A certain game engine links its shaders, calls BindAttribLocation to set
the same values a second time, then re-links them all.

If the binding doesn't actually change, there's no need to re-link,
so we can avoid flagging that.

Signed-off-by: Kenneth Graunke <[email protected]>
---
 src/mesa/main/shader_query.cpp | 15 +++++++++------
 1 file changed, 9 insertions(+), 6 deletions(-)

This also adds additional overhead, which could probably be lessened by
altering the string_to_uint_map interface to make a "put and tell me if
the value changed" method.

diff --git a/src/mesa/main/shader_query.cpp b/src/mesa/main/shader_query.cpp
index db3be0c..e6e8135 100644
--- a/src/mesa/main/shader_query.cpp
+++ b/src/mesa/main/shader_query.cpp
@@ -68,13 +68,16 @@ _mesa_BindAttribLocation(GLhandleARB program, GLuint index,
     * VERT_ATTRIB_GENERIC0 because that's how the linker differentiates
     * between built-in attributes and user-defined attributes.
     */
-   shProg->AttributeBindings->put(index + VERT_ATTRIB_GENERIC0, name);
+   unsigned new_value = index + VERT_ATTRIB_GENERIC0;
+   unsigned old;
+   if (!shProg->AttributeBindings->get(old, name) || old != new_value) {
+      shProg->AttributeBindings->put(index + VERT_ATTRIB_GENERIC0, name);
 
-   /*
-    * Note that this attribute binding won't go into effect until
-    * glLinkProgram is called again.
-    */
-   shProg->NeedsRelink = true;
+      /* Note that this attribute binding won't go into effect until
+       * glLinkProgram is called again.
+       */
+      shProg->NeedsRelink = true;
+   }
 }
 
 static bool
-- 
1.9.2

_______________________________________________
mesa-dev mailing list
[email protected]
http://lists.freedesktop.org/mailman/listinfo/mesa-dev

Reply via email to