Commit Graph

22 Commits

Author SHA1 Message Date
420c6c88b0 rdna2spirv: a translator bug in one program refuses that program instead of ending the run
An AssertionError, TypeError, AttributeError, ZeroDivisionError or
RecursionError from translate() now counts as 'translator error <type>', as
IndexError/KeyError/ValueError already did: the program's old module and
index entry are dropped and the run goes on. Before, one assert (#3976's
--wave64-emulate case) ended make_game.py's whole shaders stage.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-23 22:10:06 +00:00
e835ce671a Report missing required translator inputs and retire stale outputs (#6292)
Squash-merged after diff review of PR #6292 - Report missing required translator inputs and retire stale outputs
2026-11-23 08:22:37 -06:00
8d88450ee2 Merge pull request #3960 from Wasler
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-22 23:09:56 -05:00
fb7f380cfb Merge origin/main into fix/shader-427-structured-depth
Conflicts were both-sides additions: docs/design.md (main's DPP, EXEC and
saveexec row updates kept; this branch's Control flow row kept) and
tools/rdna2spirv.py (main's _out_inside_input and --opt kept next to
_depth_arg and --max-structured-depth).

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-22 22:51:59 -05:00
33905dc9dd Fix what the round-43 merges broke (pytest)
Merges that each passed alone but clash together:
- v_cmp_class_f64: the earlier cmp_class_f64 (685d16ed9) (operand-form checks, test_cmp_class_f64) and the later f64 branch
  in cmp_class both handled the opcode; f64 goes to cmp_class_f64 again, f16 stays in cmp_class.
- rdna2spirv CLI tests: spirv-as/spirv-val now run in the output folder with the staging file's bare name, so
  the test doubles resolve it against cwd; assemble_spirv decodes the output only when it is bytes. (The doubles
  had been writing .spirv-*.tmp files into the repository root.)
- ps_w64 fixtures (TEST-722): an 18th fixture (ps_w64_a_discard) landed; its killed lanes export nothing and
  keep the clear value.
- first_light: a run without an OBJ removes mesh.bin, and harness_env reads manifest["files"]; batch_glb's stats
  name failures and dropped textures; run_gpu_tests reports a frame never written as a missing readback
  (TEST-837).
- make_game TRANSLATION_SOURCES and runtime.yml's paths include spirv_opt.py and report_paths.py (and
  wave64_emulate_opt.py), which the translator imports.
Repo rules: stdout guard on six tools; encoding on two opens (gen_gdk_runtime_classes' helper is read_utf8);
newline on one write; anim_skeleton_match's joaat encodes like hashdict.joaat; test_feature_scan's new test is
listed with the others its globals() runner reaches.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-22 22:07:41 -05:00
b23779d6a9 tests: pass errors=replace to subprocess pipes capturing python -I tools 2026-11-23 00:42:37 +02:00
2f98a45178 Merge pull request #3768 from 216598762 2026-11-22 17:03:37 -05:00
277a567d1d rdna2spirv: a missing SPIRV tool is a setup error, not a traceback
assemble_spirv raises FileNotFoundError when spirv-as or spirv-val is not on
PATH. Report that once from main (exit 2) instead of failing the first shader
with a traceback; image_fuzz reproduces it when SPIRV-Tools is absent.

🤖 Generated with Codebuff
Co-Authored-By: Codebuff <noreply@codebuff.com>
2026-11-22 21:30:58 +00:00
05fe854898 rdna2spirv: refuse --out that is the input folder (BUILD-1044)
Translating with --out equal to the input disasm folder (or a folder inside it) wrote .spvasm/.spv/index.json among the .s inputs and exited 0. Resolve both paths and refuse with one ERROR line and exit 2 before mkdir or any output is written. The --merge path is exempt: it does not read src, and merging shard parts in place is how a shard run finishes.

Tests: out==input, out inside input, and a distinct out control.
2026-11-22 21:07:30 +00:00
b21c38e1d2 Merge origin/main into fix/shader-427-structured-depth
Conflicts: tools/rdna2spirv.py (--pc-tail-ubo and --max-structured-depth
both added next to --max-shared-memory: kept both) and docs/design.md
(upstream reworded the neighbouring rows: kept theirs and re-applied the
SHADER-427 sentence of the "Control flow" row).

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-22 15:20:40 -05:00
48a4c4d130 rdna2spirv: decide barrier rounds from the depth-capped tree (SHADER-427 review)
needs_barrier_rounds() looked at the unbounded structured tree, while
assemble() emits the dispatch loop once the tree nests deeper than
MAX_STRUCTURED_DEPTH. A wave32 compute shader with a top-level s_barrier
over the bound then got the dispatch loop without barrier rounds. Both
now use capped_tree(). With the default bound (64) no corpus module is
affected (the deepest is 29); it matters when --max-structured-depth is
set below a shader's depth.

The CLI test now pins the default to the literal 64.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-22 15:06:34 -05:00
5c6d00877a rdna2spirv: raise MAX_STRUCTURED_DEPTH to 64, add --max-structured-depth (SHADER-427)
Since #1904 the corpus's deepest structured tree is 29, not 118. With the
SHADER-299 bound at 16, 1,031 modules (747 CS, 284 PS) still took the
dispatch-loop form, which saves only 12% of their spirv-val time but
compiles 1.67x (PS) to 2.0x (CS) slower on an RTX 5070 Ti / 621.24.
The bound now sits above the corpus as a guard, and
--max-structured-depth N (0 = never) sets it per run.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-22 14:11:00 -05:00
78af7999e3 Merge pull request #2475 from Nethmina Yasas 2026-11-22 13:15:35 -05:00
4a03e78646 tools/rdna2spirv: reject a --out that is a file
Validate --out right after parsing arguments: a file, a path under a file,
a dangling symlink or an unmapped drive root is now one argparse error line
with exit 2, instead of a FileExistsError/NotADirectoryError traceback, and
before --merge or os.makedirs can write anything. Matches the guards in
shader_disasm.py (#1607) and tex_export.py (#1632).

Add subprocess tests for those paths and a control that a new output folder
with missing parents still translates. CPU-only; no game data.
2026-11-22 22:39:43 +05:30
f9c858de86 test_rdna2spirv_cli, test_translate: strengthen POPS interlock order, single emission, and spirv-val coverage 2026-11-22 21:21:22 +05:30
92c18ff4d9 rdna2spirv: emit OpBeginInvocationInterlockEXT for straight-line POPS pixel shaders (SHADER-350) 2026-11-22 21:00:13 +05:30
3de090756a Merge pull request #1781 from qerdavo-dot 2026-11-22 09:15:18 -05:00
5bf70ece68 translator: refuse a .s with no tab-indented instructions
parse_file reads tab-indented instruction lines only, so a hand-written or
re-indented .s parses to an empty shader. That used to translate to a module
that passes spirv-val, lands in index.json and does no work at all: the CLI
printed "1 shaders: 1 translated, 1 pass spirv-val" for a file whose only
line was a comment.

Refuse it in translate() with "no instructions (nothing tab-indented?)", so
it is reported like any other unsupported shader and no .spv is published.
Found while writing a fixture with spaces instead of tabs; the new test uses
that exact shape.
2026-11-22 15:04:19 +01:00
03ed39c88b rdna2spirv: drop a failed retried shader's stale .spv and index entry
A shader that raises Unsupported or a translator error on a retried partial
run kept the .spv and index.json entry an earlier successful run published:
only spirv-as/val rejections went through the invalid set that the index
merge pops. The stale entry masks the regression from make_game.py, which
takes index.json as proof the translation finished, and the stale module
stays loadable by the runtime.

Route all three failure paths through one drop_stale helper: unlink the old
.spv and mark the name for the index merge to drop. The .spvasm text stays
for diagnosis, as it does on a rejection. Shard and --limit runs write their
index fresh from this run's metadata, so they only gain the unlink.

Tests: two synthetic CLI tests (s_barrier in a PS is Unsupported before any
SPIR-V tool runs; a mocked ValueError covers the translator-error path).
Both fail without the change. Standard library only, no game data.

AI-assisted. Tested on CPU (Windows 11, Python 3.12): tests/test_rdna2spirv_cli.py
(14 tests), unittest discover tests/semantic, and pytest tests/test_rdna2spirv_cli.py
tests/test_translate.py with llvm-mc 23.1.5 (AMDGPU) and SPIRV-Tools v2026.4.
No GPU was used.
2026-11-22 16:46:48 +03:00
bfafe94bc2 test(rdna2spirv): cover invalid src and .s directories in CLI 2026-11-22 15:38:56 +05:30
60e4e904b7 Publish SPIR-V only after validation succeeds 2026-11-22 00:41:51 -03:00
96ec04967a rdna2spirv.py: check --limit and --shard before translating anything
`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>
2026-11-22 02:00:01 +01:00