diff options
Diffstat (limited to 'src/gpu/mtl/GrMtlCopyPipelineState.mm')
-rw-r--r-- | src/gpu/mtl/GrMtlCopyPipelineState.mm | 37 |
1 files changed, 37 insertions, 0 deletions
diff --git a/src/gpu/mtl/GrMtlCopyPipelineState.mm b/src/gpu/mtl/GrMtlCopyPipelineState.mm new file mode 100644 index 0000000000..27b52e60f2 --- /dev/null +++ b/src/gpu/mtl/GrMtlCopyPipelineState.mm @@ -0,0 +1,37 @@ +/* + * 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 "GrMtlCopyPipelineState.h" +#include "GrMtlGpu.h" + +GrMtlCopyPipelineState* GrMtlCopyPipelineState::CreateCopyPipelineState( + GrMtlGpu* gpu, + MTLPixelFormat dstPixelFormat, + id<MTLFunction> vertexFunction, + id<MTLFunction> fragmentFunction, + MTLVertexDescriptor* vertexDescriptor) { + + // Create pipeline state for copy as draw + MTLRenderPipelineDescriptor* pipelineDescriptor = [[MTLRenderPipelineDescriptor alloc] init]; + pipelineDescriptor.vertexFunction = vertexFunction; + pipelineDescriptor.fragmentFunction = fragmentFunction; + pipelineDescriptor.vertexDescriptor = vertexDescriptor; + pipelineDescriptor.colorAttachments[0].pixelFormat = dstPixelFormat; + + NSError* error = nil; + id<MTLRenderPipelineState> pipelineState = + [gpu->device() newRenderPipelineStateWithDescriptor: pipelineDescriptor + error: &error]; + if (error) { + SkDebugf("Error creating pipeline: %s\n", + [[error localizedDescription] cStringUsingEncoding: NSASCIIStringEncoding]); + return nil; + } + + SkASSERT(pipelineState); + return new GrMtlCopyPipelineState(pipelineState, dstPixelFormat); +} |