From 8d0e5fdbcea97d0dc411f8dee6ed4fa83e9ad6b1 Mon Sep 17 00:00:00 2001 From: Anees Iqbal Date: Sat, 7 Nov 2026 06:05:33 -0800 Subject: [PATCH] Queue sharing test: on a device that does not share, expect the round robin's wrap onto the unshared queue's VkQueue no_queue_joins_an_unshared_queue_s_vk_queue_and_one_placed_there_leaves asserted under both policies that no queue made after an unshared one lands on its VkQueue. Where the device does not share (PerQueue, or one VkQueue per family: lavapipe's single queue), an unshared queue is documented to be the round robin's next VkQueue, shared past the round robin's VkQueues as every queue's is (Device::new_command_queue_unshared; Device::next_queue is made % round_robin), so on lavapipe each of the three later queues is on VkQueue 0 and the test failed at its first look (queue_share_device.rs:286, left 0, right 0). The test now expects a later queue on the unshared queue's VkQueue exactly where the round robin wraps onto it, and nowhere where the device shares, read from the device's round robin. Verified on lavapipe in the job named in the tip's report. (cherry picked from commit 0dbef8b89b3da410821fed63b92e8cbcfb09e7c5) --- .../src/tests/queue_share_device.rs | 17 +++++++++++------ 1 file changed, 11 insertions(+), 6 deletions(-) diff --git a/crates/metal2vulkan-runtime/src/tests/queue_share_device.rs b/crates/metal2vulkan-runtime/src/tests/queue_share_device.rs index 0a7acae13..fed21b20a 100644 --- a/crates/metal2vulkan-runtime/src/tests/queue_share_device.rs +++ b/crates/metal2vulkan-runtime/src/tests/queue_share_device.rs @@ -279,14 +279,20 @@ fn no_queue_joins_an_unshared_queue_s_vk_queue_and_one_placed_there_leaves() { let others: Vec = (0..3) .map(|_| device.new_command_queue().unwrap()) .collect(); + // Where the device does not share, the unshared queue and each after it took the round + // robin's next `VkQueue` (`Device::new_command_queue_unshared`), so every `round_robin`-th + // queue after it is on its `VkQueue` (on a device of one queue, each), and no other. + let round_robin = device.shared().round_robin(); for _ in 0..16 { let kept = burst(&unshared, &scratch, 24); - for queue in &others { + for (after, queue) in others.iter().enumerate() { let made = queue.command_buffer().unwrap(); - assert_ne!( - queue.vk_queue(), - home, - "a queue joined the unshared queue's VkQueue" + let wrapped = !shares && (after + 1) % round_robin == 0; + assert_eq!( + queue.vk_queue() == home, + wrapped, + "queue {after} after the unshared one, of a round robin of {round_robin} \ + VkQueues (shares: {shares}): on the unshared queue's VkQueue" ); drop(made); } @@ -297,7 +303,6 @@ fn no_queue_joins_an_unshared_queue_s_vk_queue_and_one_placed_there_leaves() { assert!(device.work_counts().joins_withheld_from_unshared > 0); // Every round robin's `VkQueue` holds a queue, so the next unshared queue shares // one with a queue, which leaves at its next idle point. - let round_robin = device.shared().round_robin(); let filled: Vec = (0..round_robin) .map(|_| device.new_command_queue().unwrap()) .collect();