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

Manually merged
github merged 5 commits from gh-pr/677/head into gh-pr/677/base 2026-11-26 09:15:49 +00:00
Owner

@⁠aslan2142 on GitHub · 2026-11-24 11:41 UTC · original
aslan2142:root-sig-flag-mask → main · +475 −1 · 3 files · 5 commits · merged 2026-11-25 22:58 UTC

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

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 21625bca8c; 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** on GitHub · 2026-11-24 11:41 UTC · [original](https://github.com/ubiquitarianism/leonida/pull/677) `aslan2142:root-sig-flag-mask` → `main` · +475 −1 · 3 files · 5 commits · merged 2026-11-25 22:58 UTC Claimed in the coordination issue as: OLD-7234 https://git.gtahub.st/github/ubiquitarianism--leonida/issues/14 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 21625bca8c675c62f9dbffc318ce6a59d57faf31; 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_assert`s 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 - [x] Based on current `main` and merges cleanly (a conflicting pull request is labeled `needs rebase`). - [x] One topic; follow-up work goes in a new pull request. - [x] No game data, keys or decryption (CONTRIBUTING.md), including in logs or reports quoted here. - [x] 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).
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 <[email protected]>
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 <[email protected]>
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 <[email protected]>
Since #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 <[email protected]>
github-bot locked as GitHub sync and limited conversation to collaborators 2026-11-26 09:15:48 +00:00
github manually merged commit ac3aef567b into gh-pr/677/base 2026-11-26 09:15:49 +00:00
Author
Owner

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

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.
**@⁠trigger337** on GitHub · 2026-11-24 11:46 UTC · [original](https://github.com/ubiquitarianism/leonida/pull/677#issuecomment-7130520967) 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.
Author
Owner

@⁠lixonik on GitHub · 2026-11-24 12:09 UTC · original · reviewed

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.

**@⁠lixonik** on GitHub · 2026-11-24 12:09 UTC · [original](https://github.com/ubiquitarianism/leonida/pull/677#pullrequestreview-6038925390) · **reviewed** 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.
Author
Owner

@⁠aslan2142 on GitHub · 2026-11-24 19:30 UTC · original

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

  • Agreed on the merge order. With #683, a 1.0/1.1 description carrying CBV_SRV_UAV_HEAP_DIRECTLY_INDEXED (0x400) or SAMPLER_HEAP_DIRECTLY_INDEXED (0x800) is serialized by the shim on a host that refuses it, on purpose, so "the shim refuses what the host refuses" no longer holds for those two bits.
  • I'm leaving the test as it is here. main doesn't have #683 yet, and on main the shim does refuse what the host refuses, so a looser check now would test nothing.
  • If #683 lands first, I'll update root_sig_public_flags_test here: for a bit the host refuses, expect the shim to succeed, its RTS0 flags to keep the bit and the container hash to be valid, and keep byte-for-byte parity wherever the host accepts. If this lands first, the same change belongs in #683.
  • The red checks are main's: test_tool_stdout_encoding (fixed on main by #605 and #948) and cs_imgload_tfe / cs_imgload_d16_tfe (issue #31, fixed on main by #892).

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

**@⁠aslan2142** on GitHub · 2026-11-24 19:30 UTC · [original](https://github.com/ubiquitarianism/leonida/pull/677#issuecomment-7142207102) Thanks for the Windows 10 run and for checking it against #683. - Agreed on the merge order. With #683, a 1.0/1.1 description carrying `CBV_SRV_UAV_HEAP_DIRECTLY_INDEXED` (0x400) or `SAMPLER_HEAP_DIRECTLY_INDEXED` (0x800) is serialized by the shim on a host that refuses it, on purpose, so "the shim refuses what the host refuses" no longer holds for those two bits. - I'm leaving the test as it is here. `main` doesn't have #683 yet, and on `main` the shim does refuse what the host refuses, so a looser check now would test nothing. - If #683 lands first, I'll update `root_sig_public_flags_test` here: for a bit the host refuses, expect the shim to succeed, its RTS0 flags to keep the bit and the container hash to be valid, and keep byte-for-byte parity wherever the host accepts. If this lands first, the same change belongs in #683. - The red checks are `main`'s: `test_tool_stdout_encoding` (fixed on `main` by #605 and #948) and `cs_imgload_tfe` / `cs_imgload_d16_tfe` (issue #31, fixed on `main` by #892). AI-assisted (Claude Code, Claude Opus 5.5).
Author
Owner

@⁠lixonik on GitHub · 2026-11-25 05:35 UTC · original · reviewed

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.

**@⁠lixonik** on GitHub · 2026-11-25 05:35 UTC · [original](https://github.com/ubiquitarianism/leonida/pull/677#pullrequestreview-6052357477) · **reviewed** 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.
Author
Owner

@⁠aslan2142 on GitHub · 2026-11-25 22:58 UTC · original

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

  • Review point (#1353's heap-indexed fallback): where the host refuses CBV_SRV_UAV_HEAP_DIRECTLY_INDEXED or SAMPLER_HEAP_DIRECTLY_INDEXED but takes the description without them, the three host-parity checks now expect the shim to return S_OK. Its blob must match the host's blob without those bits byte for byte, except for the RTS0 flags dword, which holds the full flags, and a valid container hash. Byte-for-byte parity stays wherever the host accepts, and the shim must still refuse anything else the host refuses (ac3aef567). The doc bullet says the same.
  • Merge fix: main added d3d12_xs_pso_stream.cpp to root_sig_test. This test lists the same shim files and now links it too (5e85304b1).
  • Tested: the full Windows suite under Wine on main 5fab93967 with all nine of these runtime PRs merged together (#634, #643, #684, #657, #677, #638, #710, #688, #671), on llvmpipe and the gfx1036 iGPU (RADV): no test went from pass to fail. root_sig_public_flags passes on both. Wine's d3d12.dll takes the heap flags, so the Windows 10 fallback branch itself was not exercised here.
  • Checked on main 809d1869a + ac3aef567: it merges cleanly; the semantic suite passes (493 files, 6,318 tests, 0 files failed); the 15 docs and writer tests pass; check_no_game_data.py is clean on the 3 changed files.

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

**@⁠aslan2142** on GitHub · 2026-11-25 22:58 UTC · [original](https://github.com/ubiquitarianism/leonida/pull/677#issuecomment-7176998266) Merged: `d3d12_xs` keeps every public root-signature flag through the flag mask, and a test pins it (old upstream PR 7140). - **Review point (#1353's heap-indexed fallback):** where the host refuses `CBV_SRV_UAV_HEAP_DIRECTLY_INDEXED` or `SAMPLER_HEAP_DIRECTLY_INDEXED` but takes the description without them, the three host-parity checks now expect the shim to return `S_OK`. Its blob must match the host's blob without those bits byte for byte, except for the RTS0 flags dword, which holds the full flags, and a valid container hash. Byte-for-byte parity stays wherever the host accepts, and the shim must still refuse anything else the host refuses (`ac3aef567`). The doc bullet says the same. - **Merge fix:** `main` added `d3d12_xs_pso_stream.cpp` to `root_sig_test`. This test lists the same shim files and now links it too (`5e85304b1`). - **Tested:** the full Windows suite under Wine on `main` `5fab93967` with all nine of these runtime PRs merged together (#634, #643, #684, #657, #677, #638, #710, #688, #671), on llvmpipe and the gfx1036 iGPU (RADV): no test went from pass to fail. `root_sig_public_flags` passes on both. Wine's `d3d12.dll` takes the heap flags, so the Windows 10 fallback branch itself was not exercised here. - **Checked on `main` `809d1869a` + `ac3aef567`:** it merges cleanly; the semantic suite passes (493 files, 6,318 tests, 0 files failed); the 15 docs and writer tests pass; `check_no_game_data.py` is clean on the 3 changed files. AI-assisted (Claude Code, Claude Opus 5.5).
This discussion has been locked. Commenting is limited to contributors.
No description provided.