From 0d20ded2fe72a6f157fa5ee01ef962e01e832788 Mon Sep 17 00:00:00 2001 From: Anees Iqbal Date: Wed, 18 Nov 2026 10:03:31 -0800 Subject: [PATCH] rt tests: a command buffer's GPU start may equal its end, as Vulkan allows Vulkan orders timestamps (a later one is never lower) and lets a device write one at any logically later point; Metal documents gpuStartTime <= gpuEndTime. Mesa's Apple-GPU driver (KosmicKrisp, Mesa 26.3.1) asks Metal for relaxed timestamp granularity on a compute encoder, so the two timestamps around a command buffer with no render pass read one value: on an M3 Max, tests::command's every_device_retires_a_group_in_commit_order_each_with_its_own_times and every_device_takes_again_the_slot_of_a_command_buffer_that_never_ran failed on start == end (job m3-max-47313). The two tests now hold 0 < start <= end; the order across the group stays strict. Product code is unchanged. The README's known gaps name the driver's answer. --- crates/metal2vulkan-rt/README.md | 4 ++++ crates/metal2vulkan-rt/src/tests/command.rs | 6 ++++-- 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/crates/metal2vulkan-rt/README.md b/crates/metal2vulkan-rt/README.md index b48942231..237aaabbb 100644 --- a/crates/metal2vulkan-rt/README.md +++ b/crates/metal2vulkan-rt/README.md @@ -702,6 +702,10 @@ that touch blocks first. (15 ms at the 90th). The last command buffer's own report is not late: on the 2080 it came 97.2-97.5 ms after its commit, where the old runtime's came 94.9-96.4 ms after. The harness prints each command buffer's lateness, from its `gpu_end_time` to its completed handler (`late_us`). +- GPU start and end times are the device's timestamps. On Mesa's Apple-GPU driver a command + buffer with no render pass reports `gpu_start_time` equal to its `gpu_end_time`: the driver + writes both timestamps with Metal's relaxed timestamp granularity, which gives two writes in one + compute pass one value. Vulkan allows it: a later timestamp is never lower. - Values the runtime reads back from GPU-written memory decide nothing beyond the reading command buffer's own results (`src/readback.rs`; a rule test holds every such read there). The sites: the two timestamp queries of a command buffer, which decide only its `gpu_start_time`, through diff --git a/crates/metal2vulkan-rt/src/tests/command.rs b/crates/metal2vulkan-rt/src/tests/command.rs index 63e935d46..ea59bab26 100644 --- a/crates/metal2vulkan-rt/src/tests/command.rs +++ b/crates/metal2vulkan-rt/src/tests/command.rs @@ -1263,7 +1263,9 @@ pub(crate) mod on_device { .map(|cb| (cb.gpu_start_time(), cb.gpu_end_time())) .collect(); for &(start, end) in × { - assert!(0 < start && start < end, "{name}: {times:?}"); + // A later timestamp is never lower; a device may give two one value (Mesa's + // Apple-GPU driver does, outside a render pass). + assert!(0 < start && start <= end, "{name}: {times:?}"); } for pair in times.windows(2) { assert!( @@ -1310,7 +1312,7 @@ pub(crate) mod on_device { assert_eq!(again.status(), CommandBufferStatus::Completed, "{name}"); assert_eq!(word(&buffer), 5, "{name}"); let (start, end) = (again.gpu_start_time(), again.gpu_end_time()); - assert!(0 < start && start < end, "{name}: {start} {end}"); + assert!(0 < start && start <= end, "{name}: {start} {end}"); checked }); drop((buffer, arena, queue, device));