Recompiler: preserve zero sign in HLSL f16 multiplies #2173
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/2183"
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 luckyteagirl on 2026-11-25T08:11:22Z.
Fixes the f16 multiplication signed-zero part of #2168 on the default HLSL backend. On the RX 6800M, DXC fast math can turn a negative-zero product into positive zero for
V_MUL_F16andV_PK_MUL_F16; direct DXIL preserves the sign. A global-Gisswitch also changes FMA results on this card, so this patch repairs only the two multiply forms.What is in it
Tested
abcf799a3a08766a62a645f2159a3f9e82e9459conmain6d12f58a229bc73889878a448c64dc3af25eeba0; Windows 11 Home build 26200, Ryzen 9 5980HX, Radeon RX 6800M driver30.0.13002.13003, Rust 1.99.0 MSVC, DXC/DXIL 1.8.2502.11.cargo test --locked -p xcl --lib -j 2 gpu_f16_multiply_preserves_zero_sign -- --test-threads=1 --show-output, withXCL_ADAPTER=6800MandXCL_REQUIRE_GPU=wave64: 1 passed, 0 failed, 0 ignored, 0 SKIPPED withXCL_DIRECT_DXIL=0, and the same counts withXCL_DIRECT_DXIL=1. The two guarded runs did not trigger the memory guard.cargo build --locked --release -p xcl --bins -j 2: passed under the 1 GiB free-commit guard with no trigger on the retry. An earlier attempt was guard-stopped before completion when unrelated jobs exhausted free commit; it produced no build result.git diff --check: clean..\scripts\test.ps1completed with 1,424 passed, 0 failed, 46 ignored, and 25 explicit GPU skips (21 native-wave64, one heap-window, three refused per-lane forms). The focused f16 regression passed. A separate 60-second release title smoke showed 1,563 frames, 15,387 MB peak, and zero crashes/device removals against a same-machinemainbaseline of 1,605 frames and 15,009 MB. These are the independent reporter's results, not runs on our RX 6800M.46b7744: the RX 6800M fuzzer comparison found 26/256V_MUL_F16and 49/256V_PK_MUL_F16HLSL/direct differences before the emitter change, and 0/256 for each after it. Its full workspace run reported 993 passed, 162 failed, 46 ignored; 161 of the failed names matched a prior clean-main run after this old AMD driver suspended the device. These are not current-head suite results.Regression run
The committed release binaries for the tested
mainbase (6d12f58) and this PR ran the same locally owned title on the RX 6800M for five seconds each, with separate data and shader caches. Both exited normally with no crash, device removal, or memory-guard trigger, but neither reached a frame; these runs cover startup only. A separate seven-second main run showed six frames, while the seven-second head attempt hit the unchanged 1 GiB free-commit guard at 713 MB and produced no smoke block. The focused GPU fixture above exercises the changed f16 instructions.Tested
mainbase:This PR:
On an RTX 3070, ramon-victor reported an independent 60-second retail comparison on this exact clean PR head and main
08db802. The PR showed 1,563 frames and 15,387 MB peak commit. The reported main baseline showed 1,605 frames and 15,009 MB. Both reported zero crashes or device removals. The report includes the PR's raw smoke block and summarizes the main run, so the paired raw blocks above remain the recorded comparison for the checker. The independent smoke reached rendered frames, with no verified coverage of the changed f16 instructions. Independent RTX 3070 reportNot tested
AI use
OpenAI Codex (GPT-6; exact variant unavailable) implemented the fix and regression, rebased the commit, ran the current-head focused GPU checks and guarded release/smoke runs, reviewed logs, and drafted this description.
OpenAI Codex (GPT-6.2 Astra) verified the independent exact-head report and added its linked results to this description.
OpenAI Codex (GPT-6.2 Sol) added the attributed positive-frame comparison to the regression section and verified the PR checker without changing the code.
Imported from ivall/xcl. Originally posted by Diskuss on 2026-11-25T08:22:41Z.
Tested on AMD Radeon RX 9070 XT (RDNA4) at
46b7744cc9c39eb8f8cf06ea2c95e5164abcdf9bAMD Radeon RX 9070 XT, driver 32.0.32015.7029; Ryzen 7 5700X3D; 32 GB; Windows 11 Pro build 26300.9974; Rust 1.100.0 msvc; DXC 1.9.2602.17; debug build. The head is directly on top of main
568e7db(0 commits behind), tested as is.Tested:
cargo build --workspace: ok.cargo test -p xcl --lib gpu_f16_multiply_preserves_zero_sign -- --test-threads=1: 1 passed, 0 failed.cargo test --workspace --no-fail-fast -- --test-threads=4: 1153 passed, 2 failed, 46 ignored. Failures:fuzz_validate_and_gpu_1andfuzz_validate_and_gpu_3(the known #2115 failures). 0 device removals.568e7dbon this machine: 1152 passed, 2 failed, 46 ignored, same two failures. The +1 passed is the new test.refusedcases citing #1426, the PSO measurement without Developer Mode,heap_window_out_of_memory_falls_back_to_the_switch_form).Not tested: the #2168 cross-backend fuzzer (it is not on main, so I did not check the v_sin/v_cos or ldexp cases before/after), retail title /
scripts/smoke.ps1(no game files), release build.Update: #2169 fuzzer comparison (asked for by DarkPanda69). Base:
main568e7dbplus #2169e792e6b; head:46b7744plus #2169e792e6b. Both local merges, no conflicts, not pushed. Debug build,XCL_FUZZ_OPS=V_MUL_F16,V_PK_MUL_F16,V_LDEXP_F16,V_SIN_F16,V_SIN_F32,V_COS_F32,V_FMA_F16,V_PK_FMA_F16,cargo test -p xcl --lib valu_fuzz_backends_agree -- --ignored --test-threads=1(256 inputs per instruction, default 4 rounds):main+ #2169V_MUL_F16V_PK_MUL_F16V_LDEXP_F16V_SIN_F16V_SIN_F32V_COS_F32V_FMA_F16,V_PK_FMA_F16Instructions with differences: 6 on
main, 4 with the PR. Same numbers for both multiplies as DarkPanda69's RX 9070 run. The ldexp/sin/cos differences are unchanged (out of scope for this PR).Report written by Claude Code (Claude Sonnet 5.5) from a real run on this machine.
Imported from ivall/xcl. Originally posted by DarkPanda69 on 2026-11-25T08:34:28Z.
Update for head
abcf799: rerun onmaine1d84b7, with #2169e792e6bfor the fuzzer, same commands and cards. The table below holds at this head: RX 9070 XTV_MUL_F1626 → 0 andV_PK_MUL_F1649 → 0, the other instructions unchanged; RTX 3060 0 differences before and after.gpu_f16_multiply_preserves_zero_signok on both. Wholegpu::filter with this PR: RX 9070 XT 699 passed, 2 failed (the #2115 fuzz seeds), 6 SKIPPED; RTX 3060 701 passed, 0 failed, 24 SKIPPED.The #2169 fuzzer before and after this PR on RDNA4 and on NVIDIA ("other GPU vendors" is listed as untested, and the RDNA4 report above didn't run the fuzzer).
Head
46b7744and #2169e792e6bapplied onmain568e7db, debug,XCL_FUZZ_OPSlimited to the f16/sin/cos instructions of #2168,cargo test -p xcl --lib valu_fuzz_backends_agree -- --ignored --test-threads=1(256 inputs per instruction):mainmainV_MUL_F16V_PK_MUL_F16V_LDEXP_F16,V_SIN_F16,V_SIN_F32,V_COS_F32V_FMA_F16,V_PK_FMA_F16So the fix removes both multiply differences on RDNA4 too, and changes nothing on NVIDIA, where the HLSL path already kept the sign.
gpu_f16_multiply_preserves_zero_signpasses on both cards; wholegpu::filter with this PR: RX 9070 XT (driver 32.0.32029.2010) 585 passed, 2 failed (the #2115 fuzz seeds, same onmain); RTX 3060 (32.0.16.1088) 587 passed, 0 failed.Not tested: a title.
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 DavidM1911 on 2026-11-25T15:39:42Z.
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 ramon-victor on 2026-11-25T23:57:07Z.
Independent NVIDIA (wave32) full-suite + retail smoke test report on exact PR head
abcf799a3a08766a62a645f2159a3f9e82e9459c(clean detached checkout, no local changes).Tested
x86_64-pc-windows-msvc), DXC/DXIL 1.8.2502.11 (Windows SDK 10.0.26100.0); debug tests, release smoke.cargo test -p xcl --lib gpu_f16_multiply_preserves_zero_sign): 1 passed, 0 failed..\scripts\test.ps1): 1424 passed, 0 failed, 46 ignored (25 GPU skips expected on this wave32 adapter: 21no wave64, 1no heap windows, 3 wave32 per-lane refused for#1426f16/f32 semantics).cargo build --release -p xcl) and 60 s retail smoke run (XCL_NETWORK=0, compared againstmain @ 08db802baseline on the same machine today:1605frames,15009 MBpeak commit,0crashes,0device removals):Regression run
Not tested
XCL_SAMPLE_*tests (unset).AI use
Imported from ivall/xcl. Originally posted by DavidM1911 on 2026-11-26T08:15:27Z.
Re-verification on RTX 3060 Ti (Windows 11), new head merged with current
main:cargo test -p xcl --lib: 1 failure under parallel scheduling; clean on--test-threads=1rerun (1312 passed, 0 failed, 27 ignored, 82s). Intermittent single-test flake — tracked in #1978.Thanks!
— Devin
Imported from ivall/xcl. Originally posted by SzczepanGrela on 2026-11-27T09:04:27Z.
RX 9070 / Wine check of exact head
abcf799a3a08766a62a645f2159a3f9e82e9459c, main83b008188efbf954b846667f48d75e3fa9310a01, and an automatic conflict-free integration of this PR onto that main. All three agree with the reference in the cases below. The main control also preserves zero signs here, so this does not reproduce the Windows AMD failure on our stack.RX 9070 16 GB (RADV GFX1201), Ryzen 7 7700, CachyOS kernel 7.3.6-1-cachyos, Mesa 26.3.1-5, GE-Proton11-12 / Wine 11.0 Staging, ntsync. Native vkd3d-proton
8293130ebe370b1+, local asserts-disabled build; DXC/DXIL 1.9.2602.17, Rust 1.97.1, Windows-GNU release. Private enabled caches per process.Tested
gpu_f16_multiply_preserves_zero_sign, withXCL_DIRECT_DXIL=0and1, at both--test-threads=1and4, on each source: 1 passed / 0 failed / 0 ignored / 0 skipped per invocation. Copied unchanged to the main control; only added an observation before the original assertions. All 64 lanes' four output registers agree with the original expected values.0x3555,0x3c01, largest finite, infinity and quiet NaN. The upper input halves have opposite signs to the lower halves. Three scalar forms cover VOP2, ABS/NEG and VOP3 high-half sources/destination; three packed forms cover normal, per-half NEG and crossed source-half selection.The last filter is a local fixture. Production functions and original assertions were not edited. The exact head's parent is
6d12f58a; the PR API reports basee1d84b7d. Integration used the actual parent and main83b00818. During testing, main advanced to623d02e4via #2977; its only changed file isuma_driver.rs(grooming the coherent window). I reviewed that delta, but did not build or test the newer main snapshot.Not tested: clamp, dynamic rounding modes, OMOD, SDWA/DPP, split wave64, other shader contexts, whole suite, title/smoke or performance. No global
-Gisswitch or retail data used. These are additional Wine/RADV correctness cases.AI use: OpenAI Codex (GPT-6; exact serving variant not exposed) reviewed the public patch, prepared the source integration and local fixtures, ran and independently verified the readbacks, and drafted this report. Publication authorized by the account owner.
Imported from ivall/xcl. Originally posted by Decodere on 2026-11-27T09:40:14Z.
Independent desktop NVIDIA verification of PR #2183 at exact head
abcf799a3a08766a62a645f2159a3f9e82e9459c(1commit; exact parent & merge-base:6d12f58a229bc73889878a448c64dc3af25eeba0onmain), plus a clean temporary local conflict-free merge ontomain623d02e465a17497a757a4ce867f482b0a6c8f3b(local merge commit55e5afea7da3f297d4eef234680885f67f016319, discarded after testing).Environment
7956 MiBreported by D3D12, 32-lane waves), driver32.0.16.2114(NVIDIA621.14, WDDM 3.2)31.9 GiBusable), Windows 11 Home26200(Developer Mode off)rustc 1.100.0 (0ef1bc386 2026-11-09)MSVC, DXC1.9.2609.5,--releaseTargeted release tests & build (exact head
abcf799a& local merge55e5afeaonto623d02e4)abcf799a:cargo build --release -p xcl1m 30s, exit0,0new warnings inemit.rs/tests.rs)abcf799a:gpu_f16_multiply_preserves_zero_sign(XCL_DIRECT_DXIL=0,--test-threads=1&--test-threads=4, 3× each)1 passed; 0 failed; 0 ignored; 1324 filtered out× 6 (0.24–0.31s,0skipped)abcf799a:gpu_f16_multiply_preserves_zero_sign(XCL_DIRECT_DXIL=1,--test-threads=1&--test-threads=4, 3× each)1 passed; 0 failed; 0 ignored; 1324 filtered out× 6 (0.20–0.24s,0skipped)abcf799a:cargo test --release -p xcl --lib -- gpu::recomp:: --test-threads=4 --nocapture(3 consecutive runs)393 passed; 0 failed; 19 ignored; 913 filtered out× 3 (8.15s,7.89s,7.81s;23expected runtimeSKIPPEDlines:20no wave64+3wave32 per-lane refused)main623d02e4control (test-only hunk applied,emit.rsunpatched):gpu_f16_multiply_preserves_zero_sign(XCL_DIRECT_DXIL=0&XCL_DIRECT_DXIL=1,--test-threads=1)1 passed; 0 failedon both (0.27s/0.24s,0skipped — RTX 4060 driver621.14+ DXC1.9.2609.5already preserves-0on these f16 multiplies natively)55e5afea(abcf799aonto623d02e4,ortclean merge):cargo build --release -p xcl1m 40s, exit0,0new warnings inemit.rs/tests.rs)55e5afea:gpu_f16_multiply_preserves_zero_sign(XCL_DIRECT_DXIL=0,--test-threads=1&--test-threads=4, 3× each)1 passed; 0 failed; 0 ignored; 1357 filtered out× 6 (0.24–0.29s,0skipped)55e5afea:gpu_f16_multiply_preserves_zero_sign(XCL_DIRECT_DXIL=1,--test-threads=1&--test-threads=4, 3× each)1 passed; 0 failed; 0 ignored; 1357 filtered out× 6 (0.20–0.21s,0skipped)55e5afea:cargo test --release -p xcl --lib -- gpu::recomp:: --test-threads=4 --nocapture(3 consecutive runs)402 passed; 0 failed; 20 ignored; 936 filtered out× 3 (7.94s,7.98s,7.95s;23expected runtimeSKIPPEDlines:20no wave64+3wave32 per-lane refused)Paired quiet 60 s retail smoke (
title: 29640639,XCL_PREPARE=0 XCL_NETWORK=0)mainbaseline (623d02e465a17497a757a4ce867f482b0a6c8f3b,XCL_PREPARE=0 XCL_NETWORK=0):Temporary local conflict-free merge of PR #2183 (
abcf799a) onto623d02e4(55e5afea7da3f297d4eef234680885f67f016319,XCL_PREPARE=0 XCL_NETWORK=0):Limits of coverage
621.14, DXC1.9.2609.5) across bothXCL_DIRECT_DXIL=0andXCL_DIRECT_DXIL=1and both--test-threads=1and--test-threads=4(24/24passing runs across exact headabcf799aand local merge55e5afea), with zero parallel-scheduling flakiness observed.main623d02e4already passedgpu_f16_multiply_preserves_zero_signon this RTX 4060 + DXC1.9.2609.5host, this run confirms cross-vendor non-regression and parallel-test stability on NVIDIA Ada rather than reproducing the AMD RX 6800M / driver-0erasure failure mode directly.623d02e4(55e5afea) withXCL_PREPARE=0(XCL_NETWORK=0), bypassing startupprepare_for_launchshader precompilation.20no wave64skipped subcases), Wine hosts, and the20#[ignore]tests were not exercised on this machine.AI disclosure: test execution and report drafting assisted by Google Antigravity (Gemini 4 Neon).
Imported from ivall/xcl. Originally posted by thehollowedone on 2026-11-28T12:47:38Z.
merge-check
base: e429936c
head: abcf799
merge: clean (local noncommitting merge onto that base)
build: cargo build --offline --locked -j 4 --workspace -> ok
tests: cargo test --offline --locked -j 4 --workspace --no-fail-fast -- --test-threads=4 -> 2,126 passed, 10 failed, 48 ignored; 25 SKIPPED GPU cases. The same command on clean base -> 2,125 passed, 10 failed, 48 ignored; 25 SKIPPED. The added f16 regression passed, including a separate uncaptured HLSL GPU run (1 passed, 0 skipped). All ten failures have the same names on both: gpu::dxil::module::split::tests::{dispatch_chain_oversized_loop_matches_whole,dispatch_chain_wave32_live_loops,dispatch_chain_wave64_live_loops_and_exchange}; gpu::recomp::heap_window_tests::gpu_heap_flat_reads_match_guarded_and_root_output; gpu::recomp::pso::shader_cache_tests::console_mesh_caches_hlsl_compute_pass_in_memory_and_on_disk; gpu::recomp::tests::{gpu_compute_mode_dispatch_abi,gpu_float_cas_uses_ieee_equality}; e2e::{test_title_draws_with_a_root_signature_under_the_debug_layer,test_title_runs_and_game_folder_is_untouched,test_title_runs_under_the_debug_layer_with_dred}.
review: none after reading the complete two-file diff in the merge result. Scalar and packed source selection, ABS/NEG, clamp, and rounding paths were traced.
performance: HLSL adds a constant-size zero-magnitude check and sign select for each unclamped f16 multiply result; no allocation or new shader compilation stage. Frame-time cost was not measured.
verdict: safe to merge; the ten local suite failures also occur on clean main.
hardware / tool and model: Windows 11 build 26300, RTX 3080 Ti / 621.35, Ryzen 7 9800X3D, rustc 1.99.1, DXC 1.8.2502.11. Codex (GPT-6.2 Sol) ran the merge, build, tests and review; Codex (GPT-6.2 Astra) independently reviewed the emitter semantics.
Imported from ivall/xcl. Originally posted by throny on 2026-11-28T13:38:49Z.
merge-check claim
head:
abcf799a3aImported from ivall/xcl. Originally posted by throny on 2026-11-28T13:55:01Z.
merge-check
base:
e13d6250head:
abcf799a3amerge: clean
build: cargo build --workspace -> ok
tests: cargo test --workspace --no-fail-fast -- --test-threads=4 -> 2131 passed, 10 failed, 48 ignored (26 SKIPPED lines). The 10 failures are the ones main itself has at
e13d6250on this GPU (#3093: the nine since #2959 and, since today, gpu::dxil::msaa_tests::direct_msaa_loads_precede_get_dimensions), the same set with and without this PR; base alone: 2130 passed, 10 failed, 48 ignored.review: none. The f16 multiplies already round through the rounded helper on main; this adds the sign of a zero product, with the flip bit covering the negate bits in the packed form and the abs / neg of the scalar form. Clamped multiplies are left as they are on purpose. No overlap with #842 in text or behaviour (that PR changes the other conversion helper and the fract instruction).
performance: one compare and one select per f16 multiply. 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).