fix(shader): gather the BASE_ARRAY face of a cube T# with DIM 2D #23519

Merged
MichonGoddijn231849 merged 1 commit from upstream-pr/23519 into main 2026-11-27 04:05:37 +00:00
MichonGoddijn231849 commented 2026-11-19 06:47:55 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by MichonGoddijn231849 on 2026-11-19T06:47:55Z.


What

image_gather4 and image_gather4_lz with DIM 2D through a cube T# threw image descriptor is incompatible with the static runtime image interface. The cube-face mode (#4139), which samples the T#'s BASE_ARRAY face, was offered only to loads, stores and image_sample, _lz and _l.

  • ResourceTracker.cpp: a gather with no LOD, bias, offset or comparison (imageSampleFlags 0 or LevelZero) keeps cubeFaceCompatible set, so the image is offered the cube-face mode.
  • ResourceMaterializer.cpp: multisamplePlaneRead also uses cubeFaceCompatible. It now requires !image.gathered, so a DIM 2D read of a 2D MSAA T# still refuses gathers as before.
  • Debt: the 2D accesses through a cube T# entry lists the two gathers among the accesses that take the mode, and its throw list now says "other gathers". A new entry records the measurement.

No cache format change: cubeFaceCompatible is an existing field.

Measurement: tools/hw-oracle on gfx1036 (PC RDNA2), point S#, 32 coordinates in [1, 2] per case. The sources were a 64x64 32_FLOAT and 32_32_32_32_FLOAT cube, and a 12-face cube array at BASE_ARRAY 0, 6 and 7.

comparison result
hardware: image_gather4 / _lz with DIM 2D vs DIM CUBE face 0 32/32 equal
emulator DIM 2D (this branch) vs hardware DIM 2D, channels R, G, B, A, DISABLE_CUBE_WRAP 1 32/32 on both GPUs
same at BASE_ARRAY 0, 6 and 7 32/32 on both GPUs
same with DISABLE_CUBE_WRAP 0 31/32: the row at the face's last texel, where the hardware gathers from the neighbouring face, as the existing entry already records for samples

Tested

Windows 11 Pro 10.0.26200, MinGW Release build. ctest --test-dir build -R <pattern> -V with ANYPS5_REQUIRE_VULKAN=1 ANYPS5_NO_SHADER_CACHE=1 VK_INSTANCE_LAYERS=VK_LAYER_KHRONOS_validation VK_LOADER_DEBUG=layer, on an NVIDIA GeForce RTX 5080 (610.74) and an AMD Radeon(TM) Graphics iGPU (gfx1036, 32.0.21045.16010). Each log shows the loader inserting the validation layer, none reports it missing, and there are no VUID- messages.

  • New agc_driver_image_gather_face_on_cube: 32 threads gather a 16x16 8_8_8_8_UNORM cube array (12 faces, BASE_ARRAY 6) with DIM 2D:
    • image_gather4_lz of R and G must return the x and y footprint.
    • image_gather4 of B must return face 6 for all four texels.
    • Passes on both GPUs.
  • Negative check: against main's ResourceTracker.cpp and ResourceMaterializer.cpp, the test fails on both GPUs with image descriptor is incompatible with the static runtime image interface.
  • 64 related tests (agc_driver_*cube*, *msaa*, *gather*, *multisample*, agc_driver_image_sample*, agc_shader_memory):
    • AMD: all pass.
    • NVIDIA: everything passes except three failures that also fail on main on this machine:
      • agc_driver_image_sample_lod_clamp and agc_driver_image_sample_lod_clamp_shader_lane (known NVIDIA baseline);
      • agc_driver_msaa_dcc_unwatch (fails 3/3 runs both with and without this change).
    • The msaa_dcc_compared_import cases skip on both GPUs.

tools/pr_overlap.py cannot compare ResourceMaterializer.cpp against the PRs that conflict with main. Among open PRs on cube-face accesses, #20982 and #22534 change cube-face stores, not gathers. Not tested on a PS5.

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 RTX 5080, driver 610.74, Windows 11 Pro 10.0.26200; AMD Radeon(TM) Graphics (RDNA2 iGPU, gfx1036), driver 32.0.21045.16010, Windows 11 Pro 10.0.26200
  • AI-assisted: yes

🤖 Generated with Claude Code

<!-- greyfinch-sync:boykopovar/AnyPS5:issue:5390238628 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/23519). Originally posted by [MichonGoddijn231849](https://github.com/MichonGoddijn231849) on 2026-11-19T06:47:55Z. --- ### What `image_gather4` and `image_gather4_lz` with DIM 2D through a cube T# threw `image descriptor is incompatible with the static runtime image interface`. The cube-face mode (#4139), which samples the T#'s `BASE_ARRAY` face, was offered only to loads, stores and `image_sample`, `_lz` and `_l`. - **`ResourceTracker.cpp`:** a gather with no LOD, bias, offset or comparison (`imageSampleFlags` 0 or LevelZero) keeps `cubeFaceCompatible` set, so the image is offered the cube-face mode. - **`ResourceMaterializer.cpp`:** `multisamplePlaneRead` also uses `cubeFaceCompatible`. It now requires `!image.gathered`, so a DIM 2D read of a 2D MSAA T# still refuses gathers as before. - **Debt:** the `2D accesses through a cube T#` entry lists the two gathers among the accesses that take the mode, and its throw list now says "other gathers". A new entry records the measurement. No cache format change: `cubeFaceCompatible` is an existing field. **Measurement:** `tools/hw-oracle` on gfx1036 (PC RDNA2), point S#, 32 coordinates in [1, 2] per case. The sources were a 64x64 32_FLOAT and 32_32_32_32_FLOAT cube, and a 12-face cube array at `BASE_ARRAY` 0, 6 and 7. | comparison | result | | --- | --- | | hardware: `image_gather4` / `_lz` with DIM 2D vs DIM CUBE face 0 | 32/32 equal | | emulator DIM 2D (this branch) vs hardware DIM 2D, channels R, G, B, A, `DISABLE_CUBE_WRAP` 1 | 32/32 on both GPUs | | same at `BASE_ARRAY` 0, 6 and 7 | 32/32 on both GPUs | | same with `DISABLE_CUBE_WRAP` 0 | 31/32: the row at the face's last texel, where the hardware gathers from the neighbouring face, as the existing entry already records for samples | ### Tested Windows 11 Pro 10.0.26200, MinGW Release build. `ctest --test-dir build -R <pattern> -V` with `ANYPS5_REQUIRE_VULKAN=1 ANYPS5_NO_SHADER_CACHE=1 VK_INSTANCE_LAYERS=VK_LAYER_KHRONOS_validation VK_LOADER_DEBUG=layer`, on an NVIDIA GeForce RTX 5080 (610.74) and an AMD Radeon(TM) Graphics iGPU (gfx1036, 32.0.21045.16010). Each log shows the loader inserting the validation layer, none reports it missing, and there are no `VUID-` messages. - New `agc_driver_image_gather_face_on_cube`: 32 threads gather a 16x16 8_8_8_8_UNORM cube array (12 faces, `BASE_ARRAY` 6) with DIM 2D: - `image_gather4_lz` of R and G must return the x and y footprint. - `image_gather4` of B must return face 6 for all four texels. - Passes on both GPUs. - Negative check: against `main`'s `ResourceTracker.cpp` and `ResourceMaterializer.cpp`, the test fails on both GPUs with `image descriptor is incompatible with the static runtime image interface`. - 64 related tests (`agc_driver_*cube*`, `*msaa*`, `*gather*`, `*multisample*`, `agc_driver_image_sample*`, `agc_shader_memory`): - AMD: all pass. - NVIDIA: everything passes except three failures that also fail on `main` on this machine: - `agc_driver_image_sample_lod_clamp` and `agc_driver_image_sample_lod_clamp_shader_lane` (known NVIDIA baseline); - `agc_driver_msaa_dcc_unwatch` (fails 3/3 runs both with and without this change). - The `msaa_dcc_compared_import` cases skip on both GPUs. `tools/pr_overlap.py` cannot compare `ResourceMaterializer.cpp` against the PRs that conflict with `main`. Among open PRs on cube-face accesses, #20982 and #22534 change cube-face stores, not gathers. Not tested on a PS5. ### 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 RTX 5080, driver 610.74, Windows 11 Pro 10.0.26200; AMD Radeon(TM) Graphics (RDNA2 iGPU, gfx1036), driver 32.0.21045.16010, Windows 11 Pro 10.0.26200 - [x] AI-assisted: yes 🤖 Generated with [Claude Code](https://claude.com/claude-code)
MarcZX10 commented 2026-11-21 07:51:27 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-11-21T07:51:27Z.

Review: APPROVED


Reviewed — looks good

Nothing in the inspected change blocks merging; the author-reported test results are not independently verified here.

What I ran

Reviewed head b2393574c7c05b0c7f88bd2077a7ae12c8d7a861 from the prepared diff and source reader. No build or tests were run.

Results

Check Result Note
Diff and changed source passed Four changed files inspected
Build and tests not run Results in the PR description are author-reported

Findings

Blocking

None.

Non-blocking

None.

Not verified

No tests or build were run. The PR description reports GPU tests and hardware measurements; these were not independently verified. Read all four changed files listed in the manifest: core/libs/prx/libSceAgcDriver/tests/execution/ImageGatherFaceOnCube.cpp, core/shader/recompiler/Optimization/src/ResourceMaterializer.cpp, core/shader/recompiler/Optimization/src/ResourceTracker.cpp, and docs/dev/debt/changes/fix-cube-face-gathers.md. No changed files were excluded by the manifest.

To get this to a good state

Nothing is required.

<!-- greyfinch-sync:boykopovar/AnyPS5:review:6003965520 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/23519#pullrequestreview-6003965520). Originally posted by [MarcZX10](https://github.com/MarcZX10) on 2026-11-21T07:51:27Z. **Review:** APPROVED --- # Reviewed — looks good Nothing in the inspected change blocks merging; the author-reported test results are not independently verified here. ## What I ran Reviewed head `b2393574c7c05b0c7f88bd2077a7ae12c8d7a861` from the prepared diff and source reader. No build or tests were run. ## Results | Check | Result | Note | | --- | --- | --- | | Diff and changed source | passed | Four changed files inspected | | Build and tests | not run | Results in the PR description are author-reported | ## Findings ### Blocking None. ### Non-blocking None. ## Not verified No tests or build were run. The PR description reports GPU tests and hardware measurements; these were not independently verified. Read all four changed files listed in the manifest: `core/libs/prx/libSceAgcDriver/tests/execution/ImageGatherFaceOnCube.cpp`, `core/shader/recompiler/Optimization/src/ResourceMaterializer.cpp`, `core/shader/recompiler/Optimization/src/ResourceTracker.cpp`, and `docs/dev/debt/changes/fix-cube-face-gathers.md`. No changed files were excluded by the manifest. ## 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!23519
No description provided.