aboutsummaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
-rw-r--r--gn/gpu.gni1
-rw-r--r--src/gpu/mtl/GrMtlGpu.h8
-rw-r--r--src/gpu/mtl/GrMtlGpu.mm13
-rw-r--r--src/gpu/mtl/GrMtlGpuCommandBuffer.h93
4 files changed, 109 insertions, 6 deletions
diff --git a/gn/gpu.gni b/gn/gpu.gni
index b47fda9b12..6cac050820 100644
--- a/gn/gpu.gni
+++ b/gn/gpu.gni
@@ -628,6 +628,7 @@ skia_metal_sources = [
"$_src/gpu/mtl/GrMtlCaps.mm",
"$_src/gpu/mtl/GrMtlGpu.h",
"$_src/gpu/mtl/GrMtlGpu.mm",
+ "$_src/gpu/mtl/GrMtlGpuCommandBuffer.h",
"$_src/gpu/mtl/GrMtlRenderTarget.mm",
"$_src/gpu/mtl/GrMtlRenderTarget.h",
"$_src/gpu/mtl/GrMtlTexture.mm",
diff --git a/src/gpu/mtl/GrMtlGpu.h b/src/gpu/mtl/GrMtlGpu.h
index 8a68b763eb..1c25dedbac 100644
--- a/src/gpu/mtl/GrMtlGpu.h
+++ b/src/gpu/mtl/GrMtlGpu.h
@@ -65,13 +65,9 @@ public:
GrGpuRTCommandBuffer* createCommandBuffer(
GrRenderTarget*, GrSurfaceOrigin,
const GrGpuRTCommandBuffer::LoadAndStoreInfo&,
- const GrGpuRTCommandBuffer::StencilLoadAndStoreInfo&) override {
- return nullptr;
- }
+ const GrGpuRTCommandBuffer::StencilLoadAndStoreInfo&) override;
- GrGpuTextureCommandBuffer* createCommandBuffer(GrTexture*, GrSurfaceOrigin) override {
- return nullptr;
- }
+ GrGpuTextureCommandBuffer* createCommandBuffer(GrTexture*, GrSurfaceOrigin) override;
GrFence SK_WARN_UNUSED_RESULT insertFence() override { return 0; }
bool waitFence(GrFence, uint64_t) override { return true; }
diff --git a/src/gpu/mtl/GrMtlGpu.mm b/src/gpu/mtl/GrMtlGpu.mm
index 0295659b36..892e4bc5a1 100644
--- a/src/gpu/mtl/GrMtlGpu.mm
+++ b/src/gpu/mtl/GrMtlGpu.mm
@@ -7,6 +7,7 @@
#include "GrMtlGpu.h"
+#include "GrMtlGpuCommandBuffer.h"
#include "GrMtlTexture.h"
#include "GrMtlTextureRenderTarget.h"
#include "GrMtlUtil.h"
@@ -97,6 +98,18 @@ GrMtlGpu::GrMtlGpu(GrContext* context, const GrContextOptions& options,
fCmdBuffer = [fQueue commandBuffer];
}
+GrGpuRTCommandBuffer* GrMtlGpu::createCommandBuffer(
+ GrRenderTarget* renderTarget, GrSurfaceOrigin origin,
+ const GrGpuRTCommandBuffer::LoadAndStoreInfo& colorInfo,
+ const GrGpuRTCommandBuffer::StencilLoadAndStoreInfo& stencilInfo) {
+ return new GrMtlGpuRTCommandBuffer(this, renderTarget, origin, colorInfo, stencilInfo);
+}
+
+GrGpuTextureCommandBuffer* GrMtlGpu::createCommandBuffer(GrTexture* texture,
+ GrSurfaceOrigin origin) {
+ return new GrMtlGpuTextureCommandBuffer(this, texture, origin);
+}
+
void GrMtlGpu::submitCommandBuffer(SyncQueue sync) {
SkASSERT(fCmdBuffer);
[fCmdBuffer commit];
diff --git a/src/gpu/mtl/GrMtlGpuCommandBuffer.h b/src/gpu/mtl/GrMtlGpuCommandBuffer.h
new file mode 100644
index 0000000000..8f1fd20d62
--- /dev/null
+++ b/src/gpu/mtl/GrMtlGpuCommandBuffer.h
@@ -0,0 +1,93 @@
+/*
+ * Copyright 2018 Google Inc.
+ *
+ * Use of this source code is governed by a BSD-style license that can be
+ * found in the LICENSE file.
+ */
+
+#ifndef GrMtlGpuCommandBuffer_DEFINED
+#define GrMtlGpuCommandBuffer_DEFINED
+
+#include "GrGpuCommandBuffer.h"
+
+class GrMtlGpu;
+class GrMtlRenderTarget;
+
+class GrMtlGpuTextureCommandBuffer : public GrGpuTextureCommandBuffer {
+public:
+ GrMtlGpuTextureCommandBuffer(GrMtlGpu* gpu, GrTexture* texture, GrSurfaceOrigin origin)
+ : INHERITED(texture, origin)
+ , fGpu(gpu) {
+ // Silence unused var warning
+ (void)fGpu;
+ }
+
+ ~GrMtlGpuTextureCommandBuffer() override {}
+
+ void copy(GrSurface* src, GrSurfaceOrigin srcOrigin, const SkIRect& srcRect,
+ const SkIPoint& dstPoint) override {}
+
+ void insertEventMarker(const char* msg) override {}
+
+private:
+ void submit() override {}
+
+ GrMtlGpu* fGpu;
+
+ typedef GrGpuTextureCommandBuffer INHERITED;
+};
+
+class GrMtlGpuRTCommandBuffer : public GrGpuRTCommandBuffer {
+public:
+ GrMtlGpuRTCommandBuffer(GrMtlGpu* gpu, GrRenderTarget* rt, GrSurfaceOrigin origin,
+ const GrGpuRTCommandBuffer::LoadAndStoreInfo& colorInfo,
+ const GrGpuRTCommandBuffer::StencilLoadAndStoreInfo& stencilInfo)
+ : INHERITED(rt, origin)
+ , fGpu(gpu)
+ , fColorLoadAndStoreInfo(colorInfo)
+ , fStencilLoadAndStoreInfo(stencilInfo) {
+ // Silence unused var warning
+ (void)fColorLoadAndStoreInfo;
+ (void)fStencilLoadAndStoreInfo;
+ }
+
+ ~GrMtlGpuRTCommandBuffer() override {}
+
+ void begin() override {}
+ void end() override {}
+
+ void discard() override {}
+
+ void insertEventMarker(const char* msg) override {}
+
+ void inlineUpload(GrOpFlushState* state, GrDeferredTextureUploadFn& upload) override {}
+
+ void copy(GrSurface* src, GrSurfaceOrigin srcOrigin, const SkIRect& srcRect,
+ const SkIPoint& dstPoint) override {}
+
+ void submit() override {}
+
+private:
+ GrGpu* gpu() override { return fGpu; }
+
+ void onDraw(const GrPrimitiveProcessor& primProc,
+ const GrPipeline& pipeline,
+ const GrPipeline::FixedDynamicState* fixedDynamicState,
+ const GrPipeline::DynamicStateArrays* dynamicStateArrays,
+ const GrMesh mesh[],
+ int meshCount,
+ const SkRect& bounds) override {}
+
+ void onClear(const GrFixedClip& clip, GrColor color) override {}
+
+ void onClearStencilClip(const GrFixedClip& clip, bool insideStencilMask) override {}
+
+ GrMtlGpu* fGpu;
+ GrGpuRTCommandBuffer::LoadAndStoreInfo fColorLoadAndStoreInfo;
+ GrGpuRTCommandBuffer::StencilLoadAndStoreInfo fStencilLoadAndStoreInfo;
+
+ typedef GrGpuRTCommandBuffer INHERITED;
+};
+
+#endif
+