Mesa (master): glsl: Don' t allow unnamed interface blocks to redeclare variables.

Paul Berry stereotype441 at kemper.freedesktop.org
Thu Oct 10 21:46:57 UTC 2013


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

Author: Paul Berry <stereotype441 at gmail.com>
Date:   Fri Sep 27 14:18:09 2013 -0700

glsl: Don't allow unnamed interface blocks to redeclare variables.

Note: some limited amount of redeclaration is actually allowed,
provided the shader is redeclaring the built-in gl_PerVertex interface
block.  Support for this will be added in future patches.

Fixes piglit tests
spec/glsl-1.50/compiler/unnamed-interface-block-elem-conflicts-with-prev-{block-elem,global}.vert.

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

---

 src/glsl/ast_to_hir.cpp |    3 +++
 1 files changed, 3 insertions(+), 0 deletions(-)

diff --git a/src/glsl/ast_to_hir.cpp b/src/glsl/ast_to_hir.cpp
index 90401ad..c06a2a9 100644
--- a/src/glsl/ast_to_hir.cpp
+++ b/src/glsl/ast_to_hir.cpp
@@ -4742,6 +4742,9 @@ ast_interface_block::hir(exec_list *instructions,
                                    var_mode);
          var->init_interface_type(block_type);
 
+         if (state->symbols->get_variable(var->name) != NULL)
+            _mesa_glsl_error(&loc, state, "`%s' redeclared", var->name);
+
          /* Propagate the "binding" keyword into this UBO's fields;
           * the UBO declaration itself doesn't get an ir_variable unless it
           * has an instance name.  This is ugly.




More information about the mesa-commit mailing list