Skip to content

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

Merged
QemmHD merged 2 commits into
ProjectLeonida:mainfrom
abnalstlll-byte:restore/old-10012-versioned-root-sig-deserializer
Nov 24, 2026
Merged

QemmHD merged 2 commits into
ProjectLeonida:mainfrom
abnalstlll-byte:restore/old-10012-versioned-root-sig-deserializer

Conversation

@abnalstlll-byte

Copy link
Copy Markdown
Contributor

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).

… clearing the Xbox RTS0 flags

Upstream PR #8814
@trigger337

Copy link
Copy Markdown
Contributor

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

@SweatierKey SweatierKey left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

@abnalstlll-byte

Copy link
Copy Markdown
Contributor Author

Thank you for catching that @trigger337! Updated create_versioned_root_signature_deserializer in 3ff887f 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.)

@aslan2142 aslan2142 added the missing claim Needs a claim in #14 label Nov 24, 2026
@QemmHD

QemmHD commented Nov 24, 2026

Copy link
Copy Markdown
Collaborator

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 66d4f5a, its ctests pass both plain and with LEONIDA_VK_VALIDATION=1. Cumulative of this batch (13 PRs) on main 0b45fdc: 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 6261ca9: 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
QemmHD merged commit abc0bd8 into ProjectLeonida:main Nov 24, 2026
5 of 6 checks passed
milk4sale added a commit to milk4sale/leonida that referenced this pull request Nov 24, 2026
…rsioned zero-checksum check, asked of Wine's host the same way

main 4a50caf added a check to root_sig_test that the versioned deserializer shim accepts an all-zero-checksum Xbox
blob, next to the legacy check this branch had put behind a question to the host. Both stay. The versioned shim
forwards the same cleared copy to the host's versioned deserializer, and Wine's (wine-staging 11.21) refuses a zero
checksum there too, so the host's versioned deserializer is asked about the cleared copy directly and Wine's refusal,
and only Wine's, skips that check. Off Wine the check runs as ProjectLeonida#758 wrote it.

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

missing claim Needs a claim in #14

Projects

None yet

Development

Successfully merging this pull request may close these issues.

6 participants