summaryrefslogtreecommitdiffstats
path: root/src/glsl/ir_clone.cpp
Commit message (Collapse)AuthorAgeFilesLines
* glsl: Implement ARB_texture_query_lodDave Airlie2013-03-291-0/+1
| | | | | | | | | | | | | | | | | | | v2 [mattst88]: - Rebase. - #define GL_ARB_texture_query_lod to 1. - Remove comma after ir_lod in ir.h for MSVC. - Handled ir_lod in ir_hv_accept.cpp, ir_rvalue_visitor.cpp, opt_tree_grafting.cpp. - Rename textureQueryLOD to textureQueryLod, see https://www.khronos.org/bugzilla/show_bug.cgi?id=821 - Fix ir_reader of (lod ...). v3 [mattst88]: - Rename textureQueryLod to textureQueryLOD, pending resolution of Khronos 821. - Add ir_lod case to ir_to_mesa.cpp. Reviewed-by: Matt Turner <[email protected]> Reviewed-by: Kenneth Graunke <[email protected]>
* glsl: add support for ARB_texture_multisampleChris Forbes2013-03-021-0/+3
| | | | | | | | | | | | | | | | | | 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: Remove ir_variable::uniform_blockIan Romanick2013-01-251-1/+0
| | | | | | | | | v2: A previous patch contained a spurious hunk that removed an assignment to ir_variable::uniform_block. That hunk was moved to this patch. Suggested by Carl Worth. Signed-off-by: Ian Romanick <[email protected]> Reviewed-by: Kenneth Graunke <[email protected]>
* glsl: Add ir_variable::interface_type fieldIan Romanick2013-01-251-0/+2
| | | | | | | | | | | | | | | For variables that are in an interface block or are an instance of an interface block, this is the GLSL_TYPE_INTERFACE type for that block. Convert the ir_variable::is_in_uniform_block method added in the previous commit to use this field instead of ir_variable::uniform_block. v2: Fix the place-holder comment on ir_variable::interface_type. Suggested by Paul Berry. Signed-off-by: Ian Romanick <[email protected]> Reviewed-by: Carl Worth <[email protected]> Reviewed-by: Kenneth Graunke <[email protected]>
* glsl: Add GLSL_TYPE_INTERFACEIan Romanick2013-01-251-0/+1
| | | | | | | | | | | | | | | | | | | | | Interfaces are structurally identical to structures from the compiler's point of view. They have some additional restrictions, and generally GPUs use different instructions to access them. Using a different base type should make this a bit easier. This commit also adds the glsl_type::interface_packing fields. For GLSL_TYPE_INTERFACE types, this will track the specified packing mode. It is analogous to gl_uniform_buffer::_Packing. v2: Add serveral missing GLSL_TYPE_INTERFACE cases in switch-statements. v3: Add information about glsl_type::interface_packing. Move row_major checking in glsl_type::record_key_compare from this patch to the previous patch. Both suggested by Paul Berry. Signed-off-by: Ian Romanick <[email protected]> Reviewed-by: Paul Berry <[email protected]> Reviewed-by: Kenneth Graunke <[email protected]>
* glsl: Replace most default cases in switches on GLSL typeIan Romanick2013-01-251-2/+6
| | | | | | | | | | | | | | | This makes it easier to find switch-statements that need to be updated after a new GLSL_TYPE_* is added because the compiler will generate a warning. Switch-statements that only had a small number of cases (e.g., everything in ir_constant_expression.cpp) were not modified. I may regret that decision when we eventually add support for doubles. Signed-off-by: Ian Romanick <[email protected]> Reviewed-by: Carl Worth <[email protected]> Reviewed-by: Chad Versace <[email protected]> Reviewed-by: Kenneth Graunke <[email protected]>
* glsl: Remove stale commentIan Romanick2013-01-181-4/+0
| | | | | Signed-off-by: Ian Romanick <[email protected]> Reviewed-by: Kenneth Graunke <[email protected]>
* glsl: Translate the AST for uniform blocks into some IR structures.Eric Anholt2012-07-201-0/+1
| | | | | | | | | | We're going to need this structure to cross-validate the uniform blocks between shader stages, since unused ir_variables might get dropped. It's also the place we store the RowMajor qualifier, which is not part of the GLSL type (since that would cause a bunch of type equality checks to fail). Reviewed-by: Ian Romanick <[email protected]>
* glsl: Add an origin pointer in the function signature object.Olivier Galibert2012-05-081-0/+1
| | | | | | | | This points to the object with the function body, allowing us to map from a built-in prototype to the actual body with IR code to execute. Signed-off-by: Olivier Galibert <[email protected]> Reviewed-by: Kenneth Graunke <[email protected]>
* glsl: Always copy the index when cloning a variable.Eric Anholt2012-05-041-6/+1
| | | | | | | | The index is also used for GL_ARB_blend_func_extended. Cloning in i965 was dropping a non-ARB_explicit_attrib_location index. Reviewed-by: Kenneth Graunke <[email protected]> Reviewed-by: Dave Airlie <[email protected]>
* glsl: add support for ARB_blend_func_extended (v3)Dave Airlie2012-04-131-0/+4
| | | | | | | | | | | | | | | | | | | This adds index support to the GLSL compiler. I'm not 100% sure of my approach here, esp without how output ordering happens wrt location, index pairs, in the "mark" function. Since current hw doesn't ever have a location > 0 with an index > 0, we don't have to work out if the output ordering the hw requires is location, index, location, index or location, location, index, index. But we have no hw to know, so punt on it for now. v2: index requires layout - catch and error setup explicit index properly. v3: drop idx_offset stuff, assume index follow location Signed-off-by: Dave Airlie <[email protected]>
* glsl: Remove ir_call::get_callee() and set_callee().Kenneth Graunke2012-04-021-2/+2
| | | | | | | | | | | | | Previously, set_callee() performed some assertions about the type of the ir_call; protecting the bare pointer ensured these checks would be run. However, ir_call no longer has a type, so the getter and setter methods don't actually do anything useful. Remove them in favor of accessing callee directly, as is done with most other fields in our IR. Signed-off-by: Kenneth Graunke <[email protected]> Reviewed-by: Eric Anholt <[email protected]> Reviewed-by: Ian Romanick <[email protected]>
* glsl: Convert ir_call to be a statement rather than a value.Kenneth Graunke2012-04-021-1/+5
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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-3/+7
| | | | | | | | | | | | | | | | | | | | | | 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: when cloning a variable, copy the depth layout tooMarek Olšák2011-11-191-0/+1
| | | | | | This fixes AMD_conservative_depth. Reviewed-by: Kenneth Graunke <[email protected]>
* linker: Check that initializers for global variables matchIan Romanick2011-11-031-0/+5
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | This requires tracking a couple extra fields in ir_variable: * A flag to indicate that a variable had an initializer. * For non-const variables, a field to track the constant value of the variable's initializer. For variables non-constant initalizers, ir_variable::has_initializer will be true, but ir_variable::constant_initializer will be NULL. The linker can use the values of these fields to check adherence to the GLSL 4.20 rules for shared global variables: "If a shared global has multiple initializers, the initializers must all be constant expressions, and they must all have the same value. Otherwise, a link error will result. (A shared global having only one initializer does not require that initializer to be a constant expression.)" Previous to 4.20 the GLSL spec simply said that initializers must have the same value. In this case of non-constant initializers, this was impossible to determine. As a result, no vendor actually implemented that behavior. The 4.20 behavior matches the behavior of NVIDIA's shipping implementations. NOTE: This is candidate for the 7.11 branch. This patch also needs the preceding patch "glsl: Refactor generate_ARB_draw_buffers_variables to use add_builtin_constant" Signed-off-by: Ian Romanick <[email protected]> Bugzilla: https://bugs.freedesktop.org/show_bug.cgi?id=34687 Reviewed-by: Kenneth Graunke <[email protected]> Acked-by: Paul Berry <[email protected]>
* ir_to_mesa: Move some things outside the 'extern "C"' blocksIan Romanick2011-10-181-2/+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: Remove field array_lvalue from ir_variable.Paul Berry2011-09-141-1/+0
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | The array_lvalue field was attempting to enforce the restriction that whole arrays can't be used on the left-hand side of an assignment in GLSL 1.10 or GLSL ES, and can't be used as out or inout parameters in GLSL 1.10. However, it was buggy (it didn't work properly for built-in arrays), and it was clumsy (it unnecessarily kept track on a variable-by-variable basis, and it didn't cover the GLSL ES case). This patch removes the array_lvalue field completely in favor of explicit checks in ast_parameter_declarator::hir() (this check is added) and in do_assignment (this check was already present). This causes a benign behavioral change: when the user attempts to pass an array as an out or inout parameter of a function in GLSL 1.10, the error is now flagged at the time the function definition is encountered, rather than at the time of invocation. Previously we allowed such functions to be defined, and only flagged the error if they were invoked. Fixes Piglit tests spec/glsl-1.10/compiler/qualifiers/fn-{out,inout}-array-prohibited* and spec/glsl-1.20/compiler/assignment-operators/assign-builtin-array-allowed.vert. Reviewed-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-1/+3
| | | | | | | | 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: Calcluate Mesa state slots in front-end instead of back-endIan Romanick2011-03-291-0/+12
| | | | | | | | | | | | This should be the last bit of infrastructure changes before generating GLSL IR for assembly shaders. This commit leaves some odd code formatting in ir_to_mesa and brw_fs. This was done to minimize whitespace changes / reindentation in some loops. The following commit will restore formatting sanity. Reviewed-by: Eric Anholt <[email protected]> Reviewed-by: Chad Versace <[email protected]>
* glsl: Change texel offsets to a single vector rvalue.Kenneth Graunke2011-01-311-2/+2
| | | | | | | | | | | 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-1/+1
|
* glsl: Refactor out cloning of function prototypes.Kenneth Graunke2010-11-301-11/+21
| | | | This allows us to reuse some code and will be useful later.
* glsl: Add ir_quadop_vector expressionIan Romanick2010-11-191-1/+2
| | | | | | | | | | 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.
* glsl: Eliminate assumptions about size of ir_expression::operandsIan Romanick2010-11-191-1/+2
| | | | This may grow in the near future.
* glsl: Track explicit location in AST to IR translationIan Romanick2010-10-081-0/+3
|
* glsl2: Fixed cloning of ir_call error instructions.Tilman Sauerbeck2010-09-181-0/+3
| | | | | | | Those have the callee field set to the null pointer, so calling the public constructor will segfault. Signed-off-by: Tilman Sauerbeck <[email protected]>
* glsl: Move is_builtin flag back to ir_function_signature.Kenneth Graunke2010-09-071-2/+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.
* glsl2: Add cmp field to ir_loopIan Romanick2010-09-031-0/+1
| | | | | This reprents the type of comparison between the loop induction variable and the loop termination value.
* glsl: Move is_built_in flag from ir_function_signature to ir_function.Kenneth Graunke2010-08-261-1/+2
| | | | | | Also rename it to "is_builtin" for consistency. Signed-off-by: Ian Romanick <[email protected]>
* glsl: Silence gcc warning "control reaches end of non-void function".José Fonseca2010-08-141-1/+1
|
* 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: Add ir_assignment::write_mask and associated methodsIan Romanick2010-08-041-1/+2
| | | | | | | | | | | | | | | | | | | | | | | 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-83/+67
| | | | | | | 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: Fix spelling of "sentinel."Eric Anholt2010-07-291-1/+1
|
* glsl2: Add support for redeclaring layout of gl_FragCoord for ARB_fcc.Eric Anholt2010-07-281-0/+2
| | | | | Fixes: glsl-arb-fragment-coord-conventions
* glsl2: Set the type on cloned tex instructions.Eric Anholt2010-07-221-0/+1
|
* glsl2: Extend ir_constant to store constant arrays, and generate them.Kenneth Graunke2010-07-211-0/+11
| | | | | | | | | 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.
* glsl2: Add and use new variable mode ir_var_temporaryIan Romanick2010-07-201-2/+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
|
* glsl2: Remove unnecessary casts of clone return valuesIan Romanick2010-07-131-25/+22
|
* 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.
* glsl2: Add utility function clone_ir_listIan Romanick2010-07-121-0/+60
|
* glsl2: Implement ir_function::clone and ir_function_signature::cloneIan Romanick2010-07-121-6/+43
|
* glsl2: Add missing fields in ir_variable::cloneIan Romanick2010-07-121-0/+8
|
* glsl2: Clone methods return the type of the thing being clonedIan Romanick2010-07-061-17/+17
| | | | This is as opposed to returning the type of the base class of the hierarchy.
* glsl2: Define new ir_discard instruction.Kenneth Graunke2010-06-301-0/+12
|
* glsl2: Wrap includes of C interfaces with extern "C".Eric Anholt2010-06-241-0/+2
|
* glsl2: Move the compiler to the subdirectory it will live in in Mesa.Eric Anholt2010-06-241-0/+287