startup: gfx2hlsl lowers the non-fused v_mad_f32 family like the fused v_fma_f32 #1721
Closed
opened 2026-11-24 17:54:29 +00:00 by legacy-code-archaeologist
·
5 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#1721
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 legacy-code-archaeologist on 2026-11-24T17:54:29Z.
tools/startup/gfx2hlsl.py(main at65e758b0, lines 1051–1054) lowers the gfx1013 non-fused multiply-adds to the same plain HLSL expression as the fused forms:Why this is inexact. On gfx1013,
v_mad_f32,v_mac_f32,v_madmk_f32,v_madak_f32andv_mad_legacy_f32round the product before the add, and they do not support binary32 denormals.tools/pixel_aot.pymodels this as "round the product before the add" with operands, product and sum flushed to signed zero (mad32,preciseproduct and sum).Without
precise, the compiler may contracta * b + cinto a fused multiply-add with one rounding, and the denormals are not flushed. So these forms can differ from the console in the last bit, and in results near zero. The difference can also vary between adapters, depending on whether the compiler or the driver fuses. Desktop RDNA2 has no non-fusedv_mad_f32: LLVM 15 decodes the gfx1013 encodingd541…as invalid for gfx1030. So a fused form there is likely; that is inferred, not measured.Where it can show. It is invisible in plain shading. Near a threshold it can show:
discardor alpha comparison;These can flip, giving single-pixel seams or flicker that differs between GPUs. It does not affect startup or stability.
Not measured yet. I have not checked whether DXC or any driver actually emits a fused form for today's output on a given adapter (WARP, NVIDIA, Intel). I have not built a reproducer.
Possible fix, for whoever takes it:
pixel_aot's exact helper (flush to zero, then apreciseproduct and aprecisesum) for the five non-fused forms.v_fma_f32/v_fmac_f32is a separate limitation, since HLSL has no guaranteed fusedfloatfma.Related, for reference. Decoding the same words with LLVM 15 for gfx1013 and gfx1030 shows one more reinterpretation:
0c020702(VOP2 op 0x06)v_mac_legacy_f32(non-fused)v_fmac_legacy_f32(fused)d5400001 …(VOP3 op 0x140)v_mad_legacy_f32(non-fused)v_fma_legacy_f32(fused)Neither is a bug today, as far as I can see:
disasm_rdna2.pyandpixel_aotdecode console code as gfx1013.ffx_dispatch_aot's gfx1030 decoding is for desktop provider shaders.compute_store_aotuses gfx1030 only with--cpu gfx1030.This is a report, not a claim.
Imported from R0Y00/Xbox2Windows. Originally posted by Jess-Doit on 2026-11-24T17:56:53Z.
Taking this, AI-assisted (Codex, driven with Claude Code), with Windows 10 22H2, a GTX 1060 and WARP.
Slice: in
tools/startup/gfx2hlsl.py, lower the five non-fused forms the waypixel_aotalready does. Those arev_mad_f32,v_mac_f32,v_madmk_f32,v_madak_f32andv_mad_legacy_f32. Inputs are flushed to zero, then the product and the sum are each computed as aprecisevalue and flushed. Forv_mad_legacy_f32, the legacy multiply rule is kept.Fixture: source-built encoded instructions, decoded and translated, then dispatched on WARP and the 1060.
a * b + con the triple, and dropping the flush on the denormal case.Not in this slice: guaranteeing a fused
v_fma_f32/v_fmac_f32, since HLSL has no guaranteed fused float FMA, and the gfx1030 reinterpretations listed above.Imported from R0Y00/Xbox2Windows. Originally posted by R0Y00 on 2026-11-24T18:04:14Z.
Please proceed with those five non-fused gfx1013 forms, including the legacy multiply rule. Keep the current fused spellings outside this change. For the rounding discriminator, use runtime operands and report the two reference words. If the plain-expression mutant does not contract on an adapter, record that observation and add a deterministic fused-result or wrong-reference control. An unchanged compiler choice should not make the control pass. For the denormal case, read back integer bits so the render target cannot hide a signed-zero or subnormal difference. Please keep this separate from the ordinary arithmetic coverage in #1712.
Imported from R0Y00/Xbox2Windows. Originally posted by KainanP on 2026-11-24T18:18:51Z.
Two WARP data points that bear on the fixture planned above (WARP + GTX 1060):
The plain-expression mutant will probably not contract on WARP. In xcl-dev/xcl#472, @LAEGGYMODZ ran 32,768 operand triples that separate fused from unfused results through four standalone kernels on WARP 10.0.26100.9818 with DXC 1.9.2609:
mad(a, b, c), apreciseproduct plus aprecisesum, both in one program, and a plaina*b + c. All four gave the unfused result for every vector: https://github.com/xcl-dev/xcl/issues/472#issuecomment-7128002850. So on WARP the "restore the plaina * b + c" control will most likely read the same words as the correct lowering. This is the case R0Y00 described ("If the plain-expression mutant does not contract on an adapter..."). The deterministic wrong-reference control is the one that will do the work there.WARP does not always match a two-rounding reference on
precisechains. In LooperSalty/AnyXboxX#145, a one-lane compute shaderprecise diff = b - a; precise prod = diff * f; precise result = a + prod;, with runtime inputsa = 0x3f59d9da, b = 0, f = 0x3f400000, gives0x3e59d9daon WARP and0x3e59d9d8on an RTX 4070 Ti SUPER (DXC 1.9.2609.5;-O3,-Odand-Gisall give the same result). The second value is the two-rounding result.dxc -dumpbinshows separatefsub/fmul/faddwithout fast-math flags. The WARP value equals the single-rounding result, but we have not found which step produces it: https://github.com/LooperSalty/AnyXboxX/issues/145Taken together: a direct
preciseproduct followed by aprecisesum, with runtime operands, came out unfused on WARP in point 1. A chain where a subtraction feeds the product came out with one rounding in point 2. If thev_mad_f32discriminator row stays a directa*b + ctriple, WARP should agree with the two-rounding reference. If a row ends up lerp-shaped, a WARP-only mismatch there is the known WARP behaviour and not the lowering. Both measurements come from desktop WARP builds on Windows 11, not from console hardware.AI-assisted (Claude Code). The numbers are quoted from the linked threads. I did not re-run them for this comment.
Imported from R0Y00/Xbox2Windows. Originally posted by Jess-Doit on 2026-11-24T18:52:28Z.
#1768 has merged (
3dc78117). Its measurements line up with the points above:a * b + ccontrol contracted on the GTX 1060 (driver 32.0.15.6094) for four of the five forms, reading40000003. It didn't contract on in-box WARP (10.0.19041.5794), which read40000002for all five. Because of that, the fixture also has a text-level control, which rejects the plain expression even where the adapter happens to produce the two-rounding word.a * b + ctriples with runtime operands read from a raw UAV. Both adapters matched the two-rounding reference (40000002), with no lerp-shaped chain involved.00800000to00c00000on both adapters, under SM 6.2-denorm preserve.The fused
v_fma_f32andv_fmac_f32spellings are unchanged, as agreed. That remaining part and the gfx1030 reinterpretations are why this issue can stay open, if you want to track them here.Imported from R0Y00/Xbox2Windows. Originally posted by R0Y00 on 2026-11-24T18:53:53Z.
The five non-fused gfx1013 forms are fixed in #1768, merged at
3dc78117. Independent Windows Release verification passed all five registered cases, including WARP and RTX 4060 Laptop dispatches, denormal-preserve checks, and their distinguishing controls. The fused forms are outside this report.