Repository navigation
Description
Commit or build
2215c26 (main)
Reproduction
ctest --preset dev --no-tests=error -R '^startup_gfx2hlsl_fma_mix_dispatch_(warp|hardware)$' -VExpected behavior
negated inline 0 addend keeps a -0 product reads back 80000000, as on WARP. The case runs v1 = U(F(v2) * f16tof32(v3 >> 16) + (-0.0)); with v2 = 0x80000000 and a high half of 4.0. Stage.mix() already prints (-0.0) for this operand because "f() would print +0.0, which changes a -0 product".
Observed behavior
WARP passes. The RX 5700 XT fails two checks:
hardware: negated inline 0 addend keeps a -0 product readback: MISMATCH
expected 80000000, got 00000000
hardware: control without the high-half shift reads the low half in all 4 high-half cases: MISMATCH
The second check is the same case: with the shift removed, the low-half reference is also -0 and the card returns +0.
A standalone DXC cs_6_0 probe isolates it. Inputs are read from the UAV at run time, through offscreen_check --raw-uav-dump:
| Expression (v2 = -0, high half = 4.0) | RX 5700 XT | WARP |
|---|---|---|
F(v2) * f16tof32(v3 >> 16) + (-0.0) (the translated line) |
00000000 |
80000000 |
F(v2) * f16tof32(v3 >> 16) |
00000000 |
80000000 |
F(v2) * f16tof32(v3 & 0xffffu) + (-0.0) (low half) |
00000000 |
80000000 |
mad(F(v2), f16tof32(v3 >> 16), -0.0) |
00000000 |
80000000 |
F(v2) * F(v3) + (-0.0), v3 = 4.0 as binary32 |
80000000 |
80000000 |
precise float p = F(v2) * f16tof32(v3 >> 16) + (-0.0); |
80000000 |
80000000 |
precise float p = mad(F(v2), f16tof32(v3 >> 16), -0.0); |
80000000 |
80000000 |
The sign is lost only when a widened binary16 operand feeds a non-precise multiply. Non-precise HLSL arithmetic does not guarantee signed zeros, and WARP takes the same freedom elsewhere: F(v2) * f16tof32(v3 >> 16) + 0.0 returns 80000000 on WARP and 00000000 on the RX 5700 XT.
mad32() in the same translator already computes its product and sum as precise. For mix() there is a choice. precise float r = a * b + c; keeps -0 but forbids contraction, so every adapter rounds the product before the add. The comment in mix() already accepts 1 ULP from rounding the product, but this would make it certain. precise float r = mad(a, b, c); also keeps -0 on both adapters here. DXC emits it as FMad, which a driver may still fuse. On this card it runs unfused either way: mad(4097, 4097, -16785408) returns 0, with or without precise. Either form would need the startup shader cache revision to advance. I can send the change as a PR once you pick the form.
Environment
Windows 11 Home build 26200.9974, VS 2022 Build Tools (MSVC 19.44.35230), Windows SDK 10.0.26100.0, DXC 1.9.2602.17 (SDK). AMD Radeon RX 5700 XT (RDNA 1, 1002:731f), driver 32.0.21045.29003, hardware backend; WARP 10.0.26100.9818. Debug layer unavailable.
AI-assisted with Claude Code (Claude Opus 5.5).
Checklist
- I reproduced this on a source-built input.
- I did not include game files, dumps, distribution links or credentials.
Activity
RonLogic commentedon Nov 26, 2026
Windows x64 Release comparison against
2215c26dusing DXC1.9.2602.17. I used the #2728 build after verifying its only differences from that base were GPU package tooling and CMake registration for the package recorder. Both adapter paths ran, with no skips. WARP driver10.0.26100.10068; physical NVIDIA RTX 4070 driver32.0.16.2124. Bothstartup_gfx2hlsl_fma_mix_dispatchtests passed. The widened binary16 signed-zero case kept80000000, the high-half control passed, and the D3D12 debug layer reported zero errors or warnings. This provides a comparison point for the reported RDNA 1 result.R0Y00 commentedon Nov 26, 2026
Please send a focused fix using a
preciseresult ofmad(a, b, c)for the existingv_fma_mix_f32lowering. The RX 5700 XT probe distinguishes the signed-zero regression.madstill allows fused or unfused execution on a given backend, so record the cancellation discriminator separately and keep the documented approximation. Please bump the shader cache revision, preserve the half-selection and modifier order, and rerun the raw-bit signed-zero and wrong-half controls on RDNA 1 and WARP. RonLogic's RTX 4070 result is a useful baseline for a retest. HLSL mad · AMD RDNA 2 ISAthepatrickworld commentedon Nov 26, 2026
RDNA 4 datum for the fix requested here (
b457f7ff, RX 9070 XT, driver32.0.32029.2010, Windows26200.9974).preciseform keeps the sign:precise float p = F(v2) * f16tof32(v3 >> 16) + (-0.0);returns80000000on the card and on WARP, while the same row without it returns00000000on the card.madrow too, not only the multiply-add: in the same shadertertiary.f32 = FMad(F(v2), f16tof32(v3 >> 16), -0.0)loses the sign as well, and it is not afmul fast.fmul fastwith a binary32 operand keeps-0on this adapter.Raw words, both shaders and the DXIL mapping are in the #2746 comment: #2746 (comment)
AI-assisted.
Not-Saii commentedon Nov 26, 2026
I'm the fixture author from #2055. Here are notes on the
precisemadform requested above, for whoever sends the PR. I have a local candidate but have not opened one. @ColorMeBoom, if your PR is in progress, send yours and I'll review it against these notes.Form. I tried one helper in
Pipeline.common(), next tomul16from #2779, and changedmix()to call it. All three forms now emitmix32(a, b, c). Operand order, half selection and modifiers stay the same, andsaturatestays outside the call:DXC 1.9.2602.17,
cs_6_0, onv1 = U(mix32(F(v2), f16tof32(v3 >> 16), (-0.0)));:So the helper form keeps
!dx.preciseon both theFMadand the widening, the two places #2746 says lost the sign.Test notes (
tests/startup_gfx2hlsl_fma_mix_check.py)FandU, so they need the helper text. A module constant ingfx2hlsl.py, used by bothcommon()and the test, keeps the two copies from drifting apart.preciseis not a useful negative control: WARP keeps-0without it. A second dispatch shader whose helper returnsasfloat(asuint(result) == 0x80000000u ? 0u : asuint(result))must fail exactly the-0case. It does on both adapters below.' >> 16)'wrong-half control still matches the new text, and still changes 3 of 4 high-half results.mix32(4097, 4097, -16785408)can go in one extra row, loaded through the UAV fill like the other inputs, with the word printed per adapter.Cache revision.
mainis atx2w-startup-shader-27since #2778, so this would be 28. The revision is pinned in 11 files, includingtests/startup_packed_position_provenance_check.pyandtests/startup_resource_retire_title.cpp. Known answers at revision 28, computed with a standalone FNV-1a and checked against the revision 27 values first:pipeline_key(b"\x00VS\xff", b"PS\x00\x80", b"RTS0\x00")=0xe4791179bf7096b3; with layoutb"ia\x00\xfe"=0xf6cb7f56c2985cfbtests/startup_compute_request_offline_check.pyframed key at28cs=0x39e7422f5da15950Measured on
79410a80plus the change, presetdev, Windows 11 26300.9974, DXC 1.9.2602.17 (SDK 10.0.26100.0), debug layer on with 0 errors and 0 warnings:-0casemad(4097, 4097, -16785408)80000000-0case00000000(unfused)80000000-0case3f800000(fused)The RTX 4090 also passes on unmodified
main, so neither row shows the fix on RDNA. That still needs the RX 5700 XT retest here and the RX 9070 XT retest offered in #2746.AI-assisted with Claude Code (Claude Opus 5.5); commands listed were executed locally.
startup: lower v_fma_mix* through a precise mad so a zero product kee…
Not-Saii commentedon Nov 26, 2026
The
precisemadlowering from this thread is onmainas of02075500(#2818). All threev_fma_mix*forms now emitmix32(a, b, c), which isprecise float result = mad(a, b, c); return result;. The cache revision moves tox2w-startup-shader-28.On WARP and an RTX 4090, all 17 words match, the
-0case reads80000000, and a control helper that clears a-0result fails only that case. The RTX 4090 also passed before the change, though, so this does not yet show the fix on RDNA 1.@ColorMeBoom, could you rerun on the RX 5700 XT at
02075500or later?The useful lines are:
hardware: negated inline 0 addend keeps a -0 product readback;hardware: control that clears a -0 result fails only the -0 product case;mad(4097, 4097, -16785408)line, which tells us whether the card fuses.Please include the driver and whether the debug layer was on. If it passes, this issue can close.
AI-assisted with Claude Code (Claude Opus 5.5).
ColorMeBoom commentedon Nov 26, 2026
@Not-Saii: the fix passes on the RX 5700 XT at
22aa7bf9(currentmain, contains02075500).Environment:
dev.1002:731f), driver 32.0.21045.29003.All 4 tests passed:
startup_gfx2hlsl_fma_mix,_fxc,_dispatch_warpand_dispatch_hardware.mad(4097, 4097, -16785408)00000000(unfused)00000000(unfused)Removing
precisebrings the failure back on this card. I edited onlyMIX32intools/startup/gfx2hlsl.pytofloat result = mad(a, b, c);and reran the two dispatch tests. WARP still passes. The RX 5700 XT fails:So on this adapter the
precisekeyword is what restores the sign, which the WARP and RTX 4090 runs could not show. The wrong-half control also fails withoutprecise. I did not look into why. The edit was reverted afterwards.From my side as the reporter, this resolves the issue. I'll leave closing it to the maintainers.
AI-assisted with Claude Code (Claude Opus 5.5); the commands listed were run locally.
Not-Saii commentedon Nov 26, 2026
Thanks @ColorMeBoom, and especially for the run without
precise. That is the before/after on RDNA 1 that the WARP and RTX 4090 runs couldn't give.Taken with the RX 9070 XT runs in #2746, the
precisemadlowering (#2818) is now confirmed on both AMD architectures that failed. Without it the RX 5700 XT reads00000000for the-0case. With it, all four fma-mix tests pass at22aa7bf9.Agreed that this can be closed from my side too.
AI-assisted with Claude Code (Claude Opus 5.5).