[PR #1353] [MERGED] d3d12_xs: keep the heap-directly-indexed flags on a host that refuses to serialize them #1383

Closed
opened 2026-11-26 20:21:03 +01:00 by 4ld0 · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/ubiquitarianism/leonida/pull/1353
Author: @robot00f
Created: 11/24/2026
Status: ✅ Merged
Merged: 11/25/2026
Merged by: @QemmHD

Base: main ← Head: fix/rootsig-heap-flags


📝 Commits (1)

  • a330747 d3d12_xs: keep the heap-directly-indexed flags on a host that refuses to serialize them

📊 Changes

7 files changed (+363 additions, -21 deletions)

View changed files

📝 docs/d3d12_vulkan.md (+11 -0)
📝 runtime/shims/d3d12_xs.cpp (+6 -4)
📝 runtime/shims/d3d12_xs_rootsig.cpp (+180 -16)
📝 runtime/shims/d3d12_xs_rootsig.h (+27 -0)
📝 runtime/test/d3d12_test_shaders.h (+50 -1)
📝 runtime/test/d3d12_xs_root_signature_test.cpp (+58 -0)
📝 runtime/test/root_sig_test.cpp (+31 -0)

📄 Description

Claim: https://github.com/ubiquitarianism/leonida/issues/14#issuecomment-7145813750 (ID D3D12-SET-HEAPS-BLOB; the deterministic d3d12_set_descriptor_heaps failure in #1150)

The test failed at CHECK(!blob.empty()). The empty blob is not the shim dropping anything: it never reaches the shim, and the test was not wrong either.

Cause

The in-box d3d12.dll of Windows 10 (10.0.19041.4355, this machine) refuses D3D12_ROOT_SIGNATURE_FLAG_CBV_SRV_UAV_HEAP_DIRECTLY_INDEXED and ..._SAMPLER_HEAP_DIRECTLY_INDEXED in D3D12SerializeVersionedRootSignature at every descriptor version, with E_INVALIDARG and Unsupported bit-flag set (root signature flags c00). Versions 1.0 and 1.1 both fail; without the bits the same description serializes. That is wider than one test: the 1.0.2.1 shaders set either bit in 18,066 cases (docs/d3d12_vulkan.md), so any title root signature that indexes a heap directly could not be created at all on such a host.

Measured, so the fix is possible: the same host's deserializer, and a WARP device, accept a blob that carries 0xC00 -- a blob serialized without the bits, patched back in and re-hashed deserializes with Flags = 0xc00 and creates a root signature. Only the serializer is the problem.

Fix

serialize_versioned_keeping_heap_flags / serialize_legacy_keeping_heap_flags in runtime/shims/d3d12_xs_rootsig.cpp: call the host as before; if it fails and the description carries either bit, call again with the bits cleared, then put them back into the produced RTS0 flags dword and recompute the DXBC container hash (an all-zero hash stays zeroed). The blob is handed back through a small ID3DBlob. A host that takes the flags itself (Windows 11) still gets one call and its own blob unchanged; the version-1.2 downgrade path uses the same wrapper.

d3d12test::serialize_root_signature does the same retry for tests that serialize directly (zeroing the hash, which the host accepts and the device here does not read), so the failing case now builds a blob everywhere.

Tested

  • d3d12_set_descriptor_heaps: CHECK failed: !blob.empty() 3/3 before, passes 3/3 after.
  • d3d12_xs_root_signature_test, both versions through the real shim: the host refuses (0x80070057), the shim retries, the flags are back through the host deserializer, the shim deserializer and a WARP root signature. Passes 3/3.
  • root_sig_test: new legacy-entry-point case; the flags come back in the RTS0 chunk. All cases pass.
  • No regression: d3d12_bundle_test, d3d12_draw_test, device_proxy_test, xs_proxy_mock_test pass; ctest -R on the three touched tests 3/3.
  • check_no_game_data.py -> exit 0; tests/test_docs_links.py and tests/test_docs_table_rows.py -> OK.

Not tested: a host that natively accepts the flags (no Windows 11 here); the test asserts byte equality with the host blob in that branch. The 1.0.2.1 root signatures themselves were not run (no game files).

GPUs tested: NVIDIA GPU (Pascal class, 4 GB), driver 582.28, Windows 10 19045 (WARP for the root-signature checks).

AI-assisted: yes (OpenCode, DeepSeek V4.1 Flash)

Checklist

  • Based on current main and merges cleanly.
  • One topic.
  • No game data, keys or decryption (CONTRIBUTING.md).
  • A new translator rule is in the contract table of docs/design.md. (No translator change; the measured host behaviour is in docs/d3d12_vulkan.md.)

🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.

## 📋 Pull Request Information **Original PR:** https://github.com/ubiquitarianism/leonida/pull/1353 **Author:** [@robot00f](https://github.com/robot00f) **Created:** 11/24/2026 **Status:** ✅ Merged **Merged:** 11/25/2026 **Merged by:** [@QemmHD](https://github.com/QemmHD) **Base:** `main` ← **Head:** `fix/rootsig-heap-flags` --- ### 📝 Commits (1) - [`a330747`](https://github.com/ubiquitarianism/leonida/commit/a330747f237b7ce1d2cc82a531ef5d2220ee9c20) d3d12_xs: keep the heap-directly-indexed flags on a host that refuses to serialize them ### 📊 Changes **7 files changed** (+363 additions, -21 deletions) <details> <summary>View changed files</summary> 📝 `docs/d3d12_vulkan.md` (+11 -0) 📝 `runtime/shims/d3d12_xs.cpp` (+6 -4) 📝 `runtime/shims/d3d12_xs_rootsig.cpp` (+180 -16) 📝 `runtime/shims/d3d12_xs_rootsig.h` (+27 -0) 📝 `runtime/test/d3d12_test_shaders.h` (+50 -1) 📝 `runtime/test/d3d12_xs_root_signature_test.cpp` (+58 -0) 📝 `runtime/test/root_sig_test.cpp` (+31 -0) </details> ### 📄 Description Claim: https://github.com/ubiquitarianism/leonida/issues/14#issuecomment-7145813750 (ID `D3D12-SET-HEAPS-BLOB`; the deterministic `d3d12_set_descriptor_heaps` failure in #1150) The test failed at `CHECK(!blob.empty())`. The empty blob is not the shim dropping anything: it never reaches the shim, and the test was not wrong either. ### Cause The in-box `d3d12.dll` of Windows 10 (10.0.19041.4355, this machine) refuses `D3D12_ROOT_SIGNATURE_FLAG_CBV_SRV_UAV_HEAP_DIRECTLY_INDEXED` and `..._SAMPLER_HEAP_DIRECTLY_INDEXED` in `D3D12SerializeVersionedRootSignature` at every descriptor version, with `E_INVALIDARG` and `Unsupported bit-flag set (root signature flags c00)`. Versions 1.0 and 1.1 both fail; without the bits the same description serializes. That is wider than one test: the 1.0.2.1 shaders set either bit in 18,066 cases (docs/d3d12_vulkan.md), so any title root signature that indexes a heap directly could not be created at all on such a host. Measured, so the fix is possible: the same host's *deserializer*, and a WARP device, accept a blob that carries `0xC00` -- a blob serialized without the bits, patched back in and re-hashed deserializes with `Flags = 0xc00` and creates a root signature. Only the serializer is the problem. ### Fix `serialize_versioned_keeping_heap_flags` / `serialize_legacy_keeping_heap_flags` in `runtime/shims/d3d12_xs_rootsig.cpp`: call the host as before; if it fails and the description carries either bit, call again with the bits cleared, then put them back into the produced `RTS0` flags dword and recompute the DXBC container hash (an all-zero hash stays zeroed). The blob is handed back through a small `ID3DBlob`. A host that takes the flags itself (Windows 11) still gets one call and its own blob unchanged; the version-1.2 downgrade path uses the same wrapper. `d3d12test::serialize_root_signature` does the same retry for tests that serialize directly (zeroing the hash, which the host accepts and the device here does not read), so the failing case now builds a blob everywhere. ### Tested - `d3d12_set_descriptor_heaps`: `CHECK failed: !blob.empty()` 3/3 before, passes 3/3 after. - `d3d12_xs_root_signature_test`, both versions through the real shim: the host refuses (0x80070057), the shim retries, the flags are back through the host deserializer, the shim deserializer and a WARP root signature. Passes 3/3. - `root_sig_test`: new legacy-entry-point case; the flags come back in the RTS0 chunk. All cases pass. - No regression: `d3d12_bundle_test`, `d3d12_draw_test`, `device_proxy_test`, `xs_proxy_mock_test` pass; `ctest -R` on the three touched tests 3/3. - `check_no_game_data.py` -> exit 0; `tests/test_docs_links.py` and `tests/test_docs_table_rows.py` -> OK. Not tested: a host that natively accepts the flags (no Windows 11 here); the test asserts byte equality with the host blob in that branch. The 1.0.2.1 root signatures themselves were not run (no game files). GPUs tested: NVIDIA GPU (Pascal class, 4 GB), driver 582.28, Windows 10 19045 (WARP for the root-signature checks). AI-assisted: yes (OpenCode, DeepSeek V4.1 Flash) ### Checklist - [x] Based on current main and merges cleanly. - [x] One topic. - [x] No game data, keys or decryption (CONTRIBUTING.md). - [ ] A new translator rule is in the contract table of docs/design.md. (No translator change; the measured host behaviour is in docs/d3d12_vulkan.md.) --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
4ld0 2026-11-26 20:21:03 +01:00
Sign in to join this conversation.
No labels
bug
pull-request
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set

Reference
starred/leonida#1383
No description provided.