Flutter Engine
The Flutter Engine
Loading...
Searching...
No Matches
Public Member Functions | Static Public Member Functions | Protected Member Functions | Private Member Functions | List of all members
GrMtlTextureRenderTarget Class Reference

#include <GrMtlTextureRenderTarget.h>

Inheritance diagram for GrMtlTextureRenderTarget:
GrMtlTexture GrMtlRenderTarget GrTexture GrRenderTarget GrSurface GrSurface GrGpuResource GrGpuResource GrIORef< GrGpuResource > GrIORef< GrGpuResource > SkNoncopyable SkNoncopyable

Public Member Functions

GrBackendFormat backendFormat () const override
 
- Public Member Functions inherited from GrMtlTexture
 ~GrMtlTexture () override
 
GrMtlAttachmentattachment () const
 
id< MTLTexture > mtlTexture () const
 
GrBackendTexture getBackendTexture () const override
 
void textureParamsModified () override
 
bool reallocForMipmap (GrMtlGpu *gpu, uint32_t mipLevels)
 
- Public Member Functions inherited from GrTexture
GrTextureasTexture () override
 
const GrTextureasTexture () const override
 
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
 
void setRelease (sk_sp< skgpu::RefCntedCallback > releaseHelper)
 
void setRelease (ReleaseProc proc, ReleaseCtx ctx)
 
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
 
- 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
 
- Public Member Functions inherited from GrMtlRenderTarget
 ~GrMtlRenderTarget () override
 
bool canAttemptStencilAttachment (bool useMSAASurface) const override
 
GrMtlAttachmentcolorAttachment () const
 
id< MTLTexture > colorMTLTexture () const
 
GrMtlAttachmentresolveAttachment () const
 
id< MTLTexture > resolveMTLTexture () const
 
GrMtlAttachmentnonMSAAAttachment () const
 
GrBackendRenderTarget getBackendRenderTarget () const override
 
const GrMtlFramebuffergetFramebuffer (bool withResolve, bool withStencil)
 
- Public Member Functions inherited from GrRenderTarget
virtual bool alwaysClearStencil () const
 
GrRenderTargetasRenderTarget () override
 
const GrRenderTargetasRenderTarget () const override
 
int numSamples () const
 
GrAttachmentgetStencilAttachment (bool useMSAASurface) const
 
GrAttachmentgetStencilAttachment () const
 
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
 

Static Public Member Functions

static sk_sp< GrMtlTextureRenderTargetMakeNewTextureRenderTarget (GrMtlGpu *, skgpu::Budgeted, SkISize, int sampleCnt, MTLPixelFormat, uint32_t mipLevels, GrMipmapStatus, std::string_view label)
 
static sk_sp< GrMtlTextureRenderTargetMakeWrappedTextureRenderTarget (GrMtlGpu *, SkISize, int sampleCnt, id< MTLTexture >, GrWrapCacheable)
 
- Static Public Member Functions inherited from GrMtlTexture
static sk_sp< GrMtlTextureMakeNewTexture (GrMtlGpu *, skgpu::Budgeted budgeted, SkISize dimensions, MTLPixelFormat format, uint32_t mipLevels, GrMipmapStatus, std::string_view label)
 
static sk_sp< GrMtlTextureMakeWrappedTexture (GrMtlGpu *, SkISize, id< MTLTexture >, GrWrapCacheable, GrIOType)
 
- 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 ()
 
- Static Public Member Functions inherited from GrMtlRenderTarget
static sk_sp< GrMtlRenderTargetMakeWrappedRenderTarget (GrMtlGpu *, SkISize, int sampleCnt, id< MTLTexture >)
 

Protected Member Functions

void onAbandon () override
 
void onRelease () override
 
- Protected Member Functions inherited from GrMtlTexture
 GrMtlTexture (GrMtlGpu *, SkISize, sk_sp< GrMtlAttachment >, GrMipmapStatus, std::string_view label)
 
GrMtlGpugetMtlGpu () const
 
bool onStealBackendTexture (GrBackendTexture *, SkImages::BackendTextureReleaseProc *) override
 
- Protected Member Functions inherited from GrTexture
 GrTexture (GrGpu *, const SkISize &, GrProtected, GrTextureType, GrMipmapStatus, std::string_view label)
 
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 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
 
- Protected Member Functions inherited from GrMtlRenderTarget
 GrMtlRenderTarget (GrMtlGpu *gpu, SkISize, sk_sp< GrMtlAttachment > colorAttachment, sk_sp< GrMtlAttachment > resolveAttachment, std::string_view label)
 
GrMtlGpugetMtlGpu () const
 
- 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
 

Private Member Functions

size_t onGpuMemorySize () const override
 
void onSetLabel () override
 

Additional Inherited Members

- Public Types inherited from GrSurface
typedef void * ReleaseCtx
 
typedef void(* ReleaseProc) (ReleaseCtx)
 
- Public Types inherited from GrIORef< GrGpuResource >
enum  LastRemovedRef
 
- Protected Attributes inherited from GrMtlRenderTarget
sk_sp< GrMtlAttachmentfColorAttachment
 
sk_sp< GrMtlAttachmentfResolveAttachment
 

Detailed Description

Definition at line 14 of file GrMtlTextureRenderTarget.h.

Member Function Documentation

◆ backendFormat()

GrBackendFormat GrMtlTextureRenderTarget::backendFormat ( ) const
inlineoverridevirtual

Reimplemented from GrMtlTexture.

Definition at line 30 of file GrMtlTextureRenderTarget.h.

30 {
32 }
GrBackendFormat backendFormat() const override

◆ MakeNewTextureRenderTarget()

sk_sp< GrMtlTextureRenderTarget > GrMtlTextureRenderTarget::MakeNewTextureRenderTarget ( GrMtlGpu gpu,
skgpu::Budgeted  budgeted,
SkISize  dimensions,
int  sampleCnt,
MTLPixelFormat  format,
uint32_t  mipLevels,
GrMipmapStatus  mipmapStatus,
std::string_view  label 
)
static

Definition at line 74 of file GrMtlTextureRenderTarget.mm.

82 {
83 sk_sp<GrMtlAttachment> textureAttachment =
84 GrMtlAttachment::MakeTexture(gpu, dimensions, format, mipLevels, GrRenderable::kYes,
85 /*numSamples=*/1, budgeted);
86 if (!textureAttachment) {
87 return nullptr;
88 }
89 if (@available(macOS 10.11, iOS 9.0, tvOS 9.0, *)) {
90 SkASSERT((MTLTextureUsageShaderRead | MTLTextureUsageRenderTarget) &
91 textureAttachment->mtlTexture().usage);
92 }
93
96 if (!create_rt_attachments(gpu, dimensions, format, sampleCnt, textureAttachment,
98 return nullptr;
99 }
101 SkASSERT(sampleCnt == 1 || resolveAttachment);
102
104 gpu, budgeted, dimensions, std::move(textureAttachment), std::move(colorAttachment),
105 std::move(resolveAttachment), mipmapStatus, label));
106}
bool create_rt_attachments(GrMtlGpu *gpu, SkISize dimensions, MTLPixelFormat format, int sampleCnt, sk_sp< GrMtlAttachment > texture, sk_sp< GrMtlAttachment > *colorAttachment, sk_sp< GrMtlAttachment > *resolveAttachment)
#define SkASSERT(cond)
Definition SkAssert.h:116
static sk_sp< GrMtlAttachment > MakeTexture(GrMtlGpu *gpu, SkISize dimensions, MTLPixelFormat format, uint32_t mipLevels, GrRenderable renderable, int numSamples, skgpu::Budgeted budgeted)
GrMtlAttachment * colorAttachment() const
GrMtlAttachment * resolveAttachment() const
SkISize dimensions() const
Definition GrSurface.h:27
GrMipmapStatus mipmapStatus() const
Definition GrTexture.h:66
uint32_t uint32_t * format

◆ MakeWrappedTextureRenderTarget()

sk_sp< GrMtlTextureRenderTarget > GrMtlTextureRenderTarget::MakeWrappedTextureRenderTarget ( GrMtlGpu gpu,
SkISize  dimensions,
int  sampleCnt,
id< MTLTexture >  texture,
GrWrapCacheable  cacheable 
)
static

Definition at line 108 of file GrMtlTextureRenderTarget.mm.

113 {
114 SkASSERT(nil != texture);
115 if (@available(macOS 10.11, iOS 9.0, tvOS 9.0, *)) {
116 SkASSERT((MTLTextureUsageShaderRead | MTLTextureUsageRenderTarget) & texture.usage);
117 }
118 GrMipmapStatus mipmapStatus = texture.mipmapLevelCount > 1
123 sk_sp<GrMtlAttachment> textureAttachment =
124 GrMtlAttachment::MakeWrapped(gpu, dimensions, texture, textureUsageFlags, cacheable,
125 /*label=*/"MtlAttachment_TextureAttachment");
126 if (!textureAttachment) {
127 return nullptr;
128 }
129
132 if (!create_rt_attachments(gpu, dimensions, texture.pixelFormat, sampleCnt, textureAttachment,
134 return nullptr;
135 }
137 SkASSERT(sampleCnt == 1 || resolveAttachment);
138
140 gpu, dimensions, std::move(textureAttachment), std::move(colorAttachment),
141 std::move(resolveAttachment), mipmapStatus, cacheable,
142 /*label=*/"MtlWrappedTextureRenderTarget"));
143}
GrMipmapStatus
static sk_sp< GrMtlAttachment > MakeWrapped(GrMtlGpu *gpu, SkISize dimensions, id< MTLTexture >, UsageFlags attachmentUsages, GrWrapCacheable, std::string_view label)
FlTexture * texture

◆ onAbandon()

void GrMtlTextureRenderTarget::onAbandon ( )
inlineoverrideprotectedvirtual

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 GrMtlTexture.

Definition at line 35 of file GrMtlTextureRenderTarget.h.

35 {
38 }
void onAbandon() override
void onAbandon() override

◆ onGpuMemorySize()

size_t GrMtlTextureRenderTarget::onGpuMemorySize ( ) const
overrideprivatevirtual

Implements GrGpuResource.

Definition at line 145 of file GrMtlTextureRenderTarget.mm.

145 {
146 // The GrTexture[RenderTarget] is built up by a bunch of attachments each of which are their
147 // own GrGpuResource. Ideally the GrRenderTarget would not be a GrGpuResource and the GrTexture
148 // would just merge with the new GrSurface/Attachment world. Then we could just depend on each
149 // attachment to give its own size since we don't have GrGpuResources owning other
150 // GrGpuResources. Until we get to that point we need to live in some hybrid world. We will let
151 // the msaa and stencil attachments track their own size because they do get cached separately.
152 // For all GrTexture* based things we will continue to to use the GrTexture* to report size and
153 // the owned attachments will have no size and be uncached.
154#ifdef SK_DEBUG
155 // The nonMSAA attachment (either color or resolve depending on numSamples should have size of
156 // zero since it is a texture attachment.
158 if (this->numSamples() > 1) {
159 // Msaa attachment should have a valid size
162 this->dimensions(),
163 this->numSamples(),
164 skgpu::Mipmapped::kNo));
165 }
166#endif
167 return GrSurface::ComputeSize(this->backendFormat(), this->dimensions(),
168 1 /*colorSamplesPerPixel*/, this->mipmapped());
169}
size_t gpuMemorySize() const
GrMtlAttachment * nonMSAAAttachment() const
GrBackendFormat backendFormat() const override
int numSamples() const
static size_t ComputeSize(const GrBackendFormat &, SkISize dimensions, int colorSamplesPerPixel, skgpu::Mipmapped, bool binSize=false)
Definition GrSurface.cpp:21
skgpu::Mipmapped mipmapped() const
Definition GrTexture.h:62

◆ onRelease()

void GrMtlTextureRenderTarget::onRelease ( )
inlineoverrideprotectedvirtual

Overridden to free GPU resources in the backend API.

Reimplemented from GrMtlTexture.

Definition at line 40 of file GrMtlTextureRenderTarget.h.

40 {
43 }
void onRelease() override
void onRelease() override

◆ onSetLabel()

void GrMtlTextureRenderTarget::onSetLabel ( )
overrideprivatevirtual

Reimplemented from GrMtlTexture.

Definition at line 171 of file GrMtlTextureRenderTarget.mm.

171 {
174}
void onSetLabel() override
void onSetLabel() override

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