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>
This commit is contained in:
parent
ce5e326016
commit
b6deea8f0e
@ -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;
|
||||
|
@ -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;
|
||||
};
|
||||
|
||||
|
@ -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
|
||||
|
@ -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; }
|
||||
|
||||
|
@ -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;
|
||||
}
|
||||
|
@ -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);
|
||||
|
@ -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());
|
||||
|
@ -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) {
|
||||
|
@ -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
|
||||
|
@ -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();
|
||||
|
@ -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();
|
||||
|
@ -33,7 +33,7 @@ private:
|
||||
using DstTexture = GrXferProcessor::DstTexture;
|
||||
|
||||
public:
|
||||
GrRenderTargetOpList(sk_sp<GrRenderTargetProxy>, GrGpu*, GrAuditTrail*);
|
||||
GrRenderTargetOpList(GrRenderTargetProxy*, GrGpu*, GrAuditTrail*);
|
||||
|
||||
~GrRenderTargetOpList() override;
|
||||
|
||||
|
@ -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();
|
||||
|
@ -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)) {
|
||||
}
|
||||
|
||||
|
@ -23,7 +23,7 @@ struct SkIRect;
|
||||
|
||||
class GrTextureOpList final : public GrOpList {
|
||||
public:
|
||||
GrTextureOpList(sk_sp<GrTextureProxy>, GrGpu*, GrAuditTrail*);
|
||||
GrTextureOpList(GrTextureProxy*, GrGpu*, GrAuditTrail*);
|
||||
|
||||
~GrTextureOpList() override;
|
||||
|
||||
|
@ -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;
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user