shader: lower v_madmk_f32 and v_madak_f32 in direct Compute and Pixel DXIL #3252
No reviewers
Labels
No labels
accessibility
awaiting author
bug
documentation
duplicate
enhancement
good first issue
help wanted
invalid
priority: P0
question
wontfix
No milestone
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set
Reference
github/R0Y00--Xbox2Windows!3252
Loading…
Reference in a new issue
No description provided.
Delete branch "github-bot/gh-3250"
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?
@legacy-code-archaeologist on GitHub · 2026-11-28 01:46 UTC · original
legacy-code-archaeologist:shader/direct-mad32-k→main· +355 −3 · 4 files · 1 commits · merged 2026-11-28 04:08 UTCLower RDNA 2 unfused literal multiply-adds
v_madmk_f32(VOP2 0x20:S0 * K + S1) andv_madak_f32(VOP2 0x21:S0 * S1 + K) in the direct Compute and Pixel DXIL path (src/gfx1013_direct_compute.inl), finishing the remaining#3005unfused f32 multiply-add instructions under#2935.Fixes #3251
Refs #2935
Refs #3005
Summary
src/gfx1013_direct_compute.inl:unfused_madinsideDirectCompute::float_alu()to includev_madmk_f32andv_madak_f32.ftz), roundsfmulseparately without fast-math/FMA contraction, flushes the product, adds the flushed addend (S1forv_madmk_f32, trailing literalKforv_madak_f32), and flushes the sum.i.wide || i.subword || i.dpp_control || permuted).tests/native_mad32_k_check.py&tests/cmake/native_mad32_k.cmake:14test cases verifying asymmetricK/S1positions, unfused tie witnesses, denormalsrc0/K/product/sum FTZ, SGPR & inlinesrc0,0 * inf -> NaN, and-0.0, plus4refusals (VOP3 e64forms, SDWA, DPP).ir, DXILcontrols, SM 6.6compute_hardware, and Pixelwarp+hardware.docs/experiments/native-mad32-k.md:Verification
Host: Windows 10.0.26100,
devpreset, DXC10.0.26100.0.cmake --build --preset dev --target compile_dxil native_compute_ir_dump native_store_replay offscreen_check: passed.ctest --preset dev --no-tests=error -R '^(native_mad32_k_|native_mad32_)' -V:native_mad32_k_ir: Passed (14cases matched unfused FTZ model;4refusals matched).native_mad32_k_controls: Passed (14cases compiled with separatefmul/fadd, notertiary.f32(i32 46,)or fast-math flags;4refusals matched).native_mad32_k_pixel_warp: Passed (Microsoft Basic Render Driver,3quad draws matched).native_mad32_k_pixel_hardware: Passed (NVIDIA Quadro M1000M,3quad draws matched; debug layer unavailable).native_mad32_k_compute_hardware: Skipped (77,Intel(R) HD Graphics 53031.0.101.2111requires SM 6.6 with wave32).native_mad32_controlspassed (native_mad32_hardwareskipped77on HD 530).ctest --preset dev --no-tests=error -R '^native_.*_(controls|ir)$' --output-on-failure: 68/68 passed (0skips).src/gfx1013_direct_compute.inl(swap_madmk_madak,drop_ftz_input,drop_vop3_refusal) all failednative_mad32_k_ir(rc=8); clean source restored and re-verified passing.python -B tests/docs_links_check.py: passed (131Markdown files,631links).AI-assisted.
github-bot referenced this pull request2026-11-28 02:01:58 +00:00
@pigalot on GitHub · 2026-11-28 04:07 UTC · original · approved these changes
Independently reviewed
2502da4eintegrated overmainf41806a9(treebbca38a4). The merge is clean, andgit diff --cached --checkis clean.What I traced.
v_madmk_f32(S0 * K + S1) andv_madak_f32(S0 * S1 + K) join the existing unfused MAD path infloat_alu(). The inputs are flushed,fmulandfaddare separate, the product and sum are flushed, and K comes from the instruction's literal. That matches howv_mad_f32is already lowered and RDNA 2's no-denormal MAD.gfx1013_isa.cpp:47already reads the trailing K dword for both opcodes.0x3f800800² rounds to even before the-1; fused gives2^-11 + 2^-24, unfused gives2^-11. Inmadak_unfused_tie_addthe sum lands on 2.5 ULP; unfused rounds to even and fused rounds up.What I ran. I built
compile_dxil native_store_replay native_compute_ir_dump offscreen_checkindevandrelease, then ranThe
_hardwaretests ran at-j 1. All 7 pass in Debug and in Release/O2, with no skips:_k_ir: "14 cases matched unfused FTZ model; 4 refusals matched"._k_controls: "compiled 14 cases with separate fmul/fadd; verified 4 refusals"._k_compute_hardware: "14 cases matched across 2x32 lanes and guards" on the RTX 5090._k_pixel_warpand_k_pixel_hardware: 3 quad draws each.native_mad32_controlsandnative_mad32_hardwarealso pass.The 76
^native_.*_(controls|ir)$tests pass indev.Negative control and mutants. Each mutant was rebuilt in
devand run against all five new tests.src/gfx1013_direct_compute.inlback tomain_ir,_pixel_warp, both hardware tests_ir(madmk_ftz_lit_k),_pixel_warp_ir,_pixel_warp, both hardware tests_ir(madmk_ftz_product),_pixel_warp_ir,_controlsAfterwards I restored and rebuilt; the restored build passes again and
git diff --quietis clean.Non-blocking. On the RTX 5090, both hardware tests pass with the two flush mutants. The driver flushes f32 denormals itself, so only
_irand WARP pin the explicit flushes. That is enough on this host, but a GPU that keeps f32 denormals would be the one to show it.Verdict: approve on
2502da4e.Environment: NVIDIA GeForce RTX 5090 driver 32.0.16.1088, Windows 11 25H2 build 26200.9974; MSVC 19.52.37029; SDK 10.0.28000.0 DXC (the one CTest picked up); Python 3.12.10; wave32; D3D12 debug layer enabled in the pixel tests.
CI:
Build and test on Windowspasses on2502da4e.This reply was AI-assisted.