Debian Codegraph @

src/gpu/graphite/GraphicsPipelineDesc.h

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