xref: /aosp_15_r20/external/skia/src/gpu/graphite/GraphicsPipelineDesc.h (revision c8dee2aa9b3f27cf6c858bd81872bdeb2c07ed17)
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()22     GraphicsPipelineDesc() : fRenderStepID(0), fPaintID(UniquePaintParamsID::InvalidID()) {}
GraphicsPipelineDesc(const RenderStep * renderStep,UniquePaintParamsID paintID)23     GraphicsPipelineDesc(const RenderStep* renderStep, UniquePaintParamsID paintID)
24         : fRenderStepID(renderStep->uniqueID())
25         , fPaintID(paintID) {}
26 
27     bool operator==(const GraphicsPipelineDesc& that) const {
28         return fRenderStepID == that.fRenderStepID && fPaintID == that.fPaintID;
29     }
30 
31     bool operator!=(const GraphicsPipelineDesc& other) const {
32         return !(*this == other);
33     }
34 
35     // Describes the geometric portion of the pipeline's program and the pipeline's fixed state
36     // (except for renderpass-level state that will never change between draws).
renderStepID()37     uint32_t renderStepID() const { return fRenderStepID; }
38     // UniqueID of the required PaintParams
paintParamsID()39     UniquePaintParamsID paintParamsID() const { return fPaintID; }
40 
41 private:
42     // Each RenderStep defines a fixed set of attributes and rasterization state, as well as the
43     // shader fragments that control the geometry and coverage calculations. The RenderStep's shader
44     // is combined with the rest of the shader generated from the PaintParams. Because each
45     // RenderStep is fixed, its pointer can be used as a proxy for everything that it specifies in
46     // the GraphicsPipeline.
47     uint32_t fRenderStepID;
48     UniquePaintParamsID fPaintID;
49 };
50 
51 } // namespace skgpu::graphite
52 
53 #endif // skgpu_graphite_GraphicsPipelineDesc_DEFINED
54