summaryrefslogtreecommitdiff
path: root/src/glsl/ir.h
AgeCommit message (Collapse)Author
2011-03-14glsl: Explicitly specify a type when reading/printing ir_texture.Kenneth Graunke
This is necessary for GLSL 1.30+ shadow sampling functions, which return a single float rather than splatting the value to a vec4 based on GL_DEPTH_TEXTURE_MODE.
2011-02-21Use C-style system headers in C++ code to avoid issues with std:: namespaceIan Romanick
2011-01-31glsl: Introduce a new "const_in" variable mode.Kenneth Graunke
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.
2011-01-31glsl: Change texel offsets to a single vector rvalue.Kenneth Graunke
Having these as actual integer values makes it difficult to implement the texture*Offset built-in functions, since the offset is actually a function parameter (which doesn't have a constant value). The original rationale was that some hardware needs these offset baked into the instruction opcode. However, at least i965 should be able to support non-constant offsets. Others should be able to rely on inlining and constant propagation.
2011-01-31Convert everything from the talloc API to the ralloc API.Kenneth Graunke
2011-01-26glsl: Propagate depth layout qualifier from AST to IRChad Versace
2011-01-26glsl: Define enum ir_depth_layoutChad Versace
2011-01-15Merge branch 'draw-instanced'Brian Paul
Conflicts: src/gallium/auxiliary/draw/draw_llvm.c src/gallium/drivers/llvmpipe/lp_state_fs.c src/glsl/ir_set_program_inouts.cpp src/mesa/tnl/t_vb_program.c
2011-01-12glsl: Track variable usage, use that to enforce semanticsIan Romanick
In particular, variables cannot be redeclared invariant after being used. Fixes piglit test invariant-05.vert and bugzilla #29164. NOTE: This is a candidate for the 7.9 and 7.10 branches.
2011-01-01glsl: Remove unused "instructions" parameter.Kenneth Graunke
I think was used long ago, when we actually read the builtins into the shader's instruction stream directly, rather than creating a separate shader and linking the two. It doesn't seem to serve any purpose now.
2010-12-08glsl: add support for system values and GL_ARB_draw_instancedBrian Paul
2010-11-30glsl: Refactor out cloning of function prototypes.Kenneth Graunke
This allows us to reuse some code and will be useful later.
2010-11-30glsl: Add a helper constructor for expressions that works out result type.Eric Anholt
This doesn't cover all expressions or all operand types, but it will complain if you overreach and it allows for much greater slack on the programmer's part.
2010-11-25glsl: Add a virtual as_discard() method.Kenneth Graunke
NOTE: This is candidate for the 7.9 branch.
2010-11-19glsl: Add a helper function for determining if an rvalue could be a saturate.Eric Anholt
Hardware pretty commonly has saturate modifiers on instructions, and this can be used in codegen to produce those, without everyone else needing to understand clamping other than min and max.
2010-11-19glsl: Add ir_quadop_vector expressionIan Romanick
The vector operator collects 2, 3, or 4 scalar components into a vector. Doing this has several advantages. First, it will make ud-chain tracking for components of vectors much easier. Second, a later optimization pass could collect scalars into vectors to allow generation of SWZ instructions (or similar as operands to other instructions on R200 and i915). It also enables an easy way to generate IR for SWZ instructions in the ARB_vertex_program assembler.
2010-11-19glsl: Add unary ir_expression constructorIan Romanick
2010-11-19glsl: Add ir_rvalue::is_negative_one predicateIan Romanick
2010-11-19glsl: Add ir_unop_sin_reduced and ir_unop_cos_reducedIan Romanick
The operate just like ir_unop_sin and ir_unop_cos except that they expect their inputs to be limited to the range [-pi, pi]. Several GPUs require this limited range for their sine and cosine instructions, so having these as operations (along with a to-be-written lowering pass) helps this architectures. These new operations also matche the semantics of the GL_ARB_fragment_program SCS instruction. Having these as operations helps in generating GLSL IR directly from assembly fragment programs.
2010-11-18glsl: Make is_zero and is_one virtual methods of ir_rvalueIan Romanick
This eliminates the need in some cames to validate that an rvalue is an ir_constant before checking to see if it's 0 or 1.
2010-11-17glsl: Refactor get_num_operands.Kenneth Graunke
This adds sentinel values to the ir_expression_operation enum type: ir_last_unop, ir_last_binop, and ir_last_opcode. They are set to the previous one so they don't trigger "unhandled case in switch statement" warnings, but should never be handled directly. This allows us to remove the huge array of 1s and 2s in ir_expression::get_num_operands().
2010-11-17glsl: Remove the ir_binop_cross opcode.Kenneth Graunke
2010-11-16glsl: Refactor is_vec_{zero,one} to be methods of ir_constantIan Romanick
These predicates will be used in other places soon.
2010-10-29glsl: Remove unused ARRAY_SIZE macro.Kenneth Graunke
It's also equivalent to Elements(...) which is already used elsewhere.
2010-10-14glsl: Add a new ir_unop_round_even opcode for GLSL 1.30's roundEven.Kenneth Graunke
Also, update ir_to_mesa's "1.30 is unsupported" case to "handle" it.
2010-10-08glsl: Track explicit location in AST to IR translationIan Romanick
2010-09-22glsl: Rework assignments with write_masks to have LHS chan count match RHS.Eric Anholt
It turns out that most people new to this IR are surprised when an assignment to (say) 3 components on the LHS takes 4 components on the RHS. It also makes for quite strange IR output: (assign (constant bool (1)) (x) (var_ref color) (swiz x (var_ref v) )) (assign (constant bool (1)) (y) (var_ref color) (swiz yy (var_ref v) )) (assign (constant bool (1)) (z) (var_ref color) (swiz zzz (var_ref v) )) But even worse, even we get it wrong, as shown by this line of our current step(float, vec4): (assign (constant bool (1)) (w) (var_ref t) (expression float b2f (expression bool >= (swiz w (var_ref x))(var_ref edge)))) where we try to assign a float to the writemasked-out x channel and don't supply anything for the actual w channel we're writing. Drivers right now just get lucky since ir_to_mesa spams the float value across all the source channels of a vec4. Instead, the RHS will now have a number of components equal to the number of components actually being written. Hopefully this confuses everyone less, and it also makes codegen for a scalar target simpler. Reviewed-by: Kenneth Graunke <kenneth@whitecape.org> Reviewed-by: Ian Romanick <ian.d.romanick@intel.com>
2010-09-20glsl: Add comments to clarify the types of comparison binops.Kenneth Graunke
2010-09-20glsl: Add doxygen commentsIan Romanick
2010-09-16glsl: Change from has_builtin_signature to has_user_signature.Kenneth Graunke
The print visitor needs this, and the only existing user can work with has_user_signature just as well.
2010-09-13glsl: introduce ir_binop_all_equal and ir_binop_any_equal, allow vector cmpsLuca Barbieri
Currently GLSL IR forbids any vector comparisons, and defines "ir_binop_equal" and "ir_binop_nequal" to compare all elements and give a single bool. This is highly unintuitive and prevents generation of optimal Mesa IR. Hence, first rename "ir_binop_equal" to "ir_binop_all_equal" and "ir_binop_nequal" to "ir_binop_any_nequal". Second, readd "ir_binop_equal" and "ir_binop_nequal" with the same semantics as less, lequal, etc. Third, allow all comparisons to acts on vectors. Signed-off-by: Ian Romanick <ian.d.romanick@intel.com>
2010-09-09glsl2: Add ir_unop_noiseIan Romanick
2010-09-07glsl: Move is_builtin flag back to ir_function_signature.Kenneth Graunke
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.
2010-09-03ir_expression: Add static operator_string methodIan Romanick
I've used this in quite a few debug commits that never reached an up-stream tree.
2010-09-03glsl2: Add cmp field to ir_loopIan Romanick
This reprents the type of comparison between the loop induction variable and the loop termination value.
2010-08-26glsl: Move is_built_in flag from ir_function_signature to ir_function.Kenneth Graunke
Also rename it to "is_builtin" for consistency. Signed-off-by: Ian Romanick <ian.d.romanick@intel.com>
2010-08-23mesa: Add new ir_unop_any() expression operation.Eric Anholt
The previous any() implementation would generate arg0.x || arg0.y || arg0.z. Having an expression operation for this makes it easy for the backend to generate something easier (DPn + SNE for 915 FS, .any predication on 965 VS)
2010-08-14glsl: Standardize a few more uses of struct vs class keyword.José Fonseca
2010-08-11glsl2: remove trailing comma to silence warningBrian Paul
2010-08-06glsl2: Move gl_program->InputsRead/OutputsWritten setting to an ir pass.Eric Anholt
This lets us handle arrays much better than trying to work backwards from assembly. Fixes fbo-drawbuffers-maxtargets on swrast (i965 needs loop unrolling)
2010-08-05glsl2: Add a pass to convert exp and log to exp2 and log2.Eric Anholt
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
2010-08-05glsl2: Don't dead-code eliminate a call where the return value is unused.Eric Anholt
This showed up since the disabling of inlining at compile time, which I apparently didn't regenerate piglit summary for. Fixes: glsl-deadcode-call.
2010-08-05glsl2: Add a pass for removing unused functions.Eric Anholt
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%).
2010-08-04glsl2: Remove the shader_in/shader_out tracking separate from var->mode.Eric Anholt
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.
2010-08-04glsl2: Add ir_assignment::write_mask and associated methodsIan Romanick
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.
2010-08-04glsl2: Make the clone() method take a talloc context.Eric Anholt
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.
2010-08-04glsl2: Set ir_discard::ir_type when cloning itAras Pranckevicius
Fixes unset ir_type after inlining.
2010-07-28glsl2: Add new ir_constant::zero static method.Kenneth Graunke
This conveniently creates a zero value of whatever type you want.
2010-07-28glsl2: Add support for redeclaring layout of gl_FragCoord for ARB_fcc.Eric Anholt
Fixes: glsl-arb-fragment-coord-conventions
2010-07-27glsl2: Add optimization pass for algebraic simplifications.Eric Anholt
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).