Repository navigation
Recompiler: fold finite constant legacyF16ToF32 conversions in direct DXIL - #2552
ramon-victor wants to merge 1 commit into
Conversation
|
Verification on RTX 3060 Ti (Windows 11), branch merged with current
Thanks! — Devin |
|
Wave64 run (listed as untested; the wave64 GPU tests skipped on the RTX 3070) on an AMD RX 9070 XT, plus an RTX 3060: both new tests pass, and nothing else changes in the direct-DXIL GPU suite. Head
On both cards, the only result changes against Not tested: Intel, a title. |
|
Independent AMD RDNA4 (native wave64) verification of exact PR head Tested
(Compare against Not tested
AI use
|
|
Tested: current PR head merged onto current
Not tested: retail titles (no title data on this lane, counts only). AI use: Hermes agent (local Qwen-class) ran both machines and drafted this; I checked it before posting. |
Integrates upstream amd-dev 9f02a3b (BVH null/OOB guard), b67375b (scratch SADDR 0x7F), 4ae5668/xcl-dev#2565 (32-bit VALU add/sub carry without i64), plus open PRs xcl-dev#2559 (bfm/ffbh_i), xcl-dev#2557 (known_nonzero_bits folding), xcl-dev#2552 (f16-to-f32 fold), xcl-dev#2568 (integer min/max range opt), and xcl-dev#2580 (empty DXC blob null slice). Assisted-by: Antigravity (Gemini 4 Neon)
…l-dev#2557/xcl-dev#2568 - real.rs: require 8-byte alignment in UnadoptGuard::new before atomic vtable load (fixes debug misaligned-pointer panic on synthetic unaligned test handles). - list_x.rs: add UnadoptGuard and create_raw_fence in Wine GPU tests. - opt.rs: revert unmerged xcl-dev#2557/xcl-dev#2568 passes while keeping xcl-dev#2552. Assisted-by: Antigravity (Gemini 4 Neon)
Part of #1269.
Problem
RDNA2 mixed-precision and half-conversion instructions (
v_fma_mix_f32,v_fma_mixlo_f16,v_fma_mixhi_f16,v_cvt_f32_f16, packed f16 helpers) frequently convert inline or constant-folded 16-bit half operands tof32viaShader::f16_to_f32(dx.op.legacyF16ToF32). Even afteropt.rsfolds the precedingand 0xFFFF/lshr 16extraction to a constant integer,dx.op.legacyF16ToF32was left as an intrinsic call and was also absent fromopt::removable, preventing constant folding and dead-code elimination.Fix
f16_bits_to_f32_bits(h: u16) -> Option<u32>incrates/xcl/src/gpu/dxil/ops.rs, performing exact IEEE-754 binary16 → binary32 conversion for all finite values (±0.0, all subnormals, all normals) while returningNonefor±InfandNaNso DXIL never materializes non-finite float constants.Shader::f16_to_f32(ops.rs) and post-SSA/constant-propagationdx.op.legacyF16ToF32calls inModule::simplify_op(module/opt.rs).dx.op.legacyF16ToF32calls inModule::removable(module/opt.rs);legacyF16ToF32isReadNone, uses no 64-bit types, and sets no DXIL shader feature flags.ops::f16_fold_testscovering all 65,536 half bit patterns, finite direct & shift/mask-folded constants (verifying zero remaininglegacyF16ToF32), non-finite preservation, and bit-exact RTX 3070 GPU parity with hardwaredx.op.legacyF16ToF32.Measured impact
573-program retail direct-DXIL validation sweep (
dxil.dll1.8.2502.11):6d12f58):573/573validated (val_fail=0),51,117,488total DXIL bytes (p50=22,865 us,p95=408,132 us).84f6bdc):573/573validated (val_fail=0),51,074,004total DXIL bytes (-43,484 B/-0.085%;p50=19,788 us,p95=389,471 us).Tested
cargo test --lib -p xcl f16_fold): 2 passed, 0 failed (f16_bits_to_f32_bits_exhaustive,f16_to_f32_constant_folding_validates_and_matches_gpu)..\scripts\test.ps1, NVIDIA GeForce RTX 3070, Windows 11):1425 passed, 0 failed, 46 ignored.dxil.dllvalidation sweep:573/573passed,0failures.cargo build --release -p xcl) and 60 s retail smoke run (see below).Not tested
Regression run
Main (
f087b99):This PR (
84f6bdc):AI use