summaryrefslogtreecommitdiffstats
path: root/src/glsl
Commit message (Collapse)AuthorAgeFilesLines
* glcpp: Add GL_ARB_conservative_depth #define.Kenneth Graunke2011-08-251-1/+3
| | | | | | | Forgotten in the patch that enabled the extension. Reviewed-by: Ian Romanick <[email protected]> Signed-off-by: Kenneth Graunke <[email protected]>
* glsl: fix crash when a const is passed to texelFetchOffsetDave Airlie2011-08-251-0/+1
| | | | | | | while debugging texelFetchOffset we kept hitting the assert. Signed-off-by: Dave Airlie <[email protected]> Reviewed-by: Kenneth Graunke <[email protected]>
* glsl: Bail after reporting an error for non-constant const_in parameters.Kenneth Graunke2011-08-251-0/+1
| | | | | | | | | | Otherwise we continue and hit the "Illegal formal parameter mode" assertion. Fixes negative compile test texelFetchOffset.frag in piglit. Signed-off-by: Kenneth Graunke <[email protected]> Signed-off-by: Dave Airlie <[email protected]>
* glsl: Implement the GL_ARB_conservative_depth extension.Kenneth Graunke2011-08-255-4/+7
| | | | | | | It's the same as GL_AMD_conservative_depth. The specs have slight differences in wording, but don't differ in content or behavior. Signed-off-by: Kenneth Graunke <[email protected]>
* glsl: Make sure that Extensions.dummy_true is set to trueIan Romanick2011-08-241-0/+2
| | | | | Reviewed-by: Kenneth Graunke <[email protected]> Reviewed-by: Paul Berry <[email protected]>
* glsl/builtins: Uncomment textureSize prototypes.Kenneth Graunke2011-08-232-4/+0
| | | | | | Signed-off-by: Kenneth Graunke <[email protected]> Reviewed-by: Ian Romanick <[email protected]> Reviewed-by: Dave Airlie <[email protected]>
* texture_builtins.py: Add support for textureSize (txs).Kenneth Graunke2011-08-231-14/+36
| | | | | Signed-off-by: Kenneth Graunke <[email protected]> Reviewed-by: Ian Romanick <[email protected]>
* glsl: Add a new ir_txs (textureSize) opcode to ir_texture.Kenneth Graunke2011-08-238-35/+58
| | | | | | | | One unique aspect of TXS is that it doesn't have a coordinate. Signed-off-by: Kenneth Graunke <[email protected]> Reviewed-by: Ian Romanick <[email protected]> Reviewed-by: Dave Airlie <[email protected]>
* glsl: Make ir_validate actually visit ir_if nodes.Kenneth Graunke2011-08-221-2/+3
| | | | | | | | | | | | There is no ir_hierarchical_visitor::visit(ir_if *) method, since ir_if is not a leaf node. Instead, there are visit_enter and visit_leave methods. Use visit_enter arbitrarily (either would work fine, though visit_enter will catch errors sooner). Found thanks to a warning emitted by Clang. Reviewed-by: Ian Romanick <[email protected]> Signed-off-by: Kenneth Graunke <[email protected]>
* android: build glslChia-I Wu2011-08-212-0/+269
| | | | | | | This builds the static library libmesa_glsl and executable glsl_compiler from glsl. glsl_compiler is only installed for engineering build. Reviewed-by: Chad Versace <[email protected]>
* ralloc: include limits.h for SIZE_MAX on AndroidChia-I Wu2011-08-211-0/+5
| | | | | | | Android does not define SIZE_MAX in stdint.h. We have to include limits.h for it. Reviewed-by: Chad Versace <[email protected]>
* glsl: remove an unnecessary header includeChia-I Wu2011-08-211-1/+0
| | | | | | Reviewed-by: Brian Paul <[email protected]> Reviewed-by: Ian Romanick <[email protected]> Reviewed-by: Chad Versace <[email protected]>
* glsl: Remove unused variable.Kenneth Graunke2011-08-191-1/+0
|
* glsl: Fix type error when lowering integer divisionsPaul Berry2011-08-161-0/+4
| | | | | | | | | | | | | | | | | | | This patch fixes a bug when lowering an integer division: x/y to a multiplication by a reciprocal: int(float(x)*reciprocal(float(y))) If x was a plain int and y was an ivecN, the lowering pass incorrectly assigned the type of the product to be float, when in fact it should be vecN. This caused mesa to abort with an IR validation error. Fixes piglit tests {fs,vs}-op-div-int-ivec{2,3,4}. Reviewed-by: Kenneth Graunke <[email protected]>
* glsl: When assigning to a whole array, mark the array as accessed.Eric Anholt2011-08-151-10/+11
| | | | | | | | | | | | | The vs-varying-array-mat2-col-row-wr test writes a mat2[3] constant to a mat2[3] varying out array, and also statically accesses element 1 of it on the VS and FS sides. At link time it would get trimmed down to just 2 elements, and then codegen of the VS would end up generating assignments to the unallocated last entry of the array. On the new i965 VS backend, that happened to land on the vertex position. Some issues remain in this test on softpipe, i965/old-vs and i965/new-vs on visual inspection, but i965 is passing because only one green pixel is probed, not the whole split green/red quad.
* glsl: Add validations for ir_call.Paul Berry2011-08-151-0/+36
| | | | | | | | | | | | | | | This patch extends ir_validate.cpp to check the following characteristics of each ir_call: - The number of actual parameters must match the number of formal parameters in the signature. - The type of each actual parameter must match the type of the corresponding formal parameter in the signature. - Each "out" or "inout" actual parameter must be an lvalue. Reviewed-by: Chad Versace <[email protected]>
* glsl: Make is_lvalue() and variable_referenced() const.Paul Berry2011-08-152-11/+11
| | | | | | | | | | These functions don't modify the target instruction, so it makes sense to make them const. This allows these functions to be called from ir validation code (which uses const to ensure that it doesn't accidentally modify the IR being validated). Reviewed-by: Chad Versace <[email protected]> Reviewed-by: Kenneth Graunke <[email protected]>
* glsl: Perform implicit type conversions on function call out parameters.Paul Berry2011-08-151-5/+71
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | When an out parameter undergoes an implicit type conversion, we need to store it in a temporary, and then after the call completes, convert the resulting value. In other words, we convert code like the following: void f(out int x); float value; f(value); Into IR that's equivalent to this: void f(out int x); float value; int out_parameter_conversion; f(out_parameter_conversion); value = float(out_parameter_conversion); This transformation needs to happen during ast-to-IR convertion (as opposed to, say, a lowering pass), because it is invalid IR for formal and actual parameters to have types that don't match. Fixes piglit tests spec/glsl-1.20/compiler/qualifiers/out-conversion-int-to-float.vert and spec/glsl-1.20/execution/qualifiers/vs-out-conversion-*.shader_test, and bug 39651. Bugzilla: https://bugs.freedesktop.org/show_bug.cgi?id=39651 Reviewed-by: Chad Versace <[email protected]>
* glsl: Modify strategy for accumulating conditions when lowering if-statementsIan Romanick2011-08-151-11/+55
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Previously if-statements were lowered from inner-most to outer-most (i.e., bottom-up). All assignments within an if-statement would have the condition of the if-statement appended to its existing condition. As a result the assignments from a deeply nested if-statement would have a very long and complex condition. Several shaders in the OpenGL ES2 conformance test suite contain non-constant array indexing that has been lowered by the shader writer. These tests usually look something like: if (i == 0) { value = array[0]; } else if (i == 1) { value = array[1]; } else ... The IR for the last assignment ends up as: (assign (expression bool && (expression bool ! (var_ref if_to_cond_assign_condition) ) (expression bool && (expression bool ! (var_ref if_to_cond_assign_condition@20) ) (expression bool && (expression bool ! (var_ref if_to_cond_assign_condition@22) ) (expression bool && (expression bool ! (var_ref if_to_cond_assign_condition@24) ) (var_ref if_to_cond_assign_condition@26) ) ) ) ) (x) (var_ref value) (array_ref (var_ref array) (constant int (5))) The Mesa IR that is generated from this is just as awesome as you might expect. Three changes are made to the way if-statements are lowered. 1. Two condition variables, if_to_cond_assign_then and if_to_cond_assign_else, are created for each if-then-else structure. The former contains the "positive" condition, and the later contains the "negative" condtion. This change was implemented in the previous patch. 2. Each condition variable is added to a hash-table when it is created. 3. When lowering an if-statement, assignments to existing condtion variables get the current condition anded. This ensures that nested condition variables are only set to true when the condition variable for all outer if-statements is also true. Changes #1 and #3 combine to ensure the correctness of the resulting code. 4. When a condition assignment is encountered with a condition that is a dereference of a previously added condition variable, the condition is not modified. Change #4 prevents the continuous accumulation of conditions on assignments. If the original if-statements were: if (x) { if (a && b && c && d && e) { ... } else { ... } } else { if (g && h && i && j && k) { ... } else { ... } } The lowered code will be if_to_cond_assign_then@1 = x; if_to_cond_assign_then@2 = a && b && c && d && e && if_to_cond_assign_then@1; ... if_to_cond_assign_else@2 = !if_to_cond_assign_then && if_to_cond_assign_then@1; ... if_to_cond_assign_else@1 = !if_to_cond_assign_then@1; if_to_cond_assign_then@3 = g && h && i && j; && if_to_cond_assign_else@1; ... if_to_cond_assign_else@3 = !if_to_cond_assign_then && if_to_cond_assign_else@1; ... Depending on how instructions are emitted, there may be an extra instruction due to the duplication of the '&& if_to_cond_assign_{then,else}@1' on the nested else conditions. In addition, this may cause some unnecessary register pressure since in the simple case (where the nested conditions are not complex) the nested then-condition variables are live longer than strictly necessary. Before this change, one of the shaders in the OpenGL ES2 conformance test suite's acos_float_frag_xvary generated 348 Mesa IR instructions. After this change it only generates 124. Many, but not all, of these instructions would have also been eliminated by CSE. Reviewed-by: Eric Anholt <[email protected]>
* glsl: Slight change to the code generated by if-flatteningIan Romanick2011-08-151-21/+39
| | | | | | | | | | | | | | | | | | | | | | Now the condition (for the then-clause) and the inverse condition (for the else-clause) get written to separate temporary variables. In the presence of complex conditions, this shouldn't result in more code being generated. If the original if-statement was if (a && b && c && d && e) { ... } else { ... } The lowered code will be if_to_cond_assign_then = a && b && c && d && e; ... if_to_cond_assign_else = !if_to_cond_assign_then; ... Reviewed-by: Eric Anholt <[email protected]>
* glsl: Replace foreach_iter with foreach_list_safeIan Romanick2011-08-151-2/+2
| | | | Reviewed-by: Eric Anholt <[email protected]>
* glsl: Make move_block_to_cond_assign not care which branch it's processingIan Romanick2011-08-151-27/+17
| | | | | | This will make some future changes a bit easier to digest. Reviewed-by: Eric Anholt <[email protected]>
* glsl: validate IR after linking (debug builds only)Paul Berry2011-08-081-0/+8
| | | | | | | | | | | | | | | | | | | | At least one of the invariants verified by IR validation concerns the relative ordering of toplevel constructs in the IR: references to global variables must come after the declarations of those global variables. Since linking affects the ordering of toplevel constructs in the IR, it's possible that a bug in the linker will cause invalid IR to be generated, even if all the pre-linked shaders are valid. (In fact, such a bug was fixed by the previous commit.) Bugs like this are easily masked by further optimization passes, particularly inlining. So to make them easier to track down, this patch addes an IR validation step right after linking, and before final optimization occurs. The validation only occurs on debug builds. Reviewed-by: Kenneth Graunke <[email protected]>
* glsl: When linking, emit functions at the tail of the final linked program.Paul Berry2011-08-081-2/+4
| | | | | | | | | | | | | | | | | | | | | When link_functions.cpp adds a new function to the final linked program, it needs to add it after any global variable declarations that the function refers to, otherwise the IR will be invalid (because variable declarations must occur before variable accesses). The easiest way to do that is to have the linker emit functions to the tail of the final linked program. The linker used to emit functions to the head of the final linked program, in an effort to keep callees sorted before their callers. However, this was not reliable: it didn't work for functions declared or defined in the same compilation unit as main, for diamond-shaped patterns in the call graph, or for some obscure cases involving overloaded functions. And no code currently relies on this sort order. No Piglit regressions with i965 Ironlake. Reviewed-by: Kenneth Graunke <[email protected]>
* glsl: Check array size is const before asserting that no IR was generated.Paul Berry2011-08-081-5/+8
| | | | | | | | | | | | | process_array_type() contains an assertion to verify that no IR instructions are generated while processing the expression that specifies the size of the array. This assertion needs to happen _after_ checking whether the expression is constant. Otherwise we may crash on an illegal shader rather than reporting an error. Fixes piglit tests array-size-non-builtin-function.vert and array-size-with-side-effect.vert. Reviewed-by: Kenneth Graunke <[email protected]>
* glsl: Constant-fold built-in functions before outputting IRPaul Berry2011-08-081-2/+14
| | | | | | | | | | | | | | Rearranged the logic for converting the ast for a function call to hir, so that we constant fold before emitting any IR. Previously we would emit some IR, and then only later detect whether we could constant fold. The unnecessary IR would usually get cleaned up by a later optimization step, however in the case of a builtin function being used to compute an array size, it was causing an assertion. Fixes Piglit test array-size-constant-relational.vert. Reviewed-by: Kenneth Graunke <[email protected]> Bugzilla: https://bugs.freedesktop.org/show_bug.cgi?id=38625
* glsl: Emit function signatures at toplevel, even for built-ins.Paul Berry2011-08-084-20/+22
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | The ast-to-hir conversion needs to emit function signatures in two circumstances: when a function declaration (or definition) is encountered, and when a built-in function is encountered. To avoid emitting a function signature in an illegal place (such as inside a function), emit_function() checked whether we were inside a function definition, and if so, emitted the signature before the function definition. However, this didn't cover the case of emitting function signatures for built-in functions when those built-in functions are called from inside the constant integer expression that specifies the length of a global array. This failed because when processing an array length, we are emitting IR into a dummy exec_list (see process_array_type() in ast_to_hir.cpp). process_array_type() later checks (via an assertion) that no instructions were emitted to the dummy exec_list, based on the reasonable assumption that we shouldn't need to emit instructions to calculate the value of a constant. This patch changes emit_function() so that it emits function signatures at toplevel in all cases. This partially fixes bug 38625 (https://bugs.freedesktop.org/show_bug.cgi?id=38625). The remainder of the fix is in the patch that follows. Reviewed-by: Kenneth Graunke <[email protected]>
* Revert "glsl: Skip processing the first function's body in do_dead_functions()."Paul Berry2011-08-081-10/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | opt_dead_functions contained a shortcut to skip processing the first function's body, based on the assumption that IR functions are topologically sorted, with callees always coming before their callers (therefore the first function cannot contain any calls). This assumption turns out not to be true in general. For example, the following code snippet gets translated to IR that violates this assumption: void f(); void g(); void f() { g(); } void g() { ... } In practice, the shortcut didn't cause bugs because of a coincidence of the circumstances in which opt_dead_functions is called: (a) we do inlining right before dead function elimination, and inlining (when successful) eliminates all calls. (b) for user-defined functions, inlining is always successful, because previous optimization passes (during compilation) have reduced them to a form that is eligible for inlining. (c) the function that appears first in the IR can't possibly call a built-in function, because built-in functions are always emitted before the function that calls them. It seems unnecessarily fragile to have opt_dead_functions depend on these coincidences. And the next patch in this series will break (c). So I'm reverting the shortcut. The consequence will be a slight increase in link time for complex shaders. This reverts commit c75427f4c8767e131e5fb3de44fbc9d904cb992d. Reviewed-by: Kenneth Graunke <[email protected]>
* glsl: silence warning about trailing comma in enum listBrian Paul2011-08-081-1/+1
|
* glsl: empty declarations should be validChia-I Wu2011-08-052-12/+8
| | | | | | | | | | | | | | | Unlike C++, empty declarations such as float; should be valid. The spec is not explicit about this actually. Some apps that generate their shader sources may rely on this. This was noted when porting one of them to Linux from Windows. Reviewed-by: Chad Versace <[email protected]> Note: this is a candidate for the 7.11 branch.
* mesa: Ensure that gl_shader_program::InfoLog is never NULLIan Romanick2011-08-021-0/+1
| | | | | | | | | | | | | | | | This prevents assertion failures in ralloc_strcat. The ralloc_free in _mesa_free_shader_program_data can be omitted because freeing the gl_shader_program in _mesa_delete_shader_program will take care of this automatically. A bunch of this code could use a refactor to use ralloc a bit more effectively. A bunch of the things that are allocated with malloc and owned by the gl_shader_program should be allocated with ralloc (using the gl_shader_program as the context). Signed-off-by: Ian Romanick <[email protected]> Reviewed-by: Kenneth Graunke <[email protected]> Reviewed-by: Eric Anholt <[email protected]>
* linker: Make linker_{error,warning} generally availableIan Romanick2011-08-024-3/+22
| | | | | | | | | | linker_warning is a new function. It's identical to linker_error except that it doesn't set LinkStatus=false and it prepends "warning: " on messages instead of "error: ". Signed-off-by: Ian Romanick <[email protected]> Reviewed-by: Kenneth Graunke <[email protected]> Reviewed-by: Eric Anholt <[email protected]>
* linker: Make linker_error set LinkStatus to falseIan Romanick2011-08-024-100/+90
| | | | | | | | | | | | Remove the other places that set LinkStatus to false since they all immediately follow a call to linker_error. The function linker_error was previously known as linker_error_printf. The name was changed because it may seem surprising that a printf function will set an error flag. Signed-off-by: Ian Romanick <[email protected]> Reviewed-by: Kenneth Graunke <[email protected]> Reviewed-by: Eric Anholt <[email protected]>
* glsl: improve the accuracy of the atan(x,y) builtin function.Paul Berry2011-08-011-1/+3
| | | | | | | | | | The previous formula for atan(x,y) returned a value of +/- pi whenever |x|<0.0001, and used a formula based on atan(y/x) otherwise. This broke in cases where both x and y were small (e.g. atan(1e-5, 1e-5)). This patch modifies the formula so that it returns a value of +/- pi whenever |x|<1e-8*|y|, and uses the formula based on atan(y/x) otherwise.
* glsl: improve the accuracy of the asin() builtin function.Paul Berry2011-08-011-28/+40
| | | | | | | | | | | | | | | | | | | | | | | | The previous formula for asin(x) was algebraically equivalent to: sign(x)*(pi/2 - sqrt(1-|x|)*(A + B|x| + C|x|^2)) where A, B, and C were arbitrary constants determined by a curve fit. This formula had a worst case absolute error of 0.00448, an unbounded worst case relative error, and a discontinuity near x=0. Changed the formula to: sign(x)*(pi/2 - sqrt(1-|x|)*(pi/2 + (pi/4-1)|x| + A|x|^2 + B|x|^3)) where A and B are arbitrary constants determined by a curve fit. This has a worst case absolute error of 0.00039, a worst case relative error of 0.000405, and no discontinuities. I don't expect a significant performance degradation, since the extra multiply-accumulate should be fast compared to the sqrt() computation. Fixes piglit tests {vs,fs}-asin-float and {vs,fs}-atan-*
* glsl: Remove duplicate commentChad Versace2011-08-011-8/+0
| | | | | | | Remove duplicate doxgen comment for ir_function.cpp:parameter_lists_match(). Signed-off-by: Chad Versace <[email protected]>
* glsl: Clarify ir_function::matching_sigature()Chad Versace2011-07-301-20/+33
| | | | | | | | | | | The function used a variable named 'score', which was an outright lie. A signature matches or it doesn't; there is no fuzzy scoring. Change the return type of parameter_lists_match() to an enum, and let ir_function::matching_sigature() switch on that enum. Reviewed-by: Kenneth Graunke <[email protected]> Signed-off-by: Chad Versace <[email protected]>
* glsl: Fix conversions in array constructorsChad Versace2011-07-301-2/+10
| | | | | | | | | | | | | | | | | | | | | | Array constructors obey narrower conversion rules than other constructors [1] --- they use the implicit conversion rules [2] instead of the scalar constructor conversions [3]. But process_array_constructor() was incorrectly applying the broader rules. [1] GLSL 1.50 spec, Section 5.4.4 Array Constructors, page 52 (58 of pdf) [2] GLSL 1.50 spec, Section 4.1.10 Implicit Conversions, page 25 (31 of pdf) [3] GLSL 1.50 spec, Section 5.4.1 Conversion, page 48 (54 of pdf) To fix this, first check (with glsl_type::can_be_implicitly_converted_to) if an implicit conversion is legal before performing the conversion. Fixes: piglit:spec/glsl-1.20/compiler/structure-and-array-operations/array-ctor-implicit-conversion-bool-float.vert piglit:spec/glsl-1.20/compiler/structure-and-array-operations/array-ctor-implicit-conversion-bvec*-vec*.vert Note: This is a candidate for the 7.10 and 7.11 branches. Reviewed-by: Kenneth Graunke <[email protected]> Signed-off-by: Chad Versace <[email protected]>
* glsl: Remove ir_function.cpp:type_compare()Chad Versace2011-07-301-61/+0
| | | | | | | | | The function is no longer used and has been replaced by glsl_type::can_implicitly_convert_to(). Note: This is a candidate for the 7.10 and 7.11 branches. Reviewed-by: Kenneth Graunke <[email protected]> Signed-off-by: Chad Versace <[email protected]>
* glsl: Fix implicit conversions in non-constructor function callsChad Versace2011-07-301-17/+29
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Context ------- In ast_function_expression::hir(), parameter_lists_match() checks if the function call's actual parameter list matches the signature's parameter list, where the match may require implicit conversion of some arguments. To check if an implicit conversion exists between individual arguments, type_compare() is used. Problems -------- type_compare() allowed the following illegal implicit conversions: bool -> float bvecN -> vecN int -> uint ivecN -> uvecN uint -> int uvecN -> ivecN Change ------ type_compare() is buggy, so replace it with glsl_type::can_be_implicitly_converted_to(). This comprises a rewrite of parameter_lists_match(). Fixes piglit:spec/glsl-1.20/compiler/built-in-functions/outerProduct-bvec*.vert Note: This is a candidate for the 7.10 and 7.11 branches. Reviewed-by: Kenneth Graunke <[email protected]> Signed-off-by: Chad Versace <[email protected]>
* glsl: Add method glsl_type::can_implicitly_convert_to()Chad Versace2011-07-302-0/+51
| | | | | | | | | | | | | | This method checks if a source type is identical to or can be implicitly converted to a target type according to the GLSL 1.20 spec, Section 4.1.10 Implicit Conversions. The following commits use the method for a bugfix: glsl: Fix implicit conversions in non-constructor function calls glsl: Fix implicit conversions in array constructors Note: This is a candidate for the 7.10 and 7.11 branches. Reviewed-by: Kenneth Graunke <[email protected]> Signed-off-by: Chad Versace <[email protected]>
* Add dependency generation for Mesa and GLSL dricore objects.Eric Anholt2011-07-281-0/+1
| | | | | Reviewed-By: Christopher James Halse Rogers <[email protected]>
* glsl: improve the accuracy of the radians() builtin functionPaul Berry2011-07-281-4/+4
| | | | | | | | | | | The constant used in the radians() function didn't have enough precision, causing a relative error of 1.676e-5, which is far worse than the precision of 32-bit floats. This patch reduces the relative error to 1.14e-9, which is the best we can do in 32 bits. Fixes piglit tests {fs,vs}-radians-{float,vec2,vec3,vec4}. Reviewed-by: Kenneth Graunke <[email protected]>
* glsl: Add source location tracking to TODO listIan Romanick2011-07-271-0/+5
|
* glsl: Remove completed items from the TODO listIan Romanick2011-07-271-16/+0
|
* glsl: Correctly return progress from lower_variable_index_to_cond_assignIan Romanick2011-07-251-1/+3
| | | | | | | | | | | | | | | | | | | | lower_variable_index_to_cond_assign runs until it can't make any more progress. It then returns the result of the last pass which will always be false. This caused the lowering loop in _mesa_ir_link_shader to end before doing one last round of lower_if_to_cond_assign. This caused several if-statements (resulting from lower_variable_index_to_cond_assign) to be left in the IR. In addition to this change, lower_variable_index_to_cond_assign should take a flag indicating whether or not it should even generate if-statements. This is easily controlled by switch_generator::linear_sequence_max_length. This would generate much better code on architectures without any flow contol. Fixes i915 piglit regressions glsl-texcoord-array and glsl-fs-vec4-indexing-temp-src. Reviewed-by: Eric Anholt <[email protected]>
* glsl: Compare vector indices in blocksIan Romanick2011-07-231-23/+39
| | | | | | | | Just like the non-constant array index lowering pass, compare all N indices at once. For accesses to a vec4, this saves 3 comparison instructions on a vector architecture. Reviewed-by: Eric Anholt <[email protected]>
* glsl: Factor out code that generates block of index comparisonsIan Romanick2011-07-232-42/+73
| | | | Reviewed-by: Eric Anholt <[email protected]>
* glsl: Treat ir_dereference_array of non-var as a constant for loweringIan Romanick2011-07-231-2/+8
| | | | | | | | | | | | | | | | | | | | | | | | | | | Previously the code would just look at deref->array->type to see if it was a constant. This isn't good enough because deref->array might be another ir_dereference_array... of a constant. As a result, deref->array->type wouldn't be a constant, but deref->variable_referenced() would return NULL. The unchecked NULL pointer would shortly lead to a segfault. Instead just look at the return of deref->variable_referenced(). If it's NULL, assume that either a constant or some other form of anonymous temporary storage is being dereferenced. This is a bit hinkey because most drivers treat constant arrays as uniforms, but the lowering pass treats them as temporaries. This keeps the behavior of the old code, so this change isn't making things worse. Fixes i965 piglit: vs-temp-array-mat[234]-index-col-rd vs-temp-array-mat[234]-index-col-row-rd vs-uniform-array-mat[234]-index-col-rd vs-uniform-array-mat[234]-index-col-row-rd Reviewed-by: Eric Anholt <[email protected]>
* glsl: When lowering non-constant vector indexing, respect existing conditionsIan Romanick2011-07-231-5/+24
| | | | | | | If the non-constant index was in the LHS of an assignment, any existing condititon on that assignment would be lost. Reviewed-by: Eric Anholt <[email protected]>