]> git.tdb.fi Git - libs/gl.git/commitdiff
Use the changes member directly in PipelineState backends
authorMikko Rasa <tdb@tdb.fi>
Thu, 13 Jan 2022 21:17:01 +0000 (23:17 +0200)
committerMikko Rasa <tdb@tdb.fi>
Thu, 13 Jan 2022 21:17:01 +0000 (23:17 +0200)
source/backends/opengl/pipelinestate_backend.cpp
source/backends/vulkan/pipelinestate_backend.cpp

index 08edc5e71a05d4a04a9932fbac0ff2de4f5e8144..3117a271c405308b8b0a628a9f722e4dd8fcd02f 100644 (file)
@@ -36,12 +36,11 @@ void OpenGLPipelineState::apply() const
 {
        const PipelineState &self = *static_cast<const PipelineState *>(this);
        Device &device = Device::get_current();
-       unsigned mask = changes;
 
        if(applied_to && applied_to!=&device)
        {
                applied_to->get_state().last_pipeline = 0;
-               mask = ~0U;
+               changes = ~0U;
        }
 
        OpenGLDeviceState &dev_state = device.get_state();
@@ -52,10 +51,10 @@ void OpenGLPipelineState::apply() const
        {
                if(dev_state.last_pipeline)
                        dev_state.last_pipeline->applied_to = 0;
-               mask = ~0U;
+               changes = ~0U;
        }
 
-       if(mask&PipelineState::FRAMEBUFFER)
+       if(changes&PipelineState::FRAMEBUFFER)
        {
                const Framebuffer *framebuffer = self.framebuffer;
                glBindFramebuffer(GL_FRAMEBUFFER, framebuffer ? framebuffer->id : 0);
@@ -66,16 +65,16 @@ void OpenGLPipelineState::apply() const
                }
        }
 
-       if(mask&(PipelineState::VIEWPORT|PipelineState::SCISSOR|PipelineState::FRAMEBUFFER))
+       if(changes&(PipelineState::VIEWPORT|PipelineState::SCISSOR|PipelineState::FRAMEBUFFER))
                if(const Framebuffer *framebuffer = self.framebuffer)
                {
                        Rect fb_rect = framebuffer->get_rect();
-                       if(mask&(PipelineState::VIEWPORT|PipelineState::FRAMEBUFFER))
+                       if(changes&(PipelineState::VIEWPORT|PipelineState::FRAMEBUFFER))
                        {
                                Rect viewport = fb_rect.intersect(self.viewport);
                                glViewport(viewport.left, viewport.bottom, viewport.width, viewport.height);
                        }
-                       if(mask&(PipelineState::SCISSOR|PipelineState::FRAMEBUFFER))
+                       if(changes&(PipelineState::SCISSOR|PipelineState::FRAMEBUFFER))
                        {
                                Rect scissor = fb_rect.intersect(self.scissor);
                                if(scissor!=fb_rect)
@@ -88,7 +87,7 @@ void OpenGLPipelineState::apply() const
                        }
                }
 
-       if(mask&PipelineState::SHPROG)
+       if(changes&PipelineState::SHPROG)
        {
                glUseProgram(self.shprog ? self.shprog->id : 0);
 
@@ -106,10 +105,10 @@ void OpenGLPipelineState::apply() const
                }
        }
 
-       if(mask&PipelineState::UNIFORMS)
+       if(changes&PipelineState::UNIFORMS)
        {
                for(const PipelineState::BoundUniformBlock &u: self.uniform_blocks)
-                       if(u.changed || mask==~0U)
+                       if(u.changed || changes==~0U)
                        {
                                if(u.used)
                                {
@@ -130,10 +129,10 @@ void OpenGLPipelineState::apply() const
                        }
        }
 
-       if(mask&PipelineState::TEXTURES)
+       if(changes&PipelineState::TEXTURES)
        {
                for(const PipelineState::BoundTexture &t: self.textures)
-                       if(t.changed || mask==~0U)
+                       if(t.changed || changes==~0U)
                        {
                                if(t.used)
                                {
@@ -157,7 +156,7 @@ void OpenGLPipelineState::apply() const
                        }
        }
 
-       if(mask&PipelineState::VERTEX_SETUP)
+       if(changes&PipelineState::VERTEX_SETUP)
        {
                const VertexSetup *vertex_setup = self.vertex_setup;
                glBindVertexArray(vertex_setup ? vertex_setup->id : 0);
@@ -177,7 +176,7 @@ void OpenGLPipelineState::apply() const
                }
        }
 
-       if(mask&PipelineState::FACE_CULL)
+       if(changes&PipelineState::FACE_CULL)
        {
                glFrontFace(self.front_face==CLOCKWISE ? GL_CW : GL_CCW);
 
@@ -190,7 +189,7 @@ void OpenGLPipelineState::apply() const
                        glDisable(GL_CULL_FACE);
        }
 
-       if(mask&PipelineState::DEPTH_TEST)
+       if(changes&PipelineState::DEPTH_TEST)
        {
                const DepthTest &depth_test = self.depth_test;
                if(depth_test.enabled)
@@ -204,7 +203,7 @@ void OpenGLPipelineState::apply() const
                glDepthMask(depth_test.write);
        }
 
-       if(mask&PipelineState::STENCIL_TEST)
+       if(changes&PipelineState::STENCIL_TEST)
        {
                const StencilTest &stencil_test = self.stencil_test;
                if(stencil_test.enabled)
@@ -217,7 +216,7 @@ void OpenGLPipelineState::apply() const
                        glDisable(GL_STENCIL_TEST);
        }
 
-       if(mask&PipelineState::BLEND)
+       if(changes&PipelineState::BLEND)
        {
                const Blend &blend = self.blend;
                if(blend.enabled)
index efa08a8634ecf15b755b459121f629a2682da529..6107fa495e984cbc6aa2744f00d4cef81c6c5473 100644 (file)
@@ -35,17 +35,17 @@ void VulkanPipelineState::update() const
 {
        const PipelineState &self = *static_cast<const PipelineState *>(this);
 
-       if(self.changes&PipelineState::VERTEX_SETUP)
+       if(changes&PipelineState::VERTEX_SETUP)
                self.vertex_setup->refresh();
 
        constexpr unsigned pipeline_mask = PipelineState::SHPROG|PipelineState::VERTEX_SETUP|PipelineState::FACE_CULL|
                PipelineState::DEPTH_TEST|PipelineState::STENCIL_TEST|PipelineState::BLEND|PipelineState::PRIMITIVE_TYPE;
-       if(self.changes&pipeline_mask)
+       if(changes&pipeline_mask)
                handle = device.get_pipeline_cache().get_pipeline(self);
 
-       if(self.changes&(PipelineState::SHPROG|PipelineState::UNIFORMS|PipelineState::TEXTURES))
+       if(changes&(PipelineState::SHPROG|PipelineState::UNIFORMS|PipelineState::TEXTURES))
        {
-               unsigned changed_sets = (self.changes&PipelineState::SHPROG ? ~0U : 0U);
+               unsigned changed_sets = (changes&PipelineState::SHPROG ? ~0U : 0U);
                for(const PipelineState::BoundUniformBlock &u: self.uniform_blocks)
                        if(u.changed || changed_sets==~0U)
                        {
@@ -74,7 +74,7 @@ void VulkanPipelineState::update() const
                                descriptor_set_handles[i] = device.get_pipeline_cache().get_descriptor_set(self, i);
        }
 
-       self.changes = 0;
+       changes = 0;
 }
 
 uint64_t VulkanPipelineState::compute_hash() const