shader: lower the four double arithmetic forms #141
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/141"
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 Zettrox/ztrx. Originally posted by xiaotu030202 on 2026-11-25T14:04:46Z.
What this adds
v_add_f64,v_mul_f64,v_min_f64,v_max_f64were all refused. They became reachable when #138/#140 put adoublein the emitter — before that, all six double instructions ingfx10/opcodes.rswere unreachable together.Nothing in #132's log contains any of these. This is the rest of what the conversion pair unlocked, not a fix for a reported failure.
max_mincannot be reused, and the validator says whyThe
f32min/max go throughmax_min, which callsdx.op.binary.f32withi32bitcasts to fix the-0ordering. Handing it adoubleis refused in one line:FMin/FMaxexist only forf32/f16. Sof64_max_minis a compare and a select, keeping the hardware's-0rule — of two zeros the maximum is+0unless both are−0, the minimum is−0unless neither is — withi64masks (0x7FFF_FFFF_FFFF_FFFF) instead ofi32ones.A bug in my own test, caught by the test
The first run failed with
v_add_f64(1.0, 2.0) -> 1.0. The lowering was fine; the test was wrong.build_cshands its four input dwords tov1..v4, and I widened the first input intov2— clobbering the second input before it was read. The sum really wasa + garbage.Temporaries now start at
v8. A translate-only assertion would have passed and shipped a test that measured nothing; this is the second time in this pair of features that value-checking earned its place.Tests
the_double_arithmetic_forms_compute_in_doubleruns all four forms on the hardware adapter and WARP, over 1.0/2.0, 2.0/3.0, −2.0/1.0, 10.0/10.0, comparing against the same arithmetic in Rust atf64. Inputs are widened withv_cvt_f64_f32and the result narrowed withv_cvt_f32_f64, so it exercises #138 and #140 too.Verification
Windows 11, RTX 5070 Ti, Rust 1.98.1 (pinned), MSVC 14.44.35207, Windows SDK 10.0.26100.0,
VICTORY_DXILset. No game files.What is not claimed
No title has been seen failing on any of these. They are tested in isolation, not against a real shader.
Seven double instructions still do not lower:
v_fma_f64,v_rcp_f64,v_rsq_f64,v_sqrt_f64,v_frexp_*_f64,v_div_scale/fmas/fixup_f64, thev_cmp_*_f64family, and theds_*_f64LDS forms. Each needs its own reading of the ISA —v_sqrt_f64is a two-instruction sequence on some hardware — and none are here.The stack, and an offer
Three branches that build on each other:
mainalone?TypeDef::Double,Types::f64,Cast::FPTrunc,v_cvt_f32_f64Cast::FPExt,v_cvt_f64_f32f64_max_minSay the word and I will squash all three into one branch with one description. Three PRs for one feature is worse to review than one, and I only split them because each was independently verifiable as I went.
Imported from Zettrox/ztrx. Originally posted by xiaotu030202 on 2026-11-25T14:10:41Z.
Superseded by #142, which is all three of these in one branch.
They were split because each was verifiable on its own, but two of them cannot apply to
mainwithout the first — so reviewing them apart means reviewing a branch that does not build. #142 has the same content with one description and one diff.Closing rather than leaving three open PRs for one feature.
Pull request closed