From: Mikko Rasa Date: Sun, 13 Mar 2022 08:00:56 +0000 (+0200) Subject: Use persistent tags for the model matrix uniforms in Renderer X-Git-Url: http://git.tdb.fi/?a=commitdiff_plain;h=b84ce32a8dfcacd54c3497c6e7facb5d65e82827;p=libs%2Fgl.git Use persistent tags for the model matrix uniforms in Renderer Re-hashing the names every time takes enough time to show up in a profile. --- diff --git a/source/render/renderer.cpp b/source/render/renderer.cpp index fceee6e8..2b1503ce 100644 --- a/source/render/renderer.cpp +++ b/source/render/renderer.cpp @@ -21,6 +21,9 @@ using namespace std; namespace Msp { namespace GL { +const Tag Renderer::world_obj_matrix_tag("world_obj_matrix"); +const Tag Renderer::world_obj_normal_matrix_tag("world_obj_normal_matrix"); + Renderer::Renderer(): placeholder_texture(Resources::get_global().get("_placeholder.png")) { @@ -358,10 +361,10 @@ void Renderer::apply_state() if(changed&MATRIX) { - standard_shdata.uniform("world_obj_matrix", state.model_matrix); + standard_shdata.uniform(world_obj_matrix_tag, state.model_matrix); LinAl::SquareMatrix nm = state.model_matrix.block<3, 3>(0, 0); nm = transpose(invert(nm)); - standard_shdata.uniform("world_obj_normal_matrix", nm); + standard_shdata.uniform(world_obj_normal_matrix_tag, nm); changed &= ~MATRIX; shdata_changed = true; } diff --git a/source/render/renderer.h b/source/render/renderer.h index 31ad65ea..99c8c500 100644 --- a/source/render/renderer.h +++ b/source/render/renderer.h @@ -120,6 +120,9 @@ private: PipelineState *last_pipeline = 0; Commands commands; + static const Tag world_obj_matrix_tag; + static const Tag world_obj_normal_matrix_tag; + public: Renderer();