Commit Graph

24 Commits

Author SHA1 Message Date
14d81dd093 SHADER-86: align mem_diff reference with RX 6700 typed-buffer decode
Repeat missing channels, drop the old norm-ulp1/missing-w32 splits, and allow DST_SEL 1 in the fuzzer.
2026-11-21 22:23:22 -03:00
feefef597c Merge pull request #476 from IAmNotSiob 2026-11-21 20:09:14 -05:00
4c842cd11e Merge pull request #548 from Spaghetih 2026-11-21 19:53:12 -05:00
125ab44500 valu_fuzz: drop the wave family; FUZZ-7 is @kotorvr's crosslane_fuzz.py 2026-11-22 01:51:09 +01:00
f0fdfe360d Tools: f16, buffer memory and cross-lane differential fuzzers on the GPU (FUZZ-2, FUZZ-5, FUZZ-7) 2026-11-22 01:51:09 +01:00
ca0c66af6d Merge pull request #510 from kotorvr 2026-11-21 19:43:51 -05:00
6581bc4abd Merge pull request #476 from root 2026-11-21 19:43:41 -05:00
3f4cf2e40d FUZZ-5: typed buffer loads in tools/mem_diff.py (buffer_load_format, tbuffer_load_format)
A buffer_format family: buffer_load_format_* on every format the translator decodes (random DST_SEL 0/X/Y/Z/W) and tbuffer_load_format_* on the five formats the 1.0.2.1 corpus uses. The reference decodes each element from the GFX10 format name (tools/gfx10_formats.json), not from the translator's table.

Two outcomes await a gfx10 hardware measurement (posted in #374) and are counted apart: UNORM/SNORM results 1 ULP from the correctly rounded value (the translator multiplies by a rounded reciprocal), and the missing W of a 32-bit format (0 in the translator, 1 / 1.0 for every other format). 5,000 programs: no other difference. Mutations of the 16_16_SNORM kind, the 8_8_8_8_UINT widths and the DST_SEL order make 33, 37 and 191 of 300 programs fail.

AI-assisted.
2026-11-22 01:37:53 +01:00
0f25c63200 Tools: wave and cross-lane differential fuzzer on the GPU (FUZZ-7)
tools/crosslane_fuzz.py generates seeded wave32/wave64 compute programs
from readlane/writelane/readfirstlane, v_cmp/v_cmpx ballots, s_bcnt/s_ff1
of masks, v_mbcnt, v_cndmask, permlane16/x16, forward s_cbranch_execz/
vccz/vccnz and (--dpp) DPP16/DPP8, under random EXEC, nested saveexec,
partial waves and multi-wave groups. A 64-lane model of the ISA is
compared with the translated SPIR-V run by vk_compute_test (VKC_OUT_WORDS
/ VKC_DUMP), wave32 natively and wave64 with --wave64-emulate.

Found SHADER-52 (#407) and two DPP bugs in #238. tests/test_crosslane_fuzz.py
checks the model without a GPU.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-22 00:14:53 +00:00
edb8bb8643 Merge pull request #477 from tunczzzz
# Conflicts:
#	docs/design.md
#	runtime/test/shaders/check.py
2026-11-21 19:14:12 -05:00
85164a7d9d Merge pull request #476 from root 2026-11-21 19:14:11 -05:00
119d3084fd Merge pull request #442 from Spaghetih
# Conflicts:
#	docs/shader_validation.md
2026-11-21 19:14:05 -05:00
91050d0cee valu_fuzz: drop the wave family; FUZZ-7 is @kotorvr's crosslane_fuzz.py 2026-11-22 01:09:53 +01:00
ce822e5040 Merge pull request #375 from Vonsek 2026-11-21 19:08:38 -05:00
e9773f181d Tools: f16, buffer memory and cross-lane differential fuzzers on the GPU (FUZZ-2, FUZZ-5, FUZZ-7) 2026-11-22 01:04:35 +01:00
71a16c11cf FUZZ-8: control-flow/EXEC differential fuzzer; wave32 SCC of mask ops is wave-wide
tools/cf_diff.py generates seeded wave32/wave64 pixel shaders from the
control-flow shapes compilers emit (saveexec if/else, v_cmpx, VCC- and
SCC-voted branches, uniform and per-lane loops, two-entry cycles) and
compares every lane's export between:
  * tools/cf_ref.py: cpu_ref's Machine plus branches, compares, v_cmpx,
    saveexec and 64-bit masks (the ISA model, one wave)
  * rdna2spirv + tests/semantic/spirv_wave_interp.py: every invocation of
    one subgroup in lockstep, split at selections and rejoined at merges,
    with the subgroup operations the translator emits
in both the structured and the dispatch-loop form; --spirv-val also
validates each module, --minimize reduces a mismatch.

Finding (fixed here): in a wave32 program s_and/or/xor/andn2/orn2/nand/
nor/xnor_b32 on lane masks set SCC from the lane's own bit instead of the
whole mask, so `s_and_b32 s0, vcc_lo, exec_lo; s_cbranch_scc0` and loops
closed by `s_andn2_b32 exec_lo, ...; s_cbranch_scc1` split the wave. SCC
is now the same subgroup vote as for the _b64 forms. GPU test
ps_scc_mask32 (not run on a GPU yet).

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-22 00:02:16 +00:00
d9e629288a FUZZ-5: memory differential fuzzer (tools/mem_diff.py)
tools/mem_diff.py runs seeded s_load, s_buffer_load, buffer load/store/atomic and global load/store programs through a small reference model written from the RDNA2 addressing rules and through the translation in spirv_mini_interp, and compares the exported words and the whole final memory. Accesses are generated in bounds; OOB, OOB_SELECT, swizzle and the s_buffer_load truncation are left for GPU-confirmed rules.

spirv_mini_interp gains OpSConvert and 32-bit PhysicalStorageBuffer atomics (spec semantics, one invocation), with tests.

The fuzzer found the global_* negative-offset bug that #421 fixes; its global family and tests/test_mem_diff.py's regression test pass once #421 is in.

AI-assisted.
2026-11-22 00:52:32 +01:00
eaae31f609 Merge main; leave the s_ff fix to #349; review fixes for salu_diff
SHADER-46 (#349) fixes the same s_ff0_i32_b32 bug and was opened first, so
this branch drops its translator change and ps_salu_ff and keeps the
fuzzer. s_bfe_* control words stay inside offset + width <= 32 unless
--bfe-any; --programs/--max-ops below 1 is an argument error; the tests
no longer exclude s_min/max_i32 (#332 is on main) and check the BFE range.

AI-assisted (Claude Code).

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-22 00:50:03 +01:00
de3da41ab8 Merge pull request #368 from crastinator 2026-11-21 18:38:02 -05:00
fc7a3d9ca7 FUZZ-4: scalar ALU differential fuzzer; s_ff0_i32_b32 on a constant
tools/salu_diff.py runs seeded SOP1/SOP2/SOPC/SOPK programs through its
own reference and through the translator plus spirv_mini_interp, and
compares three SGPRs and SCC. It found that s_ff0_i32_b32 read a 32-bit
constant source as a lane mask; constants are now values, as for
s_bcnt*_b32. GPU-checked with ps_salu_ff.asm.

AI-assisted (Claude Code).

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-22 00:21:00 +01:00
71646d8507 Docs: correct stale status and duplicated mesh notes
shader_validation.md now describes the shipped CPU differential oracle in tools/shader_diff.py instead of saying it is not implemented, and keeps the GPU runner explicitly as future work. design.md drops a duplicated, contradictory mesh workgroup paragraph. pipeline_check.md records the later full 26,503/26,503 corpus run with 0 failures instead of presenting the two stalled shards as the final state.

New PROC item claimed in #156. AI-assisted (OpenCode).
2026-11-21 17:14:16 -06:00
4fe8cdf38d Tools: LDS / ds_* differential fuzzer on the GPU (FUZZ-6)
tools/lds_fuzz.py generates seeded 64-thread compute programs (wave64 or wave32, 4 KiB LDS) over the ds_*
instructions the translator accepts: every read width (also u16 d16/d16_hi), byte/short writes (also d16_hi),
read2/write2 (+st64), the add/sub/min/max/and/or/xor atomics with and without return, wrxchg, cmpst, ds_swizzle
and ds_bpermute, under random EXEC masks. It translates them, runs them with vk_compute_test and compares every
thread's 16 result VGPRs and the whole LDS bit for bit with a model written from the ISA, naming the op that last
wrote a wrong register. vk_compute_test gets VKC_OUT_WORDS / VKC_DUMP to read the whole buffer back.

On an RX 6700 XT the only mismatch is the wave32 ds_bpermute inactive-source case #253 fixes. docs/design.md no
longer claims the 8-bit d16 reads, which the translator rejects.
2026-11-22 01:13:21 +02: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
d9db324af6 Docs+tool: add CPU reference for differential shader validation
Add docs/shader_validation.md describing why spirv-val is not enough, the CPU/GPU differential model, test-program construction with llvm-mc, the harness design, coverage plan, limits, and prior art.

Add tools/cpu_ref.py, a standard-library interpreter for a small straight-line RDNA2 subset from a shader_ir listing. It models SGPR/VGPR state, VCC/EXEC/SCC, one or 64 lanes, inline constants and literals, exact f32 FMA and the requested integer/float ops. Anything outside the subset raises Unsupported.

Add tests/test_cpu_ref.py with hand-written listings pinning NaN, signed zero, denormals, FMA single rounding, cndmask, EXEC masking, 16-bit packed halves and shifts.
2026-11-21 18:09:38 +00:00