[PR #961] [CLOSED] d3d12_xs: a console volume depth-stencil is a 2D depth array (RT-VOLUME-DEPTH) #998

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

📋 Pull Request Information

Original PR: https://github.com/ubiquitarianism/leonida/pull/961
Author: @roanh47
Created: 11/24/2026
Status: ❌ Closed

Base: main ← Head: pr/volume-depth


📝 Commits (10+)

  • 522faa2 d3d12_xs: honour XMemAllocationHooks for descriptor heaps and translate CPU handles
  • f59167e d3d12_xs: device slot 25 pads a render target to whole console tiles (RT-5 stop 17)
  • 6b75cba d3d12_xs: device slot 25 gives the PC device clean resource descriptions (RT-5 stop 16)
  • 8eaccde d3d12_xs: console render target sizes follow each resource's alignment, slot 56 offsets, full mip chains, rounded-up mip extents, B5G5R5A1, saturating sums
  • e090be9 d3d12_xs: committed resources lease their size through the title's XMem hooks (RT-5 stop 17)
  • 24914e7 d3d12: preserve PC descriptor validation in slot 25
  • 4056d18 ladder: kXboxTiledResourceLayout is inline const, not constexpr (clang-cl rejects 0x101 for the unfixed enum)
  • c108c53 d3d12_xs: the console render-target sizes of slots 25 and 56 are for console-form calls only
  • 0c5a146 d3d12_xs: the hook-backed descriptor address is not applied to a console-extended heap
  • c8247cd d3d12_xs: a console indirect argument of type 105 is created as DISPATCH (slot 41)

📊 Changes

23 files changed (+2706 additions, -134 deletions)

View changed files

📝 docs/d3d12_vulkan.md (+31 -2)
📝 runtime/CMakeLists.txt (+1 -0)
📝 runtime/shims/d3d12_com.cpp (+10 -0)
📝 runtime/shims/d3d12_vulkan_device.cpp (+5 -0)
📝 runtime/shims/d3d12_xs.cpp (+17 -0)
➕ runtime/shims/d3d12_xs_alloc_size.h (+156 -0)
➕ runtime/shims/d3d12_xs_desc_clean.h (+77 -0)
📝 runtime/shims/d3d12_xs_device.cpp (+972 -63)
📝 runtime/shims/d3d12_xs_device.h (+58 -11)
📝 runtime/shims/registry.cpp (+39 -0)
📝 runtime/shims/shims.h (+13 -0)
📝 runtime/shims/xbox_present.cpp (+3 -2)
📝 runtime/shims/xbox_present.h (+2 -1)
📝 runtime/src/command_list.h (+3 -0)
📝 runtime/src/frame_pacer.h (+19 -6)
📝 runtime/src/pe_loader.cpp (+7 -0)
📝 runtime/test/allocator_proxy_test.cpp (+24 -7)
📝 runtime/test/d3d12_mesh_test.cpp (+22 -0)
📝 runtime/test/device_proxy_test.cpp (+114 -1)
📝 runtime/test/frame_pacer_test.cpp (+19 -0)

...and 3 more files

📄 Description

Claimed in the coordination issue as: RT-VOLUME-DEPTH

Depends on: #427 and #772. This branch is based on #772's head cbdaf7ece, which contains #427's 89fdb83e0; #427 adds runtime/shims/d3d12_xs_desc_clean.h and the slot-25 descriptor copy, and #772 touches slots 127 and 133. The volume-depth helper is now part of #427's header instead of a second copy of it. This PR's own commit is e0b962d89, the last one in the diff; the earlier commits are that stack (based on main a28927849), which is itself behind today's main, so the stack is not mergeable until #427/#772 are. A test merge with today's main conflicts only where that stack meets newer main changes (docs/d3d12_vulkan.md, runtime/shims/d3d12_xs_device.cpp/.h, runtime/src/frame_pacer.h and the list in xs_proxy_mock_test.cpp's main); this commit's hunks apply on top of #772.

What and why

The current native Windows/RTX 3070 stop after #517 is ID3D12Device10::CreateCommittedResource3 refusing a TEXTURE3D 768x768x6 R16_TYPELESS, one mip, one sample, ALLOW_DEPTH_STENCIL resource. PC D3D12 has no volume depth-stencil: the layer's GetResourceAllocationInfo answers UINT64_MAX and CreateCommittedResource3 fails.

On top of #427's d3d12_xs_desc_clean.h, two small functions describe exactly that measured resource as a TEXTURE2D depth array of the same six slices:

  • is_measured_volume_depth: Dimension == TEXTURE3D, ALLOW_DEPTH_STENCIL, MipLevels == 1, SampleDesc.Count == 1, DepthOrArraySize == 6;
  • pc_depth_desc: a copy with Dimension changed to TEXTURE2D; DepthOrArraySize is already the slice count.

Called where the PC device is handed a description:

  • slot 25 (GetResourceAllocationInfo): inside #427's existing descriptor copy, before the size query, so sizing and creation agree;
  • slot 76 (CreateCommittedResource), slot 127 (CreateCommittedResource3) and the slot 133 (CreatePlacedResourceX) handler: on the existing copy before the PC call.

Preserved exactly: the format (R16_TYPELESS, still typeless in the depth-stencil family), ALLOW_DEPTH_STENCIL, the clear value the caller passes, MipLevels, SampleDesc, width, height and the six array slices. The caller's descriptor is never written.

Deliberately not translated:

  • a multi-mip volume, another slice count or a multisampled volume. A 3D mip shrinks its depth, while a 2D array keeps every layer at every mip, so those shapes are not equivalent; they go on as they came and the PC device's refusal stands. xs_proxy_mock_test proves a four-slice, a two-mip and a colour volume keep TEXTURE3D;
  • the global PC rule in d3d12_vulkan_device.cpp, which is unchanged;
  • console slot 108 (GetResourceAllocationInfo2): it is not routed in this stack's d3d12_xs_device.cpp, so there is no call site to change.

d3d12_vulkan_device_test is not modified in this version: its depth-stencil volume case is four slices, outside the measured shape, and still matches the host runtime.

Tested

MSVC 19.44 (RelWithDebInfo, Visual Studio 17 2022, x64, Windows SDK 10.0.26100), Vulkan SDK 1.4.363.0, on the rebased branch:

cmake --build runtime/build --config RelWithDebInfo --target xs_proxy_mock_test d3d12_vulkan_device_test d3d12_method_variants_test d3d12_resource_desc_test
ctest -C RelWithDebInfo -R "xs_proxy_mock|d3d12_method_variants|d3d12_resource_desc|d3d12_vulkan_device"
 1/10 Test  #27: xs_proxy_mock .....................   Passed    0.01 sec
 2/10 Test  #28: xs_proxy_mock_no_reserve ..........   Passed    0.01 sec
 3/10 Test  #29: xs_proxy_mock_no_protect ..........   Passed    0.01 sec
 4/10 Test  #30: xs_proxy_mock_no_handler ..........   Passed    0.01 sec
 5/10 Test  #31: xs_proxy_mock_env_slots ...........   Passed    0.01 sec
 6/10 Test  #32: xs_proxy_mock_env_slots_invalid ...   Passed    0.01 sec
 7/10 Test  #33: xs_proxy_mock_env_slots_74 ........   Passed    0.01 sec
 8/10 Test #173: d3d12_vulkan_device ...............   Passed   10.55 sec
 9/10 Test #201: d3d12_method_variants .............   Passed    0.94 sec
10/10 Test #221: d3d12_resource_desc ...............   Passed    0.53 sec

100% tests passed, 0 tests failed out of 10
Total Test time (real) =  12.12 sec

The new regression's own lines:

[rt] d3d12_xs: slot 25: measured console TEXTURE3D depth-stencil 768x768x6 (format 53, flags 0x2, one mip, one sample) is described to the PC device as a TEXTURE2D depth array of 6 slices
xs_proxy_mock: the measured console TEXTURE3D 768x768x6 R16_TYPELESS depth-stencil is sized and created as a 2D depth array of six slices, and other volume depths keep their dimension
xs_proxy_mock_test: PASS (10 allocations refused on purpose)

It checks the descriptor through slot 25 (including a two-entry list), slots 76 and 127 and the slot 133 handler, asserts the caller's D3D12_RESOURCE_DESC/DESC1 is byte-identical after every call, and that the four-slice, multi-mip and colour volumes are not converted.

The other tests' closing lines:

D3D12 method variants: CreateCommittedResource1/2/3, CreatePlacedResource2, CreateReservedResource1/2, CreateCommandQueue1 and GetCopyableFootprints1 matched their base methods and the PC runtime's edge-case answers; a texture round-tripped
resource desc against NVIDIA GeForce RTX 3070: 26 of 26 descriptions match, 0 differ, 0 refused by the host, 0 not created by the layer
resource desc against WARP: 26 of 26 descriptions match, 0 differ, 0 refused by the host, 0 not created by the layer
Vulkan device behind the Xbox-ABI proxy: clears, zero-filled first use, uploads, texture, buffer and BC copies, a resolve, reserved resources, queries, GetCopyableFootprints, GetResourceTiling and CheckFeatureSupport error paths and fence semantics all matched

One intermediate ctest run of d3d12_vulkan_device failed once on this stack; it passed when run alone and in the next full run above (no line N: failure printed in the direct run).

python -I scripts/check_no_game_data.py runtime/shims/d3d12_xs_desc_clean.h runtime/shims/d3d12_xs_device.cpp runtime/shims/d3d12_xs_device.h runtime/test/xs_proxy_mock_test.cpp exits 0 with no output.

No game data is in the change: every descriptor in the tests is hand-written, and no log or report quotes the title.

GPUs tested: NVIDIA GeForce RTX 3070, driver 610.88, Windows 11 Pro.

AI-assisted: yes (DeepSeek v4.1 Flash 1017).

Checklist

  • Based on the #427+#772 stack (stack head cbdaf7ece, on main a28927849) and merges cleanly once they do.
  • One topic; follow-up work goes in a new pull request.
  • No game data, keys or decryption, including in logs or reports quoted here.
  • A new translator rule is in the contract table of docs/design.md — not a translator change.

🔄 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/961 **Author:** [@roanh47](https://github.com/roanh47) **Created:** 11/24/2026 **Status:** ❌ Closed **Base:** `main` ← **Head:** `pr/volume-depth` --- ### 📝 Commits (10+) - [`522faa2`](https://github.com/ubiquitarianism/leonida/commit/522faa2ee4ad77b00d11057543497f9e31c3ff05) d3d12_xs: honour __XMemAllocationHooks__ for descriptor heaps and translate CPU handles - [`f59167e`](https://github.com/ubiquitarianism/leonida/commit/f59167ef9ce47c3861a2c3f4092c6d4ccdb623e5) d3d12_xs: device slot 25 pads a render target to whole console tiles (RT-5 stop 17) - [`6b75cba`](https://github.com/ubiquitarianism/leonida/commit/6b75cbafbc9e909747c7576dc7123f4d78b4123f) d3d12_xs: device slot 25 gives the PC device clean resource descriptions (RT-5 stop 16) - [`8eaccde`](https://github.com/ubiquitarianism/leonida/commit/8eaccded7f8ea0292046f097d934f73015e3c670) d3d12_xs: console render target sizes follow each resource's alignment, slot 56 offsets, full mip chains, rounded-up mip extents, B5G5R5A1, saturating sums - [`e090be9`](https://github.com/ubiquitarianism/leonida/commit/e090be908ded3ebe84a04702e6690bd98d2cefe7) d3d12_xs: committed resources lease their size through the title's XMem hooks (RT-5 stop 17) - [`24914e7`](https://github.com/ubiquitarianism/leonida/commit/24914e72982aff3da606199eb1bb783fbaa18457) d3d12: preserve PC descriptor validation in slot 25 - [`4056d18`](https://github.com/ubiquitarianism/leonida/commit/4056d185e7e30c90df32a095cf0d30d93b20d507) ladder: kXboxTiledResourceLayout is inline const, not constexpr (clang-cl rejects 0x101 for the unfixed enum) - [`c108c53`](https://github.com/ubiquitarianism/leonida/commit/c108c5389467128dffc1414e112c8b699e724894) d3d12_xs: the console render-target sizes of slots 25 and 56 are for console-form calls only - [`0c5a146`](https://github.com/ubiquitarianism/leonida/commit/0c5a14659502a32d84c830880bc2c20aa1562c11) d3d12_xs: the hook-backed descriptor address is not applied to a console-extended heap - [`c8247cd`](https://github.com/ubiquitarianism/leonida/commit/c8247cdfa384189ed28512aa157663f4db152273) d3d12_xs: a console indirect argument of type 105 is created as DISPATCH (slot 41) ### 📊 Changes **23 files changed** (+2706 additions, -134 deletions) <details> <summary>View changed files</summary> 📝 `docs/d3d12_vulkan.md` (+31 -2) 📝 `runtime/CMakeLists.txt` (+1 -0) 📝 `runtime/shims/d3d12_com.cpp` (+10 -0) 📝 `runtime/shims/d3d12_vulkan_device.cpp` (+5 -0) 📝 `runtime/shims/d3d12_xs.cpp` (+17 -0) ➕ `runtime/shims/d3d12_xs_alloc_size.h` (+156 -0) ➕ `runtime/shims/d3d12_xs_desc_clean.h` (+77 -0) 📝 `runtime/shims/d3d12_xs_device.cpp` (+972 -63) 📝 `runtime/shims/d3d12_xs_device.h` (+58 -11) 📝 `runtime/shims/registry.cpp` (+39 -0) 📝 `runtime/shims/shims.h` (+13 -0) 📝 `runtime/shims/xbox_present.cpp` (+3 -2) 📝 `runtime/shims/xbox_present.h` (+2 -1) 📝 `runtime/src/command_list.h` (+3 -0) 📝 `runtime/src/frame_pacer.h` (+19 -6) 📝 `runtime/src/pe_loader.cpp` (+7 -0) 📝 `runtime/test/allocator_proxy_test.cpp` (+24 -7) 📝 `runtime/test/d3d12_mesh_test.cpp` (+22 -0) 📝 `runtime/test/device_proxy_test.cpp` (+114 -1) 📝 `runtime/test/frame_pacer_test.cpp` (+19 -0) _...and 3 more files_ </details> ### 📄 Description Claimed in the coordination issue as: [RT-VOLUME-DEPTH](https://github.com/ubiquitarianism/leonida/issues/14#issuecomment-7135719148) Depends on: #427 and #772. This branch is based on #772's head `cbdaf7ece`, which contains #427's `89fdb83e0`; #427 adds `runtime/shims/d3d12_xs_desc_clean.h` and the slot-25 descriptor copy, and #772 touches slots 127 and 133. The volume-depth helper is now part of #427's header instead of a second copy of it. This PR's own commit is `e0b962d89`, the last one in the diff; the earlier commits are that stack (based on `main` `a28927849`), which is itself behind today's `main`, so the stack is not mergeable until #427/#772 are. A test merge with today's `main` conflicts only where that stack meets newer `main` changes (`docs/d3d12_vulkan.md`, `runtime/shims/d3d12_xs_device.cpp`/`.h`, `runtime/src/frame_pacer.h` and the list in `xs_proxy_mock_test.cpp`'s `main`); this commit's hunks apply on top of #772. ### What and why The current native Windows/RTX 3070 stop after #517 is `ID3D12Device10::CreateCommittedResource3` refusing a `TEXTURE3D 768x768x6 R16_TYPELESS`, one mip, one sample, `ALLOW_DEPTH_STENCIL` resource. PC D3D12 has no volume depth-stencil: the layer's `GetResourceAllocationInfo` answers `UINT64_MAX` and `CreateCommittedResource3` fails. On top of #427's `d3d12_xs_desc_clean.h`, two small functions describe exactly that measured resource as a `TEXTURE2D` depth array of the same six slices: - `is_measured_volume_depth`: `Dimension == TEXTURE3D`, `ALLOW_DEPTH_STENCIL`, `MipLevels == 1`, `SampleDesc.Count == 1`, `DepthOrArraySize == 6`; - `pc_depth_desc`: a copy with `Dimension` changed to `TEXTURE2D`; `DepthOrArraySize` is already the slice count. Called where the PC device is handed a description: - **slot 25** (`GetResourceAllocationInfo`): inside #427's existing descriptor copy, before the size query, so sizing and creation agree; - **slot 76** (`CreateCommittedResource`), **slot 127** (`CreateCommittedResource3`) and the **slot 133** (`CreatePlacedResourceX`) handler: on the existing copy before the PC call. Preserved exactly: the format (`R16_TYPELESS`, still typeless in the depth-stencil family), `ALLOW_DEPTH_STENCIL`, the clear value the caller passes, `MipLevels`, `SampleDesc`, width, height and the six array slices. The caller's descriptor is never written. Deliberately **not** translated: - a multi-mip volume, another slice count or a multisampled volume. A 3D mip shrinks its depth, while a 2D array keeps every layer at every mip, so those shapes are not equivalent; they go on as they came and the PC device's refusal stands. `xs_proxy_mock_test` proves a four-slice, a two-mip and a colour volume keep `TEXTURE3D`; - the global PC rule in `d3d12_vulkan_device.cpp`, which is unchanged; - console slot 108 (`GetResourceAllocationInfo2`): it is not routed in this stack's `d3d12_xs_device.cpp`, so there is no call site to change. `d3d12_vulkan_device_test` is not modified in this version: its depth-stencil volume case is four slices, outside the measured shape, and still matches the host runtime. ### Tested MSVC 19.44 (`RelWithDebInfo`, `Visual Studio 17 2022`, x64, Windows SDK 10.0.26100), Vulkan SDK 1.4.363.0, on the rebased branch: ``` cmake --build runtime/build --config RelWithDebInfo --target xs_proxy_mock_test d3d12_vulkan_device_test d3d12_method_variants_test d3d12_resource_desc_test ctest -C RelWithDebInfo -R "xs_proxy_mock|d3d12_method_variants|d3d12_resource_desc|d3d12_vulkan_device" ``` ``` 1/10 Test #27: xs_proxy_mock ..................... Passed 0.01 sec 2/10 Test #28: xs_proxy_mock_no_reserve .......... Passed 0.01 sec 3/10 Test #29: xs_proxy_mock_no_protect .......... Passed 0.01 sec 4/10 Test #30: xs_proxy_mock_no_handler .......... Passed 0.01 sec 5/10 Test #31: xs_proxy_mock_env_slots ........... Passed 0.01 sec 6/10 Test #32: xs_proxy_mock_env_slots_invalid ... Passed 0.01 sec 7/10 Test #33: xs_proxy_mock_env_slots_74 ........ Passed 0.01 sec 8/10 Test #173: d3d12_vulkan_device ............... Passed 10.55 sec 9/10 Test #201: d3d12_method_variants ............. Passed 0.94 sec 10/10 Test #221: d3d12_resource_desc ............... Passed 0.53 sec 100% tests passed, 0 tests failed out of 10 Total Test time (real) = 12.12 sec ``` The new regression's own lines: ``` [rt] d3d12_xs: slot 25: measured console TEXTURE3D depth-stencil 768x768x6 (format 53, flags 0x2, one mip, one sample) is described to the PC device as a TEXTURE2D depth array of 6 slices xs_proxy_mock: the measured console TEXTURE3D 768x768x6 R16_TYPELESS depth-stencil is sized and created as a 2D depth array of six slices, and other volume depths keep their dimension xs_proxy_mock_test: PASS (10 allocations refused on purpose) ``` It checks the descriptor through slot 25 (including a two-entry list), slots 76 and 127 and the slot 133 handler, asserts the caller's `D3D12_RESOURCE_DESC`/`DESC1` is byte-identical after every call, and that the four-slice, multi-mip and colour volumes are not converted. The other tests' closing lines: ``` D3D12 method variants: CreateCommittedResource1/2/3, CreatePlacedResource2, CreateReservedResource1/2, CreateCommandQueue1 and GetCopyableFootprints1 matched their base methods and the PC runtime's edge-case answers; a texture round-tripped resource desc against NVIDIA GeForce RTX 3070: 26 of 26 descriptions match, 0 differ, 0 refused by the host, 0 not created by the layer resource desc against WARP: 26 of 26 descriptions match, 0 differ, 0 refused by the host, 0 not created by the layer Vulkan device behind the Xbox-ABI proxy: clears, zero-filled first use, uploads, texture, buffer and BC copies, a resolve, reserved resources, queries, GetCopyableFootprints, GetResourceTiling and CheckFeatureSupport error paths and fence semantics all matched ``` One intermediate `ctest` run of `d3d12_vulkan_device` failed once on this stack; it passed when run alone and in the next full run above (no `line N:` failure printed in the direct run). `python -I scripts/check_no_game_data.py runtime/shims/d3d12_xs_desc_clean.h runtime/shims/d3d12_xs_device.cpp runtime/shims/d3d12_xs_device.h runtime/test/xs_proxy_mock_test.cpp` exits 0 with no output. No game data is in the change: every descriptor in the tests is hand-written, and no log or report quotes the title. GPUs tested: NVIDIA GeForce RTX 3070, driver 610.88, Windows 11 Pro. AI-assisted: yes (DeepSeek v4.1 Flash 1017). ### Checklist - [x] Based on the #427+#772 stack (stack head `cbdaf7ece`, on `main` `a28927849`) and merges cleanly once they do. - [x] One topic; follow-up work goes in a new pull request. - [x] No game data, keys or decryption, including in logs or reports quoted here. - [ ] A new translator rule is in the contract table of `docs/design.md` — not a translator change. --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
4ld0 2026-11-26 20:19:45 +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#998
No description provided.