fix(agc): give a depth stencil copy's layout barrier both aspects #9057

Merged
milescoviello merged 1 commit from upstream-pr/9057 into main 2026-10-23 23:00:10 +00:00
milescoviello commented 2026-10-21 11:09:19 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by milescoviello on 2026-10-21T11:09:19Z.


What

The depth sample reorder (SampleOrder.cpp, Depth) copies the depth plane into an image of the surface's own format before redrawing it in the guest's order. For a D32_SFLOAT_S8_UINT surface that only reorders depth (SampleOrderMethod::Depth), the copy image is still D32S8. But its first transition to GENERAL named the depth aspect alone. Without separateDepthStencilLayouts, Vulkan requires a depth/stencil format's barrier to name both aspects. The Khronos layer reports this as VUID-VkImageMemoryBarrier-image-03320, 6 times over the sample order tests, from the 2x and 4x "depth format 130 through a depth pass" cases.

The barrier now takes its aspects from the format (HasStencil(target.format)), as transitionLocated in the same file already does. The copy region still moves depth only when only depth is reordered.

Tested

  • Rebased onto main d2e42c334d as 7333de6aee (commit unchanged, git range-diff). RTX 4070 Ti (615.71.09, Ubuntu 26.04.1, GCC 15.2, Release), 3 runs each: with #9056 (53949c0775) the 4 sample_order tests pass; alone, 3 of the 4 still fail there, as on main, which #9056 fixes.

Ubuntu 24.04, GCC 13.3, NVIDIA RTX 4070 Ti, driver 595.99.02, on main 275e896797.

  • Khronos validation layer 1.4.363 over the 4 tests matching sample_order:

    • main: VUID-VkImageMemoryBarrier-image-03320 ×6 and VUID-VkWriteDescriptorSet-descriptorType-00337 ×18.
    • With this change: 03320 is gone, and nothing is new.
  • Pass and fail counts are unchanged by this change, under the layer and without it (3 of 3, and under lavapipe). agc_driver_sample_order_planning passes. The other three fail on this device on main and with this change alike: the remaining 00337 reads are a test issue, which #9056 fixes. That PR passes all 4 here.

  • AMD, Windows: @DavidSamir ran it with #9056 on a Radeon 680M (driver 32.0.21030.2001) under the 1.4.363 layer. The 6 03320 errors on main 27fabb6b7 are gone.

  • NVIDIA, Windows: @MaxLikesCode ran it on an RTX 4090 (driver 617.42, Windows 11) on main 2c4b116da, under the 1.4.363 layer, 3 runs each. main + #9056 still has 6 03320 per run; with this PR added there is no VUID, and the pass and skip counts are unchanged.

  • @EagleBearerYS (#6683's author) reviewed it. They confirmed this was the only barrier in SampleOrder.cpp naming fewer aspects than its image's format has, and ran it with #9056 on GitHub's runners (lavapipe: the sample order tests pass 3 runs in a row).

  • Older layer, lavapipe: @xXPBSXx ran all 483 built agc_driver_*_tests under the Ubuntu 24.04 layer package (1.3.275) on main 950388bfd. main reports 03320 only from agc_driver_sample_order; with this change that test passes with no 03320, and only #9056's 00337 remains. One run.

  • NVIDIA and AMD, Windows: @wachi35676 ran it with #9056 on an RTX 5070 Ti (driver 617.42) and an AMD Radeon iGPU (gfx1036, driver 32.0.21042.62), Windows 11, 3 runs each: with both PRs sample_order and _recipe_depth_locations pass 3 of 3 on both GPUs (they fail on main). No validation layer on that machine.

  • lavapipe on the current host (Mesa 26.0.8-1ubuntu0.3, LLVM 21.1.8, Ubuntu 26.04.1), this PR alone merged onto main a6dcea9279: the 4 sample_order tests pass 3 of 3. On the RTX 4070 Ti (615.71.09) in the same build, 3 of the 4 still fail, as described above: #9056 fixes those.

Not tested: Intel.

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 4070 Ti, driver 595.99.02, Ubuntu 24.04, and driver 615.71.09, Ubuntu 26.04.1; lavapipe (llvmpipe), Mesa 26.0.8, LLVM 21.1.8, Ubuntu 26.04.1; lavapipe (llvmpipe, LLVM 20.1.2, Vulkan 1.4.318), Ubuntu 24.04, Mesa version not recorded; AMD Radeon 680M, driver 32.0.21030.2001, Windows 11 (@DavidSamir); NVIDIA GeForce RTX 4090, driver 617.42, Windows 11 (@MaxLikesCode); lavapipe (llvmpipe), WSL2 Ubuntu 24.04, layer 1.3.275 (@xXPBSXx; no Mesa version given); NVIDIA GeForce RTX 5070 Ti, driver 617.42, and AMD Radeon iGPU 1002:13c0 (gfx1036), driver 32.0.21042.62, Windows 11 (@wachi35676); GitHub runners (lavapipe) (@EagleBearerYS); AMD Radeon RX 9070 XT (RDNA 4), Adrenalin 26.8.1, Windows 11 (@SoRadGaming)
  • AI-assisted: yes (Claude Code)

🤖 Generated with Claude Code

<!-- greyfinch-sync:boykopovar/AnyPS5:issue:4950578088 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/9057). Originally posted by [milescoviello](https://github.com/milescoviello) on 2026-10-21T11:09:19Z. --- ### What The depth sample reorder (`SampleOrder.cpp`, `Depth`) copies the depth plane into an image of the surface's own format before redrawing it in the guest's order. For a `D32_SFLOAT_S8_UINT` surface that only reorders depth (`SampleOrderMethod::Depth`), the copy image is still D32S8. But its first transition to `GENERAL` named the depth aspect alone. Without `separateDepthStencilLayouts`, Vulkan requires a depth/stencil format's barrier to name both aspects. The Khronos layer reports this as `VUID-VkImageMemoryBarrier-image-03320`, 6 times over the sample order tests, from the 2x and 4x "depth format 130 through a depth pass" cases. The barrier now takes its aspects from the format (`HasStencil(target.format)`), as `transitionLocated` in the same file already does. The copy region still moves depth only when only depth is reordered. ### Tested - **Rebased** onto `main` d2e42c334d as `7333de6aee` (commit unchanged, `git range-diff`). RTX 4070 Ti (615.71.09, Ubuntu 26.04.1, GCC 15.2, Release), 3 runs each: with #9056 (`53949c0775`) the 4 `sample_order` tests pass; alone, 3 of the 4 still fail there, as on `main`, which #9056 fixes. Ubuntu 24.04, GCC 13.3, NVIDIA RTX 4070 Ti, driver 595.99.02, on `main` 275e896797. - Khronos validation layer 1.4.363 over the 4 tests matching `sample_order`: - `main`: `VUID-VkImageMemoryBarrier-image-03320` ×6 and `VUID-VkWriteDescriptorSet-descriptorType-00337` ×18. - With this change: `03320` is gone, and nothing is new. - Pass and fail counts are unchanged by this change, under the layer and without it (3 of 3, and under lavapipe). `agc_driver_sample_order_planning` passes. The other three fail on this device on `main` and with this change alike: the remaining `00337` reads are a test issue, which #9056 fixes. That PR passes all 4 here. - AMD, Windows: @DavidSamir [ran it with #9056](https://github.com/boykopovar/AnyPS5/pull/9056#issuecomment-6315166760) on a Radeon 680M (driver 32.0.21030.2001) under the 1.4.363 layer. The 6 `03320` errors on `main` 27fabb6b7 are gone. - NVIDIA, Windows: @MaxLikesCode [ran it](https://github.com/boykopovar/AnyPS5/pull/9056#issuecomment-6318857404) on an RTX 4090 (driver 617.42, Windows 11) on `main` 2c4b116da, under the 1.4.363 layer, 3 runs each. `main` + #9056 still has 6 `03320` per run; with this PR added there is no VUID, and the pass and skip counts are unchanged. - @EagleBearerYS (#6683's author) [reviewed it](https://github.com/boykopovar/AnyPS5/pull/9057#issuecomment-6315198375). They confirmed this was the only barrier in `SampleOrder.cpp` naming fewer aspects than its image's format has, and ran it with #9056 on GitHub's runners (lavapipe: the sample order tests pass 3 runs in a row). - Older layer, lavapipe: @xXPBSXx [ran](https://github.com/boykopovar/AnyPS5/pull/9057#issuecomment-6325127158) all 483 built `agc_driver_*_tests` under the Ubuntu 24.04 layer package (1.3.275) on `main` 950388bfd. `main` reports `03320` only from `agc_driver_sample_order`; with this change that test passes with no `03320`, and only #9056's `00337` remains. One run. - NVIDIA and AMD, Windows: @wachi35676 [ran it with #9056](https://github.com/boykopovar/AnyPS5/pull/9056#issuecomment-6329103675) on an RTX 5070 Ti (driver 617.42) and an AMD Radeon iGPU (gfx1036, driver 32.0.21042.62), Windows 11, 3 runs each: with both PRs `sample_order` and `_recipe_depth_locations` pass 3 of 3 on both GPUs (they fail on `main`). No validation layer on that machine. - lavapipe on the current host (Mesa 26.0.8-1ubuntu0.3, LLVM 21.1.8, Ubuntu 26.04.1), this PR alone merged onto `main` a6dcea9279: the 4 `sample_order` tests pass 3 of 3. On the RTX 4070 Ti (615.71.09) in the same build, 3 of the 4 still fail, as described above: #9056 fixes those. Not tested: Intel. ### 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 4070 Ti, driver 595.99.02, Ubuntu 24.04, and driver 615.71.09, Ubuntu 26.04.1; lavapipe (llvmpipe), Mesa 26.0.8, LLVM 21.1.8, Ubuntu 26.04.1; lavapipe (llvmpipe, LLVM 20.1.2, Vulkan 1.4.318), Ubuntu 24.04, Mesa version not recorded; AMD Radeon 680M, driver 32.0.21030.2001, Windows 11 (@DavidSamir); NVIDIA GeForce RTX 4090, driver 617.42, Windows 11 (@MaxLikesCode); lavapipe (llvmpipe), WSL2 Ubuntu 24.04, layer 1.3.275 (@xXPBSXx; no Mesa version given); NVIDIA GeForce RTX 5070 Ti, driver 617.42, and AMD Radeon iGPU 1002:13c0 (gfx1036), driver 32.0.21042.62, Windows 11 (@wachi35676); GitHub runners (lavapipe) (@EagleBearerYS); AMD Radeon RX 9070 XT (RDNA 4), Adrenalin 26.8.1, Windows 11 (@SoRadGaming) - [x] AI-assisted: yes (Claude Code) 🤖 Generated with [Claude Code](https://claude.com/claude-code)
DavidSamir commented 2026-10-21 11:49:00 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by DavidSamir on 2026-10-21T11:49:00Z.


AMD Radeon 680M (AMD 32.0.21030.2001, Windows) result for this PR together with #9056, under the validation layer: https://github.com/boykopovar/AnyPS5/pull/9056#issuecomment-6315166760. The VUID-VkImageMemoryBarrier-image-03320 errors (6 on main 27fabb6b7) are gone with both PRs.

AI-assisted: yes

<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6315167640 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/9057#issuecomment-6315167640). Originally posted by [DavidSamir](https://github.com/DavidSamir) on 2026-10-21T11:49:00Z. --- AMD Radeon 680M (AMD 32.0.21030.2001, Windows) result for this PR together with #9056, under the validation layer: https://github.com/boykopovar/AnyPS5/pull/9056#issuecomment-6315166760. The `VUID-VkImageMemoryBarrier-image-03320` errors (6 on `main` `27fabb6b7`) are gone with both PRs. AI-assisted: yes
EagleBearerYS commented 2026-10-21 11:50:39 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by EagleBearerYS on 2026-10-21T11:50:39Z.


Read against SampleOrder.cpp on main: this is right, and it fixes a bug in our #6683's code (57ceb9e370). Thanks for finding it.

  • A D32S8 surface whose stencil isn't reordered (SampleOrderMethod::Depth, as when it has no stencil address) still gets a D32S8 copy from copyFor. That copy's first UNDEFINED to GENERAL barrier named the depth aspect alone. Nothing in the driver enables separateDepthStencilLayouts, so VUID-VkImageMemoryBarrier-image-03320 applies and the barrier must name both.
  • layoutAspects follows the copy's format, as transitionLocated does for the surface. The copy region and the descriptor stay depth-only, so only the layout barrier changes.
  • It was the only barrier in SampleOrder.cpp that named fewer aspects than its image's format has. The tests' own ToGeneral calls already take both.
  • Checked here, with this PR and #9056 merged on main 275e896797 (run):
    • On GitHub's Linux runner (lavapipe), agc_driver_sample_order, agc_driver_sample_order_planning, agc_driver_pixel_sample_iteration and agc_driver_sample_location_grid_fallback pass 3 runs in a row, and the grid-reference and recipe tests skip.
    • On Windows, without a GPU, 4 of those 6 skip and 2 pass.
    • The runners have no validation layer, so the 03320 count isn't reproduced here.
<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6315198375 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/9057#issuecomment-6315198375). Originally posted by [EagleBearerYS](https://github.com/EagleBearerYS) on 2026-10-21T11:50:39Z. --- Read against `SampleOrder.cpp` on `main`: this is right, and it fixes a bug in our #6683's code (57ceb9e370). Thanks for finding it. - A D32S8 surface whose stencil isn't reordered (`SampleOrderMethod::Depth`, as when it has no stencil address) still gets a D32S8 copy from `copyFor`. That copy's first `UNDEFINED` to `GENERAL` barrier named the depth aspect alone. Nothing in the driver enables `separateDepthStencilLayouts`, so VUID-VkImageMemoryBarrier-image-03320 applies and the barrier must name both. - `layoutAspects` follows the copy's format, as `transitionLocated` does for the surface. The copy region and the descriptor stay depth-only, so only the layout barrier changes. - It was the only barrier in `SampleOrder.cpp` that named fewer aspects than its image's format has. The tests' own `ToGeneral` calls already take both. - Checked here, with this PR and #9056 merged on `main` 275e896797 ([run](https://github.com/EagleBearerYS/AnyPS5/actions/runs/39591205482)): - On GitHub's Linux runner (lavapipe), `agc_driver_sample_order`, `agc_driver_sample_order_planning`, `agc_driver_pixel_sample_iteration` and `agc_driver_sample_location_grid_fallback` pass 3 runs in a row, and the grid-reference and recipe tests skip. - On Windows, without a GPU, 4 of those 6 skip and 2 pass. - The runners have no validation layer, so the `03320` count isn't reproduced here.
milescoviello commented 2026-10-21 11:56:13 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by milescoviello on 2026-10-21T11:56:13Z.


Thanks @EagleBearerYS for the review, and for checking that no other barrier in SampleOrder.cpp names fewer aspects than its image's format. Thanks @DavidSamir for the 680M run under the layer. Both are in the Tested section now.

AI-assisted: yes (Claude Code)

<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6315300645 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/9057#issuecomment-6315300645). Originally posted by [milescoviello](https://github.com/milescoviello) on 2026-10-21T11:56:13Z. --- Thanks @EagleBearerYS for the review, and for checking that no other barrier in `SampleOrder.cpp` names fewer aspects than its image's format. Thanks @DavidSamir for the 680M run under the layer. Both are in the Tested section now. AI-assisted: yes (Claude Code)
xXPBSXx commented 2026-10-21 19:52:12 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by xXPBSXx on 2026-10-21T19:52:12Z.


Validation-layer data point for this PR (data only).

Setup: Linux (WSL2 Ubuntu 24.04, GCC 13.3, Release), llvmpipe, vulkan-validationlayers 1.3.275.0-1 from the Ubuntu archive (older than the SDK a driver ships with), VK_INSTANCE_LAYERS=VK_LAYER_KHRONOS_validation. main 950388bfd; this PR's change (taken as git diff upstream/main...refs/pr/9057) applied on top of it.

Before (main): across all 483 built agc_driver_*_tests the layer reports VUID-VkImageMemoryBarrier-image-03320 once, from agc_driver_sample_order: barrier on a depth/stencil image (D32_SFLOAT_S8_UINT) with only the DEPTH aspect and no separateDepthStencilLayouts.

After (this PR): agc_driver_sample_order run again with the layer: 0 reports of that VUID, test passes. VUID-VkWriteDescriptorSet-descriptorType-00337 (a depth view without SAMPLED usage used as a sampled image) is still reported 3 times in that run's log; #9056 is about that one.

One run each, on llvmpipe only.

Not run: other GPUs for the layer run, other platforms, the other tests with the change under the layer.

AI-assisted (Claude Code).

<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6325127158 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/9057#issuecomment-6325127158). Originally posted by [xXPBSXx](https://github.com/xXPBSXx) on 2026-10-21T19:52:12Z. --- Validation-layer data point for this PR (data only). **Setup:** Linux (WSL2 Ubuntu 24.04, GCC 13.3, Release), llvmpipe, `vulkan-validationlayers` 1.3.275.0-1 from the Ubuntu archive (older than the SDK a driver ships with), `VK_INSTANCE_LAYERS=VK_LAYER_KHRONOS_validation`. `main` `950388bfd`; this PR's change (taken as `git diff upstream/main...refs/pr/9057`) applied on top of it. **Before (`main`):** across all 483 built `agc_driver_*_tests` the layer reports `VUID-VkImageMemoryBarrier-image-03320` once, from `agc_driver_sample_order`: barrier on a depth/stencil image (D32_SFLOAT_S8_UINT) with only the DEPTH aspect and no separateDepthStencilLayouts. **After (this PR):** `agc_driver_sample_order` run again with the layer: 0 reports of that VUID, test passes. VUID-VkWriteDescriptorSet-descriptorType-00337 (a depth view without SAMPLED usage used as a sampled image) is still reported 3 times in that run's log; #9056 is about that one. One run each, on llvmpipe only. **Not run:** other GPUs for the layer run, other platforms, the other tests with the change under the layer. AI-assisted (Claude Code).
milescoviello commented 2026-10-21 19:53:16 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by milescoviello on 2026-10-21T19:53:16Z.


Thanks @xXPBSXx. So 03320 also comes only from agc_driver_sample_order across the 483 tests, and this PR clears it there. I added it to the Tested section.

AI-assisted: yes (Claude Code)

<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6325147568 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/9057#issuecomment-6325147568). Originally posted by [milescoviello](https://github.com/milescoviello) on 2026-10-21T19:53:16Z. --- Thanks @xXPBSXx. So `03320` also comes only from `agc_driver_sample_order` across the 483 tests, and this PR clears it there. I added it to the Tested section. 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!9057
No description provided.