Work around an amdvlk64 pipeline-creation crash (0xC0000005 on RX 9070 XT)
triggered when GLSL.std.450 PackHalf2x16 on an OpImageSampleExplicitLod d16
result feeds a structured loop (OpLoopMerge inside OpSelectionMerge) using
OpGroupNonUniformAny.
Replace PackHalf2x16 at the two d16 image_gather4*/image_sample* sites in
tools/rdna2spirv.py with a branchless pure-integer IEEE-754 binary16 RTE
packer (Gen.f32_to_f16_int / Gen.pack_f16_pair_int). Leave all other
PackHalf2x16 call sites unchanged.
Add unit tests covering edge cases and a 58,368-value sweep across all 256
exponents (tests/test_d16_pack.py), SPIR-V translation/validation tests for
d16 image_sample and image_gather4 (tests/test_translate.py), and a synthetic
GPU sample shader (runtime/test/shaders/ps_texture_sample_d16.asm).
spirv_mini_interp.py: keep main's _F32 (sNaN bits, #533) and its vector-aware
RoundEven/Floor/Ceil/Trunc; keep this branch's fma_f32, OpFDiv and
Exp2/Log2/Sqrt/InverseSqrt. regen_fixtures.py: both sides' shaders.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
AI-assisted. Addresses IAmNotSiob's review on #512 (he is taking the
arithmetic sites under SHADER-56/#513; f16_roundtrip stays here).
SPIR-V's OpQuantizeToF16 returns +0/-0 when the magnitude is too small for a
normal f16, and it pins no rounding mode. The docstring, the design row and the
test's rule text now say "round to nearest, f16 denormals flushed to signed
zero" and warn against reusing the helper where denormals or a rounding mode
matter.
The mini-interpreter used struct.pack('<e'), which keeps f16 subnormals: it was
more precise than any conforming driver, so a test could pass here and fail on a
GPU. It now flushes after float_to_half, and the test's independent oracle does
the same. A new case pins 1e-6 -> +0.0 and -1e-6 -> -0.0 through a translated
flagged shader (PS input 1e-6 is an f16 subnormal, 6.1e-5 is the smallest
normal); without the interpreter flush that test is red.
Existing 1.1 -> 1.099609375 pin and the opcode pin are unchanged.
select_candidates() checks `len(picked) >= count` after appending, so
--count 0 or a negative count still picked (and ran) one shader.
--runs 0 rendered nothing and classified every shader as "dispatch form
failed to run", and --timeout 0 gave the harness no time at all. The
three options are now positive whole numbers (argparse errors before
the output folder is made), and select_candidates() refuses a count
below 1.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
`if a.limit: texs = texs[: a.limit]` read --limit 0 as "no limit" and
exported every texture in the index, and a negative --limit silently
dropped the last textures. --limit is now a positive whole number (an
argparse error otherwise, before the output folder is made), and the
slice runs whenever it is given.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
scan_rpf() used `min(size, pos + limit) if limit else size`, so
--limit 0 scanned the whole archive. --start and --limit were plain
ints: a negative --limit gave an end before the start (an empty scan
reported as a normal run), a negative --start searched from the top of
the file, and a --start inside the RPF9 header or past the end was used
as given. --start must now be 0 or more and --limit at least 1
(argparse errors), and a --start outside an archive's data area is one
line and exit 2, before any report is written.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
`files[: a.limit] if a.limit else files` read --limit 0 as "no limit"
and translated the whole corpus, and a negative --limit dropped the
last shaders instead of being refused. --shard was split and used
unchecked: 0/0 ended in "slice step cannot be zero", 9/8 translated
nothing and wrote an empty index.part9.json that --merge then reads,
and anything that isn't i/n was a traceback.
Both are now argparse types: --limit must be at least 1, and --shard
must be i/n with n >= 1 and 0 <= i < n. A bad value is a usage error
(exit 2) before --out is created. The translation itself is unchanged,
and make_game.py's own "--shard i/jobs" values are all valid.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
files_of() treated anything that is not a file as a folder, so a
missing path ended in a FileNotFoundError traceback. --limit was a
plain int used as paths[:limit], so --limit -1 silently dropped the
last blob and --limit -5 the last five, reported as a normal tally.
The path is now checked first (exit 2, one line), and --limit must be
0 or more (an argparse error otherwise).
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
main() caught only ValueError from the scan, so a missing source
(os.path.getsize), a folder that can't be listed or a stream that
can't be read ended in an OSError traceback, as did an output path in
a folder that doesn't exist. Both now exit through sys.exit() with one
line naming the path, like the ValueError case already does.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
A missing target went to ArchiveSource and failed there; an empty or
short archive raised the RuntimeError the tool builds from
rpf9_carve.py's own message, but nothing caught it, so it surfaced as
a traceback; a carve folder without index.json, or with one that has
no "files" list, ended in FileNotFoundError / KeyError tracebacks.
main() now checks the target exists and prints each of these as one
line, exit 2, before --csv or --json is written.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
v_fma_f16, v_fmac_f16 and v_pk_fma_f16 used GLSL Fma (rounded to f32) and then narrowed, a double rounding;
an RX 6700 matches a correctly rounded f16 FMA in 12,612/12,612 cases (#374). fma_f16_odd: exact f32 product,
TwoSum, round-to-odd at f32, then f16_bits. Design row for f16 rounding.
Drivers fold PackHalf2x16 -> UnpackHalf2x16 to a no-op, so a following f16 op saw the unrounded f32 (#513:
v_pk_add_f16 -> v_pk_mul_f16 1 ulp off under --wave64-emulate on NVIDIA; v_cvt_pkrtz_f16_f32 rounding to
nearest on llvmpipe). Gen.f16_bits converts with integer ops (RTE, or RTZ with +-65504 for pkrtz) and is used
by f16_out, v_cvt_f16_f32, v_pk_*_f16, f16 sin/cos, v_interp_p2_f16, v_fma_mix* and f16_rtz.
tests/spirv_interp.py gains OpU{Less,Greater}ThanEqual and OpFUnordNotEqual.