compute: lower the MIMG gather4 variants #3606
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!3606
Loading…
Reference in a new issue
No description provided.
Delete branch "github-bot/gh-3604"
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?
@lambirou on GitHub · 2026-11-30 12:56 UTC · original
lambirou:compute/gather4-variants→main· +716 −48 · 6 files · 5 commits · openPart of the MIMG slice (P6).
This extends the compute
gather4lowering fromimage_gather4_lto the twelve remaining forms:image_gather4_b,_b_cl,_b_cl_o,_b_o,_c_b,_c_b_cl,_c_b_cl_o,_c_b_o,_c_cl,_c_cl_o,_cland_cl_o. The bias (b), depth compare (c), LOD clamp (cl) and texel offset (o) suffixes follow the RDNA 2 operand layout and reuse the existingGATHER_HLSLview, sampler and DMASK guards; the compare path uses the same depth-reference and result rules as the neighbouring sample-c forms.Refusals: dynamic coordinates, offsets, bias or clamp values across lanes; a bias outside [-16, 15.99]; a clamp outside the view; a compare reference outside [0, 1]; a non-red DMASK for a comparison gather; a non-one-hot DMASK; a missing or moving sampler; and the existing view/sampler descriptor rules. The
_CLmapping followsimage_sample_cl(minimum LOD), as the neighbouring sample path does.Tests
compute_store_aot_gfx1013_gather4_variants_warpand_hardwarepass: 16 cases, 320 words compared per dispatch, 0 mismatch on WARP and the AMD Radeon RX 9060 XT (driver 32.0.32029.2010).compute_store_aot_gfx1013_gather4_lstill passes on both adapters;pixel_aot_sample_clamp(4/4) andstartup_image_sample_c_border(3/3) also pass.form_coverage_check.pypins exactly the twelve forms and keeps the sample CL/O and BVH forms uncovered;docs_links_check.pypasses.Limits
The desktop model loads texels at a computed mip; it does not prove the console's native derived LOD. Coordinates, offset, bias and clamp must be uniform literals across lanes. The
_CLmeaning is not settled by a native run (LLVM/Mesa use minimum LOD, the ISA table describes an upper bound). Nollvm-mcround-trip or console measurement was run.AI-assisted.
@lukaslw-lab on GitHub · 2026-12-01 02:22 UTC · original · requested changes
Reviewed
46d53f76by reading the diff; not built or run.Verdict: changes requested. The bias forms select a mip that zero derivatives cannot produce, and the fixture cannot see it because its reference uses the same formula.
lod = max(bias, clamp)(compute_store_aot.py,GATHER_VARIANTSbranch; docstring "the derivative LOD is zero") treats zero derivatives as LOD 0. Lane-uniform coordinates give a zero derivative, and the implicit LOD is then log2(0) = −∞. A finite bias leaves it at −∞, so the hardware clamps to the sampler's MIN_LOD (0 undercheck_gather_sampler), and only the_clminimum can raise it. The pixel path leaves this to the hardware throughSampleBias(pixel_aot.py:5881). Under that rule, the bias-1 rows (b_lod1_green,b_o_lod1,c_b_less,c_b_o_lod1) read mip 0, not 1;b_cl_bias_rounds(1.5, clamp 0) reads mip 0, not 2; andb_cl_bias_above_clamp(2, clamp 1) reads mip 1, not 2. Either refuse a bias that rounds above the clamp, or uselevel = round(clamp or 0). A desktopSampleBiasrun with uniform UV would settle the rule for RDNA 2 compute.disasm_rdna2up to the lasts_endpgm, contains none of the twelve forms. Seven decodes have reserved bits set, so they are data, not instructions. Refusing the bias forms costs nothing today.reference(anyis_word) passes unchecked intoimage_gather_compare_2d, so a value the literal path refuses translates when it is computed. Either refuse non-literal references or emit the same check.gather4_variant_levelrepeats the translator's formula, so the 320-word match and the "bias ignored" mutant prove consistency, not the native LOD. Add a row whose expected mip comes from a desktop sampler instead.reference OP texelwith red-only DMASK; the offset helper adds the offset afterfloor, then clamps to the edge; the_lpath is unchanged.Tests: CI ran the lowering controls (Linux
compute_store_check.py). It did not runcompute_store_aot_gfx1013_gather4_variants_warp/_hardware, which are not in theprfilter.@R0Y00 on GitHub · 2026-12-02 19:09 UTC · original · reviewed
I checked the current
3f3f4479after the branch update. The gather path still deriveslodwithmax(bias, clamp), so the earlier zero-derivative concern remains. #3616 and #3619 carry this change as a dependency. Please fix or explicitly refuse the unsupported bias case in #3606 first and add a mip-distinguishing control, independent of that LOD expression. The current trial merge into521318afalso conflicts intests/form_coverage_check.py; please keep both main's coverage and the gather entries.@R0Y00 on GitHub · 2026-12-03 06:52 UTC · original · requested changes
The offset helpers in tools/compute_store_aot.py clamp scaled to [-1, dimensions] before adding the signed texel offset. The PR's CPU model and the helper comment apply the offset before clamping the final taps. These differ for finite coordinates outside the texture when a positive offset moves the footprint back toward the view.
Reproduced on this exact head, with the existing gather4 variant fixture's source-built texture and CPU reference. Create image_gather4_b_o with bias=0, offset=(2, 0), then set tx=-3 after constructing the case. Both WARP and RTX 4060 Laptop disagree on 256/320 words; word 0 is 3f001020, expected 3f001000. Likewise image_gather4_c_b_o with bias=0, offset=(0, 2), reference=0.5, compare=1, ty=-3 disagrees on 128/320 words on both adapters; word 0 is 3f800000, expected zero. With floor(scaled)=-3, the offset gives -1; clamping early makes it +1. Adding the offset before the range-safety clamp in the generated HLSL returned 320/320 in both cases on both backends. Please preserve the offset before edge clamping in both helpers and add these returning-from-outside cases to the fixture.
The existing gather4_l and gather4_variants WARP/hardware CTests passed 4/4, including all four existing variant mutations, with no skips. Windows 11 build 26300, WARP 10.0.26100.9818, RTX 4060 Laptop 32.0.16.1656, debug layer enabled.
@R0Y00 on GitHub · 2026-12-03 11:41 UTC · original
Independent result at
059b9d88: the gather translation controls and draw-mimg-gather4 passed on both WARP and RTX 4060 Laptop, with the D3D12 debug layer enabled. The new return-from-left and return-from-top inputs both matched all 320 words, with zero debug errors. Offsetting before clamping addresses my edge finding. The earlier bias/zero-derivative finding in #3606 is still open: the lowerer and the fixture still use max(bias, clamp), so the readbacks agree with that model but do not establish which mip the native operation selects. Please resolve that finding on this base before landing the stack.View command line instructions
Checkout
From your project repository, check out a new branch and test the changes.Merge
Merge the changes and update on Forgejo.