[Mesa-dev] [PATCH 2/2] mesa: fix GetProgramiv/GetActiveAttrib regression

Tapani Pälli tapani.palli at intel.com
Mon Oct 5 00:14:47 PDT 2015


Commit 4639cea2921669527eb43dcb49724c05afb27e8e added packed varyings
as part of program resource list. We need to take this to account with
all functions dealing with active input attributes.

Patch fixes the issue by adding additional check to is_active_attrib
and iterating only active attribs (not any inputs) explicitly in
GetActiveAttrib function.

I've tested that fix works for Assault Android Cactus (demo version)
and does not cause Piglit or CTS regressions in glGetProgramiv tests.

v2: simplify and optimize with help of is_packed_varying bit

Signed-off-by: Tapani Pälli <tapani.palli at intel.com>
Bugzilla: https://bugs.freedesktop.org/show_bug.cgi?id=92122
---
 src/mesa/main/shader_query.cpp | 20 ++++++++++++++------
 1 file changed, 14 insertions(+), 6 deletions(-)

diff --git a/src/mesa/main/shader_query.cpp b/src/mesa/main/shader_query.cpp
index 7189676..6d54e61 100644
--- a/src/mesa/main/shader_query.cpp
+++ b/src/mesa/main/shader_query.cpp
@@ -108,7 +108,8 @@ is_active_attrib(const ir_variable *var)
 
    switch (var->data.mode) {
    case ir_var_shader_in:
-      return var->data.location != -1;
+      return var->data.location != -1 &&
+             !var->data.is_packed_varying;
 
    case ir_var_system_value:
       /* From GL 4.3 core spec, section 11.1.1 (Vertex Attributes):
@@ -153,12 +154,18 @@ _mesa_GetActiveAttrib(GLhandleARB program, GLuint desired_index,
       return;
    }
 
-   struct gl_program_resource *res =
-      _mesa_program_resource_find_index(shProg, GL_PROGRAM_INPUT,
-                                        desired_index);
+   struct gl_program_resource *res = shProg->ProgramResourceList;
+   unsigned index = -1;
+   for (unsigned i = 0; i < shProg->NumProgramResourceList; i++, res++) {
+      if (res->Type != GL_PROGRAM_INPUT ||
+          !is_active_attrib(RESOURCE_VAR(res)))
+         continue;
+      if (++index == desired_index)
+         break;
+   }
 
    /* User asked for index that does not exist. */
-   if (!res) {
+   if (!res || index != desired_index) {
       _mesa_error(ctx, GL_INVALID_VALUE, "glGetActiveAttrib(index)");
       return;
    }
@@ -270,7 +277,8 @@ _mesa_longest_attribute_name_length(struct gl_shader_program *shProg)
    size_t longest = 0;
    for (unsigned j = 0; j < shProg->NumProgramResourceList; j++, res++) {
       if (res->Type == GL_PROGRAM_INPUT &&
-          res->StageReferences & (1 << MESA_SHADER_VERTEX)) {
+          res->StageReferences & (1 << MESA_SHADER_VERTEX) &&
+          is_active_attrib(RESOURCE_VAR(res))) {
 
           const size_t length = strlen(RESOURCE_VAR(res)->name);
           if (length >= longest)
-- 
2.4.3



More information about the mesa-dev mailing list