feat(libSceGnmDriver): run PS4 compute queue rings on AGC compute queues #18546
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/18546"
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 adam25136 on 2026-11-11T21:12:20Z.
What
sceGnmMapComputeQueue,sceGnmDingDongandsceGnmUnmapComputeQueuethrew. 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 callssceGnmDingDongwith the new write offset. DealPotato reported on 2026-10-18 that inFAMOUS Second Son (CUSA00004) callssceGnmMapComputeQueueandsceGnmDingDong(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 withsceAgcDriverSubmitAcbon that queue, and then writes the new offset to the title's read offset. The AGC driver copies the commands, and the command buffers anINDIRECT_BUFFERcalls, during that submit (all but what follows aREWINDpacket in a called command buffer), so the read offset moves whensceGnmDingDongreturns, before the packets run. AREWINDpacket in the ring throws, since the AGC driver would keep a pointer into the copy made for the submit, which is freed whensceGnmDingDongreturns.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.
sceGnmMapComputeQueue0x1a4df99, through the wrapper at0x2140830, 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;0x2128860sets the ring's end toring + (size << 2)0x24bf84000of size 8192, and the read offset at0x24bf8c000, right after a ring of 8192 dwordssceGnmDingDong0x1a4e0be(through0x2140880) passes the id and(write pointer - ring) >> 2, an offset in dwords;0x1a4e16bpasses the id and 0sceGnmUnmapComputeQueue0x1a4dfdc(through0x2140870) passes the idWhich inputs
sceGnmMapComputeQueuerefuses: 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'ssceGnmMapComputeQueueWithPriorityreturns0x80D17000to0x80D17004for exactly these, as read in open #16238, and shadPS4 refuses them insceGnmMapComputeQueuewith 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, aREWINDpacket 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 nextsceGnmDingDong(liverpool.cpp), where this throws; and it waits at aREWINDpacket 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.sceGnmMapComputeQueueWithPriorityandsceGnmDingDongForWorkload(libSceGnmDriverForNeoMode) are unchanged; open #16238 makessceGnmMapComputeQueueWithPriorityreturn firmware 10.71's error codes (and0x80D170FFfor a valid map) andsceGnmDingDongForWorkloadreturn 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 from986d2b7c52onmain4bde85a85a, this PR's commit before its rebase ontodff7484fd1(the five changed files are identical), except: the mutation checks, which ran on8b5f33d3e9(the same commit before a rebase; its five changed files are identical); the overlap check and the inFAMOUS builds, which merged it ontomainac243b6901; the GTA V starts, which were without this PR; the earlier round onedce278743named 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):WRITE_DATAbehind a0x6875marker NOP in the ring runs, and the read offset moves to the given offset;INDIRECT_BUFFERin the ring runs the command buffer it calls;WAIT_REG_MEM, its write stays undone and work on the first ring runs;REWINDpacket in the ring throws before anything is submitted: theWRITE_DATAbefore it does not run;sceGnmDingDongorsceGnmUnmapComputeQueueafter 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:
gnm_driver_compute_queuesceGnmUnmapComputeQueuenot freeing the ringREWINDpacket in the ring acceptedThe unchanged branch passes before and after them.
The tests
tools/select_tests.py selectpicks for the five changed files: 1,122 of 5,043 on this branch and 1,121 of 5,042 onmain4bde85a85a(the new test is the difference). The only failure isguest_kernel_sys_paths_symlinkat_patched, a timeout on both sides. In an earlier round on an older version of this branch (edce278743),loadexec_argumentsfailed 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 onmain, noVUID-line and no "was not found but was requested" line on either side; aVK_LOADER_DEBUG=layerrun 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
mainac243b6901, both with open #18033 (65cc907322) and #18184 (ddc3b0095a) merged locally and three local changes, none of them in this PR (the relinker also loadslibSceGnmDriverForNeoMode.prx, alibSceDiscMapplaceholder returns an error, andsceVideoOutConfigureOutputMode_returns 0); one build with this PR merged too. Three starts of up to 60 s each:sceGnmMapComputeQueue not implemented0x68754000) at dword 263 of the 324-dword compute command buffer the ring calls; the same buffer has 7-dwordRELEASE_MEMpackets with the compute header bit, which the AGC driver refuses tooGTA 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
maindff7484fd1as956a330a45: the four GNM tests pass again with the validation layer, with noVUID-line.Rebased again (2026-11-13) onto
main0d6edf029easb6f66cbaff, after #18558 added 19 declarations right aftersceGnmUnmapComputeQueueinApi.hpp. All 19 are kept and this PR'ssceGnmUnmapComputeQueue(std::uint32_t id)stays, so the changed lines are the same as956a330a45's. On0d6edf029e, with the same setup:tools/select_tests.py selectpicks for the five changed files pass;VUID-line;tools/check_conventions.pywith this title and description passes again;gnm_driver_compute_queuewith 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, onmainac243b6901): 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. #14212 conflicts withmainindocs/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
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)🤖 Generated with Claude Code