From: Mikko Rasa Date: Thu, 13 Jan 2022 21:17:01 +0000 (+0200) Subject: Use the changes member directly in PipelineState backends X-Git-Url: http://git.tdb.fi/?a=commitdiff_plain;h=2f2048a186c6a10f04999d8a01a3bcf63adc7c75;p=libs%2Fgl.git Use the changes member directly in PipelineState backends --- diff --git a/source/backends/opengl/pipelinestate_backend.cpp b/source/backends/opengl/pipelinestate_backend.cpp index 08edc5e7..3117a271 100644 --- a/source/backends/opengl/pipelinestate_backend.cpp +++ b/source/backends/opengl/pipelinestate_backend.cpp @@ -36,12 +36,11 @@ void OpenGLPipelineState::apply() const { const PipelineState &self = *static_cast(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) diff --git a/source/backends/vulkan/pipelinestate_backend.cpp b/source/backends/vulkan/pipelinestate_backend.cpp index efa08a86..6107fa49 100644 --- a/source/backends/vulkan/pipelinestate_backend.cpp +++ b/source/backends/vulkan/pipelinestate_backend.cpp @@ -35,17 +35,17 @@ void VulkanPipelineState::update() const { const PipelineState &self = *static_cast(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