Commit Graph

265 Commits

Author SHA1 Message Date
Dean 35a54f470c
Merge pull request #666 from adriadam10/feat/sdwa-ldexp-f16
feat(shader): accept every SDWA selector, clamp and omod on v_ldexp_f16
2026-10-06 18:35:46 +13:00
Dean d2b23fb135
Merge pull request #664 from adriadam10/feat/f16-ternary-clamp
fix(shader): accept clamp and omod on every f16 VOP3 result op
2026-10-06 18:35:04 +13:00
Dean cf139f3e4c
Merge pull request #751 from Celegans12/feat/shader-sdwa-vmov-byte-preserve
feat(shader): accept every SDWA selector on v_mov_b32
2026-10-06 16:28:32 +13:00
Dean ded277c3ef
Merge pull request #779 from NahuelGenchi/fix/pixel-valid-mask-helper-kill
fix(shader): keep helper invocations out of the pixel valid mask kill
2026-10-06 15:14:17 +13:00
Dean 15cc3b7347
Merge pull request #663 from adriadam10/feat/div-omod-scale
fix(shader): apply clamp on v_div_scale_f64 and accept omod on the f32 division steps and v_div_scale
2026-10-06 15:13:36 +13:00
Celegans12 e5b7427c75 feat(shader): accept every SDWA selector on v_mov_b32
v_mov_b32_sdwa threw 'VOP1 SDWA destination selector ... is not
supported' when a byte source (src0_sel BYTE_0..3) met a partial
destination (dst_sel BYTE_0..3 or WORD_0/1): the VMovB32 rule allowed
only WORD and DWORD sources there. Every src0_sel, src0_sext, dst_sel
and dst_unused combination is now accepted. Translation already follows
RDNA2 for all of them (applyBitSourceModifiers, writeRawU32): the
selected field is zero- or sign-extended, and the result's low bits go
to the dst_sel field with the other bits zeroed, sign-extended above
and zeroed below, or preserved. Reserved selectors, dst_unused 3, and
neg/abs on sub-dword sources still throw.

agc_driver_sdwa_move_selectors runs all 294 combinations as wave32 and
wave64 on the GPU, plus the in-place byte broadcast under a partial
exec mask, which is not checked on subgroups narrower than 32 lanes,
as in the other EXEC-masked execution tests. agc_vop1_sdwa_move_decode
checks the decoded operands and the reserved encodings.
2026-10-06 02:35:42 +02:00
Dean 021e4573ce
Merge pull request #668 from ThisIsAkill/fix/agc-emulated-color-compare-main
fix(agc): emulate comparison sampling of color textures in the shader
2026-10-06 13:27:39 +13:00
Dean 356435fe68
Merge pull request #753 from Celegans12/feat/shader-structurize-loop-early-exit
feat(recompiler): structurize loops whose exits reach different program ends
2026-10-06 13:18:48 +13:00
Dean 964dd3c919
Merge pull request #669 from adriadam10/fix/dot2-f16-hw-rounding
fix(shader): match v_dot2_f32_f16 and v_dot2c_f32_f16 to hardware
2026-10-06 12:25:50 +13:00
Nahuel Genchi 79feafca58 fix(shader): keep helper invocations out of the pixel valid mask kill 2026-10-05 20:16:59 -03:00
Dean d3e4edf15b
Merge pull request #750 from Celegans12/feat/shader-flat-saddr-vcc
feat(shader): accept vcc as the scalar base address of global instructions
2026-10-06 12:12:39 +13:00
Celegans12 adee347c14 feat(recompiler): structurize loops whose exits reach different program ends
A loop whose exits have no common post-dominator, such as a normal exit
to one s_endpgm tail beside an early-out to a kill tail, got no merge
block, and Structurize threw "loop at block N has no structured
merge/continue". With three or more exits, detectNaturalLoops threw
first, on a lookup of InvalidControlFlowId.

Such a loop now leaves through one new merge block that dispatches on
route variables. They are cleared before the header and set on each
exit edge to a target other than the latch's exit. Inner loops are
routed first; a routing that would change the natural loops throws.

A loop-exit tail branch whose in-body target is the continue block no
longer merges there, which spirv-val rejects ("Header block ... is
contained in the loop construct ..., but its merge block ... is not").
2026-10-06 00:35:47 +02:00
Celegans12 23c8985273 feat(shader): accept vcc as the scalar base address of global instructions
The FLAT decoder took a scalar base address (SADDR) only from a
numbered SGPR pair, so global loads, stores and atomics and
global_load/store_dword_addtid with SADDR = vcc (106) threw "FLAT
scalar address register range overflow". LLVM's GFX10 global saddr
operand accepts s, vcc, ttmp, null and off.

A two-register base may now be VCC. The address translation already
reads it as VCC_LO:VCC_HI through offsetOperand. The same helper
serves the scratch SADDR, where vcc_lo becomes the 32-bit offset.
VCC_HI, M0, EXEC and the trap temporaries still throw.
2026-10-06 00:35:37 +02:00
Celegans12 41fc6c631c feat(shader): implement s_swappc_b64 null, long branches and dword jump tables
SOP1 opcode 33 with SDST null keeps no return address, so it is exactly
s_setpc_b64; the decoder now reads it that way, as KytyPS5 does. A call
with a real destination still throws "unsupported SOP1 opcode 33".

GraphBuilder resolves two more jump shapes. A long branch is
s_getpc_b64 and s_add_u32/s_addc_u32 or s_sub_u32/s_subb_u32
immediates, also through vcc, all in one block. A dword jump table
branches to the table base minus an entry that s_load_dword reads at an
index bounded by s_min_u32 and scaled by 4; the resolver follows
register writes back through straight-line code, and anything else is
still refused. The code table load now also handles one-dword entries.

agc_shader_control_flow checks the decode, the graphs and the refusals;
the new agc_driver_scalar_swappc runs all shapes on the GPU.
2026-10-05 22:41:39 +02:00
Dean 3c681d5199
Merge pull request #670 from NahuelGenchi/feat/global-atomic-csub
feat(shader): implement global_atomic_csub
2026-10-06 07:54:05 +13:00
Dean d5b7fbc127
Merge pull request #660 from Celegans12/feat/agc-dpp16-row-share
feat(shader): implement the DPP16 row_share controls
2026-10-06 07:53:22 +13:00
Dean 7df0923570
Merge pull request #659 from Celegans12/feat/agc-image-atomics-32bit-formats
feat(agc): implement image atomics on 32_SINT and 32_FLOAT surfaces
2026-10-06 07:52:39 +13:00
Dean bbc6f42881
Merge pull request #667 from adriadam10/test/image-atomics-bitwise
test(shader): cover the bitwise and unsigned image atomics
2026-10-06 07:51:54 +13:00
Dean a509d519a1
Merge pull request #689 from adriadam10/test/flat-global-loads-ci-time
test(shader): split the flat and global loads test to keep it within CI's time limit
2026-10-06 07:51:41 +13:00
Dean 7b1d7cc78a
Merge pull request #688 from adriadam10/test/global-atomics-ci-time
test(shader): split the global atomics test to keep it within CI's time limit
2026-10-06 07:50:59 +13:00
Adrià Franch 5864b20dcb feat(shader): accept every SDWA selector, clamp and omod on v_ldexp_f16
Co-Authored-By: Claude <noreply@anthropic.com>
2026-10-05 20:31:38 +02:00
Adrià Franch b8e1936783 fix(shader): accept clamp and omod on every f16 VOP3 result op
clamp (and omod, ignored while f16 denormals are enabled) were refused or
dropped per op: v_{add,sub,subrev,mul,min,max}_f16, v_ldexp_f16,
v_frexp_mant_f16, v_cvt_norm_{i,u}16_f16, v_{max3,min3,med3,div_fixup}_f16.
They now share one clamp on the f16 bits (clampF16Bits).

Co-Authored-By: Claude <noreply@anthropic.com>
2026-10-05 20:30:47 +02:00
Dean fdd6519eac
Merge pull request #507 from adriadam10/feat/vop3-integer-clamp
fix(shader): saturate VOP3 integer mad/sad results on clamp
2026-10-06 07:27:34 +13:00
Dean 33e9a12159
Merge pull request #511 from adriadam10/feat/sdwa-vop2-float-selectors
feat(shader): accept every SDWA selector on VOP2 float ops
2026-10-06 07:13:44 +13:00
Dean b6c889d208
Merge pull request #625 from DotDebian/fix/mimg-address-instruction-dimension
fix(shader): locate image LOD, mip and sample index by the instruction's dimension
2026-10-06 07:13:30 +13: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
Celegans12 73c68c04bd feat(agc): implement image atomics on 32_SINT and 32_FLOAT surfaces
The resource materializer refused every atomic image descriptor whose
format was not 32_UINT. RDNA2 image atomics act on the raw dword and
the numeric format only affects addressing, so 32_SINT and 32_FLOAT
surfaces are now accepted with the Uint numeric class and run through
the existing integer atomics and float compare-exchange loops. Other
formats still throw, and the message now names the format.

DescriptorBinding gains imageAtomic, carried through the shader disk
cache (format version 4) and the resource content key. The driver
binds those elements through a cached R32_UINT view of R32_SINT and
R32_SFLOAT storage images.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-05 17:51:06 +02:00
Celegans12 f7ede9cd7d feat(shader): implement the DPP16 row_share controls
EmitDppTargetLane threw "DPP control 336 is not supported" for the
DPP16 row_share controls 0x150-0x15f. row_share:sel now reads lane
sel of the reading lane's own row, (lane & ~15) | sel, as the RDNA2
ISA defines it. The source never leaves the row, so the target is
always valid and an inactive source follows the existing fi and
bound_ctrl rule, as for row_xmask.

The new agc_driver_dpp16_row_share_xmask execution test covers
v_mov_b32, v_add_nc_u32, v_sub_nc_u32 and v_max_f32 with row_share
and row_xmask under a partial exec mask, with fi, bound_ctrl and
row/bank masks, as wave32 and wave64; row_xmask had no test before.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-05 17:51:00 +02:00
Adrià Franch 93d14fa5f4 test(shader): split the flat and global loads test to keep it within CI's time limit
Co-Authored-By: Claude <noreply@anthropic.com>
2026-10-05 17:32:46 +02:00
Adrià Franch 14a00e6963 test(shader): split the global atomics test to keep it within CI's time limit
Co-Authored-By: Claude <noreply@anthropic.com>
2026-10-05 17:19:12 +02:00
Adrià Franch 4066e6dd29 test(shader): keep the flat cache bits test within CI's time limit
Co-Authored-By: Claude <noreply@anthropic.com>
2026-10-05 16:54:53 +02:00
Nahuel Genchi a93faff19f feat(shader): implement global_atomic_csub
GLOBAL opcode 0x34 subtracts the data register from a global dword and
clamps the result to zero, returning the previous value. It only exists
in the global segment, so the flat form throws in the decoder, and the
form without glc throws like buffer_atomic_csub does. The clamped
subtract is now a shared helper used by both opcodes.
2026-10-05 10:32:48 -03:00
Dean 4c57426b51
Merge pull request #501 from adriadam10/fix/vop3-legacy-mods
fix(shader): v_mullit_f32 legacy rules, v_cvt_pk_u8_f32 rounding and VOP3 neg/abs
2026-10-06 02:32:06 +13:00
Dean a2b0e24e9e
Merge pull request #508 from adriadam10/feat/vop3-cube-clamp
feat(shader): accept clamp on v_cube*_f32 and match their zero and subnormal results
2026-10-06 02:31:22 +13:00
Adrià Franch b6c7f1c7e3 fix(shader): match v_dot2_f32_f16 and v_dot2c_f32_f16 to hardware
Single rounding of the whole sum, f32 accumulator denormals flushed, NaN
picked on the bits, clamp ignored and the v_dot2c accumulator read from
the lane itself under DPP, all as measured on hardware.

Co-Authored-By: Claude <noreply@anthropic.com>
2026-10-05 15:20:01 +02:00
Adrià Franch 62ad3a6802 test(shader): cover the bitwise and unsigned image atomics
Co-Authored-By: Claude <noreply@anthropic.com>
2026-10-05 15:05:14 +02:00
Akhil Moola 5202199684 fix(agc): emulate comparison sampling of color textures in the shader
AMD hardware compares a sample_c reference against a color texture's red
channel; Vulkan defines comparison sampling only for depth formats, so the
driver refused any compare-sampled texture that is not R32 float or R16
unorm. PPSA21567 compares the same LESSEQUAL, clamp-to-border (opaque
white) sampler against a shadow map and against a 1x1 RGBA8 texture.

For a compare-sampled image whose format is not natively comparable, the
specialization records the paired sampler's compare function, filter,
addressing and border, and the view's reference clamp kind; the image then
binds as an ordinary color texture. The backend fetches the red channel,
applies wrap, clamp-to-edge or clamp-to-border addressing with the
sampler's texel-centre convention (border taps take the border's red),
compares, and blends four comparisons for bilinear filtering. Real depth
formats keep the native path.

Only sample_c / sample_c_lz on 2D and 2D array views, float/unorm/snorm
formats, wrap, clamp-to-edge or clamp-to-border, point or bilinear at one
level are implemented; half-border, the border color table and everything
else on this path throw. The reference clamp for unorm/snorm color formats
is not documented by AMD and is recorded in the technical debt.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-05 06:55:03 -06:00
Adrià Franch 7e90590146 feat(shader): accept every SDWA selector on VOP2 float ops
Co-Authored-By: Claude <noreply@anthropic.com>
2026-10-05 14:49:14 +02:00
Adrià Franch 73599fad8f fix(shader): apply clamp on v_div_scale_f64 and accept omod on the f32 division steps and v_div_scale
Co-Authored-By: Claude <noreply@anthropic.com>
2026-10-05 14:31:42 +02:00
Dean 53dc19cf61
Merge pull request #617 from Erige005/test/discard-refused-recompile-results
test(agc): discard the results of recompiles expected to be refused
2026-10-05 22:16:17 +13:00
Adrià Franch f457d87bbd feat(shader): accept clamp on v_cube*_f32 and match their zero and subnormal results
Co-Authored-By: Claude <noreply@anthropic.com>
2026-10-05 10:57:27 +02:00
Adrià Franch 7bb6c59e83 fix(shader): v_mullit_f32 legacy rules, v_cvt_pk_u8_f32 rounding and VOP3 neg/abs
Co-Authored-By: Claude <noreply@anthropic.com>
2026-10-05 10:53:50 +02:00
Dean 698c23d81e
Merge pull request #528 from adriadam10/test/vop1-vop2-integer
fix(shader): v_cvt_rpi/flr_i32_f32 NaN and exact round-half-up, VOP1/VOP2 integer test
2026-10-05 21:35:53 +13: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
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 1e37ed456a
Merge pull request #514 from adriadam10/fix/dpp16-movrels-pk-fmac
fix(shader): DPP16 operands of v_pk_fmac_f16 and the relative moves
2026-10-05 21:33:48 +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 070ed19249
Merge pull request #509 from adriadam10/feat/sdwa-vop2-integer
feat(shader): accept every SDWA selector on VOP2 integer ops
2026-10-05 21:32:55 +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 bbedad3b00
Merge pull request #500 from adriadam10/fix/f32-clamp-bits
fix(shader): clamp f32 results to +0 for NaN and -0
2026-10-05 21:31:31 +13:00