Commit Graph

25 Commits

Author SHA1 Message Date
9231063348 fssm_unpack: validate DXBC magic and 24-byte XBCH header, guard empty --carve-index and write errors, and preserve index symlinks/mode 2026-11-25 08:24:05 +01:00
1f3f4ba3bb fssm_unpack: count containers and programs apart, per stage (BL-5)
The corpus is 26,503 carved containers holding 26,698 tag-0x0D payloads:
195 vertex-shader containers carry two. fssm_unpack.py now prints both
counts and, given the carve index, a line per stage. shader_library.md
records the two counts and why 195 equals the geometry-shader count.

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
2026-11-24 22:54:07 +08:00
14e9f4eb72 tools: retry os.replace on transient Windows sharing errors in the shaders stage (#2721)
Squash-merged after diff review of PR #2721
2026-11-23 09:35:47 -06:00
4921ec4b02 Merge pull request #4347 from YaBulochka
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

# Conflicts:
#	docs/design.md
2026-11-22 23:13:54 -05:00
755b1f6d14 pal_stages: read the FSSM stage-descriptor table
The FSSM header holds 0x88-byte hardware-stage records from 0x100; a record starts with
u64 0x000000C0_0002_AAHH (HH = PAL hardware stage, AA = API stage). tools/pal_stages.py
decodes them from a bare FSSM or from every tag-0x0D payload of a container, and reports
the sentinel words. tools/fssm_unpack.unpack_all() exposes the payloads the tool needs.

Measured on the 26,503-blob corpus: 26,308 blobs have one record and 195 (all GS) have
two, the second at 0x188 being the VS copy. The API id equals the carve-index stage in
26,698/26,698 blobs (0 VS, 1 PS, 2 GS, 3 CS, 6 MS). Hardware id 7 appears for all 9,282
mesh shaders and nowhere else; 2 appears only in the first payload of the 195 two-payload
VS containers. 860 blobs (1,055 records) fill unused fields with paired
0xDEADBEEFDEADBEEF qwords, never a lone 32-bit word; the other 25,643 records use zeros.

Tests: tests/test_pal_stages.py (synthetic FSSM and container), plus the fssm_unpack,
fssm_crosscheck, fssm_header, fssm_wave_size, make_game and shader-stage suites.
2026-11-23 03:55:38 +03:00
ffeb09636c Report unreadable DXBC inputs during FSSM unpacking 2026-11-22 23:48:58 +01:00
c6916f5c72 Merge pull request #2805 from Jim123666888 2026-11-22 15:12:11 -05:00
d859daeef7 fssm_unpack: use exit 2 for output directory errors 2026-11-23 02:53:34 +08:00
23919d9548 Merge pull request #2580 from Italo Felipe 2026-11-22 13:16:20 -05:00
ad8e9d591b Merge pull request #2417 from bbareth 2026-11-22 13:15:10 -05:00
11f424b80c fssm_unpack: report output directory creation errors 2026-11-23 01:56:55 +08:00
22786239bf fix: validate DXBC and XDAT container bounds 2026-11-22 14:30:10 -03:00
6962c9a8c6 fssm_unpack: stage the completion index privately 2026-11-22 17:58:58 +01:00
c7408a1f7e Keep stale shader files out of resumed builds
Select each stage's inputs from its producer index and refresh downstream
stages when a saved cache contains obsolete shader names.
2026-11-22 23:35:45 +08:00
ec9b6cf22b tools: text reports are written with LF line ends on every platform (BUILD-468)
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.
2026-11-22 14:20:30 +00:00
f698bf2206 tools: a path outside the console's code page no longer crashes a tool's output
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>
2026-11-22 11:27:00 +00:00
c3c1629c45 Bound XBCH decompression output
Validate XBCH stored size, cap output by the declared FSSM length, and reject truncated or trailing zlib data. Add synthetic regression coverage for the declared-size ceiling and malformed streams.

Addresses BUILD-342 claimed in #1218.
2026-11-22 09:46:48 +00:00
b036c3fd77 fssm_unpack: skip non-file DXBC entries 2026-11-22 04:38:49 -03:00
b3eff27528 fssm_unpack.py: a payload without FSSM magic is not published
unpack() checked the decompressed payload's size and that it holds at least a
magic and version, but not the magic itself, so a payload starting "JUNK" was
written as a .fssm and indexed. It is now a ValueError, counted with the
other per-file problems.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-22 06:28:11 +01:00
f58e9b221e fssm_unpack.py: a missing or non-folder source is one line, and nothing is created
main() made <src>/fssm before it listed <src>, so a mistyped source
folder was created, whole path included, and the run then ended with
"no shader unpacked" as if the folder were real. A file given as the
source ended in a NotADirectoryError traceback, and a folder that can't
be listed in a PermissionError one. The source is now checked first: a
missing path, a file or an unlistable folder prints one line naming it
to stderr and exits 2, and nothing is written.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-22 01:43:38 +01:00
b4735ef6d7 fssm_unpack.py: reject a truncated FSSM header before writing output 2026-11-22 00:16:37 +01:00
0a65e6a2ba Merge pull request #136 from NWX10
# Conflicts:
#	tools/fssm_unpack.py
2026-11-21 15:17:51 -05:00
7cc6068ab6 Shader stage: resume only finished steps, Windows-safe carve names, clear error on empty unpack (fixes #126)
- make_game.py: a step counts as done only when the file it writes last
  exists (index.json, fssm_index.json, disasm.done, spirv/index.json),
  not when its folder exists or holds >=1000 files. Re-running a step
  drops the later steps' markers so they run again.
- shader_carve.py / fssm_unpack.py: write their index last, via a temp
  file and os.replace, so a stopped run never leaves one behind.
- shader_carve.py: file names are unique without case and Windows device
  names (CON, NUL, COM1...) get a "_" prefix; ~N suffixes never land on
  a real name.
- fssm_unpack.py: exit 1 with a clear message when nothing unpacks,
  before writing the index, instead of an IndexError.
- tests/test_shader_stage_resume.py: 13 tests, standard library only.

AI-assisted.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-21 23:00:32 +03:00
65d62ffdc8 Tools: preserve duplicate XDAT payloads in fssm_unpack 2026-11-21 19:56:15 +00:00
db0dc8bd5e Initial commit: Leonida, build-it-yourself PC port groundwork
Shader pipeline (carve, FSSM unpack, gfx1013 disassembly, RDNA2 to SPIR-V),
asset export via rpf9-explorer's Core (submodule), PE loader and shim
skeleton, and make_game.py, which builds from the user's own copy of the game.
No game data, keys or executables are included.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-20 15:22:16 -05:00