]> git.tdb.fi Git - libs/gl.git/commitdiff
Build sequence without target format if there's no postprocessors
authorMikko Rasa <tdb@tdb.fi>
Sat, 13 Nov 2021 14:59:22 +0000 (16:59 +0200)
committerMikko Rasa <tdb@tdb.fi>
Sun, 14 Nov 2021 09:47:47 +0000 (11:47 +0200)
source/builders/sequencebuilder.cpp
source/builders/sequencebuilder.h

index c80e2f09a07ad4c69164fdf63686017f692f2211..01208cf4cc32a6c5a4c5245a57d74b32c0740cda 100644 (file)
@@ -146,27 +146,30 @@ Sequence *SequenceBuilder::build() const
 
 Sequence *SequenceBuilder::build(unsigned w, unsigned h) const
 {
-       RefPtr<Sequence> sequence = new Sequence(w, h, create_frame_format());
+       RefPtr<Sequence> sequence = create_sequence(w, h);
        build(*sequence);
        return sequence.release();
 }
 
 Sequence *SequenceBuilder::build(const View &view) const
 {
-       RefPtr<Sequence> sequence = new Sequence(view.get_width(), view.get_height(), create_frame_format());
+       RefPtr<Sequence> sequence = create_sequence(view.get_width(), view.get_height());
        build(*sequence);
        return sequence.release();
 }
 
 Sequence *SequenceBuilder::build(const Framebuffer &fbo) const
 {
-       RefPtr<Sequence> sequence = new Sequence(fbo.get_width(), fbo.get_height(), create_frame_format());
+       RefPtr<Sequence> sequence = create_sequence(fbo.get_width(), fbo.get_height());
        build(*sequence);
        return sequence.release();
 }
 
-FrameFormat SequenceBuilder::create_frame_format() const
+Sequence * SequenceBuilder::create_sequence(unsigned w, unsigned h) const
 {
+       if(!w || !h || tmpl.get_postprocessors().empty())
+               return new Sequence;
+
        unsigned samples = min(tmpl.get_maximum_multisample(), Device::get_current().get_info().limits.max_samples);
        if(samples<tmpl.get_required_multisample())
                throw invalid_operation("SequenceBuilder::create_frame_format");
@@ -174,7 +177,8 @@ FrameFormat SequenceBuilder::create_frame_format() const
        DataType color_type = (tmpl.get_hdr() ? HALF_FLOAT : UNSIGNED_BYTE);
        PixelFormat color_pf = make_pixelformat(RGBA, color_type);
 
-       return (COLOR_ATTACHMENT,color_pf, DEPTH_ATTACHMENT).set_samples(samples);
+       FrameFormat format = (COLOR_ATTACHMENT,color_pf, DEPTH_ATTACHMENT).set_samples(samples);
+       return new Sequence(w, h, format);
 }
 
 } // namespace GL
index 4cc93037dba95a322b1e04b9b77003f61bdb1d3f..931641fee8a7f6338de6b02289199194556f9544 100644 (file)
@@ -36,8 +36,7 @@ public:
        Sequence *build(unsigned, unsigned) const;
        Sequence *build(const View &) const;
        Sequence *build(const Framebuffer &) const;
-
-       FrameFormat create_frame_format() const;
+       Sequence *create_sequence(unsigned, unsigned) const;
 };
 
 } // namespace GL