From 51ca7b0d41302acbcdd865f47c33655359281fbe Mon Sep 17 00:00:00 2001 From: Foniass <107039406+Foniass@users.noreply.github.com> Date: Sun, 29 Nov 2026 04:26:35 +0100 Subject: [PATCH] Tests: a title-queue upload waits for at least the mappings made before 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 --- crates/xcl/src/hle/d3d12x/title_textures.rs | 12 ++++++++---- crates/xcl/src/hle/d3d12x/vram.rs | 7 +++++++ 2 files changed, 15 insertions(+), 4 deletions(-) diff --git a/crates/xcl/src/hle/d3d12x/title_textures.rs b/crates/xcl/src/hle/d3d12x/title_textures.rs index e6a68a9ed5..ba8c10f487 100644 --- a/crates/xcl/src/hle/d3d12x/title_textures.rs +++ b/crates/xcl/src/hle/d3d12x/title_textures.rs @@ -4488,10 +4488,14 @@ pub(super) mod tests { let _queue_uploads = DirectQueueUploads::new(&queue); let (item, _mem) = r8_item(&texture, 0x3C); own_work(|| submit_on(dev, &queue, &[item])).unwrap(); - assert_eq!( - super::super::vram::waited_for_test(raw_device as usize, key), - mapped, - "the title queue's upload must wait for the page mappings made before it" + // Other tests and late releases map and unmap pages on the same device meanwhile, so + // the upload waits for the value at its submit: at least the mapping made above, and + // no more than the device has reached. + let waited = super::super::vram::waited_for_test(raw_device as usize, key); + let now = super::super::vram::mapping_value_for_test(raw_device as usize); + assert!( + mapped <= waited && waited <= now, + "the title queue's upload must wait for the page mappings made before it (made {mapped}, waited for {waited}, device at {now})" ); assert_eq!(read_r8(dev, &queue, &texture), vec![0x3C; 64 * 64]); } diff --git a/crates/xcl/src/hle/d3d12x/vram.rs b/crates/xcl/src/hle/d3d12x/vram.rs index 25371e8f97..38c7f70c7a 100644 --- a/crates/xcl/src/hle/d3d12x/vram.rs +++ b/crates/xcl/src/hle/d3d12x/vram.rs @@ -2838,6 +2838,13 @@ pub(super) unsafe fn note_mapping_for_test(dev: &ID3D12Device) -> Option { Some(pages.value) } +/// The page mapping value of `dev` now: every mapping and unmapping on the device raises it. +#[cfg(test)] +pub(super) fn mapping_value_for_test(dev: usize) -> u64 { + let g = PAGES.lock().unwrap(); + g.get(&dev).and_then(|p| p.as_ref()).map_or(0, |p| p.value) +} + /// The page mapping value `queue` was last made to wait for on `dev` (`before_execute`). #[cfg(test)] pub(super) fn waited_for_test(dev: usize, queue: usize) -> u64 {