Skip to content

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

Merged
oneandonlydean merged 1 commit into
boykopovar:mainfrom
MichonGoddijn231849:fix-cube-face-gathers
Nov 27, 2026
Merged

oneandonlydean merged 1 commit into
boykopovar:mainfrom
MichonGoddijn231849:fix-cube-face-gathers

Conversation

@MichonGoddijn231849

Copy link
Copy Markdown
Contributor

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

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@github-actions github-actions Bot added shader core/shader docs agc libSceAgc* labels Nov 19, 2026
@domx4q

domx4q commented Nov 19, 2026

Copy link
Copy Markdown
Contributor

Ran the new test and the cube and gather tests with the Khronos validation layer on Linux and an NVIDIA GPU, plus the negative check against main's recompiler sources.

Setup: Arch Linux (kernel 7.3.4), GCC 16.2.1, Release, NVIDIA GeForce RTX 4090 (vendor 0x10de, device 0x2684, Ada), proprietary driver 620.70.06, Vulkan 1.4.357, Khronos validation layer 1.4.363.1. Head b2393574c7 merged onto main ded746ea12 with --no-ff, clean merge. Main baseline is a Release build of ded746ea12 on the same machine.

ANYPS5_REQUIRE_VULKAN=1 ANYPS5_NO_SHADER_CACHE=1 VK_INSTANCE_LAYERS=VK_LAYER_KHRONOS_validation VK_LOADER_DEBUG=layer \
ctest --test-dir build -R '^agc_driver_.*(cube|gather).*$|^agc_shader_memory$' -V
main ded746ea12 this PR
Result 12 of 12 passed 13 of 13 passed
Insert instance layer "VK_LAYER_KHRONOS_validation" 11 12
was not found but was requested by env var VK_INSTANCE_LAYERS 0 0
VUID- none none

agc_driver_image_gather_face_on_cube is new in this PR and does not exist on main; it passes (image gather face on cube tests passed). The other twelve (image_gather_*, image_store_face_on_cube, image_plane_address_on_cube, image_sample_cube_derivatives, image_sample_short_cube, vop3_cube_clamp, image_sint8_gather_constant_*, agc_shader_memory) pass on both sides. Every Vulkan test selected the RTX 4090.

Negative check: with ResourceTracker.cpp and ResourceMaterializer.cpp reverted to main, agc_driver_image_gather_face_on_cube fails here too, with image descriptor is incompatible with the static runtime image interface: descriptor format 56 decodes to {class 1, dim 5, ... cube 1, ...}, the message the Tested section reports.

No new VUID- errors; all focused tests pass on Ada.

AI-assisted: yes (Claude Code)

@github-actions

github-actions Bot commented Nov 20, 2026 •

Copy link
Copy Markdown

Other open pull requests touch the same code. Merging one will break the other, or both implement the same thing. If this one builds on them, list them in Depends on.

Pull request Conflicting files (lines on main) Same exports Same new files
PR 26012 core/shader/recompiler/Optimization/src/ResourceTracker.cpp L2734

Some comparisons could not be completed because a pull request conflicts with the base branch. Review these shared files manually before concluding that there is no overlap.

Pull request Shared files not compared
PR 5371 core/shader/recompiler/Optimization/src/ResourceMaterializer.cpp
PR 6280 core/shader/recompiler/Optimization/src/ResourceMaterializer.cpp
core/shader/recompiler/Optimization/src/ResourceTracker.cpp
PR 6412 core/shader/recompiler/Optimization/src/ResourceMaterializer.cpp
PR 6488 core/shader/recompiler/Optimization/src/ResourceMaterializer.cpp
core/shader/recompiler/Optimization/src/ResourceTracker.cpp
PR 7642 core/shader/recompiler/Optimization/src/ResourceMaterializer.cpp
core/shader/recompiler/Optimization/src/ResourceTracker.cpp
PR 7684 core/shader/recompiler/Optimization/src/ResourceMaterializer.cpp
core/shader/recompiler/Optimization/src/ResourceTracker.cpp
PR 9852 core/shader/recompiler/Optimization/src/ResourceTracker.cpp
PR 9897 core/shader/recompiler/Optimization/src/ResourceTracker.cpp
PR 10193 core/shader/recompiler/Optimization/src/ResourceMaterializer.cpp
core/shader/recompiler/Optimization/src/ResourceTracker.cpp
PR 11551 core/shader/recompiler/Optimization/src/ResourceMaterializer.cpp
PR 13928 core/shader/recompiler/Optimization/src/ResourceMaterializer.cpp
core/shader/recompiler/Optimization/src/ResourceTracker.cpp
PR 13929 core/shader/recompiler/Optimization/src/ResourceMaterializer.cpp
core/shader/recompiler/Optimization/src/ResourceTracker.cpp
PR 14032 core/shader/recompiler/Optimization/src/ResourceTracker.cpp
PR 14853 core/shader/recompiler/Optimization/src/ResourceMaterializer.cpp
core/shader/recompiler/Optimization/src/ResourceTracker.cpp
PR 14871 core/shader/recompiler/Optimization/src/ResourceMaterializer.cpp
PR 14944 core/shader/recompiler/Optimization/src/ResourceTracker.cpp
PR 15555 core/shader/recompiler/Optimization/src/ResourceMaterializer.cpp
core/shader/recompiler/Optimization/src/ResourceTracker.cpp
PR 16260 core/shader/recompiler/Optimization/src/ResourceMaterializer.cpp
PR 18106 core/shader/recompiler/Optimization/src/ResourceMaterializer.cpp
core/shader/recompiler/Optimization/src/ResourceTracker.cpp
PR 18107 core/shader/recompiler/Optimization/src/ResourceMaterializer.cpp
core/shader/recompiler/Optimization/src/ResourceTracker.cpp
PR 20248 core/shader/recompiler/Optimization/src/ResourceMaterializer.cpp
core/shader/recompiler/Optimization/src/ResourceTracker.cpp
PR 20519 core/shader/recompiler/Optimization/src/ResourceMaterializer.cpp
core/shader/recompiler/Optimization/src/ResourceTracker.cpp
PR 22424 core/shader/recompiler/Optimization/src/ResourceMaterializer.cpp
core/shader/recompiler/Optimization/src/ResourceTracker.cpp
PR 22690 core/shader/recompiler/Optimization/src/ResourceMaterializer.cpp
PR 22703 core/shader/recompiler/Optimization/src/ResourceMaterializer.cpp

@Colewiz7

Copy link
Copy Markdown
Contributor

Head b2393574c7 merged onto main e825fa1492 as 5a32909ca0, no conflict. Linux 7.3.4, GCC 16.2.1 Release, Mesa 26.2.6 RADV, RX 7900 XT (gfx1100) and 7800X3D iGPU (gfx1036).

No new failures and no new validation messages on either GPU.

RX 7900 XT iGPU
tests run (6356 on the 7900 XT, the 2037 GPU ones on the iGPU), new failures vs main none none
-R '^agc' ( tests) with the layer, new failures vs main none none
VUID- / SYNC-HAZARD lines 0 / 0 0 / 0

Layer runs used VK_LAYER_KHRONOS_validation 1.4.363.1 with VK_LOADER_DEBUG=layer and ANYPS5_REQUIRE_VULKAN=1 ANYPS5_NO_SHADER_CACHE=1; the loader inserted the layer in every run, and the set of distinct validation messages matches main.

AI-assisted: yes

@MarcZX10 MarcZX10 left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

@Script-hpp

Copy link
Copy Markdown
Contributor

Tested on Intel Arc B390 (Mesa 26.2.7 ANV, Linux 7.2.10), PR head b2393574c7 merged into main 8c254da48b, with ANYPS5_REQUIRE_VULKAN=1, ANYPS5_NO_SHADER_CACHE=1, VK_INSTANCE_LAYERS=VK_LAYER_KHRONOS_validation (layer 1.4.341, the loader log shows it inserted) and VK_LOADER_DEBUG=layer:

  • ctest -R '^agc_driver_image_gather_face_on_cube$' -V: 1/1 pass, no VUID- in the log.
  • Control: ImageGatherFaceOnCube.cpp alone on main fails on this device with image descriptor is incompatible with the static runtime image interface: descriptor format 56 decodes to {class 1, dim 5, ..., cube 1, ...}. So the test catches the bug on this device too.

AI-assisted: yes (Claude Code)

@oneandonlydean
oneandonlydean merged commit 1067c6b into boykopovar:main Nov 27, 2026
16 checks passed
oneandonlydean added a commit that referenced this pull request Nov 27, 2026
#23519 added fix-cube-face-gathers.md while fix-shader-cube-face-converted-store.md already changed the same shader entry, so debt_fold --check and the Conventions check fail on main. The merged fragment keeps both changes: gathers and converted stores take the cube-face mode, and the gathers' Functional entry stays.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

agc libSceAgc* docs shader core/shader

Projects

None yet

Development

Successfully merging this pull request may close these issues.

6 participants