diff options
author | Chris Forbes <[email protected]> | 2014-04-27 16:03:54 +1200 |
---|---|---|
committer | Chris Forbes <[email protected]> | 2014-06-04 18:56:05 +1200 |
commit | 5ecffe5a3a41cac5fe28d8136095a0c2acf385a8 (patch) | |
tree | 0c63558b0000aae323abfbaff2b693bd1e3e228d /src/glsl/ast_to_hir.cpp | |
parent | 4b756b20c446bbaf0911d1b66c5a405ab3b133ef (diff) |
glsl: Add support for `precise` redeclarations
This works like glsl-1.20+'s invariant redeclarations, but with fewer
restrictions, since `precise` is allowed on pretty much anything.
Signed-off-by: Chris Forbes <[email protected]>
Reviewed-by: Jordan Justen <[email protected]>
Diffstat (limited to 'src/glsl/ast_to_hir.cpp')
-rw-r--r-- | src/glsl/ast_to_hir.cpp | 27 |
1 files changed, 27 insertions, 0 deletions
diff --git a/src/glsl/ast_to_hir.cpp b/src/glsl/ast_to_hir.cpp index 0b28b4814c4..a57ce5058e1 100644 --- a/src/glsl/ast_to_hir.cpp +++ b/src/glsl/ast_to_hir.cpp @@ -3174,6 +3174,33 @@ ast_declarator_list::hir(exec_list *instructions, return NULL; } + if (this->precise) { + assert(this->type == NULL); + + foreach_list_typed (ast_declaration, decl, link, &this->declarations) { + assert(decl->array_specifier == NULL); + assert(decl->initializer == NULL); + + ir_variable *const earlier = + state->symbols->get_variable(decl->identifier); + if (earlier == NULL) { + _mesa_glsl_error(& loc, state, + "undeclared variable `%s' cannot be marked " + "precise", decl->identifier); + } else if (earlier->data.used) { + _mesa_glsl_error(& loc, state, + "variable `%s' may not be redeclared " + "`precise' after being used", + earlier->name); + } else { + earlier->data.precise = true; + } + } + + /* Precise redeclarations do not have r-values either. */ + return NULL; + } + assert(this->type != NULL); assert(!this->invariant); assert(!this->precise); |