shader: lower unfused f32 multiply-adds in the direct compute path #3007
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/3007"
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-27T04:35:07Z.
Summary
Lowers
v_mad_f32,v_mad_legacy_f32,v_mac_f32andv_mac_legacy_f32in the direct C++ compute path (float_alu). They were refused withdirect DXIL lowering for <name>(the VOP2 accumulators had no lowering). The semantics aregfx2hlsl.py'smad32, whichpixel_aotshares:v_mac_*add the destination's raw bits);The product and the sum are plain
fmul/faddwith no fast-math flags, so DXIL does not allow contraction intoFMad. Av_mac_*VOP3 form with abs or neg on the accumulator (src2) is refused instead of being dropped silently. The new block sits infloat_alu, away from the integer ALU chain that the open slices #2986, #2996, #2998 and #3004 edit.git merge-treeagainst each of those branches and againstcpp-migrationreports no conflict.Refs #3005, refs #2935
Tests
tests/native_mad32_check.py,tests/cmake/native_mad32.cmake,docs/experiments/native-direct-mad32.md. There are six cases, each checked in every lane of two groups:The VOP3/VOP2 words were assembled with LLVM 15.0.7 (
clang -cc1as, gfx1013).ctest --preset dev --no-tests=error -R '^native_mad32_' -V:dx.op.tertiary46, and no fast/contract flags. The fused, unflushed and legacy-as-plain references each differ. An accumulator neg is refused.ctest --preset dev --no-tests=error -R '^native_'gives 121 of 125 passed. The 4 failures are the hardware testsnative_graphics_vertex_vcc_join,native_rtv_variant,native_startup_request_cacheandstartup_compute_dispatch_native. They fail identically with this change reverted, one0d83759(adapter/PSO limits of this machine).Environment: Windows 10.0.26100, VS 2026 BuildTools 18, base
cpp-migratione0d83759.AI-assisted: written with Claude Code. I reviewed it and ran the commands above.
🤖 Generated with Claude Code
Imported from R0Y00/Xbox2Windows. Originally posted by KelboLive on 2026-11-27T05:17:32Z.
Review: COMMENTED
PR #3007 by @legacy-code-archaeologist — shader: lower unfused f32 multiply-adds in the direct compute path
What works
Issues
Recommendations
Overall
Well-scoped addition to the direct compute f32 path. The ftz design is sound and follows IEEE 754 subnormal rules. The controls verify the compilation pipeline is correct, and the test cases target the critical rounding-difference boundary. Prioritize hardware measurement on SM 6.6 hardware to confirm the rounding behavior matches console expectations.
Imported from R0Y00/Xbox2Windows. Originally posted by KelboLive on 2026-11-27T05:33:03Z.
Review: COMMENTED
PR #3007 by @legacy-code-archaeologist -- shader: lower unfused f32 multiply-adds in the direct compute path
What works
Issues
Recommendations
Overall
A clean, correct extension of the direct compute path. The semantics match the existing gfx2hlsl reference. Ready for merge after the denormal flush edge case is confirmed.
Imported from R0Y00/Xbox2Windows. Originally posted by legacy-code-archaeologist on 2026-11-27T12:40:21Z.
@KelboLive Thanks for the reviews. On the points raised:
ead(i.dst)\ for \_mac_f32\ / \_mac_legacy_f32, \p(2)\ for \_mad*) goes through \tz(c)\ identically in
esult = ftz(fadd(ftz(product), ftz(c))).
Imported from R0Y00/Xbox2Windows. Originally posted by R0Y00 on 2026-11-27T15:50:44Z.
I checked this PR and your #3004 and #3011 against
main354c6870. Each PR compares tomainwith the intended feature delta, and each currently conflicts insrc/gfx1013_direct_compute.inl. Please move them tomainin their existing PRs as you refresh the branches, keeping their tests and existing review history. #3007 can go first because its floating-point handler is separate from the two integer changes. Let me know on the relevant PR if a rebase exposes a dependency, and I’ll review the updated integrated head.Imported from R0Y00/Xbox2Windows. Originally posted by legacy-code-archaeologist on 2026-11-27T15:55:17Z.
@R0Y00 Moved #3007 (
shader/direct-mad32) ontomain(f6691b67-> commit9869cc04), keeping tests and review history intact. No dependency oncpp-migrationwas exposed (only thefloat_alu()guard line needed merging alongsidev_cvt_off_f32_i4).Verified on
9869cc04:compile_dxil,native_store_replay,native_compute_ir_dumpnative_mad32_controls: Passed (0.65s)^native_.*_(controls|ir)$:37/37passed (19.41s)tests/docs_links_check.py: passed (92files,586links)native_mad32_hardware: skipped (77, Quadro M1000M SM 6.1 lacks SM 6.6 wave32; GPU readback unmeasured locally)AI-assisted.
Imported from R0Y00/Xbox2Windows. Originally posted by R0Y00 on 2026-11-27T16:02:41Z.
Review: APPROVED
Independently reviewed
9869cc04integrated onmain6c2cddec(tree327ebf9973ddb45be26d2146a88563fb6c864647). The combinedfloat_alugate retains the adjacent i4 conversion. I checked separately rounded multiply/add, signed-zero flushing for inputs and intermediates, legacy zero-product handling, and the destination accumulator for both MAC forms.Built
compile_dxil native_store_replay native_compute_ir_dumpindevandrelease. Ranctest --test-dir <build> --no-tests=error -j 1 -V -R '^native_(mad32|mad_f16|fma|v_f32)_'. Only the two MAD32 tests match on this tree. Debug and Release/O2both passed 2/2 with no skips. Hardware replay matched 2,064 words (NaNs compared by class). Compile controls verified distinctfmulandfaddwith no FMad or fast-math flags, rejected the accumulator modifier and detected the fused, unflushed and legacy-as-plain reference mutations.git diff --check HEAD^1 HEADpassed.NVIDIA GeForce RTX 4060 Laptop GPU, driver
32.0.16.1656, Windows26200.9974, SDK/DXC10.0.26100.0, wave32, D3D12 debug layer disabled. Windows, Linux Python and gfx1013 CI succeeded on this head. Hosted/O2was skipped.