Timothy Liang | e30739a | 2018-07-31 10:51:17 -0400 | [diff] [blame] | 1 | /* |
| 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 | |
| 16 | GrMtlCopyPipelineState* 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 | } |