fix(shader): store through DIM 2D image_store to a cube T#'s BASE_ARRAY face #6799
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/6799"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Imported from boykopovar/AnyPS5. Originally posted by milescoviello on 2026-10-16T12:28:28Z.
What
A compute shader in Crimson Desert (PPSA25286, 01.000.568) writes a cube map through DIM 2D
image_stores and stops recompiling:The T# is a 256x256 16_16_16_16_FLOAT cube (
TYPE11,DEPTH5,BASE_ARRAY0) with one level. The program runs 8x8 threads per group, reads 2D images and writes its results withimage_store(0xf0200f08and0xf0200108, DIM 2D, no mip). #4139 already reads a cube T# through a DIM 2Dimage_loador sample as theBASE_ARRAYface, measured on RDNA1. A store had no such mode.How
ResourceTracker: a mip-lessImageWritekeepscubeFaceCompatible.ResourceMaterializer: the face mode (the 2D-array cube view) is added for an image the program only stores to, as well as for reads. Its integer coordinates are (x, y, 0), and the storage view starts atBASE_ARRAY, so the store writes texel (x, y) of theBASE_ARRAYface, the face the measured load reads.DEPTH11) withBASE_ARRAY0 and 6, in wave32 and wave64, write texel (x, y) of that face and leave every other byte of the 64 KiB backing unchanged. That is the same layout and the same every-other-byte checkagc_driver_image_store_face_on_cubemakes. simonbbby then measured this title's 16_16_16_16_FLOAT the same way. Four-channel stores of exactly representable half values pass 20 of 20 dispatches (BASE_ARRAY0 and 6, wave32 and wave64), and only the 64 stored eight-byte texels change in the backing. The debt entry records both measurements (273675b68), says that other formats and the title's own 256x256 tiled descriptor are not measured, and lists what still throws: atomics, an image the program also reads, formats written through a conversion such as 32_SINT, and mip loads and stores.Tested
Linux (Ubuntu 24.04, GCC 13.3, Release), RTX 4070 Ti, NVIDIA 595.99.
agc_driver_image_store_face_on_cube(new, GPU): 64 threads store their value at (tid & 7, tid >> 3) into an 8x8 cube array T# (DEPTH11) withBASE_ARRAY0 and 6, for 32_UINT and 32_FLOAT. Every texel of that face must hold its thread's value, and every other byte of the 12 faces must be unchanged. Withmain'sResourceTracker.cppandResourceMaterializer.cppit fails 3 of 3 with the error above (descriptor format 20 decodes to {class 2, dim 5, ..., cube 1, ...}). With this change it passes 3 of 3.agc_driver_image_plane_address_on_cube,agc_driver_image_store_line_through_plane,agc_driver_image_store_array_through_volume: 3 of 3.^agc_driver_|^agc_vertex_barrier|recompiler|shader_cache|request_serializer|spirv|^agc_shader|bda|journal, 502 tests) onmaineb901bcf4: 500 pass.agc_driver_store_over_untrackedfails the same way onmain(#6385 addresses it), and so doesagc_driver_graphicsin a case #5804 added (#6789 fixes it).Crimson Desert (PPSA25286, 01.000.568), 900 s limit, 16 GiB cap, scripted pad input. On
mainthe title stops 14 s in (#6612), so these runs use my test stack: #6612, #6613, #6706, #6708, #6748, #6178 and #6785.SrtWalker::EvaluateRuntimeSourcesrefusal in another compute shaderRebased onto
main82ddae75b(d697c92ec): the four cube and volume store tests pass 3 of 3, and the 502 area tests pass exceptmain'sagc_driver_graphics(#6792) andagc_driver_store_over_untracked(#6385).Not checked on Windows or on a console. On AMD, only the oracle measurement above was run, not this emulator build.
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)🤖 Generated with Claude Code
Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-10-16T12:31:53Z.
The regression proves the emulator’s selected Vulkan view writes the requested face, but the PR explicitly says the corresponding guest
image_storebehavior was not measured. Theimage_loadresult from #4139 does not by itself establish store semantics or format behavior. Could you attach a hardware-oracle measurement for DIM 2D storage writes (especiallyBASE_ARRAY0 and 6, with the supported UINT/FLOAT formats), or otherwise keep this behavior gated/refused until that contract is established? I would not treat the emulator-side expected values alone as proof of guest equivalence.Imported from boykopovar/AnyPS5. Originally posted by github-actions[bot] on 2026-10-16T12:35:07Z.
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.
main)core/shader/recompiler/Optimization/src/ResourceTracker.cppL1803docs/dev/debt/shader.mdL57-58Some 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.
core/shader/recompiler/Optimization/src/ResourceMaterializer.cppcore/shader/recompiler/Optimization/src/ResourceMaterializer.cppdocs/dev/debt/shader.mdcore/shader/recompiler/Optimization/src/ResourceMaterializer.cppdocs/dev/debt/shader.mddocs/dev/debt/shader.mddocs/dev/debt/shader.mddocs/dev/debt/shader.mddocs/dev/debt/shader.mddocs/dev/debt/shader.mddocs/dev/debt/shader.mdcore/shader/recompiler/Optimization/src/ResourceMaterializer.cppcore/shader/recompiler/Optimization/src/ResourceTracker.cppdocs/dev/debt/shader.mddocs/dev/debt/shader.mddocs/dev/debt/shader.mdcore/shader/recompiler/Optimization/src/ResourceMaterializer.cppcore/shader/recompiler/Optimization/src/ResourceMaterializer.cppdocs/dev/debt/shader.mddocs/dev/debt/shader.mdcore/shader/recompiler/Optimization/src/ResourceMaterializer.cppcore/shader/recompiler/Optimization/src/ResourceTracker.cppdocs/dev/debt/shader.mdcore/shader/recompiler/Optimization/src/ResourceMaterializer.cppcore/shader/recompiler/Optimization/src/ResourceTracker.cppdocs/dev/debt/shader.mddocs/dev/debt/shader.mddocs/dev/debt/shader.mdcore/shader/recompiler/Optimization/src/ResourceMaterializer.cppcore/shader/recompiler/Optimization/src/ResourceTracker.cppdocs/dev/debt/shader.mddocs/dev/debt/shader.mddocs/dev/debt/shader.mddocs/dev/debt/shader.mdcore/shader/recompiler/Optimization/src/ResourceMaterializer.cppcore/shader/recompiler/Optimization/src/ResourceTracker.cppcore/shader/recompiler/Optimization/src/ResourceMaterializer.cppcore/shader/recompiler/Optimization/src/ResourceTracker.cppcore/shader/recompiler/Optimization/src/ResourceMaterializer.cppImported from boykopovar/AnyPS5. Originally posted by milescoviello on 2026-10-16T12:35:47Z.
That's fair: the test only shows that the Vulkan view I chose writes the face I expect, not what the hardware writes. I don't have an RDNA GPU here, so I can't run the oracle myself, and this PR shouldn't merge on the analogy to #4139 alone. I'll leave it waiting for a measurement rather than add an opt-in gate, since a gate that stays off would leave the title stopping either way.
To make the measurement quick for anyone with an RDNA2 card (or @billythemenace2, who measured #4139), here is an oracle kernel and runner. Each of 64 lanes stores its value at (x, y) = (lane & 7, lane >> 3) through a DIM 2D
image_storeto an 8x8 cube array T# (DEPTH11,BASE_ARRAY0 or 6, 32_UINT or 32_FLOAT). It then reads all 12 slices back through a 2D-array view of the same memory, so only the hardware's own addressing is involved. It hasn't been assembled here, because this machine has no AMDGPU toolchain, so the syntax may need a touch.cube_store_body.scube_store_run.py(python3 cube_store_run.py <AnyPS5 checkout>)If the hardware writes texel (x, y) of the
BASE_ARRAYface and leaves the other 11 alone, every printed run hasbase_face_holds_values: trueand only that face differs from the fill pattern. I'll pin the measured rows inagc_driver_image_store_face_on_cube. If it writes somewhere else, I'll change the mode to match or close this PR.AI-assisted: yes
Imported from boykopovar/AnyPS5. Originally posted by simonbbby on 2026-10-16T14:24:55Z.
Measured the requested DIM 2D
image_storeon real gfx1036: it writes theBASE_ARRAYface in these UINT/FLOAT cases, includingBASE_ARRAY=6.Hardware/toolchain: AMD gfx1036, PCI
1002:13c0, Ryzen 9 9950X iGPU; Ubuntu 24.04, amdgpu kernel7.0.0-38-generic, ROCr/HSA5.7.1-2build1, clang/LLD 18.1.3. This is an RDNA2 measurement, not PS5/gfx1013 evidence. PR head checked:4ffb8bcf47d2171eb8fb7716c4d43a50fa6b1efe.I ran your posted assembly without syntax changes, with 64 rows and the 64 KiB pattern-filled
extra, through the existing oracle. Only the runner's module/body paths were adapted. Explicit controls for every run:ieee=0,dx10_clamp=0,denorm32=3,denorm16=3,round32=0,round16=0,fp16_overflow=0. Fine-grained memory, default 4096-byte LDS.For every dispatch, all 64 texels on the selected face equal the input bits
0x3f000000 + lane*0x1357; each of the other 704 texels read through the 12-slice view matches a corresponding no-store baseline. Those baselines contain none of the expected stored values at the target positions.I also checked the backing memory independently of the image-load descriptor: after the store/wait/barrier/cache invalidation, replace the image reads with
global_load_dwordx4reads from the extra-buffer address. Each lane reads 16 consecutive dwords atchunk*4096 + lane*64, for 16 fresh 64-lane dispatches covering the complete 64 KiB. For each of the four format/base combinations, exactly 64 dwords change and every other byte, including row/slice padding, is unchanged. The no-store raw control reproduces the entire original buffer.Exact rows to pin (
lane=0..63):(value, x, y, base) = (0x3f000000 + lane*0x1357, lane&7, lane>>3, base). For this descriptor's linear-aligned layout, raw dword indexbase*512 + y*64 + xholdsvalue; every other dword retains0xa5a50000 | index. Thus the measured row pitch is 256 bytes and slice stride 2048 bytes. The image readback's target face isbase, not always face zero. Both observation paths agree.These controls rule out a missing store, a BASE_ARRAY-ignored store and an apparent result caused only by the readback view. Assembly SHA-256:
a22fa915ce0a4513789e0fef3d9735121bd65f38160b879a20517b761761c943(the body in your comment, extracted with its trailing newline). Raw per-lane rows and full readbacks are retained locally.Limits: the supplied 8x8, 12-slice, mip-less descriptors, formats 20/22 and the finite value bits above. No atomics, other formats (including the title's 16_16_16_16_FLOAT), mip behavior, PS5 measurement, emulator build or Crimson Desert replay. This establishes the requested face-selection/store behavior on gfx1036; it does not validate those other paths.
Imported from boykopovar/AnyPS5. Originally posted by milescoviello on 2026-10-16T14:33:06Z.
Thank you @simonbbby, that is exactly the measurement this needed, and the raw-buffer check that only the 64 target dwords change rules out more than I asked for.
@MarcZX100: with that, the store path is no longer unmeasured for the case the test pins. On RDNA2 (gfx1036, not the PS5's gfx1013), a DIM 2D
image_storethrough 8x8 mip-less cube arrays of 32_UINT and 32_FLOAT, withBASE_ARRAY0 and 6, wave32 and wave64, writes texel (x, y) of theBASE_ARRAYface and nothing else. That is the layoutagc_driver_image_store_face_on_cubeexpects. I rebased ontomain82ddae75band changed the debt entry to say what was measured, linking simonbbby's comment (d697c92ec). It still says that other formats, including the title's 16_16_16_16_FLOAT, are not measured. The throws for atomics, read-and-store, conversion formats and mips are unchanged. The new head passes the four cube/volume store tests 3 of 3 and the 502 area tests pass except the two that fail onmain(#6792, #6385).AI-assisted: yes
Imported from boykopovar/AnyPS5. Originally posted by simonbbby on 2026-10-16T20:24:20Z.
Adding FORMAT 71 / 16_16_16_16_FLOAT to the gfx1036 measurement, since the current description explicitly leaves the title's format unmeasured. Head refreshed:
d697c92ecfbf4cde5f147712eeb10431ca035d1a.Same native RDNA2 oracle setup as the earlier result: gfx1036, Ubuntu 24.04, kernel 7.0.0-38, ROCr 5.7.1, clang/LLD 18.1.3. Controls:
ieee=0,dx10_clamp=0,denorm32=3,denorm16=3,round32=0,round16=0,fp16_overflow=0; fine-grained memory, 4096-byte LDS.Kept the supplied 8×8 mip-less cube-array descriptors, TYPE 11, DEPTH 11, BASE_ARRAY 0 or 6, and the 64 KiB patterned backing. Changed FORMAT_BITS to
0xc4700000and the store to four channels:Rows use
v4=0x3f000000 + lane*0x20000,x=lane&7,y=lane>>3. Thus the RGBA values are (0.5 + lane/128, -2, 4, 0.25), all exactly representable in binary16. Expected half words are(0x3800 + lane*16, 0xc000, 0x4400, 0x3400); I independently checked these with Python's IEEE-halfstruct.pack('<4e', ...).image_loadof all four channels expands every target texel back to the exact four input f32 bit patterns. No-store image baselines do not contain those payloads.global_load_dwordx4snapshots cover the complete 64 KiB, without using image-load addressing. All four base/wave combinations match the expected half words at byte offsetbase*2048 + y*256 + x*8, and every other byte remains unchanged, including padding. Exactly 128 dwords change (64 eight-byte RGBA texels). Raw no-store controls preserve the entire backing in both wave sizes.The generated store-prefix assembly SHA-256 is
daf66e09cd1d38f4e82d420bfec3160af1de8d942a64f84fbf9ed2b6c977f023; scripts, raw image rows and all four full backing snapshots are retained locally.Scope: this adds the four-channel half-float format with these finite, exactly representable values and this linear-aligned geometry. It does not measure the title's full 256×256 tiled descriptor, exceptional/rounding-edge values, mips, atomics, PS5/gfx1013 or an emulator/title run. No repository source changed.
Imported from boykopovar/AnyPS5. Originally posted by milescoviello on 2026-10-16T20:26:12Z.
Added this to the description and to the debt entry (273675b68): the debt entry no longer lists 16_16_16_16_FLOAT as unmeasured, and still names the title's 256x256 tiled descriptor as unmeasured.
AI-assisted: yes
Imported from boykopovar/AnyPS5. Originally posted by adriadam10 on 2026-10-19T13:05:26Z.
Checked the diff: the tracker only keeps the cube-face mode for mip-less
ImageWrite, and the materializer adds it only for images the program stores to without reading, atomics or dynamic mips, and without conversion or packed formats, so everything else still throws. The new test pins texel (x, y) of theBASE_ARRAYface for 32_UINT and 32_FLOAT, base 0 and 6, and every other byte unchanged; onmainthe descriptor is rejected. The debt entry matches the code and the RDNA2 oracle measurements from @simonbbby (gfx1036; not the PS5's gfx1013), which satisfy the earlier request for hardware evidence; merged.