From ed858ec0951a10bc8bef1f883c925e1ac5e5766f Mon Sep 17 00:00:00 2001 From: Robert Phillips Date: Wed, 7 Feb 2018 08:37:50 -0500 Subject: [PATCH] Re-enable explicit resource allocation in Skia (take 2) Unsurprisingly, given how we're adding them to the opList's deferredProxy list, a proxy can appear twice. Change-Id: I474357a1c3ee8cedf51dbeffcd0e0a96f396375c Reviewed-on: https://skia-review.googlesource.com/103701 Commit-Queue: Robert Phillips Reviewed-by: Brian Salomon --- gm/atlastext.cpp | 5 ++++- include/private/GrOpList.h | 8 ++++---- src/gpu/GrDrawingManager.cpp | 6 +++++- src/gpu/GrOpList.cpp | 2 +- src/gpu/GrTextureProxy.cpp | 6 ++---- 5 files changed, 16 insertions(+), 11 deletions(-) diff --git a/gm/atlastext.cpp b/gm/atlastext.cpp index ac5b3e4582..226b83fdd7 100644 --- a/gm/atlastext.cpp +++ b/gm/atlastext.cpp @@ -69,6 +69,9 @@ protected: } fContext = SkAtlasTextContext::Make(fRenderer); auto targetHandle = fRenderer->makeTargetHandle(kSize, kSize); + if (!targetHandle) { + return; + } fTarget = SkAtlasTextTarget::Make(fContext, kSize, kSize, targetHandle); fTypefaces[0] = sk_tool_utils::create_portable_typeface("serif", SkFontStyle::Italic()); @@ -82,7 +85,7 @@ protected: } void onDraw(SkCanvas* canvas) override { - if (!fRenderer) { + if (!fRenderer || !fTarget || !fTarget->handle()) { canvas->clear(SK_ColorRED); return; } diff --git a/include/private/GrOpList.h b/include/private/GrOpList.h index c9abd6d4e5..5359a42930 100644 --- a/include/private/GrOpList.h +++ b/include/private/GrOpList.h @@ -16,9 +16,9 @@ // Turn on/off the explicit distribution of GPU resources at flush time -#ifndef SK_DISABLE_EXPLICIT_GPU_RESOURCE_ALLOCATION - #define SK_DISABLE_EXPLICIT_GPU_RESOURCE_ALLOCATION -#endif +//#ifndef SK_DISABLE_EXPLICIT_GPU_RESOURCE_ALLOCATION +// #define SK_DISABLE_EXPLICIT_GPU_RESOURCE_ALLOCATION +//#endif // Turn on/off the sorting of opLists at flush time #ifndef SK_DISABLE_RENDER_TARGET_SORTING @@ -111,7 +111,7 @@ public: void setStencilLoadOp(GrLoadOp loadOp) { fStencilLoadOp = loadOp; } protected: - SkDEBUGCODE(bool isInstantiated() const;) + bool isInstantiated() const; GrSurfaceProxyRef fTarget; GrAuditTrail* fAuditTrail; diff --git a/src/gpu/GrDrawingManager.cpp b/src/gpu/GrDrawingManager.cpp index 1897860ee1..47c5ecf691 100644 --- a/src/gpu/GrDrawingManager.cpp +++ b/src/gpu/GrDrawingManager.cpp @@ -237,7 +237,11 @@ bool GrDrawingManager::executeOpLists(int startIndex, int stopIndex, GrOpFlushSt continue; } #else - SkASSERT(fOpLists[i]->isInstantiated()); + if (!fOpLists[i]->isInstantiated()) { + // If the backing surface wasn't allocated drop the draw of the entire opList. + fOpLists[i] = nullptr; + continue; + } #endif // TODO: handle this instantiation via lazy surface proxies? diff --git a/src/gpu/GrOpList.cpp b/src/gpu/GrOpList.cpp index b63e96ca26..0823d55b78 100644 --- a/src/gpu/GrOpList.cpp +++ b/src/gpu/GrOpList.cpp @@ -118,11 +118,11 @@ void GrOpList::addDependency(GrSurfaceProxy* dependedOn, const GrCaps& caps) { } } -#ifdef SK_DEBUG bool GrOpList::isInstantiated() const { return fTarget.get()->priv().isInstantiated(); } +#ifdef SK_DEBUG void GrOpList::dump() const { SkDebugf("--------------------------------------------------------------\n"); SkDebugf("node: %d -> RT: %d\n", fUniqueID, fTarget.get() ? fTarget.get()->uniqueID().asUInt() diff --git a/src/gpu/GrTextureProxy.cpp b/src/gpu/GrTextureProxy.cpp index 13e124021f..3362ec81d4 100644 --- a/src/gpu/GrTextureProxy.cpp +++ b/src/gpu/GrTextureProxy.cpp @@ -95,10 +95,8 @@ void GrTextureProxyPriv::setDeferredUploader(std::unique_ptrfDeferredUploader); - - // Instantiate might have failed - if (fTextureProxy->fTarget) { + // The texture proxy's contents may already have been uploaded or instantiation may have failed + if (fTextureProxy->fDeferredUploader && fTextureProxy->fTarget) { fTextureProxy->fDeferredUploader->scheduleUpload(flushState, fTextureProxy); } }