[Mesa-dev] [PATCH 07/13] mesa: Fix glGetActiveAttribute for gl_VertexID when lowered.

Kenneth Graunke kenneth at whitecape.org
Fri Aug 8 00:31:11 PDT 2014


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.

Signed-off-by: Kenneth Graunke <kenneth at whitecape.org>
---
 src/mesa/main/shader_query.cpp | 13 ++++++++++++-
 1 file changed, 12 insertions(+), 1 deletion(-)

Avoids regressing Piglit's gl-get-active-attrib-returns-all-inputs when
enabling lowering later in the series.

diff --git a/src/mesa/main/shader_query.cpp b/src/mesa/main/shader_query.cpp
index 4871d09..c395a78 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:
@@ -128,12 +129,22 @@ _mesa_GetActiveAttrib(GLhandleARB program, GLuint desired_index,
 
    foreach_in_list(ir_instruction, node, ir) {
       const ir_variable *const var = node->as_variable();
+      const char *var_name = var->name;
 
       if (!is_active_attrib(var))
          continue;
 
       if (current_index == desired_index) {
-	 _mesa_copy_string(name, maxLength, length, 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;
-- 
2.0.2



More information about the mesa-dev mailing list