Commit Graph

31 Commits

Author SHA1 Message Date
e5c8492806 tests: end the file with one newline, not two
No content change.
2026-11-30 15:47:16 +01:00
0d94741771 tests: the script run also executes FeatureScanAtomicOutputTests
The `__main__` scan collects the `test_*` globals, so the class's three methods
never ran in the plain-script invocation CI uses - which means the two skips this
PR adds never took effect there either. The class is loaded explicitly now.

Measured here: the script run goes from 13 top-level tests to those plus
"Ran 3 tests ... OK (skipped=2)", and pytest still reports 14 passed, 2 skipped.

Written with an AI assistant.
2026-11-30 14:55:30 +01:00
6c923fb419 tests: the two write-failure cases need preexec_fn, which Windows does not have
They fail on Windows today, and CI cannot see it because that file runs on Linux
there: FeatureScanAtomicOutputTests' two "failed write" cases pass
preexec_fn=fail_file_writes to subprocess, which is POSIX-only.

Measured on main b8bd37111, Windows 11, Python 3.13: 2 failed, 14 passed before;
14 passed, 2 skipped after, with the reason printed. On POSIX nothing changes.

Written with an AI assistant.
2026-11-30 14:55:30 +01:00
129c840089 ci: fix runtime/windows timeout, remove redundant CI legs, and harden caches 2026-11-29 19:17:38 -05:00
362b854007 feature_scan: write --out atomically and keep the old report on failure
Write JSON to a same-directory temporary file and replace the report only after serialization succeeds. On write failure, keep the existing report and remove the temporary file; preserve the current error message and exit code.

Evidence (run from /home/hampa/work/leonida-feature-scan):

Tests:
- Original: git checkout upstream/main -- tools/feature_scan.py && /home/hampa/work/.venv/bin/python -m pytest tests/test_feature_scan.py -q -> rc 1; 1 failed, 15 passed. The existing report was empty instead of the 23-byte sentinel.
- Fixed: git checkout HEAD -- tools/feature_scan.py && /home/hampa/work/.venv/bin/python -m pytest tests/test_feature_scan.py -q -> rc 0; 16 passed.

File-size-limit reproduction (synthetic shaders only):
- Setup: mkdir -p /home/hampa/.hermes/profiles/mikuling/cache/scratch/feature-scan-ulimit1.hlUt9B/shaders/dxbc /home/hampa/.hermes/profiles/mikuling/cache/scratch/feature-scan-ulimit1.hlUt9B/out; python3 -c 'import json,sys; json.dump([{"stage":"synthetic_stage_"+str(i)+"_"+("x"*80)} for i in range(40)], open(sys.argv[1],"w"))' /home/hampa/.hermes/profiles/mikuling/cache/scratch/feature-scan-ulimit1.hlUt9B/shaders/dxbc/index.json; printf '{"previous": "sentinel report"}\\n' > /home/hampa/.hermes/profiles/mikuling/cache/scratch/feature-scan-ulimit1.hlUt9B/out/report.json
- Before: bash -c 'ulimit -f 1; python3 -I -B tools/feature_scan.py "$1" --out "$2" >/dev/null' _ /home/hampa/.hermes/profiles/mikuling/cache/scratch/feature-scan-ulimit1.hlUt9B/shaders /home/hampa/.hermes/profiles/mikuling/cache/scratch/feature-scan-ulimit1.hlUt9B/out/report.json -> rc 2; report 32 bytes before, 1024 bytes after (old contents replaced by partial JSON).
- After: bash -c 'trap "" XFSZ; ulimit -f 1; python3 -I -B tools/feature_scan.py "$1" --out "$2" >/dev/null' _ /home/hampa/.hermes/profiles/mikuling/cache/scratch/feature-scan-ulimit1.hlUt9B/shaders /home/hampa/.hermes/profiles/mikuling/cache/scratch/feature-scan-ulimit1.hlUt9B/out/report.json -> rc 2; report 32 bytes before and after, with no temp file remaining.
2026-11-25 07:58:47 +01:00
495ff9e3ec tests: cover feature_scan refusing an --out that names the optional SPIR-V index 2026-11-24 21:48:40 +01:00
166fd116a8 Round 44 test clashes: CI registration sees inherited tests, runner skips, v_cmpx's EXEC def, wave32-half shuffles, OpFOrdLessThanEqual in spirv_interp, fixed f64 div_fixup divergence, 10_11_11 stores; the macOS runtime configure requires Vulkan
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-23 04:23:34 -05:00
cae4e87be3 feature_scan: protect the corpus index from hard-linked report paths 2026-11-22 22:10:27 -05:00
3d27679a34 test: exercise feature-scan output guard with Windows directory junctions 2026-11-22 21:55:44 -05:00
affed5997c test: cover symlinked feature scan output paths 2026-11-22 21:42:55 -05:00
dac28e6b19 Fix what the round-42 merges broke (tests and docs)
- shader_disasm: prune stale listings against every input, not the --skip-existing remainder (a resumed run
  deleted every listing it had just reused).
- progress_dashboard: a drive-letter path is never inside the repository off Windows (it printed user names);
  its own read_text helper is read_utf8, so the encoding check does not take it for pathlib's.
- Translator tests follow this round's rules: desc_lookup's BroadcastFirst in the typed-load condition walker;
  resinfo sizes are 0 past the last level and a 2D depth word is 0 (SHADER-388); SHADER-315 constant folding in
  the perm and i16 tests; #2089's structured wave64 emulation.
- test_semantic_translator_use: 57 oracle-only files merged before it are DEBT; test_spirv_tools_required is
  allowed (CI meta-test).
- Test fixes: image_fuzz fake writes the programs, preflight follows c506d00c's loader hint rule, feature_scan
  reads the first line of a pytest-decorated message, w64_graphics wording.
- docs: rows merged again in design.md, README.md, d3d12_vulkan.md; GameInput table rebuilt from #3172's rows;
  orphan rows in models.md and embedded_shaders.md; repeated bullets; anchors; a flag not on main.
- Repo rules: stdout guard on 14 programs; LF writes; csv lineterminator in bink_play.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-22 16:14:54 -05:00
295c523c41 Merge pull request #3051 from jaybeebabageyus 2026-11-22 15:14:22 -05:00
babaa582ff Merge pull request #2452 from CLHelper 2026-11-22 15:10:47 -05:00
b1ea964d0c tests: route test_feature_scan's duplicate-shader-names check through check()
test_duplicate_shader_names_keep_file_stages() is the only test in the
file whose assertion is a bare assert; in the file's stdlib run mode the
__main__ runner's except-AssertionError-pass swallows it, so a regression
prints OK (0 failures) and exits 0. Route it through check() so it
counts into the failure tally, prints, and fails the exit code.
2026-11-22 20:13:29 +01:00
5ec1f677ca Merge pull request #2522 from Vonsek 2026-11-22 13:15:53 -05:00
9cbc4c068f test_feature_scan: a failed check fails only its own test in the script run
Every test ends in `assert failures == 0` over the module-wide count, so after one failed check run_tests
reported every later test as failed too. Each test now starts from its own count; the counts are added back
to the run's total. New test pins it.
2026-11-22 18:11:41 +00:00
bf785cc204 fix(tools): invalidate permutation selectors on carry writes
A carry or scale flag can overwrite a known scalar selector through the second destination, inflating the feature scan counts.
2026-11-22 18:20:29 +01:00
aea46a87db test_feature_scan: a test that fails can no longer leave the script run green
CI's standard-library job runs tests/test_feature_scan.py with python -I. Its
__main__ held all eight tests in one try block that swallowed AssertionError,
so a failing bare assert (test_duplicate_shader_names_keep_file_stages ends in
one) skipped every test after it and the run printed "OK (0 failures)", exit 0.

Each test_* function now runs on its own (run_tests), taken from the module in
file order so a new test is not left out; one that raises is reported and
fails the run, and the rest still run. A new test covers run_tests.

AI-assisted.
2026-11-22 17:05:18 +00:00
364d9a465a feature_scan: INVALID is modelled; d3d12_vulkan.md answers open question 16
A literal V# word 3 with FORMAT 0 (an unbound descriptor) reads 0 on the
hardware and in the translator, so it is not listed as a format the
translator lacks. Row 16 gets the counts over the 1.0.2.1 corpus.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-22 15:23:28 +01:00
0fc69a771b feature_scan: answer open question 16 (UAV counters, typed buffer formats)
PSV0 resource bindings give the structured UAVs with a counter and the
typed buffer SRVs/UAVs; the listings give the MTBUF instruction formats
and, for MUBUF *_format ops, where V# word 3 comes from in the access's
basic block (literal, scalar load, computed, an earlier block or a
shader input). Formats are checked against rdna2spirv.Gen.FORMATS.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-22 15:23:28 +01:00
d92a395e10 feature_scan: refuse a --out inside the shader corpus it reads
`feature_scan.py <shaders> --out <shaders>/dxbc/index.json` wrote the report
over the corpus index and printed the counts with exit 0, so the next run of
the same command failed with "is not a shader list" and the shaders stage of
make_game.py had to be run again. A scanned .dxbc, a listing in dxbc/disasm
and the spirv/index.json the scan reads had the same problem.

--out is now checked against those inputs before anything is read: one line
and exit 2 naming the path, and nothing is written. Report paths outside the
shader folders are unchanged, including the missing-folder creation.

🤖 Generated with Codebuff
Co-Authored-By: Codebuff <noreply@codebuff.com>
2026-11-22 06:44:57 -06:00
1b47daac4f Merge pull request #1092 from bbareth 2026-11-22 02:09:04 -05:00
523d79d63d feature_scan.py: shader variants that share an original name keep their own stages
main() built stage_of from the file stems, then overwrote it with the
original shader names. Two variants with the same original name but
different stages (same.dxbc as gs, same~1.dxbc as ms) both took the last
one's stage, so the disassembly counts gave {'ms': 2}. File stems now win;
original names are only a fallback.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-22 07:52:57 +01:00
ef54f9e61b feature_scan, turing_atlas: create the --out folder instead of losing the run
Both tools opened --out with a bare open(..., "w"), so a path whose parent does
not exist threw FileNotFoundError after the whole scan or the whole compile run
had already finished (#934 is the same defect in hashdict.py). awc_manifest.py
and the other tools create the parent first; these two now do the same.

Tests: the existing CLI fixtures run each tool with --out inside a nested folder
that does not exist, and assert a clean exit and the file landing there. Both
fail without the change: feature_scan reports "FAIL --out creates a missing
folder", turing_atlas raises the FileNotFoundError the fix removes.

🤖 Generated with Codebuff
Co-Authored-By: Codebuff <noreply@codebuff.com>
2026-11-21 23:19:04 -06:00
376680bed4 tests/test_feature_scan.py: test v_perm_b32 immediate, constant-reg, clobbered, and 8-11 selector counts 2026-11-22 02:51:22 +00:00
e5e35ef6e8 feature_scan.py: a missing or unreadable shaders folder is one line
main() opened <shaders>/dxbc/index.json straight away, so a mistyped
path, a file, a work folder whose shaders stage hasn't run, a broken
index.json and one that isn't a list all ended in tracebacks
(FileNotFoundError, NotADirectoryError, JSONDecodeError,
AttributeError). Each now prints one line naming the path, and what to
run when the index is missing, and exits 2 before --out is written.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-22 01:45:43 +01:00
c6194c7495 feature_scan.py: check DXBC part bounds before counting features 2026-11-22 00:59:52 +01:00
cdaaebcac0 Tools: report a short OSG1 signature instead of aborting feature_scan
streams() read `count` 32-byte elements at `first` without checking the part
length, so a truncated OSG1 raised struct.error out of scan_dxbc and killed the
whole count-only scan. Treat a signature whose element table does not fit (or
whose first element overlaps the 8-byte count/offset header) as carrying no
stream information, matching the existing len(sig) < 8 case. Well-formed
signatures are read exactly as before.

Synthetic regression test in tests/test_feature_scan.py: it fails on
unmodified main with struct.error and passes with the fix; a work folder with
one truncated OSG1 still prints the summary and keeps the real stream-1 count.
No game data, no GPU. Full CPU suite: 1559 passed, 150 skipped, 1 xfailed;
semantic suite: 423 passed; compileall and --help clean.

New BUILD item claimed in #374. AI-assisted (OpenCode).
2026-11-21 17:34:45 -06:00
e6cf90f963 test_feature_scan: run as a pytest test as well as a script (pytest collection hit the module-level sys.exit)
AI-assisted (Claude Code).

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-21 23:29:24 +01:00
052cc571d0 feature_scan: count s_getpc_b64 kept for code-embedded data per stage; d3d12_vulkan.md: answer §8.2 #10, per-stage counts for #14, tiled resources for #18
AI-assisted (Claude Code).

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-21 23:12:07 +01:00
409f702bbb Tools: feature_scan.py, a corpus scan for D3D12-layer features (SHADER-16)
Counts, from what the shaders stage leaves in <work>/shaders, the features docs/d3d12_vulkan.md
§8.2 #10 and #14 ask about: the DXIL program kind of every shader (hull, domain, amplification),
the SFI0 D3D_SHADER_REQUIRES_* flags (values from the Windows SDK's d3d12shader.h, among them
WAVE_MMA and SHADING_RATE), output-signature streams other than 0, native v_mfma/v_wmma and
GDS/ordered-count instructions in the disassembly, and uses_code_base per stage from
spirv/index.json. Prints counts only. tests/test_feature_scan.py checks it on a synthetic work
folder (hand-built DXBC parts, listings and index).

AI-assisted (Claude Code).

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-21 23:10:38 +01:00