Split cleanup changes out of bigger CL

This are split out of: https://skia-review.googlesource.com/c/11581/ (Split up opLists)

TBR=bsalomon@google.com

Change-Id: I1239e806a30a93d3c17ad933f118b98a5077dd3a
Reviewed-on: https://skia-review.googlesource.com/13585
Commit-Queue: Robert Phillips <robertphillips@google.com>
Reviewed-by: Greg Daniel <egdaniel@google.com>
This commit is contained in:
Robert Phillips 2017-04-17 12:47:15 -04:00 committed by Skia Commit-Bot
parent b3821730e1
commit cd11c809f2
18 changed files with 67 additions and 74 deletions

View File

@ -216,13 +216,7 @@ public:
*/
TextureSampler();
TextureSampler(GrTexture*, const GrSamplerParams&);
explicit TextureSampler(GrTexture*,
GrSamplerParams::FilterMode = GrSamplerParams::kNone_FilterMode,
SkShader::TileMode tileXAndY = SkShader::kClamp_TileMode,
GrShaderFlags visibility = kFragment_GrShaderFlag);
void reset(GrTexture*, const GrSamplerParams&,
GrShaderFlags visibility = kFragment_GrShaderFlag);
// MDB TODO: this is the last GrTexture-based reset call!
void reset(GrTexture*,
GrSamplerParams::FilterMode = GrSamplerParams::kNone_FilterMode,
SkShader::TileMode tileXAndY = SkShader::kClamp_TileMode,

View File

@ -284,7 +284,7 @@ public:
GrTextureOpList* getLastTextureOpList();
/**
* Retrieves the amount of GPU memory that will be or currently is used by this resource
* Retrieves the amount of GPU memory that will be or currently is used by this resource
* in bytes. It is approximate since we aren't aware of additional padding or copies made
* by the driver.
*

View File

@ -31,7 +31,6 @@ void GrDrawingManager::cleanup() {
// We shouldn't need to do this, but it turns out some clients still hold onto opLists
// after a cleanup
fOpLists[i]->reset();
fOpLists[i]->unref();
}
fOpLists.reset();
@ -86,9 +85,11 @@ void GrDrawingManager::internalFlush(GrSurfaceProxy*, GrResourceCache::FlushType
fOpLists[i]->makeClosed();
}
#ifdef ENABLE_MDB
SkDEBUGCODE(bool result =)
SkTTopoSort<GrOpList, GrOpList::TopoSortTraits>(&fOpLists);
SkASSERT(result);
#endif
GrPreFlushResourceProvider preFlushProvider(this);
@ -148,9 +149,6 @@ void GrDrawingManager::internalFlush(GrSurfaceProxy*, GrResourceCache::FlushType
for (int i = 0; i < fOpLists.count(); ++i) {
fOpLists[i]->reset();
#ifdef ENABLE_MDB
fOpLists[i]->unref();
#endif
}
#ifndef ENABLE_MDB
@ -206,25 +204,24 @@ sk_sp<GrRenderTargetOpList> GrDrawingManager::newRTOpList(sk_sp<GrRenderTargetPr
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]);
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]);
return sk_ref_sp((GrRenderTargetOpList*) fOpLists[0].get());
}
#endif
GrRenderTargetOpList* opList = new GrRenderTargetOpList(rtp,
fContext->getGpu(),
fContext->resourceProvider(),
fContext->getAuditTrail(),
fOptionsForOpLists);
SkASSERT(rtp->getLastOpList() == opList);
sk_sp<GrRenderTargetOpList> opList(new GrRenderTargetOpList(rtp,
fContext->getGpu(),
fContext->resourceProvider(),
fContext->getAuditTrail(),
fOptionsForOpLists));
SkASSERT(rtp->getLastOpList() == opList.get());
*fOpLists.append() = opList;
fOpLists.push_back() = opList;
// DrawingManager gets the creation ref - this ref is for the caller
return sk_ref_sp(opList);
return opList;
}
sk_sp<GrTextureOpList> GrDrawingManager::newTextureOpList(sk_sp<GrTextureProxy> textureProxy) {

View File

@ -111,7 +111,7 @@ private:
GrSingleOwner* fSingleOwner;
bool fAbandoned;
SkTDArray<GrOpList*> fOpLists;
SkTArray<sk_sp<GrOpList>> fOpLists;
std::unique_ptr<GrAtlasTextContext> fAtlasTextContext;

View File

@ -26,7 +26,7 @@ class SkColorSpace;
class SkSurfaceProps;
/*
* This is the base class from which all per-flush callback objects must be derived. It
* This is the base class from which all pre-flush callback objects must be derived. It
* provides the "preFlush" interface.
*/
class GrPreFlushCallbackObject : public GrNonAtomicRef<GrPreFlushCallbackObject> {

View File

@ -204,18 +204,6 @@ bool GrResourceIOProcessor::hasSameSamplersAndAccesses(const GrResourceIOProcess
GrResourceIOProcessor::TextureSampler::TextureSampler() {}
GrResourceIOProcessor::TextureSampler::TextureSampler(GrTexture* texture,
const GrSamplerParams& params) {
this->reset(texture, params);
}
GrResourceIOProcessor::TextureSampler::TextureSampler(GrTexture* texture,
GrSamplerParams::FilterMode filterMode,
SkShader::TileMode tileXAndY,
GrShaderFlags visibility) {
this->reset(texture, filterMode, tileXAndY, visibility);
}
GrResourceIOProcessor::TextureSampler::TextureSampler(GrResourceProvider* resourceProvider,
sk_sp<GrTextureProxy> proxy,
const GrSamplerParams& params) {
@ -230,16 +218,7 @@ GrResourceIOProcessor::TextureSampler::TextureSampler(GrResourceProvider* resour
this->reset(resourceProvider, std::move(proxy), filterMode, tileXAndY, visibility);
}
void GrResourceIOProcessor::TextureSampler::reset(GrTexture* texture,
const GrSamplerParams& params,
GrShaderFlags visibility) {
SkASSERT(texture);
fTexture.set(SkRef(texture), kRead_GrIOType);
fParams = params;
fParams.setFilterMode(SkTMin(params.filterMode(), texture->texturePriv().highestFilterMode()));
fVisibility = visibility;
}
// MDB TODO: remove this!
void GrResourceIOProcessor::TextureSampler::reset(GrTexture* texture,
GrSamplerParams::FilterMode filterMode,
SkShader::TileMode tileXAndY,

View File

@ -1675,7 +1675,10 @@ uint32_t GrRenderTargetContext::addLegacyMeshDrawOp(GrPipelineBuilder&& pipeline
}
}
op->initPipeline(args, analysis, overrideColor);
// TODO: We need to add pipeline dependencies on textures, etc before recording this op.
// Add the pipeline dependencies on textures, etc before recording this op.
op->addDependenciesTo(fRenderTargetProxy.get());
op->setClippedBounds(bounds);
return this->getOpList()->addOp(std::move(op), this);
}

View File

@ -233,6 +233,10 @@ void GrRenderTargetOpList::fullClear(GrRenderTargetContext* renderTargetContext,
// 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);
return;
}
@ -316,15 +320,14 @@ GrOp* GrRenderTargetOpList::recordOp(std::unique_ptr<GrOp> op,
// 3) find a 'blocker'
GR_AUDIT_TRAIL_ADD_OP(fAuditTrail, op.get(), renderTarget->uniqueID(),
renderTargetContext->asRenderTargetProxy()->uniqueID());
GrOP_INFO("Recording (%s, opID: %u)\n"
"\tBounds: [L: %f T: %f R: %f B: %f]\n",
GrOP_INFO("opList: %d Recording (%s, opID: %u)\n"
"\tBounds [L: %.2f, T: %.2f R: %.2f B: %.2f]\n",
this->uniqueID(),
op->name(),
op->uniqueID(),
op->bounds().fLeft, op->bounds().fTop,
op->bounds().fRight, op->bounds().fBottom);
GrOP_INFO(SkTabString(op->dumpInfo(), 1).c_str());
GrOP_INFO("\tClipped Bounds: [L: %.2f, T: %.2f, R: %.2f, B: %.2f]\n", op->bounds().fLeft,
op->bounds().fTop, op->bounds().fRight, op->bounds().fBottom);
GrOP_INFO("\tOutcome:\n");
int maxCandidates = SkTMin(fMaxOpLookback, fRecordedOps.count());
// If we don't have a valid destination render target then we cannot reorder.
@ -334,33 +337,33 @@ GrOp* GrRenderTargetOpList::recordOp(std::unique_ptr<GrOp> op,
const RecordedOp& candidate = fRecordedOps.fromBack(i);
// We cannot continue to search backwards if the render target changes
if (candidate.fRenderTarget.get() != renderTarget) {
GrOP_INFO("\t\tBreaking because of (%s, opID: %u) Rendertarget mismatch\n",
GrOP_INFO("\t\tBackward: Breaking because of (%s, opID: %u) Rendertarget mismatch\n",
candidate.fOp->name(),
candidate.fOp->uniqueID());
break;
}
if (this->combineIfPossible(candidate, op.get(), clip, dstTexture)) {
GrOP_INFO("\t\tCombining with (%s, opID: %u)\n", candidate.fOp->name(),
GrOP_INFO("\t\tBackward: Combining with (%s, opID: %u)\n", candidate.fOp->name(),
candidate.fOp->uniqueID());
GrOP_INFO("\t\t\tCombined op info:\n");
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();
}
// Stop going backwards if we would cause a painter's order violation.
if (!can_reorder(fRecordedOps.fromBack(i).fOp->bounds(), op->bounds())) {
GrOP_INFO("\t\tIntersects with (%s, opID: %u)\n", candidate.fOp->name(),
GrOP_INFO("\t\tBackward: Intersects with (%s, opID: %u)\n", candidate.fOp->name(),
candidate.fOp->uniqueID());
break;
}
++i;
if (i == maxCandidates) {
GrOP_INFO("\t\tReached max lookback or beginning of op array %d\n", i);
GrOP_INFO("\t\tBackward: Reached max lookback or beginning of op array %d\n", i);
break;
}
}
} else {
GrOP_INFO("\t\tFirstOp\n");
GrOP_INFO("\t\tBackward: FirstOp\n");
}
GR_AUDIT_TRAIL_OP_RESULT_NEW(fAuditTrail, op);
if (clip) {
@ -375,12 +378,15 @@ GrOp* GrRenderTargetOpList::recordOp(std::unique_ptr<GrOp> op,
}
void GrRenderTargetOpList::forwardCombine() {
SkASSERT(!this->isClosed());
if (fMaxOpLookahead <= 0) {
return;
}
for (int i = 0; i < fRecordedOps.count() - 1; ++i) {
GrOp* op = fRecordedOps[i].fOp.get();
GrRenderTarget* renderTarget = fRecordedOps[i].fRenderTarget.get();
SkASSERT(renderTarget);
// If we don't have a valid destination render target ID then we cannot reorder.
if (!renderTarget) {
continue;
@ -391,13 +397,14 @@ void GrRenderTargetOpList::forwardCombine() {
const RecordedOp& candidate = fRecordedOps[j];
// We cannot continue to search if the render target changes
if (candidate.fRenderTarget.get() != renderTarget) {
GrOP_INFO("\t\tBreaking because of (%s, B%u) Rendertarget\n", candidate.fOp->name(),
GrOP_INFO("\t\tForward: Breaking because of (%s, opID: %u) Rendertarget\n",
candidate.fOp->name(),
candidate.fOp->uniqueID());
break;
}
if (this->combineIfPossible(fRecordedOps[i], candidate.fOp.get(),
candidate.fAppliedClip, &candidate.fDstTexture)) {
GrOP_INFO("\t\tCombining with (%s, B%u)\n", candidate.fOp->name(),
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());
fRecordedOps[j].fOp = std::move(fRecordedOps[i].fOp);
@ -405,13 +412,13 @@ void GrRenderTargetOpList::forwardCombine() {
}
// Stop going traversing if we would cause a painter's order violation.
if (!can_reorder(fRecordedOps[j].fOp->bounds(), op->bounds())) {
GrOP_INFO("\t\tIntersects with (%s, B%u)\n", candidate.fOp->name(),
GrOP_INFO("\t\tForward: Intersects with (%s, opID: %u)\n", candidate.fOp->name(),
candidate.fOp->uniqueID());
break;
}
++j;
if (j > maxCandidateIdx) {
GrOP_INFO("\t\tReached max lookahead or end of op array %d\n", i);
GrOP_INFO("\t\tForward: Reached max lookahead or end of op array %d\n", i);
break;
}
}

View File

@ -45,12 +45,18 @@ public:
~GrRenderTargetOpList() override;
void makeClosed() override {
INHERITED::makeClosed();
if (this->isClosed()) {
return;
}
fLastFullClearOp = nullptr;
this->forwardCombine();
INHERITED::makeClosed();
}
bool isEmpty() const { return fRecordedOps.empty(); }
/**
* Empties the draw buffer of any queued up draws.
*/

View File

@ -108,7 +108,7 @@ void GrTextureOpList::recordOp(std::unique_ptr<GrOp> op,
SkASSERT(!this->isClosed());
GR_AUDIT_TRAIL_ADD_OP(fAuditTrail, op.get(), resourceUniqueID, proxyUniqueID);
GrOP_INFO("Re-Recording (%s, B%u)\n"
GrOP_INFO("Re-Recording (%s, opID: %u)\n"
"\tBounds LRTB (%f, %f, %f, %f)\n",
op->name(),
op->uniqueID(),

View File

@ -180,6 +180,7 @@ public:
SkString dumpInfo() const override {
SkString str;
str.append(INHERITED::dumpInfo());
str.appendf("# combined: %d\n", fRectCnt);
const RectInfo* info = this->first();
for (int i = 0; i < fRectCnt; ++i) {
@ -189,7 +190,6 @@ public:
info = this->next(info);
}
str.append(DumpPipelineInfo(*this->pipeline()));
str.append(INHERITED::dumpInfo());
return str;
}

View File

@ -56,6 +56,7 @@ public:
SkString dumpInfo() const override {
SkString string;
string.append(INHERITED::dumpInfo());
string.appendf("rtID: %d proxyID: %d Scissor [",
fRenderTarget.get()->uniqueID().asUInt(),
fProxyUniqueID.asUInt());
@ -65,11 +66,11 @@ public:
} else {
string.append("disabled");
}
string.appendf("], Color: 0x%08x ", fColor);
string.append(INHERITED::dumpInfo());
string.appendf("], Color: 0x%08x\n", fColor);
return string;
}
GrColor color() const { return fColor; }
void setColor(GrColor color) { fColor = color; }
private:

View File

@ -25,13 +25,13 @@ public:
SkString dumpInfo() const override {
SkString string;
string.printf("src: (proxyID: %d, rtID: %d), dst: (proxyID: %d, rtID: %d), "
"srcRect: [L: %d, T: %d, R: %d, B: %d], dstPt: [X: %d, Y: %d]",
string.append(INHERITED::dumpInfo());
string.printf("src: (proxyID: %d, rtID: %d), dst: (proxyID: %d, rtID: %d),\n"
"srcRect: [L: %d, T: %d, R: %d, B: %d], dstPt: [X: %d, Y: %d]\n",
fSrcProxyID.asUInt(), fSrc.get()->uniqueID().asUInt(),
fDstProxyID.asUInt(), fDst.get()->uniqueID().asUInt(),
fSrcRect.fLeft, fSrcRect.fTop, fSrcRect.fRight, fSrcRect.fBottom,
fDstPoint.fX, fDstPoint.fY);
string.append(INHERITED::dumpInfo());
return string;
}

View File

@ -35,9 +35,9 @@ public:
SkString dumpInfo() const override {
SkString string;
string.printf("rtID: %d proxyID: %d ", fRenderTarget.get()->uniqueID().asUInt(),
fProxyUniqueID.asUInt());
string.append(INHERITED::dumpInfo());
string.printf("rtID: %d proxyID: %d\n", fRenderTarget.get()->uniqueID().asUInt(),
fProxyUniqueID.asUInt());
return string;
}

View File

@ -119,6 +119,10 @@ public:
this->applyPipelineOptimizations(PipelineOptimizations(analysis, overrideColor));
}
void addDependenciesTo(GrRenderTargetProxy* rtp) {
fPipeline.addDependenciesTo(rtp);
}
/**
* Mesh draw ops use a legacy system in GrRenderTargetContext where the pipeline is created when
* the op is recorded. These methods are unnecessary as this information is in the pipeline.

View File

@ -95,6 +95,7 @@ public:
SkString dumpInfo() const override {
SkString str;
str.append(INHERITED::dumpInfo());
str.appendf("# combined: %d\n", fRects.count());
for (int i = 0; i < fRects.count(); ++i) {
const RectInfo& info = fRects[i];
@ -103,7 +104,6 @@ public:
info.fRect.fBottom);
}
str.append(DumpPipelineInfo(*this->pipeline()));
str.append(INHERITED::dumpInfo());
return str;
}

View File

@ -220,6 +220,7 @@ void GrVkPipelineState::setData(GrVkGpu* gpu,
fXferProcessor->setData(fDataManager, pipeline.getXferProcessor(), dstTexture, offset);
GrResourceIOProcessor::TextureSampler dstTextureSampler;
if (dstTexture) {
// MDB TODO: this is the last usage of a GrTexture-based TextureSampler reset method
dstTextureSampler.reset(dstTexture);
textureBindings.push_back(&dstTextureSampler);
}

View File

@ -76,7 +76,8 @@ static sk_sp<GrTextureProxy> make_deferred(GrContext* context) {
desc.fConfig = kRGBA_8888_GrPixelConfig;
return GrSurfaceProxy::MakeDeferred(context->resourceProvider(), desc,
SkBackingFit::kApprox, SkBudgeted::kYes);
SkBackingFit::kApprox, SkBudgeted::kYes,
GrResourceProvider::kNoPendingIO_Flag);
}
static sk_sp<GrTextureProxy> make_wrapped(GrContext* context) {