D3D12.X: reclaim ON_QUEUE uploads across all queues and clean up on release #2912

Open
github-bot wants to merge 1 commit from github-bot/gh-2912 into amd-dev AGit
Owner

@⁠real-alponzo on GitHub · 2026-11-26 22:55 UTC · original
real-alponzo:fix/amd-on-queue-reclaim → amd-dev · +69 −13 · 2 files · 1 commits · open

Reclaim completed ON_QUEUE texture upload batches across all tracked title queues and remove released queues from ON_QUEUE in q_release.

Why

  • reclaim_completed_on_queue previously only polled the submitting queue_key, allowing completed upload batches on idle or secondary command queues to keep staging buffers pinned until those queues uploaded again.
  • q_release cleaned up list_x state for the released queue but left its entry in title_textures::ON_QUEUE, leaking its ID3D12Fence and any InFlight staging buffers (up to 512 MiB) and risking pointer-reuse ABA if a later queue is allocated at the same address.

What is in it

  • Updated reclaim_completed_on_queue in crates/xcl/src/hle/d3d12x/title_textures.rs to drain completed batches across all tracked queues via drain_completed.
  • Added title_textures::on_queue_release(queue_key) and wired it into q_release in crates/xcl/src/hle/d3d12x/real.rs.
  • Added unit tests drain_completed_reclaims_only_finished_batches and on_queue_release_removes_tracked_queue_entry.

Regression run

Base (main):

xcl-smoke v1
commit: 8b957bec6f82495aec940944c6bf47faa02db590
gpu: AMD Radeon RX 6800
title: 6ca5cab7
seconds: 60
exit: 0x0
frames shown: 1525 (PresentX 1525)
presents per 2 s (last 3): 60 61 59
device removals: 0
crashes: 0
peak commit: 14867 MB

PR head (baaf024d):

xcl-smoke v1
commit: baaf024d2c0b3c19c2944ce45c501ab768896e4c
gpu: AMD Radeon RX 6800
title: 6ca5cab7
seconds: 60
exit: 0x0
frames shown: 1540 (PresentX 1540)
presents per 2 s (last 3): 60 60 60
device removals: 0
crashes: 0
peak commit: 14871 MB

Tested

  • Hardware: Windows 11 Pro for Workstations x64 (Build 26300), Intel Core i9-9900K, 32 GB RAM, AMD Radeon RX 6800 (Driver 32.0.21045.29003), rustc 1.100.0, DXC 1.9.2602.17.
  • cargo test -p xcl --lib drain_completed_reclaims -- --nocapture: 1 passed; 0 failed; 0 ignored; 1695 filtered out.
  • cargo test -p xcl --lib on_queue_release_removes -- --nocapture: 1 passed; 0 failed; 0 ignored; 1695 filtered out.
  • .\scripts\smoke.ps1 -Game "C:\VIctory-SSD-test\game" -Seconds 60 on 8b957bec and baaf024d (blocks above).

Not tested

  • Full cargo test --workspace on amd-dev (note amd-dev has pre-existing no-GPU CI test failures unrelated to this change).
  • Multi-hour soak verifying peak staging memory reduction across secondary queues.

AI use

  • Antigravity (Gemini 4 Neon) identified the missing cross-queue reclaim and q_release cleanup, implemented the fix and unit tests, ran the tests and paired smoke runs, and drafted this PR description.
**@⁠real-alponzo** on GitHub · 2026-11-26 22:55 UTC · [original](https://github.com/xcl-dev/xcl/pull/2912) `real-alponzo:fix/amd-on-queue-reclaim` → `amd-dev` · +69 −13 · 2 files · 1 commits · open Reclaim completed `ON_QUEUE` texture upload batches across all tracked title queues and remove released queues from `ON_QUEUE` in `q_release`. **Why** - `reclaim_completed_on_queue` previously only polled the submitting `queue_key`, allowing completed upload batches on idle or secondary command queues to keep staging buffers pinned until those queues uploaded again. - `q_release` cleaned up `list_x` state for the released queue but left its entry in `title_textures::ON_QUEUE`, leaking its `ID3D12Fence` and any `InFlight` staging buffers (up to 512 MiB) and risking pointer-reuse ABA if a later queue is allocated at the same address. **What is in it** - Updated `reclaim_completed_on_queue` in `crates/xcl/src/hle/d3d12x/title_textures.rs` to drain completed batches across all tracked queues via `drain_completed`. - Added `title_textures::on_queue_release(queue_key)` and wired it into `q_release` in `crates/xcl/src/hle/d3d12x/real.rs`. - Added unit tests `drain_completed_reclaims_only_finished_batches` and `on_queue_release_removes_tracked_queue_entry`. **Regression run** Base (`main`): ``` xcl-smoke v1 commit: 8b957bec6f82495aec940944c6bf47faa02db590 gpu: AMD Radeon RX 6800 title: 6ca5cab7 seconds: 60 exit: 0x0 frames shown: 1525 (PresentX 1525) presents per 2 s (last 3): 60 61 59 device removals: 0 crashes: 0 peak commit: 14867 MB ``` PR head (`baaf024d`): ``` xcl-smoke v1 commit: baaf024d2c0b3c19c2944ce45c501ab768896e4c gpu: AMD Radeon RX 6800 title: 6ca5cab7 seconds: 60 exit: 0x0 frames shown: 1540 (PresentX 1540) presents per 2 s (last 3): 60 60 60 device removals: 0 crashes: 0 peak commit: 14871 MB ``` **Tested** - Hardware: Windows 11 Pro for Workstations x64 (Build 26300), Intel Core i9-9900K, 32 GB RAM, AMD Radeon RX 6800 (Driver 32.0.21045.29003), `rustc 1.100.0`, DXC 1.9.2602.17. - `cargo test -p xcl --lib drain_completed_reclaims -- --nocapture`: `1 passed; 0 failed; 0 ignored; 1695 filtered out`. - `cargo test -p xcl --lib on_queue_release_removes -- --nocapture`: `1 passed; 0 failed; 0 ignored; 1695 filtered out`. - `.\scripts\smoke.ps1 -Game "C:\VIctory-SSD-test\game" -Seconds 60` on `8b957bec` and `baaf024d` (blocks above). **Not tested** - Full `cargo test --workspace` on `amd-dev` (note `amd-dev` has pre-existing no-GPU CI test failures unrelated to this change). - Multi-hour soak verifying peak staging memory reduction across secondary queues. **AI use** - Antigravity (Gemini 4 Neon) identified the missing cross-queue reclaim and `q_release` cleanup, implemented the fix and unit tests, ran the tests and paired smoke runs, and drafted this PR description.
reclaim_completed_on_queue now drains completed InFlight batches across
all tracked title queues so idle/secondary queues do not pin staging
buffers. Also remove released queues from ON_QUEUE in q_release to avoid
leaking fences/staging buffers and pointer-reuse ABA.

Assisted-by: Antigravity (Gemini 4 Neon)
github-bot locked as GitHub sync and limited conversation to collaborators 2026-11-27 01:15:50 +00:00
Author
Owner

@⁠DarkPanda69 on GitHub · 2026-11-26 23:16 UTC · original

RDNA4 run next to your RX 6800 one: the two new tests pass, and the PR adds no failure. One title_textures test already fails on amd-dev without the PR.

Tested: head baaf024 applied on its base amd-dev bf7c82e, debug, Rust 1.100.0, Windows 11 Pro 26200, Ryzen 7 5800X, AMD RX 9070 XT (RDNA4), driver 32.0.32029.2010.

  • cargo test -p xcl --lib -- drain_completed_reclaims_only_finished_batches on_queue_release_removes_tracked_queue_entry --nocapture: 2 passed, 0 failed, 0 SKIPPED.
  • cargo test -p xcl --lib -- title_textures, 3 runs at --test-threads=4 and 1 at --test-threads=1:
    • this PR: 35 passed, 1 failed every time;
    • amd-dev alone: 33 passed, 1 failed every time (and one of the 4-thread runs also had gpu_uploads_on_the_title_queue_run_before_its_later_work_and_are_released and placed_title_textures_share_vram_and_preserve_pixels fail).

The one that fails with and without the PR, also single-threaded (panic text from the amd-dev-alone run):

title_bytes_are_used_in_place_when_all_are_readable
panicked at crates\xcl\src\hle\d3d12x\title_textures.rs:2905:13:
a committed page is not copied

The new tests make their device with D3D12CreateDevice(None, ..), so they ran on the first adapter, the RX 9070 XT here.

Not tested: the full workspace suite, a soak or title run, NVIDIA (these tests don't follow XCL_ADAPTER), Intel.

AI use: Claude Code (Claude Opus 5.5) ran the tests on this machine and wrote this report.

**@⁠DarkPanda69** on GitHub · 2026-11-26 23:16 UTC · [original](https://github.com/xcl-dev/xcl/pull/2912#issuecomment-7205403420) RDNA4 run next to your RX 6800 one: the two new tests pass, and the PR adds no failure. One `title_textures` test already fails on `amd-dev` without the PR. **Tested:** head `baaf024` applied on its base `amd-dev` `bf7c82e`, debug, Rust 1.100.0, Windows 11 Pro 26200, Ryzen 7 5800X, AMD RX 9070 XT (RDNA4), driver 32.0.32029.2010. - `cargo test -p xcl --lib -- drain_completed_reclaims_only_finished_batches on_queue_release_removes_tracked_queue_entry --nocapture`: 2 passed, 0 failed, 0 SKIPPED. - `cargo test -p xcl --lib -- title_textures`, 3 runs at `--test-threads=4` and 1 at `--test-threads=1`: - this PR: 35 passed, 1 failed every time; - `amd-dev` alone: 33 passed, 1 failed every time (and one of the 4-thread runs also had `gpu_uploads_on_the_title_queue_run_before_its_later_work_and_are_released` and `placed_title_textures_share_vram_and_preserve_pixels` fail). The one that fails with and without the PR, also single-threaded (panic text from the `amd-dev`-alone run): ``` title_bytes_are_used_in_place_when_all_are_readable panicked at crates\xcl\src\hle\d3d12x\title_textures.rs:2905:13: a committed page is not copied ``` The new tests make their device with `D3D12CreateDevice(None, ..)`, so they ran on the first adapter, the RX 9070 XT here. **Not tested:** the full workspace suite, a soak or title run, NVIDIA (these tests don't follow `XCL_ADAPTER`), Intel. AI use: Claude Code (Claude Opus 5.5) ran the tests on this machine and wrote this report.
Author
Owner

@⁠vibryxcx on GitHub · 2026-11-27 00:08 UTC · original · edited 2026-11-27 03:30 UTC

Title run on RDNA2 (the report above ran unit tests only): the 60 s pair is fine, but in 300 s runs this head lost the device in 2 of 2 runs, and its base in 0 of 2. There is also one review point in on_queue_release that could explain a GPU-side problem. I have not shown that it does.

Setup: AMD Radeon RX 6800 (driver 32.0.21045.5002), i5-10600KF, 32 GB, Windows 11 Pro 26200, release. Head baaf024d vs its base amd-dev bf7c82ee, each in its own worktree with no uncommitted changes. Same retail title, warm caches.

Regression run (60 s, after one warm-up run of base)

xcl-smoke v1
commit: bf7c82ee1b2685bb40417e09c4128177aa68d719
gpu: AMD Radeon RX 6800
title: 2c508222
seconds: 60
exit: 0x0
frames shown: 1288 (PresentX 1288)
presents per 2 s (last 3): 64 61 60
device removals: 0
crashes: 0
peak commit: 13650 MB
xcl-smoke v1
commit: baaf024d2c0b3c19c2944ce45c501ab768896e4c
gpu: AMD Radeon RX 6800
title: 2c508222
seconds: 60
exit: 0x0
frames shown: 1321 (PresentX 1321)
presents per 2 s (last 3): 60 60 64
device removals: 0
crashes: 0
peak commit: 13282 MB

300 s, XCL_PRESS_A_AT every 10 s, alternating base / head

run tree result peak commit
1 bf7c82ee ran to 300 s, 2410 frames 30652 MB
1 baaf024d 0x887a0006 at 239 s 28837 MB
2 (XCL_DRED=1) bf7c82ee ran to 300 s, 2246 frames 32156 MB
2 (XCL_DRED=1) baaf024d 0x887a0006 at 273 s 27330 MB
  • Both removals are hangs, not page faults: queues stopped for 3-6 s with work pending (title queues, sparse, vram pages, and in run 2 the sparse readback queue too), and XCL_DRED=1 logged no fault.
  • Two runs per side is not a lot, and bf7c82ee itself is not stable on this card (#2874). But the split is 2/2 against 0/2 at the same point in the title.
  • Peak commit is lower on the head (by 1.8 and 4.8 GB), but those runs also ended 30-60 s earlier.

Review point: on_queue_release drops buffers the GPU may still be copying from.

  • release_taking_first runs its take closure before the original Release when the count was 1. So title_textures::on_queue_release removes the queue's QueueUploads (its in_flight texture::InFlight staging buffers) before the queue goes away, with no check of q.fence against q.value.
  • If an upload batch is still queued, its staging buffer is freed while the copy is pending. This is the same class of bug as the one #2842 fixes for readback jobs.
  • Keeping only the entries whose fence has completed, or waiting on q.fence for q.value (bounded) before removing the entry, would close it.
  • I did not prove that this is what hangs the runs above: the log does not say when a title queue is released.

Reclaim across all queues. reclaim_completed_on_queue now locks ON_QUEUE and calls GetCompletedValue on every tracked queue on each call. That seems fine for a handful of queues. I note it only because the function keeps its _queue_key parameter and its old name.

Not tested: the full suite on this head; whether the hang is in the release path or the cross-queue reclaim (no per-queue logging); NVIDIA.

AI use: Claude Code (Claude Opus 5.5) read the diff, ran the builds and title runs, read the logs and wrote this comment. The numbers come from those runs on the hardware above.


Correction, after a soak of the base: bf7c82ee alone (same title, same settings, A every 10 s) lost the device in 3 of 3 600 s runs: 0x887a0006 at 226 s, then 0x887a0007 at 407 s and at 380 s. The last two were followed by the title's own int3 at game_scarlett_master.exe+0x2474606. With the two 300 s base runs above that survived, the base lost the device in 3 of 5 runs. So the 2 of 2 on this head does not show that this PR causes the hangs: on this card the base hangs about as often. The review point about on_queue_release stands on its own; it does not depend on these runs.


Update: full lib suite on this head (baaf024d, RX 6800, debug, cargo test -p xcl --lib -- --test-threads=1, with the tests skipped that hang or abort only inside the full amd-dev run, see #42): 1654 passed, 11 failed, 27 ignored. Against base bf7c82ee run the same way (1651 / 12 / 27), the two new tests (drain_completed_reclaims_only_finished_batches, on_queue_release_removes_tracked_queue_entry) pass. The only failure that changed is gpu_uploads_on_the_title_queue_run_before_its_later_work_and_are_released, which passed here, and it is the known flaky one on this card (#2842). No failure is new on this head. The review point about on_queue_release is unchanged: as @⁠pickles976 noted, the new test uses an empty in_flight, so it cannot catch it.

**@⁠vibryxcx** on GitHub · 2026-11-27 00:08 UTC · [original](https://github.com/xcl-dev/xcl/pull/2912#issuecomment-7206204146) · edited 2026-11-27 03:30 UTC Title run on RDNA2 (the report above ran unit tests only): **the 60 s pair is fine, but in 300 s runs this head lost the device in 2 of 2 runs, and its base in 0 of 2.** There is also one review point in `on_queue_release` that could explain a GPU-side problem. I have not shown that it does. **Setup:** AMD Radeon RX 6800 (driver 32.0.21045.5002), i5-10600KF, 32 GB, Windows 11 Pro 26200, release. Head `baaf024d` vs its base `amd-dev` `bf7c82ee`, each in its own worktree with no uncommitted changes. Same retail title, warm caches. **Regression run** (60 s, after one warm-up run of base) ``` xcl-smoke v1 commit: bf7c82ee1b2685bb40417e09c4128177aa68d719 gpu: AMD Radeon RX 6800 title: 2c508222 seconds: 60 exit: 0x0 frames shown: 1288 (PresentX 1288) presents per 2 s (last 3): 64 61 60 device removals: 0 crashes: 0 peak commit: 13650 MB ``` ``` xcl-smoke v1 commit: baaf024d2c0b3c19c2944ce45c501ab768896e4c gpu: AMD Radeon RX 6800 title: 2c508222 seconds: 60 exit: 0x0 frames shown: 1321 (PresentX 1321) presents per 2 s (last 3): 60 60 64 device removals: 0 crashes: 0 peak commit: 13282 MB ``` **300 s, `XCL_PRESS_A_AT` every 10 s, alternating base / head** | run | tree | result | peak commit | |---|---|---|---:| | 1 | `bf7c82ee` | ran to 300 s, 2410 frames | 30652 MB | | 1 | `baaf024d` | **`0x887a0006` at 239 s** | 28837 MB | | 2 (`XCL_DRED=1`) | `bf7c82ee` | ran to 300 s, 2246 frames | 32156 MB | | 2 (`XCL_DRED=1`) | `baaf024d` | **`0x887a0006` at 273 s** | 27330 MB | - Both removals are hangs, not page faults: queues stopped for 3-6 s with work pending (title queues, sparse, vram pages, and in run 2 the sparse readback queue too), and `XCL_DRED=1` logged no fault. - Two runs per side is not a lot, and `bf7c82ee` itself is not stable on this card (#2874). But the split is 2/2 against 0/2 at the same point in the title. - Peak commit is lower on the head (by 1.8 and 4.8 GB), but those runs also ended 30-60 s earlier. **Review point: `on_queue_release` drops buffers the GPU may still be copying from.** - `release_taking_first` runs its `take` closure *before* the original `Release` when the count was 1. So `title_textures::on_queue_release` removes the queue's `QueueUploads` (its `in_flight` `texture::InFlight` staging buffers) before the queue goes away, with no check of `q.fence` against `q.value`. - If an upload batch is still queued, its staging buffer is freed while the copy is pending. This is the same class of bug as the one #2842 fixes for readback jobs. - Keeping only the entries whose fence has completed, or waiting on `q.fence` for `q.value` (bounded) before removing the entry, would close it. - I did not prove that this is what hangs the runs above: the log does not say when a title queue is released. **Reclaim across all queues.** `reclaim_completed_on_queue` now locks `ON_QUEUE` and calls `GetCompletedValue` on every tracked queue on each call. That seems fine for a handful of queues. I note it only because the function keeps its `_queue_key` parameter and its old name. **Not tested:** the full suite on this head; whether the hang is in the release path or the cross-queue reclaim (no per-queue logging); NVIDIA. AI use: Claude Code (Claude Opus 5.5) read the diff, ran the builds and title runs, read the logs and wrote this comment. The numbers come from those runs on the hardware above. --- **Correction, after a soak of the base:** `bf7c82ee` alone (same title, same settings, A every 10 s) lost the device in **3 of 3** 600 s runs: `0x887a0006` at 226 s, then `0x887a0007` at 407 s and at 380 s. The last two were followed by the title's own `int3` at `game_scarlett_master.exe+0x2474606`. With the two 300 s base runs above that survived, the base lost the device in 3 of 5 runs. So the 2 of 2 on this head **does not show that this PR causes the hangs**: on this card the base hangs about as often. The review point about `on_queue_release` stands on its own; it does not depend on these runs. --- **Update: full lib suite on this head** (`baaf024d`, RX 6800, debug, `cargo test -p xcl --lib -- --test-threads=1`, with the tests skipped that hang or abort only inside the full `amd-dev` run, see #42): **1654 passed, 11 failed, 27 ignored**. Against base `bf7c82ee` run the same way (1651 / 12 / 27), the two new tests (`drain_completed_reclaims_only_finished_batches`, `on_queue_release_removes_tracked_queue_entry`) pass. The only failure that changed is `gpu_uploads_on_the_title_queue_run_before_its_later_work_and_are_released`, which passed here, and it is the known flaky one on this card (#2842). No failure is new on this head. The review point about `on_queue_release` is unchanged: as @⁠pickles976 noted, the new test uses an empty `in_flight`, so it cannot catch it.
Author
Owner

@⁠JJAutoCompare on GitHub · 2026-11-27 01:00 UTC · original

Tested

Clean baaf024d2c0b3c19c2944ce45c501ab768896e4c, Windows 11 build 26200.9974, Ryzen 7 3800X, Intel Arc A770 driver 32.0.101.9175, Rust 1.100.0 MSVC debug. Used synthetic inputs. Built the libtest artifact with Cargo restricted to two jobs outside the shared GPU lock. With XCL_ADAPTER=A770 XCL_NETWORK=0, ran these libtest filters separately under the lock with --exact --test-threads=1 --nocapture.

  • hle::d3d12x::title_textures::tests::gpu_uploads_on_the_title_queue_run_before_its_later_work_and_are_released: later queue work read back the uploaded pixels and tracked upload bytes cleared after completion.
  • gpu::texture::tests::gpu_large_mixed_upload_keeps_tight_staging_and_exact_pixels: the 138,412,032-byte RGBA8/BC7 request grew staging capacity from 134,217,728 to 150,994,944 bytes, reused it on repeat and read back exact bytes.

Both passed with zero failures, ignores or skips. Both logged the Arc A770 backend. The executable SHA-256 matched before, under and after the lock.

Not tested

A submit on one queue reclaiming completed uploads from a second tracked queue, final release with an upload pending, aggregate staging-pool totals during rendering, full workspace suite and retail smoke. These Arc results do not exercise the reported RX 6800 device hangs.

AI use

T3 Code / Codex (gpt-6.2-sol for the worker run) built and ran the existing tests. Codex in the coordinator session independently reran these two and drafted this report.

**@⁠JJAutoCompare** on GitHub · 2026-11-27 01:00 UTC · [original](https://github.com/xcl-dev/xcl/pull/2912#issuecomment-7206934548) **Tested** Clean `baaf024d2c0b3c19c2944ce45c501ab768896e4c`, Windows 11 build 26200.9974, Ryzen 7 3800X, Intel Arc A770 driver 32.0.101.9175, Rust 1.100.0 MSVC debug. Used synthetic inputs. Built the libtest artifact with Cargo restricted to two jobs outside the shared GPU lock. With `XCL_ADAPTER=A770 XCL_NETWORK=0`, ran these libtest filters separately under the lock with `--exact --test-threads=1 --nocapture`. - `hle::d3d12x::title_textures::tests::gpu_uploads_on_the_title_queue_run_before_its_later_work_and_are_released`: later queue work read back the uploaded pixels and tracked upload bytes cleared after completion. - `gpu::texture::tests::gpu_large_mixed_upload_keeps_tight_staging_and_exact_pixels`: the 138,412,032-byte RGBA8/BC7 request grew staging capacity from 134,217,728 to 150,994,944 bytes, reused it on repeat and read back exact bytes. Both passed with zero failures, ignores or skips. Both logged the Arc A770 backend. The executable SHA-256 matched before, under and after the lock. **Not tested** A submit on one queue reclaiming completed uploads from a second tracked queue, final release with an upload pending, aggregate staging-pool totals during rendering, full workspace suite and retail smoke. These Arc results do not exercise the reported RX 6800 device hangs. **AI use** T3 Code / Codex (`gpt-6.2-sol` for the worker run) built and ran the existing tests. Codex in the coordinator session independently reran these two and drafted this report.
Author
Owner

@⁠pickles976 on GitHub · 2026-11-27 01:33 UTC · original

Pending upload lifetime concern at baaf024d2c0b3c19c2944ce45c501ab768896e4c (source review, no title/test run).

The new cross-queue completed-batch drain checks each fence and looks appropriate for reclaiming idle-queue staging. The final-release hook needs the same ownership protection:

  1. q_release / release_taking_first ordinarily runs its cleanup closure before the native final Release.
  2. title_textures::on_queue_release unconditionally removes QueueUploads, including all unfinished in_flight batches, without checking their fence values or transferring ownership.
  3. texture::InFlight explicitly requires retention until submission completion. Dropping it returns small staging buffers to the reusable pool and frees oversized ones, as well as releasing its allocator/list.

[INFERENCE] If final queue release occurs while an upload is pending, staging can therefore become reusable/freed before its consumer completes. This is independent of whether native queue destruction might subsequently wait. I have not reproduced GPU corruption/device removal, and am not attributing other reporters' device removals to this path.

The new on_queue_release_removes_tracked_queue_entry uses an empty in_flight deque, so it cannot detect the lifetime problem.

Suggested correction: remove the queue-address entry immediately to avoid stale-address reuse, but transfer unfinished batches and their fence/value into fence-owned retirement; reclaim only after completion or an explicitly handled device-teardown path. Do not block waiting while holding ON_QUEUE's mutex. Add a deterministic pending-fence/drop-or-reuse regression proving staging stays retained after queue cleanup and becomes reclaimable only after completion. That is the useful next memory gate here, rather than another long title run.

Actual PR base is amd-dev bf7c82ee1b2685bb40417e09c4128177aa68d719; this review does not establish compatibility with our separate stock-vkd3d integration. AI-assisted review: omp (openai-codex/gpt-6-astra); the cited ownership/release code was inspected directly.

**@⁠pickles976** on GitHub · 2026-11-27 01:33 UTC · [original](https://github.com/xcl-dev/xcl/pull/2912#issuecomment-7207381016) **Pending upload lifetime concern at `baaf024d2c0b3c19c2944ce45c501ab768896e4c` (source review, no title/test run).** The new cross-queue completed-batch drain checks each fence and looks appropriate for reclaiming idle-queue staging. The final-release hook needs the same ownership protection: 1. [`q_release` / `release_taking_first`](https://github.com/xcl-dev/xcl/blob/baaf024d2c0b3c19c2944ce45c501ab768896e4c/crates/xcl/src/hle/d3d12x/real.rs#L9232-L9260) ordinarily runs its cleanup closure before the native final Release. 2. [`title_textures::on_queue_release`](https://github.com/xcl-dev/xcl/blob/baaf024d2c0b3c19c2944ce45c501ab768896e4c/crates/xcl/src/hle/d3d12x/title_textures.rs#L1614-L1621) unconditionally removes `QueueUploads`, including all unfinished `in_flight` batches, without checking their fence values or transferring ownership. 3. [`texture::InFlight`](https://github.com/xcl-dev/xcl/blob/baaf024d2c0b3c19c2944ce45c501ab768896e4c/crates/xcl/src/gpu/texture.rs#L582-L596) explicitly requires retention until submission completion. Dropping it returns small staging buffers to the reusable pool and frees oversized ones, as well as releasing its allocator/list. [INFERENCE] If final queue release occurs while an upload is pending, staging can therefore become reusable/freed before its consumer completes. This is independent of whether native queue destruction might subsequently wait. I have not reproduced GPU corruption/device removal, and am **not attributing other reporters' device removals to this path**. The new [`on_queue_release_removes_tracked_queue_entry`](https://github.com/xcl-dev/xcl/blob/baaf024d2c0b3c19c2944ce45c501ab768896e4c/crates/xcl/src/hle/d3d12x/title_textures.rs#L3978-L3992) uses an empty `in_flight` deque, so it cannot detect the lifetime problem. Suggested correction: remove the queue-address entry immediately to avoid stale-address reuse, but transfer unfinished batches and their fence/value into fence-owned retirement; reclaim only after completion or an explicitly handled device-teardown path. Do not block waiting while holding `ON_QUEUE`'s mutex. Add a deterministic pending-fence/drop-or-reuse regression proving staging stays retained after queue cleanup and becomes reclaimable only after completion. That is the useful next memory gate here, rather than another long title run. Actual PR base is `amd-dev` `bf7c82ee1b2685bb40417e09c4128177aa68d719`; this review does not establish compatibility with our separate stock-vkd3d integration. AI-assisted review: omp (`openai-codex/gpt-6-astra`); the cited ownership/release code was inspected directly.
This pull request has changes conflicting with the target branch.
  • crates/xcl/src/hle/d3d12x/title_textures.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/2912/head:github-bot/gh-2912'
git switch 'github-bot/gh-2912'

Merge

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