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_GraphicsPipelineDesc_DEFINED 9 #define skgpu_graphite_GraphicsPipelineDesc_DEFINED 10 11 #include "src/gpu/graphite/Renderer.h" 12 #include "src/gpu/graphite/UniquePaintParamsID.h" 13 14 namespace skgpu::graphite { 15 16 /** 17 * GraphicsPipelineDesc represents the state needed to create a backend specific GraphicsPipeline, 18 * minus the target-specific properties that can be inferred from the DrawPass and RenderPassTask. 19 */ 20 class GraphicsPipelineDesc { 21 public: GraphicsPipelineDesc(const RenderStep * renderStep,UniquePaintParamsID paintID)22 GraphicsPipelineDesc(const RenderStep* renderStep, UniquePaintParamsID paintID) 23 : fRenderStepID(renderStep->uniqueID()) 24 , fPaintID(paintID) {} 25 26 bool operator==(const GraphicsPipelineDesc& that) const { 27 return fRenderStepID == that.fRenderStepID && fPaintID == that.fPaintID; 28 } 29 30 bool operator!=(const GraphicsPipelineDesc& other) const { 31 return !(*this == other); 32 } 33 34 // Describes the geometric portion of the pipeline's program and the pipeline's fixed state 35 // (except for renderpass-level state that will never change between draws). renderStepID()36 uint32_t renderStepID() const { return fRenderStepID; } 37 // UniqueID of the required PaintParams paintParamsID()38 UniquePaintParamsID paintParamsID() const { return fPaintID; } 39 40 private: 41 // Each RenderStep defines a fixed set of attributes and rasterization state, as well as the 42 // shader fragments that control the geometry and coverage calculations. The RenderStep's shader 43 // is combined with the rest of the shader generated from the PaintParams. Because each 44 // RenderStep is fixed, its pointer can be used as a proxy for everything that it specifies in 45 // the GraphicsPipeline. 46 uint32_t fRenderStepID; 47 UniquePaintParamsID fPaintID; 48 }; 49 50 } // namespace skgpu::graphite 51 52 #endif // skgpu_graphite_GraphicsPipelineDesc_DEFINED 53