A fuzzed sNaN through v_fmamk_f32 into v_cmp_class_f32 flipped a result
bit on both Vulkan GPUs against the reference model. The model returns a
canonical quiet NaN for v_fmamk_f32, but on gfx1036 under the game's MODE
the hardware mostly returns the NaN source's word and only sometimes
quiets a signalling one (f32_hw_s5.log), so whether the result tests as
signalling or quiet is not something the model can know. Track registers
holding such a computed NaN (st["nanf"], set by v_fmamk_f32 with a
signalling or already-fuzzy NaN operand and propagated through the
pass-through ops and register moves) and raise Uncertain when
v_cmp_class_f32 reads one, instead of reporting a mismatch that is a
model gap, not a translator bug.
Co-Authored-By: Devin <noreply@cognition.ai>
Repeated merges left "Packed 16-bit integer operations on RDNA2 (SHADER-302)" in the file four
times and "Pixel-shader ISA on the hardware" twice: 2d3369a4c (a merge of origin/main into
main) tripled SHADER-302 as SHADER-681's helper-lanes subsection came in, af1b3c96d merged
#3061 a second time, and #3499's --format table then landed in only one ps_oracle copy. One
SHADER-302 copy went in as a bare heading and its bullets in the middle of the RADV paragraphs.
Keep one of each, in the order a66a71ffd had them before the repeats, with the two real
additions in place: #3499's --format paragraph and table (0d58747e0) and SHADER-681's helper
lanes (58bc80c33). Every kept line is main's own text; the only line dropped that is in no
remaining copy is the "Limits: ... mrt0 as RGBA32F only" line that 0d58747e0 itself replaced.
Deletions only, so #1037 and #1039 (which insert after the first SHADER-302 copy) still merge.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Signed-off-by: coolpilot904 <andrewjsottile@icloud.com>
design.md had no measured rule for the no-format-conversion image loads.
Measured natively on an RDNA2 iGPU (gfx1036) through tools/hw_oracle: the
texel's bytes form little-endian dwords selected by dmask (0 past the last),
a texel under 4 bytes is zero-extended (pck) or sign-extended from its top
bit (pck_sgn), and the FORMAT's numeric type does not matter.
image_fuzz.py gets --op image_load_pck|image_load_pck_sgn for the hw oracle,
the pck_oracle CPU model, sub-4-byte texel formats, a pck_sgn_zero_extend
perturbation and a wrong-FORMAT control that changes the texel size;
tests/test_image_fuzz_hw.py pins the measured words. The translator does not
translate these ops yet; this is the measured model it needs.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01RAL8MMXUuNpQAVa1iiyAMP
Review follow-ups for SHADER-DIV-SCALE-PROBE.
- D is written with a sentinel (no operand of the matrix and no candidate
prediction equals it) before every v_div_scale of the plain and modifier
kernels, so a D that is not written is reported (d_unwritten: summary line,
--json field, --table marker) instead of reading as the previous row's value.
The docstring and docs say that D = S0 where no branch assigns it is an
assumption applied in every candidate, and name the emulator that initialises
D differently.
- The f32 divide sequence omits LLVM's s_denorm_mode switch: the summary labels
the f32 tallies of the MODEs that flush f32 denormals as not comparable with
LLVM's lowering (llvm_comparable in the JSON), with a note.
- New pair 2^-60 [2^-284] over the smallest denormal: a gap below 96 [768], so
the denormal-denominator branch is reached and not the gap branch. 49 pairs,
108 rows per width.
- A run without --json ends with a line saying the summary is not the
measurement. --json has mask_lo/mask_hi instead of the bare list; --table
starts with a legend.
- isa_recip_width is described as the same text with the reciprocal classified
in the operand's width; docstring and test references to a docs/design.md row
that does not exist point at the docs/shader_validation.md section.
- tests: the preset and sentinel before every v_div_scale, the sequence against
a hand-written table of LowerFDIV32/LowerFDIV64 and as a division on exact
arithmetic, an unwritten D, the labels, the legend, a cr_ftz verdict.
AI-assisted.
Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01Y7fbZYVY7EtLknWBZUfSLf
The translator refuses v_div_scale_f32/f64: the ISA text, the D = S0
pass-through LLVM's divide lowering relies on and the rule tinygrad's
RDNA3 emulator runs disagree at the edges, so the rule has to come from
a measurement. tools/div_scale_probe.py makes that one command on a
GFX10 GPU, built like tools/f64_omod_probe.py on tools/hw_oracle: raw
one-lane kernels, the five MODEs of that probe (game MODE first), wave32
and wave64.
Per width it runs 48 numerator/denominator pairs (special, denormal,
exponent gap 95/96/97 [767/768/769], denominators around 2^126 [2^1022],
quotients around 2^-126 [2^-1022], numerator fields 22/23/24
[52/53/54], ordinary) as the denominator and the numerator call, plus
10 S0 = S1 = S2 cases, each with VCC and with an SGPR mask destination
preset to all ones; 30 modifier rows; and LLVM's whole divide sequence
on every pair. Each row prints next to it what three candidate readings
predict (the newer ISA wording, the text with an f32-width reciprocal
test, tinygrad's emulator rule), so a run shows which one the hardware
follows. Not run on hardware; no rule goes into the contract table.
tests/test_div_scale_probe.py checks the matrix and its boundaries, the
candidates' known disagreements (including the 1.0 / 2^127 -> +inf
divide through the translator's measured v_div_fmas/v_div_fixup),
assembly with llvm-mc, and parsing and the CLI with a fake oracle.
docs/shader_validation.md documents the tool.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01Y7fbZYVY7EtLknWBZUfSLf
Gen.clamp_mods applied the VOP3 clamp bit as a bare GLSL.std.450
FClamp, which is undefined for a NaN operand. The game's MODE has
DX10_CLAMP=1, under which the hardware turns a NaN result into +0
(measured on gfx1036: the v_rcp_iflag_f32 run and SHADER-186 for
v_fmac_f16 / v_fma_mix*). Select +0 for a NaN before FClamp, as the
div_fixup, cvt_pk_u8 and cvt_pknorm clamps already do. This covers
every f32/f16 op that applies clamp through clamp_mods/clamp_f16.
- tests/semantic/test_vop3_clamp_nan.py: NaN operands (quiet,
negative, signalling) and invalid operations (inf-inf, -inf*0)
under clamp give +0 for f32, f16 (low and high half), conversions,
legacy and mix ops; controls without a NaN are unchanged. It fails
33 subtests on the old translator.
- The two negative controls that expected the undefined FClamp
(test_alu_f32_min_max, test_alu_min3_max3) now expect +0, and the
f16 unary harness checks clamp of a NaN result instead of skipping.
- test_rcp_iflag_mods / test_f64_conversion match the new SPIR-V.
- docs/design.md and docs/shader_validation.md no longer list the
f32/f16 clamp of a NaN as unmodelled. Still a bare FClamp: the f64
clamp (open PR #475) and the packed v_pk_* clamp.
AI-assisted (Claude Code).
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
tools/cf_diff.py checks the generated control-flow programs against two
CPU models only (cf_ref and the SPIR-V wave interpreter), so nothing
showed what a driver does with the translated control flow: how it
reconverges after a divergent if/else, a per-lane loop with a break mask
or a saveexec idiom.
tools/cf_gpu_run.py takes the same programs, turns each into a one-wave
compute program that stores v8..v11 of every lane, runs it through
vk_fuzz_run (translator + vk_compute_test) and compares every lane with
cf_ref, in wave32 and in wave64 (LEONIDA_W64_EMULATE=1 on a 32-wide GPU).
Before a campaign it runs a control, a reference with a flipped branch
that must differ from the GPU's result, and does not start if that fails.
A skipped program is counted with its reason and is never a pass. Exit
status: 0 no mismatch, 1 mismatch (minimised in summary.json), 2 nothing
ran, 3 control failed.
vk_fuzz_run.run_programs gets encoded=True for complete listings that
already carry `; encoding:` byte counts, so they skip llvm-mc. A program
the translator does not translate now reports the translator's last
error line.
Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
Bit 24 of V# word 3 (GFX10 RESOURCE_LEVEL) is WRITE_COMPRESS_ENABLE on GFX12, so
the informational --gfx10-word3 run is refused there. On gfx1200 a vector load
after a store of the same thread needs no wait (--hw-sync none without the
scalar ops: 1,000 of 1,000); the scalar loads need the store wait and s_dcache_inv.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The gfx12 kernels are the GFX10/GFX11 text respelled (gfx12_lines): a MUBUF
soffset is null instead of the literal 0, which is what made every
buffer_load/store_b* "operands are not valid for this GPU or mode";
s_waitcnt_vscnt, s_waitcnt vmcnt/lgkmcnt and buffer_gl0/gl1_inv become
s_wait_storecnt, s_wait_loadcnt, s_wait_kmcnt and global_inv. The V#s keep
their layout (Mesa gfx12-rsrc.json: word 1 and word 3's fields as on GFX11);
word3() now refuses a family it has no layout for.
RX 9060 XT (gfx1200), AMD 26.11.2: seeds 2-4 x 2,000 programs x wave32 and
wave64, 12,000 of 12,000 match; the negative control catches all 8
perturbations. GFX10, GFX11 and translator text are byte-identical.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The valu_fuzz hardware-oracle section gets the per-family gate and the RX
9070 numbers: f16 1,000/1,000 kernels match (500 programs, both wave
sizes), mem refused on gfx12xx with the two AMD clang rejects named, and
gfx1170 assembling both families clean. The lds_fuzz GFX12 bullet now
covers ds_permute_b32 reaching all 64 lanes as well, with the send-
direction measurement, the masked ds_swizzle control, and the 500-program
numbers of the default run.
AI-assisted (GLM-5.3).
Squash-merged after diff review of PR #6911 - docs/shader_validation: f32_fuzz has no Vulkan oracle, so drop it from the --oracle hw,vk section (EGEN-DOCS-F32-FUZZ-VK)
Also: #2490's committed conflict markers in fssm_crosscheck.md resolved to main's text, the SHADER-605 section
moved below the troubleshooting table it split, a header rule for the export-format table, two backticked
paths that name no Leonida file, and the BOM dropped from anim_move.py and its test.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
mem_diff found one class of mismatch: a 16_FLOAT/16_16_FLOAT/16_16_16_16_FLOAT
typed buffer load of a half NaN. Measured natively on RDNA2 (gfx1036) with the new
tools/f16_widen_probe.py, wave32 and wave64, MUBUF and MTBUF, formats 13, 29 and 71:
the hardware widens a half NaN to f32 as sign | 0x7F800000 | (payload << 13), keeping
the sign and the quiet bit exactly as the half has them (0x7ddb -> 0x7fbb6000,
0x7fe6 -> 0x7ffcc000, 0xffb2 -> 0xfff64000).
Gen.decode_format decoded every half with UnpackHalf2x16, whose NaN result is
undefined and which the interpreter canonicalises to 0x7fc00000, so the payload was
lost. It now uses UnpackHalf2x16 for the non-NaN halves (an exact widening) and builds
the NaN word from the bits with integer ops. v_cvt_f32_f16 was measured too: it quiets
an sNaN with the payload kept (0x7ffb6000), which the typed load does not.
mem_diff's reference used struct's '<e', which keeps the payload only from Python 3.14;
f16_to_f32 pins the measured rule so the fuzzer is version independent.
tests/semantic/test_buffer_f16_widen_hw.py pins the ten measured words for MUBUF and
MTBUF and formats 13/29/71; tests/test_f16_widen_probe.py covers the probe (models,
fake oracle, CLI); mem_diff --self-test now pins the rule too.