Add a stdlib record/tree decoder for the measured RBF0 format. It joins 64 KiB continuations, parses the inline descriptor table, builds element/attribute/content/text trees, and writes JSON plus optional generic XML. Unknown descriptors, record types and malformed framing fail closed with a partial tree. Add synthetic tests and the measured grammar, samples and remaining unknowns to docs/rbf0.md; note the rig-set blob tree result in docs/animation.md.
LLVM_MC may be one executable or a command line such as the WSL llvm-mc documented for Windows. shader_disasm.py already split it, but the tests, runtime/test/shaders/build.py and scripts/run_gpu_tests.py treated it as a single executable, so the documented setup skipped translator tests, and build.py passed a Windows path to WSL. Share the splitter in tools/mc_command.py and feed assembly on stdin.
scripts/build_llvm_mc.ps1 sparse-clones the LLVM sources llvm-mc needs,
builds it alone with LLVM_TARGETS_TO_BUILD=AMDGPU, static CRT and the DIA
SDK off (its headers need ATL, which the C++ build tools don't always
include), checks it disassembles an s_endpgm for gfx1013, keeps only
llvm-mc.exe and sets LLVM_MC for the user. README, docs/design.md and the
make_game.py / shader_disasm.py hints mention it next to the WSL route.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
- A 'KB2x' match within the last 0x1C bytes of the archive (what a
truncated copy can end with) read the header's size and width/height
fields past the end of the file. struct.error is not caught, so the run
died without writing index.json, losing the whole carve. Such a match is
now skipped like any other non-video candidate.
- An archive whose data area is empty (its data offset is the file size),
or --start at the end, gave span 0 and a ZeroDivisionError in the final
"readable" line after index.json was written. The percentages now divide
by at least 1; the summary still records span 0.
- tests/test_rpf9_carve.py: one synthetic case each; both fail on main.
AI-assisted.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Add the full core_restofworld scan (1.21 GiB, 96% Bink 2 plus model/page data), re-measure story000_restofworld and story000_script, and cover the three small archives. Cross-check PSIN against script.rpf/story000 and core pages/models against packs.rpf/levels.rpf. Add a stdlib-only stream index tool and synthetic-header tests. No game data.
What was wrong
An RDNA2 SMEM load can carry a register offset and an immediate at once.
llvm-mc prints that form as "s_buffer_load_dword s12, s[24:27], s40 offset:0x4".
shader_ir.parse_line puts "offset:0x4" in mods, and Gen.scalar_load only read
the third operand, so the immediate was dropped without a diagnostic: the line
translated to the same SPIR-V with and without the modifier, and spirv-val
accepted both.
Evidence
Measured on an AMD Radeon RX 6800 (gfx1030) by running the instructions as a
raw compute kernel: for s_buffer_load_dword/x2/x4/x8 the address is
base + soffset + imm + 4*i, e.g. soffset 8 + imm 4 reads the dword at +12.
s_load_dword* with both offsets was not measured; it shares the SMEM encoding
(soffset_en + imm), so giving it the same rule is an inference.
Change
- scalar_load adds the immediate when the third operand is a register and mods
has offset:N. The no-modifier forms emit the same code as before.
- Forms llvm-mc does not accept (immediate operand plus offset:, two offset:
modifiers, a fourth operand, an unparseable offset) raise Unsupported.
- Not changed, and listed in docs/design.md as known differences: the hardware
truncates base, soffset and imm each to a multiple of 4 and s_buffer_load
returns 0 past NUM_RECORDS; the translator does neither. A negative s_load
immediate is still zero-extended from 32 bits, in both forms (not measured).
Tests
- tests/semantic/test_scalar_mem_smem.py: SmemSoffsetImmTranslatorTests runs
the code scalar_load emits against concrete SGPRs and memory and asserts the
addresses and values read (9 tests; 7 fail on main, where the loads read +8
instead of +12, and the imm-only / soffset-only regression cases pass).
- runtime/test/shaders/cs_smem_soffset_imm.asm, wired into check.py and
scripts/run_gpu_tests.py. Not run on a GPU in this change.
- unittest discover -s tests/semantic: 335 -> 344, all pass.
- pytest tests (--capture=sys, llvm-mc through WSL): 883 -> 893 passed, the
same 6 test_rtti_scan failures before and after (pefile not installed).
- The 27 hand-written GPU shaders: 27 translated, 27 pass spirv-val before and
after, output byte-identical.
AI-assisted.
Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
LLVM 21 prints the VOP3 form of v_lshlrev_b16, v_add_u16 etc. without _e64. All of them in the game's
shaders are 8-byte VOP3 encodings, so they were translated as VOP2 writes and lost the high half that
the hardware keeps (about 340 shaders). Found by #78's ps_ops5 on the GPU. Both runners now check
ps_ops5/ps_ops6, run_gpu_tests skips the interpreter-only ps_vcc_x2 (it lost the device), and
test_shader_checks derives its total from check.py.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
make_game.py takes ttpf manifest.json and audio_manifest.json as proof that
a step finished, and every exporter skips a file that already exists. Both
were written in place, so a stopped run or a full disk could leave:
- a truncated manifest, after which make_game.py skips that texture pool
or the audio banks on every later run, or
- a truncated .dds / .obj / .xma.wav under its final name, kept forever
because the next run sees it exists.
All outputs (ttpf DDS + manifest, audio_manifest.json, XMA2 .xma.wav,
model .obj, embedded and dictionary .dds) now go through Util.WriteAtomic:
written to <path>.partial, then File.Move'd over the final name; the
temporary is removed on failure, and a stale one from a stopped run is
deleted first (WriteXmaWave opens its target with FileMode.CreateNew).
The models manifest already worked this way.
Util moves to its own file so tests/Rpf9DumpDiagnostics can link it; the
diagnostics program gains four checks for WriteAtomic.
AI-assisted.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Add --wave64-emulate to tools/rdna2spirv.py. A wave64 compute or mesh
shader then uses no subgroup operation: everything a lane needs from the
rest of its wave (votes for s_cbranch_*/SCC, whole-mask words for
s_bcnt1/s_ff1/v_mbcnt, v_readlane, v_readfirstlane, ds_bpermute,
ds_swizzle, v_permlane16/x16) goes through a Workgroup buffer. The
program runs in rounds that end at one OpControlBarrier in uniform
control flow; a cross-lane op cuts its basic block, and the rest runs one
round later, when all 64 lanes have written. s_barrier becomes a
scheduler state, and conflicting memory accesses in one segment are
ordered by a round. This answers #94 and #101 for compute and mesh
shaders: on 32-wide subgroups (NVIDIA) they are now exact, not
approximate.
Two fixes that apply without the flag:
- v_writelane_b32 in cs/ms selects the lane by the wave lane. On a
32-wide subgroup writes to lanes 32-63 were lost.
- ds_bpermute_b32 in wave64 runs as two wave32s (RDNA ISA 10.4.4): on a
64-wide subgroup lanes 32-63 read the low half, and an inactive source
lane now reads 0.
New hand-written GPU tests cs_w64x_* and ms_w64x_ballot pin down the
cross-half semantics. LEONIDA_W64_EMULATE=1 makes build.py,
run_gpu_tests.py and check.py use the flag. Other translator output is
byte-identical.
Tested on NVIDIA GeForce RTX 5070 Laptop (driver 617.42, subgroup 32) and
AMD Radeon 880M (driver 26.11.2 LLPC, subgroup 64):
run_gpu_tests.py 37/37 on both with the flag (RTX 5070 without it: 21/37;
880M without it: 37/37, was 36/37 before the bpermute fix).
AI-assisted (Claude Code).
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
A lane mask of a wave32 shader in a 64-lane subgroup has bits there; s_bcnt0_i32_b32 still counts the
low word only. Restores test_wave64_bfm64_and_half_cmp_emit_wave_ops.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The audio steps had the same resume problem as the shader stage (#126):
- make_game.py: the Ogg Opus and XMA2 steps counted as done once their
folder existed, which a stopped run also leaves. They now count as done
by a marker (audio/ogg.done, audio/xma.done) written after the step
succeeds.
- make_game.py: XMA2 -> WAV with ffmpeg now runs on every assets run for
the streams that have no .wav yet, writes to a temporary name renamed on
success, and checks ffmpeg's exit code. A failed or stopped decode no
longer leaves a short .wav, and installing ffmpeg after the first run now
decodes the streams instead of never trying again.
- awc_opus.py: .ogg/.wav files are written under a temporary name and
renamed, so a stopped run or a full disk never leaves a truncated file.
A read/write error (OSError) now fails the run (exit 1) so the step is
retried; banks that do not parse are still skipped as before.
- tests: new tests/test_audio_stage_resume.py (10 tests, standard library
only); WavValidationTest updated to set up the new markers.
AI-assisted.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
tools/pe_inspect.py imported pefile at module level, which the contributing rules do not allow, and which kept
the tool out of the standard-library check job: no test imported it, so CI only syntax-checked it while
scripts/first_look.ps1 still ran it on the executable people bring. It now reads the DOS and NT headers, the
section table and the import, delay-import, export, TLS and relocation directories with struct, and writes the
same JSON and Markdown with the same keys.
Delay-import descriptors without dlattrRva store 32-bit virtual addresses, so they are converted with the image
base instead of being read as RVAs. The Markdown shim list no longer tests for a classifier result that is never
produced.
tests/test_pe_inspect.py builds a 64-bit and a 32-bit image byte by byte and covers both descriptor forms,
imports by name and ordinal, an ordinal-only export, .pdata and TLS callback counts, DLL classification, the
CLI's output files and its rejection path.
- tools/awc_opus.py: wrap export_bank file read in a with-statement to
close the handle promptly instead of relying on GC (fixes ResourceWarning
seen in test output).
- tests/test_amd_swizzle.py: use raise unittest.SkipTest instead of
import pytest; pytest.skip so the test works under both python -I and
unittest discovery when numpy is absent. No pytest dependency needed.
- tests/test_d3d12_xs_surface.py: same treatment for the two conditional
skips (Windows SDK headers, SCARAB_REF). The test still skips gracefully
without pytest installed.
- .github/workflows/runtime.yml: add a linux-gpu-tools job that installs
libvulkan-dev, builds all GPU test tools with cmake + ninja + g++, and
verifies every tool binary exists. Rename the Windows job from 'build' to
'windows' to disambiguate. This catches build regressions in GPU tool code
that only manifest on Linux.
AI-assisted.
AI-assisted (Muse Spark + explorer fleet).
Implements docs/d3d12_vulkan.md section 3.5 as code: a portable D3D12
root-signature model (1.0/1.1, no d3d12.h) plus a packer that lays root
parameters into the 32 user-SGPR dwords in root-parameter order (constants
take N, views/tables take 2, static samplers take none). Anything that does
not fit - more than 32 user SGPRs (spill layout unknown) or more than the
64-dword D3D12 cost limit - is refused loudly instead of truncated.
tools/root_sig_contract.py reconciles a candidate signature against every
shader's user_sgpr_reads from spirv/index.json (const32 vs constant dwords,
64-bit VAs vs view/table pairs, unpaired-hi detection) and exits nonzero on
the first contradiction; --cluster shows which read-set shapes the game
actually needs.
The RTS0 chunk reader is marked hypothesis until the new Windows oracle
test (synthetic descs serialized by the real d3d12.dll) confirms the layout;
Tier A (model/packer/canonical codec/RTS0 self-consistency/reconciler) runs
everywhere with no game data and no GPU.
Tested: python -m pytest tests/test_root_sig_contract.py (12 passed);
full suite 651 passed, 20 skipped, 1 xfailed; compileall + make_game --help;
portable C++ test 17/17 PASS under g++ -Wall -Wextra -Wpedantic -Werror with
ASan+UBSan; turing atlas on RTX 2060 SUPER (subgroup 32, mesh/bary/m8/heap
true): compute32/ballot64/f16_input/maintenance8 valid, broken_negative
correctly invalid. Windows-only Tier B (oracle + MSVC build) runs in CI.
- 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>