Flutter Engine
The Flutter Engine
Classes | Public Member Functions | Static Public Member Functions | Protected Member Functions | List of all members
GrVkTexture Class Reference

#include <GrVkTexture.h>

Inheritance diagram for GrVkTexture:
GrTexture GrSurface GrGpuResource GrIORef< GrGpuResource > SkNoncopyable GrVkTextureRenderTarget

Classes

struct  DescriptorCacheEntry
 

Public Member Functions

 ~GrVkTexture () override
 
GrBackendTexture getBackendTexture () const override
 
GrBackendFormat backendFormat () const override
 
void textureParamsModified () override
 
GrVkImagetextureImage () const
 
const GrVkImageViewtextureView ()
 
const GrVkDescriptorSetcachedSingleDescSet (GrSamplerState)
 
void addDescriptorSetToCache (const GrVkDescriptorSet *, GrSamplerState)
 
- Public Member Functions inherited from GrTexture
GrTextureasTexture () override
 
const GrTextureasTexture () const override
 
virtual GrBackendTexture getBackendTexture () const =0
 
virtual void textureParamsModified ()=0
 
GrTextureType textureType () const
 
bool hasRestrictedSampling () const
 
void markMipmapsDirty ()
 
void markMipmapsClean ()
 
skgpu::Mipmapped mipmapped () const
 
bool mipmapsAreDirty () const
 
GrMipmapStatus mipmapStatus () const
 
int maxMipmapLevel () 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< GrVkTextureMakeNewTexture (GrVkGpu *, skgpu::Budgeted budgeted, SkISize dimensions, VkFormat format, uint32_t mipLevels, GrProtected, GrMipmapStatus, std::string_view label)
 
static sk_sp< GrVkTextureMakeWrappedTexture (GrVkGpu *, SkISize dimensions, GrWrapOwnership, GrWrapCacheable, GrIOType, const GrVkImageInfo &, sk_sp< skgpu::MutableTextureState >)
 
- Static Public Member Functions inherited from GrTexture
static bool StealBackendTexture (sk_sp< GrTexture >, GrBackendTexture *, SkImages::BackendTextureReleaseProc *)
 
static void ComputeScratchKey (const GrCaps &caps, const GrBackendFormat &format, SkISize dimensions, GrRenderable, int sampleCnt, skgpu::Mipmapped, GrProtected, skgpu::ScratchKey *key)
 
- 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 Member Functions

 GrVkTexture (GrVkGpu *, SkISize dimensions, sk_sp< GrVkImage > texture, GrMipmapStatus, std::string_view label)
 
GrVkGpugetVkGpu () const
 
void onAbandon () override
 
void onRelease () override
 
bool onStealBackendTexture (GrBackendTexture *, SkImages::BackendTextureReleaseProc *) override
 
void onSetRelease (sk_sp< RefCntedReleaseProc > releaseHelper) override
 
- Protected Member Functions inherited from GrTexture
 GrTexture (GrGpu *, const SkISize &, GrProtected, GrTextureType, GrMipmapStatus, std::string_view label)
 
virtual bool onStealBackendTexture (GrBackendTexture *, SkImages::BackendTextureReleaseProc *)=0
 
void computeScratchKey (skgpu::ScratchKey *) const 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
 

Additional Inherited Members

- Public Types inherited from GrSurface
typedef void * ReleaseCtx
 
typedef void(* ReleaseProc) (ReleaseCtx)
 
- Public Types inherited from GrIORef< GrGpuResource >
enum  LastRemovedRef
 

Detailed Description

Definition at line 23 of file GrVkTexture.h.

Constructor & Destructor Documentation

◆ ~GrVkTexture()

GrVkTexture::~GrVkTexture ( )
override

Definition at line 162 of file GrVkTexture.cpp.

162 {
163 // either release or abandon should have been called by the owner of this object.
164 SkASSERT(!fTexture);
165}
#define SkASSERT(cond)
Definition: SkAssert.h:116

◆ GrVkTexture()

GrVkTexture::GrVkTexture ( GrVkGpu gpu,
SkISize  dimensions,
sk_sp< GrVkImage texture,
GrMipmapStatus  mipmapStatus,
std::string_view  label 
)
protected

Definition at line 83 of file GrVkTexture.cpp.

88 : GrSurface(gpu,
91 label)
92 , GrTexture(gpu,
97 label)
98 , fTexture(std::move(texture))
99 , fDescSetCache(kMaxCachedDescSets) {
101 // Since this ctor is only called from GrVkTextureRenderTarget, we can't have a ycbcr conversion
102 // since we don't support that on render targets.
103 SkASSERT(!fTexture->ycbcrConversionInfo().isValid());
105}
static constexpr bool SkToBool(const T &x)
Definition: SkTo.h:35
SkISize dimensions() const
Definition: GrSurface.h:27
GrSurface(GrGpu *gpu, const SkISize &dimensions, skgpu::Protected isProtected, std::string_view label)
Definition: GrSurface.h:140
GrMipmapStatus mipmapStatus() const
Definition: GrTexture.h:66
GrTexture(GrGpu *, const SkISize &, GrProtected, GrTextureType, GrMipmapStatus, std::string_view label)
Definition: GrTexture.cpp:42
uint32_t mipLevels() const
Definition: GrVkImage.h:94
VkImageUsageFlags vkUsageFlags()
Definition: GrVkImage.h:101
const skgpu::VulkanYcbcrConversionInfo & ycbcrConversionInfo() const
Definition: GrVkImage.h:95
FlTexture * texture
@ VK_IMAGE_USAGE_SAMPLED_BIT
Definition: vulkan_core.h:2354

Member Function Documentation

◆ addDescriptorSetToCache()

void GrVkTexture::addDescriptorSetToCache ( const GrVkDescriptorSet descSet,
GrSamplerState  state 
)

Definition at line 217 of file GrVkTexture.cpp.

217 {
218 SkASSERT(!fDescSetCache.find(state));
219 descSet->ref();
220 fDescSetCache.insert(state, std::make_unique<DescriptorCacheEntry>(descSet, this->getVkGpu()));
221}
GrVkGpu * getVkGpu() const
AtkStateType state

◆ backendFormat()

GrBackendFormat GrVkTexture::backendFormat ( ) const
inlineoverridevirtual

Implements GrSurface.

Reimplemented in GrVkTextureRenderTarget.

Definition at line 46 of file GrVkTexture.h.

46{ return fTexture->backendFormat(); }
GrBackendFormat backendFormat() const override
Definition: GrVkImage.h:84

◆ cachedSingleDescSet()

const GrVkDescriptorSet * GrVkTexture::cachedSingleDescSet ( GrSamplerState  state)

Definition at line 210 of file GrVkTexture.cpp.

210 {
211 if (std::unique_ptr<DescriptorCacheEntry>* e = fDescSetCache.find(state)) {
212 return (*e)->fDescriptorSet;
213 }
214 return nullptr;
215}

◆ getBackendTexture()

GrBackendTexture GrVkTexture::getBackendTexture ( ) const
overridevirtual

Implements GrTexture.

Definition at line 196 of file GrVkTexture.cpp.

196 {
197 return GrBackendTextures::MakeVk(fTexture->width(),
198 fTexture->height(),
199 fTexture->vkImageInfo(),
200 fTexture->getMutableState());
201}
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
SK_API GrBackendTexture MakeVk(int width, int height, const GrVkImageInfo &, std::string_view label={})

◆ getVkGpu()

GrVkGpu * GrVkTexture::getVkGpu ( ) const
protected

Definition at line 203 of file GrVkTexture.cpp.

203 {
204 SkASSERT(!this->wasDestroyed());
205 return static_cast<GrVkGpu*>(this->getGpu());
206}
GrGpu * getGpu() const
bool wasDestroyed() const

◆ MakeNewTexture()

sk_sp< GrVkTexture > GrVkTexture::MakeNewTexture ( GrVkGpu gpu,
skgpu::Budgeted  budgeted,
SkISize  dimensions,
VkFormat  format,
uint32_t  mipLevels,
GrProtected  isProtected,
GrMipmapStatus  mipmapStatus,
std::string_view  label 
)
static

Definition at line 107 of file GrVkTexture.cpp.

114 {
116 gpu, dimensions, format, mipLevels, GrRenderable::kNo, /*numSamples=*/1, budgeted,
118
119 if (!texture) {
120 return nullptr;
121 }
123 gpu, budgeted, dimensions, std::move(texture), mipmapStatus, label));
124}
bool isProtected() const
Definition: GrSurface.h:87
static sk_sp< GrVkImage > MakeTexture(GrVkGpu *gpu, SkISize dimensions, VkFormat format, uint32_t mipLevels, GrRenderable renderable, int numSamples, skgpu::Budgeted budgeted, GrProtected isProtected)
Definition: GrVkImage.cpp:65
GrVkTexture(GrVkGpu *, SkISize dimensions, sk_sp< GrVkImage > texture, GrMipmapStatus, std::string_view label)
Definition: GrVkTexture.cpp:83
uint32_t uint32_t * format

◆ MakeWrappedTexture()

sk_sp< GrVkTexture > GrVkTexture::MakeWrappedTexture ( GrVkGpu gpu,
SkISize  dimensions,
GrWrapOwnership  wrapOwnership,
GrWrapCacheable  cacheable,
GrIOType  ioType,
const GrVkImageInfo info,
sk_sp< skgpu::MutableTextureState mutableState 
)
static

Definition at line 126 of file GrVkTexture.cpp.

129 {
130 // Adopted textures require both image and allocation because we're responsible for freeing
131 SkASSERT(VK_NULL_HANDLE != info.fImage &&
132 (kBorrow_GrWrapOwnership == wrapOwnership || VK_NULL_HANDLE != info.fAlloc.fMemory));
133
136 info,
137 std::move(mutableState),
139 wrapOwnership,
140 cacheable,
141 "VkImage_MakeWrappedTexture");
142 if (!texture) {
143 return nullptr;
144 }
145
148
149 bool isExternal = info.fYcbcrConversionInfo.isValid() &&
150 (info.fYcbcrConversionInfo.fExternalFormat != 0);
151 isExternal |= (info.fImageTiling == VK_IMAGE_TILING_DRM_FORMAT_MODIFIER_EXT);
152 return sk_sp<GrVkTexture>(new GrVkTexture(gpu,
154 std::move(texture),
156 cacheable,
157 ioType,
158 isExternal,
159 /*label=*/"Vk_MakeWrappedTexture"));
160}
static void info(const char *fmt,...) SK_PRINTF_LIKE(1
Definition: DM.cpp:213
GrMipmapStatus
Definition: GrTypesPriv.h:523
@ kBorrow_GrWrapOwnership
Definition: GrTypesPriv.h:79
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
@ VK_IMAGE_TILING_DRM_FORMAT_MODIFIER_EXT
Definition: vulkan_core.h:1769
#define VK_NULL_HANDLE
Definition: vulkan_core.h:46

◆ onAbandon()

void GrVkTexture::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 GrSurface.

Reimplemented in GrVkTextureRenderTarget.

Definition at line 188 of file GrVkTexture.cpp.

188 {
189 fTexture.reset();
190
191 fDescSetCache.reset();
192
194}
void onAbandon() override
Definition: GrSurface.cpp:86
void reset(T *ptr=nullptr)
Definition: SkRefCnt.h:310

◆ onRelease()

void GrVkTexture::onRelease ( )
overrideprotectedvirtual

Overridden to free GPU resources in the backend API.

Reimplemented from GrSurface.

Reimplemented in GrVkTextureRenderTarget.

Definition at line 167 of file GrVkTexture.cpp.

167 {
168 fTexture.reset();
169
170 fDescSetCache.reset();
171
173}
void onRelease() override
Definition: GrSurface.cpp:81

◆ onSetRelease()

void GrVkTexture::onSetRelease ( sk_sp< RefCntedReleaseProc releaseHelper)
inlineoverrideprotectedvirtual

Reimplemented from GrSurface.

Definition at line 80 of file GrVkTexture.h.

80 {
81 // Forward the release proc onto the fTexture's GrVkImage
82 fTexture->setResourceRelease(std::move(releaseHelper));
83 }
void setResourceRelease(sk_sp< RefCntedReleaseProc > releaseHelper)
Definition: GrVkImage.cpp:628

◆ onStealBackendTexture()

bool GrVkTexture::onStealBackendTexture ( GrBackendTexture ,
SkImages::BackendTextureReleaseProc  
)
inlineoverrideprotectedvirtual

Implements GrTexture.

Definition at line 74 of file GrVkTexture.h.

74 {
75 return false;
76 }

◆ textureImage()

GrVkImage * GrVkTexture::textureImage ( ) const
inline

Definition at line 50 of file GrVkTexture.h.

50{ return fTexture.get(); }
T * get() const
Definition: SkRefCnt.h:303

◆ textureParamsModified()

void GrVkTexture::textureParamsModified ( )
inlineoverridevirtual

This function indicates that the texture parameters (wrap mode, filtering, ...) have been changed externally to Skia.

Implements GrTexture.

Definition at line 48 of file GrVkTexture.h.

48{}

◆ textureView()

const GrVkImageView * GrVkTexture::textureView ( )

Definition at line 208 of file GrVkTexture.cpp.

208{ return fTexture->textureView(); }
const GrVkImageView * textureView() const
Definition: GrVkImage.h:107

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