Flutter Engine
The Flutter Engine
Public Types | Public Member Functions | Static Public Member Functions | Protected Types | Protected Member Functions | List of all members
GrVkRenderTarget Class Reference

#include <GrVkRenderTarget.h>

Inheritance diagram for GrVkRenderTarget:
GrRenderTarget GrSurface GrGpuResource GrIORef< GrGpuResource > SkNoncopyable GrVkTextureRenderTarget

Public Types

using SelfDependencyFlags = GrVkRenderPass::SelfDependencyFlags
 
using LoadFromResolve = GrVkRenderPass::LoadFromResolve
 
- Public Types inherited from GrSurface
typedef void * ReleaseCtx
 
typedef void(* ReleaseProc) (ReleaseCtx)
 
- Public Types inherited from GrIORef< GrGpuResource >
enum  LastRemovedRef
 

Public Member Functions

 ~GrVkRenderTarget () override
 
GrBackendFormat backendFormat () const override
 
const GrVkFramebuffergetFramebuffer (bool withResolve, bool withStencil, SelfDependencyFlags selfDepFlags, LoadFromResolve)
 
const GrVkFramebuffergetFramebuffer (const GrVkRenderPass &renderPass)
 
GrVkImagecolorAttachment () const
 
const GrVkImageViewcolorAttachmentView () const
 
GrVkImageresolveAttachment () const
 
const GrVkImageViewresolveAttachmentView () const
 
GrVkImagenonMSAAAttachment () const
 
GrVkImageexternalAttachment () const
 
const GrVkRenderPassgetSimpleRenderPass (bool withResolve, bool withStencil, SelfDependencyFlags selfDepFlags, LoadFromResolve)
 
GrVkResourceProvider::CompatibleRPHandle compatibleRenderPassHandle (bool withResolve, bool withStencil, SelfDependencyFlags selfDepFlags, LoadFromResolve)
 
bool wrapsSecondaryCommandBuffer () const
 
sk_sp< GrVkFramebufferexternalFramebuffer () const
 
bool canAttemptStencilAttachment (bool useMSAASurface) const override
 
GrBackendRenderTarget getBackendRenderTarget () const override
 
bool getAttachmentsDescriptor (GrVkRenderPass::AttachmentsDescriptor *desc, GrVkRenderPass::AttachmentFlags *flags, bool withResolve, bool withStencil)
 
- Public Member Functions inherited from GrRenderTarget
virtual bool alwaysClearStencil () const
 
GrRenderTargetasRenderTarget () override
 
const GrRenderTargetasRenderTarget () const override
 
int numSamples () const
 
virtual GrBackendRenderTarget getBackendRenderTarget () const =0
 
GrAttachmentgetStencilAttachment (bool useMSAASurface) const
 
GrAttachmentgetStencilAttachment () const
 
virtual bool canAttemptStencilAttachment (bool useMSAASurface) const =0
 
void attachStencilAttachment (sk_sp< GrAttachment > stencil, bool useMSAASurface)
 
int numStencilBits (bool useMSAASurface) const
 
int getSamplePatternKey ()
 
const skia_private::TArray< SkPoint > & getSampleLocations ()
 
void setRequiresManualMSAAResolve ()
 
bool requiresManualMSAAResolve () const
 
- Public Member Functions inherited from GrSurface
SkISize dimensions () const
 
int width () const
 
int height () const
 
SkRect getBoundsRect () const
 
virtual GrBackendFormat backendFormat () const =0
 
void setRelease (sk_sp< skgpu::RefCntedCallback > releaseHelper)
 
void setRelease (ReleaseProc proc, ReleaseCtx ctx)
 
virtual GrTextureasTexture ()
 
virtual const GrTextureasTexture () const
 
virtual GrRenderTargetasRenderTarget ()
 
virtual const GrRenderTargetasRenderTarget () const
 
GrInternalSurfaceFlags flags () const
 
bool readOnly () const
 
bool framebufferOnly () const
 
bool isProtected () const
 
void setFramebufferOnly ()
 
- Public Member Functions inherited from GrGpuResource
bool wasDestroyed () const
 
const GrDirectContextgetContext () const
 
GrDirectContextgetContext ()
 
size_t gpuMemorySize () const
 
UniqueID uniqueID () const
 
const skgpu::UniqueKeygetUniqueKey () const
 
std::string getLabel () const
 
void setLabel (std::string_view label)
 
CacheAccess cacheAccess ()
 
const CacheAccess cacheAccess () const
 
ProxyAccess proxyAccess ()
 
ResourcePriv resourcePriv ()
 
const ResourcePriv resourcePriv () const
 
virtual void dumpMemoryStatistics (SkTraceMemoryDump *traceMemoryDump) const
 
virtual const char * getResourceType () const =0
 
- Public Member Functions inherited from GrIORef< GrGpuResource >
bool unique () const
 
void ref () const
 
void unref () const
 
void refCommandBuffer () const
 
void unrefCommandBuffer () const
 
- Public Member Functions inherited from SkNoncopyable
 SkNoncopyable ()=default
 
 SkNoncopyable (SkNoncopyable &&)=default
 
SkNoncopyableoperator= (SkNoncopyable &&)=default
 

Static Public Member Functions

static sk_sp< GrVkRenderTargetMakeWrappedRenderTarget (GrVkGpu *, SkISize, int sampleCnt, const GrVkImageInfo &, sk_sp< skgpu::MutableTextureState >)
 
static sk_sp< GrVkRenderTargetMakeSecondaryCBRenderTarget (GrVkGpu *, SkISize, const GrVkDrawableInfo &vkInfo)
 
static void ReconstructAttachmentsDescriptor (const GrVkCaps &vkCaps, const GrProgramInfo &programInfo, GrVkRenderPass::AttachmentsDescriptor *desc, GrVkRenderPass::AttachmentFlags *flags)
 
- Static Public Member Functions inherited from GrSurface
static size_t ComputeSize (const GrBackendFormat &, SkISize dimensions, int colorSamplesPerPixel, skgpu::Mipmapped, bool binSize=false)
 
- Static Public Member Functions inherited from GrGpuResource
static uint32_t CreateUniqueID ()
 

Protected Types

enum class  CreateType { kDirectlyWrapped , kFromTextureRT }
 

Protected Member Functions

 GrVkRenderTarget (GrVkGpu *gpu, SkISize dimensions, sk_sp< GrVkImage > colorAttachment, sk_sp< GrVkImage > resolveImage, CreateType createType, std::string_view label)
 
void onAbandon () override
 
void onRelease () override
 
size_t onGpuMemorySize () const override
 
void onSetLabel () override
 
- Protected Member Functions inherited from GrRenderTarget
 GrRenderTarget (GrGpu *, const SkISize &, int sampleCount, GrProtected, std::string_view label, sk_sp< GrAttachment > stenicl=nullptr)
 
 ~GrRenderTarget () override
 
void onAbandon () override
 
void onRelease () override
 
- Protected Member Functions inherited from GrSurface
void setGLRTFBOIDIs0 ()
 
bool glRTFBOIDis0 () const
 
void setRequiresManualMSAAResolve ()
 
bool requiresManualMSAAResolve () const
 
void setReadOnly ()
 
void setVkRTSupportsInputAttachment ()
 
 GrSurface (GrGpu *gpu, const SkISize &dimensions, skgpu::Protected isProtected, std::string_view label)
 
 ~GrSurface () override
 
void onRelease () override
 
void onAbandon () override
 
- Protected Member Functions inherited from GrGpuResource
void registerWithCache (skgpu::Budgeted)
 
void registerWithCacheWrapped (GrWrapCacheable)
 
 GrGpuResource (GrGpu *, std::string_view label)
 
virtual ~GrGpuResource ()
 
GrGpugetGpu () const
 
virtual void onRelease ()
 
virtual void onAbandon ()
 
virtual void setMemoryBacking (SkTraceMemoryDump *, const SkString &) const
 
SkString getResourceName () const
 
void dumpMemoryStatisticsPriv (SkTraceMemoryDump *traceMemoryDump, const SkString &resourceName, const char *type, size_t size) const
 
- Protected Member Functions inherited from GrIORef< GrGpuResource >
 GrIORef ()
 
bool internalHasRef () const
 
bool internalHasNoCommandBufferUsages () const
 
void addInitialRef () const
 

Detailed Description

Definition at line 26 of file GrVkRenderTarget.h.

Member Typedef Documentation

◆ LoadFromResolve

Definition at line 43 of file GrVkRenderTarget.h.

◆ SelfDependencyFlags

Definition at line 42 of file GrVkRenderTarget.h.

Member Enumeration Documentation

◆ CreateType

enum class GrVkRenderTarget::CreateType
strongprotected
Enumerator
kDirectlyWrapped 
kFromTextureRT 

Definition at line 118 of file GrVkRenderTarget.h.

118 {
119 kDirectlyWrapped, // We need to register this in the ctor
120 kFromTextureRT, // Skip registering this to cache since TexRT will handle it
121 };

Constructor & Destructor Documentation

◆ ~GrVkRenderTarget()

GrVkRenderTarget::~GrVkRenderTarget ( )
override

Definition at line 470 of file GrVkRenderTarget.cpp.

470 {
471 // either release or abandon should have been called by the owner of this object.
472 SkASSERT(!fColorAttachment);
473 SkASSERT(!fResolveAttachment);
474 SkASSERT(!fDynamicMSAAAttachment);
475
476 for (int i = 0; i < kNumCachedFramebuffers; ++i) {
477 SkASSERT(!fCachedFramebuffers[i]);
478 }
479
480 SkASSERT(!fCachedInputDescriptorSet);
481}
#define SkASSERT(cond)
Definition: SkAssert.h:116

◆ GrVkRenderTarget()

GrVkRenderTarget::GrVkRenderTarget ( GrVkGpu gpu,
SkISize  dimensions,
sk_sp< GrVkImage colorAttachment,
sk_sp< GrVkImage resolveImage,
CreateType  createType,
std::string_view  label 
)
protected

Definition at line 54 of file GrVkRenderTarget.cpp.

60 : GrSurface(gpu,
63 label)
64 // for the moment we only support 1:1 color to stencil
65 , GrRenderTarget(gpu,
69 label)
70 , fColorAttachment(std::move(colorAttachment))
71 , fResolveAttachment(std::move(resolveAttachment))
72 , fCachedFramebuffers() {
73 SkASSERT(fColorAttachment);
74
75 if (fColorAttachment->numSamples() == 1 && fColorAttachment->supportsInputAttachmentUsage()) {
76 SkASSERT(!fResolveAttachment);
77 // When we have a single sampled color attachment, we set both the color and resolve
78 // to the same attachment. This way if we use DMAA on this render target we will resolve
79 // to the single target attachment.
80 fResolveAttachment = fColorAttachment;
81 }
82
83 SkASSERT(!fResolveAttachment ||
84 (fResolveAttachment->isProtected() == fColorAttachment->isProtected()));
86 this->setFlags();
87 if (createType == CreateType::kDirectlyWrapped) {
89 }
90}
static constexpr bool SkToBool(const T &x)
Definition: SkTo.h:35
int numSamples() const
Definition: GrAttachment.h:38
void registerWithCacheWrapped(GrWrapCacheable)
GrRenderTarget(GrGpu *, const SkISize &, int sampleCount, GrProtected, std::string_view label, sk_sp< GrAttachment > stenicl=nullptr)
SkISize dimensions() const
Definition: GrSurface.h:27
bool isProtected() const
Definition: GrSurface.h:87
GrSurface(GrGpu *gpu, const SkISize &dimensions, skgpu::Protected isProtected, std::string_view label)
Definition: GrSurface.h:140
bool supportsInputAttachmentUsage() const
Definition: GrVkImage.h:102
VkImageUsageFlags vkUsageFlags()
Definition: GrVkImage.h:101
GrVkImage * colorAttachment() const
GrVkImage * resolveAttachment() const
@ VK_IMAGE_USAGE_COLOR_ATTACHMENT_BIT
Definition: vulkan_core.h:2356

Member Function Documentation

◆ backendFormat()

GrBackendFormat GrVkRenderTarget::backendFormat ( ) const
overridevirtual

Implements GrSurface.

Reimplemented in GrVkTextureRenderTarget.

Definition at line 226 of file GrVkRenderTarget.cpp.

226 {
227 if (this->wrapsSecondaryCommandBuffer()) {
228 return fExternalFramebuffer->colorAttachment()->backendFormat();
229 }
230 return fColorAttachment->backendFormat();
231}
GrVkImage * colorAttachment()
GrBackendFormat backendFormat() const override
Definition: GrVkImage.h:84
bool wrapsSecondaryCommandBuffer() const

◆ canAttemptStencilAttachment()

bool GrVkRenderTarget::canAttemptStencilAttachment ( bool  useMSAASurface) const
overridevirtual

Implements GrRenderTarget.

Definition at line 274 of file GrVkRenderTarget.cpp.

274 {
275 SkASSERT(!useMSAASurface || this->numSamples() > 1 ||
276 this->getVkGpu()->vkCaps().supportsDiscardableMSAAForDMSAA());
277 if (!useMSAASurface && this->numSamples() > 1) {
278 return false;
279 }
280 bool validMSAA = true;
281 if (useMSAASurface) {
282 validMSAA = this->numSamples() > 1 ||
283 (this->getVkGpu()->vkCaps().supportsDiscardableMSAAForDMSAA() &&
285 }
286 // We don't know the status of the stencil attachment for wrapped external secondary command
287 // buffers so we just assume we don't have one.
288 return validMSAA && !this->wrapsSecondaryCommandBuffer();
289}
int numSamples() const
bool supportsDiscardableMSAAForDMSAA() const
Definition: GrVkCaps.h:262
const GrVkCaps & vkCaps() const
Definition: GrVkGpu.h:61

◆ colorAttachment()

GrVkImage * GrVkRenderTarget::colorAttachment ( ) const
inline

Definition at line 56 of file GrVkRenderTarget.h.

56 {
58 return fColorAttachment.get();
59 }
T * get() const
Definition: SkRefCnt.h:303

◆ colorAttachmentView()

const GrVkImageView * GrVkRenderTarget::colorAttachmentView ( ) const
inline

Definition at line 60 of file GrVkRenderTarget.h.

60 {
62 return this->colorAttachment()->framebufferView();
63 }
const GrVkImageView * framebufferView() const
Definition: GrVkImage.h:106

◆ compatibleRenderPassHandle()

GrVkResourceProvider::CompatibleRPHandle GrVkRenderTarget::compatibleRenderPassHandle ( bool  withResolve,
bool  withStencil,
SelfDependencyFlags  selfDepFlags,
LoadFromResolve  loadFromResolve 
)

Definition at line 303 of file GrVkRenderTarget.cpp.

307 {
309
310 const GrVkFramebuffer* fb =
311 this->getFramebuffer(withResolve, withStencil, selfDepFlags, loadFromResolve);
312 if (!fb) {
313 return {};
314 }
315
316 return fb->compatibleRenderPassHandle();
317}
GrVkResourceProvider::CompatibleRPHandle compatibleRenderPassHandle() const
const GrVkFramebuffer * getFramebuffer(bool withResolve, bool withStencil, SelfDependencyFlags selfDepFlags, LoadFromResolve)

◆ externalAttachment()

GrVkImage * GrVkRenderTarget::externalAttachment ( ) const
inline

Definition at line 82 of file GrVkRenderTarget.h.

82 {
83 return fResolveAttachment ? fResolveAttachment.get() : fColorAttachment.get();
84 }

◆ externalFramebuffer()

sk_sp< GrVkFramebuffer > GrVkRenderTarget::externalFramebuffer ( ) const

Definition at line 299 of file GrVkRenderTarget.cpp.

299 {
300 return fExternalFramebuffer;
301}

◆ getAttachmentsDescriptor()

bool GrVkRenderTarget::getAttachmentsDescriptor ( GrVkRenderPass::AttachmentsDescriptor desc,
GrVkRenderPass::AttachmentFlags flags,
bool  withResolve,
bool  withStencil 
)

Definition at line 399 of file GrVkRenderTarget.cpp.

402 {
405 withResolve ? this->msaaAttachment() : this->colorAttachment();
406 if (!colorAttachment) {
407 SkDebugf("WARNING: Invalid color attachment -- possibly dmsaa attachment creation failed?");
408 return false;
409 }
410
411 desc->fColor.fFormat = colorAttachment->imageFormat();
412 desc->fColor.fSamples = colorAttachment->numSamples();
413 *attachmentFlags = GrVkRenderPass::kColor_AttachmentFlag;
414 uint32_t attachmentCount = 1;
415
416 if (withResolve) {
417 desc->fResolve.fFormat = desc->fColor.fFormat;
418 desc->fResolve.fSamples = 1;
419 *attachmentFlags |= GrVkRenderPass::kResolve_AttachmentFlag;
420 ++attachmentCount;
421 }
422
423 if (withStencil) {
424 bool useMSAA = this->numSamples() > 1 || withResolve;
425 const GrAttachment* stencil = this->getStencilAttachment(useMSAA);
426 SkASSERT(stencil);
427 const GrVkImage* vkStencil = static_cast<const GrVkImage*>(stencil);
428 desc->fStencil.fFormat = vkStencil->imageFormat();
429 desc->fStencil.fSamples = vkStencil->numSamples();
430 SkASSERT(desc->fStencil.fSamples == desc->fColor.fSamples);
431 *attachmentFlags |= GrVkRenderPass::kStencil_AttachmentFlag;
432 ++attachmentCount;
433 }
434 desc->fAttachmentCount = attachmentCount;
435
436 return true;
437}
void SK_SPI SkDebugf(const char format[],...) SK_PRINTF_LIKE(1
GrAttachment * getStencilAttachment() const
VkFormat imageFormat() const
Definition: GrVkImage.h:83

◆ getBackendRenderTarget()

GrBackendRenderTarget GrVkRenderTarget::getBackendRenderTarget ( ) const
overridevirtual

Implements GrRenderTarget.

Definition at line 512 of file GrVkRenderTarget.cpp.

512 {
514 // This should only get called with a non-released GrVkRenderTargets.
515 SkASSERT(!this->wasDestroyed());
516 // If we have a resolve attachment that is what we return for the backend render target
517 const GrVkImage* beAttachment = this->externalAttachment();
518 return GrBackendRenderTargets::MakeVk(beAttachment->width(),
519 beAttachment->height(),
520 beAttachment->vkImageInfo(),
521 beAttachment->getMutableState());
522}
bool wasDestroyed() const
int height() const
Definition: GrSurface.h:37
int width() const
Definition: GrSurface.h:32
sk_sp< skgpu::MutableTextureState > getMutableState() const
Definition: GrVkImage.h:131
const GrVkImageInfo & vkImageInfo() const
Definition: GrVkImage.h:82
GrVkImage * externalAttachment() const
SK_API GrBackendRenderTarget MakeVk(int width, int height, const GrVkImageInfo &)

◆ getFramebuffer() [1/2]

const GrVkFramebuffer * GrVkRenderTarget::getFramebuffer ( bool  withResolve,
bool  withStencil,
SelfDependencyFlags  selfDepFlags,
LoadFromResolve  loadFromResolve 
)

Definition at line 353 of file GrVkRenderTarget.cpp.

356 {
357 int cacheIndex =
358 renderpass_features_to_index(withResolve, withStencil, selfDepFlags, loadFromResolve);
359 SkASSERT(cacheIndex < GrVkRenderTarget::kNumCachedFramebuffers);
360 if (auto fb = fCachedFramebuffers[cacheIndex]) {
361 return fb.get();
362 }
363
364 this->createFramebuffer(withResolve, withStencil, selfDepFlags, loadFromResolve);
365 return fCachedFramebuffers[cacheIndex].get();
366}
static int renderpass_features_to_index(bool hasResolve, bool hasStencil, GrVkRenderPass::SelfDependencyFlags selfDepFlags, GrVkRenderPass::LoadFromResolve loadFromReslove)

◆ getFramebuffer() [2/2]

const GrVkFramebuffer * GrVkRenderTarget::getFramebuffer ( const GrVkRenderPass renderPass)
inline

Definition at line 49 of file GrVkRenderTarget.h.

49 {
50 return this->getFramebuffer(renderPass.hasResolveAttachment(),
51 renderPass.hasStencilAttachment(),
52 renderPass.selfDependencyFlags(),
53 renderPass.loadFromResolve());
54 }
LoadFromResolve loadFromResolve() const
SelfDependencyFlags selfDependencyFlags() const
bool hasStencilAttachment() const
bool hasResolveAttachment() const

◆ getSimpleRenderPass()

const GrVkRenderPass * GrVkRenderTarget::getSimpleRenderPass ( bool  withResolve,
bool  withStencil,
SelfDependencyFlags  selfDepFlags,
LoadFromResolve  loadFromResolve 
)

Definition at line 319 of file GrVkRenderTarget.cpp.

322 {
323 if (this->wrapsSecondaryCommandBuffer()) {
324 return fExternalFramebuffer->externalRenderPass();
325 }
326
327 const GrVkFramebuffer* fb =
328 this->getFramebuffer(withResolve, withStencil, selfDepFlags, loadFromResolve);
329 if (!fb) {
330 return nullptr;
331 }
332
333 return fb->compatibleRenderPass();
334}
const GrVkRenderPass * compatibleRenderPass() const
const GrVkRenderPass * externalRenderPass() const

◆ MakeSecondaryCBRenderTarget()

sk_sp< GrVkRenderTarget > GrVkRenderTarget::MakeSecondaryCBRenderTarget ( GrVkGpu gpu,
SkISize  dimensions,
const GrVkDrawableInfo vkInfo 
)
static

Definition at line 174 of file GrVkRenderTarget.cpp.

175 {
178 if (!rp) {
179 return nullptr;
180 }
181
183 return nullptr;
184 }
185
186 // We only set the few properties of the GrVkImageInfo that we know like layout and format. The
187 // others we keep at the default "null" values.
190 info.fFormat = vkInfo.fFormat;
193
194 auto mutableState =
195 sk_make_sp<skgpu::MutableTextureState>(skgpu::MutableTextureStates::MakeVulkan(
197
201 info,
202 std::move(mutableState),
206 "VkImage_ColorAttachment",
207 true);
208
209 std::unique_ptr<GrVkSecondaryCommandBuffer> scb(
211 if (!scb) {
212 return nullptr;
213 }
214
216 gpu, std::move(colorAttachment), sk_sp<const GrVkRenderPass>(rp),
217 std::move(scb)));
218
219 GrVkRenderTarget* vkRT =
220 new GrVkRenderTarget(gpu, dimensions, std::move(framebuffer),
221 /*label=*/"Vk_MakeSecondaryCBRenderTarget");
222
223 return sk_sp<GrVkRenderTarget>(vkRT);
224}
static void info(const char *fmt,...) SK_PRINTF_LIKE(1
Definition: DM.cpp:213
@ kBorrow_GrWrapOwnership
Definition: GrTypesPriv.h:79
GrVkResourceProvider & resourceProvider()
Definition: GrVkGpu.h:83
static sk_sp< GrVkImage > MakeWrapped(GrVkGpu *gpu, SkISize dimensions, const GrVkImageInfo &, sk_sp< skgpu::MutableTextureState >, UsageFlags attachmentUsages, GrWrapOwnership, GrWrapCacheable, std::string_view label, bool forSecondaryCB=false)
Definition: GrVkImage.cpp:179
GrVkRenderTarget(GrVkGpu *gpu, SkISize dimensions, sk_sp< GrVkImage > colorAttachment, sk_sp< GrVkImage > resolveImage, CreateType createType, std::string_view label)
const GrVkRenderPass * findCompatibleExternalRenderPass(VkRenderPass, uint32_t colorAttachmentIndex)
static GrVkSecondaryCommandBuffer * Create(GrVkGpu *gpu, GrVkCommandPool *cmdPool)
SK_API MutableTextureState MakeVulkan(VkImageLayout layout, uint32_t queueFamilyIndex)
VkFormat fFormat
Definition: GrVkTypes.h:88
uint32_t fColorAttachmentIndex
Definition: GrVkTypes.h:86
VkRenderPass fCompatibleRenderPass
Definition: GrVkTypes.h:87
VkCommandBuffer fSecondaryCommandBuffer
Definition: GrVkTypes.h:85
@ VK_IMAGE_LAYOUT_COLOR_ATTACHMENT_OPTIMAL
Definition: vulkan_core.h:1333
@ VK_IMAGE_USAGE_TRANSFER_DST_BIT
Definition: vulkan_core.h:2353
@ VK_IMAGE_USAGE_TRANSFER_SRC_BIT
Definition: vulkan_core.h:2352
#define VK_NULL_HANDLE
Definition: vulkan_core.h:46
#define VK_QUEUE_FAMILY_IGNORED
Definition: vulkan_core.h:127

◆ MakeWrappedRenderTarget()

sk_sp< GrVkRenderTarget > GrVkRenderTarget::MakeWrappedRenderTarget ( GrVkGpu gpu,
SkISize  dimensions,
int  sampleCnt,
const GrVkImageInfo info,
sk_sp< skgpu::MutableTextureState mutableState 
)
static

Definition at line 130 of file GrVkRenderTarget.cpp.

135 {
136 SkASSERT(VK_NULL_HANDLE != info.fImage);
137 SkASSERT(1 == info.fLevelCount);
138 SkASSERT(sampleCnt >= 1 && info.fSampleCount >= 1);
139
140 int wrappedImageSampleCnt = static_cast<int>(info.fSampleCount);
141 if (sampleCnt != wrappedImageSampleCnt && wrappedImageSampleCnt != 1) {
142 return nullptr;
143 }
144
145 sk_sp<GrVkImage> wrappedAttachment =
148 info,
149 std::move(mutableState),
153 /*label=*/"VkImage_WrappedAttachment");
154 if (!wrappedAttachment) {
155 return nullptr;
156 }
157
159 colorAttachment = std::move(wrappedAttachment);
160
161 if (!colorAttachment) {
162 return nullptr;
163 }
164
165 GrVkRenderTarget* vkRT = new GrVkRenderTarget(gpu,
167 std::move(colorAttachment),
168 nullptr,
170 /*label=*/"Vk_MakeWrappedRenderTarget");
171 return sk_sp<GrVkRenderTarget>(vkRT);
172}

◆ nonMSAAAttachment()

GrVkImage * GrVkRenderTarget::nonMSAAAttachment ( ) const

Definition at line 233 of file GrVkRenderTarget.cpp.

233 {
234 if (fColorAttachment->numSamples() == 1) {
235 return fColorAttachment.get();
236 } else {
237 return fResolveAttachment.get();
238 }
239}

◆ onAbandon()

void GrVkRenderTarget::onAbandon ( )
overrideprotectedvirtual

Overridden to abandon any internal handles, ptrs, etc to backend API resources. This may be called when the underlying 3D context is no longer valid and so no backend API calls should be made.

Reimplemented from GrRenderTarget.

Reimplemented in GrVkTextureRenderTarget.

Definition at line 507 of file GrVkRenderTarget.cpp.

507 {
508 this->releaseInternalObjects();
510}
void onAbandon() override

◆ onGpuMemorySize()

size_t GrVkRenderTarget::onGpuMemorySize ( ) const
inlineoverrideprotectedvirtual

Implements GrGpuResource.

Definition at line 134 of file GrVkRenderTarget.h.

134{ return 0; }

◆ onRelease()

void GrVkRenderTarget::onRelease ( )
overrideprotectedvirtual

Overridden to free GPU resources in the backend API.

Reimplemented from GrRenderTarget.

Reimplemented in GrVkTextureRenderTarget.

Definition at line 502 of file GrVkRenderTarget.cpp.

502 {
503 this->releaseInternalObjects();
505}
void onRelease() override

◆ onSetLabel()

void GrVkRenderTarget::onSetLabel ( )
inlineoverrideprotectedvirtual

Implements GrGpuResource.

Definition at line 136 of file GrVkRenderTarget.h.

136{}

◆ ReconstructAttachmentsDescriptor()

void GrVkRenderTarget::ReconstructAttachmentsDescriptor ( const GrVkCaps vkCaps,
const GrProgramInfo programInfo,
GrVkRenderPass::AttachmentsDescriptor desc,
GrVkRenderPass::AttachmentFlags flags 
)
static

Definition at line 439 of file GrVkRenderTarget.cpp.

442 {
445
446 desc->fColor.fFormat = format;
447 desc->fColor.fSamples = programInfo.numSamples();
449 uint32_t attachmentCount = 1;
450
451 if (vkCaps.programInfoWillUseDiscardableMSAA(programInfo)) {
452 desc->fResolve.fFormat = desc->fColor.fFormat;
453 desc->fResolve.fSamples = 1;
455 ++attachmentCount;
456 }
457
458 SkASSERT(!programInfo.isStencilEnabled() || programInfo.needsStencil());
459 if (programInfo.needsStencil()) {
460 VkFormat stencilFormat = vkCaps.preferredStencilFormat();
461 desc->fStencil.fFormat = stencilFormat;
462 desc->fStencil.fSamples = programInfo.numSamples();
463 SkASSERT(desc->fStencil.fSamples == desc->fColor.fSamples);
465 ++attachmentCount;
466 }
467 desc->fAttachmentCount = attachmentCount;
468}
SkAssertResult(font.textToGlyphs("Hello", 5, SkTextEncoding::kUTF8, glyphs, std::size(glyphs))==count)
int numSamples() const
Definition: GrProgramInfo.h:29
bool isStencilEnabled() const
Definition: GrProgramInfo.h:31
int needsStencil() const
Definition: GrProgramInfo.h:30
const GrBackendFormat & backendFormat() const
Definition: GrProgramInfo.h:37
GrInternalSurfaceFlags flags() const
Definition: GrSurface.h:68
bool programInfoWillUseDiscardableMSAA(const GrProgramInfo &) const
Definition: GrVkCaps.cpp:1796
VkFormat preferredStencilFormat() const
Definition: GrVkCaps.h:104
uint32_t uint32_t * format
SK_API bool AsVkFormat(const GrBackendFormat &, VkFormat *)
VkFormat
Definition: vulkan_core.h:1458

◆ resolveAttachment()

GrVkImage * GrVkRenderTarget::resolveAttachment ( ) const
inline

Definition at line 65 of file GrVkRenderTarget.h.

65 {
67 return fResolveAttachment.get();
68 }

◆ resolveAttachmentView()

const GrVkImageView * GrVkRenderTarget::resolveAttachmentView ( ) const
inline

Definition at line 69 of file GrVkRenderTarget.h.

69 {
71 return fResolveAttachment->framebufferView();
72 }

◆ wrapsSecondaryCommandBuffer()

bool GrVkRenderTarget::wrapsSecondaryCommandBuffer ( ) const
inline

Definition at line 97 of file GrVkRenderTarget.h.

97{ return SkToBool(fExternalFramebuffer); }

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