Flutter Engine
The Flutter Engine
GrMtlCommandBuffer.h
Go to the documentation of this file.
1/*
2 * Copyright 2019 Google Inc.
3 *
4 * Use of this source code is governed by a BSD-style license that can be
5 * found in the LICENSE file.
6 */
7
8#ifndef GrMtlCommandBuffer_DEFINED
9#define GrMtlCommandBuffer_DEFINED
10
11#import <Metal/Metal.h>
12
14#include "include/gpu/GrTypes.h"
15#include "src/gpu/GpuRefCnt.h"
21
22class GrMtlEvent;
23class GrMtlGpu;
27
28GR_NORETAIN_BEGIN
29
31public:
32 static sk_sp<GrMtlCommandBuffer> Make(id<MTLCommandQueue> queue);
33 ~GrMtlCommandBuffer() override;
34
35 void releaseResources();
36
37 bool commit(bool waitUntilCompleted);
38 bool hasWork() { return fHasWork; }
39
41 fFinishedCallbacks.push_back(std::move(callback));
42 }
43
44 id<MTLBlitCommandEncoder> getBlitCommandEncoder();
45 // Tries to reuse current renderCommandEncoder if possible
46 GrMtlRenderCommandEncoder* getRenderCommandEncoder(MTLRenderPassDescriptor*,
47 const GrMtlPipelineState*,
48 GrMtlOpsRenderPass* opsRenderPass);
49 // Replaces current renderCommandEncoder with new one
50 GrMtlRenderCommandEncoder* getRenderCommandEncoder(MTLRenderPassDescriptor*,
52
53 void addCompletedHandler(MTLCommandBufferHandler block) {
54 [fCmdBuffer addCompletedHandler:block];
55 }
56
58// Disable generic resource tracking for now
59// SkASSERT(resource);
60// fTrackedResources.push_back(std::move(resource));
61 }
62
64 fTrackedGrBuffers.push_back(std::move(buffer));
65 }
66
68 fTrackedGrSurfaces.push_back(std::move(surface));
69 }
70
73
75 [fCmdBuffer waitUntilCompleted];
76 }
77 bool isCompleted() {
78 return fCmdBuffer.status == MTLCommandBufferStatusCompleted ||
79 fCmdBuffer.status == MTLCommandBufferStatusError;
80 }
81 void callFinishedCallbacks() { fFinishedCallbacks.clear(); }
82
83 void pushDebugGroup(NSString* string) {
84 if (@available(macOS 10.13, iOS 11.0, tvOS 11.0, *)) {
85 [fCmdBuffer pushDebugGroup:string];
86 }
87 }
88
90 if (@available(macOS 10.13, iOS 11.0, tvOS 11.0, *)) {
91 [fCmdBuffer popDebugGroup];
92 }
93 }
94
95private:
96 GrMtlCommandBuffer(id<MTLCommandBuffer> cmdBuffer)
97 : fCmdBuffer(cmdBuffer)
98 , fActiveBlitCommandEncoder(nil)
99 , fActiveRenderCommandEncoder(nil)
100 , fPreviousRenderPassDescriptor(nil)
101 , fHasWork(false) {}
102
103 void endAllEncoding();
104
105 static const int kInitialTrackedResourcesCount = 32;
106
108 kInitialTrackedResourcesCount, sk_sp<const GrManagedResource>> fTrackedResources;
111
112 id<MTLCommandBuffer> fCmdBuffer;
113 id<MTLBlitCommandEncoder> fActiveBlitCommandEncoder;
114 std::unique_ptr<GrMtlRenderCommandEncoder> fActiveRenderCommandEncoder;
115 MTLRenderPassDescriptor* fPreviousRenderPassDescriptor;
116 bool fHasWork;
117
119
120};
121
122GR_NORETAIN_END
123
124#endif
static SkString resource(SkPDFResourceType type, int index)
GrMtlRenderCommandEncoder * getRenderCommandEncoder(MTLRenderPassDescriptor *, const GrMtlPipelineState *, GrMtlOpsRenderPass *opsRenderPass)
void addResource(const sk_sp< const GrManagedResource > &resource)
void addGrBuffer(sk_sp< const GrBuffer > buffer)
void pushDebugGroup(NSString *string)
void addGrSurface(sk_sp< const GrSurface > surface)
void addCompletedHandler(MTLCommandBufferHandler block)
id< MTLBlitCommandEncoder > getBlitCommandEncoder()
~GrMtlCommandBuffer() override
void encodeWaitForEvent(sk_sp< GrMtlEvent >, uint64_t value)
static sk_sp< GrMtlCommandBuffer > Make(id< MTLCommandQueue > queue)
bool commit(bool waitUntilCompleted)
void addFinishedCallback(sk_sp< skgpu::RefCntedCallback > callback)
void encodeSignalEvent(sk_sp< GrMtlEvent >, uint64_t value)
VkQueue queue
Definition: main.cc:55
VkSurfaceKHR surface
Definition: main.cc:49
FlKeyEvent uint64_t FlKeyResponderAsyncCallback callback
uint8_t value
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
Definition: switches.h:126