Skip to content
This repository was archived by the owner on Feb 25, 2025. It is now read-only.
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
56 changes: 33 additions & 23 deletions impeller/renderer/backend/metal/pipeline_library_mtl.mm
Original file line number Diff line number Diff line change
Expand Up @@ -127,31 +127,41 @@ static void GetMTLRenderPipelineDescriptor(const PipelineDescriptor& desc,
pipelines_[descriptor] = pipeline_future;
auto weak_this = weak_from_this();

auto completion_handler =
^(id<MTLRenderPipelineState> _Nullable render_pipeline_state,
NSError* _Nullable error) {
if (error != nil) {
VALIDATION_LOG << "Could not create render pipeline for "
<< descriptor.GetLabel() << " :"
<< error.localizedDescription.UTF8String;
promise->set_value(nullptr);
return;
}
// Extra info for https://github.com/flutter/flutter/issues/148320.
std::optional<std::string> thread_name =
#if FLUTTER_RELEASE
std::nullopt;
#else
[NSThread isMainThread] ? "main"
: [[[NSThread currentThread] name] UTF8String];
#endif
auto completion_handler = ^(
id<MTLRenderPipelineState> _Nullable render_pipeline_state,
NSError* _Nullable error) {
if (error != nil) {
VALIDATION_LOG << "Could not create render pipeline for "
<< descriptor.GetLabel() << " :"
<< error.localizedDescription.UTF8String << " (thread: "
<< (thread_name.has_value() ? *thread_name : "unknown")
<< ")";
promise->set_value(nullptr);
return;
}

auto strong_this = weak_this.lock();
if (!strong_this) {
promise->set_value(nullptr);
return;
}
auto strong_this = weak_this.lock();
if (!strong_this) {
promise->set_value(nullptr);
return;
}

auto new_pipeline = std::shared_ptr<PipelineMTL>(new PipelineMTL(
weak_this,
descriptor, //
render_pipeline_state, //
CreateDepthStencilDescriptor(descriptor, device_) //
));
promise->set_value(new_pipeline);
};
auto new_pipeline = std::shared_ptr<PipelineMTL>(new PipelineMTL(
weak_this,
descriptor, //
render_pipeline_state, //
CreateDepthStencilDescriptor(descriptor, device_) //
));
promise->set_value(new_pipeline);
};
GetMTLRenderPipelineDescriptor(
descriptor, [device = device_, completion_handler](
MTLRenderPipelineDescriptor* descriptor) {
Expand Down