Mesa (master): glsl: Don' t allow invalid identifiers as interface block names.

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


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

Author: Paul Berry <stereotype441 at gmail.com>
Date:   Fri Sep 27 17:35:27 2013 -0700

glsl: Don't allow invalid identifiers as interface block names.

Note: we need to make an exception for the gl_PerVertex interface
block, since this is allowed to be redeclared.  Future patches will
make redeclaration of gl_PerVertex work properly.

Fixes piglit test
spec/glsl-1.50/compiler/interface-block-name-uses-gl-prefix.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 |    4 ++++
 1 files changed, 4 insertions(+), 0 deletions(-)

diff --git a/src/glsl/ast_to_hir.cpp b/src/glsl/ast_to_hir.cpp
index c06a2a9..ab5a78d 100644
--- a/src/glsl/ast_to_hir.cpp
+++ b/src/glsl/ast_to_hir.cpp
@@ -4614,6 +4614,7 @@ ast_interface_block::hir(exec_list *instructions,
       packing = GLSL_INTERFACE_PACKING_STD140;
    }
 
+   bool redeclaring_per_vertex = strcmp(this->block_name, "gl_PerVertex") == 0;
    bool block_row_major = this->layout.flags.q.row_major;
    exec_list declared_variables;
    glsl_struct_field *fields;
@@ -4643,6 +4644,9 @@ ast_interface_block::hir(exec_list *instructions,
       assert(!"interface block layout qualifier not found!");
    }
 
+   if (!redeclaring_per_vertex)
+      validate_identifier(this->block_name, loc, state);
+
    const glsl_type *block_type =
       glsl_type::get_interface_instance(fields,
                                         num_variables,




More information about the mesa-commit mailing list