xshader: add natively on hosts with doubles where MODE allows #642
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/642"
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 brcly/TuxBox. Originally posted by NickStallman on 2026-12-01T21:44:22Z.
v_add_f64is written as integer arithmetic on 128-bit values (tb_f64_add), which matches the card bit for bit on any host. Each inlined add costs about 250 basic blocks of DXIL. 22 recorded ProjectScarlett compute programs have 24 to 72 adds each, and in their two-lane form every add is written once per wave half. These adds make up more than half of their DXIL.xshader --f64-hosttranslates for a host whose shaders run doubles. Therev_add_f64becomes apreciseHLSLdoubleadd wherever the result is the card's:s_round_mode,s_denorm_modeors_setregthat reaches those bits must be an immediate that keeps them. A register written there sends every add in the program back to the helper. The f32 fields and DX10 clamp don't changev_add_f64(native receipt: MODE bits 0x2cc).0xfff8000000000000, through the sametb_f64_qnanas the helper.precisekeeps DXC from folding or reassociating the add (-0 + +0stays+0).The multiply, the fused multiply-add and everything else stay in integers. Without
--f64-hostthe output is unchanged.The provider
The host profile now records
DoublePrecisionFloatShaderOpsasdoubles=yes|none, andTUXBOX_HOST_PROFILE=doubles=nonetakes it away. On a host with doubles, a compute program whose code decodes av_add_f64(tuxbox_dxbc::float64::adds_f64) is requested under keys of its own:<hash>_f64(.f64) and, on a 32-lane host,<hash>_w32_f64(.wave32f64). The host worker translates those with--f64-host(and--wave32-host). A host without doubles never asks for these keys, so it can't get that translation from a shared cache, and every other program keeps its key, so nothing else recompiles. The detector only picks the key: the translation is exact either way. Once any device in the process reports no doubles, the provider asks for none.Shader preparation, slow markers,
stage_baseline,shader_survey, the shader harness, triage and replay integrity know the two kinds. A program recorded as.f64is surveyed and measured like a.dxbcone.The GPU check
tools/native_rdna2/check_translated.py(JohnVonWells' comparison with native RDNA2 execution, #614/#615) gets--f64-host, which translates with the native add and fails if any program takes the other path than MODE says, and--edge-pairs, which adds every ordered pair of 20 edge values (signed zeros, denormals, the smallest normals, ±1, the largest finite values, infinities, quiet and signaling NaNs with payloads) ahead of the seeded records. The seeded records alone pair two infinities in no record and two zeros in one.Native words from an AMD Raphael iGPU through HSA (gfx1036 run as gfx1030), 1024 MODE values; translated programs under the 23 MODE values of the check, nine of them native; 4,536 records per MODE value (448 edge pairs and 4,088 seeded):
--f64-host--f64-hostwithout the NaN rules (negative control)All other forms pass as on main. Both cards report
DoublePrecisionFloatShaderOps= 1 under GE-Proton11-15. The 5090's Vulkan driver reportsshaderDenormPreserveFloat64 = false; vkd3d-proton still reports doubles for the NVIDIA driver, and the denormal sums above match.Recorded programs
On 51,414 recorded ProjectScarlett
.dxbcand.wave32requests, the 22 programs withv_add_f64change, with and without--wave32-host, and all of them compile with DXC 1.8.2505.1 and pass DXV. A seeded sample of 600 other requests translates to the same bytes, as it must: only thev_add_f64lowering looks at the flag.DXC CPU time and DXIL for the 22, main →
--f64-host:-O1 -disable-lifetime-markers -fnew-inlining-behavior)-O0flagsThe three largest (72 adds) took 60 to 64 s at the runtime flags, past
COMPUTE_TIMEOUT(60 s), so the runtime compiles them at-O0; they now take 29 to 33 s. At-O3the largest takes 237 s instead of 737 s. The NVIDIA driver's compile time for these programs was not measured, and the game was not run with this change.Tests
native_f64_add_needs_a_host_with_doublesandnative_f64_add_only_under_an_ieee_f64_mode(16 MODE writes) insrc/tests/hlsl/float64_arith.rs; they don't build on main, which has nowith_host_f64.doubles=noneand the new field.native_doublestests: a host without doubles keeps<hash>and<hash>_w32, and one device without doubles settles the process.finds_a_double_add_in_any_program_of_a_container(tuxbox-dxbc): a console container built in the test, with the add in either program; a multiply or an unknown container is no add.test_double_requests_translate_with_native_adds_under_their_own_keys: each of the four compute kinds gets its own flags and cache entry. The survey, stage baseline and harness tests cover planning the new kinds.Evidence: TuxBox check of d1fdbae544d9, no uncommitted changes, no GPU checks: 13 passed, 0 failed, 0 not runThe provider's own tests build in the Windows typecheck; they run only in the GPU check.python tuxbox.py checkofd1fdbae5(GE-Proton11-15): RTX 5090 (10de:2b85) 215 pass, AMD iGPU (1002:13c0) 214 pass; the one failure on each islanes-selftest-texture-publication(#625, fails on main too).Proposal and discussion: #641. Draft until that is agreed. Refs #533.
🤖 Generated with Claude Code