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 {