shader: lower v_dot2_f32_f16 in direct Compute and Pixel DXIL #3239
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/3239"
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-28T01:19:39Z.
Lower RDNA 2 VOP3P
v_dot2_f32_f16(0x13) in the direct Compute and Pixel DXIL path (src/gfx1013_direct_compute.inl), addressing #2935.Fixes #3238
Refs #2935
Summary
src/gfx1013_direct_compute.inl:v_dot2_f32_f16lowering inDirectCompute::float_alu():src0andsrc1viapacked_f16_inline_constant()(inline f16 floats240..248with zero high half, inline ints128..208) oroperand32(), and binary32src2viaoperand32().op_sel[1:0],op_sel_hi[1:0],neg_lo[2:0](pair 0binary16 signs +src2binary32 sign),neg_hi[1:0](pair 1binary16 signs inABS), andclamp(dx.op.unary.f32opcode7, saturate), widening selected halves viadx.op.legacyF16ToF32and computing((a0 * b0) + (a1 * b1)) + c.op_sel[2]/neg_hi[2]bits (i.a & 0x2400), DPP/permuted encodings, special scalar registers (VCC,M0,EXEC,SCC, etc.), and unsupported or dynamic binary16 rounding/denormal modes (half_binary = trueadded inDirectCompute::lower()).tests/native_f16_alu_check.py:_step) to evaluatedx.op.unary.f32(i32 7, ...)(Saturate).tests/native_dot2_f32_f16_check.py&tests/cmake/native_packed_dot2_f16.cmake:26test cases (VGPR,op_sel/op_sel_hicross-lane swaps,op_sel_hi[2]=1,neg_lo/neg_hi,clamp, inline f16 float & integer constants onsrc0/src1, inline/literal/SGPR onsrc2, subnormals, signed zeros,inf,NaN) and9refusal programs (reserved modifier bits, special scalar registers on each operand, denormal flush, RTZ rounding, and dynamic conditionalhalf_mode_knownfailure).docs/experiments/native-dot2-f32-f16.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_packed_dot2_f16_|native_packed_dot2_|native_packed_f16_|native_f16_alu_)' -V:native_packed_dot2_f16_ir: Passed (26cases matched exact binary32 model;9refusals matched).native_packed_dot2_f16_controls: Passed (26cases compiled to DXIL; verified9refusals).native_packed_dot2_f16_pixel_warp: Passed (Microsoft Basic Render Driver10.0.26100.9711,5quad draws matched; debug layer unavailable).native_packed_dot2_f16_pixel_hardware: Passed (NVIDIA Quadro M1000M32.0.15.7371,5quad draws matched; debug layer unavailable).native_packed_dot2_f16_compute_hardware: Skipped (77,Intel(R) HD Graphics 53031.0.101.2111requires SM 6.6 with wave32).*_compute_hardware/*_hardwarecompute tests also skipped77on HD 530).ctest --preset dev --no-tests=error -R '^native_.*_(controls|ir)$' --output-on-failure: 67/67 passed (0skips).src/gfx1013_direct_compute.inl(drop_hi_term,drop_neg_c,drop_clamp,swap_opsel_hi) all failednative_packed_dot2_f16_ir(rc=8); clean source restored and re-verified passing.python -B tests/docs_links_check.py: passed (130Markdown files,630links).AI-assisted.
Imported from R0Y00/Xbox2Windows. Originally posted by R0Y00 on 2026-11-28T01:43:42Z.
Review: CHANGES_REQUESTED
The source-built Compute fixture fails on a physical adapter in both Debug and Release /O2. I tested PR head
acab1a069aon main8007a539(trial tree 4ace676e91538352270b0b178cf6d940c662f485):In both builds 11 passed, including the WARP and hardware Pixel cases, and 1 failed (no skips). In native_packed_dot2_f16_compute_hardware, the first mismatch is word 25 (case 17 after the eight guard words): inline_int_src2_129 uses zero packed operands and the positive binary32 subnormal accumulator 0x00000001. The GPU returned 0x00000000 in successive lanes (25, 57, 89, ...). This is consistent with a denormal being flushed in the emitted floating-point addition. Please establish the binary32 mode for this opcode and preserve the required result or reject an unsupported mode at compile time. Keep the failing bit-exact control, including coverage for an accumulator sourced from a register if the fix handles encoded constants specially.
RTX 4060 Laptop, driver 32.0.16.1656, Windows 11 26200.9974, standalone replay without the debug layer.
Imported from R0Y00/Xbox2Windows. Originally posted by legacy-code-archaeologist on 2026-11-28T01:54:20Z.
@R0Y00 Thank you for catching that on RTX 4060 Laptop and reporting the exact failing case (
inline_int_src2_129,0x00000001flushed to0x00000000)!Root cause:
gfx1013starts withMODE[5:4] = 3(keep binary32 denormals) andMODE[1:0] = 0(RNE), whereas desktop DXILfaddandsaturate(dx.op.unary.f32(i32 7, ...)) flush binary32 subnormals to zero.Fix:
((mode_bits ^ 0xf0u) & 0x8000ffu)) forv_dot2_f32_f16(alongsideconsume_half_mode()refusings_denorm_mode/s_round_modewrites that alter binary32 fields).src2source kinds (inline constants, VGPRs, SGPRs, literals) andclamp: every finite nonzerobinary16 * binary16sum(a0 * b0) + (a1 * b1)is an integer multiple of2^-48(|sum| >= 2^-48 >> 2^-126), so a binary32 subnormalc(0 < |c| < 2^-126) is observable if and only if(a0 * b0) + (a1 * b1) == +/-0.0. Selectingcbits(orc < 0 ? 0 : cbitsunderclamp) whensum == +/-0.0andcis subnormal preserves bit-exact subnormal outputs.tests/native_dot2_f32_f16_check.py: keptinline_int_src2_129(0x00000001, now also enabled inpixeldraws), added four VGPR-sourced binary32 subnormal accumulator cases (vgpr_src2_subnormal_pos,vgpr_src2_subnormal_neg0x80400000,vgpr_src2_subnormal_clamp_pos,vgpr_src2_subnormal_clamp_neg->+0.0), and added ans_denorm_mode 0xC(FP32 denorm flush) refusal control.Re-verified locally (
devandrelease/O2presets, Windows 10.0.26100):ctest --preset dev&--preset release --no-tests=error --output-on-failure -j 1 -V -R '^native_(packed_dot2(_f16)?_.*|packed_f16_inline_(ir|controls|compute_hardware)|f16_alu_(ir|hardware))$':native_packed_dot2_f16_ir: Passed (30cases matched exact model;10refusals matched).native_packed_dot2_f16_controls: Passed (30cases compiled to DXIL;10refusals verified).native_packed_dot2_f16_pixel_warp: Passed (Microsoft Basic Render Driver10.0.26100.9711,7quad draws matched, includinginline_int_src2_129and all 4 VGPR subnormal cases).native_packed_dot2_f16_pixel_hardware: Passed (NVIDIA Quadro M1000M32.0.15.7371,7quad draws matched; debug layer unavailable).native_packed_dot2_f16_compute_hardware: Skipped (77,Intel(R) HD Graphics 530lacks SM 6.6 wave32 — please retest on RTX 4060 Laptop!).ctest --preset dev --no-tests=error -R '^native_.*_(controls|ir)$' --output-on-failure: 69/69 passed (0skips).drop_subnormal_keepfailsnative_packed_dot2_f16_pixel_warp(rc=8) oninline_int_src2_129and the VGPR subnormal cases.AI-assisted.
Imported from R0Y00/Xbox2Windows. Originally posted by R0Y00 on 2026-11-28T02:00:29Z.
Review: APPROVED
Re-reviewed
057dae6c60on main50e4f763(tested tree6ad305dc0f). The earlier RTX Compute mismatch is gone. The old inline 0x00000001 accumulator and new positive, negative, and clamped VGPR cases preserve the expected bits, and the FP32 flush-mode control refuses as expected. The integer select covers the subnormal accumulator regardless of its operand source, when the binary16 product sum is zero.Debug 12/12 and Release /O2 12/12, no skips. Physical Compute and Pixel checks used the RTX 4060 Laptop GPU (32.0.16.1656); the Pixel WARP run used inbox WARP 10.0.26100.9818. Windows 11 26200.9974, standalone replay without the debug layer.