• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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 class ShaderCodeDictionary;
17 
18 /**
19  * GraphicsPipelineDesc represents the state needed to create a backend specific GraphicsPipeline,
20  * minus the target-specific properties that can be inferred from the DrawPass and RenderPassTask.
21  */
22 class GraphicsPipelineDesc {
23 public:
GraphicsPipelineDesc()24     GraphicsPipelineDesc() : fRenderStepID(RenderStep::RenderStepID::kInvalid)
25                            , fPaintID(UniquePaintParamsID::Invalid()) {}
GraphicsPipelineDesc(RenderStep::RenderStepID renderStepID,UniquePaintParamsID paintID)26     GraphicsPipelineDesc(RenderStep::RenderStepID renderStepID, UniquePaintParamsID paintID)
27         : fRenderStepID(renderStepID)
28         , fPaintID(paintID) {}
29 
30     bool operator==(const GraphicsPipelineDesc& that) const {
31         return fRenderStepID == that.fRenderStepID && fPaintID == that.fPaintID;
32     }
33 
34     bool operator!=(const GraphicsPipelineDesc& other) const {
35         return !(*this == other);
36     }
37 
38     // Describes the geometric portion of the pipeline's program and the pipeline's fixed state
39     // (except for renderpass-level state that will never change between draws).
renderStepID()40     RenderStep::RenderStepID renderStepID() const { return fRenderStepID; }
41     // UniqueID of the required PaintParams
paintParamsID()42     UniquePaintParamsID paintParamsID() const { return fPaintID; }
43 
44 #if defined(GPU_TEST_UTILS)
45     SkString toString(ShaderCodeDictionary* dict) const;
46 #endif
47 
48 private:
49     // Each RenderStep defines a fixed set of attributes and rasterization state, as well as the
50     // shader fragments that control the geometry and coverage calculations. The RenderStep's shader
51     // is combined with the rest of the shader generated from the PaintParams. Because each
52     // RenderStep is fixed, its pointer can be used as a proxy for everything that it specifies in
53     // the GraphicsPipeline.
54     RenderStep::RenderStepID fRenderStepID;
55     UniquePaintParamsID fPaintID;
56 };
57 
58 } // namespace skgpu::graphite
59 
60 #endif // skgpu_graphite_GraphicsPipelineDesc_DEFINED
61