Repository navigation
D3D12.X: title texture reads outside the coherent window use the safe copy - #751
grahamster2 wants to merge 1 commit into
Conversation
cbd78e6 to
dc9eec1
Compare
|
CPU cost on
Both scratch fixtures passed (1/1 each, zero skips) with |
cbd78e6 to
4e101fc
Compare
…copy non-coherent reads safely Integrates upstream PRs xcl-dev#455 and xcl-dev#751: - Submit title texture upload batches directly on the title's direct queue without per-batch CPU fence waits, reclaiming staging buffers asynchronously and ordering vram tile updates before each submit (xcl-dev#455). - Copy title texture bytes outside the coherent UMA window through a reusable thread-local ReadProcessMemory buffer so concurrent page decommits cannot fault (xcl-dev#751).
|
Test run of Tested
Review: The unchanged-content hash and the detile go back through the Not tested: no retail title or regression run (I have no unpacked game), no Run and review by Claude Code (Claude Opus 5.5) on this machine; the review points were checked against the code. |
…copy non-coherent reads safely Integrates upstream PRs xcl-dev#455 and xcl-dev#751: - Submit title texture upload batches directly on the title's direct queue without per-batch CPU fence waits, reclaiming staging buffers asynchronously and ordering vram tile updates before each submit (xcl-dev#455). - Copy title texture bytes outside the coherent UMA window through a reusable thread-local ReadProcessMemory buffer so concurrent page decommits cannot fault (xcl-dev#751).
|
Independent native Windows NVIDIA RTX 5080 build/test run and code review at head Code Review
Tested
Not tested
AI use: Antigravity (Gemini 4 Neon) performed the code review, ran the RTX 5080 workspace tests, and drafted this comment. |
…copy non-coherent reads safely Integrates upstream PRs xcl-dev#455 and xcl-dev#751: - Submit title texture upload batches directly on the title's direct queue without per-batch CPU fence waits, reclaiming staging buffers asynchronously and ordering vram tile updates before each submit (xcl-dev#455). - Copy title texture bytes outside the coherent UMA window through a reusable thread-local ReadProcessMemory buffer so concurrent page decommits cannot fault (xcl-dev#751).
…copy non-coherent reads safely Integrates upstream PRs xcl-dev#455 and xcl-dev#751: - Submit title texture upload batches directly on the title's direct queue without per-batch CPU fence waits, reclaiming staging buffers asynchronously and ordering vram tile updates before each submit (xcl-dev#455). - Copy title texture bytes outside the coherent UMA window through a reusable thread-local ReadProcessMemory buffer so concurrent page decommits cannot fault (xcl-dev#751).
|
Test report on a retail title, 4e101fc (this PR's head, on 64b3f35). Setup: RTX 5080 16 GB (driver 621.24), Ryzen 7 9800X3D, Windows 11 26300, rustc 1.100.0, release, Without this PR (
In the other two runs the title reached the null write at With this PR: 2 of 2 Not tested: the race does not hit every run (1 of 3 on main), so two clean runs show no regression rather than prove the fix. I did not run the test suite on this head, and did not measure the upload time this PR adds back. Report written with Claude Code (Claude Opus 5.5) from my own runs. |
|
Test report: the fault this PR describes, reproduced in the retail title, and the same setup with this PR. Setup
Without this PR – during the story load, 114.1 s: Stack from
With this PR (same base, settings and scripted input): no fault in title textures. The title reaches the world (first Tests: Caveat: one run each. Across about ten runs on Not tested: the full suite on this stack, AMD, other titles, AI use: Claude Code (Claude Opus 5.5) ran the builds, tests and retail runs on the hardware above, symbolized the stack, and wrote this report. |
|
Test report and review for Tested
Head is 11 frames (0.7 %) above base and the warm-up (1544) is inside that spread, so no regression or gain is measurable in this window.
Review (diff read at
Not tested
AI use |
4e101fc to
1a480bc
Compare
|
A data point for this PR: we hit the race on AI use: Claude Code (Claude Opus 5.5) symbolized the stack and wrote this. |
|
Linux / AMD RX 9070 (RDNA4, RADV) test report on Setup
Tested
Not tested
AI use
|
|
A second occurrence, on an unrelated build (#2404 AI use: Claude Code (Claude Opus 5.5) wrote this. |
|
Test report, RTX 3060 12 GB (NVIDIA 621.14), i9-13900K, 64 GB, Windows 11 26200: this PR removes a crash in the retail title's world, reproduced twice without it. Tree:
AI use: Claude (claude-opus-5-5, through Hermes) ran the builds and runs over SSH, symbolized the crash and wrote this. |
Runs 1-6 on an RTX 5080 showed that a draw binding an unbuilt pipeline builds it on the title's thread (about 3.7 s each, back to back), so the title presents nothing after its loading screen. The entry holds the approved spec: adopt xcl-dev#2579, xcl-dev#2098, xcl-dev#2698 and xcl-dev#751 through the gate, then units U1-U9 (draws wait inside a shared 100 ms frame budget and never build, compute waits for a worker, a graphics lane and RAM-scaled slots at the gate, replaced parked workers, an end watchdog, telemetry). Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_018RbZY1Ag73eDeCUZHpW3is
commit 59f8e7c review sha256 7ddb0110e2a58baecfa8cdc0611ffcfbc90cb3b6c9407904d499e4233aa68a7d reviewed by Claude Code (Opus 5.5, claude-opus-5-5), Opus worker, full read (clean) Conflict in crates/xcl/src/hle/d3d12x/title_textures.rs (upload_all): our side times the content hash with part_start / add_part(Part::Hash), the PR replaces the in-place title_bytes read by with_title_bytes. Both are kept: the timing lines stay around the guarded read.
Since #602, the unchanged-content hash and the detile of title textures read the title's memory in place whenever
gpu::shader::readablepasses. That bypasses theReadProcessMemorycopy #484 gaveread_committed: the title can decommit or unmap those pages from another thread at any moment, and the hash or detile then faults with0xC0000005. @chadatouille spotted this on #484. @Dukiverse confirmed it independently in a retail title: onmaindd2ae9a the fault is intiling::Chain::detile_level←title_textures::subresourceson asubresources_onworker. Dukiverse also posted a local fix along the same lines; this version adds the regression test and reuses the read buffer.What is in it
Rebased onto
maincbc296a (head 59f8e7c). The only conflict was in the tests. #1986's 32 MiB / 256-item upload batch caps (batch_fitsand its test) are kept as they are. #1990's 3D textures with packed mip tails go throughsubresources, so they are read throughwith_title_bytestoo.D3D12.X: title texture reads outside the coherent window use the safe copy(crates/xcl/src/hle/d3d12x/title_textures.rs):with_title_bytes(at, len, f)replacestitle_bytes. A range inside the coherent committed window is still read in place: XCL'sVirtualFreenever decommits that window, andMEM_DECOMMITthere zeroes in place.read_committed's safe copy into a buffer reused per thread, so there is no new allocation and page faults per texture. A buffer that grew past 64 MiB is let go after the read. The scoped workers of a parallel batch detile still get a buffer per batch. Since D3D12.X: cap title texture upload batches by count and 32 MiB #1986 a batch is capped at 32 MiB and 256 textures, which bounds those buffers too.read_committed_intowrites every byte (copied, or zero where a page can't be read), so the reused buffer needs no memset and nothing from an earlier read shows through a hole.read_committed_intocopies the whole range with oneReadProcessMemoryfirst. It walks region by region withVirtualQueryonly when that copy is refused (a page not committed, no-access or guard). The walk was most of the copy's cost:VirtualQueryscans from the page asked about to the end of its run of like pages, and the title's memory is a few runs of hundreds of MiB.ReadProcessMemoryon a guard page fails and leaves the guard in place.title_bytes_survive_concurrent_decommit: hashes 1 MiB 2,000 times while another thread decommits and recommits its 64 KiB pages. It asserts that every decommit and recommit succeeds and that decommits happened during the hashing. Each 4 KiB holds its own value, and every read must hold those values or zeros.title_bytes_leave_guard_pages_alone: a guard page and a no-access page read as zeros, and the guard is still set afterwards.title_bytes_are_copied_outside_the_coherent_window: same bytes asread_committed, holes zero, no stale bytes from a longer read, the 64 MiB cap, and the coherent window read in place. It replacestitle_bytes_are_used_in_place_when_all_are_readable, whose behaviour this removes.Tested
title_bytes_survive_concurrent_decommit:title_bytesbehind a local shim (not committed): 3 of 3 runs end inSTATUS_ACCESS_VIOLATION;cargo test --release -p xcl --lib title_bytes, at 4e101fc).cargo build --workspace: no warnings.cargo test --workspace --no-fail-fast -- --test-threads=4on 59f8e7c: 1154 passed, 2 failed, 46 ignored. The two failures are timing tests this change does not touch,frame::tests::origin_events_issue_tokens_and_flips_have_statisticsandpso_async::used_tests::a_bind_waits_for_a_slow_pipeline_no_longer_than_its_budget("waited 460.8 ms"). Both pass when run alone on 59f8e7c (cargo test -p xcl --lib <name> -- --exact). The three new tests andbatch_fits_caps_items_bytes_and_devicepass.read_committed_into); a 16 KiB / 256 KiB / 4 MiB read of fully committed memory. The microsecond figures quoted in review came from a 9800X3D; these were measured on the 7600X.A range with holes pays one refused copy on top of the walk: 4 MiB with one 4 KiB hole went from 158 to 230 µs. With every other 64 KiB page missing it is ~150 µs either way.
gpu::recomp::lower::tests,lower_dxil::testsandrecomp::tests("no wave64"); threelower_dxilf16 / f32-conversion per-lane forms refused (V_MUL_F16,V_PK_MUL_F16VOP3 modifiers,V_CVT_F16_F32, gpu: direct RDNA2 -> DXIL backend (no HLSL / DXC), behind XCL_DIRECT_DXIL #1426);heap_window_out_of_memory_falls_back_to_the_switch_form("no heap windows").Both builds then stop at the title's watchdog (#232). One main run ended earlier on a device hang (
0x887A0006, 63 s). The decommit crash is intermittent, so these runs don't show it either way.Regression run
main:
PR:
Not tested
main:placed_title_textures_share_vram_and_preserve_pixels("cubemap extra_pages must be reused at same va") fails intermittently on this card, and its panic poisonstransitions_apply_when_their_list_is_submittedandd32s8_targets_take_their_own_size_of_video_memory.mainf4ce27c (cargo test -p xcl --lib -- --test-threads=4): 4 of 13 runs failed. Over 4 alternating pairs, main failed 1 of 4 with the same cubemap assertion and this branch 2 of 4. It also failed with this PR's two new tests skipped.read_committedandgpu::shader::readablealready did.XCL_TRACE_FRAME: samples on decommitted pages now count as zero bytes (they used to be skipped), so a texture whose samples all fall there shows as all zero. This is diagnostic only.AI use