Flutter Engine
The Flutter Engine
Public Types | Public Member Functions | Static Public Member Functions | List of all members
skgpu::graphite::RenderPassTask Class Referencefinal

#include <RenderPassTask.h>

Inheritance diagram for skgpu::graphite::RenderPassTask:
skgpu::graphite::Task SkRefCnt SkRefCntBase

Public Types

using DrawPassList = skia_private::STArray< 1, std::unique_ptr< DrawPass > >
 
- Public Types inherited from skgpu::graphite::Task
enum class  Status { kSuccess , kDiscard , kFail }
 

Public Member Functions

 ~RenderPassTask () override
 
Status prepareResources (ResourceProvider *, ScratchResourceManager *, const RuntimeEffectDictionary *) override
 
Status addCommands (Context *, CommandBuffer *, ReplayTargetData) override
 
virtual Status prepareResources (ResourceProvider *, ScratchResourceManager *, const RuntimeEffectDictionary *)=0
 
virtual Status addCommands (Context *, CommandBuffer *, ReplayTargetData)=0
 
- Public Member Functions inherited from SkRefCntBase
 SkRefCntBase ()
 
virtual ~SkRefCntBase ()
 
bool unique () const
 
void ref () const
 
void unref () const
 

Static Public Member Functions

static sk_sp< RenderPassTaskMake (DrawPassList, const RenderPassDesc &, sk_sp< TextureProxy > target)
 

Detailed Description

RenderPassTask handles preparing and recording DrawLists into a single render pass within a command buffer. If the backend supports subpasses, and the DrawLists/surfaces are compatible, a RenderPassTask can execute multiple DrawLists across different surfaces as subpasses nested within a single render pass. If there is no such support, a RenderPassTask is one-to-one with a "render pass" to specific surface.

Definition at line 26 of file RenderPassTask.h.

Member Typedef Documentation

◆ DrawPassList

Definition at line 28 of file RenderPassTask.h.

Constructor & Destructor Documentation

◆ ~RenderPassTask()

skgpu::graphite::RenderPassTask::~RenderPassTask ( )
overridedefault

Member Function Documentation

◆ addCommands()

Task::Status skgpu::graphite::RenderPassTask::addCommands ( Context context,
CommandBuffer commandBuffer,
ReplayTargetData  replayData 
)
overridevirtual

Implements skgpu::graphite::Task.

Definition at line 79 of file RenderPassTask.cpp.

81 {
82 // TBD: Expose the surfaces that will need to be attached within the renderpass?
83
84 // TODO: for task execution, start the render pass, then iterate passes and
85 // possibly(?) start each subpass, and call DrawPass::addCommands() on the command buffer
86 // provided to the task. Then close the render pass and we should have pixels..
87
88 // Instantiate the target
89 SkASSERT(fTarget && fTarget->isInstantiated());
90
91 if (fTarget->texture() == replayData.fTarget) {
92 commandBuffer->setReplayTranslation(replayData.fTranslation);
93 } else {
94 commandBuffer->clearReplayTranslation();
95 }
96
97 // We don't instantiate the MSAA or DS attachments in prepareResources because we want to use
98 // the discardable attachments from the Context.
99 ResourceProvider* resourceProvider = context->priv().resourceProvider();
100 sk_sp<Texture> colorAttachment;
101 sk_sp<Texture> resolveAttachment;
102 if (fRenderPassDesc.fColorResolveAttachment.fTextureInfo.isValid()) {
103 SkASSERT(fTarget->numSamples() == 1 &&
104 fRenderPassDesc.fColorAttachment.fTextureInfo.numSamples() > 1);
105 colorAttachment = resourceProvider->findOrCreateDiscardableMSAAAttachment(
106 fTarget->dimensions(), fRenderPassDesc.fColorAttachment.fTextureInfo);
107 if (!colorAttachment) {
108 SKGPU_LOG_W("Could not get Color attachment for RenderPassTask");
109 return Status::kFail;
110 }
111 resolveAttachment = fTarget->refTexture();
112 } else {
113 colorAttachment = fTarget->refTexture();
114 }
115
116 sk_sp<Texture> depthStencilAttachment;
117 if (fRenderPassDesc.fDepthStencilAttachment.fTextureInfo.isValid()) {
118 // TODO: ensure this is a scratch/recycled texture
119 SkASSERT(fTarget->isInstantiated());
120 SkISize dimensions = context->priv().caps()->getDepthAttachmentDimensions(
121 fTarget->texture()->textureInfo(), fTarget->dimensions());
122 depthStencilAttachment = resourceProvider->findOrCreateDepthStencilAttachment(
123 dimensions, fRenderPassDesc.fDepthStencilAttachment.fTextureInfo);
124 if (!depthStencilAttachment) {
125 SKGPU_LOG_W("Could not get DepthStencil attachment for RenderPassTask");
126 return Status::kFail;
127 }
128 }
129
130 // TODO(b/313629288) we always pass in the render target's dimensions as the viewport here.
131 // Using the dimensions of the logical device that we're drawing to could reduce flakiness in
132 // rendering.
133 if (commandBuffer->addRenderPass(fRenderPassDesc,
134 std::move(colorAttachment),
135 std::move(resolveAttachment),
136 std::move(depthStencilAttachment),
137 SkRect::Make(fTarget->dimensions()),
138 fDrawPasses)) {
139 return Status::kSuccess;
140 } else {
141 return Status::kFail;
142 }
143}
#define SKGPU_LOG_W(fmt,...)
Definition: Log.h:40
#define SkASSERT(cond)
Definition: SkAssert.h:116
uint32_t numSamples() const
Definition: TextureInfo.h:78
Definition: SkSize.h:16
static SkRect Make(const SkISize &size)
Definition: SkRect.h:669
AttachmentDesc fDepthStencilAttachment
AttachmentDesc fColorResolveAttachment

◆ Make()

sk_sp< RenderPassTask > skgpu::graphite::RenderPassTask::Make ( DrawPassList  passes,
const RenderPassDesc desc,
sk_sp< TextureProxy target 
)
static

Definition at line 22 of file RenderPassTask.cpp.

24 {
25 // For now we have one DrawPass per RenderPassTask
26 SkASSERT(passes.size() == 1);
27 if (!target) {
28 return nullptr;
29 }
30
31 if (desc.fColorAttachment.fTextureInfo.isValid()) {
32 // The color attachment's samples count must ether match the render pass's samples count
33 // or be 1 (when multisampled render to single sampled is used).
34 SkASSERT(desc.fSampleCount == desc.fColorAttachment.fTextureInfo.numSamples() ||
35 1 == desc.fColorAttachment.fTextureInfo.numSamples());
36 }
37
38 if (desc.fDepthStencilAttachment.fTextureInfo.isValid()) {
39 SkASSERT(desc.fSampleCount == desc.fDepthStencilAttachment.fTextureInfo.numSamples());
40 }
41
42 return sk_sp<RenderPassTask>(new RenderPassTask(std::move(passes), desc, target));
43}
uint32_t * target

◆ prepareResources()

Task::Status skgpu::graphite::RenderPassTask::prepareResources ( ResourceProvider resourceProvider,
ScratchResourceManager scratchManager,
const RuntimeEffectDictionary runtimeDict 
)
overridevirtual

Implements skgpu::graphite::Task.

Definition at line 52 of file RenderPassTask.cpp.

54 {
55 SkASSERT(fTarget);
56 if (!TextureProxy::InstantiateIfNotLazy(scratchManager, fTarget.get())) {
57 SKGPU_LOG_W("Failed to instantiate RenderPassTask target. Will not create renderpass!");
58 SKGPU_LOG_W("Dimensions are (%d, %d).",
59 fTarget->dimensions().width(), fTarget->dimensions().height());
60 return Status::kFail;
61 }
62
63 // Assuming one draw pass per renderpasstask for now
64 SkASSERT(fDrawPasses.size() == 1);
65 for (const auto& drawPass: fDrawPasses) {
66 if (!drawPass->prepareResources(resourceProvider, runtimeDict, fRenderPassDesc)) {
67 return Status::kFail;
68 }
69 }
70
71 // Once all internal resources have been prepared and instantiated, reclaim any pending returns
72 // from the scratch manager, since at the equivalent point in the task graph's addCommands()
73 // phase, the renderpass will have sampled from any scratch textures and their contents no
74 // longer have to be preserved.
75 scratchManager->notifyResourcesConsumed();
76 return Status::kSuccess;
77}
static bool InstantiateIfNotLazy(ResourceProvider *, TextureProxy *)
int size() const
Definition: SkTArray.h:421

The documentation for this class was generated from the following files: