Commit graph

180454 commits

Author SHA1 Message Date
Faith Ekstrand
82f0c6cf77 nak: Use the builder in some lowering passes
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/24998>
2023-11-14 00:48:10 +00:00
Faith Ekstrand
2d69a2c1d7 nak: Add a builder
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/24998>
2023-11-14 00:48:10 +00:00
Faith Ekstrand
063c9f41fa nak: Work in terms of bits for type sizes
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/24998>
2023-11-14 00:48:10 +00:00
Faith Ekstrand
ced6b44ba6 nak: Follow memcpy semantics with OpParCopy
Destination first followed by source.  Otherwise, we'll screw ourselves
up endlessly.

Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/24998>
2023-11-14 00:48:10 +00:00
Daniel Almeida
831d1ee2d6 nak: Do not allocate vectors needlessly in optimization passes
All passes allocate a Vec per Instr during map(). This is wasteful,
because most instances of map()  produce a single instruction (by
mapping one instruction to another instruction) or no instructions at
all.

In such cases, they return an empty Vec, or a Vec with a single entry.

Rework the signatures so that a Vec is only when mapping one instruction
into many.

Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/24998>
2023-11-14 00:48:10 +00:00
Daniel Almeida
5014b4697d nak: Heap-allocate Instrs
Heap-allocate Instrs to avoid copying them around whenever they are
mutated by a pass. This lowers the amount of copies in detriment of
cache-locality.

Signed-off-by: Daniel Almeida <daniel.almeida@collabora.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/24998>
2023-11-14 00:48:10 +00:00
Faith Ekstrand
fa0891d37c nak: Implement nir_op_b2b1 and nir_op_b2b32
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/24998>
2023-11-14 00:48:10 +00:00
Faith Ekstrand
3bf0882ea8 nak: Implement indirect UBO loads
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/24998>
2023-11-14 00:48:10 +00:00
Faith Ekstrand
0ff7fbf093 nak: Rework cbufs a bit
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/24998>
2023-11-14 00:48:10 +00:00
Faith Ekstrand
86684fa9aa nak: Legalize everything
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/24998>
2023-11-14 00:48:10 +00:00
Faith Ekstrand
9fcc0eaa8a nak: Fix multisampled textureing
Needed to handle txf_ms a few places and force LOD_MODE_ZERO

Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/24998>
2023-11-14 00:48:10 +00:00
Faith Ekstrand
cc88a1c78e nak: Add a Pred struct move the enum to PredRef
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/24998>
2023-11-14 00:48:10 +00:00
Faith Ekstrand
38c9d6dfbb nak: Add accum predicates to Op[FI]Setp
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/24998>
2023-11-14 00:48:10 +00:00
Faith Ekstrand
c6edf43f70 nak: Delete unused imports and dead code
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/24998>
2023-11-14 00:48:10 +00:00
Faith Ekstrand
d48bea6638 nak: Fold fsat into FAdd/FFma/FMul
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/24998>
2023-11-14 00:48:10 +00:00
Faith Ekstrand
4c3a5b16e9 nak: Rework source modifiers instructions a bit
Instead of I/D/FMov instructions, just use [DF]Add instead. For ineg, we
add a new INeg instruction which we can lower to IADD3 later.  The
reason for this is that IAdd3 is complicated and makes detecting an ineg
rather annoying.  Also, if we ever bring NAK up on older hardware, not
all hardware has IAdd3 and INeg will be lowerable everywhere.

Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/24998>
2023-11-14 00:48:10 +00:00
Faith Ekstrand
8ba1429216 nak: DCE things with constant false predicates
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/24998>
2023-11-14 00:48:10 +00:00
Faith Ekstrand
818ec3242b nak: Optimize OpLop3 and OpPLop3
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/24998>
2023-11-14 00:48:10 +00:00
Faith Ekstrand
59f6d657f3 nak: Fix the 2nd predicate on LOP3
I put it in the wrong spot.  Also, it's a source so we should use
set_pred_src() for it.

Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/24998>
2023-11-14 00:48:10 +00:00
Faith Ekstrand
4367e0786b nak: Implement image atomics
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/24998>
2023-11-14 00:48:10 +00:00
Faith Ekstrand
82e5b0dd93 nak: Implement global/shared_atomic_comp_swap
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/24998>
2023-11-14 00:48:10 +00:00
Faith Ekstrand
d359c64b2a nak: Implement nir_intrinsic_shared_atomic_*
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/24998>
2023-11-14 00:48:10 +00:00
Faith Ekstrand
d1c56b12b9 nak: Implement nir_intrinsic_global_atomic_*
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/24998>
2023-11-14 00:48:10 +00:00
Faith Ekstrand
18a11aa449 nak: Rework copy-prop to use soruce type decorations
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/24998>
2023-11-14 00:48:10 +00:00
Faith Ekstrand
9bc2bdd78f nak: Add a Src::supports_src_type() helper
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/24998>
2023-11-14 00:48:10 +00:00
Faith Ekstrand
42d31b4bfd nak: Rework source modifiers a bit
They now carry some type informaiton so FNeg and INeg are different
modifiers.  Since only INeg exists in hardware, we don't need IAbs or
INegAbs.

Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/24998>
2023-11-14 00:48:10 +00:00
Faith Ekstrand
a2390fdbc1 nak: Only divide FS inputs by .w for smooth interpolation
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/24998>
2023-11-14 00:48:10 +00:00
Faith Ekstrand
7398a262da nak: Decorate sources with types
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/24998>
2023-11-14 00:48:10 +00:00
Faith Ekstrand
4def64545a nak: Add a mechanism for decorating sources with types
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/24998>
2023-11-14 00:48:10 +00:00
Faith Ekstrand
3207f29a09 nak: Integers don't have abs() source modifiers
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/24998>
2023-11-14 00:48:10 +00:00
Faith Ekstrand
2a2103d73b nak: Implement load/store_shared
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/24998>
2023-11-14 00:48:10 +00:00
Faith Ekstrand
73976c3f31 nvk: Plumb num_barriers through from NAK
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/24998>
2023-11-14 00:48:10 +00:00
Faith Ekstrand
4c2ce288f9 nak: Implement barriers
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/24998>
2023-11-14 00:48:10 +00:00
Faith Ekstrand
53a372ec3d nak: Add F2F and implement fquantize16
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/24998>
2023-11-14 00:48:10 +00:00
Faith Ekstrand
dc3b2c7d10 nak: sin() and cos() require we divide by 2pi
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/24998>
2023-11-14 00:48:10 +00:00
Faith Ekstrand
a6e1167a83 nak: Don't allow r255 in texture or surface ops
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/24998>
2023-11-14 00:48:10 +00:00
Daniel Almeida
b70d998180 nak: compiler: replace Instr::new(..) with OpFoo {}.into()
As Instr now implements From<T: Into<Op>>, replace
Instr::new(Op::Foo(OpFoo {})) with OpFoo {}.into() to improve
readability.

Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/24998>
2023-11-14 00:48:10 +00:00
Daniel Almeida
ab9cf27c02 nak: compiler: add From<T:Into<Op>> for Instr
Adding this From implementation makes it possible to clean up
the code in the next commit.

Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/24998>
2023-11-14 00:48:10 +00:00
Faith Ekstrand
e8f220f7a1 nak: Legalize Op[FI]Setp
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/24998>
2023-11-14 00:48:10 +00:00
Faith Ekstrand
3bd42dd254 nak: Improve [FI]SETP encoding
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/24998>
2023-11-14 00:48:10 +00:00
Faith Ekstrand
3ac03b043e nak/nir: Lower image size and samples to txq
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/24998>
2023-11-14 00:48:10 +00:00
Faith Ekstrand
6750d21e65 nak: Legalize more stuff
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/24998>
2023-11-14 00:48:09 +00:00
Faith Ekstrand
854b4c0817 nak: Only put actually live SSA values in the ra.live_in sets
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/24998>
2023-11-14 00:48:09 +00:00
Faith Ekstrand
49f8fb0c03 nak: Legalize OpShf
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/24998>
2023-11-14 00:48:09 +00:00
Faith Ekstrand
4e4548afc9 nak: Improve RA failure messages
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/24998>
2023-11-14 00:48:09 +00:00
Faith Ekstrand
3c7a837c51 nak: Add a smarter new_lop2 helper
The new helper automatically detects whether you're working with
predicates or GPRs.

Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/24998>
2023-11-14 00:48:09 +00:00
Faith Ekstrand
a36a614583 nak: Implement nir_intrinsic_load/store_scratch
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/24998>
2023-11-14 00:48:09 +00:00
Faith Ekstrand
a4ea83777b nak: Wire up OpLd and OpSt for local and shared
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/24998>
2023-11-14 00:48:09 +00:00
Faith Ekstrand
840c0281ce nak: Implement image load/store
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/24998>
2023-11-14 00:48:09 +00:00
Faith Ekstrand
9d2b81e71d nak: Implement undef instructions
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/24998>
2023-11-14 00:48:09 +00:00