fix(libSceGnmDriver): lower the PS4 packets in command buffers a compute ring calls #20384

Merged
Gag21 merged 1 commit from upstream-pr/20384 into main 2026-11-15 04:21:28 +00:00
Gag21 commented 2026-11-15 03:47:06 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by Gag21 on 2026-11-15T03:47:06Z.


What

A PS4 title (CUSA01709 01.02) submits its compute work through sceGnmDingDong as rings that call other command buffers with INDIRECT_BUFFER. sceGnmDingDong lowered only the packets in the ring itself, so the PS4 packets in the called buffers reached the AGC executor unchanged and the submission was refused:

[gpu] rejected submission of 610 dwords at guest 000000fc08aa5f00:
[gpu]   DMA_DATA                     x1     DMA_DATA register destination is not implemented
[gpu]   RELEASE_MEM                  x2     PM4 header flags 0x2 are not implemented
[gpu]   at DWORD 519    header 0xc0054902 RELEASE_MEM              7 dwords: 0000062f 23000000 02a40a60 00000002 00000001 00000000
[gpu]   at DWORD 589    header 0xc0055000 DMA_DATA                 7 dwords: 60000000 004f2500 00000002 0003022c 00000000 2820006c
  what():  AGC driver: RELEASE_MEM at DWORD 519: PM4 header flags 0x2 are not implemented

The debt file already recorded the gap ("Command buffers a ring calls are not lowered"). The DMA_DATA above is the PS4 SDK's tag prefetch, which the lowering already turns into a NOP when it sees it.

  • sceGnmDingDong now copies a buffer a ring calls with a plain INDIRECT_BUFFER and lowers its packets in place of the call, up to two levels below the ring (the hardware's IB1 and IB2). A third level, and a REWIND in a called buffer, throw through NotImplemented_nid_no_patch. Predicated, chained and conditional calls are passed on as before.
  • The lowering now handles the PS4 seven-dword RELEASE_MEM: it becomes the eight-dword form the executor takes, without the compute header bit and with a zero context dword. The layout is shadPS4's PM4CmdReleaseMem. A destination select other than memory throws; any other size is refused.
  • docs/dev/debt/libSceGnmDriver.md: the "not lowered" sentence is replaced by an entry that says what is still not lowered, what throws, and that a called buffer is read once, when sceGnmDingDong is called.

One difference to be aware of: the executor rereads a called buffer behind a wait, and a buffer lowered here is a copy taken at sceGnmDingDong. That is the same as for the buffers sceGnmSubmitCommandBuffers lowers.

Tested

Windows 11 Pro 10.0.26300, i5-6600K, RTX 3070 (driver 621.01), WinLibs GCC 16.2.0, CMake 4.4.4, Ninja, Release, BUILD_TESTING=ON.

The build that was tested is a local branch with other unmerged changes plus exactly this diff (the code lines of the two source files were compared and are identical). This branch itself, on main 2d74858c14, was not built locally.

  • gnm_driver_compute_queue has a new case: a ring calls a buffer holding a PS4 32-bit RELEASE_MEM with the compute header bit, the SDK's tag prefetch DMA_DATA, a WRITE_DATA and a call to a second buffer holding a 64-bit RELEASE_MEM. All three stores land and the read offset moves. A call three levels below the ring, a RELEASE_MEM with a cache destination, and an eight-dword RELEASE_MEM in a called buffer throw, and nothing of a refused submission runs. It passes.
  • Does it fail without the change? With sceGnmDingDong lowering only the ring again, the test fails with the title's error: AGC driver: RELEASE_MEM at DWORD 0: PM4 header flags 0x2 are not implemented.
  • guest_gnm_driver, gnm_driver_packets and gnm_driver_submit_wait pass.
  • The title: with this change and other local changes that are not in this PR, CUSA01709 no longer stops at the submission above. It stops later, in the graphics path (DB_RENDER_CONTROL depth copy, resummarize or decompress is unsupported), which is a separate gap.
  • python tools/check_conventions.py --base origin/main passes. python tools/pr_overlap.py --branch fix/gnm-lower-called-compute-buffers --repo boykopovar/AnyPS5 reports no overlap with open pull requests.

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: none
  • GPUs tested: n/a
  • AI-assisted: yes

🤖 Generated with Claude Code

<!-- greyfinch-sync:boykopovar/AnyPS5:issue:5319193578 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/20384). Originally posted by [Gag21](https://github.com/Gag21) on 2026-11-15T03:47:06Z. --- ### What A PS4 title (CUSA01709 01.02) submits its compute work through `sceGnmDingDong` as rings that call other command buffers with `INDIRECT_BUFFER`. `sceGnmDingDong` lowered only the packets in the ring itself, so the PS4 packets in the called buffers reached the AGC executor unchanged and the submission was refused: ``` [gpu] rejected submission of 610 dwords at guest 000000fc08aa5f00: [gpu] DMA_DATA x1 DMA_DATA register destination is not implemented [gpu] RELEASE_MEM x2 PM4 header flags 0x2 are not implemented [gpu] at DWORD 519 header 0xc0054902 RELEASE_MEM 7 dwords: 0000062f 23000000 02a40a60 00000002 00000001 00000000 [gpu] at DWORD 589 header 0xc0055000 DMA_DATA 7 dwords: 60000000 004f2500 00000002 0003022c 00000000 2820006c what(): AGC driver: RELEASE_MEM at DWORD 519: PM4 header flags 0x2 are not implemented ``` The debt file already recorded the gap ("Command buffers a ring calls are not lowered"). The `DMA_DATA` above is the PS4 SDK's tag prefetch, which the lowering already turns into a NOP when it sees it. - `sceGnmDingDong` now copies a buffer a ring calls with a plain `INDIRECT_BUFFER` and lowers its packets in place of the call, up to two levels below the ring (the hardware's IB1 and IB2). A third level, and a `REWIND` in a called buffer, throw through `NotImplemented_nid_no_patch`. Predicated, chained and conditional calls are passed on as before. - The lowering now handles the PS4 seven-dword `RELEASE_MEM`: it becomes the eight-dword form the executor takes, without the compute header bit and with a zero context dword. The layout is [shadPS4's `PM4CmdReleaseMem`](https://github.com/shadps4-emu/shadPS4/blob/a808e7626e3c7de8d0f0fda6a91f620b42f6c762/src/video_core/amdgpu/pm4_cmds.h#L907-L935). A destination select other than memory throws; any other size is refused. - `docs/dev/debt/libSceGnmDriver.md`: the "not lowered" sentence is replaced by an entry that says what is still not lowered, what throws, and that a called buffer is read once, when `sceGnmDingDong` is called. One difference to be aware of: the executor rereads a called buffer behind a wait, and a buffer lowered here is a copy taken at `sceGnmDingDong`. That is the same as for the buffers `sceGnmSubmitCommandBuffers` lowers. ### Tested <!-- OS, title or homebrew, what was checked. "Not tested" is a valid answer. A performance change: the summary lines of main and of this PR from the same machine and scene, with the traces attached, captured as the Performance report issue form describes. --> Windows 11 Pro 10.0.26300, i5-6600K, RTX 3070 (driver 621.01), WinLibs GCC 16.2.0, CMake 4.4.4, Ninja, Release, `BUILD_TESTING=ON`. The build that was tested is a local branch with other unmerged changes plus exactly this diff (the code lines of the two source files were compared and are identical). This branch itself, on `main` `2d74858c14`, was not built locally. - **`gnm_driver_compute_queue`** has a new case: a ring calls a buffer holding a PS4 32-bit `RELEASE_MEM` with the compute header bit, the SDK's tag prefetch `DMA_DATA`, a `WRITE_DATA` and a call to a second buffer holding a 64-bit `RELEASE_MEM`. All three stores land and the read offset moves. A call three levels below the ring, a `RELEASE_MEM` with a cache destination, and an eight-dword `RELEASE_MEM` in a called buffer throw, and nothing of a refused submission runs. It passes. - **Does it fail without the change?** With `sceGnmDingDong` lowering only the ring again, the test fails with the title's error: `AGC driver: RELEASE_MEM at DWORD 0: PM4 header flags 0x2 are not implemented`. - `guest_gnm_driver`, `gnm_driver_packets` and `gnm_driver_submit_wait` pass. - **The title:** with this change and other local changes that are not in this PR, CUSA01709 no longer stops at the submission above. It stops later, in the graphics path (`DB_RENDER_CONTROL depth copy, resummarize or decompress is unsupported`), which is a separate gap. - `python tools/check_conventions.py --base origin/main` passes. `python tools/pr_overlap.py --branch fix/gnm-lower-called-compute-buffers --repo boykopovar/AnyPS5` reports no overlap with open pull requests. ### Checklist <!-- Rules behind each item: https://github.com/boykopovar/AnyPS5/blob/main/CONTRIBUTING.md --> - [x] Based on current `main`; no other open PR implements the same functions - [x] One topic per PR; follow-ups go in a new PR - [x] No comments in code except [technical debt](https://github.com/boykopovar/AnyPS5/blob/main/docs/dev/CONVENTIONS.md) - [x] Unimplemented paths throw (`NotImplemented_nid_no_patch`); silent stubs are listed under Silent stubs in their library's [technical debt](https://github.com/boykopovar/AnyPS5/tree/main/docs/dev/debt) file - [x] No notes, investigation `.md` files or images added to the repository (attach them to this PR) - [x] New third-party code is a submodule built from source - [x] Generic behaviour, not specific to one title - [x] Depends on: none - [x] Fixes: none - [x] Unblocks: none - [x] GPUs tested: n/a - [x] AI-assisted: yes 🤖 Generated with [Claude Code](https://claude.com/claude-code)
Sign in to join this conversation.
No reviewers
No labels
No milestone
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Reference
boykopovar/AnyPS5!20384
No description provided.