Repository navigation
d3d12_xs: committed resources lease their size through the title's XMem hooks, so the first render targets pass the budget check (retail boot chain stop 17) - #7240
Conversation
The retail executable calls GetCustomHeapProperties (device slot 26) with the C convention: the hidden return buffer in RCX and the device in RDX. The proxy's generic forwarder assumed the PC C++ form (this in RCX, buffer in RDX), took the buffer for the device and crashed on its vtable right after D3D12XboxCreateDevice. Slots 25 (GetResourceAllocationInfo, same rule, inferred) and 26 (measured) now get thunks that accept either form: whichever of the first two arguments is the device proxy is `this`. The runtime's own code still calls the proxy through d3d12.h in the PC form. device_proxy_test calls both slots in both forms against WARP. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…nslate CPU handles
…ttedResource3 with Xbox descriptors, RT-5 stop 15) Slot 127 is past the PC device vtable and was refused with E_NOTIMPL. It has the argument list of ID3D12Device10::CreateCommittedResource3; the proxy now calls the PC device's with the Xbox layout word and flag bits cleaned as slot 76 does. Measured in ItsNotRexed#6982.
…(RT-5 stop 17) The retail title asserts when its first full-screen render targets leave more than 2 MiB of a fixed budget unused (docs/retail_boot_chain.md, ItsNotRexed#6982). The PC size is about width x height x element bytes; the console takes whole RDNA2 SW_64KB tiles. Slot 25 adds the difference per render target description and never lowers a size. Depends on ItsNotRexed#6973.
…ons (RT-5 stop 16) The title's descriptions carry the Xbox layout word and flag bits above the PC ones. Slot 25 now passes a copy with PC flags and a PC layout; the title's array is not written. Depends on ItsNotRexed#7078.
…nment, refuses null heap properties; tests pin heap flags, session and reference counts Review of ItsNotRexed#7052: dispatch and release through the ID3D12Device10 interface pointer (not the base device's vtable); keep every PC-valid resource flag bit, 0x400 included; null heap properties return E_POINTER; the test now passes non-zero heap flags and a protected session, checks the single release returns 0 for texture and buffer, and covers a distinct Device10 pointer.
# Conflicts: # runtime/shims/d3d12_xs_device.cpp # runtime/shims/d3d12_xs_device.h # runtime/test/xs_proxy_mock_test.cpp
# Conflicts: # runtime/shims/d3d12_xs_device.h # runtime/test/xs_proxy_mock_test.cpp
# Conflicts: # runtime/shims/d3d12_xs_device.cpp # runtime/shims/d3d12_xs_device.h # runtime/test/xs_proxy_mock_test.cpp
…em hooks (RT-5 stop 17) On the console a committed resource's memory is allocated with XMemAlloc, so it goes through the title's __XMemAllocationHooks__. The retail title budgets its first full-screen render targets with a per-thread hook that bump-allocates out of a range it reserved and asserts that less than 2 MiB is left; PC resources never allocated through the hooks, so the assert always fired. Slots 76 and 127 now allocate the slot-25 size of each resource through the hooks, held by the resource with SetPrivateDataInterface and freed when it is destroyed. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
|
@jacksonslab nice, and measured on the retail exe. I had a branch for the same thing ( Two things from our version and its Codex review that may help here:
On sizes: #7078 makes slot 25 answer the console tile sizes, so your lease takes 8,847,360 B for a 1080p RGBA8 target instead of the PC's about 8,323,072. Both are fine for the 2 MiB check as you measured. With #7078 the leases also match the console's own sums. AI-assisted. |
|
Retail A/B on CachyOS / Wine 11.22, RTX 4070 (620.73.04): applying the runtime delta from |
|
@jacksonslab hook leasing clears stop 17 on RDNA2 too, but only when the lease is the console tile size. As written, this PR leases slot 25's PC size plus #7078's extra, and on the AMD Windows driver that size is larger than the tile size, enough to overrun the 64 MiB arena. RX 6900 XT (gfx1030), AMD driver 26.11.2, Windows 11, MSVC,
Not run: this PR's own branch. The overrun is from the sizes above, not from a run of Suggestion: for listed render-target shapes, lease the console tile size itself, not AI-assisted (Claude Code). |
|
@jacksonslab follow-up to my comment above, now measured: a retail A/B of
Suggestion: when the render-target rule applies, lease the console tile size itself ( AI-assisted (Claude Code). |
…answer (ItsNotRexed#7240 review) The title's stop-17 range holds two 3840x2160 RGBA8 targets at 510 SW_64KB_D tiles each. AMD's Windows driver answers 513 x 64 KiB for that target, so leasing max(PC, console) overran the range and hit an int3 inside the title's hook (measured by controldebils on an RX 6900 XT). A listed render-target shape now leases its whole tiles; anything else leases the PC size. The mock gets a driver bias to reproduce the AMD answer. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
|
@controldebils thanks for the measurement and the A/B. Fixed in @jlric, @tedin7: thanks for the Wine A/B and for dropping the duplicate branch. AI-assisted (Claude Code). |
|
Independent Windows synthetic integration result for Applying the slot-25 validation follow-up (tedin7#2) and the separate #7125 test patch gave 10/10 focused CTests on each adapter with Vulkan validation enabled: |
|
Independent native Windows clang-cl/xwin check at d61755d. All six xs_proxy_mock cases passed, including the 513-tile PC answer / 510-tile lease regression. Stock device_proxy and device_proxy_trace reproduced the two documented slot-25 expectation failures each. Applying only the cleaned-description reference check from #7110 to the local test brought the full set to 8/8. The runtime was unchanged. #7110 at d7451f9 also passed all eight cases on this setup. Synthetic mock and WARP coverage. AI-assisted testing. |
|
Reviewed
One design question: slot 76 now leases every committed resource it creates, for the whole run, while the budget check was measured only around the two slot-127 targets. When no title matcher takes a lease, the chain ends in For whoever compares the two: #7235 ( Nit: AI-assisted. Synthetic tests only, no game files, no GPU run. |
|
@jacksonslab confirmed on the real AMD Windows driver, not just the mock:
Thanks for the quick fix. AI-assisted (Claude Code). |
|
Retail run of Setup: Windows 11, RTX 3070 Ti (NVIDIA 610.88), Ryzen 7 5800X, MSVC 14.51, Vulkan SDK 1.4.341,
AI-assisted (Claude Code). |
Slots 27/53 map the console initial state 0x6 (pc_initial_state_word); slot 76 maps it too and keeps ItsNotRexed#7240's lease. No same-slot clash: 27/53 were plain forwards. The mock keeps one slot-27 entry (creating, with a words-only mode for this PR's checks) and the PR's entry for 53. Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
|
checked: #7240 | with: clang-cl cross-build (xwin SDK, ninja, ccache) of runtime target xs_proxy_mock_test, run under Wine | on: Ubuntu, Wine 9.0 (x86_64 prefix), main@867d922f0 + #7240 (merges cleanly, no conflicts) | result: build ok, xs_proxy_mock_test prints PASS (exit 0), including the committed-resource lease checks (first lease 8,847,360 B = 135 tiles for 1920x1080 RGBA8 as the doc says); negative control: with lease_title_resource_memory() made to return at once in runtime/shims/d3d12_xs_device.cpp, the test fails at xs_proxy_mock_test.cpp line 1264 (g_heap_hook.alloc_calls == 1 && last_alloc_size == 8847360) and exits 1; NOT tested: device_proxy_test (needs a real D3D12/DXGI device, not run), real Windows, the retail title's hook (the attribute word 0x80<<16 | 2<<14 stays an assumption as the PR says), AMD driver sizes Details:
agent: yes |
|
Native Windows WARP follow-up on the slot-25 test expectation at The stock test’s expected value should call the host with a copy of |
|
checked: #7240d61755d | with: AI-assisted (Claude Code). |
|
Independent Windows/MSVC check of head d61755d in a temporary integration with the existing slot-25/56, slot-127, descriptor and startup work: 13/13 targeted tests passed, including lease/free behavior and normalized descriptor sizing. With Vulkan in Windows Sandbox configured with networking disabled and guest network checks, dry-run and init succeeded. The retail run logged a committed-resource lease through the title hooks, passed the prior breakpoint after the two committed resources, reached CreateRootSignature and CreateComputePipelineState, and then raised a C++ exception after the runtime reported that LEONIDA_SHADERS was not set. This experiment supplies no translated shader directory and does not establish a rendered frame or retail memory coherence. |
…wers console tile sizes for 2D render targets (slot 25 return-buffer form; sizes ItsNotRexed#7240 leases at stop 17) Squashed from ItsNotRexed#7078 by tedin7, head 3ace986 (security scan PASS). Conflicts with ItsNotRexed#6954 (slot 48): header comment, slot overview in d3d12_xs_device.h and the mock test's check list keep both PRs' slots; slot 25/26/56 text and device_slot_overridden take this PR's form (it contains ItsNotRexed#6964).
…get size (from ItsNotRexed#7240) Wave 2 port of the sizing half of ItsNotRexed#7240 (by jacksonslab) onto ItsNotRexed#7235/ItsNotRexed#7411's xmem_size: a listed 2D render target asks the title's XMem hook for its whole console tiles (console_render_target_size, slot 25's answer), not the PC GetResourceAllocationInfo size. On AMD (RDNA2, RADV too) the PC answers 33,619,968 B for each 3840x2160 RGBA8 target, so the two stop-17 targets overran the title's 64 MiB arena; the console size is 33,423,360 B (reviewers of ItsNotRexed#7235). ItsNotRexed#7240's own lease is not taken: it would ask the hook a second time for every slot 76/127 resource that ItsNotRexed#7411 already allocates through it.
…or heaps (ItsNotRexed#7021 review) With ItsNotRexed#7021, a descriptor heap whose memory the title's XMem hook gives hands the title CPU handles in that memory, and device slots 17-24 translate them to the layer's own slots. The layer's command list dereferences CPU handles itself in OMSetRenderTargets, ClearRenderTargetView, ClearDepthStencilView and the UAV clears, so a handle in the title's range read memory the view was never written to (reported as a blocker on ItsNotRexed#7021, d3d12_com.cpp). Those four entry points now go through translate_cpu_descriptor_handle, which returns other handles unchanged and costs one atomic load while no title-backed heap exists. Also shortens the xmem_size comment of the ItsNotRexed#7240 sizing port.
…t expectations) ItsNotRexed#7759 carries ItsNotRexed#7201's slot 86/101/108 handlers; its squash added them a second time next to ItsNotRexed#7201's copy (the 101/108 bodies are identical, and ItsNotRexed#7759's slot 86 keeps the PSO stream for slot 55), so ItsNotRexed#7201's copy is removed. xs_proxy_mock_test: the check_xbox_slots summary line merged for ItsNotRexed#7163 had its \n written as a line break; ItsNotRexed#7235's slot-127 hook check now expects no PC slot 25 call for a listed render target (the console-size port from ItsNotRexed#7240 sizes it, same 33,423,360 B); ItsNotRexed#7821's check_view_heap_cap releases the heaps it makes, since its CreateDescriptorHeap mock case is now ItsNotRexed#7021's, which makes a heap proxy holding the device. d3d12_vulkan_device_test: the meta-command checks run on the device behind the Xbox proxy, as ItsNotRexed#7125 does for CreateReservedResource2: proxy slot 61 is the title's CreateSamplerX (ItsNotRexed#7115).
LaugeM
left a comment
There was a problem hiding this comment.
This is the stop 17 fix to take over #7235 (and over the PC-size lease that #8072 and #8831 carry). Leasing the console tile size is the only form reported to clear stop 17 on both NVIDIA and AMD; leasing the PC answer overran the title's range on AMD's Windows driver.
The two open problems at d61755d4d both come from carrying an older copy of #7110 instead of its current head:
runtime/shims/d3d12_xs_alloc_size.h:77still readsMipLevels0 as one mip, as @tupacfan04 found. #7110's head already fixes it in the same header (d3d12_xs_alloc_size.h:84,full_chain).- The two
device_proxyslot 25 failures come from the expected value being computed on the uncleaned description. #7110's head has the cleaned-description check that a commenter here applied to get 8/8.
git merge-tree of this head with #7110's head (2f2fb2fbb) conflicts in d3d12_xs_device.cpp, d3d12_xs_device.h, xs_proxy_mock_test.cpp and docs/d3d12_vulkan.md. Rebasing onto #7110's head as it is now should fix both points without new code here. lease_size (d3d12_xs_device.cpp:1710) then gets the full chain through console_render_target_size.
AI-assisted review (Opus 5.5). Read the diff against main; not built. Merge checks with git merge-tree against main and #7110's head.
Claimed in the coordination issue: #7049 (comment) (RT-5 stop 17).
Depends on: #7021 (the title's
__XMemAllocationHooks__plumbing), #7052 (slot 127) and #7110 (slot 25, stacked on #7078 and #6973). This branch merges their heads, so until they land the diff also shows their commits; only the last commit,d3d12_xs: committed resources lease their size ..., is this PR. At run time the title's hook chain ends inXMemAllocDefault, so the retail boot also needs a PR that serves it (#6919, or any other).What and why
Stop 17 of the retail boot chain (#6982's numbering; @KkelebekK's 17 in #6910): right after the first two slot-127 render targets, a soft assert fires because more than 2 MiB of a fixed budget is left over. #7078 approached it through the sizes slot 25 reports. On the retail executable that isn't enough, because the budget isn't compared with those sizes directly:
XMemAlloc, so it reaches that hook. On the PC, no resource ever allocated through the hooks, so the whole range was always left over, whatever slot 25 answered.This PR:
lease_title_resource_memory(ind3d12_xs_device.cpp): after slots 76 and 127 create a committed resource, the proxy allocates the resource's size through d3d12_xs: honour __XMemAllocationHooks__ for descriptor heaps and translate CPU handles #7021's installed allocator (the title's hooks). The size is slot 25's answer for the same clean description (console_allocation_size: the PC size plus d3d12_xs: GetResourceAllocationInfo answers console tile sizes for 2D render targets (slot 25 return-buffer form; sizes #7240 leases at stop 17) #7078's tile padding), which is the figure the title budgets with.IUnknownholds it and is attached to the resource withSetPrivateDataInterface, so the hooks' free runs once, when the resource is destroyed. The bytes are not used for the resource; the PC/Vulkan device owns its memory.0x80(eXALLOCAllocatorId_D3D) with page-size field 2 and object type 0. The measured matcher reads only the page-size field.docs/d3d12_vulkan.md: one paragraph after d3d12_xs: GetResourceAllocationInfo answers console tile sizes for 2D render targets (slot 25 return-buffer form; sizes #7240 leases at stop 17) #7078's slot-25 text.Tested
Windows 11, Intel Core i7-14700K, NVIDIA RTX 4070 SUPER, MSVC 2022 (14.44) RelWithDebInfo, Visual Studio generator.
xs_proxy_mock_test: PASS. Newcheck_committed_resource_leases:0x808000.SetPrivateDataInterfacereference until the object is destroyed, as the layer's objects do, and answers PCCreateCommittedResource(slot 27, seven words) from its own entry.device_proxy_test: 2 failures,slot 25 (C ABI) writes the PC device's GetResourceAllocationInfo into the caller's bufferandslot 25 still answers the PC (C++) form. They fail the same way on this branch with this commit removed: d3d12_xs: GetResourceAllocationInfo answers console tile sizes for 2D render targets (slot 25 return-buffer form; sizes #7240 leases at stop 17) #7078/d3d12_xs: device slot 25 cleans the Xbox layout word and flag bits on a copy before the PC GetResourceAllocationInfo (retail boot chain stop 16) #7110 pad slot 25, and that test still expects the unpadded PC size. Not caused by this PR, so I haven't changed it here.python -I scripts/check_no_game_data.py: exit 0.gta6rt --run --trace --trace-d3d12,LEONIDA_D3D12=vulkan, on an integration tree ofmain+ Loader: the mapped game executable owns module TLS index 0 (RT-259) #4313-style primary TLS, xgameruntime: serve XErrorReport (rebase of #5312) #6582, runtime: console DirectStorage (DStorageGetFactory) with file-to-memory reads #4348, d3d12_xs: console-ABI command lists, upload arena, PC-list fixture path #2490, d3d12_xs: honour __XMemAllocationHooks__ for descriptor heaps and translate CPU handles #7021, d3d12_xs: Xbox device slot 70 is handled by the proxy (a null SRV for now, its raw words logged), not the PC CreatePlacedResource1 (retail boot chain stop 14) #7066, d3d12_xs: Xbox device slot 127 creates a committed resource through the PC CreateCommittedResource3 (retail boot chain stop 15) #7052, d3d12_xs: device slot 25 cleans the Xbox layout word and flag bits on a copy before the PC GetResourceAllocationInfo (retail boot chain stop 16) #7110, d3d12_xs: Xbox device slot 61 is CreateSamplerX, routed to the PC CreateSampler (RT-5 stop 20) #7115, RT-500: gta6rt emulates the Zen 2 instructions an Intel CPU lacks (INSERTQ/EXTRQ, CLZERO, MONITORX/MWAITX, CLWB) #7111, file_system: drop FILE_FLAG_NO_BUFFERING, so the retail exe's unaligned archive reads succeed #7099, runtime: serve chad, xapu, xg_xs and AcpHal console audio/DSP/texture imports (RT-5 follow-up) #7009, and local physical-page and default-allocator stand-ins (as in xmem: serve the seven missing imports (physical pages, default allocators, XMemIsToolsMemAvailable); XMemVirtualAlloc takes 2 MiB pages and placeholders #6919/xmem: serve XMemAllocatePhysicalPages, XMemFreePhysicalPages and XMemMapPhysicalPages[Scatter] (RT-5 next stop) #6995):XboxBvhBuilderC++ exception afterno translated shaders(@KkelebekK's stop 18; no translated shaders on this machine yet).XMemAllocDefaultunserved, the hook chain returns null and the assert still fires. That's why xmem: serve the seven missing imports (physical pages, default allocators, XMemIsToolsMemAvailable); XMemVirtualAlloc takes 2 MiB pages and placeholders #6919 (or another PR serving it) is needed at run time.No game data: only export, API and SDK names, attribute values, slot numbers, sizes of synthetic descriptions and counts.
AI-assisted: yes (Claude Code).
🤖 Generated with Claude Code