shader: lower startup 2D-array image LOD queries #2947
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!2947
Loading…
Reference in a new issue
No description provided.
Delete branch "github-bot/gh-2947"
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?
@chadhyatt on GitHub · 2026-11-26 22:40 UTC · original
chadhyatt:backport/startup-array-lod→main· +175 −48 · 7 files · 1 commits · merged 2026-11-27 03:57 UTCAI-assisted backport patch from x2w-microlift.
Extends #2311 and #2342 to 2D-array SRVs: consume the guest slice address but query LOD with spatial coordinates only. Retain the derivative and static-sampler refusals. Extend the authored raw array mip-view fixture across two slices and two derivative scales.
Verification on Apple Silicon macOS, revision
31d4532417:python3 -B tests/startup_gfx2hlsl_image_get_lod_check.py: passed, including negative controls.git diff --check: passed.DXC, WARP and Windows GPU readback not run on this host.
@thepatrickworld on GitHub · 2026-11-26 23:40 UTC · original
Independent AMD RDNA 4 and WARP result on
31d45324: the new 2D-arrayimage_get_lodlane runs and passes on both Windows adaptersNot a code change; measurements only. The body says the DXC/WARP/GPU half was not run on the author's host, so this covers it for one Windows machine.
Environment
Captured in the run's own log directory on the machine:
Commands
Observed
#869/#939are the translation-only entries (no device argument). The four adapter entries print their adapters:#870/#940adapter=Microsoft Basic Render Driver vendor=1414 device=008c driver=10.0.26100.9818,#871/#941adapter=AMD Radeon RX 9070 XT vendor=1002 device=7550 driver=32.0.32029.2010. Each view entry issues 23 renderer invocations (7 2D cases and 4 array cases, each drawn once for the translated and once for the direct programme, plus the ordinary-sampler control) and none of them skipped (code 77would have).Readback words, first two components are (clamped LOD, unclamped LOD), duplicated into RGBA. WARP and the RX 9070 XT returned the same word for every one of these:
The three SRV-window cases (
view=1/2,1/1,0/1) show the clamped component following the view's mip window while the unclamped one stays at the LOD of the whole resource, which is the relation the fixture's comment states. The flow entries printed, for their seven cases and both compilers,<adapter> dxc|fxc <case>: GPU (…) == CPU reference (…), with the mutated variants beside them (e.g.kill: GPU (2.0, 2.0) == CPU reference (2.0, 2.0); every lane writes u -> (1.0, 1.0)).The array lane depends on this PR's translator change
Nothing rebuilt: only
tools/startup/gfx2hlsl.pywas put back to the base revision.So under the base translator the array lane has no coverage at all — the refusal happens while translating, before
compile_hlslor any draw — and the seven 2D readbacks are unchanged by the swap.The
drawmode compiles the array stage under both compilers, and no ctest entry runs itCMakeLists.txt:3733registersstartup_gfx2hlsl_image_get_lod_controlswith the fixture path only — nodraw, no compiler paths — andctest -N -R image_get_lodlists exactly the six entries above. Theps_6_0/ps_5_1compile of theTexture2DArrayform is therefore only reachable by hand today.Fractional LOD values: the two adapters do not return the same raw word
Probe (not pushed) reusing this fixture's own
stage/Pipeline/read_pixeland the same renderer, with the array lane's UV scale widened from the two hardcoded scales (1 and 0.125) to eleven LOD targets, linear filter, min 0 max 2:WARP lands below the card by 6 float steps at LOD 0.25, 2 at 0.5 and 1 at 1.25/8.5/12.5; the largest absolute difference is 9.54e-7 (LOD 8.5 and 12.5) and the card is exact at all eleven. The clamped component is identical everywhere. The cause is not isolated — the difference can sit in the derivatives, in the log2, or in the coordinate arithmetic — and this probe is not in the tree.
Every raw value the fixture itself asserts is an exact integer (2, 1, 0, −1), so this class of difference is invisible to the entry as written; if a fractional case were added, the 1/256 tolerance in
check_colorwould absorb the 9.5e-7 difference seen here.What these runs do not establish
float2(DIRECT_ARRAY_PSisDIRECT_PSwithTexture2Dreplaced byTexture2DArray), so neither side carries the array coordinate. What proves the drop is the static control (array_calltext plus'F(v2)' not in text), not the draw.pixel == referencecompares the translated programme with the direct HLSL on the same adapter; "identical on WARP and on the card" above is my comparison of the two logs, not something the fixture asserts.draw_arraythe max clamp never binds: bothstep=1cases have raw 2.0 againstmax=2, so only MIN_LOD is separated (0.5 clamped against −1 raw), and only with the linear filter. The 2D lane does separate MAX_LOD (0.75 clamped against 2 raw, with both filters). One array case withmax=0.75would close it.prpreset include regex (CMakePresets.json:45) matches none of the six entry names, so on apull_requestctest runs none of them; thepython-linuxjob does runtests/startup_gfx2hlsl_image_get_lod_check.py(windows.yml:288), which is translation-only, no DXC and no device. On a push, the dev sweep with-E '_hardware$'(windows.yml:494) keeps the two_controlsand the two_warpentries and leaves the two_hardwareones manual. Addingstartup_image_get_lod_viewto theprregex would give the new draw its first automated run.Conclusion
On Windows 26200 with DXC 1.9.2602.17, the 2D-array
image_get_lodlowering emitsTexture2DArray r0with the slice consumed and afloat2LOD query, compiles underps_6_0(DXC) andps_5_1(FXC), and the drawn values match the separately authored direct HLSL word for word on WARP 10.0.26100.9818 and on the RX 9070 XT 32.0.32029.2010, for both slices and both derivative scales, with MIN_LOD and the sampler clamp reproduced. The base translator refuses the same programme.AI-assisted.
@chadhyatt on GitHub · 2026-11-26 23:41 UTC · original
Thank you for independently running the exact head on both WARP and the RX 9070 XT, including the base-translator negative control. This closes the previously unverified Windows execution lane. Agreed on the scope: the fractional raw-LOD differences are adapter observations, not proven translator defects, and the array coordinate is tested statically.
@R0Y00 on GitHub · 2026-11-27 03:34 UTC · original · reviewed
The independent WARP and RX 9070 XT results cover
31d45324. A merge trial against currentmain(fb955a51, after #2970) found conflicts intests/offscreen_check.cppandtests/startup_image_get_lod_view_check.py. Please update the branch and preserve both the sampler-join fixture's root selector and this PR's array-slice selection. The two source-built fixtures can then be run together on the updated head.@chadhyatt on GitHub · 2026-11-27 03:37 UTC · original
@R0Y00 I am rebasing against
fb955a5172and preserving both the optional root selector and array-view mode. I will rerun the portable sampler-join and array-LOD controls on the updated head, with no new GPU claim.31d4532417to54567b51d6@chadhyatt on GitHub · 2026-11-27 03:42 UTC · original
Rebased on current upstream
fb955a5172after #2970, now54567b51d6. The existing selector and new array-view mode are both preserved. Portable image_get_lod controls pass, as do sampler-join controls (3 forms, both selector outcomes, swapped bindings, 7 refusals) and all 10 authored LLVM15 encodings. The earlier independent Windows 6/6 result belongs to the prior head; Windows GPU not rerun here. Ready for follow-up review.@R0Y00 on GitHub · 2026-11-27 03:56 UTC · original · approved these changes
Reviewed rebased head
54567b51d6f11ad13cfc37d81188e6cecb75152b. A merge trial against maine05b3cedwas clean. The 2D-view selector and the separate 2D-array fixture are both preserved. On Windows 11 build 26200.9974 I rebuiltoffscreen_checkin Release and ranctest --preset release --no-tests=error --output-on-failure -R '^startup_(gfx2hlsl_image_get_lod|image_get_lod_view|image_sample_l_join)': all six passed. WARP (10.0.26100.9818) and RTX 4060 Laptop (32.0.16.1656) matched the direct HLSL array reference for both slices and both derivative scales. They also passed the sampler-join readbacks, with zero D3D12 debug-layer warnings or errors. Required Windows CI passed.