Skip to content

D3D12.X: a wait after a write into title memory in the same list is met by that write - #1256

Open
upipibi wants to merge 1 commit into
xcl-dev:mainfrom
upipibi:fix/title-memory-write-then-wait
Open

upipibi wants to merge 1 commit into
xcl-dev:mainfrom
upipibi:fix/title-memory-write-then-wait

Conversation

@upipibi

@upipibi upipibi commented Nov 24, 2026 •

Copy link
Copy Markdown
Contributor

wait_memory drops a Wait32/64BitValueX whose address the same list already wrote (has_prior_write): the GPU reaches the write before the wait, and polling the address on the CPU before the list is submitted would only run into the timeout. Two writers do not record their range, because they go to the CPU instead (cpu_writes):

  • a Write32/64BitValueX into the title's own memory outside the unified-memory windows;
  • a timestamp written there.

So a wait on such an address later in the same list stayed. execute_with_waits_on polled it before submitting the list, while the CPU makes the write only after the submit, so every such wait ran out its timeout and was then let through. Both writers now record the range, as the GPU writers (write, fill, CopyMemoryToMemoryX, timestamps into a window) already do.

Found while checking defect 1 of @chazi123's report on #646 ("the CPU poll for a list's Wait ran before that same list was submitted"). For writes into the unified-memory windows, main already drops or splits such waits. This was the one path where it can still happen. I can't tell whether it is the case in that report (their counter is in a window), so this PR does not claim to fix the +0x23cf683 stop.

What is in it

  • hle/d3d12x/list_x.rs: write()'s title-memory branch and timestamp()'s readback branch call note_write for the range they queue.
  • Test a_wait_after_a_title_memory_write_in_the_same_list_is_met_by_it: a synthetic list writes a heap word through write() (no unified memory in the test, so it takes the CPU path), then waits on it and on another word. Only the wait on the other word may stay. It fails on main (2 waits left) and passes here. It needs no GPU.

Tested

  • NVIDIA GeForce RTX 3070, driver 616.56; Windows 11 Pro 26100; Rust 1.100.0 MSVC; debug.
  • cargo build --workspace + cargo test --workspace --no-fail-fast -- --test-threads=4:
    • this PR (23d1aa8): 752 passed, 0 failed, 41 ignored;
    • main 930e8b4: 751 passed, 0 failed, 41 ignored.
    • Both skip the same two tests (no wave64): gpu_geometry_wave32_prefix_count_over_a_mask and gpu_wave32_program_in_wave64_hardware.

Regression run

From Kalmarv's run (#1256 (comment)), thanks:

main:

xcl-smoke v1
commit: 930e8b49c1c2ec683d22c724a398b39111cd0e56
gpu: NVIDIA GeForce RTX 5070 Ti
title: ea3b5e4d
seconds: 60
exit: 0x0
frames shown: 1312 (PresentX 1312)
presents per 2 s (last 3): 38 22 59
device removals: 0
crashes: 0
peak commit: 26728 MB

PR:

xcl-smoke v1
commit: 23d1aa8dfa38db7f468991d2850db0dfacbe79c7
gpu: NVIDIA GeForce RTX 5070 Ti
title: ea3b5e4d
seconds: 60
exit: 0x0
frames shown: 1311 (PresentX 1311)
presents per 2 s (last 3): 43 55 11
device removals: 0
crashes: 0
peak commit: 28262 MB

Limits (from bmjask's review): the write stays CPU-emulated and is made only after the whole list's fence completes (cpu_writes::after), so commands after the dropped wait can run before the marker or timestamp lands. main has the same ordering (its CPU poll of the wait times out and lets the list through); this PR removes only the timeout. Ordering it properly means splitting the list at such a wait, which is a separate, larger change.

Overlap with #2506 (tiagonleal): #2506 drops a same-list wait only when the value the list wrote meets it, and keeps dropping it when no value is recorded. This PR records the title-memory and timestamp writes with note_write (no value), so on top of #2506 it would drop those waits whatever the value. The two conflict in list_x.rs. If #2506 lands first, I'll rebase this so the title-memory write() records its value through #2506's note_write_value, and the timestamp readback (value unknown) no longer drops a wait.

Not tested

  • A title. We don't know how often the title waits on its own memory right after writing it in the same list.
  • AMD, Wine.

AI use

  • Claude Code (Claude Opus 5.5) read the wait path, wrote the change and the test, ran the suites, and wrote this description.

🤖 Generated with Claude Code

…et by that write

`wait_memory` drops a Wait32/64BitValueX on an address the same list already
wrote (`has_prior_write`): the GPU reaches the write first, and polling the
address before the list is submitted would only time out. The two writers
that go to the CPU instead (`cpu_writes`: a Write32/64BitValueX into the
title's own memory outside the unified-memory windows, and a timestamp there)
did not record their range, so a wait on it later in the list stayed: it was
polled before the list was submitted, while the CPU makes the write only
after the submit, and it ran into the wait timeout every time.

Both now record the range (`note_write`) as the GPU writers do.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@DavidM1911

Copy link
Copy Markdown
Contributor

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

  • cargo test -p xcl --lib list_x new tests (wait_after_title_memory_write, copy_scratch_budget, new_list_takes_no_copy_scratch): 3 passed, 0 failed.

Thanks!

@Kalmarv

Kalmarv commented Nov 24, 2026

Copy link
Copy Markdown
Contributor

Regression pair for 23d1aa8 against main 930e8b4 (this PR's base), for the Regression run section. Both runs pass: no device removal, no crash, 100 % of main's frames, 106 % of its peak commit.

Tested

  • NVIDIA GeForce RTX 5070 Ti 16 GB (driver 610.74), AMD Ryzen 9 9950X, Windows 11 Pro 26200.
  • scripts/smoke.ps1, the same retail title for 60 s each: main at 930e8b4 (this PR's base) first, then this PR's head, one after the other on the same machine. XCL_ACTIVITY=1 on both.

main 930e8b4:

xcl-smoke v1
commit: 930e8b49c1c2ec683d22c724a398b39111cd0e56
gpu: NVIDIA GeForce RTX 5070 Ti
title: GTA VI
seconds: 60
exit: 0x0
frames shown: 1312 (PresentX 1312)
presents per 2 s (last 3): 38 22 59
device removals: 0
crashes: 0
peak commit: 26728 MB

this PR, 23d1aa8:

xcl-smoke v1
commit: 23d1aa8dfa38db7f468991d2850db0dfacbe79c7
gpu: NVIDIA GeForce RTX 5070 Ti
title: GTA VI
seconds: 60
exit: 0x0
frames shown: 1311 (PresentX 1311)
presents per 2 s (last 3): 43 55 11
device removals: 0
crashes: 0
peak commit: 28262 MB

Wait…BitValueX timed out lines (the run you asked for): 0 on main and 0 on this PR. Both logs have the 30 activity (2 s) lines and their other warnings, so the warning would have been logged; neither 60 s run hit a wait timeout at all. The activity lines' frame-event waits also match: 2624 on main, 2620 here, none timed out.

Not tested

AI use: Claude Code (Claude Opus 5.5)

@throny throny added the goal:world-load Bears on the retail title getting past world loading label Nov 25, 2026
@thehollowedone

Copy link
Copy Markdown
Contributor

Independent Windows run on 23d1aa8. Windows 11 build 26300, Ryzen 7 9800X3D, RTX 3080 Ti (621.35), Rust 1.99.1 MSVC, debug.

cargo build --offline --locked --workspace passed. cargo test --offline --locked --workspace --no-fail-fast -- --test-threads=4 --nocapture reported 752 passed, 0 failed, 41 ignored, with two wave64 skips included in Cargo's pass count.

I extended the checked-in timestamp fixture in a scratch copy. One native D3D12 list recorded a 32-bit immediate write, two 64-bit timestamp writes, and matching waits on all three CPU-memory destinations. All three destinations were zero before submission. The recording left only an unrelated wait pending. Once I satisfied that wait, one native submission delivered the immediate value 42 and both nonzero GPU timestamps. The device remained healthy. Restoring the original recording code left all four waits pending and failed the assertion before submission.

cargo test --offline --locked -p xcl --lib timestamps_outside_unified_memory_land_after_the_queue -- --nocapture --test-threads=1 passed 1/0/0 with zero fixture skips. This covers matching same-list waits in the synthetic case. AI-assisted. Codex (GPT-6, exact variant unavailable) extended the fixture, ran the tests, and drafted this report.

@oni-swr

oni-swr commented Nov 25, 2026

Copy link
Copy Markdown
Contributor

AMD RX 7800 XT test report

Tested locally by merging PR head 23d1aa8dfa38db7f468991d2850db0dfacbe79c7 onto base main 3f2777019544c0ada2cd294aa792d3c378ff0df8 (no push). The base is an ancestor of current main and both trees merge cleanly.

Hardware and tools: AMD Radeon RX 7800 XT, driver 32.0.31035.1003; Windows 10 Pro; Rust 1.100.0 / Cargo 1.100.0; DXC 1.8.2502.11 (DXIL 1.8.2502.11). Debug test build.

cargo test --workspace --no-fail-fast -- --test-threads=4: 1,356 passed, 2 failed, 46 ignored. There were 7 SKIPPED reports: six GPU cases (wave32/wave64 variants for three unsupported instruction forms) and one heap-window case. The two failures and all 7 SKIPPED reports match the baseline (1,355 passed, 2 failed, 46 ignored).

Not tested

  • Smoke run or retail titles
  • Release build
  • Other GPUs

AI use
Codex (gpt-6-luna) ran Phase 2 tests and wrote this report (Phase 1 pre-compile / initial baseline run used Claude Code (Claude Sonnet 5.5)).

@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.

P1: this removes a wait after a CPU-emulated title-memory write as if the write were GPU-ordered. write() queues cpu_writes::Write::Immediate then note_write; wait_memory sees a prior write and drops the wait. But cpu_writes::after performs the immediate write only after a fence for the submitted list completes. Thus intended write -> wait -> later commands becomes entire list (including later commands) -> CPU write; no PC/GPU write orders the marker before post-wait work. Timestamp readbacks have the same issue. Split/fence/write before the post-wait segment, or retain waits for CPU-emulated writes. The test only asserts removal and does not execute/verify ordering.

@ClosetPie107

Copy link
Copy Markdown

Independent AMD RDNA4 / Linux (RADV, native wave64) test report for head 23d1aa8dfa38db7f468991d2850db0dfacbe79c7 (merged cleanly onto main 6d12f58).

Hardware & environment

  • AMD Radeon RX 9070 16 GB (RDNA4, RADV GFX1201, Mesa 26.3.1, native wave64), Ryzen 5 9600X, 30 GiB RAM, CachyOS Linux
  • Proton Experimental (experimental-11.0-20261112), vkd3d-proton master ec207194 (3.2.0) + dxil-spirv b540c8a2 + relaxed-vtable patch (-Db_ndebug=true), DXVK v3.1.1-209, DXC 1.9.2609.5, Rust x86_64-pc-windows-gnu (debug for tests, release for retail)

Unit / GPU tests (XCL_REQUIRE_GPU=wave64, XCL_DXC_DIR, VKD3D_CONFIG=ignore_shared_fence, --test-threads=1 --nocapture)

  • hle::d3d12x::list_x::: 41 passed, 0 failed, 0 ignored (0 skipped)

Combined retail sanity run (main 6d12f58 + #2068, #1771, #1740, #1256 merged together; XCL_DIRECT_DXIL=1, XCL_TEXTURE_LEVEL_PAGES=1, XCL_PSO_WAIT_MS=50, XCL_SPLIT_MIDLIST_WAIT=0, XCL_COHERENT_MB=1024, VKD3D_CONFIG=ignore_shared_fence, XCL_PSO_PRELOAD=0, XCL_NETWORK=0)

  • Completed the full 300 s (exit=0) with 0 crashes and 0 device removals (11.55 GiB peak VRAM / 0 GTT spill, 13.35 GiB peak RSS, 1,800+ frames presented, 16,442 translated draws, 4,499 dispatches, 11,257 Opus packets).

Not tested

  • Full workspace test suite, native Windows, or an isolated single-PR retail run (retail sanity run above was on the 4-PR batch).

AI use

  • T3 Code / Antigravity (Gemini 4 Neon) merged the PR onto main, ran the tests and combined retail run under Proton on this machine, and drafted this report.

@upipibi

upipibi commented Nov 25, 2026

Copy link
Copy Markdown
Contributor Author

@bmjask Agreed on P1: this doesn't order the CPU-emulated write before the commands after the wait. cpu_writes::after makes the write only once the whole list's fence completes, so commands after the wait can run before the marker lands. The same holds for the timestamp readback.

For context, main doesn't order it either. There, execute_with_waits_on polls that wait on the CPU before the list is submitted, the write only happens after the submit, so the wait runs out its timeout and is then let through, and the later commands still run before the write. This PR removes that timeout; it doesn't change the ordering. I've added that to the description as a limit.

The proper fix is what you describe: split the list at such a wait and make the write (or a GPU write of the same value) before the post-wait part. That is a bigger change in execute_with_waits_on's segmenting than this PR, so I'd rather do it separately than grow this one. If the maintainers prefer to hold this PR until then, that's fine.

AI-assisted (Claude Code, Claude Opus 5.5).

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.

8 participants