Direct DXIL: avoid 2 - off underflow in s_setreg_b32 targeting HW_REG_MODE bit 3 #1869
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!1869
Loading…
Reference in a new issue
No description provided.
Delete branch "gh-pr/1869/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?
@emirduran707 on GitHub · 2026-11-24 22:19 UTC · original
emirduran707:dxil-setreg-mode-bit3-underflow→main· +32 −3 · 2 files · 1 commits · merged 2026-11-24 23:54 UTCWhen
s_setreg_b32writes only bit 3 ofHW_REG_MODE(off == 3,dp_mask == 2, e.g.SIMM16 = 0x00C1) in a shader with dynamic f16 rounding,Lw::setregcomputedlet sh = 2 - off;before matchingdp_mask, panicking with integer underflow (attempt to subtract with overflow).recomp/emit.rscomputes2 - offonly inside thedp_mask == 3anddp_mask == 1arms (whereoff <= 2). This moves2 - offinto those two arms indxil/lower.rs.What is in it
crates/xcl/src/gpu/dxil/lower.rs: compute2 - offonly inside thedp_mask == 3anddp_mask == 1arms ofLw::setreg.crates/xcl/src/gpu/dxil/core_tests.rs: GPU parity tests_setreg_b32_mode_bit3_does_not_underflowagainst HLSL.Tested
cargo test --workspace -- --test-threads=4onecb7547: 960 passed, 0 failed, 43 ignored; 8 SKIPPED (6 inlower_dxil::tests::{f16,f32}_programs_on_the_gpu;heap_window_out_of_memory_falls_back_to_the_switch_form;pso_measurement_compiles_an_exact_synthetic_record)s_setreg_b32_mode_bit3_does_not_underflowbefore the change panicked (the direct DXIL translator panicked: attempt to subtract with overflow); passes and matches HLSL (0x3C00,0xBC01) afterRegression run
main:
this PR:
Not tested
AI use
2 - offunderflow ins_setreg_b32targetingHW_REG_MODEbit 3 ecb75479bc@frenziedcoder on GitHub · 2026-11-24 22:25 UTC · original
NVIDIA test report for
ecb7547: full suite green, its own tests_setreg_b32_mode_bit3_does_not_underflowpasses, and a clean smoke pair on the retail title (1653 vs 1654 frames).Tested
stable-x86_64-pc-windows-msvc, DXC 1.8.2502.11 (SDK 10.0.26100.0). Exact headecb75479bc77e2ac2b34175754b046468a034c3c, no local changes.cargo build --workspace && cargo test --workspace -- --test-threads=4(debug): 960 passed, 0 failed, 43 ignored; the PR's own tests_setreg_b32_mode_bit3_does_not_underflowpasses. SKIPPED:gpu::recomp::lower::tests::a_2d_or_3d_group_agrees_with_the_hlsl_path_on_the_gpu(no wave64),gpu::recomp::lower::tests::coalesced_guarded_runs_agree_with_the_hlsl_path_on_the_gpu(no wave64),gpu::recomp::lower::tests::cross_lane_reads_agree_with_the_hlsl_path_on_the_gpu(no wave64),gpu::recomp::lower::tests::the_wave64_lowering_agrees_with_the_hlsl_path_on_the_gpu(no wave64),gpu::recomp::lower_dxil::tests::a_per_lane_2d_or_3d_group_runs_on_the_gpu(no wave64),gpu::recomp::lower_dxil::tests::f16_programs_on_the_gpu(f16 arithmetic, wave32, per-lane form: refused (unsupported V_MUL_F16 (its #1426 semantics differ from the console's))),gpu::recomp::lower_dxil::tests::f16_programs_on_the_gpu(f16 arithmetic, wave64: no wave64),gpu::recomp::lower_dxil::tests::f16_programs_on_the_gpu(f16 packed, wave32, per-lane form: refused (unsupported V_PK_MUL_F16: VOP3 modifiers (its #1426 semantics differ from the console's))),gpu::recomp::lower_dxil::tests::f16_programs_on_the_gpu(f16 packed, wave64: no wave64),gpu::recomp::lower_dxil::tests::f32_programs_on_the_gpu(f32 arithmetic, wave64: no wave64),gpu::recomp::lower_dxil::tests::f32_programs_on_the_gpu(f32 compares, wave64: no wave64),gpu::recomp::lower_dxil::tests::f32_programs_on_the_gpu(f32 conversions, wave32, per-lane form: refused (unsupported V_CVT_F16_F32 (its #1426 semantics differ from the console's))),gpu::recomp::lower_dxil::tests::f32_programs_on_the_gpu(f32 conversions, wave64: no wave64),gpu::recomp::lower_dxil::tests::f32_programs_on_the_gpu(f32 rounding, wave64: no wave64),gpu::recomp::lower_dxil::tests::f32_programs_on_the_gpu(f32 three-source, wave64: no wave64),gpu::recomp::lower_dxil::tests::f32_programs_on_the_gpu(f32 transcendentals, wave64: no wave64),gpu::recomp::lower_dxil::tests::f64_programs_on_the_gpu(f64, wave64: no wave64),gpu::recomp::lower_dxil::tests::integer_programs_on_the_gpu(integer arithmetic, wave64: no wave64),gpu::recomp::lower_dxil::tests::integer_programs_on_the_gpu(integer carries, wave64: no wave64),gpu_geometry_wave32_prefix_count_over_a_mask(no wave64),gpu_wave32_program_in_wave64_hardware(no wave64),heap_window_out_of_memory_falls_back_to_the_switch_form(no heap windows).test_title_draws_with_a_root_signature_under_the_debug_layerreports ok, but this machine has no D3D12 debug layer (debug layer requested but unavailable … (0x887A002D)), so it ran without the layer and is no evidence either way.Regression run (
scripts/smoke.ps1 -Seconds 60, release, the retail title of #505 at its start screen;XCL_PSO_PRELOAD=0for both builds, because this machine's preload list holds the program of #1307)base (
1d027e5, this PR's merge base withmain):this PR:
Not tested: this code in the title: it is on the opt-in direct-DXIL path (
XCL_DIRECT_DXIL), which the smoke runs leave unset (default HLSL backend), so they show only that nothing else regressed; the world load (the smoke runs stop at the start screen, so code that only runs later is not exercised there); AMD.AI use: Claude Code (Claude Opus 5.5) built and ran the tests and smoke runs on my machine and wrote this report; I checked it.
@upipibi on GitHub · 2026-11-24 22:43 UTC · original
NVIDIA counterpart to the Radeon run: RTX 3070 8 GB, driver 616.56, Windows 11, debug,
ecb7547onmain689f2db.s_setreg_b32_mode_bit3_does_not_underflow(direct DXIL against HLSL, MODE[3:2] = round toward −∞): passes, 2 of 2 runs.dxil::core_testsandsetreg: 13 passed, 0 failed, 1 ignored.AI-assisted (Claude Code). Synthetic tests only.
@DavidM1911 on GitHub · 2026-11-25 01:45 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!