From 6bc41c8b94bb74a7e28edc0f658d61878d5dc03d Mon Sep 17 00:00:00 2001 From: Anees Iqbal Date: Wed, 2 Dec 2026 03:17:08 -0800 Subject: [PATCH] Runtime tests: the two Managed-over tests print and check the copies over the device copy The fill-after-a-signal test prints the bytes R's submission copied between the texture and the Managed buffer's device copy (over_copy_bytes less those over Private and over Shared memory), and the failed-begin test the bytes the copy encoded again copied back in its own commands. Where the texture is owed by its buffer's entry (two copies), each must be non-zero: the evidence that the two-copy form ran, not only that the bytes match. Unverified at this commit: the failing run follows on lavapipe. --- .../metal2vulkan-runtime/src/tests/managed.rs | 29 +++++++++++++++++-- 1 file changed, 27 insertions(+), 2 deletions(-) diff --git a/crates/metal2vulkan-runtime/src/tests/managed.rs b/crates/metal2vulkan-runtime/src/tests/managed.rs index aa1249213..6de018fc2 100644 --- a/crates/metal2vulkan-runtime/src/tests/managed.rs +++ b/crates/metal2vulkan-runtime/src/tests/managed.rs @@ -1816,6 +1816,14 @@ pub(crate) mod on_device { }); } + /// The bytes the device has copied between a texture over a Managed buffer's device copy and + /// its image of its own, either way: [`Metrics::over_copy_bytes`](crate::Metrics) less those + /// over Private and over Shared memory. + fn managed_over_bytes(device: &Device) -> u64 { + let m = device.counters().metrics(); + m.over_copy_bytes - m.over_copy_bytes_private - m.over_copy_bytes_shared + } + /// `bytes`, a buffer's, with the texels of the texture over it at [`OVER_PITCH`] all `value`. fn over_filled(bytes: &[u8], value: u8) -> Vec { let mut filled = bytes.to_vec(); @@ -1984,20 +1992,28 @@ pub(crate) mod on_device { finished(name, &writer); let reader = queue.command_buffer().expect("a command buffer"); read_over(&reader, &texture, &r_read); + let copied = managed_over_bytes(&device); reader.commit().expect("a commit"); finished(name, &reader); + let copied = managed_over_bytes(&device) - copied; let rows = over_rows(&bytes); let filled = vec![0x5A; rows.len()]; let (w_bytes, r_bytes) = (read(&w_read, rows.len()), read(&r_read, rows.len())); println!( "{test}: {name}: {form}; W read the buffer's bytes {}, R read the fill {} (its \ - first texels {:?})", + first texels {:?}); R's copies over the device copy {copied} bytes", w_bytes == rows, r_bytes == filled, &r_bytes[..8] ); assert!(w_bytes == rows, "{name}: W reads the buffer's bytes"); assert!(r_bytes == filled, "{name}: R reads the fill"); + if texture.managed_over().is_some() { + assert!( + copied > 0, + "{name}: R's submission copies the texture in from the device copy" + ); + } drop((texture, managed, w_read, r_read, arena)); drop((writer, reader, queue, event)); (device.release_block(cpu)).unwrap_or_else(|error| panic!("{name}: {error}")); @@ -2042,7 +2058,9 @@ pub(crate) mod on_device { matches!(failed, Err(Error::Vulkan { .. })), "{name}: the copy fails at its begin: {failed:?}" ); + let backs = managed_over_bytes(&device); (blit.copy_from_buffer_to_buffer(&managed, 0, &copied, 0, OVER_LEN)).expect("a copy"); + let backs = managed_over_bytes(&device) - backs; blit.end_encoding(); writer.commit().expect("a commit"); finished(name, &writer); @@ -2050,11 +2068,18 @@ pub(crate) mod on_device { let written = over_filled(&bytes, 0x3C); let got = read(&copied, OVER_LEN as usize); println!( - "{test}: {name}: {form}; the copy read W's pattern {} (its first texels {:?})", + "{test}: {name}: {form}; the copy read W's pattern {} (its first texels {:?}); \ + its copies back over the device copy {backs} bytes", got == written, &got[..8] ); assert!(got == written, "{name}: the copy reads W's pattern"); + if texture.managed_over().is_some() { + assert!( + backs > 0, + "{name}: the copy takes W's copy back in its own commands" + ); + } drop((texture, managed, pattern, copied, arena)); drop((writer, queue, event)); (device.release_block(cpu)).unwrap_or_else(|error| panic!("{name}: {error}"));