You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
fix(shader): accept 3D image stores on 2D T#s - #20792
A DIM 3D image_store through a 2D T# throws today (image descriptor is incompatible with the static runtime image interface): RuntimeImageModes offers a 2D-array runtime mode for a write-only DIM 3D storage image but no 2D mode.
The rule was measured on RDNA2 (gfx1036, Windows driver 31.0.22044.1) in #17807 (evidence gist https://gist.github.com/brumskysb/1dbfc6a1dddebdc046e43762747372ac): a DIM 3D image_store through a 2D T# (8x8 32_FLOAT, image_store v4, v[5:7], s[8:15] dmask:0x1 dim:SQ_RSRC_IMG_3D) writes the lane's (x, y) texel when z is 0 and nothing when z is 1. With all z 0 it wrote all 64 texels and nothing outside the face, with all z 1 it moved 0 dwords, with mixed z it wrote exactly the z 0 lanes, and image_store_mip at mip 0 with z 0 matched. This is the store counterpart of the load rule already in EmitReadOp, and of #9249 for 2D-array T#s.
Change: ResourceMaterializer.cpp (3 lines added) offers a Dim2D mode after the Dim2DArray one for a write-only DIM 3D storage image; the relative order of the existing modes is unchanged and there is no new ImageResource field, so the shader disk cache encoder is untouched. SpirvImageEmitter.cpp (1 line changed) gates EmitWriteOp on z == 0 for a DIM 3D address on a 2D image, as it already does for a 2D-array address on a 1D image. Loads, samples and atomics are unchanged: the unit test still refuses a load+store through a 2D T# and an atomic through a UINT 2D T# whose plain store is accepted. Modes offered for a write-only 3D storage image: 50 on main, 75 here; the limit ImageTableAbi::MaxModes is 256.
Tests: a new execution test ImageStoreVolumeThroughPlane (three legs: all z 0, all z 1, z = lane & 1; 8x8 32_FLOAT 2D T#; expected values come from the rule above, not from the recompiler), a new unit case verifyPlaneVolumeStoreMode, and a debt fragment.
An existing test pinned the old refusal: verifyGuardedDescriptorSources stored through a 2D T# with DIM 3D and expected that to be refused. I repaired it by changing the DIM of that one instruction word (0xf0200f10, DIM 3D, to 0xf0200f20, DIM 1D_ARRAY), not by weakening the assertion; DIM 1D_ARRAY is refused with the same message. Other DIMs tried on this branch: CUBE and 2D_ARRAY are accepted, 2D_MSAA and 1D are refused with a different message. The repair does not depend on this change: with the two recompiler edits reverted and the new unit case removed, agc_shader_memory passes on main's sources.
Not measured and not tested: formats other than 32_FLOAT, multi-component dmasks, mip levels above 0, and a z other than 0 and 1 on a 2D T#. The recompiler applies the same rule to them, and the debt entry says so. The execution test covers image_store only (mip 0, 32_FLOAT, one dmask); image_store_mip shares EmitWriteOp but is measured on hardware at mip 0 only and is not separately tested here.
Debt entry length: the entry grows from 1,225 to 1,450 characters, over the 1,000-character guideline (check_conventions.py reports a warning, 0 errors). It is not trimmed because every sentence carries a measured condition.
Debt entry change, extracted by script from tools/debt_fold.py --show shader against docs/dev/debt/shader.md (the first 1140 characters of the entry are byte-identical; only the closing sentence differs):
Before: The recompiler implements the 2D-array store; a store through a 2D T# keeps throwing.
After: The recompiler implements the store through a 2D-array T#, which drops a layer past the array, and through a 2D T#, which drops every lane whose z is not 0. It applies the same rule to other formats, multi-component dmasks, mip levels above 0 and a z other than 0 and 1 on a 2D T#; none of those is measured.
Overlap: tools/pr_overlap.py fails closed (exit 2): it flags #16260 (ShaderMemory.cpp near line 12620, next to the new unit case) and could not compare 36 PRs that conflict with main. I read the patches of those 36 and of 42 more open PRs that touch ResourceMaterializer.cpp or SpirvImageEmitter.cpp (78 in all, from a snapshot of the open PRs taken 2026-11-15 07:47 MST): none adds a line that combines DIM 3D with a 2D image, and none implements this change. Four title searches found only unrelated PRs. Textual conflicts are possible; a duplicate was not found.
All on Linux (Ubuntu 26.04.1 LTS, kernel 7.0.0-43-generic), Mesa lavapipe (llvmpipe, LLVM 21.1.8, Vulkan 1.4.79, mesa-vulkan-drivers 26.0.8), Khronos validation layer 1.4.363.1, Release build, ANYPS5_REQUIRE_VULKAN=1 ANYPS5_NO_SHADER_CACHE=1 VK_INSTANCE_LAYERS=VK_LAYER_KHRONOS_validation VK_LOADER_DEBUG=layer, ctest -V. The loader line Insert instance layer "VK_LAYER_KHRONOS_validation" is in all 29 Vulkan test logs and was not found but was requested is in none; VUID- lines: 0 in all 40 runs, on main's sources and on the branch (no new ids). Head 229fb74cb4 on main0510af2dcc.
RED, the two recompiler edits reverted, new tests intact: agc_driver_image_store_volume_through_plane fails with image descriptor is incompatible with the static runtime image interface (format 22), and agc_shader_memory fails with the same message from the new unit case.
Repair neutral on main: with the two recompiler edits reverted and the new unit case removed, agc_shader_memory passes.
GREEN on the branch, all seven pass: the new execution test (0.08 s), image_store_volume_through_array, image_store_array_through_volume, image_store_face_on_cube, image_store_line_through_plane, image_store_line_through_plane_array and agc_shader_memory. The five neighbouring execution tests also pass on main.
Mutation control (run on the earlier base 3725323f1f; the rebase touched none of these files): with only the z == 0 gate reverted and the 2D mode kept, the execution test fails with leg B (all z 1): texel (0, 0) with z 1 is 0x3f800000, expected 0xcdcdcdcd. Restored, it passes.
verifyPlaneVolumeStoreMode: a write-only DIM 3D store on a 2D T# selects a Dim2D mode; with read set it is refused; with a UINT 2D T# the store selects Dim2D, and flipping only atomic makes it refused. The unit negatives were not mutation-tested.
tools/debt_fold.py --check: pass. --show shader against docs/dev/debt/shader.md: the final sentence of this entry is the only change of ours (plus one unrelated fragment already on main). tools/check_conventions.py --base origin/main: 0 errors, 1 warning (debt length).
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: llvmpipe (LLVM 21.1.8, 256 bits), Mesa 26.0.8 lavapipe (mesa-vulkan-drivers 26.0.8-1ubuntu0.3, Vulkan 1.4.79), Ubuntu 26.04.1 LTS; the rule itself was measured on gfx1036 (driver 31.0.22044.1) in docs(debt): measure DIM 3D stores through 2D and 2D-array T#s #17807; this test was not run on that hardware
AI-assisted: yes
Summary by CodeRabbit
New Features
3D storage image writes can now use eligible 2D texture views, enabling writes to the matching 2D slice.
Bug Fixes
Writes through a 2D view are now correctly limited to depth coordinate zero; writes from other depth coordinates are dropped.
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.
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.
Result: 2/2 passed (1.34 s), VK_LAYER_KHRONOS_validation inserted on the GPU test, 0 missing layer warnings, 0VUID- errors vs main.
Negative control: Reverting core/shader/recompiler/Optimization/src/ResourceMaterializer.cpp and core/shader/recompiler/SpirvBackend/src/SpirvImageEmitter.cpp to main fails agc_driver_image_store_volume_through_plane (ShaderRecompiler::Recompile: image descriptor is incompatible with the static runtime image interface, exit 8).
Windows + AMD run; I found no AMD run in the description or in the comments. Head 229fb74cb4 merged alone onto main3c07e1d05e with git merge --no-ff (clean merge).
Setup: Windows 11 25H2 (build 26200), AMD Radeon 760M integrated graphics (1002:15bf, Vulkan device name Radeon 5), AMD Software 26.11.2 (driver 32.0.32029.2010, Vulkan 1.4.359), selected with ANYPS5_GPU=Radeon, WinLibs GCC 15.2.0 r7 UCRT, Release, BUILD_TESTING=ON, Khronos validation layer 1.4.363 (LunarG SDK 1.4.363.1). Only the focused test targets were built; the other execution tests were left out with ANYPS5_AGC_EXECUTION_TESTS.
Negative control: with the tests of this PR built on main's sources (without the 2 production files this PR changes), agc_driver_image_store_volume_through_plane does not pass, so on this driver the test detects the change. The failing run logs a ShaderRecompiler::Recompile error, image descriptor is incompatible with the static runtime image interface.
VUID- lines: 0 in the main and PR logs. Every run logs Selected GPU name=Radeon 5 vendor=0x1002 device=0x15bf and Insert instance layer "VK_LAYER_KHRONOS_validation", and none logs was not found but was requested.
AI-assisted: yes (build and runs scripted with an AI assistant, on the hardware above).
Ran the focused tests with the Khronos validation layer on Linux and an NVIDIA GPU, since CI runs the GPU tests only on lavapipe, the Tested section is on lavapipe and the earlier GTX 1660 SUPER run is not of the current head.
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 229fb74cb4 merged onto main fbaae8a79d with --no-ff (clean, as f88c6e767f). Main baseline is a Release build of fbaae8a79d on the same machine.
was not found but was requested by env var VK_INSTANCE_LAYERS
0
0
VUID-
none
none
agc_driver_image_store_volume_through_plane is new and does not exist on main; it passes on this PR. The other agc_driver_image_store* tests pass on both sides; agc_driver_image_store_float_rounding_codegen and agc_shader_memory create no Vulkan device. Every device selected the RTX 4090.
Negative control: with main's ResourceMaterializer.cpp and SpirvImageEmitter.cpp and the rest of this PR, agc_driver_image_store_volume_through_plane fails with ShaderRecompiler::Recompile: image descriptor is incompatible with the static runtime image interface: descriptor format 22 decodes to {class 1, dim 3, ...}, as in the Tested section. With the change restored it passes.
No new VUID- errors; all focused tests pass on Ada.
AI-assisted: yes (Claude Code)
ycbuzi
added a commit
to ycbuzi/AnyPS5
that referenced
this pull request
Nov 20, 2026
The reason will be displayed to describe this comment to others. Learn more.
Reviewed — looks good
Nothing blocks this change; the code read supports the described write-only DIM 3D store behavior through a 2D T#.
What I ran
Reviewed head 229fb74cb46165f3bf166dffc709371a0ab86767. No commands or tests were run by me; the author reports Linux lavapipe tests and a separate RDNA2 hardware measurement. Read description.md, commits.md, diff.patch, manifest.json, and all included changed files. Read the changed lines and relevant context in ShaderMemory.cpp through repo_read.py; that file was excluded from the review folder because of its size. files.json was not available as a review document.
Results
Check
Result
Note
Changed code review
passed
Relevant changed code and test source read
Tests run by reviewer
not run
Author reports passing lavapipe tests
Physical console behavior
not run
Author reports a separate RDNA2 measurement
Findings
Blocking
None.
Non-blocking
None.
Not verified
No tests were run independently. The reported hardware measurement and author-reported test results were not independently confirmed. Only changed-line neighborhoods and relevant context were read for ShaderMemory.cpp, rather than its full text; all added lines in that file were inspected. No other changed file was excluded from reading.
AMD RADV Linux run with the Khronos validation layer (I don't see an RADV run in the thread yet).
Setup: Fedora 44, kernel 7.3.4, GCC 16.2.1, Release. AMD Radeon RX 7700 XT (RADV NAVI32, RDNA3), Mesa 26.2.7, Vulkan 1.4.354, Khronos validation layer 1.4.341. Head 229fb74cb4 merged with --no-ff onto maine481b13555 (clean); the baseline is e481b13555 itself, same build directory and machine.
Command (both arms):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 '<pattern>' -j6 -V, with one pattern covering the tests this PR and nine other shader PRs touch, run on main and on each merge.
agc_driver_image_store_volume_through_plane ran on the RADV device with the layer inserted and passed. The CPU-side tests this PR touches also pass: agc_shader_memory, agc_shader_memory_coherent_atomic_loads and shader_memory_decoder_tolerance. No new validation errors.
Tests check 2D mode selection for float and UINT descriptors, reject read/write and atomic access, and check the mode-count limit. The storeCode fixture changes its second image-store offset.
Execution test and change note core/libs/prx/libSceAgcDriver/tests/execution/ImageStoreVolumeThroughPlane.cpp, docs/dev/debt/changes/*
The execution test checks stores across three depth patterns and verifies that uncovered bytes retain their fill value. The change note records measured behavior and unmeasured cases; an earlier note is removed.
This change lets 3D image stores through a 2D texture descriptor write texels only for lanes with z equal to 0. That behavior was measured on RDNA2 for 32_FLOAT. Other formats, such as 32_UINT, follow the same rule without a hardware measurement, and the change note says so. The change is narrow and tested, so the remaining risk is small and limited to those unmeasured formats.
Security architecture risk: Minimal · up to f42bd
The change allows eligible 3D shader stores to write to an otherwise compatible 2D image, and only when the slice coordinate is zero and the original write condition passes. The review found no new route to write outside the selected image or reuse incompatible cached shaders.
Retained concerns
No architecture-level concerns identified.
Security review details
Security Blast Radius
inferred — The added write reach is to a compatible 2D storage image selected through the existing binding path. The new predicate also applies to other ordinary stores reaching the shared emitter with the same 3D-address and 2D-target pairing, where it can only suppress writes.
Trust Boundaries and Controls
observed — The guest descriptor and guest shader coordinates are checked at different points: the existing runtime selector inspects the descriptor before mode selection, while generated code checks the slice and original predicate before each write. A nonzero slice takes the no-write branch; it is not redirected to slice zero.
Finishing Touches
Generate unit tests (beta)
Create a new PR
Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts
Warning
Some tools did not complete. Review the errors below.
Cppcheck (2.22.0)
Cppcheck (2.22.0) exceeded its 180-second time budget. Findings from completed work are retained; remaining checks are incomplete.
The reason will be displayed to describe this comment to others. Learn more.
Reviewed — looks good
The inspected code implements the described 3D image store through a 2D view and retains the stated restrictions on reads and atomics.
What I ran
Reviewed head f42bd82ad199a3a67122e238ecc2435822df4854 using repo_read.py to inspect the prepared diff and targeted repository code. I did not run commands or tests; test results in the description are author-reported.
Results
Check
Result
Note
Changed implementation
passed
Mode selection and z guard inspected
Tests
not run
Reported results were not independently run
Findings
Blocking
None in the code inspected.
Non-blocking
None.
Not verified
Read changed lines in ResourceMaterializer.cpp, SpirvImageEmitter.cpp, ShaderMemory.cpp, ImageStoreVolumeThroughPlane.cpp, and fix-shader-3d-store-through-2d.md, plus the prepared description, commits, manifest, and diff. fix-volume-samples-on-2d-tsharp.md is deleted and has no new lines to inspect. The full contents of ShaderMemory.cpp and the deleted debt fragment were not read. Tests and hardware behavior were not independently verified; execution on PS5 gfx1013 and unmeasured formats, masks, mip levels, and z values remain unverified.
2434-2436: Minor · Functional Correctness · Quick win
Unverified finding
Verification ran but could not confirm this finding. It is shown for review, not as a verified issue.
Reject formats not settled by the measurement.
A 32_UINT 2D descriptor can select this mode, but the reported measurement covers 32_FLOAT only. Restrict this mode to formats whose behavior is settled. Based on learnings, “Cases the source doesn't settle throw,” and behavior not verified on hardware is recorded in technical debt.
Source: Learnings
Review info
Run configuration
Source mode: Auto
Repository: Unavailable
Branch: Unavailable
File: No configuration file from this repository applied
Commit: Unavailable
Layers: defaults
Review profile: CHILL
Plan: Advanced
Run ID: f8ca6712-fc98-4049-9ccd-15aa3ff77868
Commits
Reviewing files that changed from the base of the PR and between 335fd46 and f42bd82.
Included review availability: This review used your included allowance. Your plan provides up to 10 included reviews per hour; 9 remain after this review.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What
A DIM 3D
image_storethrough a 2D T# throws today (image descriptor is incompatible with the static runtime image interface):RuntimeImageModesoffers a 2D-array runtime mode for a write-only DIM 3D storage image but no 2D mode.The rule was measured on RDNA2 (gfx1036, Windows driver 31.0.22044.1) in #17807 (evidence gist https://gist.github.com/brumskysb/1dbfc6a1dddebdc046e43762747372ac): a DIM 3D
image_storethrough a 2D T# (8x8 32_FLOAT,image_store v4, v[5:7], s[8:15] dmask:0x1 dim:SQ_RSRC_IMG_3D) writes the lane's (x, y) texel when z is 0 and nothing when z is 1. With all z 0 it wrote all 64 texels and nothing outside the face, with all z 1 it moved 0 dwords, with mixed z it wrote exactly the z 0 lanes, andimage_store_mipat mip 0 with z 0 matched. This is the store counterpart of the load rule already inEmitReadOp, and of #9249 for 2D-array T#s.Change:
ResourceMaterializer.cpp(3 lines added) offers aDim2Dmode after theDim2DArrayone for a write-only DIM 3D storage image; the relative order of the existing modes is unchanged and there is no newImageResourcefield, so the shader disk cache encoder is untouched.SpirvImageEmitter.cpp(1 line changed) gatesEmitWriteOpon z == 0 for a DIM 3D address on a 2D image, as it already does for a 2D-array address on a 1D image. Loads, samples and atomics are unchanged: the unit test still refuses a load+store through a 2D T# and an atomic through a UINT 2D T# whose plain store is accepted. Modes offered for a write-only 3D storage image: 50 on main, 75 here; the limitImageTableAbi::MaxModesis 256.Tests: a new execution test
ImageStoreVolumeThroughPlane(three legs: all z 0, all z 1, z = lane & 1; 8x8 32_FLOAT 2D T#; expected values come from the rule above, not from the recompiler), a new unit caseverifyPlaneVolumeStoreMode, and a debt fragment.An existing test pinned the old refusal:
verifyGuardedDescriptorSourcesstored through a 2D T# with DIM 3D and expected that to be refused. I repaired it by changing the DIM of that one instruction word (0xf0200f10, DIM 3D, to 0xf0200f20, DIM 1D_ARRAY), not by weakening the assertion; DIM 1D_ARRAY is refused with the same message. Other DIMs tried on this branch: CUBE and 2D_ARRAY are accepted, 2D_MSAA and 1D are refused with a different message. The repair does not depend on this change: with the two recompiler edits reverted and the new unit case removed,agc_shader_memorypasses on main's sources.Not measured and not tested: formats other than 32_FLOAT, multi-component
dmasks, mip levels above 0, and a z other than 0 and 1 on a 2D T#. The recompiler applies the same rule to them, and the debt entry says so. The execution test coversimage_storeonly (mip 0, 32_FLOAT, onedmask);image_store_mipsharesEmitWriteOpbut is measured on hardware at mip 0 only and is not separately tested here.Debt entry length: the entry grows from 1,225 to 1,450 characters, over the 1,000-character guideline (
check_conventions.pyreports a warning, 0 errors). It is not trimmed because every sentence carries a measured condition.Debt entry change, extracted by script from
tools/debt_fold.py --show shaderagainstdocs/dev/debt/shader.md(the first 1140 characters of the entry are byte-identical; only the closing sentence differs):dmasks, mip levels above 0 and a z other than 0 and 1 on a 2D T#; none of those is measured.Overlap:
tools/pr_overlap.pyfails closed (exit 2): it flags #16260 (ShaderMemory.cppnear line 12620, next to the new unit case) and could not compare 36 PRs that conflict withmain. I read the patches of those 36 and of 42 more open PRs that touchResourceMaterializer.cpporSpirvImageEmitter.cpp(78 in all, from a snapshot of the open PRs taken 2026-11-15 07:47 MST): none adds a line that combines DIM 3D with a 2D image, and none implements this change. Four title searches found only unrelated PRs. Textual conflicts are possible; a duplicate was not found.Evidence (logs, the overlap scripts and their output, the test-bed scripts): https://gist.github.com/brumskysb/0117427a8393feda23e0b69eacc506c5
Tested
All on Linux (Ubuntu 26.04.1 LTS, kernel 7.0.0-43-generic), Mesa lavapipe (llvmpipe, LLVM 21.1.8, Vulkan 1.4.79, mesa-vulkan-drivers 26.0.8), Khronos validation layer 1.4.363.1, Release build,
ANYPS5_REQUIRE_VULKAN=1 ANYPS5_NO_SHADER_CACHE=1 VK_INSTANCE_LAYERS=VK_LAYER_KHRONOS_validation VK_LOADER_DEBUG=layer,ctest -V. The loader lineInsert instance layer "VK_LAYER_KHRONOS_validation"is in all 29 Vulkan test logs andwas not found but was requestedis in none;VUID-lines: 0 in all 40 runs, on main's sources and on the branch (no new ids). Head229fb74cb4onmain0510af2dcc.agc_driver_image_store_volume_through_planefails withimage descriptor is incompatible with the static runtime image interface(format 22), andagc_shader_memoryfails with the same message from the new unit case.agc_shader_memorypasses.image_store_volume_through_array,image_store_array_through_volume,image_store_face_on_cube,image_store_line_through_plane,image_store_line_through_plane_arrayandagc_shader_memory. The five neighbouring execution tests also pass on main.3725323f1f; the rebase touched none of these files): with only the z == 0 gate reverted and the 2D mode kept, the execution test fails withleg B (all z 1): texel (0, 0) with z 1 is 0x3f800000, expected 0xcdcdcdcd. Restored, it passes.verifyPlaneVolumeStoreMode: a write-only DIM 3D store on a 2D T# selects aDim2Dmode; withreadset it is refused; with a UINT 2D T# the store selectsDim2D, and flipping onlyatomicmakes it refused. The unit negatives were not mutation-tested.tools/debt_fold.py --check: pass.--show shaderagainstdocs/dev/debt/shader.md: the final sentence of this entry is the only change of ours (plus one unrelated fragment already on main).tools/check_conventions.py --base origin/main: 0 errors, 1 warning (debt length).Checklist
main; no other open PR implements the same functionsNotImplemented_nid_no_patch); silent stubs are listed under Silent stubs in their library's technical debt file.mdfiles or images added to the repository (attach them to this PR)Summary by CodeRabbit