aboutsummaryrefslogtreecommitdiffhomepage
path: root/src
diff options
context:
space:
mode:
authorGravatar Robert Phillips <robertphillips@google.com>2017-04-18 11:21:38 -0400
committerGravatar Skia Commit-Bot <skia-commit-bot@chromium.org>2017-04-18 15:59:45 +0000
commitbc8ee52d4649afdc972599e5ef2a2a543867985d (patch)
treefa21947e32de29e4c582d777e25a7b181d01efd6 /src
parent6e834799946537370e6f3c10aa2745ed969b2a27 (diff)
Split up opLists
Split into: https://skia-review.googlesource.com/c/11793/ (Remove lastProxy capability from GrSurface) Change-Id: I903ba30e17de4aab8cb0d2cc3281ae5c262142f9 Reviewed-on: https://skia-review.googlesource.com/11581 Commit-Queue: Robert Phillips <robertphillips@google.com> Reviewed-by: Brian Osman <brianosman@google.com>
Diffstat (limited to 'src')
-rw-r--r--src/gpu/GrDrawingManager.cpp53
-rw-r--r--src/gpu/GrOpList.cpp4
-rw-r--r--src/gpu/GrOpList.h18
-rw-r--r--src/gpu/GrPreFlushResourceProvider.cpp20
-rw-r--r--src/gpu/GrRenderTargetContext.cpp2
-rw-r--r--src/gpu/GrRenderTargetOpList.cpp38
-rw-r--r--src/gpu/GrSurfaceProxy.cpp16
-rw-r--r--src/gpu/GrTextureContext.cpp24
-rw-r--r--src/gpu/GrTextureOpList.cpp3
9 files changed, 63 insertions, 115 deletions
diff --git a/src/gpu/GrDrawingManager.cpp b/src/gpu/GrDrawingManager.cpp
index 6b2c5a20b4..9c5be8e6ca 100644
--- a/src/gpu/GrDrawingManager.cpp
+++ b/src/gpu/GrDrawingManager.cpp
@@ -26,10 +26,10 @@
void GrDrawingManager::cleanup() {
for (int i = 0; i < fOpLists.count(); ++i) {
fOpLists[i]->makeClosed(); // no opList should receive a new command after this
- fOpLists[i]->clearTarget();
// We shouldn't need to do this, but it turns out some clients still hold onto opLists
- // after a cleanup
+ // after a cleanup.
+ // MDB TODO: is this still true?
fOpLists[i]->reset();
}
@@ -83,6 +83,7 @@ void GrDrawingManager::internalFlush(GrSurfaceProxy*, GrResourceCache::FlushType
// but need to be flushed anyway. Closing such GrOpLists here will mean new
// GrOpLists will be created to replace them if the SkGpuDevice(s) write to them again.
fOpLists[i]->makeClosed();
+ SkDEBUGCODE(fOpLists[i]->validateTargetsSingleRenderTarget());
}
#ifdef ENABLE_MDB
@@ -115,6 +116,7 @@ void GrDrawingManager::internalFlush(GrSurfaceProxy*, GrResourceCache::FlushType
if (!opList) {
continue; // Odd - but not a big deal
}
+ opList->makeClosed();
SkDEBUGCODE(opList->validateTargetsSingleRenderTarget());
opList->prepareOps(&fFlushState);
if (!opList->executeOps(&fFlushState)) {
@@ -151,17 +153,7 @@ void GrDrawingManager::internalFlush(GrSurfaceProxy*, GrResourceCache::FlushType
fOpLists[i]->reset();
}
-#ifndef ENABLE_MDB
- // When MDB is disabled we keep reusing the same GrOpList
- if (fOpLists.count()) {
- SkASSERT(fOpLists.count() == 1);
- // Clear out this flag so the topological sort's SkTTopoSort_CheckAllUnmarked check
- // won't bark
- fOpLists[0]->resetFlag(GrOpList::kWasOutput_Flag);
- }
-#else
fOpLists.reset();
-#endif
fFlushState.reset();
// We always have to notify the cache when it requested a flush so it can reset its state.
@@ -198,19 +190,12 @@ void GrDrawingManager::addPreFlushCallbackObject(sk_sp<GrPreFlushCallbackObject>
sk_sp<GrRenderTargetOpList> GrDrawingManager::newRTOpList(sk_sp<GrRenderTargetProxy> rtp) {
SkASSERT(fContext);
-#ifndef ENABLE_MDB
- // When MDB is disabled we always just return the single GrOpList
- if (fOpLists.count()) {
- SkASSERT(fOpLists.count() == 1);
- // In the non-MDB-world the same GrOpList gets reused for multiple render targets.
- // Update this pointer so all the asserts are happy
- rtp->setLastOpList(fOpLists[0].get());
- // DrawingManager gets the creation ref - this ref is for the caller
-
- // TODO: although this is true right now it isn't cool
- return sk_ref_sp((GrRenderTargetOpList*) fOpLists[0].get());
+ // This is a temporary fix for the partial-MDB world. In that world we're not reordering
+ // so ops that (in the single opList world) would've just glommed onto the end of the single
+ // opList but referred to a far earlier RT need to appear in their own opList.
+ if (!fOpLists.empty()) {
+ fOpLists.back()->makeClosed();
}
-#endif
sk_sp<GrRenderTargetOpList> opList(new GrRenderTargetOpList(rtp,
fContext->getGpu(),
@@ -227,19 +212,21 @@ sk_sp<GrRenderTargetOpList> GrDrawingManager::newRTOpList(sk_sp<GrRenderTargetPr
sk_sp<GrTextureOpList> GrDrawingManager::newTextureOpList(sk_sp<GrTextureProxy> textureProxy) {
SkASSERT(fContext);
- sk_sp<GrTextureOpList> opList(new GrTextureOpList(std::move(textureProxy), fContext->getGpu(),
+ // This is a temporary fix for the partial-MDB world. In that world we're not reordering
+ // so ops that (in the single opList world) would've just glommed onto the end of the single
+ // opList but referred to a far earlier RT need to appear in their own opList.
+ if (!fOpLists.empty()) {
+ fOpLists.back()->makeClosed();
+ }
+
+ sk_sp<GrTextureOpList> opList(new GrTextureOpList(textureProxy, fContext->getGpu(),
fContext->getAuditTrail()));
-#ifndef ENABLE_MDB
- // When MDB is disabled we still create a new GrOpList, but don't store or ref it - we rely
- // on the caller to immediately execute and free it.
- return opList;
-#else
- *fOpLists.append() = opList;
+ SkASSERT(textureProxy->getLastOpList() == opList.get());
+
+ fOpLists.push_back() = opList;
- // Drawing manager gets the creation ref - this ref is for the caller
return opList;
-#endif
}
GrAtlasTextContext* GrDrawingManager::getAtlasTextContext() {
diff --git a/src/gpu/GrOpList.cpp b/src/gpu/GrOpList.cpp
index 91c8c7942c..5e618a21df 100644
--- a/src/gpu/GrOpList.cpp
+++ b/src/gpu/GrOpList.cpp
@@ -21,9 +21,7 @@ uint32_t GrOpList::CreateUniqueID() {
}
GrOpList::GrOpList(sk_sp<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 b7dd7fa62f..352a46c2a9 100644
--- a/src/gpu/GrOpList.h
+++ b/src/gpu/GrOpList.h
@@ -29,11 +29,7 @@ public:
virtual bool executeOps(GrOpFlushState* flushState) = 0;
virtual void makeClosed() {
- // We only close GrOpLists when MDB is enabled. When MDB is disabled there is only
- // ever one GrOpLists and all calls will be funnelled into it.
-#ifdef ENABLE_MDB
this->setFlag(kClosed_Flag);
-#endif
}
// TODO: it seems a bit odd that GrOpList has nothing to clear on reset
@@ -44,10 +40,6 @@ public:
virtual void abandonGpuResources() = 0;
virtual void freeGpuResources() = 0;
- // TODO: this entry point is only needed in the non-MDB world. Remove when
- // we make the switch to MDB
- void clearTarget() { fTarget = nullptr; }
-
bool isClosed() const { return this->isSetFlag(kClosed_Flag); }
/*
@@ -82,8 +74,8 @@ public:
SkDEBUGCODE(virtual void validateTargetsSingleRenderTarget() const = 0;)
protected:
- GrSurfaceProxy* fTarget;
- GrAuditTrail* fAuditTrail;
+ sk_sp<GrSurfaceProxy> fTarget;
+ GrAuditTrail* fAuditTrail;
private:
friend class GrDrawingManager; // for resetFlag & TopoSortTraits
@@ -135,11 +127,11 @@ private:
void addDependency(GrOpList* dependedOn);
- uint32_t fUniqueID;
- uint32_t fFlags;
+ uint32_t fUniqueID;
+ uint32_t fFlags;
// 'this' GrOpList relies on the output of the GrOpLists in 'fDependencies'
- SkTDArray<GrOpList*> fDependencies;
+ SkTDArray<GrOpList*> fDependencies;
typedef SkRefCnt INHERITED;
};
diff --git a/src/gpu/GrPreFlushResourceProvider.cpp b/src/gpu/GrPreFlushResourceProvider.cpp
index 3c6ddc4ab7..25033a0e39 100644
--- a/src/gpu/GrPreFlushResourceProvider.cpp
+++ b/src/gpu/GrPreFlushResourceProvider.cpp
@@ -30,16 +30,6 @@ sk_sp<GrRenderTargetContext> GrPreFlushResourceProvider::makeRenderTargetContext
return nullptr;
}
- // 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()),
- fDrawingMgr->fContext->getGpu(),
- fDrawingMgr->fContext->resourceProvider(),
- fDrawingMgr->fContext->getAuditTrail(),
- fDrawingMgr->fOptionsForOpLists));
- proxy->setLastOpList(opList.get());
-
sk_sp<GrRenderTargetContext> renderTargetContext(
fDrawingMgr->makeRenderTargetContext(std::move(proxy),
std::move(colorSpace),
@@ -60,16 +50,6 @@ sk_sp<GrRenderTargetContext> GrPreFlushResourceProvider::makeRenderTargetContext
sk_sp<GrSurfaceProxy> proxy,
sk_sp<SkColorSpace> colorSpace,
const SkSurfaceProps* props) {
- // 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()),
- fDrawingMgr->fContext->getGpu(),
- fDrawingMgr->fContext->resourceProvider(),
- fDrawingMgr->fContext->getAuditTrail(),
- fDrawingMgr->fOptionsForOpLists));
- proxy->setLastOpList(opList.get());
-
sk_sp<GrRenderTargetContext> renderTargetContext(
fDrawingMgr->makeRenderTargetContext(std::move(proxy),
std::move(colorSpace),
diff --git a/src/gpu/GrRenderTargetContext.cpp b/src/gpu/GrRenderTargetContext.cpp
index 34812ddfbe..eada468aed 100644
--- a/src/gpu/GrRenderTargetContext.cpp
+++ b/src/gpu/GrRenderTargetContext.cpp
@@ -128,7 +128,7 @@ GrRenderTargetOpList* GrRenderTargetContext::getOpList() {
return fOpList.get();
}
-// TODO: move this (and GrTextContext::copy) to GrSurfaceContext?
+// MDB TODO: move this (and GrTextContext::copy) to GrSurfaceContext?
bool GrRenderTargetContext::onCopy(GrSurfaceProxy* srcProxy,
const SkIRect& srcRect,
const SkIPoint& dstPoint) {
diff --git a/src/gpu/GrRenderTargetOpList.cpp b/src/gpu/GrRenderTargetOpList.cpp
index 4d309f407e..194bc265e6 100644
--- a/src/gpu/GrRenderTargetOpList.cpp
+++ b/src/gpu/GrRenderTargetOpList.cpp
@@ -87,7 +87,7 @@ void GrRenderTargetOpList::validateTargetsSingleRenderTarget() const {
#endif
void GrRenderTargetOpList::prepareOps(GrOpFlushState* flushState) {
- // MDB TODO: add SkASSERT(this->isClosed());
+ SkASSERT(this->isClosed());
// Loop over the ops that haven't yet been prepared.
for (int i = 0; i < fRecordedOps.count(); ++i) {
@@ -140,34 +140,34 @@ bool GrRenderTargetOpList::executeOps(GrOpFlushState* flushState) {
if (0 == fRecordedOps.count()) {
return false;
}
- // Draw all the generated geometry.
- const GrRenderTarget* currentRenderTarget = fRecordedOps[0].fRenderTarget.get();
+
+#ifdef SK_DEBUG
+ GrSurface* target = fTarget->instantiate(flushState->resourceProvider());
+ if (!target) {
+ return false;
+ }
+ const GrRenderTarget* currentRenderTarget = target->asRenderTarget();
SkASSERT(currentRenderTarget);
- std::unique_ptr<GrGpuCommandBuffer> commandBuffer;
+#endif
+ std::unique_ptr<GrGpuCommandBuffer> commandBuffer = create_command_buffer(fGpu);
+ flushState->setCommandBuffer(commandBuffer.get());
+
+ // Draw all the generated geometry.
for (int i = 0; i < fRecordedOps.count(); ++i) {
if (!fRecordedOps[i].fOp) {
continue;
}
- SkASSERT(fRecordedOps[i].fRenderTarget.get());
+ SkASSERT(fRecordedOps[i].fRenderTarget.get() == currentRenderTarget);
if (fRecordedOps[i].fOp->needsCommandBufferIsolation()) {
// This op is a special snowflake and must occur between command buffers
// TODO: make this go through the command buffer
finish_command_buffer(commandBuffer.get());
- currentRenderTarget = fRecordedOps[i].fRenderTarget.get();
commandBuffer.reset();
flushState->setCommandBuffer(commandBuffer.get());
- } else if (fRecordedOps[i].fRenderTarget.get() != currentRenderTarget) {
- // Changing renderTarget
- // MDB TODO: this code path goes away
- finish_command_buffer(commandBuffer.get());
- currentRenderTarget = fRecordedOps[i].fRenderTarget.get();
-
- commandBuffer = create_command_buffer(fGpu);
- flushState->setCommandBuffer(commandBuffer.get());
} else if (!commandBuffer) {
commandBuffer = create_command_buffer(fGpu);
flushState->setCommandBuffer(commandBuffer.get());
@@ -255,6 +255,7 @@ void GrRenderTargetOpList::fullClear(GrRenderTargetContext* renderTargetContext,
////////////////////////////////////////////////////////////////////////////////
+// MDB TODO: fuse with GrTextureOpList::copySurface
bool GrRenderTargetOpList::copySurface(GrResourceProvider* resourceProvider,
GrRenderTargetContext* dst,
GrSurfaceProxy* src,
@@ -311,6 +312,13 @@ GrOp* GrRenderTargetOpList::recordOp(std::unique_ptr<GrOp> op,
return nullptr;
}
+#ifdef SK_DEBUG
+ if (!fRecordedOps.empty()) {
+ GrRenderTargetOpList::RecordedOp& back = fRecordedOps.back();
+ SkASSERT(back.fRenderTarget == renderTarget);
+ }
+#endif
+
// A closed GrOpList should never receive new/more ops
SkASSERT(!this->isClosed());
@@ -410,7 +418,7 @@ void GrRenderTargetOpList::forwardCombine() {
fRecordedOps[j].fOp = std::move(fRecordedOps[i].fOp);
break;
}
- // Stop going traversing if we would cause a painter's order violation.
+ // Stop traversing if we would cause a painter's order violation.
if (!can_reorder(fRecordedOps[j].fOp->bounds(), op->bounds())) {
GrOP_INFO("\t\tForward: Intersects with (%s, opID: %u)\n", candidate.fOp->name(),
candidate.fOp->uniqueID());
diff --git a/src/gpu/GrSurfaceProxy.cpp b/src/gpu/GrSurfaceProxy.cpp
index f2a90ebab6..e833ecad18 100644
--- a/src/gpu/GrSurfaceProxy.cpp
+++ b/src/gpu/GrSurfaceProxy.cpp
@@ -32,10 +32,9 @@ GrSurfaceProxy::GrSurfaceProxy(sk_sp<GrSurface> surface, SkBackingFit fit)
}
GrSurfaceProxy::~GrSurfaceProxy() {
- if (fLastOpList) {
- fLastOpList->clearTarget();
- }
- SkSafeUnref(fLastOpList);
+ // For this to be deleted the opList that held a ref on it (if there was one) must have been
+ // deleted. Which would have cleared out this back pointer.
+ SkASSERT(!fLastOpList);
}
GrSurface* GrSurfaceProxy::instantiate(GrResourceProvider* resourceProvider) {
@@ -97,15 +96,14 @@ int GrSurfaceProxy::worstCaseHeight(const GrCaps& caps) const {
}
void GrSurfaceProxy::setLastOpList(GrOpList* opList) {
+#ifdef SK_DEBUG
if (fLastOpList) {
- // The non-MDB world never closes so we can't check this condition
-#ifdef ENABLE_MDB
SkASSERT(fLastOpList->isClosed());
-#endif
- fLastOpList->clearTarget();
}
+#endif
- SkRefCnt_SafeAssign(fLastOpList, opList);
+ // Un-reffed
+ fLastOpList = opList;
}
GrRenderTargetOpList* GrSurfaceProxy::getLastRenderTargetOpList() {
diff --git a/src/gpu/GrTextureContext.cpp b/src/gpu/GrTextureContext.cpp
index 68e94f9be3..f41fcd1837 100644
--- a/src/gpu/GrTextureContext.cpp
+++ b/src/gpu/GrTextureContext.cpp
@@ -68,32 +68,16 @@ GrTextureOpList* GrTextureContext::getOpList() {
return fOpList.get();
}
-// TODO: move this (and GrRenderTargetContext::copy) to GrSurfaceContext?
+// MDB TODO: move this (and GrRenderTargetContext::copy) to GrSurfaceContext?
bool GrTextureContext::onCopy(GrSurfaceProxy* srcProxy,
const SkIRect& srcRect,
const SkIPoint& dstPoint) {
ASSERT_SINGLE_OWNER
RETURN_FALSE_IF_ABANDONED
SkDEBUGCODE(this->validate();)
- GR_AUDIT_TRAIL_AUTO_FRAME(fAuditTrail, "GrTextureContext::copy");
+ GR_AUDIT_TRAIL_AUTO_FRAME(fAuditTrail, "GrTextureContext::onCopy");
-#ifndef ENABLE_MDB
- // We can't yet fully defer copies to textures, so GrTextureContext::copySurface will
- // execute the copy immediately. Ensure the data is ready.
- fContext->contextPriv().flushSurfaceWrites(srcProxy);
-#endif
-
- GrTextureOpList* opList = this->getOpList();
- bool result = opList->copySurface(fContext->resourceProvider(),
- fTextureProxy.get(), srcProxy, srcRect, dstPoint);
-
-#ifndef ENABLE_MDB
- GrOpFlushState flushState(fContext->getGpu(), nullptr);
- opList->prepareOps(&flushState);
- opList->executeOps(&flushState);
- opList->reset();
-#endif
-
- return result;
+ return this->getOpList()->copySurface(fContext->resourceProvider(),
+ fTextureProxy.get(), srcProxy, srcRect, dstPoint);
}
diff --git a/src/gpu/GrTextureOpList.cpp b/src/gpu/GrTextureOpList.cpp
index 689ea44783..de3cacb480 100644
--- a/src/gpu/GrTextureOpList.cpp
+++ b/src/gpu/GrTextureOpList.cpp
@@ -50,7 +50,7 @@ void GrTextureOpList::validateTargetsSingleRenderTarget() const {
#endif
void GrTextureOpList::prepareOps(GrOpFlushState* flushState) {
- // MDB TODO: add SkASSERT(this->isClosed());
+ SkASSERT(this->isClosed());
// Loop over the ops that haven't yet generated their geometry
for (int i = 0; i < fRecordedOps.count(); ++i) {
@@ -81,6 +81,7 @@ void GrTextureOpList::reset() {
////////////////////////////////////////////////////////////////////////////////
+// MDB TODO: fuse with GrRenderTargetOpList::copySurface
bool GrTextureOpList::copySurface(GrResourceProvider* resourceProvider,
GrSurfaceProxy* dst,
GrSurfaceProxy* src,