Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Impeller] Intel iOS Simulators must block on GPU completion. #53073

Merged
merged 3 commits into from
Jun 4, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 16 additions & 1 deletion impeller/renderer/backend/metal/surface_mtl.mm
Original file line number Diff line number Diff line change
Expand Up @@ -266,14 +266,29 @@ - (void)flutterPrepareForPresent:(nonnull id<MTLCommandBuffer>)commandBuffer;
flutterPrepareForPresent:command_buffer];
}

// Intel iOS simulators do not seem to give backpressure on Metal drawable
// aquisition, which can result in Impeller running head of the GPU
// workload by dozens of frames. Slow this process down by blocking
// on submit until the last command buffer is at least scheduled.
#if defined(FML_OS_IOS_SIMULATOR) && defined(FML_ARCH_CPU_X86_64)
constexpr bool alwaysWaitForScheduling = true;
#else
constexpr bool alwaysWaitForScheduling = false;
#endif // defined(FML_OS_IOS_SIMULATOR) && defined(FML_ARCH_CPU_X86_64)

// If the threads have been merged, or there is a pending frame capture,
// then block on cmd buffer scheduling to ensure that the
// transaction/capture work correctly.
if ([[NSThread currentThread] isMainThread] ||
[[MTLCaptureManager sharedCaptureManager] isCapturing]) {
[[MTLCaptureManager sharedCaptureManager] isCapturing] ||
alwaysWaitForScheduling) {
TRACE_EVENT0("flutter", "waitUntilScheduled");
[command_buffer commit];
#if defined(FML_OS_IOS_SIMULATOR) && defined(FML_ARCH_CPU_X86_64)
[command_buffer waitUntilCompleted];
#else
[command_buffer waitUntilScheduled];
#endif // defined(FML_OS_IOS_SIMULATOR) && defined(FML_ARCH_CPU_X86_64)
[drawable_ present];
} else {
// The drawable may come from a FlutterMetalLayer, so it can't be
Expand Down