[PR #375] [MERGED] d3d12_xs: the title's XMem hooks, console render-target sizes and resource leases, again (RT-XMEM-LEASE) #425

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

📋 Pull Request Information

Original PR: https://github.com/ubiquitarianism/leonida/pull/375
Author: @Mumogg
Created: 11/24/2026
Status: ✅ Merged
Merged: 11/24/2026
Merged by: @aslan2142

Base: main ← Head: xmem-hooks-sizes-lease


📝 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
  • 94f2773 Merge main into RT-XMEM-LEASE (#375)

📊 Changes

11 files changed (+1453 additions, -42 deletions)

View changed files

📝 docs/d3d12_vulkan.md (+27 -2)
📝 runtime/shims/d3d12_xs.cpp (+11 -0)
➕ runtime/shims/d3d12_xs_alloc_size.h (+156 -0)
➕ runtime/shims/d3d12_xs_desc_clean.h (+38 -0)
📝 runtime/shims/d3d12_xs_device.cpp (+503 -23)
📝 runtime/shims/d3d12_xs_device.h (+16 -1)
📝 runtime/shims/registry.cpp (+39 -0)
📝 runtime/shims/shims.h (+13 -0)
📝 runtime/src/pe_loader.cpp (+7 -0)
📝 runtime/test/device_proxy_test.cpp (+71 -1)
📝 runtime/test/xs_proxy_mock_test.cpp (+572 -15)

📄 Description

Claimed in #14 as RT-XMEM-LEASE. Depends on: #349, #350, #356, #362, #369 (their commits come first here; this pull request is the last five commits).

What and why

After #369 the title stops on a budget check: it bump-allocates its first full-screen render targets out of a range it reserved, through its own __XMemAllocationHooks__, and asserts that less than 2 MiB of that range is left. On main nothing goes through those hooks, so the whole range is left. tools/int3_cause.py on the stop shows the comparison against 0x1fffff.

Clearing it takes three pieces that build on each other. All five commits are cherry-picked with -x and keep their authors; all are ancestors of main whose content is not in the tree.

Commit Author What
355201c51 Khuraie __XMemAllocationHooks__ honoured for descriptor heaps; device slots 17 to 24 translate CPU handles in the title's own range (old PR 7021)
889785539 tedin7 device slot 25 pads a render target to whole console tiles
c7ca0f2d1 tedin7 device slot 25 gives the PC device clean resource descriptions
359390833 tedin7 sizes follow each resource's alignment, slot 56 offsets, mip chains, saturating sums
ae322dafc Jackson committed resources (slots 76 and 127) lease their size through the hooks

What I changed while resolving conflicts, so a reviewer knows where to look:

  • Everywhere the conflicts were neighbours added on either side (slot lists, the mock's cases, the test's call list): both sides kept.
  • proxy_get_resource_allocation_info: c7ca0f2d1 and 359390833 come from two branches of the original series; I resolved them as the original merge commit (aeb253754) did, including the mock's helper block.
  • The lease commit computed its size with a helper that 359390833 removes. I used the later form from the same author's follow-up (d61755d4d): a render target's console tile size, else the PC size. The commit message says so.
  • My slot 25 test from #362 is adapted to the series' own mock for slot 25 (the sizes it answers, and the proxy now passes the PC device a cleaned copy of the descriptions, so the test no longer compares the pointer).

Left out on purpose, to keep this to what the stop needs: b4d1ba179 (PC descriptor validation in slot 25), 4a8603436 (a depth-stencil texture with unordered access) and bee47186f.

One thing a maintainer should decide: 355201c51 is the title-backed descriptor heap model. main also has the slot 14 console-heap handler in the Vulkan layer. They did not conflict textually and the boot below runs with both present, but they are two answers to the same question and I have not worked out how they should share slot 14.

Measured

Linux (Nobara 44, kernel 7.3), Wine 11.21 staging, RTX 5070 Ti (driver 615.78.08), clang-cl 22.1.8 + xwin SDK 10.0.26100, own 1.0.2.1 copy, network off, on main ece4ba5b3, with #142 and #328 applied on top for the boot runs (they are not in this branch).

--run D3D12 calls Ends with
up to #369 1,639 the title's int3 on the 2 MiB budget check
+ this 1,655 the title's int3 after its device set-up returns false; the last new slot called is 41

With this the log shows the first calls of device slot 16 (CreateRootSignature) and slot 62 (the console's compute pipeline creation), and the shader library loads (28,215 translated shaders here). The next stop looks like device slot 41, CreateCommandSignature, forwarded as it is.

xs_proxy_mock_test under Wine passes with every case of the five commits: descriptor heap hooks, render-target sizes, cleaned descriptions, render-target layout and committed-resource leases.

Not built with MSVC and not run on Windows. device_proxy_test also gets cases from 355201c51; I cannot run it here (it stops at D3D12XboxCreateDevice returns a device under Wine, on main too).

AI-assisted (Claude Code); built and run on the machine above.

🤖 Generated with Claude Code

https://claude.ai/code/session_01HxBQf4pXH8PWpC5oZsM4bt


🔄 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/375 **Author:** [@Mumogg](https://github.com/Mumogg) **Created:** 11/24/2026 **Status:** ✅ Merged **Merged:** 11/24/2026 **Merged by:** [@aslan2142](https://github.com/aslan2142) **Base:** `main` ← **Head:** `xmem-hooks-sizes-lease` --- ### 📝 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 - [`94f2773`](https://github.com/ubiquitarianism/leonida/commit/94f2773c1f700ea9cbc05f02b67a4659f8e3147e) Merge main into RT-XMEM-LEASE (#375) ### 📊 Changes **11 files changed** (+1453 additions, -42 deletions) <details> <summary>View changed files</summary> 📝 `docs/d3d12_vulkan.md` (+27 -2) 📝 `runtime/shims/d3d12_xs.cpp` (+11 -0) ➕ `runtime/shims/d3d12_xs_alloc_size.h` (+156 -0) ➕ `runtime/shims/d3d12_xs_desc_clean.h` (+38 -0) 📝 `runtime/shims/d3d12_xs_device.cpp` (+503 -23) 📝 `runtime/shims/d3d12_xs_device.h` (+16 -1) 📝 `runtime/shims/registry.cpp` (+39 -0) 📝 `runtime/shims/shims.h` (+13 -0) 📝 `runtime/src/pe_loader.cpp` (+7 -0) 📝 `runtime/test/device_proxy_test.cpp` (+71 -1) 📝 `runtime/test/xs_proxy_mock_test.cpp` (+572 -15) </details> ### 📄 Description Claimed in #14 as `RT-XMEM-LEASE`. Depends on: #349, #350, #356, #362, #369 (their commits come first here; this pull request is the last five commits). ### What and why After #369 the title stops on a budget check: it bump-allocates its first full-screen render targets out of a range it reserved, through its own `__XMemAllocationHooks__`, and asserts that less than 2 MiB of that range is left. On `main` nothing goes through those hooks, so the whole range is left. `tools/int3_cause.py` on the stop shows the comparison against `0x1fffff`. Clearing it takes three pieces that build on each other. All five commits are cherry-picked with `-x` and keep their authors; all are ancestors of `main` whose content is not in the tree. | Commit | Author | What | |---|---|---| | `355201c51` | Khuraie | `__XMemAllocationHooks__` honoured for descriptor heaps; device slots 17 to 24 translate CPU handles in the title's own range (old PR 7021) | | `889785539` | tedin7 | device slot 25 pads a render target to whole console tiles | | `c7ca0f2d1` | tedin7 | device slot 25 gives the PC device clean resource descriptions | | `359390833` | tedin7 | sizes follow each resource's alignment, slot 56 offsets, mip chains, saturating sums | | `ae322dafc` | Jackson | committed resources (slots 76 and 127) lease their size through the hooks | What I changed while resolving conflicts, so a reviewer knows where to look: - Everywhere the conflicts were neighbours added on either side (slot lists, the mock's cases, the test's call list): both sides kept. - `proxy_get_resource_allocation_info`: `c7ca0f2d1` and `359390833` come from two branches of the original series; I resolved them as the original merge commit (`aeb253754`) did, including the mock's helper block. - The lease commit computed its size with a helper that `359390833` removes. I used the later form from the same author's follow-up (`d61755d4d`): a render target's console tile size, else the PC size. The commit message says so. - My slot 25 test from #362 is adapted to the series' own mock for slot 25 (the sizes it answers, and the proxy now passes the PC device a cleaned copy of the descriptions, so the test no longer compares the pointer). Left out on purpose, to keep this to what the stop needs: `b4d1ba179` (PC descriptor validation in slot 25), `4a8603436` (a depth-stencil texture with unordered access) and `bee47186f`. One thing a maintainer should decide: `355201c51` is the title-backed descriptor heap model. `main` also has the slot 14 console-heap handler in the Vulkan layer. They did not conflict textually and the boot below runs with both present, but they are two answers to the same question and I have not worked out how they should share slot 14. ### Measured Linux (Nobara 44, kernel 7.3), Wine 11.21 staging, RTX 5070 Ti (driver 615.78.08), clang-cl 22.1.8 + xwin SDK 10.0.26100, own 1.0.2.1 copy, network off, on `main` `ece4ba5b3`, with #142 and #328 applied on top for the boot runs (they are not in this branch). | `--run` | D3D12 calls | Ends with | |---|---|---| | up to #369 | 1,639 | the title's `int3` on the 2 MiB budget check | | + this | 1,655 | the title's `int3` after its device set-up returns false; the last new slot called is 41 | With this the log shows the first calls of device slot 16 (`CreateRootSignature`) and slot 62 (the console's compute pipeline creation), and the shader library loads (28,215 translated shaders here). The next stop looks like device slot 41, `CreateCommandSignature`, forwarded as it is. `xs_proxy_mock_test` under Wine passes with every case of the five commits: descriptor heap hooks, render-target sizes, cleaned descriptions, render-target layout and committed-resource leases. Not built with MSVC and not run on Windows. `device_proxy_test` also gets cases from `355201c51`; I cannot run it here (it stops at `D3D12XboxCreateDevice returns a device` under Wine, on `main` too). AI-assisted (Claude Code); built and run on the machine above. 🤖 Generated with [Claude Code](https://claude.com/claude-code) https://claude.ai/code/session_01HxBQf4pXH8PWpC5oZsM4bt --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
4ld0 2026-11-26 20:17:50 +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#425
No description provided.