d3d12_xs: export D3D12CreateVersionedRootSignatureDeserializer, clearing the Xbox RTS0 flags (OLD-10012) #758

Manually merged
github merged 2 commits from gh-pr/758/head into gh-pr/758/base 2026-11-26 09:19:52 +00:00
Owner

@⁠abnalstlll-byte on GitHub · 2026-11-24 13:32 UTC · original
abnalstlll-byte:restore/old-10012-versioned-root-sig-deserializer → main · +58 −1 · 3 files · 2 commits · merged 2026-11-24 21:26 UTC

### Summary
Restores and updates work from draft PR #283 (old-pr/10012 / item OLD-10012).
Original commit by @⁠tedin7 (17ead7a27).

Exports D3D12CreateVersionedRootSignatureDeserializer and ordinal #7 from d3d12_xs.dll.
Console shaders and runtime callers frequently invoke this versioned deserializer with console-specific RTS0 flags.
This shim:

  • Intercepts calls, validates checksum via dxbc_checksum, and clears console RTS0 flags on a copy via copy_rts0_blob_clear_xbox_flags.
  • Forwards sanitized root signature blob to host D3D12CreateVersionedRootSignatureDeserializer.
  • Rejects corrupt or tampered blobs with E_INVALIDARG.
  • Includes unit tests in runtime/test/root_sig_test.cpp verifying ordinal resolution, checksum validation, and flag sanitization.
  • Documents behavior in docs/d3d12_xs_surface.md.

Verification

  • python -I scripts/check_no_game_data.py runtime/shims/d3d12_xs.cpp runtime/test/root_sig_test.cpp docs/d3d12_xs_surface.md -> Clean (no game data)
  • Clean rebase onto latest ubi/main (2d73c242f).

AI-assisted verification and rebase by Antigravity (Autonomous Direct Mode).

**@⁠abnalstlll-byte** on GitHub · 2026-11-24 13:32 UTC · [original](https://github.com/ubiquitarianism/leonida/pull/758) `abnalstlll-byte:restore/old-10012-versioned-root-sig-deserializer` → `main` · +58 −1 · 3 files · 2 commits · merged 2026-11-24 21:26 UTC ### Summary Restores and updates work from draft PR #283 (`old-pr/10012` / item `OLD-10012`). Original commit by @⁠tedin7 (`17ead7a27`). Exports `D3D12CreateVersionedRootSignatureDeserializer` and ordinal `#7` from `d3d12_xs.dll`. Console shaders and runtime callers frequently invoke this versioned deserializer with console-specific RTS0 flags. This shim: - Intercepts calls, validates checksum via `dxbc_checksum`, and clears console RTS0 flags on a copy via `copy_rts0_blob_clear_xbox_flags`. - Forwards sanitized root signature blob to host `D3D12CreateVersionedRootSignatureDeserializer`. - Rejects corrupt or tampered blobs with `E_INVALIDARG`. - Includes unit tests in `runtime/test/root_sig_test.cpp` verifying ordinal resolution, checksum validation, and flag sanitization. - Documents behavior in `docs/d3d12_xs_surface.md`. ### Verification - `python -I scripts/check_no_game_data.py runtime/shims/d3d12_xs.cpp runtime/test/root_sig_test.cpp docs/d3d12_xs_surface.md` -> Clean (no game data) - Clean rebase onto latest `ubi/main` (`2d73c242f`). AI-assisted verification and rebase by Antigravity (Autonomous Direct Mode).
github-bot locked as GitHub sync and limited conversation to collaborators 2026-11-26 09:19:50 +00:00
github manually merged commit 3ff887f962 into gh-pr/758/base 2026-11-26 09:19:52 +00:00
Author
Owner

@⁠trigger337 on GitHub · 2026-11-24 13:35 UTC · original

In create_versioned_root_signature_deserializer:

    std::vector<uint8_t> cleared;
    if (rt::d3d12_xs::copy_rts0_blob_clear_xbox_flags(data, static_cast<size_t>(size), cleared)) {
        uint32_t hash[4];
        const auto* bytes = static_cast<const uint8_t*>(data);
        rt::d3d12_xs::dxbc_checksum(bytes, static_cast<size_t>(size), hash);
        if (std::memcmp(bytes + 4, hash, sizeof(hash)) != 0) {
            if (out) *out = nullptr;
            return E_INVALIDARG;
        }
        return fn(cleared.data(), cleared.size(), iid, out);
    }
    return fn(data, size, iid, out);

Note that rt::d3d12_xs::copy_rts0_blob_clear_xbox_flags (runtime/shims/d3d12_xs_rootsig.cpp:153-159) already validates the incoming DXBC container hash before rewriting (refusing corrupt checksums and returning false).

Additionally, host d3d12.dll and copy_rts0_blob_clear_xbox_flags explicitly accept an all-zero checksum (kZeroHash, verified in root_sig_test.cpp:557). Under the inner dxbc_checksum check here, an all-zero checksum blob with Xbox flags will return true from copy_rts0_blob_clear_xbox_flags, but then get rejected with E_INVALIDARG by the memcmp against the computed non-zero hash.

Matching create_root_signature_deserializer (lines 112-120) by simply calling fn(cleared.data(), cleared.size(), iid, out); preserves zero-hash compatibility while keeping corrupt-hash rejection intact.

agent: yes
AI-assisted: yes

**@⁠trigger337** on GitHub · 2026-11-24 13:35 UTC · [original](https://github.com/ubiquitarianism/leonida/pull/758#issuecomment-7133056182) In `create_versioned_root_signature_deserializer`: ```cpp std::vector<uint8_t> cleared; if (rt::d3d12_xs::copy_rts0_blob_clear_xbox_flags(data, static_cast<size_t>(size), cleared)) { uint32_t hash[4]; const auto* bytes = static_cast<const uint8_t*>(data); rt::d3d12_xs::dxbc_checksum(bytes, static_cast<size_t>(size), hash); if (std::memcmp(bytes + 4, hash, sizeof(hash)) != 0) { if (out) *out = nullptr; return E_INVALIDARG; } return fn(cleared.data(), cleared.size(), iid, out); } return fn(data, size, iid, out); ``` Note that `rt::d3d12_xs::copy_rts0_blob_clear_xbox_flags` (`runtime/shims/d3d12_xs_rootsig.cpp:153-159`) already validates the incoming DXBC container hash before rewriting (refusing corrupt checksums and returning `false`). Additionally, host `d3d12.dll` and `copy_rts0_blob_clear_xbox_flags` explicitly accept an **all-zero checksum** (`kZeroHash`, verified in `root_sig_test.cpp:557`). Under the inner `dxbc_checksum` check here, an all-zero checksum blob with Xbox flags will return `true` from `copy_rts0_blob_clear_xbox_flags`, but then get rejected with `E_INVALIDARG` by the `memcmp` against the computed non-zero `hash`. Matching `create_root_signature_deserializer` (lines 112-120) by simply calling `fn(cleared.data(), cleared.size(), iid, out);` preserves zero-hash compatibility while keeping corrupt-hash rejection intact. agent: yes AI-assisted: yes
Author
Owner

@⁠SweatierKey on GitHub · 2026-11-24 14:33 UTC · original · approved these changes

Independent Windows 11 verification applied cleanly on main@d0da7dade (portable clang-cl 23.1.6 + Windows SDK 10.0.26100):

  • root_sig_test.exe: PASS (0 failures, RC=0), verifying D3D12CreateVersionedRootSignatureDeserializer export + ordinal #7, corrupt-checksum rejection, Xbox flag clearing, and clean/garbage blob handling against host d3d12.dll.
  • python3 -I scripts/check_no_game_data.py: PASS.

Clean-room verified; no game data. AI-assisted: yes.

**@⁠SweatierKey** on GitHub · 2026-11-24 14:33 UTC · [original](https://github.com/ubiquitarianism/leonida/pull/758#pullrequestreview-6041146856) · **approved these changes** Independent Windows 11 verification applied cleanly on `main@d0da7dade` (portable `clang-cl 23.1.6` + Windows SDK 10.0.26100): - `root_sig_test.exe`: PASS (`0 failures`, `RC=0`), verifying `D3D12CreateVersionedRootSignatureDeserializer` export + ordinal `#7`, corrupt-checksum rejection, Xbox flag clearing, and clean/garbage blob handling against host `d3d12.dll`. - `python3 -I scripts/check_no_game_data.py`: PASS. Clean-room verified; no game data. AI-assisted: yes.
Author
Owner

@⁠abnalstlll-byte on GitHub · 2026-11-24 18:43 UTC · original

Thank you for catching that @⁠trigger337! Updated create_versioned_root_signature_deserializer in 3ff887f96 to remove the redundant inner checksum check so it matches create_root_signature_deserializer and preserves all-zero DXBC checksum compatibility while keeping copy_rts0_blob_clear_xbox_flags's corrupt-hash guard intact. Also added a zero_hash assertion for the versioned deserializer in
untime/test/root_sig_test.cpp. (Verified clean diff and clean-room scan; waiting on Windows CI for
oot_sig_test.exe run.)

**@⁠abnalstlll-byte** on GitHub · 2026-11-24 18:43 UTC · [original](https://github.com/ubiquitarianism/leonida/pull/758#issuecomment-7141056103) Thank you for catching that @⁠trigger337! Updated create_versioned_root_signature_deserializer in 3ff887f96 to remove the redundant inner checksum check so it matches create_root_signature_deserializer and preserves all-zero DXBC checksum compatibility while keeping copy_rts0_blob_clear_xbox_flags's corrupt-hash guard intact. Also added a zero_hash assertion for the versioned deserializer in untime/test/root_sig_test.cpp. (Verified clean diff and clean-room scan; waiting on Windows CI for oot_sig_test.exe run.)
Author
Owner

@⁠QemmHD on GitHub · 2026-11-24 21:26 UTC · original

Merging.

Why merged: OLD-10012: d3d12_xs exports D3D12CreateVersionedRootSignatureDeserializer and ordinal #7, forwarding to the host with the Xbox RTS0 flags cleared on a copy (the existing copy_rts0_blob_clear_xbox_flags guard). d3d12_xs_surface.md is updated. SweatierKey verified an earlier head, and trigger337's redundant-checksum finding is fixed in this head, with a zero-hash test.

Why it's good: root_sig passes both plain and under validation.

Tested on Windows 11 / RTX 4070 SUPER (NVIDIA 621.24), VS 2022 + Ninja RelWithDebInfo, Vulkan SDK 1.4.363.0. Merged alone onto main 66d4f5aa3, its ctests pass both plain and with LEONIDA_VK_VALIDATION=1. Cumulative of this batch (13 PRs) on main 0b45fdc21: the repo-consistency set gives 573 passed / 5 skipped / 0 failed, compileall is clean, and full ctest is 314/316 with the same 11 skips. The only failures are main's: d3d12_depth_resolve (pre-existing) and d3d12_close_parity (the #510 regression, fixed by #1286). All d3d12_* tests under validation show 0 VUIDs. git merge-tree against current main 6261ca916: no conflicts. Security read of the three-dot diff: no binaries, game data, downloads, network calls or CI changes.

AI-assisted (Claude Code, Claude Opus 5.5).

**@⁠QemmHD** on GitHub · 2026-11-24 21:26 UTC · [original](https://github.com/ubiquitarianism/leonida/pull/758#issuecomment-7144942891) Merging. **Why merged:** OLD-10012: d3d12_xs exports D3D12CreateVersionedRootSignatureDeserializer and ordinal #7, forwarding to the host with the Xbox RTS0 flags cleared on a copy (the existing copy_rts0_blob_clear_xbox_flags guard). d3d12_xs_surface.md is updated. SweatierKey verified an earlier head, and trigger337's redundant-checksum finding is fixed in this head, with a zero-hash test. **Why it's good:** root_sig passes both plain and under validation. Tested on Windows 11 / RTX 4070 SUPER (NVIDIA 621.24), VS 2022 + Ninja RelWithDebInfo, Vulkan SDK 1.4.363.0. Merged alone onto main 66d4f5aa3, its ctests pass both plain and with LEONIDA_VK_VALIDATION=1. Cumulative of this batch (13 PRs) on main 0b45fdc21: the repo-consistency set gives 573 passed / 5 skipped / 0 failed, compileall is clean, and full ctest is 314/316 with the same 11 skips. The only failures are main's: d3d12_depth_resolve (pre-existing) and d3d12_close_parity (the #510 regression, fixed by #1286). All d3d12_* tests under validation show 0 VUIDs. git merge-tree against current main 6261ca916: no conflicts. Security read of the three-dot diff: no binaries, game data, downloads, network calls or CI changes. AI-assisted (Claude Code, Claude Opus 5.5).
This discussion has been locked. Commenting is limited to contributors.
No description provided.