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). |
tupacfan04
left a comment
There was a problem hiding this comment.
runtime/shims/d3d12_xs_alloc_size.h:77 treats MipLevels = 0 as one mip:
const UINT mips = desc.MipLevels ? desc.MipLevels : 1;In D3D12, MipLevels = 0 means the full mip chain. The lease path uses this helper (d3d12_xs_device.cpp:1710-1711) and both slot 76 and slot 127 lease through it, so a full-chain render target is underleased.
Synthetic 2D RGBA8 render targets:
- 1920×1080: helper 135 tiles = 8,847,360 B; full chain 192 tiles = 12,582,912 B (underlease 3,735,552 B).
- 3840×2160: helper 510 tiles = 33,423,360 B; full chain 702 tiles = 46,006,272 B (underlease 12,582,912 B).
The measured stop-17 targets are 1-mip, so the retail runs above are not invalidated; the gap is for any full-chain resource leased through slots 76/127.
Missing regression: the actual stop-17 form is a 2D render target through slot 127, but xs_proxy_mock_test.cpp:1238 tests slot 76 with an RT and slot 127 with a buffer. Add a slot-127 3840×2160 1-mip case (33,423,360 B lease) and a MipLevels = 0 full-chain case.
Secondary: hiddenblur’s concern about slot 76 leasing every committed resource for its lifetime is still open and is a design risk; not new here.
No C++ toolchain was available for this review; the figures come from the helper and the PR’s tiling model. Synthetic only; no game files. AI-assisted (OpenCode).
|
Tested
Everything else ( |
|
Independent native retail before/after of both #7240 implementation commits (
I also prepared the builder's 52 embedded programs locally: 52 unpack, 52 disassemble cleanly with the Python backend, and 52 translate / pass spirv-val with wave64 emulation. That is offline translation validation only, not evidence that those pipelines were created in the retail run. I am checking the builder separately to avoid attributing its exception to missing translations without proof. Native Windows 26300, RTX 5090 / 32.0.16.2124, clang-cl 21.1.8 + xwin SDK 10.0.26100, static CRT, Vulkan; no validation layer installed. Same local startup integration on main |
|
RX 7900 XT / RADV integration result at #7240 d61755d: the previous allocation breakpoint is cleared, and startup reaches CreateRootSignature / Xbox CreateComputePipelineState, then stops on a missing local shader-library index. No frame or playable boot. Compared with our #7235 diagnostic:
This is a combined-stack comparison, not an isolated size-only A/B: #7240 also brings slot-25 description cleaning/tile sizing and slot-76 leases. It supports progress past the allocation stop on this configuration, not proof of general sizing correctness or guest-VA/GPU backing. Base: main 8575d36 + #6919 (36936f3), #4313 (28ea6b9), #6582 (4224c53), #4348 (45c39cf), #6954 (72ab762), #7076 (c7eaea3, carrying the older #2490), #6973 (5dbc30b, closed), #6964 (0d73e8b), #7021 (355201c), #7216 (5e45c7d), #6953 (4b76715), #7075 (e0b300f), #7066 (1d8d1d3), #7052 (9ec9291), plus this PR d61755d. Its carried #6973/#7021/#7052 match; new carried points are #7078 8897855 and #7110 c7ca0f2 (both older than their current heads). Started from the pre-lease control: no #7235 or attach_xmem_backing. Local integration retains the previously disclosed slot-26 conflict choice, console queue route and descriptor translation. The section-view cache-bit mask remains a local reproduction credited to ramenbellic/gkissel, not a test of their exact commit. No new production adaptation for this merge. Test-only unions retain prior checks; duplicate slot-27 mocks required one combined typed/word recorder. The initial test compile failed; the corrected build succeeded. Selected tests: 36/40, unchanged failures. All seven proxy mock modes pass, including this PR's render-target sizing, cleaned descriptions, lease lifetime, 513-PC/510-console-tile regression, and existing slot-127/133 checks. The four failures remain Wine's native abort exit-code / missing-TMP cases and device_proxy/device_proxy_trace failing WARP creation with E_INVALIDARG; hardware-level proxy tests remain unverified. This does not resolve the full-mip-chain or slot-76 commit-charge concerns raised above. Wine 11.18, Mesa RADV 26.2.3, LLVM 23.1.6 clang-cl/xwin, own local 1.0.2.1 package, Vulkan backend. One display-enabled, network-isolated, 30-second bounded run. Executed by the collaborating runner; source snapshot and exe/PDB/DLL hashes, tests and trace outcome reviewed against matching provenance. Shader-only setup is next; all extracted content and raw diagnostics stay local. AI-assisted. |
|
Follow-up after preparing the builder's shaders locally: 52/52 unpacked and cleanly disassembled, 52/52 translated with wave64 emulation and passed spirv-val. Nothing was attached or committed. With Repeating retail boot with the same prepared library now gets beyond the builder's previous exception and reaches 1,656 traced D3D12 calls, then the later renderer-init breakpoint described by #7330 (mesh command-signature creation). Still no frame/menu. The earlier cold retail attempt ended differently after a long constructor attempt, so the bounded warm repeat and the isolated fixture are the concrete results reported here. Same Windows 26300 / RTX 5090 (32.0.16.2124), clang-cl/xwin static-CRT stack as above; no Vulkan validation layer installed. Network debugger guards retained. Counts/outcomes only, no shaders or raw traces shared. AI-assisted (Codex). |
|
Independent check on the retail executable: pass — it clears stop 17, and the run now goes past the int3. Setup:
Merge notes: the branch merges #7052/#7110/#7021, so I applied only this PR's two commits (
Tests: AI-assisted: yes. |
|
Retail boot result and a merge note, from Wine 11.22 on a Radeon 760M (RADV Mesa 26.3.1), my own 1.0.2.1 executable, clang-cl 23.1.5 + xwin. Clears stop 17. Committed resources lease 33,423,360 B per target through the title's XMem hooks, and the title goes on to root signatures, compute pipelines and, with the later device-slot PRs, Merge note: on a stack with #6964 (slot 26), both PRs define AI-assisted (Claude Code). |
xs_proxy_mock_test: ItsNotRexed#7240 was written against an older ItsNotRexed#7110 mock; its texture size bias moves into the current mock_one_allocation and its lease check joins the check list. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Slot 76 keeps ItsNotRexed#7240's lease and maps the initial state as ItsNotRexed#7356 does. The mock's slot 27 entry from ItsNotRexed#7240 also records the words after the fifth for ItsNotRexed#7356's check, and creates a resource only when riid and output are real pointers. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
|
Tested on the retail boot (head Setup: native Windows 11, RTX 5060 Ti (NVIDIA), Ryzen 7 8700F, MSVC RelWithDebInfo, Counts and stop numbers only, no game files. AI-assisted (Claude Code). |
|
Synthetic stop-17 integration check from Claude Code, run with MSVC 14.44 / Windows SDK 10.0.26100. All three trees used the same
Both targets were created successfully in all three trees. The boot-integration handler took precedence in the failing merge. Keeping this PR’s slot-127 route restored leasing for both targets. In both merged trees, the separate slot-133 placed-resource stand-in forwarded through slot 76 and leased 182,452,224 B for a synthetic buffer. A first-lease diagnostic can therefore identify that buffer when it runs first, independently of whether the target leases work. The exact PR tree has a 128-slot table. The merged builds restored missing includes and needed two inert link stubs for this mock. The unfiltered mock suite passed on the PR tree. Both merged trees stopped at the existing queue expectation (line 1109), where boot-integration implements a slot the isolated test expects to refuse. These results cover the synthetic budget check. AI-assisted (Claude Code, output reviewed with Codex). Native Vulkan follow-up (Codex). I combined #7218 at A test-only addition to
The seven focused CTests ( |
|
Tested
|
…d#7052 and ItsNotRexed#7240 One PC slot 76 mock records for both the slot 133 and the slot 127 checks; one slot 27 mock keeps ItsNotRexed#7075's record and ItsNotRexed#7240's generic path. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
|
Review note for #7240 at The new block calls slot 25 with const D3D12_RESOURCE_ALLOCATION_INFO want = real->GetResourceAllocationInfo(0, 1, &desc);But The proxy's answer is the right one. Comparing with the PC device's answer for a D3D12_RESOURCE_DESC pc_desc = desc;
pc_desc.Layout = D3D12_TEXTURE_LAYOUT_ROW_MAJOR;
const D3D12_RESOURCE_ALLOCATION_INFO want = real->GetResourceAllocationInfo(0, 1, &pc_desc);Measured on Windows 11, MSVC 19.42 (VS 2022 17.12), Windows SDK 10.0.26100, WARP adapter, AMD Ryzen 7 5800X3D / Radeon RX 9070 XT machine. Seen on a local merge of Also, for whoever merges this over #6964 (they overlap on slot 26): #6964's own 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>
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>
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