d3d12_xs: add D3D12ConfigureVirtualMemoryX and XMemRegisterGraphicsMemoryConfiguration #982

Closed
EvilOpus wants to merge 1 commit from upstream-pr/989 into main
EvilOpus commented 2026-11-23 20:06:53 +00:00 (Migrated from github.com)

Imported from R0Y00/Xbox2Windows. Originally posted by EvilOpus on 2026-11-23T20:06:53Z.


Summary

Export D3D12ConfigureVirtualMemoryX (@5) and XMemRegisterGraphicsMemoryConfiguration (@25) from the desktop d3d12_xs.dll shim.

On the console, D3D12XboxCreateDevice calls D3D12ConfigureVirtualMemoryX, which reserves GPU virtual address space via VdEraConfigureVirtualMemory and registers the page-table parameters with xmem via XMemRegisterGraphicsMemoryConfiguration. The desktop shim validates the input, returns a plausible GPU VA range and stores the graphics memory configuration.

Refs #874

Struct layouts

From PDB analysis of the ERA d3d12_xs.dll and xmem.dll (GDK 261000 gameKit/symbols):

_XMEM_GRAPHICS_MEMORY_CONFIG (24 bytes):

Offset Type Field
+0x00 uint32 gpuPageTableSize
+0x04 uint32 framePreserveBufferSize
+0x08 uint64 minGpuAddress
+0x10 uint64 maxGpuAddress

D3D12ConfigureVirtualMemoryX input (32 bytes):

Offset Type Field
+0x00 uint32 flags (only bit 0 observed)
+0x04 uint32 gpuPageTablePages (max 33 = 132 MB)
+0x08 uint32 framePreserveBufferSize
+0x0C uint32 padding
+0x10 uint64 minGpuAddress (output)
+0x18 uint64 maxGpuAddress (output)

The ERA DLL computes gpuPageTableSize = gpuPageTablePages << 22 before calling XMemRegisterGraphicsMemoryConfiguration.

Test command and result

cmake --build --preset dev --target d3d12_xs_shim d3d12_xs_shim_check
ctest --preset dev --no-tests=error -R d3d12_xs_shim -V
5/5 tests passed:
  d3d12_xs_shim_exports        PASS
  d3d12_xs_shim_serialize      PASS
  d3d12_xs_shim_deserialize    PASS
  d3d12_xs_shim_configure_vm   PASS  (new)
  d3d12_xs_shim_warp_root      PASS

The configure_vm scenario covers:

  • Negative controls: null input, invalid flags (bit 1), page table pages > 33 — all return E_INVALIDARG
  • Positive cases: valid config with 8 pages populates max_gpu_address; flags=1 accepted
  • Safety: XMemRegisterGraphicsMemoryConfiguration(nullptr) does not crash

What was measured

The struct layouts and validation limits (flags mask, 33-page maximum, gpuPageTablePages << 22 scaling) are from Hex-Rays decompilation of the ERA DLLs with PDB symbols. The return code 0x10000000 is from the ERA D3D12ConfigureVirtualMemoryX (VdEraConfigureVirtualMemory ORed with 0x10000000). The desktop GPU VA range is a placeholder; the actual range on console comes from the kernel.

What remains a hypothesis

Whether all titles pass the same page-table page counts and flags, and whether any title inspects the returned min/max addresses beyond storing them.

<!-- greyfinch-sync:R0Y00/Xbox2Windows:issue:6567800882 --> Imported from [R0Y00/Xbox2Windows](https://github.com/R0Y00/Xbox2Windows/pull/989). Originally posted by [EvilOpus](https://github.com/EvilOpus) on 2026-11-23T20:06:53Z. --- ## Summary Export `D3D12ConfigureVirtualMemoryX` (`@5`) and `XMemRegisterGraphicsMemoryConfiguration` (`@25`) from the desktop `d3d12_xs.dll` shim. On the console, `D3D12XboxCreateDevice` calls `D3D12ConfigureVirtualMemoryX`, which reserves GPU virtual address space via `VdEraConfigureVirtualMemory` and registers the page-table parameters with xmem via `XMemRegisterGraphicsMemoryConfiguration`. The desktop shim validates the input, returns a plausible GPU VA range and stores the graphics memory configuration. Refs #874 ## Struct layouts From PDB analysis of the ERA `d3d12_xs.dll` and `xmem.dll` (GDK 261000 `gameKit/symbols`): **`_XMEM_GRAPHICS_MEMORY_CONFIG`** (24 bytes): | Offset | Type | Field | |--------|------|-------| | `+0x00` | `uint32` | `gpuPageTableSize` | | `+0x04` | `uint32` | `framePreserveBufferSize` | | `+0x08` | `uint64` | `minGpuAddress` | | `+0x10` | `uint64` | `maxGpuAddress` | **`D3D12ConfigureVirtualMemoryX` input** (32 bytes): | Offset | Type | Field | |--------|------|-------| | `+0x00` | `uint32` | `flags` (only bit 0 observed) | | `+0x04` | `uint32` | `gpuPageTablePages` (max 33 = 132 MB) | | `+0x08` | `uint32` | `framePreserveBufferSize` | | `+0x0C` | `uint32` | padding | | `+0x10` | `uint64` | `minGpuAddress` (output) | | `+0x18` | `uint64` | `maxGpuAddress` (output) | The ERA DLL computes `gpuPageTableSize = gpuPageTablePages << 22` before calling `XMemRegisterGraphicsMemoryConfiguration`. ## Test command and result ``` cmake --build --preset dev --target d3d12_xs_shim d3d12_xs_shim_check ctest --preset dev --no-tests=error -R d3d12_xs_shim -V ``` ``` 5/5 tests passed: d3d12_xs_shim_exports PASS d3d12_xs_shim_serialize PASS d3d12_xs_shim_deserialize PASS d3d12_xs_shim_configure_vm PASS (new) d3d12_xs_shim_warp_root PASS ``` The `configure_vm` scenario covers: - **Negative controls**: null input, invalid flags (bit 1), page table pages > 33 — all return `E_INVALIDARG` - **Positive cases**: valid config with 8 pages populates `max_gpu_address`; flags=1 accepted - **Safety**: `XMemRegisterGraphicsMemoryConfiguration(nullptr)` does not crash ## What was measured The struct layouts and validation limits (flags mask, 33-page maximum, `gpuPageTablePages << 22` scaling) are from Hex-Rays decompilation of the ERA DLLs with PDB symbols. The return code `0x10000000` is from the ERA `D3D12ConfigureVirtualMemoryX` (`VdEraConfigureVirtualMemory` ORed with `0x10000000`). The desktop GPU VA range is a placeholder; the actual range on console comes from the kernel. ## What remains a hypothesis Whether all titles pass the same page-table page counts and flags, and whether any title inspects the returned min/max addresses beyond storing them.
upstream-sync closed this pull request 2026-11-24 06:45:44 +00:00
R0Y00 commented 2026-11-24 06:49:37 +00:00 (Migrated from github.com)

Imported from R0Y00/Xbox2Windows. Originally posted by R0Y00 on 2026-11-23T20:10:24Z.


#968 already owns the configure/reservation implementation and #986 covers the separate queue-ordering check. Please hold this overlapping implementation. The generated VA span is derived from the request without reserving a usable Windows range. Returning success would publish addresses with no backing contract. If you have public, independently reproducible evidence for a distinct part of the ABI, please link it on #874 or in the overlapping PR. Replace the private-symbol and decompilation-derived contract details in this PR with public references or source-built fixture evidence, and keep the underlying material local.

<!-- greyfinch-sync:R0Y00/Xbox2Windows:comment:7112672909 --> Imported from [R0Y00/Xbox2Windows](https://github.com/R0Y00/Xbox2Windows/pull/989#issuecomment-7112672909). Originally posted by [R0Y00](https://github.com/R0Y00) on 2026-11-23T20:10:24Z. --- #968 already owns the configure/reservation implementation and #986 covers the separate queue-ordering check. Please hold this overlapping implementation. The generated VA span is derived from the request without reserving a usable Windows range. Returning success would publish addresses with no backing contract. If you have public, independently reproducible evidence for a distinct part of the ABI, please link it on #874 or in the overlapping PR. Replace the private-symbol and decompilation-derived contract details in this PR with public references or source-built fixture evidence, and keep the underlying material local.

Pull request closed

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!982
No description provided.