Mesa (master): glsl: don't rename variables in interface block arrays.

Paul Berry stereotype441 at kemper.freedesktop.org
Thu Jul 25 16:34:59 UTC 2013


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

Author: Paul Berry <stereotype441 at gmail.com>
Date:   Mon Jul 22 15:49:48 2013 -0700

glsl: don't rename variables in interface block arrays.

The linker matches up variables in interface blocks according to their
block name and variable name.  When support for interface block arrays
was added in commit d6863acb, we renamed variables appearing in
interface blocks so that their name included the array size.  For
example, in a block like this:

out foo {
   float bar
} baz[3];

The variable "bar" would get renamed to "bar[3]".

This is unnecessary, and leads to problems in supporting geometry
shaders, since geometry shaders require vertex shader outputs which
are non-arrays to be linked up to geometry shader inputs which are
arrays.

This patch makes the behaviour of interface block arrays the same as
simple non-array interface blocks; in both cases, the variables
contained within them are not renamed.

Reviewed-by: Matt Turner <mattst88 at gmail.com>

---

 src/glsl/lower_named_interface_blocks.cpp |    8 ++------
 1 files changed, 2 insertions(+), 6 deletions(-)

diff --git a/src/glsl/lower_named_interface_blocks.cpp b/src/glsl/lower_named_interface_blocks.cpp
index d0d491d..20196a3 100644
--- a/src/glsl/lower_named_interface_blocks.cpp
+++ b/src/glsl/lower_named_interface_blocks.cpp
@@ -129,9 +129,9 @@ flatten_named_interface_blocks_declarations::run(exec_list *instructions)
                                             iface_field_name);
          if (!found_var) {
             ir_variable *new_var;
+            char *var_name =
+               ralloc_strdup(mem_ctx, iface_t->fields.structure[i].name);
             if (array_t == NULL) {
-               char *var_name =
-                  ralloc_strdup(mem_ctx, iface_t->fields.structure[i].name);
                new_var =
                   new(mem_ctx) ir_variable(iface_t->fields.structure[i].type,
                                            var_name,
@@ -141,10 +141,6 @@ flatten_named_interface_blocks_declarations::run(exec_list *instructions)
                   glsl_type::get_array_instance(
                      iface_t->fields.structure[i].type,
                      array_t->length);
-               char *var_name =
-                  ralloc_asprintf(mem_ctx, "%s[%d]",
-                                  iface_t->fields.structure[i].name,
-                                  array_t->length);
                new_var =
                   new(mem_ctx) ir_variable(new_array_type,
                                            var_name,




More information about the mesa-commit mailing list