feat(shader): accept neg/abs on 32-bit integer DPP and SDWA sources #19577
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/19577"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Imported from boykopovar/AnyPS5. Originally posted by Nawid3333 on 2026-11-13T15:13:21Z.
What
The RDNA decoder accepts the DPP16 and SDWA
negandabssource bits on VOP1 and VOP2 instructions whose sources are 32-bit integers, instead of throwing.v_cvt_f32_i32,v_cvt_f32_u32,v_cvt_off_f32_i4,v_cvt_f32_ubyte0..3,v_not_b32,v_bfrev_b32,v_ffbh_u32,v_ffbl_b32,v_ffbh_i32(isVop1IntegerSourceOpcode).isVop2IntegerOpcode):v_cndmask_b32,v_mul_i32_i24,v_mul_hi_i32_i24,v_mul_u32_u24,v_mul_hi_u32_u24,v_min_i32,v_max_i32,v_min_u32,v_max_u32,v_lshrrev_b32,v_ashrrev_i32,v_lshlrev_b32,v_and_b32,v_or_b32,v_xor_b32,v_xnor_b32,v_add_nc_u32,v_sub_nc_u32,v_subrev_nc_u32,v_add_co_ci_u32,v_sub_co_ci_u32,v_subrev_co_ci_u32.On RDNA2 hardware these bits act on bit 31 of the 32-bit operand: NEG flips it, ABS clears it, both set it. There is no two's-complement negate or integer absolute value. The bit is changed after the DPP lane move (with
bound_ctrl:1an out-of-row lane reads 0, so NEG gives 0x80000000) and after the SDWA select and zero/sign extension (NEG on a zero-extended WORD_1 gives0x80000000 | field).v_cvt_f32_i32andv_cvt_f32_u32convert the changed integer:v_cvt_f32_i32with DPP NEG of 1 converts 0x80000001 and gives 0xcf000000, where a two's-complement negate would give -1.0.TranslationContext::readOperandalready reads 32-bit operands in this order (DPP move, SDWA extract, AND 0x7fffffff, XOR 0x80000000), and every opcode above reads its sources through it, so only the decoder changes. The integer SDWA rule no longer needs its own source-modifier check invalidateVop2Sdwa, so that check andVop2SdwaRule::sourceModifiersare removed (only the integer rule had it false: the float rule allowed the bits, and an opcode without an SDWA profile is refused before the rule lookup).The fragment
docs/dev/debt/changes/feat-integer-dpp-sdwa-source-modifiers-r2.mdadds ashaderdebt entry for the modifiers: the PS5's gfx1013 is not measured.SdwaCvtOffSatPkno longer requiresv_cvt_off_f32_i4SDWA withnegorabsto be refused. It runs them, and both, over all seven source selects with and without sign extension and expects the unmodified result. The modifier changes bit 31 of the selected and extended source, and the instruction reads bits 3:0. On the RDNA2 iGPU, 576 results with the modifier (DPP16, and SDWA DWORD, and BYTE_0 and WORD_1 each with and without sign extension, 32 lanes each) all equal the result without it; the other selects were not run with the modifier on hardware. Itsv_sat_pk_u8_i16refusals stay.Still rejected: 16-bit integer sources (
v_cvt_f16_u16,v_cvt_f16_i16, where the hardware uses bit 15),v_sat_pk_u8_i16,v_dot4c_i32_i8andv_mov_b32with a byte or word source. Clamp and omod handling does not change.Tested
Windows 11 Pro, no title.
Hardware reference: each opcode above ran on an RDNA2 GPU (Ryzen 5 7600X integrated graphics, gfx1036, AMD Windows driver 32.0.21045.16010) through
tools/hw-oracle, wave32: 1,296 one-instruction cases (572 in a first sweep of six VOP1 opcodes,v_mov_b32among them, and ten VOP2 opcodes, 724 for the rest), each over 32 lanes of edge values (0, 1, -1, 0x80000000, 0x7fffffff, byte and word sign bits, float specials, shift counts). Each case used DPP16 (quad_perm identity androw_shl:1) or SDWA (DWORD, WORD_1 and BYTE_0 with and without sign extension), with no modifier (the baselines) or with neg, abs or both on src0 or src1. Thev_cndmask_b32and carry cases set VCC withs_mov_b32 vcc_lofirst; the carry-out of the threeco_ciopcodes was read back too. 462 more cases cover the remaining forms the decoder now accepts:v_cndmask_b32SDWA with sign extension, the BYTE_1, BYTE_2, BYTE_3 and WORD_0 selects onv_not_b32,v_cvt_f32_i32,v_xor_b32andv_add_nc_u32, and SDWA sourcesvcc_lo, -1 and 64, in wave32 and (except the VCC-maskedv_cndmask_b32) in wave64. Every case with a modifier matched the bit-31 rule above, and every case without one matched the plain operation. llvm-mc 21 (gfx1030) disassembles the words of every case to the intended opcode, selects and DPP control with the modifier bits cleared, since LLVM rejects them on integer opcodes, exceptv_cndmask_b32SDWA with sign extension, which LLVM rejects as well. The PS5's gfx1013 is not measured.agc_driver_integer_source_modifiers(new,IntegerSourceModifiers.cpp) runs 16 DPP16 and 16 SDWA cases of these opcodes over 16 input rows in 32 lanes. Its expected values are the hardware results of the same instruction words.ctest -VwithVK_INSTANCE_LAYERS=VK_LAYER_KHRONOS_validation,ANYPS5_NO_SHADER_CACHE=1andANYPS5_REQUIRE_VULKAN=1, on the Radeon Graphics iGPU and on the RX 9070 XT. No log reportswas not found but was requested by env var VK_INSTANCE_LAYERS, and none has aVUID-line:agc_driver_integer_source_modifiers, this PRmainVOP1 DPP integer source modifiers are not supportedreadOperandpathv_not_b32 dpp neg of 0x00000000 ... is 0xffffffff, expected 0x7fffffff-R "sdwa|dpp|integer_source_modifiers|decoder_modifiers"(34 tests: every SDWA and DPP execution test,agc_decoder_modifiers,agc_dpp_write,agc_vop1_sdwa_move_decode), this PRmainagc_driver_sdwa_ldexp_f16fail)The one failure on the RX 9070 XT is
agc_driver_sdwa_ldexp_f16(lane 0 BYTE_2/BYTE_1 -> WORD_0 is 0x00000000, expected 0xffff8000).mainfails the same way on that GPU and passes on the iGPU;v_ldexp_f16has the float SDWA profile, whose decoding this PR does not change.On a device whose subgroups hold fewer than 32 lanes the test is skipped, as
Dpp16Operandsis: itsrow_shl:1cases read the neighbouring lane, which is in another subgroup there (lavapipe with 8-lane subgroups, reported in the comments).Checklist
main; no other open PR implements the same functionsNotImplemented_nid_no_patch); silent stubs are listed under Silent stubs in their library's technical debt file.mdfiles or images added to the repository (attach them to this PR)Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-11-18T16:11:33Z.
Review: APPROVED
Reviewed — looks good
Nothing blocks this change; the PR’s reported hardware and test results support the new integer source modifier behavior.
What I ran
Reviewed head
0ac1bdcf6d8e53125c9f658c3fdbae06422b4047using the prepared review bundle andrepo_read.py. No commands or tests were run.Results
Findings
Blocking
None.
Non-blocking
None.
Not verified
I did not run the reported tests or verify their output independently. PS5 gfx1013 behavior is not measured, as the PR description notes. The prepared bundle excluded no changed files (
files.jsonwas not available; the manifest lists all four changed files as included).To get this to a good state
Nothing is required.
Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-11-22T14:06:51Z.
Review: APPROVED
Reviewed — looks good
Nothing blocks this change based on the changed decoder logic and tests reviewed; the reported execution runs are author supplied.
What I ran
ee62e408b33bfcf5050816d0c5949469f9567d47using the prepared diff and pinned reader.Results
Findings
Blocking
None.
Non-blocking
None.
Not verified
IntegerSourceModifiers.cpp,SdwaCvtOffSatPk.cpp,RdnaVectorOpDecoder.cpp, andshader.md. No changed files were excluded.To get this to a good state
Nothing is required.
Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-11-25T20:21:52Z.
Review: APPROVED
Reviewed — looks good
The changed decoder and both updated execution tests are included and read at head
38fd7514b40a9e48d13eda72d722678a34952a9b; no verified defect was found in the inspected changes.What I ran
repo_read.pyto inspect the changed decoder and test code at the pinned head. No tests were run.Results
Findings
Blocking
None.
Non-blocking
None.
Not verified
No test execution was performed. Hardware results and CI outcomes in the PR description were not independently verified. No changed files were excluded;
files.jsonwas unavailable in the review bundle.To get this to a good state
Nothing is required.