diff options
author | Ian Romanick <ian.d.romanick@intel.com> | 2013-03-15 15:10:35 -0700 |
---|---|---|
committer | Ian Romanick <ian.d.romanick@intel.com> | 2013-04-08 15:17:05 -0700 |
commit | a70d2f05dc972bbc4a685e65a6ffa8a092b68b4c (patch) | |
tree | d4a321ae3b0aae59c8de342480a0ccd4294996a7 | |
parent | f9d8ca281750baf07ba623f86121f5a875f9bd40 (diff) | |
download | external_mesa3d-a70d2f05dc972bbc4a685e65a6ffa8a092b68b4c.zip external_mesa3d-a70d2f05dc972bbc4a685e65a6ffa8a092b68b4c.tar.gz external_mesa3d-a70d2f05dc972bbc4a685e65a6ffa8a092b68b4c.tar.bz2 |
glsl: Collect all of the non-constant index error checks together
This puts all of the checks togeher for easier reading. It also means
that all the checks are blocked on array->type->is_array. Shortly this
will allow elimination of some is_error check work-arounds in this
function.
Signed-off-by: Ian Romanick <ian.d.romanick@intel.com>
Reviewed-by: Kenneth Graunke <kenneth@whitecape.org>
-rw-r--r-- | src/glsl/ast_array_index.cpp | 87 |
1 files changed, 42 insertions, 45 deletions
diff --git a/src/glsl/ast_array_index.cpp b/src/glsl/ast_array_index.cpp index 5f3ae8e..486ff55 100644 --- a/src/glsl/ast_array_index.cpp +++ b/src/glsl/ast_array_index.cpp @@ -118,19 +118,18 @@ _mesa_ast_array_index_to_hir(void *mem_ctx, check_builtin_array_max_size(v->name, idx+1, loc, state); } } - } else if (array->type->array_size() == 0) { - _mesa_glsl_error(&loc, state, "unsized array index must be constant"); - } else if (array->type->is_array() - && array->type->fields.array->is_interface()) { - /* Page 46 in section 4.3.7 of the OpenGL ES 3.00 spec says: - * - * "All indexes used to index a uniform block array must be - * constant integral expressions." - */ - _mesa_glsl_error(&loc, state, - "uniform block array index must be constant"); - } else { - if (array->type->is_array()) { + } else if (array->type->is_array()) { + if (array->type->array_size() == 0) { + _mesa_glsl_error(&loc, state, "unsized array index must be constant"); + } else if (array->type->fields.array->is_interface()) { + /* Page 46 in section 4.3.7 of the OpenGL ES 3.00 spec says: + * + * "All indexes used to index a uniform block array must be + * constant integral expressions." + */ + _mesa_glsl_error(&loc, state, + "uniform block array index must be constant"); + } else { /* whole_variable_referenced can return NULL if the array is a * member of a structure. In this case it is safe to not update * the max_array_access field because it is never used for fields @@ -140,41 +139,39 @@ _mesa_ast_array_index_to_hir(void *mem_ctx, if (v != NULL) v->max_array_access = array->type->array_size() - 1; } - } - /* From page 23 (29 of the PDF) of the GLSL 1.30 spec: - * - * "Samplers aggregated into arrays within a shader (using square - * brackets [ ]) can only be indexed with integral constant - * expressions [...]." - * - * This restriction was added in GLSL 1.30. Shaders using earlier version - * of the language should not be rejected by the compiler front-end for - * using this construct. This allows useful things such as using a loop - * counter as the index to an array of samplers. If the loop in unrolled, - * the code should compile correctly. Instead, emit a warning. - */ - if (array->type->is_array() && - array->type->element_type()->is_sampler() && - const_index == NULL) { - - if (!state->is_version(130, 100)) { - if (state->es_shader) { - _mesa_glsl_warning(&loc, state, - "sampler arrays indexed with non-constant " - "expressions is optional in %s", - state->get_version_string()); + /* From page 23 (29 of the PDF) of the GLSL 1.30 spec: + * + * "Samplers aggregated into arrays within a shader (using square + * brackets [ ]) can only be indexed with integral constant + * expressions [...]." + * + * This restriction was added in GLSL 1.30. Shaders using earlier + * version of the language should not be rejected by the compiler + * front-end for using this construct. This allows useful things such + * as using a loop counter as the index to an array of samplers. If the + * loop in unrolled, the code should compile correctly. Instead, emit a + * warning. + */ + if (array->type->element_type()->is_sampler()) { + if (!state->is_version(130, 100)) { + if (state->es_shader) { + _mesa_glsl_warning(&loc, state, + "sampler arrays indexed with non-constant " + "expressions is optional in %s", + state->get_version_string()); + } else { + _mesa_glsl_warning(&loc, state, + "sampler arrays indexed with non-constant " + "expressions will be forbidden in GLSL 1.30 " + "and later"); + } } else { - _mesa_glsl_warning(&loc, state, - "sampler arrays indexed with non-constant " - "expressions will be forbidden in GLSL 1.30 and " - "later"); + _mesa_glsl_error(&loc, state, + "sampler arrays indexed with non-constant " + "expressions is forbidden in GLSL 1.30 and " + "later"); } - } else { - _mesa_glsl_error(&loc, state, - "sampler arrays indexed with non-constant " - "expressions is forbidden in GLSL 1.30 and " - "later"); } } |