Repository navigation
d3d12_xs: device slot 70 finds the buffer slot 133 placed at its address in the proxy (a real view on the PC device and with #7075's stand-in; complements #8225) - #8304
Conversation
…e PC vtable refuse with E_NOTIMPL The retail title calls device slot 133, past the 128-entry table; the call read an empty entry and jumped to 0. Every slot beyond the PC device's vtable now reaches the generic thunk. Mock test covers slot 133. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…ory (VK_EXT_external_memory_host) The retail executable opens the 64 KiB graphics region it has just committed with XMemVirtualAlloc through device slot 48 right after its first queue and fence; the layer answered E_NOTIMPL and the title asserted. The call now answers as the host runtime does on an RTX 4090 and WARP (six cases measured in d3d12_existing_heap_test): the base of a VirtualAlloc allocation committed read-write over its whole size opens a heap of that size, 64 KiB aligned, CUSTOM / WRITE_BACK / L0, SHARED | SHARED_CROSS_ADAPTER | ALLOW_SHADER_ATOMICS; an inner address, a partial or reserve-only commit and a read-only range are E_INVALIDARG. The backing is the range itself, imported with VK_EXT_external_memory_host, which the device and the test device enable when present. CheckFeatureSupport(EXISTING_HEAPS) follows the extension. Placed resources in such a heap are refused (E_NOTIMPL, logged) until the placed path addresses memory outside the arena. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
… an uncached one is refused Measured on the RTX 4090 and WARP: PAGE_READWRITE | PAGE_WRITECOMBINE is accepted with CPUPageProperty WRITE_COMBINE, PAGE_READWRITE | PAGE_NOCACHE is E_INVALIDARG. Two new cases in d3d12_existing_heap_test; 8 of 8 match both host devices. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…nslate CPU handles
…e (CreatePlacedResourceX stand-in) Xbox device slot 133 is (va, desc, initial_state, clear_value, riid, out), the shape of the console's CreatePlacedResourceX. With ItsNotRexed#6953 the call reaches the beyond-table refusal and the title asserts on the E_NOTIMPL. The proxy now answers it before that refusal: a committed DEFAULT-heap resource from the description with the PC flag bits only, slot 76's layout rule, COMMON for a buffer or the all-ones state, and the clear value only for render-target and depth textures. The resource is not backed by the memory at va; that needs the physical-page mapper. xs_proxy_mock_test: a mock CreateCommittedResource that records its arguments, and a slot 133 case over a 76-slot device (buffer, render target, all-ones state, null arguments, a failed creation). The beyond-table check moves to slot 134. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…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.
…ead of reaching PC CreatePlacedResource1 (retail boot chain stop 14)
…0 wins over the built-in slot 70 handler With LEONIDA_XS_FRAME_INTERVAL_SLOT=70, (0, 16667, 1, 0) reached the null-SRV writer and sent latency 1 as the CPU descriptor handle. The routes now live in route_xbox_device_slot, which slot 70 asks first. New xs_proxy_mock_env_slots_70 test fails before and passes after.
…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.
…resource # Conflicts: # runtime/shims/d3d12_xs_device.cpp # runtime/shims/d3d12_xs_device.h # runtime/test/xs_proxy_mock_test.cpp
…n and runs on its own line, clear of the slot 73/list changes in ItsNotRexed#7076 Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…he title's own pages Xbox device slot 133 is (va, desc, state, clear, riid, out): the title places a buffer at the VA of a physical-page range it has just mapped (docs/retail_boot_chain.md 3.4, ItsNotRexed#6915). The proxy now hands it to a handler the Vulkan layer registers (set_placed_at_va_handler), which imports [va, va + width) with VK_EXT_external_memory_host and binds a VkBuffer to it: the CPU's writes there are the GPU's reads with no copy, and the resource's console VA is the title's VA, so views and immediate writes the title names by that VA resolve to it through the buffer VA index. The Xbox flag bits above the PC ones are dropped and the layout made ROW_MAJOR, as slot 76 does; textures are E_NOTIMPL, a misaligned VA E_INVALIDARG, and with no handler (a PC device) the slot refuses with E_NOTIMPL as ItsNotRexed#6953's table does. Not decided here: a shader that adds heap_base to the title's VA (its own V#s) does not reach these pages; that needs the single address space of docs/d3d12_vulkan.md 3.3. d3d12_existing_heap_test: on a VirtualAlloc range and on a view of a pagefile-backed section (the form xmem's physical pages take), the buffer's GPU VA is the address and a GPU copy to a READBACK buffer reads a pattern the CPU wrote after creation; Vulkan validation clean on an RTX 4090. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…(XMem allocation hooks for descriptor heaps)
…le's XMem hook (retail boot chain stop 17) The console D3D runtime allocates a committed resource's memory with XMemAlloc, so a title's __XMemAllocationHooks__ see it. Around its first full-screen render targets the title installs a hook that bump-allocates allocations with page-size field 2 from a fixed arena and then asserts that little of the arena is left unused; with no call reaching the hook, nothing is counted and the assert fires. After the PC device creates the resource, slot 127 calls the installed hook (the one ItsNotRexed#7021 bridges for descriptor heaps) with the PC allocation size and the D3D allocator ID, page-size field 2, and attaches the memory to the resource as private data, so it goes back through the hook's free when the resource dies. The PC resource is not backed by it. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…ler registered by every Vulkan device The PC flag mask was a D3D12_RESOURCE_FLAGS constant past the SDK's last enumerator, which clang-cl with SDK 10.0.26100 refuses as a constant expression; it is an integer now, cast after the AND. The slot-133 handler was registered in create_vulkan_device only, so the standalone device gta6rt --run creates never served the slot; the Device constructor registers it now. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
# Conflicts: # runtime/shims/d3d12_xs_device.cpp
… found in review) Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
… not import the title's pages RADV under Wine refuses to import a view of a pagefile-backed section (E_OUTOFMEMORY on an RX 9070 XT, found in review), which is the form xmem's physical pages take, so the retail boot stopped at the first 174 MiB placement. An import failure other than a misaligned VA now gives an ordinary DEFAULT buffer of the same description, as ItsNotRexed#6915's stand-in did, logged once: the boot goes on, and the title's writes at that VA don't reach it on such a driver. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…commit re-added it, found in review) Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…sured raw-buffer shape and the VA is a buffer the layer knows (retail boot chain stop 14) AI-assisted.
…and asks for a buffer that holds the whole width (review of the raw view) AI-assisted.
…CreateCommittedResource3 with it The word slot 133 passes after the description is a D3D12_BARRIER_LAYOUT, not a resource state: the title passes all ones (UNDEFINED) for its first buffer and 6 (SHADER_RESOURCE) for 1x1 render-target and depth textures. Read as a state, 6 is INDEX_BUFFER | RENDER_TARGET, which the PC device refuses for a texture, and the title then asserts on the missing resource. On a PC device with ID3D12Device10 the resource is created through CreateCommittedResource3 with the layout as given (UNDEFINED for a buffer). An older device gets CreateCommittedResource with the legacy state of that layout, COMMON for UNDEFINED and for layouts that have none. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…ge check, immediate free, proxy test - A write-combined (or uncached) page in the range is not imported: an RTX 5090 imported such a range and read wrong bytes back (found in review). It takes the ordinary-buffer fallback. - The whole range must be committed, walked with VirtualQuery across allocations (the retail buffer spans three mapped windows); otherwise E_INVALIDARG instead of undefined behaviour in Vulkan. - The imported memory is freed as soon as the submitted work has retired (wait_retire_ticket), not after the next submission: VK_EXT_external_memory_host needs the caller's pages to outlive it, and a title may free them right after releasing the resource. - The PC flag mask is 0x5ff: 0x200, which the host refuses, is dropped. Slot 133 is listed in device_slot_overridden. - xs_proxy_mock_test registers a handler and checks slot 133's argument positions, the flag mask (0x20204 -> 0x4), the ROW_MAJOR rewrite and the iid; d3d12_existing_heap_test checks the write-combined fallback and the partly committed refusal. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…ich varies from run to run The host runtime answers 64 KiB on some runs and 4 MiB on others for the same allocation (RX 9070 XT, RTX 5090, WARP; found in review), which made the test fail about 1 run in 40. The layer's Alignment must still be 64 KiB for an opened heap, and the host's either of the two values. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…s at the offset; uncommitted pages fall back The title places small buffers inside a page too: a 16-byte UAV at a 64-byte-aligned address on an RTX 5090 (found in review), which the import refused with E_INVALIDARG, halting the boot. The import now starts at the page holding the address and the buffer is bound at the offset; an offset off the buffer's alignment takes the ordinary-buffer fallback. A range not fully committed (xmem commits on first touch) also falls back instead of failing. Only a null address or a zero width are E_INVALIDARG. d3d12_existing_heap_test: a buffer 64 bytes into a page reads back the CPU's writes at its own VA; a 1-byte offset and a partly committed range fall back. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…ad of E_NOTIMPL The retail title places textures at slot 133 too, and asserted on the E_NOTIMPL (found in review). A texture now gets an ordinary committed DEFAULT texture of the same description, as slot 76 gives one, logged once; it is not on the title's pages. The proxy rewrites a texture's Xbox layout word to UNKNOWN (a buffer's to ROW_MAJOR), as slot 76 does. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Wine can report a requested write-combined allocation as ordinary read/write memory. Check the observed protection and retain the fallback expectation when a cache modifier is present; otherwise verify the read/write import. Add PAGE_NOCACHE to keep the unsafe-protection guard covered under Wine. Claim: ItsNotRexed#7913 (comment) Depends on: ItsNotRexed#7218 AI-assisted: Codex
…e starts in the matching state The title's third word at slot 133 is a D3D12_BARRIER_LAYOUT, not a resource state (measured by @dracbat on a retail boot: 0x6 SHADER_RESOURCE for its RT/DS textures, 0x3 UNORDERED_ACCESS for its RT+UAV ones, 0xFFFFFFFF UNDEFINED for the 182 MiB buffer), as PC CreatePlacedResource2 takes it. The proxy passes it to the handler, and a texture's ordinary committed fallback starts in the equivalent legacy state (UNDEFINED and unlisted values give COMMON; a state the description refuses retries with COMMON, so the title always gets its resource). Buffers are unchanged. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…fuses the out-of-range enum cast in a constant expression)
|
Thanks for the cross-build check. Fixed in 56d2f04 ( AI-assisted (Claude Code). |
|
checked: A38 #8304 at Built Synthetic fixtures only. AI-assisted. |
|
checked: #830456d2f04 | with: Details
AI-assisted. |
|
checked: #8304 full branch (deps #6953 #7075 #7066 #7218 #7235 + head 7387445) applied on main 6312c05 | with: built xs_proxy_mock_test, device_proxy_test, d3d12_existing_heap_test (MSVC 14.44, Ninja RelWithDebInfo) | on: Windows 11, RX 9060 XT | result: PASS
Only warnings: C4456 shadowing 'pages' in the new test, C4189 unused 'device' in vulkan_present.h. AI-assisted check of the integrated branch, which is what a merge would produce. |
…emoves its entry in O(log n) Releasing N placed buffers scanned N(N+1)/2 entries under the lock slot 70 takes (shdann's review on ProjectLeonida#8304). The entries now live in a std::map keyed by their id. Ids only grow, so map order is placement order and slot 70 still walks it backwards for the newest placement; a tag whose entry already went with its device erases nothing. Teardown of 32,768 buffers released newest first: 151.63 ms before (shdann), 3.47 ms after (same loop, MSVC /O2, Windows 11). (cherry picked from commit 335d0a1) Signed-off-by: local <local@localhost>
Claimed in #8186: #8186 (comment)
Depends on: #6953, #7075, #7066, #7218, #7235 (#7235 carries #7052 and #7021).
Review only the last commit,
738744598. Everything below it on this branch is the five pull requests above, merged in that order. Three of the merges needed a resolution by hand, all inruntime/shims/d3d12_xs_device.{cpp,h}andruntime/test/xs_proxy_mock_test.cpp:device_slot_overridden).translate_cpu_handle, at the hook point 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 left for it); the device mock copies an SRV description only from a real pointer.Relation to #8225
#8225 (opened a minute after this claim) fixes the same null view inside the Vulkan layer: a refused import becomes a shadow buffer registered at the title's VA, so #7066's provider lookup finds it, and the title's writes reach it. That is the better fix for the Vulkan backend's refused-import case, and this PR does not compete with it there. This PR answers slot 70 in the device proxy, so it also covers what the layer can't see:
gta6rt's default backend (the PC D3D12 device behind the proxy, withoutLEONIDA_D3D12=vulkan), #7075's committed stand-in without #7218, and the last-resort committed buffer when no shadow can be made. With both merged, the registry answers first for buffers the proxy placed itself and the layer's index for the rest.What and why
Device slot 70 makes a shader-resource view from a buffer description, a raw SRV description and a console address, with no resource object. #7066 resolves the address through the device's resource provider, that is the Vulkan layer's own buffer index. The layer knows a slot 133 buffer by the title's address only when #7218 could import the title's pages. When the import is refused (NVIDIA here; #8166 measures a host-import budget of about 64 MiB on an RTX 3070 Ti), or when the device behind the proxy is a PC one, the slot 133 buffer has an address of its own, nothing is found, and the title's descriptor gets the null view.
The proxy made that buffer itself in slot 133, at an address the title gave it, so it can answer the question without the layer.
Design
[va, va + Width), whichever way it was made: d3d12_xs: device slot 133 (CreatePlacedResourceX) makes a buffer on the title's own pages (VK_EXT_external_memory_host) #7218's handler, PCCreateCommittedResource3, or PCCreateCommittedResource. Textures are not recorded.IUnknownattached to the resource as private data removes the entry when the resource dies. A resource that cannot hold private data is not recorded.Tested
Windows 11, MSVC 2022 Build Tools, RelWithDebInfo, NVIDIA GeForce RTX 4090, driver 32.0.16.1062.
xs_proxy_mock_testpasses. The newcheck_slot70_placed_buffercovers both committed creation paths and the handler path, the element range of the view, the cut at the buffer's end, the addresses just outside two buffers, a texture, the provider fallback and its order, a range placed twice, a released buffer and a released device.check_slot70_placed_bufferfails at its first view check (the view is the null one); restored, it passes.device_proxy_testpasses.ctest -R "xs|proxy": 11 of 11 pass. Full build ofruntime/(524 steps) is clean.python -I scripts/check_no_game_data.pyon the changed files: clean.Not shown
AI-assisted (Claude Code).