fix(shader): ignore texel offsets of samples and gathers through a cube T# #23498
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/23498"
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 MichonGoddijn231849 on 2026-11-19T05:29:38Z.
What
RDNA2 ignores the texel offset of a sample or gather through a cube T#, whatever the instruction's DIM. The recompiler applied it: an
image_sample_lz_oorimage_gather4_lz_oon a cube read the texeloffsettexels away, on both host GPUs.MakeSampleSetup(SpirvImageEmitter.cpp) now drops the offset of every access whose image takes the cube mode (image.cube). The offset VGPR stays in the address layout, so the bias, compare, coordinate and LOD components after it keep their positions.Measurement:
tools/hw-oracleon gfx1036 (PC RDNA2). A 64x64 32_FLOAT cube T# held distinct values per texel and face. 32 coordinates were tried for each of eleven offsets, from (0, 0, 0) through (1, 0, 0), (2, -3, 0), (31, -32, 0), (-32, 31, 0), (0, 0, 1) and (1, 1, 5). Each offset instruction was compared with the same instruction without an offset:image_sample_o,_lz_o,_l_o,_b_o,_c_lz_o,image_gather4_o,_lz_o,_c_lz_oimage_sample_cl_o,_b_cl_o,_c_o,_c_l_o,_c_b_o,image_gather4_l_o,_b_o,_cl_o,_c_oAn earlier run of the same comparison through the driver (
agc_oracle_runner) matched hardware on 2/32 rows forimage_gather4_lz_oand 0/32 forimage_sample_lz_oon a cube, on both GPUs. Offsets of derivative samples (image_sample_d_o) are not measured; the debt entry says so.Tested
Windows 11 Pro 10.0.26200, MinGW Release build.
ctest --test-dir build -R <pattern> -VwithANYPS5_REQUIRE_VULKAN=1 ANYPS5_NO_SHADER_CACHE=1 VK_INSTANCE_LAYERS=VK_LAYER_KHRONOS_validation VK_LOADER_DEBUG=layer, on an NVIDIA GeForce RTX 5080 (610.74) and an AMD Radeon(TM) Graphics iGPU (gfx1036, 32.0.21045.16010). Each log shows the loader inserting the validation layer, none reports it missing, and there are noVUID-messages.agc_driver_image_sample_cube_offsettest: 32 threads sample a 16x16 8_8_8_8_UNORM cube with offsets from (-2, -1) to (2, 1). Each thread runsimage_sample_lz_owith DIM CUBE,image_gather4_lz_owith DIM CUBE, andimage_sample_lz_owith DIM 2D_ARRAY through the same cube T#. Every result must be the un-offset texel or footprint. Passes on both GPUs.main'sSpirvImageEmitter.cppfails on both GPUs withimage_sample_lz_o on a cube applied its texel offset: thread 0 (face 0, texel 2,2, offset -2,-1) component 0 is 0.agc_driver_image_sample*,image_gather*, cube, offset, color-compare, depth-plane sampling, resinfo dimension):main(agc_driver_image_sample_lod_clamp,agc_driver_image_sample_lod_clamp_shader_lane).tools/pr_overlap.py --branchcould not compareSpirvImageEmitter.cppagainst the PRs that conflict withmain. No open PR I found changesMakeSampleSetupor cube offsets. Not tested on a PS5.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-11-21T07:52:20Z.
Review: COMMENTED
Reviewed — no blocking findings
The offset handling change is supported by the inspected emitter code; I did not run the reported GPU checks, so I cannot make a formal approval decision.
What I ran
b93370000645e2f4655740d43ad49824e8e21d25in the prepared review materials.description.md,commits.md,manifest.json,diff.patch, the new execution test, the changed emitter function and its relevant callers, and the added debt entry. All three changed files were included and read.Results
Findings
Blocking
None.
Non-blocking
ImageSampleCubeOffset.cppdirectly exercisesimage_sample_lz_oandimage_gather4_lz_o; the description reports hardware measurements for a broader range of sampling and gather instructions. Consider expanding the regression test to cover representative bias, compare, and explicit LOD variants, since preserving those address components is part of the change's stated goal. The emitter retains the offset slot inLayoutand only disables its use for cube images. Changed test · Emitter changeNot verified
files.jsonwas not available in the review folder; the manifest and directory listing show three changed files, each included and read. No additional excluded files were listed in the available materials.To get this to a good state
Nothing is required. Optional: add regression coverage for additional sample variants that carry bias, compare, or LOD operands.