shader: lower v_cvt_f64_f32 in direct compute path #3369
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/3369"
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 R0D4X on 2026-11-28T14:49:40Z.
Fixes #3368. Refs #2935.
Summary
v_cvt_f64_f32(0x10/0x190) in the native direct-DXIL compute path (src/gfx1013_direct_compute.inl):v[d:d+1]from a binary32 source using pure 32-bit integer arithmetic anddx.op.unaryBits.i32(33)(FirstbitHi), requiring neitherDoublePrecisionFloatShaderOpsnorInt64ShaderOps.±0.0),±Inf, andsNaN/qNaNquieting (| 0x00400000with payload preserved).240..248), and 32-bit literal sources, VOP3Aabs/neg, and overlappingD[0] == S0; refusespixel_stage,graphics_input,clamp,omod,op_sel,subword,dpp, unused VOP3 sources/modifiers, anddst == v255.v_cvt_f64_f32as a 64-bit VGPR pair write inclear_vector_spills(src/gfx1013_compute_native.cpp).tests/native_cvt_f64_f32_check.py(irCPU evaluation +controls+hardware),tests/cmake/native_f64_f32_cvt.cmake, anddocs/experiments/native-cvt-f64-f32.md.Verification
dbf57ab010.0.26300.9974), MSVC19.44.35230, Windows SDK / DXC10.0.26100.0, NVIDIA GeForce RTX 5080 (10de:2c02, driver32.0.16.2140), D3D12 debug layer off.cmake --build --preset dev --target native_compute_ir_dump compile_dxil native_store_replay&release: succeeded.ctest --preset dev --no-tests=error -R '^native_cvt_f64_f32_' -V: 3/3 passed (0 skipped); 32 CPU-evaluated IR words + 7 refusals + 2064 hardware readback words matched.ctest --preset release --no-tests=error -R '^native_cvt_f64_f32_' -V: 3/3 passed (0 skipped); all 2064 hardware words matched.tests/docs_links_check.py,tests/bidi_controls_check.py,git diff --check: passed.Imported from R0Y00/Xbox2Windows. Originally posted by KelboLive on 2026-11-28T20:46:29Z.
Review: APPROVED
LGTM — exact IEEE-754 binary32->binary64 widening using pure 32-bit integer ops and FirstbitHi.
Covers normals, subnormals (normalized to exact binary64 normals), signed zero, ±Inf, and sNaN/qNaN quieting. No DoublePrecisionFloatShaderOps or Int64ShaderOps needed. The IR dump, DXIL controls, and hardware tests are comprehensive (2064 words). Refusals cover clamp, omod, op_sel, unused sources, and dst==v255. The clear_vector_spills addition for the 64-bit VGPR pair is correct.
Ready to land.
Imported from R0Y00/Xbox2Windows. Originally posted by KelboLive on 2026-11-28T21:09:31Z.
Review: APPROVED
LGTM — clean, exact IEEE-754 widening.
Lowers VOP1/VOP3A v_cvt_f64_f32 using pure 32-bit integer arithmetic and FirstbitHi (dx.op.unaryBits.i32 33). No DoublePrecisionFloatShaderOps or Int64ShaderOps needed. Covers normals, subnormals (exact widening), signed zero, +-Inf, sNaN/qNaN quieting. Supports VGPR/SGPR/literal/inline-float/overlap sources, VOP3A abs/neg, overlapping D[0]==S0. 8 cases x 2 variants, 7 refusals, 4 negative controls.
Ready to land.
Imported from R0Y00/Xbox2Windows. Originally posted by KelboLive on 2026-11-28T21:57:25Z.
Review: APPROVED
LGTM — clean, exact IEEE-754 widening.
Lowers VOP1/VOP3A v_cvt_f64_f32 using pure 32-bit integer arithmetic and FirstbitHi (dx.op.unaryBits.i32 33). No DoublePrecisionFloatShaderOps or Int64ShaderOps needed. Covers normals, subnormals (exact widening), signed zero, +-Inf, sNaN/qNaN quieting. Supports VGPR/SGPR/literal/inline-float/overlap sources, VOP3A abs/neg, overlapping D[0]==S0. 8 cases x 2 variants, 7 refusals, 4 negative controls.
Ready to land.
Imported from R0Y00/Xbox2Windows. Originally posted by Leyukaka on 2026-11-29T04:45:00Z.
Review: COMMENTED
Commenting on head
dbf57ab0. Diff read againstmain212d4b5f; nothing built or run.Needs a rebase, no code change requested:
git merge-tree --write-tree origin/main dbf57ab0conflicts insrc/gfx1013_compute_native.cpp, because #3367 addedv_cvt_f64_i32/v_cvt_f64_u32to the samepairlist inclear_vector_spills(main lines 561-563). Keeping both sets of names resolves it.src/gfx1013_direct_compute.inlmerges cleanly.The lowering at
src/gfx1013_direct_compute.inl:3103-3153matches binary32 -> binary64 widening by reading: normal exponent + 896, subnormal exponent 905 - clz with the leading bit masked off (0x80400001 gives 0xB8000000_40000000), zero with its sign, Inf, and NaN with bit 22 set and the payload kept. f32 input denormals are kept, and that is the only mode that reaches this code:mode_bitsstarts at 0xf0, andconsume_half_modedoes not accept a write that changes the f32 denorm or round bits (main lines 4499-4545), so such a write stays refused. Only i32 ops and FirstbitHi are emitted, and_controlschecks the DXIL for nodouble/i64. No test on main asserts a refusal of this opcode in direct compute.Non-blocking test gaps. The inputs are 8 sampled values x 2 variants. Both Inf slots are -Inf, there is no qNaN input, and the only modifier case is
-|x|. So by reading, these changes still pass:inf_hi = 0xFFF00000(sign ignored)x | 0x80000000, or neg implemented asorxorinstead oforv_cvt_f64_f32from theclear_vector_spillspair list (the fixture has nov_writelane_b32spill)A +Inf input covers the first,
|x|alone and-xalone on a negative input cover the second, and a qNaN input covers the third. The four "negative controls" compare the Python reference with altered flags against the unaltered reference. They show that the reference distinguishes those cases, not that the test fails on a broken lowering.The checks pass, but none of the three new tests ran on this PR: the
prtest preset's include list does not matchnative_cvt_f64_f32_*. On pushes tomainthe dev preset runs with-E '_hardware$', so only_irand_controlsare selected in CI.Imported from R0Y00/Xbox2Windows. Originally posted by R0D4X on 2026-11-29T08:26:55Z.
Merged
upstream/main(2397aad3) keeping bothv_cvt_f64_i32/v_cvt_f64_u32andv_cvt_f64_f32inclear_vector_spills, and closed the three non-blocking test gaps @Leyukaka noted:+Inf(with-x -> -Inf) so both infinity signs are verified.qNaN(0x7fc00005) alongsidesNaN(0x7f800005) soxorvsoron the quiet bit fails.|x|(abs_m=1) and standalone-x(neg_m=1) on negative inputs.Verified on NVIDIA GeForce RTX 5080 (
10de:2c02, driver32.0.16.2140), Windows 11 (10.0.26300.9974), MSVC19.44.35230, SDK DXC10.0.26100.0:ctest --preset dev --no-tests=error -R '^native_cvt_f64_f32_' -V: 3/3 passed (0 skipped).ctest --preset release --no-tests=error -R '^native_cvt_f64_f32_' -V: 3/3 passed (0 skipped).Imported from R0Y00/Xbox2Windows. Originally posted by Leyukaka on 2026-11-29T08:39:59Z.
Review: APPROVED
Approving head
0969302a. Diff read againstmainb8c68ee9; nothing built or run.The conflict is resolved:
clear_vector_spillsnow hasv_cvt_f64_i32,v_cvt_f64_u32andv_cvt_f64_f32in thepairlist (src/gfx1013_compute_native.cpp:561), andgit merge-tree --write-tree origin/main 0969302ais clean. The net change is still the same 5 files, and thev_cvt_f64_f32block insrc/gfx1013_direct_compute.inlis unchanged fromdbf57ab0.The three test gaps are closed in
tests/native_cvt_f64_f32_check.py:0x7F800000, # +Inf (-x -> -Inf): plain expects hi0x7FF00000, the-xvariant expects0xFFF00000, so aninf_hithat ignores the sign fails either way.elif idx in (1, 4): ... abs_m=1 # |x| aloneon0x80000000and0x80400001, andelif idx in (2, 5, 7): ... neg_m=1 # -x aloneon0xBF800001: dropping abs, or neg implemented asor, fails.0x7FC00005, # qNaN with payload 5: setting the quiet bit withxorgives0x7FF00000_A0000000instead of0x7FF80000_A0000000and fails.native_cvt_f64_f32_ircompares every stored word withlane_results(), so by reading these three mutants fail in that test.Still open, non-blocking:
v_cvt_f64_f32from theclear_vector_spillspair list still passes: the fixture has nov_writelane_b32/v_readlane_b32.prtest preset does not matchnative_cvt_f64_f32_*, so the checks on this head are green without having run these tests. On pushes tomain,ctest --preset dev -E '_hardware$'selects_irand_controls.