aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/gpu/GrRenderTargetOpList.cpp
diff options
context:
space:
mode:
authorGravatar Robert Phillips <robertphillips@google.com>2017-08-30 07:41:07 -0400
committerGravatar Skia Commit-Bot <skia-commit-bot@chromium.org>2017-08-30 11:45:42 +0000
commit380b90c92bead0c1b869df08b2d2790c302c5c71 (patch)
tree06e2a81cbb53e417c5e483b24537a36d77cb33ce /src/gpu/GrRenderTargetOpList.cpp
parentfb4a20c7f54110d6c43dee4b78801c163ad6c8f3 (diff)
Push full screen clears up to OpList
Change-Id: Icfc09b3b25f4d3834bee93286e2b24a559f44ed8 Reviewed-on: https://skia-review.googlesource.com/40120 Commit-Queue: Robert Phillips <robertphillips@google.com> Reviewed-by: Greg Daniel <egdaniel@google.com>
Diffstat (limited to 'src/gpu/GrRenderTargetOpList.cpp')
-rw-r--r--src/gpu/GrRenderTargetOpList.cpp52
1 files changed, 27 insertions, 25 deletions
diff --git a/src/gpu/GrRenderTargetOpList.cpp b/src/gpu/GrRenderTargetOpList.cpp
index ce34be7495..77b6eca3bc 100644
--- a/src/gpu/GrRenderTargetOpList.cpp
+++ b/src/gpu/GrRenderTargetOpList.cpp
@@ -133,7 +133,7 @@ static inline void finish_command_buffer(GrGpuRTCommandBuffer* buffer) {
// is at flush time). However, we need to store the RenderTargetProxy in the
// Ops and instantiate them here.
bool GrRenderTargetOpList::onExecute(GrOpFlushState* flushState) {
- if (0 == fRecordedOps.count()) {
+ if (0 == fRecordedOps.count() && GrLoadOp::kClear != fColorLoadOp) {
return false;
}
@@ -180,7 +180,6 @@ bool GrRenderTargetOpList::onExecute(GrOpFlushState* flushState) {
}
void GrRenderTargetOpList::reset() {
- fLastFullClearOp = nullptr;
fLastClipStackGenID = SK_InvalidUniqueID;
fRecordedOps.reset();
if (fInstancedRendering) {
@@ -203,30 +202,35 @@ void GrRenderTargetOpList::freeGpuResources() {
}
}
+void GrRenderTargetOpList::discard() {
+ // Discard calls to in-progress opLists are ignored. Calls at the start update the
+ // opLists' color & stencil load ops.
+ if (this->isEmpty()) {
+ fColorLoadOp = GrLoadOp::kDiscard;
+ fStencilLoadOp = GrLoadOp::kDiscard;
+ }
+}
+
void GrRenderTargetOpList::fullClear(const GrCaps& caps, GrColor color) {
- // Currently this just inserts or updates the last clear op. However, once in MDB this can
- // remove all the previously recorded ops and change the load op to clear with supplied
- // color.
- if (fLastFullClearOp) {
- // As currently implemented, fLastFullClearOp should be the last op because we would
- // have cleared it when another op was recorded.
- SkASSERT(fRecordedOps.back().fOp.get() == fLastFullClearOp);
- GrOP_INFO("opList: %d Fusing clears (opID: %d Color: 0x%08x -> 0x%08x)\n",
- this->uniqueID(),
- fLastFullClearOp->uniqueID(),
- fLastFullClearOp->color(), color);
- fLastFullClearOp->setColor(color);
+
+ // This is conservative. If the opList is marked as needing a stencil buffer then there
+ // may be a prior op that writes to the stencil buffer. Although the clear will ignore the
+ // stencil buffer, following draw ops may not so we can't get rid of all the preceding ops.
+ // Beware! If we ever add any ops that have a side effect beyond modifying the stencil
+ // buffer we will need a more elaborate tracking system (skbug.com/7002).
+ if (this->isEmpty() || !fTarget.get()->asRenderTargetProxy()->needsStencil()) {
+ fRecordedOps.reset();
+ fColorLoadOp = GrLoadOp::kClear;
+ fLoadClearColor = color;
return;
}
+
std::unique_ptr<GrClearOp> op(GrClearOp::Make(GrFixedClip::Disabled(), color, fTarget.get()));
if (!op) {
return;
}
- if (GrOp* clearOp = this->recordOp(std::move(op), caps)) {
- // This is either the clear op we just created or another one that it combined with.
- fLastFullClearOp = static_cast<GrClearOp*>(clearOp);
- }
+ this->recordOp(std::move(op), caps);
}
////////////////////////////////////////////////////////////////////////////////
@@ -277,10 +281,10 @@ bool GrRenderTargetOpList::combineIfPossible(const RecordedOp& a, GrOp* b,
return a.fOp->combineIfPossible(b, caps);
}
-GrOp* GrRenderTargetOpList::recordOp(std::unique_ptr<GrOp> op,
- const GrCaps& caps,
- GrAppliedClip* clip,
- const DstProxy* dstProxy) {
+void GrRenderTargetOpList::recordOp(std::unique_ptr<GrOp> op,
+ const GrCaps& caps,
+ GrAppliedClip* clip,
+ const DstProxy* dstProxy) {
SkASSERT(fTarget.get());
// A closed GrOpList should never receive new/more ops
@@ -313,7 +317,7 @@ GrOp* GrRenderTargetOpList::recordOp(std::unique_ptr<GrOp> op,
GrOP_INFO("\t\t\tBackward: Combined op info:\n");
GrOP_INFO(SkTabString(candidate.fOp->dumpInfo(), 4).c_str());
GR_AUDIT_TRAIL_OPS_RESULT_COMBINED(fAuditTrail, candidate.fOp.get(), op.get());
- return candidate.fOp.get();
+ return;
}
// Stop going backwards if we would cause a painter's order violation.
if (!can_reorder(fRecordedOps.fromBack(i).fOp->bounds(), op->bounds())) {
@@ -337,8 +341,6 @@ GrOp* GrRenderTargetOpList::recordOp(std::unique_ptr<GrOp> op,
}
fRecordedOps.emplace_back(std::move(op), clip, dstProxy);
fRecordedOps.back().fOp->wasRecorded(this);
- fLastFullClearOp = nullptr;
- return fRecordedOps.back().fOp.get();
}
void GrRenderTargetOpList::forwardCombine(const GrCaps& caps) {