shader: lower experimental gfx1030 2D sample clamps #1631
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/1638"
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-24T15:32:21Z.
Behavior
Add an opt-in
--cpu gfx1030 --sample-clamp-mips Nprofile forimage_sample_cl,image_sample_cl_o,image_sample_b_cl, andimage_sample_b_cl_o. It lowers the trailing immediate clamp to the DXIL minimum-LOD operand onSampleorSampleBias. The supported subset uses normalized point sampling, a float Texture2D view, sequential full-width addresses and a known clamp inside the declared mip range. Unverified layouts, dynamic clamps and other sampler profiles are rejected.Refs #809 for the related desktop MinLOD investigation. This draft tests MIMG AOT and leaves the SPIR-V bridge unchanged. AMD's RDNA 2 reference describes an upper limit. Mesa ACO, Mesa's AMD LLVM builder, and AMD LLPC encode SPIR-V MinLod with these opcodes. The experiment follows the compiler mapping. Readiness requires native gfx1030 readback for the below-clamp, above-clamp, and negative-bias cases. Coverage registration is deferred until that measurement.
Verification
Tested commit
b3dc0eaef3b488ca6d013fc12d3486432bfaa5a1.All four encodings passed LLVM 15 intrinsic address-order checks, assembly/disassembly, and extracted-container CLI translation. The three Python checks passed.
17 passed, 0 failed, 0 skipped. Windows 11 build
26300.9974, Intel Arc B390 driver32.0.101.8509, Microsoft WARP driver10.0.26100.9818, D3D12 debug layer unavailable. Both adapters matched all 64 RGBA pixels in the translated DXIL and independent direct HLSLSampleLevelagainst the CPU reference. Dropping the clamp changed pixel(0,0)red from0.5to0.25. Applying bias after the clamp changed red there from0.75to0.5. The shared regression records cover 41 gfx1030 forms in this JUnit run. The experimental opcodes contribute zero records.git merge-tree --write-treepassed against upstream4b84235f39cc05ff90a9662c25355941a5d51db2. The replay places the LLVM check beside the related sampling checks and preserves the compute checks added by #1611.Imported from R0Y00/Xbox2Windows. Originally posted by tedin7 on 2026-11-25T06:56:12Z.
Review: COMMENTED
Review of head
0194ba572830e4469220d9d17779591183b6b424(comment only).Scope read:
tools/pixel_aot.py(clamp lowering, sampler check, opt-in flag),tests/pixel_sample_clamp_check.py, CMake and workflow registration, docs.State: mergeable; Linux, gfx1013 fixtures and Windows build checks green on this head; title and body are neutral; coverage registration is deliberately deferred.
Commands run locally (worktree at this head):
python3 -B tests/pixel_sample_clamp_check.py-> "Four 2D minimum-LOD sample forms checked" (CPU-reference control cases; the LLVM-15/dxc-dependent modes were not run here because LLVM 15 and dxc are not installed on this host, CI covers them)python3 -B tests/docs_links_check.py-> pass (18 files, 417 links)python3 -B tests/bidi_controls_check.py-> passgit diff --check origin/main...HEAD-> cleancoord_regs.pop()tocoord_regs.pop(0)for the clamp register -> check fails with "Sample clamp requires a known minimum LOD inside the view". Killed. Reverted.P1: none.
P2: none.
Nits:
tools/pixel_aot.py(~L4705):uv_regsis computed fromcoord_regs[-2:]before the clamp register is popped, so for_clforms the checked pair is (V, clamp) instead of (U, V). The lateruvcheck after the pop still validates U/V, so nothing unsafe is accepted. The effect is only that the clamp constant flagsfree_coordinatesspuriously, which makes a later attribute-scale interpolation in the same program get rejected (conservative). Popping the clamp before computinguv_regswould be cleaner.No Windows run was needed for this review (no gfx2hlsl change; the draw tests are gated by CI on the Windows job, which is green).
AI-assisted; commands listed were executed locally.
Imported from R0Y00/Xbox2Windows. Originally posted by stan495 on 2026-11-25T06:44:01Z.
Merged
upstream/main(06913dc1) cleanly at0194ba57to resolve the branch conflicts.Re-verified commit
0194ba572830e4469220d9d17779591183b6b424on Windows 11 (26200.9974, MSVC19.44.35228, Windows SDK10.0.26100.0,dxcompiler.dll1.8.2502.11):docs_links_check.py,bidi_controls_check.py,form_coverage_check.py): all passed.pixel_aot_sample_clamp_controls,pixel_aot_sample_clamp_compile,pixel_aot_sample_clamp_hardware,pixel_aot_sample_clamp_warp,rdna2_tools_check, and the related sampling regression checks).AMD Radeon RX 7900 XTX(vendor=1002,device=744c), driver32.0.32029.2010, D3D12 debug layer enabled.Microsoft Basic Render Driver(vendor=1414,device=008c), driver10.0.26100.9818, D3D12 debug layer enabled.form_coverage.py: 17 passed, 0 failed, 0 skipped (gfx101343/1968,gfx103043/1863; experimental_clopcodes hold 0 coverage records).Note: the Linux LLVM 15
binarytest (tests/pixel_sample_clamp_check.py binary ...) was not re-run locally on Windows (covered by CI), and the PR remains a draft pending the nativegfx1030readback gate noted indocs/experiments.md.Imported from R0Y00/Xbox2Windows. Originally posted by tedin7 on 2026-11-26T00:56:44Z.
Review: COMMENTED
Review of head
0ee41ac8f291e1607a1105b2310bd0ae83bfa39b(comment only). This head is0194ba57plus a merge of main; the PR's own diff is the same size and shape (5 files, +422/-8).Scope read:
tools/pixel_aot.py(clamp operand pop,check_sample_clamp_sampler, known-constant floor check, opt-in--sample-clamp-mips),tests/pixel_sample_clamp_check.py, CMake and workflow registration, docs.Findings: none blocking.
[0, mips-1], the sampler is point/normalized, and cpu is gfx1030. Dynamic clamps and other profiles are rejected with explicit messages.Commands run locally (worktree at this head):
python3 -B tests/pixel_sample_clamp_check.py-> "Four 2D minimum-LOD sample forms checked" (CPU-reference control cases; LLVM/dxc-dependent stages not available here)python3 tests/docs_links_check.py-> ok;python3 tests/bidi_controls_check.py-> ok;git diff --check origin/main...HEAD-> cleanfloor+1as the min-LOD operand -> test fails (AssertionError: image_sample_cl)Win2025 WARP dev+release is being run next; the receipt will follow as a separate comment.
AI-assisted; commands listed were executed locally.
Imported from R0Y00/Xbox2Windows. Originally posted by tedin7 on 2026-11-26T01:07:23Z.
Win2025 WARP receipt for head
609d91bfafter updating with main.Verified on Windows Server 2025 (Build 26100, MSVC 14.44.35207 + D3D12 WARP) at commit
609d91bf944701351b75d53926f781182e8f08d9:--preset dev):cmake --build --preset dev -- -j 2):125.58s(configure2.90s)ctest --preset dev -R '^(pixel_aot_(sample_clamp_(controls|compile|warp)|(sample_(lod|offset|gradient|coarse_gradient)|compare_sample|gather)_warp)|rdna2_tools_check)$' --parallel 4 --no-tests=error --output-on-failure): 10/10 passed (11.87s:pixel_aot_sample_lod_warp2.23s,pixel_aot_compare_sample_warp3.89s,rdna2_tools_check4.20s,pixel_aot_gather_warp4.35s,pixel_aot_sample_clamp_controls1.05s,pixel_aot_sample_coarse_gradient_warp3.32s,pixel_aot_sample_offset_warp2.56s,pixel_aot_sample_gradient_warp3.20s,pixel_aot_sample_clamp_compile2.47s,pixel_aot_sample_clamp_warp3.80s)/O2(--preset release):cmake --build --preset release -- -j 2):166.55s(configure4.17s)ctest --preset release -R '^(pixel_aot_(sample_clamp_(controls|compile|warp)|(sample_(lod|offset|gradient|coarse_gradient)|compare_sample|gather)_warp)|rdna2_tools_check)$' --parallel 4 --no-tests=error --output-on-failure): 10/10 passed (10.64s:pixel_aot_sample_lod_warp1.85s,pixel_aot_sample_coarse_gradient_warp2.92s,pixel_aot_compare_sample_warp3.35s,rdna2_tools_check3.81s,pixel_aot_sample_clamp_controls0.99s,pixel_aot_sample_gradient_warp2.98s,pixel_aot_sample_offset_warp2.27s,pixel_aot_sample_clamp_compile2.35s,pixel_aot_gather_warp3.92s,pixel_aot_sample_clamp_warp3.17s)tests/form_coverage_check.pyok (12.3s),tests/mesh_clip_cull_check.pyok (4.4s),tests/mesh_dynamic_geometry_check.pyok (0.4s),tests/mesh_heap_sampler_check.pyok (0.8s),tests/pso_readiness_check.pyok (0.9s),tests/rdna2_tools_check.pyok (2.7s),tests/startup_gfx2hlsl_cmp16_check.pyok (0.3s),tests/startup_gfx2hlsl_cvt_pk_int16_check.pyok (0.3s),tests/startup_gfx2hlsl_f32_lg_check.pyok (1.4s),tests/startup_gfx2hlsl_f32_nan_check.pyok (5.2s),tests/startup_gfx2hlsl_sop2_complement_check.pyok (6.1s),tests/startup_gfx2hlsl_vopc_sdwa_check.pyok (4.7s),tests/startup_image_load_d16_check.pyok (1.2s),tests/startup_image_sample_a16_check.pyok (0.2s)sccache: 214/357 hits; wall358.7sAI-assisted; commands listed were executed locally.