fix(shader): sample single-level volumes through biased 2D accesses #5461
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/5461"
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 eljackjoestar-cmd on 2026-10-13T20:15:44Z.
What
Lost Soul Aside (PPSA26358) stops during scene loading when a plain pixel
image_sample_bwith DIM 2D is bound to a one-slice, mip-zero-only 3D T#. No prepared image mode matches that pair.Allow this restricted pairing for direct, non-depth, unpacked 32-bit bias-only pixel accesses. Descriptor validation requires depth one and base/last/max mip zero; binding validation requires normalized point min/mag filtering and no linear mip filter. The existing coordinate emitter supplies zero for the absent third coordinate. Other accesses and larger mip/depth ranges remain refused. The proof flag is serialized with a cache format bump.
Semantics measurement
Measured directly on the PC's AMD integrated gfx1036 (Ryzen 7 7800X3D, AMD driver 32.0.21036.18, Windows 11), using a native kernel loaded through OpenCL. The compiler's
image_sample_lzDIM 3D instruction was changed toimage_sample_bDIM 2D (f0940f08 00400000); coordinate preprocessing was replaced with NOPs, so the three payload VGPRs contain bias, u and v. Texture and buffer descriptors are supplied by OpenCL. No emulator shader code runs in this measurement.Controls: wave32, IEEE off, DX10 clamp on, f32/f16 denormals preserved, round to nearest even, FP16 overflow off. Textures: 16×16×1, one level, R32_UINT and RGBA8_UNORM. Biases -16, -0.5, 0, 0.5 and 16 all sample the (u,v) texel in slice zero. R32_UINT was checked with point weighted-average/min/max reduction, both FORCE_DEGAMMA states, and the game's exact sampler words (
20175700 03800000 00000000 a0500f2e, including Z border addressing). The unchanged LZ/DIM3D instruction gives different results on the same payload, confirming the modified instruction was used. The PS5's gfx1013 and wave64 are not measured; this is recorded in shader debt.For the UINT texture, texel (x,y) contains
0x01000000 + 256*y + x. At UV pairs (1/32,1/32), (17/32,25/32), (31/32,31/32), (-1/32,33/32), every tested bias returns respectively01000000,01000c08,01000f0f,0100000f, with the other components 0,0,1. RGBA8 control texels contain bytes 64,128,32,255; FORCE_DEGAMMA changes RGB as expected, while UINT results remain identical.Tested
Rebased onto main
84b01f9cd042e1d2e9e112f8783aa5a9d26399eeon 2026-10-14; PR headc1218ef4358b13ff9afb3902f611bc1b0fd00808. Standalone branch verification (this PR alone), Windows 11 Pro 10.0.26300, WinLibs GCC 15.2, Release, SPIRV-Tools OFF: runtime and selected native test targets built successfully. All 6 focused tests passed without skips in 2.46 s. Conventions and whitespace checks passed. The conflict resolution retains main's 2D-array loads and stores over 3D descriptors and adds the restricted single-level bias case alongside them. The cache format is 32 and the ImageResource codec has 38 fields. The Vulkan checks above used NVIDIA RTX 5070 / driver 617.14. Three image regressions also passed on AMD integrated gfx1036 / 32.0.21036.18 in 0.69 s, including the existing array-to-volume store regression. No new title/gameplay run, Linux, full-suite or CI result is claimed.Earlier validation, on the bases stated below:
a0f5916a2plus this PR alone; WinLibs GCC 15.2.git merge-treewith #5375 is clean; its 3D-on-1D access support is independent. No combined runtime validation is claimed.Raw measurement
Input rows, controls and all native outputs
Checklist
main; no other open PR implements the same functionsReproduction script (Windows OpenCL, gfx1036)
The script checks the compiled instruction/register encoding before modifying the native kernel, and fails if the compiler layout differs. Requires Python 3 and the AMD OpenCL driver; no emulator build is used.
Imported from boykopovar/AnyPS5. Originally posted by ymatrix1 on 2026-10-13T23:59:18Z.
PS5 (gfx1013) measurements for a 2D image instruction over a 3D descriptor, since the description notes gfx1013 was not measured. Kena: Bridge of Spirits (PPSA01746) binds a 1x1x1 3D texture to a slot read by
image_sample_b ... dim:2D, which is what stops it without this change.Method: the PS5 Vulkan probe harness (mihawk-99/PS5_Vulkan) on a console. A 64x4x4 linear volume with four distinct slices, read by a compute shader whose instructions are
dim:2D, with the T# rewritten to TYPE 3D (10), height 4, depth 4 before the dispatch. Counts are of the 256 output texels per slice.dim:2D)image_loadimage_sample_lz, nearest samplerimage_sample_lz, linear samplerimage_sample_lwith LOD 3.0 in the register after the coordinatesimage_load dim:3Dat z = 2These are the first three accesses only;
image_sample_bitself is not in this run. They agree with your gfx1036 result that the absent third coordinate reads slice 0. I also have a branch that addsimage_load/image_sample_lz/image_sample_lover a 3D descriptor of any depth, built on the same mode:ymatrix1:fix/shader-2d-image-on-3d-descriptor(commited38ecbf7). It overlaps this PR inResourceMaterializer.cpp,ResourceTracker.cppand the disk-cache format, so I'll rebase it on this one once it lands rather than open a competing PR.AI-assisted: yes.
Imported from boykopovar/AnyPS5. Originally posted by adriadam10 on 2026-10-14T20:03:42Z.
Checked on the PR rebased onto main:
agc_shader_disk_cacheandagc_driver_image_plane_bias_on_single_level_volumepass, and the new test does not build without the change. Measured on gfx1035:image_sample_bDIM 2D over a one-slice, single-level 3D T# with a point sampler, biases -16/-0.5/0/0.5/16, wrap and clamp, 80/80 rows read the (u,v) texel of slice 0, as the PR assumes.Added as our own commits on your branch:
ImageResourcehas 37 fields,DescriptorBindingBuilderkeeps main'ssampler.tableskip before your check.ResourceMaterializer.cpp: main replacedindirectRootwithtable, so the mode now requiresimage.table == NoTable.docs/dev/debt/shader.md: moved the new line away from the end of the section to avoid adjacency conflicts.Merging once the full build is green.
Imported from boykopovar/AnyPS5. Originally posted by github-actions[bot] on 2026-10-14T20:17:16Z.
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/ShaderDiskCache.hppL16