fix(shader): write 1D storage images through 2D image stores #2348
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/2348"
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 Pipodi on 2026-10-09T16:06:32Z.
What
A compute program of PPSA26344 (Ghost of Yōtei) writes a 1D storage image (T# type 8,
80000fac) withimage_storeDIM 2D. No runtime image mode matched the descriptor:RuntimeImageModesoffers a 3D mode for a 2D access and plain modes for array accesses. For a 2D access on a 1D T# it offered nothing.RuntimeImageModes: a 2D storage image that is only written (not read, not atomic, notimage_store_mip, not packed, BY or depth) gets a 1D mode for each of its numeric modes. The emitter already builds the coordinate from the components the mode's dimension uses, so the store addresses texel x.image_storeDIM 2D through a 1D T# writes texel x. The T# type decides the addressing, and DIM only sets how many address VGPRs are read.EmitWriteOpis unchanged frommain. TechnicalDebt records the measured rule.image_store_mipthrough a 1D T# with DIM 2D still throw, as before. Mip stores are left out because their LOD is taken from the address component after the coordinates, which would move.Related: #2133 and #2140 add 2D modes for 3D accesses (a 2D T# under DIM 3D). This is the same situation one dimension down, for stores, and doesn't overlap their changes.
Tested
Windows 11, MinGW-w64 GCC 15.2.0, RTX 4090 (driver 617.42).
agc_driver_image_store_line_through_plane:image_stores into a 32-texel 1D T#: x = tid with y = 0 and dmask 0xF, then y = 1 with dmask 0x5. This is done for 32_SINT and 32_32_32_32_SINT.image_loadthrough the 1D T# is still refused.0x3c6ef362instead of 0. Without the 1D mode it fails with "image descriptor is incompatible with the static runtime image interface".Checklist
main; no other open PR implements the same functionsNotImplemented_nid_no_patch); silent stubs are listed in TechnicalDebt.mdfiles or images added to the repository (attach them to this PR)🤖 Generated with Claude Code
Imported from boykopovar/AnyPS5. Originally posted by Kikoarl on 2026-10-09T17:27:27Z.
Linux run: Linux 7.2 (x86_64), Intel(R) Graphics (RPL-S) (Mesa 26.3.0-devel, Vulkan 1.4.363), GCC 16.2.1, Release,
-DBUILD_TESTING=ON, #2348 (1716dbe7) tested on currentmain(0fdda7be).tests/agc_driver_image_store_line_through_plane_tests: passes cleanly on Vulkan (device Intel(R) Graphics (RPL-S),image store line through plane tests passed).tools/check_conventions.py: passes cleanly.Imported from boykopovar/AnyPS5. Originally posted by Kikoarl on 2026-10-09T17:52:39Z.
Tested on Linux (CachyOS x86_64, Intel RPL-S iGPU / Mesa 26.3.0-devel / Vulkan 1.4.363, GCC 16.2.1) at
1716dbe7:/tmp/anyps5_build) with zero warnings/errors.python3 tools/check_conventions.py --base origin/main --head HEAD-> PASS (0 errors).ImageStoreLineThroughPlane.cppexecution. Correctly routes 1D image stores via 2D planes for Vulkan drivers that restrict 1D storage image writing.LGTM!
Imported from boykopovar/AnyPS5. Originally posted by Celegans12 on 2026-10-10T01:58:12Z.
Could someone with the native RDNA hardware oracle measure how
image_storewith instruction DIM_2D behaves through a 1D T#? Does it ignore y, check y and discard some writes, or do something else? We have half-float output captures and a separate 1x1 UNORM case with all-zero destination selectors.This would settle the unmeasured store rule in #2348. Our Yotei integration still rejects the incompatible image interface; tolerated diagnostic skips are not successful stores. Vulkan/SPIR-V execution tests, including tests on an AMD Vulkan driver, cannot settle the original instruction's semantics because they execute the emulator's chosen lowering.
Captured instructions and suggested native test
Final candidate 12 reported 154 tolerated dispatch failures at
0x80003d8400and three at0x8000405d00. All seven captured frames were black. We stopped the run for memory pressure at 01:25 UTC on October 10, rather than observing a crash or allocation failure. No fresh descriptor dump was captured at those failing dispatches: the instruction/descriptor pairs below come from saved historical requests and are concrete measurement cases, not confirmed descriptor values for each new failure.The historical descriptors are:
Their fields decode as follows:
The exact instruction/descriptor pairing comes from saved request
415904866eeb6fa2.reqfor shader0x80003d8400, originally captured in the earlierdrv-1run. Its SRT at0x2011723290supplies A at offset0x40and B at0x60; the 16-dword scalar load at shader PC0x7cloads them into s20..s35. The current run identifies the same shader but does not dump its descriptor words; the full descriptors above come from that earlier saved capture.C comes from saved request
486484c9782d82ea.reqfor shader0x8000405d00, captured October 9. Its SRT at0x2014976730supplies C at offset0x40; the load at PC0x54places it in s4..s11. Two other historical requests contain this same 1D variant, while three contain an ordinary 2D output in that slot. Therefore this historical variant is a possible cause of the three new failures, not a fresh-capture attribution. C has a nonzero base address; it is not an ordinary null descriptor. Measured constant-swizzle sampling does not by itself establish storage behavior.0x3c4f0202f08 000500160xf0x3f0f0202308 000700160x30xc8f0202f08 000100070xfAll three decode as plain
image_store(opcode0x08), DIM_2D (encoding 1), A16=0, D16=0, GLC=1, SLC=0, DLC=0, R128=0, TFE=0, LWE=0 and NSA=0. There is no mip/LOD operand; the address uses two 32-bit VGPRs. The raw little-endian bytes are08 2f 20 f0 16 00 05 00for A,08 23 20 f0 16 00 07 00for B, and08 2f 20 f0 07 00 01 00for C. These register identities do not by themselves establish the coordinate values at execution.Please relocate the base address into oracle-owned memory; do not reuse the guest address. Preserve the other descriptor fields and captured instruction controls when testing the captured form, and report any fields or registers changed to make a native control valid. Use DMASK 0xf for A/C and 0x3 for B in the first measurements, and report the assembled bytes after adapting the registers to the oracle harness.
The existing hardware oracle should suffice. Crucially, #2237's native gfx1036 measurement found that DIM_2D
image_loadandimage_sample_lzthrough 1D T#s ignore y, including nonzero y for loads. That differs from #2023's 3D-load/2D-T# result, where nonzero z returns zero. #2237 measured only reads; #1379's native stores use the opposite mismatch direction. These results are why this store needs its own measurement, without assuming either ignored y or discarded writes.Suggested half-float measurement matrix, repeated for A and B:
Use fresh sentinel-filled storage per trial. First write baseline=(1,2,3,4) through the valid native control, then issue the tested store with replacement=(8,16,32,64). These values are exactly representable in half precision. For RG16_FLOAT only the first two stored components matter. A retained baseline texel, a replacement texel and changed guard storage distinguish the competing behaviors. Start with the captured masks above; separately repeat the core y=0/y=1 cases with DMASK 0x5, since #2348's proposed test uses it and missing write components can become zero. The DIM_1D control should use the same mask as its mismatched counterpart.
For C, keep the 1x1 RGBA8_UNORM layout and run this separate matrix twice: first with its captured all-zero selectors (
word3=80000000), then with only those selectors changed to identity (word3=80000fac). Keep DMASK 0xf and GLC=1 in both sets.For each C trial, retain the runner's initial raw sentinel
0xeeeeeeeein the texel and surrounding guards, then issue one tested store with data(1,0,1,0). Repeat with(0,1,0,1). The values are exactly representable UNORM endpoints, distinct from the sentinel. Do not use an image-store baseline for C: if zero selectors force every write to the same value, two image stores could conceal an overwrite. Inspect raw bytes, including both guards. If the native DIM_1D all-zero control itself leaves the sentinel unchanged, report that observation separately; it cannot establish the DIM_2D y rule. The identity-selector controls keep the coordinate question independently observable.An existing-harness setup can return the raw memory without changing the C runner: submit exactly 512 rows in one workgroup, AND the existing EXEC with the comparison v0==0 for stores, and leave it masked for the template's output stores. Do not set EXEC to the literal 1, which would activate one lane in every wave. The runner allocates 512*64 = 32768 output bytes, initialized to 0xee. Put the image at
align_up(output + 256, 256); the template epilogue then writes only the first 64 bytes, leaving image and guards intact. Record the image offset in lane 0's result. That allocation covers the 8192-byte RGBA16_FLOAT image plus the tested y=1/2 row-equivalent guard regions and x=1024; RG16_FLOAT and the separate four-byte C case require less. Keep all 512 result rows so host readback includes those bytes. Use a separate run per case and complete any baseline store before the tested replacement store. The runner's SYSTEM completion fence and host readback supply raw image bytes, avoiding both cross-lane races and an image-load result that could hide an unintended write. Do not use theextra/input allocation as the only observable target: this runner returns output memory, not modified input bytes.Useful result attachment: GPU model/gfx target, driver/HSA and LLVM versions, wave size and every oracle floating-point control, the eight relocated descriptor words, assembled instruction bytes, kernel/rows source, and a table of raw before/after texels and guards for each case. Report the observed behavior, including unchanged memory or writes outside the declared image. RDNA2 gfx103x evidence would answer the immediate question; label it accurately rather than calling it a PS5 measurement.
Imported from boykopovar/AnyPS5. Originally posted by adriadam10 on 2026-10-10T06:02:35Z.
Review: CHANGES_REQUESTED
Measured on RDNA2 (gfx1035) with
tools/hw-oracle, answering @Celegans12's question:image_storewith DIM 2D through a 1D T# (type 8) ignores y. It writes texel x for every y, so the y ≠ 0 drop doesn't match hardware.As with the 3D-on-2D cases in #2023/#2140, the T# type decides the addressing and DIM only sets how many address VGPRs are read. A 1D T# isn't a one-texel-high 2D image.
Requested changes:
SpirvImageEmitter.cpp:987-991: drop they == 0condition. The 1D mode already builds the coordinate from x only, so the store should just write texel x.ImageStoreLineThroughPlane.cpp:165: the test should pin the hardware result. After the y = 1 store with dmask 0x5, texel x holds that store's components 0 and 2, and components 1 and 3 are 0 (unmasked components are zeroed, whichStoreTexelalready does). Keep the "bytes past the texture" check and the refusedimage_load.TechnicalDebt.md:284: replace "dropped otherwise ... not measured" with the measured rule (y ignored, measured on gfx1035), or remove the line if nothing unverified is left.Build, the PR's test and a negative run (the test fails without the change) are fine locally, and there are no conflicts with #2133/#2140.
Imported from boykopovar/AnyPS5. Originally posted by Pipodi on 2026-10-10T06:44:38Z.
@adriadam10 thanks for measuring it. All three are in
601f4a1b:SpirvImageEmitter.cpp: they == 0condition is gone, so the file is back tomain. The 1D mode builds the coordinate from x, so the store writes texel x for any y.ImageStoreLineThroughPlane.cpp: the test pins your result. After the y = 1 store with dmask 0x5, texel x holds that store's components 0 and 2, and components 1 and 3 are 0. The past-the-texture check and the refusedimage_loadstay. With the old condition back, the test fails: texel 0 component 1 reads0x3c6ef362instead of 0.TechnicalDebt.md: the line now gives the measured rule (y ignored, gfx1035) and keeps only the unimplemented loads, atomics andimage_store_mip.Full ctest 508/508 on Windows 11, MinGW-w64 GCC 15.2.0, RTX 4090. The description is updated.
Imported from boykopovar/AnyPS5. Originally posted by adriadam10 on 2026-10-10T07:53:25Z.
Review: APPROVED
Rebased onto current
main(adjacency conflict inResourceMaterializer.cppwith the new 3D→2Dplanemode; both blocks kept, plus one small commit closing a brace).Checked:
agc_driver_image_store_line_through_planepasses on a real Vulkan device after the rebase, fails without theResourceMaterializer.cppchange, and the AgcDriver/Agc ctest scope is green (333/333). The y-ignored rule matches our gfx1035 measurement, and the TechnicalDebt line is in place.Note: #2140 touches the same spot in
RuntimeImageModes; whichever lands second needs a trivial rebase.Merging.
Imported from boykopovar/AnyPS5. Originally posted by adriadam10 on 2026-10-10T07:59:58Z.
Rebased again onto current
main: it conflicted after #2237's 2D→1D T# change (eb06284c7) landed.One small commit added on top:
agc_driver_image_store_line_through_planeasserted that a read-only DIM 2Dimage_loadthrough a 1D T# is refused, whichmainnow accepts. I removed that check (and its unused shader), and the TechnicalDebt line now says storage loads, atomics andimage_store_mipstill throw.Checked: the AgcDriver/Agc ctest scope is green (332/332) with the test passing on a real Vulkan device, and the test still fails without the
ResourceMaterializer.cppchange.Merging once CI is green.
Imported from boykopovar/AnyPS5. Originally posted by Celegans12 on 2026-10-10T12:31:48Z.
Now that #2348 is merged, could you extend the gfx1035 store measurement to
image_store DIM_2D_ARRAYthrough a 1D T#? The measured rule and merged implementation cover ordinary DIM_2D; the array instruction's extra layer operand remains unmeasured.With that store fix applied, our Yōtei run captured a separate array-store interface refusal. The descriptor is non-null, linear 1×1
8_8_8_8_UNORM, with all four destination selectors zero. The instruction uses DMASK0xf, GLC=1, 32-bit x/y/layer coordinates and 32-bit data. All 16 retained requests have zero in a uniform flag that skips this store. That flag remains runtime-loaded, and these snapshots do not establish native behavior when the store executes or the lane values of y and layer.The existing synthetic native probe should need only the array DIM encoding and one additional address VGPR; there is no need for game shader code or request files. Please keep the captured descriptor fields and DMASK, relocate the base into oracle-owned memory, and compare with the same descriptor using identity selectors as a separate control.
Small synthetic measurement matrix
Use T# type8 (
SQ_RSRC_IMG_1D), format56 (8_8_8_8_UNORM), WIDTH=HEIGHT=DEPTH=0 fields (one texel), SW_MODE=0, zero destination selectors. Preserve the remaining captured descriptor fields: word4=0, word5=0x00700000, word6=word7=0; word1 has format bits0x03800000plus only the relocated address bits, word2=0, word3=0x80000000. For the identity-selector control, change only word3 to0x80000fac. Useimage_storewithout mip/LOD, DMASK0xf, GLC=1, A16=D16=NSA=R128=0; report the assembled bytes and any additional flags needed by the harness.0xffffffff0xffffffffUse fresh raw sentinel-filled output and guard storage for each trial, then one store of
(1,0,1,0); repeat with(0,1,0,1). Keep DMASK0xfthroughout this core matrix so missing-component behavior is not mixed with the layer question. Inspect raw memory rather than loading it back through an image instruction, and do not initialize the texel with another image store: that could conceal the all-zero-selector result. Keep only the intended lane active and preserve the existing probe's output-buffer/guard arrangement.Please report the GPU/gfx target, wave size, floating-point controls, relocated eight-word T#, assembled instruction and raw texel/guard results, including unchanged sentinel bytes or unexpected addresses. This asks what the hardware does; it does not assume that either y or layer is ignored.
Imported from boykopovar/AnyPS5. Originally posted by Pipodi on 2026-10-10T12:57:26Z.
@Celegans12 I can't run that probe: I only have an RTX 4090, no RDNA hardware. The gfx1035 measurement in this PR was @adriadam10's, with
tools/hw-oracle. @adriadam10, would you be able to run the DIM_2D_ARRAY matrix above?For context, Yōtei hits it on
0x80002c4500as well. Locally I gave write-only DIM_2D_ARRAY storage accesses the same 1D mode as DIM_2D (x only; y and layer ignored, unmeasured), and the title got past that shader. That's a bring-up workaround until the layer behaviour is measured, not something I'd propose as is.