Repository navigation
Conversation
|
Verified on Windows 11 10.0.26300, NVIDIA GeForce RTX 5090 (driver 621.24), Rust 1.100.0 MSVC 14.44.35207, debug build, on One more passing test than the baseline; a held resource keeping its memory until its last use is covered and green. Tree restored afterwards (full diff against a clean checkout), hardware adapter, no Wine, no game data. AI-assisted (opencode): applied the patch to a built tree, ran the suite, reverted it. |
|
This deadlocks a retail title a few seconds into its intro on our tree, which has this PR merged: the submit thread waits for itself.
Every thread after it waits on What fixed it for us (our fork,
With both, the intro plays again on the same build. I can open that as a PR stacked on this one if that's useful. Tested: Windows 11, RTX (NVIDIA, 12 GB), Intel CPU; AI use: found from the thread dump and written by Claude Code (Claude Opus 5.5); the call path was checked against this PR's head. |
Late release (e7da8a1) holds a resource whose last Release comes while a queue may still use it, but res_release still gave back what XCL placed under it at the title's Release: the unified-memory block went back on the free list (the next resource could get it while the GPU still used it), and a sparse block was decommitted and its tiles unpinned. The bookkeeping still goes at the title's Release. A held resource's block and its sparse tile pins go to late_release. Once the queues are past it, its tiles are unpinned and a sparse block is freed before its final Release (its address is no other resource's yet), and a block in a coherent window after it. A release that is not held frees at once, as before. The drain does not wait for the sparse state's lock for this (sparse::try_forget_held): it runs inside XCL's own submits and inside D3D12 calls that make a last Release, where the lock's holder can be waiting for that thread. A resource it cannot let go then goes at the next drain. Fixes xcl-dev#1040 Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
9aa0e9a to
d0ebe34
Compare
|
@duudiis thanks for the stacks and the call path. On upstream Pushed Tests: If you can, could you run (Traced and written with Claude Code, Claude Opus 5.5; the call path checked against upstream |
Integrates upstream PRs ivall#1055 and ivall#1102 (issue ivall#1031) and ivall#1070 (issue ivall#1040). Assisted-by: xcl-ops (deepseek-v4.1-flash) Trace-Issue: ivall#1031
…1394) mem_heap_release gave a heap's HEAP_UMA block back at the title's last Release, also while a queue could still read the buffers placed in it (they live in the block, not in the PC heap). A coherent block went back on the free list, where the next allocation could take it; a sparse one was decommitted. A heap with a block is now held like a resource (late_release), and its block goes to late_release::hold with it (xcl-dev#1070), to be given back once the queues are past the work in flight. A heap without a block goes at once, as before. The test holds a queue on a fence, releases a heap with a block and checks the block stays allocated until the fence is signalled; it fails without the change.
# Conflicts: # crates/xcl/src/hle/d3d12x/sparse.rs
|
Verification on RTX 3060 Ti (Windows 11): merge conflict with current |
Late release (
e7da8a1) holds a resource whose lastReleasecomes while a queue may still have work on it. Butres_releasestill gave back, at the title'sRelease, what XCL had placed under the resource. The unified-memory block went back on the free list, so the next resource XCL placed could get it while the GPU still used it. A sparse block was decommitted and its address range returned, and the buffer's tiles were unpinned (sparse::forget_buffer→release_if_unused). The held resource's in-flight work could then read another resource's data or unmapped tiles.e7da8a1measured 356 held releases on the retail title.XCL's bookkeeping for the resource still goes at the title's
Release, as before (a held object keeps its address). A held resource's block and its tile pins go tolate_releasewith it. Once the queues are past it, its tiles are unpinned and a sparse block is freed before its finalRelease(while the resource is alive, its address is no other resource's), and a block in the coherent window after it. A release that is not held frees at once, as before.vram::forget(arena release, which has its own delay) andtitle_textures::forget(bookkeeping) are unchanged. Fixes #1040.Since
9aa0e9a(duudiis's review below): the drain no longer waits for the sparse state's lock. It runs inside XCL's own submits and inside D3D12 calls that make a resource's lastRelease, where the lock's holder can be waiting for that thread (the paths #789 and #968 take the lock off).sparse::try_forget_heldtakes the lock only if it is free; otherwise the resource goes back as an already-passed batch and goes at the next drain.What is in it
crates/xcl/src/hle/d3d12x/real.rs:res_releasepasses the block tolate_release::holdwhen it holds the resource, and skipssparse::forget_bufferthen.crates/xcl/src/hle/d3d12x/late_release.rs: held entries carry their block.let_gounpins the tiles and frees a sparse block (sparse::try_forget_held), releases the resource, then frees a coherent block; an entry the sparse state is busy for goes back to the next drain (Held::again). The two existing tests now carry the pair.crates/xcl/src/hle/d3d12x/sparse.rs:try_forget_held(STATE.try_lock()).forget_buffer's loop andfree's decommit are shared with it (State::forget_buffer,free_with,decommitted_in);lock_for_test(test-only).crates/xcl/src/gpu/uma.rs:Uma::is_allocated, test-only (#[cfg(test)]).held_release_tests::a_held_resource_keeps_its_unified_memory_until_it_goes: a known queue stands still on a fence; an adopted buffer gets a unified-memory block recorded asplace_console_bufferdoes; its lastReleasegoes throughres_release. The block must stay allocated while the queue has work, and go once it has passed. On main it fails at the first check ("the block under a held resource went back while a queue still had work").late_release::tests::letting_go_does_not_wait_for_the_sparse_state: with the sparse state locked on another thread, letting a resource go returns at once and keeps it for later. With the drain's earlier blockingforget_bufferit fails after 5 s ("the drain waited for the sparse state's lock").late_release::tests::a_resource_put_back_goes_at_the_next_drain: a resource put back goes at the next drain, ahead of a batch a stalled queue has not passed.Tested
cargo test --workspace --no-fail-fast -- --test-threads=4atd0ebe34(on main47efa2e): 744 passed, 0 failed, 41 ignored, 0 SKIPPED.cargo test -p xcl --lib -- late_release held_release_tests hle::d3d12x::sparseatd0ebe34: 18 passed, 0 failed, 1 ignored.held_release_testsfails on main and passes with the change (checked when this PR was opened; main has not moved since).Regression run
The title's 60 s smoke run (
scripts/smoke.ps1, release builds, same machine, back to back).main:
PR:
Not tested
maintoo (its watchdog, Newer retail title (TitleID 7952987A): reaches world loading, then the title's GPU watchdog ("GPU Loc Sig") after ListX #101 stub #505), so only its first minute is covered above. The corruption itself (what a reused block looks like on screen) is not observed, only the early free.XCL_LATE_RELEASE=0(nothing is held, so the change does nothing there).AI use
🤖 Generated with Claude Code