fix(recompiler): recognize plain no-carry draw offset adds #6919
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/6919"
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 yabanana on 2026-10-16T18:32:45Z.
What
Recognize plain, single-word VOP2
v_add_nc_u32additions of a draw-offset user SGPR to the vertex or instance index. The analyzer currently leaves these offsets unknown, so an otherwise eligible indexed indirect draw falls back to CPU processing. Reuse the existing offset analysis and its shared-register, prior-read and conflict checks.This changes offset recognition, not arithmetic lowering.
v_add_nc_u32produces the unsigned sum without a carry output: AMD RDNA 2 ISA, section 12.7, VOP2 opcode 37 (ISA reference, PDF page 134). VOP3 and modified forms remain outside this fold.Add decoded wave32/wave64 regression cases, encoded rejection cases for VOP3 saturation, SDWA, vector offsets, mismatched index registers, non-user scalar registers and subtraction, plus shared-offset and read-before-add controls. Extend the existing indexed indirect GPU test with a no-carry shader and exact vertex/instance-index readback, including an explicit execution marker.
Related to #5806. No captured title shader or game was tested, and this does not establish that the issue is resolved or claim a performance improvement.
Tested
-cpu max), using Mesa llvmpipe LLVM 20.1.2 (256 bits), Mesa 25.2.8. Software Vulkan was required and selected; the no-carry GPU case executed and exact readback matched.agc_embedded_vertex_fetch,agc_embedded_vertex_fetch_aliasing,agc_driver_draw_offset_indices,agc_driver_flip,agc_driver_flip_compute,agc_driver_address_space_teardown, andagc_driver_pipeline_optimized_readback_d32(exact RGBA comparison before/after pipeline optimization). The indexed indirect test printedno-carry indexed indirect GPU readback checked.python3 tools/check_conventions.py --base origin/mainandgit diff --check origin/mainpassed.No physical GPU, Windows or title runtime was tested. Full upstream Linux/Windows builds remain subject to maintainer dispatch.
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 keravyn-ops on 2026-10-17T10:52:32Z.
AMD / Windows run of this PR at
c1745992d: Radeon 780M (RDNA 3, 0x15bf), AMD driver 25.10.20.01 (32.0.21020.1007), Windows 11 Home 10.0.26100, WinLibs GCC 15.2.0 r7, Release.Test suite only, no title run. Every ctest entry built from the test targets this PR changes passes (2):
agc_driver_draw_offset_indices(0.69 s):draw offset index tests passedagc_embedded_vertex_fetch(0.07 s)AI-assisted: yes (runs made on the device above).
Imported from boykopovar/AnyPS5. Originally posted by jotitadev on 2026-10-17T13:35:44Z.
Review: COMMENTED
A run on a hardware GPU, since the description has only llvmpipe under QEMU.
Machine: Ubuntu 26.04, i7-8700, GCC 15.2, Release,
BUILD_TESTING=ON. NVIDIA GeForce RTX 3070 (driver 595.99.02) and lavapipe (Mesa 26.0.3, LLVM 21.1.8) on the same host. PR merged ontomain12a71f3f5(clean).ANYPS5_NO_SHADER_CACHE=1,-j1 --timeout 30.agc_driver_draw_offset_indices,agc_embedded_vertex_fetch,agc_embedded_vertex_fetch_aliasing,agc_driver_pipeline_optimized_readback_d32EmbeddedVertexFetch.cppfrommainagc_driver_draw_offset_indicesfails:the fetch adds of s16 and s17 were not folded into the draw (vertex -1, instance -1);agc_embedded_vertex_fetchfails (no-carry offsets: loads=1 vertex=-1 instance=-1, wave32 and wave64)The no-carry GPU case runs on the 3070 and is not skipped. With
ctest -Vthe record isclassified to the GPU, all six vertex/instance pairs read back as expected (for examplevertex 0 instance 0: after the fetch adds 702 59455; expected 702 59455), and the test printsno-carry indexed indirect GPU readback checked. Same output on lavapipe.Not run: Windows, AMD, any title.
GPUs tested: NVIDIA GeForce RTX 3070 (595.99.02) and lavapipe (Mesa 26.0.3), Ubuntu 26.04
Written with AI assistance (Claude Code). I ran the builds and tests above on my machine.
Imported from boykopovar/AnyPS5. Originally posted by github-actions[bot] on 2026-10-18T16:27:15Z.
Other open pull requests touch the same code. Merging one will break the other, or both implement the same thing. If this one builds on them, list them in Depends on.
main)core/shader/recompiler/Translation/src/EmbeddedVertexFetch.cppL359Imported from boykopovar/AnyPS5. Originally posted by adriadam10 on 2026-10-19T13:41:12Z.
Checked the
v_add_nc_u32encodings in the new tests (VOP2 opcode 37, vdst/vsrc1/src0 fields), thatcarryObservedhas nothing to observe for a carry-less add, and that VOP3/SDWA/vector-offset/mismatched-index/non-user-SGPR/subtraction forms stay rejected. Also covered by independent RTX 3070 and Radeon 780M runs in the thread. Merged.