Repository navigation
fix(recompiler): sample the first row when the address omits coordinates - #1416
Conversation
|
I've had this PR (50c6531) 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 The hour-long run had no FATAL and no Vulkan error. DetailsWindows 11, RTX 3080 Laptop. With the PR: our integration tree on main c8a2f06 + this PR at 50c6531. 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): |
adriadam10
left a comment
There was a problem hiding this comment.
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 / extent gives the same result only under point sampling or clamp/mirror addressing:
| case | u | HW (= explicit 0) | this PR (= 0.5/extent) |
|---|---|---|---|
| 1D on 2D, bilinear, wrap | 0.3 | 15.70 | 0.70 |
| 1D on 2D, bilinear, border (black) | 0.3 | 0.35 | 0.70 |
| 2D on 3D (4 slices), bilinear + linear Z, wrap | (0.3, 0.3) | 157.69 | 7.69 |
(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.- Missing derivative components read as 0 (measured with
image_sample_d1D on a 2D T#: the same result as explicitdtdx = dtdy = 0), so that part is correct. - With the measurement, the description can say that the hardware uses 0 instead of saying the ISA leaves it undocumented.
…n omits as 0 Measured on hardware: a position component the instruction omits reads as 0, like an explicit 0, and the next VGPR is ignored. Missing array layers and derivative components are 0 too. Cube coordinates still need all components.
A 1D sample or load of a 2D T# had no runtime image mode after the mode table landed, so it was still refused at materialization. Sampled 1D accesses now also accept a 2D view; the address completion in the emitter reads the missing row as 0.
50c6531 to
60a14b5
Compare
adriadam10
left a comment
There was a problem hiding this comment.
Thanks for the fix, and to @Celegans12 for running it on a title. Rebased onto current main and 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_dimension fails without the code changes and passes with them; the rest of the libSceAgc/libSceAgcDriver ctest scope is green. The PR description still mentions 0.5 / extent, please update it.
|
The new Replica of the job (ubuntu 24.04, GCC 13.3, Mesa 25.2.8 llvmpipe LLVM 20.1.2, AI-assisted: yes (Claude Code Fable 5.1 xhigh) |
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)