summaryrefslogtreecommitdiffstats
path: root/src/glsl/ast_array_index.cpp
Commit message (Collapse)AuthorAgeFilesLines
* glsl: Add check for unsized arrays to glsl typesTimothy Arceri2013-10-281-1/+1
| | | | | | | | | | | | | | | | | | | | The main purpose of this patch is to increase readability of the array code by introducing is_unsized_array() to glsl_types. Some redundent is_array() checks are also removed, and small number of other related clean ups. The introduction of is_unsized_array() should also make the ARB_arrays_of_arrays code simpler and more readable when it arrives. V2: Also replace code that checks for unsized arrays directly with the length variable Signed-off-by: Timothy Arceri <[email protected]> v3 (Paul Berry <[email protected]>): clean up formatting. Separate whitespace cleanups to their own patch. Reviewed-by: Paul Berry <[email protected]>
* glsl: Fix commentTimothy Arceri2013-10-281-1/+1
| | | | | Signed-off-by: Timothy Arceri <[email protected]> Reviewed-by: Paul Berry <[email protected]>
* glsl: In update_max_array_access, fix interface instance check.Paul Berry2013-10-171-3/+3
| | | | | | | | | | | | | | | | | | | | In commit f878d20 (glsl: Update ir_variable::max_ifc_array_access properly), I accidentally used the wrong kind of check to determine whether the variable being accessed was an interface instance (I used var->get_interface_type() != NULL when I should have used var->is_interface_instance()). As a result, if an unnamed interface block contained a struct which contained an array, update_max_array_access() would mistakenly interpret the struct as a named interface block and try to dereference a null var->max_ifc_array_access. This patch corrects the check, fixing the null dereference. Fixes piglit test interface-block-struct-nesting. Bugzilla: https://bugs.freedesktop.org/show_bug.cgi?id=70368 Reviewed-by: Matt Turner <[email protected]>
* glsl: Update ir_variable::max_ifc_array_access properly.Paul Berry2013-10-091-0/+37
| | | | | | | | | | | | This patch modifies update_max_array_access() so that it updates ir_variable::max_ifc_array_access to reflect the shader's use of arrays appearing within interface blocks. v2: Use an ordinary function in ast_array_index.cpp rather than a virtual function in ir_rvalue. Avoid dereferencing NULL when handling accesses to ordinary structs. Reviewed-by: Jordan Justen <[email protected]>
* glsl: Move update of max_array_access into a separate function.Paul Berry2013-10-091-17/+30
| | | | | | | | | | | | | | | | | Currently, when converting an access to an array element from ast to IR, we need to see if the array is an ir_dereference_variable, and if so update the variable's max_array_access. When we add support for unsized arrays in interface blocks, we'll also need to account for cases where the array is an ir_dereference_record and the record is an interface block. To make this easier, move the update into its own function. v2: Use an ordinary function in ast_array_index.cpp rather than a virtual function in ir_rvalue. Reviewed-by: Jordan Justen <[email protected]>
* glsl: Permit non-ubo input interface arrays to use non-const indexing.Paul Berry2013-08-011-1/+2
| | | | | | | | | | | | | | | | | | | From the GLSL ES 3.00 spec: "All indexes used to index a uniform block array must be constant integral expressions." Similar text exists in GLSL specs since 1.50. When we implemented this, the only type of interface block supported by Mesa was uniform blocks, so we required all indexes used to index any interface block to be constant integral expressions. Now that we are adding interface block support for GLSL 1.50, we need a more specific check. Reviewed-by: Ian Romanick <[email protected]> Reviewed-by: Kenneth Graunke <[email protected]>
* glsl: Generate ir_binop_vector_extract for indexing of vectorsIan Romanick2013-05-131-4/+16
| | | | | | | | | | | | Now ir_dereference_array of a vector will never occur in the RHS of an expression. v2: Add back the { } around the if-statement body to make it more readable. Suggested by Eric. Signed-off-by: Ian Romanick <[email protected]> Reviewed-by: Eric Anholt <[email protected]> Reviewed-by: Kenneth Graunke <[email protected]>
* glsl: Don't early-out for error-type inputsIan Romanick2013-04-081-10/+9
| | | | | | | | | | | | | | | | | | | | Check the type of the array operand and the index operand before doing other checks. This simplifies the code a bit now (eliminating the error_emitted parameter), and enables some later functional changes. The shader uniform float x[6]; uniform sampler2D s; void main() { gl_Position.x = xx[s + 1]; } still generates (only) the two expected errors: 0:3(33): error: `xx' undeclared 0:3(39): error: Operands to arithmetic operators must be numeric Signed-off-by: Ian Romanick <[email protected]> Reviewed-by: Kenneth Graunke <[email protected]>
* glsl: Don't emit spurious errors for constant indexes of the wrong typeIan Romanick2013-04-081-2/+2
| | | | | | | | | | | | | | | | | | | | | 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]>
* glsl: Collect all of the non-constant index error checks togetherIan Romanick2013-04-081-45/+42
| | | | | | | | | | 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 <[email protected]> Reviewed-by: Kenneth Graunke <[email protected]>
* glsl: Minor code compaction in _mesa_ast_array_index_to_hirIan Romanick2013-04-081-9/+8
| | | | | | | | Also, document the reason for not checking for type->is_array in some of the bound-checking cases. Signed-off-by: Ian Romanick <[email protected]> Reviewed-by: Kenneth Graunke <[email protected]>
* glsl: Remove some unnecessary uses of error_emittedIan Romanick2013-04-081-15/+4
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | The error_emitted flag is used in semantic checking to prevent spurious cascading errors. For example, void foo(sampler2D s, float a) { float x = a + (1.2 + s); ... } should only generate a single error. Without the error_emitted flag for the first error, "a + ..." would also generate an error. However, a bunch of cases in _mesa_ast_array_index_to_hir that were setting error_emitted would mask legitimate errors. For example, vec4 a[7]; float b = a[3.14]; should generate two error (float index and type mismatch in assignment). The uses of error_emitted would cause only the first to be emitted. This patch removes most of the places in _mesa_ast_array_index_to_hir that would set the error_emitted flag. Signed-off-by: Ian Romanick <[email protected]> Reviewed-by: Kenneth Graunke <[email protected]>
* glsl: Refactor handling of ast_array_index to a separate functionIan Romanick2013-04-081-0/+194
I love 800+ line switch-statements as much as the next guy... Future commits will make changes to this part of the AST-to-HIR conversion, and extracting this code will make that a bit easier. Signed-off-by: Ian Romanick <[email protected]> Reviewed-by: Kenneth Graunke <[email protected]>