aboutsummaryrefslogtreecommitdiffstats
path: root/src/glsl
Commit message (Collapse)AuthorAgeFilesLines
* glsl: add AMD_vertex_shader_layer supportJordan Justen2013-05-134-0/+37
| | | | | | | | This GLSL extension requires that AMD_vertex_shader_layer be enabled by the driver. Signed-off-by: Jordan Justen <jordan.l.justen@intel.com> Reviewed-by: Ian Romanick <ian.d.romanick@intel.com>
* glsl: Death to array dereferences of vectors!Ian Romanick2013-05-133-169/+32
| | | | | | | | | | | | | | | | Now that all the places that used to generate array derefeneces of vectors have been changed to generate either ir_binop_vector_extract or ir_triop_vector_insert (or both), remove all support for dealing with this deprecated construct. As an added safeguard, modify ir_validate to reject ir_dereference_array of a vector. v2: Convert tabs to spaces. Suggested by Eric. Signed-off-by: Ian Romanick <ian.d.romanick@intel.com> Reviewed-by: Eric Anholt <eric@anholt.net> Reviewed-by: Kenneth Graunke <kenneth@whitecape.org>
* glsl: Generate correct ir_binop_vector_extract code for out and inout parametersIan Romanick2013-05-131-47/+102
| | | | | | | | | | | | | | Like with type conversions on out parameters, some extra copies need to occur to handle these cases. The fundamental problem is that ir_binop_vector_extract is not an lvalue, but out and inout parameters must be lvalues. A previous patch delt with a similar problem in the LHS of ir_assignment. v2: Convert tabs to spaces. Suggested by Eric. Signed-off-by: Ian Romanick <ian.d.romanick@intel.com> Reviewed-by: Eric Anholt <eric@anholt.net> Reviewed-by: Kenneth Graunke <kenneth@whitecape.org>
* glsl: Use vector-insert and vector-extract on elements of gl_ClipDistanceMESAIan Romanick2013-05-131-6/+60
| | | | | | | | | | | | | | | | | Variable indexing into vectors using ir_dereference_array is being removed, so this lowering pass has to generate something different. v2: Convert tabs to spaces. Suggested by Eric. v3: Simplify code slightly by assuming that elements of gl_ClipDistanceMESA will always be vec4. Suggested by Paul. v4: Fairly substantial rewrite based on the rewrite of "glsl: Convert lower_clip_distance_visitor to be an ir_rvalue_visitor" Signed-off-by: Ian Romanick <ian.d.romanick@intel.com> Reviewed-by: Kenneth Graunke <kenneth@whitecape.org> Reviewed-by: Paul Berry <stereotype441@gmail.com>
* glsl: Remove some stale comments about ir_callIan Romanick2013-05-131-6/+2
| | | | | | | | | ir_call was changed long ago to be a statement rather than an expression. That makes this comment no longer valid. Signed-off-by: Ian Romanick <ian.d.romanick@intel.com> Reviewed-by: Kenneth Graunke <kenneth@whitecape.org> Reviewed-by: Paul Berry <stereotype441@gmail.com>
* glsl: Convert lower_clip_distance_visitor to be an ir_rvalue_visitorIan Romanick2013-05-131-23/+33
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | Right now the lower_clip_distance_visitor lowers variable indexing into gl_ClipDistance into variable indexing into both the array gl_ClipDistanceMESA and the vectors of that array. For example, gl_ClipDistance[i] = f; becomes gl_ClipDistanceMESA[i >> 2][i & 3] = f; However, variable indexing into vectors using ir_dereference_array is being removed. Instead, ir_expression with ir_triop_vector_insert will be used. The above code will become gl_ClipDistanceMESA[i >> 2] = vector_insert(gl_ClipDistanceMESA[i >> 2], i & 3, f); In order to do this, an ir_rvalue_visitor will need to be used. This commit is really just a refactor to get ready for that. v4: Split the least amount of refactor from the rest of the code changes. Signed-off-by: Ian Romanick <ian.d.romanick@intel.com> Reviewed-by: Kenneth Graunke <kenneth@whitecape.org> Reviewed-by: Paul Berry <stereotype441@gmail.com>
* 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 <ian.d.romanick@intel.com> Reviewed-by: Eric Anholt <eric@anholt.net> Reviewed-by: Kenneth Graunke <kenneth@whitecape.org>
* glsl: Convert ir_binop_vector_extract in the LHS to ir_triop_vector_insertIan Romanick2013-05-131-0/+24
| | | | | | | | | | | | | The ast_array_index code can't know whether to generate an ir_binop_vector_extract or an ir_triop_vector_insert. Instead it will always generate ir_binop_vector_extract, and the LHS and RHS have to be re-written. v2: Convert tabs to spaces. Suggested by Eric. Signed-off-by: Ian Romanick <ian.d.romanick@intel.com> Reviewed-by: Eric Anholt <eric@anholt.net> Reviewed-by: Kenneth Graunke <kenneth@whitecape.org>
* glsl: Add lowering pass for ir_triop_vector_insertIan Romanick2013-05-134-0/+142
| | | | | | | | | | | | | | | | | | This will eventually replace do_vec_index_to_cond_assign. This lowering pass is called in all the places where do_vec_index_to_cond_assign or do_vec_index_to_swizzle is called. v2: Use WRITEMASK_* instead of integer literals. Use a more concise method of generating broadcast_index. Both suggested by Eric. v3: Use a series of scalar compares instead of a single vector compare. Suggested by Eric and Ken. It still uses 'if (cond) v.x = y;' instead of conditional assignments because ir_builder doesn't do conditional assignments, and I'd rather keep the code simple. Signed-off-by: Ian Romanick <ian.d.romanick@intel.com> Reviewed-by: Eric Anholt <eric@anholt.net> Reviewed-by: Kenneth Graunke <kenneth@whitecape.org>
* glsl: Lower ir_binop_vector_extract to conditional movesIan Romanick2013-05-131-1/+31
| | | | | | | | | | | | Lower ir_binop_vector_extract with a non-constant index to a series of conditional moves. This is exactly like ir_dereference_array of a vector with a non-constant index. v2: Convert tabs to spaces. Suggested by Eric. Signed-off-by: Ian Romanick <ian.d.romanick@intel.com> Reviewed-by: Eric Anholt <eric@anholt.net> Reviewed-by: Kenneth Graunke <kenneth@whitecape.org>
* glsl: Lower ir_binop_vector_extract to swizzleIan Romanick2013-05-131-0/+45
| | | | | | | | | | | | | | | | | Lower ir_binop_vector_extract with a constant index to a swizzle. This is exactly like ir_dereference_array of a vector with a constant index. v2: Convert tabs to spaces. Suggested by Eric. v3: Correctly call convert_vector_extract_to_swizzle in ir_vec_index_to_swizzle_visitor::visit_enter(ir_call *ir). Suggested by Ken. v4: Use CLAMP instead of MIN2(MAX2()). Suggested by Ken. Signed-off-by: Ian Romanick <ian.d.romanick@intel.com> Reviewed-by: Eric Anholt <eric@anholt.net> Reviewed-by: Kenneth Graunke <kenneth@whitecape.org>
* glsl: Refactor part of convert_vec_index_to_cond_assignIan Romanick2013-05-131-20/+37
| | | | | | | | | | | | | | | | | | Use a first function that extract the vector being indexed and the index from the deref. Call the second function that does the real work. Coming patches will add a new ir_expression for variable indexing into a vector. Having the lowering pass split into two functions will make it much easier to lower the new ir_expression. v2: Convert tabs to spaces. Suggested by Eric. v3: Move some bits from a later patch back to this patch so that it actually compiles. Suggested by Ken. Signed-off-by: Ian Romanick <ian.d.romanick@intel.com> Reviewed-by: Eric Anholt <eric@anholt.net> Reviewed-by: Kenneth Graunke <kenneth@whitecape.org>
* glsl: Add ir_triop_vector_insertIan Romanick2013-05-134-1/+45
| | | | | | | | | | | | | | | The new opcode is used to generate a new vector with a single field from the source vector replaced. This will eventually replace ir_dereference_array of vectors in the LHS of assignments. v2: Convert tabs to spaces. Suggested by Eric. v3: Add constant expression handling for ir_triop_vector_insert. This prevents the constant matrix inversion tests from regressing. Duh. Signed-off-by: Ian Romanick <ian.d.romanick@intel.com> Reviewed-by: Eric Anholt <eric@anholt.net> Reviewed-by: Kenneth Graunke <kenneth@whitecape.org>
* glsl: Add ir_binop_vector_extractIan Romanick2013-05-134-5/+54
| | | | | | | | | | | | | | | | | | | | The new opcode is used to get a single field from a vector. The field index may not be constant. This will eventually replace ir_dereference_array of vectors. This is similar to the extractelement instruction in LLVM IR. http://llvm.org/docs/LangRef.html#extractelement-instruction v2: Convert tabs to spaces. Suggested by Eric. v3: Add array index range checking to ir_binop_vector_extract constant expression handling. Suggested by Ken. v4: Use CLAMP instead of MIN2(MAX2()). Suggested by Ken. Signed-off-by: Ian Romanick <ian.d.romanick@intel.com> Reviewed-by: Eric Anholt <eric@anholt.net> Reviewed-by: Kenneth Graunke <kenneth@whitecape.org>
* glsl: Fix "make check" breakage after adding options to do_common_optimization.Paul Berry2013-05-131-5/+9
| | | | | | | | | | Commit b765740 (glsl: Pass struct shader_compiler_options into do_common_optimization.) added a new parameter to do_common_optimization() but didn't update test_optpass.cpp, causing "make check" to break. This patch makes the proper updates to test_optpass.cpp so that the build succeeds again.
* glsl: Add a pass to flip matrix/vector multiplies to use dot products.Kenneth Graunke2013-05-124-0/+128
| | | | | | | | | | | | | | | | | | | | | | This pass flips (matrix * vector) operations to (vector * matrixTranspose) for certain built-in matrices (currently gl_ModelViewProjectionMatrix and gl_TextureMatrix). This is equivalent, but results in dot products rather than multiplies and adds. On some hardware, this is more efficient. This pass is conditionalized on ctx->mvp_with_dp4, the flag drivers set to indicate they prefer dot products. Improves performance in Lightsmark by 1.01131% +/- 0.162069% (n = 10) on a Haswell GT2 system. Passes Piglit on Ivybridge. v2: Use struct gl_shader_compiler_options instead of plumbing through another boolean flag for this purpose. Signed-off-by: Kenneth Graunke <kenneth@whitecape.org> Reviewed-by: Ian Romanick <ian.d.romanick@intel.com> Reviewed-by: Eric Anholt <eric@anholt.net>
* glsl: Pass struct shader_compiler_options into do_common_optimization.Kenneth Graunke2013-05-124-4/+9
| | | | | | | | | | | | | do_common_optimization may need to make choices about whether to emit certain kinds of instructions. gl_context::ShaderCompilerOptions contains exactly that information, so it makes sense to pass it in. Rather than passing the whole array, pass the structure for the stage that's currently being worked on. Signed-off-by: Kenneth Graunke <kenneth@whitecape.org> Reviewed-by: Ian Romanick <ian.d.romanick@intel.com> Reviewed-by: Eric Anholt <eric@anholt.net>
* glsl: Initialize ctx->ShaderCompilerOptions in standalone scaffolding.Kenneth Graunke2013-05-121-0/+12
| | | | | | | | This code is copied from _mesa_init_shader_state(). Signed-off-by: Kenneth Graunke <kenneth@whitecape.org> Reviewed-by: Ian Romanick <ian.d.romanick@intel.com> Reviewed-by: Eric Anholt <eric@anholt.net>
* glsl: Copy _mesa_shader_type_to_index() to standalone scaffolding.Kenneth Graunke2013-05-121-0/+17
| | | | | | | | | We can't include shaderobj.h from the standalone utilities, so we unfortunately have to copy this function. Signed-off-by: Kenneth Graunke <kenneth@whitecape.org> Reviewed-by: Ian Romanick <ian.d.romanick@intel.com> Reviewed-by: Eric Anholt <eric@anholt.net>
* glsl: fix the value of gl_MaxFragmentUniformVectorsMarek Olšák2013-05-111-1/+1
| | | | | | | NOTE: This is a candidate for the 9.1 branch. Reviewed-by: Kenneth Graunke <kenneth@whitecape.org> Reviewed-by: Brian Paul <brianp@vmware.com>
* mesa: move max texture image unit constants to gl_program_constantsMarek Olšák2013-05-113-8/+8
| | | | | | | | | | Const.MaxTextureImageUnits -> Const.FragmentProgram.MaxTextureImageUnits Const.MaxVertexTextureImageUnits -> Const.VertexProgram.MaxTextureImageUnits etc. Reviewed-by: Kenneth Graunke <kenneth@whitecape.org> Reviewed-by: Brian Paul <brianp@vmware.com> Reviewed-by: Eric Anholt <eric@anholt.net>
* glsl: Add a pass to lower bitfield-insert into bfm+bfi.Matt Turner2013-05-065-0/+72
| | | | | | | | | | i965/Gen7+ and Radeon/Evergreen+ have bfm/bfi instructions to implement bitfieldInsert() from ARB_gpu_shader5. v2: Add ir_binop_bfm and ir_triop_bfi to st_glsl_to_tgsi.cpp. Remove spurious temporary assignment and dereference. Reviewed-by: Chris Forbes <chrisf@ijw.co.nz>
* glsl: Add constant evaluation of bit built-ins.Matt Turner2013-05-061-1/+125
| | | | | | | | v2: Order bits from LSB end (31 - count) for ir_unop_find_msb. v3: Add ir_triop_bitfield_extract as an exception to the op[0]->type == op[1]->type assertion in ir_constant_expression.cpp. Reviewed-by: Chris Forbes <chrisf@ijw.co.nz> [v2]
* glsl: Add support for new bit built-ins in ARB_gpu_shader5.Matt Turner2013-05-064-5/+56
| | | | | | v2: Move use of ir_binop_bfm and ir_triop_bfi to a later patch. Reviewed-by: Chris Forbes <chrisf@ijw.co.nz>
* glsl: Add new bit built-ins IR and prototypes from ARB_gpu_shader5.Matt Turner2013-05-067-0/+342
| | | | Reviewed-by: Chris Forbes <chrisf@ijw.co.nz>
* glsl: Rework ir_reader to handle expressions with four operands.Matt Turner2013-05-061-4/+6
| | | | | | | Needed to support the bitfieldInsert() built-in added by ARB_gpu_shader5. Reviewed-by: Chris Forbes <chrisf@ijw.co.nz>
* mesa: Add infrastructure for ARB_gpu_shader5.Matt Turner2013-05-065-0/+8
| | | | Reviewed-by: Chris Forbes <chrisf@ijw.co.nz>
* glsl: Flip around "if" statements with empty "then" blocks.Eric Anholt2013-05-051-1/+26
| | | | | | | | | | | | This cleans up some funny-looking code in some unigine shaders I was looking at. Also slightly helps on planeshift and a few shaders in an upcoming Valve release. total instructions in shared programs: 1653715 -> 1653587 (-0.01%) instructions in affected programs: 16550 -> 16422 (-0.77%) Reviewed-by: Kenneth Graunke <kenneth@whitecape.org> Reviewed-by: Matt Turner <mattst88@gmail.com>
* build: remove unused API_DEFINESAndreas Boll2013-05-011-2/+1
| | | | Reviewed-by: Matt Turner <mattst88@gmail.com>
* glsl: Ignore redundant prototypes after a function's been defined.Kenneth Graunke2013-04-301-4/+11
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Consider the following shader: vec4 f(vec4 v) { return v; } vec4 f(vec4 v); The prototype exactly matches the signature of the earlier definition, so there's absolutely no point in it. However, it doesn't appear to be illegal. The GLSL 4.30 specification offers two relevant quotes: "If a function name is declared twice with the same parameter types, then the return types and all qualifiers must also match, and it is the same function being declared." "User-defined functions can have multiple declarations, but only one definition." In this case the same function was declared twice, and there's only one definition, which fits both pieces of text. There doesn't appear to be any text saying late prototypes are illegal, so presumably it's valid. Unfortunately, it currently triggers an assertion failure: ir_dereference_variable @ <p1> specifies undeclared variable `v' @ <p2> When we process the second line, we look for an existing exact match so we can enforce the one-definition rule. We then leave sig set to that existing function, and hit sig->replace_parameters(&hir_parameters), unfortunately nuking our existing definition's parameters (which have actual dereferences) with the prototype's bogus unused parameters. Simply bailing out and ignoring such late prototypes is the safest thing to do. Fixes Piglit's late-proto.vert as well as 3DMark/Ice Storm for Android. NOTE: This is a candidate for stable branches. Signed-off-by: Kenneth Graunke <kenneth@whitecape.org> Tested-by: Tapani Pälli <tapani.palli@intel.com> Reviewed-by: Jordan Justen <jordan.l.justen@intel.com> Reviewed-by: Chad Versace <chad.versace@linux.intel.com> Reviewed-by: Ian Romanick <idr@freedesktop.org>
* glsl: Teach basic block analysis about break/continue/discard.Paul Berry2013-04-241-1/+1
| | | | | | | | | | | | | Previously, the only kind of ir_jump that would terminate a basic block was "return". However, the other possible types of ir_jump ("break", "continue", and "discard") should terminate a basic block too. This patch modifies basic block analysis so that it terminates a basic block on any type of ir_jump, not just ir_return. Fixes piglit test dead-code-break-interaction.shader_test. Reviewed-by: Matt Turner <mattst88@gmail.com> Reviewed-by: Kenneth Graunke <kenneth@whitecape.org>
* glsl: Add virtual function ir_instruction::as_jump()Paul Berry2013-04-241-0/+7
| | | | | Reviewed-by: Matt Turner <mattst88@gmail.com> Reviewed-by: Kenneth Graunke <kenneth@whitecape.org>
* mesa: Restore 78-column wrapping of license text in C-style comments.Kenneth Graunke2013-04-231-3/+4
| | | | | | | | | | | | | | The previous commit introduced extra words, breaking the formatting. This text transformation was done automatically via the following shell command: $ git grep 'THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY' | sed 's/:.*$//' | xargs -I {} sh -c 'vim -e -s {} < vimscript where 'vimscript' is a file containing: /THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY/;/\*\// !fmt -w 78 -p ' * ' :wq Reviewed-by: Brian Paul <brianp@vmware.com>
* mesa: Add "OR COPYRIGHT HOLDERS" to license text disclaiming liability.Kenneth Graunke2013-04-231-1/+1
| | | | | | | | | | | | | | | This brings the license text in line with the MIT License as published on the Open Source Initiative website: http://opensource.org/licenses/mit-license.php Generated automatically be the following shell command: $ git grep 'THE AUTHORS BE LIABLE' | sed 's/:.*$//g' | xargs -I '{}' \ sed -i 's/THE AUTHORS/THE AUTHORS OR COPYRIGHT HOLDERS/' {} This introduces some wrapping issues, to be fixed in the next commit. Reviewed-by: Brian Paul <brianp@vmware.com>
* mesa: Change "BRIAN PAUL" to "THE AUTHORS" in license text.Kenneth Graunke2013-04-231-1/+1
| | | | | | | | | | | | | | | | Generated automatically be the following shell command: $ git grep 'BRIAN PAUL BE LIABLE' | sed 's/:.*$//g' | xargs -I '{}' \ sed -i 's/BRIAN PAUL/THE AUTHORS/' {} The intention here is to protect all authors, not just Brian Paul. I believe that was already the sensible interpretation, but spelling it out is probably better. More practically, it also prevents people from accidentally copy & pasting the license into a new file which says Brian is not liable when he isn't even one of the authors. Reviewed-by: Brian Paul <brianp@vmware.com>
* ralloc: Move declarations before statements.José Fonseca2013-04-181-2/+4
| | | | Trivial. Should fix MSVC build.
* ralloc: don't write to memory in case of alloc fail.Dave Airlie2013-04-181-0/+2
| | | | | | | | | | | For some reason I made this happen under indirect rendering, I think we might have a leak, valgrind gave out, so I said I'd fix the basic problem. NOTE: This is a candidate for stable branches. Reviewed-by: Ian Romanick <ian.d.romanick@intel.com> Reviewed-by: Kenneth Graunke <kenneth@whitecape.org> Signed-off-by: Dave Airlie <airlied@redhat.com>
* glsl: Fix hypothetical NULL dereference related to process_array_typeIan Romanick2013-04-121-1/+5
| | | | | | | | | | | | | | | | | | | Ensure that process_array_type never returns NULL, and let process_array_type handle the case where the supplied base type is NULL. Fixes issues identified by Klocwork analysis: Pointer 'type' returned from call to function 'get_type' at line 1907 may be NULL and may be dereferenced at line 1912. and Pointer 'field_type' checked for NULL at line 4160 will be dereferenced at line 4165. Also there is one similar error on line 4174. Signed-off-by: Ian Romanick <ian.d.romanick@intel.com> Reviewed-by: Kenneth Graunke <kenneth@whitecape.org>
* glsl: Fix hypothetical NULL dereference in ↵Ian Romanick2013-04-121-3/+8
| | | | | | | | | | | | | | | | ast_process_structure_or_interface_block Fixes issue identified by Klocwork analysis: Pointer 'field_type' returned from call to function 'glsl_type' at line 4126 may be NULL and may be dereferenced at line 4139. Also there are 2 similar errors on line(s) 4165, 4174. In practice, it should be impossible to actually get NULL in here because a syntax error would have already caused compilation to halt. Signed-off-by: Ian Romanick <ian.d.romanick@intel.com> Reviewed-by: Kenneth Graunke <kenneth@whitecape.org>
* glsl: Fix (and validate) comment above glsl_type::name.Paul Berry2013-04-112-2/+5
| | | | | | | | | | | | | The comment above glsl_type::name claimed that it could sometimes be NULL. This was wrong--it is never NULL. Many error handling paths would segfault if it were. (Anonymous structs are assigned names like "#anon_struct_0001"--see the ast_struct_specifier constructor in glsl_parser_extras.cpp.) Fix the comment and add assertions to validate that it really is never NULL. Reviewed-by: Ian Romanick <ian.d.romanick@intel.com>
* glsl/linker: Reduce scope of non-flat integer varying fix.Paul Berry2013-04-091-4/+3
| | | | | | | | | | | | | | In the mailing list discussion of "glsl/linker: fix varying packing for non-flat integer varyings." (commit 7862bde), we concluded that since the bug only applies to integral variables, it is safer to just apply the bug fix to integer varyings. I forgot to make the change before pushing the patch upstream. (Note: we aren't aware of any bugs in commit 7862bde; it just seems wise to be on the safe side). This patch makes the change. Assuming commit 7862bde gets cherry-picked back to 9.1, this commit should be cherry-picked too. NOTE: This is a candidate for the 9.1 release branch.
* glsl/linker: Adapt flat varying handling in preparation for geometry shaders.Paul Berry2013-04-091-10/+20
| | | | | | | | | | | | | | | | When a varying is consumed by transform feedback, but is not used by the fragment shader, assign_varying_locations() sets its interpolation type to "flat" in order to ensure that lower_packed_varyings never has to deal with non-flat integral varyings (the GLSL spec doesn't require integral vertex outputs to be flat if they aren't consumed by the fragment shader). A similar situation will arise when geometry shader support is added, since the GLSL spec only requires integral vertex shader outputs to be flat when they are consumed by the fragment shader. This patch modifies the linker to handle this situation too. Reviewed-by: Jordan Justen <jordan.l.justen@intel.com>
* glsl: Document lower_packed_varyings' "flat" requirement with an assert.Paul Berry2013-04-091-0/+8
| | | | | | | | | | | | | To minimize the variety of type conversions that lower_packed_varyings needs to perform, it assumes that integral varyings are always qualified as "flat". link_varyings.cpp takes care of ensuring that this is the case (even in the circumstances where GLSL doesn't require it). This patch documents the assumption with an assertion, for ease in future debugging. Reviewed-by: Jordan Justen <jordan.l.justen@intel.com>
* glsl/linker: fix varying packing for non-flat integer varyings.Paul Berry2013-04-091-0/+19
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | Commit dfb57e7 (glsl: Fix error checking on "flat" keyword to match GLSL ES 3.00, GLSL 1.50) relaxed the rules for integral varyings: they only need to be declared as "flat" if they are a fragment shader inputs. This allowed for the possibility of a vertex shader output being a non-flat integer, provided that it was not matched to a fragment shader input. A non-contrived situation where this might arise is if a vertex shader generates some integral outputs which are consumed by tranform feedback, but not by the fragment shader. Unfortunately, lower_packed_varyings assumes that *all* integral varyings are flat, regardless of whether they are consumed by the fragment shader. As a result, attempting to create a non-flat integral vertex output of a size that required packing (i.e. a size other than ivec4 or uvec4) would cause an assertion failure in lower_packed_varyings. This patch prevents the assertion failure by forcing vertex shader outputs to be "flat" whenever they are not consumed by the fragment shader. This should have no effect on rendering since the "flat" keyword only affects the behaviour of fragment shader inputs. Fixes piglit test "spec/EXT_transform_feedback/nonflat-integral". NOTE: This is a candidate for the 9.1 release branch. Reviewed-by: Jordan Justen <jordan.l.justen@intel.com>
* glsl: Check the size of ir_print_visitor's mode[] array with STATIC_ASSERT.Paul Berry2013-04-092-1/+3
| | | | | | | | | ir_print_visitor::visit(ir_variable *)'s mode[] array needs to match the declaration of the enum ir_variable_mode. It's hard to verify that at compile time, but at least we can use a STATIC_ASSERT to make sure it's the right size. This required adding ir_var_mode_count to the enum.
* glsl: Fix ir_print_visitor's handling of interpolation qualifiers.Paul Berry2013-04-091-1/+3
| | | | | | | | | | | This patch updates the interp[] array to match the enum glsl_interp_qualifier. Reviewed-by: Jordan Justen <jordan.l.justen@intel.com> Reviewed-by: Kenneth Graunke <kenneth@whitecape.org> v2: Add a STATIC_ASSERT to make sure the array is the correct size. This required adding INTERP_QUALIFIER_COUNT to the enum.
* glsl: Don't early-out for error-type inputsIan Romanick2013-04-083-15/+11
| | | | | | | | | | | | | | | | | | | | 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 <ian.d.romanick@intel.com> Reviewed-by: Kenneth Graunke <kenneth@whitecape.org>
* 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 <ian.d.romanick@intel.com> Reviewed-by: Kenneth Graunke <kenneth@whitecape.org>
* 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 <ian.d.romanick@intel.com> Reviewed-by: Kenneth Graunke <kenneth@whitecape.org>
* 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 <ian.d.romanick@intel.com> Reviewed-by: Kenneth Graunke <kenneth@whitecape.org>