]> git.tdb.fi Git - libs/gl.git/commitdiff
Ensure that DepthTest and Blend get unbound for PostProcessors
authorMikko Rasa <tdb@tdb.fi>
Sat, 26 Nov 2016 05:29:20 +0000 (07:29 +0200)
committerMikko Rasa <tdb@tdb.fi>
Sat, 26 Nov 2016 05:29:20 +0000 (07:29 +0200)
source/ambientocclusion.cpp
source/bloom.cpp
source/pipeline.cpp

index bad204a98d848ba5a55dc3048a143314c1623c40..5aba53dde9231b02decd1bf302d04f0ada796cac 100644 (file)
@@ -72,8 +72,6 @@ void AmbientOcclusion::render(const Texture2D &color, const Texture2D &depth)
        combine_texturing.attach(0, depth);
        combine_texturing.attach(1, color);
 
-       BindRestore unbind_dtest(static_cast<DepthTest *>(0));
-       BindRestore unbind_blend(static_cast<Blend *>(0));
        Bind bind_mesh(quad);
 
        {
index 58edc65dfd2bed54a99cc65b0a36f879b522dee3..2160e147cb1b8877f1a657f7f15651362ebf26fa 100644 (file)
@@ -67,8 +67,6 @@ void Bloom::set_strength(float s)
 
 void Bloom::render(const Texture2D &src, const Texture2D &)
 {
-       BindRestore unbind_dtest(static_cast<DepthTest *>(0));
-       BindRestore unbind_blend(static_cast<Blend *>(0));
        Bind bind_mesh(quad);
 
        {
index e3da053070b0cb0dcadc84e62f6b91cf4befab5a..92d80a97c3c11ef7406bd2701816407a3ea7d552 100644 (file)
@@ -176,8 +176,10 @@ void Pipeline::render(Renderer &renderer, const Tag &tag) const
                setup_frame();
 
        const Framebuffer *out_fbo = Framebuffer::current();
-       // This is a no-op but will ensure the FBO binding gets restored
+       // These is a no-ops but will ensure the related state gets restored
        BindRestore restore_fbo(out_fbo);
+       BindRestore restore_depth_test(DepthTest::current());
+       BindRestore restore_blend(Blend::current());
 
        if(target[0])
        {
@@ -186,10 +188,19 @@ void Pipeline::render(Renderer &renderer, const Tag &tag) const
                fbo.clear(COLOR_BUFFER_BIT|DEPTH_BUFFER_BIT);
        }
 
+
        for(PassList::const_iterator i=passes.begin(); i!=passes.end(); ++i)
        {
-               Bind bind_depth_test(i->get_depth_test());
-               Bind bind_blend(i->get_blend());
+               if(const DepthTest *dt = i->get_depth_test())
+                       dt->bind();
+               else
+                       DepthTest::unbind();
+
+               if(const Blend *b = i->get_blend())
+                       b->bind();
+               else
+                       Blend::unbind();
+
                renderer.set_lighting(i->get_lighting());
                renderer.set_clipping(i->get_clipping());
 
@@ -205,6 +216,9 @@ void Pipeline::render(Renderer &renderer, const Tag &tag) const
 
        if(target[0])
        {
+               BindRestore unbind_depth_test(static_cast<DepthTest *>(0));
+               BindRestore unbind_blend(static_cast<Blend *>(0));
+
                if(samples)
                        target[0]->fbo.blit_from(target_ms->fbo, COLOR_BUFFER_BIT|DEPTH_BUFFER_BIT, false);