DXIL: set DisableMathRefactoring when lowering unfused mad without FMad #1973
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!1973
Loading…
Reference in a new issue
No description provided.
Delete branch "gh-pr/1973/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:11 UTC · original
raylitebull:feat/dxil-disable-math-refactoring→main· +196 −5 · 4 files · 1 commits · merged 2026-11-25 10:46 UTCSets the DXIL entry-point
DisableMathRefactoringflag (bit1,SFI0 = 0) when the direct DXIL translator lowers unfusedmad_nf(V_MAD_F32/V_MAC_F32), unless the optimized module still emits livedx.op.tertiary.*FMad(opcode46) calls (which DXIL validation forbids combining withDisableMathRefactoring).Part of #1269.
What is in it
crates/xcl/src/gpu/dxil/kernel.rs: bumpTRANSLATOR_VERSION(8->9; merges cleanly withmain, whereXCL_DIRECT_DXIL_SOURCE_IDfrom #1947 now automatically invalidates direct-DXIL disk caches ongpu/dxilsource changes).crates/xcl/src/gpu/dxil/shader.rs: addFeature::DisableMathRefactoring(metadata_bit = 1,container_bit = 0) andShader::feature_flags()+Shader::uses_fmad()soDisableMathRefactoringis omitted whenever post-optimize()IR still containsdx.op.tertiary.*opcode46(FMad).crates/xcl/src/gpu/dxil/graphics.rs: route entry-point shader flag computation throughself.feature_flags().crates/xcl/src/gpu/dxil/prelude.rs: requireFeature::DisableMathRefactoringinLw::mad_nf, and adddisable_math_refactoring_tests(5 tests covering compute/pixel unfused mad, liveFMadsuppression, plainv_add_f32, and post-DCE deadFMad).Tested
rustc 1.99.1 (58cf8f9c3 2026-10-13), DXCdxcompiler 1.8.2502.11/dxil 1.8.2502.11, rebased cleanly onto656c0e8(aaf2c78).cargo check --workspace --tests: passed.cargo test -p xcl --lib disable_math_refactoring_tests: 5 passed, 0 failed (dxil 1.8.2502.11validated).aaf2c78:@fromthemoonx(NVIDIA RTX 3060):1067 passed, 0 failed, 45 ignored,disable_math_refactoring_tests10/10.@DavidM1911(NVIDIA RTX 3060 Ti):cargo test -p xcl --libpassed,0failed.@pablogonz12(AMD RX 9070 XT, Linux/Wine/RADV):+5/5disable_math_refactoring_tests,0regressions vs base.@JJAutoCompare:disable_math_refactoring_tests5/5passed withdxil 1.9.2609.5.@Toons29(AMD Radeon RX 9070): 60 sscripts/smoke.ps1pair passed (1634vs1566frames,0device removals,0crashes).Regression run
60 s
scripts/smoke.ps1pair on exact headaaf2c788vsmain568e7db7(AMD Radeon RX 9070, driver 32.0.32029.2010, Windows 11 26300, release,XCL_NETWORK=0on a retail title), contributed by@Toons29:main:
this PR:
Not tested
AI use
@futurepro62 on GitHub · 2026-11-25 00:26 UTC · original · edited 2026-11-25 00:38 UTC
Full-suite run, since this PR has no test report yet. Tested exact head
cda8355(on its base80f4819).Tested
cargo build --workspace, thenXCL_REQUIRE_GPU=mesh cargo test --workspace -- --test-threads=4 --skip heap_window_out_of_memory_falls_back_to_the_switch_form --skip gpu::recomp::lower_dxil::tests::f16_programs_on_the_gpu --skip gpu::recomp::lower_dxil::tests::f32_programs_on_the_gpu --skip gpu::recomp::lower_dxil::tests::integer_programs_on_the_gpu --skip gpu::recomp::lower_dxil::tests::f64_programs_on_the_gpu --skip gpu::recomp::lower_dxil::tests::const_and_null_mask_operands_agree_with_hlsl_on_the_gpu --skip gpu::dxil::fuzz_tests: 987 passed, 0 failed, 43 ignored. SKIPPED (no wave64):a_2d_or_3d_group_agrees_with_the_hlsl_path_on_the_gpu,a_per_lane_2d_or_3d_group_runs_on_the_gpu,coalesced_guarded_runs_agree_with_the_hlsl_path_on_the_gpu,cross_lane_reads_agree_with_the_hlsl_path_on_the_gpu,gpu_geometry_wave32_prefix_count_over_a_mask,gpu_wave32_program_in_wave64_hardware,the_wave64_lowering_agrees_with_the_hlsl_path_on_the_gpu.compute_unfused_mad_sets_disable_math_refactoring,pixel_unfused_mad_sets_disable_math_refactoring,fmad_suppresses_disable_math_refactoring_in_compute_and_pixel,plain_float_add_does_not_set_disable_math_refactoring,dead_fmad_eliminated_by_dce_still_allows_disable_math_refactoring.XCL_ADAPTER=radeon),cargo test --workspace -- --test-threads=4 --skip gpu::dxil::fuzz_tests::fuzz_validate_and_gpu_1: 997 passed, 0 failed, 45 ignored. SKIPPED:f16_programs_on_the_gpu(f16 arithmetic, wave32, per-lane form: refused (unsupported V_MUL_F16 (its #1426 semantics differ from the console's))),f16_programs_on_the_gpu(f16 arithmetic, wave64, per-lane form: refused (unsupported V_MUL_F16 (its #1426 semantics differ from the console's))),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))),f16_programs_on_the_gpu(f16 packed, wave64, per-lane form: refused (unsupported V_PK_MUL_F16: VOP3 modifiers (its #1426 semantics differ from the console's))),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))),f32_programs_on_the_gpu(f32 conversions, wave64, per-lane form: refused (unsupported V_CVT_F16_F32 (its #1426 semantics differ from the console's))),heap_window_out_of_memory_falls_back_to_the_switch_form(no heap windows).--skipleaves out tests that fail on main80f4819too, not because of this PR. On NVIDIA:heap_window_out_of_memory_falls_back_to_the_switch_form(#1651), the fourgpu::recomp::lower_dxil::tests::*_programs_on_the_gputests andconst_and_null_mask_operands_agree_with_hlsl_on_the_gpu(follow-up on #1651) fail becauserunner::skip_testturns their skips into failures underXCL_REQUIRE_GPU=mesh, andgpu::dxil::fuzz_testsseeds 70, 545, 1019 and 1507 failCreateComputePipelineStatewithE_OUTOFMEMORYon this card (drivers 616.64 and 621.40). On AMD:fuzz_validate_and_gpu_1fails on seed 540 (res[833]0x7 vs CPU 0x6). The AMD run does not setXCL_REQUIRE_GPU.Not tested
AI use
@raylitebull on GitHub · 2026-11-25 00:39 UTC · original
Thanks for catching that, @fromthemoonx!
Updated
#1973cleanly on top of6567c5fin commit7dfa64cto bumpTRANSLATOR_VERSIONfrom7to8incrates/xcl/src/gpu/dxil/kernel.rsso existingXCL_DIRECT_DXILdisk caches invalidate and regenerate containers withDisableMathRefactoring.Verified with
cargo check --workspace --testsandcargo test -p xcl --lib disable_math_refactoring_tests(5 passed, 0 failed,dxil 1.8.2502.11).@raylitebull on GitHub · 2026-11-25 01:14 UTC · original
Rebased
#1973cleanly onto656c0e8in commitaaf2c78withTRANSLATOR_VERSIONbumped from8to9incrates/xcl/src/gpu/dxil/kernel.rs(after#1950bumped7 -> 8), ensuring existingXCL_DIRECT_DXILdisk caches regenerate withDisableMathRefactoring— thanks again,@fromthemoonx!Verified with
cargo check --workspace --testsandcargo test -p xcl --lib disable_math_refactoring_tests(5 passed, 0 failed,dxil 1.8.2502.11validated).@pablogonz12 on GitHub · 2026-11-25 02:04 UTC · original
Test report for head
aaf2c78(base656c0e8), on the platform the description lists as not tested: Linux / Wine / RADV. It passes here with no regression; the one red assertion the description's test has on this GPU is pre-existing and unchanged.Tested
v3.1.1-235-gf90f1bf180f4135(the GE-Proton build), DXC 1.9.2609.5 (dxcompiler + dxil01b62ad4), rustc 1.100.0, release, static CRT (RUSTFLAGS=-C target-feature=+crt-static),x86_64-pc-windows-msvcbuilt withcargo xwin, run under Wine.xcllib suite,--test-threads=4, same command on both commits:656c0e8(base): 1001 passed, 9 failed, 25 ignoredaaf2c78(this head): 1006 passed, 9 failed, 25 ignored — the +5 aredisable_math_refactoring_tests; the nine red are the same nine.gpu_f64_roots,gpu_f64_math_random,gpu_nonfused_mad_and_mac_prevent_fma_contraction,gpu_depth_buffer_created_for_unordered_access_is_placed(#1475 fixes it, not merged),xma2_source_voice_decodes_and_manages_lifetime(Wine FAudio, #890/#1557),lower_dxil::tests::{f32,f64}_programs_on_the_gpuanddxil::round_tests::directed_reference_basics(the hostfmafunder Wine),dxil::fuzz_tests::fuzz_validate_and_gpu_2.integer_ops_match_cpu,uaddc_and_usubb_match_cpu,jumps_to_outer_loop_heads_are_structured. That is a RADV access violation insidelibvulkan_radeon.soduringvkCreateComputePipelines(exit 3), present on unmodifiedmainfor days and unrelated to this PR.disable_math_refactoring_tests: 5 passed, 0 failed on this head, both with and withoutXCL_DIRECT_DXIL=1.gpu_nonfused_mad_and_mac_prevent_fma_contraction, single test,--test-threads=1, base and head,XCL_DIRECT_DXILunset and=1(4 runs): every run stops at the same place,v_fma_f32 overflow control should stay fused, left2139095040(0x7F800000), right1946157055(0x73FFFFFF). Thev_mac_f32/v_mad_f32/v_madak_f32vectors above that assertion pass on both commits, with and without the flag, so on gfx12 the unfused lowering was already un-contracted here andDisableMathRefactoringchanges nothing measurable for this test. The red is the lonev_fma_f32control, which RADV on gfx12 rounds twice — the same failure as in #676; NVIDIA and RDNA2 do not see it (RDNA2 report in #676).Not tested
scripts/smoke.ps1pair for this runtime change, and the retail title.AI use
@fromthemoonx on GitHub · 2026-11-25 00:28 UTC · original · edited 2026-11-25 02:07 UTC
Update:
TRANSLATOR_VERSIONneeds10now. #1992 merged with9(daf52ab, "translator version 9 (main took 8)"), and #1742 followed. This PR also sets9, so it still merges cleanly intomain025c786(both sides write the same line), and git will not flag it. But caches built by currentmainunderXCL_DIRECT_DXILwould then be reused withoutDisableMathRefactoring.Rerun on the new head
aaf2c78(rebased,TRANSLATOR_VERSION9): still passes on the RTX 3060, and the cache point below is resolved.cargo test --workspace --no-fail-fast -- --test-threads=4: 1067 passed, 0 failed, 45 ignored.disable_math_refactoring_tests: 10 of 10. #1742 also changes direct-DXIL output without a bump yet, so whichever of the two merges second needs10. The report below is forcda8355.Passes on an RTX 3060 (Ampere). The new tests fail without the fix. One gap:
TRANSLATOR_VERSIONis not bumped, so cached direct-DXIL translations keep the old flags.The cache. This PR changes the emitted containers (entry flags bit 1) for every program with an unfused
v_mad_f32/v_mac_f32. The direct translator's disk-cache identity isTRANSLATOR_VERSION(gpu/dxil/kernel.rs:40). Its comment says to bump it on any change that alters the emitted containers, becausebuild.rs'sTRANSLATOR_SOURCEShashes onlygpu/recomp, notgpu/dxil. Without a bump, a title run withXCL_DIRECT_DXILand an existing cache keeps loading the translations withoutDisableMathRefactoring. #1966 bumps the same line 7 → 8, so whichever PR merges second needs the next number. #1947 would make this automatic, but it is still open.What this run adds to the RTX 5070 Ti report above:
cda8355(already on main80f4819, so this is also the merged tree).cargo build --workspace+cargo test --workspace --no-fail-fast -- --test-threads=4with no--skipand noXCL_REQUIRE_GPU: 998 passed, 0 failed, 45 ignored. 23 SKIPPED: 19 for no wave64 (wave32 card), 3 per-lanelower_dxilrefusals (V_MUL_F16,V_PK_MUL_F16,V_CVT_F16_F32; main skips the same way) andheap_window_out_of_memory_falls_back_to_the_switch_form(no heap windows).disable_math_refactoring_testspass 10/10 runs.self.s.require(Feature::DisableMathRefactoring)line inLw::mad_nfremoved, 3 of the 5 fail (compute_unfused_mad_…,pixel_unfused_mad_…,dead_fmad_eliminated_by_dce_…). The other 2 still pass, as expected, because they assert that the flag is absent.XCL_DIRECT_DXIL=1 cargo test -p xcl --lib gpu:: -- --test-threads=1 --skip gpu_sparse_vram: PR 468 passed / 0 failed / 21 ignored; main80f4819463 / 0 / 21 (the difference is the 5 new tests).gpu_nonfused_mad_and_mac_prevent_fma_contractionpasses on both, so this driver did not contract that program on main either: on this card the flag changes no result the suite can see.XCL_DIRECT_DXIL=1 cargo test -p xcl --test e2e: 3 passed.Hardware: RTX 3060 12 GB, driver 610.88, Windows 11 Pro 26300, Rust 1.100.0 MSVC, DXC / dxil 1.9.2602.17, debug.
Not tested: AMD, a release build,
scripts/smoke.ps1(no title on this machine), a program whose result changes with FMA contraction on NVIDIA.AI use: Claude Code (Claude Opus 5.5) ran the tests and wrote this report.
@JJAutoCompare on GitHub · 2026-11-25 03:12 UTC · original
Tested
Clean head
aaf2c788f5f6262a6e20b2e2a6de63e4b5dfa81c. The remote PR ref and open GitHub PR page showed this SHA before and after the run. PR #1973stable-x86_64-pc-windows-msvc), unoptimized test profile.dxcompiler.dll1.9.2609.5 (01b62ad4) anddxil.dll1.9.2609.5 fromXCL_DXC_DIR.Result — 5 passed, 0 failed, 0 ignored, 0 skipped, 1,038 filtered out. Cargo exited 0. The five tests reached seven explicit DXIL validator calls and seven matching disassemblies, with zero validator skips.
V_MAD_F32andV_MAC_F32each set entry-pointDisableMathRefactoring(bit 1).V_MAD_F32with an exported result emitted livefmul floatandfadd floatand set bit 1.V_MAD_F32andV_FMA_F32retained DXILFMad(opcode 46) and left bit 1 clear in compute and pixel.V_ADD_F32left bit 1 clear.FMadand the entry-point flags retained bit 1.Not tested
GPU execution, driver-level contraction or numerical parity, disk-cache behavior, malformed inputs, the full suite, release builds, and retail-title smoke runs.
AI use
T3 Code / Codex (
gpt-6.2-sol) ran the checked-in tests, verified the output, and wrote this report.@DavidM1911 on GitHub · 2026-11-25 03:19 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!
@Toons29 on GitHub · 2026-11-25 10:24 UTC · original
Regression run of
aaf2c788on the retail title, for this PR's Regression run section. Both blocks are fromscripts/smoke.ps1as printed, not edited:mainon568e7db7, this PR on its head commit with no uncommitted changes, same title and time.Against the limits in CONTRIBUTING.md: 104 % of
main's frames, 101 % of its peak commit, no crash, no device removal.AMD Radeon RX 9070 (RDNA4, driver 32.0.32029.2010), Ryzen 7 7800X3D, 32 GB, Windows 11 build 26300, Rust 1.100.0,
cargo build --release -p xcl, 60 s,XCL_NETWORK=0. This is a regression check only: it does not show whether the run reaches the code this PR changes.AI use: Claude Code (Claude Opus 5.5) built both trees and ran
scripts/smoke.ps1; a script posted this right after the run, with both blocks exactly as printed.@raylitebull on GitHub · 2026-11-25 10:45 UTC · original
Thanks @Toons29 for the exact-head RX 9070 60 s
scripts/smoke.ps1pair onaaf2c78(0 device removals, 0 crashes) — added to the PR description! Thanks also to @pablogonz12 (RX 9070 XT Wine/RADV), @fromthemoonx (RTX 3060), @DavidM1911 (RTX 3060 Ti), and @JJAutoCompare for verifyingaaf2c78.Re
#1947/TRANSLATOR_VERSION: now that #1947 (XCL_DIRECT_DXIL_SOURCE_IDincrates/xcl/src/gpu/dxil/kernel.rs) has landed onmain, direct-DXIL disk caches automatically invalidate on anygpu/dxil/*source edit without needing aTRANSLATOR_VERSION = 10bump (andTRANSLATOR_VERSION = 9merges cleanly withmain).