Repository navigation
Recomp: clamp 64-bit float results to [0.0, 1.0] instead of saturate (#105) - #246
slopgobblercobbler wants to merge 1 commit into
Conversation
|
The premise doesn't hold on the DXC versions I tried:
Tested
Not tested
🤖 Claude Opus 5.5 |
|
Thanks @Kalmarv for the thorough DXIL disassembly audit across SDK DXC 1.7 and DXC 1.9. You're completely right—@dx.op.unary.f64(i32 7, ...)\ emits a native 64-bit \Saturate\ in DXIL without narrowing, which is cleaner and produces 1 DXIL op instead of 2 (\FMax\ + \FMin.f64). We investigated the note from #105, but your DXIL trace clearly demonstrates that the existing \saturate\ emission on \main\ is already optimal and precise. Closing this PR in light of your findings. Thank you! |
|
Tested on RTX 5060 Ti 8 GB, driver 621.24, Ryzen 5 5600X, Windows 11 Pro 26300 (native), Rust 1.100.0 msvc, debug. Run and written with Claude Code (Claude Opus 5.5). |
Addresses #105 Item 4 (Recompiler 64-bit float clamp precision):
In
crates/xcl/src/gpu/recomp/emit.rs,valu64emittedsaturate(double)whenCLAMP=1. HLSL SM 6.6 does not have an intrinsicsaturateoverload fordouble, narrowing the argument tofloatand losing 29 bits of mantissa precision.Replaces
saturate(...)withclamp(..., 0.0, 1.0)on 64-bit floats, preserving full double precision across 64-bit float instructions (V_ADD_F64,V_MUL_F64,V_FMA_F64).What is in it
crates/xcl/src/gpu/recomp/emit.rs:valu64clamp emission usesclamp(expr, 0.0, 1.0).crates/xcl/src/gpu/recomp/tests.rs:valu64_clamp_and_omod_hlsltesting clamp and omod generation and validating compilation with DXC.Tested
cargo test -p xcl -- recomp(172 passed, 0 failed).cargo test --workspace(603 passed, 0 failed).Not tested
AI use
author-recomp-fp64,verify-recomp-fp64). Verified and reviewed independently.