Repository navigation
runtime: console DirectStorage (DStorageGetFactory) with file-to-memory reads - #4348
mariuslozo-boop wants to merge 7 commits into
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>
|
Independent Windows 10 check of I built |
Kam471
left a comment
There was a problem hiding this comment.
Built dstorage_test at c77338e6 on Windows 11 and ran it: 258 checks, 0 failures, exit 0; ctest -R dstorage -> 1/1 passed (0.42 s).
The test covers DStorageGetFactory, the console ABI objects and the QueryInterface policy: unknown/system/PC-DirectStorage ids return E_NOINTERFACE, a wrong-kind id is refused, and the queue interface is served; the file-to-memory queue/status paths run. No blocking issue.
|
Tested
Synthetic files only, no game data. AI-assisted (Claude Code). |
Flyander
left a comment
There was a problem hiding this comment.
P2 — Ordinary buffers above 32 MiB are accepted (runtime/shims/dstorage.cpp:763-771)
The GDK request contract allows ordinary destinations up to 32 MiB. Above that, the request must use 64-KiB or 2-MiB physical pages for each buffer exceeding 32 MiB, while remaining under the 1-GiB combined limit. This shim rejects requests that explicitly ask for pages, but the ordinary-buffer path checks only the 1-GiB cap. A 33-MiB file-to-memory read (or memory-to-memory request with an unpaged source/destination over 32 MiB) therefore reaches read_file_range/guarded_move and can report success despite violating the console request contract. Please reject unpaged oversized buffers before touching them, or implement the required page path. GDK request size rules
P2 — GetStats counts requests before Submit and never reports pending work (runtime/shims/dstorage.cpp:514-518)
TotalRequestCount and both byte totals are incremented in EnqueueRequest, so enqueueing a request and never calling Submit already changes the cumulative totals. PendingRequestCount is never updated, so it remains zero while a submitted request is executing. GDK defines total requests as submitted requests and pending requests as work whose processing has started but has not completed. Please move cumulative accounting to submission and update the pending count around actual processing. A regression can enqueue without submitting, then observe stats, and separately block/observe a submitted request in flight. GDK priority statistics
|
Tested Full |
# 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
|
Thanks for the reviews and test reports. Fixed in @Flyander, P2: unpaged buffers over 32 MiB. A request with a destination over 32 MiB ( @Flyander, P2:
@AirKyzzZ, clang-cl. Tested: Windows 11, RTX 5070 Ti, MSVC 19.44, RelWithDebInfo.
An independent reviewer read the fix (lock order, the CMake property scope, the guard-page test) and found nothing blocking. Its two small points, checking the AI-assisted (Claude Code). |
# Conflicts: # scripts/build_runtime.ps1
# Conflicts: # scripts/build_runtime.ps1
|
Tested 45c39cf on Windows 10.0.26200, MSVC 14.52 (Visual Studio 18 2026, x64, RelWithDebInfo): pass. These targets are CPU-only (file-to-memory DirectStorage), no GPU path. Built
|
|
Tested 45c39cf merged onto main 3faac55 on an RTX 5090 (driver 616.92), Windows 11, MSVC 19.44, Vulkan SDK 1.4.363, RelWithDebInfo:
AI-assisted (Claude Code). |
|
Wine 11.22 on CachyOS x86-64, clang-cl/xwin + SDL3. I compared local runs with the same GameInput fix, experimental CPU-side XMem backing and isolated display. Before adding your change, startup stops at The synthetic DirectStorage test passed 270 of 272 checks in this environment. The file/overlay reads returned the expected bytes. Both failures were in |
|
Tested |
…StorageGetFactory) with file-to-memory reads Author: mariuslozo-boop Two conflicts, both resolved by keeping each side: the docs/README.md index row and the dstorage ctest entry next to the XTaskQueue tests in runtime/CMakeLists.txt. Not built here: no Windows toolchain. Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01UkEUa9YfGQH4p9g1Guw9gq
|
Windows MSVC integration validation on current main 1cc6e3c with executable TLS slot-zero support: dstorage and unimplemented_policy CTests pass, together with all three loader_tls_index0 scenarios and run_tiny_tls_ga (6/6). A local startup diagnostic now reaches DStorageGetFactory and IDStorageFactoryX::OpenFile through xcrdapi.dll, then stops at the still-unimplemented XMemAllocatePhysicalPages export. This diagnostic uses CPU-only backing for unsupported committed graphics allocations, so it does not establish normal boot or GPU correctness. No game files, bytes or logs included. Thanks for the implementation; no duplicate PR opened. |
|
Rebased onto current main (1cc6e3c) with the conflicts resolved: |
|
This PR conflicts with The resolution is mechanical: Tested at |
|
Heads-up for the rebase, from merging this onto current |
|
Independent native Windows check of
All raw traces stay local. Socket creation, DNS and network-transmission entry points were debugger-guarded; only local Winsock initialization was permitted. No game files, title offsets or register contents attached. AI-assisted (Codex). |
Claimed in the coordination issue as: new RT item, DirectStorage (claim).
What and why
registry.cppmarkedDStorageGetFactoryas returning an error code, andxcrdapi.dllwas not named at all, so a title that loads through DirectStorage got no data. The package's textures are BCPack, which the console decodes through DirectStorage (docs/textures.md), so the game likely streams through it. The executable's imports are not measured, so this is an inference.This first PR serves the console DirectStorage API, file to memory:
DStorageGetFactoryunderdstorage_xs.dll,xcrdapi.dllanddstorage.dll, all with the console ABI.CreateFileWshim, soGAME:paths and the overlay work.ID3D12Fencesignals and events.E_NOTIMPL. They and GPU-backed destinations are later PRs.ABI. The declarations in
runtime/shims/dstorage_xs_abi.hare our own, written from Microsoft's public GDK reference for the console API (IDStorageFactoryXand so on). No header is vendored, and no GPL code was read. Struct sizes are pinned withstatic_assert.docs/directstorage.mdrecords the evidence and its confidence:QueryInterfacethen answers onlyIUnknownand IDs learned for that kind of object, and returnsE_NOINTERFACEotherwise, asdocs/d3d12_vulkan.mdasks.dstorage_xs.dllmedium,xcrdapi.dllanddstorage.dlllow.LoadLibraryof them gets the shims' handle, andGetProcAddressfor any other name returnsNULL. Static imports are unchanged. This is noted in the doc.Tested
Windows 11 (build 26300), RTX 5070 Ti (driver 616.92), MSVC 19.44, Vulkan SDK 1.4.363.0, RelWithDebInfo, on
main03b09a08.ctest: 138/138 passed, serial and-j 8. The skips are the usual ones.dstoragetest (synthetic files only): 258 checks. They cover:GAME:and the overlay;GetHandleopening its own handle, so it does not share the shim's file position.-R dstorage --repeat until-fail:30: all 30 runs passed.tests/test_*.pythat CI runs passed, except 5 that fail identically on cleanmainon this machine. This includes the docs, registry, fallback-build and line-ending tests.An independent reviewer read the change, built it, and ran stress probes: four enqueuing threads with
Close, two queues on one file, fileCloseracing submits. The 7 items it raised are fixed with tests.Checklist
docs/design.md, with how it was confirmed. (Not applicable: no translator change.)AI-assisted (Claude Code). No game files.
🤖 Generated with Claude Code