Repository navigation
d3d12_xs: device slot 133 (CreatePlacedResourceX) makes a buffer on the title's own pages (VK_EXT_external_memory_host) - #7218
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>
…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>
|
Independent synthetic test of The stock head does not compile with this SDK and clang-cl: With that one-line change, AI-assisted (Codex). |
|
Retail-path integration test of The handler is registered in AI-assisted (Codex). |
|
Independent native Windows / RTX 3060 check at I reproduced the clang-cl build error at With that build, AI-assisted testing. |
…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>
|
Retail follow-up on There is a missing registration on the retail path. The patch registers A common registration point for both device factories, or the one-line registration in the standalone factory, closes the gap. The retail test was offline with the local 1.0.2.1 package. Outcomes only. AI-assisted (Codex). |
# Conflicts: # runtime/shims/d3d12_xs_device.cpp
|
Thanks all three.
Retested at |
|
Review note (stray submodule bump). The diff at |
… found in review) Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
|
@ruvenesh thanks, right: it came in with a local merge. |
|
Tested on the retail executable (own 1.0.2.1 copy, Windows 11 26200, RX 9070 XT, AMD Windows driver, Concern: the handler is never registered on the path With that one line added before rt::d3d12_xs::set_placed_at_va_handler(&create_buffer_at_host_address);the title's call goes through: That's a 174 MiB buffer imported from the title's three mapped windows (#6919's maps), on AMD with no validation complaints in this build. The title then creates a descriptor heap (slot 14) and reads its CPU start (heap slot 9), and stops on a new assert past this PR. I'm looking at that one next. One run each way, counts and API names only. AI-assisted (Claude Code). |
|
@sneylol thanks, that's the first AMD retail run. The registration gap you hit was in |
|
Tested the #7218 slot-133 implementation with both device factories wired up, on CachyOS, Wine 11.22, Mesa 26.3.1. The same runtime and inputs give different results on RADV and lavapipe.
The last case is a synthetic guest using the public runtime entry point. I also ran my local copy offline with each backend. At the first 174 MiB placement RADV returns 0x8007000e. Lavapipe succeeds at that same call and the game creates its first descriptor heap. The full-size test checks placement and the reported address. Byte-for-byte GPU readback was tested on the 256 KiB cases indicated above. This narrows the remaining hardware issue to the section-backed case. The independent sparse binding / copy control on this Radeon may be useful for the backing-memory work. AI-assisted testing. |
|
Retested on Windows / RTX 3060, NVIDIA 621.14, clang-cl/xwin SDK 10.0.26100. Updated head 2b584ec builds unmodified, and xs_proxy_mock passes. The stock d3d12_existing_heap test exits with 0xC0000008 on both 2b584ec and main 8575d36, with validation on and off. On 2b584ec, omitting only the OpenExistingHeapFromFileMapping(0x1234) assertion in the local test let the rest pass with validation enabled. Both slot-133 fixtures read back all 262,144 bytes, and all eight host comparisons matched both native NVIDIA D3D12 and WARP. AI-assisted testing. |
… 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>
|
@Stalkerino thanks, that's the case I couldn't see on NVIDIA. RADV refusing the section view fits amdgpu userptr, which won't pin shared, file-backed mappings, while anonymous memory imports. @umnitus thanks for confirming the Retested at |
|
Independent native Windows 11 / MSVC 19.44.35230.0 / AMD Radeon RX 6700 XT (
AI-assisted (Gemini, Antigravity). |
|
checked: #7218 (branch includes dep #6953) | with: applied the diff on main 6312c05, built xs_proxy_mock_test and d3d12_existing_heap_test (MSVC 14.44, Ninja RelWithDebInfo) | on: Windows 11, AMD Radeon RX 9060 XT (RDNA4) | result: PASS
AI-assisted check. |
…difiers, so GPU-shared memory imports PAGE_WRITECOMBINE and PAGE_NOCACHE are how the console marks memory the GPU shares (a committed pool with protect 0x404, measured locally). host_protect kept them, so the host committed write-combined pages, and the D3D12 layer's import of a buffer placed there (VK_EXT_external_memory_host, ItsNotRexed#7218) refuses write-combined pages. host_protect now drops both cache modifiers along with the PAGE_GRAPHICS_* bits; a physical-page view already does (ItsNotRexed#7492). Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> (cherry picked from commit 8bf9bbe)
…xed#7235's block, layout argument)
|
Tested and read Test on NVIDIA GeForce RTX 3070, driver 610.88, Windows 11 (MSVC 14.44, RelWithDebInfo): pass. Code read, four points not raised above:
No game data used. |
…ResourceX) makes a buffer on the title's own pages (VK_EXT_external_memory_host) Squashed from ItsNotRexed#7218 by tibzejoker, head 4fb24d2 (security scan PASS). Head moved from the scanned c3fe825 to 4fb24d2 (two commits: page-base import with bind offset, committed texture fallback); the new commits were re-scanned (prescan: no flags; Haiku read: PASS). Contains ItsNotRexed#6953. Conflicts with ItsNotRexed#6964/ItsNotRexed#7078: the slot-26 handler and the slot-133 handler both kept; device_slot_overridden lists 25/26/56 and 133.
…d by the proxy (a null SRV for now, its raw words logged), not the PC CreatePlacedResource1 (retail boot chain stop 14) Squashed from ItsNotRexed#7066 by tedin7, head 1d8d1d3 (security scan PASS). Conflicts with ItsNotRexed#6964/ItsNotRexed#7218/ItsNotRexed#6954: slot 26, slot 133 and this PR's route_xbox_device_slot helper all kept; the helper's queue route calls ItsNotRexed#6954's proxy_create_command_queue_xbox (32-byte description) instead of the slot-8 path it was written against. device_slot_overridden, the header and the mock test's check list take the union.
… memory the title's XMem hook gives (slots 27, 53, 76, 127) Squashed from ItsNotRexed#7411 by garuspl, head 9335d6b (security scan PASS). Taken as its own commit 9335d6b on top of ItsNotRexed#7235 and the newer ItsNotRexed#7218 already here: the branch merges an older ItsNotRexed#7218 head, whose slot-133 code and Vulkan-device import would undo ItsNotRexed#7218's review fixes. The proxy file's reorder keeps slot 26 and the route_xbox_device_slot helper ahead of the committed-resource code, places ItsNotRexed#7218's current slot-133 handler where this PR's copy was (g_placed_at_va declared once, above), and keeps the slot 25/26/48/56/70/133 entries in the slot names, device_slot_overridden, the header and the mock test's check list.
…VK_FORMAT_A8_UNORM_KHR (VK_KHR_maintenance5) Squashed from ItsNotRexed#7403 by mrp1no, head 18b0bfb (security scan PASS). Conflict in vk_test_device.h only: the test device enables both VK_EXT_external_memory_host (ItsNotRexed#7218) and VK_KHR_maintenance5 (this PR) when asked.
…n't be imported is a shadow at the title's VA, re-copied before each submit Squashed from ItsNotRexed#8225 by tibzejoker, head 14dc9af (security scan PASS). Own commits 49410a5 and 14dc9af; test conflict with ItsNotRexed#7218's refresh resolved by renaming the loop's locals. Merged with 097e9f4 (fallback buffer aliased at the title's VA): the shadow is the path now, since it holds the title's bytes. The alias stays only behind it, for a shadow that cannot be allocated, so draws still resolve instead of failing with an unknown resource.
… arena's VA window takes the fallback From review (@FRaccie): - The texture fallback called create_committed, which takes the state without checking it (textures start undefined and take their first command's layout), so the barrier-layout state and its COMMON retry did nothing. It now goes through create_committed_validated, as CreateCommittedResource does: RENDER_TARGET on a texture without ALLOW_RENDER_TARGET is refused and the COMMON retry answers; a description the checks refuse outright is refused. - An imported buffer's VA is its host address, in the same BufferVaIndex as default-heap buffers, whose VAs are offsets in [0, arena size). A host address inside that window (low addresses, as under Wine) would shadow arena buffers in the nearest-start lookup, so such a range is not imported and the fallback answers. d3d12_existing_heap_test checks the two texture cases. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
|
@FRaccie thanks for the careful read.
AI-assisted (Claude Code). |
|
Tested
AI-assisted (Gemini). |
…difiers, so GPU-shared memory imports PAGE_WRITECOMBINE and PAGE_NOCACHE are how the console marks memory the GPU shares (a committed pool with protect 0x404, measured locally). host_protect kept them, so the host committed write-combined pages, and the D3D12 layer's import of a buffer placed there (VK_EXT_external_memory_host, ItsNotRexed#7218) refuses write-combined pages. host_protect now drops both cache modifiers along with the PAGE_GRAPHICS_* bits; a physical-page view already does (ItsNotRexed#7492). Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> (cherry picked from commit 8bf9bbe) Signed-off-by: local <local@localhost>
…e resource of a slot 70 view of that address Device slot 70 makes a shader-resource view from a description and a console address, with no resource object. It asked only the device behind the proxy for a buffer at that address, and that device knows the buffer by the title's address only when it could put the buffer on the title's own pages. When it could not (the import is refused, or the device is a PC one), the slot 133 buffer has an address of its own, nothing was found, and the title's descriptor got the null view. The proxy now remembers every buffer a slot 133 call made by the range the title placed it at, whichever way it was made (the placed-at-VA handler, PC CreateCommittedResource3 or CreateCommittedResource), and slot 70 asks there first, then the device's provider. An entry holds no reference. An object attached to the resource as private data removes the entry when the resource dies, and a device proxy's entries go with it. The newest buffer over an address answers, so a range the title places again is the new buffer's. xs_proxy_mock_test: check_slot70_placed_buffer covers both creation paths and the handler path, the element range, the cut at the buffer's end, the addresses around two buffers, a texture, the provider fallback and its order, a range placed twice, a released buffer and a released device. The check of the placed-at-VA handler in check_levels hands out a mock resource instead of a made-up pointer, since the proxy now asks the object for ID3D12Resource. Depends on: ItsNotRexed#7066 (slot 70), ItsNotRexed#7218 or ItsNotRexed#7075 (slot 133), ItsNotRexed#6953 (the table reaches slot 133), and ItsNotRexed#7235 for the mock's SetPrivateDataInterface. (cherry picked from commit 7387445) Signed-off-by: local <local@localhost>
…inter import xmem commits physical pages on first touch (#7556), so a range the title has mapped but not written yet is still MEM_RESERVE when it places a buffer on it through device slot 133, and the Vulkan layer's import (#7218) refuses reserved pages and answers with its fallback buffer, which the title's writes never reach. Slot 133 now calls a registered pages hook (set_placed_at_va_pages_hook, next to set_placed_at_va_handler) with the buffer's range before the handler; gta6rt registers rt::xmem::commit_physical_range. A failed commit is logged once and the handler still runs. Textures don't call it. The Vulkan layer doesn't link xmem. Tests: xs_proxy_mock_test checks the hook order, arguments, failure and texture cases; the new d3d12_xmem_placed_test places a buffer on untouched xmem physical pages and checks the fallback without the hook, and with it the import and a GPU copy reading the CPU's writes. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…inter import xmem commits physical pages on first touch (ProjectLeonida#7556), so a range the title has mapped but not written yet is still MEM_RESERVE when it places a buffer on it through device slot 133, and the Vulkan layer's import (ProjectLeonida#7218) refuses reserved pages and answers with its fallback buffer, which the title's writes never reach. Slot 133 now calls a registered pages hook (set_placed_at_va_pages_hook, next to set_placed_at_va_handler) with the buffer's range before the handler; gta6rt registers rt::xmem::commit_physical_range. A failed commit is logged once and the handler still runs. Textures don't call it. The Vulkan layer doesn't link xmem. Tests: xs_proxy_mock_test checks the hook order, arguments, failure and texture cases; the new d3d12_xmem_placed_test places a buffer on untouched xmem physical pages and checks the fallback without the hook, and with it the import and a GPU copy reading the CPU's writes. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claimed in the coordination issue: #6750 (comment) (design note: #6750 (comment))
Depends on: #6953 (the proxy table must reach slot 133). Relates to #6995 (xmem physical pages) and #6915 (
docs/retail_boot_chain.md, §3.4).What and why
Xbox device slot 133 is the console's
CreatePlacedResourceX:(va, desc, state, clear, riid, out). The retail title places a buffer at the VA of a physical-page range it has just mapped. Until now the slot either jumped through a missing entry or, in #6915's local stand-in, got an unrelated committed buffer, so what the title writes atvanever reached the GPU.d3d12_xs: slot 133 masks the Xbox flag bits down to the PC ones, makes a buffer's layoutROW_MAJOR(as slot 76 does), and hands the call to a handler that the device behind the proxy registers (set_placed_at_va_handler). With no handler (a PC device), it answersE_NOTIMPLwhatever the arguments, as d3d12_xs: the device proxy table covers slot 133, so slots past the PC vtable refuse instead of jumping to 0 #6953's table does. The handler keepsd3d12_xs_device.cpplinkable without the Vulkan layer (the mock tests).create_buffer_at_host_addressimports[va, va + width)withVK_EXT_external_memory_hostand binds aVkBufferto it. The CPU's writes there are the GPU's reads, with no copy. The resource's console VA is the title's own VA, so views and immediate writes the title names by that VA resolve to it through the buffer VA index. Textures areE_NOTIMPLand a VA off the import alignment isE_INVALIDARG.vk_test_device.h) enablesVK_EXT_external_memory_hostwhen present. The same import backsID3D12Device3::OpenExistingHeapFromAddress, which now answers as the host runtime does (8 cases, below) instead ofE_NOTIMPL.CheckFeatureSupport(EXISTING_HEAPS)follows the extension. Placed resources in such a heap are refused and logged for now.Not decided here: a shader computes
heap_base + console_va, so the title's own V#s that point into these pages don't reach them. That needs the single address space ofdocs/d3d12_vulkan.md§3.3 (options in the design note above). This PR makes the data path and the VA bookkeeping right without picking one.Tested
RTX 4090, driver 617.42, Windows 11 26200, MSVC 2022 RelWithDebInfo:
d3d12_existing_heap_testwithLEONIDA_VK_VALIDATION=1, no validation errors:VirtualAllocrange and on a view of a pagefile-backed section (the form xmem: serve XMemAllocatePhysicalPages, XMemFreePhysicalPages and XMemMapPhysicalPages[Scatter] (RT-5 next stop) #6995 maps physical pages in). The buffer's GPU VA is the address, and a GPU copy to a READBACK buffer reads back a pattern the CPU wrote after creation, byte for byte. A texture givesE_NOTIMPL, a misaligned VAE_INVALIDARG.OpenExistingHeapFromAddress: 8 of 8 cases match the host runtime on the RTX 4090 and on WARP. A whole read-write allocation opens a heap of its size, 64 KiB aligned,CUSTOM/L0, flags0x421,WRITE_BACK(WRITE_COMBINEfor aPAGE_WRITECOMBINErange). An inner address, a partial or reserve-only commit, read-only andPAGE_NOCACHEareE_INVALIDARG.xs_proxy_mock_test: PASS, including d3d12_xs: the device proxy table covers slot 133, so slots past the PC vtable refuse instead of jumping to 0 #6953's slot-133 refusal with no handler.ctest: the only failures ared3d12_indirect_dispatch_count,xbox_presentandd3d12_indirect_rt, which fail the same way on the base without this change (d3d12_xs: the device proxy table covers slot 133, so slots past the PC vtable refuse instead of jumping to 0 #6953 onmain).AI-assisted: yes (Claude Code).
🤖 Generated with Claude Code
On Windows: pair it with a read-write physical-page mapping
On
main, the title's physical-page views keepPAGE_WRITECOMBINE, and this PR refuses to import write-combined pages (a WC import read wrong bytes on an RTX 5090 and two RTX 4090s), so on retail the 182 MiB slot-133 buffer takes the ordinary-buffer fallback. With one of #7492 / #7499 / #7550 (views mappedPAGE_READWRITE), the same buffer imports: measured on an RX 9070 XT (@jimokulou2-ops) and an RTX 5060 Ti (@Exopus-0x65f7ad0, with #7550). Merged with currentmainat4336b7a2a(clean).