runtime: add desktop d3d12_xs.dll shim for root-signature imports #346

Merged
alexander-src merged 4 commits from upstream-pr/351 into main 2026-11-22 04:00:03 +00:00
alexander-src commented 2026-11-21 23:05:31 +00:00 (Migrated from github.com)

Imported from R0Y00/Xbox2Windows. Originally posted by alexander-src on 2026-11-21T23:05:31Z.


Change

Adds a desktop d3d12_xs.dll shim (src/d3d12_xs_shim.cpp, src/d3d12_xs_shim.def) exporting the two root-signature functions that remained unresolved across the 16 pre-executable package DLLs after src/xmem_shim.cpp resolved the six xmem.dll edges (docs/experiments.md, "Desktop xmem.dll" and "Six API call sites"):

  • D3D12SerializeVersionedRootSignature: clears only the observed console flag pair (0x03000000) in a local stack copy for D3D_ROOT_SIGNATURE_VERSION_1_0 and D3D_ROOT_SIGNATURE_VERSION_1_1 descriptors before calling desktop d3d12.dll. Unobserved invalid flag bits and unknown versions stay untouched so desktop d3d12.dll still rejects them with E_INVALIDARG.
  • D3D12CreateRootSignatureDeserializer: forwards directly to desktop d3d12.dll, matching the embedded-container and raw-blob deserialization call shape recorded for amd_fidelityfx_upscaler_xbox.dll.
  • .def export aliasing (PublicName=d3d12_xs_*) keeps internal symbols separate from desktop d3d12.lib imports so there is no self-recursion or symbol clash.
  • Adds tests/d3d12_xs_shim_check.cpp (linking d3d12_xs_shim directly via named PE imports, mirroring tests/xmem_shim_check.cpp), four CTest cases (d3d12_xs_shim_exports, d3d12_xs_shim_serialize, d3d12_xs_shim_deserialize, d3d12_xs_shim_warp_root), and documentation in docs/experiments.md.

Verification

Commit 9094856 (Linux host, no Windows SDK / MSVC / D3D12 runtime locally):

  • python3 -B tests/docs_links_check.py -> Checked 10 Markdown files and 69 links.
  • python3 -B tests/bidi_controls_check.py -> Checked 289 tracked source, script and build/CI files: no bidirectional controls.

Windows build and the four CTest scenarios (d3d12_xs_shim_exports, d3d12_xs_shim_serialize, d3d12_xs_shim_deserialize, d3d12_xs_shim_warp_root) could not be run locally on this Linux host and are exercised by the build-and-test Windows CI job.

Evidence and follow-up

  • All fixtures are source-built in this repository (tests/compute.hlsl -> pso_compute_embedded.h / pso_compute_stripped.h, MIT license) and synthetic C++ D3D12_VERSIONED_ROOT_SIGNATURE_DESC descriptors.
  • Negative controls verify:
    • Desktop d3d12.dll rejects 0x01000000, 0x02000000, and 0x03000000 with E_INVALIDARG while d3d12_xs.dll strips only those bits, leaves the caller's struct untouched, preserves valid desktop flags, and matches desktop baseline bytes.
    • d3d12_xs.dll still rejects unobserved flag bits (0x04000000, 0x07000000, 0x80000000), a null descriptor, and an unknown root-signature version (99) with E_INVALIDARG.
    • D3D12CreateRootSignatureDeserializer rejects pso_compute_stripped (no RTS0) and null/zero-length buffers with E_INVALIDARG.
    • d3d12_xs_shim_warp_root creates a WARP ID3D12RootSignature from a 0x03000000-tagged v1.1 descriptor serialized through d3d12_xs.dll and builds a live compute PSO with pso_compute_stripped.
  • Follow-up: this covers only the two pre-executable d3d12_xs.dll imports. A local tools/pe_inventory.py scan alongside both xmem.dll and d3d12_xs.dll can verify 0 unresolved edges across the 16 package DLLs; any further d3d12_xs.dll exports needed by a main executable stay separate work.

Checklist

  • This pull request covers one reviewable behavior.
  • I included the exact command and result for every check I ran.
  • I considered a negative control or failure case for a new fixture.
  • I updated README/docs when a capability or build requirement changed.
  • I did not include game files, dumps, distribution links or secrets.

AI-assisted: yes.

<!-- greyfinch-sync:R0Y00/Xbox2Windows:issue:6535580026 --> Imported from [R0Y00/Xbox2Windows](https://github.com/R0Y00/Xbox2Windows/pull/351). Originally posted by [alexander-src](https://github.com/alexander-src) on 2026-11-21T23:05:31Z. --- ## Change Adds a desktop `d3d12_xs.dll` shim (`src/d3d12_xs_shim.cpp`, `src/d3d12_xs_shim.def`) exporting the two root-signature functions that remained unresolved across the 16 pre-executable package DLLs after `src/xmem_shim.cpp` resolved the six `xmem.dll` edges (`docs/experiments.md`, "Desktop xmem.dll" and "Six API call sites"): - `D3D12SerializeVersionedRootSignature`: clears only the observed console flag pair (`0x03000000`) in a local stack copy for `D3D_ROOT_SIGNATURE_VERSION_1_0` and `D3D_ROOT_SIGNATURE_VERSION_1_1` descriptors before calling desktop `d3d12.dll`. Unobserved invalid flag bits and unknown versions stay untouched so desktop `d3d12.dll` still rejects them with `E_INVALIDARG`. - `D3D12CreateRootSignatureDeserializer`: forwards directly to desktop `d3d12.dll`, matching the embedded-container and raw-blob deserialization call shape recorded for `amd_fidelityfx_upscaler_xbox.dll`. - `.def` export aliasing (`PublicName=d3d12_xs_*`) keeps internal symbols separate from desktop `d3d12.lib` imports so there is no self-recursion or symbol clash. - Adds `tests/d3d12_xs_shim_check.cpp` (linking `d3d12_xs_shim` directly via named PE imports, mirroring `tests/xmem_shim_check.cpp`), four CTest cases (`d3d12_xs_shim_exports`, `d3d12_xs_shim_serialize`, `d3d12_xs_shim_deserialize`, `d3d12_xs_shim_warp_root`), and documentation in `docs/experiments.md`. ## Verification Commit `9094856` (Linux host, no Windows SDK / MSVC / D3D12 runtime locally): - `python3 -B tests/docs_links_check.py` -> `Checked 10 Markdown files and 69 links.` - `python3 -B tests/bidi_controls_check.py` -> `Checked 289 tracked source, script and build/CI files: no bidirectional controls.` Windows build and the four CTest scenarios (`d3d12_xs_shim_exports`, `d3d12_xs_shim_serialize`, `d3d12_xs_shim_deserialize`, `d3d12_xs_shim_warp_root`) could not be run locally on this Linux host and are exercised by the `build-and-test` Windows CI job. ## Evidence and follow-up - All fixtures are source-built in this repository (`tests/compute.hlsl` -> `pso_compute_embedded.h` / `pso_compute_stripped.h`, MIT license) and synthetic C++ `D3D12_VERSIONED_ROOT_SIGNATURE_DESC` descriptors. - Negative controls verify: - Desktop `d3d12.dll` rejects `0x01000000`, `0x02000000`, and `0x03000000` with `E_INVALIDARG` while `d3d12_xs.dll` strips only those bits, leaves the caller's struct untouched, preserves valid desktop flags, and matches desktop baseline bytes. - `d3d12_xs.dll` still rejects unobserved flag bits (`0x04000000`, `0x07000000`, `0x80000000`), a null descriptor, and an unknown root-signature version (`99`) with `E_INVALIDARG`. - `D3D12CreateRootSignatureDeserializer` rejects `pso_compute_stripped` (no `RTS0`) and null/zero-length buffers with `E_INVALIDARG`. - `d3d12_xs_shim_warp_root` creates a WARP `ID3D12RootSignature` from a `0x03000000`-tagged v1.1 descriptor serialized through `d3d12_xs.dll` and builds a live compute PSO with `pso_compute_stripped`. - Follow-up: this covers only the two pre-executable `d3d12_xs.dll` imports. A local `tools/pe_inventory.py` scan alongside both `xmem.dll` and `d3d12_xs.dll` can verify 0 unresolved edges across the 16 package DLLs; any further `d3d12_xs.dll` exports needed by a main executable stay separate work. ## Checklist - [x] This pull request covers one reviewable behavior. - [x] I included the exact command and result for every check I ran. - [x] I considered a negative control or failure case for a new fixture. - [x] I updated README/docs when a capability or build requirement changed. - [x] I did not include game files, dumps, distribution links or secrets. AI-assisted: yes.
upstream-sync closed this pull request 2026-11-24 06:42:35 +00:00
roansystemlabs commented 2026-11-24 06:48:11 +00:00 (Migrated from github.com)

Imported from R0Y00/Xbox2Windows. Originally posted by roansystemlabs on 2026-11-21T23:22:14Z.


Independent Windows run of #351 at the current head, after the two test follow-ups.

Environment: Windows 11 build 26200, desktop d3d12.dll / D3D12Core.dll 10.0.26100.9818, MSVC 19.44.35230 (VS Build Tools 2022), Windows SDK 10.0.26100.0, NVIDIA GeForce RTX 3070 (driver 32.0.16.2101), Python 3.12. D3D12 debug layer not installed on this PC.
Tested head: e30921a2a13c41f8b1b839cdd4aef3277f9def5d.

cmake --build --preset dev
ctest --preset dev --no-tests=error
ctest --preset dev -R d3d12_xs_shim -V

Result: 150/150, with the usual 3 capability skips on this PC (bvh_wave64_hardware, bvh_wave64_warp, wave_shuffle_warp). The four shim tests pass:

30: v11_cases=4 v10_cases=1 negative_cases=5 null_hr=0x80070057 bad_ver_hr=0x80070057
30: Desktop d3d12_xs.dll serialize: PASS

For the record, this matches what I saw at 9094856 on the same machine: d3d12_xs_shim_serialize failed there because desktop D3D12SerializeVersionedRootSignature 10.0.26100.9818 accepts 0x80000000 on its own (returns S_OK and a blob), so the shim, which passes it through unchanged, succeeded too. A standalone probe of every serialize_checks() step showed no other difference from the test's expectations. With 0x08000000 in its place, desktop and shim both return E_INVALIDARG here, and the new failure messages would have made the old cause visible in the CI log.

AI-assisted: run and prepared with the support of Roan System.

<!-- greyfinch-sync:R0Y00/Xbox2Windows:comment:7070828100 --> Imported from [R0Y00/Xbox2Windows](https://github.com/R0Y00/Xbox2Windows/pull/351#issuecomment-7070828100). Originally posted by [roansystemlabs](https://github.com/roansystemlabs) on 2026-11-21T23:22:14Z. --- Independent Windows run of #351 at the current head, after the two test follow-ups. **Environment:** Windows 11 build 26200, desktop `d3d12.dll` / `D3D12Core.dll` 10.0.26100.9818, MSVC 19.44.35230 (VS Build Tools 2022), Windows SDK 10.0.26100.0, NVIDIA GeForce RTX 3070 (driver 32.0.16.2101), Python 3.12. D3D12 debug layer not installed on this PC. **Tested head:** `e30921a2a13c41f8b1b839cdd4aef3277f9def5d`. ```powershell cmake --build --preset dev ctest --preset dev --no-tests=error ctest --preset dev -R d3d12_xs_shim -V ``` **Result:** 150/150, with the usual 3 capability skips on this PC (`bvh_wave64_hardware`, `bvh_wave64_warp`, `wave_shuffle_warp`). The four shim tests pass: ```text 30: v11_cases=4 v10_cases=1 negative_cases=5 null_hr=0x80070057 bad_ver_hr=0x80070057 30: Desktop d3d12_xs.dll serialize: PASS ``` For the record, this matches what I saw at `9094856` on the same machine: `d3d12_xs_shim_serialize` failed there because desktop `D3D12SerializeVersionedRootSignature` 10.0.26100.9818 accepts `0x80000000` on its own (returns `S_OK` and a blob), so the shim, which passes it through unchanged, succeeded too. A standalone probe of every `serialize_checks()` step showed no other difference from the test's expectations. With `0x08000000` in its place, desktop and shim both return `E_INVALIDARG` here, and the new failure messages would have made the old cause visible in the CI log. _AI-assisted: run and prepared with the support of Roan System._
R0Y00 commented 2026-11-24 06:48:23 +00:00 (Migrated from github.com)

Imported from R0Y00/Xbox2Windows. Originally posted by R0Y00 on 2026-11-22T03:45:04Z.


The shim and its Windows checks passed review at e30921a. GitHub refused the merge after main moved. A fresh trial against c1ca45b shows a single conflict in docs/experiments.md; the code and test registration merge cleanly. Please retain the root-signature shim results alongside current main’s experiment notes. I’ll recheck the resolved head.

<!-- greyfinch-sync:R0Y00/Xbox2Windows:comment:7073752992 --> Imported from [R0Y00/Xbox2Windows](https://github.com/R0Y00/Xbox2Windows/pull/351#issuecomment-7073752992). Originally posted by [R0Y00](https://github.com/R0Y00) on 2026-11-22T03:45:04Z. --- The shim and its Windows checks passed review at `e30921a`. GitHub refused the merge after main moved. A fresh trial against `c1ca45b` shows a single conflict in `docs/experiments.md`; the code and test registration merge cleanly. Please retain the root-signature shim results alongside current main’s experiment notes. I’ll recheck the resolved head.
R0Y00 commented 2026-11-24 06:48:24 +00:00 (Migrated from github.com)

Imported from R0Y00/Xbox2Windows. Originally posted by R0Y00 on 2026-11-22T04:00:20Z.


I resolved the documentation conflict on the PR branch, keeping both experiment sections. All four d3d12_xs_shim_* tests passed locally, including the WARP root-signature test. Windows CI passed and GitHub confirms the merge.

<!-- greyfinch-sync:R0Y00/Xbox2Windows:comment:7073918337 --> Imported from [R0Y00/Xbox2Windows](https://github.com/R0Y00/Xbox2Windows/pull/351#issuecomment-7073918337). Originally posted by [R0Y00](https://github.com/R0Y00) on 2026-11-22T04:00:20Z. --- I resolved the documentation conflict on the PR branch, keeping both experiment sections. All four d3d12_xs_shim_* tests passed locally, including the WARP root-signature test. Windows CI passed and GitHub confirms the merge.
Sign in to join this conversation.
No reviewers
No labels
No milestone
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.

Reference
R0Y00/Xbox2Windows!346
No description provided.