Skip to content

OLD-7234: restore old upstream PR 7234 - d3d12_xs: pin that the root-signature flag mask keeps every public flag (old upstream PR 7140) - #677

Merged
aslan2142 merged 5 commits into
ProjectLeonida:mainfrom
aslan2142:root-sig-flag-mask
Nov 25, 2026
Merged

aslan2142 merged 5 commits into
ProjectLeonida:mainfrom
aslan2142:root-sig-flag-mask

Conversation

@aslan2142

Copy link
Copy Markdown
Collaborator

Claimed in the coordination issue as: OLD-7234 #14 (comment)

Restoration of my original pull request, old upstream PR 7234 in ItsNotRexed/Leonida, which was closed unmerged when that repository went private on 2026-11-23 (old numbers link nowhere now). Rebased onto main at 21625bc; the only changes are that the old PR references in comments and commit messages are now plain text ("old upstream PR 7140").

What and why

  • This is a guard, not a bug fix. It changes no runtime code and pins behaviour that is already correct on main.
  • The d3d12_xs shims clear bits 24-31 of a root signature's flags (kXboxRootSignatureFlagHighByte, runtime/shims/d3d12_xs_rootsig.h) on every descriptor and RTS0 blob, whatever built it.
  • Old upstream PR 7140 asked whether that mask should depend on where the blob came from. The retail executable's root signatures do not carry 0x03000000: its direct call passes a 1.1 description with Flags = 0x80, and its decoder reads Flags as a 16-bit value.
  • Every public D3D12_ROOT_SIGNATURE_FLAGS value is in bits 0-11, so the mask cannot touch one, and it can stay unconditional.
  • docs/d3d12_vulkan.md answers the question the doc still left open ("whether its root signatures carry them is open") and says why the mask stays as it is.
  • The new root_sig_public_flags_test (Windows only, next to root_sig_test) checks:
    • the 1.0, 1.1, 1.2 and legacy descriptor helpers keep all 65536 flag values in [0, 0xFFFF];
    • an RTS0 blob with such flags is never rewritten;
    • the registered serializer shims give the host's blob byte for byte for each public flag, 0x80 and all twelve;
    • the deserializer shim returns the host's flags;
    • a blob with 0x03000080 comes back as 0x80, with a valid container hash and no other byte changed;
    • static_asserts that no public flag lies in the cleared byte.
  • On a host that serializes only up to 1.1, the shim rewrites 1.2 descriptions as 1.1. The test allows "host refuses, shim succeeds" only on such a host, which it probes once with an empty 1.2 description.

Tested

Built and run on Linux. The Windows build used clang targeting x86_64-w64-mingw32 and ran under Wine 11.22. MSVC (/W4 /permissive-) is left to CI.

  • root_sig_public_flags_test built against main's code: 28 pass, 0 fail, as expected for a guard.
  • This branch: 28 pass, 0 fail.
  • A mask that also clears 0x80, in a scratch copy: 12 pass, 16 fail. So the test catches a mask that eats a public flag.
  • root_sig_test: 56 pass, 1 fail, the same on main and on this branch. The failure is "shim deserializer accepts an all-zero-checksum Xbox blob". Wine's host deserializer causes it, and this pull request does not touch it.
  • git diff --check and scripts/check_no_game_data.py on the changed files: clean.

GPUs tested: n/a (the test needs no GPU)

AI-assisted: yes

Checklist

  • Based on current main and merges cleanly (a conflicting pull request is labeled needs rebase).
  • One topic; follow-up work goes in a new pull request.
  • No game data, keys or decryption (CONTRIBUTING.md), including in logs or reports quoted here.
  • A new translator rule is in the contract table of docs/design.md, with how it was confirmed. (n/a: no translator change)

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

aslan2142 and others added 2 commits November 24, 2026 06:39
…ag (old upstream PR 7140)

The shims clear bits 24-31 of a root signature's flags on every descriptor and RTS0 blob. Old upstream PR 7140 asks
to make that conditional on the blob's origin, since the retail executable's root signatures carry no 0x03000000
(one 1.1 description with Flags 0x80, and a decoder whose Flags is a 16-bit read). Every public
D3D12_ROOT_SIGNATURE_FLAGS value is in bits 0-11, so the mask can't change those descriptors and no behaviour change
is needed.

root_sig_public_flags_test pins it:
- the descriptor helpers (1.0, 1.1, 1.2, legacy) keep all 65536 flag values in [0, 0xFFFF], and an RTS0 blob with
  such flags is not rewritten;
- the registered serializer shims give the host's blob byte for byte for each public flag, 0x80 and all twelve, and
  the deserializer shim returns the host's flags;
- a blob with 0x03000080 comes back as 0x80 with a valid container hash and no other byte changed;
- static_asserts that no public flag is in kXboxRootSignatureFlagHighByte.

docs/d3d12_vulkan.md: the executable's answer to the open question, and why the mask stays unconditional.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…nly on a host without 1.2

The allowance is for runtimes that serialize only up to 1.1, where the shim rewrites 1.2 as 1.1. On a host that
serializes 1.2 itself it hid a real difference: under a mask that also clears 0x80, the host refuses all twelve
flags and the shim accepts 0xF7F. The host is now probed once with an empty 1.2 description, and the allowance
applies only when it refuses that too (review of old upstream PR 7234).

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@trigger337

Copy link
Copy Markdown
Contributor

agent: yes
AI-assisted: yes

Code review and repository integrity check:

  1. Specification & Implementation:
    • Verified that kXboxRootSignatureFlagHighByte in runtime/shims/d3d12_xs_rootsig.h exclusively targets bits 24-31 (0xFF000000). All standard D3D12_ROOT_SIGNATURE_FLAGS span bits 0-11 (0x00000800 max), ensuring standard flags remain unaltered across descriptor conversion and RTS0 serialization.
    • Clean doc update to docs/d3d12_vulkan.md resolving the open question on retail root signature bit patterns.
  2. Repository Integrity:
    • scripts/check_no_game_data.py: clean.
    • tests/test_text_write_line_endings.py: 3/3 tests passed.
    • tests/test_docs_links.py: 16/16 passed.

@lixonik lixonik 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 native Windows 10 run at 3769fd6b: root_sig_public_flags_test builds with MSVC and passes with zero failures.

I also built that exact test against the shim from #683 at d1029668, which is a useful merge-order check. The combined run has two failures: the host-parity assertion for versioned 1.0 and for 1.1. Each sees two different results because #683 intentionally accepts the heap-indexed cases that the host serializer refuses. The separate checks that the flags round-trip and that the input description is unchanged still pass.

Whichever lands second will need to update that test expectation for the intentional Windows 10 fallback. The flag preservation and byte-for-byte parity where the host accepts the description can still be checked.

AI-assisted testing on synthetic root signatures from full Git worktrees. No GPU required.

@aslan2142

Copy link
Copy Markdown
Collaborator Author

Thanks for the Windows 10 run and for checking it against #683.

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

@lixonik lixonik 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.

Follow-up now that #1353 has merged. I rebuilt this PR's root_sig_public_flags_test.cpp at 3769fd6b against the shim sources at the #1353 merge commit a2de554e on native Windows 10 with MSVC. The test exited 1 with three failing host-parity checks: versioned 1.0, versioned 1.1, and the legacy serializer. The legacy check is now affected as well because #1353 covers that entry point. The flag-preservation and Xbox-bit masking checks still passed.

Please account for the intentional heap-indexed fallback in those three assertions while keeping the byte-for-byte checks for the cases the host accepts. AI-assisted, CPU-only synthetic test.

aslan2142 and others added 3 commits November 25, 2026 16:40
…_test does on main

main's d3d12_xs.cpp now calls into d3d12_xs_pso_stream.cpp, and main
added that file to root_sig_test's sources; this target lists the same
shim files and needs it too.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…e host refuses those flags

Since ProjectLeonida#1353 the shims' serializers (versioned and legacy) serialize a
description the host refuses for CBV_SRV_UAV_HEAP_DIRECTLY_INDEXED or
SAMPLER_HEAP_DIRECTLY_INDEXED (Windows 10's in-box d3d12.dll): they call
the host again without the two bits and put them back into RTS0. The
three host-parity checks failed on Windows 10 for that, as reported in
review.

Where the host refuses such flags but takes the description without
them, the shim now has to return S_OK with that blob byte for byte,
except the RTS0 flags dword, which must hold all the flags, and a valid
container hash. Byte-for-byte parity stays wherever the host accepts,
and the shim still has to refuse whatever else the host refuses. The doc
bullet says the same.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@aslan2142

Copy link
Copy Markdown
Collaborator Author

Merged: d3d12_xs keeps every public root-signature flag through the flag mask, and a test pins it (old upstream PR 7140).

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants