Plumb label string from cache of scratch texture.
In this CL, cache of previously created scratch texture accepts the label and passes it to the GrGpuResource by making use of existing resource. Bug: chromium:1164111 Change-Id: Id798aa5f3fe9baa00c2f409febf4d5fcbe3a675a Reviewed-on: https://skia-review.googlesource.com/c/skia/+/532276 Reviewed-by: Greg Daniel <egdaniel@google.com> Commit-Queue: Greg Daniel <egdaniel@google.com>
This commit is contained in:
parent
62471d80c9
commit
8065fff70c
@ -176,6 +176,8 @@ public:
|
||||
|
||||
std::string_view getLabel() const { return fLabel; }
|
||||
|
||||
void setLabel(std::string_view label) { fLabel = label; }
|
||||
|
||||
/**
|
||||
* Internal-only helper class used for manipulations of the resource by the cache.
|
||||
*/
|
||||
@ -313,7 +315,7 @@ private:
|
||||
GrBudgetedType fBudgetedType = GrBudgetedType::kUnbudgetedUncacheable;
|
||||
bool fRefsWrappedObjects = false;
|
||||
const UniqueID fUniqueID;
|
||||
const std::string fLabel;
|
||||
std::string fLabel;
|
||||
|
||||
using INHERITED = GrIORef<GrGpuResource>;
|
||||
friend class GrIORef<GrGpuResource>; // to access notifyRefCntWillBeZero and
|
||||
|
@ -115,7 +115,7 @@ GrResourceAllocator::Register::Register(GrSurfaceProxy* originatingProxy,
|
||||
SkDEBUGCODE(fUniqueID = CreateUniqueID();)
|
||||
if (fScratchKey.isValid()) {
|
||||
if (can_proxy_use_scratch(*provider->caps(), originatingProxy)) {
|
||||
fExistingSurface = provider->findAndRefScratchTexture(fScratchKey);
|
||||
fExistingSurface = provider->findAndRefScratchTexture(fScratchKey, /*label=*/{});
|
||||
}
|
||||
} else {
|
||||
SkASSERT(this->uniqueKey().isValid());
|
||||
|
@ -307,7 +307,8 @@ sk_sp<GrTexture> GrResourceProvider::createApproxTexture(SkISize dimensions,
|
||||
isProtected);
|
||||
}
|
||||
|
||||
sk_sp<GrTexture> GrResourceProvider::findAndRefScratchTexture(const skgpu::ScratchKey& key) {
|
||||
sk_sp<GrTexture> GrResourceProvider::findAndRefScratchTexture(const skgpu::ScratchKey& key,
|
||||
std::string_view label) {
|
||||
ASSERT_SINGLE_OWNER
|
||||
SkASSERT(!this->isAbandoned());
|
||||
SkASSERT(key.isValid());
|
||||
@ -315,6 +316,7 @@ sk_sp<GrTexture> GrResourceProvider::findAndRefScratchTexture(const skgpu::Scrat
|
||||
if (GrGpuResource* resource = fCache->findAndRefScratchResource(key)) {
|
||||
fGpu->stats()->incNumScratchTexturesReused();
|
||||
GrSurface* surface = static_cast<GrSurface*>(resource);
|
||||
resource->setLabel(std::move(label));
|
||||
return sk_sp<GrTexture>(surface->asTexture());
|
||||
}
|
||||
return nullptr;
|
||||
@ -339,7 +341,7 @@ sk_sp<GrTexture> GrResourceProvider::findAndRefScratchTexture(SkISize dimensions
|
||||
skgpu::ScratchKey key;
|
||||
GrTexture::ComputeScratchKey(*this->caps(), format, dimensions, renderable,
|
||||
renderTargetSampleCnt, mipmapped, isProtected, &key);
|
||||
return this->findAndRefScratchTexture(key);
|
||||
return this->findAndRefScratchTexture(key, /*label=*/{});
|
||||
}
|
||||
|
||||
return nullptr;
|
||||
@ -712,7 +714,8 @@ sk_sp<GrAttachment> GrResourceProvider::makeMSAAAttachment(SkISize dimensions,
|
||||
format,
|
||||
sampleCnt,
|
||||
isProtected,
|
||||
memoryless);
|
||||
memoryless,
|
||||
/*label=*/{});
|
||||
if (scratch) {
|
||||
return scratch;
|
||||
}
|
||||
@ -724,7 +727,8 @@ sk_sp<GrAttachment> GrResourceProvider::refScratchMSAAAttachment(SkISize dimensi
|
||||
const GrBackendFormat& format,
|
||||
int sampleCnt,
|
||||
GrProtected isProtected,
|
||||
GrMemoryless memoryless) {
|
||||
GrMemoryless memoryless,
|
||||
std::string_view label) {
|
||||
ASSERT_SINGLE_OWNER
|
||||
SkASSERT(!this->isAbandoned());
|
||||
SkASSERT(!this->caps()->isFormatCompressed(format));
|
||||
@ -743,6 +747,7 @@ sk_sp<GrAttachment> GrResourceProvider::refScratchMSAAAttachment(SkISize dimensi
|
||||
if (resource) {
|
||||
fGpu->stats()->incNumScratchMSAAAttachmentsReused();
|
||||
GrAttachment* attachment = static_cast<GrAttachment*>(resource);
|
||||
resource->setLabel(std::move(label));
|
||||
return sk_sp<GrAttachment>(attachment);
|
||||
}
|
||||
|
||||
|
@ -116,7 +116,7 @@ public:
|
||||
* Search the cache for a scratch texture matching the provided arguments. Failing that
|
||||
* it returns null. If non-null, the resulting texture is always budgeted.
|
||||
*/
|
||||
sk_sp<GrTexture> findAndRefScratchTexture(const skgpu::ScratchKey&);
|
||||
sk_sp<GrTexture> findAndRefScratchTexture(const skgpu::ScratchKey&, std::string_view label);
|
||||
sk_sp<GrTexture> findAndRefScratchTexture(SkISize dimensions,
|
||||
const GrBackendFormat&,
|
||||
GrTextureType textureType,
|
||||
@ -365,7 +365,8 @@ private:
|
||||
const GrBackendFormat&,
|
||||
int sampleCnt,
|
||||
GrProtected,
|
||||
GrMemoryless memoryless);
|
||||
GrMemoryless memoryless,
|
||||
std::string_view label);
|
||||
|
||||
// Used to perform any conversions necessary to texel data before creating a texture with
|
||||
// existing data or uploading to a scratch texture.
|
||||
|
Loading…
Reference in New Issue
Block a user