From bd441b3c5e2909130f710a60c52a79cd48f2c5a1 Mon Sep 17 00:00:00 2001 From: jonahwilliams Date: Fri, 28 Jul 2023 15:24:30 -0700 Subject: [PATCH 1/2] [Impeller] revert removal of wait until scheduled. --- .../renderer/backend/metal/surface_mtl.mm | 32 ++++--------------- 1 file changed, 7 insertions(+), 25 deletions(-) diff --git a/impeller/renderer/backend/metal/surface_mtl.mm b/impeller/renderer/backend/metal/surface_mtl.mm index 450302d89da98..80b973d7ef6e1 100644 --- a/impeller/renderer/backend/metal/surface_mtl.mm +++ b/impeller/renderer/backend/metal/surface_mtl.mm @@ -218,20 +218,6 @@ return IRect::MakeSize(resolve_texture_->GetSize()); } -static bool ShouldWaitForCommandBuffer() { -#if ((FML_OS_MACOSX && !FML_OS_IOS) || FML_OS_IOS_SIMULATOR) - // If a transaction is present, `presentDrawable` will present too early. And - // so we wait on an empty command buffer to get scheduled instead, which - // forces us to also wait for all of the previous command buffers in the queue - // to get scheduled. - return true; -#else - // On Physical iOS devices we still need to wait if we're taking a frame - // capture. - return [[MTLCaptureManager sharedCaptureManager] isCapturing]; -#endif // ((FML_OS_MACOSX && !FML_OS_IOS) || FML_OS_IOS_SIMULATOR) -} - // |Surface| bool SurfaceMTL::Present() const { auto context = context_.lock(); @@ -262,17 +248,13 @@ static bool ShouldWaitForCommandBuffer() { } if (drawable_) { - // In certain situations, we need to wait until the command queue has been - // flushed before presenting to the onscreen texture. See the comments in - // `ShouldWaitForCommandBuffer` for more details. - if (ShouldWaitForCommandBuffer()) { - id command_buffer = - ContextMTL::Cast(context.get()) - ->CreateMTLCommandBuffer("Present Waiter Command Buffer"); - [command_buffer commit]; - [command_buffer waitUntilScheduled]; - } - [drawable_ present]; + TRACE_EVENT0("flutter", "waitUntilScheduled"); + id command_buffer = + ContextMTL::Cast(context.get()) + ->CreateMTLCommandBuffer("Present Waiter Command Buffer"); + [command_buffer presentDrawable:drawable_]; + + [command_buffer commit]; } return true; From ca65e8d2ff336faa4b20d885d568336b9ea49308 Mon Sep 17 00:00:00 2001 From: jonahwilliams Date: Fri, 28 Jul 2023 15:25:32 -0700 Subject: [PATCH 2/2] ++ --- impeller/renderer/backend/metal/surface_mtl.mm | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/impeller/renderer/backend/metal/surface_mtl.mm b/impeller/renderer/backend/metal/surface_mtl.mm index 80b973d7ef6e1..526e66f4c5ff5 100644 --- a/impeller/renderer/backend/metal/surface_mtl.mm +++ b/impeller/renderer/backend/metal/surface_mtl.mm @@ -252,9 +252,9 @@ id command_buffer = ContextMTL::Cast(context.get()) ->CreateMTLCommandBuffer("Present Waiter Command Buffer"); - [command_buffer presentDrawable:drawable_]; - [command_buffer commit]; + [command_buffer waitUntilScheduled]; + [drawable_ present]; } return true;