shader: lower gfx1030 2D image LOD queries #1438
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/1445"
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 stan495 on 2026-11-24T11:39:05Z.
Summary
Lower
image_get_lodfor a single gfx1030 2D texture and an ordinary sampler in the pixel AOT profile. A contiguous quad-provenance UV pair produces the clamped and unclamped LOD in lane order (dmask:0x3). The lowering checks ready image and sampler descriptors and requiresvmcnt(0)before results are consumed. Comparison samplers, two-texture binding, unverified operand flags, and non-quad coordinates are outside the tested profile.The fixture compares translated DXIL and independent hand-written HLSL with the same texture, sampler, constants, and viewport. Following the independent RTX 4060 Laptop result in review, only the rendered red channel of the two-mip upper-clamp case (
raw LOD - 2) accepts an absolute difference of one LOD step (1/256) from the CPU reference. The translated/direct comparison, clamped channel, other outputs and clear pixels, and the signed negative case remain exact. The existing SPIR-V MinLod operation retains its strict comparator.Verification
Tested clean head
8b2df3dc5edfbc34498cde57b80de9d35413ad52. From PowerShell with the test Python environment configured:Each preset reported 7 passed, 0 failed and 2 skips (legacy
spirv_minlod_{hardware,warp}cases, becausespirv-as,spirv-valandspirv-crosswere absent at configure time). Both passing get-LOD records containimage_get_lod. The five full readbacks matched bit-for-bit between translated and direct on Intel Arc B39032.0.101.8509and Microsoft WARP10.0.26100.9818on Windows 11 build26300.9974, with the debug layer unavailable. The new head has not been run on NVIDIA here.Both backends accepted the injected one-step red deviation and rejected the two-step deviation first at
(0,0), channel 0:00000000expected,bc000000actual. The clamp-both control still failed at(0,0), channel 1:bf800000expected,00000000actual. The unclamp-both control failed at the same channel:3f800000expected,40000000actual. Text checks reject an early result read, an unverified mask, a wrong dimension, a pending sampler load, and a non-quad UV.The LLVM 15 assembly, disassembly, container CLI and rejection checks passed.
git diff --check origin/main...HEADpassed.git merge-tree --write-tree origin/main HEADsucceeded against06e2ff78aec68fc9aabb9f57531b04e0f249e644and in a separate simulation with #1451 integrated first. These simulations were not integration test runs.Imported from R0Y00/Xbox2Windows. Originally posted by R0Y00 on 2026-11-24T11:58:06Z.
Review: CHANGES_REQUESTED
Windows Release on RTX 4060 Laptop driver 32.0.16.1656: the four lower-scale cases passed, including negative unclamped LOD, and the clamp-both control failed as intended. The failure is the positive upper-clamp case at pixel (0,0): red (raw LOD minus 2) expected 0 and was -0.00390625 (0xbb800000). Green (clamped LOD) stayed 1. WARP and the four neighboring sample_lod/dmask regressions passed.
I also ran an independently written HLSL shader with the same texture, sampler and scale, using a plain multiply and the two D3D LOD operations. It gave the same -0.00390625 on RTX and exactly 0 on WARP. Please keep the exact clamped channel and the polarity controls, and confine any precision allowance to the upper raw-LOD component. This measures one 1/256 step. Microsoft lists eight fractional LOD bits under D3D12_MIP_LOD_FRACTIONAL_BIT_COUNT in https://learn.microsoft.com/en-us/windows/win32/direct3d12/constants.
Imported from R0Y00/Xbox2Windows. Originally posted by tedin7 on 2026-11-24T12:21:00Z.
Review: COMMENTED
Reviewed PR #1445 (
3892513b):Summary
Clean, well-scoped lowering for gfx1030
image_get_lod(dmask:0x3,dim:SQ_RSRC_IMG_2D) intools/pixel_aot.pywith matching direct-HLSL comparison, CPU footprint reference, negative/mutation controls, and docs updates.Verification
3892513b:tests/form_coverage_check.py: PASS (44.87s)--preset dev):offscreen_checkbuilt;ctest --preset dev -R '^pixel_aot_get_lod_warp$'1/1 passed (3.72s)./O2(--preset release):offscreen_checkbuilt;ctest --preset release -R '^pixel_aot_get_lod_warp$'1/1 passed (4.00s).pixel_aot_get_lod_hardwarewas not run (the Win2025 node only has WARP).3892513b:tests/docs_links_check.py,tests/bidi_controls_check.py,git diff --check origin/main..HEAD: PASStests/pixel_get_lod_check.py binary llvm-mc-19 llvm-objcopy-19 /usr/lib/llvm-19/lib/libLLVM-19.so: PASSCode Audit Notes
tools/pixel_aot.py: descriptor/sampler readiness,sample_destoverlap,entrymask,comparison/two-texture exclusion, quad-provenance UV check, andvmcnt(0)consumption tracking are all properly enforced.tests/pixel_get_lod_check.py: good negative controls (missingvmcnt(0), wrong sampler SGPR, wrongdmask, wrongdim, non-quad UV) and draw mutations (clamping raw LOD, unclamping clamped LOD).origin/main(git merge-tree --write-tree origin/main HEADsucceeded).LGTM from Linux + Win2025 WARP verification.
Imported from R0Y00/Xbox2Windows. Originally posted by R0Y00 on 2026-11-24T12:35:30Z.
Review: APPROVED
Re-reviewed
8b2df3dcafter the scoped upper raw LOD bound. Windows Release on RTX 4060 Laptop and WARP passed get_lod, sample_lod and dmask (6/6). The direct and translated readbacks still agree bitwise; the one-step control is accepted and the two-step control is rejected. Earlier modes retain the exact reference.Imported from R0Y00/Xbox2Windows. Originally posted by stan495 on 2026-11-24T12:11:32Z.
Thanks for narrowing this to the two-mip upper-clamp case. I added an independent, handwritten desktop HLSL comparison in
3892513b071d0f9c5f380abb0ac1077084b5fa9e. It binds the same texture and sampler and uses the same UVs, constants, viewport and readback as the translated shader. Each path still runs the exact CPU comparison. Even if that comparison fails, the test runs both paths, prints the first pixel as float values and raw FP32 words, and compares the full 256-channel readbacks. No precision tolerance was added.On Windows 11
26300.9974, Intel Arc B39032.0.101.8509and WARP10.0.26100.9818produced bit-identical direct and translated results for all five draws. The debug layer was unavailable. Release and Debug each had 6 passes, 0 failures and 0 skips for^pixel_aot_(get_lod|sample_lod|dmask)_(warp|hardware)$; the LLVM 15 container check also passed. The two relevant raw first pixels were:(clamped, raw, 0.5, 1)00000000,bf800000,3f000000,3f80000000000000,bf800000,3f000000,3f800000(raw - 2, clamped, 0, 1)00000000,3f800000,00000000,3f80000000000000,3f800000,00000000,3f800000The lower wrong-clamp control still fails at
(0,0), channel 1,bf800000expected vs00000000actual. The upper wrong-unclamp control fails there with3f800000expected vs40000000actual on both local backends.I do not have an NVIDIA adapter on this host. Could you rerun the Release hardware case at the new head on driver
32.0.16.1656and share theupper-clamp path=translatedandupper-clamp path=directblocks? This command emits both even if the binary32 CPU reference still fails:The reported
-0.00390625would appear asbb800000in the red word. The direct readback will tell us whether that difference also occurs without the translator.Imported from R0Y00/Xbox2Windows. Originally posted by stan495 on 2026-11-24T12:28:35Z.
Thanks for the independent NVIDIA readback. The new head
8b2df3dc5edfbc34498cde57b80de9d35413ad52permits one D3D12 LOD step only in the covered upper-clamp red channel. The signed negative result, the clamped channel, background, both polarity controls, and translated/direct bit equality remain exact. Both local backends accepted the injected one-step value and rejected a two-step value at(0,0), channel 0 (00000000expected,bc000000actual).The PR body records the fresh Debug and Release results and the two unrelated SPIR-V tooling skips. Could you retest the new Release head on the RTX 4060 Laptop with
ctest --preset release --no-tests=error -R '^pixel_aot_get_lod_hardware$' -Vafter rebuildingoffscreen_check? The raw words are still printed for both paths.