GPU: keep CPU descriptor slots until recording consumes them #2844

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

@⁠andrewpozdnakov7-jpg on GitHub · 2026-11-25 22:02 UTC · original
andrewpozdnakov7-jpg:codex1/attachment-recording-current → main · +246 −88 · 5 files · 2 commits · open

CPU-only descriptors are read when the command list records the bind or clear. The global descriptor rings can wrap between creating a view and recording it, so another recording thread can substitute a different texture into the pending command.

Keep a slot reserved until its recording call returns. Render-target binds hold each slot through OMSetRenderTargets. Render-target, depth, and unordered-access clears hold their CPU descriptor through the clear call. If all pooled slots are busy, a short-lived CPU-only heap lets recording continue.

The same two-texture WARP scenario on 5c7489f leaves the left pixel black and clears the right pixel red. With this change the left pixel is red and the right pixel stays blue. Six paired runs across both D3D12 debug settings. The full serial GPU suite passed 242 tests with one ignored in each setting. Strict GPU Clippy in both feature configurations and asset policy passed.

CPU descriptor recording specification · Coordination claim

Please retain my Git author on cherry-pick or rebase. If you fold the fix or test into another commit, please add this trailer.

Co-authored-by: andrewpozdnakov7-jpg [email protected]

AI-assisted with Codex. Synthetic textures on Windows/WARP.

**@⁠andrewpozdnakov7-jpg** on GitHub · 2026-11-25 22:02 UTC · [original](https://github.com/Marvisak/VIctory/pull/2844) `andrewpozdnakov7-jpg:codex1/attachment-recording-current` → `main` · +246 −88 · 5 files · 2 commits · open CPU-only descriptors are read when the command list records the bind or clear. The global descriptor rings can wrap between creating a view and recording it, so another recording thread can substitute a different texture into the pending command. Keep a slot reserved until its recording call returns. Render-target binds hold each slot through `OMSetRenderTargets`. Render-target, depth, and unordered-access clears hold their CPU descriptor through the clear call. If all pooled slots are busy, a short-lived CPU-only heap lets recording continue. The same two-texture WARP scenario on `5c7489f` leaves the left pixel black and clears the right pixel red. With this change the left pixel is red and the right pixel stays blue. Six paired runs across both D3D12 debug settings. The full serial GPU suite passed 242 tests with one ignored in each setting. Strict GPU Clippy in both feature configurations and asset policy passed. [CPU descriptor recording specification](https://microsoft.github.io/DirectX-Specs/d3d/ResourceBinding.html#non-shader-visible-descriptor-heaps) · [Coordination claim](https://git.gtahub.st/github/Marvisak--VIctory/issues/1633) Please retain my Git author on cherry-pick or rebase. If you fold the fix or test into another commit, please add this trailer. Co-authored-by: andrewpozdnakov7-jpg <[email protected]> AI-assisted with Codex. Synthetic textures on Windows/WARP.
github-bot locked as GitHub sync and limited conversation to collaborators 2026-11-26 05:15:44 +00:00
Author
Owner

@⁠oni-swr on GitHub · 2026-11-25 22:27 UTC · original

Independent synthetic Windows WARP check for fdc876bb against current main (f3578e38). I confirmed Microsoft Basic Render Driver (vendor 0x1414, device 0x008c, software flag 0x2) with VICTORY_D3D12_WARP=1, diagnostics enabled, and the SDK dxil.dll configured.

  • The two-texture RTV test passed on the PR head and on a clean local merge into current main. After another thread made 1,024 views, the pending clear still changed the left pixel to red and left the right pixel blue.
  • The same test adapted to the old handle API on current main reproduced the bug. Left stayed black and right turned red.
  • I confirmed the overlap with #2834 at 208080e5 using git merge-tree. The combination conflicts in draw.rs, host.rs, and list.rs.

AI-assisted with Codex (gpt-6.2-sol). Claude Code (claude-opus-5-5) prepared the initial WARP guard and comparison worktrees. Synthetic data only.

**@⁠oni-swr** on GitHub · 2026-11-25 22:27 UTC · [original](https://github.com/Marvisak/VIctory/pull/2844#issuecomment-7176395310) <!-- oni-swr warp verification fdc876bb7a570a857d55c1c7399aaa2e018be494 --> Independent synthetic Windows WARP check for `fdc876bb` against current `main` (`f3578e38`). I confirmed Microsoft Basic Render Driver (vendor `0x1414`, device `0x008c`, software flag `0x2`) with `VICTORY_D3D12_WARP=1`, diagnostics enabled, and the SDK `dxil.dll` configured. - The two-texture RTV test passed on the PR head and on a clean local merge into current `main`. After another thread made 1,024 views, the pending clear still changed the left pixel to red and left the right pixel blue. - The same test adapted to the old handle API on current `main` reproduced the bug. Left stayed black and right turned red. - I confirmed the overlap with #2834 at `208080e5` using `git merge-tree`. The combination conflicts in `draw.rs`, `host.rs`, and `list.rs`. AI-assisted with Codex (gpt-6.2-sol). Claude Code (claude-opus-5-5) prepared the initial WARP guard and comparison worktrees. Synthetic data only.
Author
Owner

@⁠fuzeofficlal on GitHub · 2026-11-25 22:34 UTC · original

Verified fdc876bb on Windows 11 (RTX 5090 + WARP) against main (f3578e3):

  • cargo xtask policy (190 files ok), cargo clippy --locked -p victory-gpu --all-targets (default & --features diagnostics, 0 warnings).
  • RTX 5090 (--features diagnostics): host::tests 31/31 (including pending_rtv_survives_other_recorders), draw::tests 20/20, list::tests 4/4, queue::tests 5/5 passed.
  • WARP (--features diagnostics, full crate): 242 passed, 0 failed, 1 ignored.
  • Concurrency/lifetime audit looks solid: CpuViews holds its available mutex only around pop/push (never across D3D12 calls), OMSetRenderTargets keeps all slot guards alive until after the D3D12 call returns, and clear paths release slots cleanly on drop.
  • Two small test-coverage nits:
    1. pending_rtv_survives_other_recorders is gated behind #[cfg(feature = "diagnostics")] even though it doesn't use diagnostics-only APIs, so default cargo test skips it.
    2. The for _ in 0..1024 { let _view = host.rtv(...); } loop drops each CpuView immediately on every iteration, exercising serial reuse rather than >1024 live concurrent views hitting the Standalone heap fallback.
**@⁠fuzeofficlal** on GitHub · 2026-11-25 22:34 UTC · [original](https://github.com/Marvisak/VIctory/pull/2844#issuecomment-7176529393) Verified `fdc876bb` on Windows 11 (RTX 5090 + WARP) against `main` (`f3578e3`): - `cargo xtask policy` (`190 files ok`), `cargo clippy --locked -p victory-gpu --all-targets` (default & `--features diagnostics`, 0 warnings). - RTX 5090 (`--features diagnostics`): `host::tests` 31/31 (including `pending_rtv_survives_other_recorders`), `draw::tests` 20/20, `list::tests` 4/4, `queue::tests` 5/5 passed. - WARP (`--features diagnostics`, full crate): 242 passed, 0 failed, 1 ignored. - Concurrency/lifetime audit looks solid: `CpuViews` holds its `available` mutex only around `pop`/`push` (never across D3D12 calls), `OMSetRenderTargets` keeps all slot guards alive until after the D3D12 call returns, and clear paths release slots cleanly on drop. - Two small test-coverage nits: 1. `pending_rtv_survives_other_recorders` is gated behind `#[cfg(feature = "diagnostics")]` even though it doesn't use diagnostics-only APIs, so default `cargo test` skips it. 2. The `for _ in 0..1024 { let _view = host.rtv(...); }` loop drops each `CpuView` immediately on every iteration, exercising serial reuse rather than >1024 live concurrent views hitting the `Standalone` heap fallback.
Author
Owner

@⁠andrewpozdnakov7-jpg on GitHub · 2026-11-26 02:04 UTC · original

I checked the signature overlap with #2834. The verified fork composition includes exact heads fdc876b and 208080e and current main 63bcca43c6a00a758510398fa43096ce7e4f7df0. Both original Git commits are preserved.

The resolution checks the format's attachment permission before reserving a slot. Valid views keep the CpuView guard until the bind or clear has been recorded. The existing depth-bounds fixture uses the guarded handle too.

The two-texture RTV regression, the unsupported attachment format regression, and both depth-bounds tests passed together. Full Windows/WARP GPU diagnostics passed (250 passed, 1 ignored), along with strict GPU Clippy with and without diagnostics and asset policy.

If the combination is taken, please keep the original Git authors. If our change is folded into another commit, please add:

Co-authored-by: andrewpozdnakov7-jpg [email protected]

**@⁠andrewpozdnakov7-jpg** on GitHub · 2026-11-26 02:04 UTC · [original](https://github.com/Marvisak/VIctory/pull/2844#issuecomment-7180435030) I checked the signature overlap with #2834. The [verified fork composition](https://github.com/andrewpozdnakov7-jpg/VIctory/commit/cc1f95a38238fdfba023901706c091e15cc13f6e) includes exact heads `fdc876b` and `208080e` and current main `63bcca43c6a00a758510398fa43096ce7e4f7df0`. Both original Git commits are preserved. The resolution checks the format's attachment permission before reserving a slot. Valid views keep the `CpuView` guard until the bind or clear has been recorded. The existing depth-bounds fixture uses the guarded handle too. The two-texture RTV regression, the unsupported attachment format regression, and both depth-bounds tests passed together. Full Windows/WARP GPU diagnostics passed (250 passed, 1 ignored), along with strict GPU Clippy with and without diagnostics and asset policy. If the combination is taken, please keep the original Git authors. If our change is folded into another commit, please add: Co-authored-by: andrewpozdnakov7-jpg <[email protected]>
Author
Owner

@⁠Marvisak on GitHub · 2026-11-26 03:25 UTC · original · edited 2026-11-26 04:23 UTC

Automated triage for the maintainers.

Merge candidate. Thanks for merging main. render_with_depth_bounds in pipeline/depth_bounds_test.rs now keeps the CpuView from host.dsv(..) alive for the whole function and passes .handle to both calls, and the other rtv/dsv/cpu_view callers in the merged tree keep their guards long enough. The fix itself is unchanged. This still overlaps #2834 in draw.rs/host.rs/list.rs, so whichever lands second needs a small rebase.

CI: passing.


Generated by Claude Code

**@⁠Marvisak** on GitHub · 2026-11-26 03:25 UTC · [original](https://github.com/Marvisak/VIctory/pull/2844#issuecomment-7181702005) · edited 2026-11-26 04:23 UTC <!-- victory-triage v1 head=48ae0960d1774130d95be1f3ac93322a15301644 verdict=merge-candidate at=2026-11-26T04:23:21Z --> Automated triage for the maintainers. **Merge candidate.** Thanks for merging `main`. `render_with_depth_bounds` in `pipeline/depth_bounds_test.rs` now keeps the `CpuView` from `host.dsv(..)` alive for the whole function and passes `.handle` to both calls, and the other `rtv`/`dsv`/`cpu_view` callers in the merged tree keep their guards long enough. The fix itself is unchanged. This still overlaps #2834 in `draw.rs`/`host.rs`/`list.rs`, so whichever lands second needs a small rebase. CI: passing. --- _Generated by [Claude Code](https://claude.ai/code)_
Author
Owner

@⁠andrewpozdnakov7-jpg on GitHub · 2026-11-26 03:42 UTC · original

I merged current main 63bcca4 into this branch in 48ae096. The depth-bounds fixture holds the CpuView while it records both the depth clear and the target bind.

The plain merge failed cargo check -p victory-gpu --tests with two E0308 errors in that fixture. On the updated head, strict GPU Clippy passed in both configurations. The two depth-bounds tests and the recording-race regression pass on Windows/WARP. The actual depth readback for fresh, excluded, included and reset was [0.25, 0.5, 0.25, 0.25]. The full diagnostics suite passed 247 tests with one ignored in both runs. The asset policy passed.

The tested #2834 composition has the same fixture adjustment. Its attachment-guard resolution is available for the merge order the maintainers choose.

Please retain the Git author if you move the fix, or include this trailer if you fold in the patch or regression:

Co-authored-by: andrewpozdnakov7-jpg [email protected]

AI-assisted with Codex.

**@⁠andrewpozdnakov7-jpg** on GitHub · 2026-11-26 03:42 UTC · [original](https://github.com/Marvisak/VIctory/pull/2844#issuecomment-7181952253) I merged current `main` `63bcca4` into this branch in [48ae096](https://github.com/andrewpozdnakov7-jpg/VIctory/commit/48ae0960d1774130d95be1f3ac93322a15301644). The depth-bounds fixture holds the `CpuView` while it records both the depth clear and the target bind. The plain merge failed `cargo check -p victory-gpu --tests` with two E0308 errors in that fixture. On the updated head, strict GPU Clippy passed in both configurations. The two depth-bounds tests and the recording-race regression pass on Windows/WARP. The actual depth readback for fresh, excluded, included and reset was `[0.25, 0.5, 0.25, 0.25]`. The full diagnostics suite passed 247 tests with one ignored in both runs. The asset policy passed. The [tested #2834 composition](https://git.gtahub.st/github/Marvisak--VIctory/pulls/2844) has the same fixture adjustment. Its attachment-guard resolution is available for the merge order the maintainers choose. Please retain the Git author if you move the fix, or include this trailer if you fold in the patch or regression: Co-authored-by: andrewpozdnakov7-jpg <[email protected]> AI-assisted with Codex.
Author
Owner

@⁠kotekompotek on GitHub · 2026-11-25 22:11 UTC · original · reviewed

Right lifetime fix — a bare CPU handle from the RTV/DSV ring can be recycled by another view before OMSetRenderTargets records it; holding the View guard in scope through the call closes that. The MAX_TARGETS cap also handles >8 target sets gracefully now. Heads-up: this changes the same rtv()/dsv() signatures as #2834 (Option there vs Option here) — whichever lands second needs the other's shape.

**@⁠kotekompotek** on GitHub · 2026-11-25 22:11 UTC · [original](https://github.com/Marvisak/VIctory/pull/2844#pullrequestreview-6065695069) · **reviewed** Right lifetime fix — a bare CPU handle from the RTV/DSV ring can be recycled by another view before OMSetRenderTargets records it; holding the View guard in scope through the call closes that. The MAX_TARGETS cap also handles >8 target sets gracefully now. Heads-up: this changes the same rtv()/dsv() signatures as #2834 (Option<handle> there vs Option<View> here) — whichever lands second needs the other's shape.
Author
Owner

@⁠Dukestar69 on GitHub · 2026-11-26 09:51 UTC · original · approved these changes

Verified on RTX 5090 against origin/main (63bcca4):

  • cargo test -p victory-gpu --lib descriptor:: -- --test-threads=1 --skip dynamic_slots_are_held_until_released: 21/21 passed.
  • cargo test -p victory-gpu --lib draw:: -- --test-threads=1: 20/20 passed.
  • cargo clippy -p victory-gpu --all-targets -- -D warnings: clean.
  • cargo xtask policy: 191 files ok.

Cleanly keeps CPU descriptor slots alive until command-list recording consumes them.

Synthetic tests only (no game files used). AI-assisted (Gemini 4 Neon).

**@⁠Dukestar69** on GitHub · 2026-11-26 09:51 UTC · [original](https://github.com/Marvisak/VIctory/pull/2844#pullrequestreview-6071877537) · **approved these changes** Verified on RTX 5090 against `origin/main` (`63bcca4`): - `cargo test -p victory-gpu --lib descriptor:: -- --test-threads=1 --skip dynamic_slots_are_held_until_released`: 21/21 passed. - `cargo test -p victory-gpu --lib draw:: -- --test-threads=1`: 20/20 passed. - `cargo clippy -p victory-gpu --all-targets -- -D warnings`: clean. - `cargo xtask policy`: 191 files ok. Cleanly keeps CPU descriptor slots alive until command-list recording consumes them. Synthetic tests only (no game files used). AI-assisted (Gemini 4 Neon).
Author
Owner

@⁠fuzeofficlal on GitHub · 2026-11-26 10:53 UTC · original · approved these changes

Verified 48ae0960 locally on Windows 11 (RTX 5090 and WARP, with VICTORY_D3D12_DEBUG=1):

  • cargo xtask policy and cargo clippy -p victory-gpu --tests -- -D warnings (default and --all-features): clean.
  • host::tests::pending_rtv_survives_other_recorders (--features diagnostics), draw::tests (20/20), pipeline::depth_bounds_test (2/2), and queue::tests (5/5) all passed on RTX 5090, RTX 5090 + VICTORY_D3D12_DEBUG=1, and WARP + VICTORY_D3D12_DEBUG=1.
  • Also checked the >1024 pool-exhaustion standalone heap fallback directly (holding 1,030 live RTVs, recording ClearRenderTargetView with a standalone fallback descriptor, and verifying all 1,024 pooled slots return on drop) under VICTORY_D3D12_DEBUG=1 on both RTX 5090 and WARP.

Lifetimes are held cleanly across every recording site (set_targets, clear_unordered, clear_rtv, clear_dsv, and tests), set_targets properly caps at D3D12_SIMULTANEOUS_RENDER_TARGET_COUNT and only records self.targets/self.depth once the view is created, and clear_unordered acquires cpu_view before taking a dynamic slot. Looks ready to merge.

**@⁠fuzeofficlal** on GitHub · 2026-11-26 10:53 UTC · [original](https://github.com/Marvisak/VIctory/pull/2844#pullrequestreview-6072838727) · **approved these changes** Verified `48ae0960` locally on Windows 11 (RTX 5090 and WARP, with `VICTORY_D3D12_DEBUG=1`): - `cargo xtask policy` and `cargo clippy -p victory-gpu --tests -- -D warnings` (default and `--all-features`): clean. - `host::tests::pending_rtv_survives_other_recorders` (`--features diagnostics`), `draw::tests` (20/20), `pipeline::depth_bounds_test` (2/2), and `queue::tests` (5/5) all passed on RTX 5090, RTX 5090 + `VICTORY_D3D12_DEBUG=1`, and WARP + `VICTORY_D3D12_DEBUG=1`. - Also checked the >1024 pool-exhaustion standalone heap fallback directly (holding 1,030 live RTVs, recording `ClearRenderTargetView` with a standalone fallback descriptor, and verifying all 1,024 pooled slots return on drop) under `VICTORY_D3D12_DEBUG=1` on both RTX 5090 and WARP. Lifetimes are held cleanly across every recording site (`set_targets`, `clear_unordered`, `clear_rtv`, `clear_dsv`, and tests), `set_targets` properly caps at `D3D12_SIMULTANEOUS_RENDER_TARGET_COUNT` and only records `self.targets`/`self.depth` once the view is created, and `clear_unordered` acquires `cpu_view` before taking a dynamic slot. Looks ready to merge.
This pull request can be merged automatically.
You are not authorized to merge this pull request.
View command line instructions

Checkout

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

Merge

Merge the changes and update on Forgejo.
git switch 'main'
git merge --no-ff 'github-bot/gh-2844'
git switch 'github-bot/gh-2844'
git rebase 'main'
git switch 'main'
git merge --ff-only 'github-bot/gh-2844'
git switch 'github-bot/gh-2844'
git rebase 'main'
git switch 'main'
git merge --no-ff 'github-bot/gh-2844'
git switch 'main'
git merge --squash 'github-bot/gh-2844'
git switch 'main'
git merge --ff-only 'github-bot/gh-2844'
git switch 'main'
git merge 'github-bot/gh-2844'
git push origin 'main'
This discussion has been locked. Commenting is limited to contributors.
No reviewers
No milestone
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set

Reference
github/Marvisak--VIctory!2844
No description provided.