summaryrefslogtreecommitdiffstats
path: root/src/glsl/linker.cpp
Commit message (Collapse)AuthorAgeFilesLines
* 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.
* glsl2: Actually use the linked dead code eliminator.Eric Anholt2010-07-271-1/+1
| | | | | | I managed to revert the change from unlinked at some point while cleaning up the changes. glsl-fs-raytrace-bug27060 drops from 389 instructions to 370.
* glsl2: Use ir_dead_code's linked version after linking.Eric Anholt2010-07-271-3/+1
| | | | | glsl-fs-raytrace-bug27060 goes from 485 Mesa IR instructions to 389 before Mesa IR optimization.
* Merge remote branch 'origin/master' into glsl2Eric Anholt2010-07-261-1/+1
| | | | | | | | | | | This pulls in multiple i965 driver fixes which will help ensure better testing coverage during development, and also gets past the conflicts of the src/mesa/shader -> src/mesa/program move. Conflicts: src/mesa/Makefile src/mesa/main/shaderapi.c src/mesa/main/shaderobj.h
* linker: Link built-in functions instead of including them in every shaderIan Romanick2010-07-211-1/+22
| | | | | | | | This is an invasive set of changes. Each user shader tracks a set of other shaders that contain built-in functions. During compilation, function prototypes are imported from these shaders. During linking, the shaders are linked with these built-in-function shaders just like with any other shader.
* linker: Do post-link lowering and optimizationIan Romanick2010-07-201-0/+38
| | | | The lowering code should probably be moved elsewhere.
* glsl2: Add and use new variable mode ir_var_temporaryIan Romanick2010-07-201-6/+44
| | | | | | | | | | | | | | | | | This is quite a large patch because breaking it into smaller pieces would result in the tree being intermitently broken. The big changes are: * Add the ir_var_temporary variable mode * Change the ir_variable constructor to take the mode as a parameter and correctly specify the mode for all ir_varables. * Change the linker to not cross validate ir_var_temporary variables. * Change the linker to pull all ir_var_temporary variables from global scope into 'main'.
* linker: Remove the FINISHME comment for intrastage linkingIan Romanick2010-07-191-1/+2
|
* linker: Remove redundant check for 'main' in shadersIan Romanick2010-07-191-10/+0
| | | | This is now handled in link_intrastage_shaders.
* linker: Track and validate GLSL versions used in shadersIan Romanick2010-07-191-0/+21
|
* linker: Add comment about bug in initializer handlingIan Romanick2010-07-191-0/+8
|
* linker: First bits of intrastage, intershader function linkingIan Romanick2010-07-191-0/+2
| | | | | | This handles the easy case of linking a function in a different compilation unit that doesn't call any functions or reference any global variables.
* linker: Remove some unnecessary includesIan Romanick2010-07-191-2/+0
|
* linker: Use foreach_list_safe in move_non_declarationsIan Romanick2010-07-191-1/+1
| | | | | | The node being processed may be removed from the list and put in a different list. Not using the safe version caused list processing to change streams after moving a node.
* linker: Move global instructions from the linked shader firstIan Romanick2010-07-191-4/+8
| | | | | | For the shader containing 'main', use the linked shader (i.e., the clone of the original shader that contained main) as the source for global instructions to move into main.
* glsl2: When linking makes a variable not a varying output, make it ir_var_auto.Eric Anholt2010-07-131-1/+4
| | | | | This almost fixes glsl-unused-varying, except that the used varying gets assigned to the first varying slot (position).
* glsl2: Remove unnecessary casts of clone return valuesIan Romanick2010-07-131-2/+1
|
* linker: Merge global-scope instructions into mainIan Romanick2010-07-121-0/+121
| | | | | | | | Find instructions in all shaders that are not contained in a function (i.e., initializers for global variables). "Move" these instructions to the top of the main function in the linked shader. As a side-effect, many global variables will also be copied into the linked shader.
* linker: Detect the shader that contains "main" during intrastage linkingIan Romanick2010-07-121-5/+45
|
* linker: Implement first bits of intrastage linkingIan Romanick2010-07-121-2/+58
| | | | | | | This currently involves an ugly hack so that every link doesn't result in all the built-in functions showing up as multiply defined. As soon as the built-in functions are stored in a separate compilation unit, ir_function_signature::is_built_in can be removed.
* linker: Refactor cross_validate_uniforms into cross_validate_globalsIan Romanick2010-07-121-13/+54
| | | | The later, more generic function will be used in the intra-stage linker.
* linker: Stub-out intrastage linkerIan Romanick2010-07-121-14/+67
|
* linker: Use bit-0 instead of VERT_BIT_GENERIC0Ian Romanick2010-07-071-1/+1
| | | | | | Uses of the bits for allocation are offset by 16, and VERT_BIT_GENERIC0 already has the 16 offset. As a result, it was preventing the wrong thing from being allocated.
* glsl2: Allow a fragment shader to not write a color.Eric Anholt2010-06-301-6/+0
| | | | | | I can't find any text justifying this check, and it caused a reasonable-looking shader in glsl-bug-22603 (which writes only gl_FragDepth) to fail.
* linker: Don't dynamically allocate slots for linked shadersIan Romanick2010-06-301-2/+0
| | | | | The can be at most one shader per stage. There are currently only two stages. There is zero reason to dynamically size this array.
* linker: Don't automatically allocate VERT_ATTRIB_GENERIC0Ian Romanick2010-06-301-0/+6
|