summaryrefslogtreecommitdiffstats
path: root/src/glsl
Commit message (Collapse)AuthorAgeFilesLines
* glsl: Don't require gl_Position to be written in GLSL 1.40.Eric Anholt2012-03-211-5/+30
| | | | | | | Fixes piglit glsl-1.40/execution/tf-no-position. Reviewed-by: Ian Romanick <[email protected]> Reviewed-by: Kenneth Graunke <[email protected]>
* Add .deps/, .libs/, and *.la to toplevel .gitignorePaul Berry2012-03-201-2/+0
| | | | | | | To avoid redundancies, this patch also removes .deps, .libs, and *.la from .gitignore files in subdirectories. Reviewed-by: Kenneth Graunke <[email protected]>
* glsl: Don't include the deprecated structure types in GLSL 1.40.Eric Anholt2012-03-192-15/+17
| | | | Reviewed-by: Kenneth Graunke <[email protected]>
* glsl: Add GLSL 1.40 textureSize() implementations for sampler2DRect.Eric Anholt2012-03-153-2/+19
| | | | | | | | | | | | | By setting lod to 0 in the builtin function implementation, we avoid needing to update all the visitors to ignore LOD in this case, when the hardware drivers actually want to ask for LOD 0 for rectangular textures. Fixes piglit spec/GLSL-1.40/textureSize-*Rect. v2: Change style of looking for substrings. Reviewed-by: Kenneth Graunke <[email protected]>
* glsl: Set up generated builtin functions handling for GLSL 1.40.Eric Anholt2012-03-151-3/+3
| | | | | | | Otherwise, when we go to use ir_reader on the generated code, we won't have the types present. Reviewed-by: Kenneth Graunke <[email protected]>
* glsl: Add support for integer sampler2DRect variants in GLSL 1.40.Eric Anholt2012-03-153-2/+27
| | | | Reviewed-by: Kenneth Graunke <[email protected]>
* glsl: Drop ftransform() from GLSL 1.40 profile.Eric Anholt2012-03-151-2/+0
| | | | | | | | | This is the one builtin function claimed to be dropped due to the ARB_compatibility split. Fixes piglit spec/GLSL-1.40/compiler/ftransform.vert Reviewed-by: Kenneth Graunke <[email protected]>
* glsl: Copy GLSL 1.30 builtin profile to GLSL 1.40.Eric Anholt2012-03-152-0/+1946
| | | | | | All that's changed is the #version changing to 140. Reviewed-by: Kenneth Graunke <[email protected]>
* glsl: When failing to compile some builtins, print the error.Eric Anholt2012-03-151-0/+8
| | | | | | | This makes the process slightly more debuggable, though it would be nice if the build just failed immediately instead. Reviewed-by: Kenneth Graunke <[email protected]>
* glsl: Let the builtin compiler process GLSL 1.40 shaders.Eric Anholt2012-03-151-3/+3
| | | | | | | This is required to put the new 1.40 builtins in place, since they require new types. Reviewed-by: Kenneth Graunke <[email protected]>
* glsl: Update builtin variables for GLSL 1.40.Eric Anholt2012-03-151-109/+150
| | | | | | | | | | Mostly this is a matter of removing variables that have been moved to the compatibility profile. There's one addition: gl_InstanceID is present in the core now. This fixes the new piglit tests for GLSL 1.40 builtin variables. Reviewed-by: Kenneth Graunke <[email protected]>
* glsl: Hook up the current GLSL 1.30 types and builtins for 1.40.Eric Anholt2012-03-153-1/+10
| | | | | | This gets a basic #version 140 shader compiling. Reviewed-by: Kenneth Graunke <[email protected]>
* glsl: Add support for parsing #version 140.Eric Anholt2012-03-153-0/+6
| | | | Reviewed-by: Kenneth Graunke <[email protected]>
* glsl: Avoid extra if statements for logic and/or with no side effects.Eric Anholt2012-03-131-17/+6
| | | | | | | | | | | | | This avoids extra if statements in the common case of just comparing two expressions that don't involve assignments or function calls, along with simplifying the handling of constant expressions. Reduces i965 instructions generated in unigine tropics and sanctuary, yofrankie, warsow, gstreamer shaders, and the weston compositor. shader-db results: Total instructions: 213052 -> 212752 38/1246 programs affected (3.0%) 14309 -> 14009 instructions in affected programs (2.1% reduction)
* glsl: Refine the loop instruction counting.Eric Anholt2012-03-081-12/+36
| | | | | | | | | | | | Before, we were only counting top-level instructions. But if we have an assignment of a giant expression tree (such as the ones eventually generated by glsl-fs-unroll), we were counting the same as an assignment of a variable deref. glsl-fs-unroll-explosion now fails in a reasonable amount of time on i965 because the unrolling didn't go ridiculously far. Reviewed-by: Kenneth Graunke <[email protected]>
* glsl: Make gl_InstanceID available with GL_ARB_draw_instanced extensionIan Romanick2012-02-291-1/+13
| | | | | | | | | | | Originally ARB_draw_instanced only specified that ARB decorated name. Since no vendor actually implemented that behavior and some apps use the undecorated name, the extension now specifies that both names are available. Signed-off-by: Ian Romanick <[email protected]> Reviewed-by: Kenneth Graunke <[email protected]> Reviewed-by: Marek Olšák <[email protected]>
* glcpp: Don't strlen() the output for every token being printed.Kenneth Graunke2012-02-282-24/+28
| | | | | | | | | | | | | The ralloc string appending functions were originally intended for simple, non-hot-path uses like printing to an info log. Cuts Unigine Tropics load time by around 20% (6 seconds). v2: Avoid strlen() on every newline, too. Signed-off-by: Kenneth Graunke <[email protected]> Reviewed-by: Ian Romanick <[email protected]> [v1] Acked-by: José Fonseca <[email protected]> [v1]
* ralloc: Make rewrite_tail increase "start" by the new text's length.Kenneth Graunke2012-02-284-16/+18
| | | | | | | | | | | | | | | | | | Both callers of rewrite_tail immediately compute the new total string length by adding the (known) length of the existing string plus the length of the newly appended text. Unfortunately, callers generally won't know the length of the new text, as it's printf-formatted. Since ralloc already computes this length, it makes sense to add it in and save the caller the effort. This simplifies both existing callers, but more importantly, will allow for cheap-appending in the next commit. v2: The link_uniforms code needs both the old and new length. Apply the obvious fix (which sadly makes it less of a cleanup). Signed-off-by: Kenneth Graunke <[email protected]> Reviewed-by: Ian Romanick <[email protected]> [v1] Acked-by: José Fonseca <[email protected]> [v1]
* glsl: Avoid excessive loop unrolling.Mathias Fröhlich2012-02-091-0/+15
| | | | | | | | | | | | | | | | | | | Avoid unrollong loops that are either nested loops or where the loop body times the unroll count is huge. The change is far from being perfect but it extends the loop unrolling decision heuristic by some additional safeguard. In particular this cuts down compilation of a shader precomputing atmospheric scattering integral tables containing two nesting levels in a loop from something way beyond some minutes (I never waited for it to finish) to some fractions of a second. This fixes piglit tests glsl-fs-unroll-explosion and glsl-vs-unroll-explosion on r600g. Reviewed-by: Eric Anholt <[email protected]> Signed-off-by: Mathias Fröhlich <[email protected]>
* glsl: Fix Android buildChad Versace2012-02-081-0/+1
| | | | | | | | | | | | The build was broken by the line below, added in commit 4f82fed4. s_expression.cpp:26: #include <limits> Mesa's half of the fix is to add 'external/astl/include' to the include path. The other half of the fix requires implementing numeric_limits<float>::infinity() in astl, for which I have patches submitted upstream for review. Signed-off-by: Chad Versace <[email protected]>
* glsl: Add error case for switch() with two default cases.Eric Anholt2012-02-032-0/+16
| | | | | | | | Fixes piglit switch-case-duplicated.vert. NOTE: This is a candidate for the 8.0 branch. Reviewed-by: Ian Romanick <[email protected]>
* glsl: Throw an error when faced with a duplicated switch() case label.Eric Anholt2012-02-032-0/+27
| | | | | | | | | The error message I chose matches gcc's error. Fixes piglit switch-case-duplicated.vert. NOTE: This is a candidate for the 8.0 branch. Reviewed-by: Ian Romanick <[email protected]>
* glsl: Add other missing error location information for switch statements.Eric Anholt2012-02-031-0/+4
| | | | | | NOTE: This is a candidate for the 8.0 branch. Reviewed-by: Ian Romanick <[email protected]>
* glsl: Add missing location info to case labels.Eric Anholt2012-02-031-0/+2
| | | | | | | | Otherwise, the upcoming error messages said the location was 0:0(0). NOTE: This is a candidate for the 8.0 branch. Reviewed-by: Ian Romanick <[email protected]>
* glsl: Throw the required error when a case label is a non-constant.Eric Anholt2012-02-031-2/+14
| | | | | | | | | | | | It's not quite spelled out in the spec text, but the grammar indicates that only constant values are allowed as switch() case labels (and only constant values make sense, anyway). Fixes piglit glsl-1.30/compiler/switch-statement/switch-case-uniform-int.vert. NOTE: This is a candidate for the 8.0 branch. Reviewed-by: Ian Romanick <[email protected]>
* glsl: Save and restore the whole switch state for nesting.Eric Anholt2012-02-033-260/+255
| | | | | | | | | This stuffs them all in a struct for sanity. Fixes piglit glsl-1.30/execution/switch/fs-uniform-nested. NOTE: This is a candidate for the 8.0 branch. Reviewed-by: Ian Romanick <[email protected]>
* glsl: move array_sizing_visitor class outside of link_intrastage_shaders()Brian Paul2012-02-021-16/+22
| | | | | | To silence warnings with gcc 4.4.x on Linux and llvm-g++ 4.2 on Mac. Reviewed-by: Kenneth Graunke <[email protected]>
* glsl: Avoid ralloc_stealing a long-lived object to a short-lived parentCarl Worth2012-02-021-3/+0
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | In commit 6ecee54a9aecc120cb68b02f7e14dcac86b9eca2 a call to talloc_reference was replaced with a call to talloc_steal. This was in preparation for moving to ralloc which doesn't support reference counting. The justification for talloc_steal within token_list_append in that commit is that the tokens are being copied already. But the copies are shallow, so this does not work. Fortunately, the lifetime of these tokens is easy to understand. A token list for "replacements" is created and stored in a hash table when a function-like macro is defined. This list will live until the macro is #undefed (if ever). Meanwhile, a shallow copy of the list is created when the macro is used and the list expanded. This copy is short-lived, so is unsuitable as a new parent. So we can just let the original, longer-lived owner continue to own the underlying objects and things will work. This fixes bug #45082: "ralloc.c:78: get_header: Assertion `info->canary == 0x5A1106' failed." when using a macro in GLSL https://bugs.freedesktop.org/show_bug.cgi?id=45082 Reviewed-by: Kenneth Graunke <[email protected]> NOTE: This is a candidate for stable release branches.
* glsl: Add glcpp tests for a macro used twiceCarl Worth2012-02-022-0/+33
| | | | | | | | | | | | | This test cases exposes a bug as described in this bug report: "ralloc.c:78: get_header: Assertion `info->canary == 0x5A1106' failed." when using a macro in GLSL https://bugs.freedesktop.org/show_bug.cgi?id=45082 Clearly, some memory is getting (incorrectly) freed on the first macro invocation, leading to problems with the second macro invocation. Reviewed-by: Kenneth Graunke <[email protected]>
* glcpp: Fix so that trailing punctuation does not prevent macro expansionCarl Worth2012-02-021-1/+9
| | | | | | | | | | | | | | | | | | | | The trick here is that flex always chooses the rule that matches the most text. So with a input text of "two:" which we want to be lexed as an IDENTIFIER token "two" followed by an OTHER token ":" the previous OTHER rule would match longer as a single token of "two:" which we don't want. We prevent this by forcing the OTHER pattern to never match any characters that appear in other constructs, (no letters, numbers, #, _, whitespace, nor any punctuation that appear in CPP operators). Fixes bug #44764: GLSL preprocessor doesn't replace defines ending with ":" https://bugs.freedesktop.org/show_bug.cgi?id=44764 Reviewed-by: Kenneth Graunke <[email protected]> NOTE: This is a candidate for stable release branches.
* glcpp: Add new test showing bug where a trailing ':' prevents macro expansionCarl Worth2012-02-022-0/+15
| | | | | | | | | | | This demonstrates a bug that was recently triggered in piglit. Here is the original bug report (containing a test case almost identical to this one): https://bugs.freedesktop.org/show_bug.cgi?id=44764 Reviewed-by: Kenneth Graunke <[email protected]>
* Revert "automake: src/glsl and src/glsl/glcpp"Matt Turner2012-01-315-136/+172
| | | | This reverts commit 9947656168d09f9019600fccc42ca8e0de49b83a.
* Revert "src/glsl/glcpp: wire up glcpp-test to make check"Matt Turner2012-01-312-7/+1
| | | | This reverts commit 2bb9f9e1fda61fceb9284cbb4619d7e60e39f190.
* src/glsl/glcpp: wire up glcpp-test to make checkMatt Turner2012-01-302-1/+7
| | | | | | Reviewed-by: Eric Anholt <[email protected]> Tested-by: Eric Anholt <[email protected]> Signed-off-by: Matt Turner <[email protected]>
* glcpp-test: don't return failure if valgrind tests aren't runMatt Turner2012-01-301-1/+1
| | | | | | | | | | | | Success was (tests-passed AND valgrind-tests-passed) but this meant that if the valgrind tests weren't run it would be considered a failure. The logic is now (tests-passed AND (!valgrind OR valgrind-tests-passed)) which lets us return success if the valgrind tests aren't run. Reviewed-by: Eric Anholt <[email protected]> Tested-by: Eric Anholt <[email protected]> Signed-off-by: Matt Turner <[email protected]>
* automake: src/glsl and src/glsl/glcppMatt Turner2012-01-305-172/+136
| | | | | | Reviewed-by: Eric Anholt <[email protected]> Tested-by: Eric Anholt <[email protected]> Signed-off-by: Matt Turner <[email protected]>
* glsl: rename Makefile.sources' _SOURCES variablesMatt Turner2012-01-304-29/+29
| | | | | | | | automake uses variables named *_SOURCES. Reviewed-by: Eric Anholt <[email protected]> Tested-by: Eric Anholt <[email protected]> Signed-off-by: Matt Turner <[email protected]>
* glsl: Rename class variable_entry to ir_variable_refcount_entry.Kenneth Graunke2012-01-304-13/+13
| | | | | | | | | | | | | | | | | | | Exporting a publicly visible class with a generic name like "variable_entry" via ir_variable_refcount.h is kind of mean. Many IR transformers would like to define their own "variable_entry" class. If they accidentally include this header, the compiler/linker may get confused and try to instantiate the wrong variable_entry class, leading to bizarre runtime crashes. The hope is that renaming this one will allow .cpp files to safely declare and use their own file-scope "variable_entry" classes. This avoids crashes caused by converting src/glsl to automake. Signed-off-by: Kenneth Graunke <[email protected]> Reviewed-and-tested-by: Matt Turner <[email protected]> Reviewed-by: Eric Anholt <[email protected]>
* mesa: Add a flag for forcing all GLSL extensions to "warn".Eric Anholt2012-01-301-0/+3
| | | | | NOTE: This is a candidate for the 8.0 branch. Reviewed-by: Kenneth Graunke <[email protected]>
* glsl: Don't use newlocale on HaikuAlexander von Gluck2012-01-241-1/+2
| | | | | | NOTE: This is a candidate for the 8.0 branch. Signed-off-by: Brian Paul <[email protected]>
* glsl: Fix 'control reaches end of non-void function' warning.Vinson Lee2012-01-201-2/+2
| | | | | | | | | | | | | Fix this GCC warning on non-debug builds. glsl_types.cpp: In member function 'gl_texture_index glsl_type::sampler_index() const': glsl_types.cpp:157: warning: control reaches end of non-void function NOTE: This is a candidate for the 8.0 branch. Signed-off-by: Vinson Lee <[email protected]> Reviewed-by: Chad Versace <[email protected]> Reviewed-by: Kenneth Graunke <[email protected]>
* mesa: allocate transform_feedback_info::Outputs array dynamicallyChristoph Bumiller2012-01-201-24/+40
| | | | | | | | | | | | The nvc0 gallium driver is advertising 128 MAX_INTERLEAVED_COMPS which made it always assert in the linker when TFB was used since the Outputs array was smaller than that maximum. v2: added assertions NOTE: This is a candidate for the 8.0 branch. Reviewed-by: Paul Berry <[email protected]>
* glsl: Fix isinf() for non-C99-compliant compilers.Paul Berry2012-01-191-14/+22
| | | | | | | | | | | | | | | | | | Commit ede60bc4670a8d9c14921c77abee1ac57fc0e6bf (glsl: Add isinf() and isnan() builtins) uses "+INF" in the .ir file to represent infinity. This worked on C99-compliant compilers, since the s-expression reader uses strtod() to read numbers, and C99 requires strtod() to understand "+INF". However, it didn't work on non-C99-compliant compilers such as MSVC. This patch modifies the s-expression reader to explicitly check for "+INF" rather than relying on strtod() to support it. This is a candidate for the 8.0 branch. Bugzilla: https://bugs.freedesktop.org/show_bug.cgi?id=44767 Tested-by: Morgan Armand <[email protected]> Reviewed-by: Kenneth Graunke <[email protected]>
* glsl: Fix leak of linked uniform names at relink/free of the shader_program.Eric Anholt2012-01-181-1/+1
| | | | NOTE: This is a candidate for the 8.0 branch.
* glsl: Fix leak of LinkedTransformFeedback.Varyings.Eric Anholt2012-01-181-1/+1
| | | | | | | | I copy-and-pasted the thing I was allocating for as the context, so the first time it would be NULL (root of a ralloc context) and they'd chain off each other from then on. NOTE: This is a candidate for the 8.0 branch.
* linker: Calculate used samplers and shadow samplers in the linkerIan Romanick2012-01-111-1/+44
| | | | | | | | | | | | It used to be done in ir_to_mesa, and that was kind of a bad place. I didn't change st_glsl_to_tgsi because there is some strange stuff happening in the code that generates glDrawPixels shaders. It looked like this would break horribly if I touched anything. Signed-off-by: Ian Romanick <[email protected]> Reviewed-by: Eric Anholt <[email protected]> Reviewed-by: Kenneth Graunke <[email protected]>
* linker: Calculate the sampler to texture target mapping during linkingIan Romanick2012-01-111-1/+14
| | | | | | | | | Track the calculated data in gl_shader_program instead of the individual assembly shaders. Signed-off-by: Ian Romanick <[email protected]> Reviewed-by: Eric Anholt <[email protected]> Reviewed-by: Kenneth Graunke <[email protected]>
* glsl: Add glsl_type::sampler_indexIan Romanick2012-01-112-0/+35
| | | | | | Signed-off-by: Ian Romanick <[email protected]> Reviewed-by: Eric Anholt <[email protected]> Reviewed-by: Kenneth Graunke <[email protected]>
* mesa: Move transform feedback error check to reduce array overflow risk.Paul Berry2012-01-111-20/+32
| | | | | | | | | | | | | | | | | | | | | | | | | Previous to this patch, we didn't do the limit check for MAX_TRANSFORM_FEEDBACK_INTERLEAVED_COMPONENTS until the end of the store_tfeedback_info() function, *after* storing all of the transform feedback info in the gl_transform_feedback_info::Outputs array. This meant that the limit check wouldn't prevent us from overflowing the array and corrupting memory. This patch moves the limit check to the top of tfeedback_decl::store() so that there is no risk of overflowing the array. It also adds assertions to verify that the checks for MAX_TRANSFORM_FEEDBACK_INTERLEAVED_COMPONENTS and MAX_TRANSFORM_FEEDBACK_SEPARATE_COMPONENTS are sufficient to avoid array overflow. Note: strictly speaking this patch isn't necessary, since the maximum possible number of varyings is MAX_VARYING (16), whereas the size of the Outputs array is MAX_PROGRAM_OUTPUTS (64), so it's impossible to have enough varyings to overflow the array. However it seems prudent to do the limit check before the array access in case these limits change in the future. Reviewed-by: Ian Romanick <[email protected]>
* mesa: Fix transform feedback of unsubscripted gl_ClipDistance array.Paul Berry2012-01-111-33/+56
| | | | | | | | | | | | | | | | | | | | | On drivers that set gl_shader_compiler_options::LowerClipDistance (for example i965), we need to handle transform feedback of gl_ClipDistance specially, to account for the fact that the hardware represents it as an array of vec4's rather than an array of floats. The previous way this was accounted for (translating the request for gl_ClipDistance[n] to a request for a component of gl_ClipDistanceMESA[n/4]) doesn't work when performing transform feedback on the whole unsubscripted array, because we need to keep track of the size of the gl_ClipDistance array prior to the lowering pass. So I replaced it with a boolean is_clip_distance_mesa, which switches on the special logic that is needed to handle the lowered version of gl_ClipDistance. Fixes Piglit tests "EXT_transform_feedback/builtin-varyings gl_ClipDistance[{1,2,3,5,6,7}]-no-subscript". Reviewed-by: Eric Anholt <[email protected]>