From: Ian Romanick <ian.d.roman...@intel.com>

glGetUniformIndices requires that the block instance index not be
present in the name of queried uniforms.  However,
gl_uniform_buffer_variable::Name will include the instance index.  The
IndexName field is added to handle this difference.

Note that currently IndexName will always point to the same string as
Name.  This will change soon.

Signed-off-by: Ian Romanick <ian.d.roman...@intel.com>
---
 src/glsl/ast_to_hir.cpp    |  1 +
 src/glsl/link_uniforms.cpp |  8 +++++++-
 src/mesa/main/mtypes.h     | 13 +++++++++++++
 src/mesa/main/uniforms.c   |  2 +-
 4 files changed, 22 insertions(+), 2 deletions(-)

diff --git a/src/glsl/ast_to_hir.cpp b/src/glsl/ast_to_hir.cpp
index c922a84..3aa9c15 100644
--- a/src/glsl/ast_to_hir.cpp
+++ b/src/glsl/ast_to_hir.cpp
@@ -4303,6 +4303,7 @@ ast_uniform_block::hir(exec_list *instructions,
          &ubo->Uniforms[ubo->NumUniforms++];
 
       ubo_var->Name = ralloc_strdup(state->uniform_blocks, fields[i].name);
+      ubo_var->IndexName = ubo_var->Name;
       ubo_var->Type = fields[i].type;
       ubo_var->Offset = 0; /* Assigned at link time. */
       ubo_var->RowMajor = fields[i].row_major;
diff --git a/src/glsl/link_uniforms.cpp b/src/glsl/link_uniforms.cpp
index 439b711..c4c7dad 100644
--- a/src/glsl/link_uniforms.cpp
+++ b/src/glsl/link_uniforms.cpp
@@ -505,7 +505,13 @@ link_cross_validate_uniform_block(void *mem_ctx,
       struct gl_uniform_buffer_variable *ubo_var =
         &linked_block->Uniforms[i];
 
-      ubo_var->Name = ralloc_strdup(*linked_blocks, ubo_var->Name);
+      if (ubo_var->Name == ubo_var->IndexName) {
+         ubo_var->Name = ralloc_strdup(*linked_blocks, ubo_var->Name);
+         ubo_var->IndexName = ubo_var->Name;
+      } else {
+         ubo_var->Name = ralloc_strdup(*linked_blocks, ubo_var->Name);
+         ubo_var->IndexName = ralloc_strdup(*linked_blocks, 
ubo_var->IndexName);
+      }
    }
 
    return linked_block_index;
diff --git a/src/mesa/main/mtypes.h b/src/mesa/main/mtypes.h
index 1808717..65fe285 100644
--- a/src/mesa/main/mtypes.h
+++ b/src/mesa/main/mtypes.h
@@ -2273,6 +2273,19 @@ typedef enum
 struct gl_uniform_buffer_variable
 {
    char *Name;
+
+   /**
+    * Name of the uniform as seen by glGetUniformIndices.
+    *
+    * glGetUniformIndices requires that the block instance index \b not be
+    * present in the name of queried uniforms.
+    *
+    * \note
+    * \c gl_uniform_buffer_variable::IndexName and
+    * \c gl_uniform_buffer_variable::Name may point to identical storage.
+    */
+   char *IndexName;
+
    const struct glsl_type *Type;
    unsigned int Offset;
    GLboolean RowMajor;
diff --git a/src/mesa/main/uniforms.c b/src/mesa/main/uniforms.c
index 62c85b3..d902407 100644
--- a/src/mesa/main/uniforms.c
+++ b/src/mesa/main/uniforms.c
@@ -695,7 +695,7 @@ _mesa_GetActiveUniformBlockiv(GLuint program,
       for (i = 0; i < block->NumUniforms; i++) {
         unsigned offset;
         params[i] = _mesa_get_uniform_location(ctx, shProg,
-                                               block->Uniforms[i].Name,
+                                               block->Uniforms[i].IndexName,
                                                &offset);
       }
       return;
-- 
1.7.11.7

_______________________________________________
mesa-dev mailing list
mesa-dev@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/mesa-dev

Reply via email to