Repository navigation
Recompiler: preserve zero sign in HLSL f16 multiplies - #2183
luckyteagirl wants to merge 1 commit into
Conversation
|
Tested on AMD Radeon RX 9070 XT (RDNA4) at AMD 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:
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 / Update: #2169 fuzzer comparison (asked for by DarkPanda69). Base:
Instructions with differences: 6 on Report written by Claude Code (Claude Sonnet 5.5) from a real run on this machine. |
|
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
So the fix removes both multiply differences on RDNA4 too, and changes nothing on NVIDIA, where the HLSL path already kept the sign. Not tested: a title. |
Fixes the f16 multiplication signed-zero part of #2168 on the default HLSL backend. On the RX 6800M, DXC's default fast math turns a negative-zero product into positive zero for
V_MUL_F16andV_PK_MUL_F16; direct DXIL preserves the sign. Applying-Gisglobally removes those differences but introduces FMA-family differences on this same GPU (measurements).What is in it
f16_mul_zero_signrestores the zero sign from the source half bits. Nonzero results are returned unchanged. The scalar path accounts for ABS/NEG; the packed path accounts for per-half NEG. Clamped multiplies stay on their existing saturation path.V_LDEXP_F16/V_SIN_*/V_COS_F32differences in Recompiler: the HLSL backend's fast-math loses -0 in f16 results and changes v_sin/v_cos on AMD #2168.Tested
30.0.13002.13003; Rust 1.99.0 MSVC; DXC/DXIL 1.9.2609.5. Debug tests and release build.568e7db,cargo test --locked -p xcl --lib -j 2 gpu_f16_multiply_preserves_zero_sign -- --test-threads=1 --show-outputfailed on the HLSL path at lane 0:0xBEEF0000vs expected0xBEEF8000. The direct-DXIL control passed. After this fix, the expanded regression passed on both HLSL and direct DXIL withXCL_REQUIRE_GPU=wave64: 1 passed, 0 failed, 0 ignored, no skips in each run.V_MUL_F16and 49/256V_PK_MUL_F16HLSL/direct differences on this GPU. With only this emitter patch applied there and default DXC flags, both instructions compared over 256 inputs each with 0 differences, 0 refusals. The fuzzer worktree was restored afterward; its code is not part of this PR.cargo build --locked --workspace -j 2,cargo build --locked --workspace --release -j 2, and thee2eintegration suite (3 passed, 0 failed, 0 ignored) passed.cargo test --locked --workspace --no-fail-fast -j 2 -- --test-threads=4 --show-outputafter the workspace build: 993 passed, 162 failed, 46 ignored across 21 test targets. Clean main on the same RX 6800M driver previously reported 993 passed, 161 failed, 46 ignored. The 161 common failure names are GPU/device-suspension failures (0x887A0005). The one additional failed name is this new GPU test: in the bulk run it too hitCreateComputePipelineState: ... device ... suspended (0x887A0005)after earlier GPU failures; it passed in isolated HLSL and direct runs. The log has nine explicitSKIPPEDnotices, which count as passed but do not provide coverage. A follow-up excluding the DXIL fuzz group still hit device suspension in other GPU tests.Regression run
Paired guarded seven-second launches of the same owned 1.0.2.1 title with isolated data and shader caches. The baseline commit differs from this branch's main base only in
README.mdandassets/readme/status.svg, so its runtime source matches. Both runs reached one frame, with zero draws and dispatches in the observed window; they did not demonstrate execution of the changed f16 code.Not tested
AI use
OpenAI Codex wrote the fix and regression, ran the failed-first and direct controls, ran the AMD fuzzer comparison and Windows checks, and prepared this description. The owner requested this PR. No game files or shader packs are included.