summaryrefslogtreecommitdiffstats
path: root/src/glsl/linker.cpp
Commit message (Collapse)AuthorAgeFilesLines
* mesa: Add a flag to indicate whether a program uses gl_ClipDistance.Paul Berry2011-09-231-1/+4
| | | | | | | | | | | | | | | | | | GLSL 1.30 requires us to use gl_ClipDistance for clipping if the vertex shader contains a static write to it, and otherwise use user-defined clipping planes. Since the driver needs to behave differently in these two cases, we need a flag to record whether the shader has written to gl_ClipDistance. The new flag is called UsesClipDistance. We initially store it in gl_shader_program (since that is the data structure that is available when we check to see whethe gl_ClipDistance was written to), and we later copy it to a flag with the same name in gl_vertex_program, since that is a more convenient place for the driver to access it (in i965, at least). Reviewed-by: Eric Anholt <[email protected]> Tested-by: Brian Paul <[email protected]>
* glsl: Implement a lowering pass for gl_ClipDistance.Paul Berry2011-09-231-0/+3
| | | | | | | | | | | | | | | | | | | In i965 GEN6+ (and I suspect most other hardware), gl_ClipDistance needs to be laid out as a pair of vec4's (the first containing clip distances 0-3, and the second containing clip distances 4-7). However, it is declared in GLSL as an array of 8 floats. This lowering pass acts at the GLSL level, modifying the declaration of gl_ClipDistance so that it is an array of vec4's rather than an array of floats, and renaming it to gl_ClipDistanceMESA. In addition, it modifies all accesses to the array so that they access the appropiate component of one of the vec4's. Since some hardware may not internally represent gl_ClipDistance as a pair of vec4's, this lowering pass is optional. To enable it, set the LowerClipDistance flag in gl_shader_compiler_options to true. Reviewed-by: Kenneth Graunke <[email protected]>
* glsl: Make sure gl_ClipDistance and gl_ClipVertex are not both written.Paul Berry2011-09-081-0/+19
| | | | | | | | | | | | | From section 7.1 (Vertex Shader Special Variables) of the GLSL 1.30 spec: "It is an error for a shader to statically write both gl_ClipVertex and gl_ClipDistance." Fixes piglit test mixing-clip-distance-and-clip-vertex-disallowed.c. Reviewed-by: Kenneth Graunke <[email protected]> Reviewed-by: Ian Romanick <[email protected]>
* glsl: Implement the GL_ARB_conservative_depth extension.Kenneth Graunke2011-08-251-1/+1
| | | | | | | 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: 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]>
* linker: Make linker_{error,warning} generally availableIan Romanick2011-08-021-0/+13
| | | | | | | | | | 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-021-94/+86
| | | | | | | | | | | | 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: Reject shaders that contain static recursionIan Romanick2011-07-201-0/+4
| | | | | | | | | | | | | | | | | | | The GLSL 1.20 and later specs say: "Recursion is not allowed, not even statically. Static recursion is present if the static function call graph of the program contains cycles." Recursion is detected and rejected both a compile-time and at link-time. The complie-time check happens to detect some cases that may be removed by various optimization passes. The spec doesn't seem to allow this, but other vendors (e.g., NVIDIA) appear to only check at link-time after all optimizations. Bugzilla: https://bugs.freedesktop.org/show_bug.cgi?id=33885 Reviewed-by: Paul Berry <[email protected]> Reviewed-by: Eric Anholt <[email protected]> Reviewed-by: Kenneth Graunke <[email protected]>
* glsl: silence warning in linker.cppBrian Paul2011-07-191-1/+1
|
* glsl: use casts to silence warningBrian Paul2011-07-071-1/+1
|
* linker: Assign locations for fragment shader outputIan Romanick2011-07-061-33/+75
| | | | | | | | | | | | | | | | | | | | | Fixes an assertion failure in the piglib out-01.frag ARB_explicit_attrib_location test. The locations set via the layout qualifier in fragment shader were not being applied to the shader outputs. As a result all of these variables still had a location of -1 set. This may need some more work for pre-3.0 contexts. The problem is dealing with generic outputs that lack a layout qualifier. There is no way for the application to specify a location (glBindFragDataLocation is not supported) or query the location assigned by the linker (glGetFragDataLocation is not supported). NOTE: This is a candidate for the 7.10 and 7.11 branches. Bugzilla: https://bugs.freedesktop.org/show_bug.cgi?id=38624 Reviewed-by: Eric Anholt <[email protected]> Cc: Kenneth Graunke <[email protected]> Cc: Vinson Lee <[email protected]>
* 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]>
* glsl: Fix typos in comments.Bryan Cain2011-04-231-6/+6
|
* glsl: Calcluate Mesa state slots in front-end instead of back-endIan Romanick2011-03-291-0/+13
| | | | | | | | | | | | 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]>
* Use C-style system headers in C++ code to avoid issues with std:: namespaceIan Romanick2011-02-211-4/+0
|
* linker: Fix off-by-one error implicit array sizingIan Romanick2011-02-151-1/+1
| | | | | | | | | Arrays are zero based. If the highest element accessed is 6, the array needs to have 7 elements. Fixes piglit test glsl-fs-implicit-array-size-03 and bugzilla #34198. NOTE: This is a candidate for the 7.9 and 7.10 branches.
* linker: Generate link errors when ES shaders are missing stagesIan Romanick2011-02-041-0/+14
| | | | | | ES requires that a vertex shader and a fragment shader be present. Fixes bugzilla #32214.
* glsl: Introduce a new "const_in" variable mode.Kenneth Graunke2011-01-311-0/+1
| | | | | | | | This annotation is for an "in" function parameter for which it is only legal to pass constant expressions. The only known example of this, currently, is the textureOffset functions. This should never be used for globals.
* Convert everything from the talloc API to the ralloc API.Kenneth Graunke2011-01-311-11/+11
|
* glsl: Raise linking error if gl_FragDepth layout is inconsistentChad Versace2011-01-261-0/+26
| | | | | | | | | From the AMD_conservative_depth spec: If gl_FragDepth is redeclared in any fragment shader in a program, it must be redeclared in all fragment shaders in that program that have static assignments to gl_FragDepth. All redeclarations of gl_FragDepth in all fragment shaders in a single program must have the same set of qualifiers.
* linker: Propagate max_array_access while linking functionsIan Romanick2011-01-251-4/+1
| | | | | | | | | Update the max_array_access of a global as functions that use that global are pulled into the linked shader. Fixes piglit test glsl-fs-implicit-array-size-01 and bugzilla #33219. NOTE: This is a candidate for the 7.9 and 7.10 branches.
* linker: Set sizes for non-global arrays as wellIan Romanick2011-01-251-18/+17
| | | | | | | | | Previously only global arrays with implicit sizes would be patched. This causes all arrays that are actually accessed to be sized. Fixes piglit test glsl-fs-implicit-array-size-02. NOTE: This is a candidate for the 7.9 and 7.10 branches.
* glsl, i965: Remove unnecessary talloc includes.Kenneth Graunke2011-01-211-4/+0
| | | | These are already picked up by ir.h or glsl_types.h.
* glsl: At link-time, check that globals have matching centroid qualifiersChad Versace2011-01-101-0/+6
| | | | Fixes bug 31923: http://bugs.freedesktop.org/show_bug.cgi?id=31923
* linker: Allow built-in arrays to have different sizes between shader stagesIan Romanick2010-12-131-8/+29
| | | | Fixes pitlit test glsl-link-varying-TexCoord (bugzilla #31650).
* linker: Fix regressions caused by previous commitIan Romanick2010-12-071-12/+16
| | | | | | | | | That's what I get for not running piglit before pushing. Don't try to patch types of unsized arrays when linking fails. Don't try to patch types of unsized arrays that are shared between shader stages.
* linker: Ensure that unsized arrays have a size after linkingIan Romanick2010-12-071-1/+27
| | | | | | | Fixes piglit test case glsl-vec-array (bugzilla #31908). NOTE: This bug does not affect 7.9, but I think this patch is a candiate for the 7.9 branch anyway.
* glsl: Fix linker bug in cross_validate_globals()Chad Versace2010-12-011-0/+7
| | | | | | Cause linking to fail if a global has mismatching invariant qualifiers. See https://bugs.freedesktop.org/show_bug.cgi?id=30261
* glsl/linker: Free any IR discarded by optimization passes.Kenneth Graunke2010-11-301-4/+19
| | | | | | | | | | | Previously, IR for a linked shader was allocated directly out of the gl_shader object - meaning all of it lived as long as the shader. Now, IR is allocated out of a temporary context, and any -live- IR is reparented/stolen to (effectively) the gl_shader. Any remaining IR can be freed. NOTE: This is a candidate for the 7.9 branch.
* glsl: Make the symbol table's add_variable just use the variable's name.Eric Anholt2010-11-291-4/+4
|
* glsl: Make the symbol table's add_function just use the function's name.Eric Anholt2010-11-291-1/+1
|
* linker: Improve handling of unread/unwritten shader inputs/outputsIan Romanick2010-10-191-11/+25
| | | | | | | | | | | | Previously some shader input or outputs that hadn't received location assignments could slip through. This could happen when a shader contained user-defined varyings and was used with either fixed-function or assembly shaders. See the piglit tests glsl-[fv]s-user-varying-ff and sso-user-varying-0[12]. NOTE: this is a candidate for the 7.9 branch.
* linker: Trivial indention fixIan Romanick2010-10-151-2/+2
|
* glsl: Slightly change the semantic of _LinkedShadersIan Romanick2010-10-141-19/+64
| | | | | | | | | | | | | | | Previously _LinkedShaders was a compact array of the linked shaders for each shader stage. Now it is arranged such that each slot, indexed by the MESA_SHADER_* defines, refers to a specific shader stage. As a result, some slots will be NULL. This makes things a little more complex in the linker, but it simplifies things in other places. As a side effect _NumLinkedShaders is removed. NOTE: This may be a candidate for the 7.9 branch. If there are other patches that get backported to 7.9 that use _LinkedShader, this patch should be cherry picked also.
* linker: Reject shaders that have unresolved function callsIan Romanick2010-10-131-2/+6
| | | | | | | | | | This really amounts to just using the return value from link_function_calls. All the work was being done, but the result was being ignored. Fixes piglit test link-unresolved-funciton. NOTE: this is a candidate for the 7.9 branch.
* Drop GLcontext typedef and use struct gl_context insteadKristian Høgsberg2010-10-131-2/+2
|
* glsl: Add linker support for explicit attribute locationsIan Romanick2010-10-081-1/+32
|
* glsl: Fail linking if assign_attribute_locations failsIan Romanick2010-10-081-1/+3
|
* glsl: Also update implicit sizes of varyings at link time.Eric Anholt2010-09-281-4/+7
| | | | | | Otherwise, we'll often end up with gl_TexCoord being 0 length, for example. With ir_to_mesa, things ended up working out anyway, as long as multiple implicitly-sized arrays weren't involved.
* glsl2: fix typo in error msgBrian Paul2010-09-211-1/+1
|
* glsl: add several EmitNo* options, and MaxUnrollIterationsLuca Barbieri2010-09-081-1/+1
| | | | | | | | | This increases the chance that GLSL programs will actually work. Note that continues and returns are not yet lowered, so linking will just fail if not supported. Signed-off-by: Ian Romanick <[email protected]>
* glsl: Move is_builtin flag back to ir_function_signature.Kenneth Graunke2010-09-071-2/+2
| | | | | | | | | | | This effectively reverts b6f15869b324ae64a00d0fe46fa3c8c62c1edb6c. In desktop GLSL, defining a function with the same name as a built-in hides that built-in function completely, so there would never be built-in and user function signatures in the same ir_function. However, in GLSL ES, overloading built-ins is allowed, and does not hide the built-in signatures - so we're back to needing this.
* linker: Fix assertion and cross-version checks for version 100.Kenneth Graunke2010-09-071-2/+3
| | | | | | Fixes an assert (min_version >= 110) which was no longer correct, and also prohibits linking ES2 shaders with non-ES2 shaders. I'm not positive this is correct, but the specification doesn't seem to say.
* glsl2: check for _NumLinkedShaders being 0Török Edvin2010-09-071-1/+1
| | | | | | | Otherwise spring 0.82+.4.0 crashes when starting a game because prog->_LinkedShaders[0] is NULL. This also fixes piglit test cases glsl-link-empty-prog-0[12].
* linker: Handle varying arrays, matrices, and arrays of matricesIan Romanick2010-08-301-6/+15
| | | | Fixes piglit test case glsl-array-varying-01.
* linker: Treat sized and unsized array types as the sameIan Romanick2010-08-291-6/+20
| | | | | | | | | | If two shaders contain variables declared with array types that have the same base type but one is sized and the other is not, linking should succeed. I'm not super pleased with the way this is implemented, and I am more convinced than ever that we need more linker tests. We especially need "negative" tests. Fixes bugzilla #29697 and piglit test glsl-link-array-01.
* glsl: Move is_built_in flag from ir_function_signature to ir_function.Kenneth Graunke2010-08-261-2/+2
| | | | | | Also rename it to "is_builtin" for consistency. Signed-off-by: Ian Romanick <[email protected]>
* ir_to_mesa: Convert this code to using linker.cpp's uniform locations.Eric Anholt2010-08-251-0/+1
| | | | Fixes: glsl-fs-uniform-array-4.
* glsl: Make uniform linking generate separate uniforms for struct members.Eric Anholt2010-08-251-42/+89
| | | | | This is a step towards making the linker code usable as our uniform setup, instead of having it wedged into ir_to_mesa.cpp.
* glsl: Include main/core.h.Chia-I Wu2010-08-241-4/+1
| | | | Make glsl include only main/core.h from core mesa.