Squash-merged after diff review of PR #6923 - spirv_asm: refuse an OpSwitch whose selector has no known type, instead of guessing 32 bits (SHADER-1089)
SPIRV-Tools reads a hex literal as a bit pattern only when it has no sign:
`OpConstant %short +0xFFFF` is 65535 and is refused for a 16-bit signed type,
while `0xFFFF` is still -1. _int_literal took `+0x...` as a bit pattern too, so
it assembled +0xFFFF (i16), +0x8000 (i16), +0x80 (i8), +0xFFFFFFFF (i32),
+0xFFFFFFFFFFFFFFFF (i64) and the same OpSwitch arms where spirv-as refuses
them. Found by @mrbean56.
Twelve more cases in IntegerLiteralRangeTests (77 in all, 40 refused),
measured with the Vulkan SDK 1.4.363.1 spirv-as; seven of them fail on the
previous commit.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The Python assembler masked every integer literal to its word size, so
`OpConstant %uint 4294967296` assembled as 0, `OpConstant %uint -1` as
0xffffffff, and `OpDecorate %x Location 4294967296` as 0, where spirv-as
refuses all three. It also wrote a hex literal for a signed type narrower
than 32 bits without sign-extending it (`OpConstant %short 0xFFFF` gave
0x0000ffff where spirv-as gives 0xffffffff, as the spec requires).
_int_literal now reads a literal for a given width and signedness the way
SPIRV-Tools does: unsigned takes 0..2^w-1 and no minus sign; signed takes
-2^(w-1)..2^(w-1)-1 or a hex bit pattern up to 2^w-1; narrow types are
zero- or sign-extended into their word. It is used for OpConstant /
OpSpecConstant, OpSwitch case literals (by the selector's type, which now
carries its signedness), LiteralInteger and PairIdRefLiteralInteger operands,
and the numeric fallbacks for enum values, masks and OpExtInst numbers.
IntegerLiteralRangeTests pins 65 cases (33 refused) measured with the Vulkan SDK
1.4.363.1 spirv-as, and compares each with spirv-as when it is installed.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Signed narrow hexadecimal constants and case labels require sign extension to the SPIR-V word width. Emitting the unextended words produces binaries rejected by Vulkan validation.
Addresses standalone compatibility review findings on PR #2251 (@FreddyxS):
- Encode width-aware IEEE-754 hex-float literals (16/32/64-bit) directly into bit
patterns, including SPIRV-Tools Inf and NaN payload spellings (0x1p+128 -> 0x7f800000,
0x1.8p+128 -> 0x7fc00000, and f16/f64 equivalents) without OverflowError.
- Match SPIRV-Tools literal string decoding in _unquote_string: \<ch> yields <ch>
verbatim (e.g. \n -> 'n', not LF).
- Add regression test comparing assembled words against spirv-as in tests/test_spirv_asm.py.
- docs: one row per topic again in design.md (59 topics merged sentence by sentence, keeping every
number) and README.md (the current models/character rows); one Other languages line.
- docs/i18n: the two Spanish quickstarts had been concatenated; keep #1912's, drop #2277's row.
- make_game: the shader fingerprint covers spirv_asm.py and its tables; LF settings write.
- tools: pe_shader_containers, gamedata_maps and anim_rigs use report_paths.same_report_path (BUILD-589);
stdout guard on five tools; LF text writes in three; user_sgpr_census tolerates an unreachable --json.
- tests: fspx stage fakes write real carve/unpack indexes (c7408a1f); typed f16 stores round toward zero
(SHADER-358); test_ci_registration's helper is no longer collected as a test.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>