aboutsummaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorGravatar Robert Phillips <robertphillips@google.com>2017-04-26 11:53:10 -0400
committerGravatar Skia Commit-Bot <skia-commit-bot@chromium.org>2017-04-26 16:29:08 +0000
commitee683655a9a9d57487ab8d4b0b01bb9bc2def144 (patch)
tree7e08cd03f4f5476a547b9809aa72dac27930517c
parentdeca5c3af6f15211b7eb3772aa5cb203f2c3e053 (diff)
Remove GrResourceProvider & GrGpu pointers from GrRenderTargetOpList
Additional shrinking of GrRenderTargetOpList since there will soon be more of them. Change-Id: Ib3e68fdf3462838baf7a5a2644e418be066cf79c Reviewed-on: https://skia-review.googlesource.com/14363 Reviewed-by: Brian Salomon <bsalomon@google.com> Commit-Queue: Robert Phillips <robertphillips@google.com>
-rw-r--r--src/gpu/GrDrawingManager.cpp6
-rw-r--r--src/gpu/GrOpList.cpp4
-rw-r--r--src/gpu/GrOpList.h5
-rw-r--r--src/gpu/GrPreFlushResourceProvider.cpp2
-rw-r--r--src/gpu/GrRenderTargetOpList.cpp37
-rw-r--r--src/gpu/GrRenderTargetOpList.h20
-rw-r--r--src/gpu/instanced/InstancedOp.cpp2
7 files changed, 32 insertions, 44 deletions
diff --git a/src/gpu/GrDrawingManager.cpp b/src/gpu/GrDrawingManager.cpp
index 2258c9e120..9cc584527a 100644
--- a/src/gpu/GrDrawingManager.cpp
+++ b/src/gpu/GrDrawingManager.cpp
@@ -25,7 +25,8 @@
void GrDrawingManager::cleanup() {
for (int i = 0; i < fOpLists.count(); ++i) {
- fOpLists[i]->makeClosed(); // no opList should receive a new command after this
+ // no opList should receive a new command after this
+ fOpLists[i]->makeClosed(*fContext->caps());
fOpLists[i]->clearTarget();
// We shouldn't need to do this, but it turns out some clients still hold onto opLists
@@ -91,7 +92,7 @@ void GrDrawingManager::internalFlush(GrSurfaceProxy*, GrResourceCache::FlushType
// needs to flush mid-draw. In that case, the SkGpuDevice's GrOpLists won't be closed
// 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();
+ fOpLists[i]->makeClosed(*fContext->caps());
}
#ifdef ENABLE_MDB
@@ -223,7 +224,6 @@ sk_sp<GrRenderTargetOpList> GrDrawingManager::newRTOpList(sk_sp<GrRenderTargetPr
sk_sp<GrRenderTargetOpList> opList(new GrRenderTargetOpList(rtp,
fContext->getGpu(),
- fContext->resourceProvider(),
fContext->getAuditTrail()));
SkASSERT(rtp->getLastOpList() == opList.get());
diff --git a/src/gpu/GrOpList.cpp b/src/gpu/GrOpList.cpp
index 91c8c7942c..3781213136 100644
--- a/src/gpu/GrOpList.cpp
+++ b/src/gpu/GrOpList.cpp
@@ -48,7 +48,7 @@ void GrOpList::addDependency(GrOpList* dependedOn) {
}
// Convert from a GrSurface-based dependency to a GrOpList one
-void GrOpList::addDependency(GrSurfaceProxy* dependedOn) {
+void GrOpList::addDependency(GrSurfaceProxy* dependedOn, const GrCaps& caps) {
if (dependedOn->getLastOpList()) {
// If it is still receiving dependencies, this GrOpList shouldn't be closed
SkASSERT(!this->isClosed());
@@ -60,7 +60,7 @@ void GrOpList::addDependency(GrSurfaceProxy* dependedOn) {
this->addDependency(opList);
// Can't make it closed in the self-read case
- opList->makeClosed();
+ opList->makeClosed(caps);
}
}
}
diff --git a/src/gpu/GrOpList.h b/src/gpu/GrOpList.h
index b7dd7fa62f..b354abed76 100644
--- a/src/gpu/GrOpList.h
+++ b/src/gpu/GrOpList.h
@@ -14,6 +14,7 @@
//#define ENABLE_MDB 1
class GrAuditTrail;
+class GrCaps;
class GrOpFlushState;
class GrRenderTargetOpList;
class GrSurfaceProxy;
@@ -28,7 +29,7 @@ public:
virtual void prepareOps(GrOpFlushState* flushState) = 0;
virtual bool executeOps(GrOpFlushState* flushState) = 0;
- virtual void makeClosed() {
+ virtual void makeClosed(const GrCaps&) {
// 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
@@ -53,7 +54,7 @@ public:
/*
* Notify this GrOpList that it relies on the contents of 'dependedOn'
*/
- void addDependency(GrSurfaceProxy* dependedOn);
+ void addDependency(GrSurfaceProxy* dependedOn, const GrCaps& caps);
/*
* Does this opList depend on 'dependedOn'?
diff --git a/src/gpu/GrPreFlushResourceProvider.cpp b/src/gpu/GrPreFlushResourceProvider.cpp
index 01d948a3b0..43037be3ab 100644
--- a/src/gpu/GrPreFlushResourceProvider.cpp
+++ b/src/gpu/GrPreFlushResourceProvider.cpp
@@ -35,7 +35,6 @@ sk_sp<GrRenderTargetContext> GrPreFlushResourceProvider::makeRenderTargetContext
sk_sp<GrRenderTargetOpList> opList(new GrRenderTargetOpList(
sk_ref_sp(proxy->asRenderTargetProxy()),
fDrawingMgr->fContext->getGpu(),
- fDrawingMgr->fContext->resourceProvider(),
fDrawingMgr->fContext->getAuditTrail()));
proxy->setLastOpList(opList.get());
@@ -64,7 +63,6 @@ sk_sp<GrRenderTargetContext> GrPreFlushResourceProvider::makeRenderTargetContext
sk_sp<GrRenderTargetOpList> opList(new GrRenderTargetOpList(
sk_ref_sp(proxy->asRenderTargetProxy()),
fDrawingMgr->fContext->getGpu(),
- fDrawingMgr->fContext->resourceProvider(),
fDrawingMgr->fContext->getAuditTrail()));
proxy->setLastOpList(opList.get());
diff --git a/src/gpu/GrRenderTargetOpList.cpp b/src/gpu/GrRenderTargetOpList.cpp
index a7e109d5e8..3abc21c131 100644
--- a/src/gpu/GrRenderTargetOpList.cpp
+++ b/src/gpu/GrRenderTargetOpList.cpp
@@ -26,21 +26,17 @@ static const int kMaxOpLookback = 10;
static const int kMaxOpLookahead = 10;
GrRenderTargetOpList::GrRenderTargetOpList(sk_sp<GrRenderTargetProxy> proxy, GrGpu* gpu,
- GrResourceProvider* resourceProvider,
GrAuditTrail* auditTrail)
: INHERITED(std::move(proxy), auditTrail)
- , fGpu(SkRef(gpu))
- , fResourceProvider(resourceProvider)
, fLastClipStackGenID(SK_InvalidUniqueID)
, fClipAllocator(fClipAllocatorStorage, sizeof(fClipAllocatorStorage),
sizeof(fClipAllocatorStorage)) {
- if (GrCaps::InstancedSupport::kNone != this->caps()->instancedSupport()) {
- fInstancedRendering.reset(fGpu->createInstancedRendering());
+ if (GrCaps::InstancedSupport::kNone != gpu->caps()->instancedSupport()) {
+ fInstancedRendering.reset(gpu->createInstancedRendering());
}
}
GrRenderTargetOpList::~GrRenderTargetOpList() {
- fGpu->unref();
}
////////////////////////////////////////////////////////////////////////////////
@@ -161,10 +157,10 @@ bool GrRenderTargetOpList::executeOps(GrOpFlushState* flushState) {
finish_command_buffer(commandBuffer.get());
currentRenderTarget = fRecordedOps[i].fRenderTarget.get();
- commandBuffer = create_command_buffer(fGpu);
+ commandBuffer = create_command_buffer(flushState->gpu());
flushState->setCommandBuffer(commandBuffer.get());
} else if (!commandBuffer) {
- commandBuffer = create_command_buffer(fGpu);
+ commandBuffer = create_command_buffer(flushState->gpu());
flushState->setCommandBuffer(commandBuffer.get());
}
@@ -182,7 +178,7 @@ bool GrRenderTargetOpList::executeOps(GrOpFlushState* flushState) {
finish_command_buffer(commandBuffer.get());
flushState->setCommandBuffer(nullptr);
- fGpu->finishOpList();
+ flushState->gpu()->finishOpList();
return true;
}
@@ -197,16 +193,14 @@ void GrRenderTargetOpList::reset() {
}
void GrRenderTargetOpList::abandonGpuResources() {
- if (GrCaps::InstancedSupport::kNone != this->caps()->instancedSupport()) {
- InstancedRendering* ir = this->instancedRendering();
- ir->resetGpuResources(InstancedRendering::ResetType::kAbandon);
+ if (fInstancedRendering) {
+ fInstancedRendering->resetGpuResources(InstancedRendering::ResetType::kAbandon);
}
}
void GrRenderTargetOpList::freeGpuResources() {
- if (GrCaps::InstancedSupport::kNone != this->caps()->instancedSupport()) {
- InstancedRendering* ir = this->instancedRendering();
- ir->resetGpuResources(InstancedRendering::ResetType::kDestroy);
+ if (fInstancedRendering) {
+ fInstancedRendering->resetGpuResources(InstancedRendering::ResetType::kDestroy);
}
}
@@ -278,7 +272,8 @@ static inline bool can_reorder(const SkRect& a, const SkRect& b) {
bool GrRenderTargetOpList::combineIfPossible(const RecordedOp& a, GrOp* b,
const GrAppliedClip* bClip,
- const DstTexture* bDstTexture) {
+ const DstTexture* bDstTexture,
+ const GrCaps& caps) {
if (a.fAppliedClip) {
if (!bClip) {
return false;
@@ -296,7 +291,7 @@ bool GrRenderTargetOpList::combineIfPossible(const RecordedOp& a, GrOp* b,
} else if (a.fDstTexture.texture()) {
return false;
}
- return a.fOp->combineIfPossible(b, *this->caps());
+ return a.fOp->combineIfPossible(b, caps);
}
GrOp* GrRenderTargetOpList::recordOp(std::unique_ptr<GrOp> op,
@@ -309,6 +304,8 @@ GrOp* GrRenderTargetOpList::recordOp(std::unique_ptr<GrOp> op,
return nullptr;
}
+ const GrCaps* caps = renderTargetContext->caps();
+
// A closed GrOpList should never receive new/more ops
SkASSERT(!this->isClosed());
@@ -340,7 +337,7 @@ GrOp* GrRenderTargetOpList::recordOp(std::unique_ptr<GrOp> op,
candidate.fOp->uniqueID());
break;
}
- if (this->combineIfPossible(candidate, op.get(), clip, dstTexture)) {
+ if (this->combineIfPossible(candidate, op.get(), clip, dstTexture, *caps)) {
GrOP_INFO("\t\tBackward: Combining with (%s, opID: %u)\n", candidate.fOp->name(),
candidate.fOp->uniqueID());
GrOP_INFO("\t\t\tBackward: Combined op info:\n");
@@ -375,7 +372,7 @@ GrOp* GrRenderTargetOpList::recordOp(std::unique_ptr<GrOp> op,
return fRecordedOps.back().fOp.get();
}
-void GrRenderTargetOpList::forwardCombine() {
+void GrRenderTargetOpList::forwardCombine(const GrCaps& caps) {
SkASSERT(!this->isClosed());
for (int i = 0; i < fRecordedOps.count() - 1; ++i) {
@@ -398,7 +395,7 @@ void GrRenderTargetOpList::forwardCombine() {
break;
}
if (this->combineIfPossible(fRecordedOps[i], candidate.fOp.get(),
- candidate.fAppliedClip, &candidate.fDstTexture)) {
+ candidate.fAppliedClip, &candidate.fDstTexture, caps)) {
GrOP_INFO("\t\tForward: Combining with (%s, opID: %u)\n", candidate.fOp->name(),
candidate.fOp->uniqueID());
GR_AUDIT_TRAIL_OPS_RESULT_COMBINED(fAuditTrail, op, candidate.fOp.get());
diff --git a/src/gpu/GrRenderTargetOpList.h b/src/gpu/GrRenderTargetOpList.h
index 88bb6fdf85..4b3f0d0659 100644
--- a/src/gpu/GrRenderTargetOpList.h
+++ b/src/gpu/GrRenderTargetOpList.h
@@ -33,19 +33,19 @@ private:
using DstTexture = GrXferProcessor::DstTexture;
public:
- GrRenderTargetOpList(sk_sp<GrRenderTargetProxy>, GrGpu*, GrResourceProvider*, GrAuditTrail*);
+ GrRenderTargetOpList(sk_sp<GrRenderTargetProxy>, GrGpu*, GrAuditTrail*);
~GrRenderTargetOpList() override;
- void makeClosed() override {
+ void makeClosed(const GrCaps& caps) override {
if (this->isClosed()) {
return;
}
fLastFullClearOp = nullptr;
- this->forwardCombine();
+ this->forwardCombine(caps);
- INHERITED::makeClosed();
+ INHERITED::makeClosed(caps);
}
bool isEmpty() const { return fRecordedOps.empty(); }
@@ -65,11 +65,6 @@ public:
void prepareOps(GrOpFlushState* flushState) override;
bool executeOps(GrOpFlushState* flushState) override;
- /**
- * Gets the capabilities of the draw target.
- */
- const GrCaps* caps() const { return fGpu->caps(); }
-
uint32_t addOp(std::unique_ptr<GrOp> op, GrRenderTargetContext* renderTargetContext) {
this->recordOp(std::move(op), renderTargetContext, nullptr, nullptr);
return this->uniqueID();
@@ -138,19 +133,16 @@ private:
GrOp* recordOp(std::unique_ptr<GrOp>, GrRenderTargetContext*, GrAppliedClip* = nullptr,
const DstTexture* = nullptr);
- void forwardCombine();
+ void forwardCombine(const GrCaps&);
// If this returns true then b has been merged into a's op.
bool combineIfPossible(const RecordedOp& a, GrOp* b, const GrAppliedClip* bClip,
- const DstTexture* bDstTexture);
+ const DstTexture* bDstTexture, const GrCaps&);
GrClearOp* fLastFullClearOp = nullptr;
GrGpuResource::UniqueID fLastFullClearResourceID = GrGpuResource::UniqueID::InvalidID();
GrSurfaceProxy::UniqueID fLastFullClearProxyID = GrSurfaceProxy::UniqueID::InvalidID();
- GrGpu* fGpu;
- GrResourceProvider* fResourceProvider;
-
std::unique_ptr<gr_instanced::InstancedRendering> fInstancedRendering;
int32_t fLastClipStackGenID;
diff --git a/src/gpu/instanced/InstancedOp.cpp b/src/gpu/instanced/InstancedOp.cpp
index 58807212f1..1ebb0b5a49 100644
--- a/src/gpu/instanced/InstancedOp.cpp
+++ b/src/gpu/instanced/InstancedOp.cpp
@@ -163,7 +163,7 @@ void InstancedOp::wasRecorded(GrRenderTargetOpList* opList) {
fIsTracked = true;
}
-bool InstancedOp::onCombineIfPossible(GrOp* other, const GrCaps& caps) {
+bool InstancedOp::onCombineIfPossible(GrOp* other, const GrCaps&) {
InstancedOp* that = static_cast<InstancedOp*>(other);
SkASSERT(!that->fInstancedRendering || (fInstancedRendering == that->fInstancedRendering));
SkASSERT(fTailDraw);