aboutsummaryrefslogtreecommitdiffstats
path: root/src/glsl/ast_array_index.cpp
Commit message (Collapse)AuthorAgeFilesLines
* 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]>