From afb95d09c066b45b7a66b644c04e2d0b2cee2723 Mon Sep 17 00:00:00 2001 From: Mikko Rasa Date: Sun, 28 Jul 2019 03:03:58 +0300 Subject: [PATCH] Add a function to flush shader data in Renderer Necessary if the same shader data object is used in successive draw commands but the contained uniform values are changed. --- source/renderer.cpp | 9 +++++++-- source/renderer.h | 2 ++ 2 files changed, 9 insertions(+), 2 deletions(-) diff --git a/source/renderer.cpp b/source/renderer.cpp index 90ac4551..c5fe3c64 100644 --- a/source/renderer.cpp +++ b/source/renderer.cpp @@ -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; diff --git a/source/renderer.h b/source/renderer.h index 973e1b00..f997171c 100644 --- a/source/renderer.h +++ b/source/renderer.h @@ -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 *); -- 2.45.2