runtime: restore the console DirectStorage shim, with the typed-error inflate it needs (RT-DSTORAGE-RESTORE, #47) #131

Merged
Mumogg merged 1 commit from upstream-pr/131 into main 2026-11-24 03:36:13 +00:00
Mumogg commented 2026-11-24 02:24:24 +00:00 (Migrated from github.com)

Imported from ubiquitarianism/leonida. Originally posted by Mumogg on 2026-11-24T02:24:24Z.


Claimed in #14 as RT-DSTORAGE-RESTORE. Addresses #47 (stop 5 of docs/retail_boot_chain.md).

What and why

The merge that brought the mirrored pull requests into main (6dece9231) did not take the DirectStorage shim; its message says it "needs the typed-error zlib inflate". The shim's commits (f87d05fdd, ac1843da2 by mariuslozo-boop, 00551ba00 by Kelebek) are ancestors of main, but the files are not in the tree, so XCRDAPI.dll!DStorageGetFactory is the one unimplemented import #47 reports, and a plain merge of those commits is a no-op.

  • shims/dstorage.cpp, shims/dstorage_xs_abi.h, test/dstorage_test.cpp and docs/directstorage.md are back, byte for byte as those commits left them. None of this code is mine.
  • leonida::zlib_inflate takes an optional ZlibError* why (header, data, checksum, limit), which the shim turns into its E_DSTORAGE_ZLIB_* codes. It is the interface the shim was written against, added to main's current table-driven inflater. A caller that passes no pointer gets the same bool as before. This is the part I wrote.
  • registry.cpp classes xcrdapi.dll!DStorageGetFactory as an HRESULT import: the retail spelling #47 found missing from the policy class.
  • CMake and scripts/build_runtime.ps1 build the shim into gta6rt (with /EHa for that file under clang-cl, as before); CMake builds and registers dstorage_test.

Measured

Linux (Nobara 44, kernel 7.3), Wine 11.21 staging, RTX 5070 Ti (driver 615.78.08), clang-cl 22.1.8 + xwin SDK 10.0.26100, own 1.0.2.1 copy, network off.

  • The import listing changes from UNIMPLEMENTED XCRDAPI.dll!DStorageGetFactory to shim (shim=94, unimplemented=0).
  • --run on main + this + #127 (under Wine the title stops earlier without #127): 0 D3D12 calls before, D3D12XboxCreateDevice ok after. The next stop is in the host at device slot 26, the first forwarded call (stop 7 of the chain document).
  • shader_library_test under Wine: passes, including its inflate cases (stored, fixed, dynamic, truncated, bad Adler-32, over the limit).
  • dstorage_test under Wine: 329 checks, 2 failures, both in the one case that holds a copy on a PAGE_GUARD page with a vectored handler (the copy reached the guard page, a running request is pending). I have not run it on Windows and do not know whether that case passes there on this tree; CI will say. I did not change the test.

Not done here

  • Not tested with MSVC or on Windows.
  • scripts/build_runtime.ps1 gets the source file added but I could not run that script.

AI-assisted (Claude Code); built and run on the machine above.

🤖 Generated with Claude Code

https://claude.ai/code/session_01HxBQf4pXH8PWpC5oZsM4bt

<!-- greyfinch-sync:ubiquitarianism/leonida:issue:5464895328 --> Imported from [ubiquitarianism/leonida](https://github.com/ProjectLeonida/mandy/pull/131). Originally posted by [Mumogg](https://github.com/Mumogg) on 2026-11-24T02:24:24Z. --- Claimed in #14 as `RT-DSTORAGE-RESTORE`. Addresses #47 (stop 5 of `docs/retail_boot_chain.md`). ### What and why The merge that brought the mirrored pull requests into `main` (`6dece9231`) did not take the DirectStorage shim; its message says it "needs the typed-error zlib inflate". The shim's commits (`f87d05fdd`, `ac1843da2` by mariuslozo-boop, `00551ba00` by Kelebek) are ancestors of `main`, but the files are not in the tree, so `XCRDAPI.dll!DStorageGetFactory` is the one unimplemented import #47 reports, and a plain merge of those commits is a no-op. - `shims/dstorage.cpp`, `shims/dstorage_xs_abi.h`, `test/dstorage_test.cpp` and `docs/directstorage.md` are back, byte for byte as those commits left them. None of this code is mine. - `leonida::zlib_inflate` takes an optional `ZlibError* why` (`header`, `data`, `checksum`, `limit`), which the shim turns into its `E_DSTORAGE_ZLIB_*` codes. It is the interface the shim was written against, added to `main`'s current table-driven inflater. A caller that passes no pointer gets the same `bool` as before. This is the part I wrote. - `registry.cpp` classes `xcrdapi.dll!DStorageGetFactory` as an HRESULT import: the retail spelling #47 found missing from the policy class. - CMake and `scripts/build_runtime.ps1` build the shim into `gta6rt` (with `/EHa` for that file under clang-cl, as before); CMake builds and registers `dstorage_test`. ### Measured Linux (Nobara 44, kernel 7.3), Wine 11.21 staging, RTX 5070 Ti (driver 615.78.08), clang-cl 22.1.8 + xwin SDK 10.0.26100, own 1.0.2.1 copy, network off. - The import listing changes from `UNIMPLEMENTED XCRDAPI.dll!DStorageGetFactory` to `shim` (`shim=94`, `unimplemented=0`). - `--run` on `main` + this + #127 (under Wine the title stops earlier without #127): 0 D3D12 calls before, `D3D12XboxCreateDevice ok` after. The next stop is in the host at device slot 26, the first forwarded call (stop 7 of the chain document). - `shader_library_test` under Wine: passes, including its inflate cases (stored, fixed, dynamic, truncated, bad Adler-32, over the limit). - `dstorage_test` under Wine: 329 checks, **2 failures**, both in the one case that holds a copy on a `PAGE_GUARD` page with a vectored handler (`the copy reached the guard page`, `a running request is pending`). I have not run it on Windows and do not know whether that case passes there on this tree; CI will say. I did not change the test. ### Not done here - Not tested with MSVC or on Windows. - `scripts/build_runtime.ps1` gets the source file added but I could not run that script. AI-assisted (Claude Code); built and run on the machine above. 🤖 Generated with [Claude Code](https://claude.com/claude-code) https://claude.ai/code/session_01HxBQf4pXH8PWpC5oZsM4bt
moffington commented 2026-11-24 03:27:48 +00:00 (Migrated from github.com)

Imported from ubiquitarianism/leonida. Originally posted by moffington on 2026-11-24T03:27:48Z.


I reproduced both PAGE_GUARD failures at 2d7be48 on Omarchy Linux x86-64 (kernel 7.2.15-1-omarchy, Wine 11.20, Clang 23.1.3 targeting x86_64-w64-mingw32). This was a diagnostic build with VirtualQuery checks in guarded_move because my MinGW-targeted build omitted the SEH handler.

In the failing run, the guarded allocation landed exactly at the queue worker’s StackBase. The worker copied all 4096 bytes and cleared PAGE_GUARD, but no guard-page exception reached the vectored handler. Moving the allocation away from StackBase restored the exception, and test_stats_timing passed all 25 checks.

shader_library_test passed at both revisions, and the synthetic zlib checks passed. I’d wait for native Windows CI to pass the unmodified dstorage_test before merging.

<!-- greyfinch-sync:ubiquitarianism/leonida:comment:7121115397 --> Imported from [ubiquitarianism/leonida](https://github.com/ubiquitarianism/leonida/pull/131#issuecomment-7121115397). Originally posted by [moffington](https://github.com/moffington) on 2026-11-24T03:27:48Z. --- I reproduced both PAGE_GUARD failures at 2d7be48 on Omarchy Linux x86-64 (kernel 7.2.15-1-omarchy, Wine 11.20, Clang 23.1.3 targeting x86_64-w64-mingw32). This was a diagnostic build with VirtualQuery checks in guarded_move because my MinGW-targeted build omitted the SEH handler. In the failing run, the guarded allocation landed exactly at the queue worker’s StackBase. The worker copied all 4096 bytes and cleared PAGE_GUARD, but no guard-page exception reached the vectored handler. Moving the allocation away from StackBase restored the exception, and test_stats_timing passed all 25 checks. shader_library_test passed at both revisions, and the synthetic zlib checks passed. I’d wait for native Windows CI to pass the unmodified dstorage_test before merging.
tib1rgitta-eng commented 2026-11-24 03:41:31 +00:00 (Migrated from github.com)

Imported from ubiquitarianism/leonida. Originally posted by tib1rgitta-eng on 2026-11-24T03:41:31Z.


Tested on native Windows, which the description says is missing. Windows 11, AMD RX 6750 GRE 12GB (RDNA2), own 1.0.2.1 copy, network off, main 1c7f5b5106 with this diff applied unmodified, runtime stage built with make_game.py (clang-cl, Windows SDK 10.0.26100).

  • It compiles clean, including the /EHa file and the CMake and build_runtime.ps1 additions.
  • --dry-run: 0 unimplemented imports; XCRDAPI.dll!DStorageGetFactory lists as shim, policy hresult=0 other=0 (on main alone it is the one UNIMPLEMENTED entry).
  • --run: D3D12XboxCreateDevice ok as the only D3D12 call, then the host AV at device slot 26 — the same next stop you measured under Wine, at gta6rt.exe+0xf5478 (callq *0xd0(%r10), read 0xd0) from exe+0x2478713.

So the console spelling in registry.cpp is what clears stop 5 on Windows too. Details and an A/B table are in #47. dstorage_test I did not run.

(Prepared with AI assistance.)

<!-- greyfinch-sync:ubiquitarianism/leonida:comment:7121330727 --> Imported from [ubiquitarianism/leonida](https://github.com/ubiquitarianism/leonida/pull/131#issuecomment-7121330727). Originally posted by [tib1rgitta-eng](https://github.com/tib1rgitta-eng) on 2026-11-24T03:41:31Z. --- Tested on native Windows, which the description says is missing. Windows 11, AMD RX 6750 GRE 12GB (RDNA2), own 1.0.2.1 copy, network off, `main` `1c7f5b5106` with this diff applied unmodified, `runtime` stage built with `make_game.py` (clang-cl, Windows SDK 10.0.26100). - It compiles clean, including the `/EHa` file and the CMake and `build_runtime.ps1` additions. - `--dry-run`: 0 unimplemented imports; `XCRDAPI.dll!DStorageGetFactory` lists as `shim`, policy `hresult=0 other=0` (on `main` alone it is the one `UNIMPLEMENTED` entry). - `--run`: `D3D12XboxCreateDevice ok` as the only D3D12 call, then the host AV at device slot 26 — the same next stop you measured under Wine, at `gta6rt.exe+0xf5478` (`callq *0xd0(%r10)`, read `0xd0`) from `exe+0x2478713`. So the console spelling in `registry.cpp` is what clears stop 5 on Windows too. Details and an A/B table are in #47. `dstorage_test` I did not run. *(Prepared with AI assistance.)*
ecox982745 commented 2026-11-30 20:12:51 +00:00 (Migrated from github.com)

Imported from ubiquitarianism/leonida. Originally posted by ecox982745 on 2026-11-30T20:12:51Z.


Native Windows follow-up for the requested dstorage CTest. I built the unmodified dstorage_test target with MSVC 19.44 in Release on Windows 11 build 26300 and ran the registered CTest serially three times per revision.

  • PR #131 merge fabe844cd: 329 checks, zero failures in every run. This includes the original test_stats_timing case with the PAGE_GUARD source.
  • main 0f86bd594: 563 checks, zero failures in every run. The current timing fixture uses PAGE_NOACCESS for its first-read barrier. It also passed its wait for the worker to reach that barrier.

CPU-only tests with synthetic temporary files. Coordination finding. AI-assisted with OpenAI Codex (GPT-6.2 Sol).

<!-- greyfinch-sync:ubiquitarianism/leonida:comment:7290576317 --> Imported from [ubiquitarianism/leonida](https://github.com/ProjectLeonida/mandy/pull/131#issuecomment-7290576317). Originally posted by [ecox982745](https://github.com/ecox982745) on 2026-11-30T20:12:51Z. --- Native Windows follow-up for the requested `dstorage` CTest. I built the unmodified `dstorage_test` target with MSVC 19.44 in Release on Windows 11 build 26300 and ran the registered CTest serially three times per revision. - PR #131 merge `fabe844cd`: **329 checks, zero failures** in every run. This includes the original `test_stats_timing` case with the `PAGE_GUARD` source. - `main` `0f86bd594`: **563 checks, zero failures** in every run. The current timing fixture uses `PAGE_NOACCESS` for its first-read barrier. It also passed its wait for the worker to reach that barrier. CPU-only tests with synthetic temporary files. [Coordination finding](https://github.com/ProjectLeonida/mandy/issues/2570#issuecomment-7288839384). AI-assisted with OpenAI Codex (GPT-6.2 Sol).
Sign in to join this conversation.
No reviewers
No labels
No milestone
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Reference
ProjectLeonida/mandy!131
No description provided.