Recompiler: keep v_fma_f64 precise so a driver cannot split it #2109
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/2119"
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 ivall/xcl. Originally posted by pablogonz12 on 2026-11-25T05:03:01Z.
The HLSL path emitted
v_fma_f64as a plainfma(). DXC then left thedx.op.tertiaryFma call without!dx.precise, vkd3d-proton gave RADV anOpExtInst FmawithoutNoContraction, and RADV split that fma when the shader already computed the samea * b: it merged the two products and rounded twice.v_fma_f64(x, x, -(x * x))returned0instead of the rounding error of the product (2^-56 + 2^-104,0x3C70000000200000), so any f64 fma whose product is also written elsewhere in the shader loses its fused result on RADV.v_fma_f64now goes throughfma_d(), whose result isprecise. Related: #472 is the f32 form of an unfused fma (mad()on RDNA1); this is the f64 form, which needs only that the host passespreciseon.What is in it
crates/xcl/src/gpu/recomp/emit.rs:v_fma_f64emitsfma_d(...);fma_dis defined in the prelude besidemad_nfand computes the fma in aprecisedouble.crates/xcl/src/gpu/recomp/tests.rs:gpu_v_fma_f64_stays_fused_beside_the_same_productcompiles with the runtime's own DXC arguments (no-Gis), runsp = x * xandfma(x, x, -p)on the GPU and checkspand the exact residual.Evidence
7b5f620(disassembled withdxil::validate::disassemble, there is nodxc.exeon this machine):call double @dx.op.tertiary.f64(i32 47, …), !dx.precise !12 ; Fma(a,b,c).VKD3D_SHADER_DUMP_PATHon the same commit:%81 = OpFMul %doubledecoratedNoContraction, theFmadecoratedNoContractionas well. Before the change theFmahad no decoration.d3d12core.dllour test prefix has (dxil-spirv7c048638is in the tree, but that DLL was built beforefd92a550"Handle precise for full FMA opcode") and passes with vkd3d-proton master30b0eb9(dxil-spirv34f0ff8) and with our patched v3.1 rebuilt today (10c5f7c4). The fix therefore takes effect with any vkd3d-proton whose dxil-spirv containsfd92a550; on an older one the host dropspreciseforFmaand nothing in XCL can keep the fma fused on that path.Tested
cargo xwinx86_64-pc-windows-msvc,-C target-feature=+crt-static, release.xcllib suite,--test-threads=4, skippinginteger_ops_match_cpu,uaddc_and_usubb_match_cpu,jumps_to_outer_loop_heads_are_structured(they kill the lib test binary on RADV; #1246, separate):6987e491085 passed, 10 failed, 26 ignored; this head7b5f6201088 passed, 8 failed, 26 ignored (head's extra failure is the new test, which stays red on that stale DLL; the 3 title-textures / d32s8 failures of main's run passed on head)10c5f7c4): main6987e491088 passed, 7 failed, 26 ignored; this head7b5f6201089 passed, 7 failed, 26 ignored — the same 7 on both (fuzz_validate_and_gpu_2,directed_reference_basics,lower_dxilf64 and f32,gpu_nonfused_mad_and_mac_prevent_fma_contraction, depth-UAV placement,xma2_source_voice), and the new test passes.e2e,pls_quota,predication_e2eand the other 14 test binaries), one thread: the same 3 failures on main and on head (e2econsole-screen cloak,pls_quotaWineERROR_FILE_NOT_FOUND,predication_e2ecopies not predicated by vkd3d-proton).SKIPPEDon this adapter: the four f16 / f32-conversion programs oflower_dxil(unsupportedV_MUL_F16semantics, #1426), unchanged by this PR.Regression run
Both blocks are the output of each commit's own unmodified
scripts/smoke.ps1, written to a file by PowerShell and pasted as is. It ran in Windows PowerShell 7.7.0 (pwsh.exe) under Wine (GE-Proton11-14, Linux), not on native Windows, with MinGit 2.56.1 forgit;xcl.exeis an MSVC release build (cargo xwin, static CRT), passed with-Xcl. Host workarounds outside the script: a pseudo-terminal,DOTNET_SYSTEM_GLOBALIZATION_USENLS=1, and importing PowerShell's Utility and Management modules before calling it.mainis this PR's base commit. These replace the earlier blocks from a bash port. Frame counts at this speed are small; I read them only as no crash or device removal. Each commit was run once. Note that this title can end in a device removal on this host even onmain(seen in repeat runs of another base commit, see #464).main:This PR's head:
Not tested
NoContractionon theFma, so the fma should stay fused, but I did not measure it.v_fma_f64with the same product written elsewhere; no title was checked for a change in output.XCL_DIRECT_DXIL: itsFmastill carries nodx.preciseand itsf64_programs_on_the_gpufails the same way; that is a separate change ingpu/dxil.AI use
fma_dand the test, dumped the DXIL and SPIR-V, ran the suite, the integration tests and the two smoke runs, and wrote this description. I checked every line of the diff and every number above.Imported from ivall/xcl. Originally posted by futurepro62 on 2026-11-25T05:19:00Z.
Full-suite run, since this PR has no test report yet. Tested exact head
7b5f620(on its base6987e49).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::recomp::lower_dxil::tests::mask_ff0_and_flbit_agree_with_hlsl_on_the_gpu --skip gpu::dxil::fuzz_tests: 1143 passed, 0 failed, 44 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.gpu_v_fma_f64_stays_fused_beside_the_same_product.XCL_ADAPTER=radeon),cargo test --workspace -- --test-threads=4 --skip gpu::dxil::fuzz_tests::fuzz_validate_and_gpu_1: 1154 passed, 0 failed, 46 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 main6020a33too, 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,const_and_null_mask_operands_agree_with_hlsl_on_the_gpuandmask_ff0_and_flbit_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
Imported from ivall/xcl. Originally posted by DarkPanda69 on 2026-11-25T05:23:59Z.
Tested:
gpu_v_fma_f64_stays_fused_beside_the_same_productpasses on an AMD D3D12 driver and on an RTX 3060.gpu::filter: 585 passed, 2 failed, 22 ignored. The 2 failures are the AMD fuzz seeds 722 and 1599 tracked in #2115, which fail the same way onmain.Head
7b5f620applied onmain6020a33,cargo test -p xcl --lib -- gpu:: --test-threads=4withXCL_ADAPTERset to each card.Not tested: retail runs, and nothing beyond what the test itself asserts about the fused result.
AI use: Claude Code (Claude Opus 5.5) ran the tests on this machine and wrote this report.
Imported from ivall/xcl. Originally posted by JoaoPauluu on 2026-11-25T06:12:07Z.
A run with vkd3d-proton as the host D3D12. The DXIL goes through dxil-spirv and then the NVIDIA Vulkan driver, not the native-Windows path: this PR's new test passes, none skipped.
Tested
x86_64-pc-windows-gnu.7b5f620as it is (merge base withmain6987e49), no uncommitted changes. The lib test binary runs under Wine, one test per process.gpu_v_fma_f64_stays_fused_beside_the_same_product: okNot tested
AI use
Imported from ivall/xcl. Originally posted by DavidM1911 on 2026-11-25T06:17:44Z.
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!
Imported from ivall/xcl. Originally posted by jennydeth on 2026-11-25T14:23:06Z.
Native Windows run on an NVIDIA D3D12 driver (listed under Not tested).
Setup: RTX 3060 12 GB (32-lane waves, driver 32.0.16.2101), Ryzen 5 5600X, 32 GB RAM, Windows 11 build 26300, Rust 1.100.0, DXC 1.9.2609.5, debug build. Head
7b5f620.Result: cargo test --workspace -- --test-threads=4: 1155 passed, 0 failed, 46 ignored. SKIPPED: 18 GPU tests for no wave64 (expected on this card); the per-lane refused cases; heap windows; driver cache.
Not tested: AMD; a title run.
AI use: Claude Code (Claude Opus 5.5) ran the tests and wrote this report.
Imported from ivall/xcl. Originally posted by luckyteagirl on 2026-11-26T09:06:39Z.
Review: COMMENTED
The new
gpu_v_fma_f64_stays_fused_beside_the_same_producttest on7b5f620only callsgpu_ready(), which checks adapter, wave support, and DXC but not shader FP64. It then unconditionally compiles and runs a shader withdoubleoperations. A reported XCL test adapter, Intel Arc A770, returnsDoublePrecisionFloatShaderOps=0(hardware report); on such a device the new test can fail during PSO creation before it checks fused rounding. D3D12 exposes this requirement throughD3D12_FEATURE_DATA_D3D12_OPTIONS(Microsoft reference).Could the test query that option on the adapter selected by the runner and skip the GPU execution when FP64 is unsupported? A CPU-side check of the emitted precision metadata could still exercise translation on those adapters. This is source and capability-report review only; I did not run this test on an FP64-limited GPU.
Imported from ivall/xcl. Originally posted by pablogonz12 on 2026-11-26T10:23:13Z.
Thanks — confirmed, and it is wider than this PR's test.
Checked at head
7b5f620:gpu_v_fma_f64_stays_fused_beside_the_same_product(crates/xcl/src/gpu/recomp/tests.rs:7759) gates ongpu_ready()(tests.rs:13) only: adapter,wave64_programs_supported()anddxc::location(). No FP64 check, as you say.6987e49gate the same way:gpu_f64_class_compare,gpu_rndne_f64,gpu_frexp_f64_exp_and_mant,gpu_f64_rounding_and_conversions,gpu_f64_roots,gpu_ldexp_f64,gpu_f64_compares_with_nan,gpu_f64_math_random,gpu_f64_literal_high_word.crates/xcl/src/gpuasks forD3D12_OPTIONS.DoublePrecisionFloatShaderOps:runner::adapter()queriesD3D12_FEATURE_SHADER_MODEL,D3D12_OPTIONS1andD3D12_OPTIONS7(mesh). So on an adapter such as the A770 the nine tests that exist onmainshould fail the same way; this PR adds a tenth test of that shape, not a new hardware requirement.precise double r = fma(a, b, c);(emit.rs:6164). An assertion on the!dx.precisemetadata would still need DXC, which the DXC-gated tests here already need, but it would only cover the translation half, not the execution this PR is about.About the fix: it is not a one-line test change. It needs a capability helper in
gpu/recomp/runner.rsbesidemesh_shaders_supported(), askip_test("no fp64")in all ten f64 tests, and a mapping forXCL_REQUIRE_GPU, becauseskip_testcounts any reason other than"no mesh shaders"as a failure underXCL_REQUIRE_GPU=wave64(runner.rs:617-625) — an unmapped"no fp64"would turn a skip into a red test on that runner. If a maintainer wants that on this branch, we will push it here as one commit; otherwise a separate PR covering all ten tests is the honest scope, since it changesmain's f64 coverage too.AI use: prepared with AI assistance (DeepSeek), report only — the file and line references above were read from the source at
7b5f620.Imported from ivall/xcl. Originally posted by thehollowedone on 2026-11-28T08:53:40Z.
merge-check
base:
e429936c10head:
7b5f620228merge: clean; the trial merge changes only
crates/xcl/src/gpu/recomp/emit.rsandtests.rs(+36/-1).build:
cargo build --offline --locked -j 4 --workspace-> ok on the trial merge and untouched main.tests:
cargo test --offline --locked -j 4 --workspace --no-fail-fast -- --test-threads=4-> trial merge 2,125 passed, 11 failed, 48 ignored; untouched main 2,124 passed, 11 failed, 48 ignored. Both printed 25SKIPPEDGPU/environment notices. The same 11 tests failed with matching signatures on both: threedispatch_chain_*split tests,gpu_heap_flat_reads_match_guarded_and_root_output,console_mesh_caches_hlsl_compute_pass_in_memory_and_on_disk,gpu_compute_mode_dispatch_abi,gpu_float_cas_uses_ieee_equality, threetest_title_*e2e tests, andtwo_pass_driver_cache_reuses_both_passes_and_recovers_corrupt_blobs. The latter launches a child test process whose own failure summary appears in Cargo's log; I counted it once. The newgpu_v_fma_f64_stays_fused_beside_the_same_productpassed on the RTX 3080 Ti with no skip. Neither suite is green on this machine.review: the full two-file diff has no apparent arithmetic-path blocker:
fma_dkeeps the three operands and marks the resultprecise, and the new test checks both the rounded product and nonzero fused residual. The previous FP64 capability review remains unresolved in this head.gpu_ready()does not checkD3D12_OPTIONS.DoublePrecisionFloatShaderOps; an FP64-limited adapter can fail at pipeline creation before the new assertion. The author confirmed the same gap in nine existing f64 tests. To close it, query FP64 support on the runner's selected adapter, skip those f64 tests only when unsupported, and letXCL_REQUIRE_GPU=wave64or=meshacceptno fp64as a separate capability skip. Verify the skip on an FP64-limited adapter and the numeric assertions on an FP64-capable one. This is a portability finding, not a failure reproduced on my GPU.performance:
precisecan constrain optimization of f64 FMA in shaders that use it; there is no new persistent allocation or CPU frame-loop work. I did not measure shader compile or frame time.verdict: not yet: resolve the acknowledged FP64 test gate for hardware without shader FP64, or document a maintainer decision to track the existing f64-suite limitation separately. The arithmetic regression itself passed here, and the trial merge introduced no failure relative to this main control.
hardware / tool and model: Windows 11 build 26300, Ryzen 7 9800X3D, NVIDIA RTX 3080 Ti driver 621.35, DXC 1.8.2502.11; Codex (GPT-6.2 Sol) performed the merge, build, tests, baseline comparison, and synthesis; Codex (GPT-6.2 Astra) independently reviewed the source and FP64 capability path.
Imported from ivall/xcl. Originally posted by throny on 2026-11-28T14:26:55Z.
merge-check claim
head:
7b5f620228Imported from ivall/xcl. Originally posted by throny on 2026-11-28T14:40:16Z.
merge-check
base:
b937fbabhead:
7b5f620228merge: clean
build: cargo build --workspace -> ok
tests: cargo test --workspace --no-fail-fast -- --test-threads=4 -> 2141 passed, 1 failed, 48 ignored (26 SKIPPED lines). The one failure is gpu::dxil::msaa_tests::direct_msaa_loads_precede_get_dimensions, which main itself has at
b937fbab(#3093); base alone: 2140 passed, 1 failed, 48 ignored.review: no blocking finding. Two notes: the direct-DXIL lowering still emits a plain fma for this instruction without the precise marker (an opt-in path; whether it needs the same I could not tell), and whether the marker really keeps a driver from splitting the operation cannot be shown here beyond the test passing, as it does in the testers' runs on three vendors. Open from the thread: the test, like the nine f64 tests already on main, checks only that a GPU is there and not that it supports double precision, so on a GPU without it the test fails instead of skipping.
performance: none expected (one precise fma). It changes a translator source: every tester re-translates all shaders once.
verdict: safe to merge
hardware / tool and model: RTX 4080 16 GB (621.40), i9-12900K, Windows 11 26300, Rust 1.100.0, debug. Claude Code; merge, build and suite run by Claude Fable 5.2, diff review by Claude Opus 5.5 (every hunk read; nothing run on the GPU beyond the suite).
Imported from ivall/xcl. Originally posted by Foniass on 2026-12-01T07:25:03Z.
Triage (#1607) – head
7b5f620No open or merged PR makes the same change; main still emits a plain
fma(...)for v_fma_f64 inemit.rs.No problems found in the diff. The GPU test only shows the bug on a driver that splits the fma (RADV through vkd3d-proton, per the comment), so on other drivers it passes with or without the fix.
Recommendation: keep open.
AI review: Claude Code (Claude Opus 5.5), diffs read only, not built or run; not checked by a human.
View command line instructions
Checkout
From your project repository, check out a new branch and test the changes.Merge
Merge the changes and update on Forgejo.Warning: The "Autodetect manual merge" setting is not enabled for this repository, you will have to mark this pull request as manually merged afterwards.