fix(recompiler): sample the first row when the address omits coordinates #1416
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/1416"
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 gjonn on 2026-10-08T03:12:54Z.
What
A sample, gather or
image_get_lodwhoseDIMfield encodes fewer coordinates than the bound resource was refused at SPIR-V emission ("has an image address with too few coordinate components"). A title runsimage_sample_lzwith a 1D address on a 2D texture. This is the sampling counterpart of #1379, which reads missing components of image loads as 0.CoordF32now completes the address:0.5 / extentof the base level, fromOpImageQuerySizeLod. This is exact for an extent of 1 under any filter and addressing mode, and selects that row with point sampling. Bilinear sampling of a taller image reads only that row.DIM.The ISA does not document what the hardware reads for address components the instruction does not provide. Addressing the first row, slice or layer matches what #1379 does for loads.
Tested
agc_driver_image_address_dimensionpasses. The case that expectedimage_sample_l1d on a 2D texture to be refused now checks its result: for 32 threads it returns row 0 of the selected level at the requested x (level, x >> level, 0, from a texture whose texels encode their level, x and y). The other image sampling tests still pass.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 Celegans12 on 2026-10-08T09:11:36Z.
I've had this PR (50c65319b) in our Ghost of Yōtei (PPSA26344 v1.008) tree for two runs today, and it fixes the only SPIR-V emission failures the game had.
Without it, three pixel shaders failed with
ImageSampleRaw ... has an image address with too few coordinate components(8 skipped draws in a 3,000 s run). With it, all three recompile: 0x802ce1bd00 into 42,225 SPIR-V words, 0x8053ebce00 into 19,047 and 0x8069151500 into 14,735, and an hour-long run from the disk cache has no emission failure at all. I can't tell you whether any of their images is a cube, since I have no dump of their T#s, and I haven't compared what they draw against a console.The hour-long run had no FATAL and no Vulkan error.
Details
Windows 11, RTX 3080 Laptop. With the PR: our integration tree on main
c8a2f0632+ this PR at 50c65319b. Without: the previous integration build.Without the PR (the log prints the hashes in decimal: 550508805376 = 0x802ce1bd00, 551163776512 = 0x8053ebce00, 551518803200 = 0x8069151500):
With it (cold cache):
Imported from boykopovar/AnyPS5. Originally posted by adriadam10 on 2026-10-08T13:10:22Z.
Review: CHANGES_REQUESTED
Measured on the HW oracle (gfx1035,
image_sample_lz/image_sample_d, point and bilinear samplers with clamp, wrap, mirror and border addressing). The hardware reads an address component the instruction omits as 0 (normalized), exactly like an explicit 0, and ignores the next VGPR.0.5 / extentgives the same result only under point sampling or clamp/mirror addressing:(4×4 R32F texture, texel = x + 10·y + 100·z.)
SpirvImageEmitter.cpp:173-181: a missing position component should beZeroF32, the same as #1379 does for loads. That also removes theOpImageQuerySizeLod.ImageAddressDimension.cpp:216-226:CheckNarrowsamples with point filtering, so it passes with either 0 or0.5 / extent. Please add a bilinear sampler with wrap (or border) addressing at a row where the two differ, so the test pins the value.image_sample_d1D on a 2D T#: the same result as explicitdtdx = dtdy = 0), so that part is correct.Imported from boykopovar/AnyPS5. Originally posted by adriadam10 on 2026-10-11T09:10:45Z.
Review: APPROVED
Thanks for the fix, and to @Celegans12 for running it on a title. Rebased onto current
mainand pushed two changes on top:SpirvImageEmitter.cppCoordF32: an omitted position component is now0, not0.5 / extent. Measured on gfx1035 (image_sample_lz/image_sample_d, point and bilinear, clamp/wrap/mirror/border): the hardware reads the omitted component as an explicit 0 and ignores the next VGPR.0.5 / extentdiffers under wrap/border with bilinear filtering (1D on 2D, u = 0.3, wrap: HW 15.70 vs 0.70). This also drops theOpImageQuerySizeLod.ImageAddressDimension.cpp: added a bilinear + wrap case that pins row 0/last-row averaging (7.5), which0.5 / extentwould fail; the existing point-sampled case passes with either value.ResourceMaterializer.cppRuntimeImageModes: after the runtime image mode table landed, a 1D access on a 2D T# no longer matched any mode and was refused with the same "too few coordinate components" before reaching the emitter. Sampled 1D accesses (not storage/depth/converted/packed) now also accept a 2D view.agc_driver_image_address_dimensionfails without the code changes and passes with them; the rest of the libSceAgc/libSceAgcDriver ctest scope is green. The PR description still mentions0.5 / extent, please update it.Imported from boykopovar/AnyPS5. Originally posted by orishamir on 2026-10-11T09:52:56Z.
The new
agc_driver_image_address_dimensionfails on lavapipe, so it is one of the three failures of CI'slinuxjob onmainsince this merged: run 38128072167 on4c9686fe(the other two,agc_driver_image_plane_address_on_line_implicit_lodandguest_kernel_stack_protect, are older and unrelated).Replica of the job (ubuntu 24.04, GCC 13.3, Mesa 25.2.8 llvmpipe LLVM 20.1.2,
ANYPS5_REQUIRE_VULKAN=1 GALLIUM_OVERRIDE_CPU_CAPS=avx) onmaina73a1af9: the same line 3/3. The same binary on Mesa 26.0.8 llvmpipe (LLVM 21.1.8) reads 7.000000 instead, also outside the 0.25 tolerance. So the bilinear sample at the omitted coordinate's 0 with wrap lands on one neighbour row or the other on llvmpipe instead of the half-way blend the RTX 5090 returned; the other cases of the test pass on both llvmpipes.AI-assisted: yes (Claude Code Fable 5.1 xhigh)