mirror of
https://github.com/ubiquitarianism/leonida.git
synced 2026-11-26 21:30:53 +01:00
[PR #968] [MERGED] d3d12_xs: queue slot 31 is CopyPageMappingsBatchX, mapped through xmem (RT-QUEUE31) #1006
Labels
No labels
bug
pull-request
No milestone
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set
Reference
starred/leonida#1006
Loading…
Reference in a new issue
No description provided.
Delete branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
📋 Pull Request Information
Original PR: https://github.com/ubiquitarianism/leonida/pull/968
Author: @CLHelper
Created: 11/24/2026
Status: ✅ Merged
Merged: 11/25/2026
Merged by: @aslan2142
Base:
main← Head:runtime/queue-slot31📝 Commits (5)
f2268abd3d12_xs: queue slot 31 is CopyPageMappingsBatchX, mapped through xmem (RT-QUEUE31)6fdeadfMerge main with #984 into RT-QUEUE31 (#968)255f170xmem: map slot-31 copies at the GPU-only range's paired CPU view too7fcbf1fdocs: queue slot 31 (CopyPageMappingsBatchX) is handledc551073Merge main (with #984) into RT-QUEUE31 (#968)📊 Changes
7 files changed (+370 additions, -7 deletions)
View changed files
📝
docs/d3d12_vulkan.md(+2 -1)📝
docs/linux_proton.md(+9 -5)📝
runtime/shims/d3d12_xs_device.cpp(+87 -0)📝
runtime/shims/xmem.cpp(+56 -0)📝
runtime/shims/xmem.h(+8 -0)📝
runtime/test/xmem_test.cpp(+124 -0)📝
runtime/test/xs_proxy_mock_test.cpp(+84 -1)📄 Description
Claimed in the coordination issue as: RT-QUEUE31 (https://github.com/ubiquitarianism/leonida/issues/14#issuecomment-7136768155)
What and why
The retail title calls its command queue's slot 31, one of the console-only slots past
ID3D12CommandQueue, asCopyPageMappingsBatchX(count, batches, pool, pool pages, flags).mainrefuses it withE_NOTIMPL(theXboxID3D12CommandQueue::Slot31 unsupportedlines in the #432 and #602 runs). The title does not test the result: it goes on to use the destinations as if the pages were mapped there.The shape, read statically from my own 1.0.2.1 copy (RVAs and instruction shapes only):
game_scarlett_master.exe+0xf2cc7f:call [vtable + 0xf8]with EDX the batch count, R8 the batches, R9 the base of the title's physical-page pool, the pool's size in 64 KiB pages as the fifth argument and 0 as the sixth.+0xf2ca74fills a batch as{UINT64 destination; UINT32 range count; const range* ranges}(24 bytes) and a range as{UINT32 kind, start, count}(12 bytes).start, start + 1, ...; 1 maps pool pagestartat every destination page; 2 leaves the destination unmapped; 3 leaves it as it is. Each range moves the destination on bycountpages.copy_page_mappings; there the newer layout has every slot from 14 on two later than older titles, so their 29 is this 31).XMemAllocatePhysicalPagescall.The change:
xmem.cpp:copy_page_mappings(exposed asrt::xmem::copy_page_mappings_fninxmem.h) maps at each destination page the physical page that is mapped at its source page, as a second view of the same section, so both addresses are one memory, exactly what twoXMemMapPhysicalPagescalls with one page give. Every source page is looked up before any destination page changes, so an overlapping range maps what was there before. A source page with nothing mapped, or a null source, leaves the destination unmapped.d3d12_xs_device.cpp: queue slot 31 walks the batches and hands each range to that hook. It returnsS_OKwhen every range was applied andE_INVALIDARGwhen one was refused (outside the pool, an unknown kind, or xmem refusing it, logged once). When xmem is not linked (tests that compile the proxy alone) the slot is refused as before, socheck_tailis unchanged.Known gap (raised in review): the mappings change when the call is made, while on the console the batch takes effect in queue order. The title does not drain the queue before the call in the function that makes it (
XMemMapPhysicalPagesScatterat+0xf2cc3e, then slot 31 at+0xf2cc7f); whether earlier work can still read a destination page then is not measured. A strict version would apply each batch when the queue reaches it.Not in scope: the console maps GPU page tables, the layer maps CPU views. Whether the GPU sees a destination page follows from how that window reaches the GPU, the same as for any
XMemMapPhysicalPageswindow; this pull request does not change that.Tested
Native Windows 11, MSVC 19.44 (VS 2022 Build Tools), Ninja, RelWithDebInfo, on
main3d3770c16(rebased ontoa28927849, a docs-only change):xmem_test: newtest_copy_page_mappings(a run, one page repeated, a run ending in an unmapped pool page, a null source, an overlapping range, a destination outside any window, unaligned destination and source); a write through the destination is read back through the pool. All checks pass.xs_proxy_mock_test: newcheck_queue_copy_page_mappingswith a recording stand-in for the hook (the four kinds, the destination moving on past a kind-3 range, a range past the pool, an unknown kind, xmem refusing, no batches, and the old refusal without xmem). PASS.repeat_firstfailsxmem_test; not moving the destination on for kind 3 failsxs_proxy_mock_test.boot-prototypefa497b930with an earlier local version of the same mapping): by the 32nd call every page the title sent was handled (3,150 mapped, 211 unmapped, none refused). What it changes further on I cannot say yet: on that machine the run ends at about 25 s on a lost Vulkan device first, which this does not touch.GPUs tested: none needed for the two tests (no GPU); the boot above on an RTX 4060 Laptop, NVIDIA 576.80, Windows 11.
AI-assisted: yes
Checklist
mainand merges cleanly (a conflicting pull request is labeledneeds rebase).docs/design.md, with how it was confirmed. (n/a: no translator change)🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.