The per-stage report took the stage from the file name's first two characters before an
underscore, but most corpus names carry no stage prefix, so on my 26,503-shader corpus 25,040
(94%) landed under "?" (ps 1,228, vs 225, ms 10, cs 0). shader_carve.py's index.json next to the
disasm folder has every container's stage from its program header, as rdna2spirv.stage_of reads
it; stage_map() now loads it and the name prefix is only the fallback for shaders it doesn't list
(or when there is no readable index).
Real data (counts only), the same 26,503 shaders, main -> this change:
? 25,040 -> 0, ps 1,228 -> 12,101, ms 10 -> 9,282, cs 0 -> 2,689, vs 225 -> 2,236, gs 0 -> 195.
Tests: test_cli_takes_the_stage_from_the_carve_index (main: every listed shader without a prefix
is "?", and a name prefix wins over the index).
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
A missing source or a file given as one ended in a traceback from
os.listdir. An --out in a folder that doesn't exist (or that is a
folder itself) failed only after the whole corpus had been profiled,
again as a traceback. The source and the output folder are now checked
first, and a failed write is caught; each case prints one line naming
the path and exits 2.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
profile_shader() and register_footprint() were only called from the tests.
main() now runs profile_shader() on every shader and adds a "registers"
section to profile.json: per stage, the max and mean VGPR/SGPR count and a
VGPR histogram (<=32/64/128/256). --per-shader also lists each shader's
instruction count and VGPR/SGPR footprint. Existing output is unchanged.
Tested with hand-written disassembly only (tests/test_shader_profile.py).
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_011jW1LkcxdgoMR14Ng7tzCo