Commit Graph

39 Commits

Author SHA1 Message Date
Adrià 4adefa0708
Merge pull request #1898 from fisherjoey/fix/vop3-add-sub-clamp
fix(shader): saturate VOP3 v_add/sub_nc_u32 and 16-bit add/sub on clamp
2026-10-10 08:04:49 +02:00
QRMOE e65a707f61 fix(shader): truncate overflowing 32-bit bitfield masks
Construct the low-bit mask at offset zero, then shift it in 32-bit arithmetic. AI-assisted: yes.
2026-10-10 02:13:34 +02:00
Joey Fisher 1f0060d72d fix(shader): saturate VOP3 v_add/sub_nc_u32 and 16-bit add/sub on clamp 2026-10-08 16:55:06 -06:00
Adrià 4d1a356d43
Merge pull request #928 from MichonGoddijn231849/fix/scalar-sop1-movrelsd
fix(shader): read relative SGPRs through a one-hot mux
2026-10-07 11:16:35 +02:00
Adrià 219a1cf8d2
Merge pull request #916 from adriadam10/feat/s-bfe-i64
feat(shader): implement s_bfe_i64
2026-10-07 10:36:58 +02:00
Adrià 00c9f9256e
Merge pull request #531 from adriadam10/test/vop3-integer
fix(shader): saturate v_cvt_pk_u16_u32/i16_i32; test VOP3 integer ops
2026-10-06 23:12:45 +02:00
Michon 177a452c60 fix(shader): read relative SGPRs through a one-hot mux
s_movrels and s_movrelsd_2 read the source register through a chain of
selects keyed on the M0 offset, and the relative destination write is a
select between that value and the old register. When the old register
also appears in the chain, the NVIDIA compiler (RTX 5080, 610.74)
evaluates select(a, select(b, x, y), x) as select(a || b, y, x) instead
of select(a && !b, y, x), so s_movrelsd_2_b32 clobbered s13 whenever the
source offset was 3. Rewriting the select, a branch with a phi, a masked
xor or a small function array all fold back into the same form.

Build the read as an OR of select(offset == k, s[base + k], 0) terms, with
the base register used for offsets outside [1, count) as before. The
result is unchanged, and the select nesting the compiler mishandles no
longer forms.

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
2026-10-06 19:37:21 +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
Adrià Franch fa996bbccb fix(shader): saturate VOP3 integer mad/sad results on clamp
Co-Authored-By: Claude <noreply@anthropic.com>
2026-10-05 19:05:34 +02:00
Dean 5ad0c99f98
Merge pull request #525 from adriadam10/test/scalar-alu
fix(shader): s_lshlN_add SCC and s_bfe_[iu]32 fields past bit 31
2026-10-05 21:34:30 +13:00
Dean 6fd9739d9d
Merge pull request #510 from adriadam10/feat/sdwa-vop2-integer-clamp
feat(shader): saturate VOP2 integer SDWA results on clamp
2026-10-05 21:33:38 +13:00
Dean 17ef50b681
Merge pull request #504 from adriadam10/feat/vop3-opsel-16
fix(shader): VOP3 op_sel on v_alignbit/alignbyte_b32 and 16-bit max3/min3/med3
2026-10-05 21:32:13 +13:00
Dean 033ac78439
Merge pull request #563 from adriadam10/feat/vop3-mad64-clamp
feat(shader): implement clamp on v_mad_u64_u32 and v_mad_i64_i32
2026-10-05 20:26:55 +13:00
Adrià Franch e58e2f0605 feat(shader): accept float modifiers on v_cndmask_b32, v_mul_legacy_f32 and v_ldexp_f16
- v_cndmask_b32: neg/abs on DPP; neg/abs applied on the bits, as the hardware does
- v_mul_legacy_f32: neg/abs on DPP and SDWA, clamp/omod on SDWA and VOP3
- v_ldexp_f16: neg/abs on src0 for VOP3, DPP and SDWA; NaN result chosen on the bits

Co-Authored-By: Claude <noreply@anthropic.com>
2026-10-05 04:59:40 +02:00
Adrià Franch a15a21c2c6 feat(shader): implement clamp on v_mad_u64_u32 and v_mad_i64_i32
Co-Authored-By: Claude <noreply@anthropic.com>
2026-10-05 04:59:15 +02:00
Adrià Franch 03760d937b fix(shader): s_lshlN_add SCC and s_bfe_[iu]32 fields past bit 31
s_lshl1..4_add_u32 never wrote SCC; hardware sets it when the shifted-out
bits or the add carry are non-zero. s_bfe_i32/u32 went through
OpBitField{S,U}Extract, which RADV gets wrong when the width runs past
bit 31; build the field from shifts instead.

Adds an execution test for 38 SOP2 opcodes with hardware-captured results.

Co-Authored-By: Claude <noreply@anthropic.com>
2026-10-04 22:35:45 +02:00
Adrià Franch f08e691b22 fix(shader): saturate v_cvt_pk_u16_u32/i16_i32; test VOP3 integer ops
Co-Authored-By: Claude <noreply@anthropic.com>
2026-10-04 17:09:47 +02:00
Adrià Franch c5effd409e feat(shader): saturate VOP2 integer SDWA results on clamp
Co-Authored-By: Claude <noreply@anthropic.com>
2026-10-04 13:36:35 +02:00
Adrià Franch 50256b0ac4 fix(shader): VOP3 op_sel on v_alignbit/alignbyte_b32 and 16-bit max3/min3/med3
op_sel[1:0] on v_alignbit_b32/v_alignbyte_b32 selects the byte of src2 that
holds the shift, op_sel[2] is ignored and op_sel[3] writes the low 16 result
bits to the high half with the low half zeroed (measured on gfx1035).
v_alignbyte_b32 now uses src2[1:0] only, as the ISA says; values >= 4 gave
a wrong result before. v_max3/min3_{i16,u16} and v_med3_u16 take op_sel like
v_med3_i16 already does.

Co-Authored-By: Claude <noreply@anthropic.com>
2026-10-04 12:41:07 +02:00
Adrià Franch 89eb938803 fix(shader): VOP3P integer clamp on v_pk_mad/add/sub_{i16,u16}
Co-Authored-By: Claude <noreply@anthropic.com>
2026-10-04 12:33:38 +02:00
Adrià Franch e1b7ecc1c5 feat(shader): implement v_mad_i64_i32
Decode VOP3b 0x177 and translate it next to v_mad_u64_u32: the high half of
the product comes from SMulHi, and the carry-out is the sign of the exact
sum (bit 64 of the sign-extended product plus the sign-extended addend), as
measured on RDNA2 hardware.

Co-Authored-By: Claude <noreply@anthropic.com>
2026-10-04 09:17:12 +02:00
Adrià Franch f9a074250f feat(shader): implement v_qsad_pk_u16_u8 and the mqsad ops
Decode VOP3 0x172, 0x173 and 0x175. Each op slides a 4-byte window over the
64-bit src0 and adds the byte SAD against src1 to the matching 16-bit
(pk_u16) or 32-bit (mqsad_u32) field of src2; the mqsad forms skip zero
reference bytes. Sums wrap per field, as measured on RDNA2 hardware.

Co-Authored-By: Claude <noreply@anthropic.com>
2026-10-04 08:22:25 +02:00
Dean 0df090c30b
Merge pull request #386 from DotDebian/feat/vop3p-integer-dot
feat(shader): implement the integer dot products
2026-10-04 14:04:14 +13:00
Alexey b45716210c
Merge pull request #326 from adriadam10/feat/scalar-relative-indexing
feat(shader): implement s_movrels/s_movreld (b32, b64) and s_movrelsd_2_b32
2026-10-03 10:35:26 +03:00
boykopovar 5540d1953b
Merge pull request #384 from DotDebian/feat/vop3-lerp-u8
feat(shader): implement v_lerp_u8
2026-10-02 23:28:28 +03:00
boykopovar b68c8c27f1
Merge pull request #379 from DotDebian/feat/shader-vop3-sad
feat(shader): implement v_sad_u8, v_sad_hi_u8, v_sad_u16 and v_msad_u8
2026-10-02 23:28:10 +03:00
boykopovar 2af9dda269
Merge pull request #255 from adriadam10/feat/scalar-bit-count-ops
feat(shader): implement s_bcnt0_i32_b64, s_ff0_i32_b64, s_flbit_i32(_i64), s_quadmask_b32
2026-10-02 22:21:49 +03:00
DotDebian 362ba8a1a6 feat(shader): implement the integer dot products
Decode and translate v_dot2_i32_i16, v_dot2_u32_u16, v_dot4_i32_i8,
v_dot4_u32_u8, v_dot8_i32_i4, v_dot8_u32_u4 (VOP3P 0x14-0x19) and
v_dot4c_i32_i8 (VOP2 0x0d).

Clamp, neg and the op_sel combinations whose behaviour is not
established throw.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-02 19:01:57 +02:00
DotDebian 4a4a1eddc1 feat(shader): implement v_lerp_u8
Decode VOP3 0x14d and translate it as the per-byte average of S0 and S1,
rounded up where bit 0 of the matching S2 byte is set and truncated
otherwise.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-02 18:57:06 +02:00
DotDebian 9f2319b46e feat(shader): implement v_sad_u8, v_sad_hi_u8, v_sad_u16 and v_msad_u8
Decode VOP3 0x15a, 0x15b, 0x15c and 0x171 and translate them as the
unsigned sum of absolute differences over the byte or word fields of
the first two sources, accumulated into the third. v_sad_hi_u8 shifts
the sum into the high half first, v_msad_u8 skips the fields whose
reference byte in the second source is zero.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-02 18:25:22 +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
Adrià Franch e144f43f05 feat(shader): implement VOP3 v_add/sub_nc_i32 with clamp, v_mul_lo_u16, v_mad_u16/i16/u32_u16/i32_i16, v_ashrrev_i64
These VOP3 opcodes threw in the decoder. v_add_nc_i32 and v_sub_nc_i32 are
what compilers emit for signed saturating add/sub, so their clamp saturates
to the int32 range. The 16-bit mads honour op_sel on their 16-bit sources;
the u32_u16/i32_i16 forms take a 32-bit addend and write all 32 bits, so
they do not get the 16-bit destination select.

Co-Authored-By: Claude <noreply@anthropic.com>
2026-10-01 22:45:25 +02:00
asimplestray b15f6800dd feat(shader): implement VOP3 I16/U16 min/max/med3 2026-10-01 16:11:33 +00:00
SamG-Coder 70cb9e2eaf feat(shader): translate signed and unsigned 24-bit high products 2026-10-01 20:23:21 +10:00
Digote e2c426f528 feat(shader): support 64-bit scalar bit compare 2026-09-29 13:37:38 -03:00
SamG-Coder 730de17774 fix(shader): support V_PERM_B32 byte selection 2026-09-28 19:35:18 +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/IntegerInstructions.cpp (Browse further)