shader: lower image_gather4_lz with repeat (wrap) addressing in gfx2hlsl (Part of #1723) #2760
No reviewers
Labels
No labels
accessibility
awaiting author
bug
documentation
duplicate
enhancement
good first issue
help wanted
invalid
priority: P0
question
wontfix
No milestone
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set
Reference
github/R0Y00--Xbox2Windows!2760
Loading…
Reference in a new issue
No description provided.
Delete branch "gh-pr/2760/head"
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?
@tedin7 on GitHub · 2026-11-26 06:32 UTC · original
tedin7:x2w-gather-wrap→main· +148 −46 · 5 files · 5 commits · closed without mergingPart of #1723
What this unblocks:
image_gather4_lzwith a repeat (wrap) sampler, the same bilinear / point-mip sampler the clamp form already accepts, now translates instead of being refused with "requires normalized clamp".Source: AMD "RDNA 2" Instruction Set Architecture reference guide, MIMG instruction IMAGE_GATHER4_LZ and the sampler (S#) clamp / wrap address fields; Microsoft D3D12 documentation,
D3D12_TEXTURE_ADDRESS_MODE_WRAPand HLSLGather.What changed
gather_2d_setuptakes anative_gatherflag, set only byimage_gather4_lz(the form lowered to the native HLSLGather). For it, CLAMP_X and CLAMP_Y (SQ_IMG_SAMP_WORD0 bits 2:0 and 5:3) of 0 (repeat) are read as the clamp-to-last-texel value for the profile check only (gather_2d_wrap_as_clamp).translated_sampler_bindings.halready maps the field value 0 toD3D12_TEXTURE_ADDRESS_MODE_WRAP, so the footprint wraps across the edge as the repeat addressing does (D3D11.3 functional spec 22.4.2: "Only the addressing modes of the sampler are used").What stays refused
image_gather4_l, which emulates the gather with texel loads and an explicit clamp: it does not call the new function and still refuses repeat.Tests
Extends
tests/startup_image_gather_lz_check.py(no new test file):--draw, WARP and hardware): footprints that straddle u = 0, u = 1, v = 0 and v = 1 (one axis and both, plus an out-of-range coordinate) read the texels of the opposite edge, per channel, against a CPU reference that wraps the four taps. The same draws with the clamp sampler read the clamped texels (clamp control), the clamp sampler against the repeat expectation must fail (wrong-sampler control), and the existing mutant (wrong channel) must fail.Draw harness
tests/pixel_aot_render.cppcheck_pixel_gatherused one fixed clamp static sampler, so a repeat draw could never wrap.--check-pixel-gathernow takes an optionalsmpmanifest line and a vertex shader and builds the static sampler from the guest words withdecode_statics(the same mapping the runtime uses intranslated_sampler_bindings.h, which sends the field value 0 to WRAP); without them it keeps the clamp default, so the other callers are unchanged. The comparison gather shares the new root-signature helper.startup_image_gather_lz_check.py --drawpasses the manifest line for every draw, so the clamp and wrong-sampler controls now really read with the clamp sampler.Verification
python3 -B tests/startup_image_gather_lz_check.py: PASS (the repeat controls fail onorigin/main)python3 -B tests/startup_image_gather_c_lz_check.py,tests/startup_compute_gather_lz_check.py,tests/startup_compute_gather_l_check.py: PASS--draw): pending Stage-2.AI-assisted; commands listed were executed locally.
@tedin7 on GitHub · 2026-11-26 10:12 UTC · original
Withdrawn: shader translation is moving to the native C++ frontend (see #870), so we are not continuing this change to the Python translator. The branch stays available if any part is useful later. Thank you to everyone who reviewed and tested it.
Pull request closed