fix(agc): rebind moved read-only buffers in place instead of snapshotting them #19131

Merged
relativespace2K merged 7 commits from upstream-pr/19131 into main 2026-11-19 09:11:44 +00:00
relativespace2K commented 2026-11-12 20:56:45 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by relativespace2K on 2026-11-12T20:56:45Z.


What

A dispatch-cache hit that moves a read-only buffer now binds the host import serving the buffer at its new address instead of snapshotting its bytes into device memory. MovedDispatchBuffers accepts such a buffer regardless of APS5_DISPMOVE_MAX_KIB, so the 1 MiB snapshot limit no longer refuses a moved read-only buffer that an import serves, and a buffer too large to snapshot (the 4 GiB descriptor heap in #18186) can take the hit instead of rebuilding.

DrawBindings carries the imported buffer, offset and range, and MarkGpuWrites notes the rebound ranges as in-place reads, so a CPU store into them after the record waits like any other in-place read. The import is resolved per use through HostImportView, which returns its serial: a retired or replaced import (a re-registered range) is picked up by the next dispatch instead of being bound stale. A range whose descriptor offset would need an adjustment keeps the snapshot path, as the build's patches are not recomputed here.

As discussed in #18186, this is the correctness PR for the DispatchMoveBytes() limit, for the limit's own sake. It is not a performance change; the per-dispatch resources cost stays in #18186.

Tested

Windows 11 IoT Enterprise LTSC 26100, Ryzen 5 5600, RX 6800 XT (RDNA2, subgroup 64), AMD proprietary driver 26.10.1, Vulkan 1.4.315, WinLibs GCC 15.2, Release. AGC tests with ANYPS5_REQUIRE_VULKAN=1, ANYPS5_NO_SHADER_CACHE=1, VK_INSTANCE_LAYERS=VK_LAYER_KHRONOS_validation, VK_LOADER_DEBUG=layer and ctest -V, from one build directory.

  • main b99796f81b: agc_driver_dispatch_move, agc_driver_dispatch_move_depth, agc_driver_dispatch_cache_defaults, agc_driver_dispatch_data_hit_words, agc_driver_address_draw_space_reuse and its _off, _transitions, _verify, _held variants: 9 of 9 pass.
  • This PR 47d76d23a5: the same 9 plus the new agc_driver_dispatch_rebind: 10 of 10 pass.
  • Each log shows Insert instance layer "VK_LAYER_KHRONOS_validation", neither contains was not found but was requested by env var VK_INSTANCE_LAYERS, and neither has a VUID- line.

agc_driver_dispatch_rebind moves a 2 MiB read-only buffer between host-imported guest ranges and requires the move to be taken in place (no snapshot, no rebuild). It then writes the guest range from the CPU between two dispatches and requires the next dispatch to read the new bytes, and re-registers the range (a new import) and requires the dispatch after it to read the new bytes again.

PPSA24096 (Cronos: The New Dawn), the intro cinematic v001_cinebink.bk2, 3840x2160, warm caches, APS5_REGISTRATION_PREPARE_COMMIT_GB=24, trace window anchored on the file open and 180 s long, same machine and scene. These are main f57c971559 and the change at 15569ffec809 (its head before the rebase onto current main; the rebase did not touch the change):

p50 p90 p99
main 1280 / 1053 ms 4525 / 4713 7984 / 7441
this PR 1059 / 1250 ms 4995 / 4701 7819 / 7363

Two 180 s windows per side. Neutral on frame time, as expected: the rotating heap is not what bounds this scene. [dispmove] in the same scene: 2556 of 2569 moved read-only buffers per 10 s bind in place (none before this change), and the over the limit refusals fall from 354 to 54 per 10 s. Captured 4K frames match main: no right-edge text column and no corner icon artifact from the earlier prototype.

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: PPSA24096 (Cronos: The New Dawn), #18186
  • GPUs tested: AMD Radeon RX 6800 XT, driver 26.10.1, Windows 11 IoT Enterprise LTSC 26100
  • AI-assisted: yes
<!-- greyfinch-sync:boykopovar/AnyPS5:issue:5285071384 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/19131). Originally posted by [relativespace2K](https://github.com/relativespace2K) on 2026-11-12T20:56:45Z. --- ### What A dispatch-cache hit that moves a read-only buffer now binds the host import serving the buffer at its new address instead of snapshotting its bytes into device memory. `MovedDispatchBuffers` accepts such a buffer regardless of `APS5_DISPMOVE_MAX_KIB`, so the 1 MiB snapshot limit no longer refuses a moved read-only buffer that an import serves, and a buffer too large to snapshot (the 4 GiB descriptor heap in #18186) can take the hit instead of rebuilding. `DrawBindings` carries the imported buffer, offset and range, and `MarkGpuWrites` notes the rebound ranges as in-place reads, so a CPU store into them after the record waits like any other in-place read. The import is resolved per use through `HostImportView`, which returns its serial: a retired or replaced import (a re-registered range) is picked up by the next dispatch instead of being bound stale. A range whose descriptor offset would need an adjustment keeps the snapshot path, as the build's patches are not recomputed here. As discussed in #18186, this is the correctness PR for the `DispatchMoveBytes()` limit, for the limit's own sake. It is not a performance change; the per-dispatch resources cost stays in #18186. ### Tested Windows 11 IoT Enterprise LTSC 26100, Ryzen 5 5600, RX 6800 XT (RDNA2, subgroup 64), AMD proprietary driver 26.10.1, Vulkan 1.4.315, WinLibs GCC 15.2, Release. AGC tests with `ANYPS5_REQUIRE_VULKAN=1`, `ANYPS5_NO_SHADER_CACHE=1`, `VK_INSTANCE_LAYERS=VK_LAYER_KHRONOS_validation`, `VK_LOADER_DEBUG=layer` and `ctest -V`, from one build directory. - `main` `b99796f81b`: `agc_driver_dispatch_move`, `agc_driver_dispatch_move_depth`, `agc_driver_dispatch_cache_defaults`, `agc_driver_dispatch_data_hit_words`, `agc_driver_address_draw_space_reuse` and its `_off`, `_transitions`, `_verify`, `_held` variants: 9 of 9 pass. - This PR `47d76d23a5`: the same 9 plus the new `agc_driver_dispatch_rebind`: 10 of 10 pass. - Each log shows `Insert instance layer "VK_LAYER_KHRONOS_validation"`, neither contains `was not found but was requested by env var VK_INSTANCE_LAYERS`, and neither has a `VUID-` line. `agc_driver_dispatch_rebind` moves a 2 MiB read-only buffer between host-imported guest ranges and requires the move to be taken in place (no snapshot, no rebuild). It then writes the guest range from the CPU between two dispatches and requires the next dispatch to read the new bytes, and re-registers the range (a new import) and requires the dispatch after it to read the new bytes again. PPSA24096 (`Cronos: The New Dawn`), the intro cinematic `v001_cinebink.bk2`, 3840x2160, warm caches, `APS5_REGISTRATION_PREPARE_COMMIT_GB=24`, trace window anchored on the file open and 180 s long, same machine and scene. These are `main` `f57c971559` and the change at `15569ffec809` (its head before the rebase onto current `main`; the rebase did not touch the change): | | p50 | p90 | p99 | |---|---|---|---| | main | 1280 / 1053 ms | 4525 / 4713 | 7984 / 7441 | | this PR | 1059 / 1250 ms | 4995 / 4701 | 7819 / 7363 | Two 180 s windows per side. Neutral on frame time, as expected: the rotating heap is not what bounds this scene. `[dispmove]` in the same scene: 2556 of 2569 moved read-only buffers per 10 s bind in place (none before this change), and the `over the limit` refusals fall from 354 to 54 per 10 s. Captured 4K frames match `main`: no right-edge text column and no corner icon artifact from the earlier prototype. ### 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) 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: PPSA24096 (Cronos: The New Dawn), #18186 - [x] GPUs tested: AMD Radeon RX 6800 XT, driver 26.10.1, Windows 11 IoT Enterprise LTSC 26100 - [x] AI-assisted: yes
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!19131
No description provided.