Skip to content

Tests: a title-queue upload waits for at least the mappings made before it - #3278

Merged
Prime1997 merged 1 commit into
xcl-dev:mainfrom
Foniass:tests-title-queue-mapping-race
Nov 29, 2026
Merged

Prime1997 merged 1 commit into
xcl-dev:mainfrom
Foniass:tests-title-queue-mapping-race

Conversation

@Foniass

@Foniass Foniass commented Nov 29, 2026 •

Copy link
Copy Markdown
Collaborator

Fixes the flaky Build and test (Windows, no GPU) failures that show up on many PRs that never touch D3D12.X (e.g. #3250, #3266): 8 title_textures tests red in one run, green in the next.

There is one flaky test, gpu_a_title_queue_upload_waits_for_the_page_mappings_before_it. It asserted that the upload waited for exactly the page-mapping value the test had just made. That value is device-wide: every mapping and unmapping on the device raises it (vram.rs, self.value += 1 in map / unmap), including late releases of earlier tests and tests that do not hold VRAM_TEST_LOCK. When one lands between the test's mapping and its upload, the upload rightly waits for the newer value and the test fails. CI logs: left: 28, right: 26. Its panic then poisons TEST_LOCK, so the next 7 title_textures tests fail on PoisonError in the same run.

The test now asserts what its doc comment says: the upload waits for at least the mapping made before it, and for no more than the device has reached. An upload that does not wait still fails it, so the check keeps what it tests; it no longer requires that nothing else maps pages meanwhile.

What is in it

  • crates/xcl/src/hle/d3d12x/title_textures.rs: the assertion, with the three values in its message
  • crates/xcl/src/hle/d3d12x/vram.rs: mapping_value_for_test (test-only)

Test-only: both changes are in #[cfg(test)] code. It touches files under crates/xcl/src, so it needs the test-only label instead of smoke runs.

Tested

  • RTX 5070 Ti (driver 32.0.16.2114), Windows 11 build 26300, Rust 1.100.0 msvc, debug
  • cargo test -p xcl --lib title_textures -- --test-threads=4: 63 passed, 0 failed, 1 ignored
  • cargo test -p xcl --lib -- --test-threads=4: 2465 passed, 4 failed, 29 ignored. The 4 are gpu::dxil::fuzz_tests::fuzz_validate_and_gpu_0..3 with a driver E_OUTOFMEMORY that this machine also has on main (they pass on other 5070 Tis).
  • The flake itself never reproduced on this machine; the fix comes from the CI logs and the code, not from catching it locally.

Not tested

AI use

  • Claude Code with Claude Opus 5.5: traced the failures in the CI logs, wrote the change and this description, ran the tests above.

🤖 Generated with Claude Code

…re it

gpu_a_title_queue_upload_waits_for_the_page_mappings_before_it asserted
that the upload waited for exactly the page-mapping value the test had
just made. The value is device-wide: every mapping and unmapping on the
device raises it, including late releases of earlier tests and tests
that do not hold VRAM_TEST_LOCK. When one lands between the test's
mapping and its upload, the upload rightly waits for the newer value,
and the test failed (CI: "left: 28, right: 26"). It then poisoned
TEST_LOCK, so seven more title_textures tests failed on PoisonError in
the same run; that is most of the "Build and test" failures on recent
PRs that do not touch D3D12.X.

The test now asserts what it describes: the upload waits for at least
the mapping made before it, and for no more than the device has
reached (new vram::mapping_value_for_test). An upload that does not
wait still fails it.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@github-actions github-actions Bot added area:d3d12 D3D12.X runtime, command lists, resources, sparse memory area:memory Virtual/physical memory, arenas, VRAM budget, UMA gpu:both Code affects both AMD and NVIDIA GPUs (scope tag; see needs:*-test for remaining checks) labels Nov 29, 2026
@Kalmarv

Kalmarv commented Nov 29, 2026

Copy link
Copy Markdown
Contributor

merge-check
base: fa20459
head: 51ca7b0
merge: clean onto main.
build: cargo test -p xcl --lib title_textures::tests -> ok (test-only change: #[cfg(test)] helper in vram.rs + test assertion in title_textures.rs).
tests: cargo test -p xcl --lib title_textures::tests -- --test-threads=4 (DXC 1.9.2609.5) -> 63 passed, 0 failed, 1 ignored (including gpu_a_title_queue_upload_waits_for_the_page_mappings_before_it); failing: none.
review: none (whole 12-line diff read: vram::mapping_value_for_test is #[cfg(test)]-only and reads PAGES under its mutex; changing assert_eq!(waited, mapped) to mapped <= waited && waited <= now fixes the parallel-test device-wide fence increment race while still failing if an upload does not wait).
performance: zero runtime impact (#[cfg(test)] only).
verdict: safe to merge
hardware / tool and model: NVIDIA GeForce RTX 5070 Ti 16 GB, Windows 11, DXC 1.9.2609.5 via XCL_DXC_DIR; Antigravity (Gemini 3.5 Pro) ran the merge, tests, diff review, and drafted this check.

@github-actions github-actions Bot added the needs-pr-check Failing the PR description check (CONTRIBUTING.md) label Nov 29, 2026
@tiagonleal

tiagonleal commented Nov 29, 2026 •

Copy link
Copy Markdown
Contributor

merge-check
base: d8bd9a3
head: 51ca7b0
merge: clean (trial merge 722f5631, local, not pushed; git diff --check clean). main moved to d2ec83de while this ran; the trial merge onto it is clean too. Build and tests below are on the d8bd9a38 merge.
build: cargo build --workspace -> ok
tests: cargo test --workspace --no-fail-fast -j 8 -- --test-threads=4 -> 2614 passed, 4 failed, 49 ignored; SKIPPED: 26 (21 "no wave64" on this GPU, 3 per-lane f16 forms refused, 2 "no heap windows"); failing: gpu::dxil::fuzz_tests::fuzz_validate_and_gpu_0 to _3, which fail on the base too. Then the lib test binary with the filter title_textures and --test-threads=16, 20 times: 63 passed, 0 failed, 1 ignored every time, gpu_a_title_queue_upload_waits_for_the_page_mappings_before_it among them. I did not loop the base, so these 20 runs show no regression; they do not show the flake going away, which I have not seen fail on this PC.
review: whole diff read (+15/-4; the test in title_textures.rs and a #[cfg(test)] reader in vram.rs). The old assert wanted the upload to have waited for exactly the mapping value the test had just made. That value is one counter per device and every map or unmap raises it, so a parallel test can move it between the test's mapping and its upload. The new assert is mapped <= waited && waited <= now, with now read after waited: an upload that does not wait still fails it (waited stays below mapped), and a wait for a value the device never reached fails it too. mapping_value_for_test only reads PAGES under its lock. No runtime code changes. The failure is real on CI today: two runs on PRs of mine that do not touch this code went red on this group (46257774766, 46260503226), each with this test first (left: 28, right: 26 in the first run) and the other seven on PoisonError.
performance: none, test code only.
verdict: safe to merge
hardware / tool and model: NVIDIA GeForce RTX 5070 Ti 16 GB (617.42), AMD Ryzen 7 9800X3D, Windows 11 Pro 26300, rustc 1.100.0, debug / Claude Code: Claude Fable 5.2 ran the merge, build, suite and loop and read the diff.

  • Tiago

Note for @Foniass: the PR description check is red because the body has no xcl-smoke blocks (title_textures.rs counts as a runtime file). Both blocks, from scripts/smoke.ps1 on this head and on main, are in my next comment for you to paste, if that helps.

@tiagonleal

Copy link
Copy Markdown
Contributor

@Foniass here are the two xcl-smoke blocks the PR description check asks for, in case you have no retail title at hand. scripts/smoke.ps1 -Seconds 60 -Title 9cc6a39e (Newer Retail Game), release builds in clean trees, one run each, XCL_PREPARE=0, same DXIL cache, RTX 5070 Ti. The PR block is on your head 51ca7b0d as it is, not on a merge with main. Paste them under Regression run if you want to use them; they stop matching if you push again.

main (d2ec83de):

xcl-smoke v1
commit: d2ec83de146a41c3e5a6b6aab3829f7f9395f01f
gpu: NVIDIA GeForce RTX 5070 Ti
title: 9cc6a39e
seconds: 60
exit: 0x0
frames shown: 1685 (PresentX 1685)
presents per 2 s (last 3): 60 60 60
device removals: 0
crashes: 0
peak commit: 16667 MB

This PR (51ca7b0d):

xcl-smoke v1
commit: 51ca7b0d41302acbcdd865f47c33655359281fbe
gpu: NVIDIA GeForce RTX 5070 Ti
title: 9cc6a39e
seconds: 60
exit: 0x0
frames shown: 1695 (PresentX 1695)
presents per 2 s (last 3): 60 60 60
device removals: 0
crashes: 0
peak commit: 16986 MB

AI use: Claude Code (Claude Fable 5.2) ran the two builds and the smoke script.

  • Tiago

@Prime1997 Prime1997 added the test-only A maintainer reviewed the diff: tests only, no smoke run needed for this revision (CONTRIBUTING.md) label Nov 29, 2026
@Prime1997
Prime1997 merged commit cef7a54 into xcl-dev:main Nov 29, 2026
4 of 6 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area:d3d12 D3D12.X runtime, command lists, resources, sparse memory area:memory Virtual/physical memory, arenas, VRAM budget, UMA gpu:both Code affects both AMD and NVIDIA GPUs (scope tag; see needs:*-test for remaining checks) needs-pr-check Failing the PR description check (CONTRIBUTING.md) test-only A maintainer reviewed the diff: tests only, no smoke run needed for this revision (CONTRIBUTING.md)

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants