Reuse D3D12 texture readback buffers after command-list retirement #92

Open
github-bot wants to merge 2 commits from github-bot/gh-92 into main AGit
Owner

@⁠cxy0072019-sketch on GitHub · 2026-11-27 00:08 UTC · original
cxy0072019-sketch:codex/texture-readback-pool → main · +402 −12 · 2 files · 2 commits · open

Summary

Backport the optional D3D12 texture readback pool from Cool Fox, preserving its authorship. The pool keeps a readback buffer leased while a closed command list can still replay it. Retired buffers can be reused in bounded size classes. The relay also rejects the device-removal fence value before retiring pooled buffers.

Enable with VICTORY_READBACK_POOL=1. VICTORY_READBACK_POOL_MB sets the idle-byte limit in MiB, with a default of 256 MiB. Oversized requests and failed rounded allocations use the original requested size.

Validation

  • The four Windows release readback_pool tests passed. They cover lease exclusivity and idle limits, the original-size fallback, and a closed D3D12 command list replayed before its lease can be reused.
  • On a local Series S runtime with existing water fixes, I tested the same executable and checkpoint twice at 1920×1080 on an RTX 5070 Ti. Toggling the pool was the sole setting change. Water, reflections and wake rendered during the enabled run. This measures the pool on top of those local fixes.
Window New buffers off → on FPS off → on
~55 seconds stationary 17,405 → 0 20.82 → 21.40
Early sailing 18.69 → 19.20
~33 seconds of sailing after acceleration 8,844 → 0 17.79 → 17.87

The pool held at most 20.25 MiB idle in this run. Both runs recorded zero readback allocation failures. The longer route varied with other boats and shoreline geometry. These measurements primarily establish the reduction in allocations.

**@⁠cxy0072019-sketch** on GitHub · 2026-11-27 00:08 UTC · [original](https://github.com/TaynanGT/Vice-Tay/pull/92) `cxy0072019-sketch:codex/texture-readback-pool` → `main` · +402 −12 · 2 files · 2 commits · open ## Summary Backport the optional D3D12 texture readback pool from [Cool Fox](https://github.com/DoubleGhosty/cool_fox/commit/67028e2193051340edcd3e06e960e673a58af1b5), preserving its authorship. The pool keeps a readback buffer leased while a closed command list can still replay it. Retired buffers can be reused in bounded size classes. The relay also rejects the device-removal fence value before retiring pooled buffers. Enable with `VICTORY_READBACK_POOL=1`. `VICTORY_READBACK_POOL_MB` sets the idle-byte limit in MiB, with a default of 256 MiB. Oversized requests and failed rounded allocations use the original requested size. ## Validation - The four Windows release `readback_pool` tests passed. They cover lease exclusivity and idle limits, the original-size fallback, and a closed D3D12 command list replayed before its lease can be reused. - On a local Series S runtime with existing water fixes, I tested the same executable and checkpoint twice at 1920×1080 on an RTX 5070 Ti. Toggling the pool was the sole setting change. Water, reflections and wake rendered during the enabled run. This measures the pool on top of those local fixes. | Window | New buffers off → on | FPS off → on | | --- | ---: | ---: | | ~55 seconds stationary | 17,405 → 0 | 20.82 → 21.40 | | Early sailing | | 18.69 → 19.20 | | ~33 seconds of sailing after acceleration | 8,844 → 0 | 17.79 → 17.87 | The pool held at most 20.25 MiB idle in this run. Both runs recorded zero readback allocation failures. The longer route varied with other boats and shoreline geometry. These measurements primarily establish the reduction in allocations.
Keep each readback exclusive until its recording is reset or retired. Add a per-device bounded idle pool and separate allocation, reuse and landing telemetry.

(cherry picked from commit 67028e2193051340edcd3e06e960e673a58af1b5)
The submission relay must not retire flights on the D3D12 removed-device sentinel while readback buffers can be reused. Follow the fence check in fxceless/victory-fork@d036cea8.
github-bot locked as GitHub sync and limited conversation to collaborators 2026-11-27 00:42:02 +00:00
Author
Owner

@⁠TaynanGT on GitHub · 2026-11-27 01:28 UTC · original · requested changes

Thanks, @⁠cxy0072019-sketch. I checked the lease lifetime and the original-size fallback. The Windows CI logs show all four pool tests passing in both builds, including replaying a closed D3D12 list before reset. There's one device-removal reporting issue to fix before this goes in.

**@⁠TaynanGT** on GitHub · 2026-11-27 01:28 UTC · [original](https://github.com/TaynanGT/Vice-Tay/pull/92#pullrequestreview-6082279641) · **requested changes** Thanks, @⁠cxy0072019-sketch. I checked the lease lifetime and the original-size fallback. The Windows CI logs show all four pool tests passing in both builds, including replaying a closed D3D12 list before reset. There's one device-removal reporting issue to fix before this goes in.
@ -5692,6 +5997,7 @@ impl Host {
Err(e) => tracing::warn!(error = %e, "submissions sent ahead not waited for"),
}
}
self.verify_texture_readback_fence(*submitted);
Author
Owner

@⁠TaynanGT on GitHub · 2026-11-27 01:28 UTC · original

With the pool enabled, GetCompletedValue() returns u64::MAX on device removal, so this call reaches fail before the existing branch can report removal_data(&runs) and last_notes(&runs) for the affected lists. The direct submission path has the same ordering. Can both paths handle device removal with the existing list details first and still verify the fence before any readback or retirement? In the direct path, the removal check would need to move up too, since FINISHED and bury are currently ahead of it.

**@⁠TaynanGT** on GitHub · 2026-11-27 01:28 UTC · [original](https://github.com/TaynanGT/Vice-Tay/pull/92#discussion_r4714796253) With the pool enabled, `GetCompletedValue()` returns `u64::MAX` on device removal, so this call reaches `fail` before the existing branch can report `removal_data(&runs)` and `last_notes(&runs)` for the affected lists. The direct submission path has the same ordering. Can both paths handle device removal with the existing list details first and still verify the fence before any readback or retirement? In the direct path, the removal check would need to move up too, since `FINISHED` and `bury` are currently ahead of it.
@ -5692,6 +5997,7 @@ impl Host {
Err(e) => tracing::warn!(error = %e, "submissions sent ahead not waited for"),
}
}
self.verify_texture_readback_fence(*submitted);
Author
Owner

@⁠TaynanGT on GitHub · 2026-11-27 02:24 UTC · original

I prepared a follow-up in #118 on top of your commits. The fence sentinel now goes through the existing device-removal report in both synchronous submission paths, while an incomplete fence still stops recycling. The new regression and the full CI passed. The opt-in title run is still pending.

**@⁠TaynanGT** on GitHub · 2026-11-27 02:24 UTC · [original](https://github.com/TaynanGT/Vice-Tay/pull/92#discussion_r4715062622) I prepared a follow-up in #118 on top of your commits. The fence sentinel now goes through the existing device-removal report in both synchronous submission paths, while an incomplete fence still stops recycling. The new regression and the full CI passed. The opt-in title run is still pending.
Author
Owner

@⁠TaynanGT on GitHub · 2026-11-27 05:46 UTC · original

Thanks for including the closed-list replay case, @⁠cxy0072019-sketch. It covers the lease lifetime, and the 17,405-to-zero allocation count is the concrete result from your stationary run.

The branch currently conflicts with main. #166 has since changed host.rs and texback.rs, so the pool needs to sit on the current readback path. The replay lease test and the device-removal fence guard should carry through that reconciliation.

**@⁠TaynanGT** on GitHub · 2026-11-27 05:46 UTC · [original](https://github.com/TaynanGT/Vice-Tay/pull/92#issuecomment-7210937833) Thanks for including the closed-list replay case, @⁠cxy0072019-sketch. It covers the lease lifetime, and the 17,405-to-zero allocation count is the concrete result from your stationary run. The branch currently conflicts with `main`. #166 has since changed `host.rs` and `texback.rs`, so the pool needs to sit on the current readback path. The replay lease test and the device-removal fence guard should carry through that reconciliation.
This pull request has changes conflicting with the target branch.
  • crates/victory-gpu/src/host.rs
View command line instructions

Manual merge helper

Use this merge commit message when completing the merge manually.

Checkout

From your project repository, check out a new branch and test the changes.
git fetch -u origin '+refs/pull/92/head:github-bot/gh-92'
git switch 'github-bot/gh-92'

Merge

Merge the changes and update on Forgejo.
git switch 'main'
git merge --no-ff 'github-bot/gh-92'
git switch 'github-bot/gh-92'
git rebase 'main'
git switch 'main'
git merge --ff-only 'github-bot/gh-92'
git switch 'github-bot/gh-92'
git rebase 'main'
git switch 'main'
git merge --no-ff 'github-bot/gh-92'
git switch 'main'
git merge --squash 'github-bot/gh-92'
git switch 'main'
git merge --ff-only 'github-bot/gh-92'
git switch 'main'
git merge 'github-bot/gh-92'
git push origin 'main'
This discussion has been locked. Commenting is limited to contributors.
No description provided.