Mesa (master): glsl: Don't allow invalid identifier names in struct/ interface fields.
Paul Berry
stereotype441 at kemper.freedesktop.org
Thu Oct 10 21:46:57 UTC 2013
Module: Mesa
Branch: master
Commit: 9b5b0320b65631aa53bb591681bdb730c90c99da
URL: http://cgit.freedesktop.org/mesa/mesa/commit/?id=9b5b0320b65631aa53bb591681bdb730c90c99da
Author: Paul Berry <stereotype441 at gmail.com>
Date: Fri Sep 27 14:52:08 2013 -0700
glsl: Don't allow invalid identifier names in struct/interface fields.
Note: we need to make an exception for the gl_PerVertex interface
block, since built-in variables are allowed to be redeclared inside
it. Future patches will make redeclaration of gl_PerVertex work
properly.
Fixes piglit tests:
- spec/glsl-1.50/compiler/interface-block-array-elem-uses-gl-prefix.vert
- spec/glsl-1.50/compiler/named-interface-block-elem-uses-gl-prefix.vert
- spec/glsl-1.50/compiler/unnamed-interface-block-elem-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 | 12 +++++++++---
1 files changed, 9 insertions(+), 3 deletions(-)
diff --git a/src/glsl/ast_to_hir.cpp b/src/glsl/ast_to_hir.cpp
index ab5a78d..1d7539d 100644
--- a/src/glsl/ast_to_hir.cpp
+++ b/src/glsl/ast_to_hir.cpp
@@ -4410,7 +4410,8 @@ ast_process_structure_or_interface_block(exec_list *instructions,
YYLTYPE &loc,
glsl_struct_field **fields_ret,
bool is_interface,
- bool block_row_major)
+ bool block_row_major,
+ bool allow_reserved_names)
{
unsigned decl_count = 0;
@@ -4452,6 +4453,9 @@ ast_process_structure_or_interface_block(exec_list *instructions,
foreach_list_typed (ast_declaration, decl, link,
&decl_list->declarations) {
+ if (!allow_reserved_names)
+ validate_identifier(decl->identifier, loc, state);
+
/* From the GL_ARB_uniform_buffer_object spec:
*
* "Sampler types are not allowed inside of uniform
@@ -4568,7 +4572,8 @@ ast_struct_specifier::hir(exec_list *instructions,
loc,
&fields,
false,
- false);
+ false,
+ false /* allow_reserved_names */);
const glsl_type *t =
glsl_type::get_record_instance(fields, decl_count, this->name);
@@ -4625,7 +4630,8 @@ ast_interface_block::hir(exec_list *instructions,
loc,
&fields,
true,
- block_row_major);
+ block_row_major,
+ redeclaring_per_vertex);
ir_variable_mode var_mode;
const char *iface_type_name;
More information about the mesa-commit
mailing list