D3D12.X: a held last Release gives the resource's unified memory / sparse tiles back while the queues still use it #1040

Open
opened 2026-11-26 04:41:32 +00:00 by github-bot · 0 comments
Owner

@⁠DTsordas on GitHub · 2026-11-24 10:47 UTC · original

Since e7da8a1 (late release), res_release holds a resource whose last Release comes while a queue may still have work on it. But the cleanup in the same call still runs at once (crates/xcl/src/hle/d3d12x/real.rs, res_release):

  • u.free(p) puts the unified-memory block XCL placed under the resource back on the free list, so the next buffer or texture XCL places can get it while the GPU still reads or writes it for the held one;
  • sparse::free(p) decommits the pages and gives the address range back, and sparse::forget_buffer unpins the buffer's tiles (release_if_unused). The held resource's in-flight work then reads unmapped tiles or loses its writes.

The hold exists for exactly this case: e7da8a1 measured 356 held last releases on the retail title.

Reproduced on main e74dda2 with a unit test. It stalls a known queue (Wait on a fence nobody signals), places an adopted buffer on a unified-memory block as place_console_buffer records it, and does the title's last Release through res_release: the block is free again before the queue has moved on.

I have a fix. Bookkeeping is still dropped at the title's Release; a held resource's block and tile pins go to late_release, which gives them back when the resource goes. The full suite passes with it on an RX 9060 XT (debug, cargo test --workspace --no-fail-fast -- --test-threads=4: 728 passed, 0 failed, 41 ignored, 0 SKIPPED). I'll open the PR once I have the smoke runs on a title.

AI use: found, reproduced and written up with Claude Code (Claude Opus 5.5).

**@⁠DTsordas** on GitHub · 2026-11-24 10:47 UTC · [original](https://github.com/xcl-dev/xcl/issues/1040) Since `e7da8a1` (late release), `res_release` holds a resource whose last `Release` comes while a queue may still have work on it. But the cleanup in the same call still runs at once (`crates/xcl/src/hle/d3d12x/real.rs`, `res_release`): - `u.free(p)` puts the unified-memory block XCL placed under the resource back on the free list, so the next buffer or texture XCL places can get it while the GPU still reads or writes it for the held one; - `sparse::free(p)` decommits the pages and gives the address range back, and `sparse::forget_buffer` unpins the buffer's tiles (`release_if_unused`). The held resource's in-flight work then reads unmapped tiles or loses its writes. The hold exists for exactly this case: `e7da8a1` measured 356 held last releases on the retail title. Reproduced on main `e74dda2` with a unit test. It stalls a known queue (`Wait` on a fence nobody signals), places an adopted buffer on a unified-memory block as `place_console_buffer` records it, and does the title's last `Release` through `res_release`: the block is free again before the queue has moved on. I have a fix. Bookkeeping is still dropped at the title's `Release`; a held resource's block and tile pins go to `late_release`, which gives them back when the resource goes. The full suite passes with it on an RX 9060 XT (debug, `cargo test --workspace --no-fail-fast -- --test-threads=4`: 728 passed, 0 failed, 41 ignored, 0 SKIPPED). I'll open the PR once I have the smoke runs on a title. **AI use:** found, reproduced and written up with Claude Code (Claude Opus 5.5).
github-bot locked as GitHub sync and limited conversation to collaborators 2026-11-26 04:41:32 +00:00
This discussion has been locked. Commenting is limited to contributors.
No description provided.