summaryrefslogtreecommitdiffstats
path: root/src/compiler/nir
Commit message (Collapse)AuthorAgeFilesLines
* nir/gather_info: Set info.gs.uses_streamsNeil Roberts2018-07-311-0/+5
| | | | | | | | | | | Whenever a non-zero stream is written to it now sets uses_streams to true. This reflects the code in validate_geometry_shader_emissions for GLSL. v2: set uses_streams at gather_info instead that at spirv to nir (Jason Ekstrand) Reviewed-by: Jason Ekstrand <[email protected]>
* nir: Add members for the explicit XFB properties to nir_variableNeil Roberts2018-07-311-1/+26
| | | | | | | | These are copied from the from the corresponding values in ir_variable. The intention is to eventually use them in a pure-NIR linker. Reviewed-by: Timothy Arceri <[email protected]>
* nir/instr_set: Fix nir_instrs_equal for derefsJason Ekstrand2018-07-291-2/+2
| | | | | | | | | | | | We weren't returning at the end of the nir_isntr_type_deref case in nir_instrs_equal and it was falling through to the default of false. While we're at it, make the default unreachable because all statements in the switch now have their own returns. Had we done that before, we would have caught this bug a long time ago. Fixes: 19a4662a540a8c94 "nir: Add a deref instruction type" Reviewed-by: Caio Marcelo de Oliveira Filho <[email protected]> Reviewed-by: Thomas Helland<[email protected]>
* nir: Take if uses into account in ssa_def_components_readJason Ekstrand2018-07-291-0/+3
| | | | | Fixes: d800b7daa5440 "nir: Add a helper for figuring out what..." Reviewed-by: Caio Marcelo de Oliveira Filho <[email protected]>
* nir/lower_int64: mark all metadata as dirtyKarol Herbst2018-07-281-0/+3
| | | | | | | | | v2: use nir_metadata_preserve preserve metadata in case of !progress Fixes: 074f5ba0b56b12ddaca81eac3d9ed19da7054297 "nir: Add a simple int64 lowering pass" Signed-off-by: Karol Herbst <[email protected]>
* i965: Combine both gl_PatchVerticesIn lowering passes.Kenneth Graunke2018-07-262-7/+64
| | | | | | | | | | | | | | | | | | Until now, we had separate passes for lowering gl_PatchVerticesIn to a statically known constant (for TES inputs when linked against a TCS), and a uniform in the other cases. Annoyingly, one had to be run before nir_lower_system_values, and the other afterward. This simplified the passes, but made life painful for the callers. This patch combines both into a single pass. If you give it a non-zero static count, it uses that. If you give it Mesa state slots, it turns it back into a built-in uniform. Otherwise, it does nothing. This also moves the i965 uniform lowering out to shared code. v2: Make token arrays const. Reviewed-by: Eric Anholt <[email protected]>
* nir: Add flipping of gl_PointCoord.y in nir_lower_wpos_ytransform.Eric Anholt2018-07-262-0/+32
| | | | | | | This is controlled by a new nir_shader_compiler_options flag, and fixes dEQP-GLES3.functional.shaders.builtin_variable.pointcoord on V3D. Reviewed-by: Kenneth Graunke <[email protected]>
* nir: remove wrong assertion in print_var_decl()Samuel Pitoiset2018-07-261-1/+0
| | | | | | | | | This breaks printing input/output variables with more than 4 components like mat4. Fixes: 1beef89ad8 ("nir: prepare for bumping up max components to 16") Signed-off-by: Samuel Pitoiset <[email protected]> Reviewed-by: Bas Nieuwenhuizen <[email protected]>
* nir: Add a couple of iand/ior optimizationsJason Ekstrand2018-07-241-0/+4
| | | | | | Spotted in a shader in Batman: Arkham City. Reviewed-by: Timothy Arceri <[email protected]>
* nir/serialize: Alloc constants off the variableJason Ekstrand2018-07-241-1/+1
| | | | | | | | | | | nir_sweep assumes that constants area always allocated off the variable to which they belong. Violating this assumption causes them to get freed early and leads to use-after-free bugs. Fixes: 120da00975541 "nir: add serialization and deserialization" Bugzilla: https://bugs.freedesktop.org/show_bug.cgi?id=107366 Reviewed-by: Lionel Landwerlin <[email protected]> Tested-by: Mark Janes <[email protected]>
* nir: rename f2f16_undef to f2f16Karol Herbst2018-07-242-6/+6
| | | | | | | | | | | we need rounding modes on other conversions involving floats and it is easier to rename f2f16_undef than renaming all the other ones. v2: rebased on master Reviewed-by: Jason Ekstrand <[email protected]> Acked-by: Rob Clark <[email protected]> Signed-off-by: Karol Herbst <[email protected]>
* nir: add builtin builderKarol Herbst2018-07-243-0/+151
| | | | | | | | | | | also move some of the GLSL builtins over we will need for implementing some OpenCL builtins v2: replace NIR_IMM_FP by nir_imm_floatN_t in ported code fix up changes caused by swizzle rework Reviewed-by: Jason Ekstrand <[email protected]> Signed-off-by: Karol Herbst <[email protected]>
* python: Use range() instead of xrange()Mathieu Bridon2018-07-241-2/+2
| | | | | | | | | | | | | | | | Python 2 has a range() function which returns a list, and an xrange() one which returns an iterator. Python 3 lost the function returning a list, and renamed the function returning an iterator as range(). As a result, using range() makes the scripts compatible with both Python versions 2 and 3. Signed-off-by: Mathieu Bridon <[email protected]> Reviewed-by: Eric Engestrom <[email protected]> Reviewed-by: Dylan Baker <[email protected]> Reviewed-by: Ian Romanick <[email protected]>
* python: Better use iteratorsMathieu Bridon2018-07-241-2/+2
| | | | | | | | | | | | | | | | | In Python 2, iterators had a .next() method. In Python 3, instead they have a .__next__() method, which is automatically called by the next() builtin. In addition, it is better to use the iter() builtin to create an iterator, rather than calling its __iter__() method. These were also introduced in Python 2.6, so using it makes the script compatible with Python 2 and 3. Signed-off-by: Mathieu Bridon <[email protected]> Reviewed-by: Eric Engestrom <[email protected]> Reviewed-by: Dylan Baker <[email protected]>
* python: Better iterate over dictionariesMathieu Bridon2018-07-246-8/+8
| | | | | | | | | | | | | | | | In Python 2, dictionaries have 2 sets of methods to iterate over their keys and values: keys()/values()/items() and iterkeys()/itervalues()/iteritems(). The former return lists while the latter return iterators. Python 3 dropped the method which return lists, and renamed the methods returning iterators to keys()/values()/items(). Using those names makes the scripts compatible with both Python 2 and 3. Signed-off-by: Mathieu Bridon <[email protected]> Reviewed-by: Eric Engestrom <[email protected]> Reviewed-by: Dylan Baker <[email protected]>
* nir: Add a couple trivial abs optimizationsJason Ekstrand2018-07-231-0/+2
| | | | | | | Spotted in a shader in Batman: Arkham City. Reviewed-by: Matt Turner <[email protected]> Reviewed-by: Ian Romanick <[email protected]>
* nir: Fix end of function without return warning/error.Bas Nieuwenhuizen2018-07-201-0/+2
| | | | | | | | | There always is a continue block, so let us just do unreachable. Reviewed-by: Jason Ekstrand <[email protected]> Fixes: 8cacf38f527 "nir: Do not use continue block after removing it." CC: 18.1 <[email protected]> Bugzilla: https://bugs.freedesktop.org/show_bug.cgi?id=107312
* nir: Do not use continue block after removing it.Bas Nieuwenhuizen2018-07-201-6/+25
| | | | | | | | | | | | | | | | Reinserting code directly before a jump means the block gets split and merged, removing the original block and replacing it in the process. Hence keeping a pointer to the continue block over a reinsert causes issues. This code changes nir_opt_if to simply look for the new continue block. Reviewed-by: Jason Ekstrand <[email protected]> Bugzilla: https://bugs.freedesktop.org/show_bug.cgi?id=107275 CC: 18.1 <[email protected]>
* nir: add lowering for gl_HelperInvocationRob Clark2018-07-183-0/+34
| | | | | | | | | v2: reword comment about lower_helper_invocations to be more clear that it might not work on all hardware v3: add special variant of load_sample_id which does not imply per- sample shading Signed-off-by: Rob Clark <[email protected]>
* nir: fixup intrinsic commentRob Clark2018-07-181-1/+1
| | | | | | | Now the deref is the first src. Signed-off-by: Rob Clark <[email protected]> Reviewed-by: Samuel Iglesias Gonsálvez <[email protected]>
* nir: add a couple of ior opts to nir_opt_algebraicTimothy Arceri2018-07-181-0/+3
| | | | | | One of these was seen in a Deus Ex shader. Reviewed-by: Jason Ekstrand <[email protected]>
* nir: allow opt_peephole_select to handle nir_instr_type_derefTimothy Arceri2018-07-181-0/+1
| | | | Reviewed-by: Jason Ekstrand <[email protected]>
* nir: prepare for bumping up max components to 16Karol Herbst2018-07-1711-51/+55
| | | | | | | | | | | OpenCL knows vector of size 8 and 16. v2: rebased on master (nir_swizzle rework) rework more declarations with nir_component_mask_t adjust print_var_decl Reviewed-by: Jason Ekstrand <[email protected]> Signed-off-by: Karol Herbst <[email protected]>
* nir: fix msvc buildRoland Scheidegger2018-07-161-1/+1
| | | | | | | | Empty initializer braces aren't valid c (it's a gnu extension, and it's valid in c++). Hopefully fixes appveyor / msvc build... Fixes a3150c1d06ae7766c3d3fe3b33432e55c3c7527e
* nir/worklist: Rework the foreach macroJason Ekstrand2018-07-162-4/+3
| | | | | | | | | This makes the arguments match the (thing, container) pattern used in other nir_foreach macros and also renames it to make that a bit more clear. Reviewed-by: Caio Marcelo de Oliveira Filho <[email protected]> Reviewed-by: Eric Anholt <[email protected]>
* nir: fix printing of vec16 typeKarol Herbst2018-07-151-0/+1
| | | | | | | | Fixes: 2f181c8c183cc8b4d0450789bb20c2be48d32db3 "glsl_types: vec8/vec16 support" Reviewed-by: Jason Ekstrand <[email protected]> Signed-off-by: Karol Herbst <[email protected]>
* nir/spirv: implement BuiltInWorkDimRob Clark2018-07-152-0/+3
| | | | | Reviewed-by: Jason Ekstrand <[email protected]> Signed-off-by: Karol Herbst <[email protected]>
* nir/lower_tex: Use nir_format_srgb_to_linearJason Ekstrand2018-07-131-18/+3
| | | | | | | A while ago, we added a bunch of format conversion helpers; we should use them instead of hand-rolling sRGB conversions. Reviewed-by: Eric Anholt <[email protected]>
* nir: cleanup oversized arrays in nir_swizzle callsKarol Herbst2018-07-133-15/+11
| | | | | | | | | | There are no fixed sized array arguments in C, those are simply pointers to unsized arrays and as the size is passed in anyway, just rely on that. where possible calls are replaced by nir_channel and nir_channels. Reviewed-by: Jason Ekstrand <[email protected]> Signed-off-by: Karol Herbst <[email protected]>
* nir: delete not needed for reinserted nir_cf_listCaio Marcelo de Oliveira Filho2018-07-121-2/+0
| | | | | | | It wasn't causing problems since there's nothing to delete, but better be consistent with the rest of existing codebase. Reviewed-by: Jason Ekstrand <[email protected]>
* nir/spirv: implement BuiltInGlobalSizeKarol Herbst2018-07-121-0/+7
| | | | | Reviewed-by: Jason Ekstrand <[email protected]> Signed-off-by: Karol Herbst <[email protected]>
* nir: move lowering of SYSTEM_VALUE_LOCAL_GROUP_SIZE into a functionKarol Herbst2018-07-121-16/+14
| | | | | | | | we already have this code duplicated and we will need it for the global group size as well Reviewed-by: Jason Ekstrand <[email protected]> Signed-off-by: Karol Herbst <[email protected]>
* nir/print: Print texture and sampler indicesJason Ekstrand2018-07-071-0/+11
| | | | | | | | Commit 5fb69daa6076e56b deleted support from nir_print for printing the texture and sampler indices on texture instructions. This commit just brings it back as best as we can. Reviewed-by: Bas Nieuwenhuizen <[email protected]>
* python: Use the print functionMathieu Bridon2018-07-065-10/+17
| | | | | | | | | | | | In Python 2, `print` was a statement, but it became a function in Python 3. Using print functions everywhere makes the script compatible with Python versions >= 2.6, including Python 3. Signed-off-by: Mathieu Bridon <[email protected]> Acked-by: Eric Engestrom <[email protected]> Acked-by: Dylan Baker <[email protected]>
* nir: Apply fragment color clamping to gl_FragData[] as well.Eric Anholt2018-07-051-7/+2
| | | | | | | | | | | | | | From the ARB_color_buffer_float spec: 35. Should the clamping of fragment shader output gl_FragData[n] be controlled by the fragment color clamp. RESOLVED: Since the destination of the FragData is a color buffer, the fragment color clamp control should apply. Fixes arb_color_buffer_float-mrt mixed on v3d. Reviewed-by: Rob Clark <[email protected]>
* python: Stabilize some script outputsMathieu Bridon2018-07-052-2/+4
| | | | | | | | | | | | In Python, dictionaries and sets are unordered, and as a result their is no guarantee that running this script twice will produce the same output. Using ordered dicts and explicitly sorting items makes the build more reproducible, and will make it possible to verify that we're not breaking anything when we move the build scripts to Python 3. Reviewed-by: Eric Engestrom <[email protected]>
* nir: Fix OpAtomicCounterIDecrement for uniform atomic countersAntia Puentes2018-07-032-4/+7
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | From the SPIR-V 1.0 specification, section 3.32.18, "Atomic Instructions": "OpAtomicIDecrement: <skip> The instruction's result is the Original Value." However, we were implementing it, for uniform atomic counters, as a pre-decrement operation, as was the one available from GLSL. Renamed the former nir intrinsic 'atomic_counter_dec*' to 'atomic_counter_pre_dec*' for clarification purposes, as it implements a pre-decrement operation as specified for GLSL. From GLSL 4.50 spec, section 8.10, "Atomic Counter Functions": "uint atomicCounterDecrement (atomic_uint c) Atomically 1. decrements the counter for c, and 2. returns the value resulting from the decrement operation. These two steps are done atomically with respect to the atomic counter functions in this table." Added a new nir intrinsic 'atomic_counter_post_dec*' which implements a post-decrement operation as required by SPIR-V. v2: (Timothy Arceri) * Add extra spec quotes on commit message * Use "post" instead "pos" to avoid confusion with "position" Signed-off-by: Antia Puentes <[email protected]> Signed-off-by: Alejandro Piñeiro <[email protected]> Reviewed-by: Timothy Arceri <[email protected]>
* nir: Add a large constants optimization passJason Ekstrand2018-07-023-0/+310
| | | | | | | | | | | | | | | | This pass searches for reasonably large local variables which can be statically proven to be constant and moves them into shader constant data. This is especially useful when large tables are baked into the shader source code because they can be moved into a UBO by the driver to reduce register pressure and make indirect access cheaper. v2 (Jason Ekstrand): - Use a size/align function to ensure we get the right alignments - Use the newly added deref offset helpers Reviewed-by: Timothy Arceri <[email protected]> Reviewed-by: Iago Toral Quiroga <[email protected]> Reviewed-by: Kenneth Graunke <[email protected]>
* nir: Add a concept of constant data associated with a shaderJason Ekstrand2018-07-025-0/+30
| | | | | | | | | | | | | | | | | | | This commit adds a concept to NIR of having a blob of constant data associated with a shader. Instead of being a UBO or uniform that can be manipulated by the client, this constant data considered part of the shader and remains constant across all invocations of the given shader until the end of time. To access this constant data from the shader, we add a new load_constant intrinsic. The intention is that drivers will eventually lower load_constant intrinsics to load_ubo, load_uniform, or something similar. Constant data will be used by the optimization pass in the next commit but this concept may also be useful for OpenCL. v2 (Jason Ekstrand): - Rename num_constants to constant_data_size (anholt) Reviewed-by: Timothy Arceri <[email protected]> Reviewed-by: Iago Toral Quiroga <[email protected]> Reviewed-by: Kenneth Graunke <[email protected]>
* nir/deref: Add helpers for getting offsetsJason Ekstrand2018-07-022-0/+95
| | | | | | | | | | | | | These are very similar to the related function in nir_lower_io except that they don't handle per-vertex or packed things (that could be added, in theory) and they take a more detailed size/align function pointer. One day, we should consider switching nir_lower_io over to using the more detailed size/align functions and then we could make it use these helpers instead of having its own. Reviewed-by: Timothy Arceri <[email protected]> Reviewed-by: Iago Toral Quiroga <[email protected]> Reviewed-by: Kenneth Graunke <[email protected]>
* nir: Add a deref_instr_has_indirect helperJason Ekstrand2018-07-022-0/+20
| | | | | | Reviewed-by: Timothy Arceri <[email protected]> Reviewed-by: Iago Toral Quiroga <[email protected]> Reviewed-by: Kenneth Graunke <[email protected]>
* nir: fix selection of loop terminator when two or more have the same limitTimothy Arceri2018-06-302-4/+4
| | | | | | | | | | | | | | | | | We need to add loop terminators to the list in the order we come across them otherwise if two or more have the same exit condition we will select that last one rather than the first one even though its unreachable. This fix is for simple unrolls where we only have a single exit point. When unrolling these type of loops the unreachable terminators and their unreachable branch are removed prior to unrolling. Because of the logic change we also switch some list access in the complex unrolling logic to avoid breakage. Fixes: 6772a17acc8e ("nir: Add a loop analysis pass") Reviewed-by: Jason Ekstrand <[email protected]>
* nir/opt_if: Remove unneeded phis if we make progressJason Ekstrand2018-06-263-3/+11
| | | | | | | | | | Now that SSA values can be derefs and they have special rules, we have to be a bit more careful about our LCSSA phis. In particular, we need to clean up in case LCSSA ended up creating a phi node for a deref. This fixes validation issues with some Vulkan CTS tests with the new deref instructions. Reviewed-by: Samuel Iglesias Gonsálvez <[email protected]>
* nir/lower_system_values: Assert/assume direct var derefsJason Ekstrand2018-06-221-4/+13
| | | | | | | | | | | | | System values are never arrays or structs so we can assume a direct var deref. This simplifies things a bit and prevents us from accidentally throwing away an array index. Suggested-by: Caio Marcelo de Oliveira Filho <[email protected]> Reviewed-by: Caio Marcelo de Oliveira Filho <[email protected]> Acked-by: Rob Clark <[email protected]> Acked-by: Bas Nieuwenhuizen <[email protected]> Acked-by: Dave Airlie <[email protected]> Reviewed-by: Kenneth Graunke <[email protected]>
* nir: Remove old-school deref chain supportJason Ekstrand2018-06-2238-1354/+6
| | | | | | | Acked-by: Rob Clark <[email protected]> Acked-by: Bas Nieuwenhuizen <[email protected]> Acked-by: Dave Airlie <[email protected]> Reviewed-by: Kenneth Graunke <[email protected]>
* nir: Remove deref chain support from analyze_loopsJason Ekstrand2018-06-221-56/+0
| | | | | | | | | | Note that this patch needs to come late in the series since this pass can be run after any pass that damages nir_metadata_loop_analysis. Acked-by: Rob Clark <[email protected]> Acked-by: Bas Nieuwenhuizen <[email protected]> Acked-by: Dave Airlie <[email protected]> Reviewed-by: Kenneth Graunke <[email protected]>
* nir: promote intrinsic_get_var() to helperRob Clark2018-06-222-10/+10
| | | | | | | | | | Useful in a few other places.. let's not copy-pasta Signed-off-by: Rob Clark <[email protected]> Acked-by: Rob Clark <[email protected]> Acked-by: Bas Nieuwenhuizen <[email protected]> Acked-by: Dave Airlie <[email protected]> Reviewed-by: Kenneth Graunke <[email protected]>
* nir: Rework lower_locals_to_regs to use deref instructionsJason Ekstrand2018-06-221-100/+88
| | | | | | | | | | This completely reworks the pass to support deref instructions and delete support for old deref chains Acked-by: Rob Clark <[email protected]> Acked-by: Bas Nieuwenhuizen <[email protected]> Acked-by: Dave Airlie <[email protected]> Reviewed-by: Kenneth Graunke <[email protected]>
* nir: Rework opt_copy_prop_vars to use deref instructionsJason Ekstrand2018-06-221-170/+146
| | | | | | | Acked-by: Rob Clark <[email protected]> Acked-by: Bas Nieuwenhuizen <[email protected]> Acked-by: Dave Airlie <[email protected]> Reviewed-by: Kenneth Graunke <[email protected]>
* nir/copy_prop_vars: Re-order some logic in compare_derefsJason Ekstrand2018-06-221-8/+8
| | | | | | | Acked-by: Rob Clark <[email protected]> Acked-by: Bas Nieuwenhuizen <[email protected]> Acked-by: Dave Airlie <[email protected]> Reviewed-by: Kenneth Graunke <[email protected]>