Make render task targets be just a proxy.
Change-Id: I09548cc22b13bc0b9b5f77cf1f20c1505a529c51
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/356760
Commit-Queue: Brian Salomon <bsalomon@google.com>
Reviewed-by: Adlai Holler <adlai@google.com>
Reviewed-by: Greg Daniel <egdaniel@google.com>
diff --git a/src/gpu/GrOpsTask.cpp b/src/gpu/GrOpsTask.cpp
index 7a20c9a..db8a27b 100644
--- a/src/gpu/GrOpsTask.cpp
+++ b/src/gpu/GrOpsTask.cpp
@@ -356,14 +356,17 @@
////////////////////////////////////////////////////////////////////////////////
-GrOpsTask::GrOpsTask(GrDrawingManager* drawingMgr, GrRecordingContext::Arenas arenas,
+GrOpsTask::GrOpsTask(GrDrawingManager* drawingMgr,
+ GrRecordingContext::Arenas arenas,
GrSurfaceProxyView view,
GrAuditTrail* auditTrail)
: GrRenderTask()
, fArenas(arenas)
, fAuditTrail(auditTrail)
- SkDEBUGCODE(, fNumClips(0)) {
- this->addTarget(drawingMgr, std::move(view));
+ , fTargetSwizzle(view.swizzle())
+ , fTargetOrigin(view.origin())
+ SkDEBUGCODE(, fNumClips(0)) {
+ this->addTarget(drawingMgr, view.detachProxy());
}
void GrOpsTask::deleteOps() {
@@ -404,7 +407,7 @@
this->addSampledTexture(dstProxyView.proxy());
}
addDependency(dstProxyView.proxy(), GrMipmapped::kNo);
- if (this->target(0).proxy() == dstProxyView.proxy()) {
+ if (this->target(0) == dstProxyView.proxy()) {
// Since we are sampling and drawing to the same surface we will need to use
// texture barriers.
SkASSERT(GrDstSampleTypeDirectlySamplesDst(dstProxyView.dstSampleType()));
@@ -448,10 +451,11 @@
return;
}
+ GrSurfaceProxyView dstView(sk_ref_sp(this->target(0)), fTargetOrigin, fTargetSwizzle);
for (const auto& chain : fOpChains) {
if (chain.shouldExecute()) {
chain.head()->prePrepare(context,
- this->target(0),
+ dstView,
chain.appliedClip(),
chain.dstProxyView(),
fRenderPassXferBarriers,
@@ -461,7 +465,7 @@
}
void GrOpsTask::onPrepare(GrOpFlushState* flushState) {
- SkASSERT(this->target(0).proxy()->peekRenderTarget());
+ SkASSERT(this->target(0)->peekRenderTarget());
SkASSERT(this->isClosed());
#ifdef SK_BUILD_FOR_ANDROID_FRAMEWORK
TRACE_EVENT0("skia.gpu", TRACE_FUNC);
@@ -475,6 +479,7 @@
}
flushState->setSampledProxyArray(&fSampledProxies);
+ GrSurfaceProxyView dstView(sk_ref_sp(this->target(0)), fTargetOrigin, fTargetSwizzle);
// Loop over the ops that haven't yet been prepared.
for (const auto& chain : fOpChains) {
if (chain.shouldExecute()) {
@@ -482,7 +487,7 @@
TRACE_EVENT0("skia.gpu", chain.head()->name());
#endif
GrOpFlushState::OpArgs opArgs(chain.head(),
- this->target(0),
+ dstView,
chain.appliedClip(),
chain.dstProxyView(),
fRenderPassXferBarriers,
@@ -548,7 +553,7 @@
}
SkASSERT(this->numTargets() == 1);
- GrRenderTargetProxy* proxy = this->target(0).proxy()->asRenderTargetProxy();
+ GrRenderTargetProxy* proxy = this->target(0)->asRenderTargetProxy();
SkASSERT(proxy);
TRACE_EVENT0("skia.gpu", TRACE_FUNC);
@@ -614,10 +619,17 @@
? GrStoreOp::kDiscard
: GrStoreOp::kStore;
- GrOpsRenderPass* renderPass = create_render_pass(
- flushState->gpu(), proxy->peekRenderTarget(), stencil, this->target(0).origin(),
- fClippedContentBounds, fColorLoadOp, fLoadClearColor, stencilLoadOp, stencilStoreOp,
- fSampledProxies, fRenderPassXferBarriers);
+ GrOpsRenderPass* renderPass = create_render_pass(flushState->gpu(),
+ proxy->peekRenderTarget(),
+ stencil,
+ fTargetOrigin,
+ fClippedContentBounds,
+ fColorLoadOp,
+ fLoadClearColor,
+ stencilLoadOp,
+ stencilStoreOp,
+ fSampledProxies,
+ fRenderPassXferBarriers);
if (!renderPass) {
return false;
@@ -625,6 +637,8 @@
flushState->setOpsRenderPass(renderPass);
renderPass->begin();
+ GrSurfaceProxyView dstView(sk_ref_sp(this->target(0)), fTargetOrigin, fTargetSwizzle);
+
// Draw all the generated geometry.
for (const auto& chain : fOpChains) {
if (!chain.shouldExecute()) {
@@ -635,7 +649,7 @@
#endif
GrOpFlushState::OpArgs opArgs(chain.head(),
- this->target(0),
+ dstView,
chain.appliedClip(),
chain.dstProxyView(),
fRenderPassXferBarriers,
@@ -657,7 +671,7 @@
fColorLoadOp = op;
fLoadClearColor = color;
if (GrLoadOp::kClear == fColorLoadOp) {
- GrSurfaceProxy* proxy = this->target(0).proxy();
+ GrSurfaceProxy* proxy = this->target(0);
SkASSERT(proxy);
fTotalBounds = proxy->backingStoreBoundsRect();
}
@@ -672,7 +686,7 @@
// If the opsTask is using a render target which wraps a vulkan command buffer, we can't do
// a clear load since we cannot change the render pass that we are using. Thus we fall back
// to making a clear op in this case.
- return !this->target(0).asRenderTargetProxy()->wrapsVkSecondaryCB();
+ return !this->target(0)->asRenderTargetProxy()->wrapsVkSecondaryCB();
}
// Could not empty the task, so an op must be added to handle the clear
@@ -814,7 +828,7 @@
alloc->addInterval(fDeferredProxies[i], 0, 0, GrResourceAllocator::ActualUse::kNo);
}
- GrSurfaceProxy* targetProxy = this->target(0).proxy();
+ GrSurfaceProxy* targetProxy = this->target(0);
// Add the interval for all the writes to this GrOpsTasks's target
if (fOpChains.count()) {
@@ -832,8 +846,11 @@
}
auto gather = [ alloc SkDEBUGCODE(, this) ] (GrSurfaceProxy* p, GrMipmapped) {
- alloc->addInterval(p, alloc->curOp(), alloc->curOp(), GrResourceAllocator::ActualUse::kYes
- SkDEBUGCODE(, this->target(0).proxy() == p));
+ alloc->addInterval(p,
+ alloc->curOp(),
+ alloc->curOp(),
+ GrResourceAllocator::ActualUse::kYes
+ SkDEBUGCODE(, this->target(0) == p));
};
for (const OpChain& recordedOp : fOpChains) {
recordedOp.visitProxies(gather);
@@ -849,7 +866,7 @@
const DstProxyView* dstProxyView, const GrCaps& caps) {
SkDEBUGCODE(op->validate();)
SkASSERT(processorAnalysis.requiresDstTexture() == (dstProxyView && dstProxyView->proxy()));
- GrSurfaceProxy* proxy = this->target(0).proxy();
+ GrSurfaceProxy* proxy = this->target(0);
SkASSERT(proxy);
// A closed GrOpsTask should never receive new/more ops
@@ -942,7 +959,7 @@
SkIRect* targetUpdateBounds) {
this->forwardCombine(caps);
if (!this->isNoOp()) {
- GrSurfaceProxy* proxy = this->target(0).proxy();
+ GrSurfaceProxy* proxy = this->target(0);
// Use the entire backing store bounds since the GPU doesn't clip automatically to the
// logical dimensions.
SkRect clippedContentBounds = proxy->backingStoreBoundsRect();
@@ -950,7 +967,10 @@
// then we can simply assert here that the bounds intersect.
if (clippedContentBounds.intersect(fTotalBounds)) {
clippedContentBounds.roundOut(&fClippedContentBounds);
- *targetUpdateBounds = fClippedContentBounds;
+ *targetUpdateBounds = GrNativeRect::MakeIRectRelativeTo(
+ fTargetOrigin,
+ this->target(0)->backingStoreDimensions().height(),
+ fClippedContentBounds);
return ExpectedOutcome::kTargetDirty;
}
}