From 5481c1b88b28f6825b007023eabfbedb0cc000fb Mon Sep 17 00:00:00 2001 From: Anees Iqbal Date: Fri, 27 Nov 2026 04:28:55 -0800 Subject: [PATCH] Runtime tests: an event keeps the largest value, from the deleted suite The deleted runtime's the_largest_value_is_kept, on the public API: a signal of u64::MAX reaches a shared event, which reads it; a second is left out; a host set of it changes nothing. Metal's event values are uint64_t (MTLEvent.h, signaledValue). The runtime puts Metal's value on the event's timeline semaphore as it is, and Vulkan bounds a signal's distance from the semaphore's value by maxTimelineSemaphoreValueDifference (VUID-VkSubmitInfo2-semaphore-03883; Vulkan's minimum is 2^31-1), so on a device whose limit is below 2^64-1 the validation layer is expected to report this signal: a separate commit, held off landing until its runs are read. Verification: not run when committed; the lavapipe run and one card per vendor follow on this branch. --- .../src/tests/event_values.rs | 28 +++++++++++++++++-- 1 file changed, 26 insertions(+), 2 deletions(-) diff --git a/crates/metal2vulkan-runtime/src/tests/event_values.rs b/crates/metal2vulkan-runtime/src/tests/event_values.rs index a453e7ebf..d7577a470 100644 --- a/crates/metal2vulkan-runtime/src/tests/event_values.rs +++ b/crates/metal2vulkan-runtime/src/tests/event_values.rs @@ -1,8 +1,9 @@ //! An event's values, under a device cfg on every device of the cfg's kind: a signal not above //! the highest value known is left out, whichever queue it is on; the host's value of a shared //! event reads at once below a GPU signal still pending and never signals the semaphore, and a -//! host value above a pending GPU signal stays the event's value once that signal lands; and a -//! shared event's listeners run on one thread, not the posting one, in the order posted. +//! host value above a pending GPU signal stays the event's value once that signal lands; the +//! largest value is kept; and a shared event's listeners run on one thread, not the posting one, +//! in the order posted. //! //! The GPU signals stay pending while the test reads the values: a [`Busy`] gate submitted ahead //! of them holds every later command of the device's one `VkQueue` until the test opens it. @@ -174,6 +175,29 @@ fn a_host_set_above_a_pending_signal_reaches_every_wait_below_it() { }); } +/// The largest value is kept: a signal of `u64::MAX` reaches the event, which reads it, a second +/// is left out, and a host set of it changes nothing. Metal's values are `uint64_t` (MTLEvent.h's +/// `signaledValue`). The validation layer checks the semaphore's signal of it, which Vulkan bounds +/// by the device's `maxTimelineSemaphoreValueDifference` from the semaphore's value +/// (`VUID-VkSubmitInfo2-semaphore-03883`). +#[test] +fn the_largest_value_is_kept() { + each_device("event_largest_value", |name, _, device| { + let event = shared_event(&device); + let queue = queue(&device); + let first = signal(name, &device, &queue, event.as_event(), u64::MAX); + finished(name, &first); + assert_eq!(event.signaled_value(), u64::MAX, "{name}"); + let second = signal(name, &device, &queue, event.as_event(), u64::MAX); + finished(name, &second); + within(name, || pending(event.as_event()).is_empty()); + event.set_signaled_value(u64::MAX); + assert_eq!(event.signaled_value(), u64::MAX, "{name}"); + assert_eq!(counter(event.as_event()), u64::MAX, "{name}"); + drop((first, second, queue, event, device)); + }); +} + /// The notifications of a shared event's listeners run off the posting thread, on one thread for /// them all, in the order posted. #[test]