GrMtlCommandBuffer.h 1.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748
  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. #ifndef GrMtlCommandBuffer_DEFINED
  8. #define GrMtlCommandBuffer_DEFINED
  9. #import <Metal/Metal.h>
  10. #include "include/core/SkRefCnt.h"
  11. class GrMtlGpu;
  12. class GrMtlPipelineState;
  13. class GrMtlGpuRTCommandBuffer;
  14. class GrMtlCommandBuffer {
  15. public:
  16. static GrMtlCommandBuffer* Create(id<MTLCommandQueue> queue);
  17. ~GrMtlCommandBuffer();
  18. void commit(bool waitUntilCompleted);
  19. id<MTLBlitCommandEncoder> getBlitCommandEncoder();
  20. id<MTLRenderCommandEncoder> getRenderCommandEncoder(MTLRenderPassDescriptor*,
  21. const GrMtlPipelineState*,
  22. GrMtlGpuRTCommandBuffer* gpuCommandBuffer);
  23. void addCompletedHandler(MTLCommandBufferHandler block) {
  24. [fCmdBuffer addCompletedHandler:block];
  25. }
  26. private:
  27. GrMtlCommandBuffer(id<MTLCommandBuffer> cmdBuffer)
  28. : fCmdBuffer(cmdBuffer)
  29. , fPreviousRenderPassDescriptor(nil) {}
  30. void endAllEncoding();
  31. id<MTLCommandBuffer> fCmdBuffer;
  32. id<MTLBlitCommandEncoder> fActiveBlitCommandEncoder;
  33. id<MTLRenderCommandEncoder> fActiveRenderCommandEncoder;
  34. MTLRenderPassDescriptor* fPreviousRenderPassDescriptor;
  35. };
  36. #endif