GPU: split duplicate HostList entries into separate ExecuteCommandLists batches #1400

Closed
piyonchu wants to merge 1 commit from upstream-pr/1400 into main
piyonchu commented 2026-11-24 17:45:52 +00:00 (Migrated from github.com)

Imported from Marvisak/VIctory. Originally posted by piyonchu on 2026-11-24T17:45:52Z.


Summary

Fixes a D3D12 prelude-clobbering and duplicate-command-list submission bug when the same HostList appears more than once in Host::execute(runs).

Cause

HostList owns a single (allocator, list) pair in self.prelude. Previously Host::execute iterated every entry of runs, called list.prelude(), and appended the returned ID3D12CommandList to one lists slice passed to a single ExecuteCommandLists batch:

  1. Calling list.prelude() a second time on the same HostList in the same runs slice reset its allocator and list, overwriting the barriers recorded for the first occurrence before ExecuteCommandLists ran.
  2. Submitting the same closed ID3D12GraphicsCommandList twice in one ExecuteCommandLists batch violates D3D12 batch uniqueness and triggers DXGI_ERROR_DEVICE_HUNG (0x887A0006) even with separate preludes.

Change

  • crates/victory-gpu/src/host.rs:
    • Flush run_deferred(&mut batch) across runs up front, then partition runs into contiguous duplicate-free slices inside Host::execute, running list.prelude() -> ExecuteCommandLists -> fence Signal + WaitForSingleObject per slice.
    • Non-duplicate submissions (the common case) execute in a single batch with zero extra fence waits or allocations.
    • Added GPU regression test host::tests::duplicate_list_in_submission_runs_without_clobbering_prelude submitting [&list_a, &list_b, &list_a] twice in a row with intervening texture state changes (COMMON -> COPY_DEST -> RENDER_TARGET -> PIXEL_SHADER_RESOURCE).

Verification

Hardware: Intel Core i9-14900HX, NVIDIA GeForce RTX 4060 Laptop GPU (driver 32.0.16.1656), Windows 11 x64 (10.0.26100), rustc 1.98.1.

  • cargo clippy --workspace --locked -- -D warnings: pass
  • cargo clippy --workspace --all-features --locked -- -D warnings: pass
  • cargo test -p victory-gpu --locked: 51 passed, 0 failed, 1 ignored (texture_checks_per_submission)
  • cargo test -p victory-gpu --all-features --locked: 54 passed, 0 failed, 1 ignored
  • cargo test -p xtask --locked: 4 passed, 0 failed (includes repository_passes_policy)
  • cargo test --workspace --locked -- --skip v_med3_f32_matches_rdna2_with_nan: passed (v_med3_f32_matches_rdna2_with_nan fails at baseline on NVIDIA as tracked in #726 / #745)
  • git diff --check: clean

AI Disclosure

Prepared, implemented, tested, and verified locally with Antigravity (Google DeepMind); no proprietary game assets, bytes, or dumps were used or included.

<!-- greyfinch-sync:Marvisak/VIctory:issue:6587917793 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/1400). Originally posted by [piyonchu](https://github.com/piyonchu) on 2026-11-24T17:45:52Z. --- ### Summary Fixes a D3D12 prelude-clobbering and duplicate-command-list submission bug when the same `HostList` appears more than once in `Host::execute(runs)`. ### Cause `HostList` owns a single `(allocator, list)` pair in `self.prelude`. Previously `Host::execute` iterated every entry of `runs`, called `list.prelude()`, and appended the returned `ID3D12CommandList` to one `lists` slice passed to a single `ExecuteCommandLists` batch: 1. Calling `list.prelude()` a second time on the same `HostList` in the same `runs` slice reset its `allocator` and `list`, overwriting the barriers recorded for the first occurrence before `ExecuteCommandLists` ran. 2. Submitting the same closed `ID3D12GraphicsCommandList` twice in one `ExecuteCommandLists` batch violates D3D12 batch uniqueness and triggers `DXGI_ERROR_DEVICE_HUNG` (`0x887A0006`) even with separate preludes. ### Change - **`crates/victory-gpu/src/host.rs`**: - Flush `run_deferred(&mut batch)` across `runs` up front, then partition `runs` into contiguous duplicate-free slices inside `Host::execute`, running `list.prelude()` -> `ExecuteCommandLists` -> fence `Signal` + `WaitForSingleObject` per slice. - Non-duplicate submissions (the common case) execute in a single batch with zero extra fence waits or allocations. - Added GPU regression test `host::tests::duplicate_list_in_submission_runs_without_clobbering_prelude` submitting `[&list_a, &list_b, &list_a]` twice in a row with intervening texture state changes (`COMMON -> COPY_DEST -> RENDER_TARGET -> PIXEL_SHADER_RESOURCE`). ### Verification Hardware: Intel Core i9-14900HX, NVIDIA GeForce RTX 4060 Laptop GPU (driver `32.0.16.1656`), Windows 11 x64 (`10.0.26100`), `rustc 1.98.1`. - `cargo clippy --workspace --locked -- -D warnings`: pass - `cargo clippy --workspace --all-features --locked -- -D warnings`: pass - `cargo test -p victory-gpu --locked`: 51 passed, 0 failed, 1 ignored (`texture_checks_per_submission`) - `cargo test -p victory-gpu --all-features --locked`: 54 passed, 0 failed, 1 ignored - `cargo test -p xtask --locked`: 4 passed, 0 failed (includes `repository_passes_policy`) - `cargo test --workspace --locked -- --skip v_med3_f32_matches_rdna2_with_nan`: passed (`v_med3_f32_matches_rdna2_with_nan` fails at baseline on NVIDIA as tracked in #726 / #745) - `git diff --check`: clean ### AI Disclosure Prepared, implemented, tested, and verified locally with Antigravity (Google DeepMind); no proprietary game assets, bytes, or dumps were used or included.
piyonchu commented 2026-11-25 01:08:22 +00:00 (Migrated from github.com)

Imported from Marvisak/VIctory. Originally posted by piyonchu on 2026-11-25T01:06:14Z.


Closing #1400 in favor of #1414, which solves the same duplicate-HostList ExecuteCommandLists submission bug (with the same batch-splitting boundary approach) and already has maintainer/contributor reviews across multiple GPUs and #595 coordination.

<!-- greyfinch-sync:Marvisak/VIctory:comment:7149208510 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/1400#issuecomment-7149208510). Originally posted by [piyonchu](https://github.com/piyonchu) on 2026-11-25T01:06:14Z. --- Closing `#1400` in favor of `#1414`, which solves the same duplicate-`HostList` `ExecuteCommandLists` submission bug (with the same batch-splitting boundary approach) and already has maintainer/contributor reviews across multiple GPUs and `#595` coordination.
upstream-sync closed this pull request 2026-11-25 02:04:09 +00:00

Pull request closed

Sign in to join this conversation.
No reviewers
No labels
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.

Reference
Marvisak/VIctory!1400
No description provided.