D3D12.X: do not borrow title memory in texture workers #2849
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/2849"
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 guinpereira on 2026-11-26T18:31:56Z.
Relates to #2841.
Copies title bytes page by page instead of borrowing the range, so a worker cannot fault if the title decommits pages between the readability check and the detile copy.
What is in it
crates/xcl/src/hle/d3d12x/title_textures.rs: page-by-page copy instead of borrowing the title range.Tested
cargo test -p xcl --lib -- --test-threads=4: 1315 passed, 4 failed (GPU OOM in dxil fuzz tests, environment), 27 ignored.cargo build -p xcl: clean.Regression run
Reference run on the author's local main (05adb5a). A run on ivall/xcl main and on this PR's head commit is still pending (cold shader cache crashes the title's startup precompile on this machine).
Not tested
AI use
OpenCode, Beam Free - drafted the change; smoke run and review by the author.
Imported from ivall/xcl. Originally posted by pickles976 on 2026-11-26T18:45:25Z.
Independent Wine verification of production head
4e93173413fed5f2d079ae4f2da37f07996e9727: 2 focused tests passed, 0 failed/ignored, 1.45 s after fresh 25.42 s compilation fromxcl-pr2849.Environment: Linux, Wine 11.0, Rust 1.98.1, Windows MSVC target, 16 GiB host RAM; 9 GiB memory / 512 MiB swap cgroup limits, 180 s timeout, one test thread. RTX 4060 Laptop host, but these are CPU/Win32 memory tests, not GPU rendering. The installed vkd3d stack is diagnostic-relaxed; no native-Windows or stock-driver certification is implied.
Production code unchanged. Two local test-only strengthenings:
title_bytes_are_used_in_place_when_all_are_readable: requireVirtualFree(..., MEM_RELEASE)to succeed, then inspect the already returned whole/holed snapshots again. Original byte tags and the zero hole survive source release. The existingCow::Ownedassertion remains before release, so a borrowed-result control would fail safely before touching freed memory.lab_title_bytes_survive_concurrent_decommit: adapted #751'stitle_bytes_survive_concurrent_decommitto this PR'stitle_bytes/Cow API. One MiB source, 16 x 64 KiB regions, distinct byte tags per 4 KiB page; another thread repeatedly decommits/recommits the inner regions. For 256 snapshots, hash and verify each page consists only of its original-tag prefix followed by zeros. The counter recorded 420,948 decommits during the snapshot/hash interval, not an idle mutator. No exception. This is a stress interleaving, not proof of all schedules.The API adaptation is simply:
The local fixture additionally uses a scoped thread and a stop-on-drop guard to stop the mutator on assertion failure. It requires a nonzero concurrent-decommit count and successful decommit/recommit calls. No production hooks or mocked memory calls.
Suggested changes before merge: rename the existing test/doc comment (it now requires copying outside UMA, not in-place use whenever readable), and retain a source-release/concurrent-decommit regression. The existing static byte-equality test alone does not exercise the lifetime defect from #2841.
Performance/RAM limitation:
read_committedcreates a fresh zeroedVecper non-UMA read. This test does not measure title allocation pressure, texture-worker throughput, or peak RAM. #751 already proposes a reusable buffer and whole-rangeReadProcessMemoryfast path; coordinate with that owner rather than silently assuming the new copy is free. A bounded identical-input detile/streaming comparison is still needed before any performance claim. No recommendation to enable the experimental driver-window path from #2844 under Wine.No matched-parent race run: deliberately reproducing the known worker access violation is not needed for this verification. No title launch, Game Init watchdog fix claim, or gameplay/OOM claim. Local evidence:
.compat-xcl/logs/verify-pr2849-wine-title-bytes.log; local test-only edits retained for reproducibility. AI-assisted verification (OpenAI GPT-6 Astra).Imported from ivall/xcl. Originally posted by ClosetPie107 on 2026-11-26T20:26:57Z.
Independent test report under Wine/Proton (not native Windows) for head
4e931734, merged cleanly ontomain8b957bec(test commit3a077ec6). On this setup,mainhits the #2841 crash (symbolized stack in #2841).Tested
AMD Radeon RX 9070 (RDNA4, RADV GFX1201, Mesa 26.3.1), Ryzen 5 9600X, 30 GiB RAM, CachyOS Linux 7.3.5
Proton Experimental
experimental-11.0-20261112,vkd3d-protonmasterec207194(dxil-spirvb540c8a2) with a local patch that drops thelpVtblidentity checks ind3d12_command_allocator_from_iface/d3d12_command_list_from_iface, DXC1.9.2609.5, Rust 1.96.0, targetx86_64-pc-windows-gnu, release builds for the titlecargo test -p xcl --lib hle::d3d12x::title_textures:: -- --test-threads=1:main19 passed, 0 failed. This PR: 19 passed, 0 failed. None skipped (GPU tests ran).Retail title (1.0.2.1). 300 s per run (
XCL_RUN_SECONDS), A pressed every 10 s from 20 s, all runs from one copy of the same warm cache. Flags:XCL_PSO_WAIT_MS=50,XCL_DIRECT_DXIL=1,XCL_TEXTURE_LEVEL_PAGES=1,XCL_SPLIT_MIDLIST_WAIT=0,XCL_COHERENT_MB=1024,XCL_PSO_PRELOAD=1,XCL_NETWORK=0,VKD3D_CONFIG=ignore_shared_fence.main8b957becmain+ #2849(Counts are from the last
activityandconsole code so farlines.)main, and 6 of 9 runs ofmainand two PRs that do not touchtitle_textures(see #2841).main. The title presents only 1–4 times per 2 s after the world start on all trees, so a cost in the detile would be hard to see here.The test change only switches the existing assertion from
BorrowedtoOwned. There is no test that fails without the fix, for example a page decommitted between the readability check and the detile.Not tested
XCL_TEXTURE_LEVEL_PAGESunset, cold cachesAI use
Imported from ivall/xcl. Originally posted by throny on 2026-11-27T02:49:31Z.
Two contributors checked independently and found that #2877 solves the same problem (for #2841) in a different way: #1607, group D142. You may want to compare them with the other author and agree on one, or say in the PR why both are needed.
This is a hint from the community triage in #1607, not a maintainer decision.
AI use: Claude Code (Claude Opus 5.5), posted by a script from the #1607 table.
Imported from ivall/xcl. Originally posted by ettehn on 2026-11-27T02:57:37Z.
For D142, I compared the exact read helpers from
4e931734(#2849) andc1c22863(#2877) in an optimized standalone Windows fixture on a Ryzen 9 8945HX. Both worker paths returned an owned copy of an ordinary three-page span with a reserved middle page, preserving the two readable pages and zeroing the hole. For a fully committed coherent UMA window, #2849 returned the original slice and #2877 returned a separate copy, with identical bytes.Across three processes with nine alternating samples each, the #2877 UMA helper’s per-process medians were 0.27–0.29 us (16 KiB), 4.75–6.60 us (256 KiB), and 476–485 us (4 MiB). In that same fixture #2849 did no copy for those ranges. This measures obtaining and dropping the slice or copy, before detile or upload. No GPU work, title run, or frame-rate claim. The choice also affects scope: #2849 changes the shared helper used by submit-time hashing for non-UMA memory; #2877 keeps that caller on the old path.
OpenAI Codex (6.2sol) assisted with verification.
Imported from ivall/xcl. Originally posted by Foniass on 2026-12-01T09:03:15Z.
Triage (#1607) – head
4e93173Main already has this approach: commit
b84e0378("D3D12.X: title texture reads outside the coherent window use the safe copy") replacedtitle_bytesintitle_textures.rswithwith_title_bytes. That function reads in place only whenuma::in_committed_window(at, len)holds and copies everything else viaread_committed_into. The function this PR changes no longer exists on main.#2877 makes the same fix only for the texture workers, and main covers that too.
Recommendation: close (superseded by main commit
b84e0378).AI review: Claude Code (Claude Opus 5.5), diffs read only, not built or run; not checked by a human.
Imported from ivall/xcl. Originally posted by throny on 2026-12-01T13:00:07Z.
Closing as superseded: this change is already on
main(b84e0378). main title_textures.rs with_title_bytes (b84e0378) reads in place only inside the UMA committed window and copies everything else; same rule as the PR; tests title_bytes_are_copied_outside_the_coherent_window etcTwo independent checks found this: Foniass's close list on #1607 and ours against current
main. If something here is still missing onmain, say so and reopen it, or ask and I will.AI use: Claude Code (Claude Opus 5.5); the per-PR comparison was done by Claude Sonnet 5.5 sub-agents.
Pull request closed