Commit Graph

3 Commits

Author SHA1 Message Date
e166d2eb34 fix(fuzz): v_perm_b32 selectors 9/11 read bit 31, not bit 23
The oracle took bit 23 as the sign bit for selector bytes 9 and 11.
The ISA takes bit 7 of bytes 1/3 of each source: bits 15/31 of src1 and
47/63 of src0, so the second sign bit of each source is bit 31. The
translated SPIR-V was already right; this was a false mismatch in the
oracle, found by @kotorvr reviewing #325.

Adds a pinned test with both sign-bit patterns, and makes half of the
generated v_perm cases use a pinned selector built from bytes 0..15 so
the sign-bit, 0x00 and 0xff ranges are exercised instead of depending
on the seeded scratch values.

Verified: 29 cpu_ref tests, 6 shader_diff tests, 440 semantic tests,
and 3000 seeded programs with 0 mismatches and 0 skips.
2026-11-22 00:31:28 +01:00
10d6d4b876 test(fuzz): differential coverage for the integer and bit VALU family
FUZZ-1: model the integer/bit VALU block in tools/cpu_ref.py and add
those ops to the shader_diff program table: v_add_nc_u32, v_sub_nc_u32,
v_subrev_nc_u32, v_mul_u32_u24, v_mul_i32_i24, v_mul_lo_u32,
v_mul_hi_u32/i32, v_mad_u32_u24/i32_i24, v_min_u32/u32, v_max_i32/u32,
v_bfe_u32/i32, v_bfi_b32, v_alignbit_b32, v_alignbyte_b32, v_perm_b32
and v_med3_i32/u32.

Pinned known-answer tests cover the boundaries: bfe width cut and zero,
perm selector ranges (bytes, sign bits, constants), align shift 0 and
24, signed mul_hi, 24-bit sign extension and mad wraparound.

The generator keeps integer ops away from registers last written by a
float op: Vulkan does not promise a NaN payload and the comparison
accepts both-NaN, so reusing those bits as an integer would compare an
unobservable payload. Unobservable as a float, not as an integer.

Verified CPU-only: 28 cpu_ref tests, 6 shader_diff tests, 423 semantic
tests, and 8000 seeded programs (8 seeds x 1000) with 0 mismatches and
0 skips. GPU confirmation on the 5090 is pending.
2026-11-21 23:57:59 +01:00
188fb19d0e Tools: CPU differential oracle for the translator (shader_diff.py)
AI-assisted. New runner comparing tools/cpu_ref.py (ISA model, untouched) against rdna2spirv + tests/semantic/spirv_mini_interp.py (translated SPIR-V), bit-exact over seeded straight-line ALU programs.

- tools/shader_diff.py: program table (12 verified vector ALU ops), seed handling, first-mismatch report (case, seed, lane, register, expected/actual bits, last-writer op), counted skips with reasons, exit 0/1/2, --self-test canaries (a passing case, an intentionally wrong expectation that must fail, an unsupported op that must skip).
- tests/test_shader_diff.py: determinism, mismatch + NaN controls, skip accounting, fixed-seed end-to-end run, self-test gate.
- docs/shader_validation.md: harness-design paragraph updated to the shipped tool.

Verified here: 6 pytest green; 400 seeded programs, 0 mismatch, 0 skipped, 0 harness errors; mutation check (blinded comparator) turns 3 tests red; compileall + make_game --help green. Scope is the harness only: no changes to cpu_ref semantics, no GPU needed, runs in standard CI.
2026-11-21 19:05:43 -03:00