aboutsummaryrefslogtreecommitdiffstats
path: root/src/glsl/ir_print_visitor.cpp
Commit message (Collapse)AuthorAgeFilesLines
* glsl: add support for ARB_texture_multisampleChris Forbes2013-03-021-1/+4
| | | | | | | | | | | | | | | | | | V2: - emit `sample` parameter properly for multisample texelFetch() - fix spurious whitespace change - introduce a new opcode ir_txf_ms rather than overloading the existing ir_txf further. This makes doing the right thing in the driver somewhat simpler. V3: - fix weird whitespace V4: - don't forget to include the new opcode in tex_opcode_strs[] (thanks Kenneth for spotting this) Signed-off-by: Chris Forbes <[email protected]> [V2] Reviewed-by: Eric Anholt <[email protected]> [V2] Reviewed-by: Paul Berry <[email protected]> Reviewed-by: Ian Romanick <[email protected]>
* glsl: Eliminate ambiguity between function ins/outs and shader ins/outsPaul Berry2013-01-241-1/+2
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | This patch replaces the three ir_variable_mode enums: - ir_var_in - ir_var_out - ir_var_inout with the following five: - ir_var_shader_in - ir_var_shader_out - ir_var_function_in - ir_var_function_out - ir_var_function_inout This eliminates a frustrating ambiguity: it used to be impossible to tell whether an ir_var_{in,out} variable was a shader in/out or a function in/out without seeing where the variable was declared in the IR. This complicated some optimization and lowering passes, and would have become a problem for implementing varying structs. In the lisp-style serialization of GLSL IR to strings performed by ir_print_visitor.cpp and ir_reader.cpp, I've retained the names "in", "out", and "inout" for function parameters, to avoid introducing code churn to the src/glsl/builtins/ir/ directory. Note: a couple of comments in the code seemed to indicate that we were planning for a possible future in which geometry shaders could have shader-scope inout variables. Our GLSL grammar rejects shader-scope inout variables, and I've been unable to find any evidence in the GLSL standards documents (or extensions) that this will ever be allowed, so I've eliminated these comments. Reviewed-by: Carl Worth <[email protected]> Reviewed-by: Jordan Justen <[email protected]> Reviewed-by: Eric Anholt <[email protected]>
* glsl: Convert ir_call to be a statement rather than a value.Kenneth Graunke2012-04-021-1/+4
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | Aside from ir_call, our IR is cleanly split into two classes: - Statements (typeless; used for side effects, control flow) - Values (deeply nestable, pure, typed expression trees) Unfortunately, ir_call confused all this: - For void functions, we placed ir_call directly in the instruction stream, treating it as an untyped statement. Yet, it was a subclass of ir_rvalue, and no other ir_rvalue could be used in this way. - For functions with a return value, ir_call could be placed in arbitrary expression trees. While this fit naturally with the source language, it meant that expressions might not be pure, making it difficult to transform and optimize them. To combat this, we always emitted ir_call directly in the RHS of an ir_assignment, only using a temporary variable in expression trees. Many passes relied on this assumption; the acos and atan built-ins violated it. This patch makes ir_call a statement (ir_instruction) rather than a value (ir_rvalue). Non-void calls now take a ir_dereference of a variable, and store the return value there---effectively a call and assignment rolled into one. They cannot be embedded in expressions. All expression trees are now pure, without exception. Signed-off-by: Kenneth Graunke <[email protected]> Reviewed-by: Eric Anholt <[email protected]> Reviewed-by: Ian Romanick <[email protected]>
* glsl: Use ir_rvalue to represent generic error_type values.Kenneth Graunke2012-04-021-0/+4
| | | | | | | | | | | | | | | | | | | | | | Currently, ir_call can be used as either a statement (for void functions) or a value (for non-void functions). This is rather awkward, as it's the only class that can be used in both forms. A number of places use ir_call::get_error_instruction() to construct a generic value of error_type. If ir_call is to become a statement, it can no longer serve this purpose. Unfortunately, none of our classes are particularly well suited for this, and creating a new one would be rather aggrandizing. So, this patch introduces ir_rvalue::error_value(), a static method that creates an instance of the base class, ir_rvalue. This has the nice property that you can't accidentally try and access uninitialized fields (as it doesn't have any). The downside is that the base class is no longer abstract. Signed-off-by: Kenneth Graunke <[email protected]> Reviewed-by: Eric Anholt <[email protected]> Reviewed-by: Ian Romanick <[email protected]>
* glsl: Remove pointless uses of glsl_type::get_base_type().Kenneth Graunke2011-10-281-3/+1
| | | | | | | | These are effectively doing type->get_base_type()->base_type, which is equivalent to type->base_type. Just use that, as it's simpler. Signed-off-by: Kenneth Graunke <[email protected]> Reviewed-by: Ian Romanick <[email protected]>
* ir_to_mesa: Move some things outside the 'extern "C"' blocksIan Romanick2011-10-181-3/+0
| | | | | | | | | | | Having a few of these includes or forward declarations inside the 'extern "C"' block can cause problems later. Specifically, it prevents C++ linkage functions from being added to ir_to_mesa.h and makes G++ angry if 'struct foo' is seen both inside and outside an 'extern "C"'. Signed-off-by: Ian Romanick <[email protected]> Reviewed-by: Kenneth Graunke <[email protected]>
* glsl: Add a new ir_txs (textureSize) opcode to ir_texture.Kenneth Graunke2011-08-231-9/+12
| | | | | | | | One unique aspect of TXS is that it doesn't have a coordinate. Signed-off-by: Kenneth Graunke <[email protected]> Reviewed-by: Ian Romanick <[email protected]> Reviewed-by: Dave Airlie <[email protected]>
* glsl: Don't choke when printing an anonymous function parameterIan Romanick2011-07-061-0/+10
| | | | | | | NOTE: This is a candidate for the 7.10 and 7.11 branches. Bugzilla: https://bugs.freedesktop.org/show_bug.cgi?id=38584 Reviewed-by: Kenneth Graunke <[email protected]>
* glsl: fixed printing of structure constants.Paul Berry2011-06-031-1/+1
| | | | | | | | ir_print_visitor::visit(ir_constant *) was failing to index properly into ir->type->fields.structure, so the first field name was being reprinted for every field in the structure. Signed-off-by: Brian Paul <[email protected]>
* glsl: Generate readable unique names at print time.Kenneth Graunke2011-03-251-2/+43
| | | | | | | | | | | | | | | | | | | | Since GLSL IR allows multiple ir_variables to share the same name, we need to generate unique names when printing the IR. Previously, we always used %s@%p, appending the ir_variable's memory address. While this worked, it had two drawbacks: - When there aren't duplicates, the extra "@0x669a3e88" is useless and makes the code harder to read. - Real duplicates were hard to tell apart: channel_expressions@0x6699e3c8 vs. channel_expressions@0x6699ddd8 We now append @2, @3, @4, and so on, but only where necessary to distinguish duplicates. Since we only do this at print time, any performance impact is irrelevant. Signed-off-by: Kenneth Graunke <[email protected]> Reviewed-by: Eric Anholt <[email protected]> Reviewed-by: Ian Romanick <[email protected]>
* glsl: Explicitly specify a type when reading/printing ir_texture.Kenneth Graunke2011-03-141-0/+3
| | | | | | 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.
* Use C-style system headers in C++ code to avoid issues with std:: namespaceIan Romanick2011-02-211-3/+0
|
* glsl: Add using statements for standard library functions.Vinson Lee2011-02-031-0/+3
| | | | | | | | | | | | | Standard library functions in C++ are in the std namespace. When using C++-style header files for the standard library, some compilers, such as Sun Studio, provide symbols only for the std namespace and not for the global namespace. This patch adds using statements for standard library functions. Another option could have been to prepend standard library function calls with 'std::'. This patch fixes several compilation errors with Sun Studio.
* glsl: Introduce a new "const_in" variable mode.Kenneth Graunke2011-01-311-1/+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.
* glsl: Change texel offsets to a single vector rvalue.Kenneth Graunke2011-01-311-1/+9
| | | | | | | | | | | 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.
* glsl: Re-synchronize ir_variable_mode and the printer's string array.Kenneth Graunke2011-01-311-1/+1
| | | | | | Since the introduction of ir_var_system_value, system variables would be printed as "temporary" and temporaries would result in out-of-bounds array access, showing up as garbage in printed IR.
* ir_reader: Make assignment conditions optional.Kenneth Graunke2011-01-121-3/+0
| | | | | You can now simply write (assign (xy) <lhs> <rhs>) instead of the verbose (assign (constant bool (1)) (xy) <lhs> <rhs>).
* ir_print_visitor: Print out constant structure values.Kenneth Graunke2010-12-031-0/+9
| | | | In the form (constant type ((field1 value) (field2 value) ...))
* glsl: Remove anti-built-in hacks from the print visitor.Kenneth Graunke2010-11-301-7/+0
| | | | | Now that we only import built-in signatures that are actually used, printing them is reasonable.
* glsl: Eliminate assumptions about size of ir_expression::operandsIan Romanick2010-11-191-4/+3
| | | | This may grow in the near future.
* glsl: Don't print blank (function ...) headers for built-ins.Kenneth Graunke2010-09-161-0/+3
| | | | Fixes a regression caused when I added my GLSL ES support.
* glsl: Move is_builtin flag back to ir_function_signature.Kenneth Graunke2010-09-071-4/+3
| | | | | | | | | | | 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.
* ir_print_visitor: Print empty else blocks more compactlyIan Romanick2010-09-031-9/+13
|
* glsl: Move is_built_in flag from ir_function_signature to ir_function.Kenneth Graunke2010-08-261-8/+2
| | | | | | Also rename it to "is_builtin" for consistency. Signed-off-by: Ian Romanick <[email protected]>
* glsl2: added casts to silence warningsBrian Paul2010-08-111-4/+4
|
* glsl2: Add ir_assignment::write_mask and associated methodsIan Romanick2010-08-041-1/+13
| | | | | | | | | | | | | | | | | | | | | | | 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: Allow use of _mesa_print_ir without a parse state on hand.Eric Anholt2010-07-291-10/+12
|
* glsl2: When dumping IR for debug, indent nested blocks.Eric Anholt2010-07-291-3/+50
| | | | | No more trying to match parens in my head when looking at the body of a short function containing an if statement.
* glsl2: When dumping IR for debug, skip all the empty builtin prototypes.Eric Anholt2010-07-291-3/+15
|
* ir_print_visitor: Add "temporary" to mode string printing.Kenneth Graunke2010-07-221-1/+2
| | | | | | Variables with mode ir_var_temporary were causing an out of bounds array access and filling my screen with rubbish. I'm not sure if "temporary" is the right thing to print.
* ir_print_visitor: Print out constant arrays.Kenneth Graunke2010-07-211-10/+14
|
* ir_print_visitor: Remove commas between ir_constant's components.Kenneth Graunke2010-07-211-1/+1
| | | | The IR reader does not expect commas.
* glsl2: Define new ir_discard instruction.Kenneth Graunke2010-06-301-0/+14
|
* glsl2: Move the compiler to the subdirectory it will live in in Mesa.Eric Anholt2010-06-241-0/+373