]> git.tdb.fi Git - libs/gl.git/blobdiff - source/backends/opengl/pipelinestate_backend.cpp
Reorder members of Renderer and PipelineState
[libs/gl.git] / source / backends / opengl / pipelinestate_backend.cpp
index 58e12e7ff2126040eed1b2d62580b8c0bf68cbc4..91789701705d31441a55864f80a4e337d84cfdae 100644 (file)
@@ -106,37 +106,28 @@ void OpenGLPipelineState::apply(unsigned mask) const
                }
        }
 
-       if(mask&PipelineState::VERTEX_SETUP)
+       if(mask&PipelineState::UNIFORMS)
        {
-               const VertexSetup *vertex_setup = self->vertex_setup;
-               glBindVertexArray(vertex_setup ? vertex_setup->id : 0);
-               if(vertex_setup)
-               {
-                       static Require _req(MSP_primitive_restart);
-
-                       vertex_setup->refresh();
-                       unsigned ri = (vertex_setup->get_index_type()==UNSIGNED_INT ? 0xFFFFFFFF : 0xFFFF);
-                       if(ri!=restart_index)
+               for(const PipelineState::BoundUniformBlock &u: self->uniform_blocks)
+                       if(u.changed || mask==~0U)
                        {
-                               if(!restart_index)
-                                       glEnable(GL_PRIMITIVE_RESTART);
-                               glPrimitiveRestartIndex(ri);
-                               restart_index = ri;
-                       }
-               }
-       }
-
-       if(mask&PipelineState::FACE_CULL)
-       {
-               glFrontFace(self->front_face==CLOCKWISE ? GL_CW : GL_CCW);
+                               if(u.block)
+                               {
+                                       if(u.binding>=0)
+                                       {
+                                               glBindBufferRange(GL_UNIFORM_BUFFER, u.binding, u.block->get_buffer()->id, u.block->get_offset(), u.block->get_data_size());
+                                               bound_uniform_blocks[u.binding] = 1;
+                                       }
+                                       else if(self->shprog)
+                                       {
+                                               const char *data = static_cast<const char *>(u.block->get_data_pointer());
+                                               for(const Program::UniformCall &call: self->shprog->uniform_calls)
+                                                       call.func(call.location, call.size, data+call.location*16);
+                                       }
+                               }
 
-               if(self->face_cull!=NO_CULL && self->front_face!=NON_MANIFOLD)
-               {
-                       glEnable(GL_CULL_FACE);
-                       glCullFace(self->face_cull==CULL_FRONT ? GL_FRONT : GL_BACK);
-               }
-               else
-                       glDisable(GL_CULL_FACE);
+                               u.changed = false;
+                       }
        }
 
        if(mask&PipelineState::TEXTURES)
@@ -166,28 +157,37 @@ void OpenGLPipelineState::apply(unsigned mask) const
                        }
        }
 
-       if(mask&PipelineState::UNIFORMS)
+       if(mask&PipelineState::VERTEX_SETUP)
        {
-               for(const PipelineState::BoundUniformBlock &u: self->uniform_blocks)
-                       if(u.changed || mask==~0U)
-                       {
-                               if(u.block)
-                               {
-                                       if(u.binding>=0)
-                                       {
-                                               glBindBufferRange(GL_UNIFORM_BUFFER, u.binding, u.block->get_buffer()->id, u.block->get_offset(), u.block->get_data_size());
-                                               bound_uniform_blocks[u.binding] = 1;
-                                       }
-                                       else if(self->shprog)
-                                       {
-                                               const char *data = static_cast<const char *>(u.block->get_data_pointer());
-                                               for(const Program::UniformCall &call: self->shprog->uniform_calls)
-                                                       call.func(call.location, call.size, data+call.location*16);
-                                       }
-                               }
+               const VertexSetup *vertex_setup = self->vertex_setup;
+               glBindVertexArray(vertex_setup ? vertex_setup->id : 0);
+               if(vertex_setup)
+               {
+                       static Require _req(MSP_primitive_restart);
 
-                               u.changed = false;
+                       vertex_setup->refresh();
+                       unsigned ri = (vertex_setup->get_index_type()==UNSIGNED_INT ? 0xFFFFFFFF : 0xFFFF);
+                       if(ri!=restart_index)
+                       {
+                               if(!restart_index)
+                                       glEnable(GL_PRIMITIVE_RESTART);
+                               glPrimitiveRestartIndex(ri);
+                               restart_index = ri;
                        }
+               }
+       }
+
+       if(mask&PipelineState::FACE_CULL)
+       {
+               glFrontFace(self->front_face==CLOCKWISE ? GL_CW : GL_CCW);
+
+               if(self->face_cull!=NO_CULL && self->front_face!=NON_MANIFOLD)
+               {
+                       glEnable(GL_CULL_FACE);
+                       glCullFace(self->face_cull==CULL_FRONT ? GL_FRONT : GL_BACK);
+               }
+               else
+                       glDisable(GL_CULL_FACE);
        }
 
        if(mask&PipelineState::DEPTH_TEST)