fix(shader): store through a cube face for 32_SINT, 16_16_FLOAT and 16_16_16_16_FLOAT images #20982

Closed
brumskysb wants to merge 1 commit from upstream-pr/20982 into main
brumskysb commented 2026-11-15 18:57:36 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by brumskysb on 2026-11-15T18:57:36Z.


What

A DIM 2D image_store through a cube T# is refused for images whose format is written through a conversion: 32_SINT (21), 16_16_FLOAT (29) and 16_16_16_16_FLOAT (71). ResourceMaterializer::RuntimeImageModes offers the cube face mode only when conversion == IrBufferFormat::Invalid, and the decode sets conversionFormat for those three storage formats, so the store aborts with image descriptor is incompatible with the static runtime image interface.

The measured rule (RDNA2 gfx1036, driver 31.0.22044.1, #16491, merged as dbf9b788c9; evidence https://gist.github.com/brumskysb/0f2d44c209a50bfbfd23f2a1ac451e86): image_store v4, v[5:6], s[8:15] dmask:0x1 dim:SQ_RSRC_IMG_2D through a cube T# (type 11, DEPTH 11, BASE_ARRAY 0 and 6) writes the 64 texels of the 8x8 face selected by BASE_ARRAY and no other byte of the 64 KiB backing, for 8_8_8_8_UNORM, 8_8_8_8_SNORM, 32_SINT, 16_16_FLOAT, 16_16_16_16_FLOAT and 32_FLOAT. I recounted the dumps twice: with the script that generated the test's tables, and with a second script that parses the literal tables back out of the test source and compares them with the raw 16,384-dword backing (10 format x BASE_ARRAY combinations: 64 dwords moved, 128 for the 8-byte format, 0 outside the face, 0 face dwords untouched, 0 word mismatches; its controls fire). The per-texel words follow the rules the test pins: components outside dmask:0x1 are written as zero, and the 32_SINT store writes the register dword unconverted. The store words the test dispatches (0xf0200108 0x0001141e) disassemble to the measured instruction.

The change is one predicate: the cube face mode is also offered when conversion is Format32SInt, Format16_16Float or Format16_16_16_16Float. The written-not-read, no-atomic, no-dynamic-mips condition (cubeFaceStorage) is unchanged, and the emitter needs no change. Every other conversion format (8_8_8_8_SINT, 16_16_SINT, 16_16_16_16_SINT, 16_FLOAT, the 10_11_11 and 11_11_10 families, 5_6_5 and the other packed formats), atomics, images the program also reads, and mip stores stay refused: they are not measured. The sample decision of the entry does not apply (this is a store).

Tests: ImageStoreFaceOnCube.cpp (existing ctest agc_driver_image_store_face_on_cube) keeps its 32_UINT and 32_FLOAT rows and adds 8_8_8_8_UNORM, 8_8_8_8_SNORM, 32_SINT, 16_16_FLOAT and 16_16_16_16_FLOAT at BASE_ARRAY 0 and 6 with the measured words, the face-landing and nothing-else-changed check, an identical store through a plain 2D T# for each new format, and refusal rows for 8_8_8_8_SINT and 16_FLOAT through a cube T#. ShaderMemory.cpp gets verifyCubeFaceConversionStoreMode (mode selection for the three formats, modes.size() < ImageTableAbi::MaxModes, refusal of three other conversion formats and of an atomic 32_SINT).

Debt: the fragment docs/dev/debt/changes/fix-shader-cube-face-conversion-store.md replaces only the item formats written through a conversion such as 32_SINT in the final sentence of the entry [2D accesses through a cube T#]. The entry was already over the 1,000-character guideline (3,274 characters, 3,384 after); tools/check_conventions.py reports that one debt-length warning and no errors. No measured condition was trimmed.

CHANGE SUMMARY (the only span that differs between the entry on main and the fragment, computed from both texts):

  • before: formats written through a conversion such as 32_SINT
  • after: a format written through a conversion other than the 32_SINT, 16_16_FLOAT and 16_16_16_16_FLOAT dmask:0x1 stores above (every other such format is not measured)

Tested

Linux 7.0.0-43-generic (Ubuntu 26.04.1), lavapipe (llvmpipe (LLVM 21.1.8, 256 bits), Mesa 26.0.8), Khronos validation layer inserted by the loader in every Vulkan run, no was not found but was requested. The rule itself was not run on hardware here. Every log, the scripts and the recount: https://gist.github.com/brumskysb/4a58f73a74293731846c9e7e4111c6bf

  • Head 8d61bef655 rebased on 7085a08145: agc_driver_image_store_face_on_cube (21 rows), agc_driver_image_store_volume_through_array, agc_driver_image_store_array_through_volume, agc_driver_image_store_line_through_plane, agc_driver_image_store_line_through_plane_array and agc_shader_memory all pass, 0 VUID- lines in every log. Main before the change (545e7b64a1): the same tests pass, 0 VUID-.
  • The same head with only ResourceMaterializer.cpp set back to main: agc_driver_image_store_face_on_cube fails on exactly the six cube rows for 32_SINT, 16_16_FLOAT and 16_16_16_16_FLOAT (BASE_ARRAY 0 and 6) with image descriptor is incompatible with the static runtime image interface: descriptor format 21 decodes to {class 2, dim 5, conversion 21, packed 0, cube 1, ...} (29 and 71 likewise); the 32_UINT, 32_FLOAT, 8_8_8_8_UNORM and 8_8_8_8_SNORM cube rows, all five plane control rows and both refusal rows pass. agc_shader_memory fails with the same message. After restoring the source both pass.
  • Mutations of the predicate (run before the rebase, on 545e7b64a1; the rebase changed none of these lines; each restored and proven identical with git diff + cmp): dropping Format32SInt fails only the two 32_SINT rows; dropping Format16_16Float only the two 16_16_FLOAT rows; dropping Format16_16_16_16Float only the two 16_16_16_16_FLOAT rows; removing the conversion condition fails both refusal rows; adding Format16Float fails only the 16_FLOAT refusal row; adding Format8_8_8_8SInt fails only the 8_8_8_8_SINT refusal row. Each of the six also fails agc_shader_memory.
  • tools/debt_fold.py --check exit 0; tools/check_conventions.py --base origin/main: 1 finding (debt-length), 0 errors.
  • Overlap: tools/pr_overlap.py --branch on the commit before the rebase probed 1,593 open PRs, 85 share files with the branch, no line conflict and no same-export row; it exits 2 because 29 old PRs conflict with main itself and their shared files could not be compared. A first run had shown line conflicts with #16260 and #20792 in ShaderMemory.cpp; moving the new test function resolved them. By hand, on a fresh scan with positive and negative controls (in the gist), 48 open PRs touch ResourceMaterializer.cpp or ImageStoreFaceOnCube.cpp and none changes the cube-face predicate; five touch the test file (#7642, #9508, #10193, #13928, #13929: large image-table and descriptor-heap PRs that conflict with main). #19096 (store DST_SEL channel selection) touches the store emitter, not these files; the rows here use the identity DST_SEL with dmask:0x1.
  • Not tested on the PS5 or on gfx1036; the rule itself was measured on gfx1036.

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: lavapipe (llvmpipe (LLVM 21.1.8, 256 bits), Mesa 26.0.8), Linux 7.0.0-43-generic, Ubuntu 26.04.1; the rule itself was measured on gfx1036 (driver 31.0.22044.1) in #16491 and these tests were not run on that hardware
  • AI-assisted: yes
<!-- greyfinch-sync:boykopovar/AnyPS5:issue:5326037404 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/20982). Originally posted by [brumskysb](https://github.com/brumskysb) on 2026-11-15T18:57:36Z. --- ### What A DIM 2D `image_store` through a cube T# is refused for images whose format is written through a conversion: `32_SINT` (21), `16_16_FLOAT` (29) and `16_16_16_16_FLOAT` (71). `ResourceMaterializer::RuntimeImageModes` offers the cube face mode only when `conversion == IrBufferFormat::Invalid`, and the decode sets `conversionFormat` for those three storage formats, so the store aborts with `image descriptor is incompatible with the static runtime image interface`. The measured rule (RDNA2 gfx1036, driver 31.0.22044.1, #16491, merged as dbf9b788c9; evidence https://gist.github.com/brumskysb/0f2d44c209a50bfbfd23f2a1ac451e86): `image_store v4, v[5:6], s[8:15] dmask:0x1 dim:SQ_RSRC_IMG_2D` through a cube T# (type 11, DEPTH 11, BASE_ARRAY 0 and 6) writes the 64 texels of the 8x8 face selected by `BASE_ARRAY` and no other byte of the 64 KiB backing, for 8_8_8_8_UNORM, 8_8_8_8_SNORM, 32_SINT, 16_16_FLOAT, 16_16_16_16_FLOAT and 32_FLOAT. I recounted the dumps twice: with the script that generated the test's tables, and with a second script that parses the literal tables back out of the test source and compares them with the raw 16,384-dword backing (10 format x BASE_ARRAY combinations: 64 dwords moved, 128 for the 8-byte format, 0 outside the face, 0 face dwords untouched, 0 word mismatches; its controls fire). The per-texel words follow the rules the test pins: components outside `dmask:0x1` are written as zero, and the 32_SINT store writes the register dword unconverted. The store words the test dispatches (`0xf0200108 0x0001141e`) disassemble to the measured instruction. The change is one predicate: the cube face mode is also offered when `conversion` is `Format32SInt`, `Format16_16Float` or `Format16_16_16_16Float`. The written-not-read, no-atomic, no-dynamic-mips condition (`cubeFaceStorage`) is unchanged, and the emitter needs no change. Every other conversion format (8_8_8_8_SINT, 16_16_SINT, 16_16_16_16_SINT, 16_FLOAT, the 10_11_11 and 11_11_10 families, 5_6_5 and the other packed formats), atomics, images the program also reads, and mip stores stay refused: they are not measured. The sample decision of the entry does not apply (this is a store). Tests: `ImageStoreFaceOnCube.cpp` (existing ctest `agc_driver_image_store_face_on_cube`) keeps its 32_UINT and 32_FLOAT rows and adds 8_8_8_8_UNORM, 8_8_8_8_SNORM, 32_SINT, 16_16_FLOAT and 16_16_16_16_FLOAT at BASE_ARRAY 0 and 6 with the measured words, the face-landing and nothing-else-changed check, an identical store through a plain 2D T# for each new format, and refusal rows for 8_8_8_8_SINT and 16_FLOAT through a cube T#. `ShaderMemory.cpp` gets `verifyCubeFaceConversionStoreMode` (mode selection for the three formats, `modes.size() < ImageTableAbi::MaxModes`, refusal of three other conversion formats and of an atomic 32_SINT). Debt: the fragment `docs/dev/debt/changes/fix-shader-cube-face-conversion-store.md` replaces only the item `formats written through a conversion such as 32_SINT` in the final sentence of the entry [2D accesses through a cube T#]. The entry was already over the 1,000-character guideline (3,274 characters, 3,384 after); `tools/check_conventions.py` reports that one `debt-length` warning and no errors. No measured condition was trimmed. CHANGE SUMMARY (the only span that differs between the entry on main and the fragment, computed from both texts): - before: `formats written through a conversion such as 32_SINT` - after: `a format written through a conversion other than the 32_SINT, 16_16_FLOAT and 16_16_16_16_FLOAT `dmask:0x1` stores above (every other such format is not measured)` ### Tested Linux 7.0.0-43-generic (Ubuntu 26.04.1), lavapipe (`llvmpipe (LLVM 21.1.8, 256 bits)`, Mesa 26.0.8), Khronos validation layer inserted by the loader in every Vulkan run, no `was not found but was requested`. The rule itself was not run on hardware here. Every log, the scripts and the recount: https://gist.github.com/brumskysb/4a58f73a74293731846c9e7e4111c6bf - Head `8d61bef655` rebased on `7085a08145`: `agc_driver_image_store_face_on_cube` (21 rows), `agc_driver_image_store_volume_through_array`, `agc_driver_image_store_array_through_volume`, `agc_driver_image_store_line_through_plane`, `agc_driver_image_store_line_through_plane_array` and `agc_shader_memory` all pass, 0 `VUID-` lines in every log. Main before the change (`545e7b64a1`): the same tests pass, 0 `VUID-`. - The same head with only `ResourceMaterializer.cpp` set back to main: `agc_driver_image_store_face_on_cube` fails on exactly the six cube rows for 32_SINT, 16_16_FLOAT and 16_16_16_16_FLOAT (BASE_ARRAY 0 and 6) with `image descriptor is incompatible with the static runtime image interface: descriptor format 21 decodes to {class 2, dim 5, conversion 21, packed 0, cube 1, ...}` (29 and 71 likewise); the 32_UINT, 32_FLOAT, 8_8_8_8_UNORM and 8_8_8_8_SNORM cube rows, all five plane control rows and both refusal rows pass. `agc_shader_memory` fails with the same message. After restoring the source both pass. - Mutations of the predicate (run before the rebase, on `545e7b64a1`; the rebase changed none of these lines; each restored and proven identical with `git diff` + `cmp`): dropping Format32SInt fails only the two 32_SINT rows; dropping Format16_16Float only the two 16_16_FLOAT rows; dropping Format16_16_16_16Float only the two 16_16_16_16_FLOAT rows; removing the conversion condition fails both refusal rows; adding Format16Float fails only the 16_FLOAT refusal row; adding Format8_8_8_8SInt fails only the 8_8_8_8_SINT refusal row. Each of the six also fails `agc_shader_memory`. - `tools/debt_fold.py --check` exit 0; `tools/check_conventions.py --base origin/main`: 1 finding (`debt-length`), 0 errors. - Overlap: `tools/pr_overlap.py --branch` on the commit before the rebase probed 1,593 open PRs, 85 share files with the branch, no line conflict and no same-export row; it exits 2 because 29 old PRs conflict with main itself and their shared files could not be compared. A first run had shown line conflicts with #16260 and #20792 in `ShaderMemory.cpp`; moving the new test function resolved them. By hand, on a fresh scan with positive and negative controls (in the gist), 48 open PRs touch `ResourceMaterializer.cpp` or `ImageStoreFaceOnCube.cpp` and none changes the cube-face predicate; five touch the test file (#7642, #9508, #10193, #13928, #13929: large image-table and descriptor-heap PRs that conflict with main). #19096 (store DST_SEL channel selection) touches the store emitter, not these files; the rows here use the identity DST_SEL with `dmask:0x1`. - Not tested on the PS5 or on gfx1036; the rule itself was measured on gfx1036. ### 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) 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: lavapipe (`llvmpipe (LLVM 21.1.8, 256 bits)`, Mesa 26.0.8), Linux 7.0.0-43-generic, Ubuntu 26.04.1; the rule itself was measured on gfx1036 (driver 31.0.22044.1) in #16491 and these tests were not run on that hardware - [x] AI-assisted: yes
MarcZX10 commented 2026-11-20 12:58:29 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-11-20T12:58:29Z.

Review: APPROVED


Reviewed — looks good

Nothing blocks this change; the implementation and included test coverage support the measured cube-face store cases.

What I ran

Reviewed head 8d61bef655fd6a55c8cb312be1eac6b71a667a11. Read the prepared description, commit summary, manifest, diff, and changed source context through repo_read.py. I ran no commands or tests.

Results

Check Result Note
Source review passed All changed files reviewed
Tests not run Relied on author-reported results

Findings

Blocking

None.

Non-blocking

None.

Not verified

I did not run the test suite or independently verify the hardware measurements and author-reported test results. The changed files read were core/libs/prx/libSceAgcDriver/tests/ShaderMemory.cpp, core/libs/prx/libSceAgcDriver/tests/execution/ImageStoreFaceOnCube.cpp, core/shader/recompiler/Optimization/src/ResourceMaterializer.cpp, and docs/dev/debt/changes/fix-shader-cube-face-conversion-store.md. All files listed as reviewed in files.json were read; none was excluded by rule.

To get this to a good state

Nothing is required.

<!-- greyfinch-sync:boykopovar/AnyPS5:review:5993060085 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/20982#pullrequestreview-5993060085). Originally posted by [MarcZX10](https://github.com/MarcZX10) on 2026-11-20T12:58:29Z. **Review:** APPROVED --- # Reviewed — looks good Nothing blocks this change; the implementation and included test coverage support the measured cube-face store cases. ## What I ran Reviewed head `8d61bef655fd6a55c8cb312be1eac6b71a667a11`. Read the prepared description, commit summary, manifest, diff, and changed source context through `repo_read.py`. I ran no commands or tests. ## Results | Check | Result | Note | |---|---|---| | Source review | passed | All changed files reviewed | | Tests | not run | Relied on author-reported results | ## Findings ### Blocking None. ### Non-blocking None. ## Not verified I did not run the test suite or independently verify the hardware measurements and author-reported test results. The changed files read were `core/libs/prx/libSceAgcDriver/tests/ShaderMemory.cpp`, `core/libs/prx/libSceAgcDriver/tests/execution/ImageStoreFaceOnCube.cpp`, `core/shader/recompiler/Optimization/src/ResourceMaterializer.cpp`, and `docs/dev/debt/changes/fix-shader-cube-face-conversion-store.md`. All files listed as reviewed in `files.json` were read; none was excluded by rule. ## To get this to a good state Nothing is required.

Pull request closed

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!20982
No description provided.