Repository navigation
DirectStorage: a late page array holds a half-full queue until Submit - #549
papasmurph0 wants to merge 1 commit into
Conversation
A retail title enqueues requests whose destination page array has an entry of 0 and fills that entry after EnqueueRequest, before its own Submit. xcl-dev#289 reads such an entry again at the request's turn, but a half-full queue submits by itself, so during the title's loading bursts the worker reaches the request before the title has filled the entry: the reread still sees 0 and the request fails with E_ACCESS_VIOLATION (0x89240009). Logged on a local build: every refused request had a one-entry array still holding 0 at its turn. Now a queue holding such a request does not submit by itself; the title's Submit reads the missing entries again on the title's own thread (through ReadProcessMemory, as at enqueue), where the array is still the title's - which also narrows the window xcl-dev#476 describes. An entry still 0 then is read again at the request's turn, as before. Test: a capacity-2 queue does not run a request with a missing page before Submit, and the request lands once the title fills the entry and submits; it fails without the change. Assisted-by: Claude Code (Claude Opus 5.5) Claude-Session: https://claude.ai/code/session_01SEW8zXNUmMq1tRUZpstWXS
|
Additional local validation of the late-page change: the baseline recorded 3,972 DirectStorage Both patched runs still crashed before reaching the prologue, and BCPack refusals remained. The measured improvement is specific to the zero-page DirectStorage failures. |
|
I ran into the same failures independently before finding this PR, so here's a second machine's How I got there. On a laptop I added a local log line for every failed DirectStorage request This PR on my machine. Your commit on
On the older base ( Setup and test suite
Not tested: AMD, runs longer than 4 minutes, the PR on its own base. AI use: Claude Code with Claude Opus 5.5 built and ran everything, wrote the local counter and drafted |
|
One input pattern worth covering in In one run, 17,639 requests shared a table start with another pending request, had disjoint proposed destination writes, and had no other Enqueue snapshot that independently identified the missing page. Another 26 had partially overlapping tables with the same properties. These are counts of requests, not distinct tables. The local build left those requests alone. It adopted 6,612 independent snapshots in that run and completed all 6,612 file reads (1,488,826,368 bytes). A small test case for this PR would enqueue two file slices against one initially empty table, fill it before Submit, reuse the table immediately afterwards, and check both destination byte ranges and their untouched neighbours. The counters establish that sharing occurs. They do not tell us whether the title intended to recycle the table, or whether either destination was incorrect. This was a local experiment, not a run of AI use: Codex (GPT-6) checked the per-run counters and the PR diff and drafted this note. |
|
I tested the late-page change on Windows 11 build 26300, i7-14650HX, 32 GB RAM, RTX 4060 Laptop 8 GB, NVIDIA 616.92. Both release builds ran the same retail 1.0.2.1 story load with the same saved profile, initial cache, four memory windows and default pipeline waits. I ran The control was #905 at
All eight detailed failures captured in the control were AI use OpenAI Codex (GPT-6) prepared the local builds, ran the tests and wrote this report. |
|
Retail data from Linux for this PR: the failure it fixes, and a run with it merged. Setup: RTX 5080 (NVIDIA 620.73.04), proton-cachyos-slr Wine, vkd3d-proton master
With this PR merged (head as of today, on the same branch, stopgap still in): 0 DirectStorage failures in a 270 s world-loading run, where the 11 runs before had 128 to over 2 048 each. Not tested: Windows, AMD. AI use: Claude Code (Claude Opus 5.5) found this in the run logs, ran the PR and wrote this text; the user approved posting it. |
|
Linux RTX 4060 (8 GB), 16 GB RAM, NVIDIA 620.73.04, GE-Proton11-14; retail 1.0.2.1, Series X profile. Five runs used the same unmodified release binary from
I didn't test the PR head. This is baseline variability on a second Linux/NVIDIA configuration, not confirmation or refutation of a late page array. For comparisons here I'd report the first same-request stage and the cumulative request count alongside the failure total. No game data or logs attached. AI use: Hermes Agent (gpt-6.2-astra) ran the local measurements and checked the activity intervals against the title logs for this note. |
|
AMD (RDNA4) run of this change: 2 072 requests failed with Tested
The run with the change ended on a device removal 2.7 s after Not tested
AI use: Claude Code (Claude Fable 5.2) built both trees, ran the tests, read the logs and wrote this report. A person passed the menus. All numbers are from the logs of these two runs. |
|
@papasmurph0 a follow-up to Plan: at the title's It is a small commit on top of this PR, with two tests. You can fold it in, or I can open it stacked on this one. Measured in runs on my machine; the diagnostic, the change and this report were written with Claude Code (Claude Opus 5.5, reviewed with Claude Fable 5.2). |
|
Test report for #549 at Setup
Results
Not tested
AI use
|
|
Linux (Wine + vkd3d-proton) + NVIDIA test of Setup: Fedora 44 (kernel 7.2.9), Wine 11.21 Staging (Wayland driver), vkd3d-proton v3.1-90-g30b0eb9b with the relaxed-vtable patch from #175 and a local dxil-spirv patch. RTX 4070 12 GB (driver 615.71.09), Ryzen 9 9950X3D, 64 GB RAM. Release, cross-compiled to Tested
Without the change the failures come in one burst, nearly all within one 2 s window between 74 s and 90 s of the run (for example 1,994 in the window ending at 82 s), during the world load. The files named in the warnings are the title's texture tables ( Read
Not tested: past 100 s, so not the AI use: Claude Code (Claude Fable 5.2) read the diff, built the tree, ran the test and the ten runs with |
…fallbacks Incorporate targeted upstream fixes from ivall/xcl PRs and local diagnostics to resolve world-loading E_ACCESS_VIOLATION streaming errors, fence monitor deadlocks, and mesh/compute PSO visibility: - DirectStorage (ivall/xcl PR xcl-dev#549; relates to xcl-dev#289, xcl-dev#476, xcl-dev#1164): * crates/xcl/src/hle/dstorage.rs: Add Pending::late and refill_late_pages() so queues with 0 entries in destination physical-page arrays do not auto-submit at half capacity before the title calls Submit() and fills the page entries. Add unit test a_late_page_array_holds_a_half_full_queue_until_the_titles_submit. * Ensure lazy physical pages via kernelx::lazy::ensure() in snapshot_page_array() and before re-reading stale destination page tables on execute() failure, logging failing snapshot/live entries (adds test dest_physical_pages_rereads_stale_snapshot). - D3D12.X fences (ivall/xcl PR xcl-dev#1297): * crates/xcl/src/hle/d3d12x/fence_x.rs: Track all intermediate queued signal values in Fence::pending (BTreeSet<u64>) before completed_value_address() creates the cell, initialize the cell from GetCompletedValue() before publishing, and arm all pending values > initial so *cell cannot remain stale at 0 and deadlock callers waiting on intermediate fence values. Adds test intermediate_signal_queued_before_completed_value_address_updates_cell. - D3D12.X PSOs (ivall/xcl PR xcl-dev#1300 / xcl-dev#1035 and PR xcl-dev#1298): * crates/xcl/src/hle/d3d12x/real.rs: Log driver rejections of translated compute PSOs (hr, DXIL byte size, elapsed compile ms) directly via xlog_warn! so refusals are not masked after note_translation_error's 40-reason limit is consumed (PR xcl-dev#1300). * Update fallback_stream() to handle subobject types 24/25 (AS/MS) so mesh pipelines with MS in slot 24 rewrite cleanly with stand-in mesh shaders instead of invalid null AS payloads (PR xcl-dev#1298). Assisted-by: Antigravity (Gemini 4 Neon)
ivall#1379 Integrate 22 open upstream PRs targeting world rendering, shader correctness, DirectStorage terrain loads, and crash/memory stability: - ivall#1321 (ivall#1307): fall back to pc blocks when structured CFG HLSL grows oversized (eliminates the 148 MB HLSL / 1 GB/s commit explosion from b8b1f49 so XCL_PSO_PRELOAD=1 stays flat at ~5.4 GiB) - ivall#549, ivall#1312: DirectStorage late page-array queue hold (fixes 0x89240009 terrain read failures) and 0-byte memory-source requests - ivall#1365 (ivall#1361): GFX10.30 scratch SADDR 0x7F addresses the immediate offset alone instead of adding v0 - ivall#1368: translated compute PSOs use NodeMask 0 - ivall#1371 (ivall#105): deduplicate packed ISG1 vertex input struct fields - ivall#1375 (ivall#1360): ES s_setpc_b64 ends block before gs_start - ivall#1350, ivall#1351, ivall#1352, ivall#1353, ivall#1349: VS layer/viewport outputs, PS sample index/fixed-point position & SV_Coverage, depth+UAV initial states, console SetPredication - ivall#1305, ivall#1306, ivall#1314, ivall#1319, ivall#1322, ivall#1334, ivall#1339, ivall#1355, ivall#1357, ivall#1379: console_list UMA hold on Release, v_cmp_class_f32 bitwise abs/neg, late_release vram queue wait, root arg clamping, empty BVH / NaN rays, NULL IASetIndexBuffer clearing, MSAA MipLevels=1, VFS lazy-page commits, coherent VirtualFree validation, cpu_writes PAGE_GUARD & stale fence wakeups - README.md: document the integrated PRs, XCL_PSO_PRELOAD=1, and 16 GiB cap Verified on RX 9060 XT / GE-Proton11-14: release build clean, targeted unit tests pass (75 passed, 0 failed), and 80 s run with XCL_PSO_PRELOAD=1 and XCL_MEM_LIMIT=12G stays flat at 5340-5413 MB with 512+ pipelines preloaded (1385 frames, exit 0x0). Assisted-by: Antigravity (Google DeepMind)
ivall#1379 Integrate 22 open upstream PRs targeting world rendering, shader correctness, DirectStorage terrain loads, and crash/memory stability: - ivall#1321 (ivall#1307): fall back to pc blocks when structured CFG HLSL grows oversized (eliminates the 148 MB HLSL / 1 GB/s commit explosion from b8b1f49 so XCL_PSO_PRELOAD=1 stays flat at ~5.4 GiB) - ivall#549, ivall#1312: DirectStorage late page-array queue hold (fixes 0x89240009 terrain read failures) and 0-byte memory-source requests - ivall#1365 (ivall#1361): GFX10.30 scratch SADDR 0x7F addresses the immediate offset alone instead of adding v0 - ivall#1368: translated compute PSOs use NodeMask 0 - ivall#1371 (ivall#105): deduplicate packed ISG1 vertex input struct fields - ivall#1375 (ivall#1360): ES s_setpc_b64 ends block before gs_start - ivall#1350, ivall#1351, ivall#1352, ivall#1353, ivall#1349: VS layer/viewport outputs, PS sample index/fixed-point position & SV_Coverage, depth+UAV initial states, console SetPredication - ivall#1305, ivall#1306, ivall#1314, ivall#1319, ivall#1322, ivall#1334, ivall#1339, ivall#1355, ivall#1357, ivall#1379: console_list UMA hold on Release, v_cmp_class_f32 bitwise abs/neg, late_release vram queue wait, root arg clamping, empty BVH / NaN rays, NULL IASetIndexBuffer clearing, MSAA MipLevels=1, VFS lazy-page commits, coherent VirtualFree validation, cpu_writes PAGE_GUARD & stale fence wakeups - README.md: document the integrated PRs, XCL_PSO_PRELOAD=1, and 16 GiB cap Verified on RX 9060 XT / GE-Proton11-14: release build clean, targeted unit tests pass (75 passed, 0 failed), and 80 s run with XCL_PSO_PRELOAD=1 and XCL_MEM_LIMIT=12G stays flat at 5340-5413 MB with 512+ pipelines preloaded (1385 frames, exit 0x0). Assisted-by: Antigravity (Google DeepMind)
|
Bumping with emphasis because the queue has jammed elsewhere and this has sat done-with-evidence since 14:53Z: Royalflamejlh's five alternated 100 s Wine/NVIDIA runs are the cleanest A/B posted on any thread this weekend — 5/5 fail-then-5/5 pass on the same build plus #684, DirectStorage request failures eliminated. Meanwhile #1337 today added an independent field data point of the same class from the other direction (texture-page failures at streaming start surviving everything else), and the mechanism is not speculative: enqueue-time page-array snapshot ( |
|
Reproduced the half-full queue failure on an RTX 5060 Laptop GPU (8 GB, NVIDIA 615.78.08), Bazzite 44 Testing and Proton Experimental 11.0-20261112, with vkd3d-proton 3.1
I also tested the one-file port on clean main OpenAI Codex with GPT-6.2-Sol high prepared the local port, ran the comparison and wrote this report. |
|
Half-full check happens before Rechecking the late-page count inside the lock fixes that, may want to add! Cancelling the last request with missing pages also leaves the late-page count set which holds up ready requests afterwards Recomputing it after cancellation fixes |
…pub(crate) Fixes compilation errors on MSVC Windows target: - D3D12.X: restores pub(crate) unsafe fn create_raw_fence in real.rs required by sparse::readback_after_execute (xcl-dev#1732). Creates an unproxied raw ID3D12Fence bypassing title vtable hooks so internal queue worker threads under Wine/vkd3d-proton signal native fences without hitting proxy mismatches. - KernelX: restores pub(crate) visibility for commit_sparse in kernelx.rs (xcl-dev#549, xcl-dev#1298), required by DirectStorage's lazy MEM_RESERVE sparse window allocation in dstorage.rs and placeholder mappings. - Recompiler: adds #[cfg(test)] gate above mod tests in emit.rs to silence unused PRELUDE_MEM import warnings in non-test release builds (xcl-dev#1524). Assisted-by: Antigravity
Native Windows follow-up (not a story-load A/B)This is another occurrence of the already reported
cargo test --release --locked --offline -p xcl --lib hle::dstorage::tests -- --nocapture --test-threads=1Not tested: No fresh title run with the port; I could not verify the local package's publisher. No claim about reduced real-game failures, the black screen, or playability. This is a focused retest, not the full suite. AI use: OpenAI Codex reran the focused tests, checked the previous diagnostic evidence, and drafted this note (model ID not exposed). Follow-up: same synthetic test on main
|
| Variant | Observed result |
|---|---|
| Main + fixture | The half-full queue completed before explicit Submit with 0x89240009 instead of staying E_PENDING. The focused assertion failed as expected (0 passed, 1 failed). |
Main + same fixture + only the runtime hunks of the #549 port at 4cd10c0d6f43b69e1a482bd7d863cc753ec8e503 |
The status stayed E_PENDING, then became S_OK after explicit Submit. All 37 payload bytes matched. The focused test passed. |
cargo test --release --locked --offline -p xcl --lib hle::dstorage::tests::synthetic_half_full_queue_waits_for_pages_at_explicit_submit -- --exact --nocapture --test-threads=1The focused command uses a local test fixture, not a test in either public tree. Clean main's DirectStorage suite passed 18 tests; the patched tree passed 19 including this fixture (0 failed, ignored or skipped in either suite). No #1464 changes were included. This confirms the premature submission in this synthetic case only, not a game or story-load fix.
AI use: OpenAI Codex wrote and ran the synthetic fixture, applied the existing runtime hunks in the local test tree, and drafted this follow-up (model ID not exposed).
Reusable test-only patch
The diff below adds just the synthetic fixture; it changes no runtime code. Save it as 0001-synthetic-test.patch (UTF-8, LF) in a disposable checkout. The exact reproduction is pinned to 568e7db7729c8fa6c8f0f4b32d798faaf11462bb. To try a different candidate, apply only this fixture to that branch after git apply --check succeeds. No title data is needed.
Run in a Windows x64 MSVC developer shell with Git, the Rust MSVC toolchain and Windows SDK available:
$fixture = '0001-synthetic-test.patch'
git apply --check $fixture
if ($LASTEXITCODE -ne 0) { throw 'Test patch does not apply.' }
git apply $fixture
if ($LASTEXITCODE -ne 0) { throw 'Test patch failed.' }
$env:XCL_COHERENT_MB = '1'
$env:XCL_UMA_MB = '1'
$env:XCL_NETWORK = '0'
$focus = 'hle::dstorage::tests::synthetic_half_full_queue_waits_for_pages_at_explicit_submit'
# A: pinned base with the fixture only
cargo test --release --locked --target-dir target/repro-control -p xcl --lib $focus -- --exact --nocapture --test-threads=1
# B: same fixture and pinned base with the candidate runtime change applied
cargo test --release --locked --target-dir target/repro-candidate -p xcl --lib $focus -- --exact --nocapture --test-threads=1A reproduces the assertion before explicit Submit: expected pending, got 0x89240009; B with the tested reference port passes and checks the payload. A compiler error or a SKIPPED result is not a reproduction. Keep distinct target directories: while validating separate source checkouts, using one target directory caused Cargo to reuse A's test executable for B. The intended results were reproduced with separate target directories. Undo the fixture with git apply -R $fixture after testing.
Test-only patch (0001-synthetic-test.patch)
diff --git a/crates/xcl/src/hle/dstorage.rs b/crates/xcl/src/hle/dstorage.rs
index 5dd9d2e..648eb37 100644
--- a/crates/xcl/src/hle/dstorage.rs
+++ b/crates/xcl/src/hle/dstorage.rs
@@ -1653,6 +1653,72 @@ mod tests {
b
}
+ #[test]
+ fn synthetic_half_full_queue_waits_for_pages_at_explicit_submit() {
+ use crate::hle::kernelx::{AllocateTitlePhysicalPages, FreeTitlePhysicalPages, MapTitlePhysicalPages, PHYS_PAGE_SIZE};
+ use windows_sys::Win32::System::Memory::{VirtualAlloc, VirtualFree, MEM_RELEASE, MEM_RESERVE, PAGE_READWRITE};
+ if crate::gpu::uma::get().is_none() {
+ crate::gpu::recomp::runner::skip_test("no title UMA window for the destination page");
+ return;
+ }
+
+ unsafe {
+ let mut page_count = 1usize;
+ let mut pages = [0usize];
+ assert_eq!(AllocateTitlePhysicalPages(std::ptr::null_mut(), 0, &mut page_count, pages.as_mut_ptr()), 1);
+ let mapped = VirtualAlloc(std::ptr::null_mut(), PHYS_PAGE_SIZE, MEM_RESERVE, PAGE_READWRITE);
+ assert!(!mapped.is_null());
+ assert_eq!(MapTitlePhysicalPages(mapped, 1, 0, 4, pages.as_mut_ptr()), mapped);
+
+ let mut desc = [0u8; 0x18];
+ desc[..4].copy_from_slice(&1u32.to_le_bytes()); // memory source
+ desc[8..10].copy_from_slice(&4u16.to_le_bytes()); // two entries reach half full
+ desc[10] = 2;
+ let (mut q, mut status) = (std::ptr::null_mut(), std::ptr::null_mut());
+ assert_eq!(factory_create_queue(std::ptr::null_mut(), desc.as_ptr(), &IID_QUEUE, &mut q), S_OK);
+ assert_eq!(factory_create_status_array(std::ptr::null_mut(), 1, std::ptr::null(), &IID_STATUS_ARRAY, &mut status), S_OK);
+ let wait_status = || {
+ let started = std::time::Instant::now();
+ while !status_is_complete(status, 0) && started.elapsed().as_secs() < 5 {
+ std::thread::yield_now();
+ }
+ status_get_hresult(status, 0)
+ };
+
+ let data = b"synthetic DirectStorage queue payload";
+ let mut table = Box::new([0usize]);
+ let size = data.len() as u32;
+ let request = request_ex(SOURCE_MEMORY_BIT | DEST_PHYS_PAGES_BIT, table.as_ptr() as u64, 0,
+ size, data.as_ptr() as u64, 0, size, 0, 0);
+ queue_enqueue_request(q, request.as_ptr());
+ queue_enqueue_status(q, status, 0);
+
+ // A started worker must finish reading the table before the test changes it.
+ // On a deferred queue there is no worker yet, so inspecting the status is enough.
+ let started_early = queue(q).worker.lock().unwrap().is_some();
+ let before = if started_early { wait_status() } else { status_get_hresult(status, 0) };
+ let timed_out = started_early && before == E_PENDING;
+ if !timed_out {
+ std::ptr::write_volatile(&mut table[0], pages[0]);
+ queue_submit(q);
+ }
+ let after = if timed_out { E_PENDING } else { wait_status() };
+
+ queue_close(q);
+ let copied = after == S_OK && std::slice::from_raw_parts(mapped.cast::<u8>(), data.len()) == data;
+ queue_release(q);
+ status_release(status);
+ MapTitlePhysicalPages(mapped, 1, 0, 4, std::ptr::null_mut());
+ VirtualFree(mapped, 0, MEM_RELEASE);
+ assert_eq!(FreeTitlePhysicalPages(std::ptr::null_mut(), 1, pages.as_mut_ptr()), 1);
+
+ assert!(!timed_out, "an early worker did not finish within the fixture timeout");
+ assert_eq!(before, E_PENDING, "before explicit Submit: expected pending, got {before:#010x}");
+ assert_eq!(after, S_OK, "after explicit Submit: expected success, got {after:#010x}");
+ assert!(copied, "the submitted request must copy the synthetic payload");
+ }
+ }
+
#[repr(C)]
struct MockFence {
vtbl: *const usize,|
Verification on RTX 3060 Ti (Windows 11): merge conflict with current |
A retail title fills a destination page array entry after
EnqueueRequestand before its ownSubmit. #289 rereads such an entry at the request's turn, but a half-full queue submits by itself, so during the title's loading bursts the worker reaches the request first and it fails withE_ACCESS_VIOLATION(0x89240009). Part of #476: the missing entries are now read on the title's thread atSubmit, which narrows that issue's window.What is in it
crates/xcl/src/hle/dstorage.rs:Pending::latecounts requests whose destination array had a0entry. A half-full queue holding one doesn't submit by itself. The title'sSubmitrefills the missing entries (refill_late_pages, throughsnapshot_page_array/ReadProcessMemory). DirectStorage: a destination page array entry that is 0 at enqueue is read at the request's turn #289's reread stays as the fallback.a_late_page_array_holds_a_half_full_queue_until_the_titles_submit. It fails without the change.Tested
cargo test --workspace -- --test-threads=4at1870880: 677 passed, 0 failed, 41 ignored. SKIPPED (no wave64):gpu_geometry_wave32_prefix_count_over_a_mask,gpu_wave32_program_in_wave64_hardware.XCL_RUN_SECONDS=230, with a local failure counter by HRESULT on both builds (not part of this PR):main: about 2,850 failures with0x89240009(counted in steps of 50), plus 1,050 BCPack refusals.0x89240009, plus 161 BCPack refusals.title_textures(refresh→note_gpu_write, copying a page that was no longer mapped). This PR doesn't touch that code, and it's the same kind of race as D3D12.X: read_committed survives concurrent decommit and unmap #454/D3D12.X: tolerate concurrent page decommits in title texture reads #484.main's run didn't hit it. One run each.Regression run
Not tested
Submitafter enqueuing such a request. Its requests would then wait for the nextSubmit.AI use
https://claude.ai/code/session_01SEW8zXNUmMq1tRUZpstWXS