7#include "flutter/fml/make_copyable.h"
8#include "flutter/fml/synchronization/semaphore.h"
18static NSString* MTLCommandEncoderErrorStateToString(
19 MTLCommandEncoderErrorState
state) {
21 case MTLCommandEncoderErrorStateUnknown:
23 case MTLCommandEncoderErrorStateCompleted:
25 case MTLCommandEncoderErrorStateAffected:
27 case MTLCommandEncoderErrorStatePending:
29 case MTLCommandEncoderErrorStateFaulted:
37 case MTLCommandBufferErrorNone:
39 case MTLCommandBufferErrorInternal:
41 case MTLCommandBufferErrorTimeout:
43 case MTLCommandBufferErrorPageFault:
45 case MTLCommandBufferErrorNotPermitted:
46 return @"not permitted";
47 case MTLCommandBufferErrorOutOfMemory:
48 return @"out of memory";
49 case MTLCommandBufferErrorInvalidResource:
50 return @"invalid resource";
51 case MTLCommandBufferErrorMemoryless:
52 return @"memory-less";
57 return [NSString stringWithFormat:
@"<unknown> %zu",
code];
65 if (
buffer.status == MTLCommandBufferStatusCompleted) {
70 stream <<
">>>>>>>" << std::endl;
71 stream <<
"Impeller command buffer could not be committed!" << std::endl;
73 if (
auto desc =
buffer.error.localizedDescription) {
79 << (
buffer.error.domain.length > 0u ?
buffer.error.domain.UTF8String
83 static_cast<MTLCommandBufferError
>(
buffer.error.code))
88 if (@available(iOS 14.0, macOS 11.0, *)) {
89 NSArray<id<MTLCommandBufferEncoderInfo>>* infos =
90 buffer.error.userInfo[MTLCommandBufferEncoderInfoErrorKey];
91 for (id<MTLCommandBufferEncoderInfo>
info in infos) {
93 :
"<Unlabelled Render Pass>")
95 << MTLCommandEncoderErrorStateToString(
info.errorState).UTF8String
98 auto signposts = [
info.debugSignposts componentsJoinedByString:
@", "];
99 if (signposts.length > 0u) {
100 stream << signposts.UTF8String << std::endl;
104 for (id<MTLFunctionLog>
log in
buffer.logs) {
106 if (
desc.length > 0u) {
118#ifndef FLUTTER_RELEASE
119 if (@available(iOS 14.0, macOS 11.0, *)) {
120 auto desc = [[MTLCommandBufferDescriptor alloc]
init];
123 desc.errorOptions = MTLCommandBufferErrorOptionEncoderExecutionStatus;
124 return [
queue commandBufferWithDescriptor:
desc];
127 return [
queue commandBuffer];
130CommandBufferMTL::CommandBufferMTL(
const std::weak_ptr<const Context>& context,
131 id<MTLCommandQueue>
queue)
134CommandBufferMTL::~CommandBufferMTL() =
default;
136bool CommandBufferMTL::IsValid()
const {
137 return buffer_ != nil;
140void CommandBufferMTL::SetLabel(
const std::string& label)
const {
145 [buffer_ setLabel:@(label.data())];
150 case MTLCommandBufferStatusCompleted:
151 return CommandBufferMTL::Status::kCompleted;
152 case MTLCommandBufferStatusEnqueued:
153 return CommandBufferMTL::Status::kPending;
160bool CommandBufferMTL::OnSubmitCommands(CompletionCallback
callback) {
161 auto context = context_.lock();
166 ContextMTL::Cast(*context).GetGPUTracer()->RecordCmdBuffer(buffer_);
170 addCompletedHandler:^(id<MTLCommandBuffer>
buffer) {
171 [[maybe_unused]]
auto result =
174 <<
"Must not have errors during command buffer submission.";
185void CommandBufferMTL::OnWaitUntilScheduled() {}
187std::shared_ptr<RenderPass> CommandBufferMTL::OnCreateRenderPass(
193 auto context = context_.lock();
197 auto pass = std::shared_ptr<RenderPassMTL>(
198 new RenderPassMTL(context,
target, buffer_));
199 if (!pass->IsValid()) {
206std::shared_ptr<BlitPass> CommandBufferMTL::OnCreateBlitPass() {
211 auto pass = std::shared_ptr<BlitPassMTL>(
new BlitPassMTL(buffer_));
212 if (!pass->IsValid()) {
219std::shared_ptr<ComputePass> CommandBufferMTL::OnCreateComputePass() {
223 auto context = context_.lock();
229 std::shared_ptr<ComputePassMTL>(
new ComputePassMTL(context, buffer_));
230 if (!pass->IsValid()) {
static void info(const char *fmt,...) SK_PRINTF_LIKE(1
FlKeyEvent uint64_t FlKeyResponderAsyncCallback callback
#define FML_DCHECK(condition)
SK_API sk_sp< SkSurface > ios(9.0)
SK_API sk_sp< SkSurface > RenderTarget(GrRecordingContext *context, skgpu::Budgeted budgeted, const SkImageInfo &imageInfo, int sampleCount, GrSurfaceOrigin surfaceOrigin, const SkSurfaceProps *surfaceProps, bool shouldCreateWithMips=false, bool isProtected=false)
DEF_SWITCHES_START aot vmservice shared library Name of the *so containing AOT compiled Dart assets for launching the service isolate vm snapshot The VM snapshot data that will be memory mapped as read only SnapshotAssetPath must be present isolate snapshot The isolate snapshot data that will be memory mapped as read only SnapshotAssetPath must be present cache dir Path to the cache directory This is different from the persistent_cache_path in embedder which is used for Skia shader cache icu native lib Path to the library file that exports the ICU data vm service The hostname IP address on which the Dart VM Service should be served If not defaults to or::depending on whether ipv6 is specified vm service A custom Dart VM Service port The default is to pick a randomly available open port disable vm Disable the Dart VM Service The Dart VM Service is never available in release mode disable vm service Disable mDNS Dart VM Service publication Bind to the IPv6 localhost address for the Dart VM Service Ignored if vm service host is set endless trace buffer
static bool LogMTLCommandBufferErrorIfPresent(id< MTLCommandBuffer > buffer)
API_AVAILABLE(ios(14.0), macos(11.0)) static NSString *MTLCommandEncoderErrorStateToString(MTLCommandEncoderErrorState state)
static NSString * MTLCommandBufferErrorToString(MTLCommandBufferError code)
static id< MTLCommandBuffer > CreateCommandBuffer(id< MTLCommandQueue > queue)
static CommandBuffer::Status ToCommitResult(MTLCommandBufferStatus status)