feat(agc): implement unnormalized sampler coordinates on single-level 1D and 2D views #799
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/799"
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 Celegans12 on 2026-10-06T03:04:42Z.
What
A sampled S# with
FORCE_UNNORMALIZED(word0 bit 15) throws inDecodeSamplerResource:guest sampler descriptor uses unnormalized coordinates which are not implemented.ShaderInfoCollectorrecords each sampler's live uses with the emitter's explicit-LOD predicate.Populateflags a direct S# with the bit and its paired images only if every use is an explicit-LODimage_sample(_lz,_l; outside pixel shaders alsoimage_sample,_b,_cl,_b_cl) of a direct 1D or 2D image without format conversion; otherwise it throws and names the use. No specialization is added.TRUNC_COORDorMC_COORD_TRUNC; itsVkSamplergetsunnormalizedCoordinates, nearest mips and a zero LOD range. The view must be a single-level, single-layer 1D or 2D view of mip 0. Without the proof the old message stays.textures.adoc; VUIDs 01072-01077, 08609-08611, 09635) then address the same texels, as radv relies on, and with one level the LOD fields cannot matter. As on the normalized path, nearest-filter 1/256 rounding and filter arithmetic are not modelled, and opaque borders use the existing integer border colors. shadPS4 (PS4 reference) divides in the shader; Kyty (PS4 reference) passes the flag through.image_get_lod, implicit-LOD pixel samples, offsets, comparison, derivatives,_a, run-time-selected, array, 3D, cube, MSAA and converted images, and multi-level views. TechnicalDebt gets three lines; the shader disk cache format becomes 5.image_sample_lzthrough S#00008092 00fff000 05500000 00000000.FormatVersion5, so whichever lands second moves to 6; the other conflicts are textual, and its table S#s stay unproven. #639 rewrites the same binding code; the proof here is aShaderInfofield plus binding flags, not a specialization.Tested
mainb10f5701: configure-DBUILD_TESTING=ON, full build,--target libs,ctest:ctest --output-on-failure)VK_DRIVER_FILES): 342/342 pass;agc_driver_flat_storeis left out there because it takes several minutes on Windows llvmpipeagc_driver_image_sample_unnormalized(GPU; RTX 3080 Laptop GPU, Intel UHD Graphics):image_sample_lz,_landimage_sampleat quarter-texel coordinates against the Vulkan formulas, with bilinear and point S#s, clamp-to-last-texel and transparent-black clamp-to-border; the first level of a 4-level image matches; a 3-level view, unequal filters and clamp mode 0 throw. Fails onmain.agc_driver_graphics,agc_shader_memoryandagc_shader_disk_cacheare extended (accepted and rejected S# fields and uses, SPIR-V operand masks, the new cache fields); they do not build onmain.VkSampler; the title then stops at compute shader 0x8000265d00:sampled image descriptor uses an unsupported format.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 oneandonlydean on 2026-10-06T05:34:00Z.
Thanks, this looks right to me. I checked the conditions against the Vulkan rules for
unnormalizedCoordinates:Sampler._bemitsLod 0and_clemitsFMaxinto theLodoperand, so neither adds a bias or MinLod operand.materializeResult, likeguestDescriptor, so a cached variant doesn't carry the flag from a normalized S# to an unnormalized one or back.One small point. An image paired with both an unnormalized and a normalized sampler gets
imageUnnormalizedand must then be single-level, even when the other sampler is the one that matters. That throws rather than producing wrong output, so it's fine, but it might be worth half a sentence in the second TechnicalDebt line.As you noted, this and #757-#759 both move
FormatVersionto 5 and touchResources.hpp,DescriptorBindingBuilder.cppandShaderDiskCache.cpp. Whichever lands second will need a rebase and version 6.Imported from boykopovar/AnyPS5. Originally posted by Celegans12 on 2026-10-06T05:43:56Z.
Thanks. Added to the second TechnicalDebt line: the single-level view is required "even when the image is also sampled through a normalized S#". Force-pushed (one commit, ctest 343/343 on Windows and lavapipe). The
FormatVersion5 clash with #757 is noted in the description; whichever lands second moves to 6.Imported from boykopovar/AnyPS5. Originally posted by github-actions[bot] on 2026-10-07T05:59:29Z.
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/DescriptorBindingBuilder.cppL244core/shader/recompiler/ShaderDiskCache.cppL67Imported from boykopovar/AnyPS5. Originally posted by adriadam10 on 2026-10-07T06:50:13Z.
Checked on the HW oracle (gfx1035, single-level 2D f32 texture):
image_sample_lz,image_sample_land computeimage_samplewith bilinear/point × clamp-to-last-texel/clamp-to-border S#s (plus MIN_LOD 1 + LOD bias 1.5) over 144 coordinates including out-of-range and quarter-texel rows match the Vulkan unnormalized formulas, apart from the 1/256 bilinear weight quantization already noted. Build + ctest 384/384 on RADV, CI green; merging.