1 /* 2 * Copyright 2021 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 skgpu_graphite_GraphicsPipeline_DEFINED 9 #define skgpu_graphite_GraphicsPipeline_DEFINED 10 11 #include "src/gpu/graphite/Resource.h" 12 #include "src/gpu/graphite/UniquePaintParamsID.h" 13 14 namespace skgpu::graphite { 15 16 /** 17 * GraphicsPipeline corresponds to a backend specific pipeline used for rendering (vs. compute), 18 * e.g. MTLRenderPipelineState (Metal), 19 * CreateRenderPipeline (Dawn), 20 * CreateGraphicsPipelineState (D3D12), 21 * or VkGraphicsPipelineCreateInfo (Vulkan). 22 * 23 * A GraphicsPipeline is created from the combination of a GraphicsPipelineDesc (representing draw 24 * specific configuration) and a RenderPassDesc (representing the target of the draw). 25 */ 26 class GraphicsPipeline : public Resource { 27 public: 28 ~GraphicsPipeline() override; 29 getResourceType()30 const char* getResourceType() const override { return "Graphics Pipeline"; } 31 32 #if defined(GRAPHITE_TEST_UTILS) 33 // This is not quite enough information to fully recreate the pipeline, as the RenderPassDesc 34 // used to make the pipeline is not preserved. 35 struct PipelineInfo { 36 uint32_t fRenderStepID; 37 UniquePaintParamsID fPaintID; 38 std::string fSkSLVertexShader; 39 std::string fSkSLFragmentShader; 40 std::string fNativeVertexShader; 41 std::string fNativeFragmentShader; 42 }; 43 getPipelineInfo()44 const PipelineInfo& getPipelineInfo() const { 45 return fPipelineInfo; 46 } 47 #else 48 struct PipelineInfo; 49 #endif 50 51 protected: 52 GraphicsPipeline(const SharedContext*, PipelineInfo*); 53 54 private: 55 #if defined(GRAPHITE_TEST_UTILS) 56 PipelineInfo fPipelineInfo; 57 #endif 58 }; 59 60 } // namespace skgpu::graphite 61 62 #endif // skgpu_graphite_GraphicsPipeline_DEFINED 63