Flutter Engine
The Flutter Engine
Public Member Functions | Static Public Member Functions | Public Attributes | List of all members
skgpu::graphite::RenderPassDesc Struct Reference

#include <RenderPassDesc.h>

Public Member Functions

SkString toString () const
 
SkString toPipelineLabel () const
 

Static Public Member Functions

static RenderPassDesc Make (const Caps *caps, const TextureInfo &targetInfo, LoadOp loadOp, StoreOp storeOp, SkEnumBitMask< DepthStencilFlags > depthStencilFlags, const std::array< float, 4 > &clearColor, bool requiresMSAA, Swizzle writeSwizzle)
 

Public Attributes

AttachmentDesc fColorAttachment
 
std::array< float, 4 > fClearColor
 
AttachmentDesc fColorResolveAttachment
 
AttachmentDesc fDepthStencilAttachment
 
float fClearDepth
 
uint32_t fClearStencil
 
Swizzle fWriteSwizzle
 
uint32_t fSampleCount
 

Detailed Description

Definition at line 31 of file RenderPassDesc.h.

Member Function Documentation

◆ Make()

RenderPassDesc skgpu::graphite::RenderPassDesc::Make ( const Caps caps,
const TextureInfo targetInfo,
LoadOp  loadOp,
StoreOp  storeOp,
SkEnumBitMask< DepthStencilFlags depthStencilFlags,
const std::array< float, 4 > &  clearColor,
bool  requiresMSAA,
Swizzle  writeSwizzle 
)
static

Definition at line 37 of file RenderPassDesc.cpp.

44 {
45 RenderPassDesc desc;
46 desc.fWriteSwizzle = writeSwizzle;
47 desc.fSampleCount = 1;
48 // It doesn't make sense to have a storeOp for our main target not be store. Why are we doing
49 // this DrawPass then
50 SkASSERT(storeOp == StoreOp::kStore);
51 if (requiresMSAA) {
52 if (caps->msaaRenderToSingleSampledSupport()) {
53 desc.fColorAttachment.fTextureInfo = targetInfo;
54 desc.fColorAttachment.fLoadOp = loadOp;
55 desc.fColorAttachment.fStoreOp = storeOp;
56 desc.fSampleCount = caps->defaultMSAASamplesCount();
57 } else {
58 // TODO: If the resolve texture isn't readable, the MSAA color attachment will need to
59 // be persistently associated with the framebuffer, in which case it's not discardable.
60 auto msaaTextureInfo = caps->getDefaultMSAATextureInfo(targetInfo, Discardable::kYes);
61 if (msaaTextureInfo.isValid()) {
62 desc.fColorAttachment.fTextureInfo = msaaTextureInfo;
63 if (loadOp != LoadOp::kClear) {
64 desc.fColorAttachment.fLoadOp = LoadOp::kDiscard;
65 } else {
66 desc.fColorAttachment.fLoadOp = LoadOp::kClear;
67 }
68 desc.fColorAttachment.fStoreOp = StoreOp::kDiscard;
69
70 desc.fColorResolveAttachment.fTextureInfo = targetInfo;
71 if (loadOp != LoadOp::kLoad) {
72 desc.fColorResolveAttachment.fLoadOp = LoadOp::kDiscard;
73 } else {
74 desc.fColorResolveAttachment.fLoadOp = LoadOp::kLoad;
75 }
76 desc.fColorResolveAttachment.fStoreOp = storeOp;
77
78 desc.fSampleCount = msaaTextureInfo.numSamples();
79 } else {
80 // fall back to single sampled
81 desc.fColorAttachment.fTextureInfo = targetInfo;
82 desc.fColorAttachment.fLoadOp = loadOp;
83 desc.fColorAttachment.fStoreOp = storeOp;
84 }
85 }
86 } else {
87 desc.fColorAttachment.fTextureInfo = targetInfo;
88 desc.fColorAttachment.fLoadOp = loadOp;
89 desc.fColorAttachment.fStoreOp = storeOp;
90 }
91 desc.fClearColor = clearColor;
92
93 if (depthStencilFlags != DepthStencilFlags::kNone) {
94 desc.fDepthStencilAttachment.fTextureInfo = caps->getDefaultDepthStencilTextureInfo(
95 depthStencilFlags, desc.fSampleCount, targetInfo.isProtected());
96 // Always clear the depth and stencil to 0 at the start of a DrawPass, but discard at the
97 // end since their contents do not affect the next frame.
98 desc.fDepthStencilAttachment.fLoadOp = LoadOp::kClear;
99 desc.fClearDepth = 0.f;
100 desc.fClearStencil = 0;
101 desc.fDepthStencilAttachment.fStoreOp = StoreOp::kDiscard;
102 }
103
104 return desc;
105}
#define SkASSERT(cond)
Definition: SkAssert.h:116

◆ toPipelineLabel()

SkString skgpu::graphite::RenderPassDesc::toPipelineLabel ( ) const

Definition at line 120 of file RenderPassDesc.cpp.

120 {
121 // This intentionally only includes the fixed state that impacts pipeline compilation.
122 // We include the load op of the color attachment when there is a resolve attachment because
123 // the load may trigger a different renderpass description.
124 const char* colorLoadStr = "";
127 colorLoadStr = " w/ msaa load";
128 }
129 // TODO: Remove `fSampleCount` in label when the Dawn backend manages its MSAA color attachments
130 // directly instead of relying on msaaRenderToSingleSampledSupport().
131 return SkStringPrintf("RP(color: %s%s, resolve: %s, ds: %s, samples: %u, swizzle: %s)",
133 colorLoadStr,
138}
SK_API SkString SkStringPrintf(const char *format,...) SK_PRINTF_LIKE(1
Creates a new string and writes into it using a printf()-style format.
const char * c_str() const
Definition: SkString.h:133
SkString asString() const
Definition: Swizzle.cpp:46
SkString toRPAttachmentString() const
AttachmentDesc fDepthStencilAttachment
AttachmentDesc fColorResolveAttachment

◆ toString()

SkString skgpu::graphite::RenderPassDesc::toString ( ) const

Definition at line 107 of file RenderPassDesc.cpp.

107 {
108 return SkStringPrintf("RP(color: %s, resolve: %s, ds: %s, samples: %u, swizzle: %s, "
109 "clear: c(%f,%f,%f,%f), d(%f), s(0x%02x))",
118}
std::array< float, 4 > fClearColor

Member Data Documentation

◆ fClearColor

std::array<float, 4> skgpu::graphite::RenderPassDesc::fClearColor

Definition at line 42 of file RenderPassDesc.h.

◆ fClearDepth

float skgpu::graphite::RenderPassDesc::fClearDepth

Definition at line 46 of file RenderPassDesc.h.

◆ fClearStencil

uint32_t skgpu::graphite::RenderPassDesc::fClearStencil

Definition at line 47 of file RenderPassDesc.h.

◆ fColorAttachment

AttachmentDesc skgpu::graphite::RenderPassDesc::fColorAttachment

Definition at line 41 of file RenderPassDesc.h.

◆ fColorResolveAttachment

AttachmentDesc skgpu::graphite::RenderPassDesc::fColorResolveAttachment

Definition at line 43 of file RenderPassDesc.h.

◆ fDepthStencilAttachment

AttachmentDesc skgpu::graphite::RenderPassDesc::fDepthStencilAttachment

Definition at line 45 of file RenderPassDesc.h.

◆ fSampleCount

uint32_t skgpu::graphite::RenderPassDesc::fSampleCount

Definition at line 54 of file RenderPassDesc.h.

◆ fWriteSwizzle

Swizzle skgpu::graphite::RenderPassDesc::fWriteSwizzle

Definition at line 49 of file RenderPassDesc.h.


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