Dependencies are now added between the drawTargets in GrPipeline
This CL relies on https://codereview.chromium.org/1414773002/ (Add the machinery to GrDrawTarget to enable topological sorting)
BUG=skia:4094
Committed: https://skia.googlesource.com/skia/+/45a1c34f607a970933e5cd05e1df6cd8090db1be
Committed: https://skia.googlesource.com/skia/+/869c5e82a725a6928a45cd1fa6945ac783b8b3d8
Review URL: https://codereview.chromium.org/1414903002
diff --git a/src/gpu/GrDrawTarget.cpp b/src/gpu/GrDrawTarget.cpp
index 5a3fecc..7b1464c 100644
--- a/src/gpu/GrDrawTarget.cpp
+++ b/src/gpu/GrDrawTarget.cpp
@@ -32,7 +32,7 @@
////////////////////////////////////////////////////////////////////////////////
-GrDrawTarget::GrDrawTarget(GrGpu* gpu, GrResourceProvider* resourceProvider,
+GrDrawTarget::GrDrawTarget(GrRenderTarget* rt, GrGpu* gpu, GrResourceProvider* resourceProvider,
const Options& options)
: fGpu(SkRef(gpu))
, fResourceProvider(resourceProvider)
@@ -40,7 +40,8 @@
, fFlushing(false)
, fFirstUnpreparedBatch(0)
, fFlags(0)
- , fOptions(options) {
+ , fOptions(options)
+ , fRenderTarget(rt) {
// TODO: Stop extracting the context (currently needed by GrClipMaskManager)
fContext = fGpu->getContext();
fClipMaskManager.reset(new GrClipMaskManager(this));
@@ -52,6 +53,10 @@
}
GrDrawTarget::~GrDrawTarget() {
+ if (fRenderTarget && this == fRenderTarget->getLastDrawTarget()) {
+ fRenderTarget->setLastDrawTarget(nullptr);
+ }
+
fGpu->unref();
}
@@ -184,7 +189,7 @@
// drawTargets will be created to replace them if the SkGpuDevice(s) write to them again.
this->makeClosed();
- // Loop over all batches and generate geometry
+ // Loop over the batches that haven't yet generated their geometry
for (; fFirstUnpreparedBatch < fBatches.count(); ++fFirstUnpreparedBatch) {
fBatches[fFirstUnpreparedBatch]->prepare(&fFlushState);
}
@@ -227,6 +232,11 @@
return;
}
+#ifdef ENABLE_MDB
+ SkASSERT(fRenderTarget);
+ batch->pipeline()->addDependenciesTo(fRenderTarget);
+#endif
+
this->recordBatch(batch);
}
@@ -455,6 +465,10 @@
const SkIPoint& dstPoint) {
GrBatch* batch = GrCopySurfaceBatch::Create(dst, src, srcRect, dstPoint);
if (batch) {
+#ifdef ENABLE_MDB
+ this->addDependency(src);
+#endif
+
this->recordBatch(batch);
batch->unref();
}