feat(libSceAgcDriver): back the global data share with driver-owned guest memory #285

Merged
SP4C3B4R-8 merged 3 commits from upstream-pr/285 into main 2026-10-07 21:00:33 +00:00
SP4C3B4R-8 commented 2026-10-01 21:57:11 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by SP4C3B4R-8 on 2026-10-01T21:57:11Z.


What

Implements the Gds descriptor role. The 64 KiB global data share is allocated once as driver-owned guest memory (an anonymous mmap in the guest address range). Shader GDS bindings bind that range as a writable, atomic guest buffer, and DMA_DATA packets with a GDS source or destination read and write the same range, so both go through the existing CPU/GPU coherence tracking. The test that expected unsupported descriptor role Gds now checks that a GDS binding with a guest descriptor is rejected. The new execution test agc_driver_gds_append_consume sets GDS counters with DMA_DATA, runs ds_append/ds_consume on the GDS (wave32, wave64, full and partial EXEC, two waves per group) and reads the counters back with DMA_DATA.

Tested

Windows 11, MinGW-w64 GCC 15.2.0 (winlibs, ucrt posix seh). Rebased on main 4764e59c. Full build and ctest: 396/396 passed on this branch alone. Also checked with a retail title.

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 in TechnicalDebt
  • No notes, investigation .md files or images added to the repository
  • New third-party code is a submodule built from source
  • Generic behaviour, not specific to one title
  • Depends on: none
  • AI-assisted: yes (Claude). I reviewed and take responsibility for every line.

🤖 Generated with Claude Code

<!-- greyfinch-sync:boykopovar/AnyPS5:issue:4710110056 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/285). Originally posted by [SP4C3B4R-8](https://github.com/SP4C3B4R-8) on 2026-10-01T21:57:11Z. --- ### What Implements the `Gds` descriptor role. The 64 KiB global data share is allocated once as driver-owned guest memory (an anonymous `mmap` in the guest address range). Shader GDS bindings bind that range as a writable, atomic guest buffer, and DMA_DATA packets with a GDS source or destination read and write the same range, so both go through the existing CPU/GPU coherence tracking. The test that expected `unsupported descriptor role Gds` now checks that a GDS binding with a guest descriptor is rejected. The new execution test `agc_driver_gds_append_consume` sets GDS counters with DMA_DATA, runs `ds_append`/`ds_consume` on the GDS (wave32, wave64, full and partial EXEC, two waves per group) and reads the counters back with DMA_DATA. ### Tested Windows 11, MinGW-w64 GCC 15.2.0 (winlibs, ucrt posix seh). Rebased on `main` `4764e59c`. Full build and `ctest`: 396/396 passed on this branch alone. Also checked with a retail title. ### Checklist - [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 - [x] Unimplemented paths throw (`NotImplemented_nid_no_patch`); silent stubs are listed in TechnicalDebt - [x] No notes, investigation `.md` files or images added to the repository - [x] New third-party code is a submodule built from source - [x] Generic behaviour, not specific to one title - [x] Depends on: none - [x] AI-assisted: yes (Claude). I reviewed and take responsibility for every line. 🤖 Generated with [Claude Code](https://claude.com/claude-code)
oneandonlydean commented 2026-10-02 00:51:01 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by oneandonlydean on 2026-10-02T00:51:01Z.


Some context first: PPSA21564 runs its light lists through GDS, with ds_append in a pixel shader and in compute kernels, and the CP reads the counters back through DMA_DATA. On my integration branch I had that working another way, with a device-owned 64 KiB Vulkan buffer. From reading the diff, this PR covers everything that title needed from mine: draws and dispatches can bind the GDS, and a DMA_DATA from GDS sees the shaders' results through the existing write tracking. So I don't plan to send mine.

One thing this PR changes: GdsAddress() takes the 64 KiB from the title's flexible memory budget. sceKernelMapFlexibleMemory is checked against FLEXIBLE_MEMORY_SIZE in libkernel, but the hardware GDS is not part of that budget. Two effects:

  • Allocation failure: a title that maps all of its flexible memory before its first GDS access gets ENOMEM, and GdsAddress() throws "cannot allocate the global data share". This also covers a CP-only DMA_DATA into GDS (clearing append counters, for example), which works on main today without any shader.
  • Reported size: sceKernelAvailableFlexibleMemorySize reports 64 KiB less after the first GDS access than before it.

Allocating the GDS outside the flexible accounting would avoid both.

If they're useful, I also have GPU tests for this on my branch: ds_append and ds_consume from compute in wave32 and wave64, a pixel shader appending per pixel, and the CP reading the counters back through DMA_DATA. I can port them onto the execution test harness from #251 as a follow-up once this lands.

<!-- greyfinch-sync:boykopovar/AnyPS5:comment:5943504960 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/285#issuecomment-5943504960). Originally posted by [oneandonlydean](https://github.com/oneandonlydean) on 2026-10-02T00:51:01Z. --- Some context first: PPSA21564 runs its light lists through GDS, with ds_append in a pixel shader and in compute kernels, and the CP reads the counters back through DMA_DATA. On my integration branch I had that working another way, with a device-owned 64 KiB Vulkan buffer. From reading the diff, this PR covers everything that title needed from mine: draws and dispatches can bind the GDS, and a DMA_DATA from GDS sees the shaders' results through the existing write tracking. So I don't plan to send mine. One thing this PR changes: `GdsAddress()` takes the 64 KiB from the title's flexible memory budget. `sceKernelMapFlexibleMemory` is checked against `FLEXIBLE_MEMORY_SIZE` in libkernel, but the hardware GDS is not part of that budget. Two effects: - **Allocation failure:** a title that maps all of its flexible memory before its first GDS access gets `ENOMEM`, and `GdsAddress()` throws "cannot allocate the global data share". This also covers a CP-only DMA_DATA into GDS (clearing append counters, for example), which works on main today without any shader. - **Reported size:** `sceKernelAvailableFlexibleMemorySize` reports 64 KiB less after the first GDS access than before it. Allocating the GDS outside the flexible accounting would avoid both. If they're useful, I also have GPU tests for this on my branch: ds_append and ds_consume from compute in wave32 and wave64, a pixel shader appending per pixel, and the CP reading the counters back through DMA_DATA. I can port them onto the execution test harness from #251 as a follow-up once this lands.
SP4C3B4R-8 commented 2026-10-02 09:41:05 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by SP4C3B4R-8 on 2026-10-02T09:41:05Z.


Thanks, both points are right. c7eac17 maps the GDS through the anonymous mapping path instead of sceKernelMapFlexibleMemory, so it is no longer charged to FLEXIBLE_MEMORY_SIZE: a title that has used its whole flexible budget can still touch the GDS (including a CP-only DMA_DATA into it), and sceKernelAvailableFlexibleMemorySize reports the same value before and after the first GDS access. The PM4 test now checks that, and it fails on the previous commit.

Porting your ds_append/ds_consume and per-pixel append tests onto the #251 harness as a follow-up would be great, they cover far more of the shader side than this PR does.

<!-- greyfinch-sync:boykopovar/AnyPS5:comment:5949438310 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/285#issuecomment-5949438310). Originally posted by [SP4C3B4R-8](https://github.com/SP4C3B4R-8) on 2026-10-02T09:41:05Z. --- Thanks, both points are right. c7eac17 maps the GDS through the anonymous mapping path instead of `sceKernelMapFlexibleMemory`, so it is no longer charged to `FLEXIBLE_MEMORY_SIZE`: a title that has used its whole flexible budget can still touch the GDS (including a CP-only DMA_DATA into it), and `sceKernelAvailableFlexibleMemorySize` reports the same value before and after the first GDS access. The PM4 test now checks that, and it fails on the previous commit. Porting your ds_append/ds_consume and per-pixel append tests onto the #251 harness as a follow-up would be great, they cover far more of the shader side than this PR does.
oneandonlydean commented 2026-10-02 10:01:58 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by oneandonlydean on 2026-10-02T10:01:58Z.


Thanks, c7eac17 looks right to me: the GDS now goes through the anonymous mapping path, so it stays out of the flexible accounting, and the new Pm4 check covers the reported size. I'll port the ds_append/ds_consume and per-pixel append tests onto the #251 harness once this lands.

<!-- greyfinch-sync:boykopovar/AnyPS5:comment:5949849651 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/285#issuecomment-5949849651). Originally posted by [oneandonlydean](https://github.com/oneandonlydean) on 2026-10-02T10:01:58Z. --- Thanks, c7eac17 looks right to me: the GDS now goes through the anonymous mapping path, so it stays out of the flexible accounting, and the new Pm4 check covers the reported size. I'll port the ds_append/ds_consume and per-pixel append tests onto the #251 harness once this lands.
SP4C3B4R-8 commented 2026-10-02 10:06:46 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by SP4C3B4R-8 on 2026-10-02T10:06:46Z.


Thanks for checking it, and for taking the tests on.

<!-- greyfinch-sync:boykopovar/AnyPS5:comment:5949950856 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/285#issuecomment-5949950856). Originally posted by [SP4C3B4R-8](https://github.com/SP4C3B4R-8) on 2026-10-02T10:06:46Z. --- Thanks for checking it, and for taking the tests on.
ThisIsAkill commented 2026-10-03 20:00:23 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by ThisIsAkill on 2026-10-03T20:00:23Z.


Tested on Linux (GCC 16.2), PPSA21567, with this PR's two commits applied onto main d3ec1f15. It clears unsupported descriptor role Gds. The shader that hit it uses only ds_append on GDS (6 sites, M0 base 0xc60, size 0x20). ds_consume and plain GDS reads and writes were not exercised, and I did not check whether the title uses the DMA_DATA GDS path. The title then stops at an unrelated error in a later compute shader.

<!-- greyfinch-sync:boykopovar/AnyPS5:comment:5972954038 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/285#issuecomment-5972954038). Originally posted by [ThisIsAkill](https://github.com/ThisIsAkill) on 2026-10-03T20:00:23Z. --- Tested on Linux (GCC 16.2), PPSA21567, with this PR's two commits applied onto `main` d3ec1f15. It clears `unsupported descriptor role Gds`. The shader that hit it uses only `ds_append` on GDS (6 sites, M0 base 0xc60, size 0x20). `ds_consume` and plain GDS reads and writes were not exercised, and I did not check whether the title uses the DMA_DATA GDS path. The title then stops at an unrelated error in a later compute shader.
Celegans12 commented 2026-10-05 20:29:15 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by Celegans12 on 2026-10-05T20:29:15Z.


Tested c7eac179 on Windows 11, MinGW-w64 GCC 15.2.0, RTX 3080 Laptop (NVIDIA 610.62).

  • Merged onto current main 681f83e5 (clean): -DBUILD_TESTING=ON, full build, ctest 316/316, GPU execution tests included.
  • PR test changes alone on main: agc_driver_graphics fails with unsupported descriptor role Gds. agc_driver_pm4 passes there: main keeps the GDS in a static array, so the new flexible-memory check has nothing to catch on main.
  • Branch as is: ctest 95/95 apart from agc_driver_flip, which crashes intermittently here (heap corruption or segfault) on its base 709d7fe0 as well.
  • Local GPU check (throwaway execution test, not proposed for this PR): compute ds_append (full and partial EXEC) and ds_consume on GDS with M0 = 0x01000020, two dispatches back to back, counters set by DMA_DATA immediate→GDS and read by DMA_DATA GDS→memory through Pm4::Execute. For wave64 (64- and 32-lane subgroups) and wave32 the final counters and per-wave returned values are exact, and a GDS read issued before WaitIdle already sees both dispatches. On main it fails with unsupported descriptor role Gds.
  • PPSA26344 v1.008, on our integration branch with this PR merged and an unrelated local workaround to get past an earlier stop: the title clears GDS ranges with DMA_DATA, dispatches 0x80003f2a00 and 0x80003a1d00 (wave64, 60×34 groups of 8×8, M0 user data 0x0d180010 and 0x0d280024), then reads the counters back with DMA_DATA. The counter at GDS +0xd28 (M0 base of 0x80003a1d00) reads back 0x1fe00, the dispatch's thread count. unsupported descriptor role Gds is gone; the run now stops at an unrelated compute shader 0x800040a500: guest sampler descriptor uses unnormalized coordinates. These two shaders use only ds_append on GDS (1 and 9 sites); the title's ds_add_rtn_u32 GDS sites were not reached.

Nit: the description still says the GDS is allocated with sceKernelMapFlexibleMemory; since c7eac17 it is an anonymous mmap.

<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6002352332 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/285#issuecomment-6002352332). Originally posted by [Celegans12](https://github.com/Celegans12) on 2026-10-05T20:29:15Z. --- Tested c7eac179 on Windows 11, MinGW-w64 GCC 15.2.0, RTX 3080 Laptop (NVIDIA 610.62). - Merged onto current main 681f83e5 (clean): `-DBUILD_TESTING=ON`, full build, ctest 316/316, GPU execution tests included. - PR test changes alone on main: `agc_driver_graphics` fails with `unsupported descriptor role Gds`. `agc_driver_pm4` passes there: main keeps the GDS in a static array, so the new flexible-memory check has nothing to catch on main. - Branch as is: ctest 95/95 apart from `agc_driver_flip`, which crashes intermittently here (heap corruption or segfault) on its base 709d7fe0 as well. - Local GPU check (throwaway execution test, not proposed for this PR): compute `ds_append` (full and partial EXEC) and `ds_consume` on GDS with M0 = 0x01000020, two dispatches back to back, counters set by DMA_DATA immediate→GDS and read by DMA_DATA GDS→memory through `Pm4::Execute`. For wave64 (64- and 32-lane subgroups) and wave32 the final counters and per-wave returned values are exact, and a GDS read issued before `WaitIdle` already sees both dispatches. On main it fails with `unsupported descriptor role Gds`. - PPSA26344 v1.008, on our integration branch with this PR merged and an unrelated local workaround to get past an earlier stop: the title clears GDS ranges with DMA_DATA, dispatches 0x80003f2a00 and 0x80003a1d00 (wave64, 60×34 groups of 8×8, M0 user data 0x0d180010 and 0x0d280024), then reads the counters back with DMA_DATA. The counter at GDS +0xd28 (M0 base of 0x80003a1d00) reads back 0x1fe00, the dispatch's thread count. `unsupported descriptor role Gds` is gone; the run now stops at an unrelated `compute shader 0x800040a500: guest sampler descriptor uses unnormalized coordinates`. These two shaders use only `ds_append` on GDS (1 and 9 sites); the title's `ds_add_rtn_u32` GDS sites were not reached. Nit: the description still says the GDS is allocated with `sceKernelMapFlexibleMemory`; since c7eac17 it is an anonymous `mmap`.
Celegans12 commented 2026-10-06 13:11:47 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by Celegans12 on 2026-10-06T13:11:47Z.


Performance data from PPSA26344 v1.008 with c7eac179, for after this lands. Not a regression: the drain is in main's packet path.

Build: our integration branch (main 5895ea72 + c7eac179 + other open PRs and local fixes) with a local per-packet timer (wall time in the packet loop), same machine as above.

  1. Every frame clears four GDS ranges with DMA_DATA from immediate 0. Two of them, on q20 (GDS +0x400, 0x200 bytes; +0x600, 0x40 bytes), usually take under 15 ms. Each of the other two sits right before a dispatch whose user data carries that base and size:
    • q38 +328 46104000 00000000 00000000 00000d28 00000000 40000024 (+0xd28, 0x24 bytes), the 0x80003a1d00 range from the comment above;
    • q0 +3172 c6104000 00000000 00000000 00000d50 00000000 00000018 (+0xd50, 0x18 bytes), then a 240×135-group dispatch (0x0d500018).
  2. Pm4::ResolveStore returns nullopt for a GDS destination (Execution/src/Pm4.cpp:505 at c7eac179), so preparePacketMemory drains the device before each fill.
  3. 120 s run, 86 frames from 30 s on, frame period 997 ms (median): q38 +328 takes 594 ms (572–620), q0's fill 579 ms (509–605). In every frame the two end within 1.6 ms of each other, so they overlap: about 0.58 s per frame with both queue workers blocked.
  4. The title orders both fills after 0x800036e100 ("Cull CS Lights", q38 +214): q38 has CS_PARTIAL_FLUSH at +286/+288 (after +281, 0x8000405a00), and q0 waits for the label q38 +219 releases. The wait follows that dispatch's GPU time: in two runs with APS5_PROFILE_GPU and different debug options, q38 +328 averaged 582 / 644 ms against 605 / 646 ms per 0x800036e100 dispatch.
  5. A 300 s run reports [sync] 680 device drains by packet: DMA_DATA=680 at about 285 s, the number of GDS fills started by then (four per frame plus 7 on q30, GDS +0xd18 (0x10 bytes)). In that run q20's and q30's fills went over 15 ms 31 times. The 4-byte GDS→memory copies are not drains; the first on q0 (+3186) takes about 22 ms per frame.

That exclusion (on main as well) is what makes these fills drain. Not measured: the frame time without it.

<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6017018040 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/285#issuecomment-6017018040). Originally posted by [Celegans12](https://github.com/Celegans12) on 2026-10-06T13:11:47Z. --- Performance data from PPSA26344 v1.008 with c7eac179, for after this lands. Not a regression: the drain is in `main`'s packet path. Build: our integration branch (`main` 5895ea72 + c7eac179 + other open PRs and local fixes) with a local per-packet timer (wall time in the packet loop), same machine as above. 1. Every frame clears four GDS ranges with DMA_DATA from immediate 0. Two of them, on q20 (GDS +0x400, 0x200 bytes; +0x600, 0x40 bytes), usually take under 15 ms. Each of the other two sits right before a dispatch whose user data carries that base and size: - q38 +328 `46104000 00000000 00000000 00000d28 00000000 40000024` (+0xd28, 0x24 bytes), the 0x80003a1d00 range from the comment above; - q0 +3172 `c6104000 00000000 00000000 00000d50 00000000 00000018` (+0xd50, 0x18 bytes), then a 240×135-group dispatch (0x0d500018). 2. `Pm4::ResolveStore` returns nullopt for a GDS destination (`Execution/src/Pm4.cpp:505` at c7eac179), so `preparePacketMemory` drains the device before each fill. 3. 120 s run, 86 frames from 30 s on, frame period 997 ms (median): q38 +328 takes 594 ms (572–620), q0's fill 579 ms (509–605). In every frame the two end within 1.6 ms of each other, so they overlap: about 0.58 s per frame with both queue workers blocked. 4. The title orders both fills after 0x800036e100 ("Cull CS Lights", q38 +214): q38 has CS_PARTIAL_FLUSH at +286/+288 (after +281, 0x8000405a00), and q0 waits for the label q38 +219 releases. The wait follows that dispatch's GPU time: in two runs with `APS5_PROFILE_GPU` and different debug options, q38 +328 averaged 582 / 644 ms against 605 / 646 ms per 0x800036e100 dispatch. 5. A 300 s run reports `[sync] 680 device drains by packet: DMA_DATA=680` at about 285 s, the number of GDS fills started by then (four per frame plus 7 on q30, GDS +0xd18 (0x10 bytes)). In that run q20's and q30's fills went over 15 ms 31 times. The 4-byte GDS→memory copies are not drains; the first on q0 (+3186) takes about 22 ms per frame. That exclusion (on `main` as well) is what makes these fills drain. Not measured: the frame time without it.
SP4C3B4R-8 commented 2026-10-06 21:15:35 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by SP4C3B4R-8 on 2026-10-06T21:15:35Z.


@Celegans12 thanks for testing on Windows and for the GPU check of ds_append / ds_consume. Fixed the description: since c7eac17 the GDS is an anonymous mmap, not sceKernelMapFlexibleMemory.

Written with AI assistance (Claude Code).

<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6025593774 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/285#issuecomment-6025593774). Originally posted by [SP4C3B4R-8](https://github.com/SP4C3B4R-8) on 2026-10-06T21:15:35Z. --- @Celegans12 thanks for testing on Windows and for the GPU check of `ds_append` / `ds_consume`. Fixed the description: since c7eac17 the GDS is an anonymous `mmap`, not `sceKernelMapFlexibleMemory`. Written with AI assistance (Claude Code).
ThisIsAkill commented 2026-10-06 23:40:51 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by ThisIsAkill on 2026-10-06T23:40:51Z.


Tested on PPSA21567 (Linux, RTX 3070 8 GB, default build, virtual display) on main 5895ea72 + #732 (for the loader) + this PR, merged locally (c748c384).

  • Without this PR, 2 of 2 runs on main + #732 ended 6 to 11 s in with AGC graphics: unsupported descriptor role Gds.
  • With it, that stop no longer appears. The run now ends 7 s in at compute shader 0x5005f7800: AGC driver: guest memory is not readable at 0x30 (range 0x30+0x4), which looks like the #479 class (null SRT pointer reads, #759).

One run with this PR, so I can't say more about how far it gets.

<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6027496321 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/285#issuecomment-6027496321). Originally posted by [ThisIsAkill](https://github.com/ThisIsAkill) on 2026-10-06T23:40:51Z. --- Tested on PPSA21567 (Linux, RTX 3070 8 GB, default build, virtual display) on `main` `5895ea72` + #732 (for the loader) + this PR, merged locally (`c748c384`). - Without this PR, 2 of 2 runs on `main` + #732 ended 6 to 11 s in with `AGC graphics: unsupported descriptor role Gds`. - With it, that stop no longer appears. The run now ends 7 s in at `compute shader 0x5005f7800: AGC driver: guest memory is not readable at 0x30 (range 0x30+0x4)`, which looks like the #479 class (null SRT pointer reads, #759). One run with this PR, so I can't say more about how far it gets.
adriadam10 commented 2026-10-07 13:29:19 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by adriadam10 on 2026-10-07T13:29:19Z.

Review: CHANGES_REQUESTED


Checked on Linux (RADV): build and full ctest green merged onto current main, the GDS ranges are still validated before use (Pm4.cpp:433-434), and the mapping stays out of the flexible budget. One thing missing before merge:

  • No test covers the new path. The only test that fails without the change is the rejection in tests/Graphics.cpp:1284, and the new check in tests/Pm4.cpp:330 passes on main too (main has no mapping to charge). Nothing exercises a shader binding the GDS, which is what this PR adds; tests/execution/DsAppendConsume.cpp covers LDS only. Please add an execution test along the lines of the one @Celegans12 described: set counters with DMA_DATA immediate→GDS, run ds_append/ds_consume on GDS from compute in wave32 and wave64 (full and partial EXEC), and read them back with DMA_DATA GDS→memory, pinning the final counters and the per-wave return values. If @oneandonlydean's tests from his branch are ready to port, including them here works just as well.

Not blocking, for a follow-up: with the GDS now in guest memory, Pm4::ResolveStore no longer needs to return nullopt for a GDS destination (Pm4.cpp:556); that exclusion is what makes the per-frame GDS clears drain the device in @Celegans12's measurements.

<!-- greyfinch-sync:boykopovar/AnyPS5:review:5443023281 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/285#pullrequestreview-5443023281). Originally posted by [adriadam10](https://github.com/adriadam10) on 2026-10-07T13:29:19Z. **Review:** CHANGES_REQUESTED --- Checked on Linux (RADV): build and full ctest green merged onto current main, the GDS ranges are still validated before use (`Pm4.cpp:433-434`), and the mapping stays out of the flexible budget. One thing missing before merge: - **No test covers the new path.** The only test that fails without the change is the rejection in `tests/Graphics.cpp:1284`, and the new check in `tests/Pm4.cpp:330` passes on `main` too (main has no mapping to charge). Nothing exercises a shader binding the GDS, which is what this PR adds; `tests/execution/DsAppendConsume.cpp` covers LDS only. Please add an execution test along the lines of the one @Celegans12 described: set counters with DMA_DATA immediate→GDS, run `ds_append`/`ds_consume` on GDS from compute in wave32 and wave64 (full and partial EXEC), and read them back with DMA_DATA GDS→memory, pinning the final counters and the per-wave return values. If @oneandonlydean's tests from his branch are ready to port, including them here works just as well. Not blocking, for a follow-up: with the GDS now in guest memory, `Pm4::ResolveStore` no longer needs to return `nullopt` for a GDS destination (`Pm4.cpp:556`); that exclusion is what makes the per-frame GDS clears drain the device in @Celegans12's measurements.
github-actions[bot] commented 2026-10-07 13:55:19 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by github-actions[bot] on 2026-10-07T13:55:19Z.


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.

Pull request Conflicting files (lines on main) Same exports Same new files
#757 core/libs/prx/libSceAgcDriver/Graphics/src/ShaderValidation.cpp L456
#758 core/libs/prx/libSceAgcDriver/Graphics/src/ShaderValidation.cpp L456
#759 core/libs/prx/libSceAgcDriver/Graphics/src/ShaderValidation.cpp L456
#920 core/libs/prx/libSceAgcDriver/Graphics/src/ShaderValidation.cpp L456
#1128 mmap_nid_postfix
<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6039481960 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/285#issuecomment-6039481960). Originally posted by [github-actions[bot]](https://github.com/apps/github-actions) on 2026-10-07T13:55:19Z. --- <!-- pr-overlap --> 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**. | Pull request | Conflicting files (lines on `main`) | Same exports | Same new files | |---|---|---|---| | #757 | `core/libs/prx/libSceAgcDriver/Graphics/src/ShaderValidation.cpp` [L456](https://github.com/boykopovar/AnyPS5/blob/cea1ef13c35044356348bc6221d45f3a80f7df09/core/libs/prx/libSceAgcDriver/Graphics/src/ShaderValidation.cpp#L456) | | | | #758 | `core/libs/prx/libSceAgcDriver/Graphics/src/ShaderValidation.cpp` [L456](https://github.com/boykopovar/AnyPS5/blob/cea1ef13c35044356348bc6221d45f3a80f7df09/core/libs/prx/libSceAgcDriver/Graphics/src/ShaderValidation.cpp#L456) | | | | #759 | `core/libs/prx/libSceAgcDriver/Graphics/src/ShaderValidation.cpp` [L456](https://github.com/boykopovar/AnyPS5/blob/cea1ef13c35044356348bc6221d45f3a80f7df09/core/libs/prx/libSceAgcDriver/Graphics/src/ShaderValidation.cpp#L456) | | | | #920 | `core/libs/prx/libSceAgcDriver/Graphics/src/ShaderValidation.cpp` [L456](https://github.com/boykopovar/AnyPS5/blob/cea1ef13c35044356348bc6221d45f3a80f7df09/core/libs/prx/libSceAgcDriver/Graphics/src/ShaderValidation.cpp#L456) | | | | #1128 | | `mmap_nid_postfix` | |
orbz22 commented 2026-10-07 15:37:37 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by orbz22 on 2026-10-07T15:37:37Z.


Tested with Astro's Playroom (PPSA01325) on Windows 11, RTX 3060 Laptop, MinGW-w64 GCC 15.2.0, with this PR (c7eac179) merged onto main 3c054008 (the merge is clean).

  • Without this PR the title stops at its first presentation with compute shader 0x5002a8500: AGC graphics: unsupported descriptor role Gds.
  • With it, that error no longer occurs. The run now stops at a different compute shader, 0x5001c6a00: AGC driver: guest memory is not readable at 0x28 (the SRT walk reads through a null user-data pointer), so I can't tell yet whether the GDS shader's output is correct.

Other blockers for this title were bypassed locally to get this far (a missing libSceJobManager and three undeclared imports); they are unrelated to this PR. Tested with AI assistance (Claude Code).

<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6041271253 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/285#issuecomment-6041271253). Originally posted by [orbz22](https://github.com/orbz22) on 2026-10-07T15:37:37Z. --- Tested with Astro's Playroom (PPSA01325) on Windows 11, RTX 3060 Laptop, MinGW-w64 GCC 15.2.0, with this PR (c7eac179) merged onto main 3c054008 (the merge is clean). - Without this PR the title stops at its first presentation with `compute shader 0x5002a8500: AGC graphics: unsupported descriptor role Gds`. - With it, that error no longer occurs. The run now stops at a different compute shader, `0x5001c6a00: AGC driver: guest memory is not readable at 0x28` (the SRT walk reads through a null user-data pointer), so I can't tell yet whether the GDS shader's output is correct. Other blockers for this title were bypassed locally to get this far (a missing `libSceJobManager` and three undeclared imports); they are unrelated to this PR. Tested with AI assistance (Claude Code).
Celegans12 commented 2026-10-07 15:42:15 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by Celegans12 on 2026-10-07T15:42:15Z.


@orbz22 the stop you hit next (guest memory is not readable at 0x28, an SRT walk through a null user-data pointer in a compute shader) looks like what #759 covers. It turns descriptor reads through a null SRT pointer into deferred faults, so the dispatch only faults if a lane actually executes the read. Ghost of Yōtei has several shaders like that behind branches the GPU never takes. #759 is being rebased onto current main right now; once it's up, it might be worth a try with Astro's Playroom on top of this PR.

<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6041360781 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/285#issuecomment-6041360781). Originally posted by [Celegans12](https://github.com/Celegans12) on 2026-10-07T15:42:15Z. --- @orbz22 the stop you hit next (`guest memory is not readable at 0x28`, an SRT walk through a null user-data pointer in a compute shader) looks like what #759 covers. It turns descriptor reads through a null SRT pointer into deferred faults, so the dispatch only faults if a lane actually executes the read. Ghost of Yōtei has several shaders like that behind branches the GPU never takes. #759 is being rebased onto current main right now; once it's up, it might be worth a try with Astro's Playroom on top of this PR.
orbz22 commented 2026-10-07 16:06:24 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by orbz22 on 2026-10-07T16:06:24Z.


@Celegans12 thanks, that was it. With #759 (a3de45b1) and this PR (c7eac179) both merged onto main 3c054008, the guest memory is not readable at 0x28 stop in compute shader 0x5001c6a00 is gone. The only conflict was the role list in ShaderValidation.cpp, resolved by accepting both Gds and ImageTableMap.

Astro's Playroom now opens its window and presents one frame (black), then hangs:

[gpu] queue 0x3d WAIT_REG_MEM_64 at 0x400201f40 timed out after 1000ms (function 3 ref 0x1 mask 0xffffffff value 0x0)
[gpu]   preceding packet DISPATCH_RESET 000000c2
[gpu]   preceding packet PUSH_MARKER 00000000
[gpu]   preceding packet SET_UCONFIG_REG 00000342 c8020004 00201f40
[gpu]   preceding packet WAIT_REG_MEM_64 06000013 00201f40 00000004 00000001 00000000 ffffffff 00000000 00000019

Nothing writes 1 to that label before the timeout. Before it, some draws are skipped (color compression, DCC ... is unsupported, vertex fetch exceeds descriptor record count, missing register at DWORD 0x1b3). I'll look into where that label should come from. Tested with AI assistance (Claude Code).

<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6041811306 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/285#issuecomment-6041811306). Originally posted by [orbz22](https://github.com/orbz22) on 2026-10-07T16:06:24Z. --- @Celegans12 thanks, that was it. With #759 (a3de45b1) and this PR (c7eac179) both merged onto main 3c054008, the `guest memory is not readable at 0x28` stop in compute shader `0x5001c6a00` is gone. The only conflict was the role list in `ShaderValidation.cpp`, resolved by accepting both `Gds` and `ImageTableMap`. Astro's Playroom now opens its window and presents one frame (black), then hangs: ``` [gpu] queue 0x3d WAIT_REG_MEM_64 at 0x400201f40 timed out after 1000ms (function 3 ref 0x1 mask 0xffffffff value 0x0) [gpu] preceding packet DISPATCH_RESET 000000c2 [gpu] preceding packet PUSH_MARKER 00000000 [gpu] preceding packet SET_UCONFIG_REG 00000342 c8020004 00201f40 [gpu] preceding packet WAIT_REG_MEM_64 06000013 00201f40 00000004 00000001 00000000 ffffffff 00000000 00000019 ``` Nothing writes 1 to that label before the timeout. Before it, some draws are skipped (`color compression, DCC ... is unsupported`, `vertex fetch exceeds descriptor record count`, `missing register at DWORD 0x1b3`). I'll look into where that label should come from. Tested with AI assistance (Claude Code).
SP4C3B4R-8 commented 2026-10-07 20:14:36 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by SP4C3B4R-8 on 2026-10-07T20:14:36Z.


@adriadam10 thanks, test added in faa1cc59; the branch is rebased onto current main (4764e59c, no conflicts).

tests/execution/GdsAppendConsume.cpp (agc_driver_gds_append_consume):

  • sets four GDS counters with DMA_DATA immediate → GDS and reads them back with DMA_DATA GDS → memory before the first dispatch;
  • runs a compute program with ds_append / ds_consume on the GDS (M0 base 0, size 0xffff), at full EXEC and then with v_cmpx leaving only part of the lanes; inactive lanes must keep their sentinel;
  • four groups: wave32 with 32 lanes active, wave32 with 20, two wave32 waves in one group with 40 active (the second wave partial), and wave64 with 40 active (EXEC across both halves);
  • two dispatches per group, reading the counters back after each, so the counters must carry over between dispatches in the GDS memory. For every wave all active lanes must get the same value, and the per-wave values must be the counter start plus/minus the active counts of the waves before it, in either wave order.

On main without this PR it fails with unsupported descriptor role Gds. Full ctest passes on Windows (396/396). I left ResolveStore alone, as you suggested, for a follow-up.

Written with AI assistance (Claude Code).

<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6046008535 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/285#issuecomment-6046008535). Originally posted by [SP4C3B4R-8](https://github.com/SP4C3B4R-8) on 2026-10-07T20:14:36Z. --- @adriadam10 thanks, test added in `faa1cc59`; the branch is rebased onto current `main` (`4764e59c`, no conflicts). `tests/execution/GdsAppendConsume.cpp` (`agc_driver_gds_append_consume`): - sets four GDS counters with `DMA_DATA` immediate → GDS and reads them back with `DMA_DATA` GDS → memory before the first dispatch; - runs a compute program with `ds_append` / `ds_consume` on the GDS (M0 base 0, size 0xffff), at full EXEC and then with `v_cmpx` leaving only part of the lanes; inactive lanes must keep their sentinel; - four groups: wave32 with 32 lanes active, wave32 with 20, two wave32 waves in one group with 40 active (the second wave partial), and wave64 with 40 active (EXEC across both halves); - two dispatches per group, reading the counters back after each, so the counters must carry over between dispatches in the GDS memory. For every wave all active lanes must get the same value, and the per-wave values must be the counter start plus/minus the active counts of the waves before it, in either wave order. On `main` without this PR it fails with `unsupported descriptor role Gds`. Full `ctest` passes on Windows (396/396). I left `ResolveStore` alone, as you suggested, for a follow-up. Written with AI assistance (Claude Code).
adriadam10 commented 2026-10-07 21:00:29 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by adriadam10 on 2026-10-07T21:00:29Z.

Review: APPROVED


Thanks for the test. Checked on Linux (RADV) merged onto current main: full ctest green, and agc_driver_gds_append_consume and agc_driver_graphics both fail with the driver changes reverted, so the shader GDS binding and the DMA_DATA GDS path are now covered. Merging once CI is green.

<!-- greyfinch-sync:boykopovar/AnyPS5:review:5448299239 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/285#pullrequestreview-5448299239). Originally posted by [adriadam10](https://github.com/adriadam10) on 2026-10-07T21:00:29Z. **Review:** APPROVED --- Thanks for the test. Checked on Linux (RADV) merged onto current main: full ctest green, and `agc_driver_gds_append_consume` and `agc_driver_graphics` both fail with the driver changes reverted, so the shader GDS binding and the DMA_DATA GDS path are now covered. Merging once CI is green.
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!285
No description provided.