Commit Graph

19 Commits

Author SHA1 Message Date
09f6ce74e5 shader_diff: reseed integer operands when the clean pool is exhausted (#3189)
Squash-merged after diff review of PR #3189
2026-11-23 09:51:21 -06:00
924b14656c shader_diff: replay a single seeded program by index (#6855)
Squash-merged after diff review of PR #6855 - shader_diff: replay a single seeded program by index
2026-11-23 09:50:23 -06:00
76cf23f5c3 Merge pull request #4448 from tedin7
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-22 23:14:49 -05:00
6caeae4ac6 cf_diff, mem_diff, shader_diff, fmisc_diff: exit 2 when every program was skipped 2026-11-23 02:29:16 +01:00
0c48c1f432 shader_diff: report unexpected translator errors (TEST-807) 2026-11-23 00:29:39 +03:00
8b20b95059 fix: make shader_diff scalar copy observable 2026-11-22 13:54:26 -03:00
d1dec80bd6 Merge pull request #1883 from skwizzy222 2026-11-22 10:39:09 -05:00
89924428f9 fix(tests): report unexpected shader interpreter failures 2026-11-22 17:49:31 +03:00
ec9b6cf22b tools: text reports are written with LF line ends on every platform (BUILD-468)
open(path, "w") without newline= turns each \n into \r\n on Windows, so the same JSON report, manifest or assembly
listing was CRLF there and LF elsewhere. 91 text-mode writes (open, os.fdopen, Path.write_text) under tools/, scripts/,
make_game.py and runtime/test/shaders/ now pass newline="\n". tests/test_text_write_line_endings.py reads the source
with ast and fails for a writer that forgets it; CONTRIBUTING.md names the convention.

AI-assisted (Claude), on behalf of dev-ewann.
2026-11-22 14:20:30 +00:00
f698bf2206 tools: a path outside the console's code page no longer crashes a tool's output
On Windows a redirected stdout uses the console's ANSI code page, and python -I ignores PYTHONUTF8 and
PYTHONIOENCODING, so a caller path with a character outside that code page ended a run with
UnicodeEncodeError as soon as a tool printed it. #1406 fixed make_game.py; every CLI tool in tools/ now starts
its __main__ block the same way (stdout errors="replace").

tests/test_tool_stdout_encoding.py checks every tool's __main__ block and reruns two measured crashes
(analyze_4240_full.py, meshlet_page.py) with a private-use-named input. Found by @abilliontokens.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-22 11:27:00 +00:00
780a0a479d shader_diff: refuse an option below 1 instead of running nothing
--programs and --limit took bare ints, so 0 or a negative value ran no
program and still printed "0 programs (seed 1): 0 pass, 0 mismatch ..."
with exit 0. That reads as a pass from the differential oracle the docs
tell people to run, and a negative --limit is easy to get from shell
arithmetic. --max-ops had the same gap and died with
ValueError: empty range in randrange(1, 1).

All three now require at least 1: one argparse line, exit 2, which is what
anim_index, rbf0_index, rpf9_carve and shader_disasm already do. Defaults,
the output format and the 2/1/0 exit codes are unchanged, and the new
tests cover both the refusal and a valid --limit still running that many
programs.

🤖 Generated with Codebuff
Co-Authored-By: Codebuff <noreply@codebuff.com>
2026-11-22 05:00:37 -06:00
ea038ddee6 Merge pull request #1141 from Tayar 2026-11-22 02:47:54 -05:00
0e6bc2a491 shader_diff: report the number of programs run 2026-11-22 04:34:11 -03:00
9df1a6cee1 shader_diff: a harness error exits 2, as documented, not 1 like a mismatch
run_suite sets first_failure for a harness error too, and main returned 1
whenever first_failure was set, so the exit-2 branch was unreachable and a
broken harness read as a translator mismatch.
2026-11-22 12:37:25 +05:30
d21d97a9d4 Fix NaN comparison for suffixed float writers 2026-11-22 15:19:23 +10:00
b228b56c2e Add files via upload 2026-11-22 02:06:42 +00:00
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