feat(shader): implement image_store_pck and image_store_mip_pck #561
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/561"
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 adriadam10 on 2026-10-04T20:47:54Z.
What
Implements the two packed MIMG stores:
image_store_pckandimage_store_mip_pck(gfx10 opcodes 0x0a and 0x0b, numbers fromllvm-mc -mcpu=gfx1013 -show-encoding). They are the store side of #557, and this PR is stacked on it. Only the second commit is new.Behaviour measured on HW
Measured with raw kernels on an RDNA2 iGPU (gfx1035). Each lane stored one texel, and the result was read back from texture memory with
global_load ... glc dlc. Covered: 7 formats (8 uint, 16 sint, 8_8 unorm, 8_8_8_8 uint, 16_16_16_16 sint, 32_32_32 float, 32_32_32_32 float), both ops, dmask 0xf/0x1/0x2/0x5/0xa/0x8. A Python model matched all 2688 cells:igets the next data register when dmask bitiis set, and 0 otherwise. The whole texel is always written, sodmask:0x2on a 64-bit texel writes0and thenv0. Bits past the texel width are dropped, and register dwords past the end of the texel are ignored.32_32_32) are not written at all.Implementation
imageStorepath. The mip form takes one more address component, asimage_store_mipdoes. Both forms setMemoryInfo::imagePacked, soResourceTrackerkeeps them as a separate resource, as it does for the loads.ResourceMaterializernow accepts packed accesses on storage images. Identity dst_sel is still required for sampled ones only, because the hardware ignores it on these stores.PackedTexelFormat.PackedStoreTexel(SPIR-V) builds the texel dwords from dmask, extracts each component's bits at its offset, and writes them through the storage view. It only accepts formats whose bits go through that view unchanged: unsigned integer components, 32-bit float (bitcast), and the raw 32-bit signed integer storage case that already exists. Everything else throws:Tested
Linux (CachyOS), RADV (Mesa 26.2) + lavapipe, and CI's lavapipe (Mesa 25.2.8), cold: 1 s.
agc_driver_image_store_packed_tests(tests/execution/ImageStorePacked.cpp). It covers 10 formats: 8/16 uint, 8_8 uint, 32 sint, 32 float, 16_16 uint, 8_8_8_8 uint, 32_32 uint, 16_16_16_16 uint and 32_32_32_32 float, with 32 lanes.image_store_pckruns with dmask 0xf/0x5/0xa/0x8, one row each.image_store_mip_pck(dmask 0xb) writes level 0 from even lanes and level 1 from odd lanes.0xff8e8900) and a denormal in a 32-bit float texel. Both pass bit-exact on the three drivers. OnlyOpBitcastandOpImageWritetouch them, with no float arithmetic.image_storeagc_driver_pixel_helper_lanes, which also fails on local RADV onmain(since #305).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)Imported from boykopovar/AnyPS5. Originally posted by github-actions[bot] on 2026-10-04T20:48:14Z.
Progress report (
d7f0c49→ef84d7b)📈 GPU shader instructions: 80.79% (+0.52%, +6 implemented instructions)
✅ 6 implemented
IMAGE_LOAD_MIP_PCKIMAGE_LOAD_MIP_PCK_SGNIMAGE_LOAD_PCKIMAGE_LOAD_PCK_SGNIMAGE_STORE_MIP_PCKIMAGE_STORE_PCKImported from boykopovar/AnyPS5. Originally posted by github-actions[bot] on 2026-10-04T21:11:24Z.
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/RdnaDecoder/src/RdnaImageOpDecoder.cppL296-298Imported from boykopovar/AnyPS5. Originally posted by oneandonlydean on 2026-10-04T21:19:46Z.
Thanks. llvm-mc for gfx1013 gives 0x0a and 0x0b for image_store_pck and image_store_mip_pck, LLVM rejects d16 on both, and the decoder refuses d16 for them too. The data path matches your measurement: register DmaskComponentIndex(dmask, i) goes to texel dword i, unselected dwords are written as 0, and the whole texel is always written. I also checked that dropping the swizzle check for storage can't reach a packed load. ImageRead is always a sampled resource and ImageWrite always a storage one, so sampled packed loads still need an identity swizzle.
The accepted set looks right to me: only components whose bits go through the storage view unchanged, with a throw for fields that straddle a dword, normalized formats, f16, narrow signed formats and the 96-bit formats the hardware doesn't write. Existing stores take the same path as before.
Ready to merge from my side once #557 is in.