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
Collaborator

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
Contributor

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.

@DavidM1911

Copy link
Copy Markdown
Contributor

Verification on RTX 3060 Ti (Windows 11), branch merged with current main:

Thanks!

@thehollowedone

thehollowedone commented Nov 27, 2026 •

Copy link
Copy Markdown
Contributor

merge-check
base: 6089122a1c96dff16e93b6fdf04c8ed20cfb6102 (main, checked 2026-11-27)
head: d9a96fd1fd57314b516b452d7eb1ef7315b698e9
merge: clean text merge; one test call is incompatible with current main
build: cargo build --workspace -> ok on the unmodified merge
tests: cargo test --workspace --no-fail-fast -- --test-threads=4 -> compilation failed on the unmodified merge (E0061 at dstorage_lazy_input_tests.rs:59; no tests ran). After adding only the missing false argument in a disposable local copy, the same command ran: 1,470 passed, 1 failed, 47 ignored, with 25 SKIPPED GPU notices. All six new deferred-input tests passed. The failure was gpu::recomp::pso::shader_cache_tests::console_mesh_caches_hlsl_compute_pass_in_memory_and_on_disk (cached_only console_mesh hit: "DXIL not compiled yet"). The exact focused test also failed on untouched base 6089122 (0 passed, 1 failed).
review: the test helper calls execute(&request, None, None, None), but current main added the dest_on_stack: bool parameter before src_pages. This test uses a virtual destination, so false matches its setup. I found no further issue in the merged source path for deferred preparation or owned page snapshots.
performance: successful native reads retain one read and do not acquire the lazy-page lock. A failed read tries preparation under that lock and retries once; this path is limited to failed/first-touch reads. Frame-time and memory effects were not measured.
verdict: not yet. Update the fixture call on the PR head and rerun the required checks against current main; then the merge result can be checked again.
hardware / tool and model: Windows 11 build 26300, Ryzen 7 9800X3D, NVIDIA RTX 3080 Ti 12 GB / 621.35, Rust 1.99.1 MSVC, DXC 1.8.2502.11. Codex (GPT-6.2 Sol) ran the builds/tests and checked the merge; Codex (GPT-6.2 Astra) independently traced the source path.

One-line test compatibility adjustment used for the verification run
-    execute(&request, None, None, None)
+    execute(&request, None, None, false, None)

@throny

throny commented Nov 27, 2026

Copy link
Copy Markdown
Collaborator

merge-check claim
head: d9a96fd

@throny

throny commented Nov 27, 2026

Copy link
Copy Markdown
Collaborator

merge-check
base: 6089122
head: d9a96fd
merge: clean
build: cargo build --workspace -> ok
tests: cargo test --workspace --no-fail-fast -- --test-threads=4 -> does not compile: E0061 in crates/xcl/src/hle/dstorage_lazy_input_tests.rs:59, execute takes 5 arguments on current main (a bool before the source pages), the test passes 4. No test ran. Base alone: 1465 passed, 0 failed, 47 ignored.
review: apart from that, nothing blocking. prepare_read checks the range for overflow, holds the write lock and commits only tracked pages whose whole 64 KiB is still reserved; its lock order matches the fault handler's. read_own now also prepares pages for its other callers (late-fill compare, file-vtable read): harmless, but not in the description. The test's VirtualAlloc / VirtualProtect touch only its own reservation.
performance: a read that succeeds is unchanged; only a failed read takes the write lock and retries once (reasoned).
verdict: not yet: add the new argument to the test call (the first check says false), rebase on current main; I will rerun the suite on the new head.
hardware / tool and model: RTX 4080 16 GB (621.40), i9-12900K, Windows 11 26300, Rust 1.100.0, debug. Claude Code; merge, build and suite run by Claude Fable 5.2, diff review by Claude Opus 5.5 (every hunk read; nothing run on the GPU beyond the suite).

@bmjask bmjask left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Critical review of current head d9a96fd1. The deferred-zero input retry is targeted and the cross-page behavior has a direct queue-level Windows test. Current-main test-build blocker: dstorage_lazy_input_tests.rs:59 calls execute with four arguments, while main's signature now takes five; a text-clean merge cannot run the suite until the missing argument is ported. See the merge-check report. Please rebase that fixture and rerun the whole storage test filter; also retain the protection/partial-commit negative cases so the retry does not make unrelated addresses readable. No local Windows run.

@Foniass

Foniass commented Dec 1, 2026

Copy link
Copy Markdown
Collaborator

Review (head d9a96fd, diff read, not a merge-check; it conflicts with main, so not built or run):

  • Overlaps open DirectStorage: commit lazy pages before reading a source or page array #2359, which closes the same gap with the existing kernelx::lazy::ensure. The gap is still on main: the memory source is only checked with shader::readable (dstorage.rs ~970) and the page array read with read_own (~811), neither of which commits lazy pages first.
  • prepare_read adds a second version of lazy::commit / ensure (lazy.rs ~38, ~92) instead of reusing them as writable() does (dstorage.rs ~868).
  • On main read_own is pub(crate) and called from bvh_want.rs ~79, list_x.rs ~302 / ~2471 and sparse.rs ~3500, so after a rebase a failed read in any of those would commit lazy pages too, a behaviour change outside DirectStorage.
  • The README row describes an internal detail, and the tests sit in a separate #[path] file instead of dstorage.rs's mod tests.

Fine: the tests cover the protection and partial-commit cases. Recommendation: close in favour of #2359 (moving the protection and partial-commit tests there), or rebase onto lazy::ensure limited to the two DirectStorage reads.

AI review: Claude Code (Claude Opus 5.5), posted by Foniass without a human check of each point.

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.

10 participants