#include <GrGpuResource.h>
Base class for objects that can be kept in the GrResourceCache.
Definition at line 126 of file GrGpuResource.h.
◆ GrGpuResource()
GrGpuResource::GrGpuResource |
( |
GrGpu * |
gpu, |
|
|
std::string_view |
label |
|
) |
| |
|
protected |
Definition at line 27 of file GrGpuResource.cpp.
30}
SkDEBUGCODE(SK_SPI) SkThreadID SkGetThreadID()
static uint32_t CreateUniqueID()
◆ ~GrGpuResource()
GrGpuResource::~GrGpuResource |
( |
| ) |
|
|
protectedvirtual |
◆ cacheAccess() [1/2]
◆ cacheAccess() [2/2]
◆ computeScratchKey()
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 in GrTexture.
Definition at line 294 of file GrGpuResource.h.
◆ CreateUniqueID()
uint32_t GrGpuResource::CreateUniqueID |
( |
| ) |
|
|
static |
Definition at line 210 of file GrGpuResource.cpp.
210 {
211 static std::atomic<uint32_t> nextID{1};
213 do {
214 id = nextID.fetch_add(1, std::memory_order_relaxed);
217}
static constexpr uint32_t SK_InvalidUniqueID
◆ dumpMemoryStatistics()
void GrGpuResource::dumpMemoryStatistics |
( |
SkTraceMemoryDump * |
traceMemoryDump | ) |
const |
|
virtual |
Dumps memory usage information for this GrGpuResource to traceMemoryDump. Typically, subclasses should not need to override this, and should only need to override setMemoryBacking.
Reimplemented in GrGLRenderTarget, GrGLTexture, and GrGLTextureRenderTarget.
Definition at line 73 of file GrGpuResource.cpp.
73 {
75 return;
76 }
77
80}
size_t gpuMemorySize() const
void dumpMemoryStatisticsPriv(SkTraceMemoryDump *traceMemoryDump, const SkString &resourceName, const char *type, size_t size) const
SkString getResourceName() const
virtual const char * getResourceType() const =0
virtual bool shouldDumpWrappedObjects() const
◆ dumpMemoryStatisticsPriv()
void GrGpuResource::dumpMemoryStatisticsPriv |
( |
SkTraceMemoryDump * |
traceMemoryDump, |
|
|
const SkString & |
resourceName, |
|
|
const char * |
type, |
|
|
size_t |
size |
|
) |
| const |
|
protected |
A helper for subclasses that override dumpMemoryStatistics(). This method using a format consistent with the default implementation of dumpMemoryStatistics() but allows the caller to customize various inputs.
Definition at line 82 of file GrGpuResource.cpp.
84 {
85 const char* tag = "Scratch";
87 tag = (fUniqueKey.
tag() !=
nullptr) ? fUniqueKey.
tag() :
"Other";
88 }
89
94 if (this->isPurgeable()) {
96 }
99 }
100
102}
std::string getLabel() const
virtual void setMemoryBacking(SkTraceMemoryDump *, const SkString &) const
const char * c_str() const
virtual void dumpWrappedState(const char *, bool)
virtual void dumpStringValue(const char *, const char *, const char *)
virtual void dumpNumericValue(const char *dumpName, const char *valueName, const char *units, uint64_t value)=0
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
◆ getContext() [1/2]
Definition at line 133 of file GrGpuResource.cpp.
133 {
134 if (fGpu) {
136 } else {
137 return nullptr;
138 }
139}
GrDirectContext * getContext()
◆ getContext() [2/2]
Retrieves the context that owns the object. Note that it is possible for this to return NULL. When objects have been release()ed or abandon()ed they no longer have an owning context. Destroying a GrDirectContext automatically releases all its resources.
Definition at line 125 of file GrGpuResource.cpp.
125 {
126 if (fGpu) {
128 } else {
129 return nullptr;
130 }
131}
◆ getGpu()
GrGpu * GrGpuResource::getGpu |
( |
| ) |
const |
|
inlineprotected |
◆ getLabel()
std::string GrGpuResource::getLabel |
( |
| ) |
const |
|
inline |
◆ getResourceName()
SkString GrGpuResource::getResourceName |
( |
| ) |
const |
|
protected |
Returns a string that uniquely identifies this resource.
Definition at line 118 of file GrGpuResource.cpp.
118 {
119
120 SkString resourceName(
"skia/gpu_resources/resource_");
121 resourceName.appendU32(this->
uniqueID().asUInt());
122 return resourceName;
123}
UniqueID uniqueID() const
◆ getResourceType()
virtual const char * GrGpuResource::getResourceType |
( |
| ) |
const |
|
pure virtual |
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.
◆ getUniqueKey()
Returns the current unique key for the resource. It will be invalid if the resource has no associated unique key.
Definition at line 191 of file GrGpuResource.h.
191{ return fUniqueKey; }
◆ gpuMemorySize()
size_t GrGpuResource::gpuMemorySize |
( |
| ) |
const |
|
inline |
Retrieves the amount of GPU memory used by this resource in bytes. It is approximate since we aren't aware of additional padding or copies made by the driver.
- Returns
- the amount of GPU memory used in bytes
Definition at line 156 of file GrGpuResource.h.
156 {
157 if (kInvalidGpuMemorySize == fGpuMemorySize) {
159 SkASSERT(kInvalidGpuMemorySize != fGpuMemorySize);
160 }
161 return fGpuMemorySize;
162 }
virtual size_t onGpuMemorySize() const =0
◆ onAbandon()
virtual void GrGpuResource::onAbandon |
( |
| ) |
|
|
inlineprotectedvirtual |
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 in GrD3DAttachment, GrD3DBuffer, GrD3DRenderTarget, GrD3DTexture, GrD3DTextureRenderTarget, GrGLAttachment, GrGLBuffer, GrGLRenderTarget, GrGLTexture, GrGLTextureRenderTarget, GrRenderTarget, GrSurface, GrMockTexture, GrMtlAttachment, GrMtlBuffer, GrMtlRenderTarget, GrMtlTexture, GrMtlTextureRenderTarget, GrVkRenderTarget, GrVkTexture, and GrVkTextureRenderTarget.
Definition at line 262 of file GrGpuResource.h.
◆ onGpuMemorySize()
virtual size_t GrGpuResource::onGpuMemorySize |
( |
| ) |
const |
|
privatepure virtual |
◆ onRelease()
virtual void GrGpuResource::onRelease |
( |
| ) |
|
|
inlineprotectedvirtual |
Overridden to free GPU resources in the backend API.
Reimplemented in GrD3DAttachment, GrD3DBuffer, GrD3DRenderTarget, GrD3DTexture, GrD3DTextureRenderTarget, GrGLAttachment, GrGLBuffer, GrGLRenderTarget, GrGLTexture, GrGLTextureRenderTarget, GrRenderTarget, GrSurface, GrMockTexture, GrMtlAttachment, GrMtlBuffer, GrMtlRenderTarget, GrMtlTexture, GrMtlTextureRenderTarget, GrVkRenderTarget, GrVkTexture, and GrVkTextureRenderTarget.
Definition at line 258 of file GrGpuResource.h.
◆ onSetLabel()
virtual void GrGpuResource::onSetLabel |
( |
| ) |
|
|
privatepure virtual |
◆ proxyAccess()
◆ registerWithCache()
Definition at line 32 of file GrGpuResource.cpp.
32 {
38}
static GrResourceCache * get_resource_cache(GrGpu *gpu)
virtual void computeScratchKey(skgpu::ScratchKey *) const
ResourceAccess resourceAccess()
◆ registerWithCacheWrapped()
◆ resourcePriv() [1/2]
◆ resourcePriv() [2/2]
◆ setLabel()
void GrGpuResource::setLabel |
( |
std::string_view |
label | ) |
|
|
inline |
Definition at line 195 of file GrGpuResource.h.
195 {
196 fLabel = label;
198 }
virtual void onSetLabel()=0
◆ setMemoryBacking()
◆ uniqueID()
UniqueID GrGpuResource::uniqueID |
( |
| ) |
const |
|
inline |
Gets an id that is unique for this GrGpuResource object. It is static in that it does not change when the content of the GrGpuResource object changes. This will never return 0.
Definition at line 187 of file GrGpuResource.h.
◆ wasDestroyed()
bool GrGpuResource::wasDestroyed |
( |
| ) |
const |
|
inline |
Tests whether a object has been abandoned or released. All objects will be in this state after their creating GrContext is destroyed or has contextLost called. It's up to the client to test wasDestroyed() before attempting to use an object if it holds refs on objects across ~GrContext, freeResources with the force flag, or contextLost.
- Returns
- true if the object has been released or abandoned, false otherwise.
Definition at line 138 of file GrGpuResource.h.
138{ return nullptr == fGpu; }
◆ GrIORef< GrGpuResource >
The documentation for this class was generated from the following files: