From 9e23b44bfe1e6e85231b1c07d945cadf0c868648 Mon Sep 17 00:00:00 2001 From: marha Date: Wed, 16 Oct 2013 11:23:27 +0200 Subject: fontconfig libxcb libxcb/xcb-proto xserver mesa pixman xkbcomp git update 16 oct 2013 xserver commit 7cf1b595c8c8f9776a39559d2878cf90af3f2859 libxcb commit e4e0c6eec861f4c69da12060dc8dbe7a63fa5eb6 libxcb/xcb-proto commit 55c75accecf0e76d2aa38656efd2be4044b9e643 xkbcomp commit 839ccda42d8b088d94324cd77c4be954859914d3 pixman commit 9e81419ed5c0ee490ddacf7bada516a25cae87eb fontconfig commit 5406919c5e186f74ccdade1a65344ce7b5c56a64 mesa commit 6e444a72c1f9e4446e025b8cb780523cb89f0584 --- mesalib/src/glsl/ast_array_index.cpp | 84 ++++++++++++++++++++++++++++-------- 1 file changed, 67 insertions(+), 17 deletions(-) (limited to 'mesalib/src/glsl/ast_array_index.cpp') diff --git a/mesalib/src/glsl/ast_array_index.cpp b/mesalib/src/glsl/ast_array_index.cpp index 51f6b10f3..da96cc10e 100644 --- a/mesalib/src/glsl/ast_array_index.cpp +++ b/mesalib/src/glsl/ast_array_index.cpp @@ -25,6 +25,71 @@ #include "glsl_types.h" #include "ir.h" + +/** + * If \c ir is a reference to an array for which we are tracking the max array + * element accessed, track that the given element has been accessed. + * Otherwise do nothing. + * + * This function also checks whether the array is a built-in array whose + * maximum size is too small to accommodate the given index, and if so uses + * loc and state to report the error. + */ +static void +update_max_array_access(ir_rvalue *ir, unsigned idx, YYLTYPE *loc, + struct _mesa_glsl_parse_state *state) +{ + if (ir_dereference_variable *deref_var = ir->as_dereference_variable()) { + ir_variable *var = deref_var->var; + if (idx > var->max_array_access) { + var->max_array_access = idx; + + /* Check whether this access will, as a side effect, implicitly cause + * the size of a built-in array to be too large. + */ + check_builtin_array_max_size(var->name, idx+1, *loc, state); + } + } else if (ir_dereference_record *deref_record = + ir->as_dereference_record()) { + /* There are two possibilities we need to consider: + * + * - Accessing an element of an array that is a member of a named + * interface block (e.g. ifc.foo[i]) + * + * - Accessing an element of an array that is a member of a named + * interface block array (e.g. ifc[j].foo[i]). + */ + ir_dereference_variable *deref_var = + deref_record->record->as_dereference_variable(); + if (deref_var == NULL) { + if (ir_dereference_array *deref_array = + deref_record->record->as_dereference_array()) { + deref_var = deref_array->array->as_dereference_variable(); + } + } + + if (deref_var != NULL) { + const glsl_type *interface_type = + deref_var->var->get_interface_type(); + if (interface_type != NULL) { + unsigned field_index = + deref_record->record->type->field_index(deref_record->field); + assert(field_index < interface_type->length); + if (idx > deref_var->var->max_ifc_array_access[field_index]) { + deref_var->var->max_ifc_array_access[field_index] = idx; + + /* Check whether this access will, as a side effect, implicitly + * cause the size of a built-in array to be too large. + */ + check_builtin_array_max_size(deref_record->field, idx+1, *loc, + state); + } + } + } + } +} + + ir_rvalue * _mesa_ast_array_index_to_hir(void *mem_ctx, struct _mesa_glsl_parse_state *state, @@ -97,23 +162,8 @@ _mesa_ast_array_index_to_hir(void *mem_ctx, type_name); } - if (array->type->is_array()) { - /* If the array is a variable dereference, it dereferences the - * whole array, by definition. Use this to get the variable. - * - * FINISHME: Should some methods for getting / setting / testing - * FINISHME: array access limits be added to ir_dereference? - */ - ir_variable *const v = array->whole_variable_referenced(); - if ((v != NULL) && (unsigned(idx) > v->max_array_access)) { - v->max_array_access = idx; - - /* Check whether this access will, as a side effect, implicitly - * cause the size of a built-in array to be too large. - */ - check_builtin_array_max_size(v->name, idx+1, loc, state); - } - } + if (array->type->is_array()) + update_max_array_access(array, idx, &loc, state); } 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"); -- cgit v1.2.3