Skip to content

DirectStorage: read deferred zero mappings as native inputs - #671

Open
Prime1997 wants to merge 1 commit into
xcl-dev:mainfrom
Prime1997:fix/dstorage-lazy-read-inputs
Open

Prime1997 wants to merge 1 commit into
xcl-dev:mainfrom
Prime1997:fix/dstorage-lazy-read-inputs

Conversation

@Prime1997

@Prime1997 Prime1997 commented Nov 24, 2026 •

Copy link
Copy Markdown
Contributor

DirectStorage could reject a valid zero-filled memory source or a physical-page table before its first CPU access. Native reads bypass XCL's first-touch handler.

What is in it

Tested

  • Windows 11 build 26200, Intel Core i5-10400, GeForce RTX 3060 Ti, driver 32.0.16.1714, Rust 1.100.0. Release workspace build succeeded.
  • cargo test --locked --workspace -- --test-threads=4 --nocapture on the PR head, debug, 696 passed, 0 failed, 41 ignored. Two GPU tests emitted SKIPPED because this adapter lacks wave64: gpu_geometry_wave32_prefix_count_over_a_mask and gpu_wave32_program_in_wave64_hardware.
  • On dd2ae9a the untouched memory source and zero-filled page-table tests both failed with E_ACCESS_VIOLATION. On d9a96fd all 19 DirectStorage tests and both existing kernelx lazy-page tests passed.
  • Paired offline retail startup runs used the same adapter and compiler DLLs, 60 seconds each, with no menu input. Each run used a fresh title-data directory and the same initial shader-cache contents.

Regression run

Official main:

xcl-smoke v1
commit: dd2ae9a70af5eb5aad60f02d86e386b72abe1e95
gpu: NVIDIA GeForce RTX 3060 Ti
title: 419239bf
seconds: 60
exit: 0x0
frames shown: 239 (PresentX 240)
presents per 2 s (last 3): 9 11 16
device removals: 0
crashes: 0
peak commit: 15399 MB

PR head:

xcl-smoke v1
commit: d9a96fd1fd57314b516b452d7eb1ef7315b698e9
gpu: NVIDIA GeForce RTX 3060 Ti
title: 419239bf
seconds: 60
exit: 0x0
frames shown: 268 (PresentX 268)
presents per 2 s (last 3): 11 11 10
device removals: 0
crashes: 0
peak commit: 15799 MB

Not tested

  • The retail comparison covers startup. A separate player-controlled run on our integration containing this change and D3D12.X: bound wait_for_commit so big background compiles cannot deadlock #567 still hit the world-loading watchdog. The cause of individual retail storage failures remains unverified. Hardware coverage was limited to the RTX 3060 Ti. Optional RPF, TTPF and AWC sample fixtures were unset during the workspace tests.

AI use

  • OpenAI Codex (GPT-6) investigated the bug, implemented and reviewed the change, ran the tests and prepared this description.

I use a temporary Discord to coordinate my work. Anyone helping test XCL or compare results is welcome. Test coordination on Discord

Kernel-native reads cannot invoke the first-touch handler. A valid untouched lazy page table or memory source therefore failed with E_ACCESS_VIOLATION. Prepare only still-reserved whole pages already tracked as lazy, then retry the normal read or validation, including when another thread already committed them. Other reservations and committed protections remain unchanged.

Six CPU regressions cover deferred memory sources, owned page-array snapshots across a page boundary, ordinary unreadable reservations, explicit readonly/noaccess/guard protection, partially committed pages, and a deterministic competing-first-touch race. The two positive cases fail on official dd2ae9a without the fix. Focused DirectStorage tests: 19 passed; existing lazy tests: 2 passed. No GPU or retail run in this change; relationship to the observed retail storage failures remains unproven.
@thehollowedone

Copy link
Copy Markdown

Tested

I tested a legal cross-page memory request through XCL’s DirectStorage queue, including enqueue, submit, worker execution, and the completion status. The first 48 bytes came from committed memory filled with 0x5a. The next 48 bytes came from a tracked zero page that was still reserved after enqueue.

  • main at 91f9a5e completed with E_ACCESS_VIOLATION and left all 96 destination bytes unchanged.
  • With d9a96fd integrated onto that baseline, the same queued request completed with S_OK and returned the expected 48 patterned and 48 zero bytes.

cargo test --offline --locked -p xcl --lib hle::dstorage -- --nocapture --test-threads=1 passed 14/14 on the baseline and 20/20 with the patch. Each count includes the scratch queue fixture and its revision-specific assertion.

Windows 11 build 26300, Ryzen 7 9800X3D, Rust 1.99.1 MSVC, debug. This was a CPU-side synthetic check.

Not tested

Retail streaming, GPU timing, and the full workspace suite.

AI use

Codex with GPT-6.2 Sol wrote the scratch fixture, ran the tests, and drafted this report.

@upipibi upipibi mentioned this pull request Nov 24, 2026
@JoaoPauluu

Copy link
Copy Markdown

Test report: #671 under Wine (Linux, NVIDIA): one new test fails on Wine's ReadProcessMemory with a guard page; GTA VI regression pair

Setup

  • CachyOS, kernel 7.3.3-1-cachyos, Intel i5-10400F, 16 GB RAM, NVIDIA GeForce RTX 3060 12 GB, driver 620.70.06
  • Proton Experimental experimental-11.0-20261112 (wine-11.0), vkd3d-proton v3.1 (4522cc1a) + the patch from Linux: docs/linux.md, scripts/linux and Wine start-up checks for vkd3d-proton and DXVK (#154, #241) #257, DXVK from Proton, DXC 1.9.2609, DXVK_CONFIG="dxgi.hideNvidiaGpu = False"
  • Rust 1.100.0, x86_64-pc-windows-gnu (mingw-w64-gcc 16.2.0); debug for the tests, release for the runs
  • Commits: this PR's head d9a96fd and its merge base main dd2ae9a

Unit tests (lib test binary under Wine, --test-threads=1, filter dstorage): 18 passed, 1 failed, in 2 of 2 runs.

hle::dstorage::lazy_input_tests::deferred_read_preparation_preserves_explicit_page_protections
panicked at crates/xcl/src/hle/dstorage_lazy_input_tests.rs:176:17:
  left: Ok([0])
 right: Err(-1994129399)

To see which protection it is, I printed each case locally (test file restored afterwards):

protect copy_from snapshot_page_array Protect afterwards
PAGE_READONLY (0x2) Ok, zeros Ok([0]) 0x2
PAGE_NOACCESS (0x1) Err, destination untouched Err(E_ACCESS_VIOLATION) 0x1
PAGE_READWRITE | PAGE_GUARD (0x104) Err, destination untouched Ok([0]) 0x4

So only the guard-page case differs: ReadProcessMemory(GetCurrentProcess(), …) under this Wine reads a guard page and the guard is gone afterwards, so the test's last assert (Protect == protect) would fail too. read_own on main makes the same ReadProcessMemory call; the PR only adds the retry around it, so this looks like a Wine difference that the new test exposes, not something the PR changes. I didn't check other Wine versions.

GTA VI 1.0.2.1 (my own dump; 60 s runs with scripts/linux/smoke.sh from #257, XCL_NETWORK=0, alternating base / PR / PR / base)

build frames shown DirectStorage requests / MB / failed removals / crashes
dd2ae9a 960, 1012 9764 / 650 / 0; 9767 / 650 / 0 0 / 0
d9a96fd 1014, 985 9767 / 650 / 0; 9767 / 650 / 0 0 / 0
xcl-smoke v1
commit: dd2ae9a70af5eb5aad60f02d86e386b72abe1e95
gpu: NVIDIA GeForce RTX 3060
title: GTA6.Xbox.v1.0.2.1
seconds: 60
exit: 0x0
frames shown: 960 (PresentX 960)
presents per 2 s (last 3): 42 49 0
device removals: 0
crashes: 0
peak commit: 0 MB
xcl-smoke v1
commit: d9a96fd1fd57314b516b452d7eb1ef7315b698e9
gpu: NVIDIA GeForce RTX 3060
title: GTA6.Xbox.v1.0.2.1
seconds: 60
exit: 0x0
frames shown: 1014 (PresentX 1014)
presents per 2 s (last 3): 56 2 21
device removals: 0
crashes: 0
peak commit: 0 MB

(The first pair. peak commit: 0 MB is XCL reading 0 MB committed under Wine, see #257.) GTA VI's requests all succeed on both builds, so these runs don't show whether it ever hits the deferred-zero-page case.

Not tested

  • Windows, AMD; other Wine versions for the guard-page case; the other test filters on this branch

AI use: Claude Code (Claude Opus 5.5) built both commits, ran everything above on the machine above and wrote this report. The blocks, counts and the panic are pasted from those runs. The account owner asked for test reports to be posted while they were away and has not reviewed this one.

@MesshM

MesshM commented Nov 24, 2026

Copy link
Copy Markdown

Test run of d9a96fd1fd57314b516b452d7eb1ef7315b698e9 on AMD RDNA4. I merged it onto current main 64b3f35 locally (clean merge) and tested that tree.

Tested

  • AMD Radeon RX 9060 XT 16 GB (RDNA4), driver 32.0.32029.2010; Ryzen 7 5700X, 64 GB RAM, Windows 11 Pro build 26200 (native Windows, not Wine), Rust 1.100.0 stable-x86_64-pc-windows-msvc, debug
  • cargo build --workspace + cargo test --workspace -- --test-threads=4 on the merge: 707 passed, 0 failed, 41 ignored, exit code 0; xcl lib tests 666 passed, 0 failed, 21 ignored
  • 0 SKIPPED; the dstorage and lazy tests pass, the new ones included.

Review: This run is on native Windows; the Wine failure reported above (Wine's ReadProcessMemory on a guard page) does not show up here, so it looks Wine-specific rather than a problem in the change. Preparing the reserved pages kernelx tracks and retrying the read once keeps a valid zero-filled source from being refused before its first touch. I did not trace the concurrent first-touch race the description mentions.

Not tested: no retail title or regression run (I have no unpacked game), no XCL_SAMPLE_* tests, release build; the PR's head on its old base was not run, only its merge onto main.

Run and review by Claude Code (Claude Opus 5.5) on this machine; the review points were checked against the code.

@PedroNunes11

Copy link
Copy Markdown

Native Windows retail-title data point for d9a96fd.

Tested

  • Windows 11 Pro build 26200; Ryzen 7 9800X3D; 32 GB RAM; NVIDIA RTX 4070 Ti SUPER 16 GB, driver 32.0.16.2124; Rust 1.100.0 MSVC; release build.
  • GTA VI 1.0.2.1, Series X profile, XCL_NETWORK=0, XCL_ACTIVITY=1, XCL_UMA_MB=4095, XCL_COHERENT_MB=4095.
  • d9a96fd cherry-picked onto main e50836b (local commit 16e2f17). The tree also had a four-line local XCL_NO_SYSTEM_XGAMERUNTIME opt-out because the system XGameRuntime crashes on this machine; that change is outside DirectStorage.
  • cargo test -p xcl --lib deferred -- --test-threads=1: 7 passed, 0 failed (including the five new deferred-input tests selected by the filter).

The PR removes the deferred physical-page failures this title hits. On the immediately preceding main baseline (d208e14, the only later main change was README), with unsupported BCPack destinations filled and reported as successful, the activity log had 1,893 failed DirectStorage requests in one 2 s interval, with representative status 0x89240009. With d9a96fd integrated and the same local BCPack diagnostic, every activity interval reported 0 failed requests, including the heavy world-streaming intervals.

It does not remove the later world-loading stall on this machine:

58.020 s: 6 presents; DirectStorage 5325 requests, 298 MB, 0 failed
64.023 s: 16 presents; DirectStorage 3635 requests, 179 MB, 0 failed
66.023 s: 0 presents; DirectStorage 162 requests, 15 MB, 0 failed
66.535 s: Wait64BitValueX timed out
94.402 s: null write at game_scarlett_master.exe+0x23cf683
peak process commit: 30.65 GB; peak local video memory: 14.21 GB

The local BCPack diagnostic filled unsupported blocks and reported those requests as successful; it is not proposed as a fix. Its purpose here was to isolate the remaining stall after both known DirectStorage failure classes were suppressed. The result supports d9a96fd fixing the lazy-input failures, but shows that those failures are not the only cause of the GTA VI stall tracked in #232.

Not tested

  • Full workspace suite, AMD, or an unmodified system-XGameRuntime path.
  • This is not a clean PR smoke block because of the disclosed XGameRuntime opt-out and BCPack diagnostic; the timings above are copied from the real run log, not presented as a merge-gating regression run.

AI use

OpenAI Codex with GPT-5 built the branches, ran the tests and title, analyzed the logs, and drafted this report. The account owner requested that the useful results be posted.

@JJAutoCompare

Copy link
Copy Markdown

Empirical test report (d9a96fd)

Hardware / environment

  • PR DirectStorage: read deferred zero mappings as native inputs #671, commit d9a96fd1fd57314b516b452d7eb1ef7315b698e9.
  • Windows 11 Enterprise Evaluation x64, build 26200.9974. AMD CPU reported as AMD64 Family 23 Model 113 Stepping 0, approximately 3.9 GHz, with 12 logical processors visible to the session.
  • Rust and Cargo 1.100.0, host x86_64-pc-windows-msvc. DXC 1.9.2609.5 (01b62ad47). CPU-only execution with XCL_ADAPTER=NONE_CPU_ONLY. No GPU adapter used.

Commands and results

  • cargo test --workspace --no-run exited 0 and built the workspace test executables. Compilation only.
  • cargo test -p xcl --lib hle::dstorage::lazy_input_tests:: -- --test-threads=1 exited 0 with RUST_TEST_NOCAPTURE=1. The captured result was 6 passed, 0 failed, 0 ignored, and 671 filtered out. The log contained 0 case-sensitive lines beginning with SKIPPED .

Observed behavior

  • A DirectStorage memory read committed a tracked deferred mapping and copied 64 zero-valued bytes. A page-array snapshot spanning two deferred pages retained its original zero entries after the source was overwritten, and a new snapshot saw the new entries.
  • An untracked reservation and an overflowing page-array address were rejected. Preparation left the reserved portion of a partly committed page uncommitted and preserved read-only, no-access, and guard protections.
  • After another thread materialized the page, both read paths succeeded on the second attempt and the native copy returned zero-filled data.

Not tested

The full GPU workspace suite and game smoke runs were omitted.

AI use

Verified with T3 Code / Codex (gpt-6.2-sol, reasoningEffort: high). Coordinator #2 (T3 Code / Antigravity, gemini-4-neon) verified counts against pr671-focused.log and published.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

goal:world-load Bears on the retail title getting past world loading

Projects

None yet

Development

Successfully merging this pull request may close these issues.

7 participants