Skip to content

D3D12.X: preserve unwritten gaps when tracking same-list waits - #592

Open
dervoxx wants to merge 1 commit into
xcl-dev:mainfrom
dervoxx:fix/same-list-written-gaps
Open

dervoxx wants to merge 1 commit into
xcl-dev:mainfrom
dervoxx:fix/same-list-written-gaps

Conversation

@dervoxx

@dervoxx dervoxx commented Nov 24, 2026 •

Copy link
Copy Markdown

The command list used to stop tracking individual UMA write ranges after 256 entries. It expanded the last entry across later writes, so a wait targeting an unwritten gap could be treated as a same-list dependency and skipped. The tracker now coalesces overlapping or adjacent writes while preserving gaps.

What is in it

  • crates/xcl/src/hle/d3d12x/list_x.rs tracks sorted, disjoint write ranges and uses binary search for overlap checks. The regression test records 300 scattered writes, checks an unwritten gap, then writes into that gap and verifies the neighboring gap stays unwritten.

Tested

  • RTX 5080, NVIDIA 621.01, Ryzen 9 9900X3D, Windows 11 build 26300, rustc 1.100.0. Workspace debug build succeeded. GPU suite (cargo test --workspace -- --test-threads=4): 752 passed, 0 failed, 41 ignored.
  • Two tests reported SKIPPED on this adapter (native wave64): gpu_geometry_wave32_prefix_count_over_a_mask and gpu_wave32_program_in_wave64_hardware.
  • Release regression test: adding the same test to 9ce2070 reproduced the false overlap on the first unwritten gap. On 905b90d it passed.

Regression run

Release builds, fresh XCL data and DXIL directories, same title and duration. Rebased onto 930e8b4 with the upstream GPU wait watchdog preserved.

xcl-smoke v1
commit: 930e8b49c1c2ec683d22c724a398b39111cd0e56
gpu: NVIDIA GeForce RTX 5080
title: 419239bf
seconds: 60
exit: 0x0
frames shown: 1173 (PresentX 1173)
presents per 2 s (last 3): 60 59 59
device removals: 0
crashes: 0
peak commit: 15886 MB
xcl-smoke v1
commit: 189f9db18c0304714ca17ce600770aacc2bf3287
gpu: NVIDIA GeForce RTX 5080
title: 419239bf
seconds: 60
exit: 0x0
frames shown: 1194 (PresentX 1194)
presents per 2 s (last 3): 60 60 60
device removals: 0
crashes: 0
peak commit: 15844 MB

Not tested

  • The smoke run covers startup. Whether a retail frame waits on an unwritten gap after 256 scattered writes was not measured. Performance on very long lists of disjoint, out-of-order writes was not benchmarked.

AI use

  • OpenAI Codex (gpt-6.2-astra) implemented the range tracker and regression test, ran the builds and tests, and compiled the results. Codex (gpt-6.2-sol) reviewed the patch and drafted the description.

@MesshM

MesshM commented Nov 24, 2026

Copy link
Copy Markdown

Test run of 905b90d5d93877d19da142b24bdf88788212a47d on AMD RDNA4; the PR was tested on NVIDIA only. I merged it onto current main 3db536e locally (clean merge) and tested that tree.

Tested

  • AMD Radeon RX 9060 XT 16 GB (RDNA4, native wave64), driver 32.0.32029.2010; Ryzen 7 5700X, 64 GB RAM, Windows 11 Pro build 26200, Rust 1.100.0 stable-x86_64-pc-windows-msvc, debug
  • cargo build --workspace + cargo test --workspace -- --test-threads=4 on the merge: 687 passed, 0 failed, 41 ignored, exit code 0; xcl lib tests 647 passed, 0 failed, 21 ignored
  • 0 SKIPPED; scattered_writes_preserve_unwritten_gaps passes.

Review: note_write keeps the ranges sorted and disjoint: partition_point(stop < va) finds the first range that overlaps or touches va, the second partition_point(start <= end) counts those it reaches, and they are merged into one (touching ranges included) or the new range is inserted. has_prior_write then needs one lookup, and an exact-boundary read (stop <= va) does not count as overlap, matching the half-open ranges. One thing to consider: with the 256-entry cap gone the list has no bound, and each insert into the middle shifts the tail, so a list with many scattered small writes costs O(n) per write until Reset/KickoffX. A cap that falls back to the old merge-everything behaviour only past, say, a few thousand entries would keep the gap tracking for normal lists. Not a blocker.

Not tested: no retail title or regression run (I have no unpacked game), no XCL_SAMPLE_* tests, release build; the PR's head on its old base was not run, only its merge onto main.

Run and review by Claude Code (Claude Opus 5.5) on this machine; the review points were checked against the code.

@brainhay5

Copy link
Copy Markdown

Retail result on Blackwell, since your "Not tested" names exactly this: whether a retail frame waits on an unwritten gap after 256 scattered writes.

Setup: main 91f9a5e with this PR merged on top (merge 11ccb8a, clean, 1 file), release build. RTX 5070 Ti (15997 MiB, driver 32.0.16.1088), Ryzen 7 5800X3D, Windows 11 22631, rustc 1.100.0, DXC 1.9.2602.17 from Windows SDK 10.0.26100. Interactive desktop session, XCL_NETWORK=0, full launch (not smoke.ps1), no XCL_SAMPLE_*.

It moves the title off the fault it was dying on. Same hardware, main at 63cdc25 without the PR, dies after ~80 s at VCRUNTIME140.dll+0x1dafb (read at 0x285e28f9fc0, stack inside xcl.exe). With this PR the same run gets to game_scarlett_master.exe+0x23cf683 (write at 0x0), which is the known remaining fault in #616, with that issue's exact stack:

unhandled exception 0xc0000005 in game_scarlett_master.exe+0x23cf683 (write at address 0x0)
on the stack: game_scarlett_master.exe+0x4e4ba89, +0x2215c35, +0x71b9a20, +0x2215eca

Counts from report.json, same ~80 s window:

63cdc25 91f9a5e + #592
translated pipelines 12 73
failed_pipelines 0 0
presents 1960 1521
xapu_packets_decoded 813 71,224
xapu_nonzero_samples 1,537,310 70,748,379

So the range tracker change is what removed the CRT fault; the run now reaches the loading-screen/cutscene wall described in #616 instead.

One observation, not a blocker: presents held 29.9 fps for the first 1200 frames, then dropped to 8.9 fps over the last 300 as the pipeline count climbed toward 73. Consistent with compile stalls, but it happens after the point where the unpatched tree died.

Not tested: AMD hardware, other GPUs, XCL_SAMPLE_*, longer runs past the #616 fault.

AI use: OpenCode, DeepSeek V4.1 Flash 1017.

@brainhay5

Copy link
Copy Markdown

Important for this PR's justification: on pure main f4ce27c (no PRs merged, no switches) the fault I used to motivate this is gone.

Before (63cdc25, no PR): VCRUNTIME140.dll+0x1dafb, read of an uncommitted page, ~80 s.
Now (f4ce27c, no PR): game_scarlett_master.exe+0x23cf683 (write at 0x0), the known #616 fault, 120 s, presents: 1573, translated_pipelines: 140, failed_pipelines: 0, xapu_packets_decoded: 16,957.

So something in the last batch (#347 write-watch-resume, #484 title-textures-safe-read-committed — both about reading pages that were not committed) removed the CRT fault without this PR. The gap-tracking bug this PR fixes may still be real on its own merits, but the crash evidence I posted earlier no longer reproduces on current main, and you should not merge on that basis alone.

Same hardware and setup as before: RTX 5070 Ti, driver 32.0.16.1088, Windows 11 22631, interactive session, XCL_NETWORK=0, release build.

AI use: OpenCode, DeepSeek V4.1 Flash 1017.

@CryingLaughing

Copy link
Copy Markdown

Tested

  • PR head 905b90d5d93877d19da142b24bdf88788212a47d, its exact parent 9ce2070eccf436d7bd38601c90407da447df34f3, and updated main f4ce27ceb6d1b0576d0c659b713b674778bf1968, each with the same scratch-only test in list_x.rs. NVIDIA GeForce RTX 4080, driver 621.01, Intel Core i5-13600K, Windows 11 25H2 build 26200.9974, Rust 1.100.0 MSVC x64, debug. XCL_ADAPTER=4080, XCL_REQUIRE_GPU=1, all XCL_SAMPLE_* variables unset.
  • Built each revision with cargo test -p xcl --lib --locked -j 4 --no-run --message-format=json, then ran the executable with hle::d3d12x::list_x::tests::gpu_gap_wait_splits_batch_after_scattered_writes --exact --test-threads=1 --nocapture.
  • The fixture records 300 scattered GPU writes and a Wait64BitValueX on the unwritten gap after write 260. A preceding native DIRECT list writes 42 to that gap. The test runs the real execute_with_waits splitting path and records the gap value immediately before each native queue submission. The callback waits on a queue fence after each submission, and the fixture checks all 300 GPU-written values.
  • On the parent and updated main, the wrapper failed 0/1. Each submitted both lists while the gap still held 0. On the PR head it passed 1/1 with zero skips. The producer was submitted alone with the gap at 0, then the waiting list was submitted alone after the gap reached 42. The GPU writes read back correctly on all three revisions.

The synthetic gap still reaches the old batching behavior on the same main revision where the reported retail fault disappeared. Retail follow-up

Not tested

  • GPU output from an independent producer queue, a full workspace run on the PR, other adapters, release builds, and retail titles. This checks the CPU-side batching decision with real command lists and GPU writes.

AI use

  • OpenAI Codex (GPT-6 family, exact variant unavailable) prepared the synthetic fixture, ran the checks, and drafted this report.

@relativespace2K

relativespace2K commented Nov 24, 2026 •

Copy link
Copy Markdown

Tested - 189f9db on main 3da2abb, retail GTA6 1.0.2.1

Tool: OpenCode with DeepSeek V4.1 Flash 1017

  • 360 s: the game ran ~358 s (past the old 160-190 s streaming crash), then exited
    0xc0000409; the XCL log up to that point is clean (40 refusals, 0 failed pipelines,
    0 shader errors, peak 31,837 MB).
  • Previous head 905b90d on b8b1f49 crashed at game_scarlett_master.exe+0x23cf683;
    that no longer happens on 3da2abb.
  • The late fast-fail is at this 31.9 GB machine's memory ceiling (commit limit 39.9 GB);
    a re-run with more headroom is needed to tell whether it is memory-related.

Tested - native Windows, AMD RDNA2

  • PR head 905b90d5d93877d19da142b24bdf88788212a47d (based on 9ce2070), applied as a
    cherry-pick without committing onto current main f4ce27c (clean).
  • AMD Radeon RX 6800 XT (16338 MiB), driver 32.0.21045.29003; Ryzen 5 5600, 31.9 GB;
    Windows 11 IoT Enterprise LTSC 26100; Rust 1.100.0 MSVC; DXC 1.9.2602.17; debug;
    no XCL_SAMPLE_*.
  • cargo build --workspace && cargo test --workspace --no-fail-fast -- --test-threads=4:
tree passed failed ignored
main f4ce27c 698 3 41
main + this PR 699 3 41
  • The same three known RDNA2 tests fail as on the base (the title-texture test plus the
    two PoisonError follow-ons); this PR does not touch them. The parallel run's
    title-texture assertion was its known cubemap extra_pages variant.
  • Focused scattered_writes_preserve_unwritten_gaps: 1 passed, 0 failed.
  • 0 SKIPPED GPU tests on this adapter.

Not tested: whether a retail title still waits on an unwritten gap (the thread reports
the original fault is gone on f4ce27c without this PR), release build, NVIDIA / Intel.

AI use: OpenCode with DeepSeek V4.1 Flash 1017 ran the tests and drafted this report.

@JJAutoCompare

Copy link
Copy Markdown

Empirical test report (189f9db)

Hardware / environment

  • PR D3D12.X: preserve unwritten gaps when tracking same-list waits #592 at commit 189f9db18c0304714ca17ce600770aacc2bf3287, tested from a clean detached checkout.
  • Windows x64 build 10.0.26200.9974, AMD Ryzen 7 3800X 8-Core Processor. The focused runs used XCL_ADAPTER=NONE_CPU_ONLY.
  • Rust 1.100.0 (0ef1bc386 2026-11-09), target x86_64-pc-windows-msvc. DXC 1.9.2609.5 (01b62ad47). Cargo's unoptimized test profile ran with incremental compilation and debug info disabled.

Commands and results

  • cargo test --workspace --no-run exited 0 and built 18 test executables. This was a compilation check.
  • $unitTestExe was the built library test binary xcl-77aca8ccb20e299f.exe. Both commands ran outside the Arc test wrapper.
  • cmd /d /c "$unitTestExe hle::d3d12x::list_x::tests::scattered_writes_preserve_unwritten_gaps --exact --test-threads=1 > $focusedLog 2>&1" exited 0. Counts were 1 passed, 0 failed, 0 ignored, 0 skipped.
  • cmd /d /c "$unitTestExe hle::d3d12x::list_x::tests::written_ranges_detect_same_list_overlap --exact --test-threads=1 >> $focusedLog 2>&1" exited 0. Counts were 1 passed, 0 failed, 0 ignored, 0 skipped.
  • Focused total was 2 passed / 0 failed / 0 ignored / 0 skipped. Skips were counted from case-sensitive ^SKIPPED lines.

Observed behavior

After 300 scattered writes, the new regression test found the selected gap unwritten. Filling that gap made it detectable as a prior write and preserved the preceding gap. The existing overlap test also passed its partial-overlap and boundary checks.

Not tested

The full GPU workspace suite and game smoke runs were omitted. The PR changes no GPU tests.

AI use

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

@DavidM1911

Copy link
Copy Markdown
Contributor

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

Thanks!

@upipibi

upipibi commented Nov 25, 2026

Copy link
Copy Markdown
Contributor

NVIDIA test report for 189f9db (head as is, base 930e8b4), for #1607's NVIDIA list. RTX 3070 8 GB (Ampere, 32-lane waves), driver 616.56, Windows 11, debug, after cargo build --workspace:

  • cargo test --workspace --no-fail-fast -- --test-threads=4 --skip hle::xaudio2: 743 passed, 0 failed, 41 ignored. The end-to-end title tests pass.
  • main at 0829441 (not current main) on the same machine, same command: 1263 passed, 0 failed, 46 ignored (the PR's base is older, so it has fewer tests).
  • Skipped hle::xaudio2, because its tests fail or hang on this machine on main too. The PR doesn't touch it.
  • SKIPPED lines: 2, both no wave64 on this card.

AI-assisted (Claude Code, Claude Opus 5.5). Synthetic tests only; no title run.

@Royalflamejlh

Copy link
Copy Markdown
Contributor

Linux (Wine + vkd3d-proton) + NVIDIA, the title, 3 runs with #592 and 3 of the same base with a counter: in the 3 base runs XCL never skipped a wait on an address the same list had written earlier, so the case this fixes did not occur here. The counter, at the has_prior_write return in list_x.rs, logs from the first skipped wait, and it logged nothing in 3 of 3 runs. No run crashed or lost its device; in both trees the title stopped presenting between 72 and 90 s and stayed stopped until XCL ended it at 120 s.

Setup: main c56e7448 + #684 e56dbc3 + #592 189f9db (local merge b4ab8fe0), against the same base + one counter commit (local 9875adc1). RTX 4070 12 GB (615.71.09), Fedora 44, Wine 11.21 Staging, vkd3d-proton v3.1-90-g30b0eb9b with the relaxed-vtable patch from #175 and a local dxil-spirv patch, VKD3D_CONFIG=ignore_shared_fence, release, Series X profile, the first-run screens completed once and no story progress, 120 s, XCL_NETWORK=0, XCL_PSO_PRELOAD=0, WINEDEBUG=err+all,fixme-all. A was pressed once the title presented steadily, once at 16.2 to 18.3 s; in 115051-b the title presented steadily from 8 s, so a press at 10.0 s did not start loading and a second followed at 20.3 s.

base + counter (3 runs) #592 (3 runs)
waits skipped as written earlier in the same list 0, 0, 0 –
last 2 s with a present 89.9, 80.3, 78.3 s 84.1, 72.0, 78.1 s
frames 1,469, 1,387, 1,341 1,443, 1,296, 1,360
  • Read: has_prior_write has one caller, wait_memory in list_x.rs, which serves both Wait32BitValueX and Wait64BitValueX. By our reading of the diff, the new tracker reports a prior write only where the old one did (it drops only the old merging past 256 ranges), so with no skip in the base tree D3D12.X: preserve unwritten gaps when tracking same-list waits #592 had nothing to change in these runs.

Not tested: the test suite, including the PR's new test; Windows; AMD and Intel; runs past 120 s; how many lists passed 256 written ranges (the counter counts skipped waits only).

AI use: Claude Code (Claude Opus 5.5) wrote the counter, ran the title and wrote this comment.

Posted without review by a person: the account owner was away and reads replies later.

@bmjask bmjask left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2: removing the 256-range cap leaves written_ranges unbounded, while every note_write holds global LISTS and uses Vec::insert/drain. Descending scattered writes insert at index 0, shift O(N) entries each, and create O(N^2) CPU/memory work under the global lock (list_x.rs:590-608; note_write wrapper :954-955). The old cap bounded this. The new 300-range test checks correctness but not adversarial scale. Please use a bounded exact interval structure/cap-preserving fallback, or at least add a stress benchmark/limit; merge/binary-search correctness otherwise looks sound.

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.