fix(agc): accept GDS DMA_DATA register address controls #16345

Merged
AlexWhitehouse merged 1 commit from upstream-pr/16345 into main 2026-11-17 20:57:22 +00:00
AlexWhitehouse commented 2026-11-06 10:26:33 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by AlexWhitehouse on 2026-11-06T10:26:33Z.


What

A PM4 DMA_DATA (opcode 0x50) with a GDS endpoint was refused whenever that endpoint's address-control bits were set. dmaSource() and dmaDestination() in core/libs/prx/libSceAgcDriver/Execution/src/Pm4.cpp fold SAS/SAIC (packet[6] bits 26 and 28) and DAS/DAIC (bits 27 and 29) into the selector. So GDS (selector 1) with both bits set became selector 13, and validation rejected it with DMA_DATA register source is not implemented or DMA_DATA register destination is not implemented.

That is the encoding Mesa's radeonsi emits for every GDS DMA. Mesa 24.0.0 si_cp_dma.c, lines 72–86:

  • a GDS destination is DST_SEL(GDS) | DAS(REGISTER) | DAIC(NO_INCREMENT);
  • a GDS source is SRC_SEL(GDS) | SAS(REGISTER) | SAIC(NO_INCREMENT);
  • Mesa's comment says the GDS advances the address itself.

The bit positions match PAL's GFX9+ packet definition at c5e8000 (selectors, lines 1238–1249; address controls, lines 1285–1289) and Mesa's pkt3.json.

Change:

  • Normalisation: the two helpers map exactly "GDS with both of its endpoint's controls set" back to GDS. Validation, ResolveStore, DecodeStores, execution and capture therefore treat those packets as the consecutive GDS transfers the driver already performs with clear controls.
  • Still refused, with the same messages as before: GDS with only one of the two controls set, register-space or no-increment controls on any other endpoint, and GDS ranges past the GDS. Register-source and register-destination DMA_DATA are not implemented here.
  • Scope: no other code changes, so the hunks stay clear of #12568, #15136 and #14330, which edit DMA stores elsewhere in the file.
  • Debt: a fragment, docs/dev/debt/changes/fix-agc-dma-data-gds-address-controls.md, adds a libSceAgcDriver entry that records the accepted encodings, the Mesa source, that PS5 is not measured, and what still throws.

Tested

  • New testDmaGdsAddressControls in core/libs/prx/libSceAgcDriver/tests/Pm4.cpp (ctest agc_driver_pm4). Existing assertions are unchanged, and testCopies is untouched.
    • Round trips: memory to GDS with the radeonsi destination encoding, then GDS to memory with the source encoding, returns all four distinct words (none repeated). The same holds for GDS to GDS with both encodings, and for an immediate fill into GDS.
    • Same treatment as clear controls: for each case, Validate, ResolveStore and DecodeStores give the same result as the clear-control GDS packet, and a GDS destination reports no guest memory store.
    • Still refused: out-of-range GDS offsets still fail the range checks. Every other selector with partial or full controls (both endpoints, all four selectors) still fails with the existing register-source or register-destination message.
  • Linux (Ubuntu 26.04, GCC 15, lavapipe Mesa 26.0.8), with ANYPS5_REQUIRE_VULKAN=1, ANYPS5_NO_SHADER_CACHE=1 and VK_INSTANCE_LAYERS=VK_LAYER_KHRONOS_validation, over the 18 tests matching agc_driver_pm4|agc_driver_recorder|agc_driver_register_key:
    • main passes 18/18. With only the new test added, agc_driver_pm4 fails with DMA_DATA register destination is not implemented; a source-only variant fails with DMA_DATA register source is not implemented;
    • this PR passes 18/18;
    • no VUID- lines and no missing-layer messages.
  • Mutation check: removing the source-side normalisation fails with DMA_DATA register source is not implemented.
  • Windows 11, NVIDIA RTX 3060 (driver 610.88, WinLibs MinGW-w64 GCC 15.2.0, Release), with the same three variables:
    • the 18 matching tests pass at ab1d54e4e4. Windows registers agc_driver_pm4_ring_report_heap where Linux registers agc_driver_pm4_priority_refused;
    • with main's Pm4.cpp, agc_driver_pm4 fails with DMA_DATA register destination is not implemented;
    • no VUID- lines and no missing-layer messages. A VK_LOADER_DEBUG=layer rerun of agc_driver_recorder confirmed that the validation layer was inserted at instance and device level.
  • python3 tools/check_conventions.py --base origin/main: all conventions checks passed.
  • python3 tools/pr_overlap.py --branch fix/agc-dma-data-gds-address-controls: no confirmed overlap.
    • Trial merges of #12568, #15136, #14330, #6549 and #16184, and of every PR it could not compare (54 in all), add no conflicted file or hunk beyond what each already has with main.
    • #15136 keeps its 5 existing conflicts; the other four named PRs merge cleanly.

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 3060, driver 610.88, Windows 11 (build 26300); Mesa lavapipe 26.0.8 (LLVM 21.1.8), Ubuntu 26.04
  • AI-assisted: yes

🤖 Generated with Claude Code

<!-- greyfinch-sync:boykopovar/AnyPS5:issue:5186425842 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/16345). Originally posted by [AlexWhitehouse](https://github.com/AlexWhitehouse) on 2026-11-06T10:26:33Z. --- ### What A PM4 `DMA_DATA` (opcode 0x50) with a GDS endpoint was refused whenever that endpoint's address-control bits were set. `dmaSource()` and `dmaDestination()` in `core/libs/prx/libSceAgcDriver/Execution/src/Pm4.cpp` fold SAS/SAIC (`packet[6]` bits 26 and 28) and DAS/DAIC (bits 27 and 29) into the selector. So GDS (selector 1) with both bits set became selector 13, and validation rejected it with `DMA_DATA register source is not implemented` or `DMA_DATA register destination is not implemented`. That is the encoding Mesa's radeonsi emits for every GDS DMA. [Mesa 24.0.0 `si_cp_dma.c`](https://github.com/chaotic-cx/mesa-mirror/blob/03ecd8b0a517e528d790a3d252194f7b898d0e8f/src/gallium/drivers/radeonsi/si_cp_dma.c#L72-L86), lines 72–86: - a GDS destination is `DST_SEL(GDS) | DAS(REGISTER) | DAIC(NO_INCREMENT)`; - a GDS source is `SRC_SEL(GDS) | SAS(REGISTER) | SAIC(NO_INCREMENT)`; - Mesa's comment says the GDS advances the address itself. The bit positions match PAL's GFX9+ packet definition at [c5e8000](https://github.com/GPUOpen-Drivers/pal/blob/c5e800072a32f68b6ccc4422936d96167c6e0728/src/core/hw/gfxip/gfx9/chip/gfx9_plus_merged_f32_me_pm4_packets.h#L1238-L1249) (selectors, lines 1238–1249; [address controls](https://github.com/GPUOpen-Drivers/pal/blob/c5e800072a32f68b6ccc4422936d96167c6e0728/src/core/hw/gfxip/gfx9/chip/gfx9_plus_merged_f32_me_pm4_packets.h#L1285-L1289), lines 1285–1289) and Mesa's [`pkt3.json`](https://github.com/chaotic-cx/mesa-mirror/blob/03ecd8b0a517e528d790a3d252194f7b898d0e8f/src/amd/registers/pkt3.json#L379-L385). **Change:** - **Normalisation:** the two helpers map exactly "GDS with both of its endpoint's controls set" back to GDS. Validation, `ResolveStore`, `DecodeStores`, execution and capture therefore treat those packets as the consecutive GDS transfers the driver already performs with clear controls. - **Still refused, with the same messages as before:** GDS with only one of the two controls set, register-space or no-increment controls on any other endpoint, and GDS ranges past the GDS. Register-source and register-destination `DMA_DATA` are not implemented here. - **Scope:** no other code changes, so the hunks stay clear of #12568, #15136 and #14330, which edit DMA stores elsewhere in the file. - **Debt:** a fragment, `docs/dev/debt/changes/fix-agc-dma-data-gds-address-controls.md`, adds a `libSceAgcDriver` entry that records the accepted encodings, the Mesa source, that PS5 is not measured, and what still throws. ### Tested - **New `testDmaGdsAddressControls`** in `core/libs/prx/libSceAgcDriver/tests/Pm4.cpp` (ctest `agc_driver_pm4`). Existing assertions are unchanged, and `testCopies` is untouched. - **Round trips:** memory to GDS with the radeonsi destination encoding, then GDS to memory with the source encoding, returns all four distinct words (none repeated). The same holds for GDS to GDS with both encodings, and for an immediate fill into GDS. - **Same treatment as clear controls:** for each case, `Validate`, `ResolveStore` and `DecodeStores` give the same result as the clear-control GDS packet, and a GDS destination reports no guest memory store. - **Still refused:** out-of-range GDS offsets still fail the range checks. Every other selector with partial or full controls (both endpoints, all four selectors) still fails with the existing register-source or register-destination message. - **Linux** (Ubuntu 26.04, GCC 15, lavapipe Mesa 26.0.8), with `ANYPS5_REQUIRE_VULKAN=1`, `ANYPS5_NO_SHADER_CACHE=1` and `VK_INSTANCE_LAYERS=VK_LAYER_KHRONOS_validation`, over the 18 tests matching `agc_driver_pm4|agc_driver_recorder|agc_driver_register_key`: - `main` passes 18/18. With only the new test added, `agc_driver_pm4` fails with `DMA_DATA register destination is not implemented`; a source-only variant fails with `DMA_DATA register source is not implemented`; - this PR passes 18/18; - no `VUID-` lines and no missing-layer messages. - **Mutation check:** removing the source-side normalisation fails with `DMA_DATA register source is not implemented`. - **Windows 11, NVIDIA RTX 3060** (driver 610.88, WinLibs MinGW-w64 GCC 15.2.0, Release), with the same three variables: - the 18 matching tests pass at ab1d54e4e4. Windows registers `agc_driver_pm4_ring_report_heap` where Linux registers `agc_driver_pm4_priority_refused`; - with `main`'s `Pm4.cpp`, `agc_driver_pm4` fails with `DMA_DATA register destination is not implemented`; - no `VUID-` lines and no missing-layer messages. A `VK_LOADER_DEBUG=layer` rerun of `agc_driver_recorder` confirmed that the validation layer was inserted at instance and device level. - `python3 tools/check_conventions.py --base origin/main`: all conventions checks passed. - **`python3 tools/pr_overlap.py --branch fix/agc-dma-data-gds-address-controls`:** no confirmed overlap. - Trial merges of #12568, #15136, #14330, #6549 and #16184, and of every PR it could not compare (54 in all), add no conflicted file or hunk beyond what each already has with `main`. - #15136 keeps its 5 existing conflicts; the other four named PRs merge cleanly. ### 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: NVIDIA GeForce RTX 3060, driver 610.88, Windows 11 (build 26300); Mesa lavapipe 26.0.8 (LLVM 21.1.8), Ubuntu 26.04 - [x] AI-assisted: yes 🤖 Generated with [Claude Code](https://claude.com/claude-code)
milescoviello commented 2026-11-06 16:53:58 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by milescoviello on 2026-11-06T16:53:58Z.

Review: COMMENTED


Checked that the normalisation reaches every consumer on main. Nothing reads the SAS/SAIC/DAS/DAIC bits outside dmaSource/dmaDestination. The users of the selectors all go through Pm4::DmaSource/Pm4::DmaDestination:

  • the pipeline overlap check for DMA_DATA in PacketExecution.cpp (the GDS source range against DrawPipeline::Queue0());
  • the GDS copies and the GDS-destination checks in PacketMemory.cpp (gdsDestination, gdsWritesPending, the store-limit split);
  • describeDmaEnd in tools/Pm4Analysis.cpp.

So a controlled GDS endpoint takes the same paths as a plain one everywhere, not just in validation. The refusal loop in the test covers the other 11 selector and control combinations. testDmaGdsAddressControls is CPU-only, so a GPU run adds nothing beyond the CI result above.

AI-assisted: yes (Claude Code)

<!-- greyfinch-sync:boykopovar/AnyPS5:review:5803803915 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/16345#pullrequestreview-5803803915). Originally posted by [milescoviello](https://github.com/milescoviello) on 2026-11-06T16:53:58Z. **Review:** COMMENTED --- Checked that the normalisation reaches every consumer on `main`. Nothing reads the SAS/SAIC/DAS/DAIC bits outside `dmaSource`/`dmaDestination`. The users of the selectors all go through `Pm4::DmaSource`/`Pm4::DmaDestination`: - the pipeline overlap check for `DMA_DATA` in `PacketExecution.cpp` (the GDS source range against `DrawPipeline::Queue0()`); - the GDS copies and the GDS-destination checks in `PacketMemory.cpp` (`gdsDestination`, `gdsWritesPending`, the store-limit split); - `describeDmaEnd` in `tools/Pm4Analysis.cpp`. So a controlled GDS endpoint takes the same paths as a plain one everywhere, not just in validation. The refusal loop in the test covers the other 11 selector and control combinations. `testDmaGdsAddressControls` is CPU-only, so a GPU run adds nothing beyond the CI result above. AI-assisted: yes (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!16345
No description provided.