From 0cab38e81a176e64024df2ce6bc5cd2316370e1a Mon Sep 17 00:00:00 2001 From: Greg Daniel Date: Fri, 4 Mar 2022 10:35:11 -0500 Subject: [PATCH] [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 Commit-Queue: Greg Daniel --- experimental/graphite/src/ResourceProvider.cpp | 13 +++++++++++-- experimental/graphite/src/ResourceProvider.h | 2 +- experimental/graphite/src/TextureProxy.cpp | 2 +- 3 files changed, 13 insertions(+), 4 deletions(-) diff --git a/experimental/graphite/src/ResourceProvider.cpp b/experimental/graphite/src/ResourceProvider.cpp index 81b9a5365a..c07104b692 100644 --- a/experimental/graphite/src/ResourceProvider.cpp +++ b/experimental/graphite/src/ResourceProvider.cpp @@ -83,8 +83,17 @@ sk_sp ResourceProvider::GraphicsPipelineCache::refPipeline( return (*entry)->fPipeline; } -sk_sp ResourceProvider::findOrCreateTexture(SkISize dimensions, const TextureInfo& info) { - return this->createTexture(dimensions, info); +sk_sp 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 ResourceProvider::findOrCreateDepthStencilAttachment(SkISize dimensions, diff --git a/experimental/graphite/src/ResourceProvider.h b/experimental/graphite/src/ResourceProvider.h index 993b464cd9..45ea885a67 100644 --- a/experimental/graphite/src/ResourceProvider.h +++ b/experimental/graphite/src/ResourceProvider.h @@ -43,7 +43,7 @@ public: sk_sp findOrCreateGraphicsPipeline(const GraphicsPipelineDesc&, const RenderPassDesc&); - sk_sp findOrCreateTexture(SkISize, const TextureInfo&); + sk_sp findOrCreateScratchTexture(SkISize, const TextureInfo&); virtual sk_sp createWrappedTexture(const BackendTexture&) = 0; sk_sp findOrCreateDepthStencilAttachment(SkISize dimensions, diff --git a/experimental/graphite/src/TextureProxy.cpp b/experimental/graphite/src/TextureProxy.cpp index f71fc03cfe..1cc3918a67 100644 --- a/experimental/graphite/src/TextureProxy.cpp +++ b/experimental/graphite/src/TextureProxy.cpp @@ -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; }