summaryrefslogtreecommitdiffstats
path: root/src/glsl
Commit message (Collapse)AuthorAgeFilesLines
* nir: Generalize the optimization of subs of subs from 0.Eric Anholt2015-02-211-2/+2
| | | | | | | | | | | | I initially wrote this based on the "(('fneg', ('fneg', a)), a)" above, but we can generalize it and make it more potentially useful. In the specific original case of a 0 for our new 'a' argument, it'll get further algebraic optimization once the 0 is an argument to the new add. No shader-db effects. Reviewed-by: Matt Turner <[email protected]> Reviewed-by: Connor Abbott <[email protected]>
* nir: Collapse repeated bcsels on the same argument.Eric Anholt2015-02-211-0/+1
| | | | | | | | | vc4 results: total instructions in shared programs: 39881 -> 39794 (-0.22%) instructions in affected programs: 6302 -> 6215 (-1.38%) Reviewed-by: Matt Turner <[email protected]> Reviewed-by: Connor Abbott <[email protected]>
* nir: When faced with a csel on !condition, just flip the arguments.Eric Anholt2015-02-211-0/+1
| | | | | | | | total NIR instructions in shared programs: 39426 -> 39411 (-0.04%) NIR instructions in affected programs: 3748 -> 3733 (-0.40%) Reviewed-by: Matt Turner <[email protected]> Reviewed-by: Connor Abbott <[email protected]>
* nir: Allow nir_opt_algebraic to see booleanness through &&, ||, ^, !.Eric Anholt2015-02-211-1/+29
| | | | | | | | | | | | | | | | | We have some useful optimizations to drop things like 'ine a, 0' on a boolean argument, but if 'a' came from logical operations on bools, it couldn't tell. These kinds of constructs appear as a result of TGSI->NIR quite frequently (at least with if flattening), so being a little more aggressive in detecting booleans can pay off. v2: Add ixor as a booleanness-preserving op (Suggestion by Connor). vc4 results: total instructions in shared programs: 40207 -> 39881 (-0.81%) instructions in affected programs: 6677 -> 6351 (-4.88%) Reviewed-by: Matt Turner <[email protected]> (v1) Reviewed-by: Connor Abbott <[email protected]>
* nir: Add a couple of simplifications of csel operations.Eric Anholt2015-02-211-0/+3
| | | | | | | | vc4 was already cleaning these up, but it does shave 4 NIR instructions in shader-db. Reviewed-by: Matt Turner <[email protected]> Reviewed-by: Connor Abbott <[email protected]>
* glsl: ensure that enter/leave record get a record typeIlia Mirkin2015-02-212-0/+5
| | | | | | | May make life easier for tools like Coverity. Signed-off-by: Ilia Mirkin <[email protected]> Reviewed-by: Matt Turner <[email protected]>
* nir: Fix the Mesa build without -DDEBUG.Kenneth Graunke2015-02-201-2/+2
| | | | | | | | | | | | | With -DDEBUG -UNDEBUG, this assert uses reg_state::stack_size, which doesn't exist, breaking the build: assert(state->states[index].index < state->states[index].stack_size); Switch it to ifndef NDEBUG, so the field will exist if the assertion actually generates code. Signed-off-by: Kenneth Graunke <[email protected]> Reviewed-by: Matt Turner <[email protected]>
* nir: Drop dependency on mtypes.h for core NIR.Eric Anholt2015-02-203-1/+5
| | | | | | | | One less new directory necessary for gallium code that wants to interact with NIR. Reviewed-by: Connor Abbott <[email protected]> Reviewed-by: Jose Fonseca <[email protected]>
* glsl: Only include mtypes from glsl_types.h for the C++ code that needs it.Eric Anholt2015-02-201-1/+1
| | | | | | It's used in one of the methods, not in the structure definitions. Reviewed-by: Jose Fonseca <[email protected]>
* util: Move Mesa's bitset.h to util/.Eric Anholt2015-02-201-1/+1
| | | | Reviewed-by: Jose Fonseca <[email protected]>
* mesa: Add gallium include dirs to more parts of the tree.Eric Anholt2015-02-202-0/+4
| | | | | | v2: Try to patch up the scons bits. Reviewed-by: Jose Fonseca <[email protected]>
* glsl: don't allow invariant qualifiers for interface blocksSamuel Iglesias Gonsalvez2015-02-201-0/+22
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | GLSL 1.50 and GLSL 4.40 specs, they both say the same in "Interface Blocks" section: "If optional qualifiers are used, they can include interpolation qualifiers, auxiliary storage qualifiers, and storage qualifiers and they must declare an input, output, or uniform member consistent with the interface qualifier of the block" From GLSL ES 3.0, chapter 4.3.7 "Interface Blocks", page 38: "GLSL ES 3.0 does not support interface blocks for shader inputs or outputs." and from GLSL ES 3.0, chapter 4.6.1 "The invariant qualifier", page 52. "Only variables output from a shader can be candidates for invariance." This patch fixes the following dEQP tests: dEQP-GLES3.functional.shaders.declarations.invalid_declarations.invariant_uniform_block_2_vertex dEQP-GLES3.functional.shaders.declarations.invalid_declarations.invariant_uniform_block_2_fragment No piglit regressions. Signed-off-by: Samuel Iglesias Gonsalvez <[email protected]> v2: - Enable this check for GLSL. Signed-off-by: Samuel Iglesias Gonsalvez <[email protected]> Reviewed-by: Matt Turner <[email protected]> Reviewed-by: Ian Romanick <[email protected]>
* glsl: Use the without_array predicateTimothy Arceri2015-02-201-5/+2
| | | | Reviewed-by: Matt Turner <[email protected]>
* nir/GCM: Pull unpinned instructions out of blocks while pinningJason Ekstrand2015-02-191-37/+25
| | | | | | | | This lets us be slightly more efficient by not walking the CFG extra times. Also, it may make it easier to ensure that GVN happens on only unpinned instructions. Reviewed-by: Reviewed-by: Connor Abbott <[email protected]>
* nir/GCM: Use pass_flags instead of bitsets for tracking visited/pinnedJason Ekstrand2015-02-191-46/+49
| | | | Reviewed-by: Reviewed-by: Connor Abbott <[email protected]>
* nir: Add a global code motion (GCM) passJason Ekstrand2015-02-193-0/+504
| | | | | | | | | v2 Jason Ekstrand <[email protected]>: - Use nir_dominance_lca for computing least common anscestors - Use the block index for comparing dominance tree depths - Pin things that do partial derivatives Reviewed-by: Reviewed-by: Connor Abbott <[email protected]>
* nir/instr: Change "live" to a more generic "pass_flags" fieldJason Ekstrand2015-02-192-7/+13
| | | | Reviewed-by: Connor Abbott <[email protected]>
* nir: Make nir_[cf_node/instr]_[prev/next] return null if at the endJason Ekstrand2015-02-191-6/+22
| | | | Reviewed-by: Connor Abbott <[email protected]>
* nir/from_ssa: Don't try to read an invalid instructionJason Ekstrand2015-02-191-1/+1
| | | | | | | | | | | | Right now, the nir_instr_prev function function blindly looks up the previous element in the exec list and casts it to an instruction even if it's the tail sentinel. The next commit will change this to return null if it's the first instruction. Making this change first avoids getting a segfault between commits. The only reason we never noticed is that, thanks to the way things are laid out in nir_block, the casted instruction's type was never parallal_copy. Reviewed-by: Connor Abbott <[email protected]>
* nir/validate: Validate SSA defs the same way we do for registersJason Ekstrand2015-02-191-8/+79
| | | | Reviewed-by: Connor Abbott <[email protected]>
* nir/validate: Validate if_uses on registersJason Ekstrand2015-02-191-18/+44
| | | | Reviewed-by: Connor Abbott <[email protected]>
* nir: Properly clean up CF nodes when we remove themJason Ekstrand2015-02-191-0/+54
| | | | | | | | | | Previously, if you remved a CF node that still had instructions in it, none of the use/def information from those instructions would get cleaned up. Also, we weren't removing if statements from the if_uses of the corresponding register or SSA def. This commit fixes both of these problems Reviewed-by: Connor Abbott <[email protected]>
* nir: use nir_foreach_ssa_def for indexing ssa defsJason Ekstrand2015-02-191-23/+5
| | | | | | | This is both simpler and more correct. The old code didn't properly index load_const instructions. Reviewed-by: Connor Abbott <[email protected]>
* nir/from_ssa: Use the nir_block_dominance function instead of our ownJason Ekstrand2015-02-191-7/+2
| | | | Reviewed-by: Connor Abbott <[email protected]>
* nir/dominance: Add a constant-time mechanism for comparing blocksJason Ekstrand2015-02-192-0/+39
| | | | | | | | | This is mostly thanks to Connor. The idea is to do a depth-first search that computes pre and post indices for all the blocks. We can then figure out if one block dominates another in constant time by two simple comparison operations. Reviewed-by: Connor Abbott <[email protected]>
* nir/dominance: Expose the dominance intersection functionJason Ekstrand2015-02-192-0/+24
| | | | | | | | | | Being able to find the least common anscestor in the dominance tree is a useful thing that we may want to do in other passes. In particular, we need it for GCM. v2: Handle NULL inputs by returning the other block Reviewed-by: Connor Abbott <[email protected]>
* glsl: Add compute to _mesa_shader_stage_to_string(); use unreachable.Kenneth Graunke2015-02-191-2/+2
| | | | | | | | This is basically Ian's review feedback for my patch that added _mesa_shader_stage_to_abbrev() - it just makes both consistent again. Signed-off-by: Kenneth Graunke <[email protected]> Reviewed-by: Ian Romanick <[email protected]>
* glsl: Create a _mesa_shader_stage_to_abbrev() function.Kenneth Graunke2015-02-192-0/+20
| | | | | | | | | | | | | This is similar to _mesa_shader_stage_to_string(), but returns "VS" instead of "vertex". v2: Use unreachable() and add MESA_SHADER_COMPUTE (requested by Ian). Signed-off-by: Kenneth Graunke <[email protected]> Reviewed-by: Jason Ekstrand <[email protected]> Reviewed-by: Ian Romanick <[email protected]> Reviewed-by: Kristian Høgsberg <[email protected]> Reviewed-by: Anuj Phogat <[email protected]>
* glsl: add lowering for double divide to rcp/mulDave Airlie2015-02-201-3/+4
| | | | | | | | It looks like no hw does div anyways, so we should just lower at the GLSL level. Reviewed-by: Ilia Mirkin <[email protected]> Signed-off-by: Dave Airlie <[email protected]>
* nir: add missing GLSL_TYPE_DOUBLE case in type_size()Brian Paul2015-02-191-0/+1
| | | | | | | To silence compiler warning about unhandled switch case. v2: move GLSL_TYPE_DOUBLE to the "not reached" section, per Ilia. Reviewed-by: Ilia Mirkin <[email protected]>
* glsl: A shader cannot redefine or overload built-in functions in GLSL ES 3.00Samuel Iglesias Gonsalvez2015-02-193-0/+36
| | | | | | | | | | | | | | | | | | | | | | | | | | | Create a new search function to look for matching built-in functions by name and use it for built-in function redefinition or overload in GLSL ES 3.00. GLSL ES 3.0 spec, chapter 6.1 "Function Definitions", page 71 "A shader cannot redefine or overload built-in functions." While in GLSL ES 1.0 specification, chapter 8 "Built-in Functions" "User code can overload the built-in functions but cannot redefine them." So this check is specific to GLSL ES 3.00. This patch fixes the following dEQP tests: dEQP-GLES3.functional.shaders.functions.invalid.overload_builtin_function_vertex dEQP-GLES3.functional.shaders.functions.invalid.overload_builtin_function_fragment dEQP-GLES3.functional.shaders.functions.invalid.redefine_builtin_function_vertex dEQP-GLES3.functional.shaders.functions.invalid.redefine_builtin_function_fragment No piglit regressions. Signed-off-by: Samuel Iglesias Gonsalvez <[email protected]> Reviewed-by: Kenneth Graunke <[email protected]>
* glsl: remove bogus 'd' constant qualifiersIlia Mirkin2015-02-191-2/+2
| | | | | | | | | 0.0 is a double anyways. Apparently my version of gcc was happy with 0.0d as well, but this is not true of all compilers. Bugzilla: https://bugs.freedesktop.org/show_bug.cgi?id=89218 Signed-off-by: Ilia Mirkin <[email protected]>
* nir: Add an ALU op builder kind of like ir_builder.hEric Anholt2015-02-185-0/+175
| | | | | | | | | | | | | | | | | v2: Rebase on the nir_opcodes.h python code generation support. v3: Use SSA values, and set an appropriate writemask on dot products. v4: Make the arguments be SSA references as well. This lets you stack up expressions in the arguments of other expressions, at the cost of having to insert a fmov/imov if you want to swizzle. Also, add the generated file to NIR_GENERATED_FILES. v5: Use more pythonish style for iterating the list. v6: Infer the size of the dest from the size of the srcs, and auto-swizzle a single small src out to the appropriate size. v7: Add little helpers for initializing the struct, add a typedef for the struct like other nir types have. Reviewed-by: Kenneth Graunke <[email protected]> (v6) Reviewed-by: Connor Abbott <[email protected]> (v7)
* glsl/tests: add DOUBLE typesIlia Mirkin2015-02-191-0/+9
| | | | | Signed-off-by: Ilia Mirkin <[email protected]> Reviewed-by: Dave Airlie <[email protected]>
* glsl: add a lowering pass for frexp/ldexp with double argumentsIlia Mirkin2015-02-192-1/+279
| | | | | Signed-off-by: Ilia Mirkin <[email protected]> Reviewed-by: Dave Airlie <[email protected]>
* glsl: lower double optional passes (v2)Dave Airlie2015-02-192-0/+176
| | | | | | | | | | | | These lowering passes are optional for the backend to request, currently the TGSI softpipe backend most likely the r600g backend would want to use these passes as is. They aim to hit the gallium opcodes from the standard rounding/truncation functions. v2: also lower floor in mod_to_floor Signed-off-by: Dave Airlie <[email protected]> Reviewed-by: Ilia Mirkin <[email protected]>
* glsl: implement double builtin functionsDave Airlie2015-02-191-259/+492
| | | | | | | This implements the bulk of the builtin functions for fp64 support. Signed-off-by: Dave Airlie <[email protected]> Reviewed-by: Ilia Mirkin <[email protected]>
* glsl/lower_instructions: add double lowering passesDave Airlie2015-02-191-0/+65
| | | | | | | This lowers double dot product and lrp to fma. Signed-off-by: Dave Airlie <[email protected]> Reviewed-by: Ilia Mirkin <[email protected]>
* glsl: enable/disable certain lowering passes for doublesDave Airlie2015-02-191-3/+3
| | | | | | | | We want to restrict some lowering passes to floats only, and enable other for doubles. Signed-off-by: Dave Airlie <[email protected]> Reviewed-by: Ilia Mirkin <[email protected]>
* glsl: validate output types for shader stagesTapani Pälli2015-02-191-0/+45
| | | | | | | | | | | Patch fixes Piglit test: arb_gpu_shader_fp64/preprocessor/fs-output-double.frag and adds additional validation for shader outputs. Signed-off-by: Tapani Pälli <[email protected]> Signed-off-by: Dave Airlie <[email protected]> Reviewed-by: Ilia Mirkin <[email protected]>
* glsl: add double support to lower_mat_op_to_vecDave Airlie2015-02-191-0/+2
| | | | | | Signed-off-by: Dave Airlie <[email protected]> Reviewed-by: Ian Romanick <[email protected]> Reviewed-by: Ilia Mirkin <[email protected]>
* glsl: Linking support for doublesDave Airlie2015-02-191-1/+7
| | | | | | Signed-off-by: Dave Airlie <[email protected]> Reviewed-by: Ian Romanick <[email protected]> Reviewed-by: Ilia Mirkin <[email protected]>
* glsl: Support double loop controlDave Airlie2015-02-191-2/+6
| | | | | Signed-off-by: Dave Airlie <[email protected]> Reviewed-by: Ilia Mirkin <[email protected]>
* glsl: Support double inoutsDave Airlie2015-02-191-4/+24
| | | | | Signed-off-by: Dave Airlie <[email protected]> Reviewed-by: Ilia Mirkin <[email protected]>
* glsl/lexer: Support double floatsDave Airlie2015-02-191-4/+27
| | | | | | | Signed-off-by: Dave Airlie <[email protected]> Reviewed-by: Ian Romanick <[email protected]> Reviewed-by: Matt Turner <[email protected]> Reviewed-by: Ilia Mirkin <[email protected]>
* glsl/parser: Support double floatsDave Airlie2015-02-191-4/+29
| | | | | | | Signed-off-by: Dave Airlie <[email protected]> Reviewed-by: Matt Turner <[email protected]> Reviewed-by: Ian Romanick <[email protected]> Reviewed-by: Ilia Mirkin <[email protected]>
* glsl/ast: Support double floatsDave Airlie2015-02-194-15/+90
| | | | | Signed-off-by: Dave Airlie <[email protected]> Reviewed-by: Ilia Mirkin <[email protected]>
* glsl: Add ubo lowering support for doublesDave Airlie2015-02-191-24/+33
| | | | | Signed-off-by: Dave Airlie <[email protected]> Reviewed-by: Ilia Mirkin <[email protected]>
* glsl: Add support doubles in optimization passesDave Airlie2015-02-193-4/+38
| | | | | | Signed-off-by: Dave Airlie <[email protected]> Reviewed-by: Matt Turner <[email protected]> Reviewed-by: Ilia Mirkin <[email protected]>
* glsl/ir: Add builder support for functions with double floatsDave Airlie2015-02-192-0/+28
| | | | | | | Signed-off-by: Dave Airlie <[email protected]> Reviewed-by: Matt Turner <[email protected]> Reviewed-by: Ian Romanick <[email protected]> Reviewed-by: Ilia Mirkin <[email protected]>