fix(shader): accept 3D image stores on 2D-array T#s #9249

Merged
Pacuka merged 1 commit from upstream-pr/9249 into main 2026-10-22 22:06:05 +00:00
Pacuka commented 2026-10-21 16:33:37 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by Pacuka on 2026-10-21T16:33:37Z.


What

A 3D image_store bound to a 2D-array T# was refused with image descriptor is incompatible with the static runtime image interface (descriptor dim 2D-array, prepared modes only 3D), which aborts the dispatch. The hardware addresses the layer of a 2D-array image through z, so the access is the same as a 2D-array store with (x, y, layer).

This is the inverse of #5555 (2D-array loads and stores on 3D T#s):

  • ResourceMaterializer: a write-only 3D storage image (no read, no atomic, no dynamic mips, not packed or by elements) also gets a 2D-array runtime mode.
  • SpirvImageEmitter: a store through that mode drops texels whose layer is past the array, with the same VolumeSliceInRange check #5555 uses for the volume depth.

Loads, samples and atomics are unchanged.

Tested

Linux (CachyOS, kernel 7.2.2), AMD RX 6650 XT, RADV Mesa 26.2.4.

  • New execution test ImageStoreVolumeThroughArray (mirror of ImageStoreArrayThroughVolume): 3D stores into a 4x4x2 2D-array T#, then a store at layer 2 that must not touch the bytes after the array. New unit case verifyArrayVolumeStoreMode in agc_shader_memory_tests: selects the 2D-array mode for a write-only 3D store, refuses a load+store and an atomic. Both fail on main and pass with this PR.
  • The other 70 image/volume/array/storage execution tests and agc_shader_memory_tests pass. agc_driver_image_array_window_past_layer_limit_tests fails on this machine with and without this PR (same output on main).
  • The Last of Us Part I (PPSA03396, 02.000.000): on main cecb540a6 it aborts about a minute after start, while loading the core world, on compute shader 0x12b6559e00 (two image_store ... dim:SQ_RSRC_IMG_3D into a format-56 2D-array T# 11800100 c3800000 0003c003 d0900fac 00000000 00700000 00000000 00000000). The dumped request replays with agc_shader_replay --materialize on this PR, and the title gets past that point and starts presenting at 2560x1440 (black screen). It then stops on a separate memory problem (a 16384x16384 storage view placed in host memory), which is not part of this PR.

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: PPSA03396 (no bring-up discussion yet)
  • GPUs tested: AMD Radeon RX 6650 XT (RADV NAVI23), Mesa 26.2.4, Linux
  • AI-assisted: yes

🤖 Generated with Claude Code

<!-- greyfinch-sync:boykopovar/AnyPS5:issue:4954960560 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/9249). Originally posted by [Pacuka](https://github.com/Pacuka) on 2026-10-21T16:33:37Z. --- ### What A 3D `image_store` bound to a 2D-array T# was refused with `image descriptor is incompatible with the static runtime image interface` (descriptor dim 2D-array, prepared modes only 3D), which aborts the dispatch. The hardware addresses the layer of a 2D-array image through z, so the access is the same as a 2D-array store with (x, y, layer). This is the inverse of #5555 (2D-array loads and stores on 3D T#s): - `ResourceMaterializer`: a write-only 3D storage image (no read, no atomic, no dynamic mips, not packed or by elements) also gets a 2D-array runtime mode. - `SpirvImageEmitter`: a store through that mode drops texels whose layer is past the array, with the same `VolumeSliceInRange` check #5555 uses for the volume depth. Loads, samples and atomics are unchanged. ### Tested Linux (CachyOS, kernel 7.2.2), AMD RX 6650 XT, RADV Mesa 26.2.4. - New execution test `ImageStoreVolumeThroughArray` (mirror of `ImageStoreArrayThroughVolume`): 3D stores into a 4x4x2 2D-array T#, then a store at layer 2 that must not touch the bytes after the array. New unit case `verifyArrayVolumeStoreMode` in `agc_shader_memory_tests`: selects the 2D-array mode for a write-only 3D store, refuses a load+store and an atomic. Both fail on `main` and pass with this PR. - The other 70 image/volume/array/storage execution tests and `agc_shader_memory_tests` pass. `agc_driver_image_array_window_past_layer_limit_tests` fails on this machine with and without this PR (same output on `main`). - The Last of Us Part I (PPSA03396, 02.000.000): on `main` cecb540a6 it aborts about a minute after start, while loading the `core` world, on compute shader `0x12b6559e00` (two `image_store ... dim:SQ_RSRC_IMG_3D` into a format-56 2D-array T# `11800100 c3800000 0003c003 d0900fac 00000000 00700000 00000000 00000000`). The dumped request replays with `agc_shader_replay --materialize` on this PR, and the title gets past that point and starts presenting at 2560x1440 (black screen). It then stops on a separate memory problem (a 16384x16384 storage view placed in host memory), which is not part of this PR. ### 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: PPSA03396 (no bring-up discussion yet) - [x] GPUs tested: AMD Radeon RX 6650 XT (RADV NAVI23), Mesa 26.2.4, Linux - [x] AI-assisted: yes 🤖 Generated with [Claude Code](https://claude.com/claude-code)
MaxLikesCode commented 2026-10-21 19:53:20 +00:00 (Migrated from github.com)

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


RTX 4090 (Ada) on Windows, head adca8cfa2 merged onto main 38d3c0858 (clean).

NVIDIA GeForce RTX 4090, driver 617.42, Windows 11 Pro 26200, WinLibs GCC 15.2.0 r7, Release, BUILD_TESTING=ON. ctest --test-dir build -R '^agc_driver_(image_|layered_|array_layer|storage)|^agc_shader_memory$' -V with ANYPS5_REQUIRE_VULKAN=1 and ANYPS5_NO_SHADER_CACHE=1, 3 runs without and 3 with VK_INSTANCE_LAYERS=VK_LAYER_KHRONOS_validation (Vulkan-ValidationLayers vulkan-sdk-1.4.363.0, implicit layers disabled). The loader log shows the layer inserted, and no log has was not found but was requested by env var VK_INSTANCE_LAYERS. agc_driver_image_array_window_past_layer_limit is left out: it does not compile with MinGW (#8310).

Build Tests Without the layer With the layer VUID- per validation run
main 72 all pass, 3 of 3 all pass, 3 of 3 2 × VkImageViewCreateInfo-usage-02275
main + #9249 73, with agc_driver_image_store_volume_through_array all pass, 3 of 3 all pass, 3 of 3 the same 2
  • The two 02275 come from agc_driver_image_srgb_sample_copy on both sides (an R8_SRGB view with storage usage, which this device doesn't support for that format), so nothing new.
  • main with only this PR's test changes applied: agc_driver_image_store_volume_through_array fails with image descriptor is incompatible with the static runtime image interface: descriptor format 20 decodes to {class 2, dim 5, ...}, and agc_shader_memory with the same message for format 56. Both pass with the PR.
  • tools/select_tests.py on the merged tree: 1138 of the 1141 selected tests pass. The 3 failures are agc_driver_sample_order, _grid_reference and _recipe_depth_locations, which fail the same way on main on this GPU (#9313, fixed by #9056).

AI-assisted: yes (Claude Code)

<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6325149009 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/9249#issuecomment-6325149009). Originally posted by [MaxLikesCode](https://github.com/MaxLikesCode) on 2026-10-21T19:53:20Z. --- RTX 4090 (Ada) on Windows, head `adca8cfa2` merged onto `main` `38d3c0858` (clean). NVIDIA GeForce RTX 4090, driver 617.42, Windows 11 Pro 26200, WinLibs GCC 15.2.0 r7, Release, `BUILD_TESTING=ON`. `ctest --test-dir build -R '^agc_driver_(image_|layered_|array_layer|storage)|^agc_shader_memory$' -V` with `ANYPS5_REQUIRE_VULKAN=1` and `ANYPS5_NO_SHADER_CACHE=1`, 3 runs without and 3 with `VK_INSTANCE_LAYERS=VK_LAYER_KHRONOS_validation` (Vulkan-ValidationLayers `vulkan-sdk-1.4.363.0`, implicit layers disabled). The loader log shows the layer inserted, and no log has `was not found but was requested by env var VK_INSTANCE_LAYERS`. `agc_driver_image_array_window_past_layer_limit` is left out: it does not compile with MinGW (#8310). | Build | Tests | Without the layer | With the layer | `VUID-` per validation run | |---|---|---|---|---| | `main` | 72 | all pass, 3 of 3 | all pass, 3 of 3 | 2 × `VkImageViewCreateInfo-usage-02275` | | `main` + #9249 | 73, with `agc_driver_image_store_volume_through_array` | all pass, 3 of 3 | all pass, 3 of 3 | the same 2 | - The two `02275` come from `agc_driver_image_srgb_sample_copy` on both sides (an `R8_SRGB` view with storage usage, which this device doesn't support for that format), so nothing new. - `main` with only this PR's test changes applied: `agc_driver_image_store_volume_through_array` fails with `image descriptor is incompatible with the static runtime image interface: descriptor format 20 decodes to {class 2, dim 5, ...}`, and `agc_shader_memory` with the same message for format 56. Both pass with the PR. - `tools/select_tests.py` on the merged tree: 1138 of the 1141 selected tests pass. The 3 failures are `agc_driver_sample_order`, `_grid_reference` and `_recipe_depth_locations`, which fail the same way on `main` on this GPU (#9313, fixed by #9056). AI-assisted: yes (Claude Code)
oneandonlydean commented 2026-10-21 21:32:29 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by oneandonlydean on 2026-10-21T21:32:29Z.


@Pacuka thanks for this. I ran PPSA03396 on main 95d17687 with this PR at adca8cfa2f. It gets past the stop on main, "image descriptor is incompatible with the static runtime image interface: descriptor format 56", and now runs to about 236 s. There it stops at a different one: "buffer descriptor uses an unsupported type". That one is separate from this change.

I'm assigning myself to take it through review and CI.

<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6327026085 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/9249#issuecomment-6327026085). Originally posted by [oneandonlydean](https://github.com/oneandonlydean) on 2026-10-21T21:32:29Z. --- @Pacuka thanks for this. I ran PPSA03396 on main 95d17687 with this PR at adca8cfa2f. It gets past the stop on main, "image descriptor is incompatible with the static runtime image interface: descriptor format 56", and now runs to about 236 s. There it stops at a different one: "buffer descriptor uses an unsupported type". That one is separate from this change. I'm assigning myself to take it through review and CI.
jotitadev commented 2026-10-21 22:34:07 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by jotitadev on 2026-10-21T22:34:07Z.

Review: COMMENTED


Confirmed red→green on two more vendors (the PR run is AMD RADV only): the new agc_driver_image_store_volume_through_array fails on main and passes with this change on both an NVIDIA RTX 3070 (Linux) and lavapipe.

Tested

Ubuntu 26.04, i7-8700, Release, BUILD_TESTING=ON, ANYPS5_NO_SHADER_CACHE=1, device selected with VK_ICD_FILENAMES, run as ./agc_driver_image_store_volume_through_array_tests, on main a6dcea927 (this PR applies cleanly on it).

agc_driver_image_store_volume_through_array NVIDIA RTX 3070 (595.99.02) lavapipe (Mesa 26.0.3, LLVM 21.1.8)
main a6dcea927 + new test only (recompiler reverted) fail 3/3 fail 3/3
this PR pass 3/3 pass 3/3

To confirm the test guards the regression, I built the new ImageStoreVolumeThroughArray.cpp on top of main with ResourceMaterializer.cpp and SpirvImageEmitter.cpp reverted. It fails on both devices with:

ShaderRecompiler::Recompile: image descriptor is incompatible with the static runtime image interface: descriptor format 20 decodes to {class 2, dim 5, ...}; modes: {class 1, dim 4, ...} {class 2, dim 4, ...} ...

i.e. a dim 5 (3D) store reaching a dim 4 (2D-array) runtime interface, which is exactly what this PR accepts. With the full PR both devices pass 3 of 3.

GPUs tested: NVIDIA GeForce RTX 3070 (595.99.02, Linux) and lavapipe (Mesa 26.0.3, LLVM 21.1.8), Ubuntu 26.04.

Written with AI assistance (Claude Code). I ran the builds and tests above on my machine.

<!-- greyfinch-sync:boykopovar/AnyPS5:review:5607052372 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/9249#pullrequestreview-5607052372). Originally posted by [jotitadev](https://github.com/jotitadev) on 2026-10-21T22:34:07Z. **Review:** COMMENTED --- Confirmed `red→green` on two more vendors (the PR run is AMD RADV only): the new `agc_driver_image_store_volume_through_array` fails on `main` and passes with this change on both an NVIDIA RTX 3070 (Linux) and lavapipe. ### Tested Ubuntu 26.04, i7-8700, Release, `BUILD_TESTING=ON`, `ANYPS5_NO_SHADER_CACHE=1`, device selected with `VK_ICD_FILENAMES`, run as `./agc_driver_image_store_volume_through_array_tests`, on `main` `a6dcea927` (this PR applies cleanly on it). | `agc_driver_image_store_volume_through_array` | NVIDIA RTX 3070 (595.99.02) | lavapipe (Mesa 26.0.3, LLVM 21.1.8) | |---|---|---| | `main` `a6dcea927` + new test only (recompiler reverted) | **fail 3/3** | **fail 3/3** | | this PR | pass 3/3 | pass 3/3 | To confirm the test guards the regression, I built the new `ImageStoreVolumeThroughArray.cpp` on top of `main` with `ResourceMaterializer.cpp` and `SpirvImageEmitter.cpp` reverted. It fails on both devices with: ``` ShaderRecompiler::Recompile: image descriptor is incompatible with the static runtime image interface: descriptor format 20 decodes to {class 2, dim 5, ...}; modes: {class 1, dim 4, ...} {class 2, dim 4, ...} ... ``` i.e. a `dim 5` (3D) store reaching a `dim 4` (2D-array) runtime interface, which is exactly what this PR accepts. With the full PR both devices pass 3 of 3. GPUs tested: NVIDIA GeForce RTX 3070 (595.99.02, Linux) and lavapipe (Mesa 26.0.3, LLVM 21.1.8), Ubuntu 26.04. Written with AI assistance (Claude Code). I ran the builds and tests above on my machine.
jotitadev commented 2026-10-22 00:01:47 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by jotitadev on 2026-10-22T00:01:47Z.

Review: COMMENTED


First Apple GPU / MoltenVK run of this PR. Both the execution test and the unit case go red→green here.

Machine: Apple M2 Max, macOS 27.2, x86_64 under Rosetta 2. Vulkan loader + MoltenVK 1.4.2 (Vulkan SDK 1.4.363.0), and again against MoltenVK main + SPIRV-Cross #2704. Release, BUILD_TESTING=ON.

Base/method: PR #8658 feat/macos-port @ a1fb8e3e9c (current main a6dcea9279 plus the macOS port), not main — main does not build on macOS. This PR's diff (git diff merge-base..adca8cfa2 -- . ':!docs') applied on top, clean.

With this PR (--repeat until-fail:3, both drivers): agc_driver_image_store_volume_through_array and agc_shader_memory pass 3/3 on each.

image store volume through array tests passed

Negative control (revert ResourceMaterializer.cpp and SpirvImageEmitter.cpp to the PR's base, keep both tests): both fail with exactly the message this PR addresses:

agc_shader_memory: image descriptor is incompatible with the static runtime image interface: descriptor format 56 decodes to {class 1, dim 5, ...}; modes: {class 1, dim 4, ...} {class 2, dim 4, ...} ...

agc_driver_image_store_volume_through_array: ShaderRecompiler::Recompile: image descriptor is incompatible with the static runtime image interface: descriptor format 20 decodes to {class 2, dim 5, ...}; modes: {class 1, dim 4, ...} ...

So the descriptor (dim 5 = 3D) has no dim 5 runtime mode and the recompile aborts; with the PR the write-only 3D store gets a dim 4 (2D-array) mode and the store lands, layer-past-array bytes untouched. The behaviour is not Apple-specific, but this confirms it on MoltenVK: the test detects the regression here and the fix clears it on both drivers.

Full ^agc suite with this PR (SDK, clean rebuild): the same 15 failures as the #8658 base, no new one, and the new agc_driver_image_store_volume_through_array passes — so the recompiler change adds nothing to the failing set on Apple.

GPUs tested: Apple M2 Max (MoltenVK 1.4.2; and MoltenVK main + SPIRV-Cross #2704).

Written with AI assistance (Claude Code). I ran the builds and tests above on my machine.

<!-- greyfinch-sync:boykopovar/AnyPS5:review:5607688816 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/9249#pullrequestreview-5607688816). Originally posted by [jotitadev](https://github.com/jotitadev) on 2026-10-22T00:01:47Z. **Review:** COMMENTED --- First Apple GPU / MoltenVK run of this PR. Both the execution test and the unit case go red→green here. **Machine:** Apple M2 Max, macOS 27.2, x86_64 under Rosetta 2. Vulkan loader + MoltenVK 1.4.2 (Vulkan SDK 1.4.363.0), and again against MoltenVK main + SPIRV-Cross #2704. Release, `BUILD_TESTING=ON`. **Base/method:** PR #8658 `feat/macos-port` @ `a1fb8e3e9c` (current `main` `a6dcea9279` plus the macOS port), not `main` — `main` does not build on macOS. This PR's diff (`git diff merge-base..adca8cfa2 -- . ':!docs'`) applied on top, clean. **With this PR** (`--repeat until-fail:3`, both drivers): `agc_driver_image_store_volume_through_array` and `agc_shader_memory` pass 3/3 on each. ``` image store volume through array tests passed ``` **Negative control** (revert `ResourceMaterializer.cpp` and `SpirvImageEmitter.cpp` to the PR's base, keep both tests): both fail with exactly the message this PR addresses: ``` agc_shader_memory: image descriptor is incompatible with the static runtime image interface: descriptor format 56 decodes to {class 1, dim 5, ...}; modes: {class 1, dim 4, ...} {class 2, dim 4, ...} ... agc_driver_image_store_volume_through_array: ShaderRecompiler::Recompile: image descriptor is incompatible with the static runtime image interface: descriptor format 20 decodes to {class 2, dim 5, ...}; modes: {class 1, dim 4, ...} ... ``` So the descriptor (`dim 5` = 3D) has no `dim 5` runtime mode and the recompile aborts; with the PR the write-only 3D store gets a `dim 4` (2D-array) mode and the store lands, layer-past-array bytes untouched. The behaviour is not Apple-specific, but this confirms it on MoltenVK: the test detects the regression here and the fix clears it on both drivers. Full `^agc` suite with this PR (SDK, clean rebuild): the same 15 failures as the `#8658` base, no new one, and the new `agc_driver_image_store_volume_through_array` passes — so the recompiler change adds nothing to the failing set on Apple. GPUs tested: Apple M2 Max (MoltenVK 1.4.2; and MoltenVK main + SPIRV-Cross #2704). Written with AI assistance (Claude Code). I ran the builds and tests above on my machine.
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!9249
No description provided.