compute: lower 2D image_gather4_lz_o #3319
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/3319"
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 R0Y00/Xbox2Windows. Originally posted by Leyukaka on 2026-11-28T09:29:16Z.
Part of #3224 (claimed there). Target branch
main.image_gather4_lz_ois a gather at LOD 0 whose first address VGPR packs a per-lane offset: signed 6-bit x in bits [5:0] and y in bits [13:8] (docs/experiments.mdgather notes,tools/pixel_aot.pygather decoder). The direct compute path refused it with "direct image opcode or descriptor modifiers".Change (
src/gfx1013_direct_compute.inl,image_io):0x57is accepted as a gather. The coordinates are the address operands after the offset.dx.op.textureGather:(p << 26) >> 26for x and(p << 18) >> 26for y.cs_6_6HLSLGatherBluewith offsets computed fromSV_DispatchThreadIDcompiles and validates, and emits non-constanti32offset operands. The direct path also targetscs_6_6.Tests. The setup was Windows 11 with an NVIDIA GeForce RTX 5080 and DXC from the Windows SDK 10.0.26100, Release, on
main3f780716plus this commit.native_gather_lz_offset_controls:textureGathercall, its coordinate registers and the shift and sign-extension chain, with both NSA and contiguous addresses (the fixture's offset words also set bits outside the two fields);main'scompile_dxilthe positive program is refused with "direct image opcode or descriptor modifiers", so the test fails there.native_gather_lz_offset_hardwarepasses on the RTX 5080: four lanes with different offsets match all four taps with both address encodings.native_gather_lz_offset_warpreports a capability skip (77).ctest -R "native_|startup_compute|compile_dxil|salu"passes 528 of 529.native_scalar_lds_hardwarefails as onmain.compile_dxil --jobs 8 gfx1013-direct-cs@36 --requests(counts only):main3f780716, and 254 with this commit;image_gather4_lz_orefusals, 1,004 dispatches in that run;image_storewith DMASK0x9, which this PR does not change.I did not run source mutations. The failure on
maincovers removing the change.AI-assisted.
Imported from R0Y00/Xbox2Windows. Originally posted by tedin7 on 2026-11-28T11:06:28Z.
Review: COMMENTED
Review of head
bb3f07ef(the PR's own change is87296ce1; the new head only merges currentmain). Not merged: the PR's own D3D12 WARP readback test fails on Windows Server 2025.What I checked:
src/gfx1013_direct_compute.inl: opcode 0x57 forimage_gather4_lz_o, the x field in bits [5:0] and y in [13:8] of the first address VGPR, sign extension byshl/ashr 26, and the refusals (3D, array, compare, multi-channel, unnormalized, A16) look right against the public RDNA2 MIMG description. The controls test matches that.Result on Windows Server 2025, D3D12 WARP 1.0.22,
-R '^native_gather_(lz_offset_(controls|warp)|lod_(controls|warp))$'(targetscompile_dxil,offscreen_check):native_gather_lz_offset_controlspassed,native_gather_lod_controlspassed,native_gather_lz_offset_warpFAILED. Release: same.compared_words=320 mismatches=16, the first oneword=0 expected=3f1020c4 actual=c5c5c5c5. All four lanes times four taps read back as the fill pattern, so the gather with a non-constant offset did not write its result on WARP (debug layer: 0 errors, 0 warnings).native_gather_lod_warpdoes not exist in this tree, so only the controls ran for the sibling.What is needed: either the lowering or the test expectation must hold on WARP, or the WARP leg must skip cleanly (exit 77) when the adapter lacks the capability, with the real-GPU leg staying as the guard. As it stands the PR's own WARP test is red, so I did not merge. Mutation runs (swapped y shift, dropped address-register shift) also fail the controls test, so the controls do guard the encoding.
AI-assisted; commands listed were executed locally.
Imported from R0Y00/Xbox2Windows. Originally posted by Leyukaka on 2026-11-28T11:12:30Z.
I can't reproduce this here: on Windows 11 build 26300 the WARP leg exits 77 (
skip: shader wave32 fixture requires SM 6.6, WaveOps, and a 32-lane wave), and the RTX 5080 leg passes.16 mismatches is the number of result words (4 lanes x 4 taps), and word 0 still holds the fill value
0xc5c5c5c5, so on WARP lane 0's gather result was never stored or the dispatch did not run. The harness prints only the first mismatch, so the other 15 are not shown.Could you run
ctest -R '^native_gather_lod_cs_warp$'on the same machine? It uses the same--shader-wave32gate, compute texture case and mip-1 view, with constant offsets. If it fails too, the non-constant offset is not the cause. The stdout and stderr of the failing run would also help. I'd rather not turn the WARP leg into a skip before the cause is known.Imported from R0Y00/Xbox2Windows. Originally posted by Leyukaka on 2026-11-29T03:07:48Z.
Since the review of
bb3f07ef: rebased ontomainas one commit,da296e99, with the same lowering and tests; the WARP failure is not addressed yet. Still open: on Server 2025, the result ofctest -R '^native_gather_lod_cs_warp$'(constant offsets, same wave32 gate) and the stdout and stderr of the failingnative_gather_lz_offset_warpwould separate the offset path from the WARP wave32 path.Imported from R0Y00/Xbox2Windows. Originally posted by JohnConnorNPC on 2026-11-29T12:55:24Z.
Review of
da296e99against main77d1ba4d. Verdict: hold. It merges cleanly (git merge-tree --write-tree origin/main da296e99→ rc 0), but no WARP run of the PR's own readback test has passed.MUST
native_gather_lz_offset_warpis red on Windows Server 2025 (compared_words=320 mismatches=16, word 0actual=c5c5c5c5, from tedin7's review ofbb3f07ef). No run since has passed, andda296e99doesn't change the lowering. The default launcher path makes this a blocker: since #3449 runs use the native path (X2W_NATIVE_SHADERS_ONLY=1), so this lowering replaces a refusal there. A gather that silently leaves its destination unwritten is worse than the refusal. Either a passing WARP run, or a cause showing it is WARP-only (thenative_gather_lod_cs_warpcomparison Leyukaka asked for) with a clean 77 for that adapter, would clear it.SHOULD
re.searchof theprpreset filter →Falsefornative_gather_lz_offset_controlsandnative_gather_lz_offset_warp. The controls leg needs onlycompile_dxiland DXC, so it could run in CI.What I checked by reading, and it agrees with the repo mapping:
0x57isimage_gather4_lz_o(tools/disasm_rdna2.py:0x57: ("image_gather4_lz_o", True, 1)).@dx.op.textureGather.f32withi32 73(the test assertsargs[0] == 'i32 73'), and the base-level sampler path is the same as op 71.shl 26/shl 18thenashr 26.coordinate(j + unsigned(bias || compare || gather_offset))).Nothing built or run here.
AI-assisted.
Imported from R0Y00/Xbox2Windows. Originally posted by Leyukaka on 2026-11-29T15:24:32Z.
Re the hold on
da296e99: new head8cfd018c. It changes onlytests/native_gather_lz_offset_check.py(+15/-6); the lowering is the same as inda296e99.What changed. The readback test now dispatches one full 32-thread wave instead of 4 threads. Lanes 4-31 repeat the offsets of lanes 0-3 (
lane & 3), and each lane writes its own 16-byte slot. The reference is the 4 lanes x 4 taps repeated 8 times (128 words) followed by 192 sentinel words; all 320 words are compared, for both address encodings.Runs. Windows Sandbox with no network adapter,
devpreset with-DX2W_WITH_OPUS=OFF, full build, on a Windows 11 build 26300 host. WARP is 1.0.22 from theMicrosoft.Direct3D.WARPNuGet package, placed next tooffscreen_check.exe(adapter=Microsoft Basic Render Driver,driver=1.0.22.0). The hardware adapter is an NVIDIA GeForce RTX 5080, driver 32.0.16.2101.da296e99,ctest -R '^native_gather_lz_offset_':_controlspassed,_hardwarepassed,_warpfailed withgroups=1 compared_words=320 mismatches=16,word=0 expected=3f1020c4 actual=c5c5c5c5. This reproduces the Server 2025 result. A local diagnostic build (not pushed) printed all 16 result words asc5c5c5c5for both address encodings, and got the same 16 mismatches with a constant-offset gather (diag immediate-zero) and with the offset register forced to zero (diag vgpr-zero). Both diagnostic lines givemismatches=0on the RTX 5080.5de0b114,ctest -R '^startup_compute_dispatch_native_':_hardwarepassed,_warpfailed withword=0 got=c5c5c5c5 expected=00000400 (288 words differ). That test has no gather. On the same WARP, #3320'snative_ds_bpermute_warp, which runs 32 threads per group, passes.8cfd018c,ctest -R '^native_gather_lz_offset_':_controls,_warpand_hardwareall passed (3/3);_warpand_hardwareprintAll 32 lanes matched all four blue taps with both address encodings.With the offset removed from the lowering (
ashrresult replaced by0),_hardwareat8cfd018cfails withmismatches=112; with the two shift amounts swapped it fails withmismatches=128.Cause. WARP-only, and not the offset lowering: it is the partial wave under
WaveSize(32)tracked in #3160. Insrc/gfx1013_direct_compute.inlon5de0b114,initialize()sets EXEC fromwaveActiveBallot(true)andlane_bit = 1 << waveGetLaneIndex()(lines 280-287),active()is(EXEC & lane_bit) != 0(176-180), and every buffer store branches onactive()(863-866). If the ballot of a 4-thread group does not contain the lane's own bit, no lane stores and the buffer keeps its fill, which is what runs 1 and 2 show. With a full wave the test passes.tests/native_int32_minmax3_check.pyon main already uses full waves for the same reason.Not covered.
native_gather_lz_offset_controlschecks the DXIL of the 4-thread shader only. The 32-thread shader is checked by the readback compare.Imported from R0Y00/Xbox2Windows. Originally posted by JohnConnorNPC on 2026-11-29T15:33:12Z.
Re-review at
8cfd018c(delta vsda296e99:tests/native_gather_lz_offset_check.pyonly, +15/-6; lowering unchanged).Our MUST (no green WARP run) is resolved:
8cfd018chas_controls,_warp(WARP 1.0.22) and_hardwarepassing, with the adapter, driver, Windows build and commit given, plus two hardware mutations (offset dropped:mismatches=112; shifts swapped:mismatches=128).tests/native_int32_minmax3_check.pyon main says "Full physical waves avoid the WARP 1.0.22 partial-wave ballot issue (#3160)". The failure also shows on main'sstartup_compute_dispatch_native_warp, which has no gather, so it is not caused by this lowering.0x1b << 25 | offset << 17 | 131isv_and_b32 v[offset], 3, v0(VOP2 op 0x1b, src0 inline 3). The mul now readsv[offset].v3 = v0 << 4is computed before the AND, so each of the 32 lanes stores to its own slot: 128 data words plus 192 sentinels = 320.Still open, not blocking: the
prpreset runs none of thenative_gather_lz_offset_*tests (earlier SHOULD). The run report does not say whether the debug layer was on (the test asserts 0 errors only when it is).Trial merge onto main
5de0b114: clean. CI: Windows, gfx1013 and Linux pass. Merging.AI-assisted review.