blob: 2e1e40dfe99842cd92ca6405df035cd10c3835ec [file] [log] [blame]
Timothy Liange30739a2018-07-31 10:51:17 -04001/*
2 * Copyright 2018 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#include "GrMtlResourceProvider.h"
9
10#include "GrMtlCopyManager.h"
11#include "GrMtlGpu.h"
12#include "GrMtlUtil.h"
13
14#include "SkSLCompiler.h"
15
16GrMtlCopyPipelineState* GrMtlResourceProvider::findOrCreateCopyPipelineState(
17 MTLPixelFormat dstPixelFormat,
18 id<MTLFunction> vertexFunction,
19 id<MTLFunction> fragmentFunction,
20 MTLVertexDescriptor* vertexDescriptor) {
21
22 for (const auto& copyPipelineState: fCopyPipelineStateCache) {
23 if (GrMtlCopyManager::IsCompatible(copyPipelineState.get(), dstPixelFormat)) {
24 return copyPipelineState.get();
25 }
26 }
27
28 fCopyPipelineStateCache.emplace_back(GrMtlCopyPipelineState::CreateCopyPipelineState(
29 fGpu, dstPixelFormat, vertexFunction, fragmentFunction, vertexDescriptor));
30 return fCopyPipelineStateCache.back().get();
31}