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

Merged
Foniass merged 1 commit from upstream-pr/3278 into main 2026-11-29 16:17:33 +00:00
Foniass commented 2026-11-29 03:26:53 +00:00 (Migrated from github.com)

Imported from ivall/xcl. Originally posted by Foniass on 2026-11-29T03:26:53Z.


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

  • a CI run of this head (it is the test that shows it)
  • the other flaky test in #3250's run, uma_driver::tests::mixed_window_keeps_its_bytes_and_the_gpu_sees_every_segment (its watched regions sometimes include the 128 MiB GPU_UPLOAD segment). It has a different cause, and #3187 already addresses those mixed-window tests, so it is not touched here.

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

<!-- greyfinch-sync:ivall/xcl:issue:5547175747 --> Imported from [ivall/xcl](https://github.com/xcl-dev/xcl/pull/3278). Originally posted by [Foniass](https://github.com/Foniass) on 2026-11-29T03:26:53Z. --- 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** - a CI run of this head (it is the test that shows it) - the other flaky test in #3250's run, `uma_driver::tests::mixed_window_keeps_its_bytes_and_the_gpu_sees_every_segment` (its watched regions sometimes include the 128 MiB GPU_UPLOAD segment). It has a different cause, and #3187 already addresses those mixed-window tests, so it is not touched here. **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](https://claude.com/claude-code)
Kalmarv commented 2026-11-29 03:42:19 +00:00 (Migrated from github.com)

Imported from ivall/xcl. Originally posted by Kalmarv on 2026-11-29T03:42:19Z.


merge-check
base: fa204595a4
head: 51ca7b0d41
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.

<!-- greyfinch-sync:ivall/xcl:comment:7250209371 --> Imported from [ivall/xcl](https://github.com/xcl-dev/xcl/pull/3278#issuecomment-7250209371). Originally posted by [Kalmarv](https://github.com/Kalmarv) on 2026-11-29T03:42:19Z. --- merge-check base: fa204595a488c60c6c5f905244f0172072c9c2a9 head: 51ca7b0d41302acbcdd865f47c33655359281fbe 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.
tiagonleal commented 2026-11-29 12:02:51 +00:00 (Migrated from github.com)

Imported from ivall/xcl. Originally posted by tiagonleal on 2026-11-29T12:02:51Z.


merge-check
base: d8bd9a3820
head: 51ca7b0d41
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.

<!-- greyfinch-sync:ivall/xcl:comment:7255527657 --> Imported from [ivall/xcl](https://github.com/xcl-dev/xcl/pull/3278#issuecomment-7255527657). Originally posted by [tiagonleal](https://github.com/tiagonleal) on 2026-11-29T12:02:51Z. --- merge-check base: d8bd9a38204667f3ca7dd9eeffcc2f1c937b07b0 head: 51ca7b0d41302acbcdd865f47c33655359281fbe 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](https://github.com/xcl-dev/xcl/actions/runs/46257774766), [46260503226](https://github.com/xcl-dev/xcl/actions/runs/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 commented 2026-11-29 13:08:57 +00:00 (Migrated from github.com)

Imported from ivall/xcl. Originally posted by tiagonleal on 2026-11-29T13:08:57Z.


@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
<!-- greyfinch-sync:ivall/xcl:comment:7256324133 --> Imported from [ivall/xcl](https://github.com/xcl-dev/xcl/pull/3278#issuecomment-7256324133). Originally posted by [tiagonleal](https://github.com/tiagonleal) on 2026-11-29T13:08:57Z. --- @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
Sign in to join this conversation.
No reviewers
No labels
No milestone
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Reference
xcl-dev/xcl!3278
No description provided.