Flutter Engine
The Flutter Engine
Loading...
Searching...
No Matches
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 *, const RuntimeEffectDictionary *) override
 
Status addCommands (Context *, CommandBuffer *, ReplayTargetData) override
 
- 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 71 of file RenderPassTask.cpp.

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

◆ Make()

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

Definition at line 21 of file RenderPassTask.cpp.

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

◆ prepareResources()

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

Implements skgpu::graphite::Task.

Definition at line 51 of file RenderPassTask.cpp.

52 {
53 SkASSERT(fTarget);
54 if (!TextureProxy::InstantiateIfNotLazy(resourceProvider, fTarget.get())) {
55 SKGPU_LOG_W("Failed to instantiate RenderPassTask target. Will not create renderpass!");
56 SKGPU_LOG_W("Dimensions are (%d, %d).",
57 fTarget->dimensions().width(), fTarget->dimensions().height());
58 return Status::kFail;
59 }
60
61 // Assuming one draw pass per renderpasstask for now
62 SkASSERT(fDrawPasses.size() == 1);
63 for (const auto& drawPass: fDrawPasses) {
64 if (!drawPass->prepareResources(resourceProvider, runtimeDict, fRenderPassDesc)) {
65 return Status::kFail;
66 }
67 }
68 return Status::kSuccess;
69}
static bool InstantiateIfNotLazy(ResourceProvider *, TextureProxy *)
int size() const
Definition SkTArray.h:416

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