feat(shader): accept neg/abs on 16-bit integer DPP and SDWA sources #19592
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/19592"
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:30:38Z.
What
This builds on #19577 (
neg/abson 32-bit integer DPP and SDWA sources), which is merged.The RDNA decoder accepts the DPP16 and SDWA
negandabssource bits on 16-bit integer sources instead of throwing, and the 16-bit integer source reader applies them.v_cvt_f16_u16andv_cvt_f16_i16: DPP16 and SDWA, every source select (isVop1Integer16SourceOpcode, accepted where #19577 accepts the 32-bit integer opcodes; thevop1SdwaRulesrows are unchanged).v_ldexp_f16src1, the i16 exponent: DPP16 and SDWA. Its VOP2 exponent is now read withreadU16AsU32instead ofreadU32.On RDNA2 hardware these bits act on bit 15, the sign bit of the 16-bit operand: NEG flips it, ABS clears it, both set it. There is no two's-complement negate or integer absolute value, and bit 31 is not used. The bit is changed after the DPP lane move (with
bound_ctrl:1an out-of-row lane reads 0, so NEG gives 0x8000) and after the SDWA select and zero/sign extension (sext(BYTE_0)ABS of 0x80 gives 0x7f80).v_cvt_f16_i16with DPP NEG of 1 converts 0x8001 (-32767) and gives 0xf800 (-32768.0 after f16 rounding), where a two's-complement negate would give -1.0.v_ldexp_f16with DPP NEG on an exponent of 1 scales by 2^-32767 and gives +0.TranslationContext::readU16AsU32now applies AND 0x7fff and XOR 0x8000 after the DPP move, the SDWA select and the 16-bit read, before the optional sign extension. The decoder already accepted SDWAneg/abson the VOPC 16-bit integer compares and the reader ignored them; they now follow the same measured rule. The debt fragmentdocs/dev/debt/changes/feat-int16-dpp-sdwa-source-modifiers-r2.mdadds ashaderentry for the modifiers, the VOP3v_ldexp_f16gap and the unmeasured VOPC DPP form below. The VOP3 16-bit integer ALU opcodes and VOP3v_cvt_f16_u16/v_cvt_f16_i16still rejectabsandnegincheckNativeVop3Modifiers, so they are unchanged.SdwaLdexpF16no longer requires the twov_ldexp_f16SDWA forms with src1neg(0x10050404) and src1abs(0x26060604) to be refused.SdwaCvtF16I16Bytes(#18244) no longer requires SDWAnegon thev_cvt_f16_i16source to throw; it now requires that form to decode withnegateset andabsoluteclear. Its refusals of destination selector 7 and destination unused 3 stay.Still rejected:
v_sat_pk_u8_i16, where the hardware changes bit 15 and bit 31, the sign of each packed half. Clamp and omod handling does not change. VOP3 integer compares are not changed: the decoder accepts theirabsbit and does not pass it to the operands; on RDNA2 it clears bit 15 of a 16-bit compare source. VOP3v_ldexp_f16withabsornegon src1 still throws (VOP3 source modifiers are not implemented) and is not changed here. VOPC DPP is not an RDNA2 encoding ("DPP is compatible only with: VOP1 and VOP2", RDNA2 ISA §6.9), llvm-mc 21 does not assemble it for gfx1030, and it was not run; the decoder still decodes it, so theneg/absbits of a VOPC DPP 16-bit integer compare now reach both operands as in VOPC SDWA. The debt entry records that form as not measured.Tested
Windows 11 Pro, no title.
Hardware reference: an RDNA2 GPU (Ryzen 5 7600X integrated graphics, gfx1036, AMD Windows driver 32.0.21045.16010) through
tools/hw-oracle, wave32, 163 one-instruction cases over 32 lanes of edge values (0, 1, 0x7fff, 0x8000, 0xffff, 0x8001, byte sign values, and garbage in the upper half):v_cvt_f16_u16andv_cvt_f16_i16: DPP16 quad_perm identity androw_shl:1withbound_ctrl1 and 0; SDWA DWORD, and WORD_0, WORD_1 and BYTE_0 each with and without sign extension.v_ldexp_f16src1: DPP16 quad_perm identity with no modifier, neg, abs and both, androw_shl:1with neg (the lane move applies to src0); the same SDWA forms as above.v_cmp_lt_i16andv_cmp_lt_u16, with neg, abs or both on src0 or src1.Every case with a modifier matched the bit-15 rule above, and every case without one matched the plain operation. The 16-bit DPP results of
v_cvt_f16_*andv_ldexp_f16keep the upper half of the destination. llvm-mc 21 (gfx1030) disassembles every case to the intended opcode, selects and DPP control with the DPP/SDWA modifier bits cleared. The PS5's gfx1013 is not measured.agc_driver_integer16_source_modifiers(new,Integer16SourceModifiers.cpp) runs 16 DPP16, 16 SDWA and 16 VOPC SDWA compare cases over 16 input rows in 32 lanes. Its expected values are the hardware results of the same instruction words, with FLOAT_MODE 0xc0, IEEE 0 and DX10_CLAMP 1.All runs:
ctest -VwithVK_INSTANCE_LAYERS=VK_LAYER_KHRONOS_validation,ANYPS5_NO_SHADER_CACHE=1andANYPS5_REQUIRE_VULKAN=1. No log reportswas not found but was requested by env var VK_INSTANCE_LAYERS, and none has aVUID-line.This head, on
mainatae0df0e03e(the last commit changes only the debt fragment), on the Radeon Graphics iGPU and on lavapipe (Mesa 26.2.6,llvmpipe (LLVM 23.1.4, 256 bits)), validation layer 1.4.363:agc_driver_sdwa_cvt_f16_i16_bytesandagc_driver_sdwa_cvt_f16_i16_bytes_wave64alone: pass on lavapipe. With the previous head'sSdwaCvtF16I16Bytes.cpp, both fail on both devices before a device opens:SDWA negate on i16 integer source must throw std::invalid_argument. With this head's test file andmain's decoder and translation, both fail:VOP1 SDWA source selector 4 of opcode 0x51 at pc 0x0 is not supported.agc_driver_sdwa_ldexp_f16, the f16 conversion, f16, fp16 overflow,v_ldexp_f16inline constant, NaN quieting, SDWA destination and VOP2 modifier form execution tests,agc_decoder_modifiers,agc_rdna_truncated_modifierandagc_vop1_sdwa_move_decode. On the iGPU all 18 pass; on lavapipe the new test is skipped and the other 17 pass. Withmain's version of every file this PR changes except the new test, the new test fails on the iGPU withVOP1 DPP integer source modifiers are not supported, and the other 17 pass on both devices.Before the rebase (this change on top of #19577's branch), on the Radeon Graphics iGPU and on the RX 9070 XT. The 43 tests: the new test, every SDWA and DPP execution test,
agc_decoder_modifiers, and the f16 conversion,v_ldexp_f16, VOPC, packed 16-bit integer and VOP1/VOP2 integer execution tests (F16ConversionFloatMode,Float16Misc,Float16Modifiers,LdexpF16InlineConstants,Vop1Vop2Integer,Vop2ModifierForms,VopcCompare,VopcCompareTable,PackedIntegerNegate,PackedIntegerClamp,MulLoU16HighHalf):agc_driver_integer16_source_modifiers, this PRVOP1 DPP integer source modifiers are not supportedreadU16AsU32v_cvt_f16_u16 dpp neg of 0x00000000 ... is 0xa5a57c00, expected 0xa5a57800On the RX 9070 XT,
agc_driver_f16_conversion_float_mode,agc_driver_float16_misc,agc_driver_float16_modifiers,agc_driver_ldexp_f16_inline_constants,agc_driver_sdwa_ldexp_f16andagc_driver_vop2_modifier_formsfail on the parent (#19577) and on this PR with the same messages: av_ldexp_f16result of negative zero comes back as +0 (for examplev_ldexp_f16 0x8000, 0.5 is 0x0000, expected 0x8000), including the VOP3 and inline-constant forms that this PR does not change. All six pass on the iGPU.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 on #19577).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-21T04:02:24Z.
Review: APPROVED
Reviewed — looks good
Nothing blocks this change; the reviewed implementation supports merging, and the hardware and test results below are author-reported.
What I ran
Reviewed head
c5e354fc346fa93d6e592251974aa3b6d7bbc147; no commands or tests were run. The prepared diff was used without fetching it again. I read all eight changed files listed inreview/manifest.json, including every changed line; all were included. No files were excluded.Results
ctestresults are author-reportedNegative control
The author reports that replacing bit 15 with bit 31 makes the new test fail on both reported GPUs. I did not run this control.
Findings
Blocking
None.
Non-blocking
None.
Sources
Behavior claims were checked against the prepared diff and the source at the pinned head. The new 16-bit test covers DPP, SDWA, and VOPC SDWA comparisons;
readU16AsU32applies ABS/NEG to bit 15 after lane selection, andv_ldexp_f16uses that reader for the VOP2 exponent. The decoder’s opcode checks and SDWA validation were also inspected.Not verified
No tests were run during this review. GPU execution, console behavior on PS5 gfx1013, and the reported driver and validation-layer results were not independently verified.
To get this to a good state
Nothing is required.
Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-11-22T15:04:07Z.
Review: COMMENTED
Reviewed — no blocking findings
Nothing blocks this change; the source behavior and targeted test paths are consistent with the stated bit-15 modifier semantics, but the review is incomplete because the prepared review folder did not expose the listed full-text files.
What I ran
Reviewed head
8ea8fb8e495c4ea7dbd36b4c320deba4d3d1d9e3using the prepareddiff.patchandrepo_read.pysearches and targeted source reads. No build or test commands were run. The manifest marked all eight changed files as included, but the review-folder listing reported no files underreview/files.Results
Findings
Blocking
None verified in the code inspected.
Non-blocking
None.
Not verified
The full text of all eight manifest-reviewed files was not available in
review/files. Read ranges from the new 16-bit modifier test and selected ranges from other changed files, but not their complete bodies. No tests were run; hardware results in the description are author-reported. PS5 gfx1013 behavior was not confirmed.To get this to a good state
Nothing is required. Optional: make the manifest-listed full-text files available for review and rerun the stated test suite on this head.
Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-11-25T20:21:05Z.
Review: APPROVED
Reviewed — looks good
Nothing blocks this change; the inspected code and author-reported hardware and test results support merging.
What I ran
Reviewed head
f2c848539a6c5455a046eed04fc900b85eef22ceusingrepo_read.pyagainst the prepared review bundle and pinned repository source. No tests or build commands were run by me.Results
Findings
Blocking
None.
Non-blocking
None.
Not verified
No build, test, or physical hardware run was performed during this review. The author reports RDNA2 and RDNA4 test results; PS5 gfx1013 behavior and VOPC DPP behavior were not verified. The bundle’s excluded-file list was not available through the reader; the README lists all nine changed files as included. Reviewed files:
Integer16SourceModifiers.cpp,IntegerSourceModifiers.cpp,SdwaCvtOffSatPk.cpp,SdwaLdexpF16.cpp,RdnaVectorOpDecoder.cpp,FloatInstructions.cpp,SubwordPacking.cpp, and bothfeat-*-source-modifiers-r2.mddebt entries. The reader exposed no additional excluded changed-file content.To get this to a good state
Nothing is required.
Imported from boykopovar/AnyPS5. Originally posted by coderabbitai[bot] on 2026-11-28T18:53:17Z.
Review: COMMENTED
Actionable comments posted: 1
db570037-e02f-4dc5-9ae9-2d86cd07aa61Reviewing files that changed from the base of the PR and between
67d64e4e52andaac5954aa1.core/libs/prx/libSceAgcDriver/tests/execution/Integer16SourceModifiers.cppcore/libs/prx/libSceAgcDriver/tests/execution/SdwaCvtF16I16Bytes.cppcore/libs/prx/libSceAgcDriver/tests/execution/SdwaLdexpF16.cppcore/shader/recompiler/RdnaDecoder/src/RdnaVectorOpDecoder.cppcore/shader/recompiler/Translation/src/FloatInstructions.cppcore/shader/recompiler/Translation/src/TranslationContext/SubwordPacking.cppdocs/dev/debt/changes/feat-int16-dpp-sdwa-source-modifiers-r2.mdIncluded review availability: This review used your included allowance. Your plan provides up to 10 included reviews per hour; 9 remain after this review.
Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-11-28T18:56:40Z.
Review: APPROVED
Reviewed — looks good
Nothing blocks this change; the reviewed code and the reported hardware results support merging.
What I ran
Reviewed head
aac5954aa1ef1f18b661758f55758353f9a58cf0usingrepo_read.pyto inspect the prepared diff and changed source lines, plus the directly touched helpers and callers. No build or test command was run by me. Environment and toolchain were not available through the reader.Results
Negative control
I did not run a negative control. The author reports that replacing bit 15 with bit 31 in
readU16AsU32caused the new execution test to fail on both tested GPUs; this result was not independently verified here.Findings
Blocking
None.
Non-blocking
None.
Sources
v_ldexp_f16Not verified
I did not run the build, tests, hardware oracle, or console behavior checks. The described Windows and GPU results are author-reported. All seven changed files are included and their changed lines were read;
files.jsonwas not available through the reader, so its exclusion list could not be independently checked.To get this to a good state
Nothing is required.
Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-11-28T19:25:42Z.
Review: APPROVED
Reviewed — looks good
Nothing blocks this change; the reviewed implementation and focused coverage support merging.
What I ran
Reviewed head
edb2a71425e5fc623860969cd904b8bf1cb3f72dusing the prepared diff and pinned repository reader. No tests were run by me; I did not perform a merged preview check.Results
Findings
Blocking
None.
Non-blocking
None.
Not verified
The test runs and RDNA2 hardware measurements in the description were author-reported, not run by me. The PR description identifies gfx1013 hardware and VOPC DPP behavior as unmeasured. I read every changed file listed in the manifest; no changed files were excluded from review.
To get this to a good state
Nothing is required.
Imported from boykopovar/AnyPS5. Originally posted by Plyxen on 2026-12-03T14:03:19Z.
Review: APPROVED
I read the diff at
edb2a71425. Windows 11, GCC 15.2, merged intomainat6c6b29320fetogether with other open PRs (so not an isolated build), withANYPS5_REQUIRE_VULKAN=1 ANYPS5_NO_SHADER_CACHE=1andVK_LAYER_KHRONOS_validationon an RTX 5080 (621.24) and a Radeon iGPU (26.11.2).agc_driver_integer16_source_modifiers,agc_driver_sdwa_cvt_f16_i16_bytes(wave32 and wave64) andagc_driver_sdwa_ldexp_f16: pass on both GPUs. The loader log shows the layer inserted and no "was not found" line, and neither run has aVUID-orSYNC-HAZARDline.Not checked: a title.
AI-assisted: yes (Claude Code)
Imported from boykopovar/AnyPS5. Originally posted by ligmaSec on 2026-12-03T22:31:04Z.
Review: COMMENTED
The trial merge onto
c1601e56d5was clean. I checked that the modifier changes bit 15 after DPP/SDWA selects the source halfword and before signed interpretation, and that thev_ldexp_f16exponent uses the 16-bit read path. Keep the fixture’s signed and unsigned conversion controls alongside exponent cases, since clearing a sign bit differs from computing an absolute value. Paired shader execution is pending.AI-assisted: yes.
View command line instructions
Checkout
From your project repository, check out a new branch and test the changes.Merge
Merge the changes and update on Forgejo.Warning: The "Autodetect manual merge" setting is not enabled for this repository, you will have to mark this pull request as manually merged afterwards.