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 #ifndef GrMtlPipelineStateBuilder_DEFINED 9 #define GrMtlPipelineStateBuilder_DEFINED 10 11 #include "GrPipeline.h" 12 #include "GrProgramDesc.h" 13 #include "GrMtlUniformHandler.h" 14 #include "GrMtlVaryingHandler.h" 15 #include "SkSLCompiler.h" 16 #include "glsl/GrGLSLProgramBuilder.h" 17 18 #import <metal/metal.h> 19 20 class GrMtlGpu; 21 class GrMtlPipelineState; 22 23 class GrMtlPipelineStateBuilder : public GrGLSLProgramBuilder { 24 public: 25 static GrMtlPipelineState* CreatePipelineState(GrRenderTarget*, GrSurfaceOrigin, 26 const GrPrimitiveProcessor&, 27 const GrTextureProxy* const primProcProxies[], 28 const GrPipeline&, 29 GrProgramDesc*, 30 GrMtlGpu*); 31 32 private: 33 GrMtlPipelineStateBuilder(GrRenderTarget*, GrSurfaceOrigin, 34 const GrPrimitiveProcessor&, 35 const GrTextureProxy* const primProcProxies[], 36 const GrPipeline&, 37 GrProgramDesc*, GrMtlGpu*); 38 39 const GrCaps* caps() const override; 40 uniformHandler()41 GrGLSLUniformHandler* uniformHandler() override { return &fUniformHandler; } 42 uniformHandler()43 const GrGLSLUniformHandler* uniformHandler() const override { return &fUniformHandler; } 44 varyingHandler()45 GrGLSLVaryingHandler* varyingHandler() override { return &fVaryingHandler; } 46 47 void finalizeFragmentOutputColor(GrShaderVar& outputColor) override; 48 49 void finalizeFragmentSecondaryColor(GrShaderVar& outputColor) override; 50 51 id<MTLLibrary> createMtlShaderLibrary(const GrGLSLShaderBuilder& builder, 52 SkSL::Program::Kind kind, 53 const SkSL::Program::Settings& settings, 54 GrProgramDesc* desc); 55 56 GrMtlPipelineState* finalize(const GrPrimitiveProcessor&, const GrPipeline&, GrProgramDesc*); 57 58 GrMtlGpu* fGpu; 59 GrMtlUniformHandler fUniformHandler; 60 GrMtlVaryingHandler fVaryingHandler; 61 62 typedef GrGLSLProgramBuilder INHERITED; 63 }; 64 #endif 65