1 /* 2 * Copyright 2020 Google LLC 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 GrD3DPipelineStateBuilder_DEFINED 9 #define GrD3DPipelineStateBuilder_DEFINED 10 11 #include "src/gpu/ganesh/GrPipeline.h" 12 #include "src/gpu/ganesh/GrSPIRVUniformHandler.h" 13 #include "src/gpu/ganesh/GrSPIRVVaryingHandler.h" 14 #include "src/gpu/ganesh/d3d/GrD3DPipelineState.h" 15 #include "src/gpu/ganesh/glsl/GrGLSLProgramBuilder.h" 16 #include "src/sksl/ir/SkSLProgram.h" 17 18 class GrProgramDesc; 19 class GrD3DGpu; 20 class GrVkRenderPass; 21 22 class GrD3DPipelineStateBuilder : public GrGLSLProgramBuilder { 23 public: 24 /** Generates a pipeline state. 25 * 26 * The returned GrD3DPipelineState implements the supplied GrProgramInfo. 27 * 28 * @return the created pipeline if generation was successful; nullptr otherwise 29 */ 30 static std::unique_ptr<GrD3DPipelineState> MakePipelineState(GrD3DGpu*, 31 GrD3DRenderTarget*, 32 const GrProgramDesc&, 33 const GrProgramInfo&); 34 35 static sk_sp<GrD3DPipeline> MakeComputePipeline(GrD3DGpu*, GrD3DRootSignature*, 36 const char* shader); 37 38 const GrCaps* caps() const override; 39 gpu()40 GrD3DGpu* gpu() const { return fGpu; } 41 42 SkSL::Compiler* shaderCompiler() const override; 43 44 void finalizeFragmentSecondaryColor(GrShaderVar& outputColor) override; 45 46 private: 47 GrD3DPipelineStateBuilder(GrD3DGpu*, GrD3DRenderTarget*, const GrProgramDesc&, 48 const GrProgramInfo&); 49 50 std::unique_ptr<GrD3DPipelineState> finalize(); 51 52 bool loadHLSLFromCache(SkReadBuffer* reader, gr_cp<ID3DBlob> shaders[]); 53 54 gr_cp<ID3DBlob> compileD3DProgram(SkSL::ProgramKind kind, 55 const std::string& sksl, 56 const SkSL::ProgramSettings& settings, 57 SkSL::Program::Inputs* outInputs, 58 std::string* outHLSL); 59 uniformHandler()60 GrGLSLUniformHandler* uniformHandler() override { return &fUniformHandler; } uniformHandler()61 const GrGLSLUniformHandler* uniformHandler() const override { return &fUniformHandler; } varyingHandler()62 GrGLSLVaryingHandler* varyingHandler() override { return &fVaryingHandler; } 63 64 GrD3DGpu* fGpu; 65 GrSPIRVVaryingHandler fVaryingHandler; 66 GrSPIRVUniformHandler fUniformHandler; 67 GrD3DRenderTarget* fRenderTarget; 68 69 using INHERITED = GrGLSLProgramBuilder; 70 }; 71 72 #endif 73