A buffer_load_format_* with a run-time FORMAT called the four per-component
decode functions %fmt_dec_c0..3 at every load, whatever it wrote. One
function %fmt_dec(format, element, component) replaces them, and a load
calls it once per register it writes, with the component that register's
DST_SEL picks: _x makes one call, not four. The function computes the four
components' channel width and offset as before and the parameter selects
one, so the values are the same.
fconst (and tof of a uint constant) emitted a new OpBitcast of the uint
constant at every use; they now give one cached OpConstant %float per bit
pattern, written so spirv-as reads back the same 32 bits (float_literal:
shortest decimal for a finite value, the SPIRV-Tools hex-float spelling for
an infinity or a NaN). The test interpreters read that spelling.
Tests: test_buffer_format_decode_one.py with hand-written fixtures
(calls per load, values for 16 codes, swizzles, out of bounds, _x/_xy
against _xyzw for all 128 codes) and test_fconst_constant.py (exact bits of
+-0, denormals, infinities and NaN payloads).
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
A buffer_load_format_* whose format comes from the V# no longer searches a binary tree over the
format codes. One table word per code gives the conversion kind, the channel count and the
four channel widths; one shared function per output component reads that word and picks the
conversion with OpSelect, so the decode has no branch and the module carries one copy of it.
The exact UNORM/SNORM quotient comes from a shared %fmt_norm_bits that reads the width's 64-bit
repeat constant from a table. The fixed-format (MTBUF) path is unchanged.
In a module with one dynamic-format load the decode goes from 3,498 instructions and 306 branch
ops to 565 instructions and no branch, and the module from 250,869 to 56,763 bytes. Every one of
the 128 codes gives the same words as before (tests/semantic/test_format_decode_table.py).
AI-assisted (Claude/MiniMax Code).