]> git.tdb.fi Git - libs/gl.git/blobdiff - source/render/renderer.cpp
Cache texture bindings when the shader program does not change
[libs/gl.git] / source / render / renderer.cpp
index 8a2833b8b55b5551a5ae992d7cd8a22ef0108299..b935ce14c3e88bf94636135cc5ae0fe084574cbf 100644 (file)
@@ -303,11 +303,13 @@ void Renderer::apply_state()
                flush_textures();
 
        for(const BoundTexture &t: texture_stack)
-       {
-               int unit = (t.tag.id ? state->shprog->get_uniform_binding(t.tag) : t.unit);
-               if(unit>=0)
-                       pipeline_state.set_texture(unit, t.texture, t.sampler);
-       }
+               if(t.texture && t.replaced<0)
+               {
+                       if(t.binding<0 || shprog_changed)
+                               t.binding = state->shprog->get_uniform_binding(t.tag);
+                       if(t.binding>=0)
+                               pipeline_state.set_texture(t.binding, t.texture, t.sampler);
+               }
 
        bool shdata_changed = changed&SHADER_DATA;
        for(auto i=shdata_stack.begin(); (!shdata_changed && i!=shdata_stack.end()); ++i)