]> git.tdb.fi Git - libs/gl.git/commitdiff
Use persistent tags for the model matrix uniforms in Renderer
authorMikko Rasa <tdb@tdb.fi>
Sun, 13 Mar 2022 08:00:56 +0000 (10:00 +0200)
committerMikko Rasa <tdb@tdb.fi>
Sun, 13 Mar 2022 08:00:56 +0000 (10:00 +0200)
Re-hashing the names every time takes enough time to show up in a
profile.

source/render/renderer.cpp
source/render/renderer.h

index fceee6e8c631f71cacfb3a3ce908ad65cce8afc1..2b1503ce23c847b025b75325e2b7e2cb13960a53 100644 (file)
@@ -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<Texture>("_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<float, 3> 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;
        }
index 31ad65ea1a373bf8c6c5478d4bf878d571ffce4f..99c8c5002b242da1d18c694d77996ff8ded0607c 100644 (file)
@@ -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();