fix(shader): read cube T#s through DIM 2D image_sample and image_load as face 0 #5509
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/5509"
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 billythemenace2 on 2026-10-13T21:45:51Z.
What
Before: a DIM 2D
image_sampleorimage_loadbound to a cube T# had no runtime image mode. The draw threw "image descriptor is incompatible with the static runtime image interface ... {class 1, dim 5, ..., cube 1, ...}". This is shape 2 of #4139: High on Life (PPSA15388) samples a 32x32 cube placeholder throughdim:SQ_RSRC_IMG_2D.After: these accesses get a cube mode, the one DIM CUBE accesses already use, with face coordinate 0. Sampling sees the
BASE_ARRAYface of the cube's 2D-array view at (u - 1, v - 1). A load reads texel (x, y) of that face. The mode is offered only when every access isimage_sample_lz, plainimage_sample,image_sample_lor a mip-lessimage_load; other DIM 2D accesses on a cube T# still throw. Shape 1 of #4139 (a non-image descriptor in an image slot) is not addressed here.Hardware semantics, measured on RDNA1 (gfx1010, AMD Radeon RX 5700 XT) with the
tools/hw-oracletemplate. The kernels were assembled with the Windows driver'samd_comgr_2.dlland launched with its HIP runtime. The cubes were 8x8 and 32x32 32_FLOAT, withDEPTH5 and 11 andBASE_ARRAY0 and 6, and every texel holds its own word index.image_sample_lzequals DIM CUBEimage_sample_lzwith face coordinate 0 on every row. That covers point and bilinear filters, wrap, clamp and mirror addressing,DISABLE_CUBE_WRAP0 and 1, and coordinates from -1 to 4. The same holds for plainimage_sample(one level, and six levels in 2x2 compute quads with steps of 1-32 texels) andimage_sample_l(the third address VGPR is the LOD, integer and fractional). Explicit LOD matched 24/24 rows and implicit LOD 24/24.BASE_ARRAYface.floor((u - 1) * width).image_loadreads texel (x, y) of theBASE_ARRAYface, the same word as a DIM 2D load on a 2D T# for base 0.The measurement write-up is attached.
measurement-results-cube-2d-gfx1010.md
Outside the face the translation follows the DIM CUBE path and samples the 2D-array view with the S# addressing. That matches the hardware only inside [1, 2). On the hardware:
DISABLE_CUBE_WRAPsetting measured;DISABLE_CUBE_WRAP0, a coordinate of 2 or more clamps to the last texel (point filter), and bilinear filtering blends texels of the neighbouring faces at the edges;DISABLE_CUBE_WRAP1, a coordinate of 2 or more follows the S# addressing.This is recorded in technical debt, together with the accesses that still throw.
Tested
agc_driver_image_plane_address_on_cuberuns DIM 2Dimage_sample_lz,image_sample_l, plainimage_sampleandimage_loadon an 8x8 32_FLOAT cube (six faces) over 32 lanes. The same kernel semantics ran on the RX 5700 XT through the oracle, and its expected values matched all 32 lanes. The test passes. Without the change it fails with the error above.ctest -R "image_|shader_memory|disk_cache|runtime_images|cube|sampl|emulated_color_compare": no test fails that does not also fail on unchangedmain(dacd78525) on this machine.python3 tools/check_conventions.py --base origin/mainpasses.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)Imported from boykopovar/AnyPS5. Originally posted by xXPBSXx on 2026-10-13T23:47:55Z.
Windows test of #5509: Windows 10 (19045), MinGW-w64 GCC 15.2, Release,
ninja -j 4, ctest called directly. Tree:maind1670009f+ merge ofda58289f0ea7e540caf3c2baced8d8f7bd586ae6(local merge799a8b817).Six ctest targets, 3 runs each, exit code 0 in every run (18 of 18):
agc_driver_image_plane_address_on_cube(the new test of this PR),agc_driver_image_plane_address_on_line,agc_driver_image_plane_address_on_line_implicit_lod,agc_driver_image_sample_cube_derivatives,agc_driver_vop3_cube_clamp,agc_shader_disk_cache.Additional run, same
maind1670009f+ the same PR head (local merge27519610d):agc_shader_bindlessandagc_shader_memory(both cover recompiler files this PR changes), exit code 0, 3 of 3 each.Not tested: that the new test fails without the change (no baseline run), other ctest targets that touch
ResourceMaterializer.cpp, which GPU the execution tests used (not recorded in the ctest output; the machine has an NVIDIA GeForce RTX 4080 SUPER and an AMD Radeon RX 6400), Linux, a title run (PPSA15388 not available here).AI-assisted (Claude Code).
Imported from boykopovar/AnyPS5. Originally posted by xXPBSXx on 2026-10-14T01:58:32Z.
Windows build check of #5509 (head
da58289f0ea7e540caf3c2baced8d8f7bd586ae6) onmain52d134c02: Windows 10 (19045), MinGW-w64 GCC 15.2, Release. The merge has no textual conflict, but compilingcore/shader/recompiler/ShaderDiskCache.cppfails:static assertion failed: ImageResource changed: update the info encoder. With this PR merged the assertion onImageResourcefires: the shader disk cache pins the field counts of the structures it encodes (assertions from664ad7703, 13 October), so the PR needs the info encoder and the count updated. Only this one object file was built (ninja ...ShaderDiskCache.cpp.obj, logdc_check_result.txt); a full build of the merge was not run. My earlier test of this PR (all tests exit 0, 18 of 18 +agc_shader_bindless/agc_shader_memory) was onmaind1670009f.AI-assisted (Claude Code).
Imported from boykopovar/AnyPS5. Originally posted by oneandonlydean on 2026-10-14T03:05:53Z.
This no longer builds on main:
ShaderDiskCache.cppassertsfieldCount<ImageResource>() == 37(664ad7703), andcubeFaceCompatiblemakes it 38. Please update that count and bumpFormatVersioninShaderDiskCache.hpp(30 on main), since the encoded info changed.Imported from boykopovar/AnyPS5. Originally posted by billythemenace2 on 2026-10-14T12:36:06Z.
Rebased on main.
fieldCount<ImageResource>()is now 38, the minimum image record is 76 bytes andFormatVersionis 33. The new cube test, the cube derivative and clamp tests,agc_shader_disk_cacheandagc_shader_memorypass on an RX 5700 XT.image_plane_address_on_lineand its implicit-LOD variant fail on this GPU on plain main too.Imported from boykopovar/AnyPS5. Originally posted by adriadam10 on 2026-10-14T21:46:06Z.
Checked on the HW oracle (gfx1035, IEEE off): on 8x8 32_FLOAT cubes (
DEPTH5 withBASE_ARRAY0,DEPTH11 withBASE_ARRAY6), DIM 2Dimage_sample_lz,image_sample_land plainimage_sampleequal DIM CUBE with face 0 bit for bit over 484 rows per mode (wrap/mirror/clamp, point/bilinear,DISABLE_CUBE_WRAP0 and 1, u and v from -1 to 4), andimage_loadreads texel (x, y) of theBASE_ARRAYface, matching your gfx1010 measurements. The new test fails without the change and passes here on RADV and on CI's lavapipe.What we added on your branch:
sizeof(ImageResource) == 88, so withcubeFaceCompatiblethey are 38 and 92, the minimum image record is 77 bytes andFormatVersionis 36.DISABLE_CUBE_WRAP0 within half a texel of the face edge already blends texels of the neighbouring faces on hardware (e.g. u = 1.0625, v = 1.03125 on face 0), so the translation matches only away from those edges. The line now says so.Merging once the full Build is green.
Imported from boykopovar/AnyPS5. Originally posted by github-actions[bot] on 2026-10-14T21:47:59Z.
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/ResourceMaterializer.cppL1240-1241Imported from boykopovar/AnyPS5. Originally posted by adriadam10 on 2026-10-15T11:00:19Z.
Checked on the HW oracle (gfx1035, IEEE off): on 8x8 32_FLOAT cubes (
DEPTH5 withBASE_ARRAY0,DEPTH11 withBASE_ARRAY6), DIM 2Dimage_sample_lz,image_sample_land plainimage_sampleequal DIM CUBE with face 0 bit for bit over 484 rows per mode (wrap/mirror/clamp, point/bilinear,DISABLE_CUBE_WRAP0 and 1, u and v from -1 to 4), andimage_loadreads texel (x, y) of theBASE_ARRAYface, matching your gfx1010 measurements. The new test fails without the change and passes here on RADV and on CI's lavapipe.What we added on your branch:
sizeof(ImageResource) == 88, so withcubeFaceCompatiblethey are 38 and 92, the minimum image record is 77 bytes andFormatVersionis 36.DISABLE_CUBE_WRAP0 within half a texel of the face edge already blends texels of the neighbouring faces on hardware (e.g. u = 1.0625, v = 1.03125 on face 0), so the translation matches only away from those edges. The line now says so.Merging once the full Build is green.