diff --git a/crates/metal2vulkan-runtime/src/tests/device_recovery_carry.rs b/crates/metal2vulkan-runtime/src/tests/device_recovery_carry.rs index 39d338b3e..4acb6bc6f 100644 --- a/crates/metal2vulkan-runtime/src/tests/device_recovery_carry.rs +++ b/crates/metal2vulkan-runtime/src/tests/device_recovery_carry.rs @@ -213,22 +213,24 @@ fn a_recovery_carries_events_private_and_fresh_page_buffers() { // It holds the lost `VkDevice`, which keeps no memory for work. assert_eq!(live_vk_devices(&device, 2), 2); let after = pooled.device().work_counts_now(); + let blocks = + |counts: &crate::WorkCounts| counts.memory_blocks_live + counts.empty_memory_blocks_live; + eprintln!( + "CARRY-LOST-MEMORY: {}: the lost generation held {} blocks before the loss, {} at rest, \ + {} freed as it came to rest", + device.name(), + blocks(&before), + blocks(&after), + after.memory_frees.teardown - before.memory_frees.teardown + ); assert_eq!(after.empty_memory_blocks_live, 0, "{after:?}"); assert!( - after.device_memory_allocated + REUSED <= before.device_memory_allocated, - "the lost generation holds {} bytes, {} before the loss", - after.device_memory_allocated, - before.device_memory_allocated - ); - eprintln!( - "CARRY-LOST-MEMORY: {}: the lost generation held {} bytes in {} blocks before the loss, \ - {} in {} at rest", - device.name(), - before.device_memory_allocated, - before.memory_blocks_live, - after.device_memory_allocated, - after.memory_blocks_live + blocks(&after) < blocks(&before), + "the lost generation holds {} blocks, {} before the loss", + blocks(&after), + blocks(&before) ); + assert!(after.memory_frees.teardown > before.memory_frees.teardown); drop(pooled); assert_eq!(live_vk_devices(&device, 1), 1); } diff --git a/crates/metal2vulkan-validation/src/runtime_lane/device_recovery.rs b/crates/metal2vulkan-validation/src/runtime_lane/device_recovery.rs index 71853f096..78e6866bf 100644 --- a/crates/metal2vulkan-validation/src/runtime_lane/device_recovery.rs +++ b/crates/metal2vulkan-validation/src/runtime_lane/device_recovery.rs @@ -329,6 +329,11 @@ fn carried_objects_serve_on_the_new_vk_device() { let bytes = unsafe { std::slice::from_raw_parts(contents.as_ptr(), 4096) }; assert!(bytes.iter().all(|&byte| byte == round)); } + // The handles `Device::raw` answered as the lane checked the device's making + // (`creation_kinds` reads the driver's pipeline cache through them) keep the first + // generation's `VkDevice` until a later call answers the serving one's. + // SAFETY: the handles are read and not used. + let _ = unsafe { device.raw() }; let began = Instant::now(); while device.work_counts().vk_devices_live > 1 && began.elapsed() < Duration::from_secs(60) {