Repository navigation
d3d12_xs: committed buffers live on the memory the title's XMem hook gives (slots 27, 53, 76, 127) - #7411
Open
garuspl wants to merge 12 commits into
Open
d3d12_xs: committed buffers live on the memory the title's XMem hook gives (slots 27, 53, 76, 127)#7411garuspl wants to merge 12 commits into
garuspl wants to merge 12 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>
…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.
…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.
…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>
…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>
# Conflicts: # runtime/shims/d3d12_xs_device.cpp
…gives (slots 27, 53, 76, 127) The memory a committed resource took through the title's XMem allocation hook was bookkeeping only: the PC/Vulkan resource was not backed by it, so what the title read or wrote at that address missed the resource. - A committed buffer whose memory the hook gives is now made on that memory through the slot-133 placed-at-VA handler (create_buffer_at_host_address, VK_EXT_external_memory_host). Its GPU VA is the hook's address, and the title's CPU reads and writes there are the buffer's bytes. The memory is zeroed first unless the heap flags say CREATE_NOT_ZEROED, and it goes back through the hook's free with the resource. - A texture, a shared heap, or a buffer the handler cannot make (a PC device behind the proxy, no extension, an address off the import alignment) keeps the device's own memory, with the hook memory as bookkeeping. The hook is asked once per resource either way. - Device slots 27 (CreateCommittedResource) and 53 (CreateCommittedResource1) were forwarded verbatim; they now take their memory through the hook like slots 76 and 127. Their arguments reach the PC device unchanged, and a capability check (no output) or an argument error is the PC runtime's answer. - LEONIDA_XMEM_RESOURCE_BACKING=0 keeps every committed resource on the device's memory, as before. Tests: xs_proxy_mock_test covers every path on the mock device; d3d12_existing_heap_test checks, through the proxy over the Vulkan device, that the buffer's GPU VA is the hook's address and that CPU and GPU writes are seen both ways. docs/retail_boot_chain.md section 3.5 records the model. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
|
Independent Windows + GPU test of Setup: Windows 11 x64, MSVC 19.44.35220 (
AI-assisted review/test. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Claimed in the coordination issue as: #7231 (comment) (the open item in #7231 (comment))
Depends on: #7235 (slot 127 through the XMem hook, itself on #7021 and #7052) and #7218 (the slot-133
create_buffer_at_host_addresshandler, on #6953). This branch is #7235's head with #7218 merged in; only the last commit,9335d6b14, is this PR. Overlaps #7240, which takes stop 17 another way.What and why
Since #7235, a committed resource takes its memory through the title's
__XMemAllocationHooks__hook, but only for the accounting: the PC/Vulkan resource isn't backed by that memory, so anything the title writes or reads at that address misses the resource. This PR backs the resource with that memory where the layer can:create_buffer_at_host_address, which imports it withVK_EXT_external_memory_host). The buffer's GPU VA is the hook's address, and the title's CPU reads and writes there are the buffer's bytes, with no copy. The memory is zeroed first unless the heap flags sayD3D12_HEAP_FLAG_CREATE_NOT_ZEROED, as a PC committed resource starts, and it goes back through the hook's free with the resource.docs/retail_boot_chain.md§3.5.CreateCommittedResource,CreateCommittedResource1) were forwarded verbatim and never called the hook. They now take the same path as 76 and 127. Their arguments reach the PC device unchanged, and a capability check (no output) or an argument error still gets the PC runtime's own answer, with no hook call.LEONIDA_XMEM_RESOURCE_BACKING=0keeps every committed resource on the device's memory (bookkeeping only), to compare runs. GPU reads of host memory cross the bus, so a heavily read DEFAULT buffer is slower there.The attribute word is #7235's
kXmemCommittedResourceAttributes, measured at stop 17's call sites. Whether the console uses the same word for slots 27/53/76 isn't measured. Not run against the retail executable.Tested
Windows 11, MSVC 14.44, NVIDIA GeForce RTX 4090, driver 617.42, Vulkan SDK 1.4.363:
xs_proxy_mock_test: PASS. The newcheck_committed_buffers_on_xmemcovers: a buffer on the hook memory (zeroed, PC device not called, freed with the resource),CREATE_NOT_ZEROED, a texture, a shared heap, the handler refusing (one hook allocation, used as bookkeeping), handler and PC device both refusing (memory freed, null object), the hook refusing, slots 27/53 (arguments and session passed through, a capability check takes no memory), and slot 127. d3d12_xs: device slot 127 takes the resource's memory through the title's XMem hook (retail boot chain stop 17) #7235's own checks still pass.d3d12_existing_heap_testwithLEONIDA_VK_VALIDATION=1: PASS, 0 validation errors. A newcheck_committed_on_hookputs the Xbox device proxy over the Vulkan device, with a bump-allocator hook over aVirtualAllocrange. The buffer's GPU VA is the hook's address, a GPU copy reads what the CPU wrote there, and the CPU reads what a GPU copy wrote. A texture only takes its size from the hook and leaves its bytes alone, and both go back through the hook's free.ctest: 253 of 255 pass, plus 12 skipped or disabled (they need game files). The 2 failures,d3d12_vulkan_deviceandd3d12_indirect_dispatch_count, fail the same way on this branch's base without this commit.d3d12_vulkan_deviceis TEST-1649 in Coordinating who works on what (42) (moved to #7333) #7231.tests/test_docs_*.pychecks pass.scripts/check_no_game_data.pypasses on the changed files.AI-assisted: yes (Claude Code)
Checklist
docs/design.md, with how it was confirmed. (No translator change.)🤖 Generated with Claude Code