The oracle serializes synthetic versioned root signatures with Microsoft's
D3D12SerializeVersionedRootSignature and requires rt::rootsig::parse_rts0 to recover
the same model. It covered 27 of 53 features: every fixture used FLAG_NONE, only SRV
and UAV ranges existed, dtype 4 (root UAV) never reached the parser, and 1.0 root
views were only tested as SRV.
That matters because a mis-read flags word silently switches the binding model, and
bindless signatures (NumDescriptors == UINT_MAX, sampler tables) are exactly what a
modern title uses. A first root UAV in a compute signature would have failed to parse
with no test to catch the regression.
Adds 32 assertions across 1.0/1.1/1.2: every root-signature flag, CBV and SAMPLER
ranges including unbounded counts and DESCRIPTORS_VOLATILE, root UAVs, the 1.0 root
view form, static samplers in a second table, and checkerboard parameter orders.
Each case is named, so a failure reads 'flags: allow IA layout survives' rather than
'false'. parse_checked() stops a failed parse from being indexed, which is what
segfaulted the earlier attempt.
Verified on Windows with MSVC 19.44 / SDK 10.0.26100 at /W4: 62 PASS, 0 FAIL.
Mutation-checked: reading flags at +16, dropping dtype 4, and mapping MESH to PIXEL
each fail new cases only, and the untouched suite passes none of them.
parse_rts0 read 1.1/1.2 descriptor-range records with Flags and
OffsetInDescriptorsFromTableStart swapped (offset at +16, flags at +20).
The PC serializer writes D3D12_DESCRIPTOR_RANGE1 order: type, count, base
register, space, Flags, then the offset. Both values were discarded, so
nothing broke yet, but the descriptor-table layout would have read flags as
offsets.
DescriptorRange now keeps all six fields; the canonical codec stores them
(codec version 2; nothing persists version 1 blobs). The hand-built 1.1
fixture in root_signature_test had the same swap and is corrected; a 1.0
fixture is added, and root_signature_oracle_test checks every range field
against the host serializer for 1.0, 1.1 and 1.2.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The in-box d3d12.dll of Windows 10 (and Windows 11 23H2, #361) serializes
root signatures only up to 1.1: on Windows 10 it rejects even an empty 1.2
description with E_INVALIDARG (#528). #361 made the tests skip there, but the
d3d12_xs serializer still forwarded 1.2 descriptions unchanged, so every 1.2
root signature from the package DLLs or the game failed on those hosts.
- d3d12_xs_rootsig: downgrade_root_signature_1_2_to_1_1 rewrites a 1.2
description whose static samplers all have Flags == 0 as the same root
signature in 1.1 (1.2 differs only in D3D12_STATIC_SAMPLER_DESC1::Flags).
- d3d12_xs: probe the host once with an empty 1.2 description; where it
stops at 1.1, serialize 1.2 as 1.1, or refuse one with sampler flags
with a log line.
- root_sig_test: the registered shim's 1.2 checks run on every runtime again;
new checks cover the rewrite field by field, through the registered shim
and back through the host deserializer, and the refusal.
- root_signature_oracle_test: its 1.2 cases use sampler flags, which have no
1.1 form, so they print SKIP where the host can't serialize 1.2.
- docs/d3d12_vulkan.md: the measurement and the rule.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
parse_rts0 refused D3D_ROOT_SIGNATURE_VERSION_1_2 blobs. 1.2 is 1.1 plus
D3D12_STATIC_SAMPLER_DESC1::Flags: the PC serializer writes RTS0 version 3 with
14-dword static samplers (13 before). The model gains Version::V1_2 and
StaticSampler::flags. The canonical codec writes the flags only for 1.2, so 1.0/1.1
encodings are byte-for-byte unchanged.
Checking it against the real serializer found an older bug: a descriptor table's
payload is {num_ranges, ranges_offset} with the ranges at that offset, but the
parser read them inline after the count. Every table came back with a wrong range
type and count. The oracle test only covered constants and a CBV, so it never saw it.
root_signature_oracle_test now serializes 1.0, 1.1 and 1.2 signatures with a
two-range table, a root SRV and two static samplers (1.2 with a UINT border colour,
then non-normalized coordinates). Every sampler field, the ranges and the canonical
round trip must match. root_signature_test adds hand-built 1.2 and table payloads
and their truncation controls.
AI-assisted (Claude Code).
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
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).
The Windows oracle test segfaulted in CI. Most likely cause: an
unbounded static-sampler reserve driven by real-blob bytes under a wrong
layout hypothesis. Both decoders now refuse absurd sampler counts, and the
oracle test prints the blob size plus the first 32 bytes before parsing so
the next CI log shows the true D3D12 layout either way.
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.