aboutsummaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorGravatar Robert Phillips <robertphillips@google.com>2018-02-07 08:37:50 -0500
committerGravatar Skia Commit-Bot <skia-commit-bot@chromium.org>2018-02-07 14:22:58 +0000
commited858ec0951a10bc8bef1f883c925e1ac5e5766f (patch)
treeb1b12d3ccd7778b9d96cf1b172f638c3b951ab00
parent14962b7f1341941ec1f2e759c4783f28fd0330c6 (diff)
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 <robertphillips@google.com> Reviewed-by: Brian Salomon <bsalomon@google.com>
-rw-r--r--gm/atlastext.cpp5
-rw-r--r--include/private/GrOpList.h8
-rw-r--r--src/gpu/GrDrawingManager.cpp6
-rw-r--r--src/gpu/GrOpList.cpp2
-rw-r--r--src/gpu/GrTextureProxy.cpp6
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_ptr<GrDeferredProxyUplo
}
void GrTextureProxyPriv::scheduleUpload(GrOpFlushState* flushState) {
- SkASSERT(fTextureProxy->fDeferredUploader);
-
- // 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);
}
}