Add a function to flush shader data in Renderer master
authorMikko Rasa <tdb@tdb.fi>
Sun, 28 Jul 2019 00:03:58 +0000 (03:03 +0300)
committerMikko Rasa <tdb@tdb.fi>
Sun, 28 Jul 2019 00:03:58 +0000 (03:03 +0300)
Necessary if the same shader data object is used in successive draw
commands but the contained uniform values are changed.

source/renderer.cpp
source/renderer.h

index 90ac455107ffc078a6db1dbe8e452ea06ed44f7a..c5fe3c64a8baca0d39b7966d43edc61c3efa9be4 100644 (file)
@@ -134,14 +134,19 @@ void Renderer::add_shader_data(const ProgramData &d)
                ++state->shdata_count;
        else
        {
-               if(shdata_stack.size()>state->shdata_count)
-                       shdata_stack.erase(shdata_stack.begin()+state->shdata_count, shdata_stack.end());
+               flush_shader_data();
                shdata_stack.push_back(&d);
                state->shdata_count = shdata_stack.size();
                changed |= SHADER_DATA;
        }
 }
 
+void Renderer::flush_shader_data()
+{
+       if(shdata_stack.size()>state->shdata_count)
+               shdata_stack.erase(shdata_stack.begin()+state->shdata_count, shdata_stack.end());
+}
+
 void Renderer::set_mesh(const Mesh *m)
 {
        state->mesh = m;
index 973e1b00263330101aca291ccef3c38a75e5e82c..f997171c4403e9dfb8759833c1aea5b1ae80995c 100644 (file)
@@ -151,6 +151,8 @@ public:
        Renderer state is popped. */
        void add_shader_data(const ProgramData &data);
 
+       void flush_shader_data();
+
        void set_mesh(const Mesh *);
        void set_vertex_setup(const VertexSetup *);
        void set_winding_test(const WindingTest *);