Commit graph

190574 commits

Author SHA1 Message Date
Faith Ekstrand
29aad97279 nak/copy_prop: Don't propagate UBOs into uniform instructions
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/29591>
2024-06-13 20:43:45 +00:00
Faith Ekstrand
5406cfc7fe nak/copy_prop: Rewrap a couple comments
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/29591>
2024-06-13 20:43:45 +00:00
Faith Ekstrand
81288bfad7 nak: Add a opt_uniform_instrs() pass
This both lowers away invalid uniform instructions and tries to optimize
things a bit so we don't end up with more R2UR than necessary.

Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/29591>
2024-06-13 20:43:45 +00:00
Faith Ekstrand
be91c321c9 nak/calc_instr_deps: Add latencies for uniform instructions
We know this is wrong.  In many cases, they're faster than warp
instructions, sometimes with a latency as low as 2.  However, there seem
to be a bunch of exceptions we don't understand and it's better to be
more concervative and have correct shaders.

Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/29591>
2024-06-13 20:43:45 +00:00
Faith Ekstrand
2d4e445099 nak/calc_instr_deps: Rewrite calc_delays() again
This time we take into account WaR and WaW dependencies and not just RaW
dependencies.  The NVIDIA ISA is actually quite dynamic and the not
everything is nicely pipelined such that writes always happen at
consistent cycles.  There are exact rules, of course, but we don't know
what those are so we need to make some worst-case assumptions.

Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/29591>
2024-06-13 20:43:45 +00:00
Faith Ekstrand
434af5b98b nak/calc_instr_deps: Rename a couple variables
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/29591>
2024-06-13 20:43:45 +00:00
Faith Ekstrand
b47b8643b7 nak/legalize: Explicitly ignore OpPhiSrcs and OpPhiDsts
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/29591>
2024-06-13 20:43:45 +00:00
Faith Ekstrand
66a5608c11 nak/legalize: Uniform instructions can't have cbuf sources
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/29591>
2024-06-13 20:43:45 +00:00
Faith Ekstrand
7efc113bfe nak/legalize: Copy uniform vectors in non-uniform control-flow
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/29591>
2024-06-13 20:43:45 +00:00
Faith Ekstrand
e4df28ade8 nak/legalize: Ensure all SSA values for a given ref are in the same file
It's possible for copy propagation to put a GPR and a UGPR into the same
vector source in an instruction.  Hardware registers, however, are
either GPRs or UGPRs and never a mix.

Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/29591>
2024-06-13 20:43:45 +00:00
Faith Ekstrand
caf033b142 nak/legalize: Handle uniform sources in warp instructions
UGPRs in warp instructions are treated more like cbufs than GPRs.
You're only allowed to have one and it has to share space with the
possible cbuf or immediate.  This means we need to treat them as a "not
a register" case for warp instructions but as a register for uniform
instructions.

Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/29591>
2024-06-13 20:43:45 +00:00
Faith Ekstrand
6ad49ca7d0 nak/legalize: Patch a RegFile through to copy helpers
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/29591>
2024-06-13 20:43:45 +00:00
Faith Ekstrand
c83593b07e nak/legalize: Fix imad and ffma legalization on SM50
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/29591>
2024-06-13 20:43:45 +00:00
Faith Ekstrand
d9422a0897 nak/legalize: Be more precise about shfl and out
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/29591>
2024-06-13 20:43:45 +00:00
Faith Ekstrand
c1203ef5d1 nak/legalize: Drop some pointless plop3 logic
There is no restrictions on plop3 in terms of what sources can be
immediates vs. registers.  Also, since we fold constants, all of this
code is dead.

Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/29591>
2024-06-13 20:43:45 +00:00
Faith Ekstrand
37b55ee34f nak/legalize: Fold immediate sources before instructions
This way, if we insert a copy to move the immediate to a GPR, the
immediate we place in the copy is also folded.

Fixes: 85462f7455 ("nak: Legalize immediates with source modifiers")
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/29591>
2024-06-13 20:43:45 +00:00
Faith Ekstrand
00c6244ca2 nak/sm70: Implement a bunch of uniform ops on SM75+
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/29591>
2024-06-13 20:43:45 +00:00
Faith Ekstrand
7359c214b7 nak/sm70: Fix encoding of fadd/fsetp and friends with UGPRs
UGPRs are treated more like CBufs or immediates so we want to use the
default encoding in the UGPR case and only use the reg encoding in the
zero or GPR case.

Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/29591>
2024-06-13 20:43:45 +00:00
Faith Ekstrand
21b1eb8da7 nak/sm70: Add support for encoding uniform ALU ops
This requires a pretty significant rework of encode_alu_base().  In
particular, we can't know the register file that's going to be used
until we get into encode_alu_base() so ALUSrc::from_src() can't handle
Zero itself.  Instead, we defer to a new ALUSrc::with_op_uniformity()
helper which does a postprocess step.

Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/29591>
2024-06-13 20:43:45 +00:00
Faith Ekstrand
8d2d2db6a0 nak/sm70: Rework ALU source encode helpers
We have a LOT of repeated bit numbers here and it helps if we can reduce
that a bit by making helpers for each thing.

Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/29591>
2024-06-13 20:43:45 +00:00
Faith Ekstrand
1ae83135af nak/sm70: Defer ALU src processing until encode_alu()
This makes encode_alu() take Option<&Src> and call ALUSrc::from_src()
itself.  This is necessary for handling uniform ALU correctly as we
can't actually separate Reg from UReg without knowing what kind of ALU
op we are.  While we're here, take an Option<&Dst> instead of
Option<Dst>.

Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/29591>
2024-06-13 20:43:45 +00:00
Faith Ekstrand
e244f7bb44 nak: Support uniform regs in lower_copy_swap()
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/29591>
2024-06-13 20:43:45 +00:00
Faith Ekstrand
130392e7ab nak/ra: Never move uniform regs in non-uniform blocks
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/29591>
2024-06-13 20:43:45 +00:00
Faith Ekstrand
11670be661 nak/ra: Spill UGPRs and UPreds
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/29591>
2024-06-13 20:43:45 +00:00
Faith Ekstrand
1334cf8fca nak/to_cssa: Resolve phi register file mismatches
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/29591>
2024-06-13 20:43:45 +00:00
Faith Ekstrand
1ed59706ea nak: Add a concept of uniform blocks
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/29591>
2024-06-13 20:43:45 +00:00
Faith Ekstrand
d7f544365d nak: Drop BasicBlock::new()
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/29591>
2024-06-13 20:43:45 +00:00
Faith Ekstrand
f0ec1873df nak: Make SSARef::file() return Option<RegFile>
Once we start using UGPRs, it's possible to have a vector with a mix of
GPRs and UGPRs.  This isn't actually allowed by the hardware but it's
possible as an intermediate state thanks to copy-propagation.

Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/29591>
2024-06-13 20:43:45 +00:00
Faith Ekstrand
d3e9373a90 nak/ra: Move an assert
We're allocating one register file at a time and our invariants are
per-file so we don't want to check the components assumption until we've
checked that it uses the active file.

Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/29591>
2024-06-13 20:43:45 +00:00
Faith Ekstrand
e0b051da39 nak: Clean up bindless cbuf handles
Take an SSARef instead of an SSAValue because they need to be vec2s.
Also, rename BindlessGPR to BindlessUGPR because that's what it is.

Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/29591>
2024-06-13 20:43:45 +00:00
Faith Ekstrand
35b445ba27 nak: Add OpR2UR
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/29591>
2024-06-13 20:43:45 +00:00
Faith Ekstrand
ebd16d1a56 nak: Add some helpers for uniform instructions and registers
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/29591>
2024-06-13 20:43:45 +00:00
Faith Ekstrand
0f70b14d9a nak: Expose a BasicBlock::map_instrs() helper
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/29591>
2024-06-13 20:43:45 +00:00
Faith Ekstrand
fe2b06395e nak: Get rid of OpINeg
Instead, do the same thing we do for float modifiers and use OpIAdd2 or
OpIAdd3.  This makes for a little more work in copy-prop but the extra
opcode and lowering pass just isn't worth it.

Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/29591>
2024-06-13 20:43:45 +00:00
Faith Ekstrand
a08f8c8804 nak: Only copy-prop neg into iadd2/3 if no carry is written
Fixes: 1b3382b861 ("nak: Add modifier propagation")
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/29591>
2024-06-13 20:43:45 +00:00
Faith Ekstrand
0a089b1b13 nak: BMov is always variable-latency
The barrier half is HW scoreboarded by the GPR isn't.  When moving from
a GPR to a barrier, we still need a token for WaR hazards.

Fixes: 7cd9680554 ("nak: Add back OpBMov with better semantics")
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/29591>
2024-06-13 20:43:45 +00:00
Faith Ekstrand
61be2c94dc nak: Fix BasicBlock::phi*() for OpAnnotate
They assumed that phis would be at the start of the block which isn't
true if there are annotations in the way.

Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/29591>
2024-06-13 20:43:45 +00:00
Faith Ekstrand
944365802f nak: Only convert the written portion of the buffer in NirInstrPrinter
Fixes: 02774be708 ("nak/sm50: add a memstream abstraction")
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/29591>
2024-06-13 20:43:45 +00:00
Faith Ekstrand
70b381e928 nak: Fix NAK_DEBUG=serial for warp barriers
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/29591>
2024-06-13 20:43:44 +00:00
Faith Ekstrand
290cbf413c nir/print: Improve divergence information
Reviewed-by: Alyssa Rosenzweig <alyssa@rosenzweig.io>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/29591>
2024-06-13 20:43:44 +00:00
Heinrich Fink
222fbcbfd5 zink: remove workaround of FB modifiers forcing present state
Remove a legacy workaround where presence of modifiers in framebuffer
state results in `needs_present` to be set without a good reason.

This prevents hitting an assertion for framebuffers that use DRM
modifiers, e.g. via GBM BO alloc -> EGLImage import -> GL FBO bind.

Co-authored-by: Daniel Stone <daniels@collabora.com>
Signed-off-by: Heinrich Fink <hfink@snap.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/29715>
2024-06-13 20:44:28 +02:00
Timothy Arceri
4c3d1a09de nir: add additional opt_loop_merge() test of deref handling
Here we test the rematerialization of the deref produces valid nir
when both the deref and array index value are moved to the else branch of
the first terminator during the merge.

Reviewed-by: Rhys Perry <pendingchaos02@gmail.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/29686>
2024-06-13 15:00:35 +00:00
Timothy Arceri
abb51f449d nir: test opt_loop_merge_terminators() skips unhandled loops
This test makes sure the merge if pass skips loops with trainling phis
as those are not handled by the pass.

Reviewed-by: Rhys Perry <pendingchaos02@gmail.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/29686>
2024-06-13 15:00:35 +00:00
Timothy Arceri
b26ef8f153 nir: correctly track current loop in nir_opt_loop()
We were not restoring an outer loop as the current loop after we had
finished processing a nested loop.

Fixes: 9995f336e6 ("nir: add merge loop terminators optimisation")

Reviewed-by: Rhys Perry <pendingchaos02@gmail.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/29686>
2024-06-13 15:00:35 +00:00
Timothy Arceri
3d2a821198 nir: add test for opt_loop_merge_terminators
Makes sure we correctly rematerialize derefs moved during the merge.

Reviewed-by: Rhys Perry <pendingchaos02@gmail.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/29686>
2024-06-13 15:00:35 +00:00
Rhys Perry
92af96e0b3 nir/opt_loop: fix formatting
Reviewed-by: Timothy Arceri <tarceri@itsqueeze.com>
Signed-off-by: Rhys Perry <pendingchaos02@gmail.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/29686>
2024-06-13 15:00:35 +00:00
Rhys Perry
cb51a93c1e nir/opt_loop: rematerialize derefs instead of creating phis
Fixes NIR validation of hogwarts_legacy/00ac08423ad6e422.

Reviewed-by: Timothy Arceri <tarceri@itsqueeze.com>
Signed-off-by: Rhys Perry <pendingchaos02@gmail.com>
Fixes: 9995f336e6 ("nir: add merge loop terminators optimisation")
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/29686>
2024-06-13 15:00:35 +00:00
Eric Engestrom
ea97397296 turnip+zink/ci: mark dEQP-GLES3.functional.fbo.depth.depth_test_clamp.* tests as fixed
Fixes: 96ed275a53 ("turnip: Implement VK_EXT_depth_clamp_zero_one")
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/29717>
2024-06-13 14:20:18 +00:00
Sergi Blanch Torne
b24dd1fa1c ci: Fix parse GitLab pipeline url
When the namespace have a dash, this method cannot recogniza properly
the fields in a url. Better to use a regular expression quickly defining
the fields. The exception raised, when the pattern is not recognized
would help more the handler.

Signed-off-by: Sergi Blanch Torne <sergi.blanch.torne@collabora.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/29683>
2024-06-13 14:10:57 +00:00
Eric Engestrom
f1fdba2432 lavapipe/ci: document regression while it's being worked on
Regression caused by !28998

Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/29712>
2024-06-13 13:47:43 +00:00