d3d12_xs: keep the heap-directly-indexed flags on a host that refuses to serialize them #1353
No reviewers
Labels
No labels
accessibility
bug
documentation
duplicate
enhancement
good first issue
help wanted
invalid
missing claim
needs rebase
question
wontfix
No milestone
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set
Reference
github/ubiquitarianism--leonida!1353
Loading…
Reference in a new issue
No description provided.
Delete branch "gh-pr/1353/head"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
@robot00f on GitHub · 2026-11-24 22:16 UTC · original
robot00f:fix/rootsig-heap-flags→main· +363 −21 · 7 files · 1 commits · merged 2026-11-25 02:35 UTCClaim: #14 (ID
D3D12-SET-HEAPS-BLOB; the deterministicd3d12_set_descriptor_heapsfailure 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.dllof Windows 10 (10.0.19041.4355, this machine) refusesD3D12_ROOT_SIGNATURE_FLAG_CBV_SRV_UAV_HEAP_DIRECTLY_INDEXEDand..._SAMPLER_HEAP_DIRECTLY_INDEXEDinD3D12SerializeVersionedRootSignatureat every descriptor version, withE_INVALIDARGandUnsupported 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 withFlags = 0xc00and creates a root signature. Only the serializer is the problem.Fix
serialize_versioned_keeping_heap_flags/serialize_legacy_keeping_heap_flagsinruntime/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 producedRTS0flags dword and recompute the DXBC container hash (an all-zero hash stays zeroed). The blob is handed back through a smallID3DBlob. 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_signaturedoes 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.d3d12_bundle_test,d3d12_draw_test,device_proxy_test,xs_proxy_mock_testpass;ctest -Ron the three touched tests 3/3.check_no_game_data.py-> exit 0;tests/test_docs_links.pyandtests/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
@Snooozs on GitHub · 2026-11-25 01:00 UTC · original
Retail confirmation on Windows 10, counts only. Windows 10 Pro 22H2 (19045), Ryzen 7 7700, 32 GB RAM, RTX 5060 Ti 16 GB (NVIDIA 621.01), VS 2022 RelWithDebInfo, own 1.0.2.1 copy. Base: #984
273b3bdf9+ #968f2268abea+ the CPU-alias change from the #968 comments; shaders translated with that tree;scripts/windows-boot/boot.ps1defaults.runtime/shimschange0xc0000005atexe+0xb5a5f8(read of0x68), two threadsPresentXok / failedOne run each, same overlay and pipeline cache folder, so the second run also had the cache the first one left. The only code difference is this PR applied to
d3d12_xs.cppandd3d12_xs_rootsig.*(it applies cleanly to #984). So on Windows 10 that stop is the refused0xC00flags, as suspected in #14.While reading it:
RewrittenBlobcounts references with a plainULONG;std::atomicorInterlockedIncrementwould match the thread-safety a host blob has. I have not seen it matter. I did not run the PR's own tests.AI-assisted (Claude Code, Claude Opus 5.5).
@QemmHD on GitHub · 2026-11-25 02:35 UTC · original · edited 2026-11-25 04:27 UTC
Merging.
Why merged: on Windows 10, the in-box
d3d12.dllrefuses root-signature flags0xC00(heap directly indexed) in its serializer, so the title is left with a null program and stops about 15 s in (a read of0x68); testers on Windows 10 hit this every boot. This retries only after the host has refused, and only when0xC00is in the description. It covers both the versioned and the legacyD3D12SerializeRootSignature, patches the flags back intoRTS0after checking the container hash (failing closed), and it's claimed as D3D12-SET-HEAPS-BLOB. It's the better of the two PRs for this. #683 does the same for the versioned path only, by probing each bit through a static that captures the first serializer pointer.Why it's good: on this Windows 11 host the real serializer accepts the flags, so I also checked the refusal path independently with a harness: a fake serializer that refuses
0xC00and forwards everything else to the real Windows 11 serializer, on the RTX 4070 SUPER's hardware D3D12 device. #1353's wrappers (versioned 1.0 and 1.1, legacy 1.0) return S_OK after exactly one refusal; the flags read back as0xc01through the host deserializer; hardwareCreateRootSignaturesucceeds; an unrelated failure is passed through; and a host that accepts the flags gets a byte-identical blob, 16/16. root_sig, root_signature, root_signature_oracle, d3d12_set_descriptor_heaps, d3d12_xs_root_signature, d3d12_draw, bundle, device_proxy and xs_proxy_mock* pass 14/14, both plain and withLEONIDA_VK_VALIDATION=1. The repository-consistency set gives 578/5/0. It merges cleanly onto main after #984 (neither #984 nor DadaCap's prototype carries this fix). Minor note: it returns S_FALSE ("flags lost") if a blob can't be patched, which is fine.AI-assisted (Claude Code, Claude Opus 5.5).