Commit Graph

36 Commits

Author SHA1 Message Date
Morten Holm 93b0f48d37 fix(shader): keep s_cselect_b64 of two masks as a lane bit and fold constant masks
A select of exec and zero gives a mask that is the same for every lane. Reading
it back went through a lane number, which Metal does not have in a vertex
shader, so MoltenVK rejected the shader. The select now stores the lane bit and
marks the pair as a mask, a constant mask word reads as a constant, and the
constant folder removes the bit test on an all-zero or all-one word.

agc_scalar_select_mask runs the translated IR over a wave and pins the lane
values for scc set and clear, a source that differs per lane, the two wave64
halves differing, a destination that is also a source, and constant and
literal sources.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
2026-10-10 10:15:05 +02:00
Sanjaysrinivas 140c46093c fix(shader): guard runtime MODE changes
Read MODE rounding fields from the declared initial mode. Accept only
constant writes that preserve it; diagnose unsupported runtime changes.
Document the supported contract and add decoder-to-recompiler regressions.

Refs #1668, #981
2026-10-10 03:16:25 +02:00
Sanjaysrinivas ee0b1109f4 feat(shader): execute bounded S_CALL_B64
Reuse the prerequisite call-region analysis for signed relative calls, including callees after s_endpgm. Lower the saved link as shader base plus PC+4 and reject unsupported targets and call shapes.

Add decoder, IR, CFG and Vulkan execution regressions. Seven focused CMake tests pass; five layouts cover 15 dispatches and 3,200 output comparisons on lavapipe. Record ISA sources and native RDNA2/PS5 limits in TechnicalDebt.
2026-10-08 20:22:51 +02:00
ebosido444-ai c48e01977d feat(shader): implement s_swappc_b64 fetch-shader call
Decodes SOP1 0x21 s_swappc_b64 (link pair = pc + 4) and resolves its call/return pairing through the existing s_setpc_b64 path: static call regions in GraphBuilder and the vertex-entry fetch-shader call inlined from the parsed fetch-shader plan. s_call_b64 (SOPK 0x16) and s_rfe_b64 (SOP1 0x22) throw at decode. Unmodeled cases throw; see docs/dev/TechnicalDebt.md.
2026-10-08 20:05:24 +02:00
Adrià 17350cf5fd
Merge pull request #895 from Kikoarl/feat/s-call-b64
feat(shader): implement S_CALL_B64
2026-10-08 19:24:59 +02:00
popcoder565 a5717b6613 feat(shader): decode halt, trap return, code end, GWS and ordered count instructions
s_sethalt with SIMM16[0] clear is a no-op; s_sethalt 1, s_sendmsghalt, a reached s_code_end, s_rfe_b64, the ds_gws_* instructions and ds_ordered_count throw with the reason at translation. Linear decoding stops at s_code_end like at s_endpgm, so code padded with s_code_end after a final backward branch decodes. Encodings from LLVM SOPInstructions.td and DSInstructions.td, checked against the gfx10 MC tests; semantics from the RDNA 2 ISA guide.
2026-10-08 11:49:06 +02:00
Kikoarl f5619c4dcc feat(shader): implement S_CALL_B64 2026-10-07 15:02:33 +02:00
Adrià Franch 42ab8af70e feat(shader): implement s_bfe_i64
Co-Authored-By: Claude <noreply@anthropic.com>
2026-10-06 18:21:25 +02:00
Dean e3e1dfae16
Merge pull request #526 from adriadam10/test/scalar-sop1
fix(shader): s_wqm SCC and s_andn{1,2}_wrexec destination, SOP1/SOPC/SOPK execution test
2026-10-05 21:35:11 +13:00
Adrià Franch 36c2fa4ffe fix(shader): translate s_round_mode only for round to nearest even
Any other mode throws instead of being a silent no-op.

Co-Authored-By: Claude <noreply@anthropic.com>
2026-10-05 03:34:37 +02:00
Adrià Franch 69e2d801d1 feat(shader): decode the s_endpgm variants, s_round_mode and SMEM probe/discard
s_endpgm_saved and s_endpgm_ordered_ps_done end the wave like s_endpgm
(checked on an RDNA2 GPU: nothing after them runs), so they decode to
SEndpgm and the control flow graph treats them as terminators.
s_atc_probe, s_atc_probe_buffer and s_dcache_discard(_x2) have no visible
effect and translate to no-ops like the other scalar cache controls.
s_round_mode is ignored like s_setreg MODE writes; listed in TechnicalDebt.

Co-Authored-By: Claude <noreply@anthropic.com>
2026-10-05 03:34:37 +02:00
Chad 4e888083f9 feat(shader): implement s_getreg_b32 for the MODE round mode fields
SOPK 0x12 threw in the decoder. The recompiler emits round to nearest
even, which s_setreg_imm32_b32 already requires, so reads that stay
within MODE bits 0..3 return 0. Other hardware registers and fields
throw with the register and bits read.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-04 18:11:59 -05:00
Dean b44b308c53
Merge pull request #333 from adriadam10/feat/sopk-misc
feat(shader): implement s_cmovk_i32, s_version and s_setreg_imm32_b32
2026-10-05 11:41:47 +13:00
Adrià Franch f64a683bdf fix(shader): s_wqm SCC and s_andn{1,2}_wrexec destination
Co-Authored-By: Claude <noreply@anthropic.com>
2026-10-04 16:56:48 +02:00
Adrià Franch 1a5507698b fix(shader): choose v_div_scale_f32/v_div_fmas_f32 NaNs on the bits and refuse s_denorm_mode
v_div_scale_f32 returns a NaN source unchanged instead of scaling it,
and v_div_fmas_f32 quiets the first NaN input or returns the default
NaN 0xffc00000, so results no longer depend on the driver's NaNs. The
test compares NaN results bit for bit. s_denorm_mode throws: the
recompiler does not pin a denormal mode, so no value matches what it
models.

Co-Authored-By: Claude <noreply@anthropic.com>
2026-10-04 12:05:33 +02:00
Adrià Franch 11bc279945 feat(shader): implement v_div_scale_f32, v_div_fmas_f32, v_div_fixup_f32 and s_denorm_mode
These make up the precise f32 division macro compilers emit for a / b. No
reference emulator implements them and the ISA pseudocode disagrees with the
hardware, so the rules were measured on an RDNA2 GPU:
- div_scale decides from the exponent fields only: 2^64 or 2^-64 scaling
  and VCC for differences >= 96 or <= -96, a denormal or huge (>= 253)
  denominator and a numerator exponent <= 24; a zero input gives 0xffc00000.
- div_fmas scales by 2^64 when the exponent of S2 is >= 128, else 2^-64,
  before the single rounding (the ISA says a fixed 2^32).
- div_fixup follows the ISA, and a NaN quotient with finite inputs becomes
  +-inf.
s_denorm_mode is accepted and ignored; listed in TechnicalDebt.

Co-Authored-By: Claude <noreply@anthropic.com>
2026-10-04 12:05:33 +02:00
Adrià Franch eff7af93d4 fix(shader): translate s_setreg_imm32_b32 only for round to nearest even in MODE
Any other field or value throws. The existing s_setreg_b32 no-op is
recorded under Functional technical debt instead of silent stubs.

Co-Authored-By: Claude <noreply@anthropic.com>
2026-10-04 08:28:52 +02:00
Adrià Franch f994cc6ab7 feat(shader): implement s_cmovk_i32, s_version and s_setreg_imm32_b32
s_cmovk_i32 writes the sign-extended 16-bit immediate when SCC is set.
s_version is a no-op marker. s_setreg_imm32_b32 takes its value from a
literal dword and is ignored like s_setreg_b32; both are now listed as
silent stubs in TechnicalDebt.

Co-Authored-By: Claude <noreply@anthropic.com>
2026-10-04 08:26:58 +02:00
Dean ea07493147
Merge pull request #372 from DotDebian/feat/shader-s-wakeup
feat(shader): decode s_wakeup as a no-op
2026-10-04 14:03:57 +13:00
DotDebian 146795c9cb feat(shader): decode s_wakeup as a no-op
s_wakeup (SOPP 0x03) threw "unsupported SOPP opcode 3" in the decoder. It
pings the other waves of the thread group so they leave s_sleep early.
s_sleep already translates to nothing, so no wave is ever asleep and the
ping has nothing to wake: s_wakeup translates like s_sleep. It carries no
operand.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-02 18:10:07 +02:00
Adrià Franch 3033e5e554 feat(shader): implement s_movrels/s_movreld (b32, b64) and s_movrelsd_2_b32
s_movrels reads SGPR[src + M0] and s_movreld writes SGPR[dst + M0].
The 64-bit forms align the offset down to even (M0 & ~1), and
s_movrelsd_2_b32 takes the source offset from M0[9:0] and the
destination offset from M0[25:16], as measured on hardware. They use
the same select-over-registers lowering as the vector forms, over the
106 SGPRs. The embedded vertex-fetch scan forgets every tracked SGPR on
a relative write.

Co-Authored-By: Claude <noreply@anthropic.com>
2026-10-02 09:59:59 +02:00
Adrià Franch f3f9b4fff7 feat(shader): implement s_bcnt0_i32_b64, s_ff0_i32_b64, s_flbit_i32(_i64), s_quadmask_b32
The decoder threw for these SOP1 opcodes. The 64-bit find-first-zero and
signed leading-bit counts reuse the existing 64-bit helpers with a flag;
s_quadmask_b32 is the 32-bit half of s_quadmask_b64. s_bcnt0 and s_quadmask
set SCC to result != 0; the find and leading-bit forms leave it.

Co-Authored-By: Claude <noreply@anthropic.com>
2026-10-02 09:59:47 +02:00
boykopovar 01eaae0bf9
Merge pull request #253 from adriadam10/feat/shader-cache-hint-noops
feat(shader): decode cache invalidations and performance hints as no-ops
2026-10-02 10:50:20 +03:00
asimplestray f2bfdd26f9 feat(shader): implement SOP1 saveexec/wrexec family 2026-10-02 00:22:41 +00:00
Adrià Franch e56511f2b4 feat(shader): decode cache invalidations and performance hints as no-ops
s_icache_inv, s_incperflevel, s_decperflevel, s_ttracedata_imm, s_wait_idle,
s_gl1_inv, s_dcache_inv, s_dcache_wb, buffer_gl0_inv and buffer_gl1_inv threw
in the decoder. SPIR-V has no cache control, so they translate like s_clause
and s_waitcnt, which already emit nothing. The SMEM and MUBUF forms carry no
operands, so no pass sees a phantom base or destination register.

Co-Authored-By: Claude <noreply@anthropic.com>
2026-10-01 22:45:25 +02:00
boykopovar c09b8759b2
Merge pull request #152 from Digote/feat/shader-s-bitcmp-b64
feat(shader): support 64-bit scalar bit compare
2026-09-30 19:25:12 +03:00
Dean Galvin 5a257bee52 feat(recompiler): conditional debug branches translate as never taken
S_CBRANCH_CDBGSYS, S_CBRANCH_CDBGUSER, S_CBRANCH_CDBGSYS_OR_USER and S_CBRANCH_CDBGSYS_AND_USER
(SOPP 0x17-0x1a) branch only while a debugger sets the conditional debug bits in the wave's
status, which never happens on a retail console, so they decode to one no-op opcode.
2026-09-30 10:56:31 +13:00
Digote e2c426f528 feat(shader): support 64-bit scalar bit compare 2026-09-29 13:37:38 -03:00
boykopovar 9d6ba601c9
Merge pull request #100 from Digote/feat/shader-s-clause
feat(shader): support S_CLAUSE scheduling hints
2026-09-29 10:58:40 +03:00
Digote 24c163b5de feat(shader): support S_CLAUSE scheduling hints 2026-09-28 17:27:11 -03:00
SamG-Coder 86401fe5ab feat(shader): support scalar 64-bit reverse and arithmetic shift 2026-09-29 05:09:29 +10:00
SamG-Coder 198b43c985 fix(shader): support additional 64-bit saveexec operations 2026-09-28 18:37:51 +10:00
SamG-Coder 2e398be5a0 fix(shader): support scalar conditional move and zero-bit operations 2026-09-28 18:21:34 +10:00
SamG-Coder f7f60b4ec5 fix(shader): translate scalar byte and short sign extension 2026-09-28 17:49:09 +10:00
boykopovar 3efd37596d feat(shader): add integer and scalar instruction translation 2026-09-16 13:39:55 +03:00
boykopovar d084eed394 feat(shader): rdna memory op decoder impl 2026-09-15 07:07:50 +03:00
Renamed from core/shader/recompilier/Translation/src/ScalarInstructions.cpp (Browse further)