DirectStorage: resolve GPU-view addresses to their paired CPU view #973
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/979"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Imported from ivall/xcl. Originally posted by n-romanovich on 2026-11-24T09:50:09Z.
A title that reserves paired 64 KiB CPU and GPU views (
VirtualAllocflags0x20402000:PAGE_READWRITE, thenPAGE_NOACCESS | PAGE_GRAPHICS_NOACCESS) maps physical pages into the CPU view while passing GPU-view virtual addresses as DirectStorage request destinations and memory sources. Without resolving those addresses throughkernelx::mirrors,writableandshader::readablesee reservedPAGE_NOACCESSmemory and refuse the requests withE_ACCESS_VIOLATION(0x89240009). Resolve virtual destination and memory-source addresses throughkernelx::mirrors::sourcewhen the GPU view has no page mapped of its own (physical_page_atorMEM_COMMIT), including inbcpack_fill.What is in it
crates/xcl/src/hle/kernelx.rs: addmirrors::overlaps_gpu_viewandmirrors::resolvefor GPU-view reservations without a page mapped of their own (physical_page_atorMEM_COMMIT).crates/xcl/src/hle/dstorage.rs: add per-64 KiB-pagefor_each_mirror_run/mirror_writable/write_virtual_destination/read_virtual_sourceso multi-page and mixed-view spans,execute(includingsnapshot_page_arrayand late zero-entry re-reads), andbcpack_fillresolve GPU-view addresses and re-check/write viaNtWriteVirtualMemory.crates/xcl/src/hle/dstorage/parallel.rs: route file-backed zlib parallel decompression checks and writes throughmirror_writableandwrite_virtual_destination.gpu_view_addresses_read_and_write_their_paired_cpu_view: tests zlib memory-source/destination mirror resolution,XCL_DSTORAGE_BCPACK_FILL(mode 2 / BC2), direct physical-page mappings + cross-page mixed-view reads (withrunner::skip_testif unavailable), and file-backed zlib viaparallel.rs.Tested
Hardware: Windows 11 x64, NVIDIA GeForce RTX 5060 Ti.
cargo test -p xcl --lib dstorage -- --test-threads=4:30 passed; 0 failed; 0 ignoredcargo test --workspace -- --test-threads=4:892 passed; 0 failed; 42 ignoredSKIPPED:gpu::recomp::tests::gpu_geometry_wave32_prefix_count_over_a_mask(no wave64),gpu::recomp::tests::gpu_wave32_program_in_wave64_hardware(no wave64),shaders::tests::pso_measurement_compiles_an_exact_synthetic_record(Windows Developer Mode is required),heap_window_out_of_memory_falls_back_to_the_switch_form(no heap windows)Regression run
Main (
5478c4a7c1ae5adba127c8d27018d7fdbf3a8725):PR (
063c281f879e53fb081fc335fcaaefd573f30d28):Not tested
AI use
smoke.ps1runs.Imported from ivall/xcl. Originally posted by raylitebull on 2026-11-24T10:40:29Z.
Code/CI review only (not independently runtime-tested by me): clean merge and
PR descriptiongreen (just awaiting CI workflow approval). Cleanly resolves DirectStorage GPU-view addresses to their paired CPU view. Recommend approving CI and merging, @ivall.Imported from ivall/xcl. Originally posted by Filip722 on 2026-11-24T11:22:16Z.
I tested
b8d21b0on XCL main47efa2eplus #640, #793 and #820, using an RTX 5060 Laptop GPU (8 GB, driver 615.78.08) on Bazzite 44 with Proton Experimental11.0-20261112, the vkd3d-proton4522cc1compatibility build from #257 and the #775 dxil-spirv pin.hle::dstorage::tests --test-threads=1(15 tests). Fourteen passed.gpu_view_addresses_read_and_write_their_paired_cpu_viewpassed the zlib source/destination checks and failed at the BC7 debug-fill assertion. On this main, that BC7 request reaches the decoder, which rejects the malformed stream withE_DECOMPRESSION. The solid-fill branch runs on an enqueue refusal.XCL_COHERENT_MB=512,XCL_PAGE_BUDGET_MB=2048,XCL_PSO_WAIT_MS=50andXCL_BIG_COMPILES=1. Both builds showed unlit silhouettes during loading and exited after avkAllocateMemoryaccess violation. The run with this PR recorded zero storage failures through 39,196 executed requests. The comparison recorded 44 failures (0x89240009first on a file request) by 45,904 requests and crashed after 59,883 sampled requests. The patched run ended before it reached a comparable request count, so the retail result is inconclusive for this fix.AI assistance by OpenAI Codex for the build, test and report. Model GPT-6.2-Sol (high).
Visual follow-up: a later run rendered the full loading artwork. The earlier silhouette frames did not establish entry into the playable world.
Focused retest: changing the debug-fill subcase to BC2 exercises the enqueue refusal on current main. With that test-only adjustment, the same
hle::dstorage::tests --test-threads=1suite reported 15 passed and 0 failed under Proton.Imported from ivall/xcl. Originally posted by SlopTart on 2026-11-24T11:55:29Z.
Linux / AMD RDNA3 run: the new GPU-view/CPU-view pairing test fails deterministically under Wine.
Merged state: head onto main (
a027808lane merge), clean merge, full suite 729 passed / 13 failed / 41 ignored: the known Wine-lane set from #42, this rig's mirror flake, and thexapu_connect_returns_oom...flake from my #943 footnote. The one that does not clear in isolation:hle::dstorage::tests::gpu_view_addresses_read_and_write_their_paired_cpu_view- fails 2/2 isolated, panic atcrates/xcl/src/hle/dstorage.rs:2603: after filling through the GPU view, the paired CPU view's 16-byte chunks don't match the source block (slice::from_raw_parts(fill_dst_cpu...).chunks(16).all(...)is false).Diagnosis lead, not a verdict: on this rig all D3D12.X heaps come through vkd3d-proton's translated/host-visible path rather than real device-memory aliasing, so "resolve GPU-view address to its paired CPU view" has different coherence semantics here than on native Windows or NVIDIA's d3d12-on-Wine lanes. Either the test assumes console-style paired views that vkd3d-proton can't provide (then it should gate like #983's atomics skip), or the pairing code returns a stale/duplicate CPU address on the translated path. Worth one isolated run on a Windows lane to split those two.
Everything else dstorage-related is green in-lane (the batch's
multi_stage...andrequests_are_checked...tests included).Counts only, no game data.
Not tested: retail titles (none here), Windows, RDNA4.
Machine: RX 7900 XT (RADV NAVI31), Mesa 26.2.5, kernel 7.2 (Arch), Proton Experimental (wine-11.0), patched vkd3d-proton v3.1, Rust cross
x86_64-pc-windows-gnu,XCL_NETWORK=0, release profile,--test-threads=4. My Linux rows: #42 / #718.AI use: Hermes agent (local Qwen-class) ran the suite and drafted this; I checked it before posting.
Imported from ivall/xcl. Originally posted by pvfreis on 2026-11-24T12:26:16Z.
Review: COMMENTED
Review of
b8d21b0against its merge base077ce40, by reading the code; nothing was built or run here. The runtime change is small and I found no crash or memory-safety defect in it: the resolved address goes through the samewritable/readablechecks as before, so the worst case is still a refused request. The problems are in the test, which no longer passes on today'smain.main(crates/xcl/src/hle/dstorage.rs:2397-2409, request at:2404, assertion at:2408). The branch merges intomain47efa2ewithout a textual conflict, butmainnow unpacks BCPack BC7 (8cad517). ThereRequest::checkaccepts mode 7 (can_decode), so the request is no longer refused at enqueue; it runs, the decoder rejects the 16 bytes of zlib data as a BC7 stream, andexecutereturnsE_DECOMPRESSION. The solid fill is only done for anEntry::Refusedfrom enqueue, so the status assertion passes and the fill assertion fails. The Proton report in this thread already says this. In the merged file that assertion is line 2603, the panic line of the Linux/RDNA3 report, so that failure has the same cause: it is not a property of Wine or vkd3d-proton, and the test needs no Wine skip.main's own fill test moved to BC2 for the same reason. Fix: rebase and use a mode without a decoder (2 << BCPACK_SHIFT,bcpack_fill_block(2)) in subcase 2. The smoke block and the counts then need a rerun on the new head.Also against CONTRIBUTING: subcase 3 is skipped silently when there is no unified memory (
dstorage.rs:2413), so on the GPU-lessCIthe "page mapped in the GPU view" branch ofmirror_addressis not exercised and nothing printsSKIPPED; AI use names the tool and model but not what it did; Tested gives whole-suite counts only for--test-threads=1. TheCIcheck has not run on this head yet (onlyPR descriptionis green). The Regression run blocks are present, on the merge base and on this head, and the description says plainly that the 30 s run does not reach the changed code.Verdict: not ready to merge as it stands; the runtime change looks safe, but the test must be rebased onto the BCPack decoder (finding 1).
Review by Claude Code (written by Claude Fable 5.2, checked and edited with Claude Opus 5.5); each point checked by a person before posting.
Imported from ivall/xcl. Originally posted by DavidM1911 on 2026-11-24T12:27:30Z.
Independent verification — the PR's own new test fails standalone on its head
b480ae7(which already contains amainmerge), and identically after merging currentmain384f7f7locally.Machine: Windows 11, Ryzen 9 7900X + RTX 3060 Ti; Rust stable MSVC, debug.
cargo test -p xcl --lib dstorage: 14 passed, 1 failed —gpu_view_addresses_read_and_write_their_paired_cpu_view.E_DECOMPRESSION(packed=16, dst=32— "the stream ends early or is corrupt"), sofill_dst_cpunever receives the expected block and thechunks(16) == blockassertion atdstorage.rs:2603fails. The paired GPU→CPU view resolution itself looks right (the request reaches the queue with the resolved destination); the fixture stream appears too short for the destination size, or the test needs thebcpackdecode path to accept it.AI use: test runs by Devin (Cognition, SWE-2); no code changes.
Imported from ivall/xcl. Originally posted by SlopTart on 2026-11-24T12:44:31Z.
Re-check on the updated head: re-merged
b8d21b0onto current main (lane merge568cb1a) andgpu_view_addresses_read_and_write_their_paired_cpu_viewstill fails, same panic sitedstorage.rs:2603(chunks(16)comparison against the expected BC7 block), same as my comment above and same as the Windows reproduction from DavidM1911 (E_DECOMPRESSIONon the BCPack fill,packed=16, dst=32).So the failure survives the head move and now has three independent confirmations: this Wine/RADV rig, that Windows/NVIDIA rig, on both the old head and the post-main-merge head. It does not look rig-specific or Wine-specific anymore; the destination resolution reaching the queue looks fine on both reports, the decompression/fill step is where the stream dies.
Counts only, no game data.
Machine: RX 7900 XT (RADV NAVI31), Mesa 26.2.5, kernel 7.2 (Arch), Proton Experimental (wine-11.0), patched vkd3d-proton v3.1, Rust cross
x86_64-pc-windows-gnu,XCL_NETWORK=0, release profile. My Linux rows: #42 / #718.AI use: Hermes agent (local Qwen-class) ran the suite and drafted this; I checked it before posting.
Imported from ivall/xcl. Originally posted by einfachama on 2026-11-24T14:49:40Z.
Test report for #979 at
b8d21b0, merged locally ontomain47efa2e(no conflicts), on my retail title's world load. Short version: on this title, #979 doesn't change the0x89240009failures. They come in both builds, at the same time in the load, from the same package files and in about the same numbers.Setup
cargo build --release -p xcl).main47efa2e;main+ #979 (b8d21b0merged locally).XCL_NETWORK=0,XCL_ACTIVITY=1,XCL_RUN_SECONDS=100, A pressed at 26 s and 30 s. The title then starts its world load by itself at about 66 s.main/ #979 / #979 /main/main/ #979 / #979 /main, with the same shader caches.DirectStorage … failedcounts in theXCL_ACTIVITY2 s lines.Results
main0x887a0006at 83.5 smainmainmainmain17–754 (median 195), #979 70–4 054 (median 177). All of them are0x89240009, on file-source reads from the title's package files, in one or two 2 s bursts 1–9 s into the world load.main+ #816 (2ffb5a4) twice withXCL_DSTORAGE_FAILURE_DETAILS=1. All 10 records it wrote aresubmit=HalfFull stage=DestinationPages destination=pages, and the destination page array still has its one entry at 0, also on the late reread (dst-snapshot=[1 total/1 zero] … late-reread=Read). These destinations are physical-page arrays, not virtual GPU-view addresses, so #979's change doesn't reach them. That matches what #549 describes. Those records come frommain+ #816 runs, not from #979 runs, so I'm inferring that #979's failures are the same kind from their code, timing and files.0x887a0006(device hung) at 83.5 s, while presents were coming back after the load. In the same session, 1 of 2main+ #816 runs also hung, at 65.3 s. None of the 6mainruns hung (the 4 above and 2 later controls), and neither did 4main+ #549 runs. With 2 hangs in 16 runs, spread over two different PRs, I can't attribute it to #979.1870880, merged locally), in the same session and with the same settings: 0 failed requests in 4 of 4 runs. Its 2 interleavedmaincontrols had 7 and 1 009.E_OUTOFMEMORY. In every run of both builds, the only WARN kind that first shows up after the load starts is thea request failedline. Commit and video memory are the same within the noise: peak commit 26.9–28.4 GB at 96–98 s.Not tested
gpu_view_addresses_read_and_write_their_paired_cpu_view) andcargo test --workspacewere not run on this merge.AI use
Imported from ivall/xcl. Originally posted by crastinator on 2026-11-24T15:44:17Z.
Review: COMMENTED
Merged onto current
main, the new test fails. That isn't Wine:mainhas gained BCPack decoding since this PR's base. The test passes at the PR's own head.Tested (head
b8d21b0; base077ce40is 49 commits behindmain930e8b4)-Db_ndebug=true, dxil-spirv53aac418from #775), DXVK v3.1.1-209dxgi, DXC 1.9.2609.5, libopus 1.5.2,XCL_REQUIRE_GPU=wave64,mesh(0 SKIPPED)x86_64-pc-windows-msvc(clang-cl / lld-link, xwin SDK 10.0.26100), Rust 1.99.1, debugb8d21b0itself:hle::dstorage::tests::gpu_view_addresses_read_and_write_their_paired_cpu_viewpasses 2/2.main930e8b4(no textual conflict): it fails 3/3 atdstorage.rs:2603, the fill check of step 2. The destination still holds the0xCDthe test wrote, and the log saysBCPack BC7 stream (decode): the stream ends early or is corrupt (packed=16, dst=32); the request fails with E_DECOMPRESSION.8cad517("DirectStorage: unpack BCPack BC1, BC3, BC4, BC5, BC6H and BC7 streams"), a BC7 request is no longer refused atEnqueueRequest. It is decoded and fails at execute time. Onmain,bcpack_fillonly runs forEntry::Refused, so step 2 never fills.mainstill refuses, asmain's own fill test does with mode 2, makes it pass 3/3 on the merged tree, and all 15hle::dstoragetests pass: That holds only while mode 2 stays undecoded onmain. A rebase ontomainwould show the failure in this PR's own CI.main: 740 / 11 / 41, with the #718 flakes failing in that run). Apart from this test, nothing fails that passes onmain.Not tested
XCL_SAMPLE_*was set, so the tests that read them (about 66) pass without running.AI use
Update: retested
8f7dc3a(rebased onmain4178e88; same RX 6700 XT / RADV 26.3.1 / Proton Experimental Wine;--test-threads=1, compared per test withmain4178e88on the same build)main's 877 / 14 / 42. The extra pass is this PR's test, and no test fails here that passes onmain. Nohle::dstoragetest fails, andgpu_view_addresses_read_and_write_their_paired_cpu_viewpasses (the BC2 subcase included). The 14 are the Wine-lane setmainhas here.for_each_mirror_run/mirror_writable/write_virtual_destinationand theparallel.rschange. The page walk resolving each 64 KiB page throughmirrors::resolveand merging contiguous runs looks right to me. One leftover from the conflict resolution: the doc comment abovefor_each_mirror_runstarts "Where a virtual address in a GPU view (kernelx::mirrors) is read or written: its own" and then breaks off into "Walk[va, va + len)…".XCL_SAMPLE_*).Imported from ivall/xcl. Originally posted by n-romanovich on 2026-11-24T18:04:04Z.
Thanks for the reviews and test reports (@pvfreis, @SlopTart, @DavidM1911, @Filip722, @einfachama).
Rebased onto
main(9e3831e) and updated the PR:gpu_view_addresses_read_and_write_their_paired_cpu_viewsubcase 2 from mode 7 (now decoded onmainsince8cad517) to mode 2 (BC2, withassert!(!crate::hle::bcpack::can_decode(2))), sobcpack_fillexercises the enqueue-refusal path as intended.skip_testfor subcase 3: Addedcrate::gpu::recomp::runner::skip_test(...)when unified memory or title physical pages are unavailable instead of silently skipping.24 GiBto26 GiB + 64 KiBso it does not collide in globalkernelx::mirrorswithtitle_texturestests under--test-threads=4.Verified on Windows 11 (RTX 5060 Ti):
mirror_address(0x89240009), passes with it (dstorage::tests: 18 passed, 0 failed).cargo test --workspace -- --test-threads=4: 777 passed, 0 failed, 41 ignored (3 consecutive runs).xcl-smokeblocks in the PR description for9e3831eandce8acc5.@einfachama: thanks for tracing the
0x89240009burst in your run — indeed,DestinationPageszero-entry arrays are separate from virtual GPU-view addresses (handled by#549).Ready for re-review!
Imported from ivall/xcl. Originally posted by pvfreis on 2026-11-24T18:19:49Z.
Thanks. Checked at
ce8acc5(read in full): the BCPack subcase uses mode 2 and assertscan_decode(2)is false, and the two skips print. On an RTX 3060, merged ontomain9e3831e(clean),cargo test --workspace --locked --offline --no-fail-fast -- --test-threads=4: 776 passed, 1 failed, 41 ignored (main: 775 / 1 / 41). The one added test isgpu_view_addresses_read_and_write_their_paired_cpu_view, which passes; the one failure is the e2e test, which fails the same way onmainhere (no display in this session). SKIPPED: the two wave64 tests andheap_window_out_of_memory_falls_back_to_the_switch_form. Finding 1 of the review is fixed. Not tested: AMD, a retail title.Reply by Claude Code (Claude Opus 5.5); checked by a person before posting.
Imported from ivall/xcl. Originally posted by crastinator on 2026-11-24T20:59:57Z.
@n-romanovich retested
8f7dc3aunder Wine on RDNA2. No regression againstmain4178e88, and the new test passes. Details are in my review above (edited), with one leftover doc line from the conflict resolution. I can't merge (I'm not a maintainer), so that's up to the maintainer's batch.Imported from ivall/xcl. Originally posted by n-romanovich on 2026-11-24T20:45:19Z.
I just rebased onto
main(4178e88) after#819landed (and wiredparallel.rs+ multi-page mixed-view handling into8f7dc3awhile resolving the conflict). Sincedstorage.rsis getting heavy traffic right now, keeping this open much longer will likely force another rebase and re-review cycle for all of us.If
8f7dc3alooks good, ready for a quick approval/merge while the branch is clean so I can move on to the next DirectStorage issues.upstream-sync referenced this pull request2026-11-25 06:04:27 +00:00
Imported from ivall/xcl. Originally posted by JJAutoCompare on 2026-11-25T05:38:32Z.
Empirical test report (
8f7dc3a0)PR #979, “DirectStorage: resolve GPU-view addresses to their paired CPU view,” at
8f7dc3a057001c698bc007ef8432ff40d0f9e39d.Hardware / environment
rustc 1.100.0 (0ef1bc386 2026-11-09). DXC reports1.9.2609.5 (01b62ad47).Commands and results
cargo test --workspace --no-runbuilt the workspace test executables and exited 0.cargo test -p xcl --lib hle::dstorage::tests::gpu_view_addresses_read_and_write_their_paired_cpu_view -- --exactran withXCL_ADAPTER=NONE_CPU_ONLY,RUST_TEST_NOCAPTURE=1, andXCL_DSTORAGE_PARALLEL_DECOMPRESS=1. It exited 0 with 1 passed, 0 failed, 0 ignored, 0SKIPPEDlines, and 864 filtered out. Both commands ran outside the Arc test wrapper.Observed behavior
E_DECOMPRESSION(0x89240030) and wrote the fallback blocks through the paired CPU view.Not tested
The full GPU workspace suite and game smoke runs on main and the PR head were omitted. This run provides focused CPU fixture coverage.
AI use
Verified with T3 Code / Codex (gpt-6.2-sol, reasoningEffort: high). Coordinator #2 (T3 Code / Antigravity, gemini-4-neon) verified counts against
pr979-focused.logand published.Imported from ivall/xcl. Originally posted by thehollowedone on 2026-11-25T07:04:19Z.
Independent Windows check of b986487. I extended the PR’s fixture with one file-backed zlib write that crossed a 64 KiB boundary, from a GPU view backed by its paired CPU page into a GPU view with a directly mapped physical page.
Tested
cargo test --offline --locked -p xcl --lib dstorage -j 3 -- --nocapture --test-threads=1passed twice (31 passed, 0 failed, 0 ignored, 0 runtime skips each).S_OK. Both 512-byte halves matched their distinct expected data. The guard bytes and the second page in the paired CPU view remained intact. The existingBeforeDecodehook recorded one worker decode for this request, confirming the parallel path.Not tested
Workspace suite, retail streaming, or other adapters. Synthetic input only. I have the fixture as a test-only patch if useful.
AI use
Codex (GPT-6.2 Sol) wrote and ran the test extension and drafted this report.
Imported from ivall/xcl. Originally posted by pvfreis on 2026-11-25T22:00:56Z.
Read at
063c281f(nothing run): no defect found. One thing for your next rebase: #1405 added a page-list read inexecutewith plainread_own(r.destination, …); it needsfor_each_mirror_runlike your other two.AI use: Claude Code (Claude Opus 5.5) read it; Claude Fable 5.2 reviewed the text; checked by a person before posting.
Imported from ivall/xcl. Originally posted by DavidM1911 on 2026-11-26T00:23:14Z.
Re-verification on RTX 3060 Ti (Windows 11), new head merged with current
main:cargo test -p xcl --lib: all passed, 0 failed, 27 ignored. The earlier BCPack fixture failure is fixed.Thanks!
— Devin
Imported from ivall/xcl. Originally posted by Foniass on 2026-12-01T04:35:10Z.
Triage (#1607) – head
063c281No open or merged PR resolves DirectStorage destinations and memory sources in a GPU view through
kernelx::mirrors. Main's dstorage.rs does not usemirrorsat all, and the related PRs (#768, #1995, #1055) do this for D3D12.X copies, not DirectStorage.Notes on the diff: the doc comment above
for_each_mirror_run(dstorage.rs) starts with a half sentence ("Where a virtual address in a GPU view ... its own"). Every virtual-destination write inexecuteandbcpack_fillnow goes throughNtWriteVirtualMemoryinstead of a memcpy, and every request takes themirrorslock inoverlaps_gpu_view; both are small per-request costs, but they apply to every title, not only to ones with paired views. The branch conflicts with main.Recommendation: keep open.
AI review: Claude Code (Claude Opus 5.5), diffs read only, not built or run; not checked by a human.
View command line instructions
Checkout
From your project repository, check out a new branch and test the changes.Merge
Merge the changes and update on Forgejo.Warning: The "Autodetect manual merge" setting is not enabled for this repository, you will have to mark this pull request as manually merged afterwards.