aboutsummaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorGravatar Robert Phillips <robertphillips@google.com>2017-05-11 14:14:30 -0400
committerGravatar Skia Commit-Bot <skia-commit-bot@chromium.org>2017-05-11 19:44:39 +0000
commitb6deea8f0ed61475382fc48c7359118bfdcbff85 (patch)
treeb06cb1b81f0c5cb9f0aa92e85207c6059f9e18cb
parentce5e326016f7ade56afc2381e0f951b6c2ebc779 (diff)
Setup for another attempt to split up opLists
Split out of: https://skia-review.googlesource.com/c/14186 (Split up opLists (take 3)) Change-Id: Ifa600c88fb9185991d3197c7776c820f54c9bf0f Reviewed-on: https://skia-review.googlesource.com/16540 Reviewed-by: Brian Salomon <bsalomon@google.com> Commit-Queue: Robert Phillips <robertphillips@google.com>
-rw-r--r--include/gpu/GrGpuResourceRef.h17
-rw-r--r--include/private/GrSurfaceProxy.h51
-rw-r--r--src/gpu/GrDrawingManager.cpp7
-rw-r--r--src/gpu/GrDrawingManager.h4
-rw-r--r--src/gpu/GrGpuResource.cpp3
-rw-r--r--src/gpu/GrGpuResourceRef.cpp18
-rw-r--r--src/gpu/GrOnFlushResourceProvider.cpp4
-rw-r--r--src/gpu/GrOpList.cpp4
-rw-r--r--src/gpu/GrOpList.h5
-rw-r--r--src/gpu/GrRenderTargetContext.cpp2
-rw-r--r--src/gpu/GrRenderTargetOpList.cpp8
-rw-r--r--src/gpu/GrRenderTargetOpList.h2
-rw-r--r--src/gpu/GrTextureContext.cpp2
-rw-r--r--src/gpu/GrTextureOpList.cpp4
-rw-r--r--src/gpu/GrTextureOpList.h2
-rw-r--r--tests/ProxyRefTest.cpp2
16 files changed, 64 insertions, 71 deletions
diff --git a/include/gpu/GrGpuResourceRef.h b/include/gpu/GrGpuResourceRef.h
index f82b502574..ca1b55a2ed 100644
--- a/include/gpu/GrGpuResourceRef.h
+++ b/include/gpu/GrGpuResourceRef.h
@@ -89,13 +89,13 @@ private:
typedef SkNoncopyable INHERITED;
};
-class GrTextureProxy;
+class GrSurfaceProxy;
-class GrTextureProxyRef : SkNoncopyable {
+class GrSurfaceProxyRef : SkNoncopyable {
public:
- virtual ~GrTextureProxyRef();
+ virtual ~GrSurfaceProxyRef();
- GrTextureProxy* getProxy() const { return fProxy; }
+ GrSurfaceProxy* getProxy() const { return fProxy; }
/** Does this object own a pending read or write on the resource it is wrapping. */
bool ownsPendingIO() const { return fPendingIO; }
@@ -109,15 +109,15 @@ public:
void reset();
protected:
- GrTextureProxyRef();
+ GrSurfaceProxyRef();
/** ioType expresses what type of IO operations will be marked as
pending on the resource when markPendingIO is called. */
- GrTextureProxyRef(sk_sp<GrTextureProxy>, GrIOType);
+ GrSurfaceProxyRef(sk_sp<GrSurfaceProxy>, GrIOType);
/** ioType expresses what type of IO operations will be marked as
pending on the resource when markPendingIO is called. */
- void setProxy(sk_sp<GrTextureProxy>, GrIOType);
+ void setProxy(sk_sp<GrSurfaceProxy>, GrIOType);
private:
/** Called by owning GrProgramElement when the program element is first scheduled for
@@ -137,8 +137,9 @@ private:
void pendingIOComplete() const;
friend class GrResourceIOProcessor;
+ friend class GrOpList; // for setProxy
- GrTextureProxy* fProxy;
+ GrSurfaceProxy* fProxy;
mutable bool fOwnRef;
mutable bool fPendingIO;
GrIOType fIOType;
diff --git a/include/private/GrSurfaceProxy.h b/include/private/GrSurfaceProxy.h
index b2ccfe0b7f..29bb8620e0 100644
--- a/include/private/GrSurfaceProxy.h
+++ b/include/private/GrSurfaceProxy.h
@@ -45,27 +45,24 @@ public:
fTarget->unref();
}
- if (!(--fRefCnt)) {
- delete this;
- return;
- }
-
- this->validate();
+ --fRefCnt;
+ this->didRemoveRefOrPendingIO();
}
void validate() const {
-#ifdef SK_DEBUG
- SkASSERT(fRefCnt >= 1);
+#ifdef SK_DEBUG
+ SkASSERT(fRefCnt >= 0);
SkASSERT(fPendingReads >= 0);
SkASSERT(fPendingWrites >= 0);
SkASSERT(fRefCnt + fPendingReads + fPendingWrites >= 1);
if (fTarget) {
- SkASSERT(!fPendingReads && !fPendingWrites);
// The backing GrSurface can have more refs than the proxy if the proxy
// started off wrapping an external resource (that came in with refs).
// The GrSurface should never have fewer refs than the proxy however.
SkASSERT(fTarget->fRefCnt >= fRefCnt);
+ SkASSERT(fTarget->fPendingReads >= fPendingReads);
+ SkASSERT(fTarget->fPendingWrites >= fPendingWrites);
}
#endif
}
@@ -96,9 +93,6 @@ protected:
fTarget->fRefCnt += (fRefCnt-1); // don't xfer the proxy's creation ref
fTarget->fPendingReads += fPendingReads;
fTarget->fPendingWrites += fPendingWrites;
-
- fPendingReads = 0;
- fPendingWrites = 0;
}
bool internalHasPendingIO() const {
@@ -123,18 +117,16 @@ protected:
private:
// This class is used to manage conversion of refs to pending reads/writes.
- friend class GrTextureProxyRef;
+ friend class GrSurfaceProxyRef;
template <typename, GrIOType> friend class GrPendingIOResource;
void addPendingRead() const {
this->validate();
+ ++fPendingReads;
if (fTarget) {
fTarget->addPendingRead();
- return;
}
-
- ++fPendingReads;
}
void completedRead() const {
@@ -142,21 +134,19 @@ private:
if (fTarget) {
fTarget->completedRead();
- return;
}
-
- SkFAIL("How was the read completed if the Proxy hasn't been instantiated?");
+
+ --fPendingReads;
+ this->didRemoveRefOrPendingIO();
}
void addPendingWrite() const {
this->validate();
+ ++fPendingWrites;
if (fTarget) {
fTarget->addPendingWrite();
- return;
}
-
- ++fPendingWrites;
}
void completedWrite() const {
@@ -164,10 +154,16 @@ private:
if (fTarget) {
fTarget->completedWrite();
- return;
}
-
- SkFAIL("How was the write completed if the Proxy hasn't been instantiated?");
+
+ --fPendingWrites;
+ this->didRemoveRefOrPendingIO();
+ }
+
+ void didRemoveRefOrPendingIO() const {
+ if (0 == fPendingReads && 0 == fPendingWrites && 0 == fRefCnt) {
+ delete this;
+ }
}
mutable int32_t fRefCnt;
@@ -374,14 +370,13 @@ private:
mutable size_t fGpuMemorySize;
// The last opList that wrote to or is currently going to write to this surface
- // The opList can be closed (e.g., no render target context is currently bound
- // to this renderTarget).
+ // The opList can be closed (e.g., no surface context is currently bound
+ // to this proxy).
// This back-pointer is required so that we can add a dependancy between
// the opList used to create the current contents of this surface
// and the opList of a destination surface to which this one is being drawn or copied.
GrOpList* fLastOpList;
-
typedef GrIORefProxy INHERITED;
};
diff --git a/src/gpu/GrDrawingManager.cpp b/src/gpu/GrDrawingManager.cpp
index 5b8d37b37d..b6ca9661a6 100644
--- a/src/gpu/GrDrawingManager.cpp
+++ b/src/gpu/GrDrawingManager.cpp
@@ -125,6 +125,7 @@ void GrDrawingManager::internalFlush(GrSurfaceProxy*, GrResourceCache::FlushType
if (!opList) {
continue; // Odd - but not a big deal
}
+ opList->makeClosed(*fContext->caps());
SkDEBUGCODE(opList->validateTargetsSingleRenderTarget());
opList->prepareOps(&fFlushState);
if (!opList->executeOps(&fFlushState)) {
@@ -208,7 +209,7 @@ void GrDrawingManager::addOnFlushCallbackObject(GrOnFlushCallbackObject* onFlush
fOnFlushCBObjects.push_back(onFlushCBObject);
}
-sk_sp<GrRenderTargetOpList> GrDrawingManager::newRTOpList(sk_sp<GrRenderTargetProxy> rtp) {
+sk_sp<GrRenderTargetOpList> GrDrawingManager::newRTOpList(GrRenderTargetProxy* rtp) {
SkASSERT(fContext);
#ifndef ENABLE_MDB
@@ -235,10 +236,10 @@ sk_sp<GrRenderTargetOpList> GrDrawingManager::newRTOpList(sk_sp<GrRenderTargetPr
return opList;
}
-sk_sp<GrTextureOpList> GrDrawingManager::newTextureOpList(sk_sp<GrTextureProxy> textureProxy) {
+sk_sp<GrTextureOpList> GrDrawingManager::newTextureOpList(GrTextureProxy* textureProxy) {
SkASSERT(fContext);
- sk_sp<GrTextureOpList> opList(new GrTextureOpList(std::move(textureProxy), fContext->getGpu(),
+ sk_sp<GrTextureOpList> opList(new GrTextureOpList(textureProxy, fContext->getGpu(),
fContext->getAuditTrail()));
#ifndef ENABLE_MDB
diff --git a/src/gpu/GrDrawingManager.h b/src/gpu/GrDrawingManager.h
index 85a29df420..8ea70debab 100644
--- a/src/gpu/GrDrawingManager.h
+++ b/src/gpu/GrDrawingManager.h
@@ -47,8 +47,8 @@ public:
// The caller automatically gets a ref on the returned opList. It must
// be balanced by an unref call.
- sk_sp<GrRenderTargetOpList> newRTOpList(sk_sp<GrRenderTargetProxy> rtp);
- sk_sp<GrTextureOpList> newTextureOpList(sk_sp<GrTextureProxy> textureProxy);
+ sk_sp<GrRenderTargetOpList> newRTOpList(GrRenderTargetProxy* rtp);
+ sk_sp<GrTextureOpList> newTextureOpList(GrTextureProxy* textureProxy);
GrContext* getContext() { return fContext; }
diff --git a/src/gpu/GrGpuResource.cpp b/src/gpu/GrGpuResource.cpp
index 872bbbbb93..df8e72c5ed 100644
--- a/src/gpu/GrGpuResource.cpp
+++ b/src/gpu/GrGpuResource.cpp
@@ -161,8 +161,7 @@ bool GrGpuResource::notifyRefCountIsZero() const {
}
GrGpuResource* mutableThis = const_cast<GrGpuResource*>(this);
- uint32_t flags =
- GrResourceCache::ResourceAccess::kRefCntReachedZero_RefNotificationFlag;
+ uint32_t flags = GrResourceCache::ResourceAccess::kRefCntReachedZero_RefNotificationFlag;
if (!this->internalHasPendingIO()) {
flags |= GrResourceCache::ResourceAccess::kAllCntsReachedZero_RefNotificationFlag;
}
diff --git a/src/gpu/GrGpuResourceRef.cpp b/src/gpu/GrGpuResourceRef.cpp
index fc1c8b914f..115e0b1797 100644
--- a/src/gpu/GrGpuResourceRef.cpp
+++ b/src/gpu/GrGpuResourceRef.cpp
@@ -129,20 +129,20 @@ void GrGpuResourceRef::removeRef() const {
///////////////////////////////////////////////////////////////////////////////
#include "GrTextureProxy.h"
-GrTextureProxyRef::GrTextureProxyRef() {
+GrSurfaceProxyRef::GrSurfaceProxyRef() {
fProxy = nullptr;
fOwnRef = false;
fPendingIO = false;
}
-GrTextureProxyRef::GrTextureProxyRef(sk_sp<GrTextureProxy> proxy, GrIOType ioType) {
+GrSurfaceProxyRef::GrSurfaceProxyRef(sk_sp<GrSurfaceProxy> proxy, GrIOType ioType) {
fProxy = nullptr;
fOwnRef = false;
fPendingIO = false;
- this->setProxy(proxy, ioType);
+ this->setProxy(std::move(proxy), ioType);
}
-GrTextureProxyRef::~GrTextureProxyRef() {
+GrSurfaceProxyRef::~GrSurfaceProxyRef() {
if (fOwnRef) {
SkASSERT(fProxy);
fProxy->unref();
@@ -163,7 +163,7 @@ GrTextureProxyRef::~GrTextureProxyRef() {
}
}
-void GrTextureProxyRef::reset() {
+void GrSurfaceProxyRef::reset() {
SkASSERT(!fPendingIO);
SkASSERT(SkToBool(fProxy) == fOwnRef);
if (fOwnRef) {
@@ -173,7 +173,7 @@ void GrTextureProxyRef::reset() {
}
}
-void GrTextureProxyRef::setProxy(sk_sp<GrTextureProxy> proxy, GrIOType ioType) {
+void GrSurfaceProxyRef::setProxy(sk_sp<GrSurfaceProxy> proxy, GrIOType ioType) {
SkASSERT(!fPendingIO);
SkASSERT(SkToBool(fProxy) == fOwnRef);
SkSafeUnref(fProxy);
@@ -187,7 +187,7 @@ void GrTextureProxyRef::setProxy(sk_sp<GrTextureProxy> proxy, GrIOType ioType) {
}
}
-void GrTextureProxyRef::markPendingIO() const {
+void GrSurfaceProxyRef::markPendingIO() const {
// This should only be called when the owning GrProgramElement gets its first
// pendingExecution ref.
SkASSERT(!fPendingIO);
@@ -207,7 +207,7 @@ void GrTextureProxyRef::markPendingIO() const {
}
}
-void GrTextureProxyRef::pendingIOComplete() const {
+void GrSurfaceProxyRef::pendingIOComplete() const {
// This should only be called when the owner's pending executions have ocurred but it is still
// reffed.
SkASSERT(fOwnRef);
@@ -228,7 +228,7 @@ void GrTextureProxyRef::pendingIOComplete() const {
fPendingIO = false;
}
-void GrTextureProxyRef::removeRef() const {
+void GrSurfaceProxyRef::removeRef() const {
// This should only be called once, when the owners last ref goes away and
// there is a pending execution.
SkASSERT(fOwnRef);
diff --git a/src/gpu/GrOnFlushResourceProvider.cpp b/src/gpu/GrOnFlushResourceProvider.cpp
index 377c1f6bc6..a86d269d39 100644
--- a/src/gpu/GrOnFlushResourceProvider.cpp
+++ b/src/gpu/GrOnFlushResourceProvider.cpp
@@ -33,7 +33,7 @@ sk_sp<GrRenderTargetContext> GrOnFlushResourceProvider::makeRenderTargetContext(
// MDB TODO: This explicit resource creation is required in the pre-MDB world so that the
// pre-Flush ops are placed in their own opList.
sk_sp<GrRenderTargetOpList> opList(new GrRenderTargetOpList(
- sk_ref_sp(proxy->asRenderTargetProxy()),
+ proxy->asRenderTargetProxy(),
fDrawingMgr->fContext->getGpu(),
fDrawingMgr->fContext->getAuditTrail()));
proxy->setLastOpList(opList.get());
@@ -61,7 +61,7 @@ sk_sp<GrRenderTargetContext> GrOnFlushResourceProvider::makeRenderTargetContext(
// MDB TODO: This explicit resource creation is required in the pre-MDB world so that the
// pre-Flush ops are placed in their own opList.
sk_sp<GrRenderTargetOpList> opList(new GrRenderTargetOpList(
- sk_ref_sp(proxy->asRenderTargetProxy()),
+ proxy->asRenderTargetProxy(),
fDrawingMgr->fContext->getGpu(),
fDrawingMgr->fContext->getAuditTrail()));
proxy->setLastOpList(opList.get());
diff --git a/src/gpu/GrOpList.cpp b/src/gpu/GrOpList.cpp
index 3781213136..a088c447ae 100644
--- a/src/gpu/GrOpList.cpp
+++ b/src/gpu/GrOpList.cpp
@@ -20,10 +20,10 @@ uint32_t GrOpList::CreateUniqueID() {
return id;
}
-GrOpList::GrOpList(sk_sp<GrSurfaceProxy> surfaceProxy, GrAuditTrail* auditTrail)
+GrOpList::GrOpList(GrSurfaceProxy* surfaceProxy, GrAuditTrail* auditTrail)
// MDB TODO: in the future opLists will own the GrSurfaceProxy they target.
// For now, preserve the status quo.
- : fTarget(surfaceProxy.get())
+ : fTarget(surfaceProxy)
, fAuditTrail(auditTrail)
, fUniqueID(CreateUniqueID())
, fFlags(0) {
diff --git a/src/gpu/GrOpList.h b/src/gpu/GrOpList.h
index 54a13e1d91..d6e1c30e4d 100644
--- a/src/gpu/GrOpList.h
+++ b/src/gpu/GrOpList.h
@@ -22,7 +22,7 @@ class GrTextureOpList;
class GrOpList : public SkRefCnt {
public:
- GrOpList(sk_sp<GrSurfaceProxy> surfaceProxy, GrAuditTrail* auditTrail);
+ GrOpList(GrSurfaceProxy*, GrAuditTrail*);
~GrOpList() override;
// These two methods are invoked as flush time
@@ -34,10 +34,9 @@ public:
// ever one GrOpLists and all calls will be funnelled into it.
#ifdef ENABLE_MDB
this->setFlag(kClosed_Flag);
-#endif
+#endif
}
- // TODO: it seems a bit odd that GrOpList has nothing to clear on reset
virtual void reset() = 0;
// TODO: in an MDB world, where the OpLists don't allocate GPU resources, it seems like
diff --git a/src/gpu/GrRenderTargetContext.cpp b/src/gpu/GrRenderTargetContext.cpp
index 56e2c2f937..d6081dbed8 100644
--- a/src/gpu/GrRenderTargetContext.cpp
+++ b/src/gpu/GrRenderTargetContext.cpp
@@ -121,7 +121,7 @@ GrRenderTargetOpList* GrRenderTargetContext::getOpList() {
SkDEBUGCODE(this->validate();)
if (!fOpList || fOpList->isClosed()) {
- fOpList = this->drawingManager()->newRTOpList(fRenderTargetProxy);
+ fOpList = this->drawingManager()->newRTOpList(fRenderTargetProxy.get());
}
return fOpList.get();
diff --git a/src/gpu/GrRenderTargetOpList.cpp b/src/gpu/GrRenderTargetOpList.cpp
index a9f4351a77..56b817f1fe 100644
--- a/src/gpu/GrRenderTargetOpList.cpp
+++ b/src/gpu/GrRenderTargetOpList.cpp
@@ -26,12 +26,11 @@ using gr_instanced::InstancedRendering;
static const int kMaxOpLookback = 10;
static const int kMaxOpLookahead = 10;
-GrRenderTargetOpList::GrRenderTargetOpList(sk_sp<GrRenderTargetProxy> proxy, GrGpu* gpu,
+GrRenderTargetOpList::GrRenderTargetOpList(GrRenderTargetProxy* proxy, GrGpu* gpu,
GrAuditTrail* auditTrail)
- : INHERITED(std::move(proxy), auditTrail)
+ : INHERITED(proxy, auditTrail)
, fLastClipStackGenID(SK_InvalidUniqueID)
- SkDEBUGCODE(, fNumClips(0))
-{
+ SkDEBUGCODE(, fNumClips(0)) {
if (GrCaps::InstancedSupport::kNone != gpu->caps()->instancedSupport()) {
fInstancedRendering.reset(gpu->createInstancedRendering());
}
@@ -187,6 +186,7 @@ void GrRenderTargetOpList::reset() {
fLastFullClearOp = nullptr;
fLastFullClearResourceID.makeInvalid();
fLastFullClearProxyID.makeInvalid();
+ fLastClipStackGenID = SK_InvalidUniqueID;
fRecordedOps.reset();
if (fInstancedRendering) {
fInstancedRendering->endFlush();
diff --git a/src/gpu/GrRenderTargetOpList.h b/src/gpu/GrRenderTargetOpList.h
index 21dd70e01b..f3514c72a8 100644
--- a/src/gpu/GrRenderTargetOpList.h
+++ b/src/gpu/GrRenderTargetOpList.h
@@ -33,7 +33,7 @@ private:
using DstTexture = GrXferProcessor::DstTexture;
public:
- GrRenderTargetOpList(sk_sp<GrRenderTargetProxy>, GrGpu*, GrAuditTrail*);
+ GrRenderTargetOpList(GrRenderTargetProxy*, GrGpu*, GrAuditTrail*);
~GrRenderTargetOpList() override;
diff --git a/src/gpu/GrTextureContext.cpp b/src/gpu/GrTextureContext.cpp
index fb8e79584e..479957b8e1 100644
--- a/src/gpu/GrTextureContext.cpp
+++ b/src/gpu/GrTextureContext.cpp
@@ -62,7 +62,7 @@ GrTextureOpList* GrTextureContext::getOpList() {
SkDEBUGCODE(this->validate();)
if (!fOpList || fOpList->isClosed()) {
- fOpList = this->drawingManager()->newTextureOpList(fTextureProxy);
+ fOpList = this->drawingManager()->newTextureOpList(fTextureProxy.get());
}
return fOpList.get();
diff --git a/src/gpu/GrTextureOpList.cpp b/src/gpu/GrTextureOpList.cpp
index 97a4bbf05e..15ca7c1aab 100644
--- a/src/gpu/GrTextureOpList.cpp
+++ b/src/gpu/GrTextureOpList.cpp
@@ -15,8 +15,8 @@
////////////////////////////////////////////////////////////////////////////////
-GrTextureOpList::GrTextureOpList(sk_sp<GrTextureProxy> proxy, GrGpu* gpu, GrAuditTrail* auditTrail)
- : INHERITED(std::move(proxy), auditTrail)
+GrTextureOpList::GrTextureOpList(GrTextureProxy* proxy, GrGpu* gpu, GrAuditTrail* auditTrail)
+ : INHERITED(proxy, auditTrail)
, fGpu(SkRef(gpu)) {
}
diff --git a/src/gpu/GrTextureOpList.h b/src/gpu/GrTextureOpList.h
index f351ea811b..984762c8ae 100644
--- a/src/gpu/GrTextureOpList.h
+++ b/src/gpu/GrTextureOpList.h
@@ -23,7 +23,7 @@ struct SkIRect;
class GrTextureOpList final : public GrOpList {
public:
- GrTextureOpList(sk_sp<GrTextureProxy>, GrGpu*, GrAuditTrail*);
+ GrTextureOpList(GrTextureProxy*, GrGpu*, GrAuditTrail*);
~GrTextureOpList() override;
diff --git a/tests/ProxyRefTest.cpp b/tests/ProxyRefTest.cpp
index d5569b41d1..cd07e186c8 100644
--- a/tests/ProxyRefTest.cpp
+++ b/tests/ProxyRefTest.cpp
@@ -31,7 +31,6 @@ int32_t GrIORefProxy::getBackingRefCnt_TestOnly() const {
int32_t GrIORefProxy::getPendingReadCnt_TestOnly() const {
if (fTarget) {
- SkASSERT(!fPendingReads);
return fTarget->fPendingReads;
}
@@ -40,7 +39,6 @@ int32_t GrIORefProxy::getPendingReadCnt_TestOnly() const {
int32_t GrIORefProxy::getPendingWriteCnt_TestOnly() const {
if (fTarget) {
- SkASSERT(!fPendingWrites);
return fTarget->fPendingWrites;
}