nir: Add a new nir_var_mem_constant variable mode Reviewed-by: Eric Anholt <eric@anholt.net> Reviewed-by: Jesse Natalie <jenatali@microsoft.com> Reviewed-by: Karol Herbst <kherbst@redhat.com> Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/6379>
nir: Rename num_shared to shared_size This one is always a size in bytes. Reviewed-by: Boris Brezillon <boris.brezillon@collabora.com> Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/6524>
nir/vtn: Add type constant to image intrinsics Since OpenCL supports untyped images, backends might need type info to be able to support the load/store ops. Reviewed-by: Jason Ekstrand <jason@jlekstrand.net> Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/5242>
nir: Switch the indexing of block->live_in/out arrays. In nir-to-tgsi, I want to free temps storing SSA values when they go dead, and NIR liveness has most of the information I need. Hoever, when I reach the end of a block, I need to free whatever temps were in liveout which are dead at that point. If liveout is indexed by live_index, then I don't know the maximum live_index for iterating the live_out bitset, and I also don't have a way to map that index back to the def->index that my temps are stored under. We can use the more typical def->index for these bitsets, which resolves both of those problems. The only cost is that ssa_undefs don't get merged into a single bit in the bitfield, but there are generally 1-4 of them in a shader and we don't track liveness for those anyway so splitting them apart is fine. Reviewed-by: Jason Ekstrand <jason@jlekstrand.net> Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/6408>
nir: Invalidate live SSA def information when making new SSA defs. Noted by @jekstrand in review of the SSA live index changes. Reviewed-by: Jason Ekstrand <jason@jlekstrand.net> Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/6408>
nir: fix nir_variable_create for kernels We ended up with INTERP_MODE_SMOOTH but we really just want to have NONE. Signed-off-by: Karol Herbst <kherbst@redhat.com> Reviewed-by: Jason Ekstrand <jason@jlekstrand.net> Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/5891>
nir: Add new system values and intrinsics for dealing with CL work offsets New intrinsics are added for global invocation IDs and work group IDs to deal with offsets in both. The only one of these that needs a system value is global invocation offset, for CL's get_global_offset(). Note that CL requires very large work group sizes, so these intrinsics are modified to be able to use 64bit values, for 64bit SPIR-V. Reviewed-by: Karol Herbst <kherbst@redhat.com> Reviewed-by: Jason Ekstrand <jason@jlekstrand.net> Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/5891>
nir: Populate some places where existing system values were missing Reviewed-by: Karol Herbst <kherbst@redhat.com> Reviewed-by: Jason Ekstrand <jason@jlekstrand.net> Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/5891>
nir: Initialize nir_ssa_def::live_index Previously, this was left uninitialized. Let's initialize it to an obviously bogus value so we notice if anyone ever tries to use stale liveness data. Reviewed-by: Caio Marcelo de Oliveira Filho <caio.oliveira@intel.com> Reviewed-by: Jesse Natalie <jenatali@microsoft.com> Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/6210>
spirv: parse unstructured CFG v2 (Boris Brezillon): handle functions with return values v3: call structurizer v4: entire rewrite v5: fix handling of already visited default branches v2 (Jason Ekstrand): Stop walking hash tables Signed-off-by: Karol Herbst <kherbst@redhat.com> Reviewed-by: Jason Ekstrand <jason@jlekstrand.net> Tested-by: Jesse Natalie <jenatali@microsoft.com> Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/2401>
nir: Add goto_if jump instruction Signed-off-by: Karol Herbst <kherbst@redhat.com> Reviewed-by: Jason Ekstrand <jason@jlekstrand.net> Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/2401>
nir: Add and use nir_foreach_block_unstructured helpers These are safe to call on either structured or unstructured NIR but don't provide the nice ordering guarantees of nir_foreach_block and friends. While we're here, we use them for a very small selection of passes which are known to be safe for unstructured control-flow. The most important such pass is nir_dominance which is required for structurizing. Signed-off-by: Karol Herbst <kherbst@redhat.com> Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/2401>
nir: Add a structured flag to nir_shader v2 (Jason Ekstrand): - Make "structured" a property of nir_function_impl not nir_shader - More validation and asserts Signed-off-by: Karol Herbst <kherbst@redhat.com> Reviewed-by: Jason Ekstrand <jason@jlekstrand.net> Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/2401>
nir: Add a find_variable_with_[driver_]location helper We've hand-rolled this loop 10 places and those are just the ones I found easily. Reviewed-by: Eric Anholt <eric@anholt.net> Reviewed-by: Iago Toral Quiroga <itoral@igalia.com> Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/5966>
nir: Use a single list for all shader variables Instead of having separate lists of variables, roughly sorted by mode, use a single list for all shader-level NIR variables. This makes a few list walks a bit longer here and there but list walks aren't a very common thing in NIR at all. On the other hand, it makes a lot of things like validation, printing, etc. way simpler. Also, there are a number of cases where we move variables from inputs/outputs to globals and this makes it way easier because we no longer have to move them between lists. We only have to deal with that if moving them from the shader to a nir_function_impl. Reviewed-by: Rob Clark <robdclark@chromium.org> Reviewed-By: Mike Blumenkrantz <michael.blumenkrantz@gmail.com> Reviewed-by: Vasily Khoruzhick <anarsoul@gmail.com> Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/5966>
nir: Split nir_index_vars into two functions We also very slightly change the semantics. It no longer is one index per list for global variables and is a single index over-all. Reviewed-by: Gert Wollny <gert.wollny@collabora.com> Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/5966>
nir: Add and use a nir_variable_list_for_mode helper We also add a new list iterator which takes a modes bitfield and automatically figures out which list to use. In the future, this iterator will work for multiple modes but today it assumes a single mode thanks to the behavior of nir_variable_list_for_mode. This also doesn't work for function_temp variables. Reviewed-by: Gert Wollny <gert.wollny@collabora.com> Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/5966>
nir: Add nir_foreach_shader_in/out_variable helpers Reviewed-by: Jose Maria Casanova Crespo <jmcasanova@igalia.com> Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/5966>
compiler: Add a system value for the line coord The line coord is a coordinate along the axis perpendicular to the line. It is in the range [0,1] between the two edges of the line. It is available at least on Broadcom hardware. Reviewed-by: Eric Anholt <eric@anholt.net> Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/5624>
nir: fix implicit fallthrough warnings Reviewed-by: Marek Olšák <marek.olsak@amd.com> Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/5705>