Repository navigation
Conversation
RDNA2 ignores the VOP3 output modifier of the f64 VALU ops while f64 denormals are kept, which is the MODE this translator assumes. Measured with tools/hw_oracle raw kernels on a gfx1036 iGPU (Radeon iGPU of a Ryzen 7 7800X3D, Windows driver 31.0.24002.92, code object v5), wave32 and wave64 identical, over the four combinations of MODE.IEEE and denorm_mode_16_64: mul:2 / mul:4 / div:2 changed nothing for v_add_f64, v_rcp_f64, v_rsq_f64, v_sqrt_f64, v_trunc_f64, v_ceil_f64, v_floor_f64 and v_rndne_f64 while denormals were kept, applied only with MODE.IEEE off and denormals flushed, and clamp applied in every run. Both f64 call sites now hand clamp_mods_f64 only the clamp they actually apply. Coordinated as SHADER-721. The v_add_f64, v_rcp_f64/v_rsq_f64/v_sqrt_f64 and f64 rounding rows of docs/design.md now carry the measured rule and how it was confirmed, and the rows that said the translator applies the omod are corrected. Counted over the whole corpus: 216 v_add_f64 in 5 of the 26 503 listings, none of them with an omod or a clamp, and no f64 mnemonic in the corpus carries one, so no game shader changes. Expectations flipped in tests/semantic/test_valu_add_f64.py, tests/semantic/test_f64_round.py, tests/test_f64_output_modifiers.py and tests/test_f64_transcendentals.py, and in the GPU fixtures runtime/test/shaders/ps_f64_mods.asm and cs_f64_add.asm with their runners. ps_f64_mods, cs_f64_add and ps_f64_round pass on an NVIDIA RTX 4090 (driver 32.0.16.2124) and on that gfx1036 iGPU.
Kam471
left a comment
There was a problem hiding this comment.
Ran this at f2d33415 on Windows 11:
tests/semantic/test_valu_add_f64.py-> 8 tests, OK.tests/semantic/test_f64_round.py-> 2 tests, OK.tests/test_f64_output_modifiers.py-> 2 tests, OK.tests/test_f64_transcendentals.py-> 2 tests, OK.git diff --checkclean.
The change records that the f64 VALU ops keep clamp but not their omod, and updates the CPU/GPU fixtures accordingly; all affected tests pass. I cannot reproduce the hardware measurement here. No blocking issue.
|
Tested f2d3341 on NVIDIA GeForce RTX 3070 (Ampere,
So the omod-dropping result (1.25 instead of 2.5 for the No game files. AI-assisted (Claude). |
|
Windows + GPU check: NVIDIA GeForce RTX 5080 (driver 621.01) + AMD Radeon 610M iGPU (driver 32.0.13018.6, RDNA2-class), Windows 11, MSVC (VS BuildTools 18) + Ninja, RelWithDebInfo, llvm-mc 21.1.8 (gfx1013), spirv-as/spirv-val. Tested head Build: clean, 20 targets. GPU shader fixtures (
Python:
Full suite (
The PR's unstable CI state did not reproduce locally. Synthetic fixtures only, no game files. AI-assisted (opencode); runs on my machine. |
Flyander
left a comment
There was a problem hiding this comment.
The translator now preserves only the measured clamp behavior for the covered f64 VALU and rounding operations, while leaving unmeasured f64 ops untouched. The updated semantic and GPU fixtures exercise the changed output, and the reported hardware runs agree across wave sizes and vendor backends.
|
Tested
Every test has the same result as on
Tested and written by Claude (Claude Code), posting from @theswiss24's account. |
|
Tested f2d3341 on AMD Radeon RX 9070 XT (RADV GFX1201) and the Ryzen 7 9800X3D iGPU (RADV RAPHAEL_MENDOCINO, gfx1036), Mesa 26.2.6, Linux 7.3.4: pass, no regressions.
No game files. AI-assisted. |
Coordinated as SHADER-721 in #4084.
What changes
docs/design.mdsaidv_add_f64scales its result bymul:2/mul:4/div:2before clamping, and the rows forv_rcp_f64,v_rsq_f64,v_sqrt_f64and for the four f64 rounding ops repeated the same. On RDNA2 that omod doesnothing while f64 denormals are kept, which is the MODE this port assumes, so the translator was applying a modifier
the hardware drops. Both f64 call sites in
tools/rdna2spirv.pynow passclamp_mods_f64only theclamptheyactually apply;
clampis unchanged, andv_div_fixup_f64,v_div_fmas_f64andv_frexp_mant_f64are left asthey are (not measured here, and none of them occurs in the corpus).
How it was confirmed
tools/hw_oracleraw kernels, wave32 and wave64, on the Radeon iGPU (gfx1036) of a Ryzen 7 7800X3D, Windows driver31.0.24002.92, code object v5, AMD clang 23 from
rocm-sdk-core10.0.0: 23 cases across the four MODE combinationsof
IEEE×denorm_mode_16_64, coveringv_add_f64,v_rcp_f64,v_rsq_f64,v_sqrt_f64,v_trunc_f64,v_ceil_f64,v_floor_f64andv_rndne_f64. Wave32 and wave64 agreed on every case.denorm_mode_16_64 = 3(denormals kept): no omod changed anything, with MODE.IEEE on or off.denorm_mode_16_64 = 0with IEEE on: still nothing.denorm_mode_16_64 = 0with IEEE off: the omod applied.clampapplied in every run:1.25→ 1.0,sqrt(2.00003)→ 1.0,ceil(1.75)→ 1.0,ceil(-1.75)→ 0.0,floor(-0.25)→ 0.0.v_add_f64 2^-1074 + 0 mul:2kept0x0000000000000001in the two denormals-kept MODEs. With denormals flushedthe operand is already 0, so that case separates nothing; the normal sums are what show the second half.
@Vonsek measured the same split on a different gfx1036 in #3896 (
1.5 + 1.5 mul:2→ 3.0, and 6.0 only with IEEE offand denormals flushed) and left this op as a finding asking for exactly this fix. The rounding row here was already
measured by @timelery on gfx1036; this makes the translator agree with it instead of writing that it applies the omod.
Separately recorded and not fixed here:
v_sqrt_f64on this part is not the correctly rounded root —sqrt(4.0)stored0x4000000004000000(2.0000000298),sqrt(9.0)0x4008000004000000,sqrt(0.25)0x3fe0000004000000andsqrt(2.0)0x3ff6a09e64000000(1.4142135531 against 1.4142135624), each off by 2^26ulps of its own result, so only about 26 of the 53 significand bits are right. Four samples only, and the exact
v_rcp_f64/v_rsq_f64results prove nothing because those inputs are powers of two. Nov_sqrt_f64occurs in thecorpus, so it is written down as a finding rather than fixed.
Counted over the corpus
Counting every mnemonic that contains
f64in all 26 503 listings: 216v_add_f64in 5 shaders and 36v_cvt_f32_f64in 5, none with an omod and none withclamp, and no other f64 op appears at all. So thischanges no game shader's output; it is a contract fix, not a rendering fix.
Translating all 26 503 listings twice with the same flags (
--wave64-emulate, 8 shards,--no-asm) — once with thetranslator at main
aa2988cc, once with this branch — gives 26 503 translated in both runs and 26 473 passingspirv-valin both, with the same 30 rejected (Operand 'NNN[%NNN]' requires a previous definition, all of themcompute shaders, none of the 30 containing any
f64instruction: they come from what main merged after my earlierbuild, not from this change). Comparing the two output trees file by file, the 26 473
.spvare identical in sizeand SHA-256. So this changes no game shader's output; it is a contract fix, not a rendering fix.
Tested
runtime/test/shaders/ps_f64_mods.asm,cs_f64_add.asmandps_f64_round.asm: 3/3 pass on the RTX 4090(driver 32.0.16.2124) and on the gfx1036 iGPU (driver 31.0.24002.92), with the words this rule predicts
(
ps_f64_mods0x3ff40000, 0x3ff00000, 0x3ff00000, 0x3fd00000 — 1.25, 1.0, 1.0, 0.25). Their inputs areunchanged; only the expected words and their comments moved.
tests/semantic/test_valu_add_f64.py,tests/semantic/test_f64_round.py,tests/test_f64_output_modifiers.py,tests/test_f64_transcendentals.py: expectations flipped to clamp-only and passing.python -m unittest discover -s tests/semantic: 7456 tests, 7 failures and 2 errors — the same count and the sametests main already has (
test_mutations×2 for thev_mul_legacy_f32anchor,test_loop_ballot_barrier×3failures + 2 errors,
test_cmp_class_f64×2),skipped=1,expected failures=1. Nothing in an f64 module fails,and no new failure appears.
tests/semantic/regen_fixtures.py --check,scripts/check_no_game_data.py,python -m compileall -q make_game.py tools tests: clean.Related, not dependencies
v_mul_f64/v_fma_f64and recorded this as its finding.mainhas neither op,so this pull request builds on nothing.
hw_oracleretry on hip error 303. My probe needed code object v5 for the same reason; no dependency.untouched here.
AI-assisted: an agent ran the measurements and wrote the change; the doc rows and test expectations follow from them.