• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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 
13 #include "include/core/SkRefCnt.h"
14 
15 class GrMtlGpu;
16 class GrMtlPipelineState;
17 class GrMtlGpuRTCommandBuffer;
18 
19 class GrMtlCommandBuffer {
20 public:
21     static GrMtlCommandBuffer* Create(id<MTLCommandQueue> queue);
22     ~GrMtlCommandBuffer();
23 
24     void commit(bool waitUntilCompleted);
25 
26     id<MTLBlitCommandEncoder> getBlitCommandEncoder();
27     id<MTLRenderCommandEncoder> getRenderCommandEncoder(MTLRenderPassDescriptor*,
28                                                         const GrMtlPipelineState*,
29                                                         GrMtlGpuRTCommandBuffer* gpuCommandBuffer);
30 
addCompletedHandler(MTLCommandBufferHandler block)31     void addCompletedHandler(MTLCommandBufferHandler block) {
32         [fCmdBuffer addCompletedHandler:block];
33     }
34 
35 private:
GrMtlCommandBuffer(id<MTLCommandBuffer> cmdBuffer)36     GrMtlCommandBuffer(id<MTLCommandBuffer> cmdBuffer)
37         : fCmdBuffer(cmdBuffer)
38         , fPreviousRenderPassDescriptor(nil) {}
39 
40     void endAllEncoding();
41 
42     id<MTLCommandBuffer>        fCmdBuffer;
43     id<MTLBlitCommandEncoder>   fActiveBlitCommandEncoder;
44     id<MTLRenderCommandEncoder> fActiveRenderCommandEncoder;
45     MTLRenderPassDescriptor*    fPreviousRenderPassDescriptor;
46 };
47 
48 #endif
49