Skip to content

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

Merged
oneandonlydean merged 2 commits into
boykopovar:mainfrom
brumskysb:fix/shader-3d-store-through-2d
Nov 30, 2026
Merged

oneandonlydean merged 2 commits into
boykopovar:mainfrom
brumskysb:fix/shader-3d-store-through-2d

Conversation

@brumskysb

@brumskysb brumskysb commented Nov 15, 2026 •

Copy link
Copy Markdown
Contributor

What

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.

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 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 main 0510af2dcc.

  • 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.

@github-actions github-actions Bot added shader core/shader docs agc libSceAgc* labels Nov 15, 2026
@github-actions

github-actions Bot commented Nov 15, 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 16260 core/libs/prx/libSceAgcDriver/tests/ShaderMemory.cpp L13459

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/libs/prx/libSceAgcDriver/tests/ShaderMemory.cpp
core/shader/recompiler/Optimization/src/ResourceMaterializer.cpp
core/shader/recompiler/SpirvBackend/src/SpirvImageEmitter.cpp
PR 6235 core/libs/prx/libSceAgcDriver/tests/ShaderMemory.cpp
PR 6280 core/shader/recompiler/Optimization/src/ResourceMaterializer.cpp
core/shader/recompiler/SpirvBackend/src/SpirvImageEmitter.cpp
PR 6412 core/libs/prx/libSceAgcDriver/tests/ShaderMemory.cpp
core/shader/recompiler/Optimization/src/ResourceMaterializer.cpp
PR 6488 core/libs/prx/libSceAgcDriver/tests/ShaderMemory.cpp
core/shader/recompiler/Optimization/src/ResourceMaterializer.cpp
core/shader/recompiler/SpirvBackend/src/SpirvImageEmitter.cpp
PR 7642 core/libs/prx/libSceAgcDriver/tests/ShaderMemory.cpp
core/shader/recompiler/Optimization/src/ResourceMaterializer.cpp
core/shader/recompiler/SpirvBackend/src/SpirvImageEmitter.cpp
PR 7684 core/libs/prx/libSceAgcDriver/tests/ShaderMemory.cpp
core/shader/recompiler/Optimization/src/ResourceMaterializer.cpp
PR 7689 core/shader/recompiler/Optimization/src/ResourceMaterializer.cpp
PR 9356 core/libs/prx/libSceAgcDriver/tests/ShaderMemory.cpp
PR 9387 core/libs/prx/libSceAgcDriver/tests/ShaderMemory.cpp
PR 9508 core/libs/prx/libSceAgcDriver/tests/ShaderMemory.cpp
core/shader/recompiler/SpirvBackend/src/SpirvImageEmitter.cpp
PR 9633 core/shader/recompiler/Optimization/src/ResourceMaterializer.cpp
PR 9749 core/shader/recompiler/Optimization/src/ResourceMaterializer.cpp
PR 9790 core/libs/prx/libSceAgcDriver/tests/ShaderMemory.cpp
PR 9897 core/libs/prx/libSceAgcDriver/tests/ShaderMemory.cpp
PR 9969 core/libs/prx/libSceAgcDriver/tests/ShaderMemory.cpp
core/shader/recompiler/Optimization/src/ResourceMaterializer.cpp
PR 10193 core/libs/prx/libSceAgcDriver/tests/ShaderMemory.cpp
core/shader/recompiler/Optimization/src/ResourceMaterializer.cpp
core/shader/recompiler/SpirvBackend/src/SpirvImageEmitter.cpp
PR 10359 core/libs/prx/libSceAgcDriver/tests/ShaderMemory.cpp
PR 10652 core/shader/recompiler/SpirvBackend/src/SpirvImageEmitter.cpp
PR 10867 core/libs/prx/libSceAgcDriver/tests/ShaderMemory.cpp
core/shader/recompiler/Optimization/src/ResourceMaterializer.cpp
core/shader/recompiler/SpirvBackend/src/SpirvImageEmitter.cpp
PR 11483 core/libs/prx/libSceAgcDriver/tests/ShaderMemory.cpp
PR 11551 core/libs/prx/libSceAgcDriver/tests/ShaderMemory.cpp
core/shader/recompiler/Optimization/src/ResourceMaterializer.cpp
PR 12324 core/libs/prx/libSceAgcDriver/tests/ShaderMemory.cpp
PR 12828 core/libs/prx/libSceAgcDriver/tests/ShaderMemory.cpp
PR 13928 core/libs/prx/libSceAgcDriver/tests/ShaderMemory.cpp
core/shader/recompiler/Optimization/src/ResourceMaterializer.cpp
core/shader/recompiler/SpirvBackend/src/SpirvImageEmitter.cpp
PR 13929 core/libs/prx/libSceAgcDriver/tests/ShaderMemory.cpp
core/shader/recompiler/Optimization/src/ResourceMaterializer.cpp
core/shader/recompiler/SpirvBackend/src/SpirvImageEmitter.cpp
PR 14032 core/libs/prx/libSceAgcDriver/tests/ShaderMemory.cpp
PR 14853 core/shader/recompiler/Optimization/src/ResourceMaterializer.cpp
PR 14944 core/libs/prx/libSceAgcDriver/tests/ShaderMemory.cpp
PR 14964 core/shader/recompiler/SpirvBackend/src/SpirvImageEmitter.cpp
PR 15343 core/libs/prx/libSceAgcDriver/tests/ShaderMemory.cpp
PR 15555 core/libs/prx/libSceAgcDriver/tests/ShaderMemory.cpp
core/shader/recompiler/Optimization/src/ResourceMaterializer.cpp
PR 16935 core/libs/prx/libSceAgcDriver/tests/ShaderMemory.cpp
core/shader/recompiler/SpirvBackend/src/SpirvImageEmitter.cpp
PR 16953 core/shader/recompiler/SpirvBackend/src/SpirvImageEmitter.cpp
PR 17056 core/libs/prx/libSceAgcDriver/tests/ShaderMemory.cpp
PR 17611 core/libs/prx/libSceAgcDriver/tests/ShaderMemory.cpp
PR 18106 core/libs/prx/libSceAgcDriver/tests/ShaderMemory.cpp
core/shader/recompiler/Optimization/src/ResourceMaterializer.cpp
PR 18107 core/libs/prx/libSceAgcDriver/tests/ShaderMemory.cpp
core/shader/recompiler/Optimization/src/ResourceMaterializer.cpp
PR 20030 core/libs/prx/libSceAgcDriver/tests/ShaderMemory.cpp
PR 20111 core/libs/prx/libSceAgcDriver/tests/ShaderMemory.cpp
PR 20153 core/libs/prx/libSceAgcDriver/tests/ShaderMemory.cpp
PR 20248 core/shader/recompiler/Optimization/src/ResourceMaterializer.cpp
core/shader/recompiler/SpirvBackend/src/SpirvImageEmitter.cpp
PR 20519 core/libs/prx/libSceAgcDriver/tests/ShaderMemory.cpp
core/shader/recompiler/Optimization/src/ResourceMaterializer.cpp
core/shader/recompiler/SpirvBackend/src/SpirvImageEmitter.cpp
PR 22071 core/libs/prx/libSceAgcDriver/tests/ShaderMemory.cpp
PR 22424 core/libs/prx/libSceAgcDriver/tests/ShaderMemory.cpp
core/shader/recompiler/Optimization/src/ResourceMaterializer.cpp
core/shader/recompiler/SpirvBackend/src/SpirvImageEmitter.cpp
PR 22647 core/libs/prx/libSceAgcDriver/tests/ShaderMemory.cpp
PR 22675 core/shader/recompiler/Optimization/src/ResourceMaterializer.cpp
PR 22724 core/libs/prx/libSceAgcDriver/tests/ShaderMemory.cpp
core/shader/recompiler/SpirvBackend/src/SpirvImageEmitter.cpp
PR 23157 core/shader/recompiler/Optimization/src/ResourceMaterializer.cpp
core/shader/recompiler/SpirvBackend/src/SpirvImageEmitter.cpp
PR 23243 core/libs/prx/libSceAgcDriver/tests/ShaderMemory.cpp
PR 23244 core/libs/prx/libSceAgcDriver/tests/ShaderMemory.cpp
PR 23553 core/libs/prx/libSceAgcDriver/tests/ShaderMemory.cpp
PR 23632 core/shader/recompiler/SpirvBackend/src/SpirvImageEmitter.cpp
PR 24781 core/shader/recompiler/Optimization/src/ResourceMaterializer.cpp
PR 24906 core/libs/prx/libSceAgcDriver/tests/ShaderMemory.cpp
PR 25010 core/libs/prx/libSceAgcDriver/tests/ShaderMemory.cpp
PR 25660 core/libs/prx/libSceAgcDriver/tests/ShaderMemory.cpp
PR 26365 core/libs/prx/libSceAgcDriver/tests/ShaderMemory.cpp
PR 28142 core/libs/prx/libSceAgcDriver/tests/ShaderMemory.cpp

@gurtgg

gurtgg commented Nov 15, 2026

Copy link
Copy Markdown
Contributor

Tested merged onto upstream/main (e9cfe038c1) on NVIDIA hardware (AI-assisted: yes):

  • GPU / Driver: NVIDIA GeForce GTX 1660 SUPER (595.99.02, Vulkan 1.4.329, Linux Ubuntu 26.04.1)
  • Env: ANYPS5_REQUIRE_VULKAN=1 ANYPS5_NO_SHADER_CACHE=1 VK_INSTANCE_LAYERS=VK_LAYER_KHRONOS_validation VK_LOADER_DEBUG=layer (layer 1.4.341)
  • Command: ctest --test-dir build -R "^(agc_driver_image_store_volume_through_plane|agc_shader_memory)$" -V
  • Result: 2/2 passed (1.34 s), VK_LAYER_KHRONOS_validation inserted on the GPU test, 0 missing layer warnings, 0 VUID- 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).

@rafaconvaitis

Copy link
Copy Markdown
Contributor

Windows + AMD run; I found no AMD run in the description or in the comments. Head 229fb74cb4 merged alone onto main 3c07e1d05e 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.

ANYPS5_REQUIRE_VULKAN=1 ANYPS5_NO_SHADER_CACHE=1 VK_INSTANCE_LAYERS=VK_LAYER_KHRONOS_validation VK_LOADER_DEBUG=layer, ctest -R '^(agc_driver_image_store_volume_through_plane)$' -V -j 1, 3 runs per side.

test main this PR this PR's tests on main's sources (1 run)
agc_driver_image_store_volume_through_plane new test, not in main passes 3/3 fails
  • 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).

@domx4q

domx4q commented Nov 19, 2026

Copy link
Copy Markdown
Contributor

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.

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_image_store|^agc_shader_memory$' -V
main fbaae8a79d this PR
Result 11 of 11 passed 12 of 12 passed
Insert instance layer "VK_LAYER_KHRONOS_validation" 9 10
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)

@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 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.

To get this to a good state

Nothing is required.

@ge9x0

ge9x0 commented Nov 20, 2026

Copy link
Copy Markdown
Contributor

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 main e481b13555 (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.

tests passed Insert instance layer "VK_LAYER_KHRONOS_validation" was not found but was requested VUID-
main 14 14 11 0 0
this PR 15 15 12 0 0

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.

AI-assisted: yes

@coderabbitai

coderabbitai Bot commented Nov 30, 2026 •

Copy link
Copy Markdown

Explain Change →

Walkthrough

Changes: 3D stores through 2D planes

Layer / File(s) Summary
Runtime mode and emitted write condition
core/shader/recompiler/Optimization/src/ResourceMaterializer.cpp, core/shader/recompiler/SpirvBackend/src/SpirvImageEmitter.cpp
Eligible 3D storage writes can use a 2D runtime mode. The emitter requires address component 2 to be zero before writing to a 2D image.
Runtime mode tests
core/libs/prx/libSceAgcDriver/tests/ShaderMemory.cpp
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.

Suggested reviewers: shahulmubeen-a, marczx10, michongoddijn231849

Change: Bug fix

Merge Risk: Low · up to f42bd

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.

core/libs/prx/libSceAgcDriver/tests/ShaderMemory.cpp

Cppcheck interrupted; analysis of this file is incomplete

@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

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.

To get this to a good state

Nothing is required.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Additional comments: 1

core/shader/recompiler/Optimization/src/ResourceMaterializer.cpp-2434-2436: 1

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.

Files selected for processing: 6

  • core/libs/prx/libSceAgcDriver/tests/ShaderMemory.cpp
  • core/libs/prx/libSceAgcDriver/tests/execution/ImageStoreVolumeThroughPlane.cpp
  • core/shader/recompiler/Optimization/src/ResourceMaterializer.cpp
  • core/shader/recompiler/SpirvBackend/src/SpirvImageEmitter.cpp
  • docs/dev/debt/changes/fix-shader-3d-store-through-2d.md
  • docs/dev/debt/changes/fix-volume-samples-on-2d-tsharp.md
Files with no reviewable changes: 1

  • docs/dev/debt/changes/fix-volume-samples-on-2d-tsharp.md

Included review availability: This review used your included allowance. Your plan provides up to 10 included reviews per hour; 9 remain after this review.

@oneandonlydean
oneandonlydean merged commit bea4ceb into boykopovar:main Nov 30, 2026
17 of 19 checks passed
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.

7 participants