Skip to content

D3D12.X: preserve busy allocators when replacement fails - #994

Draft
nova-aryan wants to merge 1 commit into
xcl-dev:mainfrom
nova-aryan:contrib/allocator-reset-errors
Draft

nova-aryan wants to merge 1 commit into
xcl-dev:mainfrom
nova-aryan:contrib/allocator-reset-errors

Conversation

@nova-aryan

@nova-aryan nova-aryan commented Nov 24, 2026 •

Copy link
Copy Markdown
Contributor

When a busy command allocator needs another backing, failure in GetDevice or CreateCommandAllocator currently returns None from title_reset. The caller interprets that as permission to reset the original allocator, even though its recordings are still held. Return the failure HRESULT instead and preserve the backing and recording associations. Fixes #989.

This is a failure-path fix following #897/#907. It does not establish the cause of the retail world-loading watchdog or null-write reports.

What is in it

  • alloc_pool.rs: propagate replacement errors instead of falling through to the original Reset; synthetic COM regression for device-lookup failure, allocation failure, retries, recording associations and reference cleanup.
  • README.md: describe failed replacement behavior. One commit, no new dependencies or game data.

Tested

  • Source inspection of the caller and replacement paths on main 9aec53d.
  • git diff --check: exit 0.
  • No local build, test executable, GPU workload or game was run for this change. Local execution is disabled at the user's request; no local passing test counts are claimed.
  • Independent report by @dcastell1: this PR's patch applied to main@02bfd1d, Windows 11 10.0.26300, RTX 5090 driver 621.24, Rust 1.100.0/MSVC 14.44.35207, debug; cargo test --workspace -- --test-threads=4: 728 passed, 0 failed, 41 ignored versus baseline 727/0/41. Report prepared using opencode (model not specified). This is an external patch-on-main run, not an exact-head retail smoke run; GPU skip counts were not reported.

Regression run
Not run. Main/head retail smoke blocks are missing; this remains a draft pending Windows validation.

Not tested

  • Local compilation/execution, actual allocation pressure and retail gameplay. The independent suite report above does not replace paired main/head retail smoke runs.
  • Expected negative control by source inspection: the unmodified path returns None for both injected failures, so the new HRESULT assertions should fail. This has not been executed.
  • The existing successful replacement path is unchanged. Other allocator failure cases and the title's response to an allocation error remain outside this patch.

AI use
Codex (GPT-6) inspected the code, wrote the patch and regression, and prepared this description. The exact backend model identifier was not provided in this session.

Propagate replacement GetDevice/CreateCommandAllocator failures instead of letting the Reset hook fall back to the original backing. Add synthetic COM coverage for failure and retry paths; execution remains pending at the user's request. Fixes xcl-dev#989.
@dcastell1

Copy link
Copy Markdown

Verified on Windows 11 10.0.26300, NVIDIA GeForce RTX 5090 (driver 621.24), Rust 1.100.0 MSVC 14.44.35207, debug build, on main@02bfd1d (baseline 727 passed, 0 failed, 41 ignored on this box):

patch -p1 < this PR            # clean, no fuzz
cargo test --workspace -- --test-threads=4
728 passed; 0 failed; 41 ignored   (exit 0)

One more passing test than the baseline: preserving busy allocators when a replacement fails is exercised and green.

Tree restored afterwards (full diff against a clean checkout), hardware adapter, no Wine, no game data. AI-assisted (opencode): applied the patch to a built tree, ran the suite, reverted it.

@SlopTart

Copy link
Copy Markdown

Heads-up: this branch no longer merges cleanly.

Rebuild today: pull/994/head onto current main fails to merge - main took PRs #1009 and #1012 (384f7f7, the allocator pool: failed Resets / released lists), which touch the same allocator-recording code this PR's preserve busy allocators when replacement fails sits on. CI here is description-check-only, so the conflict won't surface beyond the merge button. Untested until rebased; I can run it on RDNA3/Wine after that (my allocator-adjacent rows: #1012/#1023 lanes were green here today).

Machine: RX 7900 XT (RADV NAVI31), Mesa 26.2.5, kernel 7.2 (Arch), Proton Experimental (wine-11.0), patched vkd3d-proton v3.1, Rust cross x86_64-pc-windows-gnu, XCL_NETWORK=0, release profile. My Linux rows: #42 / #718.

AI use: Hermes agent (local Qwen-class) ran the checks and drafted this; I checked it before posting.

@DavidM1911

Copy link
Copy Markdown
Contributor

Independent check — this branch no longer merges cleanly into current main 384f7f7.

git merge upstream/main conflicts in crates/xcl/src/hle/d3d12x/alloc_pool.rs (tests module, two hunks). It is not just textual: main's merged allocator-pool work (#1009/#1012/#1023) added a_spare_whose_reset_fails_stays_available_for_retry and released_lists_leave_only_live_recordings_and_gpu_work_holding_the_backing in the same spot, and both sides define unsafe extern "system" fn release with different signatures (Device refs vs Fence releases) plus share the unexpected_call/SLOT scaffolding — so the resolution needs a rename, not just keeping both blocks.

Until rebased, the new test a_failed_replacement_keeps_the_busy_allocator cannot run against current main. (I did not resolve it locally — the fix belongs to the author.)

AI use: merge test by Devin (Cognition, SWE-2); no code changes.

@Toons29

Toons29 commented Nov 25, 2026

Copy link
Copy Markdown

Regression run of ff3182f9 on the retail title, for this PR's Regression run section. Both blocks are from scripts/smoke.ps1 as printed, not edited: main on 4178e888, this PR on its head commit with no uncommitted changes, same title and time.

xcl-smoke v1
commit: 4178e888c0b5be50a2887eda45cdb832763b68a4
gpu: AMD Radeon RX 9070
title: game.exe
seconds: 60
exit: 0x0
frames shown: 1618 (PresentX 1618)
presents per 2 s (last 3): 61 60 60
device removals: 0
crashes: 0
peak commit: 14831 MB
xcl-smoke v1
commit: ff3182f9e37fc51d28b83feb581a402b1975c677
gpu: AMD Radeon RX 9070
title: game.exe
seconds: 60
exit: 0x0
frames shown: 1628 (PresentX 1629)
presents per 2 s (last 3): 60 60 60
device removals: 0
crashes: 0
peak commit: 14813 MB

Against the limits in CONTRIBUTING.md: 101 % of main's frames, 100 % of its peak commit, no crash, no device removal.

AMD Radeon RX 9070 (RDNA4, driver 32.0.32029.2010), Ryzen 7 7800X3D, 32 GB, Windows 11 build 26300, Rust 1.100.0, cargo build --release -p xcl, 60 s, XCL_NETWORK=0. This is a regression check only: it does not show whether the run reaches the code this PR changes.

AI use: Claude Code (Claude Opus 5.5) built both trees and ran scripts/smoke.ps1; I checked the blocks before posting.

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

D3D12.X: failed replacement allocation falls back to resetting a busy allocator

5 participants