From 2c8a34a79e0bccc61608f2ebad082e16bed757d5 Mon Sep 17 00:00:00 2001 From: Anees Iqbal Date: Thu, 12 Nov 2026 01:27:33 -0800 Subject: [PATCH] Test: recorded_at_the_call counts fills once the device's queue-switch check ended What: a_fill_is_recorded_at_its_call waits for the device's queue-switch check (settle_queue_switch_check, 120 s) after making its command queue and before it counts, as the other tests that read commands_recorded do (fill_waits, fill_queue, draw_again). Why: the test's expectation went stale at RUNTIME_VERSION 2089 (24f233db8b). The check's rounds now open their gate on the GPU with a vkCmdFillBuffer of the check's scratch buffer, recorded on the check's thread, and WorkCounts::commands_recorded counts every command of the device whatever the thread (its contract). The test counts all of the device's fills, so a check whose opening was recorded between the test's fill and its commit read as "the fill recorded again": the RTX 5080's runtime suite at pin 45 (m3-max-19738) saw 1 at the call and 2 after the commit. Verified on the RTX 5080 Laptop GPU (NVIDIA 615.71.09), b5080 batch m3-max-19866, with a scratch probe that counts the device's fills from before its first command queue until its check settled, the program recording none: 0 at pin 44 (bf442ceb9e + the probe) and 1 at development 9768c1b352 (+ the probe), the check's verdict Idles at both. In that batch this commit's test passed (fills 1 at the call, 1 after the commit). The failure itself needs the check's recording to land inside the test's window (it did under the suite's load); the unsettled test passed alone in the batch, as it did in the other devices' suites. --- .../src/tests/recorded_at_the_call.rs | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) diff --git a/crates/metal2vulkan-runtime/src/tests/recorded_at_the_call.rs b/crates/metal2vulkan-runtime/src/tests/recorded_at_the_call.rs index 77f975f17..d30401c9a 100644 --- a/crates/metal2vulkan-runtime/src/tests/recorded_at_the_call.rs +++ b/crates/metal2vulkan-runtime/src/tests/recorded_at_the_call.rs @@ -4,11 +4,20 @@ //! moves at the call itself, before the encoder ends and before the commit, where a command //! logged for a later recording would move it only after the commit. //! +//! That count is the whole device's, whatever the thread: the queue-switch check +//! (`queue_switch_check.rs`, started by the device's first command queue) records its rounds' +//! openings, fills of a scratch buffer of its own, on its thread. So the test waits for that check +//! to end before it counts. +//! //! Device tests: compiled only under the validation crate's GPU safety cfgs (`m2v_gpu`, //! `m2v_cpu_icd`). use super::blit_holds::{device, Scratch, WAIT}; use crate::{CommandBufferStatus, CommandsRecorded, ResourceOptions}; +use std::time::Duration; + +/// How long the device's queue-switch check may take to end. +const SETTLE: Duration = Duration::from_secs(120); /// The fills recorded so far, each one `vkCmdFillBuffer` (`word_fill.rs`). fn fills(counts: &CommandsRecorded) -> u64 { @@ -17,12 +26,17 @@ fn fills(counts: &CommandsRecorded) -> u64 { /// A blit encoder's fill of a buffer's word is in the driver's command buffer as the call /// returns: the count of fills recorded rose by one at the call, the encoder still open and the -/// command buffer uncommitted, and by no more at its end and commit. The bytes are the fill's. +/// command buffer uncommitted, and by no more at its end and commit, the device's queue-switch +/// check ended before (the module docs). The bytes are the fill's. #[test] fn a_fill_is_recorded_at_its_call() { let scratch = Scratch::new("recorded-at-the-call"); let device = device(&scratch.0); let queue = device.new_command_queue().unwrap(); + assert!( + device.settle_queue_switch_check(SETTLE), + "the device's queue-switch check ended" + ); let buffer = (device.new_buffer(16, ResourceOptions::shared())).unwrap(); let command_buffer = queue.command_buffer().unwrap(); let mut blit = command_buffer.blit_command_encoder().unwrap();