Timothy Liang | 7ac582e | 2018-08-06 09:47:23 -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 | #ifndef GrMtlPipelineStateBuilder_DEFINED |
| 9 | #define GrMtlPipelineStateBuilder_DEFINED |
| 10 | |
| 11 | #include "GrPipeline.h" |
| 12 | #include "GrProgramDesc.h" |
Timothy Liang | 057c390 | 2018-08-08 10:48:45 -0400 | [diff] [blame] | 13 | #include "GrMtlUniformHandler.h" |
| 14 | #include "GrMtlVaryingHandler.h" |
Timothy Liang | 7ac582e | 2018-08-06 09:47:23 -0400 | [diff] [blame] | 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: |
Robert Phillips | d0fe875 | 2019-01-31 14:13:59 -0500 | [diff] [blame] | 25 | static GrMtlPipelineState* CreatePipelineState(GrRenderTarget*, GrSurfaceOrigin, |
| 26 | const GrPrimitiveProcessor&, |
Greg Daniel | 9a51a86 | 2018-11-30 10:18:14 -0500 | [diff] [blame] | 27 | const GrTextureProxy* const primProcProxies[], |
Timothy Liang | 7ac582e | 2018-08-06 09:47:23 -0400 | [diff] [blame] | 28 | const GrPipeline&, |
| 29 | GrProgramDesc*, |
| 30 | GrMtlGpu*); |
| 31 | |
| 32 | private: |
Robert Phillips | d0fe875 | 2019-01-31 14:13:59 -0500 | [diff] [blame] | 33 | GrMtlPipelineStateBuilder(GrRenderTarget*, GrSurfaceOrigin, |
| 34 | const GrPrimitiveProcessor&, |
Greg Daniel | 9a51a86 | 2018-11-30 10:18:14 -0500 | [diff] [blame] | 35 | const GrTextureProxy* const primProcProxies[], |
| 36 | const GrPipeline&, |
Timothy Liang | 7ac582e | 2018-08-06 09:47:23 -0400 | [diff] [blame] | 37 | GrProgramDesc*, GrMtlGpu*); |
| 38 | |
| 39 | const GrCaps* caps() const override; |
| 40 | |
Timothy Liang | 057c390 | 2018-08-08 10:48:45 -0400 | [diff] [blame] | 41 | GrGLSLUniformHandler* uniformHandler() override { return &fUniformHandler; } |
Timothy Liang | 7ac582e | 2018-08-06 09:47:23 -0400 | [diff] [blame] | 42 | |
Timothy Liang | 057c390 | 2018-08-08 10:48:45 -0400 | [diff] [blame] | 43 | const GrGLSLUniformHandler* uniformHandler() const override { return &fUniformHandler; } |
Timothy Liang | 7ac582e | 2018-08-06 09:47:23 -0400 | [diff] [blame] | 44 | |
Timothy Liang | 057c390 | 2018-08-08 10:48:45 -0400 | [diff] [blame] | 45 | GrGLSLVaryingHandler* varyingHandler() override { return &fVaryingHandler; } |
Timothy Liang | 7ac582e | 2018-08-06 09:47:23 -0400 | [diff] [blame] | 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 | |
Timothy Liang | 057c390 | 2018-08-08 10:48:45 -0400 | [diff] [blame] | 56 | GrMtlPipelineState* finalize(const GrPrimitiveProcessor&, const GrPipeline&, GrProgramDesc*); |
Timothy Liang | 7ac582e | 2018-08-06 09:47:23 -0400 | [diff] [blame] | 57 | |
| 58 | GrMtlGpu* fGpu; |
Timothy Liang | 057c390 | 2018-08-08 10:48:45 -0400 | [diff] [blame] | 59 | GrMtlUniformHandler fUniformHandler; |
| 60 | GrMtlVaryingHandler fVaryingHandler; |
Timothy Liang | 7ac582e | 2018-08-06 09:47:23 -0400 | [diff] [blame] | 61 | |
| 62 | typedef GrGLSLProgramBuilder INHERITED; |
| 63 | }; |
| 64 | #endif |