Repository navigation
Conversation
The VOP3 clamp bit was GLSL.std.450 FClamp, whose result is undefined for a NaN and may keep the sign of -0. RDNA2 (gfx1036, docs/shader_validation.md; gfx1150 agrees) clamps a NaN to +0 with DX10_CLAMP 1, the MODE the translator assumes, and -0 to +0 in every MODE. Gen.clamp01 emits it as an ordered x > 0 select, then a < 1 select, for f32/f16 results and the mix ops (clamp_mods), each half of the packed f16 ops, and v_add_f64. - tests/semantic/test_float_clamp_nan.py: NaN, -0, +-inf and in-range rows - runtime/test/shaders/ps_fnan_clamp.asm: GPU test, inputs from memory - tests that matched the FClamp text now use support.clamp01_count / drop_clamp01; the rcp and mad reference models give +0 for a NaN - docs/design.md: new "Float clamp bit" contract row Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…ata-flow checks (SHADER-186) Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
# Conflicts: # docs/design.md
…ow the clamp bit (SHADER-186) test_alu_min3_max3 (new on main) asserted that the interpreter refuses FClamp of a NaN; the clamp bit no longer emits FClamp, and the measured answer with DX10_CLAMP set is +0. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
|
Independent check of c065a3f on Windows 11 build 26300, RTX 5070, driver 621.24. All 10 SHADER-186 unit tests passed and the stock I also checked the f64 change on the GPU, since the mini-interpreter only checks its SPIR-V. A hand-written fragment fixture loaded two doubles from the heap, added each to itself with
The two modules passed Vulkan 1.2 SPIR-V validation. This verifies the translated f64 behavior on NVIDIA. Native AMD f64 clamp behavior remains unmeasured here. Synthetic inputs only. AI-assisted review. |
|
Independent AMD Windows validation of c065a3f passed. Compared with main 4947579 using the same synthetic shader inputs, runner and test binaries. Coordination claim. Windows 11 x64 build 26200, AMD driver 26.10.1. Tested Radeon RX 9070 XT (RDNA4, LLPC, Vulkan 1.4.359) and Ryzen 7 7700X Radeon iGPU (Raphael/RDNA2, AMD proprietary shader compiler, Vulkan 1.4.315). Both report compute subgroups of 32–64. LLVM 23.1.6, SPIRV-Tools 2026.4 and Python 3.13.15.
Synthetic inputs only. AI-assisted (Codex). |
|
Tested c065a3f on NVIDIA GeForce RTX 3090 (Ampere, subgroup 32..32), driver 610.88 (Vulkan 1.4.341), Windows 11 Pro 26300: pass. The PR's diff applied cleanly to
|
|
Tested |
|
Tested Test programs built from
AI-assisted run on a contributor machine. |
|
Tested
So the clamp rule (NaN and -0 give +0) also holds on NVIDIA, not only on the AMD parts it was measured on. AI-assisted run. |
|
Full-corpus counts, before and after (my own Xbox Series 1.0.2.1 copy: all 108 files match The work folder was built with
No change in either count. Which modules changed: 18,461 of the 26,503 Windows 11, Python 3.12, AI-assisted (Claude Code). |
|
Tested c065a3f on an RX 9070 (RDNA4), AMD 26.11.1 (LLPC), Vulkan 1.4.359, Windows 11: pass New AI-assisted |
# Conflicts: # docs/design.md # tests/semantic/regen_fixtures.py # tests/semantic/test_valu_fract_f16.py # tools/rdna2spirv.py
c065a3f to
826f4c4
Compare
…e-and-select form (SHADER-186) The f64 checks in test_alu_div_fixup, test_alu_div_fmas, test_alu_frexp_f64 and test_f64_transcendentals look for the clamp01 sequence on the double (support.clamp01_f64_count, or the four instructions in the value's data flow). The f16/f32 structure checks and negative controls in test_alu_f16_min_max, test_alu_f32_fma_clamp and test_valu_f16_round use support.clamp01_count / drop_clamp01. test_alu_f32_min_max asserted that clamp of an all-NaN v_min_f32 is refused by the interpreter; it now asserts +0. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…st with the measured words 572 distinct forms with clamp/omod/op_sel/neg (1,270,932 instructions in the 26,503 listings), 542 swept natively on gfx1036 through tools/hw_oracle in the game's MODE, 64,802 cases: 51,761 give the translator's word; the rest are differences already on record (NaN payload, f32 denormals SHADER-377, omod -0 -> +0 #1281, rcp/log/sin ulps, FClamp of NaN #2437). The test replays 1,616 words and fails without clamp (326) or omod (237). Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Conflicts: the ps_fnan_clamp GPU-test entries sit beside main's new ps_vcmp_f32_nan and ps_vcmp_64 entries, and the med3 row in docs/design.md takes main's text with the clamp-bit clauses pointing at the "Float `clamp` bit" row (dropping a repeated sentence that still said FClamp). v_div_fixup_f32, new on main, clamped with an IsNan select and FClamp, which leaves the sign of a -0 result open; it now uses clamp01 (SHADER-186), and its test and design row follow. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
|
Tested
No game files. AI-assisted (Claude Code). |
|
Tested 9789c94 on NVIDIA RTX 4080, driver 610.88, Windows 11: pass This is the head rebased on
AI-assisted. |
|
Tested 9789c94 (merge base aa2988c) on NVIDIA GeForce RTX 5080, Linux 580.65.06: fail Tested the PR head merged with current main
Line-by-line against my main run (results that differ from main):
Why fail: the PR does not merge cleanly with current main, and the semantic unit tests disagree after it. Not run: the full AI-assisted (Claude Code). |
|
Tested
AI-assisted (Claude Code). Synthetic shaders only, no game files. |
|
Tested
Not run: AI-assisted (Claude Code). |
Item: SHADER-186 (claimed in #2078)
The VOP3
clampbit on float results was GLSL.std.450FClamp, whose result is undefined for a NaN and may keep the sign of -0. RDNA2 clamps a NaN to +0 with DX10_CLAMP 1 (the MODE the translator assumes for the game) and -0 to +0 in every MODE. The rule is measured indocs/shader_validation.md, not taken from the ISA text: gfx1036f32_fuzz.py --oracle hwand the f16 / mix-op runs, and gfx1150 agrees.Change
tools/rdna2spirv.py: a newGen.clamp01emits the clamp asOpFOrdGreaterThan x > 0→ select x or +0 (false for NaN and both zeros), thenOpFOrdLessThan < 1→ select or 1.0. Used byclamp_mods(f32 and f16 results, mix ops), each half ofv_pk_*_f16 ... clamp, andclamp_mods_f64(v_add_f64: the same VOP3 field, unmeasured for f64). The otherFClampuses (format conversions,v_cvt_pk_*, LOD clamps) are not the clamp bit and stay as they are.docs/design.md: a new contract row "Floatclampbit: NaN, -0, infinity (SHADER-186)". The med3/NaN row and thev_add_f64row no longer say this case isn't modelled.docs/shader_validation.mditem 2 is marked fixed.Tests
tests/semantic/test_float_clamp_nan.py: NaN, -0, ±inf and in-range rows through the translator and interpreter. It coversv_mul_f32andv_add_f32with omod,v_mad_f32,v_fma_mix_f32,v_mul_f16,v_fmac_f16andv_pk_mul_f16, plus the f64 SPIR-V (the interpreters run no f64). Onmainit fails, with 10 errors and 2 failures (the interpreter refusesFClampof a NaN).runtime/test/shaders/ps_fnan_clamp.asm. Its inputs are read from memory, and it is registered incheck.py,run_gpu_tests.pyandregen_fixtures.py.FClamptext now usesupport.clamp01_count/support.drop_clamp01:test_valu_f16_round,test_interp_p1lv_f16, the negative controls intest_valu_f32_min3_max3_madandtest_valu_rcp_fdiv,test_rcp_iflag_mods,test_f64_conversionandtest_f64_output_modifiers. The rcp and mad reference models give +0 for a NaN under clamp.test_alu_min3_max3(new onmain) asserted that clamp of an all-NaN min3/max3 is refused; it now asserts +0. Eight more test modules that arrived with latermainmerges follow the same form: the f64 checks intest_alu_div_fixup,test_alu_div_fmas,test_alu_frexp_f64andtest_f64_transcendentalslook for the sequence on the double (newsupport.clamp01_f64_count),test_alu_f16_min_max,test_alu_f32_fma_clampandtest_valu_f16_rounduse the helpers above, andtest_alu_f32_min_maxasserts +0 for clamp of an all-NaNv_min_f32instead of a refusal.What I ran, on Windows 11 with an NVIDIA GeForce RTX 5070 Ti, driver 621.01, after merging
mainat f847748:python -I -m unittest discover -s tests/semantic: 7,332 tests, OK (mainalone: 7,322, OK).python -I -m unittest discover -s tests -p "test_*.py": 4,330 tests. The only failures are the same as onmain, run side by side:test_report_paths's macOS case-sensitive volume test and 27 import errors for modules this machine can't load.python -I tests/semantic/regen_fixtures.py --check,python -m compileall -q make_game.py tools testsandpython -I make_game.py --help: all clean.scripts/run_gpu_tests.py --filter ps_fnanand--filter _mods(LEONIDA_VK_DEVICE=5070): 12/12 pass, 4096/4096 pixels exact, includingps_fnan_clampand the nine existing output-modifier fixtures.The
maintranslator also passesps_fnan_clampon every driver tested so far. That covers NVIDIA here, and AMD Windows driver 26.10.1 on an RX 9070 XT (RDNA4) and a Raphael RDNA2 iGPU (FreddyxS's comparison run below). These drivers happen to give +0 forFClampof a NaN and of -0, which the spec doesn't require, so the old SPIR-V was correct only by accident there. The CPU test (test_float_clamp_nan.py) is what catches the old behaviour. RADV and MoltenVK haven't been tried.Checked by others (thank you)
All passes, on
c065a3f8; details in the comments below.v_add_f64 ... clampprobe: NaN and -0 give the double +0, ±inf give 1.0 / +0, and in-range values pass. That checks the translation on NVIDIA and AMD. What actual RDNA2 hardware does for an f64 clamp is still unmeasured.ps_fnan(3/3),_mods(9/9), the full semantic suite andregen_fixtures.py --checkon both AMD GPUs. They also ran the new test module againstmain's translator, where it fails as expected.main), Marukooh (RTX 5070 Ti, 620.73.04, Linux, wave64 emulation on and off), ricarmandoagent (RTX 4060, 620.70.06, Linux) and SashaTun (RTX 5060, 621.01; full GPU suite 140/186, 0 failed; 2,577 semantic tests OK).Full corpus, before and after (on
main4947579, details):mainand this PR both translate all 26,503 shaders, and all 26,503 passspirv-val. 18,461 modules change. These are exactly the shaders with a float op carryingclamp(717,346 instructions); no other module changes.Related, no dependency: #1970 (f16 omod/clamp, SHADER-297) and #718 (
v_cvt_f16_f32takes clamp) both go throughclamp_mods, so they get the new rule automatically.AI-assisted (Claude Code). No game data in this PR: the fixture and tests are hand-written.
🤖 Generated with Claude Code