From 1a8bb026249f6c3b396dfebadf48ee5ca9eebbe5 Mon Sep 17 00:00:00 2001 From: Austin Eng Date: Mon, 8 May 2023 19:43:35 +0000 Subject: [PATCH] Ensure commands are submitted before exporting the last signaled event Consumers of the event expect it to be signaled after all work enqueued thus far. Ensure that commands are flushed to ensure this. Fixed: dawn:1691 Change-Id: I1409c668119a12e5e50a1ce2924ebc16d0470a4d Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/131880 Commit-Queue: Austin Eng Kokoro: Austin Eng Reviewed-by: Loko Kung --- src/dawn/native/metal/DeviceMTL.mm | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/src/dawn/native/metal/DeviceMTL.mm b/src/dawn/native/metal/DeviceMTL.mm index 7223e1a282..9409cb934f 100644 --- a/src/dawn/native/metal/DeviceMTL.mm +++ b/src/dawn/native/metal/DeviceMTL.mm @@ -361,6 +361,12 @@ MaybeError Device::SubmitPendingCommandBuffer() { } void Device::ExportLastSignaledEvent(ExternalImageMTLSharedEventDescriptor* desc) { + // Ensure commands are submitted before getting the last submited serial. + // Ignore the error since we still want to export the serial of the last successful + // submission - that was the last serial that was actually signaled. + ForceEventualFlushOfCommands(); + DAWN_UNUSED(ConsumedError(SubmitPendingCommandBuffer())); + desc->sharedEvent = *mMtlSharedEvent; desc->signaledValue = static_cast(GetLastSubmittedCommandSerial()); }