D3D12.X: drain present queue after Present before ResizeBuffers #711

Open
github-bot wants to merge 1 commit from github-bot/gh-711 into main AGit
Owner

@⁠RandomGithub12309 on GitHub · 2026-11-24 03:59 UTC · original
RandomGithub12309:d3d12x/drain-present-before-resize → main · +305 −35 · 1 files · 1 commits · open

Fix a pre-existing swap-chain synchronization bug on main (surfaced during review of #674; isolated here from #674's triple-buffering change) where q.Signal(&p.fence, p.value) ran before sc.Present(0, DXGI_PRESENT(0)) and ensure_swapchain called sc.ResizeBuffers without draining the present queue first.

Because DXGI's Present submits internal GPU queue work on the swap-chain back buffer after p.fence was signaled, waiting on p.value did not wait for Present to retire. When ResizeBuffers ran (or when present_now moved to another queue), old back-buffer allocations could be freed while still referenced by DXGI's in-flight Present work (D3D12 error 921 / OBJECT_DELETED_WHILE_STILL_IN_USE).

What is in it

  • crates/xcl/src/hle/d3d12x/present.rs:
    • Extract present_frame_on from present_now and move p.value += 1; q.Signal(&p.fence, p.value) after sc.Present(0, DXGI_PRESENT(0)) so p.fence orders behind DXGI's Present queue work (while still signaling when Present returns an error so the submitted copy command list remains fenced).
    • Add drain_queue(p, timeout_ms) to signal a new p.fence value on p.queue, wait via fence::wait, and clear p.copy_source and p.dumps; extract drain_and_reset_for_queue(slot, queue, timeout_ms) for cross-queue switch draining, retaining the old presenter when a drain fails with a non-Removed error (e.g. timeout) so in-flight swap-chain, copy_source, and dump resources stay alive until the GPU finishes.
    • Call drain_queue(p, 2000) before sc.ResizeBuffers(2, ...) in ensure_swapchain (preserving p.disabled |= ... on device removal) and drain_and_reset_for_queue before dropping old on queue switches in present_now.
    • Add FRAME_DUMP_TEST_LOCK and unit/GPU regression tests covering multi-resize + frame dumps (present_and_resize_with_frame_dumps_drains_queue_cleanly), cross-queue switch draining (queue_switch_drains_old_presenter_before_recreating_swapchain), and drain/queue-move timeout retention and ResizeBuffers error recovery (drain_queue_and_resize_error_paths_preserve_in_flight_state).

Tested

  • Hardware: NVIDIA GeForce RTX 5050 Laptop GPU, Intel Core Ultra 7 255HX, Windows 11 Build 26300, rustc 1.100.0 (0ef1bc386 2026-11-09) stable-x86_64-pc-windows-msvc (debug for unit tests, release for smoke.ps1).
  • cargo test -p xcl --lib hle::d3d12x::present -- --test-threads=1 --nocapture at f98dc20: 9 passed, 0 failed, 0 ignored (0 skipped).
  • cargo test --workspace -- --test-threads=4 --skip fuzz_validate_and_gpu at f98dc20: xcl lib 940 passed, 0 failed, 25 ignored (SKIPPED on this adapter: wave64-only GPU tests and pso_measurement_compiles_an_exact_synthetic_record because Windows Developer Mode is off; gpu::dxil::fuzz_tests::fuzz_validate_and_gpu_{0..3} excluded due to pre-existing 0x8007000E CreateComputePipelineState OOM on this adapter).
  • Game checked: 60 s scripts/smoke.ps1 release build at f98dc20 vs main (8e87fc7).

Regression run

xcl-smoke v1
commit: 8e87fc7b62a87ea589ccb9ea6182f514016cf7db
gpu: NVIDIA GeForce RTX 5050 Laptop GPU
title: e61570a3
seconds: 60
exit: 0x0
frames shown: 1603 (PresentX 1603)
presents per 2 s (last 3): 60 60 60
device removals: 0
crashes: 0
peak commit: 14543 MB
xcl-smoke v1
commit: f98dc204d358723e497259e6fd3c8203f4aa146c
gpu: NVIDIA GeForce RTX 5050 Laptop GPU
title: e61570a3
seconds: 60
exit: 0x0
frames shown: 1596 (PresentX 1596)
presents per 2 s (last 3): 60 60 60
device removals: 0
crashes: 0
peak commit: 14538 MB

Not tested

  • D3D12 debug layer on this host (d3d12SDKLayers.dll / Graphics Tools not installed; 0x887A002D), AMD/Intel/wave64 GPUs, Wine/Linux, and gameplay beyond the 60 s smoke window.

AI use

  • Antigravity (Gemini 4 Neon) wrote the initial fix, addressed the queue-move drain timeout review comments, rebased onto main, ran the tests and scripts/smoke.ps1 on the hardware above, and updated this description.
**@⁠RandomGithub12309** on GitHub · 2026-11-24 03:59 UTC · [original](https://github.com/xcl-dev/xcl/pull/711) `RandomGithub12309:d3d12x/drain-present-before-resize` → `main` · +305 −35 · 1 files · 1 commits · open Fix a pre-existing swap-chain synchronization bug on `main` (surfaced during review of #674; isolated here from #674's triple-buffering change) where `q.Signal(&p.fence, p.value)` ran **before** `sc.Present(0, DXGI_PRESENT(0))` and `ensure_swapchain` called `sc.ResizeBuffers` without draining the present queue first. Because DXGI's `Present` submits internal GPU queue work on the swap-chain back buffer after `p.fence` was signaled, waiting on `p.value` did not wait for `Present` to retire. When `ResizeBuffers` ran (or when `present_now` moved to another queue), old back-buffer allocations could be freed while still referenced by DXGI's in-flight `Present` work (D3D12 error `921` / `OBJECT_DELETED_WHILE_STILL_IN_USE`). **What is in it** - `crates/xcl/src/hle/d3d12x/present.rs`: - Extract `present_frame_on` from `present_now` and move `p.value += 1; q.Signal(&p.fence, p.value)` **after** `sc.Present(0, DXGI_PRESENT(0))` so `p.fence` orders behind DXGI's `Present` queue work (while still signaling when `Present` returns an error so the submitted copy command list remains fenced). - Add `drain_queue(p, timeout_ms)` to signal a new `p.fence` value on `p.queue`, wait via `fence::wait`, and clear `p.copy_source` and `p.dumps`; extract `drain_and_reset_for_queue(slot, queue, timeout_ms)` for cross-queue switch draining, retaining the old presenter when a drain fails with a non-`Removed` error (e.g. timeout) so in-flight swap-chain, `copy_source`, and dump resources stay alive until the GPU finishes. - Call `drain_queue(p, 2000)` before `sc.ResizeBuffers(2, ...)` in `ensure_swapchain` (preserving `p.disabled |= ...` on device removal) and `drain_and_reset_for_queue` before dropping `old` on queue switches in `present_now`. - Add `FRAME_DUMP_TEST_LOCK` and unit/GPU regression tests covering multi-resize + frame dumps (`present_and_resize_with_frame_dumps_drains_queue_cleanly`), cross-queue switch draining (`queue_switch_drains_old_presenter_before_recreating_swapchain`), and drain/queue-move timeout retention and `ResizeBuffers` error recovery (`drain_queue_and_resize_error_paths_preserve_in_flight_state`). **Tested** - Hardware: NVIDIA GeForce RTX 5050 Laptop GPU, Intel Core Ultra 7 255HX, Windows 11 Build 26300, `rustc 1.100.0 (0ef1bc386 2026-11-09)` `stable-x86_64-pc-windows-msvc` (debug for unit tests, release for `smoke.ps1`). - `cargo test -p xcl --lib hle::d3d12x::present -- --test-threads=1 --nocapture` at `f98dc20`: **9 passed, 0 failed, 0 ignored** (0 skipped). - `cargo test --workspace -- --test-threads=4 --skip fuzz_validate_and_gpu` at `f98dc20`: `xcl` lib **940 passed, 0 failed, 25 ignored** (`SKIPPED` on this adapter: wave64-only GPU tests and `pso_measurement_compiles_an_exact_synthetic_record` because Windows Developer Mode is off; `gpu::dxil::fuzz_tests::fuzz_validate_and_gpu_{0..3}` excluded due to pre-existing `0x8007000E` `CreateComputePipelineState` OOM on this adapter). - Game checked: 60 s `scripts/smoke.ps1` release build at `f98dc20` vs `main` (`8e87fc7`). **Regression run** ``` xcl-smoke v1 commit: 8e87fc7b62a87ea589ccb9ea6182f514016cf7db gpu: NVIDIA GeForce RTX 5050 Laptop GPU title: e61570a3 seconds: 60 exit: 0x0 frames shown: 1603 (PresentX 1603) presents per 2 s (last 3): 60 60 60 device removals: 0 crashes: 0 peak commit: 14543 MB ``` ``` xcl-smoke v1 commit: f98dc204d358723e497259e6fd3c8203f4aa146c gpu: NVIDIA GeForce RTX 5050 Laptop GPU title: e61570a3 seconds: 60 exit: 0x0 frames shown: 1596 (PresentX 1596) presents per 2 s (last 3): 60 60 60 device removals: 0 crashes: 0 peak commit: 14538 MB ``` **Not tested** - D3D12 debug layer on this host (`d3d12SDKLayers.dll` / Graphics Tools not installed; `0x887A002D`), AMD/Intel/wave64 GPUs, Wine/Linux, and gameplay beyond the 60 s smoke window. **AI use** - Antigravity (Gemini 4 Neon) wrote the initial fix, addressed the queue-move drain timeout review comments, rebased onto `main`, ran the tests and `scripts/smoke.ps1` on the hardware above, and updated this description.
Previously present_now signaled p.fence before sc.Present(0, DXGI_PRESENT(0)), leaving DXGI's internal Present queue work unordered behind p.fence. When ensure_swapchain called sc.ResizeBuffers or present_now moved queues, old swap-chain back buffers could be freed while still in use (D3D12 error 921).

Extract present_frame_on so q.Signal runs after sc.Present (while still fencing submitted copy command lists on Present failure), extract drain_and_reset_for_queue, add drain_queue to wait for all in-flight copy and Present work before ResizeBuffers and queue switches, handle ResizeBuffers device removal via fence::api_error, and add regression tests for dimension/format resizes, queue switches, timeouts, and ResizeBuffers error recovery.

Assisted-by: Antigravity (Gemini 4 Neon)
github-bot locked as GitHub sync and limited conversation to collaborators 2026-11-26 04:30:12 +00:00
Author
Owner

@⁠thehollowedone on GitHub · 2026-11-24 04:07 UTC · original

Tested

I reran the synthetic frame-capture fixture from #674 on the standalone fix 091a941, with the D3D12 debug layer active.

  • One DIRECT queue: 28 presents through three ResizeBuffers calls, with zero D3D12 validation errors.
  • Two DIRECT queues on the same device: two resizes, then a switch to the second queue at the final size change. XCL logged that the swap chain moved to the second queue and created the replacement. All 28 presents completed with zero D3D12 validation errors.

In each run, all 14 BMP captures matched their expected dimensions and all 250,944 sampled pixels matched. Both scratch tests passed 1/1 with no skips. Runtime code was stock.

Windows 11 build 26300, Ryzen 7 9800X3D, RTX 3080 Ti / 621.35, Rust 1.99.1 MSVC, debug. cargo test --offline --locked -p xcl --lib hle::d3d12x::present::scratch_resize::check -- --exact --nocapture --test-threads=1 with XCL_FRAME_DUMP=2.

Not tested

Queue-drain timeout, device removal, and retail performance.

AI use

Codex with GPT-6.2 Sol adapted the scratch fixture, ran the tests, and drafted this report.

**@⁠thehollowedone** on GitHub · 2026-11-24 04:07 UTC · [original](https://github.com/xcl-dev/xcl/pull/711#issuecomment-7121726507) **Tested** I reran the synthetic frame-capture fixture from [#674](https://github.com/ivall/xcl/pull/674#issuecomment-7121097043) on the standalone fix [`091a941`](https://github.com/ivall/xcl/commit/091a9415af324dd6258c3cb7a93a3e864af983e6), with the D3D12 debug layer active. - One DIRECT queue: 28 presents through three `ResizeBuffers` calls, with zero D3D12 validation errors. - Two DIRECT queues on the same device: two resizes, then a switch to the second queue at the final size change. XCL logged that the swap chain moved to the second queue and created the replacement. All 28 presents completed with zero D3D12 validation errors. In each run, all 14 BMP captures matched their expected dimensions and all 250,944 sampled pixels matched. Both scratch tests passed 1/1 with no skips. Runtime code was stock. Windows 11 build 26300, Ryzen 7 9800X3D, RTX 3080 Ti / 621.35, Rust 1.99.1 MSVC, debug. `cargo test --offline --locked -p xcl --lib hle::d3d12x::present::scratch_resize::check -- --exact --nocapture --test-threads=1` with `XCL_FRAME_DUMP=2`. **Not tested** Queue-drain timeout, device removal, and retail performance. **AI use** Codex with GPT-6.2 Sol adapted the scratch fixture, ran the tests, and drafted this report.
Author
Owner

@⁠iggyvilla on GitHub · 2026-11-24 07:53 UTC · original

Read of e21f158 (nothing built or run by me).

Overlap with #674. This is the drain / signal-after-Present part of #674 (present_frame_on, drain_queue, the drain before ResizeBuffers), on the two-buffer presenter. A tree merge of the two heads conflicts in present.rs, so they cannot both land as they stand. If #674 goes first, what #711 has that #674 does not is the |= on p.disabled after a failed drain (present.rs:605, :619; #674 assigns with = at :631, which can clear the disabled that a failed Signal just set) and the test helpers. If #711 goes first, #674 has to drop its copies of the drain hunks.

Queue move. drain_and_reset_for_queue ignores the result of drain_queue(old, 1000) and then sets *slot = None (:657-667). On a timeout that releases the swap chain with a Present still queued, which is the error 921 case this PR exists to remove. Returning false without dropping old when the drain fails with anything but Removed (the p.queue != queue guard then skips that frame) would close it; the same point is on #674.

Tests. assert_no_debug_errors does nothing without the D3D12 debug layer (the PR says 0x887A002D on the author's machine), so a green run shows the fence/drain order but not the 921 itself; a run on a machine with Graphics Tools installed, named in the report, would show it.

AI use: Claude Code, Claude Sonnet 5.5, read the code at the head above; the points are mine.

**@⁠iggyvilla** on GitHub · 2026-11-24 07:53 UTC · [original](https://github.com/xcl-dev/xcl/pull/711#issuecomment-7125492470) Read of `e21f158` (nothing built or run by me). **Overlap with #674.** This is the drain / signal-after-`Present` part of #674 (`present_frame_on`, `drain_queue`, the drain before `ResizeBuffers`), on the two-buffer presenter. A tree merge of the two heads conflicts in `present.rs`, so they cannot both land as they stand. If #674 goes first, what #711 has that #674 does not is the `|=` on `p.disabled` after a failed drain (`present.rs:605`, `:619`; #674 assigns with `=` at `:631`, which can clear the `disabled` that a failed `Signal` just set) and the test helpers. If #711 goes first, #674 has to drop its copies of the drain hunks. **Queue move.** `drain_and_reset_for_queue` ignores the result of `drain_queue(old, 1000)` and then sets `*slot = None` (`:657-667`). On a timeout that releases the swap chain with a `Present` still queued, which is the error 921 case this PR exists to remove. Returning `false` without dropping `old` when the drain fails with anything but `Removed` (the `p.queue != queue` guard then skips that frame) would close it; the same point is on #674. **Tests.** `assert_no_debug_errors` does nothing without the D3D12 debug layer (the PR says `0x887A002D` on the author's machine), so a green run shows the fence/drain order but not the 921 itself; a run on a machine with Graphics Tools installed, named in the report, would show it. **AI use:** Claude Code, Claude Sonnet 5.5, read the code at the head above; the points are mine.
Author
Owner

@⁠iggyvilla on GitHub · 2026-11-24 09:31 UTC · original

Read of e21f158 (nothing built or run by me).

Overlap with #674. This is the drain / signal-after-Present part of #674 (present_frame_on, drain_queue, the drain before ResizeBuffers), on the two-buffer presenter. A tree merge of the two heads conflicts in present.rs, so they cannot both land as they stand. If #674 goes first, what #711 has that #674 does not is the |= on p.disabled after a failed drain (present.rs:605, :619; #674 assigns with = at :631, which can clear the disabled that a failed Signal just set) and the test helpers. If #711 goes first, #674 has to drop its copies of the drain hunks.

Queue move. drain_and_reset_for_queue ignores the result of drain_queue(old, 1000) and then sets *slot = None (:657-667). On a timeout that releases the swap chain with a Present still queued, which is the error 921 case this PR exists to remove. Returning false without dropping old when the drain fails with anything but Removed (the p.queue != queue guard then skips that frame) would close it; the same point is on #674.

Tests. assert_no_debug_errors does nothing without the D3D12 debug layer (the PR says 0x887A002D on the author's machine), so a green run shows the fence/drain order but not the 921 itself; a run on a machine with Graphics Tools installed, named in the report, would show it.

AI use: Claude Code, Claude Sonnet 5.5, read the code at the head above; the points are mine.

**@⁠iggyvilla** on GitHub · 2026-11-24 09:31 UTC · [original](https://github.com/xcl-dev/xcl/pull/711#issuecomment-7127541954) Read of `e21f158` (nothing built or run by me). **Overlap with #674.** This is the drain / signal-after-`Present` part of #674 (`present_frame_on`, `drain_queue`, the drain before `ResizeBuffers`), on the two-buffer presenter. A tree merge of the two heads conflicts in `present.rs`, so they cannot both land as they stand. If #674 goes first, what #711 has that #674 does not is the `|=` on `p.disabled` after a failed drain (`present.rs:605`, `:619`; #674 assigns with `=` at `:631`, which can clear the `disabled` that a failed `Signal` just set) and the test helpers. If #711 goes first, #674 has to drop its copies of the drain hunks. **Queue move.** `drain_and_reset_for_queue` ignores the result of `drain_queue(old, 1000)` and then sets `*slot = None` (`:657-667`). On a timeout that releases the swap chain with a `Present` still queued, which is the error 921 case this PR exists to remove. Returning `false` without dropping `old` when the drain fails with anything but `Removed` (the `p.queue != queue` guard then skips that frame) would close it; the same point is on #674. **Tests.** `assert_no_debug_errors` does nothing without the D3D12 debug layer (the PR says `0x887A002D` on the author's machine), so a green run shows the fence/drain order but not the 921 itself; a run on a machine with Graphics Tools installed, named in the report, would show it. **AI use:** Claude Code, Claude Sonnet 5.5, read the code at the head above; the points are mine.
Author
Owner

@⁠RandomGithub12309 on GitHub · 2026-11-25 00:57 UTC · original · edited 2026-11-25 01:03 UTC

Updated at f98dc20 (rebased onto main 8e87fc7):

  • Addressed @⁠iggyvilla and @⁠gut0to's review on drain_and_reset_for_queue: on a non-Removed drain failure (e.g. timeout), the old presenter and its swap-chain / copy_source / dump resources are now retained and false is returned instead of dropping *slot.
  • Added queue-move drain timeout retention coverage to drain_queue_and_resize_error_paths_preserve_in_flight_state.
  • Stacked #674 cleanly on top of #711 so the two PRs no longer conflict in present.rs.
**@⁠RandomGithub12309** on GitHub · 2026-11-25 00:57 UTC · [original](https://github.com/xcl-dev/xcl/pull/711#issuecomment-7149066092) · edited 2026-11-25 01:03 UTC Updated at `f98dc20` (rebased onto `main` `8e87fc7`): - Addressed @⁠iggyvilla and @⁠gut0to's review on `drain_and_reset_for_queue`: on a non-`Removed` drain failure (e.g. timeout), the old presenter and its swap-chain / `copy_source` / dump resources are now retained and `false` is returned instead of dropping `*slot`. - Added queue-move drain timeout retention coverage to `drain_queue_and_resize_error_paths_preserve_in_flight_state`. - Stacked #674 cleanly on top of #711 so the two PRs no longer conflict in `present.rs`.
Author
Owner

@⁠JJAutoCompare on GitHub · 2026-11-25 06:18 UTC · original

Empirical test report (f98dc204)

Hardware / environment

  • PR #711 head f98dc204d358723e497259e6fd3c8203f4aa146c, detached and clean. Windows 11 Enterprise Evaluation x64, build 26200, non-interactive Session 0, AMD Ryzen 7 3800X.
  • Intel Arc A770, driver 32.0.101.9175. The WARP case explicitly uses the software adapter. The HWND cases use an automatic adapter selection with fallback, despite XCL_ADAPTER=A770.
  • Rust 1.100.0 (0ef1bc386), x86_64-pc-windows-msvc, unoptimized test profile with debuginfo and incremental compilation disabled. DXC 1.9.2609.5 (01b62ad47).

Commands and results

  • cargo test --workspace --no-run exited 0 outside the Arc lock. This compiled the test binaries without running tests.
  • Ran xcl-77aca8ccb20e299f.exe --exact <test> --test-threads=1 --format terse once per test. Each name below starts with hle::d3d12x::present::frame_dump_tests::.
    • Outside the lock, XCL_ADAPTER=NONE_CPU_ONLY: reports_without_frame_dumps_remain_readable exited 0. 1 passed, 0 failed, 0 ignored, 0 skipped.
    • Inside Invoke-ArcTest.ps1 -Test, XCL_ADAPTER=A770 and RUST_TEST_NOCAPTURE=1: mapped_frame_dump_distinguishes_dark_bright_and_undecoded_content exited 0. 1 passed, 0 failed, 0 ignored, 0 skipped.
    • In that same wrapper, present_and_resize_with_frame_dumps_drains_queue_cleanly, queue_switch_drains_old_presenter_before_recreating_swapchain, and drain_queue_and_resize_error_paths_preserve_in_flight_state each exited 0. The wrapper exited 0.
  • Log totals: libtest reported 5 passed, 0 failed, 0 ignored. Three of those passes emitted a case-sensitive SKIPPED line, leaving 2 tests that ran without skipping.

Observed behavior

All three HWND tests skipped at CreateSwapChainForHwnd with 0x887A0022. The resize, queue-switch, and error-path assertions were not reached.

Not tested

Full GPU workspace suite, interactive desktop presentation, and game smoke runs.

AI use: Verified with T3 Code / Codex (gpt-6.2-sol, reasoningEffort: high). Coordinator #2 (T3 Code / Antigravity, gemini-4-neon) verified counts against pr711-focused.log and published.

**@⁠JJAutoCompare** on GitHub · 2026-11-25 06:18 UTC · [original](https://github.com/xcl-dev/xcl/pull/711#issuecomment-7154655566) ### Empirical test report (f98dc204) **Hardware / environment** - PR #711 head `f98dc204d358723e497259e6fd3c8203f4aa146c`, detached and clean. Windows 11 Enterprise Evaluation x64, build 26200, non-interactive Session 0, AMD Ryzen 7 3800X. - Intel Arc A770, driver 32.0.101.9175. The WARP case explicitly uses the software adapter. The HWND cases use an automatic adapter selection with fallback, despite `XCL_ADAPTER=A770`. - Rust 1.100.0 (0ef1bc386), x86_64-pc-windows-msvc, unoptimized test profile with debuginfo and incremental compilation disabled. DXC 1.9.2609.5 (01b62ad47). **Commands and results** - `cargo test --workspace --no-run` exited 0 outside the Arc lock. This compiled the test binaries without running tests. - Ran `xcl-77aca8ccb20e299f.exe --exact <test> --test-threads=1 --format terse` once per test. Each name below starts with `hle::d3d12x::present::frame_dump_tests::`. - Outside the lock, `XCL_ADAPTER=NONE_CPU_ONLY`: `reports_without_frame_dumps_remain_readable` exited 0. 1 passed, 0 failed, 0 ignored, 0 skipped. - Inside `Invoke-ArcTest.ps1 -Test`, `XCL_ADAPTER=A770` and `RUST_TEST_NOCAPTURE=1`: `mapped_frame_dump_distinguishes_dark_bright_and_undecoded_content` exited 0. 1 passed, 0 failed, 0 ignored, 0 skipped. - In that same wrapper, `present_and_resize_with_frame_dumps_drains_queue_cleanly`, `queue_switch_drains_old_presenter_before_recreating_swapchain`, and `drain_queue_and_resize_error_paths_preserve_in_flight_state` each exited 0. The wrapper exited 0. - Log totals: libtest reported 5 passed, 0 failed, 0 ignored. Three of those passes emitted a case-sensitive `SKIPPED ` line, leaving 2 tests that ran without skipping. **Observed behavior** All three HWND tests skipped at `CreateSwapChainForHwnd` with `0x887A0022`. The resize, queue-switch, and error-path assertions were not reached. **Not tested** Full GPU workspace suite, interactive desktop presentation, and game smoke runs. **AI use**: Verified with T3 Code / Codex (gpt-6.2-sol, reasoningEffort: high). Coordinator #2 (T3 Code / Antigravity, gemini-4-neon) verified counts against pr711-focused.log and published.
Author
Owner

@⁠DavidM1911 on GitHub · 2026-11-25 11:54 UTC · original

Verification on RTX 3060 Ti (Windows 11), branch merged with current main:

  • cargo test -p xcl --lib: all passed, 0 failed, ~26 ignored. (Intermittent single-test flake / 0xc0000005 abort under parallel scheduling — tracked in #1978; clean on single-threaded rerun.)

Thanks!

**@⁠DavidM1911** on GitHub · 2026-11-25 11:54 UTC · [original](https://github.com/xcl-dev/xcl/pull/711#issuecomment-7161660707) Verification on RTX 3060 Ti (Windows 11), branch merged with current `main`: - `cargo test -p xcl --lib`: all passed, 0 failed, ~26 ignored. (Intermittent single-test flake / 0xc0000005 abort under parallel scheduling — tracked in #1978; clean on single-threaded rerun.) Thanks!
Author
Owner

@⁠gut0to on GitHub · 2026-11-24 17:13 UTC · original
On crates/xcl/src/hle/d3d12x/present.rs line 662 (outdated):

@@ -624,6 +654,18 @@ unsafe fn ensure_swapchain(p: &mut Presenter, hwnd: HWND, w: u32, h: u32, fmt: D
     }
 }
 
+unsafe fn drain_and_reset_for_queue(slot: &mut Option<Presenter>, queue: usize) -> bool {
+    if !slot.as_ref().is_some_and(|p| p.queue != queue) {
+        return false;
+    }
+    if let Some(old) = slot.as_mut() {
+        let _ = drain_queue(old, 1000);

Could we keep the old presenter until this drain succeeds? If the wait times out, the queue may still be executing the copy or present, but this code drops the presenter immediately, including copy_source and pending dump resources. Those D3D12 resources must stay alive until the GPU finishes using them. Please retain the presenter after a timeout and reset the slot only after a successful drain. AI-assisted review: I checked this path against drain_queue and the presenter-owned resource lifetimes.

**@⁠gut0to** on GitHub · 2026-11-24 17:13 UTC · [original](https://github.com/xcl-dev/xcl/pull/711#discussion_r4683754483) On `crates/xcl/src/hle/d3d12x/present.rs` line 662 (outdated): ```diff @@ -624,6 +654,18 @@ unsafe fn ensure_swapchain(p: &mut Presenter, hwnd: HWND, w: u32, h: u32, fmt: D } } +unsafe fn drain_and_reset_for_queue(slot: &mut Option<Presenter>, queue: usize) -> bool { + if !slot.as_ref().is_some_and(|p| p.queue != queue) { + return false; + } + if let Some(old) = slot.as_mut() { + let _ = drain_queue(old, 1000); ``` Could we keep the old presenter until this drain succeeds? If the wait times out, the queue may still be executing the copy or present, but this code drops the presenter immediately, including `copy_source` and pending dump resources. Those D3D12 resources must stay alive until the GPU finishes using them. Please retain the presenter after a timeout and reset the slot only after a successful drain. AI-assisted review: I checked this path against `drain_queue` and the presenter-owned resource lifetimes.
This pull request has changes conflicting with the target branch.
  • crates/xcl/src/hle/d3d12x/present.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/711/head:github-bot/gh-711'
git switch 'github-bot/gh-711'

Merge

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