This repository was archived by the owner on Feb 25, 2025. It is now read-only.
File tree Expand file tree Collapse file tree 1 file changed +19
-0
lines changed
impeller/renderer/backend/metal Expand file tree Collapse file tree 1 file changed +19
-0
lines changed Original file line number Diff line number Diff 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+ // multi-pass rendering/SaveLayer support was 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}
You can’t perform that action at this time.
0 commit comments