feat(agc): copy depth planes to and from color storage images directly where maintenance8 allows #11685

Merged
oneandonlydean merged 1 commit from upstream-pr/11685 into main 2026-10-27 10:03:00 +00:00
oneandonlydean commented 2026-10-27 02:41:59 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by oneandonlydean on 2026-10-27T02:41:59Z.


What

A depth plane and the color storage image that holds or receives its texels are copied with one vkCmdCopyImage where VK_KHR_maintenance8 allows it, in place of the image to buffer to image round trip through a staging buffer.

With VK_KHR_maintenance8, which the device already enables, vkCmdCopyImage copies the depth aspect directly to and from a single-component color format of its size (D32 with R32, D16 with R16): copyPlane and LayeredDepthStorage::Copy record one image copy and two barriers where the staging path records an image-to-buffer copy, a buffer-to-image copy and three barriers. TakeStorage records three barriers with one image copy when it keeps the discard (no stencil plane), against four on the staging path, and two against three when a stencil plane is present. The graphics Context now carries the maintenance8 flag the device already had. Used by copyPlane, TakeStorage and LayeredDepthStorage::Copy in DepthSurface.cpp. TakeStorage keeps its discard of the new depth surface before the copy (#10681). 24-bit depth, the stencil plane, every format that is not a single component of the aspect's size and a device without maintenance8 keep the buffer path, as does APS5_NO_DIRECT_DEPTH_COPY=1 (documented in docs/dev/ENVIRONMENT.md; it covers depth planes only). No performance claim is made and none was measured.

Main had no depth to color image copy; its only image-to-image depth copy is CopyAspectFrom (depth to depth of one format). No open PR touches these copies.

Tested

  • Linux, Intel i9-14900KF, NVIDIA GeForce RTX 4090 (driver 610.57.04), Vulkan 1.4.363, validation layer VK_LAYER_KHRONOS_validation (loader log: "Insert instance layer VK_LAYER_KHRONOS_validation"). VK_INSTANCE_LAYERS=VK_LAYER_KHRONOS_validation ANYPS5_NO_SHADER_CACHE=1 ANYPS5_REQUIRE_VULKAN=1 ctest -V -R 'depth|stencil|array_layer|public_headers' on this change rebased on main e0b13f2990: 112 tests selected, 111 passed, 0 failed, 1 skipped (agc_driver_stencil_ref_export, which needs a device without native stencil export); 0 VUID- lines. With APS5_NO_DIRECT_DEPTH_COPY=1 the same 112 give 111 passed and the same 1 skipped. On the previous base (main b82c33ef65) the same selection ran 111 tests with 110 passed and the same 1 skipped, against 112 and 111 passed with this change.
  • The 112th test, agc_driver_depth_plane_partial_store_buffer_copy, runs the partial-store test with the buffer path forced and asserts 0 direct copies; the default run asserts at least one direct copy whenever the device's Context has maintenance8 (16 on this device), independent of the format selector. With the selector forced to refuse every pair, the default and unimported runs fail and the buffer-copy run stays green.
  • Direct copies per site, counted with a temporary counter on an earlier instrumented head (a994d9f7c2, before the stencil direct path was removed), so historical: copyPlane 1 to 72 across 7 tests, TakeStorage 5, LayeredDepthStorage::Copy 4.
  • Not run: Windows; AMD or any non-NVIDIA GPU (TakeStorage keeps the #10681 discard by construction; the flake it fixed was not rerun); speed or GPU time (no claim); maintenance8 devices other than the RTX 4090.

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 (none added)
  • No notes, investigation .md files or images added to the repository
  • New third-party code is a submodule built from source (none added)
  • Generic behaviour, not specific to one title
  • Depends on: none
  • Fixes: none
  • Unblocks: none
  • GPUs tested: NVIDIA GeForce RTX 4090, driver 610.57.04, Linux
  • AI-assisted: yes
<!-- greyfinch-sync:boykopovar/AnyPS5:issue:5027757791 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/11685). Originally posted by [oneandonlydean](https://github.com/oneandonlydean) on 2026-10-27T02:41:59Z. --- ### What A depth plane and the color storage image that holds or receives its texels are copied with one `vkCmdCopyImage` where `VK_KHR_maintenance8` allows it, in place of the image to buffer to image round trip through a staging buffer. With `VK_KHR_maintenance8`, which the device already enables, `vkCmdCopyImage` copies the depth aspect directly to and from a single-component color format of its size (D32 with R32, D16 with R16): `copyPlane` and `LayeredDepthStorage::Copy` record one image copy and two barriers where the staging path records an image-to-buffer copy, a buffer-to-image copy and three barriers. `TakeStorage` records three barriers with one image copy when it keeps the discard (no stencil plane), against four on the staging path, and two against three when a stencil plane is present. The graphics `Context` now carries the `maintenance8` flag the device already had. Used by `copyPlane`, `TakeStorage` and `LayeredDepthStorage::Copy` in `DepthSurface.cpp`. `TakeStorage` keeps its discard of the new depth surface before the copy (#10681). 24-bit depth, the stencil plane, every format that is not a single component of the aspect's size and a device without `maintenance8` keep the buffer path, as does `APS5_NO_DIRECT_DEPTH_COPY=1` (documented in `docs/dev/ENVIRONMENT.md`; it covers depth planes only). No performance claim is made and none was measured. Main had no depth to color image copy; its only image-to-image depth copy is `CopyAspectFrom` (depth to depth of one format). No open PR touches these copies. ### Tested - Linux, Intel i9-14900KF, NVIDIA GeForce RTX 4090 (driver 610.57.04), Vulkan 1.4.363, validation layer `VK_LAYER_KHRONOS_validation` (loader log: "Insert instance layer VK_LAYER_KHRONOS_validation"). `VK_INSTANCE_LAYERS=VK_LAYER_KHRONOS_validation ANYPS5_NO_SHADER_CACHE=1 ANYPS5_REQUIRE_VULKAN=1 ctest -V -R 'depth|stencil|array_layer|public_headers'` on this change rebased on `main` e0b13f2990: 112 tests selected, 111 passed, 0 failed, 1 skipped (`agc_driver_stencil_ref_export`, which needs a device without native stencil export); 0 `VUID-` lines. With `APS5_NO_DIRECT_DEPTH_COPY=1` the same 112 give 111 passed and the same 1 skipped. On the previous base (`main` b82c33ef65) the same selection ran 111 tests with 110 passed and the same 1 skipped, against 112 and 111 passed with this change. - The 112th test, `agc_driver_depth_plane_partial_store_buffer_copy`, runs the partial-store test with the buffer path forced and asserts 0 direct copies; the default run asserts at least one direct copy whenever the device's `Context` has `maintenance8` (16 on this device), independent of the format selector. With the selector forced to refuse every pair, the default and unimported runs fail and the buffer-copy run stays green. - Direct copies per site, counted with a temporary counter on an earlier instrumented head (a994d9f7c2, before the stencil direct path was removed), so historical: `copyPlane` 1 to 72 across 7 tests, `TakeStorage` 5, `LayeredDepthStorage::Copy` 4. - Not run: Windows; AMD or any non-NVIDIA GPU (`TakeStorage` keeps the #10681 discard by construction; the flake it fixed was not rerun); speed or GPU time (no claim); `maintenance8` devices other than the RTX 4090. ### 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 under Silent stubs in their library's technical debt file (none added) - [x] No notes, investigation `.md` files or images added to the repository - [x] New third-party code is a submodule built from source (none added) - [x] Generic behaviour, not specific to one title - [x] Depends on: none - [x] Fixes: none - [x] Unblocks: none - [x] GPUs tested: NVIDIA GeForce RTX 4090, driver 610.57.04, Linux - [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!11685
No description provided.