gfx2hlsl: the v_fma_mix lowering is not precise, so RDNA 1 drops the sign of a -0 product (startup_gfx2hlsl_fma_mix_dispatch_hardware) #2721
Closed
opened 2026-11-26 04:13:15 +00:00 by ColorMeBoom
·
7 comments
No Branch/Tag specified
main
codex/indirect-large-backed-views
codex/word3-preflight-check
codex/vertex-table-two-records
codex/live-index-alias
codex/copied-vertex-buffer-srv
codex/windows-stage-test-output
codex/preserve-live-srv-retirement
codex/share-render-target-tracking
codex/sgd5-negative-offset-fixture
coverage-dashboard
codex/mesh-loose-root
codex/mesh86-cache-padding
codex/xmem-scatter-preflight
codex/mesh-depth-ps
codex/indirect-dispatch-refresh
codex/compute-container-index
codex/startup-compute-formatted-load
codex/compute-indirect-producer
codex/compute-atomic-soffset
codex/mesh-dual-handoff
codex/startup-run-sh-watcher-control
codex/queue31-page-alias
codex/indexed-indirect-compute-root
codex/typed-buffer-view-metadata
codex/translated-indexed-address-alias
codex/fixed-mesh-create-result
codex/xmem-section-lease
codex/startup-slot86-mesh-cache
codex/restore-mesh-barrier-iteration
codex/translated-indirect-upload-index
codex/xapu-completion-opt-in
codex/translated-indexed-rect
codex/translated-indexed-indirect
codex/startup-mesh-lds-integration
codex/startup-console-ms24
codex/startup-slot57-mesh-request
codex/indirect-copy-provenance
codex/present-color-producer-trace
codex/compute-dispatch-binding-trace
codex/translated-indirect-table-buffers
codex/indirect-copy-provenance-base
codex/mix-half-literal-source
codex/translated-indirect-draw
codex/xmem-scatter-diagnostics
codex/slot148-recording-upload
codex/slot70-loading-art-verified
codex/command-list-upload-arena
codex/recover-failed-command-list
codex/startup-heap-timing-notes
codex/align-audio-input-timeline
codex/synthetic-depth-export-control
codex/startup-texture1d-on-windows
codex/1629-packed-position-fixture
codex/cpu-srv-refresh
codex/stream-root-srv-draw
codex/audio-mixer-timer
codex/startup-reload-published-shader
codex/priority-integrate-1284
codex/guest-sixteen-page-record
codex/aot-placed-dxr-batch
codex/guest-directory-selection
codex/gamesave-enumerate-read
codex/readme-archive-to-pixels
codex/pe-placed-view-draw
codex/archive-directory-gpu
codex/slot133-dxr-build
codex/materialize-placed-vertex-view
codex/dstorage-directory-offsets
codex/xg-nine-bc-copy
codex/xg-slot10-bc64-arrays
codex/dxr-guest-address-readback
codex/gpu-va-high-bits
codex/clarify-diagnostic-startup-scope
codex/xg-six-levels
codex/typed-derived-blend
codex/english-legal-text-progress
codex/address-bc-4ks
codex/dstorage-bounded-file-read
codex/wide-srv-offsets-menu
codex/startup-memory-srv
codex/bound-view-tail
codex/language-selector-readback
codex/setup-menu-progress
codex/cpu-plane-refresh
codex/startup-ubyte-vertex
codex/presenter-window-selection
codex/startup-uniform-buffer-lane
codex/intro-loop-timing
codex/static-clzero-loops
codex/document-rtx-intro
codex/startup-insertq
codex/nv12-startup-texture
codex/stream-stage-draw
codex/startup-null-uav-format
codex/startup-draw-capture
codex/shorten-windows-checks
codex/dstorage-rfc1950
codex/startup-dump-fence
codex/pr1135-review-base
codex/startup-stream-requests
codex/startup-chroma-view
codex/readme-graphics-pipeline-streams
codex/static-crt-free-tls
codex/arc-140t-rtx-5080-laptop-gpu-reports
codex/main-startup-progress-entry
codex/signed-dxil-catalogue
codex/reloc-free-preferred-base
codex/quad-dpp-bit-mask
codex/raw-srv-bounds
codex/rx9070-31044-hardware-report
codex/gpu-page-source-provenance
codex/runtime-placeholder-interior
codex/gpu-copy-queue-tile-order
codex/pe-pin-external-providers
codex/xmem-placeholder-reservations
codex/xmem-shared-physical-pages
codex/pe-package-startup
codex/xmem-tools-memory-query
codex/cpu-stack-output-import
codex/pe-load-security-cookie
codex/record-three-bvh-retests
codex/cpu-rbp-frame-anchor
codex/xmem-default-startup
codex/record-rtx-3050-ti-9597
codex/docs-readme-start-here
codex/check-compute-mad24-truncation
codex/docs-discord-community
codex/bound-rcx-branch-mutants
codex/rtx5060ti-bvh-62114
codex/837-neutral-readme-disclaimer
codex/record-rtx-3070-ti
codex/title-neutral-public-wording
codex/exe-shadow-frame-submissions
codex/exe-shadow-runtime-chain
codex/readme-polish
codex/gpu-coverage-nov23
codex/spirv-minlod
codex/shadow-shim-device
codex/exe-two-shadow-frames
codex/shim-dispatch-cleanup
codex/fix-spirv-cache-probe
codex/sampler-use
codex/ballot-bit-extract
codex/packed-fma-release
codex/cpu-packed-fma-o2
codex/publish-coverage-dashboard
codex/mesh-cbv-binding-order
codex/spirv-window-fixture
codex/ps-e32-float-uint
codex/ps-cbuffer-reads
codex/fixed-profile-rescan
codex/shim-compute-integration
codex/readme-visible-coverage
codex/readme-research-navigation
codex/integrate-pr-256
codex/indexed-mesh
codex/sampled-coverage
codex/first-ms
codex/dual-ps
codex/ps-attribute
codex/compute-first
codex/ps-export
codex/readme-research-status
codex/ps-layout
codex/blast-window
codex/chart-caption
codex/reviewer-roles
codex/blast-aot
codex/archive-program
codex/crc-stream-program
codex/exe-image-data-chain
codex/local-cpu-fixture-coverage
codex/exe-bound-frame-chain
codex/exe-mapped-comparison
codex/contribution-dependencies
codex/exe-entry-aot
codex/bink-frame-heap-integration
docs/hardware-seven-reports
codex/bink-custom-heap
codex/bink-heap-callers
codex/discussions-entry-points
codex/gpu-community-batch-64
codex/ffx-scratch-writers
codex/generic-project-documentation
codex/ffx-dispatch-rcas
codex/four-windows-gpu-reports
codex/title-neutral-project-wording
codex/community-coverage-provenance
codex/rcas-packed-texels
codex/community-gpu-retests
codex/community-build-and-gpu-reports
codex/ffx-provider-loop
codex/ffx-recurrent-views
codex/ffx-recurrent-resource
codex/amd-wave64-reports
codex/ffx-backend-slots
codex/upscaler-device-init
codex/ffx-context-lifecycle
codex/ffx-version-query
codex/ffx-provider-contract
codex/typed-object-callback
codex/cpu-ordinal-import
codex/chained-cpu-ranges
codex/cpu-import-call
codex/cpu-direct-call
codex/cpu-leaf-aot
codex/community-project-status
codex/script-state-path-replay
codex/script-state-evidence
codex/bc7-resident-tail
codex/bcpack-mip-tail
codex/bc7-texture-draw
codex/asset-ranges
codex/pixel-constants
codex/pixel-aot
codex/pre-exe-workloads
codex/root-signature-device-coverage
engineering/packed-bvh-leaves
engineering/bvh-build-and-update
engineering/intake-root-roundtrip
community/gpu-check-release
community/english-contributor-entry
gpu-check-v0.1.0
Labels
Clear labels
No items
No labels
Milestone
Clear milestone
No items
No milestone
Assignees
Clear assignees
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".
No due date set.
Reference
R0Y00/Xbox2Windows#2721
Loading…
Reference in a new issue
No description provided.
Delete branch "%!s()"
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 R0Y00/Xbox2Windows. Originally posted by ColorMeBoom on 2026-11-26T04:13:15Z.
Commit or build
2215c26d(main)Reproduction
Expected behavior
negated inline 0 addend keeps a -0 productreads back80000000, as on WARP. The case runsv1 = U(F(v2) * f16tof32(v3 >> 16) + (-0.0));withv2 = 0x80000000and 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:
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_0probe isolates it. Inputs are read from the UAV at run time, throughoffscreen_check --raw-uav-dump:F(v2) * f16tof32(v3 >> 16) + (-0.0)(the translated line)0000000080000000F(v2) * f16tof32(v3 >> 16)0000000080000000F(v2) * f16tof32(v3 & 0xffffu) + (-0.0)(low half)0000000080000000mad(F(v2), f16tof32(v3 >> 16), -0.0)0000000080000000F(v2) * F(v3) + (-0.0), v3 = 4.0 as binary328000000080000000precise float p = F(v2) * f16tof32(v3 >> 16) + (-0.0);8000000080000000precise float p = mad(F(v2), f16tof32(v3 >> 16), -0.0);8000000080000000The sign is lost only when a widened binary16 operand feeds a non-
precisemultiply. Non-preciseHLSL arithmetic does not guarantee signed zeros, and WARP takes the same freedom elsewhere:F(v2) * f16tof32(v3 >> 16) + 0.0returns80000000on WARP and00000000on the RX 5700 XT.mad32()in the same translator already computes its product and sum asprecise. Formix()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 inmix()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 asFMad, which a driver may still fuse. On this card it runs unfused either way:mad(4097, 4097, -16785408)returns 0, with or withoutprecise. 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
Imported from R0Y00/Xbox2Windows. Originally posted by RonLogic on 2026-11-26T04:24:35Z.
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.Imported from R0Y00/Xbox2Windows. Originally posted by R0Y00 on 2026-11-26T04:28:08Z.
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 ISAImported from R0Y00/Xbox2Windows. Originally posted by thepatrickworld on 2026-11-26T07:33:54Z.
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: https://github.com/R0Y00/Xbox2Windows/issues/2746#issuecomment-7185588802
AI-assisted.
Imported from R0Y00/Xbox2Windows. Originally posted by Not-Saii on 2026-11-26T10:06:38Z.
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.
Imported from R0Y00/Xbox2Windows. Originally posted by Not-Saii on 2026-11-26T11:38:46Z.
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).
Imported from R0Y00/Xbox2Windows. Originally posted by ColorMeBoom on 2026-11-26T13:26:46Z.
@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.
Imported from R0Y00/Xbox2Windows. Originally posted by Not-Saii on 2026-11-26T13:33:29Z.
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).