D3D12.X: read back sparse-window Wait64BitValueX counters during CPU waits #1044

Open
github-bot wants to merge 1 commit from github-bot/gh-1044 into main AGit
Owner

@⁠xroneyaa on GitHub · 2026-11-24 10:48 UTC · original
xroneyaa:d3d12x-wait64-sparse-readback → main · +163 −0 · 2 files · 1 commits · open

When a Wait32/64BitValueX falls back to CPU polling (PendingWait::wait_until_satisfied) for a counter inside a sparse VRAM window, CPU memory only holds the last uploaded/copied-back value while GPU writes live in sparse VRAM. This reads back [va, va + width) from sparse VRAM (sparse::readback_now) before spinning and at 10 ms intervals during the sleep loop (plus a final readback on timeout). Addresses item #2 measured in #505 (and keeps coherent-window / heap addresses lock-free on the fast path via uma::is_sparse). Part of #505.

What is in it

  • crates/xcl/src/hle/d3d12x/sparse.rs:
    • sparse::contains(va): checks gpu::uma::get().is_some_and(|u| u.is_sparse(va)) before taking STATE to verify an active sparse window covers va.
  • crates/xcl/src/hle/d3d12x/list_x.rs:
    • PendingWait::wait_until_satisfied / wait_until_satisfied_with: preserves the zero-overhead fast path when CPU memory already satisfies the wait; for unsatisfied sparse-window addresses, runs sparse::readback_now(va, width) before spinning, throttled at 10 ms intervals while polling, and once on timeout expiry.
    • Unit test pending_wait_sparse_readback_pulls_gpu_writes_and_skips_coherent verifying coherent waits never call readback and sparse waits pull delayed writes cleanly.
    • GPU test pending_wait_reads_back_gpu_write_in_sparse_window verifying a real CopyBufferRegion into a sparse window buffer (invisible to CPU-only polling) is read back and satisfies PendingWait::wait_until_satisfied.

Tested

  • GPU: NVIDIA GeForce RTX 3060 Ti (8024 MiB VRAM, driver 32.0.16.1088, 32-lane waves); CPU: Intel Core i5-12400F; 16 GB RAM; Windows 11 Pro Build 22631; Rust 1.100.0 (stable-x86_64-pc-windows-msvc), debug (scripts/test.ps1) and release (cargo build --release -p xcl).
  • cargo test --workspace -- --test-threads=4 (scripts/test.ps1): 729 passed, 0 failed, 41 ignored (SKIPPED GPU tests: 2 (no wave64: gpu_geometry_wave32_prefix_count_over_a_mask, gpu_wave32_program_in_wave64_hardware)).
  • cargo test -p xcl --lib pending_wait_ -- --test-threads=4: 3 passed, 0 failed (run 3 consecutive times with 0 flakes). In pending_wait_reads_back_gpu_write_in_sparse_window, CPU-only polling (wait_until_satisfied_with(..., false, ...)) fails on the real GPU sparse-VRAM write before wait_until_satisfied passes with sparse readback enabled.

Regression run
main:

xcl-smoke v1
commit: 6efdabcdaac93ce5cc123a85e85deba5d49cb294
gpu: NVIDIA GeForce RTX 3060 Ti
title: retail-title
seconds: 60
exit: 0x0
frames shown: 1508 (PresentX 1509)
presents per 2 s (last 3): 60 60 60
device removals: 0
crashes: 0
peak commit: 10406 MB

PR:

xcl-smoke v1
commit: 8fd59213003554c868d6b8729ecdb1fb7d09a77c
gpu: NVIDIA GeForce RTX 3060 Ti
title: retail-title
seconds: 60
exit: 0x0
frames shown: 1554 (PresentX 1554)
presents per 2 s (last 3): 61 59 61
device removals: 0
crashes: 0
peak commit: 10404 MB

Not tested

  • AMD GPUs / wave64 paths and Linux / Wine + vkd3d-proton.
  • A retail title phase where a CPU-fallback Wait64BitValueX counter explicitly lands in a sparse window on main (not yet triggered during our 60 s retail smoke run).

AI use

  • Antigravity (Google DeepMind; exact model identifier not exposed in environment) analyzed #505 and the D3D12.X sync/sparse implementation, wrote the fix and tests, and ran the test suite and retail smoke runs.
**@⁠xroneyaa** on GitHub · 2026-11-24 10:48 UTC · [original](https://github.com/xcl-dev/xcl/pull/1044) `xroneyaa:d3d12x-wait64-sparse-readback` → `main` · +163 −0 · 2 files · 1 commits · open When a `Wait32/64BitValueX` falls back to CPU polling (`PendingWait::wait_until_satisfied`) for a counter inside a sparse VRAM window, CPU memory only holds the last uploaded/copied-back value while GPU writes live in sparse VRAM. This reads back `[va, va + width)` from sparse VRAM (`sparse::readback_now`) before spinning and at 10 ms intervals during the sleep loop (plus a final readback on timeout). Addresses item #2 measured in `#505` (and keeps coherent-window / heap addresses lock-free on the fast path via `uma::is_sparse`). Part of #505. **What is in it** - `crates/xcl/src/hle/d3d12x/sparse.rs`: - `sparse::contains(va)`: checks `gpu::uma::get().is_some_and(|u| u.is_sparse(va))` before taking `STATE` to verify an active sparse window covers `va`. - `crates/xcl/src/hle/d3d12x/list_x.rs`: - `PendingWait::wait_until_satisfied` / `wait_until_satisfied_with`: preserves the zero-overhead fast path when CPU memory already satisfies the wait; for unsatisfied sparse-window addresses, runs `sparse::readback_now(va, width)` before spinning, throttled at 10 ms intervals while polling, and once on timeout expiry. - Unit test `pending_wait_sparse_readback_pulls_gpu_writes_and_skips_coherent` verifying coherent waits never call readback and sparse waits pull delayed writes cleanly. - GPU test `pending_wait_reads_back_gpu_write_in_sparse_window` verifying a real `CopyBufferRegion` into a sparse window buffer (invisible to CPU-only polling) is read back and satisfies `PendingWait::wait_until_satisfied`. **Tested** - GPU: NVIDIA GeForce RTX 3060 Ti (8024 MiB VRAM, driver 32.0.16.1088, 32-lane waves); CPU: Intel Core i5-12400F; 16 GB RAM; Windows 11 Pro Build 22631; Rust 1.100.0 (`stable-x86_64-pc-windows-msvc`), debug (`scripts/test.ps1`) and release (`cargo build --release -p xcl`). - `cargo test --workspace -- --test-threads=4` (`scripts/test.ps1`): 729 passed, 0 failed, 41 ignored (SKIPPED GPU tests: 2 (`no wave64`: `gpu_geometry_wave32_prefix_count_over_a_mask`, `gpu_wave32_program_in_wave64_hardware`)). - `cargo test -p xcl --lib pending_wait_ -- --test-threads=4`: 3 passed, 0 failed (run 3 consecutive times with 0 flakes). In `pending_wait_reads_back_gpu_write_in_sparse_window`, CPU-only polling (`wait_until_satisfied_with(..., false, ...)`) fails on the real GPU sparse-VRAM write before `wait_until_satisfied` passes with sparse readback enabled. **Regression run** main: ``` xcl-smoke v1 commit: 6efdabcdaac93ce5cc123a85e85deba5d49cb294 gpu: NVIDIA GeForce RTX 3060 Ti title: retail-title seconds: 60 exit: 0x0 frames shown: 1508 (PresentX 1509) presents per 2 s (last 3): 60 60 60 device removals: 0 crashes: 0 peak commit: 10406 MB ``` PR: ``` xcl-smoke v1 commit: 8fd59213003554c868d6b8729ecdb1fb7d09a77c gpu: NVIDIA GeForce RTX 3060 Ti title: retail-title seconds: 60 exit: 0x0 frames shown: 1554 (PresentX 1554) presents per 2 s (last 3): 61 59 61 device removals: 0 crashes: 0 peak commit: 10404 MB ``` **Not tested** - AMD GPUs / wave64 paths and Linux / Wine + vkd3d-proton. - A retail title phase where a CPU-fallback `Wait64BitValueX` counter explicitly lands in a sparse window on main (not yet triggered during our 60 s retail smoke run). **AI use** - Antigravity (Google DeepMind; exact model identifier not exposed in environment) analyzed `#505` and the D3D12.X sync/sparse implementation, wrote the fix and tests, and ran the test suite and retail smoke runs.
github-bot locked as GitHub sync and limited conversation to collaborators 2026-11-26 04:41:39 +00:00
Author
Owner

@⁠DavidM1911 on GitHub · 2026-11-24 11:25 UTC · original

Independent verification, merged onto current main 384f7f7 locally (clean merge).

Machine: Windows 11, Ryzen 9 7900X + RTX 3060 Ti + Radeon iGPU; Rust stable MSVC, debug.

  • cargo test -p xcl --lib wait: 15 passed, 0 failed — includes the two new tests pending_wait_sparse_readback_pulls_gpu_writes_and_skips_coherent and pending_wait_reads_back_gpu_write_in_sparse_window (the latter exercises the real UMA/sparse path).

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

**@⁠DavidM1911** on GitHub · 2026-11-24 11:25 UTC · [original](https://github.com/xcl-dev/xcl/pull/1044#issuecomment-7130079938) Independent verification, merged onto current `main` `384f7f7` locally (clean merge). **Machine:** Windows 11, Ryzen 9 7900X + RTX 3060 Ti + Radeon iGPU; Rust stable MSVC, debug. - `cargo test -p xcl --lib wait`: **15 passed, 0 failed** — includes the two new tests `pending_wait_sparse_readback_pulls_gpu_writes_and_skips_coherent` and `pending_wait_reads_back_gpu_write_in_sparse_window` (the latter exercises the real UMA/sparse path). AI use: test runs by Devin (Cognition, SWE-2); no code changes.
Author
Owner

@⁠AlexandreSchuelter on GitHub · 2026-11-24 11:26 UTC · original

Test report on AMD (RX 6900 XT, RDNA2): no new failures, and the sparse-window GPU test runs (not skipped) and passes here.

Tested

  • AMD Radeon RX 6900 XT (Navi 21), driver 32.0.21045.29003; Ryzen 7 5800X3D; Windows NT 10.0.26300
  • Rust 1.100.0 stable-x86_64-pc-windows-msvc, debug; DXC 1.9.2602.17; XCL_NETWORK=0, XCL_REQUIRE_GPU=wave64; no SKIPPED tests
  • cargo build --workspace + cargo test --workspace --no-fail-fast -- --test-threads=4:
Tree Passed Failed Ignored
main 47efa2e 738 3 41
this PR (8fd5921) merged onto 47efa2e 740 3 41
  • The 3 failures are the same on both trees and come from main: the RDNA2 packed-mip failure in placed_title_textures_share_vram_and_preserve_pixels (fixed by #470 / #1028) and its two PoisonError cascades.
  • pending_wait_reads_back_gpu_write_in_sparse_window and pending_wait_sparse_readback_pulls_gpu_writes_and_skips_coherent pass; neither printed a SKIPPED line (no "no GPU" / "no sparse UMA" skip).

Not tested

  • A retail title / scripts/smoke.ps1 (no game here), release build, repeated runs of the new tests, Linux / vkd3d-proton
  • The PR as-is (only merged onto main)

AI use: Claude Code (Claude Opus 5.5) fetched the branch, ran the suites and wrote this report; the runs are real, on the hardware above.

**@⁠AlexandreSchuelter** on GitHub · 2026-11-24 11:26 UTC · [original](https://github.com/xcl-dev/xcl/pull/1044#issuecomment-7130110309) Test report on AMD (RX 6900 XT, RDNA2): no new failures, and the sparse-window GPU test runs (not skipped) and passes here. **Tested** - AMD Radeon RX 6900 XT (Navi 21), driver 32.0.21045.29003; Ryzen 7 5800X3D; Windows NT 10.0.26300 - Rust 1.100.0 `stable-x86_64-pc-windows-msvc`, debug; DXC 1.9.2602.17; `XCL_NETWORK=0`, `XCL_REQUIRE_GPU=wave64`; no SKIPPED tests - `cargo build --workspace` + `cargo test --workspace --no-fail-fast -- --test-threads=4`: | Tree | Passed | Failed | Ignored | |---|---|---|---| | `main` `47efa2e` | 738 | 3 | 41 | | this PR (`8fd5921`) merged onto `47efa2e` | 740 | 3 | 41 | - The 3 failures are the same on both trees and come from `main`: the RDNA2 packed-mip failure in `placed_title_textures_share_vram_and_preserve_pixels` (fixed by #470 / #1028) and its two `PoisonError` cascades. - `pending_wait_reads_back_gpu_write_in_sparse_window` and `pending_wait_sparse_readback_pulls_gpu_writes_and_skips_coherent` pass; neither printed a `SKIPPED` line (no "no GPU" / "no sparse UMA" skip). **Not tested** - A retail title / `scripts/smoke.ps1` (no game here), release build, repeated runs of the new tests, Linux / vkd3d-proton - The PR as-is (only merged onto `main`) **AI use**: Claude Code (Claude Opus 5.5) fetched the branch, ran the suites and wrote this report; the runs are real, on the hardware above.
Author
Owner

@⁠JJAutoCompare on GitHub · 2026-11-25 05:31 UTC · original

Empirical test report (8fd59213)

Commit 8fd59213003554c868d6b8729ecdb1fb7d09a77c (PR #1044).

Hardware / environment

  • Intel Arc A770 selected with XCL_ADAPTER=A770, Windows x64 build 26200, and an AMD Family 23 Model 113 CPU. The fixture initialized three sparse VRAM windows and a 512 MB coherent window. The GPU driver version was not recorded.
  • rustc 1.100.0 (0ef1bc386 2026-11-09), DXC 1.9.2609.5, and Cargo's unoptimized test profile with debug info and incremental compilation disabled. The focused run used RUST_TEST_NOCAPTURE=1.

Commands and results

  • cargo test --workspace --no-run compiled the workspace test binaries outside the Arc lock (exit 0).
  • Inside Invoke-ArcTest.ps1, ran only the two new fixtures using the prebuilt xcl library test executable (exit 0):
xcl-77aca8ccb20e299f.exe --exact hle::d3d12x::list_x::tests::pending_wait_sparse_readback_pulls_gpu_writes_and_skips_coherent hle::d3d12x::list_x::tests::pending_wait_reads_back_gpu_write_in_sparse_window --test-threads=2
  • 2 passed, 0 failed, 0 ignored, 0 skipped, 706 filtered out. Both fixtures exercised their assertions.

Observed behavior

  • The CPU fixture verified that non-sparse and already-satisfied waits bypass readback. It also verified that sparse waits can complete on the first readback or after a later poll.
  • The GPU fixture copied a 64-bit value into a mapped sparse VRAM tile and waited for the copy to complete. The CPU view remained zero and a CPU-only poll timed out. The sparse wait succeeded and the CPU view matched the GPU-written value.

Not tested

The full GPU workspace suite and game smoke runs were omitted.

AI use

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

**@⁠JJAutoCompare** on GitHub · 2026-11-25 05:31 UTC · [original](https://github.com/xcl-dev/xcl/pull/1044#issuecomment-7153858159) ### Empirical test report (8fd59213) Commit `8fd59213003554c868d6b8729ecdb1fb7d09a77c` (PR #1044). **Hardware / environment** - Intel Arc A770 selected with `XCL_ADAPTER=A770`, Windows x64 build 26200, and an AMD Family 23 Model 113 CPU. The fixture initialized three sparse VRAM windows and a 512 MB coherent window. The GPU driver version was not recorded. - `rustc 1.100.0 (0ef1bc386 2026-11-09)`, DXC 1.9.2609.5, and Cargo's unoptimized test profile with debug info and incremental compilation disabled. The focused run used `RUST_TEST_NOCAPTURE=1`. **Commands and results** - `cargo test --workspace --no-run` compiled the workspace test binaries outside the Arc lock (exit 0). - Inside `Invoke-ArcTest.ps1`, ran only the two new fixtures using the prebuilt `xcl` library test executable (exit 0): ```text xcl-77aca8ccb20e299f.exe --exact hle::d3d12x::list_x::tests::pending_wait_sparse_readback_pulls_gpu_writes_and_skips_coherent hle::d3d12x::list_x::tests::pending_wait_reads_back_gpu_write_in_sparse_window --test-threads=2 ``` - 2 passed, 0 failed, 0 ignored, 0 skipped, 706 filtered out. Both fixtures exercised their assertions. **Observed behavior** - The CPU fixture verified that non-sparse and already-satisfied waits bypass readback. It also verified that sparse waits can complete on the first readback or after a later poll. - The GPU fixture copied a 64-bit value into a mapped sparse VRAM tile and waited for the copy to complete. The CPU view remained zero and a CPU-only poll timed out. The sparse wait succeeded and the CPU view matched the GPU-written value. **Not tested** The full GPU workspace suite and game smoke runs were omitted. **AI use** Verified with T3 Code / Codex (gpt-6.2-sol, reasoningEffort: high). Coordinator #2 (T3 Code / Antigravity, gemini-4-neon) verified counts against `pr1044-focused.log` and published.
Author
Owner

@⁠luckyteagirl on GitHub · 2026-11-25 06:17 UTC · original

Independent native Windows AMD GPU check of exact PR head 8fd59213003554c868d6b8729ecdb1fb7d09a77c.

Tested

  • Windows 11 build 26200, Ryzen 9 5980HX, Radeon RX 6800M driver 30.0.13002.13003, Rust 1.99.0 MSVC, DXC/DXIL 1.9.2609.5.
  • XCL_ADAPTER=6800M XCL_REQUIRE_GPU=wave64 cargo test --locked -p xcl --lib -j 2 pending_wait_ -- --test-threads=1 --show-output: 3 passed, 0 failed, 0 ignored in 1.26 s, with no SKIPPED line.
  • The run included pending_wait_reads_back_gpu_write_in_sparse_window. Its log shows three sparse VRAM windows and D3D12.X UMA initialization on the RX 6800M; the GPU fixture completed. The other two wait tests passed as well.

This checks the focused sparse readback regression on the PR head. I did not run a full workspace suite, a current-main merge, or a retail title phase with a sparse counter wait. No game data was used or uploaded.

AI-assisted testing and report drafting with OpenAI Codex (GPT-6); I checked the exact revision and test log before posting.

**@⁠luckyteagirl** on GitHub · 2026-11-25 06:17 UTC · [original](https://github.com/xcl-dev/xcl/pull/1044#issuecomment-7154646954) Independent native Windows AMD GPU check of exact PR head `8fd59213003554c868d6b8729ecdb1fb7d09a77c`. **Tested** - Windows 11 build 26200, Ryzen 9 5980HX, Radeon RX 6800M driver `30.0.13002.13003`, Rust 1.99.0 MSVC, DXC/DXIL 1.9.2609.5. - `XCL_ADAPTER=6800M XCL_REQUIRE_GPU=wave64 cargo test --locked -p xcl --lib -j 2 pending_wait_ -- --test-threads=1 --show-output`: **3 passed, 0 failed, 0 ignored** in 1.26 s, with no `SKIPPED` line. - The run included `pending_wait_reads_back_gpu_write_in_sparse_window`. Its log shows three sparse VRAM windows and D3D12.X UMA initialization on the RX 6800M; the GPU fixture completed. The other two wait tests passed as well. This checks the focused sparse readback regression on the PR head. I did not run a full workspace suite, a current-main merge, or a retail title phase with a sparse counter wait. No game data was used or uploaded. AI-assisted testing and report drafting with OpenAI Codex (GPT-6); I checked the exact revision and test log before posting.
Author
Owner

@⁠upipibi on GitHub · 2026-11-25 18:19 UTC · original · edited 2026-11-25 18:20 UTC

NVIDIA test report for 8fd5921 (head as is, base 6efdabc), 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: 720 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.

**@⁠upipibi** on GitHub · 2026-11-25 18:19 UTC · [original](https://github.com/xcl-dev/xcl/pull/1044#issuecomment-7170748486) · edited 2026-11-25 18:20 UTC NVIDIA test report for `8fd5921` (head as is, base `6efdabc`), 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`: **720 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.
This pull request has changes conflicting with the target branch.
  • crates/xcl/src/hle/d3d12x/list_x.rs
View command line instructions

Manual merge helper

Use this merge commit message when completing the merge manually.

Checkout

From your project repository, check out a new branch and test the changes.
git fetch -u origin '+refs/pull/1044/head:github-bot/gh-1044'
git switch 'github-bot/gh-1044'

Merge

Merge the changes and update on Forgejo.
git switch 'main'
git merge --no-ff 'github-bot/gh-1044'
git switch 'github-bot/gh-1044'
git rebase 'main'
git switch 'main'
git merge --ff-only 'github-bot/gh-1044'
git switch 'github-bot/gh-1044'
git rebase 'main'
git switch 'main'
git merge --no-ff 'github-bot/gh-1044'
git switch 'main'
git merge --squash 'github-bot/gh-1044'
git switch 'main'
git merge --ff-only 'github-bot/gh-1044'
git switch 'main'
git merge 'github-bot/gh-1044'
git push origin 'main'
This discussion has been locked. Commenting is limited to contributors.
No description provided.