summaryrefslogtreecommitdiffstats
path: root/src/glsl/nir
Commit message (Collapse)AuthorAgeFilesLines
* glsl: keep track of intra-stage indices for atomicsTimothy Arceri2015-10-273-9/+22
| | | | | | | | | | | | | | | This is more optimal as it means we no longer have to upload the same set of ABO surfaces to all stages in the program. This also fixes a bug where since commit c0cd5b var->data.binding was being used as a replacement for atomic buffer index, but they don't have to be the same value they just happened to end up the same when binding is 0. Reviewed-by: Francisco Jerez <[email protected]> Reviewed-by: Samuel Iglesias Gonsálvez <[email protected]> Cc: Ilia Mirkin <[email protected]> Cc: Alejandro Piñeiro <[email protected]> Bugzilla: https://bugs.freedesktop.org/show_bug.cgi?id=90175
* nir: Add opcodes for saturated vector math.Eric Anholt2015-10-232-0/+51
| | | | | | | | | This corresponds to instructions used on vc4 for its blending inside of shaders. I've seen these opcodes on other architectures before, but I think it's the first time these are needed in Mesa. v2: Rename to 'u' instead of 'i', since they're all 'u'norm (from review by jekstrand)
* nir: Constify nir_gs_count_verticesJason Ekstrand2015-10-212-2/+2
| | | | Reviewed-by: Kenneth Graunke <[email protected]>
* nir/info: Add more information about geometry shadersJason Ekstrand2015-10-212-0/+16
| | | | Reviewed-by: Kenneth Graunke <[email protected]>
* glsl: add is_array_of_arrays() helperTimothy Arceri2015-10-211-0/+5
| | | | | | As suggested by Ian Romanick Reviewed-by: Tapani Pälli <[email protected]>
* mesa: replace UsesClipDistance with ClipDistanceArraySizeMarek Olšák2015-10-201-1/+2
| | | | | | | This is more practical and needed by gallium. Reviewed-by: Ilia Mirkin <[email protected]> Reviewed-by: Brian Paul <[email protected]>
* nir/info: Add a few bits of info for fragment shadersJason Ekstrand2015-10-192-0/+23
| | | | Reviewed-by: Topi Pohjolainen <[email protected]>
* nir/info: Add compute shader local size to nir_shader_infoJason Ekstrand2015-10-192-0/+12
| | | | Reviewed-by: Topi Pohjolainen <[email protected]>
* nir/info: Move the GS info into a stage-specific info unionJason Ekstrand2015-10-192-8/+18
| | | | | | | | This way we can have other stage-specific info without consuming too much extra space. While we're at it, we make sure that the geometry info is only set if we're actually a goemetry shader. Reviewed-by: Topi Pohjolainen <[email protected]>
* mesa: Move gl_frag_depth_layout from mtypes.h to shader_enums.hJason Ekstrand2015-10-191-0/+17
| | | | Reviewed-by: Topi Pohjolainen <[email protected]>
* nir: Add a label to nir_shader_infoJason Ekstrand2015-10-193-0/+7
| | | | Reviewed-by: Topi Pohjolainen <[email protected]>
* nir: remove dependency on glslRob Clark2015-10-164-1/+2785
| | | | | | | | | | | | | | | Move glsl_types into NIR, now that the dependency on glsl_symbol_table has been split out. Possibly makes sense to rename things at this point, but if we do that I'd like to keep it split out into a separate patch to make git history easier to follow (IMHO). v2: fix android build v3: I f***ing hate scons.. but at least it builds Reviewed-by: Jason Ekstrand <[email protected]> Signed-off-by: Rob Clark <[email protected]>
* glsl: move half<->float convertion to utilRob Clark2015-10-161-0/+1
| | | | | | | | Needed in NIR too, so move out of mesa/main/imports.c Reviewed-by: Jason Ekstrand <[email protected]> Reviewed-by: Emil Velikov <[email protected]> Signed-off-by: Rob Clark <[email protected]>
* glsl: couple shader_enums cleanupsRob Clark2015-10-162-0/+15
| | | | | | | | | | | | Add missing enum to gl_system_value_name() and move VARYING_SLOT_MAX / FRAG_RESULT_MAX / etc into shader_enums.h as suggested by Emil. v2: add STATIC_ASSERT()'s Reported-by: Emil Velikov <[email protected]> Acked-by: Emil Velikov <[email protected]> Reviewed-by: Jason Ekstrand <[email protected]> Signed-off-by: Rob Clark <[email protected]>
* nir: add atomic lowering support for AoATimothy Arceri2015-10-171-10/+12
| | | | | Cc: Francisco Jerez <[email protected]> Reviewed-by: Jason Ekstrand <[email protected]>
* nir: wrapper for glsl_type arrays_of_arrays_size()Timothy Arceri2015-10-172-0/+8
| | | | | Reviewed-by: Tapani Pälli <[email protected]> Reviewed-by: Ian Romanick <[email protected]>
* nir: Get the number of SSBOs and UBOs rightIago Toral Quiroga2015-10-161-2/+2
| | | | | | | | | | | Before d31f98a272e429d and 56e2bdbca36a20 we had a sigle index space for UBOs and SSBOs, so NumBufferInterfaceBlocks would contain the combined number of blocks, not just one kind. This means that for shader programs using both UBOs and SSBOs, we were setting num_ssbos and num_ubos to a larger number than we should. Since the above commits we have separate index spaces for each so we can just get the right numbers. Reviewed-by: Jason Ekstrand <[email protected]>
* nir/glsl: Use shader_prog->Name for naming the NIR shaderJason Ekstrand2015-10-151-1/+1
| | | | | | | This has the better name to use. Aparently, sh->Name is usually 0. Reviewed-by: Kenneth Graunke <[email protected]> Reviewed-by: Neil Roberts <[email protected]>
* nir: Add helpers for creating variables and adding them to listsJason Ekstrand2015-10-153-34/+92
| | | | Reviewed-by: Iago Toral Quiroga <[email protected]>
* mesa: Rename {Num}UniformBlocks to {Num}BufferInterfaceBlocksIago Toral Quiroga2015-10-141-1/+1
| | | | | | | | | | | | | | Currently, these arrays in gl_shader and gl_shader_program hold both UBOs and SSBOs, so this looks like a better name. We were already using NumBufferInterfaceBlocks in gl_shader_program, so this makes things more consistent as well. In a later patch we will add {Num}UniformBlocks and {Num}ShaderStorageBlocks which will contain only references to UBOs and SSBOs respectively that will provide backends with a separate index space for both types of objects. Reviewed-by: Kristian Høgsberg <[email protected]>
* nir: split SSBO min/max atomic instrinsics into signed/unsigned versionsIago Toral Quiroga2015-10-142-6/+22
| | | | | | | | | | | | | NIR is typeless so this is the only way to keep track of the type to select the proper atomic to use. v2: - Use imin,imax,umin,umax for the intrinsic names (Connor Abbott) - Change message for unreachable paths (Michael Schellenberger) Tested-by: Markus Wick <[email protected]> Reviewed-by: Kristian Høgsberg <[email protected]> Reviewed-by: Kenneth Graunke <[email protected]>
* glsl: move shader_enums into nirRob Clark2015-10-093-1/+682
| | | | | | | | | | | | | | | | | | | | First step towards inverting the dependency between glsl and nir (so nir can be used without glsl). Also solves this issue with 'make distclean' Making distclean in mesa make[2]: Entering directory '/mnt/sdb1/Src64/Mesa-git/mesa/src/mesa' Makefile:2486: ../glsl/.deps/shader_enums.Plo: No such file or directory make[2]: *** No rule to make target '../glsl/.deps/shader_enums.Plo'. Stop. make[2]: Leaving directory '/mnt/sdb1/Src64/Mesa-git/mesa/src/mesa' Makefile:684: recipe for target 'distclean-recursive' failed make[1]: *** [distclean-recursive] Error 1 make[1]: Leaving directory '/mnt/sdb1/Src64/Mesa-git/mesa/src' Makefile:615: recipe for target 'distclean-recursive' failed make: *** [distclean-recursive] Error 1 Reported-by: Andy Furniss <[email protected]> Reviewed-by: Emil Velikov <[email protected]> Signed-off-by: Rob Clark <[email protected]>
* nir/instr_set: remove unnecessary check in nir_instrs_equal()Connor Abbott2015-10-091-2/+1
| | | | | | | | | | | | | This was originally added to nir_instrs_equal() instead of nir_instr_can_cse() incorrectly, but this was fixed when moving to the instruction set API (as it had to be, otherwise hashing wouldn't work). Now, this is dead code since instr_can_rewrite() will only return true for texture instructions that use an index, so we can turn the check into an assert. This also means that now nir_instrs_equal(instr, instr) will always return true unless it assert-fails. Reviewed-by: Jason Ekstrand <[email protected]> Signed-off-by: Connor Abbott <[email protected]>
* nir: make nir_instrs_equal() staticConnor Abbott2015-10-092-3/+1
| | | | | | | | | | This was previously tied to CSE, since it would only work for instructions where nir_can_cse() (now instr_can_rewrite()) returned true. Now that CSE uses the instruction set abstraction which only uses this internally, we can make it local to nir_instr_set.c. Reviewed-by: Jason Ekstrand <[email protected]> Signed-off-by: Connor Abbott <[email protected]>
* nir/cse: use the instruction set APIConnor Abbott2015-10-091-115/+23
| | | | | | | | | | | | | | | | | | | | | | | | | | This replaces an O(n^2) algorithm with an O(n) one, while allowing us to import most of the infrastructure required for GVN. The idea is to walk the dominance tree depth-first, similar when converting to SSA, and remove the instructions from the set when we're done visiting the sub-tree of the dominance tree so that the only instructions in the set are the instructions that dominate the current block. No piglit regressions. No shader-db changes. Compilation time for full shader-db: Difference at 95.0% confidence -35.826 +/- 2.16018 -6.2852% +/- 0.378975% (Student's t, pooled s = 3.37504) v2: - rebase on start_block removal - remove useless state struct - change commit message Reviewed-by: Jason Ekstrand <[email protected]> Signed-off-by: Connor Abbott <[email protected]>
* nir: add an instruction set APIConnor Abbott2015-10-092-0/+349
| | | | | | | | | | | | | | | | | | | | | | | This will replace direct usage of nir_instrs_equal() in the CSE pass, which reduces an O(n^2) algorithm with an effectively O(n) one. It'll also be useful for implementing GVN on top of GCM. v2: - Add texture support. - Add more comments. - Rename instr_can_hash() to instr_can_rewrite() since it's really more about whether its uses can be rewritten, and it's implicitly used by nir_instrs_equal() as well. - Rename nir_instr_set_add() to nir_instr_set_add_or_rewrite() (Jason). - Make the HASH() macro less magical (Topi). - Rewrite the commit message. v3: - For sorting phi sources, use a VLA, store pointers to the sources, and compare the predecessor pointer directly (Jason). Reviewed-by: Jason Ekstrand <[email protected]> Signed-off-by: Connor Abbott <[email protected]>
* nir: constify instruction comparison functionsConnor Abbott2015-10-092-4/+4
| | | | | | | | v2: rebase, don't constify nir_srcs_equal() as it's pass-by-value anyways Reviewed-by: Jason Ekstrand <[email protected]> Signed-off-by: Connor Abbott <[email protected]>
* nir: constify nir_ssa_alu_instr_src_components()Connor Abbott2015-10-091-1/+1
| | | | | Reviewed-by: Jason Ekstrand <[email protected]> Signed-off-by: Connor Abbott <[email protected]>
* nir: split out instruction comparison functionsConnor Abbott2015-10-094-181/+236
| | | | | | | | | | | | Right now nir_instrs_equal() is tied pretty tightly to CSE, but we're going to introduce the idea of an instruction set and tie it to that instead. In anticipation of that, move this into its own file where we'll add the rest of the instruction set implementation later. v2: Rebase on texture support. Reviewed-by: Jason Ekstrand <[email protected]> Signed-off-by: Connor Abbott <[email protected]>
* nir: Add a function to determine if a source is dynamically uniformNeil Roberts2015-10-092-0/+30
| | | | | | | | | | | | Adds nir_src_is_dynamically_uniform which returns true if the source is known to be dynamically uniform. This will be used in a later patch to add a workaround for cases that only work with dynamically uniform sources. Note that the function is not definitive, it can return false negatives (but not false positives). Currently it only detects constants and uniform accesses. It could easily be extended to include more cases. Reviewed-by: Matt Turner <[email protected]>
* nir/sweep: Reparent the shader nameJason Ekstrand2015-10-081-0/+2
| | | | | | | | | | Previously the name of the nir shader was being freed prematurely during nir_sweep. Since 756613ed35d the name was later being used to generate filenames for the optimiser debug output and these would end up with garbage from the dangling pointer. Co-authored-by: Neil Roberts <[email protected]> Reviewed-by: Matt Turner <[email protected]>
* glsl: reduce memory footprint of uniform_storage structTimothy Arceri2015-10-051-2/+2
| | | | | | | | The uniform will only be of a single type so store the data for opaque types in a single array. Cc: Francisco Jerez <[email protected]> Cc: Ilia Mirkin <[email protected]>
* nir: Add a nir_shader_info::has_transform_feedback_varyings flag.Kenneth Graunke2015-10-042-0/+5
| | | | | Signed-off-by: Kenneth Graunke <[email protected]> Reviewed-by: Matt Turner <[email protected]>
* nir: Introduce new nir_intrinsic_load_per_vertex_input intrinsics.Kenneth Graunke2015-10-043-6/+52
| | | | | | | | | | | | | | | | | | | | | | | | | | | Geometry and tessellation shaders process multiple vertices; their inputs are arrays indexed by the vertex number. While GLSL makes this look like a normal array, it can be very different behind the scenes. On Intel hardware, all inputs for a particular vertex are stored together - as if they were grouped into a single struct. This means that consecutive elements of these top-level arrays are not contiguous. In fact, they may sometimes be in completely disjoint memory segments. NIR's existing load_input intrinsics are awkward for this case, as they distill everything down to a single offset. We'd much rather keep the vertex ID separate, but build up an offset as normal beyond that. This patch introduces new nir_intrinsic_load_per_vertex_input intrinsics to handle this case. They work like ordinary load_input intrinsics, but have an extra source (src[0]) which represents the outermost array index. v2: Rebase on earlier refactors. v3: Use ssa defs instead of nir_srcs, rebase on earlier refactors. Signed-off-by: Kenneth Graunke <[email protected]> Reviewed-by: Jason Ekstrand <[email protected]>
* nir/lower_io: Make get_io_offset() return a nir_ssa_def * for indirects.Kenneth Graunke2015-10-041-42/+20
| | | | | | | | | | | | | | | get_io_offset() already walks the dereference chain and discovers whether or not we have an indirect; we can just return that rather than computing it a second time via deref_has_indirect(). This means moving the call a bit earlier. By returning a nir_ssa_def *, we can pass back both an existence flag (via NULL checking the pointer) and the value in one parameter. It also simplifies the code somewhat. nir_lower_samplers works in a similar fashion. Signed-off-by: Kenneth Graunke <[email protected]> Reviewed-by: Jason Ekstrand <[email protected]>
* nir: Add a nir_foreach_variable macroJason Ekstrand2015-10-027-18/+21
| | | | | | | This is a common enough operation that it's nice to not have to think about the arguments to foreach_list_typed every time. Reviewed-by: Kenneth Graunke <[email protected]>
* nir: Move GS data to nir_shader_infoJason Ekstrand2015-10-024-14/+11
| | | | Reviewed-by: Kenneth Graunke <[email protected]>
* nir: Add a a nir_shader_info structJason Ekstrand2015-10-023-0/+53
| | | | | | This commit also adds code to glsl_to_nir and prog_to_nir to fill it out. Reviewed-by: Kenneth Graunke <[email protected]>
* nir/glsl: Take a gl_shader_program and a stage rather than a gl_shaderJason Ekstrand2015-10-022-3/+8
| | | | Reviewed-by: Kenneth Graunke <[email protected]>
* nir: Fix uninitialized 'progress' variable in nir_lower_system_values.Chris Wilson2015-10-021-1/+1
| | | | | | | | | | | | | | | | | | Commit 0a1adaf11d051b71b4c46aabee2e5342f2d6aef3 (nir: Report progress from nir_lower_system_values().) introduced a bug caught by Valgrind: ==823== Conditional jump or move depends on uninitialised value(s) ==823== at 0xB09020C: convert_block (nir_lower_system_values.c:68) ==823== by 0xB079FB8: foreach_cf_node (nir.c:1310) ==823== by 0xB07A0AF: nir_foreach_block (nir.c:1336) ==823== by 0xB09026B: convert_impl (nir_lower_system_values.c:79) ... ==823== Uninitialised value was created by a stack allocation ==823== at 0xB090249: convert_impl (nir_lower_system_values.c:76) which is trivially fixed by initializing progress. Reviewed-by: Kenneth Graunke <[email protected]>
* nir/remove_phis: handle trivial back-edgesConnor Abbott2015-10-021-0/+19
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Some loops may have phi nodes that look like: foo = ... loop { bar = phi(foo, bar) ... } in which case we can remove the phi node and replace all uses of 'bar' with 'foo'. In particular, there are some L4D2 vertex shaders with loops that, after optimization, look like: /* succs: block_1 */ loop { block block_1: /* preds: block_0 block_4 */ vec1 ssa_2195 = phi block_0: ssa_2136, block_4: ssa_994 vec1 ssa_7321 = phi block_0: ssa_8195, block_4: ssa_7321 vec1 ssa_7324 = phi block_0: ssa_8198, block_4: ssa_7324 vec1 ssa_7327 = phi block_0: ssa_8174, block_4: ssa_7327 vec1 ssa_8139 = intrinsic load_uniform () () (232) vec1 ssa_588 = ige ssa_2195, ssa_8139 /* succs: block_2 block_3 */ if ssa_588 { block block_2: /* preds: block_1 */ break /* succs: block_5 */ } else { block block_3: /* preds: block_1 */ /* succs: block_4 */ } block block_4: /* preds: block_3 */ vec1 ssa_994 = iadd ssa_2195, ssa_2150 /* succs: block_1 */ } where after removing the second, third, and fourth phi nodes, the loop becomes entirely dead, and this patch will cause the loop to be deleted entirely. No piglit regressions. Shader-db results on bdw: instructions in affected programs: 5824 -> 5664 (-2.75%) total loops in shared programs: 2234 -> 2202 (-1.43%) helped: 32 Reviewed-by: Matt Turner <[email protected]> Signed-off-by: Connor Abbott <[email protected]>
* nir: Allow nir_lower_io() to only lower one type of variable.Kenneth Graunke2015-10-012-4/+18
| | | | | | | | | We may want to use different type_size functions for (e.g.) inputs vs. uniforms. Passing in -1 for mode ignores this, handling all modes as before. Signed-off-by: Kenneth Graunke <[email protected]> Reviewed-by: Matt Turner <[email protected]>
* nir: Don't set dest in SSBO store glsl_to_nir conversionJordan Justen2015-09-291-1/+0
| | | | | | | | | This matches the function signature created in lower_ubo_reference_visitor::ssbo_store which has a void return. Suggested-by: Jason Ekstrand <[email protected]> Signed-off-by: Jordan Justen <[email protected]> Reviewed-by: Samuel Iglesias Gonsálvez <[email protected]>
* nir: Use a system value for gl_PrimitiveIDIn.Kenneth Graunke2015-09-293-1/+10
| | | | | | | | | | | | | | | | At least on Intel hardware, gl_PrimitiveIDIn comes in as a special part of the payload rather than a normal input. This is typically what we use system values for. Dave and Ilia also agree that a system value would be nicer. At some point, we should change it at the GLSL IR level as well. But that requires changing most of the drivers. For now, let's at least make NIR do the right thing, which is easy. v2: Add a comment about not creating a temporary (suggested by Iago). Signed-off-by: Kenneth Graunke <[email protected]> Reviewed-by: Iago Toral Quiroga <[email protected]>
* nir: Convert SYSTEM_VALUE_NUM_WORK_GROUPS to a nir intrinsicJordan Justen2015-09-292-0/+5
| | | | | Signed-off-by: Jordan Justen <[email protected]> Reviewed-by: Kristian Høgsberg <[email protected]>
* nir: Add a function to count the number of vertices a GS emits.Kenneth Graunke2015-09-262-0/+95
| | | | | | | | | | | Some hardware (such as Broadwell) can run geometry shaders more efficiently when the number of vertices emitted is statically known. This pass provides a way to obtain the constant vertex count, or -1 indicating that the vertex count is unknown/non-constant. Signed-off-by: Kenneth Graunke <[email protected]> Reviewed-by: Jordan Justen <[email protected]>
* nir: Implement lowered SSBO atomic intrinsicsIago Toral Quiroga2015-09-252-0/+82
| | | | | | | | | | | | The original GLSL IR intrinsics have been lowered to an internal version that accepts a block index and an offset instead of a SSBO reference. v2 (Connor): - Document the sources used by the atomic intrinsics. Reviewed-by: Connor Abbott <[email protected]> Reviewed-by: Kristian Høgsberg <[email protected]>
* nir/glsl_to_nir: ignore an instruction's dest if it hasn't anyIago Toral Quiroga2015-09-251-1/+2
| | | | | Reviewed-by: Connor Abbott <[email protected]> Reviewed-by: Kristian Høgsberg <[email protected]>
* nir: Implement __intrinsic_load_ssboIago Toral Quiroga2015-09-253-1/+70
| | | | | | | | | | | v2: - Fix ssbo loads with boolean variables. v3: - Simplify the changes (Kristian) Reviewed-by: Connor Abbott <[email protected]> Reviewed-by: Kristian Høgsberg <[email protected]>
* nir: modify the instruction insertion in nir_visitor::visit(ir_call *ir)Samuel Iglesias Gonsalvez2015-09-251-4/+10
| | | | | | | | | | | | This patch moves nir_instr_insert_after_cf_list call into each case in the intrinsics switch at nir_visitor::visit(ir_call *ir) and define a nir_dest variable which will be used when handling ir->return_deref after the switch. This patch simplifies the code for nir_intrinsic_load_ssbo implementation changes we are going to do next. Reviewed-by: Kristian Høgsberg <[email protected]>