[graphite] Add support for caching scratch textures.

Bug: skia:12754
Change-Id: I666bda6a192e3c3dc95953e5a36fbabbf65171ec
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/515857
Reviewed-by: Jim Van Verth <jvanverth@google.com>
Commit-Queue: Greg Daniel <egdaniel@google.com>
This commit is contained in:
Greg Daniel 2022-03-04 10:35:11 -05:00 committed by SkCQ
parent f60584eb0f
commit 0cab38e81a
3 changed files with 13 additions and 4 deletions

View File

@ -83,8 +83,17 @@ sk_sp<GraphicsPipeline> ResourceProvider::GraphicsPipelineCache::refPipeline(
return (*entry)->fPipeline;
}
sk_sp<Texture> ResourceProvider::findOrCreateTexture(SkISize dimensions, const TextureInfo& info) {
return this->createTexture(dimensions, info);
sk_sp<Texture> ResourceProvider::findOrCreateScratchTexture(SkISize dimensions,
const TextureInfo& info) {
SkASSERT(info.isValid());
static const ResourceType kType = GraphiteResourceKey::GenerateResourceType();
GraphiteResourceKey key;
// Scratch textures are not shareable
fGpu->caps()->buildKeyForTexture(dimensions, info, kType, Shareable::kNo, &key);
return this->findOrCreateTextureWithKey(dimensions, info, key);
}
sk_sp<Texture> ResourceProvider::findOrCreateDepthStencilAttachment(SkISize dimensions,

View File

@ -43,7 +43,7 @@ public:
sk_sp<GraphicsPipeline> findOrCreateGraphicsPipeline(const GraphicsPipelineDesc&,
const RenderPassDesc&);
sk_sp<Texture> findOrCreateTexture(SkISize, const TextureInfo&);
sk_sp<Texture> findOrCreateScratchTexture(SkISize, const TextureInfo&);
virtual sk_sp<Texture> createWrappedTexture(const BackendTexture&) = 0;
sk_sp<Texture> findOrCreateDepthStencilAttachment(SkISize dimensions,

View File

@ -26,7 +26,7 @@ bool TextureProxy::instantiate(ResourceProvider* resourceProvider) {
if (fTexture) {
return true;
}
fTexture = resourceProvider->findOrCreateTexture(fDimensions, fInfo);
fTexture = resourceProvider->findOrCreateScratchTexture(fDimensions, fInfo);
if (!fTexture) {
return false;
}