Flutter Engine
The Flutter Engine
Loading...
Searching...
No Matches
DrawPass.h
Go to the documentation of this file.
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_DrawPass_DEFINED
9#define skgpu_graphite_DrawPass_DEFINED
10
12#include "include/core/SkRect.h"
21
22#include <memory>
23
24struct SkImageInfo;
25
26namespace skgpu::graphite {
27
28class BoundsManager;
29class CommandBuffer;
30class DrawList;
31class GraphicsPipeline;
32class Recorder;
33struct RenderPassDesc;
35class RuntimeEffectDictionary;
36class Sampler;
37class TextureDataBlock;
38class Texture;
39enum class UniformSlot;
40
41/**
42 * DrawPass is analogous to a subpass, storing the drawing operations in the order they are stored
43 * in the eventual command buffer, as well as the surface proxy the operations are intended for.
44 * DrawPasses are grouped into a RenderPassTask for execution within a single render pass if the
45 * subpasses are compatible with each other.
46 *
47 * Unlike DrawList, DrawPasses are immutable and represent as closely as possible what will be
48 * stored in the command buffer while being flexible as to how the pass is incorporated. Depending
49 * on the backend, it may even be able to write accumulated vertex and uniform data directly to
50 * mapped GPU memory, although that is the extent of the CPU->GPU work they perform before they are
51 * executed by a RenderPassTask.
52 */
53class DrawPass {
54public:
56
57 static std::unique_ptr<DrawPass> Make(Recorder*,
58 std::unique_ptr<DrawList>,
60 const SkImageInfo& targetInfo,
61 std::pair<LoadOp, StoreOp>,
62 std::array<float, 4> clearColor);
63
64 // Defined relative to the top-left corner of the surface the DrawPass renders to, and is
65 // contained within its dimensions.
66 const SkIRect& bounds() const { return fBounds; }
67 TextureProxy* target() const { return fTarget.get(); }
68 std::pair<LoadOp, StoreOp> ops() const { return fOps; }
69 std::array<float, 4> clearColor() const { return fClearColor; }
70
71 bool requiresDstTexture() const { return false; }
72 bool requiresMSAA() const { return fRequiresMSAA; }
73
74 SkEnumBitMask<DepthStencilFlags> depthStencilFlags() const { return fDepthStencilFlags; }
75
76 size_t vertexBufferSize() const { return 0; }
77 size_t uniformBufferSize() const { return 0; }
78
79 // Instantiate and prepare any resources used by the DrawPass that require the Recorder's
80 // ResourceProvider. This includes things likes GraphicsPipelines, sampled Textures, Samplers,
81 // etc.
84 const RenderPassDesc&);
85
86 DrawPassCommands::List::Iter commands() const {
87 return fCommandList.commands();
88 }
89
90 const GraphicsPipeline* getPipeline(size_t index) const {
91 return fFullPipelines[index].get();
92 }
93 const Texture* getTexture(size_t index) const;
94 const Sampler* getSampler(size_t index) const;
95
96 skia_private::TArray<sk_sp<TextureProxy>> sampledTextures() const { return fSampledTextures; }
97
98 void addResourceRefs(CommandBuffer*) const;
99
100private:
101 class SortKey;
102
104 std::pair<LoadOp, StoreOp> ops,
105 std::array<float, 4> clearColor);
106
107 DrawPassCommands::List fCommandList;
108
109 sk_sp<TextureProxy> fTarget;
111
112 std::pair<LoadOp, StoreOp> fOps;
113 std::array<float, 4> fClearColor;
114
116 bool fRequiresMSAA = false;
117
118 // The pipelines are referenced by index in BindGraphicsPipeline, but that will index into a
119 // an array of actual GraphicsPipelines.
122
123 // These resources all get instantiated during prepareResources.
127};
128
129} // namespace skgpu::graphite
130
131#endif // skgpu_graphite_DrawPass_DEFINED
const SkRect fBounds
size_t vertexBufferSize() const
Definition DrawPass.h:76
const Texture * getTexture(size_t index) const
Definition DrawPass.cpp:756
std::array< float, 4 > clearColor() const
Definition DrawPass.h:69
bool prepareResources(ResourceProvider *, const RuntimeEffectDictionary *, const RenderPassDesc &)
Definition DrawPass.cpp:694
size_t uniformBufferSize() const
Definition DrawPass.h:77
const Sampler * getSampler(size_t index) const
Definition DrawPass.cpp:762
DrawPassCommands::List::Iter commands() const
Definition DrawPass.h:86
const SkIRect & bounds() const
Definition DrawPass.h:66
SkEnumBitMask< DepthStencilFlags > depthStencilFlags() const
Definition DrawPass.h:74
std::pair< LoadOp, StoreOp > ops() const
Definition DrawPass.h:68
static std::unique_ptr< DrawPass > Make(Recorder *, std::unique_ptr< DrawList >, sk_sp< TextureProxy > target, const SkImageInfo &targetInfo, std::pair< LoadOp, StoreOp >, std::array< float, 4 > clearColor)
Definition DrawPass.cpp:452
bool requiresDstTexture() const
Definition DrawPass.h:71
TextureProxy * target() const
Definition DrawPass.h:67
bool requiresMSAA() const
Definition DrawPass.h:72
skia_private::TArray< sk_sp< TextureProxy > > sampledTextures() const
Definition DrawPass.h:96
void addResourceRefs(CommandBuffer *) const
Definition DrawPass.cpp:744
const GraphicsPipeline * getPipeline(size_t index) const
Definition DrawPass.h:90
std::function< ProfileSample(void)> Sampler
Sampler is run during SamplingProfiler::SampleRepeatedly. Each platform should implement its version ...