Repository navigation
Conversation
OpConvertUToF and OpConvertSToF went through float(v), which rounds a 64-bit value to binary64 before binary32: 2**62 + 2**38 + 1 gave 0x5E800000 and 2**62 + 3 * 2**38 - 1 gave 0x5E800002 instead of 0x5E800001. The integer is now rounded to 24 significant bits (to nearest, ties to even) first; 32-bit values give the same words as before.
Values that round the wrong way through binary64, with the words an RTX 2060 gives for them.
|
Independent Windows CPU check at 560d89d: the new integer-to-binary32 helper matched the Windows UCRT on all 50,950 distinct inputs. The previous conversion disagreed on 84 of the same inputs. For the reference I passed each integer as an exact decimal string to This checks the conversion helper directly. Windows / CPython 3.14, CPU only, synthetic inputs. AI-assisted. |
|
Tested 560d89d on Arch Linux, Python 3.14.10, CPU only: pass — first Linux check. test_spirv_wave_interp 20/20 (28 subtests) + related test_interp 52/52 (116 subtests) OK. Negative control: base file → exactly the 2 new 64-bit-rounding tests fail; restored, green again. No game files, no GPU. AI-assisted. |
|
Tested
Beyond the PR's own tests, the agent ran a differential harness against an exact reference (Python integers and No conflict with #8449 or #8149 by its trial merges. Independent check (not the author). Run by an AI agent (DeepSeek V4.1 Flash) and re-run by the orchestrating session (Claude Code) before posting. |
Claimed in #7496 as: #7496 (comment)
What and why
tests/semantic/spirv_wave_interp.pyconverted an integer to float as_f32_pack(float(v)).float(v)rounds a 64-bit value to binary64 first, and the binary32 rounding after that can then go the wrong way:OpConvertUToF %floatof0x5E8000000x5E8000010x5E8000020x5E8000010x5F0000000x5F000001OpConvertSToFof the negated values gives the same words with the sign bit set. Vulkan requires conversions to be correctly rounded, and the interpreter's own arithmetic rounds to nearest even. Main rounds the first two values in opposite directions, so no single rounding mode gives its words.The fix rounds the integer to 24 significant bits (to nearest, ties to even) with integer arithmetic.
float()is exact after that. Every 32-bit value is exact in binary64, so 32-bit conversions give the same words as before.spirv_mini_interp.pyrefuses 64-bit conversion operands, andtools/rdna2spirv.pyonly converts 32-bit integers, so no translator test relied on the double rounding.Commits:
spirv_wave_interp: a new_int_to_f32rounds once, andOpConvertUToF/OpConvertSToFuse it.WideIntegers.test_64bit_integer_to_float_rounds_onceintest_spirv_wave_interp.pycovers eight 64-bit conversions and checks the words the GPU gives. Three values per op round the wrong way through binary64; 2^64 − 1, −2^63 and 2^53 + 1 are controls.Tested
Linux, Python 3.14.10 (standard library only), RTX 2060 SUPER with driver 620.70.06, on main 042c5f3:
spirv-as,spirv-val --target-env vulkan1.2andvk_harness, and the GPU gave the expected words. Those words are the ones the test checks.python3 -I tests/semantic/test_spirv_wave_interp.py: 20 tests OK. With main'sspirv_wave_interp.pyput back, both subtests of the new test fail (0x5E800000, 0x5E800002, 0x5F000000, 0x5F800000against0x5E800001, 0x5E800001, 0x5F000001, 0x5F800000, and the same for the signed ones)._int_to_f32against an exact reference over 57,618 values of every width up to 64 bits and their negations, with no difference. On 40,000 32-bit values it gives the same words asfloat().tests/semanticfiles that use the wave interpreter pass, and so dotests/test_cf_diff.py,tests/test_wint_diff.pyandtests/test_semantic_translator_use.py.Checklist