aboutsummaryrefslogtreecommitdiffstats
path: root/src/glsl/ir.h
Commit message (Collapse)AuthorAgeFilesLines
* glsl2: Don't dead-code eliminate a call where the return value is unused.Eric Anholt2010-08-051-0/+3
| | | | | | | | This showed up since the disabling of inlining at compile time, which I apparently didn't regenerate piglit summary for. Fixes: glsl-deadcode-call.
* glsl2: Add a pass for removing unused functions.Eric Anholt2010-08-051-1/+0
| | | | | | | | | 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-10/+4
| | | | | | | | | | | | | | | 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: Add ir_assignment::write_mask and associated methodsIan Romanick2010-08-041-1/+43
| | | | | | | | | | | | | | | | | | | | | | | Replace swizzles on the LHS with additional swizzles on the RHS and a write mask in the assignment instruction. As part of this add ir_assignment::set_lhs. Ideally we'd make ir_assignment::lhs private to prevent erroneous writes, but that would require a lot of code butchery at this point. Add ir_assignment constructor that takes an explicit write mask. This is required for ir_assignment::clone, but it can also be used in other places. Without this, ir_assignment clones lose their write masks, and incorrect IR is generated in optimization passes. Add ir_assignment::whole_variable_written method. This method gets the variable on the LHS if the whole variable is written or NULL otherwise. This is different from ir->lhs->whole_variable_referenced() because the latter has no knowledge of the write mask stored in the ir_assignment. Gut all code from ir_to_mesa that handled swizzles on the LHS of assignments. There is probably some other refactoring that could be done here, but that can be left for another day.
* glsl2: Make the clone() method take a talloc context.Eric Anholt2010-08-041-21/+26
| | | | | | | 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: Set ir_discard::ir_type when cloning itAras Pranckevicius2010-08-041-0/+1
| | | | Fixes unset ir_type after inlining.
* glsl2: Add new ir_constant::zero static method.Kenneth Graunke2010-07-281-0/+5
| | | | This conveniently creates a zero value of whatever type you want.
* glsl2: Add support for redeclaring layout of gl_FragCoord for ARB_fcc.Eric Anholt2010-07-281-0/+4
| | | | | Fixes: glsl-arb-fragment-coord-conventions
* glsl2: Add optimization pass for algebraic simplifications.Eric Anholt2010-07-271-0/+8
| | | | | | This cleans up the assembly output of almost all the non-logic tests glsl-algebraic-*. glsl-algebraic-pow-two needs love (basically, flattening to a temporary and squaring it).
* glsl2: Initialize ir_instruction::type and ir_rvalue::type.Kenneth Graunke2010-07-221-4/+2
| | | | | | | | | | | Top-level instructions now get NULL as their default type (since type is irrelevant for things like ir_function), while ir_rvalues get error_type by default. This should make it easier to tell if we've forgotten to set a type. It also fixes some "Conditional jump or move depends on uninitialized value" errors in valgrind caused by ir_validate examining the type of top level ir_instructions, which weren't set.
* glsl2: Make ir_assignment derive from ir_instruction, not ir_rvalue.Kenneth Graunke2010-07-221-1/+1
| | | | | | Assignments can only exist at the top level instruction stream; the residual value is handled by assigning the value to a temporary and returning an ir_dereference_variable of that temporary.
* glsl2: Extend ir_constant to store constant arrays, and generate them.Kenneth Graunke2010-07-211-0/+6
| | | | | | | | | Since GLSL permits arrays of structures, we need to store each element as an ir_constant*, not just ir_constant_data. Fixes parser tests const-array-01.frag, const-array-03.frag, const-array-04.frag, const-array-05.frag, though 03 and 04 generate the wrong code.
* linker: Link built-in functions instead of including them in every shaderIan Romanick2010-07-211-0/+3
| | | | | | | | 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.
* glsl2: Add function to import function prototypes from one IR tree to anotherIan Romanick2010-07-211-0/+6
|
* glsl2: Implement utility routine to talloc reparent an IR treeIan Romanick2010-07-201-0/+3
|
* glsl2: Add and use new variable mode ir_var_temporaryIan Romanick2010-07-201-2/+3
| | | | | | | | | | | | | | | | | 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'.
* ir_constant_expression: Convert from a visitor to a virtual function.Kenneth Graunke2010-07-201-2/+20
| | | | | | | | | The constant_expression_wrapper was already the only external API, and much of the internal code used it anyway. Also, it wouldn't ever visit non-rvalue ir_instructions, so using a visitor seemed a bit unnecessary. This uses "ir_foo *ir = this;" lines to avoid code churn. These should be removed.
* glsl2: Move constant_expression_value method to ir_rvalue.Kenneth Graunke2010-07-201-2/+2
| | | | | This prevents top-level callers from asking for the value of something that is guaranteed not to have one.
* glsl2: Explicitly walk lists in ir_function::parameter_lists_matchIan Romanick2010-07-191-2/+2
| | | | | | Give ir_function::parameter_lists_match_exist similar treatment. Make the parameters const, and propogate the constness as far as it will trivially go.
* ir_function_signature: Make actual_parameters publicIan Romanick2010-07-191-3/+3
|
* glsl2: Give IR nodes a type field.Eric Anholt2010-07-191-8/+34
| | | | | | | This is a big deal for debugging if nothing else ("what class is this ir_instruction, really?"), but is also nice for avoiding building a whole visitor or an if (node->as_whatever() || node->as_other_thing()) chain.
* glsl2: Remove the const disease from function signature's callee.Eric Anholt2010-07-181-4/+4
|
* glsl2: Make cross() be an expression operation.Eric Anholt2010-07-181-0/+1
| | | | | | ARB_fp, ARB_vp, Mesa IR, and the 965 vertex shader all have instructions for cross. Shaves 12 Mesa instructions off of a 66-instruction shader I have.
* glsl2: Remove ir_program bong hits.Kenneth Graunke2010-07-141-4/+0
|
* ir_function: Make matching_signature not return constIan Romanick2010-07-121-1/+1
| | | | | | | The linker needs to use this function to get specific function signatures, but it also needs to modify the returned signature. Since this method isn't itself const (i.e., const this pointer), there is no value in making a const and non-const version.
* linker: Implement first bits of intrastage linkingIan Romanick2010-07-121-0/+3
| | | | | | | 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.
* ir_function_signature: Add method to get the function owning a signatureIan Romanick2010-07-121-4/+21
| | | | | | | | | There is no setter function, the getter returns a constant pointer, and ir_function_signature::_function is private for a reason. The only way to make a connection between a function and function signature is via ir_function::add_signature. This helps ensure that certain invariants (i.e., a function signature is in the list of signatures for its _function) are met.
* glsl2: Add utility function clone_ir_listIan Romanick2010-07-121-0/+9
|
* ir_call: Add method to set the function signature being calledIan Romanick2010-07-121-0/+5
|
* glsl2: Add a new pass at the IR level to break down matrix ops to vector ops.Eric Anholt2010-07-121-0/+6
| | | | | | | This will be used by the Mesa IR and likely most HW backends, as it allows other optimizations to occur that might not otherwise. Fixes glsl-vs-mat-sub-1, glsl-vs-mat-div-1.
* glsl2: Clone methods return the type of the thing being clonedIan Romanick2010-07-061-17/+21
| | | | This is as opposed to returning the type of the base class of the hierarchy.
* glsl2: Add a pass to convert mod(a, b) to b * fract(a/b).Eric Anholt2010-07-011-0/+9
| | | | This is used by the Mesa IR backend to implement mod, fixing glsl-fs-mod.
* glsl2: Add ir_unop_fract as an expression type.Eric Anholt2010-07-011-0/+1
| | | | | Most backends will prefer seeing this to seeing (a - floor(a)), so represent it explicitly.
* glsl2: Define new ir_discard instruction.Kenneth Graunke2010-06-301-0/+27
|
* ir_to_mesa: Start adding support for texture instructions.Eric Anholt2010-06-291-0/+6
| | | | | | | Fixes: glsl-fs-bug25902 glsl-fs-sampler-numbering glsl-lod-bias
* ir_swizzle: Add new constructor, refactor constructorsIan Romanick2010-06-291-0/+11
| | | | | Adds a new constructor that takes an array of component values. Refactors the meat of the two constructors to an init_mask method.
* glsl2: Move the compiler to the subdirectory it will live in in Mesa.Eric Anholt2010-06-241-0/+1178