dxil: lower 64-bit icmp via 32-bit dwords and guard MIMG heap indices #1969
No reviewers
Labels
No labels
accessibility
bug
documentation
duplicate
enhancement
goal:world-load
good first issue
help wanted
invalid
keep-open
off-goal
question
stale
test-only
wontfix
No milestone
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set
Reference
github/xcl-dev--xcl!1969
Loading…
Reference in a new issue
No description provided.
Delete branch "gh-pr/1969/head"
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?
@raylitebull on GitHub · 2026-11-25 00:06 UTC · original
raylitebull:fix/amd-rdna4-icmp-and-oob→main· +465 −215 · 4 files · 1 commits · merged 2026-11-25 00:53 UTCFixes two RDNA4 / Tier-3 D3D12 shader correctness and stability issues across both Direct DXIL and HLSL backends: (1) lowers all 64-bit integer comparisons (
v_cmp_*_{i64,u64},v_cmpx_*_{i64,u64}, andv_mad_{u64_u32,i64_i32}) as exact 32-bit high/low dword comparisons instead ofpack64 + icmp i64, avoiding driver miscompilation on shared-dword pairs; (2) clampsResourceDescriptorHeapandSamplerDescriptorHeapindices and guards non-derivative MIMG descriptor-heap ops against invalid/out-of-bounds T# views and inactive lanes.Part of #1269 and #1833.
What is in it
crates/xcl/src/gpu/dxil/lower_wide.rs,lower.rs, &crates/xcl/src/gpu/recomp/emit.rs: replacepack64 + icmp i64across 64-bitv_cmp_*/v_cmpx_*(Lw::cmp64in Direct DXIL and 32-bit dword comparisons in HLSL) andv_mad_{u64_u32,i64_i32}with 32-bit high/low dword comparisons (hi_cmp || (hi == hi && lo_cmp)) plus 32-bit carry/borrow arithmetic fors_addc_u32/s_subb_u32/s_lshl{1..4}_add_u32, eliminatingFeature::Int64Opsandicmp i64on 64-bit comparisons.crates/xcl/src/gpu/dxil/lower_image.rs&crates/xcl/src/gpu/recomp/emit.rs: validate T# descriptors (valid_tsharpcheckingtw3[31:28] >= 8,tw1[7:0] == 0, andtw0 < VIEW_HEAP_MAX_SRV(2_097_151) to block null/unpatched/OOB T# indices andtw0 + 1wraparound) and clamp dynamicSamplerDescriptorHeapindices withSAMPLER_HEAP_MASK(0x7FF); guard non-derivative MIMG ops (sample/gatherexplicit-LOD,get_resinfo,load/load_mip,mimg_msaa,store,atomic_*including moving HLSL atomic UAV handle inside the guard) onact && valid, while keeping PS implicit-LODsample/get_lodquad-convergent viaselect(valid, tw0, 0).dxil.dll 1.8validated):gpu::dxil::lower_wide::cmp64_tests(cmp64_uses_32bit_dwords_no_i64_icmp,carry_ops_avoid_i64_icmp) andgpu::dxil::lower_image::heap_bounds_tests(mimg_view_and_sampler_heap_indices_are_guarded,ps_implicit_lod_sample_and_get_lod_validate).Tested
10.0.22631.0),rustc 1.99.1 (58cf8f9c3 2026-10-13), DXC1.8.2502.11, rebased onto80f4819(5195e27).cargo check --workspace --tests,cargo test -p xcl --lib cmp64_tests(2 passed, 0 failed), andcargo test -p xcl --lib heap_bounds_tests(2 passed, 0 failed;dxil.dll 1.8validated).5195e27(@eizispark, driver32.0.32015.16001,rustc 1.100.0): unfilteredcargo test --workspace --no-fail-fast -- --test-threads=4passed995(2pre-existing#1679fuzz failures,0new failures,45ignored,8skipped);XCL_DIRECT_DXIL=1 cargo test -p xcl --lib gpu::recomp -- --test-threads=4passed265/0/18;cmp64_tests,heap_bounds_tests,msaa_tests(5/5),ops_tests,graphics::tests, and native wave64 GPU tests all passed, plus a clean 60 sscripts/smoke.ps1pair (1675/1675frames,0device removals/crashes).Regression run
60 s
scripts/smoke.ps1pair on AMD Radeon RX 9070 XT (Windows 11 x64, driver32.0.32015.16001, release), contributed by @eizispark:main:
PR:
Not tested
XCL_DIRECT_DXIL=1/XCL_SHADER_BACKEND=dxil, and Linux/Wine/vkd3d-proton.AI use
@eizispark on GitHub · 2026-11-25 00:14 UTC · original
Hardware test report — commit
5195e27Verified
5195e27be9021c7c2515ef4c0b74cb8742773fc1(based onmain80f4819098e921f2e1ab371144d4832f68ffedd6, clean merge): pass (0new failures vsmain; all MIMG/MSAA andXCL_DIRECT_DXIL=1gpu::recompGPU tests pass under the newvalid_tsharpand 32-bitcmp64lowering).Tested
32.0.32015.16001), 32 GB RAM,rustc 1.100.0 (0ef1bc386 2026-11-09)(stable-x86_64-pc-windows-msvc), debug tests + release smokecargo test --workspace --no-fail-fast -- --test-threads=4:995 passed, 2 failed, 45 ignored(8 skipped) —0new failures:gpu::dxil::lower_wide::cmp64_tests(cmp64_uses_32bit_dwords_no_i64_icmp,carry_ops_avoid_i64_icmp),gpu::dxil::lower_image::heap_bounds_tests(mimg_view_and_sampler_heap_indices_are_guarded,ps_implicit_lod_sample_and_get_lod_validate),gpu::dxil::msaa_tests(5/5incl.gpu_direct_msaa_image_loads),gpu::dxil::ops_tests,gpu::dxil::graphics::tests, and native RDNA4 wave64 GPU tests (gpu_geometry_wave32_prefix_count_over_a_mask,gpu_wave32_program_in_wave64_hardware,console_wave64_compute_through_the_pso_hook_dispatch_and_read_back) all passed with no synthetic T# descriptor rejected byvalid_tsharpgpu::dxil::fuzz_tests::fuzz_validate_and_gpu_1seed722andfuzz_validate_and_gpu_3seed1599) are the pre-existing#1679syntheticdxil::Shaderfuzz seeds (switch+WaveReadLaneFirstandCountbits.i64→lshr/Bfrev, which do not go throughlower_wide::cmp64)8 skipped: 6gpu::recomp::lower_dxil::testsf16/f32#1426-semantics sub-cases,shaders::tests::pso_measurement_compiles_an_exact_synthetic_record(0x887A002D), andheap_window_out_of_memory_falls_back_to_the_switch_form: no heap windowsXCL_DIRECT_DXIL=1 cargo test -p xcl --lib gpu::recomp -- --test-threads=4:265 passed, 0 failed, 18 ignored(6 skipped)Regression run
main(8e87fc7b62a87ea589ccb9ea6182f514016cf7db):PR (
5195e27be9021c7c2515ef4c0b74cb8742773fc1):Not tested
XCL_DIRECT_DXIL=1/XCL_SHADER_BACKEND=dxil, NVIDIA/Intel GPUs, Wine/vkd3d-protonAI use
@raylitebull on GitHub · 2026-11-25 00:18 UTC · original
@eizispark Thank you for the comprehensive RX 9070 XT verification (995 passed,
@DarkPanda69 on GitHub · 2026-11-25 00:47 UTC · original
NVIDIA run (32-lane waves only), which this PR lists as not tested; the RX 9070 XT side is covered above.
Tested: pass, head
5195e27applied onmain6567c5f, debug, Rust 1.100.0, Windows 11 Pro 26200, Ryzen 7 5800X, DXC 1.9.2602.17.cargo test -p xcl --lib -- gpu:: --test-threads=4:mimg_view_and_sampler_heap_indices_are_guarded,ps_implicit_lod_sample_and_get_lod_validate,cmp64_uses_32bit_dwords_no_i64_icmpandcarry_ops_avoid_i64_icmpok. The SKIPPED lines (no wave64, and the per-lane refusals) are the same as onmain.mainon that card.Not tested:
XCL_DIRECT_DXIL=1title runs; Intel; Linux / Wine; the whole workspace suite.AI use: Claude Code (Claude Opus 5.5) ran the tests on this machine and wrote this report.
@DavidM1911 on GitHub · 2026-11-25 03:09 UTC · original
Verification on RTX 3060 Ti (Windows 11), branch merged with current
main:cargo test -p xcl --lib: all passed, 0 failed, ~26 ignored. (Intermittent single-test flake / 0xc0000005 abort under parallel scheduling — tracked in #1978; clean on single-threaded rerun.)Thanks!