Commit graph

180654 commits

Author SHA1 Message Date
Faith Ekstrand
9166b3354c nak: Drop some unused helpers
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/24998>
2023-11-14 00:48:14 +00:00
Faith Ekstrand
d0b724aaac nak: Add some #[allow(dead_code)]
All this is either enums where we want all of them for the sake of
documentation or where I'm pretty sure we want them in the future.

Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/24998>
2023-11-14 00:48:14 +00:00
Faith Ekstrand
eb8f907855 nak: Upgrade to more modern meson
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/24998>
2023-11-14 00:48:14 +00:00
Mary Guillemard
f757508d65 nak: Move nir_lower_int64 after I/O lowering
Signed-off-by: Mary Guillemard <mary.guillemard@collabora.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/24998>
2023-11-14 00:48:14 +00:00
Mary Guillemard
09d3871267 nak: Implement VK_KHR_shader_terminate_invocation
Signed-off-by: Mary Guillemard <mary.guillemard@collabora.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/24998>
2023-11-14 00:48:14 +00:00
Faith Ekstrand
c32b73fdf2 nak: A quick rustfmt fix
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/24998>
2023-11-14 00:48:14 +00:00
Faith Ekstrand
2b4621b9d8 nak: Use Src::From<u32> and Src::From<bool>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/24998>
2023-11-14 00:48:14 +00:00
Faith Ekstrand
0616003de9 nak: Rename lower_vec_split() to lower_ineg()
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/24998>
2023-11-14 00:48:14 +00:00
Faith Ekstrand
a43e6addca nak: Fix fneg to do fadd(-0, x)
Thanks to floating point sillyness, fadd(0, x) isn't a no-op but
fadd(-0, x) is.

Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/24998>
2023-11-14 00:48:14 +00:00
Faith Ekstrand
2c1cc06d03 nak: Support encoding -Zero
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/24998>
2023-11-14 00:48:14 +00:00
Mary Guillemard
a0b517ba3f nak: Ensure we allocate one barrier when using BAR.SYNC
Fix "Illegal Instruction Parameter" when using barrier() on compute
shaders.

Signed-off-by: Mary Guillemard <mary.guillemard@collabora.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/24998>
2023-11-14 00:48:14 +00:00
Faith Ekstrand
29804bfd26 nak/nir: Don't lower 1-bit phis
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/24998>
2023-11-14 00:48:14 +00:00
Faith Ekstrand
8d802553a2 nak: Fix to_cssa()
I somehow got the dominance check backwards so it's not actually
inserting parallel copies most of the places it should.

Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/24998>
2023-11-14 00:48:14 +00:00
Faith Ekstrand
ed187b6e51 nak: Fix parallel copy handling in spilling
Only consider copies with the right file.  Otherwise, the spill chooser
will blow up looking for the next use.  Also, we were marking
destinations as spilled when I ment to mark them as being in W.  This
was a right mess.  God thing to_cssa() was also broken so it wasn't
inserting nearly as many parallel copies as it was supposed to. 🙃

Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/24998>
2023-11-14 00:48:14 +00:00
Faith Ekstrand
2ff6a36e2a nak: Fix repair_ssa() for back-edges
In the presence of nested loops, there is no guarantee that we can
handle back-edges in a single pass.  Instead, use a bitset as a worlist
and repair until we're out of missing sources.

Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/24998>
2023-11-14 00:48:14 +00:00
Faith Ekstrand
5839be3c4d nak/sph: Round tls_size up to a multiple of 16
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/24998>
2023-11-14 00:48:14 +00:00
Faith Ekstrand
009ae6e7f5 nak/bitset: Fix next_set()
It was resetting mask to 0 instead of u32::MAX.  This is a copy+paste
error from when I copied it from next_unset() and tweaked it to find set
bits.

Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/24998>
2023-11-14 00:48:14 +00:00
Faith Ekstrand
2cc51639ab nak/bitset: Add an is_empty() helepr
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/24998>
2023-11-14 00:48:14 +00:00
Faith Ekstrand
0f6d8640e1 nak/bitset: Improve set_words()
Only set the bits requested and don't clobber other bits.

Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/24998>
2023-11-14 00:48:14 +00:00
Faith Ekstrand
5b355ff25a nak: Fix opt_out
It was converting instructions to/from Op which throws away predicates.
This meant that any instruction immediately after an OUT.EMIT would
loose its predicate (if any).  If an OUT.EMIT comes right before a BRA,
this results in the branch always getting taken.

While reworking things, I also totally reformatted the pass to make it
more readable IMO.

Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/24998>
2023-11-14 00:48:14 +00:00
Mary Guillemard
950db58132 nak: Add geometry shader support
Tested on SM75 and SM86.

Signed-off-by: Mary Guillemard <mary.guillemard@collabora.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/24998>
2023-11-14 00:48:14 +00:00
Faith Ekstrand
c87693a700 nak: Fix a bunch of warnings
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/24998>
2023-11-14 00:48:14 +00:00
M Henning
09d78e8572 nak: Memory order/scope encodings for Ampere
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/24998>
2023-11-14 00:48:14 +00:00
M Henning
ad0743c948 nak: Remove MemScope::Cluster
because
 * ptxas refuses inputs with .cluster before sm90
 * on sm90 ptxas encodes .cluster as .gpu
 * nvdisasm calls this encoding on sm75 .SM
so I don't think we have an actual .cluster on any released gpus

Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/24998>
2023-11-14 00:48:14 +00:00
M Henning
93f83a948f nak: Fix a warn(unused_must_use) by calling drop
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/24998>
2023-11-14 00:48:14 +00:00
Daniel Almeida
590133b28d nak: add support for atomic cmpxcgh on images
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/24998>
2023-11-14 00:48:14 +00:00
Faith Ekstrand
f85069ed57 nak: Use nak_nir_lower_vtg_io
This massively simplifies nak_from_nir.rs because it lets us do all the
annoying NIR fiddling in NIR and not in the back-end.

Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/24998>
2023-11-14 00:48:14 +00:00
Faith Ekstrand
7ece220f96 nak/nir: Lower systm values before lowering I/O
This way I/O lowering can lower the stuff we generate in
lower_system_values().

Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/24998>
2023-11-14 00:48:14 +00:00
Faith Ekstrand
abe9c1fea2 nak: Add NIR lowering for attribute I/O
This adds 4 NIR intrinsics for attribute I/O which match the Turing
hardware instructions as well as a lowering pass to lower
load/store[_per_vertex]_input/output to thewe intrinsics.  This greatly
simplifies nak_to_nir.rs.  Also, this pass is able to handle a bunch of
cases that the current code in nak_from_nir.rs can't:

 - Misaligned access (i.e., a vec3 load at 0x0f4)

 - Write masks on store[_per_vertex]_output

 - Indirect load/store where we need to use AL2P to get physical
   addresses, including scalarizing those cases

It also handles the casses where we need to use ISBERD on vertex indices
in the same pass.  When we switch to this, we'll rip out the dedicated
per_vertex lowering pass.

Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/24998>
2023-11-14 00:48:14 +00:00
Faith Ekstrand
c1ffdb3ee9 nak/nir: Use count_vec4_slots instead of count_attribute_slots
This will give us the correct behavior in for doubles when the time
comes.  The count_attribute_slots() helper is for GL attributes where a
dvec4 countes as one slot.

Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/24998>
2023-11-14 00:48:14 +00:00
Faith Ekstrand
498afcdb88 HACK: Only emit OpBar in compute shaders
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/24998>
2023-11-14 00:48:14 +00:00
Faith Ekstrand
611fe837bb nak: Fix lowering for patch_vertices_in
We have to grab the 2nd byte of the sysval for some reason.

Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/24998>
2023-11-14 00:48:14 +00:00
Faith Ekstrand
efbbc3ed93 nak: Implement load_tess_coord
We could lower this to load_per_vertex_output in NIR but then it
confuses all sorts of NIR passes which assume load_*output only
happens in control shaders.  We could also add a magic NIR intrinsic
but it's probably easier to just special-case this one.

Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/24998>
2023-11-14 00:48:14 +00:00
Faith Ekstrand
b5cb508523 nak,nvk: Plumb through tessellation info
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/24998>
2023-11-14 00:48:14 +00:00
Faith Ekstrand
bd90031b5b nak/nir: Lower load_primitive_id
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/24998>
2023-11-14 00:48:14 +00:00
Faith Ekstrand
c2768736c9 nak: Implement more attribute I/O
This commits implement load/store_per_vertex* and load_output which are
required for tessellation shaders.  Because things are getting a bit
complicated, it's easier to combine all the attribute load/store ops in
a single case in the match.

Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/24998>
2023-11-14 00:48:14 +00:00
Faith Ekstrand
091410c708 nak: Add lowering for per-vertex I/O
NVIDIA hardware doesn't take a vertex index for per-vertex I/O.
Instead, it takes an offset into the primitive.  This has to be fetched
using a combination of SR_INVOCATION_INFO and the ISBERD instruction.
To keep things simple and allow for maximum CSE, we do the lowering in
NIR and patch the load/store_per_vertex_input/output intrinsic.

Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/24998>
2023-11-14 00:48:14 +00:00
Faith Ekstrand
aa76c86042 nak: Handle location_frac for FS outputs in nak_from_nir.rs
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/24998>
2023-11-14 00:48:14 +00:00
Faith Ekstrand
1251bb7588 nak: Set per patch attribute count both places in the SPH
This is what codegen does and it seems to be required.  Maybe it's an
SPH version thing?

Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/24998>
2023-11-14 00:48:14 +00:00
Faith Ekstrand
f097303a99 nak: Rework OpALd and OpASt a bit
Replace the out_load flag with an output flag which we now require to be
set for OpASt.  Also, improve printing so we add .O and .P qualifiers as
needed.

Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/24998>
2023-11-14 00:48:14 +00:00
Faith Ekstrand
f5805dadab nak: NVIDIA calls them tessellation init shaders
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/24998>
2023-11-14 00:48:13 +00:00
Faith Ekstrand
dfbc03fa88 spirv: Fix locations for per-patch varyings
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/24998>
2023-11-14 00:48:13 +00:00
Faith Ekstrand
c6c2c1b2b2 nak/nir: Lower tessellation and geometry I/O
We also need to call nir_lower_indirect_derefs.  Even though we're not
lowering anything away, we need to call it so that it will lower clip
distance arrays.  The pass always lowers compact array derfs.

Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/24998>
2023-11-14 00:48:13 +00:00
Faith Ekstrand
93db2c1254 nak: Plumb clip/cull enables through nak
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/24998>
2023-11-14 00:48:13 +00:00
Faith Ekstrand
d4d7f26151 nak: Add enums for sysvals and attributes
It's much nicer to have a canonical place for all these things to live
which gives them actual names.

Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/24998>
2023-11-14 00:48:13 +00:00
Faith Ekstrand
a4c1ec3892 nak: Implement From for SrcRef for more types
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/24998>
2023-11-14 00:48:13 +00:00
Faith Ekstrand
0d725cccbd nak: Implement NIR control barriers
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/24998>
2023-11-14 00:48:13 +00:00
Faith Ekstrand
5e6dd0412b nak/builder: Return the instruction from push_*()
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/24998>
2023-11-14 00:48:13 +00:00
Faith Ekstrand
9b6a4aab8d nak: Add barrier instructions
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/24998>
2023-11-14 00:48:13 +00:00
Faith Ekstrand
2514058c82 nak: Allow encoding Dst::None
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/24998>
2023-11-14 00:48:13 +00:00