fix(agc): refuse depth targets with a sample count the device cannot hold #23386

Merged
GiannisG1 merged 1 commit from upstream-pr/23386 into main 2026-11-27 02:50:33 +00:00
GiannisG1 commented 2026-11-18 23:44:25 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by GiannisG1 on 2026-11-18T23:44:25Z.


What

DepthSurface creates a multisample depth target in the host format without asking whether that format supports the target's sample count. Its sampling paths do check (supports for the sample shadow and the directly sampled image), but the attachment itself does not. lavapipe and llvmpipe offer only 1, 4 and 8 samples for D32_SFLOAT_S8_UINT. The two-sample stencil plane of agc_driver_stencil_copy_draw is therefore created invalid on them, and the validation layer reports it:

VUID-VkImageCreateInfo-samples-02258: vkCreateImage(): pCreateInfo->samples (VK_SAMPLE_COUNT_2_BIT) is not supported by format VK_FORMAT_D32_SFLOAT_S8_UINT supported sampleCounts: VK_SAMPLE_COUNT_1_BIT|VK_SAMPLE_COUNT_4_BIT|VK_SAMPLE_COUNT_8_BIT

Since #21093 the test then skips, because these devices also lack 2x custom sample locations, so the invalid image only shows with the validation layer on. #20289's author noted the remaining VUID when closing it. Any title with a two-sample depth/stencil target on such a device gets the same invalid image.

Right before the image is created, DepthSurface now queries vkGetPhysicalDeviceImageFormatProperties with the image's own usage and flags. If the sample count is not in sampleCounts, it refuses the target with depth/stencil format N cannot hold S samples on this device, as it already refuses a format that cannot be an attachment. Devices that support the sample count create the same image as before.

agc_driver_stencil_copy_draw checks up front whether the device can hold a two-sample D32_SFLOAT_S8_UINT plane. Where it cannot, the test requires that refusal and skips with a device reason; the sample-locations skip stays for devices that hold the plane but lack the locations. In tests/DepthSurfaceReuse.cpp, the attachment-only mock now answers the attachment query (1 to 8 samples) and refuses only sampled usage, which is what it stands for; it used to refuse every query. A new mock holding only one or two samples checks the refusal on any machine.

Tested

All runs below are mine, on one machine: Linux Mint 22.3, GCC 13.3.0, Release, head on main 866864a5bc.

  • agc_driver_stencil_copy_draw, 3 runs on each device. Without the DepthSurface change, llvmpipe and lavapipe fail with a two-sample stencil plane the device cannot hold was not refused for its sample count: AGC graphics: custom sample locations require VK_EXT_sample_locations support for the draw's sample count. With it, both skip with skipped, the device lacks two-sample D32_SFLOAT_S8_UINT depth/stencil attachments. The GTX and the HD 630 hold the two-sample plane and pass all six cases on both sides. check_skips.py is clean.
  • Validation layer (Khronos 1.4.363.1 from the LunarG SDK): VK_INSTANCE_LAYERS=VK_LAYER_KHRONOS_validation, VK_LOADER_DEBUG=layer, ANYPS5_NO_SHADER_CACHE=1, ANYPS5_REQUIRE_VULKAN=1, ctest -V -j2 on the 63 stencil, MSAA, multisample and EQAA tests (^agc_.*(stencil|msaa|multisample|eqaa).*$), main 866864a5bc and this PR, on the GTX, the HD 630, llvmpipe and lavapipe. The loader inserts the layer every time and never reports it as not found. On main, llvmpipe and lavapipe each report VUID-VkImageCreateInfo-samples-02258 twice, in agc_driver_stencil_copy_draw, and the GTX and the HD 630 report nothing. With this PR, no device reports anything. No test changes its result between the two sides on any device.
  • tests/DepthSurfaceReuse.cpp (agc_driver_graphics): a four-sample D32_SFLOAT target on a mock device whose attachment holds 1 or 2 samples is refused with cannot hold 4 samples on this device; without the DepthSurface change the test fails with a four-sample depth target in a format the device holds only at one or two samples must be refused, not created. With the fix, agc_driver_graphics, agc_driver_graphics_maps_fallback and agc_graphics_profile_draw pass 3 times on the GTX and once on the HD 630, llvmpipe and lavapipe.
  • Split suite (tools/suite.py: every test once, GPU tests on all three devices) on this PR, compared with main 866864a5bc's own run on the same machine. GTX: 6163 run, 5 failed. Two are guest_libressl3_aes and guest_libressl3_aes_wrap, which fail on main too (#23208, reverted in #23365). The other three are agc_driver_graphics, agc_driver_graphics_maps_fallback and agc_graphics_profile_draw: the run used the old attachment-only mock, they pass with the mock fixed above, and only that test file changed after the run. HD 630: 1686 run, 10 failed, all failing on main too. llvmpipe: 1686 run, 9 failed: main's 8 and agc_driver_frame_replay_rewind_copy, which passes 3 of 3 alone (it also failed only under load in a validation sweep).
  • check_conventions.py, check_test_registration.py, check_main_sync.py (merges cleanly), check_compile.py and git diff --check are clean.
  • Overlap: pr_overlap.py --branch finds no open PR that changes these lines. Of the 18 PRs it could not compare (they conflict with main), only #7256 changes this part of the DepthSurface constructor: it puts the vkCreateImage depth call into an else for its layered array image, and the check here would move into that branch.

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 and the licence notice of code adapted from upstream (see AGENTS.md)
  • 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 GTX 1050 Ti (580.178.04), Intel HD Graphics 630 (Mesa 25.2.8), llvmpipe (Mesa 25.2.8), lavapipe (Mesa 26.0.8, built locally), Linux Mint 22.3
  • AI-assisted: yes

🤖 Generated with Claude Code

<!-- greyfinch-sync:boykopovar/AnyPS5:issue:5386046968 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/23386). Originally posted by [GiannisG1](https://github.com/GiannisG1) on 2026-11-18T23:44:25Z. --- ### What `DepthSurface` creates a multisample depth target in the host format without asking whether that format supports the target's sample count. Its sampling paths do check (`supports` for the sample shadow and the directly sampled image), but the attachment itself does not. lavapipe and llvmpipe offer only 1, 4 and 8 samples for `D32_SFLOAT_S8_UINT`. The two-sample stencil plane of `agc_driver_stencil_copy_draw` is therefore created invalid on them, and the validation layer reports it: ``` VUID-VkImageCreateInfo-samples-02258: vkCreateImage(): pCreateInfo->samples (VK_SAMPLE_COUNT_2_BIT) is not supported by format VK_FORMAT_D32_SFLOAT_S8_UINT supported sampleCounts: VK_SAMPLE_COUNT_1_BIT|VK_SAMPLE_COUNT_4_BIT|VK_SAMPLE_COUNT_8_BIT ``` Since #21093 the test then skips, because these devices also lack 2x custom sample locations, so the invalid image only shows with the validation layer on. #20289's author noted the remaining VUID when closing it. Any title with a two-sample depth/stencil target on such a device gets the same invalid image. Right before the image is created, `DepthSurface` now queries `vkGetPhysicalDeviceImageFormatProperties` with the image's own usage and flags. If the sample count is not in `sampleCounts`, it refuses the target with `depth/stencil format N cannot hold S samples on this device`, as it already refuses a format that cannot be an attachment. Devices that support the sample count create the same image as before. `agc_driver_stencil_copy_draw` checks up front whether the device can hold a two-sample `D32_SFLOAT_S8_UINT` plane. Where it cannot, the test requires that refusal and skips with a device reason; the sample-locations skip stays for devices that hold the plane but lack the locations. In `tests/DepthSurfaceReuse.cpp`, the attachment-only mock now answers the attachment query (1 to 8 samples) and refuses only sampled usage, which is what it stands for; it used to refuse every query. A new mock holding only one or two samples checks the refusal on any machine. ### Tested All runs below are mine, on one machine: Linux Mint 22.3, GCC 13.3.0, Release, head on `main` `866864a5bc`. - `agc_driver_stencil_copy_draw`, 3 runs on each device. Without the `DepthSurface` change, llvmpipe and lavapipe fail with `a two-sample stencil plane the device cannot hold was not refused for its sample count: AGC graphics: custom sample locations require VK_EXT_sample_locations support for the draw's sample count`. With it, both skip with `skipped, the device lacks two-sample D32_SFLOAT_S8_UINT depth/stencil attachments`. The GTX and the HD 630 hold the two-sample plane and pass all six cases on both sides. `check_skips.py` is clean. - Validation layer (Khronos 1.4.363.1 from the LunarG SDK): `VK_INSTANCE_LAYERS=VK_LAYER_KHRONOS_validation`, `VK_LOADER_DEBUG=layer`, `ANYPS5_NO_SHADER_CACHE=1`, `ANYPS5_REQUIRE_VULKAN=1`, `ctest -V -j2` on the 63 stencil, MSAA, multisample and EQAA tests (`^agc_.*(stencil|msaa|multisample|eqaa).*$`), `main` `866864a5bc` and this PR, on the GTX, the HD 630, llvmpipe and lavapipe. The loader inserts the layer every time and never reports it as not found. On `main`, llvmpipe and lavapipe each report `VUID-VkImageCreateInfo-samples-02258` twice, in `agc_driver_stencil_copy_draw`, and the GTX and the HD 630 report nothing. With this PR, no device reports anything. No test changes its result between the two sides on any device. - `tests/DepthSurfaceReuse.cpp` (`agc_driver_graphics`): a four-sample `D32_SFLOAT` target on a mock device whose attachment holds 1 or 2 samples is refused with `cannot hold 4 samples on this device`; without the `DepthSurface` change the test fails with `a four-sample depth target in a format the device holds only at one or two samples must be refused, not created`. With the fix, `agc_driver_graphics`, `agc_driver_graphics_maps_fallback` and `agc_graphics_profile_draw` pass 3 times on the GTX and once on the HD 630, llvmpipe and lavapipe. - Split suite (`tools/suite.py`: every test once, GPU tests on all three devices) on this PR, compared with `main` `866864a5bc`'s own run on the same machine. GTX: 6163 run, 5 failed. Two are `guest_libressl3_aes` and `guest_libressl3_aes_wrap`, which fail on `main` too (#23208, reverted in #23365). The other three are `agc_driver_graphics`, `agc_driver_graphics_maps_fallback` and `agc_graphics_profile_draw`: the run used the old attachment-only mock, they pass with the mock fixed above, and only that test file changed after the run. HD 630: 1686 run, 10 failed, all failing on `main` too. llvmpipe: 1686 run, 9 failed: `main`'s 8 and `agc_driver_frame_replay_rewind_copy`, which passes 3 of 3 alone (it also failed only under load in a validation sweep). - `check_conventions.py`, `check_test_registration.py`, `check_main_sync.py` (merges cleanly), `check_compile.py` and `git diff --check` are clean. - Overlap: `pr_overlap.py --branch` finds no open PR that changes these lines. Of the 18 PRs it could not compare (they conflict with `main`), only #7256 changes this part of the `DepthSurface` constructor: it puts the `vkCreateImage depth` call into an `else` for its layered array image, and the check here would move into that branch. ### 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) and the licence notice of code adapted from upstream (see AGENTS.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 GTX 1050 Ti (580.178.04), Intel HD Graphics 630 (Mesa 25.2.8), llvmpipe (Mesa 25.2.8), lavapipe (Mesa 26.0.8, built locally), Linux Mint 22.3 - [x] AI-assisted: yes 🤖 Generated with [Claude Code](https://claude.com/claude-code)
MarcZX10 commented 2026-11-19 01:30:38 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-11-19T01:30:38Z.

Review: APPROVED


Reviewed — looks good

Nothing blocks this change; the inspected implementation and tests support the stated behavior.

What I ran

Reviewed head 88f36f27ba851fcb93a190e5009c8a2d74bf1327. Read the prepared description, commits, manifest, diff, and all three changed source files. Used repo_read.py search for relevant call sites. No build or tests were run; reported test results below are from the PR description.

Results

Check Result Note
Source review passed Three changed files inspected
Build and tests not run Results were author-reported
Call-site search passed Relevant context and query uses located

Findings

Blocking

None.

Non-blocking

None.

Not verified

Build, automated tests, and runtime behavior were not independently verified. No changed files were excluded from the review bundle.

To get this to a good state

Nothing is required.

<!-- greyfinch-sync:boykopovar/AnyPS5:review:5967981024 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/23386#pullrequestreview-5967981024). Originally posted by [MarcZX10](https://github.com/MarcZX10) on 2026-11-19T01:30:38Z. **Review:** APPROVED --- # Reviewed — looks good Nothing blocks this change; the inspected implementation and tests support the stated behavior. ## What I ran Reviewed head `88f36f27ba851fcb93a190e5009c8a2d74bf1327`. Read the prepared description, commits, manifest, diff, and all three changed source files. Used `repo_read.py` search for relevant call sites. No build or tests were run; reported test results below are from the PR description. ## Results | Check | Result | Note | |---|---|---| | Source review | passed | Three changed files inspected | | Build and tests | not run | Results were author-reported | | Call-site search | passed | Relevant context and query uses located | ## Findings ### Blocking None. ### Non-blocking None. ## Not verified Build, automated tests, and runtime behavior were not independently verified. No changed files were excluded from the review bundle. ## To get this to a good state Nothing is required.
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!23386
No description provided.