summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorIan Romanick <[email protected]>2013-03-15 15:14:18 -0700
committerIan Romanick <[email protected]>2013-04-08 15:17:05 -0700
commita131b87706a6e59be35997d24b2236130aa09689 (patch)
treee8f95a8e8d28ec9863a798f8d7a50ee5b08274ac
parenta70d2f05dc972bbc4a685e65a6ffa8a092b68b4c (diff)
glsl: Don't emit spurious errors for constant indexes of the wrong type
Previously the shader uniform float x[6]; void main() { gl_Position.x = x[1.0]; } would have generated the errors 0:2(33): error: array index must be integer type 0:2(36): error: array index must be < 6 Now only 0:2(33): error: array index must be integer type will be generated. Signed-off-by: Ian Romanick <[email protected]> Reviewed-by: Kenneth Graunke <[email protected]>
-rw-r--r--src/glsl/ast_array_index.cpp4
1 files changed, 2 insertions, 2 deletions
diff --git a/src/glsl/ast_array_index.cpp b/src/glsl/ast_array_index.cpp
index 486ff551d54..c7ebcbdc6b7 100644
--- a/src/glsl/ast_array_index.cpp
+++ b/src/glsl/ast_array_index.cpp
@@ -58,7 +58,7 @@ _mesa_ast_array_index_to_hir(void *mem_ctx,
* declared size.
*/
ir_constant *const const_index = idx->constant_expression_value();
- if (const_index != NULL) {
+ if (const_index != NULL && idx->type->is_integer()) {
const int idx = const_index->value.i[0];
const char *type_name = "error";
unsigned bound = 0;
@@ -118,7 +118,7 @@ _mesa_ast_array_index_to_hir(void *mem_ctx,
check_builtin_array_max_size(v->name, idx+1, loc, state);
}
}
- } else if (array->type->is_array()) {
+ } else if (const_index == NULL && 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()) {