summaryrefslogtreecommitdiffstats
path: root/src/glsl/linker.cpp
Commit message (Collapse)AuthorAgeFilesLines
* 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.
* glsl: Count function call outvals as writing to variables for linker checks.Eric Anholt2010-08-231-0/+21
| | | | Fixes: glsl-vs-position-outval. Bug #28138 (regnum online)
* glsl: Trim the size of uniform arrays to the maximum element used.Eric Anholt2010-08-231-0/+52
| | | | Fixes glsl-getactiveuniform-array-size.
* glsl: Also strdup the names of uniform list entries for >vec4 types.Eric Anholt2010-08-181-1/+1
| | | | Fixes double-free since the fix to free all of the uniform list.
* mesa: Free old linked shaders when relinking new shaders.Eric Anholt2010-08-181-5/+10
|
* linker: Demote user-defined varyings in the VS-only caseIan Romanick2010-08-171-14/+28
| | | | Fixes piglit test case glsl-vs-ff-frag and bugzilla #29623.
* linker: Include compiler.h to avoid spurious warnings about INLINEIan Romanick2010-08-161-0/+1
|
* glsl2: Move the common optimization passes to a helper function.Eric Anholt2010-08-131-41/+6
| | | | | These are passes that we expect all codegen to be happy with. The other lowering passes for Mesa IR are moved to the Mesa IR generator.
* linker: Assign attrib location 0 if gl_Vertex is not usedIan Romanick2010-08-131-1/+36
| | | | | | | If gl_Vertex is not used in the shader, then attribute location 0 is available for use. Fixes piglit test case glsl-getattriblocation (bugzilla #29540).
* glsl2: Add a pass to transform ir_binop_sub to add(op0, neg(op1))Eric Anholt2010-08-091-0/+1
| | | | | | All the current HW backends transform subtract to adding the negation, so I haven't bothered peepholing it back out in Mesa IR. This allows some subtract of subtract to get removed in ir_algebraic.
* glsl2: Add constant propagation.Eric Anholt2010-08-091-0/+1
| | | | | | | | Whereas constant folding evaluates constant expressions at rvalue nodes, constant propagation tracks constant components of vectors across execution to replace (possibly swizzled) variable dereferences with constant values, triggering possible constant folding or reduced variable liveness.
* glsl2: Don't assert in a couple of places when encountering sampler arrays.Eric Anholt2010-08-061-4/+6
| | | | Fixes glean shaderAPI.
* glsl2: Add a pass to convert exp and log to exp2 and log2.Eric Anholt2010-08-051-0/+1
| | | | | | | | | Fixes ir_to_mesa handling of unop_log, which used the weird ARB_vp LOG opcode that doesn't do what we want. This also lets the multiplication coefficients in there get constant-folded, possibly. Fixes: glsl-fs-log
* ir_structure_splitting: New pass to chop structures into their components.Eric Anholt2010-08-051-0/+1
| | | | | | | This doesn't do anything if your structure goes through an uninlined function call or if whole-structure assignment occurs. As such, the impact is limited, at least until we do some global copy propagation to reduce whole-structure assignment.
* glsl2: Add a pass for removing unused functions.Eric Anholt2010-08-051-0/+1
| | | | | | | | | For a shader involving many small functions, this avoids running optimization across all of them after they've been inlined post-linking. Reduces the runtime of linking and running a fragment shader from Yo Frankie from 1.6 seconds to 0.9 seconds (-44.9%, +/- 3.3%).
* glsl2: Remove the shader_in/shader_out tracking separate from var->mode.Eric Anholt2010-08-041-2/+0
| | | | | | | | | | | | | | | I introduced this for ir_dead_code to distinguish function parameter outvals from varying outputs. Only, since ast_to_hir's current_function is unset when setting up function parameters (they're needed for making the function signature in the first place), all function parameter outvals were marked as shader outputs anyway. This meant that an inlined function's cloned outval was marked as a shader output and couldn't be dead-code eliminated. Instead, since ir_dead_code doesn't even look at function parameters, just use var->mode. The longest Mesa IR coming out of ir_to_mesa for Yo Frankie drops from 725 instructions to 636.
* glsl2: Use linked ir_constant_variable after linking, instead of unlinked.Eric Anholt2010-08-041-1/+1
|
* glsl2: Don't try to assign locations for samplers during linking.Eric Anholt2010-08-041-0/+3
| | | | | | Mesa will do the mapping at _mesa_add_sampler() time. Fixes assertion failures in debug builds, which might have caught real problems with multiple samplers linked in a row.
* glsl2: Make the clone() method take a talloc context.Eric Anholt2010-08-041-11/+14
| | | | | | | In most cases, we needed to be reparenting the cloned IR to a different context (for example, to the linked shader instead of the unlinked shader), or optimization before the reparent would cause memory usage of the original object to grow and grow.
* glsl2: Give the path within src/mesa/ for headers instead of relying on -I.Aras Pranckevicius2010-08-021-1/+1
|
* glsl2: Do algebraic optimizations after linking as well.Eric Anholt2010-07-311-0/+1
| | | | | Linking brings in inlining of builtins, so we weren't catching the (rcp(/sqrt(x)) -> rsq(x)) without it.
* glsl2: Add new tree grafting optimization pass.Eric Anholt2010-07-311-0/+1
|
* glsl2: Fix spelling of "sentinel."Eric Anholt2010-07-291-1/+1
|
* glsl2: Fail linking where the FS reads a varying that the VS doesn't write.Eric Anholt2010-07-281-7/+30
| | | | | | Fixes: glsl1-varying read but not written glsl1-varying var mismatch
* glsl2: Unmark unwritten varyings as varying.Eric Anholt2010-07-281-0/+1
| | | | | This fixes an assertion failure in ir_to_mesa, and the varying won't take up varying space.