feat(agc): implement unnormalized S# clamp mode 7 (mirror-once-border) #14963
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/14963"
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 shahulmubeen-a on 2026-11-02T05:36:24Z.
What
A FORCE_UNNORMALIZED S# with clamp mode 7 (mirror-once-border) on X or Y is refused today (after #11126):
I measured modes 4 to 7 on the hardware first, with the same setup as #11126:
tools/hw-oraclethrough the AMD Windows driver's comgr and HIP runtime.image_sample_lzandimage_sample_lz_o.100 + x + 1000 * y, so a border value (0 or 1) never equals a texel. A second run used a 2-level chain viewed from mip 1 (32x2, texel5000 + x + 1000 * y).What the hardware does with mode 7:
Measured rows (excerpt)
X, 64x4, v = 1.5 (row 1, texel = 1100 + x), transparent black border:
With the white border each border tap adds its weight, e.g. 872.5, 582 and 291.5 at 63.75, 64.0 and 64.25.
Y (u = 10.5, texel = 110 + 1000 * y), clamp 7 linear, transparent black:
-4.5:0 -3.5:3110 -1:610 -0.75:360 -0.25:110 3.75:2332.5 4.0:1555 4.25:777.5 4.5:0.Offsets (
image_sample_lz_o, clamp 7 point):1.5 + (-3)reads 1101,5.5 + (-8)1102,62.5 + 3the border.View from mip 1 (32x2, v = 0.5, texel 5000 + x), clamp 7 point:
-33.0:border -32.5:border -31.5:5031 -1.0:5000 31.75:5031 32.0:border.How the change implements this:
DecodeSamplerResourceaccepts mode 7 with unnormalized coordinates and binds clamp-to-border for that axis.ProveUnnormalizedsets the axis bit of the existingMirrorUnnormalizedBaseconstant for mode 7 as for 1 and 3, so the shader folds a negative coordinate as #11126 does.A Python model of exactly this (fold to the float below -c, at least 0.5, then the host sampler with 8-bit bilinear weights) matches all 1660 measured values of both runs, modes 2 and 4 to 7. Without the 0.5 step it misses 44 of them, all bilinear mode 5 and 7 samples at -0.25, 0.0 and 0.25.
The probe scripts (
probe_border.py,probe_border2.py), their output and the model check are in the first comment.The
debt/libSceAgcDriver.mdentry now covers mode 7. Modes 4 and 5 still throw; a follow-up PR implements them.No title I know of uses mode 7, so
Unblocksis none.Tested
Windows 11 Pro 26300, NVIDIA GeForce RTX 4070 Ti SUPER (610.88), WinLibs GCC 15.2.0, Release. Tested head: c1baa5b78 on #11126's head
1c9c1faf4(which mergesmaina644edf30).agc_driver_image_sample_unnormalizedgains four mode 7 samplers, checked throughimage_sample_lz,image_sample_l,image_sample, the offset variants andimage_sample_d, on 1-level and 4-level views and on a view from mip 1:The reference now takes each axis's clamp mode and the border colour from the S# words; a mirrored axis maps index i < 0 to -i - 1 and mode 6 or 7 returns the border colour past the edge.
guest sampler descriptor uses unnormalized coordinates with clamp mode 7 on X; only wrap, mirror, clamp-to-last-texel, mirror-once and clamp-to-border are implemented.SpirvImageEmitter.cppfrom #11126's head (no 0.5 step), it fails withimage_sample_lz, bilinear mirror-once-border on X and Y, opaque white, 1-level image: (0.000000, 3.500000) offset (0, 0) component 0 is 247.501938, expected 240.000000.agc_driver_graphics(the sampler decode test) expects mode 7 to decode to clamp-to-border, with each border colour type, and clamp-to-edge for a mode 2 Y axis. With the sources of #11126's head it fails with the same mode 7 refusal.I ran 84 sampling and shader tests with
ctest -V,VK_INSTANCE_LAYERS=VK_LAYER_KHRONOS_validation,ANYPS5_NO_SHADER_CACHE=1andANYPS5_REQUIRE_VULKAN=1onmain926f7dd49and on c1baa5b78. The regex wassample|gather|sampler|shader_memory|offset|unnormalized|shader_disk_cache|on_line|on_plane|on_volume|lod|^agc_driver_graphics$.was not found but was requested, and each log has the same 9 validation warnings (Undefined-Value-ShaderOutputNotConsumed-DynamicRendering).VUID-error.agc_driver_sample_order_grid_reference, which skips itself on this device (it does not keep depth at custom sample locations).tools/check_conventions.py --base origin/mainpasses.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 BunnyFl on 2026-11-02T16:15:32Z.
Review: APPROVED
Tested as part of #14964's stack, which contains this commit (
c1baa5b783), on Windows 11 with an AMD Radeon RX 9070 XT (RDNA 4), AMD proprietary driver 32.0.32015.7029, and the Khronos validation layer on:agc_driver_image_sample_unnormalizedand theagc_driver_graphicsdescriptor checks pass, with 0 VUIDs.main's sampler and recompiler sources, the test stops on the mode 7 refusal.Details are on #14964.