Repository navigation
SHADER-597: declare SignedZeroInfNanPreserve 64 in modules that use Float64 - #3290
tomgamer22 wants to merge 3 commits into
Conversation
…R-597) Modules that declare Float64 now also get OpExecutionMode %main SignedZeroInfNanPreserve 64, so -0, NaN and inf in native f64 ops no longer rest on driver defaults. Same gating as the 32-bit mode from ItsNotRexed#664: the index entry lists shaderSignedZeroInfNanPreserveFloat64 next to Float32, vk_pipeline_check skips the shader where that property is false, and --no-float-controls leaves both modes out. Modules without Float64 are unchanged. Found by @Jolymmiles (issue ItsNotRexed#3047). Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Conflict in docs/design.md only: main updated the "Floating-point class compare" row next to the float-controls rows. Kept main's row, the SHADER-99 row's pointer to f64 and the SHADER-597 row. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
|
Tested 782c09c on NVIDIA GeForce RTX 3060 Ti (Ampere), driver 610.88, Vulkan 1.4.341 (
For the record, main's translator also gives 2/2 on this driver: NVIDIA keeps -0 for f64 without the mode, so this card shows no failure without the PR, only that the declared mode is accepted. No game files. AI-assisted (Claude Code). |
|
Code read at the current head. The translator side looks complete: the 64-bit mode follows the same
With this PR, Smaller, and older than this PR: No game files. AI-assisted (Claude Code). |
|
Tested Machine: Linux Mint 22 (Ubuntu 24.04 base), NVIDIA driver 615.71.09, Vulkan 1.4.351, GPU tests pass on both cards, no regression:
Translator side:
|
|
Tested 782c09c on AMD Radeon RX 9070 (RDNA4, subgroup 32..64), AMD 26.10.1 (LLPC), Vulkan 1.4.359, Windows 11 26300: pass. Test programs: runtime build of main f847748, so the vk_pipeline_check change here was not built or run. Python 3.12.10, llvm-mc 21.1.8, Vulkan SDK 1.4.363.0,
Neither f64 test has a −0, NaN or ±inf result, and main's translator also gives 2/2 here, so this shows the mode is accepted on AMD, not what it changes; |
|
Tested 782c09c 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. |
|
Tested
No game files. AI-assisted (Claude Code). |
|
Tested on Windows 11 with two GPUs on one machine (head merged with main f847748, MSVC 14.51, Python 3.13.1;
Only the f64 programs were run on the GPUs. |
|
Tested
None of the GPU fixtures use f64 with the new AI-assisted (Claude Code). No game files. |
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
|
Re-tested the current head
AI-assisted (Claude Code). |
|
Tested d62694e (a re-test at the new head) 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. |
What and why
#664 (SHADER-99) made every module declare
OpExecutionMode %main SignedZeroInfNanPreserve 32, and left f64 for later. Native f64 shaders still don't declare the 64-bit mode, so Vulkan lets the driver assume no −0, NaN or ±inf in 64-bit float ops, and results such asv_add_f64of −0 and −0 = −0 rest on driver defaults.This PR adds the 64-bit mode, only in modules that use
Float64:tools/rdna2spirv.py. When the module declaresFloat64(gen.uses_f64), it also getsOpExecutionMode %main SignedZeroInfNanPreserve 64.SignedZeroInfNanPreservethat Translator: declare SignedZeroInfNanPreserve so drivers keep NaN, inf and -0 (SHADER-99) #664 already declares (core since SPIR-V 1.4), so noSPV_KHR_float_controlsextension is needed atvulkan1.2.shader_metanow buildsfloat_controlsfrom the declared widths. An f64 module lists["shaderSignedZeroInfNanPreserveFloat32", "shaderSignedZeroInfNanPreserveFloat64"]; other modules keep["shaderSignedZeroInfNanPreserveFloat32"].Float64are byte-for-byte unchanged.runtime/test/vk_pipeline_check.cpp. It acceptsshaderSignedZeroInfNanPreserveFloat64and skips the shader whereVkPhysicalDeviceFloatControlsProperties::shaderSignedZeroInfNanPreserveFloat64is false. Before this change it would have reported "unknown float control". The change is oneelse ifnext to the Float32 check, sincefcPropsis already queried.docs/design.md. A new "Float controls for f64 (SHADER-597)" contract row. The SHADER-99 row now points to it.Gating (mirrors #664)
vk_pipeline_checkskips the shader on a device that reports it false.--no-float-controlsleaves out both modes and the capability, so a device without the Float64 property still gets a valid module through the same fallback flag thatmake_game.pyalready forwards.--no-float-controlsfor its f64 shaders, which also drops the 32-bit mode. If that combination shows up in practice, a narrower flag can follow.Credit
The finding is @Jolymmiles's, in #3047.
Testing
No GPU run was done by the author; there is no Vulkan device or compiler on this machine. A GPU run is wanted:
ps_f64_round(#2273, once it lands; it checks-0 + -0 == -0) and the existingps_f64_mods, on a device withshaderFloat64, plusvk_pipeline_checkon the f64 fixtures. The C++ change was not compiled.CPU tests (Python 3.11, Windows; no pytest, llvm-mc or spirv-val available here):
python -I -m unittest discover -s tests -p "test_f64*.py": 8 tests OK. This includes the newtests/test_f64_float_controls.py, which checks three cases:float_controls;Float64has only the 32-bit mode;--no-float-controlsdrops both.python -I -m unittest discover -s tests -p "test_shader_checks.py": 71 OK.python -I -m unittest discover -s tests -p "test_make_game_translator_flags.py": 14 OK.python -I -m unittest discover -s tests -p "test_fspx_shaders_stage.py": 12 OK.python -I -m unittest discover -s tests -p "test_docs*.py": 11 OK.python -I -m unittest discover -s tests/semantic -p "test_*.py": 4142 tests OK, 4 skipped.git diff --check: clean.tests/test_translate.py(Translator: declare SignedZeroInfNanPreserve so drivers keep NaN, inf and -0 (SHADER-99) #664's float-controls tests) needs pytest, which isn't installed here, so it wasn't run. The modules it checks have noFloat64, so its expectations are unchanged.AI-assisted (Claude Code).
🤖 Generated with Claude Code