Skip to content
This repository was archived by the owner on Feb 25, 2025. It is now read-only.

Commit dba13f1

Browse files
committed
Add comment
1 parent 965877b commit dba13f1

File tree

1 file changed

+19
-0
lines changed

1 file changed

+19
-0
lines changed

impeller/renderer/backend/metal/command_buffer_mtl.mm

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -166,9 +166,28 @@ static bool LogMTLCommandBufferErrorIfPresent(id<MTLCommandBuffer> buffer) {
166166
}
167167

168168
[buffer_ commit];
169+
169170
#if (FML_OS_MACOSX || FML_OS_IOS_SIMULATOR)
171+
// We're using waitUntilScheduled on macOS and iOS simulator to force a hard
172+
// barrier between the execution of different command buffers. This forces all
173+
// renderable texture access to be synchronous (i.e. a write from a previous
174+
// command buffer will not get scheduled to happen at the same time as a read
175+
// in a future command buffer).
176+
//
177+
// Metal hazard tracks shared memory resources by default, and we don't need
178+
// to do any additional work to synchronize access to MTLTextures and
179+
// MTLBuffers on iOS devices with UMA. However, shared textures are disallowed
180+
// on macOS according to the documentation:
181+
// https://developer.apple.com/documentation/metal/mtlstoragemode/shared
182+
// And so this is a stopgap solution that has been present in Impeller since
183+
// the playgrounds were first set up.
184+
//
185+
// TODO(bdero): Remove this for all targets once a solution for resource
186+
// tracking that works everywhere is established:
187+
// https://github.com/flutter/flutter/issues/120406
170188
[buffer_ waitUntilScheduled];
171189
#endif
190+
172191
buffer_ = nil;
173192
return true;
174193
}

0 commit comments

Comments
 (0)