Mesa (master): mesa: Fix glGetActiveAttribute for gl_VertexID when lowered.

Kenneth Graunke kwg at kemper.freedesktop.org
Wed Sep 10 18:32:26 UTC 2014


Module: Mesa
Branch: master
Commit: 26e949b26effe741f9792e3efcba31c7209f3465
URL:    http://cgit.freedesktop.org/mesa/mesa/commit/?id=26e949b26effe741f9792e3efcba31c7209f3465

Author: Kenneth Graunke <kenneth at whitecape.org>
Date:   Thu Aug  7 22:42:55 2014 -0700

mesa: Fix glGetActiveAttribute for gl_VertexID when lowered.

The lower_vertex_id pass converts uses of the gl_VertexID system value
to the gl_BaseVertex and gl_VertexIDMESA system values.  Since
gl_VertexID is no longer accessed, it would not be considered active.

Of course, it should be, since the shader uses gl_VertexID.

v2: Move the var->name dereference past the var != NULL check.

Signed-off-by: Kenneth Graunke <kenneth at whitecape.org>
Reviewed-by: Ian Romanick <ian.d.romanick at intel.com>

---

 src/mesa/main/shader_query.cpp |   14 +++++++++++++-
 1 file changed, 13 insertions(+), 1 deletion(-)

diff --git a/src/mesa/main/shader_query.cpp b/src/mesa/main/shader_query.cpp
index 4871d09..766ad29 100644
--- a/src/mesa/main/shader_query.cpp
+++ b/src/mesa/main/shader_query.cpp
@@ -93,6 +93,7 @@ is_active_attrib(const ir_variable *var)
        * and gl_InstanceID."
        */
       return var->data.location == SYSTEM_VALUE_VERTEX_ID ||
+             var->data.location == SYSTEM_VALUE_VERTEX_ID_ZERO_BASE ||
              var->data.location == SYSTEM_VALUE_INSTANCE_ID;
 
    default:
@@ -133,7 +134,18 @@ _mesa_GetActiveAttrib(GLhandleARB program, GLuint desired_index,
          continue;
 
       if (current_index == desired_index) {
-	 _mesa_copy_string(name, maxLength, length, var->name);
+         const char *var_name = var->name;
+
+         /* Since gl_VertexID may be lowered to gl_VertexIDMESA, we need to
+          * consider gl_VertexIDMESA as gl_VertexID for purposes of checking
+          * active attributes.
+          */
+         if (var->data.mode == ir_var_system_value &&
+             var->data.location == SYSTEM_VALUE_VERTEX_ID_ZERO_BASE) {
+            var_name = "gl_VertexID";
+         }
+
+	 _mesa_copy_string(name, maxLength, length, var_name);
 
 	 if (size)
 	    *size = (var->type->is_array()) ? var->type->length : 1;




More information about the mesa-commit mailing list