startup: image_gather4 has no lowering and needs view/mip state the translator does not model #1802
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#1802
Loading…
Reference in a new issue
No description provided.
Delete branch "%!s()"
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?
@triggered02 on GitHub · 2026-11-24 18:52 UTC · original
Census group at 2 refused shaders (#870). This issue records why it is not a straight port and what it needs, so a future slice starts from the constraint rather than from a misleadingly small patch.
Problem
Stage.image()lowersimage_sample,_lz,_l,image_loadandimage_load_mip; gathers are not handled at all.Why it is not a port
tools/pixel_aot.pydoes lower gathers, but through machinerygfx2hlsl.pydoes not have:image.loweringrefuses an implicit-LOD gather unless the view has exactly one visible mip, and an_lgather unless the LOD is a known integer inside the view.gfx2hlslhas no notion of the image's mip count or declared view at all — it lowers from the descriptor registers only.pixel_aot.pychecks the sampler's filter and mip state against the gather mode (check_gather_sampler).gfx2hlslbinds samplers from constant words without a gather-specific check.uv.x,alu…,params…) and the known LOD bits;gfx2hlsltranslates instructions individually and has no such tracking.GATHER_RESOURCES,gather_compare_resources), which is generated per draw by the AOT path.Deliverable
Lower
image_gather4(_c)(_lz|_l)on 2D images, in a slice that first establishes how the translator learns the view's mip count:Stagefrom the pipeline state (the way pixel AOT gets it) and the lowering refuses when it is unknown, orThen:
dmaskselects the component (1→red,2→green,4→blue,8→alpha), aspixel_aot.pydoes; anything else is refused;Texture2D.Gather*semantics: four texels returned into four consecutive destination registers;docs/experiments.mdrecords what is lowered and what is refused.Done when
AI-assisted (Claude Code).
@avt0m4t48 on GitHub · 2026-11-24 21:15 UTC · original
I'll take the source-built 2D
image_gather4_lzslice. RDNA2 documents the_lzform as fixed mip zero, and the Direct3D functional spec defines native gather at mip zero of the bound view. I'll check that against the startup SRV path, require a validated constant sampler, and verify all four gather outputs with encoded instructions and a synthetic texture. The implicit, explicit-LOD, and compare variants remain separate.@R0Y00 on GitHub · 2026-11-24 21:56 UTC · original
The fixed-mip 2D slice #1927 is on main. On the exact candidate, the nine source-built 64-pixel cases matched on WARP and RTX 4060 Laptop (32.0.16.1656), with zero debug warnings or errors. Each adapter detected the changed tap at pixel (0,0). A view starting at resource mip 1 matched its view-relative mip zero. The implicit, explicit-LOD, comparison and offset gathers remain open here.
@ArnabSaga on GitHub · 2026-11-25 04:27 UTC · original
I'd like to take the source-built 2D image_gather4_c_lz slice. I'll verify the RDNA2 comparison-gather semantics against the existing fixed-mip implementation, including comparison-sampler compatibility, view-relative mip zero, and destination ordering. I'll add encoded instruction fixtures and synthetic texture tests with exact readback on WARP and physical hardware. Implicit-LOD, explicit-LOD, and offset gathers will remain separate.
@triggered02 on GitHub · 2026-11-26 03:21 UTC · original
Status check on current main (
7967c5af), because this issue is narrower than when it was filed:Implemented now: image_gather4_lz, image_gather4_l, and image_gather4_c_lz all have handlers in ools/startup/gfx2hlsl.py (op_image_gather4_lz, op_image_gather4_l, op_image_gather4_c_lz), with the sampler addressing-mode contract documented at the top of the file ("gather4 only uses the addressing modes of the sampler"). ests/compute_gather4_l_check.py covers the explicit-LOD compute form.
Still refused: the plain image_gather4 (no explicit LOD) form � there is no op_image_gather4 handler, so the un-suffixed gather still refuses. That is not a missing table entry: an implicit-LOD gather needs the derivative/quad state the startup translator does not model, which is the same blocker the issue names.
Smallest next step if someone wants it: either (a) refuse it with the specific reason (needs the sample's implicit LOD) instead of a bare mnemonic, so the census separates it from missing handlers, or (b) lower it only where the caller proves a constant LOD from its own state. (a) is a small, self-contained change with a synthetic fixture; (b) needs the same view/mip-state proof this issue describes. Keeping this open for the un-suffixed form only.
@R0Y00 on GitHub · 2026-11-26 04:47 UTC · original
The diagnostic slice is on main in #2735 (
434aa90d). Plain image_gather4 now reports that it needs the guest implicit mip level. Fixed-mip readbacks and a wrong-mip control still pass their checks. Keep this issue open for a mip-selection proof. A useful source-built comparison would give each mip distinct four-tap values, use a nonzero view base mip, and compare two cases where known derivatives select different levels. For the first implementation, the fixed-view path is suitable only where the caller can prove the guest-selected mip. Reusing the visible first mip without that proof would change the result.@RonLogic on GitHub · 2026-11-27 13:21 UTC · original
I’ll take the source-built mip-selection comparison suggested above. I’ll hold the sampled UV fixed at the checked pixel, vary the quad derivatives to select two known levels through an SRV starting at resource mip 1, and compare all four taps on WARP and RTX 4070. I’ll compare the selected-level path with the existing mip-zero gather as a negative control. This is a Windows differential fixture. The plain guest opcode will keep its refusal until its mip choice is proved.
@RonLogic on GitHub · 2026-11-27 13:29 UTC · original
The Windows differential is in #3065. With the two-level SRV based at resource mip 1, changing only the derivative picked different sets of four taps on both WARP and RTX 4070. The mip-zero substitution disagreed at all four taps in the second case. The fixture does not decide the native guest opcode’s mip selection; the remaining evidence is an RDNA comparison on matching inputs.
@R0Y00 on GitHub · 2026-11-27 15:14 UTC · original
The Windows differential #3065 and direct explicit-LOD lowering #3068 are now on
main. On WARP and RTX the two-level view produced both expected four-tap patterns, and the first-visible-mip control failed all four taps in the second case. For the native explicit opcode, Pixel passed on WARP and RTX, and four RTX Compute lanes chose resource mips 1, 2, 2, 2. WARP Compute returned a wave32 capability skip. This issue stays open for an RDNA readback of the plain guest opcode's implicit mip choice on matching inputs.