diff --git a/crates/metal2vulkan-rt/README.md b/crates/metal2vulkan-rt/README.md index b17cfeb02..e1ef0beeb 100644 --- a/crates/metal2vulkan-rt/README.md +++ b/crates/metal2vulkan-rt/README.md @@ -643,15 +643,16 @@ made, with no lock, and never rewritten for layouts. - The completion thread retires command buffers as the progress semaphore reaches them, a submission's in commit order: the status, the blocks they kept, their recorders and their place in the queue, then the completed handlers. Completed handlers and listeners run on it, in - turn. A wait in one for what that thread has not yet done is `Refusal::WaitOnOwnThread`, and - one already met answers at once: `wait_until_completed` for a command buffer not yet completed - (its own handler's command buffer has), `wait_until_scheduled` for one not yet scheduled, - `wait_until_signaled_value` for a value not yet reached, and `CommandQueue::command_buffer` on a - queue whose maximum count are made and not yet completed, which a scheduled handler answers - the same way. No wait of the runtime's hangs by construction. A command buffer of a group is seen complete - with the group's last: up to the GPU time of the fifteen after it late. Only a queue already three - submissions behind holds a group; one whose submissions have completed sends its next command - buffer alone. Without a wait or a hint, the lateness is bounded only while three submissions are + turn. A wait in one for what that thread has not yet done is `Refusal::WaitOnOwnThread`, and one + already met answers at once: `wait_until_completed` for a command buffer not yet completed (its + own handler's command buffer has), `wait_until_scheduled` for one not yet scheduled, + `wait_until_signaled_value` for a value not yet reached (a timed wait too: it is refused, never + false at its timeout, since the thread that would observe the value is the one waiting), and + `CommandQueue::command_buffer` on a queue whose maximum count are made and not yet completed, + which a scheduled handler answers the same way. No wait of the runtime's hangs by construction. + A command buffer of a group is seen complete with the group's last: up to the GPU time of the + fifteen after it late. Only a queue already three submissions behind holds a group; one whose + submissions have completed sends its next command buffer alone. Without a wait or a hint, the lateness is bounded only while three submissions are in flight, and the completion that leaves fewer sends the group (the measured lateness is under "Known gaps"). A command buffer ended while its queue holds a group joins it, and retires in its place; the group goes at once. diff --git a/crates/metal2vulkan-rt/src/event.rs b/crates/metal2vulkan-rt/src/event.rs index e1a7b4597..d7702c89c 100644 --- a/crates/metal2vulkan-rt/src/event.rs +++ b/crates/metal2vulkan-rt/src/event.rs @@ -157,7 +157,8 @@ impl SharedEvent { /// /// Err: [`Refusal::InScheduledHandler`](crate::Refusal::InScheduledHandler) in a scheduled /// handler; [`Refusal::WaitOnOwnThread`](crate::Refusal::WaitOnOwnThread) in a completed - /// handler or a listener of its device for a value not yet reached. + /// handler or a listener of its device for a value not yet reached, whatever `timeout`: no + /// false there, since that thread observes the value. pub fn wait_until_signaled_value(&self, value: u64, timeout: Duration) -> Result { crate::command::not_in_scheduled_handler()?; let inner = &self.event.inner; diff --git a/crates/metal2vulkan-rt/src/tests/command.rs b/crates/metal2vulkan-rt/src/tests/command.rs index 8123ac272..a401448f2 100644 --- a/crates/metal2vulkan-rt/src/tests/command.rs +++ b/crates/metal2vulkan-rt/src/tests/command.rs @@ -2153,8 +2153,8 @@ pub(crate) mod on_device { } /// On the completion thread, in a completed handler and in a listener, a wait for what that - /// thread has not yet done is refused with `WaitOnOwnThread`, and one already met answers at - /// once: the handler's own command buffer has completed. A command buffer asked of a full + /// thread has not yet done is refused with `WaitOnOwnThread`, a timed one too, never false at + /// its timeout, and one already met answers at once: the handler's own command buffer has completed. A command buffer asked of a full /// queue is refused there and in a scheduled handler, on the submit thread. #[test] fn every_device_refuses_in_a_handler_each_wait_its_own_thread_would_have_to_end() { @@ -2200,7 +2200,14 @@ pub(crate) mod on_device { ), ("completed: value 0", format!("{:?}", waited(0))), ("completed: value 1", format!("{:?}", waited(1))), - ("completed: room", answer(made.as_ref().map(drop))), + ( + "completed: value 1 at once", + format!( + "{:?}", + in_event.wait_until_signaled_value(1, Duration::ZERO) + ), + ), + ("completed: room", format!("{:?}", made.as_ref().map(drop))), ( "completed: a full queue", answer(in_queue.command_buffer().map(drop)), @@ -2241,7 +2248,7 @@ pub(crate) mod on_device { "listener: done completed", answer(in_done.wait_until_completed()), ), - ("listener: room", answer(made.as_ref().map(drop))), + ("listener: room", format!("{:?}", made.as_ref().map(drop))), ( "listener: a full queue", answer(in_queue.command_buffer().map(drop)), @@ -2270,7 +2277,7 @@ pub(crate) mod on_device { }; assert_eq!(*got, want, "{name}: {call}"); } - assert_eq!(lines.len(), 15, "{name}: {lines:?}"); + assert_eq!(lines.len(), 16, "{name}: {lines:?}"); // Outside a handler the same waits answer as before. assert_eq!(word(&a), 5, "{name}"); assert_eq!(held.status(), CommandBufferStatus::NotEnqueued, "{name}");