Repository navigation
Conversation
…irv-as does The fallback encoded hex-float literals with float.fromhex + struct.pack, which round to nearest. spirv-as keeps only the target mantissa bits and drops the rest, so the two assemblers wrote different constants (e.g. f16 0x1.8p-24: ours 0x0002, spirv-as 0x0001). Encode the significand directly with an integer shift, matching spirv-as. Verified bit-for-bit against spirv-as on 600 generated f16/f32 literals (normals, subnormals, truncation cases): 0 mismatches. Adds a regression test with values measured from spirv-as v2026.1 (fails on the previous code, passes now). Refs ItsNotRexed#4330
0xKaji
reviewed
Nov 23, 2026
0xKaji
left a comment
There was a problem hiding this comment.
Reviewed the diff: handles excess mantissa truncation toward zero as spirv-as does, with measured cases. Good.
Contributor
|
Tested 498d6e6 on Ubuntu 24.04.4 (kernel 7.0.0-31-generic), Python 3.12.3, CPU only, no game files: pass.
Synthetic inputs only; no game data. AI-assisted. |
|
Tested
AI-assisted. |
Contributor
|
Tested 498d6e6 on Windows 11 (26200.9974), Python 3.12.0: pass.
Synthetic literals only; no game data, no GPU, no AI-assisted. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes #4330.
What
tools/spirv_asm.pyencoded hex-float literals withfloat.fromhex+struct.pack, which round to nearest.spirv-askeeps only the target mantissa bits and drops the rest (truncates toward zero). The two assemblers wrote different constants:0x1.8p-240x00020x00010x1.ffffp-240x00020x00010x1.0000018p+00x3F8000010x3F800000Change
The hex-float fallback now shifts the significand directly (integer arithmetic), so excess bits are dropped the same way
spirv-asdrops them. Inf/NaN handling is unchanged.Verification
spirv-as(v2026.1,--target-env vulkan1.2) on 600 generated literals (300 f16, 300 f32, covering normals, subnormals and truncation): 0 mismatches (checked by reading the constant words from thespirv-asbinary).test_hex_float_excess_mantissa_truncates_toward_zero_like_spirv_as: fails on the previous code (4 of 5 subtests), passes now.python -m unittest discover -s tests -p 'test_spirv_asm*.py' -t tests: OK.scripts/check_no_game_data.py: OK. No game files attached.AI disclosure
AI-assisted (Claude). The author reviewed the change and reran the comparison against
spirv-asbefore opening this PR.