summaryrefslogtreecommitdiffstats
path: root/src/glsl/nir
Commit message (Collapse)AuthorAgeFilesLines
* nir: Report progress from nir_lower_system_values().Kenneth Graunke2015-09-212-10/+19
| | | | | Signed-off-by: Kenneth Graunke <[email protected]> Reviewed-by: Jason Ekstrand <[email protected]>
* nir: Report progress from nir_split_var_copies().Kenneth Graunke2015-09-212-4/+13
| | | | | Signed-off-by: Kenneth Graunke <[email protected]> Reviewed-by: Jason Ekstrand <[email protected]>
* nir: Report progress from nir_lower_locals_to_regs().Kenneth Graunke2015-09-212-4/+16
| | | | | Signed-off-by: Kenneth Graunke <[email protected]> Reviewed-by: Jason Ekstrand <[email protected]>
* nir: Report progress from nir_remove_dead_variables().Kenneth Graunke2015-09-212-5/+12
| | | | | Signed-off-by: Kenneth Graunke <[email protected]> Reviewed-by: Jason Ekstrand <[email protected]>
* nir: Report progress from lower_vec_to_movs().Jason Ekstrand2015-09-212-7/+22
| | | | | Signed-off-by: Kenneth Graunke <[email protected]> Reviewed-by: Jason Ekstrand <[email protected]>
* nir: Report progress from nir_lower_globals_vars_to_local().Kenneth Graunke2015-09-212-2/+6
| | | | | Signed-off-by: Kenneth Graunke <[email protected]> Reviewed-by: Jason Ekstrand <[email protected]>
* nir/builder: Don't use designated initializersJason Ekstrand2015-09-211-3/+18
| | | | | | | | | | | Designated initializers are not allowed in C++ (not even C++11). Since nir_lower_samplers is now using nir_builder, and nir_lower_samplers is in C++, this breaks the build on some compilers. Aparently, GCC 5 allows it in some limited extent because mesa still builds on my system without this patch. Bugzilla: https://bugs.freedesktop.org/show_bug.cgi?id=92052 Reviewed-by: Kenneth Graunke <[email protected]>
* nir: Move system value -> intrinsic mapping into nir.cJason Ekstrand2015-09-213-40/+40
| | | | | | This way they're right next to the map going the other direction. Reviewed-by: Kenneth Graunke <[email protected]>
* nir: rename nir_lower_samplers.c{pp,}Emil Velikov2015-09-211-4/+2
| | | | | | | | | | | | | | | | | | With the only C++ function having its own wrapper we can 'demote' this file to a normal C one. This allows us to get rid of extern C { #include <foo.h> } 'hacks'. Plus some of the headers may use C99 initializers, which are not supported by the ISO standard. This may cause build issue on incremental builds. If so run the following: sed -i -e 's|samplers\.cpp|samplers.c|' src/glsl/nir/.deps/nir_lower_samplers.Plo Fixes: ef8eebc6ad5(nir: support indirect indexing samplers in struct arrays) Signed-off-by: Emil Velikov <[email protected]> Reported-by: Gottfried Haider <[email protected]> Tested-by: Gottfried Haider <[email protected]> Reviewed-by: Timothy Arceri <[email protected]>
* nir: add C wrapper around glsl_type::record_location_offsetEmil Velikov2015-09-212-0/+9
| | | | | | | | This will allow us to convert nir_lower_sampler.cpp to C. Signed-off-by: Emil Velikov <[email protected]> Tested-by: Gottfried Haider <[email protected]> Reviewed-by: Timothy Arceri <[email protected]>
* nir: move stdio.h inclusion before extern CEmil Velikov2015-09-211-2/+2
| | | | | | Signed-off-by: Emil Velikov <[email protected]> Tested-by: Gottfried Haider <[email protected]> Reviewed-by: Timothy Arceri <[email protected]>
* nir/print: fix coverity errorRob Clark2015-09-201-1/+1
| | | | | | | | | | | | | | | | | | | | | | | | | Not something actually hit in real life (now state is never non-null, but only case state->syms is null is if nir_print_instr() path). But it was something I overlooked the first time, so might as well fix it. *** CID 1324642: Null pointer dereferences (REVERSE_INULL) /src/glsl/nir/nir_print.c: 299 in print_var_decl() 293 294 fprintf(fp, " (%s, %u)", loc, var->data.driver_location); 295 } 296 297 fprintf(fp, "\n"); 298 >>> CID 1324642: Null pointer dereferences (REVERSE_INULL) >>> Null-checking "state" suggests that it may be null, but it has already been dereferenced on all paths leading to the check. 299 if (state) { 300 _mesa_set_add(state->syms, name); 301 _mesa_hash_table_insert(state->ht, var, name); 302 } 303 } 304 Signed-off-by: Rob Clark <[email protected]>
* nir: add two-sided-color lowering passRob Clark2015-09-182-0/+210
| | | | | Signed-off-by: Rob Clark <[email protected]> Reviewed-by: Eric Anholt <[email protected]>
* nir/build: add nir_vec() helperRob Clark2015-09-183-31/+20
| | | | | Signed-off-by: Rob Clark <[email protected]> Reviewed-by: Connor Abbott <[email protected]>
* nir/lower_tex: add support to clamp texture coordsRob Clark2015-09-182-1/+103
| | | | | | | | | | | | | | Some hardware needs to clamp texture coordinates to [0.0, 1.0] in the shader to emulate GL_CLAMP. This is added to lower_tex_proj since, in the case of projected coords, the clamping needs to happen *after* projection. v2: comments/suggestions from Ilia and Eric, use txs to get texture size and clamp RECT textures to their dimensions rather than [0.0, 1.0] to avoid having to lower RECT textures to 2D. Signed-off-by: Rob Clark <[email protected]> Reviewed-by: Kenneth Graunke <[email protected]>
* nir/lower_tex: support for lowering RECT texturesRob Clark2015-09-182-3/+63
| | | | | | | | v2: comments/suggestions from Ilia and Eric, split out get_texture_size() helper so we can use it in the next commit for clamping RECT textures. Signed-off-by: Rob Clark <[email protected]> Reviewed-by: Kenneth Graunke <[email protected]>
* nir/lower_tex: support projector lowering per sampler typeRob Clark2015-09-182-9/+30
| | | | | | | | | | | | Some hardware, such as adreno a3xx, supports txp on some but not all sampler types. In this case we want more fine grained control over which texture projectors get lowered. v2: split out nir_lower_tex_options struct to make it easier to add the additional parameters coming in the following patches Signed-off-by: Rob Clark <[email protected]> Reviewed-by: Kenneth Graunke <[email protected]>
* nir/lower_tex: split out project_src() helperRob Clark2015-09-181-69/+77
| | | | | | | Split this out to reduce noise in later patches. Signed-off-by: Rob Clark <[email protected]> Reviewed-by: Kenneth Graunke <[email protected]>
* nir: rename nir_lower_tex_projectorRob Clark2015-09-182-6/+6
| | | | | | | | | | Since the following patches will add additional tex-lowering related functionality, which doesn't make sense to split out into a separate pass (as they would require duplication of the projector lowering logic), let's give this pass a more generic name. Signed-off-by: Rob Clark <[email protected]> Reviewed-by: Kenneth Graunke <[email protected]>
* nir/builder: fix c++11 compiler warningRob Clark2015-09-171-1/+1
| | | | | | | | | | | Fixes: In file included from nir/nir_lower_samplers.cpp:27:0: nir/nir_builder.h: In function 'nir_ssa_def* nir_channel(nir_builder*, nir_ssa_def*, int)': nir/nir_builder.h:222:37: warning: narrowing conversion of 'c' from 'int' to 'unsigned int' inside { } is ill-formed in C++11 [-Wnarrowing] unsigned swizzle[4] = {c, c, c, c}; Signed-off-by: Rob Clark <[email protected]>
* nir: really actually fix comment this timeRob Clark2015-09-171-1/+1
| | | | Signed-off-by: Rob Clark <[email protected]>
* nir/print: print variable namesRob Clark2015-09-171-0/+30
| | | | | Signed-off-by: Rob Clark <[email protected]> Reviewed-by: Timothy Arceri <[email protected]>
* nir: some comment fixupsRob Clark2015-09-171-5/+5
| | | | | Signed-off-by: Rob Clark <[email protected]> Reviewed-by: Timothy Arceri <[email protected]>
* nir: add lowering stage for user-clip-planes / clipdistRob Clark2015-09-172-0/+343
| | | | | | | | | | | | | | | The vertex shader lowering adds calculation for CLIPDIST, if needed (ie. user-clip-planes), and the frag shader lowering adds conditional kills based on CLIPDIST value (which should be treated as a normal interpolated varying by the driver). Note that this won't quite do the right thing in the face of MSAA plus user-clip-planes, since all the samples would be killed or not (rather than potentially only a portion of them). But it's better than no UCP support at all for drivers that don't have this in hw. Signed-off-by: Rob Clark <[email protected]> Reviewed-by: Eric Anholt <[email protected]>
* nir: add sysval for user-clip-planesRob Clark2015-09-171-13/+14
| | | | | | | | For lowering user-clip-planes, we need a way to pass the enabled/used user-clip-planes in to shader. Signed-off-by: Rob Clark <[email protected]> Reviewed-by: Jason Ekstrand <[email protected]>
* nir: Add a pass to rewrite uses of vecN sources to the vecN destinationJason Ekstrand2015-09-172-0/+198
| | | | | | | v2 (Jason Ekstrand): - Handle non-SSA sources and destinations Reviewed-by: Eduardo Lima Mitev <[email protected]>
* nir: Add comments to nir_index_instrs and nir_index_ssa_defsJason Ekstrand2015-09-171-0/+8
| | | | | | | The provided indices have the very nice property that if A dominates B then A->index <= B->index. We should document that somewhere. Reviewed-by: Kenneth Graunke <[email protected]>
* nir: Add a generic instruction indexJason Ekstrand2015-09-172-0/+22
| | | | Reviewed-by: Kenneth Graunke <[email protected]>
* nir: support indirect indexing samplers in struct arraysTimothy Arceri2015-09-171-76/+88
| | | | | | | | | | | | | | | | As a bonus we get indirect support for arrays of arrays for free. V5: couple of small clean-ups suggested by Jason. V4: fix struct member location caclulation, use nir_ssa_def rather than nir_src for the indirect as suggested by Jason V3: Use nir_instr_rewrite_src() with empty src rather then clearing the use_link list directly for the old indirects as suggested by Jason V2: Fixed validation error in debug build Reviewed-by: Jason Ekstrand <[email protected]>
* glsl: store uniform slot id in var location fieldTimothy Arceri2015-09-171-0/+1
| | | | | | | | | | | | | | This will allow us to access the uniform later on without resorting to building a name string and looking it up in UniformHash. V3: remove line wrap change from this patch V2: store slot number for all non-UBO uniforms to make code more consitent, renamed explicit_binding to explicit_location and added comment about what it does. Store the location at every shader stage. Updated data.location comments in ir/nir.h. Reviewed-by: Jason Ekstrand <[email protected]>
* nir/print: print symbolic names from shader-enumRob Clark2015-09-161-3/+42
| | | | | | | | | v2: split out moving of FILE *fp into state structure into it's own (more complete patch) to reduce the noise in this one Signed-off-by: Rob Clark <[email protected]> Reviewed-by: Connor Abbott <[email protected]> Reviewed-by: Iago Toral Quiroga <[email protected]>
* nir/print: bit of state refactoringRob Clark2015-09-161-109/+152
| | | | | | | | | | | | Rename print_var_state to print_state, and stuff FILE ptr into the state object. This avoids passing around an extra parameter everywhere. v2: even more extensive conversion.. use state *everywhere* instead of FILE ptr, and convert nir_print_instr() to use state as well Signed-off-by: Rob Clark <[email protected]> Reviewed-by: Iago Toral Quiroga <[email protected]> Reviewed-by: Connor Abbott <[email protected]>
* nir: add lowering for ffractRob Clark2015-09-162-0/+4
| | | | | Signed-off-by: Rob Clark <[email protected]> Reviewed-by: Iago Toral Quiroga <[email protected]>
* nir/builder: Use a normal temporary array in nir_channelJason Ekstrand2015-09-151-1/+2
| | | | | | | | C++ gets cranky if we take references of temporaries. This isn't a problem yet in master because nir_builder is never used from C++. However, it will be in the future so we should fix it now. Reviewed-by: Rob Clark <[email protected]>
* nir/lower_vec_to_movs: Coalesce into destinations of fdot instructionsJason Ekstrand2015-09-151-13/+36
| | | | | | | | | | | | | | | | | | | Now that we have a replicating fdot instruction, we can actually coalesce into the destinations of vec4 instructions. We couldn't really do this before because, if the destination had to end up in .z, we couldn't reswizzle the instruction. With a replicated destination, the result ends up in all channels so we can just set the writemask and we're done. Shader-db results for vec4 programs on Haswell: total instructions in shared programs: 1747753 -> 1746280 (-0.08%) instructions in affected programs: 143274 -> 141801 (-1.03%) helped: 667 HURT: 0 It turns out that dot-products matter... Reviewed-by: Eduardo Lima Mitev <[email protected]>
* nir: Add a fdot instruction that replicates the result to a vec4Jason Ekstrand2015-09-153-0/+12
| | | | | | | | Fortunately, nir_constant_expr already auto-splats if "dst" never shows up in the constant expression field so we don't need to do anything there. Reviewed-by: Connor Abbott <[email protected]> Reviewed-by: Eduardo Lima Mitev <[email protected]>
* nir/lower_vec_to_movs: Coalesce movs on-the-fly when possibleJason Ekstrand2015-09-151-0/+85
| | | | | | | | | | | | | | | | | | | The old pass blindly inserted a bunch of moves into the shader with no concern for whether or not it was really needed. This adds code to try and coalesce into the destination of the instruction providing the value. Shader-db results for vec4 shaders on Haswell: total instructions in shared programs: 1754420 -> 1747753 (-0.38%) instructions in affected programs: 231230 -> 224563 (-2.88%) helped: 1017 HURT: 2 This approach is heavily based on a different patch by Eduardo Lima Mitev <[email protected]>. Eduardo's patch did this in a separate pass as opposed to integrating it into nir_lower_vec_to_movs. Reviewed-by: Eduardo Lima Mitev <[email protected]>
* nir/lower_vec_to_movs: Get rid of start_idx and swizzle compactingJason Ekstrand2015-09-151-20/+13
| | | | | | | | | | | | | Previously, we did this thing with keeping track of a separate start_idx which was different from the iteration variable. I think this was a relic of the way that GLSL IR implements writemasks. In NIR, if a given bit in the writemask is unset then that channel is just "unused", not missing. In particular, a vec4 operation with a writemask of 0xd will use sources 0, 2, and 3 and leave source 1 alone. We can simplify things a good deal (and make them correct) by removing this "compacting" step. Reviewed-by: Eduardo Lima Mitev <[email protected]> Reviewed-by: Eric Anholt <[email protected]>
* nir/lower_vec_to_movs: Handle partially SSA shadersJason Ekstrand2015-09-151-6/+15
| | | | | | | | v2 (Jason Ekstrand): - Use nir_instr_rewrite_dest - Pass the impl directly into lower_vec_to_movs_block Reviewed-by: Eduardo Lima Mitev <[email protected]>
* nir/lower_vec_to_movs: Pass the shader around directlyJason Ekstrand2015-09-151-6/+8
| | | | | | | | Previously, we were passing the shader around, we were just calling it "mem_ctx". However, the nir_shader is (and must be for the purposes of mark-and-sweep) the mem_ctx so we might as well pass it around explicitly. Reviewed-by: Eduardo Lima Mitev <[email protected]>
* nir: Add gl_WorkGroupID system variableJordan Justen2015-09-133-0/+6
| | | | | Signed-off-by: Jordan Justen <[email protected]> Reviewed-by: Kristian Høgsberg <[email protected]>
* nir: Add gl_LocalInvocationID variableJordan Justen2015-09-133-0/+6
| | | | | | Signed-off-by: Jordan Justen <[email protected]> Reviewed-by: Iago Toral Quiroga <[email protected]> Reviewed-by: Kristian Høgsberg <[email protected]>
* nir: add nir_channel() to get at single components of vec'sRob Clark2015-09-133-28/+22
| | | | | | | Rather than make yet another copy of channel(), let's move it into nir. Signed-off-by: Rob Clark <[email protected]> Reviewed-by: Jason Ekstrand <[email protected]>
* nir/from_ssa: Use instr_rewrite_destJason Ekstrand2015-09-111-3/+1
| | | | Reviewed-by: Eduardo Lima Mitev <[email protected]>
* nir: Add a function for rewriting instruction destinationsJason Ekstrand2015-09-112-0/+26
| | | | Reviewed-by: Eduardo Lima Mitev <[email protected]>
* nir: Only unlink sources that are actually validJason Ekstrand2015-09-111-7/+8
| | | | Reviewed-by: Thomas Helland <[email protected]>
* nir: Remove the mem_ctx parameter from ssa_def_rewrite_usesJason Ekstrand2015-09-1120-47/+25
| | | | Reviewed-by: Thomas Helland <[email protected]>
* nir: Fix a bunch of ralloc parenting errorsJason Ekstrand2015-09-1110-31/+32
| | | | | | | | | | | | | | As of a10d4937, we would really like things associated with an instruction to be allocated out of that instruction and not out of the shader. In particular, you should be passing the instruction that will ultimately be holding the source into nir_src_copy rather than an arbitrary memory context. We also change the prototypes of nir_dest_copy and nir_alu_src/dest_copy to explicitly take an instruction so we catch this earlier in the future. Cc: "11.0" <[email protected]> Reviewed-by: Thomas Helland <[email protected]>
* nir/lower_outputs_to_temporaries: Reparent the output nameJason Ekstrand2015-09-111-0/+3
| | | | | | | | | | We copy the output, make the old output the temporary, and give the temporary a new name. The copy keeps the pointer to the old name. This works just fine up until the point where we lower things to SSA and delete the old variable and, with it, the name. Instead, we should re-parent to the copy. Reviewed-by: Eduardo Lima Mitev <[email protected]>
* nir: Store some geometry shader data in nir_shader.Kenneth Graunke2015-09-113-0/+14
| | | | | | | | | | | | | | | | | | | | | | | | This makes it possible for NIR shaders to know the number of output vertices and the number of invocations. Drivers could also access these directly without going through gl_program. We should probably add InputType and OutputType here too, but currently those are stored as GL_* enums, and I wanted to avoid using those in NIR, as I suspect Vulkan/SPIR-V will use different enums. (We should probably make our own.) We could add VerticesIn, but it's easily computable from the input topology, so I'm not sure whether it's worth it. It's also currently not stored in gl_shader (only gl_shader_program), which would require changes to the glsl_to_nir interface or require us to store it there. This is a bit of duplication of data...ideally, we would factor these substructs out of gl_program, gl_shader_program, and nir_shader, creating a gl_geometry_info class...but it would need to go in a new place (in src/glsl?) that isn't mtypes.h nor nir.h. Signed-off-by: Kenneth Graunke <[email protected]> Reviewed-by: Jason Ekstrand <[email protected]>