Skip to content

D3D12.X: release alloc_pool queue fence on queue release - #1967

Open
n-romanovich wants to merge 1 commit into
xcl-dev:mainfrom
n-romanovich:d3d12x/alloc-pool-release-queue-fence
Open

n-romanovich wants to merge 1 commit into
xcl-dev:mainfrom
n-romanovich:d3d12x/alloc-pool-release-queue-fence

Conversation

@n-romanovich

@n-romanovich n-romanovich commented Nov 25, 2026 •

Copy link
Copy Markdown
Contributor

Fixes #1909.

alloc_pool::State.fences previously retained (ID3D12Fence, u64) per command queue indefinitely with no cleanup when real::q_release released the queue at refcount 0.

This PR adds alloc_pool::on_queue_release(queue), called from real::q_release when n == 0, to drop the queue's retained fence from State.fences and clear any already-completed Backing.marks entries for that queue (while leaving in-flight marks alive until completion/reset).

What is in it

  • crates/xcl/src/hle/d3d12x/alloc_pool.rs: add on_queue_release(queue) and unit test released_queue_drops_retained_fence_from_state.
  • crates/xcl/src/hle/d3d12x/real.rs: call super::alloc_pool::on_queue_release(this as usize) in q_release when n == 0.

Tested
Hardware: Windows 11 x64, NVIDIA GeForce RTX 5060 Ti.

  • cargo test -p xcl --lib alloc_pool -- --test-threads=4: 4 passed, 0 failed, 0 ignored (961 filtered out)
  • cargo test --workspace -- --test-threads=4: 989 passed, 0 failed, 45 ignored
    • SKIPPED: 22 gpu::recomp wave64 / refused per-lane f16 tests (no wave64 / refused per-lane f16), shaders::tests::pso_measurement_compiles_an_exact_synthetic_record (Windows Developer Mode is required, 0x887A002D), heap_window_out_of_memory_falls_back_to_the_switch_form (no heap windows)

Regression run
Main (5478c4a7c1ae5adba127c8d27018d7fdbf3a8725):

xcl-smoke v1
commit: 5478c4a7c1ae5adba127c8d27018d7fdbf3a8725
gpu: NVIDIA GeForce RTX 5060 Ti
title: FILES
seconds: 60
exit: 0x0
frames shown: 1541 (PresentX 1541)
presents per 2 s (last 3): 60 60 60
device removals: 0
crashes: 0
peak commit: 15701 MB

PR (4fffef38d1edb0be45b3c51859b0f711e7f85098):

xcl-smoke v1
commit: 4fffef38d1edb0be45b3c51859b0f711e7f85098
gpu: NVIDIA GeForce RTX 5060 Ti
title: FILES
seconds: 60
exit: 0x0
frames shown: 1533 (PresentX 1534)
presents per 2 s (last 3): 60 60 60
device removals: 0
crashes: 0
peak commit: 14706 MB

Not tested

  • macOS / Linux (crate targets Windows only).
  • AMD / wave64-capable GPU.

AI use

  • Antigravity (model name not provided): implemented the fix and unit test, ran the test suite and smoke.ps1 runs.

@futurepro62

futurepro62 commented Nov 25, 2026 •

Copy link
Copy Markdown

Full-suite run, since this PR has no test report yet. Tested exact head 61db31a (on its base fc14fab).

Tested

  • NVIDIA GeForce RTX 5070 Ti 16 GB (Blackwell, 32-lane waves only, mesh shaders), driver 621.40, Ryzen 7 9800X3D, Windows 11 Home 26300, Rust 1.100.0 MSVC, DXC + dxil.dll 1.9.2602.17 (Windows SDK 10.0.26100), debug, D3D12 debug layer installed.
  • cargo build --workspace, then XCL_REQUIRE_GPU=mesh cargo test --workspace -- --test-threads=4 --skip heap_window_out_of_memory_falls_back_to_the_switch_form --skip gpu::recomp::lower_dxil::tests::f16_programs_on_the_gpu --skip gpu::recomp::lower_dxil::tests::f32_programs_on_the_gpu --skip gpu::recomp::lower_dxil::tests::integer_programs_on_the_gpu --skip gpu::recomp::lower_dxil::tests::f64_programs_on_the_gpu --skip gpu::recomp::lower_dxil::tests::const_and_null_mask_operands_agree_with_hlsl_on_the_gpu --skip gpu::dxil::fuzz_tests: 978 passed, 0 failed, 43 ignored. SKIPPED (no wave64): a_2d_or_3d_group_agrees_with_the_hlsl_path_on_the_gpu, a_per_lane_2d_or_3d_group_runs_on_the_gpu, coalesced_guarded_runs_agree_with_the_hlsl_path_on_the_gpu, cross_lane_reads_agree_with_the_hlsl_path_on_the_gpu, gpu_geometry_wave32_prefix_count_over_a_mask, gpu_wave32_program_in_wave64_hardware, the_wave64_lowering_agrees_with_the_hlsl_path_on_the_gpu.
  • The new tests ran and passed: released_queue_drops_retained_fence_from_state.
  • Same head on the AMD Radeon integrated GPU (iGPU) of the Ryzen 7 9800X3D (RDNA2, XCL_ADAPTER=radeon), cargo test --workspace -- --test-threads=4 --skip gpu::dxil::fuzz_tests::fuzz_validate_and_gpu_1: 988 passed, 0 failed, 45 ignored. SKIPPED: f16_programs_on_the_gpu (f16 arithmetic, wave32, per-lane form: refused (unsupported V_MUL_F16 (its gpu: direct RDNA2 -> DXIL backend (no HLSL / DXC), behind XCL_DIRECT_DXIL #1426 semantics differ from the console's))), f16_programs_on_the_gpu (f16 arithmetic, wave64, per-lane form: refused (unsupported V_MUL_F16 (its gpu: direct RDNA2 -> DXIL backend (no HLSL / DXC), behind XCL_DIRECT_DXIL #1426 semantics differ from the console's))), f16_programs_on_the_gpu (f16 packed, wave32, per-lane form: refused (unsupported V_PK_MUL_F16: VOP3 modifiers (its gpu: direct RDNA2 -> DXIL backend (no HLSL / DXC), behind XCL_DIRECT_DXIL #1426 semantics differ from the console's))), f16_programs_on_the_gpu (f16 packed, wave64, per-lane form: refused (unsupported V_PK_MUL_F16: VOP3 modifiers (its gpu: direct RDNA2 -> DXIL backend (no HLSL / DXC), behind XCL_DIRECT_DXIL #1426 semantics differ from the console's))), f32_programs_on_the_gpu (f32 conversions, wave32, per-lane form: refused (unsupported V_CVT_F16_F32 (its gpu: direct RDNA2 -> DXIL backend (no HLSL / DXC), behind XCL_DIRECT_DXIL #1426 semantics differ from the console's))), f32_programs_on_the_gpu (f32 conversions, wave64, per-lane form: refused (unsupported V_CVT_F16_F32 (its gpu: direct RDNA2 -> DXIL backend (no HLSL / DXC), behind XCL_DIRECT_DXIL #1426 semantics differ from the console's))), heap_window_out_of_memory_falls_back_to_the_switch_form (no heap windows).
  • --skip leaves out tests that fail on main 80f4819 too, not because of this PR. On NVIDIA: heap_window_out_of_memory_falls_back_to_the_switch_form (Tests: heap_window_out_of_memory_falls_back_to_the_switch_form fails under XCL_REQUIRE_GPU=mesh (opt-in skip counted as missing coverage) #1651), the four gpu::recomp::lower_dxil::tests::*_programs_on_the_gpu tests and const_and_null_mask_operands_agree_with_hlsl_on_the_gpu (follow-up on #1651) fail because runner::skip_test turns their skips into failures under XCL_REQUIRE_GPU=mesh, and gpu::dxil::fuzz_tests seeds 70, 545, 1019 and 1507 fail CreateComputePipelineState with E_OUTOFMEMORY on this card (drivers 616.64 and 621.40). On AMD: fuzz_validate_and_gpu_1 fails on seed 540 (res[833] 0x7 vs CPU 0x6). The AMD run does not set XCL_REQUIRE_GPU.

Not tested

  • a release build, a game (test run only).

AI use

  • Claude Code (Claude Opus 5.5) ran the tests and wrote this report. I checked it before posting.

@raylitebull

Copy link
Copy Markdown
Member

Code review on 61db31a:

  • Diff audited (crates/xcl/src/hle/d3d12x/alloc_pool.rs, real.rs) and CI workflow approved (running).
  • Note the overlap with #1945 (alloc_pool.rs + q_release): #1945 additionally moves still-pending queue marks into Backing.retired on forget_queue (so a new queue reusing the same address cannot overwrite an in-flight mark) and uses create_pc_fence to bypass real::FENCES. If #1967 moves forward instead, it still needs Build and test green plus AMD verification.

@JJAutoCompare

Copy link
Copy Markdown

PR #1967 compatibility verification

Tested 61db31aacab5bcc912eb8426f180ba6881d12d2f on STOR-WINLAB. The allocator-pool regression test passed in both runs. The workspace suite exited 101 with 25 failures.

Environment

Windows 11 Enterprise Evaluation build 26200.9974, Ryzen 7 3800X, Intel Arc A770 16 GiB with driver 32.0.101.9175. Wave range 8–32, DoublePrecisionFloatShaderOps=0, and no d3d12SDKLayers.dll. Rust 1.100.0 (0ef1bc386, 2026-11-09), DXC/DXIL 1.9.2609.5, unoptimized builds with debug info and incremental compilation disabled, XCL_ADAPTER=A770.

Tested

  • cargo build --workspace and cargo test --workspace --no-run succeeded.
  • cargo test -p xcl hle::d3d12x::alloc_pool::tests -- --nocapture reported 4 passed, 0 failed, 0 ignored, and 0 skip markers. released_queue_drops_retained_fence_from_state submitted a D3D12 list, waited for completion, then called the cleanup directly and verified removal of the retained fence and completed backing mark. Source inspection confirmed that q_release calls the cleanup when the native reference count reaches zero.
  • cargo test --workspace --no-fail-fast -- --test-threads=4 ran once under the shared Arc lock. Across 20 result summaries, Cargo reported 964 passed, 25 failed, 45 ignored. The log contained 23 SKIPPED lines. Some tests emit multiple markers, and skipped paths contribute no coverage.

Of the 25 failures, 20 library tests reported CreateComputePipelineState error 0x80070057, and four library tests had result mismatches in fused FMA, implicit-LOD sampling, f16 VALU, and wave reductions. The test-title e2e case failed its RSSetDepthBiasX check (blue pixel, expected green). Skip markers covered 18 wave64 cases, three refused wave32 lowering cases, one driver-cache prerequisite, and one heap-window case.

Not tested

Baseline on main, retail-title smoke, other GPUs, the D3D12 debug layer, or optional XCL_SAMPLE_* data. The focused test did not exercise the release hook directly, an in-flight mark at release, or queue-address reuse.

AI use

T3 Code / Codex (gpt-6.2-sol, reasoningEffort: high) ran the build and verification. Coordinator #2 (T3 Code / Antigravity, gemini-4-neon) verified counts against pr1967-suite.log and published this report.

@DavidM1911

Copy link
Copy Markdown
Contributor

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

Thanks!

@throny throny added the goal:world-load Bears on the retail title getting past world loading label Nov 25, 2026
Fixes xcl-dev#1909.

alloc_pool::State.fences retained (ID3D12Fence, u64) per command queue
with no cleanup when real::q_release released the queue (refcount 0).
Add alloc_pool::on_queue_release(queue), called from real::q_release
when n == 0, to remove the queue's retained fence and any already
completed backing marks for that queue.

Tested: cargo test --workspace -- --test-threads=4.

Assisted-by: Antigravity (model name not provided)
@n-romanovich
n-romanovich force-pushed the d3d12x/alloc-pool-release-queue-fence branch from 61db31a to 4fffef3 Compare November 25, 2026 10:54
@thehollowedone

Copy link
Copy Markdown

Independent Windows check on 4fffef3. Windows 11 build 26300, Ryzen 7 9800X3D, RTX 3080 Ti (621.35), Rust 1.99.1 MSVC, debug.

The stock allocator-pool tests passed 5/0/0 with zero skips (cargo test --offline --locked -p xcl --lib hle::d3d12x::alloc_pool::tests -- --test-threads=1 --nocapture).

I also tested simulated queue-key reuse with native D3D12 fences. An unsignaled fence represented the old queue. The backing stayed busy after the release callback. After a new native submission under the same key completed, the backing reported free while the old fence was still unsignaled. The same fixture on #1945’s f581057 kept the backing busy until I signaled the old fence.

The scratch check used cargo test --offline --locked -p xcl --lib released_queue_key_reuse_keeps_the_older_pending_fence -- --test-threads=1 --nocapture (with -j 4 on #1945). It failed the busy-state assertion on #1967 and passed 1/0/0 on #1945, with zero skips in both runs. The fixture only queried eligibility. It never reset a busy allocator or blocked live GPU work. AI-assisted. Codex (GPT-6, exact variant unavailable) wrote the fixture, ran the checks, and drafted this report.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

goal:world-load Bears on the retail title getting past world loading

Projects

None yet

Development

Successfully merging this pull request may close these issues.

D3D12.X: allocator pool retains internal fences after command queue release

7 participants