Repository navigation
d3d12_xs: device slot 133 (CreatePlacedResourceX) makes a buffer on the title's own pages (VK_EXT_external_memory_host) - #7218
tibzejoker wants to merge 17 commits into
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). |
…, sub-page import); keeps ItsNotRexed#7075's stand-in as the last resort
|
Tested
AI-assisted. |
|
Tested a3eae95 on RTX 5060 (driver 621.24), Windows 11, MSVC 2022 RelWithDebInfo: pass.
|
|
@tibzejoker: In my offline, network-blocked Windows boot with #7218 in the private integration stack, the buffer path passed, then two slot-133 2D texture requests returned the documented |
…xed#7235's block, layout argument)
|
@editrice: go ahead and claim it, I'm not planning title-backed textures. Some context for scoping it:
|
…ourceX on the title's pages) for the RT-5 boot # Conflicts: # runtime/shims/d3d12_xs_device.cpp # runtime/test/xs_proxy_mock_test.cpp
|
Retail boot test (RT-5): own 1.0.2.1 copy, Windows 11, i9-12900KF, RTX 3070 (NVIDIA 617.42), MSVC 2022 RelWithDebInfo, Result: clears stop 12 (slot 133), and the first descriptor heap follows. Finding on NVIDIA: the page import fails on this RTX 3070: AI-assisted test run. |
|
@XIIYAZ thanks, a clean per-PR confirmation. The |
|
Windows + GPU check. Hardware: NVIDIA GeForce RTX 5080 + RTX 3070 Ti (driver 621.01) and AMD Radeon 610M iGPU (Ryzen 9 9950X3D, driver 32.0.13018.6). OS: Windows 11. Toolchain: MSVC (VS BuildTools 18) + Ninja, single-config RelWithDebInfo; llvm-mc 21.1.8; SPIRV-Tools. Configured with -DLEONIDA_LLVM_MC and -DLEONIDA_SPIRV_AS/VAL. Tested head a3eae95 (base dde82f2, the current main tip). Build: 445/445 targets, 0 errors/warnings. Targeted tests (the files this PR touches), --repeat until-fail:3 on the RTX 5080: d3d12_existing_heap, d3d12_descriptor, xs_proxy_mock - all pass x3. d3d12_vulkan_device still fails (pre-existing main-red, see below). REGRESSION - d3d12_depth_resolve: a NEW failure at this head; it passes on the base/main dde82f2. It fails serially --repeat until-fail:3 on BOTH GPUs (not -j6 contention). The depth/stencil resolve matches are fine (97/97 against the RTX 5080, 71/71 against WARP), but 8 refused ResolveSubresourceRegion cases now leave the destination CHANGED where main left it untouched:
A refused resolve (Close 0x80070057 / E_INVALIDARG) should leave the destination buffer untouched; here it is mutated. Likely from the d3d12_vulkan_device.cpp changes (+338) in this PR - the resolve path appears to touch/allocate the destination before bailing on the refusal. Full runtime suite, ctest -C RelWithDebInfo -j 6, excluding the 4 windowed present tests:
Windowed present tests, run serially --repeat until-fail:3 on each GPU: d3d12_present and xbox_present pass x3 on both GPUs. Net: the PR's placed-resource / external-memory tests (d3d12_existing_heap, d3d12_descriptor, xs_proxy_mock) are green x3, but d3d12_depth_resolve is a new regression on this head (refused resolves now mutate the destination), reproducing on both GPUs; the other failures are pre-existing main-red on my hardware. Synthetic fixtures only, no game files. AI-assisted (opencode); runs on my machine. |
|
@2-CD thanks for the full-suite run. I checked |
a8_as_alpha added beside the uint_backed format field (which replaced r9g9b9e5_as_r32_uint here); the RTV chain has the A8 case then the B5G5R5A1 case; vk_test_device.h enables both VK_EXT_external_memory_host (ItsNotRexed#7218) and maintenance5. Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
|
CachyOS, Wine 11.22, RTX 4070 / 620.73.04, AI-assisted. I adapted the buffer-import path from |
…ndler really placed them ItsNotRexed#7218's head fixes the slot-133 flags constant clang-cl rejected (reported on ItsNotRexed#7411) and changes the placed-at-VA handler: it takes the title's barrier layout, and when it cannot import the pages it answers with an ordinary DEFAULT buffer instead of failing. For a committed buffer that fallback would drop the title's heap type (an UPLOAD or READBACK buffer could no longer be mapped). create_committed_through_xmem now passes UNDEFINED as the layout, checks that the buffer it got back has the hook's address as its GPU VA, and otherwise gives it back and makes the buffer on the PC device with the title's heap, keeping the hook memory as bookkeeping. xs_proxy_mock_test covers that case. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
|
Linux + Wine run on an RDNA4 desktop (not the author's RTX 4090) GPU: AMD RX 9060 XT (RDNA4/GFX1200), RADV Mesa 26.0.8, Ubuntu 26.04 Built from Builds
Suites
Device slot 133 on RADV
so at least one slot-133 buffer came back with a GPU VA that is not the caller's address, i.e. it took the ordinary-buffer fallback. The layer logged the fallback for two imports, with alongside So on this hardware Caveat on attributionI compared against a clone at Two other Wine failures are not this PR's: On the #7218 + #2490 + #6953 combination
AI-assisted: yes (this run). |
|
Measured on the retail title (via #8304, which carries this PR), RTX 5060 Ti, Windows 11:
AI-assisted (Claude Code). on: Windows 11, MSVC RelWithDebInfo, RTX 5060 Ti, LEONIDA_D3D12=vulkan. |
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).