Commit Graph

13 Commits

Author SHA1 Message Date
a2de554e56 Merge pull request #1353 from robot00f/fix/rootsig-heap-flags
Merging.

**Why merged:** on Windows 10, the in-box `d3d12.dll` refuses root-signature flags `0xC00` (heap directly indexed) in its serializer, so the title is left with a null program and stops about 15 s in (`exe+0xb5a5f8`, a read of `0x68`); testers on Windows 10 hit this every boot. This retries only after the host has refused, and only when `0xC00` is in the description. It covers both the versioned and the legacy `D3D12SerializeRootSignature`, patches the flags back into `RTS0` after 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 `0xC00` and 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 as `0xc01` through the host deserializer; hardware `CreateRootSignature` succeeds; 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 with `LEONIDA_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).
2026-11-24 21:35:06 -05:00
a330747f23 d3d12_xs: keep the heap-directly-indexed flags on a host that refuses to serialize them 2026-11-24 19:16:06 -03:00
3ff887f962 d3d12_xs: preserve all-zero DXBC checksum compatibility in versioned deserializer 2026-11-24 21:43:04 +03:00
a5bb4b9b8c feat: d3d12_xs exports D3D12CreateVersionedRootSignatureDeserializer, clearing the Xbox RTS0 flags
Upstream PR #8814
2026-11-24 16:31:56 +03:00
b95925cbfc d3d12_xs: verify DXBC total_size and incoming checksum before re-signing RTS0 blobs 2026-11-23 20:51:51 +01:00
0544ba9a21 d3d12_xs: rehash the RTS0 blob after clearing the Xbox flag byte
The host root-signature deserializer checks the DXBC container hash, not
the 0x03000000 flag byte: it accepts a flagged blob with a valid hash and
rejects one with a stale hash. The shim cleared the byte in a copy and kept
the old hash, so it turned blobs the host accepts into E_INVALIDARG. It now
recomputes the hash (DXBC's MD5 variant, as vkd3d and Wine) after clearing.
2026-11-22 13:30:09 +05:30
694ae035ad tests: D3D12 tests skip without WARP and on host-dependent serializer checks
device_proxy and d3d12_xs_root_signature need a WARP adapter, which
Wine doesn't have: without one they exit 77, which CTest reads as a
skip (SKIP_RETURN_CODE). A missing DXGI factory still fails.

root_sig_test checked that the host serializer rejects the Xbox flag
byte. Microsoft's d3d12.dll does; Wine's (vkd3d) doesn't validate it.
That is a property of the host, not of the shim, so a host that accepts
it is reported as a skip, as the deserializer check already does.
2026-11-22 03:46:44 +00:00
bd7e53f43a Runtime: serialize root signature 1.2 as 1.1 on runtimes that stop at 1.1 (WIN10-ROOTSIG)
The in-box d3d12.dll of Windows 10 (and Windows 11 23H2, #361) serializes
root signatures only up to 1.1: on Windows 10 it rejects even an empty 1.2
description with E_INVALIDARG (#528). #361 made the tests skip there, but the
d3d12_xs serializer still forwarded 1.2 descriptions unchanged, so every 1.2
root signature from the package DLLs or the game failed on those hosts.

- d3d12_xs_rootsig: downgrade_root_signature_1_2_to_1_1 rewrites a 1.2
  description whose static samplers all have Flags == 0 as the same root
  signature in 1.1 (1.2 differs only in D3D12_STATIC_SAMPLER_DESC1::Flags).
- d3d12_xs: probe the host once with an empty 1.2 description; where it
  stops at 1.1, serialize 1.2 as 1.1, or refuse one with sampler flags
  with a log line.
- root_sig_test: the registered shim's 1.2 checks run on every runtime again;
  new checks cover the rewrite field by field, through the registered shim
  and back through the host deserializer, and the refusal.
- root_signature_oracle_test: its 1.2 cases use sampler flags, which have no
  1.1 form, so they print SKIP where the host can't serialize 1.2.
- docs/d3d12_vulkan.md: the measurement and the rule.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-21 17:01:11 -08:00
86bbb87fcc Runtime: make the deserializer host-check robust to runtime behaviour
The host deserializer rejects an Xbox-high-byte blob on newer runtimes but
accepts it (keeping the high byte) on older ones such as Windows 11 23H2, so
"host deserializer rejects the Xbox high byte" failed there. Replace it with a
check that holds either way: if the host accepts, it must keep the high byte
(which is the bug the shim fixes); if it rejects, print that instead.

AI-assisted (Cline).
2026-11-22 00:44:27 +01:00
5f2456327b Runtime: skip the 1.2 serializer checks when the host runtime lacks 1.2
Older in-box D3D12 runtimes (e.g. Windows 11 23H2) refuse root signature 1.2
entirely, so root_sig_test's 1.2 serializer checks fail there even though the
flag clearing is correct. Gate the serializer-dependent 1.2 checks on
CheckFeatureSupport(D3D12_FEATURE_ROOT_SIGNATURE) >= 1.2, printing SKIP
otherwise. The byte-level helper checks never touch the serializer and stay
unconditional.

AI-assisted (Cline).
2026-11-22 00:42:08 +01:00
421207afdc Runtime: clear the Xbox flag high byte in the d3d12_xs deserializer
The d3d12_xs shim masked 0x03000000 on a copy before the host serializer but
forwarded D3D12CreateRootSignatureDeserializer blobs unchanged. The host
deserializer rejects a blob whose RTS0 flags carry that high byte (measured
E_INVALIDARG), and docs/d3d12_vulkan.md says the flags "must be masked on a
copy before the host serializer/deserializer".

copy_rts0_blob_clear_xbox_flags walks the DXBC chunk table to the RTS0 chunk,
clears bits 24-31 of its flags on a copy, and the deserializer forwards that
copy when a rewrite is needed. root_sig_test adds test_deserializer: it
tampers a serialized blob with 0x03000000, checks the host rejects it, and
checks the registered shim deserializer clears it and returns flags 0.

AI-assisted (Cline).
2026-11-22 00:36:18 +01:00
e0e9b901ff Runtime: test the 1.2 root-signature Xbox flag high byte clearing
root_sig_test only exercised the high byte clearing for 1.0 and 1.1. Add the
1.2 case (Desc_1_2 is D3D12_ROOT_SIGNATURE_DESC2, whose static samplers are
D3D12_STATIC_SAMPLER_DESC1) so the shim's 1.2 path is covered, and extend
test_registered_shim to prove the registered d3d12_xs serializer clears the
byte for 1.2 end-to-end.

AI-assisted (Cline).
2026-11-22 00:26:50 +01:00
34d2e63c65 Runtime: match the measured Xbox xmem/d3d12_xs ABI
- xmem: XMemVirtualQuery(process, address, out64) fills the known MEMORY_BASIC_INFORMATION prefix and zeroes the rest; the working-set size goes at +8 with a TRUE return; allocator alignment and size-0 behaviour are documented.
- d3d12_xs: copy root-signature descriptors and clear the Xbox high flag byte (0x03000000) before forwarding to the PC serializer; add the legacy serializer; keep the deserializer.
- d3d12_xs: add D3D12XboxCreateDevice, create a PC device and log the 24-word params block. The Xbox ABI proxy is not implemented; measured slot overrides are documented as TODO and logged at runtime.
- test: root_sig_test serializes synthetic flags=0x03000000 descriptors through the PC d3d12.dll, checks the untouched copy is rejected and the cleared copy is accepted, and exercises the registered shim.

Clean-room: implemented from an ABI-facts spec derived from public write-ups; no source from americas-recomp or AnyPS5 was read or copied.
2026-11-21 17:23:05 +00:00