shader: preserve signed zero in plain, packed and SDWA binary16 multiplication #2771
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/2779"
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 RavenCurseBurg on 2026-11-26T08:20:45Z.
Refs #2746. This covers the packed and SDWA half-multiply cases in the RX 9070 XT report. The shared binary16 multiplication expression also serves plain
v_mul_f16.Widening binary16 operands makes their finite product exact in binary32, but an ordinary HLSL multiply lets the compiler disregard the sign of zero. Apply
preciseto the product before the existing binary16 rounding. The existing per-lane comparisons still cover the selected half, sign modifiers, and the preserved half of the destination. The portable test checks the precision qualifier and the emitted calls for the plain, packed and SDWA paths. After merging main at96a7b4fb, cached shaders advance to 25/25cs.The focused SDWA case (set 0, lane 2) read back
e000abcdon WARP, Intel UHD 770 and RTX 4060 with both FXC and DXC. The complete draw suite passed on all three at the initial implementation, with 220 calls per adapter including the existing wrong-value controls. For the packed and SDWA pixel fixtures I also compiled a copy with just the qualifier removed. DXC changes the relevantfmul floattofmul fast float; FXC drops[precise]from the correspondingmul.Repeated the complete FXC/DXC draw suite on
3cc0d4b8on all three adapters. On3fdbaa40the SDWA case again gavee000abcdin all six compiler/adapter combinations. A compiled control that clears the product's sign exactly when its magnitude is zero gave6000abcdand exited 1 in all six. Locally ran the two binary16 Python checks, LLVM 15 gfx1013 reassembly, both cache-key checks, offline compute request, packed-position, buffer-store, const-copy-join and fract checks. An independently compiled C++ FNV calculation for the final graphics keys givesdf78b28cb80d4c5aand466483d084260802. Windows 11 build 26100.9711, DXC 1.9.2609.5, FXC ps_5_1, UHD 770 driver 32.0.101.5973, RTX 4060 driver 32.0.15.9579, WARP 10.0.26100.9711. Debug layer unavailable.For the reporter's RDNA 4 retest on this exact candidate:
AI-assisted with Codex (GPT-6.2 Astra, xhigh).
Imported from R0Y00/Xbox2Windows. Originally posted by tedin7 on 2026-11-26T08:26:32Z.
Review: COMMENTED
Review of head
3fdbaa40(0 commits behind main).Verdict: sound, no blocking findings.
What I checked
mul16(precise float product = a * b) is emitted once in the shared helper prelude (gfx2hlsl.pynearfma16o), and all three multiply paths go through it: plainv_mul_f16(VEC_H, also used by the SDWA path) andv_pk_mul_f16. No other binary16 multiply site was left on a plain*.preciseonly changes the sign of zero results; the existingf16rnrounding after it is unchanged.cs) is mirrored in the tests and docs that pin it.e000abcdon three adapters with FXC and DXC, and a control that gives6000abcd); the added Linux controls check the qualifier and call count for the plain, packed and SDWA forms.Commands run locally (Linux)
startup_gfx2hlsl_f16_alu_check,startup_gfx2hlsl_f16_alu_draw_check,startup_shader_cache_key_check,startup_gfx2hlsl_fract_check,startup_gfx2hlsl_buffer_store_check,startup_gfx2hlsl_const_copy_join_check,startup_compute_request_offline_check,startup_packed_position_provenance_checktests/docs_links_check.py,tests/bidi_controls_check.py,git diff --check origin/main...HEAD: cleanprecisefrommul16->startup_gfx2hlsl_f16_alu_draw_checkfails (plain, packed and SDWA controls).v_pk_mul_f16to{0} * {1}-> the same check fails (packed control).Windows WARP run and the real-GPU run are separate and will be reported in a receipt comment.
AI-assisted; commands listed were executed locally.
Imported from R0Y00/Xbox2Windows. Originally posted by tedin7 on 2026-11-26T08:32:31Z.
Win2025 WARP receipt for head
3fdbaa40(focused tests: the PR's own f16 ALU, draw, cache-key and sibling checks; WARP draw and hardware draw both ran, not skipped).Verified on Windows Server 2025 (Build 26100, MSVC 14.44.35207 + D3D12 WARP) at commit
3fdbaa40fb3c7a99f7bec4eb7ef315e8734bf0ef:--preset dev):cmake --build --preset dev --target d3d12_xs_device_obj d3d12_xs_shim startup_buffer_format_word3_check startup_indirect_draw_indexed startup_resource_retire_title -- -j 2):26.55s(configure1.84s)ctest --preset dev -R 'startup_gfx2hlsl_f16_alu|startup_shader_cache_key|startup_gfx2hlsl_fract|startup_gfx2hlsl_buffer_store|startup_gfx2hlsl_const_copy_join|startup_compute_request_offline|startup_packed_position|startup_indirect_draw_indexed|startup_resource_retire_title' --parallel 6 --no-tests=error --output-on-failure): 17/20 passed (45.84s:startup_shader_cache_key0.73s,startup_gfx2hlsl_buffer_store0.75s,startup_compute_request_offline0.80s,startup_gfx2hlsl_f16_alu_draw_controls0.58s,startup_gfx2hlsl_fract_draw_warp0.67s,startup_gfx2hlsl_fract_draw_hardware0.71s,startup_resource_retire_title_warp_debug00.13s,startup_gfx2hlsl_fract0.25s,startup_gfx2hlsl_fract_draw_controls0.25s,startup_gfx2hlsl_const_copy_join0.12s,startup_resource_retire_title_hardware_debug00.12s,startup_resource_retire_title_off_warp0.08s,startup_resource_retire_title_warp_debug10.03s,startup_indirect_draw_indexed_warp0.12s,startup_resource_retire_title_hardware_debug10.04s,startup_resource_retire_title_off_hardware0.10s,startup_indirect_draw_indexed_hardware0.03s,startup_gfx2hlsl_f16_alu4.15s,startup_gfx2hlsl_f16_alu_draw_hardware45.03s,startup_gfx2hlsl_f16_alu_draw_warp45.69s); skipped (capability, not a pass):startup_resource_retire_title_warp_debug1,startup_resource_retire_title_hardware_debug1,startup_indirect_draw_indexed_hardware/O2(--preset release):cmake --build --preset release --target d3d12_xs_device_obj d3d12_xs_shim startup_buffer_format_word3_check startup_indirect_draw_indexed startup_resource_retire_title -- -j 2):62.32s(configure1.83s)ctest --preset release -R 'startup_gfx2hlsl_f16_alu|startup_shader_cache_key|startup_gfx2hlsl_fract|startup_gfx2hlsl_buffer_store|startup_gfx2hlsl_const_copy_join|startup_compute_request_offline|startup_packed_position|startup_indirect_draw_indexed|startup_resource_retire_title' --parallel 6 --no-tests=error --output-on-failure): 17/20 passed (32.15s:startup_gfx2hlsl_fract_draw_warp0.55s,startup_gfx2hlsl_fract_draw_hardware0.57s,startup_gfx2hlsl_buffer_store0.70s,startup_shader_cache_key0.61s,startup_gfx2hlsl_f16_alu_draw_controls0.49s,startup_compute_request_offline0.70s,startup_indirect_draw_indexed_warp0.08s,startup_gfx2hlsl_fract0.20s,startup_gfx2hlsl_fract_draw_controls0.20s,startup_resource_retire_title_warp_debug00.10s,startup_resource_retire_title_hardware_debug00.09s,startup_gfx2hlsl_const_copy_join0.12s,startup_resource_retire_title_off_hardware0.07s,startup_resource_retire_title_warp_debug10.02s,startup_resource_retire_title_hardware_debug10.03s,startup_indirect_draw_indexed_hardware0.03s,startup_resource_retire_title_off_warp0.06s,startup_gfx2hlsl_f16_alu3.73s,startup_gfx2hlsl_f16_alu_draw_hardware32.00s,startup_gfx2hlsl_f16_alu_draw_warp32.02s); skipped (capability, not a pass):startup_resource_retire_title_warp_debug1,startup_resource_retire_title_hardware_debug1,startup_indirect_draw_indexed_hardwaretests/startup_gfx2hlsl_f16_alu_check.pyok (2.8s),tests/startup_gfx2hlsl_f16_alu_draw_check.pyok (0.4s),tests/startup_shader_cache_key_check.pyok (0.4s)sccache: 0/10 hits; wall133.5sAI-assisted; commands listed were executed locally.
Imported from R0Y00/Xbox2Windows. Originally posted by thepatrickworld on 2026-11-26T08:52:24Z.
Post-merge receipt on the merged head
3fdbaa40(main4bbe52ee):startup_gfx2hlsl_f16_alu_draw_hardwarepasses on an RX 9070 XT, wheremain96a7b4fbfails eight cases per compiler; keeping themul16()call and removing onlypreciserestores those same sixteen failures.Measurements only. The
preciseexperiment below is a local, unpushed edit.Environment
10.0.26200.9974; MSVC19.44.35230, toolset14.44.35207; DXC1.9.2602.17; FXC from the same Windows Kits10.0.26100.0directory,ps_5_1profile.AMD Radeon RX 9070 XT vendor=1002 device=7550, driver32.0.32029.2010.warpreportsMicrosoft Basic Render Driver vendor=1414 device=008c, driver10.0.26100.9818.dev. Every mode line of this run reportsdebug_layer=unavailable.3fdbaa40,git status --porcelainempty before the build (recorded in the build log).tools/startup/gfx2hlsl.pyandtests/startup_gfx2hlsl_f16_alu_draw_check.pyare byte-identical at3fdbaa40and at the merge commit4bbe52ee(sha256158324c0a8ecb71ae88dd15e6fc933ce2b1617a3f52ce6a45056420444607918and07d07c4556e8de20c41525500cb2dbb50cd77ede1abe2d74edff2e4a3d4a0011, LF-normalised), so this receipt covers the codemaincarries.Commands
The same hardware entry was also run on
main96a7b4fb— the merge base — in a separate worktree, same machine.Observed on
3fdbaa40The renderer's own lines inside that log read
adapter=AMD Radeon RX 9070 XT vendor=1002 device=7550,driver=32.0.32029.2010,backend=hardware debug_layer=unavailable. NoMISMATCHline appears in either log.Observed on
main96a7b4fb, before the mergeSixteen mismatching draws, eight per compiler: seven
v_pk_mul_f16selectors and the SDWA preserve case. Two of the raw pairs (ctestprefixes each line with the test number; input lists trimmed):precise, not the callI kept the
mul16()helper and both call sites and removed only the keyword:float mul16(float a, float b) { float product = a * b; return product; }. To let that run reach the draws, the wholeif BODY_WORDS:block (the new assertion and the per-op translation checks) was disabled, and both edits are recorded at the head of that run's log; the tree was restored afterwards. Result: the same sixteen case labels and the same expected/actual words asmain— I compared the(case, expected, actual)triplets, not just the labels.Control for the disabled block: the same two edits with
precisekept giveexit 0and zero mismatches, so the block is inert for the draws and the qualifier is the variable.The added checks assert text
Reverting
v_mul_f16to{0} * {1}trips the plain and SDWA labels together (they share theVEC_Hrow); revertingop_v_pk_mul_f16trips only packed. One caveat on the first conjunct:'precise float product = a * b; return product;' in textis already true of a shader that does not multiply (v_add_f16,v_min_f16), because the helper sits in the preamble — it constrains the helper body, whiletext.count('f16rn(mul16(')is what ties a given path to it.Regression on the merged head
startup_shader_cache_key,startup_gfx2hlsl_const_copy_join,startup_gfx2hlsl_buffer_store,startup_gfx2hlsl_fract,startup_gfx2hlsl_fract_draw_controls,_draw_warp,_draw_hardware,startup_compute_request_offline: 8 pass / 0 skip / 0 fail.startup_indirect_draw_indexed_hardware,startup_indirect_translated_indexed_hardware: 2 pass.startup_resource_retire_title_hardware_debug0,startup_resource_retire_title_off_hardware: 2 pass;startup_resource_retire_title_hardware_debug1skipped, return code 77 (withX2W_D3D12_DEBUG=1the fixture returns 77 whenD3D12GetDebugInterfacefails, and the debug layer is not installed here). A skip is not a pass.tests/startup_packed_position_provenance_check.pyhas noctestentry in this preset; run directly, it exits 0.Still failing on this head
startup_gfx2hlsl_fma_mix_dispatch_hardware: WARP passes, hardware fails onnegated inline 0 addend keeps a -0 product readback: MISMATCH,expected 80000000, got 00000000, plus its high-half-shift control. That is thev_fma_mixhalf of #2746, and this PR does not cover it.Limits
debug_layer=unavailable, so no API-validation output is part of this result.preciserun is an experiment, not a commit; nothing was pushed.mul16is called" from "mul16is inlined". What is measured is that the sign of zero survives with the qualifier and is lost without it, on this adapter and driver.AI-assisted.