fix(shader): accept abs, neg and omod on VOP3 v_alignbit_b32 and v_alignbyte_b32 #25799
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/25799"
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 chippy01 on 2026-11-22T17:58:03Z.
What
The RDNA decoder refused the VOP3
abs,negandomodbits onv_alignbit_b32(0x14e) andv_alignbyte_b32(0x14f) withVOP3 source modifiers are not implemented. It now accepts them and passesabsandnegto the three sources.Measured on RDNA2 (gfx1036; the PS5's gfx1013 is not measured):
absclears bit 31,negflips it, and both set it, as #19577 measured for integer DPP and SDWA sources. There is no integer negate or absolute value.op_selbyte select,absandnegcannot change the result, so the measurement cannot show whether they apply there, or in which order against the byte select. Bit 31 of src0 is bit 63 of{src0, src1}, which a shift of at most 31 never brings into the result, and the shift amount keeps only bits 0-4 (v_alignbit_b32) or 0-1 (v_alignbyte_b32) of src2 or of its selected byte.op_selresults match the src2 byte select followed by the masked shift.omodandclampleave the result unchanged, at IEEE 0 and 1 with f32 denormals flushed and kept.readOperandalready appliesabsandnegto bit 31 after the src2 byte select, and the decoder already dropsomodandclampfor these opcodes, so the change is decoder-only: the align branch ofcheckNativeVop3Modifiersstops throwing, and the decode path callsapplyNativeVop3SourceModifiersafterapplyNativeVop3AlignSelectors. It passesabsandnegto all three sources, which gives the same results as passing them to src1 alone.PS4 shaders take the same path:
encodeVop3inGcnInstructionDecoder.cppre-encodes GCN VOP30x14eand0x14fto the same RDNA opcodes and copies theabs,negandomodbits, so GCN shaders with them are now accepted too. GCN hardware is not measured.Tested
Setup: Windows 11 Pro 10.0.26200; AMD Ryzen 9 7900X with its integrated AMD Radeon Graphics (gfx1036, AMD Windows driver 32.0.21045.29003) and an NVIDIA GeForce RTX 3070 Ti (driver 616.64); MSYS2 UCRT64 GCC 16.2.0, CMake 4.5.1, Ninja 1.13.2, Release,
BUILD_TESTING=ON; Vulkan SDK 1.4.363 validation layer; onmainfb6ac32ba9.RDNA2 measurement (hardware oracle, HIP runtime, wave32): 314 encodings in 26 kernels over 1024 lanes, written with
.longbecause the assembler refuses these bits:abs/negcombinations on both opcodes;omod1, 2 and 3 withneg0, 1 and 7, and with every bit set, at IEEE 0 and 1 with f32 denormals flushed (0) and kept (3);clampwith sixabs/negpatterns;op_sel1, 2, 4, 8, 3 and 15 with sixabs/negpatterns;Lanes combine 0, 1,
0x7fffffff,0x80000000,0x80000001,0xffffffffand other words with and without bit 31 for src0 and src1, and shifts with bit 31 set and clear and different bytes for theop_selselect. All 321,536 results match the model above. Replayed withabsandnegon src1 alone, on all three sources with src2 changed before the byte select, and on all three with src2 changed after it, they give 0 mismatches each; withoutabsandneg, or with them on src0 and src2 only, 123,396 results in 176 encodings differ (scripts/replay_models.py). The scripts, kernels, rows and results are in the attached zip.vop3-align-source-modifiers-evidence.zip
Recompiler comparison (
agc_oracle_runner,HW_ORACLE_RUNTIME=vulkan): the same 26 kernels. Onmainevery kernel is refused withVOP3 source modifiers are not implemented; with this change all 321,536 words equal the hardware results on both the RTX 3070 Ti and the Radeon iGPU.New test:
agc_driver_vop3_align_source_modifierspins 16 encodings per opcode over 32 lanes, with expected values measured on gfx1036. It fails onmainwith the decoder message and passes with the change, 10 of 10 repeated runs on each GPU.Focused tests:
ctest -R '^(agc_driver_vop3.*|agc_decoder_modifiers)$' -VwithANYPS5_REQUIRE_VULKAN=1,ANYPS5_NO_SHADER_CACHE=1,VK_INSTANCE_LAYERS=VK_LAYER_KHRONOS_validationandVK_LOADER_DEBUG=layer, on each GPU throughANYPS5_GPU:main23 of 23 pass, this branch 24 of 24. Every GPU test log showsInsert instance layer "VK_LAYER_KHRONOS_validation", none showswas not found but was requested by env var VK_INSTANCE_LAYERS, and neither branch logs aVUID-.Full ctest (RTX 3070 Ti,
-j 24): 6723 of 6730 pass.agc_driver_store_over_untracked,agc_driver_frame_replay_multisample_depthandframe_capture_minimizepass when rerun alone. The other four fail the same way onmainon this machine:agc_process_sampler_stack(SEH toolchain, #24354),agc_storage_write_back_host_retile(#23708),agc_driver_cpu_label_wake(#25167) andguest_raise_short_sleep_without_wake(#24358).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-22T18:28:16Z.
Review: APPROVED
Reviewed — looks good
The decoder change applies source modifiers after align selectors, matching the stated behavior; the included test covers both align opcodes and modifier combinations.
What I ran
Reviewed head
f5f8d12d0e454140ad64fee3936e208e06dbdb8aagainst prepared artifacts and targeted source context usingrepo_read.py. No tests were run in this review.Results
Findings
Blocking
None.
Non-blocking
None.
Not verified
No test commands were run. Hardware behavior on PS5 gfx1013 was not measured. The PR description’s reported test runs and attached measurement artifacts were not independently verified. Read:
Vop3AlignSourceModifiers.cpp,RdnaVectorOpDecoder.cpp, andfix-vop3-align-source-modifiers.md; the manifest lists all three as reviewed, with full text available. Excluded files:files.jsonwas not accessible in the prepared review folder, so additional exclusions are not verified.To get this to a good state
Nothing is required.
Imported from boykopovar/AnyPS5. Originally posted by mihiii1337 on 2026-11-23T04:20:30Z.
Review: CHANGES_REQUESTED
Tested exact head
f5f8d12d0eagainst its direct parentdd53c30766on the physical Intel A78B (driver 101.6127), using the same fixture bytes. The parent failed 0/3 with the expected VOP3 source-modifier decoder rejection; the head passed 3/3 with all 1,024 expected words per run. agc_driver_vop3_align_op_sel and agc_driver_vop3_legacy_source_modifiers passed 2/2 on each arm. All ten fresh CTest processes loaded Khronos Validation 1.4.369 and reported no VUIDs, missing-layer diagnostics, validation errors, skips, or synchronization hazards.The decoder behavior and expected tables are functionally consistent. One measurement-precision issue remains in the permanent debt entry and the PR description: the readback cannot distinguish whether src0/src2 sign-bit modifiers are applied or ignored, nor their order relative to src2 byte selection. Please narrow those claims to the observable behavior; details and suggested wording are inline. No decoder or fixture change is requested.
This is independent Intel execution against the embedded gfx1036 reference vectors, not a native gfx1013 measurement.
AI-assisted: yes.
Imported from boykopovar/AnyPS5. Originally posted by mihiii1337 on 2026-11-23T09:20:24Z.
Review: APPROVED
Re-reviewed exact head
37f26a228731b65f2d0f9cfdbbaa1ac41f1c5c66. The documentation-only tip resolves my remaining evidence-scope request: the debt entry and PR description now claim only the observable src1 sign-bit behavior, explain that src0/src2 and selector ordering are indistinguishable from the captured outputs, and mark GCN/PS4 plus gfx1013 as unmeasured.The production decoder and fixture blobs are unchanged from
f5f8d12d0e454140ad64fee3936e208e06dbdb8a, so my earlier physical Intel A78B A/B remains applicable: the parent rejected the modifier in 3/3 runs; the implementation passed 3/3 with all 1,024 expected words, while the op-select and legacy controls passed 2/2 on both arms. Ten fresh processes loaded Khronos Validation 1.4.369 with no VUIDs or missing-layer diagnostics. Helldiverr independently ran the unchanged implementation 3/3 on the R9700 and reproduced that the pinned words distinguish src1 modifiers but not the other sources. The author's replay of all 321,536 hardware words reports the same split.I did not rerun the GPU on this exact head because the only new repository changes are the corrected debt text; hosted replacement checks are still queued. The implementation remains an execution of embedded gfx1036 reference words, not a native gfx1013 or GCN hardware measurement.
AI-assisted: yes.
Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-11-23T09:31:08Z.
Review: COMMENTED
Reviewed — comments
Formal approval is not justified because I could not run the focused tests or inspect the full new test file at the pinned head.
What I ran
Read the prepared description, commits, manifest, diff, and selected decoder and test code at head
37f26a228731b65f2d0f9cfdbbaa1ac41f1c5c66. No commands or tests were run; the reader tools do not execute repository tests.Results
Findings
Blocking
None verified.
Non-blocking
Not verified
The full contents of
Vop3AlignSourceModifiers.cpp, test registration and build configuration, and test results on this revision were not verified. Read:description.md,commits.md,manifest.json,diff.patch, selected sections ofRdnaVectorOpDecoder.cpp, and selected sections ofVop3AlignSourceModifiers.cpp.files.jsonwas unavailable through the reader. No repository files were excluded by the manifest.To get this to a good state
Nothing is required. Optional: confirm the test is registered and run the focused test suite on this revision; validate on gfx1013 or GCN when available.