summaryrefslogtreecommitdiffstats
path: root/src/glsl/ir_reader.cpp
Commit message (Collapse)AuthorAgeFilesLines
* glsl: Convert ir_call to be a statement rather than a value.Kenneth Graunke2012-04-021-7/+25
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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: Split out ir_reader's ability to read ir_dereference_variables.Kenneth Graunke2012-04-021-8/+20
| | | | | | | | | | Most of the time, we just want to read an ir_dereference, so there's no need to have these in separate functions. However, the next patch will want to read an ir_dereference_variable directly. 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-4/+2
| | | | | | | | 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]>
* mesa: Expose GLSL interpolation qualifiers in gl_fragment_program.Paul Berry2011-10-271-3/+3
| | | | | | | | | | | | | | | | | This patch makes GLSL interpolation qualifiers visible to drivers via the array InterpQualifier[] in gl_fragment_program, so that they can easily be used by driver back-ends to select the correct interpolation mode. Previous to this patch, the GLSL compiler was using the enum ir_variable_interpolation to represent interpolation types. Rather than make a duplicate enum in core mesa to represent the same thing, I moved the enum into mtypes.h and renamed it to be more consistent with the other enums defined there. Reviewed-by: Brian Paul <[email protected]> Reviewed-by: Kenneth Graunke <[email protected]> Reviewed-by: Eric Anholt <[email protected]>
* glsl: Free all S-Expressions immediately after reading IR.Kenneth Graunke2011-09-231-2/+3
| | | | | | | | | For some reason I thought subexpressions were chained off the top-level one. This isn't the case, so just create a temporary context and free it. All of this memory would be eventually freed, but now is freed much sooner. Signed-off-by: Kenneth Graunke <[email protected]>
* glsl: s/int/unsigned/ to silence warningBrian Paul2011-09-071-2/+2
|
* glsl/ir_reader: Make sure constants have the right number of components.Kenneth Graunke2011-09-071-0/+5
| | | | | | | | The list of numbers in (constant type (<numbers>)) needs to contain exactly type->components() numbers (16 for a mat4, 3 for a vec3, etc.) Signed-off-by: Kenneth Graunke <[email protected]> Reviewed-by: Ian Romanick <[email protected]>
* glsl: Add a new ir_txs (textureSize) opcode to ir_texture.Kenneth Graunke2011-08-231-15/+22
| | | | | | | | 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: Make ir_reader able to read plain (return) statements.Paul Berry2011-07-081-11/+13
| | | | | | | | | Previously ir_reader was only able to handle return of non-void. This patch is necessary in order to allow optimization passes to be tested in isolation. Reviewed-by: Kenneth Graunke <[email protected]>
* glsl: Explicitly specify a type when reading/printing ir_texture.Kenneth Graunke2011-03-141-4/+13
| | | | | | 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.
* glsl: Introduce a new "const_in" variable mode.Kenneth Graunke2011-01-311-0/+2
| | | | | | | | 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-12/+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.
* Convert everything from the talloc API to the ralloc API.Kenneth Graunke2011-01-311-10/+8
|
* glsl: silence uninitialized var warning in read_texture()Brian Paul2011-01-251-1/+4
| | | | And generate an error if the texture pattern is not matched.
* glsl, i965: Remove unnecessary talloc includes.Kenneth Graunke2011-01-211-4/+0
| | | | These are already picked up by ir.h or glsl_types.h.
* ir_reader: Make assignment conditions optional.Kenneth Graunke2011-01-121-8/+13
| | | | | You can now simply write (assign (xy) <lhs> <rhs>) instead of the verbose (assign (constant bool (1)) (xy) <lhs> <rhs>).
* ir_reader: Convert to a class.Kenneth Graunke2011-01-121-238/+241
| | | | | | | This makes it unnecessary to pass _mesa_glsl_parse_state around everywhere, making at least the prototypes a lot easier to read. It's also more C++-ish than a pile of static C functions.
* ir_reader: Combine the three dereference reading functions into one.Kenneth Graunke2011-01-121-83/+36
| | | | | These used to be more complicated, but now are so simple there's no real point in keeping them separate.
* ir_reader: Relax requirement that function arguments be s_lists.Kenneth Graunke2011-01-121-85/+78
| | | | | | | | | All of these functions used to take s_list pointers so they wouldn't all need SX_AS_LIST conversions and error checking. However, the new pattern matcher conveniently does this for us in one centralized place. So there's no need to insist on s_list. Switching to s_expression saves a bit of code and is somewhat cleaner.
* ir_reader: Remove s_list::length() method.Kenneth Graunke2011-01-121-7/+8
| | | | | Most code now relies on the pattern matcher rather than this function, and for the only remaining case, not using this saves an iteration.
* ir_reader: Add a pattern matching system and use it everywhere.Kenneth Graunke2011-01-121-308/+210
| | | | | | | | | | | | | | | | | | | Previously, the IR reader was riddled with code that: 1. Checked for the right number of list elements (via a linked list walk) 2. Retrieved references to each component (via ->next->next pointers) 3. Downcasted as necessary to make sure that each sub-component was the right type (i.e. symbol, int, list). 4. Checking that the tag (i.e. "declare") was correct. This was all very ad-hoc and a bit ugly. Error checking had to be done at both steps 1, 3, and 4. Most code didn't even check the tag, relying on the caller to do so. Not all callers did. The new pattern matching module performs the whole process in a single straightforward function call, resulting in shorter, more readable code. Unfortunately, MSVC does not support C99-style anonymous arrays, so the pattern must be declared outside of the match call.
* glsl: Make the symbol table's add_variable just use the variable's name.Eric Anholt2010-11-291-1/+1
|
* glsl: Make the symbol table's add_function just use the function's name.Eric Anholt2010-11-291-1/+1
|
* ir_reader: Fix some potential NULL pointer dereferences.Kenneth Graunke2010-11-031-4/+4
| | | | Found by inspection.
* ir_reader: Remove useless error check.Kenneth Graunke2010-11-031-6/+0
| | | | | It's already been determined that length == 3, so clearly swiz->next is a valid S-Expression.
* ir_reader: Return a specific ir_dereference variant.Kenneth Graunke2010-11-031-6/+9
| | | | | There's really no reason to return the base class when we have more specific information about what type it is.
* glsl: Move is_builtin flag back to ir_function_signature.Kenneth Graunke2010-09-071-1/+1
| | | | | | | | | | | 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_reader: Only validate IR when a global 'debug' flag is set.Kenneth Graunke2010-09-051-1/+4
| | | | | | | | | This extra validation is very useful when working on the built-ins, but in general overkill - the results should stay the same unless the built-ins or ir_validate have changed. Also, validating all the built-in functions in every test case makes piglit run unacceptably slow.
* ir_reader: Run ir_validate on the generated IR.Kenneth Graunke2010-09-041-0/+2
| | | | It's just too easy to get something wrong in hand-written IR.
* ir_reader: Emit global variables at the top of the instruction list.Kenneth Graunke2010-09-041-2/+11
| | | | | | | | Since functions are emitted when scanning for prototypes, functions always come first, even if the original IR listed the variable declarations first. Fixes an ir_validate error (to be turned on in the next commit).
* ir_reader: Drop support for reading the old assignment format.Kenneth Graunke2010-09-041-6/+4
|
* ir_reader: Read the new assignment format (with write mask).Kenneth Graunke2010-09-041-6/+46
| | | | | This preserves the ability to read the old format, for momentary compatibility with all the existing IR implementations of built-ins.
* ir_reader: Track the current function and report it in error messages.Kenneth Graunke2010-09-041-0/+6
|
* glsl: Initialize data in read_constant.Vinson Lee2010-08-291-1/+1
| | | | | | | Completely initialize data that is passed into a ir_constant constructor. Fixes piglit glsl-fs-mix valgrind uninitialized variable error on softpipe and llvmpipe.
* glsl: Move is_built_in flag from ir_function_signature to ir_function.Kenneth Graunke2010-08-261-1/+1
| | | | | | Also rename it to "is_builtin" for consistency. Signed-off-by: Ian Romanick <[email protected]>
* glsl2: Rework builtin function generation.Kenneth Graunke2010-08-131-8/+16
| | | | | | | | | | | | | | | | Each language version/extension and target now has a "profile" containing all of the available builtin function prototypes. These are written in GLSL, and come directly out of the GLSL spec (except for expanding genType). A new builtins/ir/ folder contains the hand-written IR for each builtin, regardless of what version includes it. Only those definitions that have prototypes in the profile will be included. The autogenerated IR for texture builtins is no longer written to disk, so there's no longer any confusion as to what's hand-written or generated. All scripts are now in python instead of perl.
* ir_reader: Don't mark functions as defined if their body is empty.Kenneth Graunke2010-08-131-1/+1
|
* glsl2: Make ir_assignment derive from ir_instruction, not ir_rvalue.Kenneth Graunke2010-07-221-2/+2
| | | | | | 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.
* ir_reader: Add support for reading constant arrays.Kenneth Graunke2010-07-211-2/+27
|
* glsl2: glsl_type has its own talloc context, don't pass one inIan Romanick2010-07-201-1/+1
|
* glsl2: Add and use new variable mode ir_var_temporaryIan Romanick2010-07-201-1/+2
| | | | | | | | | | | | | | | | | 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'.
* glsl2: Remove the const disease from function signature's callee.Eric Anholt2010-07-181-1/+1
|
* linker: Implement first bits of intrastage linkingIan Romanick2010-07-121-0/+1
| | | | | | | 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_reader: Don't emit ir_function multiple times.Kenneth Graunke2010-07-071-8/+8
|
* glsl2: Fix for dead strings being stored in the symbol table.Kenneth Graunke2010-07-021-2/+2
|
* glsl2: Use _mesa_glsl_parse_state as the talloc parent, not glsl_shader.Kenneth Graunke2010-06-301-15/+15
| | | | | | | | | | | | | _mesa_glsl_parse_state should be the parent for all temporary allocation done while compiling a shader. glsl_shader should only be used as the parent for the shader's final IR---the _result_ of compilation. Since many IR instructions may be added or discarded during optimization passes, IR should not ever be allocated to glsl_shader directly. Done via sed -i s/talloc_parent(state)/state/g and s/talloc_parent(st)/st/g. This also removes a ton of talloc_parent calls, which may help performance.
* ir_reader: Free memory for S-Expressions earlier.Kenneth Graunke2010-06-251-2/+2
| | | | | | There's no point in keeping it around once we've read the IR. Also, remove an unnecessary talloc_parent call.
* glsl2: Move the compiler to the subdirectory it will live in in Mesa.Eric Anholt2010-06-241-0/+1053