Skip to content

[upstream #929] D3D12.X: newer list layout #139 Reset goes through title_list::reset - #162

Closed
ufoptg wants to merge 1 commit into
mainfrom
upstream-pr/929
Closed

ufoptg wants to merge 1 commit into
mainfrom
upstream-pr/929

Conversation

@ufoptg

@ufoptg ufoptg commented Nov 24, 2026

Copy link
Copy Markdown
Owner

On the newer console command-list layout (real::QUEUE_SHIFTED), titles reset pooled command lists through slot #139 (Reset(allocator, initial_pso, flags)), which real.rs maps to list_x::reset_x.

title_list's wrapper vtable only overrode slots 0, 1, 2, 9, 10, leaving v[139] as a raw forwarder to F_BACKING. Once a mid-list Wait64 split switched F_BACKING to a continuation segment, #139 reset only that continuation segment and never ran title_list::reset: F_PRIMARY kept its old recording/allocator, F_BACKING was never restored to F_PRIMARY, and extra_active kept accumulating split segments across frames. Before #897 that caused 0x887a0001 device removals (ID3D12CommandAllocator reset while still referenced by an un-reset primary list); even with #897/#907 allocator pooling, stale primary and prior split segments stay attached and get resubmitted until extra_active hits MAX_EXTRA_SEGMENTS.

The wrapper's v[139] is now a guard::make_layout_split of its own: a title on the newer layout (real::QUEUE_SHIFTED) goes to a four-argument adapter that runs title_list::reset; a title on the older layout and the runtime keep the generated forwarder to F_BACKING, whose tail jump preserves the caller's return address for the backing list's own layout guard at #139 (review finding by @ettehn: a Rust call into the backing slot hid the title caller, so an older-layout title reached the PC method).

What is in it

  • crates/xcl/src/hle/d3d12x/title_list.rs: vtable slot #139 becomes slot_139(forwarder, &QUEUE_SHIFTED), a make_layout_split with the generated forwarder as older and pc and the adapter reset_139 (runs title_list::reset) as newer. Unit tests: newer_layout_slot_139_resets_primary_and_reclaims_split_segments (forwarder and newer-layout reset on fake lists) and slot_139_keeps_the_title_caller_for_the_backing_layout_guard (a caller in a registered mapped image calls the slot with the backing slot behind a layout guard as real.rs installs it; flag clear reaches the older handler with the title's arguments, flag set resets the primary and reclaims the split segment). Both use a test-local layout flag, not the global QUEUE_SHIFTED.

Tested

  • Hardware: AMD Radeon RX 6800 (driver 32.0.21045.29003), AMD Ryzen 9 7950X3D, Windows 11 Pro 10.0.26300 (Build 26300), rustc 1.100.0 (0ef1bc386 2026-11-09), debug (cargo test) and release (cargo build --release -p xcl).
  • cargo test --workspace --no-fail-fast -- --test-threads=4: 715 passed, 3 failed, 41 ignored on head b3a969b (integration test binaries: 41 passed, 0 failed, 20 ignored; cargo test -p xcl --lib title_list in release and in debug: 3 passed, 0 failed, 0 ignored; d3d12x::guard tests in debug: 4 passed, 0 failed).
    • The 3 failures are pre-existing in-process interference on this adapter unrelated to title_list.rs: hle::d3d12x::title_textures::tests::placed_title_textures_share_vram_and_preserve_pixels fails (3D 64x64x64 4 mips: subresource 2 mismatch) when preceded in-process by gpu_mirror_upload_follows_cpu_writes_and_later_mapping_changes (reproduces when running only hle::d3d12x::title_textures with --test-threads=1), poisoning the shared lock for hle::d3d12x::title_textures::tests::transitions_apply_when_their_list_is_submitted and hle::d3d12x::vram::tests::d32s8_targets_take_their_own_size_of_video_memory. Each of the 3 passes individually (1 passed, 0 failed with --test-threads=1).
  • SKIPPED GPU tests on this adapter: none (0 skipped).
  • Retail testing: verified on a newer retail title that exercises mid-list Wait64 splits and newer-layout slot #139 resets; previously hit 0x887a0001 device removals after the first mid-list split, and with the newer-layout part of this fix (first revision of this PR, release build) survived 64+ mid-list splits with 0 device removals. That retail run has not been repeated on the current head.

Regression run

xcl-smoke v1
commit: 09940bb87fa11bc394fd9e5de570c2b7cfd16323
gpu: AMD Radeon RX 6800
title: retail-title
seconds: 60
exit: 0x0
frames shown: 1401 (PresentX 1401)
presents per 2 s (last 3): 60 60 60
device removals: 0
crashes: 0
peak commit: 21704 MB
xcl-smoke v1
commit: b3a969b72cbcbf951f0b99a3b2a67aa6b03a1176
gpu: AMD Radeon RX 6800
title: retail-title
seconds: 60
exit: 0x0
frames shown: 1491 (PresentX 1491)
presents per 2 s (last 3): 60 60 60
device removals: 0
crashes: 0
peak commit: 19341 MB

Not tested

  • NVIDIA, Intel, RDNA4 / wave32-only GPUs, and Wine/Proton.
  • Older command-list layout (QUEUE_SHIFTED == false) on a real title (covered by unit test only). The second unit test fails on this PR's first revision only in a debug build; in release that call was compiled as a tail jump.
  • The PR-head smoke block is the second run of that binary; the first run after the build showed 914 frames (33-34 presents per 2 s) with 0 device removals and 0 crashes, which I attribute to shader caches being rebuilt for a new binary, without having measured that.
  • The 60 s regression smoke run above stays in the title's startup/menu window and does not reach mid-list Wait64 splits (which happen later in loading).

AI use

  • Antigravity with Gemini 4: used to diagnose the slot #139 bypass, write the fix and unit test in title_list.rs, run the test and smoke commands, and draft this description; diff and test outputs reviewed by the author.
  • Claude Code with Claude Opus 5.5: used to verify the review finding in the code, write the make_layout_split change and the second unit test, rerun the suite and the smoke run, and update this description.

Mirror of xcl-dev#929 (auto-synced, do not edit).

On the newer console command-list layout (real::QUEUE_SHIFTED), titles reset pooled lists through slot #139 Reset(allocator, initial_pso, flags), which real.rs routes to list_x::reset_x.

title_list's wrapper vtable only overrode slots 0, 1, 2, 9, and 10, leaving slot #139 as a raw forwarder to F_BACKING. Once a mid-list Wait64 split switched F_BACKING to a continuation segment, #139 reset only that continuation segment and never ran title_list::reset: F_PRIMARY stayed bound to the previous recording/allocator, F_BACKING was never restored to F_PRIMARY, and extra_active kept accumulating split segments across frames.

On pre-xcl-dev#897 main that caused D3D12 device removal (0x887a0001 / debug-layer id 541) as soon as the old allocator was reused; even with xcl-dev#897/xcl-dev#907 allocator pooling, stale primary/prior segments continue to be resubmitted and extra_active grows until MAX_EXTRA_SEGMENTS.

The wrapper's #139 is now a guard::make_layout_split of its own: a title on the newer layout goes to a four-argument adapter that runs wrapper reset, while a title on the older layout and the runtime take the generated forwarder. The forwarder's tail jump keeps the caller's return address and arguments, which the backing list's own layout guard at #139 needs to tell a title from the runtime; calling the backing slot from Rust would hide it and send an older-layout title to the PC method.

Tests: one covers the forwarder and the newer-layout reset on fake lists; one calls the slot from a caller in a registered mapped image, with the backing slot behind a layout guard as real.rs installs it and a test-local layout flag (flag clear: the older handler with the title's arguments; flag set: the primary is reset and the split segment reclaimed).

Co-Authored-By: Antigravity <noreply@google.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@ufoptg

ufoptg commented Nov 25, 2026

Copy link
Copy Markdown
Owner Author

Upstream PR xcl-dev#929 was closed or merged.

@ufoptg ufoptg closed this Nov 25, 2026
@ufoptg
ufoptg deleted the upstream-pr/929 branch November 25, 2026 00:08
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.

2 participants