docs/d3d12_vulkan.md §5.2 leaves the push-constant shape open and says to decide after measuring how many
real PSOs have two code-base stages; row 14 of the docs/boot.md checklist asks the same thing, and
tools/feature_scan.py's header says the pairing is in the executable, not in shaders.rpf. It is in shaders.rpf:
the pipeline library names a program per stage slot, and a stage's resource-layout blob ends with the HASH
digest of the container its code came from, so a stage joins to that program's `uses_code_base` in the
translation index through the container shader_carve.py carved.
The new tool reads the library, as an archive or as a saved library, joins
PSO -> stage slot -> program -> digest -> carved container -> spirv/index.json row, and prints counts only:
graphics PSOs by the number of code-base stages, those stages, the stage slots, the per-stage program counts
and the records it could not resolve. --out writes the same counts as JSON and refuses to name one of its own
inputs.
Measured on Xbox 1.0.2.1 (library 0x65F41EDD 930.048.020, 25,471 graphics records): no PSO has two code-base
stages. 25,027 have none and 444 exactly one - 343 MS, 60 PS, 41 VS - in a corpus of 13,383 VS+PS, 10,726
MS+PS, 1,336 MS, 24 VS and 2 VS+PS+slot 6; 21 records stay unknown because a stage's program is not in the
carve output. Its per-stage program counts (38 VS, 46 PS, 260 MS, 263 CS) are lower than the corpus's own
54 / 93 / 266 / 263: the library holds a second compiled form of 6,522 carved shaders and a program can serve
two slots.
So one 144-byte block with one code base at dwords 34-35 is enough for this package, and the runtime's refusal
of a pair where both stages read it can stand. docs/d3d12_vulkan.md §5.2 and its question 14, docs/boot.md
row 14 and docs/shader_library.md §4 and §6 say so; the stale pairing line in feature_scan.py's header is
corrected, and shader_library.py's header now says slot 6 is used by the 2 records that also have VS and PS.
tests/test_pso_code_base_pairs.py builds the library, the carve folder and both translation-index shapes from
bytes: 9 tests, no game data. The tool's __main__ block sets errors="replace" on stdout like every other tool,
which tests/test_tool_stdout_encoding.py checks. Also run: compileall, scripts/check_no_game_data.py,
test_shader_library.py (21) and test_text_write_line_endings.py (3). Whole-suite comparison, `python -I
scripts/run_semantic_tests.py tests -j 4` on Windows 11: plain 89d7dfcf5 reports 522 files, 8,099 tests, 42 files
failed; with this commit 523 files, 8,108 tests, 42 files failed - the two lists differ only by
test_run_wine_tests and test_build_batch_launch, which both pass alone on this machine and fail under -j 4 on a
loaded box. Those 42 are unchanged by this commit: 30 are pytest-based files that `python -I` cannot import and 6
more are script-style files the runner collects nothing from (ci.yml:87 runs both kinds elsewhere), plus the
Windows-only failures in test_world_names, test_bink_names, test_opus_tags, test_ci_registration and
test_mesh_alloc_single_writer. All of them are filed as findings on #14.
Claimed in the coordination issue as SHADER-CODEBASE-PAIRS (issue #14, comment 7146787349). AI-assisted.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
scan_disasm followed os.listdir, and its report keeps its keys in the order
they are first seen (wave_mma_ops, ordered_or_gws_ops and the per-stage
counts). The same folder therefore gave a different JSON file on NTFS (name
order) and on ext4 (hash order), against the rule that the same input gives
the same bytes on every platform.
Sort the listing. The test builds two hand-written listings and forces the
listing order both ways; it fails on the old code and passes now.
Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
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>
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>
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.
`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>
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>
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>
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>
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>
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).
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>
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>