aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/gpu/mtl/GrMtlResourceProvider.mm
diff options
context:
space:
mode:
Diffstat (limited to 'src/gpu/mtl/GrMtlResourceProvider.mm')
-rw-r--r--src/gpu/mtl/GrMtlResourceProvider.mm31
1 files changed, 31 insertions, 0 deletions
diff --git a/src/gpu/mtl/GrMtlResourceProvider.mm b/src/gpu/mtl/GrMtlResourceProvider.mm
new file mode 100644
index 0000000000..2e1e40dfe9
--- /dev/null
+++ b/src/gpu/mtl/GrMtlResourceProvider.mm
@@ -0,0 +1,31 @@
+/*
+ * Copyright 2018 Google Inc.
+ *
+ * Use of this source code is governed by a BSD-style license that can be
+ * found in the LICENSE file.
+ */
+
+#include "GrMtlResourceProvider.h"
+
+#include "GrMtlCopyManager.h"
+#include "GrMtlGpu.h"
+#include "GrMtlUtil.h"
+
+#include "SkSLCompiler.h"
+
+GrMtlCopyPipelineState* GrMtlResourceProvider::findOrCreateCopyPipelineState(
+ MTLPixelFormat dstPixelFormat,
+ id<MTLFunction> vertexFunction,
+ id<MTLFunction> fragmentFunction,
+ MTLVertexDescriptor* vertexDescriptor) {
+
+ for (const auto& copyPipelineState: fCopyPipelineStateCache) {
+ if (GrMtlCopyManager::IsCompatible(copyPipelineState.get(), dstPixelFormat)) {
+ return copyPipelineState.get();
+ }
+ }
+
+ fCopyPipelineStateCache.emplace_back(GrMtlCopyPipelineState::CreateCopyPipelineState(
+ fGpu, dstPixelFormat, vertexFunction, fragmentFunction, vertexDescriptor));
+ return fCopyPipelineStateCache.back().get();
+}