blob: ce416181543013d7fbe780b08a75c21980fb582b [file] [log] [blame]
Timothy Liang7ac582e2018-08-06 09:47:23 -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#ifndef GrMtlPipelineStateBuilder_DEFINED
9#define GrMtlPipelineStateBuilder_DEFINED
10
11#include "GrPipeline.h"
12#include "GrProgramDesc.h"
Timothy Liang057c3902018-08-08 10:48:45 -040013#include "GrMtlUniformHandler.h"
14#include "GrMtlVaryingHandler.h"
Timothy Liang7ac582e2018-08-06 09:47:23 -040015#include "SkSLCompiler.h"
16#include "glsl/GrGLSLProgramBuilder.h"
17
18#import <metal/metal.h>
19
20class GrMtlGpu;
21class GrMtlPipelineState;
22
23class GrMtlPipelineStateBuilder : public GrGLSLProgramBuilder {
24public:
Robert Phillipsd0fe8752019-01-31 14:13:59 -050025 static GrMtlPipelineState* CreatePipelineState(GrRenderTarget*, GrSurfaceOrigin,
26 const GrPrimitiveProcessor&,
Greg Daniel9a51a862018-11-30 10:18:14 -050027 const GrTextureProxy* const primProcProxies[],
Timothy Liang7ac582e2018-08-06 09:47:23 -040028 const GrPipeline&,
29 GrProgramDesc*,
30 GrMtlGpu*);
31
32private:
Robert Phillipsd0fe8752019-01-31 14:13:59 -050033 GrMtlPipelineStateBuilder(GrRenderTarget*, GrSurfaceOrigin,
34 const GrPrimitiveProcessor&,
Greg Daniel9a51a862018-11-30 10:18:14 -050035 const GrTextureProxy* const primProcProxies[],
36 const GrPipeline&,
Timothy Liang7ac582e2018-08-06 09:47:23 -040037 GrProgramDesc*, GrMtlGpu*);
38
39 const GrCaps* caps() const override;
40
Timothy Liang057c3902018-08-08 10:48:45 -040041 GrGLSLUniformHandler* uniformHandler() override { return &fUniformHandler; }
Timothy Liang7ac582e2018-08-06 09:47:23 -040042
Timothy Liang057c3902018-08-08 10:48:45 -040043 const GrGLSLUniformHandler* uniformHandler() const override { return &fUniformHandler; }
Timothy Liang7ac582e2018-08-06 09:47:23 -040044
Timothy Liang057c3902018-08-08 10:48:45 -040045 GrGLSLVaryingHandler* varyingHandler() override { return &fVaryingHandler; }
Timothy Liang7ac582e2018-08-06 09:47:23 -040046
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 Liang057c3902018-08-08 10:48:45 -040056 GrMtlPipelineState* finalize(const GrPrimitiveProcessor&, const GrPipeline&, GrProgramDesc*);
Timothy Liang7ac582e2018-08-06 09:47:23 -040057
58 GrMtlGpu* fGpu;
Timothy Liang057c3902018-08-08 10:48:45 -040059 GrMtlUniformHandler fUniformHandler;
60 GrMtlVaryingHandler fVaryingHandler;
Timothy Liang7ac582e2018-08-06 09:47:23 -040061
62 typedef GrGLSLProgramBuilder INHERITED;
63};
64#endif