Repository navigation
Conversation
…ry reads Serve the Xbox DirectStorage API (IDStorageFactoryX2, IDStorageQueueX2, IDStorageFileX, IDStorageStatusArrayX) under dstorage_xs.dll, xcrdapi.dll and dstorage.dll. Declarations are our own (shims/dstorage_xs_abi.h), written from the public GDK reference; layouts are pinned with static_asserts. - OpenFile goes through the registry's kernel32!CreateFileW, so GAME: paths use the console path mapping and the write overlay. GetHandle returns a ReOpenFile handle with its own file position. - One worker thread per queue runs submitted entries in order: file and memory requests, status arrays, ID3D12Fence::Signal, EnqueueSetEvent (on a duplicate of the title's handle taken at enqueue). - Auto-submit at half the capacity (or disabled through DSTORAGE_QUEUE_OPTIONS), enqueue into a full queue waits, CancelRequestsWithTag (a cancelled request is a success and not a failure), error record and error event, Close and the last Release drain the queue, IDStorageFileX::Close waits for the file's submitted reads. - Request checks: reserved bits, source type, BCPack/swizzle ranges, sizes, 1 GiB limit, null and foreign objects and closed files (also for zero-size requests), end of file, inaccessible memory. - zlib, BCPack, swizzle and physical pages return E_NOTIMPL (later PRs). - Interface ids of the X interfaces are not public: a creating call accepts and logs a new id per object kind, but refuses system COM ids (IMarshal, IAgileObject, ...) and the PC DirectStorage ids; QueryInterface accepts only IUnknown, the PC IDStorageStatusArray id (same shape) and the ids creating calls accepted for that kind. Bad arguments are logged once per method. - registry.cpp classifies xcrdapi.dll!DStorageGetFactory as HRESULT; the cl.exe fallback in build_runtime.ps1 builds the new shim too. ctest dstorage: 258 checks over synthetic files in %TEMP%, no GPU, no game data. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
docs/directstorage.md records which DLL and ABI the console title is expected to use (dstorage_xs.dll medium, xcrdapi.dll and dstorage.dll low confidence), what is not public (vtable order, interface ids, some constants) and the choice made for each, what owning the modules shadows at run time, what the shim does (including the order of its request checks), and what later PRs add (zlib, BCPack, swizzle, physical pages, GPU-backed destinations, parallel reads). Index row in docs/README.md; the owned-module list in runtime_imports.md and the shim list in runtime/README.md name the new modules. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
# Conflicts: # scripts/build_runtime.ps1
…mit, /EHa under clang-cl Review fixes for ItsNotRexed#4348 (Flyander, AirKyzzZ): - DSTORAGE_REQUEST allows a buffer over 32 MiB only with 64 KiB or 2 MiB pages, which are not implemented yet, so such a request now fails with E_DSTORAGE_REQUEST_TOO_LARGE before any memory is touched. - TotalRequestCount and the byte totals grow when a request is submitted, not when it is enqueued, and PendingRequestCount counts the request the worker is processing (DSTORAGE_PRIORITY_STATS). - dstorage.cpp is built with /EHa under clang-cl, so guarded_move's __try catches an access violation in a title's buffer there too. Tests: an over-limit and an at-limit 32 MiB copy, and stats checked before Submit and while a copy is held on a guard page. The three new failing checks fail with the previous shim. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
# Conflicts: # scripts/build_runtime.ps1
# Conflicts: # scripts/build_runtime.ps1
# Conflicts: # scripts/build_runtime.ps1
…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>
A request with ZlibDecompress alone now reads SourceSize bytes of the file or of memory into a staging buffer, inflates them with the runtime's RFC 1950 inflater (leonida::zlib_inflate in src/shader_library.h) and copies the result to Destination only when it is exactly DestinationSize bytes. A failed stream leaves the destination untouched, and a memory source inside its own destination inflates correctly. Checks follow DSTORAGE_REQUEST and dstorageerr.h: DestinationSize must be larger than SourceSize with zlib (E_DSTORAGE_INVALID_DESTINATION_SIZE), a zlib FileOffset must be 16-byte aligned (E_DSTORAGE_INVALID_FILE_OFFSET), IntermediateSize stays 0 without BCPack. Stream failures map to E_DSTORAGE_ZLIB_BAD_HEADER, _ZLIB_BAD_DATA, _ZLIB_PARITY_FAIL (Adler-32) and E_DSTORAGE_DECOMPRESSION_ERROR (a result of another size). GetStats counts the inflates, the pending ones and the decompression errors. zlib_inflate gains an optional failure reason (header, data, checksum, limit); its existing callers are unchanged. BCPack, swizzle and physical-page requests still fail with E_NOTIMPL. dstorage_test: synthetic streams only (Python zlib levels 9 and 1, stored blocks built by the test), from a file and from memory, with every failure code; shader_library_test checks the new failure reasons. 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>
…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 ProjectLeonida#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>
…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>
# Conflicts: # docs/README.md # runtime/CMakeLists.txt
… xmem shim's pages A request with DestinationIsPhysicalPages names its destination as an array of 64 KiB page numbers from XMemAllocatePhysicalPages and a 16-bit offset into the first page. The shim answered E_NOTIMPL. The retail executable's chunked read path builds such requests whenever its destination lies in the range it backs with physical pages. - rt::xmem::write_physical_pages (shims/xmem_pages.h, shims/xmem.cpp) writes through views of the pages' backing sections, one view per run of pages that follow one another in one allocation. Every page number is checked before a byte is written; a page needs no mapping, and a mapped page shows the bytes. - dstorage.cpp stages the source (file range or memory, inflated for zlib) and hands it to write_destination, which copies the page numbers out of the title's array under the usual guard. A bad array or page number is E_DSTORAGE_ACCESS_VIOLATION and leaves the pages untouched. - The 32 MiB limit for 4 KiB-page destinations no longer applies to these requests (64 KiB pages); an address keeps it. - SourceIsPhysicalPages, BCPack and swizzle stay E_NOTIMPL. dstorage_test: 362 checks, xmem_test: 173 checks, both pass (MSVC, Windows 11). Synthetic data only. Co-Authored-By: Claude Mythos 5.2 <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>
Read file and zlib payloads back through imported Vulkan buffers after a DirectStorage fence. Check both aliases of the pages, then reverse the mappings, recreate the resource and check a new payload. Verified on RTX 4060 under Wine 11.20 and Proton-CachyOS Wine 11.0. A stale-write negative control fails at the zlib update. AI-assisted.
|
Native Windows MSVC build and RTX 3090 GPU verification on Environment
Verification results
Review notes
AI-assisted review and native Windows GPU verification. |
|
✅ Automated security review: CLEAN (commit
Scope: static analysis of added diff lines only; no code was executed. Please review findings manually. |
This was referenced Nov 23, 2026
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.
Adds a synthetic GPU acceptance test for DirectStorage writes into XMem physical pages. It checks the combined storage, page backing, imported-buffer and fence path, including data changed after the resource was created.
TEST-1773, claimed in the coordination issue.
Depends on: #7652 and #7218. The branch integrates those heads. The test and its CMake registration are in commit 1f9f796.
Coverage
CTest registers dstorage_gpu with a 120 s timeout, skip code 77 for unavailable imports, and validation-error detection.
Verification
CachyOS, RTX 4060, NVIDIA 615.78.08.
The local cross-build uses clang/llvm-mingw 23, DirectX-Headers 1.619.1 with build-local return-type/UUID adapters, and clang-cl /EHa for guarded_move. Native Windows and a full standard runtime build remain unverified.
Under Wine 11.20, native validation reports VUID-vkCreateDevice-ppEnabledExtensionNames-01387 for Wine's injected external_memory_dma_buf extension dependency. The existing heap test emits the same message. The Proton run is clean.
Synthetic inputs only. AI-assisted.