aboutsummaryrefslogtreecommitdiff
path: root/src/gpu/graphite/GraphicsPipelineDesc.h
blob: 0226a111f7bf986c8c4be8c69d59235c5e89aae6 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
/*
 * Copyright 2021 Google LLC
 *
 * Use of this source code is governed by a BSD-style license that can be
 * found in the LICENSE file.
 */

#ifndef skgpu_graphite_GraphicsPipelineDesc_DEFINED
#define skgpu_graphite_GraphicsPipelineDesc_DEFINED

#include "src/gpu/graphite/Renderer.h"
#include "src/gpu/graphite/UniquePaintParamsID.h"

namespace skgpu::graphite {

/**
 * GraphicsPipelineDesc represents the state needed to create a backend specific GraphicsPipeline,
 * minus the target-specific properties that can be inferred from the DrawPass and RenderPassTask.
 */
class GraphicsPipelineDesc {
public:
    GraphicsPipelineDesc(const RenderStep* renderStep, UniquePaintParamsID paintID)
        : fRenderStepID(renderStep->uniqueID())
        , fPaintID(paintID) {}

    bool operator==(const GraphicsPipelineDesc& that) const {
        return fRenderStepID == that.fRenderStepID && fPaintID == that.fPaintID;
    }

    bool operator!=(const GraphicsPipelineDesc& other) const {
        return !(*this == other);
    }

    // Describes the geometric portion of the pipeline's program and the pipeline's fixed state
    // (except for renderpass-level state that will never change between draws).
    uint32_t renderStepID() const { return fRenderStepID; }
    // UniqueID of the required PaintParams
    UniquePaintParamsID paintParamsID() const { return fPaintID; }

private:
    // Each RenderStep defines a fixed set of attributes and rasterization state, as well as the
    // shader fragments that control the geometry and coverage calculations. The RenderStep's shader
    // is combined with the rest of the shader generated from the PaintParams. Because each
    // RenderStep is fixed, its pointer can be used as a proxy for everything that it specifies in
    // the GraphicsPipeline.
    uint32_t fRenderStepID;
    UniquePaintParamsID fPaintID;
};

} // namespace skgpu::graphite

#endif // skgpu_graphite_GraphicsPipelineDesc_DEFINED