Skip to content

feat(libSceGnmDriver): run PS4 compute queue rings on AGC compute queues - #18546

Merged
oneandonlydean merged 1 commit into
boykopovar:mainfrom
adam25136:feat/gnm-compute-queues
Nov 14, 2026
Merged

oneandonlydean merged 1 commit into
boykopovar:mainfrom
adam25136:feat/gnm-compute-queues

Conversation

@adam25136

@adam25136 adam25136 commented Nov 11, 2026 •

Copy link
Copy Markdown
Contributor

What

sceGnmMapComputeQueue, sceGnmDingDong and sceGnmUnmapComputeQueue threw. A PS4 title uses them for asynchronous compute: it maps a ring of PM4 packets for a compute pipe and queue, writes packets into the ring and calls sceGnmDingDong with the new write offset. DealPotato reported on 2026-10-18 that inFAMOUS Second Son (CUSA00004) calls sceGnmMapComputeQueue and sceGnmDingDong (comment on #6977), with a local change, not pushed, that ran the rings on AGC compute queues.

  • sceGnmMapComputeQueue(pipe, queue, ring, ring size in dwords, read offset) gives each pipe and queue its own AGC compute queue, from 0x20 on, and returns a positive id. The first map selects GCN shaders, as the first draw submission does.
  • sceGnmDingDong(id, offset in dwords) takes the ring's packets from the last offset to the new one, wrapping at the end of the ring, lowers them as the packets of a draw command buffer are lowered, submits them with sceAgcDriverSubmitAcb on that queue, and then writes the new offset to the title's read offset. The AGC driver copies the commands, and the command buffers an INDIRECT_BUFFER calls, during that submit (all but what follows a REWIND packet in a called command buffer), so the read offset moves when sceGnmDingDong returns, before the packets run. A REWIND packet in the ring throws, since the AGC driver would keep a pointer into the copy made for the submit, which is freed when sceGnmDingDong returns.
  • sceGnmUnmapComputeQueue(id) frees the id and its pipe and queue without waiting; work already submitted keeps running on that AGC queue.

Where the arguments come from: GTA V's call sites and the values inFAMOUS passed in a local run, not a console measurement.

Call CUSA00419 01.57 (GTA V) CUSA00223 01.07 (inFAMOUS Second Son)
sceGnmMapComputeQueue the call at 0x1a4df99, through the wrapper at 0x2140830, passes the pipe and queue from a structure, the ring, its size and a read-offset address; a negative result is an error, and after a success the title stores the id and writes 0 to the read offset itself; 0x2128860 sets the ring's end to ring + (size << 2) a local run logged pipe 0, queue 0, a ring at 0x24bf84000 of size 8192, and the read offset at 0x24bf8c000, right after a ring of 8192 dwords
sceGnmDingDong 0x1a4e0be (through 0x2140880) passes the id and (write pointer - ring) >> 2, an offset in dwords; 0x1a4e16b passes the id and 0
sceGnmUnmapComputeQueue 0x1a4dfdc (through 0x2140870) passes the id

Which inputs sceGnmMapComputeQueue refuses: a pipe above 6, a queue above 7, a ring that is not 256-byte aligned or not a power of two in size, and a read offset that is not 4-byte aligned. PS4 firmware 10.71's sceGnmMapComputeQueueWithPriority returns 0x80D17000 to 0x80D17004 for exactly these, as read in open #16238, and shadPS4 refuses them in sceGnmMapComputeQueue with the same codes. The codes of this function itself are not read from its firmware, so here these inputs throw (NotImplemented_nid_no_patch), as do these cases, whose console results are not known: a missing ring or read offset, a pipe and queue that are already mapped, an id that is not mapped, a REWIND packet in the ring, and an offset at or past the end of the ring or inside a packet. The new debt entry lists them. The ids are AnyPS5's own; titles only pass them back.

Where this differs from shadPS4 at 4788f0b108: it returns the error codes, where this throws; it accepts a second map of a pipe and queue; its map writes 0 to the read offset (GTA V's wrapper does that itself); it moves the read offset packet by packet as it runs them (liverpool.cpp); it keeps a packet that ends past the offset until the next sceGnmDingDong (liverpool.cpp), where this throws; and it waits at a REWIND packet in the ring until its valid bit is set (liverpool.cpp), where this throws.

Not done here: the packets in the command buffers a ring calls are not lowered. The AGC driver copies an INDIRECT_BUFFER's target into the submission and checks it as it is, so PS4 forms there still throw; inFAMOUS stops on one of them (below). Open #20127 accepts four of these forms in AGC, so this one stays on the three functions. sceGnmMapComputeQueueWithPriority and sceGnmDingDongForWorkload (libSceGnmDriverForNeoMode) are unchanged; open #16238 makes sceGnmMapComputeQueueWithPriority return firmware 10.71's error codes (and 0x80D170FF for a valid map) and sceGnmDingDongForWorkload return 0 without ringing.

Tested

Windows 10 Pro 22H2 (19045), i9-12900KF, NVIDIA GeForce RTX 5080 (driver 621.14), WinLibs GCC 15.2.0 r7, CMake 4.3.1, Ninja, Release, BUILD_TESTING=ON. The results below are from 986d2b7c52 on main 4bde85a85a, this PR's commit before its rebase onto dff7484fd1 (the five changed files are identical), except: the mutation checks, which ran on 8b5f33d3e9 (the same commit before a rebase; its five changed files are identical); the overlap check and the inFAMOUS builds, which merged it onto main ac243b6901; the GTA V starts, which were without this PR; the earlier round on edce278743 named under the selected tests; and the two rebase bullets near the end, which name their own commits.

  • New test gnm_driver_compute_queue (tests/ComputeQueue.cpp, skips without a Vulkan device):

    • a WRITE_DATA behind a 0x6875 marker NOP in the ring runs, and the read offset moves to the given offset;
    • an INDIRECT_BUFFER in the ring runs the command buffer it calls;
    • a packet that wraps past the end of a 16-dword ring runs;
    • a second ring gets its own id; while it waits on a WAIT_REG_MEM, its write stays undone and work on the first ring runs;
    • an offset inside a packet throws and leaves the read offset where it was;
    • a REWIND packet in the ring throws before anything is submitted: the WRITE_DATA before it does not run;
    • a pipe and queue mapped twice, pipe 7, queue 8, a ring of 12 dwords, a null ring, a ring 4 bytes off 256-byte alignment, a read offset 2 bytes off 4-byte alignment, an offset at the ring's end, an unknown id, and sceGnmDingDong or sceGnmUnmapComputeQueue after unmapping all throw; pipe 6, queue 7 maps, and a pipe and queue can be mapped again after unmapping.

    It passed 30 of 30 runs (0.74 to 0.84 s).

  • Does it fail without the change? Each part broken in turn, with the test kept:

    Broken gnm_driver_compute_queue
    the read offset not written fails: "the read offset was not moved to the ring offset sceGnmDingDong was given"
    no wrap at the end of the ring fails: "a packet that wraps past the end of the ring did not run"
    ring packets not lowered fails: the AGC driver refuses the marker NOP
    one AGC queue for every ring fails: "work on one ring waited for a WAIT_REG_MEM on another ring"
    an unmapped id accepted fails: "sceGnmDingDong after sceGnmUnmapComputeQueue did not throw"
    sceGnmUnmapComputeQueue not freeing the ring fails, with the same message
    a pipe and queue mapped twice accepted fails: "expected an exception"
    any ring size accepted fails: "expected an exception"
    any pipe accepted fails: "expected an exception"
    any queue accepted fails: "expected an exception"
    a ring off 256-byte alignment accepted fails: "expected an exception"
    a read offset off 4-byte alignment accepted fails: "expected an exception"
    an offset inside a packet accepted fails: "an offset inside a packet did not throw"
    a REWIND packet in the ring accepted fails: "expected an exception"

    The unchanged branch passes before and after them.

  • The tests tools/select_tests.py select picks for the five changed files: 1,122 of 5,043 on this branch and 1,121 of 5,042 on main 4bde85a85a (the new test is the difference). The only failure is guest_kernel_sys_paths_symlinkat_patched, a timeout on both sides. In an earlier round on an older version of this branch (edce278743), loadexec_arguments failed once on the branch side; in this head's round it passed, and run alone on this head it passed 5 of 5.

  • Validation layer (VK_INSTANCE_LAYERS=VK_LAYER_KHRONOS_validation, ANYPS5_REQUIRE_VULKAN=1, ANYPS5_NO_SHADER_CACHE=1), ctest -R "^(gnm_driver_|guest_gnm_driver)" -V: 4 of 4 on the branch and 3 of 3 on main, no VUID- line and no "was not found but was requested" line on either side; a VK_LOADER_DEBUG=layer run of the new test shows the layer loaded.

  • A build with ANYPS5_ENABLE_SPIRV_TOOLS=ON: the same four GNM tests pass.

  • The title, inFAMOUS Second Son CUSA00223 01.07: two builds on main ac243b6901, both with open fix(libSceVideoOut): accept buffer option 8 from PS4 callers #18033 (65cc907322) and fix(libSceSysmodule): accept four PS4-only module ids in a PS4 process #18184 (ddc3b0095a) merged locally and three local changes, none of them in this PR (the relinker also loads libSceGnmDriverForNeoMode.prx, a libSceDiscMap placeholder returns an error, and sceVideoOutConfigureOutputMode_ returns 0); one build with this PR merged too. Three starts of up to 60 s each:

    Build Result
    without this PR 3 of 3 end after 6.8 to 7.1 s with sceGnmMapComputeQueue not implemented
    with this PR 3 of 3 pass the map (pipe 0, queue 0) and end after 6.8 to 7.1 s on the next stop: the AGC driver refuses a PS4 marker NOP (0x68754000) at dword 263 of the 324-dword compute command buffer the ring calls; the same buffer has 7-dword RELEASE_MEM packets with the compute header bit, which the AGC driver refuses too
  • GTA V CUSA00419 imports all three, but none of our GTA V starts without this PR called them; the furthest stopped on other errors after 37 to 39 s. It was not run with this PR.

  • Rebased before opening onto main dff7484fd1 as 956a330a45: the four GNM tests pass again with the validation layer, with no VUID- line.

  • Rebased again (2026-11-13) onto main 0d6edf029e as b6f66cbaff, after feat(libSceGnmDriver): export the 19 remaining NeoMode-only imports #18558 added 19 declarations right after sceGnmUnmapComputeQueue in Api.hpp. All 19 are kept and this PR's sceGnmUnmapComputeQueue(std::uint32_t id) stays, so the changed lines are the same as 956a330a45's. On 0d6edf029e, with the same setup:

    • the 1,061 tests tools/select_tests.py select picks for the five changed files pass;
    • the four GNM tests pass with the validation layer, with no VUID- line;
    • tools/check_conventions.py with this title and description passes again;
    • each of the 14 mutations above fails gnm_driver_compute_queue with the same message as before, and the unchanged branch passes before and after them.
  • python tools/check_conventions.py --base origin/main --title "<this title>" --body <this description>: all conventions checks passed.

  • tools/pr_overlap.py --branch (in a full clone, on main ac243b6901): 1,998 open pull requests; ten share files or exports with this branch, and none of them conflicts with it, adds the same exports or adds the same new files. docs(debt): separate entries with blank lines and drop derived export totals #14212 conflicts with main in docs/dev/debt/libSceGnmDriver.md, so the tool could not compare it there; by hand: it only adds blank lines between entries, and merged with this branch its existing conflict hunk also holds the new entry, with no other conflict in that file.

Not covered: Linux and macOS (built and run only on Windows); AMD and Intel GPUs; what a console returns for the cases that throw, its queue ids and when it moves the read offset; titles that call sceGnmMapComputeQueueWithPriority.

Checklist

  • Based on current main; no other open PR implements the same functions
  • One topic per PR; follow-ups go in a new PR
  • No comments in code except technical debt
  • Unimplemented paths throw (NotImplemented_nid_no_patch); silent stubs are listed under Silent stubs in their library's technical debt file
  • No notes, investigation .md files or images added to the repository (attach them to this PR)
  • New third-party code is a submodule built from source
  • Generic behaviour, not specific to one title
  • Depends on: none
  • Fixes: none
  • Unblocks: CUSA00223 inFAMOUS Second Son (CUSA00223) #8214
  • GPUs tested: NVIDIA GeForce RTX 5080, driver 621.14, Windows 10 Pro 22H2
  • AI-assisted: yes

🤖 Generated with Claude Code

@JJenkx

JJenkx commented Nov 11, 2026

Copy link
Copy Markdown
Contributor

Windows check of head 956a330a45. Setup: Windows 11 Enterprise 22621, AMD RX 6700 XT, AMD driver 26.10.1, MinGW-w64 GCC 15.2 UCRT, Release.

gnm_driver_compute_queue:

  • GPU, through the shared Windows GPU FIFO with ANYPS5_REQUIRE_VULKAN=1, merged onto main 229394a16d (merge 60c75458ea): passed in 3 of 3 runs. The binary matched the hash recorded at preparation, and the receipt shows exit 0 and app_count=0.
  • CPU, Vulkan hidden, merged onto main 7014889b3e (merge 43ff911da9): skipped (it needs a device), 0 failed, in 3 of 3 runs.

AI-assisted: yes.

@relativespace2K

Copy link
Copy Markdown
Contributor

Windows/AMD validation on RDNA 2: the new compute-queue case passes.

  • AMD Radeon RX 6800 XT (gfx1030, subgroup 64), AMD proprietary driver 26.10.1, Windows 11 IoT Enterprise LTSC 26100, head 956a330a45, Release, WinLibs GCC 15.2.
  • ANYPS5_REQUIRE_VULKAN=1, ANYPS5_NO_SHADER_CACHE=1, VK_INSTANCE_LAYERS=VK_LAYER_KHRONOS_validation.
  • gnm_driver_compute_queue passes in 1.49 s; the neighbours pass too (gnm_driver_packets 0.05 s, gnm_driver_submit_wait 1.28 s); no VUID- line and the layer loaded.
  • The device line reports Wave32 programs run on subgroups of 32: compute 1, mesh 0, so the PS4 compute ring path ran on the AMD wave32 packing rather than the NVIDIA one.

The PR's run was on an RTX 5080; this adds an AMD one.

sceGnmMapComputeQueue, sceGnmDingDong and sceGnmUnmapComputeQueue threw.
Each pipe and queue now has its own AGC compute queue from 0x20 and a
positive id. sceGnmDingDong takes the ring's packets from the last offset to
the new one, wrapping at the ring's end, lowers them as a draw command
buffer's packets are lowered, submits them with sceAgcDriverSubmitAcb and
then sets the title's read offset to the new offset. sceGnmUnmapComputeQueue
frees the id without waiting: the AGC driver has copied the ring's commands,
and the command buffers they call, by then. A REWIND packet in a ring throws,
since the AGC driver would keep a pointer into the copy made for the submit.

A pipe above 6, a queue above 7, a ring that is not 256-byte aligned or not
a power of two in size, and a read offset that is not 4-byte aligned throw:
PS4 firmware 10.71's sceGnmMapComputeQueueWithPriority refuses these inputs
(as read in boykopovar#16238), and shadPS4 refuses them too. The arguments follow call
sites in CUSA00419 and the values CUSA00223 passed in a local run; what they
leave open, such as a missing ring or read offset, throws and is listed in
the debt entry.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@adam25136
adam25136 force-pushed the feat/gnm-compute-queues branch from 956a330 to b6f66cb Compare November 13, 2026 07:29
@github-actions github-actions Bot added the review queue Next in the maintainer review queue: checks pass, no open change request, no conflict label Nov 14, 2026
@github-actions

Copy link
Copy Markdown

Some comparisons could not be completed because a pull request conflicts with the base branch. Review these shared files manually before concluding that there is no overlap.

Pull request Shared files not compared
PR 17942 core/libs/prx/libSceGnmDriver/CMakeLists.txt
core/libs/prx/libSceGnmDriver/Export.cpp
core/libs/prx/libSceGnmDriver/include/Api.hpp
docs/dev/debt/libSceGnmDriver.md
PR 18217 core/libs/prx/libSceGnmDriver/CMakeLists.txt
core/libs/prx/libSceGnmDriver/Export.cpp
core/libs/prx/libSceGnmDriver/include/Api.hpp
docs/dev/debt/libSceGnmDriver.md

@Ricard-Kollcaku

Copy link
Copy Markdown
Contributor

NVIDIA run on Ubuntu 26.04.1 LTS: NVIDIA GeForce RTX 4080 SUPER, driver 595.99.02, Intel Core i9-14900KF, GCC 15.2.0 Release, validation layer 1.4.341. PR head b6f66cbaff merged onto main c04f8bec02 (git merge --no-ff, clean merge).

main c04f8bec02 this PR
whole ctest suite (5424 tests on main, 5425 with the PR) 0 failed, 61 skipped 0 failed, the same 61 skipped
gnm_driver_compute_queue not in main passed 3/3 alone and once in the suite; each log shows Selected GPU name=NVIDIA GeForce RTX 4080 SUPER, none skipped
gnm_driver_packets, gnm_driver_submit_wait, guest_gnm_driver passed passed
VUID- lines / layer not found 0 / 0 0 / 0

Negative control: none: gnm_driver_compute_queue does not compile against main (error: too many arguments to function 'int sceGnmMapComputeQueue()', and the same for sceGnmDingDong()).

Command: ANYPS5_GPU="RTX 4080" ANYPS5_REQUIRE_VULKAN=1 ANYPS5_NO_SHADER_CACHE=1 VK_INSTANCE_LAYERS=VK_LAYER_KHRONOS_validation VK_LOADER_DEBUG=layer ctest --test-dir build -j 8 --timeout 120 -V

AI-assisted: yes (Claude Code ran the tests and drafted this comment)

@oneandonlydean
oneandonlydean merged commit 68abe63 into boykopovar:main Nov 14, 2026
15 of 17 checks passed
@github-actions github-actions Bot removed the review queue Next in the maintainer review queue: checks pass, no open change request, no conflict label Nov 14, 2026
oneandonlydean pushed a commit that referenced this pull request Nov 29, 2026
sceGnmSubmitCommandBuffers and sceGnmSubmitAndFlipCommandBuffers merge
each draw and constant command buffer into a copy, hand the copy to AGC
and free it on return. AGC waits on a REWIND by reading the packet's
control word, and later the packets after it, at the address it was
given, so for a REWIND at the top of a draw command buffer it kept
reading the freed copy, and never saw the title release the REWIND in
its own buffer.

Such a REWIND now throws, as a REWIND in a compute ring (#18546) or in
a buffer a compute ring calls (#20384) already does. A REWIND in a
buffer the draw command buffer calls is read from the title's memory
and is not changed by this.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

build docs prx unblocks title Names a title ID on the Unblocks line

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants