fix(agc): avoid host synchronous drain on GDS DMA_DATA packets #13137

Closed
ashwin280802 wants to merge 1 commit from upstream-pr/13137 into main
ashwin280802 commented 2026-10-30 04:04:22 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by ashwin280802 on 2026-10-30T04:04:22Z.


What

In Driver::preparePacketMemory(), packets with PM4 opcode 0x50 (DMA_DATA) transferring data to GDS (Pm4::DmaDestination(packet) == Pm4::DmaSelectGds) unconditionally forced a device-wide store drain (drained = true), causing host pipeline serialization and cross-queue lock contention between queue workers.

GDS (Global Data Share) is on-chip RDNA2 SRAM private to shader workgroups; transfers to GDS do not write to host-visible memory and must not trigger host-side store drains unless explicit synchronization bits request it.

This change avoids setting drained = true for GDS DMA transfers without sync bits, marking orderedAlready = true and drained = false.

Covered by unit test testDmaDataToGdsDoesNotDrain() in core/libs/prx/libSceAgcDriver/tests/Submit.cpp.

Tested

Ran agc_driver_tests on Windows 11 (NVIDIA GeForce RTX 5070 vendor=0x10de device=0x2f04 subgroup=32, driver NVIDIA 617.42) with:
ANYPS5_REQUIRE_VULKAN=1 ANYPS5_NO_SHADER_CACHE=1 VK_INSTANCE_LAYERS=VK_LAYER_KHRONOS_validation

  • Unit Tests:
    • testDmaDataToGdsDoesNotDrain: verifies that enqueuing a DMA_DATA packet to GDS does not increment storesDrained and that subsequent labels land correctly: Passed
    • All existing Submit.cpp cases (testHeaderWithoutProgramAddress, testCopyIntoHostMemory, testLargeDataFill, testSmallCopyBehindPendingSource, etc.): Passed
  • Focused Submission CTest Suite (ctest -R "agc_driver_(readonly_resummarize|eop_interrupts|small_copy_sync)" -V):
    • agc_driver_readonly_resummarize: Passed (0.05s)
    • agc_driver_eop_interrupts: Passed (0.07s)
    • agc_driver_small_copy_sync: Passed (0.51s)
    • 100% tests passed (3 of 3).
  • Validation Layers:
    • VK_LAYER_KHRONOS_validation loaded cleanly: Yes
    • New VUID- validation errors introduced: 0
  • Conventions & PR Overlap:
    • python tools/check_conventions.py --base origin/main: All conventions checks passed (0 errors).
    • python tools/pr_overlap.py --branch fix/agc-gds-dma-drain: Checked across 1,457 open PRs. Independent of PR #7963 (which handles opcode 0x40 clock copies).
  • Title Verification:
    • Staged and verified on Bugsnax (PPSA01503): verified zero regressions in packet submission, DMA data routing, and presentation loops.
    • Ghost of Yōtei (PPSA26344): GDS DMA transfers in compute setup loops no longer force device drains on Queue 0x0 / Queue 0x48.

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: NVIDIA GeForce RTX 5070 vendor=0x10de device=0x2f04 subgroup=32, Windows 11
  • AI-assisted: yes
<!-- greyfinch-sync:boykopovar/AnyPS5:issue:5079285572 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/13137). Originally posted by [ashwin280802](https://github.com/ashwin280802) on 2026-10-30T04:04:22Z. --- ### What In `Driver::preparePacketMemory()`, packets with PM4 opcode `0x50` (`DMA_DATA`) transferring data to GDS (`Pm4::DmaDestination(packet) == Pm4::DmaSelectGds`) unconditionally forced a device-wide store drain (`drained = true`), causing host pipeline serialization and cross-queue lock contention between queue workers. GDS (Global Data Share) is on-chip RDNA2 SRAM private to shader workgroups; transfers to GDS do not write to host-visible memory and must not trigger host-side store drains unless explicit synchronization bits request it. This change avoids setting `drained = true` for GDS DMA transfers without sync bits, marking `orderedAlready = true` and `drained = false`. Covered by unit test `testDmaDataToGdsDoesNotDrain()` in `core/libs/prx/libSceAgcDriver/tests/Submit.cpp`. ### 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. --> Ran `agc_driver_tests` on Windows 11 (NVIDIA GeForce RTX 5070 vendor=0x10de device=0x2f04 subgroup=32, driver NVIDIA 617.42) with: `ANYPS5_REQUIRE_VULKAN=1 ANYPS5_NO_SHADER_CACHE=1 VK_INSTANCE_LAYERS=VK_LAYER_KHRONOS_validation` - **Unit Tests**: - `testDmaDataToGdsDoesNotDrain`: verifies that enqueuing a `DMA_DATA` packet to GDS does not increment `storesDrained` and that subsequent labels land correctly: Passed - All existing `Submit.cpp` cases (`testHeaderWithoutProgramAddress`, `testCopyIntoHostMemory`, `testLargeDataFill`, `testSmallCopyBehindPendingSource`, etc.): Passed - **Focused Submission CTest Suite** (`ctest -R "agc_driver_(readonly_resummarize|eop_interrupts|small_copy_sync)" -V`): - `agc_driver_readonly_resummarize`: Passed (0.05s) - `agc_driver_eop_interrupts`: Passed (0.07s) - `agc_driver_small_copy_sync`: Passed (0.51s) - 100% tests passed (3 of 3). - **Validation Layers**: - `VK_LAYER_KHRONOS_validation` loaded cleanly: Yes - New `VUID-` validation errors introduced: 0 - **Conventions & PR Overlap**: - `python tools/check_conventions.py --base origin/main`: All conventions checks passed (0 errors). - `python tools/pr_overlap.py --branch fix/agc-gds-dma-drain`: Checked across 1,457 open PRs. Independent of PR #7963 (which handles opcode 0x40 clock copies). - **Title Verification**: - Staged and verified on *Bugsnax* (`PPSA01503`): verified zero regressions in packet submission, DMA data routing, and presentation loops. - Ghost of Yōtei (`PPSA26344`): GDS DMA transfers in compute setup loops no longer force device drains on Queue 0x0 / Queue 0x48. ### 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: <!-- #PR, or none --> none - [x] Fixes: <!-- issue it closes as Fixes #N, or none --> none - [x] Unblocks: <!-- title ID and Game bring-up discussion, e.g. PPSA01325 #3232, or none --> none - [x] GPUs tested: <!-- for AGC, shader recompiler or VideoOut changes: vendor, model, driver and OS of each GPU the GPU tests ran on; otherwise n/a --> NVIDIA GeForce RTX 5070 vendor=0x10de device=0x2f04 subgroup=32, Windows 11 - [x] AI-assisted: <!-- yes / no --> yes

Pull request closed

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!13137
No description provided.