diff options
author | 2017-03-16 14:19:07 -0400 | |
---|---|---|
committer | 2017-03-16 19:10:15 +0000 | |
commit | 2bf4b3a97b770811d9e0558dbbfbdb57cfafbdb7 (patch) | |
tree | 3e73ebe67a871db43e4ba9f0a9df3edf15361bca /src/gpu/GrRenderTargetOpList.cpp | |
parent | 1165b1ef6f069d512c6d5a43ef431b3be6f8c80f (diff) |
Remove GrPipeline from GrDrawOp.
GrDrawOp subclasses are now free to construct their pipelines at flush time and now in theory could use multiple GrPipelines for multipass rendering.
GrProcessorSet may be used to retain the processors from a GrPaint with "pending execution" style refs.
NVPR and Instanced rendering are updated to create their pipelines at flush time without a GrPipelineBuilder.
The monolithic pipeline creation/management that was on GrDrawOp is moved to GrMeshDrawOp. However, this is temporary and will be removed in coming changes.
Change-Id: I124282e3cea5d070970b5460c8a679fcaf7a8eff
Reviewed-on: https://skia-review.googlesource.com/7279
Commit-Queue: Brian Salomon <bsalomon@google.com>
Reviewed-by: Robert Phillips <robertphillips@google.com>
Diffstat (limited to 'src/gpu/GrRenderTargetOpList.cpp')
-rw-r--r-- | src/gpu/GrRenderTargetOpList.cpp | 71 |
1 files changed, 61 insertions, 10 deletions
diff --git a/src/gpu/GrRenderTargetOpList.cpp b/src/gpu/GrRenderTargetOpList.cpp index 1c9835389e..1a9452f724 100644 --- a/src/gpu/GrRenderTargetOpList.cpp +++ b/src/gpu/GrRenderTargetOpList.cpp @@ -30,10 +30,12 @@ static const int kDefaultMaxOpLookahead = 10; GrRenderTargetOpList::GrRenderTargetOpList(GrRenderTargetProxy* rtp, GrGpu* gpu, GrResourceProvider* resourceProvider, GrAuditTrail* auditTrail, const Options& options) - : INHERITED(rtp, auditTrail) - , fGpu(SkRef(gpu)) - , fResourceProvider(resourceProvider) - , fLastClipStackGenID(SK_InvalidUniqueID) { + : INHERITED(rtp, auditTrail) + , fGpu(SkRef(gpu)) + , fResourceProvider(resourceProvider) + , fLastClipStackGenID(SK_InvalidUniqueID) + , fClipAllocator(fClipAllocatorStorage, sizeof(fClipAllocatorStorage), + sizeof(fClipAllocatorStorage)) { fMaxOpLookback = (options.fMaxOpCombineLookback < 0) ? kDefaultMaxOpLookback : options.fMaxOpCombineLookback; @@ -82,7 +84,17 @@ void GrRenderTargetOpList::prepareOps(GrOpFlushState* flushState) { // Loop over the ops that haven't yet been prepared. for (int i = 0; i < fRecordedOps.count(); ++i) { if (fRecordedOps[i].fOp) { + GrOpFlushState::DrawOpArgs opArgs; + if (fRecordedOps[i].fRenderTarget) { + opArgs = { + fRecordedOps[i].fRenderTarget.get(), + fRecordedOps[i].fAppliedClip, + fRecordedOps[i].fDstTexture + }; + } + flushState->setDrawOpArgs(&opArgs); fRecordedOps[i].fOp->prepare(flushState); + flushState->setDrawOpArgs(nullptr); } } @@ -122,7 +134,17 @@ bool GrRenderTargetOpList::executeOps(GrOpFlushState* flushState) { } flushState->setCommandBuffer(commandBuffer.get()); } + GrOpFlushState::DrawOpArgs opArgs; + if (fRecordedOps[i].fRenderTarget) { + opArgs = { + fRecordedOps[i].fRenderTarget.get(), + fRecordedOps[i].fAppliedClip, + fRecordedOps[i].fDstTexture + }; + flushState->setDrawOpArgs(&opArgs); + } fRecordedOps[i].fOp->execute(flushState); + flushState->setDrawOpArgs(nullptr); } if (commandBuffer) { commandBuffer->end(); @@ -213,8 +235,33 @@ static inline bool can_reorder(const SkRect& a, const SkRect& b) { b.fRight <= a.fLeft || b.fBottom <= a.fTop; } +bool GrRenderTargetOpList::combineIfPossible(const RecordedOp& a, GrOp* b, + const GrAppliedClip* bClip, + const DstTexture* bDstTexture) { + if (a.fAppliedClip) { + if (!bClip) { + return false; + } + if (*a.fAppliedClip != *bClip) { + return false; + } + } else if (bClip) { + return false; + } + if (bDstTexture) { + if (a.fDstTexture != *bDstTexture) { + return false; + } + } else if (a.fDstTexture.texture()) { + return false; + } + return a.fOp->combineIfPossible(b, *this->caps()); +} + GrOp* GrRenderTargetOpList::recordOp(std::unique_ptr<GrOp> op, - GrRenderTargetContext* renderTargetContext) { + GrRenderTargetContext* renderTargetContext, + GrAppliedClip* clip, + const DstTexture* dstTexture) { GrRenderTarget* renderTarget = renderTargetContext ? renderTargetContext->accessRenderTarget() : nullptr; @@ -249,7 +296,7 @@ GrOp* GrRenderTargetOpList::recordOp(std::unique_ptr<GrOp> op, candidate.fOp->uniqueID()); break; } - if (candidate.fOp->combineIfPossible(op.get(), *this->caps())) { + if (this->combineIfPossible(candidate, op.get(), clip, dstTexture)) { GrOP_INFO("\t\tCombining with (%s, B%u)\n", candidate.fOp->name(), candidate.fOp->uniqueID()); GrOP_INFO("\t\t\tCombined op info:\n"); @@ -273,7 +320,10 @@ GrOp* GrRenderTargetOpList::recordOp(std::unique_ptr<GrOp> op, GrOP_INFO("\t\tFirstOp\n"); } GR_AUDIT_TRAIL_OP_RESULT_NEW(fAuditTrail, op); - fRecordedOps.emplace_back(std::move(op), renderTarget); + if (clip) { + clip = fClipAllocator.make<GrAppliedClip>(std::move(*clip)); + } + fRecordedOps.emplace_back(std::move(op), renderTarget, clip, dstTexture); fRecordedOps.back().fOp->wasRecorded(); fLastFullClearOp = nullptr; fLastFullClearRenderTargetID.makeInvalid(); @@ -306,9 +356,10 @@ void GrRenderTargetOpList::forwardCombine() { // via backwards combining in recordOp. // not sure why this fires with device-clipping in gm/complexclip4.cpp -// SkASSERT(!op->combineIfPossible(candidate.fOp.get(), *this->caps())); - - } else if (op->combineIfPossible(candidate.fOp.get(), *this->caps())) { + SkASSERT(!this->combineIfPossible(fRecordedOps[i], candidate.fOp.get(), + candidate.fAppliedClip, &candidate.fDstTexture)); + } else if (this->combineIfPossible(fRecordedOps[i], candidate.fOp.get(), + candidate.fAppliedClip, &candidate.fDstTexture)) { GrOP_INFO("\t\tCombining with (%s, B%u)\n", candidate.fOp->name(), candidate.fOp->uniqueID()); GR_AUDIT_TRAIL_OPS_RESULT_COMBINED(fAuditTrail, op, candidate.fOp.get()); |