Commit Graph

3 Commits

Author SHA1 Message Date
71d39cefb9 Rework RTS0 parser to offset-table layout; harden oracle test
Per maintainer feedback: the real blob is a DXBC container whose RTS0
chunk starts version, numParameters, parametersOffset, numStaticSamplers,
staticSamplersOffset, flags, with parameters as a {type, visibility,
offset} table and payloads at their offsets (d3d types follow
D3D12_ROOT_PARAMETER_TYPE numbering, not the model's enum order).

Also fixes the oracle segfault mechanism: return early when parsing fails
instead of indexing an empty model, and bounds every offset addition in
size_t so hostile containers cannot wrap the guard into an OOB read.
Adds a wild-offset control plus a DXBC-walk test (19 portable checks green
under ASan+UBSan).
2026-11-21 17:40:40 -03:00
87989cea5f Parse RTS0 via DXBC chunk walk; fix OOB wrap and FourCC typo
The MS serializer returns a DXBC container, not a bare payload (proven
by the CI blob dump starting with DXBC). parse_rts0 now walks the chunk
table like input_signature does and decodes the RTS0 payload.

Also fixed: 'O' (0x4F) vs '0' (0x30) in the FourCC check, which silently
missed every chunk, and u32 arithmetic wrap in the bounds checks (a hostile
offset could wrap off+8 past the guard into an OOB read).

Adds a hand-built DXBC container test covering the walk path.
2026-11-21 17:31:08 -03:00
612f1edebd Root signature packer + reconciler + hard-fail (fix the least verifiable part of the layer)
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.
2026-11-21 17:04:28 -03:00