[Impeller] Label present waiter command buffer in SurfaceMTL (flutter/engine#43165)

Just to curb confusion and make it searchable. I double-take this lingering command buffer in frame captures quite a bit.
This commit is contained in:
Brandon DeRosier
2023-06-23 16:59:33 -07:00
committed by GitHub
parent f7d1aada2e
commit 85b2589b20
3 changed files with 13 additions and 4 deletions

View File

@@ -84,7 +84,7 @@ class ContextMTL final : public Context,
// |Context|
bool UpdateOffscreenLayerPixelFormat(PixelFormat format) override;
id<MTLCommandBuffer> CreateMTLCommandBuffer() const;
id<MTLCommandBuffer> CreateMTLCommandBuffer(const std::string& label) const;
const std::shared_ptr<fml::ConcurrentTaskRunner>& GetWorkerTaskRunner() const;

View File

@@ -343,8 +343,13 @@ bool ContextMTL::UpdateOffscreenLayerPixelFormat(PixelFormat format) {
return true;
}
id<MTLCommandBuffer> ContextMTL::CreateMTLCommandBuffer() const {
return [command_queue_ commandBuffer];
id<MTLCommandBuffer> ContextMTL::CreateMTLCommandBuffer(
const std::string& label) const {
auto buffer = [command_queue_ commandBuffer];
if (!label.empty()) {
[buffer setLabel:@(label.data())];
}
return buffer;
}
} // namespace impeller

View File

@@ -262,9 +262,13 @@ bool SurfaceMTL::Present() const {
}
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<MTLCommandBuffer> command_buffer =
ContextMTL::Cast(context.get())->CreateMTLCommandBuffer();
ContextMTL::Cast(context.get())
->CreateMTLCommandBuffer("Present Waiter Command Buffer");
[command_buffer commit];
[command_buffer waitUntilScheduled];
}