summaryrefslogtreecommitdiffstats
path: root/src/glsl
Commit message (Collapse)AuthorAgeFilesLines
* glsl: Use the default values of ir_assignment() in lower_mat_op_to_vec.Eric Anholt2011-06-291-24/+8
| | | | Reviewed-by: Kenneth Graunke <[email protected]>
* glsl: Allow ir_assignment() constructor to not specify condition.Eric Anholt2011-06-291-1/+1
| | | | | | | | | | | We almost never want to specify a condition, and when we do we're already thinking about it (because we're writing a lowering pass generating the condition), so a default argument should make the code more pleasant to read. NOTE: This is a candidate for the 7.11 branch (we want to be able to cherry-pick future code). Reviewed-by: Kenneth Graunke <[email protected]>
* glsl: Avoid making a temporary for lower_mat_op_to_vec if not needed.Eric Anholt2011-06-291-0/+11
| | | | | | | | | | | | | Our copy propagation tends to be bad at handling the later array accesses of the matrix argument we moved to a temporary. Generally we don't need to move it to a temporary, though, so this avoids needing more copy propagation complexity. Reduces instruction count of some Unigine Tropics and Sanctuary fragment shaders that do operations on uniform matrix arrays by 5.9% on gen6. Reviewed-by: Kenneth Graunke <[email protected]>
* glsl: Make lower_mat_op_to_vec track derefs, not variables.Eric Anholt2011-06-291-71/+56
| | | | | | | We were constrained to using temporaries because we were assuming variables all over. This simplifies things a bit. Reviewed-by: Kenneth Graunke <[email protected]>
* glsl: Rename lower_mat_op_to_vec operands/results to be less hungarian.Eric Anholt2011-06-291-74/+74
| | | | | | | | | | | This awkward typing was to avoid shadowing the function argument (the matrix) with the temporary deref (the column) before the get_column()/get_element()s were moved into the expression/assignment constructors. They're about to become not-variables, so the current names had to go. This change is almost mechanical (other than column_expr), so it should make the next diff clearer. Reviewed-by: Kenneth Graunke <[email protected]>
* glsl: Move get_{column,element} to expression args.Eric Anholt2011-06-291-43/+22
| | | | | | | | I think this makes the code more obvious by moving the declarations to their single usage (now that we aren't using them to get at the ->type field for expression constructors). Reviewed-by: Kenneth Graunke <[email protected]>
* glsl: Drop explicit types of lower_mat_op_to_vec expressions.Eric Anholt2011-06-291-27/+6
| | | | | | The constructor can figure it out for us these days. Reviewed-by: Kenneth Graunke <[email protected]>
* glsl: Rewrote _mesa_glsl_process_extension to use table-driven logic.Paul Berry2011-06-281-109/+218
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Instead of using a chain of manually maintained if/else blocks to handle "#extension" directives, we now consult a table that specifies, for each extension, the circumstances under which it is available, and what flags in _mesa_glsl_parse_state need to be set in order to activate it. This makes it easier to add new GLSL extensions in the future, and fixes the following bugs: - Previously, _mesa_glsl_process_extension would sometimes set the "_enable" and "_warn" flags for an extension before checking whether the extension was supported by the driver; as a result, specifying "enable" behavior for an unsupported extension would sometimes cause front-end support for that extension to be switched on in spite of the fact that back-end support was not available, leading to strange failures, such as those in https://bugs.freedesktop.org/show_bug.cgi?id=38015. - "#extension all: warn" and "#extension all: disable" had no effect. Notes: - All extensions are currently marked as unavailable in geometry shaders. This should not have any adverse effects since geometry shaders aren't supported yet. When we return to working on geometry shader support, we'll need to update the table for those extensions that are available in geometry shaders. - Previous to this commit, if a shader mentioned ARB_shader_texture_lod, extension ARB_texture_rectangle would be automatically turned on in order to ensure that the types sampler2DRect and sampler2DRectShadow would be defined. This was unnecessary, because (a) ARB_shader_texture_lod works perfectly well without those types provided that the builtin functions that reference them are not called, and (b) ARB_texture_rectangle is enabled by default in non-ES contexts anyway. I eliminated this unnecessary behavior in order to make the behavior of all extensions consistent. NOTE: This is a candidate for the 7.10 and 7.11 branches. Reviewed-by: Ian Romanick <[email protected]>
* glsl: Changed extension enable bits to bools.Paul Berry2011-06-281-22/+22
| | | | | | | | | | These were previously 1-bit-wide bitfields. Changing them to bools has a negligible performance impact, and allows them to be accessed by offset as well as by direct structure access. NOTE: This is a candidate for the 7.10 and 7.11 branches. Reviewed-by: Ian Romanick <[email protected]>
* glsl: permit explicit locations on fragment shader outputs, not inputsPaul Berry2011-06-281-1/+1
| | | | | | | | | | | | | | | | | | | | From the OpenGL docs for GL_ARB_explicit_attrib_location: This extension provides a method to pre-assign attribute locations to named vertex shader inputs and color numbers to named fragment shader outputs. This was accidentally implemented for fragment shader inputs. This patch fixes it to apply to fragment shader outputs. Fixes piglit tests spec/ARB_explicit_attrib_location/1.{10,20}/compiler/layout-{01,03,06,07,08,09,10}.frag Reviewed-by: Ian Romanick <[email protected]> NOTE: This is a candidate for the 7.10 and 7.11 branches. Bugzilla: https://bugs.freedesktop.org/show_bug.cgi?id=38624
* glsl: Fix depth unbalancing problem in if-statement flatteningIan Romanick2011-06-271-3/+1
| | | | | | | | | | | | | | | | | | | | | | Previously, if max_depth were 1, the following code would see the first if-statement (correctly) not get flattened, but the second if-statement would (incorrectly) get flattened: void main() { if (a) gl_Position = vec4(0); if (b) gl_Position = vec4(1); } This is because the visit_leave(ir_if*) method would not decrement the depth before returning on the first if-statement. NOTE: This is a candidate for the 7.10 and 7.11 branches. Reviewed-by: Kenneth Graunke <[email protected]>
* glsl: Flagged extension EXT_texture3D as "supported" in the builtin compiler.Paul Berry2011-06-231-0/+1
| | | | | | | Previously, the builtins in OES_texture_3D.{frag,vert} were only compiling properly as a consequence of bug 38015, which allows unsupported extensions to be enabled. This fix eliminates the builtin compiler's reliance on bug 38015, so that bug 38015 can be fixed.
* linker: Reject shaders that use too many varyingsIan Romanick2011-06-201-5/+36
| | | | | | | | | | | | Previously it was up to the driver or later code generator to reject these shaders. It turns out that nobody did this. This will need changes to support geometry shaders. NOTE: This is a candidate for the stable branches. Bugzilla: https://bugs.freedesktop.org/show_bug.cgi?id=37743 Reviewed-by: Kenneth Graunke <[email protected]>
* scons: make embedding orthogonal to the platformJosé Fonseca2011-06-171-2/+2
| | | | To enable embedding in platforms other than linux.
* glsl/builtins: Actually implement int/ivec variants of abs().Kenneth Graunke2011-06-141-0/+20
| | | | | | | Signed-off-by: Kenneth Graunke <[email protected]> NOTE: This is a candidate for stable release branches (and don't forget to re-run "make builtins" after cherry-picking.)
* glsl/generate_builtins.py: Remove regexp to kill pointer addresses.Kenneth Graunke2011-06-141-4/+0
| | | | | | | | | Commit 56ef62d9885f805bbfb2243dc860ff425d5b4d3b "glsl: Generate readable unique names at print time." changed ir_print_visitor to not generate @0x1234567 suffixes except where necessary. So there's no need to manually remove them. Signed-off-by: Kenneth Graunke <[email protected]>
* glsl: Fix incorrect optimization of instructions before discard statements.Eric Anholt2011-06-101-3/+17
| | | | | | | | The function was named "find_unconditional_discard", but didn't actually check that the discard statement found was unconditional. Fixes piglit glsl-fs-discard-04. Reviewed-by: Kenneth Graunke <[email protected]>
* glsl: fixed printing of structure constants.Paul Berry2011-06-031-1/+1
| | | | | | | | ir_print_visitor::visit(ir_constant *) was failing to index properly into ir->type->fields.structure, so the first field name was being reprinted for every field in the structure. Signed-off-by: Brian Paul <[email protected]>
* AST dump: fixed printing of conditionals.Paul Berry2011-06-031-1/+1
| | | | | | | ast_expression::print() had an incorrect index into the subexpressions array, so (a ? b : c) was being incorrectly rendered as (a ? b : b). Signed-off-by: Brian Paul <[email protected]>
* mesa: check that flex/bison are installedBrian Paul2011-05-181-4/+4
| | | | | | Fixes https://bugs.freedesktop.org/show_bug.cgi?id=36651 NOTE: This is a candidate for the 7.10 branch.
* glsl: Add compiler support for ARB_shader_texture_lod.Kenneth Graunke2011-05-096-0/+188
| | | | | Signed-off-by: Kenneth Graunke <[email protected]> Tested-by: Marek Olšák <[email protected]>
* glsl: Remove extra newline from error messageIan Romanick2011-05-031-1/+1
|
* mesa: implement AMD_shader_stencil_exportMarek Olšák2011-05-033-0/+32
| | | | | | | | It's just an alias of the ARB variant with some GLSL compiler changes. Reviewed-by: Brian Paul <[email protected]> Reviewed-by: Ian Romanick <[email protected]> Reviewed-by: Kenneth Graunke <[email protected]>
* glsl: Fix typos in comments.Bryan Cain2011-04-231-6/+6
|
* glsl/ast_to_hir: Only use the local 'type' variable as a temporary.Kenneth Graunke2011-04-201-20/+4
| | | | | | | | | Lots of code (deleted by this patch) tried to make type == result->type, but not all cases did. Don't pretend; just use result->type. Signed-off-by: Kenneth Graunke <[email protected]> Reviewed-by: Eric Anholt <[email protected]> Reviewed-by: Ian Romanick <[email protected]>
* glsl: fix conversions from uint to bool and from float/bool to uintBryan Cain2011-04-181-3/+3
| | | | | Reviewed-by: Kenneth Graunke <[email protected]> Signed-off-by: Ian Romanick <[email protected]>
* glsl: 80-column wrapping and whitespace fixesIan Romanick2011-04-181-1/+5
|
* glsl: Emit a warning when the left-hand operand of a comma has no effectIan Romanick2011-04-181-1/+35
| | | | | | | | | | | | | | | | | The expression x = y, 5, 3; will generate 0:7(9): warning: left-hand operand of comma expression has no effect The warning is only emitted for the left-hand operands, becuase the right-most operand is the result of the expression. This could be used in an assignment, etc. Reviewed-by: Eric Anholt <[email protected]> Reviewed-by: Kenneth Graunke <[email protected]>
* glcpp: Fix attempts to expand recursive macros infinitely (bug #32835).Carl Worth2011-04-171-1/+5
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | The 095-recursive-define test case was triggering infinite recursion with the following test case: #define A(a, b) B(a, b) #define C A(0, C) C Here's what was happening: 1. "C" was pushed onto the active list to expand the C node 2. While expanding the "0" argument, the active list would be emptied by the code at the end of _glcpp_parser_expand_token_list 3. When expanding the "C" argument, the active list was now empty, so lather, rinse, repeat. We fix this by adjusting the final popping at the end of _glcpp_parser_expand_token_list to never pop more nodes then this particular invocation had pushed itself. This is as simple as saving the original state of the active list, and then interrupting the popping when we reach this same state. With this fix, all of the glcpp-test tests now pass. Bugzilla: https://bugs.freedesktop.org/show_bug.cgi?id=32835 Signed-off-by: Carl Worth <[email protected]> Reviewed-by: Ian Romanick <[email protected]> Reviewed-and-tested-by: Kenneth Graunke <[email protected]>
* Add expected file for 095-recursive-define test case.Carl Worth2011-04-141-0/+4
| | | | | | | | | | It's clear enough that the current segmentation fault isn't what we want. And it's also very easy to know what we do want here, (just check with any functional C preprocessor such as "gcc -E"). Add the desired output as an expected file so that the test suite gives useful output, (showing the omitted output and the segfault), rather than just reporting "No such file" for the expected file.
* glcpp: Simplify calling convention of parser's active_list functionsCarl Worth2011-04-141-38/+38
| | | | | | | | | | | | These were all written as generic list functions, (accepting and returning a list to act upon). But they were only ever used with parser->active as the list. By simply accepting the parser itself, these functions can update parser->active and now return nothing at all. This makes the code a bit more compact. And hopefully the code is no less readable since the functions are also now renamed to have "_parser_active" in the name for better correlation with nearby tests of the parser->active field.
* glcpp: Add --valgrind option to the glcpp-test utilityCarl Worth2011-04-141-16/+46
| | | | | | | | | | | The common case for this test suite is to quickly test that everything returns the correct results. In this case, the second run of the test suite under valgrind was just annoying, (and the user would often interrupt it). Now, do what is wanted in the common case by default (just run the test suite), and require a run with "glcpp-test --valgrind" in order to test with valgrind.
* Add an expected file for 084-unbalanced-parenthesesCarl Worth2011-04-141-0/+2
| | | | | | | | | | | | The expected file here captures the current behavior of glcpp (which is to generate an obscure "syntax error, unexpected $end" diagnostic for this case). It would certainly be better for glcpp to generate a nicer diagnostic, (such as "missing closing parenthesis in function-like macro definition" or so), but the current behavior is at least correct, and expected. So we can make the test suite more useful by marking the current behavior as expected.
* Add an expected file for 094-divide-by-zero-short-circuitCarl Worth2011-04-142-0/+26
| | | | | | | | | | | The expected file here captures the current behavior of glcpp (which is to generate a division-by-zero error) for this case. It's easy to argue that it should be short-circuiting the evaluation and not generating the diagnostic (which happens to be what gcc does). But it doesn't seem like we should force this behavior on our pre-processor, (and, as always, the GLSL specification of the pre-processor is too vague on this point).
* Add an expected file for 093-divide-by-zeroCarl Worth2011-04-141-0/+4
| | | | | | This test is behaving just fine already---it's generating an informative diagnostic, ("error: division by 0 in preprocessor directive"), so adding this in the expected file makes things pass.
* glsl: Perform type checking on "^^" operands.Eric Anholt2011-04-131-3/+10
| | | | | | | | | | | We were letting any old operand through, which generally resulted in assertion failures later. Fixes array-logical-xor.vert. Reviewed-by: Kenneth Graunke <[email protected]> Reviewed-by: Chad Versace <[email protected]> Reviewed-by: Ian Romanick <[email protected]>
* glsl: When we've emitted a semantic error for ==, return a bool constant.Eric Anholt2011-04-131-3/+7
| | | | | | | | | | | This prevents later errors (including an assertion failure) from cascading the failure. Fixes invalid-equality-04.vert. Bugzilla: https://bugs.freedesktop.org/show_bug.cgi?id=33303 Reviewed-by: Kenneth Graunke <[email protected]> Reviewed-by: Chad Versace <[email protected]>
* glsl: Semantically check the RHS of `||' even when short-circuiting.Eric Anholt2011-04-131-6/+5
| | | | | | | | | | | We just do the AST-to-HIR processing, and only push the instructions if needed in the constant false case. Fixes glslparsertest/glsl2/logic-02.frag Reviewed-by: Kenneth Graunke <[email protected]> Reviewed-by: Chad Versace <[email protected]> Reviewed-by: Ian Romanick <[email protected]>
* glsl: Semantically check the RHS of `&&' even when short-circuiting.Eric Anholt2011-04-131-6/+6
| | | | | | | | | | | We just do the AST-to-HIR processing, and only push the instructions if needed in the constant true case. Fixes glslparsertest/glsl2/logic-01.frag Reviewed-by: Kenneth Graunke <[email protected]> Reviewed-by: Chad Versace <[email protected]> Reviewed-by: Ian Romanick <[email protected]>
* glsl: Avoid cascading errors when looking for a scalar boolean and failing.Eric Anholt2011-04-131-76/+48
| | | | | | | | | | | | | | | By always using a boolean, we should generally avoid further complaints. The failure case I see is logic_not, where the user might understandably make the mistake of using `!' on a boolean vector (like a piglit case did recently!), and then get a further complaint that the new boolean type doesn't match the bvec it gets assigned to. Fixes invalid-logic-not-06.vert (assertion failure when the bad type ends up in an expression and ir_constant_expression gets angry). Bugzilla: https://bugs.freedesktop.org/show_bug.cgi?id=33314 Reviewed-by: Kenneth Graunke <[email protected]> Reviewed-by: Ian Romanick <[email protected]>
* glsl/opt_cpe: Reenable opt_copy_propagation_elements.cpp pass.Eric Anholt2011-04-131-1/+1
|
* glsl/opt_cpe: Fix a crash when a kill kills for two reasons.Eric Anholt2011-04-131-1/+3
| | | | | | | Fixes glsl-copy-propagation-loop-2 when this optimization pass is re-enabled. Reported-by: David Lamparter <[email protected]>
* glsl/opt_cpe: Kill when the assignment isn't something we recognize.Eric Anholt2011-04-131-2/+9
| | | | | | | | | A few GLES2 tests tripped over this when using array dereferences to hit channels on the LHS (see piglit test glsl-copy-propagation-vector-indexing). We wouldn't find the ir_dereference_variable, and assume that that meant that it wasn't an assignment to a scalar/vector, and thus not notice that the variable had been changed.
* glsl: Make GL_ARB_shader_stencil_export enable block be similar to other blocksIan Romanick2011-04-111-7/+7
| | | | | Tested-by: Brian Paul <[email protected]> Reviewed-by: Kenneth Graunke <[email protected]>
* glsl: Only let a shader enable GL_ARB_draw_instanced if the driver supports itIan Romanick2011-04-111-6/+5
| | | | | | | | Also make the GL_ARB_draw_instanced block follow the same pattern as the other blocks. Tested-by: Brian Paul <[email protected]> Reviewed-by: Kenneth Graunke <[email protected]>
* glsl: Calcluate Mesa state slots in front-end instead of back-endIan Romanick2011-03-294-3/+94
| | | | | | | | | | | | This should be the last bit of infrastructure changes before generating GLSL IR for assembly shaders. This commit leaves some odd code formatting in ir_to_mesa and brw_fs. This was done to minimize whitespace changes / reindentation in some loops. The following commit will restore formatting sanity. Reviewed-by: Eric Anholt <[email protected]> Reviewed-by: Chad Versace <[email protected]>
* glsl: Move _mesa_builtin_uniform_desc from uniforms.c to ir_variable.cppIan Romanick2011-03-291-0/+253
| | | | | | | | This array is going to be used in the main compiler soon. Leaving them uniforms.c caused problems for building the stand-alone compiler. Reviewed-by: Eric Anholt <[email protected]> Reviewed-by: Chad Versace <[email protected]>
* glsl: Accept precision qualifiers on sampler types, but only in ES.Kenneth Graunke2011-03-261-2/+9
| | | | | | | | | | GLSL 1.30 states clearly that only float and int are allowed, while the GLSL ES specification's issues section states that sampler types may take precision qualifiers. Fixes compilation failures in 3DMarkMobileES 2.0 and GLBenchmark 2.0. NOTE: This is a candidate for stable release branches.
* glsl: Generate readable unique names at print time.Kenneth Graunke2011-03-252-11/+63
| | | | | | | | | | | | | | | | | | | | Since GLSL IR allows multiple ir_variables to share the same name, we need to generate unique names when printing the IR. Previously, we always used %s@%p, appending the ir_variable's memory address. While this worked, it had two drawbacks: - When there aren't duplicates, the extra "@0x669a3e88" is useless and makes the code harder to read. - Real duplicates were hard to tell apart: channel_expressions@0x6699e3c8 vs. channel_expressions@0x6699ddd8 We now append @2, @3, @4, and so on, but only where necessary to distinguish duplicates. Since we only do this at print time, any performance impact is irrelevant. Signed-off-by: Kenneth Graunke <[email protected]> Reviewed-by: Eric Anholt <[email protected]> Reviewed-by: Ian Romanick <[email protected]>
* glsl: Make add_variable, add_uniform, et. al. have similar signaturesIan Romanick2011-03-251-106/+109
| | | | | | While making some other changes in this area I was finding it annoying each of these functions took mostly the same set of parameters in differing orders.