diff options
author | Paul Berry <stereotype441@gmail.com> | 2011-08-01 15:23:07 -0700 |
---|---|---|
committer | Marek Olšák <maraeo@gmail.com> | 2011-10-02 19:17:42 +0200 |
commit | 27f00df2b74778d30e9ba897ac1a26dd376b3751 (patch) | |
tree | 864972453bf55889e5ca3edf2d0720a966d9d2b2 | |
parent | 8dcfe15a9ab9c9f2c889c3bd103f6d6491d4c4ec (diff) |
glsl: Check array size is const before asserting that no IR was generated.
process_array_type() contains an assertion to verify that no IR
instructions are generated while processing the expression that
specifies the size of the array. This assertion needs to happen
_after_ checking whether the expression is constant. Otherwise we may
crash on an illegal shader rather than reporting an error.
Fixes piglit tests array-size-non-builtin-function.vert and
array-size-with-side-effect.vert.
Reviewed-by: Kenneth Graunke <kenneth@whitecape.org>
(cherry picked from commit d4144a123b603d3c33cb356cf3c8e5ae4653594e)
-rw-r--r-- | src/glsl/ast_to_hir.cpp | 13 |
1 files changed, 8 insertions, 5 deletions
diff --git a/src/glsl/ast_to_hir.cpp b/src/glsl/ast_to_hir.cpp index 4c9e15a0d8b..d773226dd95 100644 --- a/src/glsl/ast_to_hir.cpp +++ b/src/glsl/ast_to_hir.cpp @@ -1761,11 +1761,6 @@ process_array_type(YYLTYPE *loc, const glsl_type *base, ast_node *array_size, ir_rvalue *const ir = array_size->hir(& dummy_instructions, state); YYLTYPE loc = array_size->get_location(); - /* FINISHME: Verify that the grammar forbids side-effects in array - * FINISHME: sizes. i.e., 'vec4 [x = 12] data' - */ - assert(dummy_instructions.is_empty()); - if (ir != NULL) { if (!ir->type->is_integer()) { _mesa_glsl_error(& loc, state, "array size must be integer type"); @@ -1782,6 +1777,14 @@ process_array_type(YYLTYPE *loc, const glsl_type *base, ast_node *array_size, } else { assert(size->type == ir->type); length = size->value.u[0]; + + /* If the array size is const (and we've verified that + * it is) then no instructions should have been emitted + * when we converted it to HIR. If they were emitted, + * then either the array size isn't const after all, or + * we are emitting unnecessary instructions. + */ + assert(dummy_instructions.is_empty()); } } } |