d3d12_xs: the title's XMem hooks, console render-target sizes and resource leases, again (RT-XMEM-LEASE) #375
No reviewers
Labels
No labels
accessibility
bug
documentation
duplicate
enhancement
good first issue
help wanted
invalid
missing claim
needs rebase
question
wontfix
No milestone
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set
Reference
github/ubiquitarianism--leonida!375
Loading…
Reference in a new issue
No description provided.
Delete branch "gh-pr/375/head"
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?
@Mumogg on GitHub · 2026-11-24 04:07 UTC · original
Mumogg:xmem-hooks-sizes-lease→main· +1453 −42 · 11 files · 11 commits · merged 2026-11-24 22:12 UTCClaimed 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. Onmainnothing goes through those hooks, so the whole range is left.tools/int3_cause.pyon the stop shows the comparison against0x1fffff.Clearing it takes three pieces that build on each other. All five commits are cherry-picked with
-xand keep their authors; all are ancestors ofmainwhose content is not in the tree.355201c51__XMemAllocationHooks__honoured for descriptor heaps; device slots 17 to 24 translate CPU handles in the title's own range (old PR 7021)889785539c7ca0f2d1359390833ae322dafcWhat I changed while resolving conflicts, so a reviewer knows where to look:
proxy_get_resource_allocation_info:c7ca0f2d1and359390833come from two branches of the original series; I resolved them as the original merge commit (aeb253754) did, including the mock's helper block.359390833removes. 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.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) andbee47186f.One thing a maintainer should decide:
355201c51is the title-backed descriptor heap model.mainalso 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
mainece4ba5b3, with #142 and #328 applied on top for the boot runs (they are not in this branch).--runint3on the 2 MiB budget checkint3after its device set-up returns false; the last new slot called is 41With 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_testunder 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_testalso gets cases from355201c51; I cannot run it here (it stops atD3D12XboxCreateDevice returns a deviceunder Wine, onmaintoo).AI-assisted (Claude Code); built and run on the machine above.
🤖 Generated with Claude Code
https://claude.ai/code/session_01HxBQf4pXH8PWpC5oZsM4bt
@ubiquitarianism on GitHub · 2026-11-24 05:04 UTC · original
Holding this. #362 and #369 are merged. With this PR on top of them, a Windows MSVC build (AMD RX 6800, WARP for the proxy test) fails three checks that pass without it:
The console tile sizes for slots 25 and 56 change what GetResourceAllocationInfo returns, so it no longer matches the PC device these tests compare against. Either scope the console sizes to the title's resources, or update the tests to state the new contract, with a reason.
Follow-ups from review, not blocking on their own:
proxy_create_descriptor_heapapplies the hook-backed address even when main's console-extended handler created the heap. It should require!console_extended.translate_cpu_descriptor_handlehas no callers, so command-list CPU handles (OMSetRenderTargets, Clear*View) aren't translated for title-backed heaps.#377 and the PRs stacked on it wait on this and on the ExecuteIndirect fix noted there.
@fiestorra on GitHub · 2026-11-24 07:14 UTC · original
Tested your change against the retail title on today's
main. Based42773d07. Windows build 26300, MSVCRelWithDebInfo,LEONIDA_D3D12=vulkanon a Radeon 780M integrated GPU (gfx1036), 1.0.2.1 executable and package. Written with an AI assistant.Good news first: the five commits are now clean on top of
main. The parts of your branch that are not inmain(0a714544d,856334399,584ef36fa,f1a68eeff,35e687f2a) cherry-pick ontod42773d07one after another with no conflicts — 11 files, +1419/−40 — and the build succeeds. #349, #350, #356, #362 and #369 have all landed since you opened this, so the neighbours you were resolving against on both sides are gone. A rebase onto the currentmainlooks mechanical.What you fix is now behind a wall this pull request does not cross. On
d42773d07with your five commits applied, the title stops exactly where it stops without them: 13 recorded D3D12 calls, device slot 73CreateCommandListXrefused for the console command-list IID, and the title's own assert0x80000003atgame_scarlett_master.exe+0x2478b7b. Nothing in your change is reachable until one of #142, #359 or #445 answers that IID, so I would add one of them to your "depends on" list — as written, a reviewer following your dependency chain cannot get this far on today'smain.With the IID answered, your change clears the budget check you describe. I added #445's mapping on top (nothing else) and re-ran: the assert your body describes is gone. That check is visible in the executable —
add rax, …; cmp rax,1FFFFFh; jbe <ok>; int 3atgame_scarlett_master.exe+0x247af2d, inside the function the title reaches from a call at+0x247942b, so it is a span the title requires to stay under 2 MiB. In the earlier run that call faults; with your commits applied the same call returns and the title continues to+0x247944f, which is where the run ends now. The XMem events in the startup trace also grow from 7 to 9, which fits your hooks being used.And here is what it hands over, which I could not fix and am reporting rather than claiming. The run ends with a C++ exception,
0xe06d7363(a throw, not an assert), thrown from insideXboxBvhBuilder.dll:The title got there through the call at
+0x247944f, which iscall qword ptr [game_scarlett_master+0x6793f78]— a function pointer the title holds in its own data, not an import-table entry (I walked the image's import directory and that address is not in it, so it was filled at run time). The D3D12 side is otherwise unchanged from the run without your commits: same 1639 recorded calls, 1619ok, ending onID3D12Device::CreateUnorderedAccessView. So on this machine your change moves the stop from the title's 2 MiB span assert to the title asking the BVH builder to do something and the BVH builder throwing. What it was asked to build, and why that throws, I have not established.Limits, so you know what this evidence does and does not cover: one machine (integrated Radeon 780M, gfx1036), no Vulkan NVIDIA comparison for this part. I did not run
xs_proxy_mock_test.cppordevice_proxy_test.cppfrom your branch — I tested by running the title. Combined with #445's mapping only, not with #359's retry form.@VibeClauding on GitHub · 2026-11-24 07:37 UTC · original
Same three failures on NVIDIA (RTX 3070, driver 610.88, Windows 11, MSVC), with #432's stack merged onto
main8f481cf16and on #432's branch alone. Bisected over the stack withdevice_proxyas the test: the first bad commit is584ef36fa("device slot 25 gives the PC device clean resource descriptions");0a714544dand856334399before it pass.d3d12_vulkan_device'sallocation_mismatchescheck fails on the same stack (not bisected separately). AI-assisted.@Mumogg on GitHub · 2026-11-24 09:54 UTC · original
Updated: rebased on
maind7576d56a(so the branch is now only its own commits) with four more on top.The three failing checks. I took the first option, scoping the console behaviour to the title's calls:
b4d1ba179(Johan John Joji,-x, from the integration history): slot 25 cleans the description only for a console-form call or the console tiled layout; a PC-form caller's flags and layout reach the host unchanged. Plus the one-line clang-cl fix that follows it there (inline constfor the 0x101 layout).xs_proxy_mock_teststates the new contract: its PC-form slot 25 case now expects the mock device's size, and the mixed slot 56 case is asked in the console form.What I could and could not verify here.
device_proxy_testneeds WARP, which Wine does not have (D3D12CreateDevicefails, "no device"), so I cannot run the two slot 25 checks that failed for you; the change follows from reading them, and they need a Windows run.d3d12_vulkan_device,xs_proxy_mock,queue_proxyandallocator_proxypass under Wine (RTX 5070 Ti, driver 615.78.08, clang-cl 22.1.8).d3d12_vulkan_devicereaches the proxy in the PC form, so it should be covered, but I did not reproduce its failure before the change, so I am not claiming I fixed it. Thanks to VibeClauding for the bisect.Follow-ups.
!console_extended: done, in its own commit.translate_cpu_descriptor_handlewithout callers: #416 is the commit that gives the list proxy its callers (console list slots 50 to 54).The title's retail run with the whole stack is in #602. To fiestorra: thank you for the Windows run; the
XboxBvhBuilderthrow is outside what this branch touches and I have not looked at it.AI-assisted.
@DesertGamer on GitHub · 2026-11-24 14:11 UTC · original
Check on a second NVIDIA machine (Windows 11, RTX 5070, driver 617.14,
LEONIDA_D3D12=vulkan, own 1.0.2.1 copy): this pull request merged on top ofmain21625bca8+ #641 + #427 + #727 + #602 + #387 + #357 + #432, which reaches the frame loop, keeps it there: 549,783PresentX okand 19,857,246 D3D12 calls in 200 s, no exception, merged without conflicts. I did not check what the resource leases and render-target sizes do to the frames (still black on this stack).AI-assisted: yes (Claude Code, Sonnet 5.5)
@aslan2142 on GitHub · 2026-11-24 20:55 UTC · original
@Mumogg this PR is the gate for
main's current stop (1,639 D3D12 calls, the title's 2 MiB budget check), so we want it in. We'll merge it as soon as it's rebased and the three held checks are confirmed.mainagain since your 09:54 update. Could you rebase onto currentmain?device_proxy_testchecks from the hold: your update scopes the console behaviour to the title's calls, and you said you couldn't run that test. I'm building this branch merged with currentmainnow and will rundevice_proxyand the related tests under Wine (clang-cl with the xwin SDK), then post the results here.device_proxyon0c5a14659, or on the rebased head once it's up?AI-assisted (Claude Code, Claude Fable 5.2).
@Mouad-Scriptz-0 on GitHub · 2026-11-24 21:59 UTC · original
This conflicts with
main, and it's first on the path to the frame loop, so here's a rebase to save a step:rebased/pr375(799d93d8d). It has the same 9 commits and authors onmain4a50cafc7.git range-diffagainst this branch shows no commit's own change was altered; only the surrounding context moved.Every conflict was an add/add. I kept both sides:
runtime/shims/d3d12_xs.cpp:main's newcreate_versioned_root_signature_deserializer, then this PR'sxmem_descriptor_heap_alloc/xmem_descriptor_heap_free.runtime/test/xs_proxy_mock_test.cpp, mock struct:main'smax_leveland this PR'sheld. Both live in the zero-initializedg_pooland are set by name, so their order doesn't matter.runtime/test/xs_proxy_mock_test.cpp,main()'s check chain:main'scheck_presentation_wiring()followed by all five of this PR's checks (check_descriptor_heap_hooks,check_render_target_sizes,check_allocation_descriptions_cleaned,check_render_target_layout,check_committed_resource_leases).Not compiled or run here: I have no Windows SDK on this machine, so CI is the first build.
To take it (maintainer edits are on):
AI-assisted.
@aslan2142 on GitHub · 2026-11-24 22:13 UTC · original
Merged. Mumogg has been away since this morning and this PR is the gate for
main's current stop (1,639 D3D12 calls, the title's 2 MiB budget check), so, as agreed among the maintainers, I brought the branch up to date myself: two merge commits ofmainon top of0c5a14659(94f2773c1, thend15a91601formain4a50cafc7). Mumogg's nine commits and their authors are untouched, and nothing was force-pushed.Conflicts: three, each from additions on both sides, both kept.
runtime/test/xs_proxy_mock_test.cpp: the mock'sheldnext tomain'smax_level, and this PR's five checks next tocheck_presentation_wiring().runtime/shims/d3d12_xs.cpp:main'screate_versioned_root_signature_deserializer(#758) next toxmem_descriptor_heap_alloc/free.Thanks @Mouad-Scriptz-0 for the independent rebase: it resolves the same three places the same way, and differs from this branch only in the order of two lines in the test.
The three checks behind the hold:
device_proxy, both slot 25 checks: with the four commits since the hold reverted, both fail under Wine (which has a WARP adapter here); with them, both pass. GitHub's Windows job also passeddevice_proxyon this PR merged withmain, on real WARP.d3d12_vulkan_deviceallocation_mismatches: not measured. The host comparison is skipped under Wine, and CI skips the test (no Vulkan). From the code it should pass: a PC-form call reaches the Vulkan device exactly as onmain, and no case incompare_allocation_infouses0x101. A run on Windows with a Vulkan GPU would settle it:ctest -R "^d3d12_vulkan_device$" -Vshould print noallocation infolines and not skip the comparison. If it is red, I'll fix it forward or revert.Tests, the merged branch against
mainon the same commit (Linux; clang-cl with the xwin SDK; Wine, headless; llvmpipe and an RDNA2 iGPU):ctest: 74/74 on both.maindoesn't also have.device_proxy,device_proxy_trace,xs_proxy_mock*,d3d12_vulkan_device,queue_proxy,allocator_proxy, the loader tests andd3d12_close_paritypass on both.Next: #546 reads the same export with its own struct and conflicts with this in
pe_loader.cpp; it fits on top of this PR using its registry. #377 is the next rung of the stack.AI-assisted (Claude Code, Claude Fable 5.2 and Claude Opus 5.5).
@Diegobecker07 on GitHub · 2026-11-24 22:32 UTC · original
The check left open above, measured on Windows with a Vulkan GPU, plus the retail boot after this merge.
Setup:
main51a6074d2(contains this PR). Built withscripts\build_runtime.ps1(MSVC 19.44, CMake 3.31.6 + Ninja). NVIDIA GeForce RTX 5070 Ti, driver 621.24, Vulkan 1.4.357, Windows 11 Pro 26300, Ryzen 9 5900X, 48 GB.ctest -R "^d3d12_vulkan_device$" -V: passed (20.7 s), and the comparison ran against the host device.GetResourceAllocationInfo: no host D3D12 device to compare with, skippedline.compare_allocation_info(the stderr formallocation info <case>: ours size … alignment …, host size … alignment …).allocation info <case>: alignment …, size ours … host …lines: that is the informationalprintffor every case with a top-mip size, so "noallocation infolines" can't be the criterion on a run with a host device. In 45 of them the sizes are equal. The one difference is64x64 BC1 small(alignment 4096, ours 8192, host 4096), which the case's rule accepts (same alignment, a multiple of it, at least the top mip).device_proxy,xs_proxy_mock,pe_loader: passed, 6 runs each.Retail boot (own 1.0.2.1 copy,
LEONIDA_D3D12=vulkan,--trace,--trace-d3d12, overlay outside the package):committed resources lease their size through the title's XMem hooks (first: 33423360 B)), and the title goes on toXboxBvhBuilder.dll's firstCreateRootSignatureandCreateComputePipelineState.XboxBvhBuilder.dll(the stop 18 shape indocs/retail_boot_intel_host.md).mainbefore this PR, left the budget stop unchanged.AI-assisted.