Loosen up uniqueKey asserts between GrTextureProxy and GrTexture in DDLs (alt. version)
When recording a DDL it is possible for a uniquely keyed resource to lose its uniqueKey in the direct context (and its proxyProvider) while the DDL's proxyProvider still has a proxy with a uniqueKey.
Bug: 1056730
Change-Id: I565b08a8eb280aea19fc3052c758e059392a4c12
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/289890
Commit-Queue: Robert Phillips <robertphillips@google.com>
Reviewed-by: Brian Salomon <bsalomon@google.com>
diff --git a/src/gpu/GrTextureProxy.h b/src/gpu/GrTextureProxy.h
index 06afa9a..7781cc2 100644
--- a/src/gpu/GrTextureProxy.h
+++ b/src/gpu/GrTextureProxy.h
@@ -73,7 +73,8 @@
*/
const GrUniqueKey& getUniqueKey() const {
#ifdef SK_DEBUG
- if (this->isInstantiated() && fUniqueKey.isValid() && fSyncTargetKey) {
+ if (this->isInstantiated() && fUniqueKey.isValid() && fSyncTargetKey &&
+ fCreatingProvider == GrDDLProvider::kNo) {
GrSurface* surface = this->peekSurface();
SkASSERT(surface);
@@ -100,6 +101,8 @@
GrTextureProxyPriv texPriv();
const GrTextureProxyPriv texPriv() const;
+ SkDEBUGCODE(GrDDLProvider creatingProvider() const { return fCreatingProvider; })
+
protected:
// DDL TODO: rm the GrSurfaceProxy friending
friend class GrSurfaceProxy; // for ctors
@@ -116,7 +119,8 @@
SkBudgeted,
GrProtected,
GrInternalSurfaceFlags,
- UseAllocator);
+ UseAllocator,
+ GrDDLProvider creatingProvider);
// Lazy-callback version
// There are two main use cases for lazily-instantiated proxies:
@@ -137,15 +141,19 @@
SkBudgeted,
GrProtected,
GrInternalSurfaceFlags,
- UseAllocator);
+ UseAllocator,
+ GrDDLProvider creatingProvider);
// Wrapped version
- GrTextureProxy(sk_sp<GrSurface>, UseAllocator);
+ GrTextureProxy(sk_sp<GrSurface>, UseAllocator, GrDDLProvider creatingProvider);
~GrTextureProxy() override;
sk_sp<GrSurface> createSurface(GrResourceProvider*) const override;
+ // By default uniqueKeys are propagated from a textureProxy to its backing GrTexture.
+ // Setting syncTargetKey to false disables this behavior and only keeps the unique key
+ // on the proxy.
void setTargetKeySync(bool sync) { fSyncTargetKey = sync; }
private:
@@ -173,6 +181,12 @@
bool fSyncTargetKey = true; // Should target's unique key be sync'ed with ours.
+ // For GrTextureProxies created in a DDL recording thread it is possible for the uniqueKey
+ // to be cleared on the backing GrTexture while the uniqueKey remains on the proxy.
+ // A fCreatingProvider of DDLProvider::kYes loosens up asserts that the key of an instantiated
+ // uniquely-keyed textureProxy is also always set on the backing GrTexture.
+ GrDDLProvider fCreatingProvider = GrDDLProvider::kNo;
+
GrUniqueKey fUniqueKey;
GrProxyProvider* fProxyProvider; // only set when fUniqueKey is valid