From 7a4f0afaae5e3cde7abee4c13b5e0dc3cc5d8a5f Mon Sep 17 00:00:00 2001 From: CryingLaughing <62956736+CryingLaughing@users.noreply.github.com> Date: Fri, 27 Nov 2026 06:49:53 +0800 Subject: [PATCH] D3D12.X: honor placed buffer offsets in CopyTiles Use the console placement prefix in both directions for graphics and DMA lists. Verify native readback and keep host CopyTiles offsets unchanged. Fixes #2908 --- README.md | 2 +- crates/xcl/src/hle/d3d12x/list_x.rs | 19 +++ crates/xcl/src/hle/d3d12x/real.rs | 98 ++++++++++++- crates/xcl/tests/d3d12_resource_and_sync.rs | 152 ++++++++++++++++++++ 4 files changed, 265 insertions(+), 6 deletions(-) diff --git a/README.md b/README.md index 0f7b14c29e..d409bca324 100644 --- a/README.md +++ b/README.md @@ -150,7 +150,7 @@ A gamepad is recommended ([Controls](#controls)). The game folder is never modif | **Shader recompiler** | ✅ | RDNA2 → HLSL → DXIL: VS, PS, CS, mesh (NGG), GS; atomics, LDS, scratch, images, samplers incl. static ones, wave ops, ray-tracing instructions; structured control flow; parallel DXC, disk cache | 26 698 / 26 698 programs of the retail pack; 0 DXC errors on random samples; per-instruction GPU tests | | **Pipelines** | ✅ | PSOs from console shaders: VS+PS, CS, MS+PS, VS+GS+PS; root signature with the shaders' static samplers; non-blocking creation – a pipeline whose shaders are not compiled yet gets a stand-in at once and is built in the background | GPU tests drawing the game's own VS / PS pairs, also built in the background | | **D3D12.X compute** | ✅ | console device slots, console descriptor heaps (T# / V# / S#), buffers at their console addresses, compute command lists recorded in the console format and replayed (tables, barriers, clears, copies) | the game's BVH builder and FSR 4 record and run through XCL | -| **D3D12.X graphics** | ✅ | device, resources and heaps (also placed in title memory), pipelines; the title's graphics command lists – draws, indirect draws, graphics root arguments, barriers, copies, clears – and command lists recorded by console code, replayed; `PresentX` and frame pacing into an XCL window | Minecraft Preview plays its worlds (millions of draws, none skipped); Fortnite and XDefiant draw their screens | +| **D3D12.X graphics** | ✅ | device, resources and heaps (also placed in title memory), pipelines; the title's graphics command lists – draws, indirect draws, graphics root arguments, barriers, copies (including tile copies with console-placed buffers), clears – and command lists recorded by console code, replayed; `PresentX` and frame pacing into an XCL window | Minecraft Preview plays its worlds (millions of draws, none skipped); Fortnite and XDefiant draw their screens | | **Textures** | ✅ | GFX10 tiling (all 14 2D swizzle modes, the 6 3D thick modes, linear), mip chains with mip tail, arrays, cubes and 3D textures → PC textures | 912 / 912 entries detiled in the tested retail archive; GPU upload bit exact in test fixtures | | **Ray tracing** | ✅ | BLAS / TLAS built on the GPU by the game's own XboxBvhBuilder; RDNA2 BVH node format; BVH intersection instructions emulated in shaders | GPU traversal = brute force reference; the game's builder output checked on the GPU | | **Upscaling** | ✅ | the game's AMD FSR 4 console DLL (`amd_fidelityfx_upscaler_xbox.dll`): context, the 29 pipelines in the console driver's own container (FSPX) translated, a frame's 20 passes recorded and run on the GPU | end-to-end with the real DLL: a 1280×720 → 1920×1080 frame on an RX 9070, the input's gradient in the output | diff --git a/crates/xcl/src/hle/d3d12x/list_x.rs b/crates/xcl/src/hle/d3d12x/list_x.rs index ee544dec22..de77c5f890 100644 --- a/crates/xcl/src/hle/d3d12x/list_x.rs +++ b/crates/xcl/src/hle/d3d12x/list_x.rs @@ -37,6 +37,7 @@ const PC_RESET: usize = 10; const PC_COPY_BUFFER_REGION: usize = 15; const PC_COPY_TEXTURE_REGION: usize = 16; const PC_COPY_RESOURCE: usize = 17; +const PC_COPY_TILES: usize = 18; const PC_SET_PIPELINE_STATE: usize = 25; const PC_RESOURCE_BARRIER: usize = 26; const PC_IA_SET_INDEX_BUFFER: usize = 43; @@ -4258,6 +4259,24 @@ pub(super) unsafe extern "system" fn copy_buffer_region_x(this: *mut c_void, dst pc::(this, PC_COPY_BUFFER_REGION)(this, dst, dst_off + real::buffer_delta(dst), src, src_off + real::buffer_delta(src), n) } +/// CopyTiles uses a byte offset into its linear buffer in either copy direction. +pub(super) unsafe extern "system" fn copy_tiles_x( + this: *mut c_void, + tiled: usize, + start: *const D3D12_TILED_RESOURCE_COORDINATE, + size: *const D3D12_TILE_REGION_SIZE, + buffer: usize, + buffer_offset: u64, + flags: D3D12_TILE_COPY_FLAGS, +) { + type CopyTiles = unsafe extern "system" fn( + *mut c_void, usize, *const D3D12_TILED_RESOURCE_COORDINATE, *const D3D12_TILE_REGION_SIZE, + usize, u64, D3D12_TILE_COPY_FLAGS, + ); + let offset = buffer_offset.saturating_add(real::buffer_delta(buffer)); + pc::(this, PC_COPY_TILES)(this, tiled, start, size, buffer, offset, flags); +} + /// `XCL_TRACE_FRAME` with a watched target (`present::watch_rt`): copies out of it – that /// object, or another at its title address (the first 16) unsafe fn trace_watched_copy(what: &str, dst: usize, src: usize) { diff --git a/crates/xcl/src/hle/d3d12x/real.rs b/crates/xcl/src/hle/d3d12x/real.rs index 19eedfe6ac..7d8af92061 100644 --- a/crates/xcl/src/hle/d3d12x/real.rs +++ b/crates/xcl/src/hle/d3d12x/real.rs @@ -868,10 +868,9 @@ unsafe fn class_for(obj: *mut c_void, orig: usize, kind: Kind) -> usize { fn console_remap(kind: Kind) -> Vec<(usize, usize)> { match kind { Kind::CommandList => (28..=31).map(|x| (x, x + 24)).chain((32..=55).map(|x| (x, x - 4))).chain((104..=109).map(|x| (x, x - 44))).chain([(124, 77), (125, 78)]).collect(), - // the DMA list: Close / Reset, then the copy methods (XDefiant calls #12 with - // CopyTextureRegion's arguments): 11–14 = PC 15–18 (CopyBufferRegion, CopyTextureRegion, - // CopyResource, CopyTiles); what follows is not known yet (`console_extensions`) - Kind::DmaList => (11..=14).map(|x| (x, x + 4)).collect(), + // The DMA list: Close / Reset, then 11–13 = PC 15–17 (CopyBufferRegion, + // CopyTextureRegion, CopyResource). CopyTiles at #14 is handled in `console_slots`. + Kind::DmaList => (11..=13).map(|x| (x, x + 4)).collect(), _ => Vec::new(), } } @@ -983,7 +982,7 @@ fn console_slots(kind: Kind) -> Vec<(usize, usize)> { Kind::CommandQueue => QUEUE_SLOTS.iter().enumerate().map(|(k, &f)| (QUEUE_FIRST + k, f as usize)).collect(), Kind::DmaList => { use super::list_x as l; - vec![(9, l::dma_close_x as usize), (10, l::reset_x as usize), (11, l::copy_buffer_region_x as usize), (12, l::copy_texture_region_x as usize), (13, l::copy_resource_x as usize)] + vec![(9, l::dma_close_x as usize), (10, l::reset_x as usize), (11, l::copy_buffer_region_x as usize), (12, l::copy_texture_region_x as usize), (13, l::copy_resource_x as usize), (14, l::copy_tiles_x as usize)] } Kind::CommandList => { use super::bind as b; @@ -994,6 +993,7 @@ fn console_slots(kind: Kind) -> Vec<(usize, usize)> { (15, l::copy_buffer_region_x as usize), (16, l::copy_texture_region_x as usize), (17, l::copy_resource_x as usize), + (18, l::copy_tiles_x as usize), (19, l::resolve_subresource_x as usize), (51, l::clear_depth_stencil_x as usize), (53, l::clear_uav_uint_x as usize), @@ -7971,6 +7971,94 @@ mod readback_routing_tests { assert!(slots.contains(&(54, l::clear_uav_float_x as usize))); } + #[test] + fn console_copy_tiles_adjusts_only_the_linear_buffer_offset() { + type CopyTiles = unsafe extern "system" fn( + *mut c_void, usize, *const D3D12_TILED_RESOURCE_COORDINATE, *const D3D12_TILE_REGION_SIZE, + usize, u64, D3D12_TILE_COPY_FLAGS, + ); + + #[repr(C)] + struct FakeList { + vtable: *const usize, + copies: Vec<(usize, usize, usize, usize, u64, i32)>, + dispatch: Option<(u32, u32, u32)>, + } + + unsafe extern "system" fn no_interface(_: *mut c_void, _: *const GUID, _: *mut *mut c_void) -> HRESULT { + E_NOINTERFACE + } + unsafe extern "system" fn release(_: *mut c_void) -> u32 { 0 } + unsafe extern "system" fn dispatch(list: *mut c_void, x: u32, y: u32, z: u32) { + (*list.cast::()).dispatch = Some((x, y, z)); + } + unsafe extern "system" fn record_copy( + list: *mut c_void, tiled: usize, start: *const D3D12_TILED_RESOURCE_COORDINATE, + size: *const D3D12_TILE_REGION_SIZE, buffer: usize, offset: u64, flags: D3D12_TILE_COPY_FLAGS, + ) { + (*list.cast::()).copies.push((tiled, start as usize, size as usize, buffer, offset, flags.0)); + } + + // The adopted class stores the original table beyond the lifetime of the fake list. + static NATIVE: OnceLock<[usize; 128 + MAX_SCAN]> = OnceLock::new(); + let native = NATIVE.get_or_init(|| { + let mut vtable = [0; 128 + MAX_SCAN]; + vtable[0] = no_interface as usize; + vtable[2] = release as usize; + vtable[14] = dispatch as usize; + vtable[18] = record_copy as usize; + vtable + }); + let resources = [0u32; 3]; + let [tiled, prefixed, plain] = [&resources[0], &resources[1], &resources[2]].map(|p| p as *const u32 as usize); + let start = D3D12_TILED_RESOURCE_COORDINATE::default(); + let size = D3D12_TILE_REGION_SIZE { NumTiles: 1, ..Default::default() }; + let to_tile = D3D12_TILE_COPY_FLAG_LINEAR_BUFFER_TO_SWIZZLED_TILED_RESOURCE; + let to_buffer = D3D12_TILE_COPY_FLAG_SWIZZLED_TILED_RESOURCE_TO_LINEAR_BUFFER; + let offset = 0x1000; + let delta = 0x1000; + + // A delta on the tiled resource must never change the other resource's byte offset. + set_test_buffer_delta(tiled, Some(0x4000)); + set_test_buffer_delta(prefixed, Some(delta)); + let mut observed = Vec::new(); + for (kind, slot) in [(Kind::CommandList, 18), (Kind::DmaList, 14)] { + let mut list = FakeList { vtable: native.as_ptr(), copies: Vec::new(), dispatch: None }; + let ptr = (&mut list as *mut FakeList).cast::(); + unsafe { + adopt(ptr, kind); + // Select the console side of the split without registering a game code image. + let console = console_slots(kind).into_iter().find(|&(s, _)| s == slot).map(|(_, f)| f) + .unwrap_or_else(|| { + let pc = console_remap(kind).into_iter().find(|&(s, _)| s == slot).map_or(slot, |(_, p)| p); + orig_fn(ptr, pc) + }); + let console: CopyTiles = std::mem::transmute(console); + console(ptr, tiled, &start, &size, prefixed, offset, to_tile); + console(ptr, tiled, &start, &size, prefixed, offset, to_buffer); + console(ptr, tiled, &start, &size, plain, offset, to_tile); + let host: CopyTiles = std::mem::transmute(*vt(ptr).add(18)); + host(ptr, tiled, &start, &size, prefixed, offset, to_tile); + let host_dispatch: unsafe extern "system" fn(*mut c_void, u32, u32, u32) = std::mem::transmute(*vt(ptr).add(14)); + host_dispatch(ptr, 1, 2, 3); + } + observed.push((kind, list.copies, list.dispatch)); + } + set_test_buffer_delta(prefixed, None); + set_test_buffer_delta(tiled, None); + + let args = |buffer, off, flags: D3D12_TILE_COPY_FLAGS| (tiled, &start as *const _ as usize, &size as *const _ as usize, buffer, off, flags.0); + for (kind, copies, dispatch) in observed { + assert_eq!(copies, [ + args(prefixed, offset + delta, to_tile), + args(prefixed, offset + delta, to_buffer), + args(plain, offset, to_tile), + args(prefixed, offset, to_tile), + ], "{kind:?}"); + assert_eq!(dispatch, Some((1, 2, 3)), "{kind:?} host Dispatch"); + } + } + /// Bug #6: `Kind::DmaList` must install `cl_release` so releasing a DMA command list removes /// its entry from `list_x::LISTS`. #[test] diff --git a/crates/xcl/tests/d3d12_resource_and_sync.rs b/crates/xcl/tests/d3d12_resource_and_sync.rs index ac4e86ffdf..060b08dae6 100644 --- a/crates/xcl/tests/d3d12_resource_and_sync.rs +++ b/crates/xcl/tests/d3d12_resource_and_sync.rs @@ -7,6 +7,7 @@ use std::ffi::c_void; use std::path::PathBuf; +use std::ptr; use std::sync::atomic::{AtomicBool, AtomicU64, Ordering}; use std::sync::{Arc, OnceLock}; use std::time::{Duration, Instant}; @@ -14,6 +15,7 @@ use std::time::{Duration, Instant}; use windows::core::{Interface, GUID}; use windows::Win32::Foundation::{CloseHandle, E_INVALIDARG, S_OK, WAIT_OBJECT_0}; use windows::Win32::Graphics::Direct3D12::*; +use windows::Win32::Graphics::Dxgi::{CreateDXGIFactory1, IDXGIAdapter1, IDXGIFactory4}; use windows::Win32::Graphics::Dxgi::Common::{DXGI_FORMAT_R8G8B8A8_UNORM, DXGI_FORMAT_UNKNOWN, DXGI_SAMPLE_DESC}; use windows::Win32::System::Threading::{CreateEventW, WaitForSingleObject}; use windows_sys::Win32::System::Diagnostics::Debug::RtlAddFunctionTable; @@ -183,6 +185,156 @@ unsafe fn wait_fence_event(fence: &ID3D12Fence, value: u64) { assert_eq!(r, WAIT_OBJECT_0, "timed out waiting for fence value {value}"); } +#[test] +fn console_copy_tiles_reads_and_writes_placed_buffer_bytes() { + let Some(dev) = adopted_device() else { return }; + let Some(uma) = xcl::gpu::uma::get() else { + runner::skip_test("no coherent UMA for a console placed buffer"); + return; + }; + const TILE: usize = D3D12_TILED_RESOURCE_TILE_SIZE_IN_BYTES as usize; + const PREFIX: usize = 4096; + const PHYSICAL: usize = TILE + PREFIX; + const GUARD: u8 = 0xd3; + const DMA_IID: GUID = GUID::from_u128(0x30bc77b9_8379_4b25_95de_b8588c42275d); + + struct ArenaBlock(&'static xcl::gpu::uma::Uma, usize); + impl Drop for ArenaBlock { + fn drop(&mut self) { self.0.free(self.1); } + } + + let Some(base) = uma.alloc(2 * TILE, TILE) else { + runner::skip_test("no coherent UMA space for a console placed buffer"); + return; + }; + let allocation = ArenaBlock(uma, base as usize); + unsafe { + let factory: IDXGIFactory4 = CreateDXGIFactory1().expect("CopyTiles DXGI factory"); + let adapter: IDXGIAdapter1 = factory.EnumAdapterByLuid(dev.GetAdapterLuid()).expect("CopyTiles adapter LUID"); + let name = adapter.GetDesc1().expect("CopyTiles adapter description").Description; + let name = String::from_utf16_lossy(&name[..name.iter().position(|&c| c == 0).unwrap_or(name.len())]); + println!("CopyTiles adapter={name}"); + let mut options = D3D12_FEATURE_DATA_D3D12_OPTIONS::default(); + dev.CheckFeatureSupport(D3D12_FEATURE_D3D12_OPTIONS, (&mut options as *mut D3D12_FEATURE_DATA_D3D12_OPTIONS).cast(), + std::mem::size_of_val(&options) as u32).expect("CopyTiles tiled resource support"); + if options.TiledResourcesTier == D3D12_TILED_RESOURCES_TIER_NOT_SUPPORTED { + runner::skip_test("no tiled resources"); + return; + } + + let mut placed_raw: *mut c_void = ptr::null_mut(); + let placed_desc = buffer_desc(TILE as u64, D3D12_RESOURCE_FLAG_NONE); + let hr = call_console(dev.as_raw(), 44, &[ + allocation.1 + PREFIX, &placed_desc as *const _ as usize, + D3D12_RESOURCE_STATE_COMMON.0 as usize, 0, &ID3D12Resource::IID as *const _ as usize, + &mut placed_raw as *mut _ as usize, + ]) as i32; + assert_eq!(hr, S_OK.0, "CreatePlacedResourceX({PREFIX:#x} prefix)"); + assert!(!placed_raw.is_null()); + let placed = ID3D12Resource::from_raw(placed_raw); + assert_eq!(real::buffer_delta(placed_raw as usize), PREFIX as u64); + println!("CopyTiles placement_delta={PREFIX}"); + + let mut tile: Option = None; + dev.CreateReservedResource(&placed_desc, D3D12_RESOURCE_STATE_COMMON, None, &mut tile).expect("reserve one buffer tile"); + let tile = tile.unwrap(); + let mut heap: Option = None; + dev.CreateHeap(&D3D12_HEAP_DESC { + SizeInBytes: TILE as u64, Properties: heap_props(D3D12_HEAP_TYPE_DEFAULT), + Flags: D3D12_HEAP_FLAG_ALLOW_ONLY_BUFFERS, ..Default::default() + }, &mut heap).expect("allocate one buffer tile"); + let heap = heap.unwrap(); + let start = D3D12_TILED_RESOURCE_COORDINATE::default(); + let region = D3D12_TILE_REGION_SIZE { NumTiles: 1, ..Default::default() }; + let staging = create_committed(&dev, &heap_props(D3D12_HEAP_TYPE_UPLOAD), D3D12_HEAP_FLAG_NONE, + &buffer_desc(2 * PHYSICAL as u64, D3D12_RESOURCE_FLAG_NONE), D3D12_RESOURCE_STATE_GENERIC_READ); + let readback = create_committed(&dev, &heap_props(D3D12_HEAP_TYPE_READBACK), D3D12_HEAP_FLAG_NONE, + &buffer_desc(PHYSICAL as u64, D3D12_RESOURCE_FLAG_NONE), D3D12_RESOURCE_STATE_COPY_DEST); + let empty = D3D12_RANGE { Begin: 0, End: 0 }; + let mut mismatches = Vec::new(); + + for (list_type, console_type, iid, slot) in [ + (D3D12_COMMAND_LIST_TYPE_DIRECT, 0, ID3D12GraphicsCommandList::IID, 18), + (D3D12_COMMAND_LIST_TYPE_COPY, 0x10, DMA_IID, 14), + ] { + let queue: ID3D12CommandQueue = dev.CreateCommandQueue(&D3D12_COMMAND_QUEUE_DESC { Type: list_type, ..Default::default() }).unwrap(); + queue.UpdateTileMappings(&tile, 1, Some(&start), Some(®ion), &heap, 1, + Some(&D3D12_TILE_RANGE_FLAG_NONE), Some(&0), Some(&1), D3D12_TILE_MAPPING_FLAG_NONE); + let fence: ID3D12Fence = dev.CreateFence(0, D3D12_FENCE_FLAG_NONE).unwrap(); + for (fence_value, to_tile) in [(1, true), (2, false)] { + let seed = (slot as u8) ^ ((fence_value as u8) << 6); + let payload = |i: usize| ((i * 37) ^ (i >> 8)) as u8 ^ seed; + let payload_start = if to_tile { PREFIX } else { 0 }; + let mut mapped: *mut c_void = ptr::null_mut(); + staging.Map(0, Some(&empty), Some(&mut mapped)).unwrap(); + let bytes = std::slice::from_raw_parts_mut(mapped as *mut u8, 2 * PHYSICAL); + bytes.fill(GUARD); + for (i, b) in bytes[payload_start..payload_start + TILE].iter_mut().enumerate() { *b = payload(i); } + staging.Unmap(0, None); + + let alloc: ID3D12CommandAllocator = dev.CreateCommandAllocator(list_type).unwrap(); + let mut raw: *mut c_void = ptr::null_mut(); + let params = [console_type, 0u32, 1, 0]; + let hr = call_console(dev.as_raw(), 73, &[ + params.as_ptr() as usize, alloc.as_raw() as usize, 0, &iid as *const _ as usize, &mut raw as *mut _ as usize, + ]) as i32; + assert_eq!(hr, S_OK.0); + assert!(!raw.is_null()); + let list = ID3D12GraphicsCommandList::from_raw(raw); + let transition = |res: &ID3D12Resource, before, after| { + list.ResourceBarrier(&[D3D12_RESOURCE_BARRIER { + Type: D3D12_RESOURCE_BARRIER_TYPE_TRANSITION, Flags: D3D12_RESOURCE_BARRIER_FLAG_NONE, + Anonymous: D3D12_RESOURCE_BARRIER_0 { Transition: std::mem::ManuallyDrop::new(D3D12_RESOURCE_TRANSITION_BARRIER { + pResource: std::mem::transmute_copy(res), Subresource: D3D12_RESOURCE_BARRIER_ALL_SUBRESOURCES, + StateBefore: before, StateAfter: after, + }) }, + }]); + }; + let (common, src, dst) = (D3D12_RESOURCE_STATE_COMMON, D3D12_RESOURCE_STATE_COPY_SOURCE, D3D12_RESOURCE_STATE_COPY_DEST); + transition(&placed, common, dst); + let staging_offset = if to_tile { 0 } else { PHYSICAL as u64 }; + list.CopyBufferRegion(&placed, 0, &staging, staging_offset, PHYSICAL as u64); + transition(&placed, dst, if to_tile { src } else { common }); + transition(&tile, common, dst); + let flags = if to_tile { D3D12_TILE_COPY_FLAG_LINEAR_BUFFER_TO_SWIZZLED_TILED_RESOURCE } + else { D3D12_TILE_COPY_FLAG_SWIZZLED_TILED_RESOURCE_TO_LINEAR_BUFFER }; + let copy_console = || call_console(raw, slot, &[tile.as_raw() as usize, &start as *const _ as usize, + ®ion as *const _ as usize, placed_raw as usize, 0, flags.0 as usize]); + let (read_count, expected_prefix) = if to_tile { + copy_console(); + transition(&tile, dst, src); + list.CopyTiles(&tile, &start, ®ion, &readback, 0, D3D12_TILE_COPY_FLAG_SWIZZLED_TILED_RESOURCE_TO_LINEAR_BUFFER); + (TILE, 0) + } else { + list.CopyTiles(&tile, &start, ®ion, &staging, 0, D3D12_TILE_COPY_FLAG_LINEAR_BUFFER_TO_SWIZZLED_TILED_RESOURCE); + transition(&tile, dst, src); + transition(&placed, common, dst); + copy_console(); + transition(&placed, dst, src); + list.CopyBufferRegion(&readback, 0, &placed, 0, PHYSICAL as u64); + (PHYSICAL, PREFIX) + }; + transition(&tile, src, common); + transition(&placed, src, common); + list.Close().expect("tile copy list Close"); + queue.ExecuteCommandLists(&[Some(list.cast::().unwrap())]); + queue.Signal(&fence, fence_value).expect("tile copy queue Signal"); + wait_fence_event(&fence, fence_value); + dev.GetDeviceRemovedReason().expect("tile copy device remains live"); + assert_eq!(fence.GetCompletedValue(), fence_value); + + readback.Map(0, Some(&D3D12_RANGE { Begin: 0, End: read_count }), Some(&mut mapped)).unwrap(); + let result = std::slice::from_raw_parts(mapped as *const u8, read_count); + let wrong = result.iter().enumerate().filter(|&(i, b)| *b != if i < expected_prefix { GUARD } else { payload(i - expected_prefix) }).count(); + readback.Unmap(0, Some(&empty)); + println!("CopyTiles slot={slot} to_tile={to_tile} fence={fence_value} read={read_count} mismatch={wrong}"); + mismatches.push(wrong); + } + } + assert_eq!(mismatches, [0, 0, 0, 0], "graphics/DMA × upload/readback"); + } +} + #[test] fn resource_map_unmap_write_and_gpu_va_match_host_and_console_contracts() { let Some(dev) = adopted_device() else { return };