[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:
@@ -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;
|
||||
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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];
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user