fix(agc): leave the GDS unallocated until it is used when no importable GDS was requested #15610

Merged
milescoviello merged 1 commit from upstream-pr/15610 into main 2026-11-07 12:38:18 +00:00
milescoviello commented 2026-11-03 21:42:41 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by milescoviello on 2026-11-03T21:42:41Z.


What

Since #13159, Pm4::GdsImportable() and Pm4::GdsShared() call GdsAddress() to answer, and the Vulkan device asks GdsImportable() when it is created. So every process maps the 64 KiB GDS guest mapping at device creation, also on discrete GPUs, which never request an importable GDS. Before, the GDS was mapped by its first use. On Windows the extra early mapping makes agc_driver_direct_write_completion fail (#15564): the completion of a buffer write dropped image results recorded after it.

How

  • GdsImportable() and GdsShared() answer false without mapping the GDS unless an importable GDS was requested (ImportableGdsRequested()). Both could only be true when one was requested anyway, so neither answer changes.
  • The GDS is mapped by its first use again. An importable GDS that the device requests at creation, on an integrated GPU, is still mapped shared when it is first asked for.

Tested

  • Windows 11 VM, NVIDIA GeForce GT 1030 (discrete), driver 582.78, WinLibs GCC 15.2.0. agc_driver_direct_write_completion, agc_driver_gds_dma_fill and agc_driver_linear_target_direct_write_completion, 3 runs each side:
Tree Result
main 086c0686c8 2 of 3 pass in each run: agc_driver_direct_write_completion fails all 3 times with the error above
this PR 7c53e47f34 3 of 3 pass in each of the 3 runs
  • @Superseabas ran it on Windows 11, on both GPUs from #15564. On the RTX 5070 Ti, agc_driver_direct_write_completion passed 6 of 10 on main and 10 of 10 with this PR. On the integrated Radeon of the Ryzen 7 7700X it passed 0 of 10 on main and 1 of 10 with this PR. #15551 passes 10 of 10 on both.
  • I couldn't run the integrated-GPU half of #15564 (the Ryzen 7 7700X Radeon). There the device requests an importable GDS at creation, so this change doesn't alter what happens, and that case may need its own fix.
  • Linux, NVIDIA GeForce RTX 4070 Ti, driver 615.71.09, the same 3 tests at 7c53e47f34: 3 of 3 pass in each of 3 runs (they pass on main there too).
  • @adam25136 ran it on Windows 10 Pro 22H2, NVIDIA GeForce RTX 5080 (discrete), driver 617.42, WinLibs GCC 15.2.0 r7, with head 7c53e47f34 merged into main 1c8c0efc8c, 5 runs each. agc_driver_direct_write_completion passed 0 of 5 on main and 5 of 5 with this PR; the other two tests passed 5 of 5 on both.
  • Khronos validation 1.4.363, the same 3 tests, each side run with VK_INSTANCE_LAYERS=VK_LAYER_KHRONOS_validation ANYPS5_REQUIRE_VULKAN=1 ANYPS5_NO_SHADER_CACHE=1: base 086c0686c8 3 of 3 and head 7c53e47f34 3 of 3 pass. The layer was loaded in each, 6 Vulkan devices were created per side, and no VUID- lines appeared.

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
  • 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. #15551 (rickyalvarez185, opened before this PR) fixes the race behind #15564 on both GPUs. This PR only removes the early GDS mapping that exposes it on discrete GPUs.
  • Unblocks: none
  • GPUs tested: NVIDIA GeForce GT 1030, driver 582.78, Windows 11 VM; NVIDIA GeForce RTX 4070 Ti, driver 615.71.09, Ubuntu 26.04.1
  • AI-assisted: yes (Claude Code)

🤖 Generated with Claude Code

<!-- greyfinch-sync:boykopovar/AnyPS5:issue:5144949666 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/15610). Originally posted by [milescoviello](https://github.com/milescoviello) on 2026-11-03T21:42:41Z. --- ### What Since #13159, `Pm4::GdsImportable()` and `Pm4::GdsShared()` call `GdsAddress()` to answer, and the Vulkan device asks `GdsImportable()` when it is created. So every process maps the 64 KiB GDS guest mapping at device creation, also on discrete GPUs, which never request an importable GDS. Before, the GDS was mapped by its first use. On Windows the extra early mapping makes `agc_driver_direct_write_completion` fail (#15564): `the completion of a buffer write dropped image results recorded after it`. ### How - `GdsImportable()` and `GdsShared()` answer `false` without mapping the GDS unless an importable GDS was requested (`ImportableGdsRequested()`). Both could only be true when one was requested anyway, so neither answer changes. - The GDS is mapped by its first use again. An importable GDS that the device requests at creation, on an integrated GPU, is still mapped shared when it is first asked for. ### Tested - Windows 11 VM, NVIDIA GeForce GT 1030 (discrete), driver 582.78, WinLibs GCC 15.2.0. `agc_driver_direct_write_completion`, `agc_driver_gds_dma_fill` and `agc_driver_linear_target_direct_write_completion`, 3 runs each side: | Tree | Result | |---|---| | `main` `086c0686c8` | 2 of 3 pass in each run: `agc_driver_direct_write_completion` fails all 3 times with the error above | | this PR `7c53e47f34` | 3 of 3 pass in each of the 3 runs | - @Superseabas [ran it](https://github.com/boykopovar/AnyPS5/pull/15610#issuecomment-6634713106) on Windows 11, on both GPUs from #15564. On the RTX 5070 Ti, `agc_driver_direct_write_completion` passed 6 of 10 on `main` and 10 of 10 with this PR. On the integrated Radeon of the Ryzen 7 7700X it passed 0 of 10 on `main` and 1 of 10 with this PR. #15551 passes 10 of 10 on both. - I couldn't run the integrated-GPU half of #15564 (the Ryzen 7 7700X Radeon). There the device requests an importable GDS at creation, so this change doesn't alter what happens, and that case may need its own fix. - Linux, NVIDIA GeForce RTX 4070 Ti, driver 615.71.09, the same 3 tests at `7c53e47f34`: 3 of 3 pass in each of 3 runs (they pass on `main` there too). - @adam25136 [ran it](https://github.com/boykopovar/AnyPS5/pull/15610#issuecomment-6617924097) on Windows 10 Pro 22H2, NVIDIA GeForce RTX 5080 (discrete), driver 617.42, WinLibs GCC 15.2.0 r7, with head `7c53e47f34` merged into `main` `1c8c0efc8c`, 5 runs each. `agc_driver_direct_write_completion` passed 0 of 5 on `main` and 5 of 5 with this PR; the other two tests passed 5 of 5 on both. - Khronos validation 1.4.363, the same 3 tests, each side run with `VK_INSTANCE_LAYERS=VK_LAYER_KHRONOS_validation ANYPS5_REQUIRE_VULKAN=1 ANYPS5_NO_SHADER_CACHE=1`: base `086c0686c8` 3 of 3 and head `7c53e47f34` 3 of 3 pass. The layer was loaded in each, 6 Vulkan devices were created per side, and no `VUID-` lines appeared. ### 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](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) - [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. #15551 (rickyalvarez185, opened before this PR) fixes the race behind #15564 on both GPUs. This PR only removes the early GDS mapping that exposes it on discrete GPUs. - [x] Unblocks: none - [x] GPUs tested: NVIDIA GeForce GT 1030, driver 582.78, Windows 11 VM; NVIDIA GeForce RTX 4070 Ti, driver 615.71.09, Ubuntu 26.04.1 - [x] AI-assisted: yes (Claude Code) 🤖 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!15610
No description provided.