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

#include <GrAttachment.h>

Inheritance diagram for GrAttachment:
GrSurface GrGpuResource GrIORef< GrGpuResource > SkNoncopyable GrD3DAttachment GrGLAttachment GrMockAttachment GrMtlAttachment GrVkImage

Public Types

enum class  UsageFlags : uint8_t { kStencilAttachment = 0x1 , kColorAttachment = 0x2 , kTexture = 0x4 }
 
- Public Types inherited from GrSurface
typedef void * ReleaseCtx
 
typedef void(* ReleaseProc) (ReleaseCtx)
 
- Public Types inherited from GrIORef< GrGpuResource >
enum  LastRemovedRef
 

Public Member Functions

 GR_DECL_BITFIELD_CLASS_OPS_FRIENDS (UsageFlags)
 
 ~GrAttachment () override
 
UsageFlags supportedUsages () const
 
int numSamples () const
 
skgpu::Mipmapped mipmapped () const
 
bool hasPerformedInitialClear () const
 
void markHasPerformedInitialClear ()
 
- 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
 
- 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 void ComputeSharedAttachmentUniqueKey (const GrCaps &caps, const GrBackendFormat &format, SkISize dimensions, UsageFlags requiredUsage, int sampleCnt, skgpu::Mipmapped mipmapped, GrProtected isProtected, GrMemoryless memoryless, skgpu::UniqueKey *key)
 
static void ComputeScratchKey (const GrCaps &caps, const GrBackendFormat &format, SkISize dimensions, UsageFlags requiredUsage, int sampleCnt, skgpu::Mipmapped mipmapped, GrProtected, GrMemoryless, 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

 GrAttachment (GrGpu *gpu, SkISize dimensions, UsageFlags supportedUsages, int sampleCnt, skgpu::Mipmapped mipmapped, GrProtected isProtected, std::string_view label, GrMemoryless memoryless=GrMemoryless::kNo)
 
- 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
 

Private Member Functions

size_t onGpuMemorySize () const final
 
void onSetLabel () override
 
void computeScratchKey (skgpu::ScratchKey *) const final
 
const char * getResourceType () const override
 

Detailed Description

This is a generic attachment class for out GrSurfaces. It always represents a single gpu allocation. It contains usage flags so that we know what the attachment can be used for.

TODO: Once we can pull out GrRenderTarget to be more of a framebuffer and break apart our texture render target diamond, we will merge this class with GrSurface. Until then this will act as the staging class for the new surface and framebuffer world.

Definition at line 25 of file GrAttachment.h.

Member Enumeration Documentation

◆ UsageFlags

enum class GrAttachment::UsageFlags : uint8_t
strong
Enumerator
kStencilAttachment 
kColorAttachment 
kTexture 

Definition at line 27 of file GrAttachment.h.

Constructor & Destructor Documentation

◆ ~GrAttachment()

GrAttachment::~GrAttachment ( )
inlineoverride

Definition at line 34 of file GrAttachment.h.

34{}

◆ GrAttachment()

GrAttachment::GrAttachment ( GrGpu gpu,
SkISize  dimensions,
UsageFlags  supportedUsages,
int  sampleCnt,
skgpu::Mipmapped  mipmapped,
GrProtected  isProtected,
std::string_view  label,
GrMemoryless  memoryless = GrMemoryless::kNo 
)
inlineprotected

Definition at line 73 of file GrAttachment.h.

81 : INHERITED(gpu, dimensions, isProtected, label)
82 , fSupportedUsages(supportedUsages)
83 , fSampleCnt(sampleCnt)
84 , fMipmapped(mipmapped)
85 , fMemoryless(memoryless) {}
skgpu::Mipmapped mipmapped() const
UsageFlags supportedUsages() const
SkISize dimensions() const
Definition GrSurface.h:27
bool isProtected() const
Definition GrSurface.h:87

Member Function Documentation

◆ ComputeScratchKey()

void GrAttachment::ComputeScratchKey ( const GrCaps caps,
const GrBackendFormat format,
SkISize  dimensions,
UsageFlags  requiredUsage,
int  sampleCnt,
skgpu::Mipmapped  mipmapped,
GrProtected  isProtected,
GrMemoryless  memoryless,
skgpu::ScratchKey key 
)
static

Definition at line 81 of file GrAttachment.cpp.

89 {
91
93 build_key(&builder, caps, format, dimensions, requiredUsage, sampleCnt, mipmapped, isProtected,
94 memoryless);
95}
static void build_key(skgpu::ResourceKey::Builder *builder, const GrCaps &caps, const GrBackendFormat &format, SkISize dimensions, GrAttachment::UsageFlags requiredUsage, int sampleCnt, skgpu::Mipmapped mipmapped, GrProtected isProtected, GrMemoryless memoryless)
static ResourceType GenerateResourceType()
uint32_t ResourceType
uint32_t uint32_t * format

◆ computeScratchKey()

void GrAttachment::computeScratchKey ( skgpu::ScratchKey ) const
finalprivatevirtual

Called by the registerWithCache if the resource is available to be used as scratch. Resource subclasses should override this if the instances should be recycled as scratch resources and populate the scratchKey with the key. By default resources are not recycled as scratch.

Reimplemented from GrGpuResource.

Definition at line 97 of file GrAttachment.cpp.

97 {
98 // We do don't cache GrAttachments as scratch resources when used for stencils or textures. For
99 // stencils we share/cache them with unique keys so that they can be shared. Textures are in a
100 // weird place on the Vulkan backend. Currently, GrVkTexture contains a GrAttachment (GrVkImage)
101 // that actually holds the VkImage. The GrVkTexture is cached as a scratch resource and is
102 // responsible for tracking the gpuMemorySize. Thus we set the size of the texture GrVkImage,
103 // above in onGpuMemorySize, to be zero. Therefore, we can't have the GrVkImage getting cached
104 // separately on its own in the GrResourceCache or we may grow forever adding them thinking they
105 // contatin a memory that's size 0 and never freeing the actual VkImages.
106 if (!SkToBool(fSupportedUsages & UsageFlags::kStencilAttachment) &&
107 !SkToBool(fSupportedUsages & UsageFlags::kTexture)) {
108 auto isProtected = this->isProtected() ? GrProtected::kYes : GrProtected::kNo;
109 ComputeScratchKey(*this->getGpu()->caps(),
110 this->backendFormat(),
111 this->dimensions(),
112 fSupportedUsages,
113 this->numSamples(),
114 this->mipmapped(),
116 fMemoryless,
117 key);
118 }
119}
static constexpr bool SkToBool(const T &x)
Definition SkTo.h:35
int numSamples() const
static void ComputeScratchKey(const GrCaps &caps, const GrBackendFormat &format, SkISize dimensions, UsageFlags requiredUsage, int sampleCnt, skgpu::Mipmapped mipmapped, GrProtected, GrMemoryless, skgpu::ScratchKey *key)
GrGpu * getGpu() const
virtual GrBackendFormat backendFormat() const =0

◆ ComputeSharedAttachmentUniqueKey()

void GrAttachment::ComputeSharedAttachmentUniqueKey ( const GrCaps caps,
const GrBackendFormat format,
SkISize  dimensions,
UsageFlags  requiredUsage,
int  sampleCnt,
skgpu::Mipmapped  mipmapped,
GrProtected  isProtected,
GrMemoryless  memoryless,
skgpu::UniqueKey key 
)
static

Definition at line 65 of file GrAttachment.cpp.

73 {
75
77 build_key(&builder, caps, format, dimensions, requiredUsage, sampleCnt, mipmapped, isProtected,
78 memoryless);
79}
static Domain GenerateDomain()

◆ getResourceType()

const char * GrAttachment::getResourceType ( ) const
inlineoverrideprivatevirtual

Describes the type of gpu resource that is represented by the implementing class (e.g. texture, buffer object, stencil). This data is used for diagnostic purposes by dumpMemoryStatistics().

The value returned is expected to be long lived and will not be copied by the caller.

Implements GrGpuResource.

Definition at line 94 of file GrAttachment.h.

94 {
95 if (fSupportedUsages == UsageFlags::kStencilAttachment) {
96 return "StencilAttachment";
97 }
98
99 // This is a general grouping of all textures and color attachments.
100 return "Surface";
101 }

◆ GR_DECL_BITFIELD_CLASS_OPS_FRIENDS()

GrAttachment::GR_DECL_BITFIELD_CLASS_OPS_FRIENDS ( UsageFlags  )

◆ hasPerformedInitialClear()

bool GrAttachment::hasPerformedInitialClear ( ) const
inline

Definition at line 42 of file GrAttachment.h.

42{ return fHasPerformedInitialClear; }

◆ markHasPerformedInitialClear()

void GrAttachment::markHasPerformedInitialClear ( )
inline

Definition at line 43 of file GrAttachment.h.

43{ fHasPerformedInitialClear = true; }

◆ mipmapped()

skgpu::Mipmapped GrAttachment::mipmapped ( ) const
inline

Definition at line 40 of file GrAttachment.h.

40{ return fMipmapped; }

◆ numSamples()

int GrAttachment::numSamples ( ) const
inline

Definition at line 38 of file GrAttachment.h.

38{ return fSampleCnt; }

◆ onGpuMemorySize()

size_t GrAttachment::onGpuMemorySize ( ) const
finalprivatevirtual

Implements GrGpuResource.

Definition at line 17 of file GrAttachment.cpp.

17 {
18 // The GrTexture[RenderTarget] is built up by a bunch of attachments each of which are their
19 // own GrGpuResource. Ideally the GrRenderTarget would not be a GrGpuResource and the GrTexture
20 // would just merge with the new GrSurface/Attachment world. Then we could just depend on each
21 // attachment to give its own size since we don't have GrGpuResources owning other
22 // GrGpuResources. Until we get to that point we need to live in some hybrid world. We will let
23 // the msaa and stencil attachments track their own size because they do get cached separately.
24 // For all GrTexture* based things we will continue to to use the GrTexture* to report size and
25 // the owned attachments will have no size and be uncached.
26 if (!(fSupportedUsages & UsageFlags::kTexture) && fMemoryless == GrMemoryless::kNo) {
29
30 uint64_t size = skgpu::NumCompressedBlocks(compression, this->dimensions());
32 size *= this->numSamples();
33 return size;
34 }
35 return 0;
36}
SkTextureCompressionType GrBackendFormatToCompressionType(const GrBackendFormat &format)
size_t GrBackendFormatBytesPerBlock(const GrBackendFormat &format)
it will be possible to load the file into Perfetto s trace viewer disable asset Prevents usage of any non test fonts unless they were explicitly Loaded via prefetched default font Indicates whether the embedding started a prefetch of the default font manager before creating the engine run In non interactive keep the shell running after the Dart script has completed enable serial On low power devices with low core running concurrent GC tasks on threads can cause them to contend with the UI thread which could potentially lead to jank This option turns off all concurrent GC activities domain network JSON encoded network policy per domain This overrides the DisallowInsecureConnections switch Embedder can specify whether to allow or disallow insecure connections at a domain level old gen heap size
Definition switches.h:259
size_t NumCompressedBlocks(SkTextureCompressionType type, SkISize baseDimensions)

◆ onSetLabel()

void GrAttachment::onSetLabel ( )
inlineoverrideprivatevirtual

Implements GrGpuResource.

Reimplemented in GrD3DAttachment, GrGLAttachment, and GrMtlAttachment.

Definition at line 90 of file GrAttachment.h.

90{}

◆ supportedUsages()

UsageFlags GrAttachment::supportedUsages ( ) const
inline

Definition at line 36 of file GrAttachment.h.

36{ return fSupportedUsages; }

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