Add a GrTextureResolveManager class

Adds a GrTextureResolveManager class and plumbs it through calls to
generate the drawing manager's dependency DAG. This new class is
currently unimplemented, but it wraps GrDrawingManager and will
eventually give limited access to functionality for making new tasks
that regenerate mipmaps and/or resolve MSAA. We will use this object
to move mipmap generation up to the DAG/proxy level.

Bug: skia:
Change-Id: Ie1deef21e7ae579a0262f2eeb93d451f0740d823
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/232633
Reviewed-by: Robert Phillips <robertphillips@google.com>
Commit-Queue: Chris Dalton <csmartdalton@google.com>
This commit is contained in:
Chris Dalton 2019-08-05 16:13:47 -06:00 committed by Skia Commit-Bot
parent 87cef069ca
commit 08755129a1
10 changed files with 98 additions and 33 deletions

View File

@ -231,6 +231,7 @@ skia_gpu_sources = [
"$_src/gpu/GrTextureProxyPriv.h",
"$_src/gpu/GrTextureRenderTargetProxy.cpp",
"$_src/gpu/GrTextureRenderTargetProxy.h",
"$_src/gpu/GrTextureResolveManager.h",
"$_src/gpu/GrTRecorder.h",
"$_src/gpu/GrUserStencilSettings.h",
"$_src/gpu/GrWindowRectangles.h",

View File

@ -323,8 +323,8 @@ void GrRenderTargetContext::internalClear(const GrFixedClip& clip,
GrFillRectOp::MakeNonAARect(fContext, std::move(paint), SkMatrix::I(),
rtRect));
} else {
opList->addOp(GrClearOp::Make(fContext, SkIRect::MakeEmpty(), color,
/* fullscreen */ true), *this->caps());
this->addOp(GrClearOp::Make(
fContext, SkIRect::MakeEmpty(), color, /* fullscreen */ true));
}
} else {
if (this->caps()->performPartialClearsAsDraws()) {
@ -343,7 +343,7 @@ void GrRenderTargetContext::internalClear(const GrFixedClip& clip,
if (!op) {
return;
}
this->getRTOpList()->addOp(std::move(op), *this->caps());
this->addOp(std::move(op));
}
}
}
@ -390,10 +390,8 @@ void GrRenderTargetContextPriv::absClear(const SkIRect* clearRect, const SkPMCol
// Must use the ClearOp factory that takes a boolean (false) instead of a surface
// proxy. The surface proxy variant would intersect the clip rect with its logical
// bounds, which is not desired in this special case.
fRenderTargetContext->getRTOpList()->addOp(
GrClearOp::Make(fRenderTargetContext->fContext, rtRect, color,
/* fullscreen */ false),
*fRenderTargetContext->caps());
fRenderTargetContext->addOp(GrClearOp::Make(
fRenderTargetContext->fContext, rtRect, color, /* fullscreen */ false));
}
} else {
// Reset the oplist like in internalClear(), but do not rely on a load op for the clear
@ -412,10 +410,9 @@ void GrRenderTargetContextPriv::absClear(const SkIRect* clearRect, const SkPMCol
SkMatrix::I(), SkRect::Make(rtRect)));
} else {
// Nothing special about this path in absClear compared to internalClear()
fRenderTargetContext->getRTOpList()->addOp(
GrClearOp::Make(fRenderTargetContext->fContext, SkIRect::MakeEmpty(), color,
/* fullscreen */ true),
*fRenderTargetContext->caps());
fRenderTargetContext->addOp(GrClearOp::Make(
fRenderTargetContext->fContext, SkIRect::MakeEmpty(), color,
/* fullscreen */ true));
}
}
}
@ -872,7 +869,7 @@ void GrRenderTargetContext::internalStencilClear(const GrFixedClip& clip, bool i
if (!op) {
return;
}
this->getRTOpList()->addOp(std::move(op), *this->caps());
this->addOp(std::move(op));
}
}
@ -914,7 +911,7 @@ void GrRenderTargetContextPriv::stencilPath(const GrHardClip& clip,
op->setClippedBounds(bounds);
fRenderTargetContext->setNeedsStencil(GrAA::kYes == doStencilMSAA);
fRenderTargetContext->getRTOpList()->addOp(std::move(op), *fRenderTargetContext->caps());
fRenderTargetContext->addOp(std::move(op));
}
void GrRenderTargetContext::drawTextureSet(const GrClip& clip, const TextureSetEntry set[], int cnt,
@ -1565,7 +1562,7 @@ void GrRenderTargetContext::drawDrawable(std::unique_ptr<SkDrawable::GpuDrawHand
const SkRect& bounds) {
std::unique_ptr<GrOp> op(GrDrawableOp::Make(fContext, std::move(drawable), bounds));
SkASSERT(op);
this->getRTOpList()->addOp(std::move(op), *this->caps());
this->addOp(std::move(op));
}
void GrRenderTargetContext::asyncRescaleAndReadPixels(
@ -2013,14 +2010,15 @@ bool GrRenderTargetContext::waitOnSemaphores(int numSemaphores,
kAdopt_GrWrapOwnership);
std::unique_ptr<GrOp> waitOp(GrSemaphoreOp::MakeWait(fContext, std::move(sema),
fRenderTargetProxy.get()));
this->getRTOpList()->addWaitOp(std::move(waitOp), *this->caps());
this->getRTOpList()->addWaitOp(
std::move(waitOp), GrTextureResolveManager(this->drawingManager()), *this->caps());
}
return true;
}
void GrRenderTargetContext::insertEventMarker(const SkString& str) {
std::unique_ptr<GrOp> op(GrDebugMarkerOp::Make(fContext, fRenderTargetProxy.get(), str));
this->getRTOpList()->addOp(std::move(op), *this->caps());
this->addOp(std::move(op));
}
void GrRenderTargetContext::drawPath(const GrClip& clip,
@ -2288,6 +2286,11 @@ static void op_bounds(SkRect* bounds, const GrOp* op) {
}
}
void GrRenderTargetContext::addOp(std::unique_ptr<GrOp> op) {
this->getRTOpList()->addOp(
std::move(op), GrTextureResolveManager(this->drawingManager()), *this->caps());
}
void GrRenderTargetContext::addDrawOp(const GrClip& clip, std::unique_ptr<GrDrawOp> op,
const std::function<WillAddOpFn>& willAddFn) {
ASSERT_SINGLE_OWNER
@ -2344,7 +2347,8 @@ void GrRenderTargetContext::addDrawOp(const GrClip& clip, std::unique_ptr<GrDraw
if (willAddFn) {
willAddFn(op.get(), opList->uniqueID());
}
opList->addDrawOp(std::move(op), analysis, std::move(appliedClip), dstProxy, *this->caps());
opList->addDrawOp(std::move(op), analysis, std::move(appliedClip), dstProxy,
GrTextureResolveManager(this->drawingManager()), *this->caps());
}
bool GrRenderTargetContext::setupDstProxy(GrRenderTargetProxy* rtProxy, const GrClip& clip,

View File

@ -599,6 +599,8 @@ private:
void drawShapeUsingPathRenderer(const GrClip&, GrPaint&&, GrAA, const SkMatrix&,
const GrShape&);
void addOp(std::unique_ptr<GrOp>);
// Allows caller of addDrawOp to know which op list an op will be added to.
using WillAddOpFn = void(GrOp*, uint32_t opListID);
// These perform processing specific to GrDrawOp-derived ops before recording them into an

View File

@ -594,7 +594,8 @@ bool GrRenderTargetOpList::copySurface(GrRecordingContext* context,
return false;
}
this->addOp(std::move(op), *context->priv().caps());
this->addOp(std::move(op), GrTextureResolveManager(context->priv().drawingManager()),
*context->priv().caps());
return true;
}
@ -606,7 +607,8 @@ void GrRenderTargetOpList::transferFrom(GrRecordingContext* context,
size_t dstOffset) {
auto op = GrTransferFromOp::Make(context, srcRect, surfaceColorType, dstColorType,
std::move(dst), dstOffset);
this->addOp(std::move(op), *context->priv().caps());
this->addOp(std::move(op), GrTextureResolveManager(context->priv().drawingManager()),
*context->priv().caps());
}
void GrRenderTargetOpList::handleInternalAllocationFailure() {

View File

@ -61,9 +61,11 @@ public:
void onPrepare(GrOpFlushState* flushState) override;
bool onExecute(GrOpFlushState* flushState) override;
void addOp(std::unique_ptr<GrOp> op, const GrCaps& caps) {
auto addDependency = [ &caps, this ] (GrSurfaceProxy* p, GrMipMapped) {
this->addDependency(p, caps);
void addOp(std::unique_ptr<GrOp> op, GrTextureResolveManager textureResolveManager,
const GrCaps& caps) {
auto addDependency = [ textureResolveManager, &caps, this ] (
GrSurfaceProxy* p, GrMipMapped mipmapped) {
this->addDependency(p, mipmapped, textureResolveManager, caps);
};
op->visitProxies(addDependency);
@ -71,15 +73,18 @@ public:
this->recordOp(std::move(op), GrProcessorSet::EmptySetAnalysis(), nullptr, nullptr, caps);
}
void addWaitOp(std::unique_ptr<GrOp> op, const GrCaps& caps) {
fHasWaitOp= true;
this->addOp(std::move(op), caps);
void addWaitOp(std::unique_ptr<GrOp> op, GrTextureResolveManager textureResolveManager,
const GrCaps& caps) {
fHasWaitOp = true;
this->addOp(std::move(op), textureResolveManager, caps);
}
void addDrawOp(std::unique_ptr<GrDrawOp> op, const GrProcessorSet::Analysis& processorAnalysis,
GrAppliedClip&& clip, const DstProxy& dstProxy, const GrCaps& caps) {
auto addDependency = [ &caps, this ] (GrSurfaceProxy* p, GrMipMapped) {
this->addDependency(p, caps);
GrAppliedClip&& clip, const DstProxy& dstProxy,
GrTextureResolveManager textureResolveManager, const GrCaps& caps) {
auto addDependency = [ textureResolveManager, &caps, this ] (
GrSurfaceProxy* p, GrMipMapped mipmapped) {
this->addDependency(p, mipmapped, textureResolveManager, caps);
};
op->visitProxies(addDependency);

View File

@ -69,7 +69,8 @@ void GrRenderTask::addDependency(GrRenderTask* dependedOn) {
}
// Convert from a GrSurface-based dependency to a GrRenderTask one
void GrRenderTask::addDependency(GrSurfaceProxy* dependedOn, const GrCaps& caps) {
void GrRenderTask::addDependency(GrSurfaceProxy* dependedOn, GrMipMapped, GrTextureResolveManager,
const GrCaps& caps) {
if (dependedOn->getLastRenderTask()) {
// If it is still receiving dependencies, this GrRenderTask shouldn't be closed
SkASSERT(!this->isClosed());

View File

@ -12,6 +12,7 @@
#include "include/private/SkColorData.h"
#include "include/private/SkTDArray.h"
#include "src/gpu/GrTextureProxy.h"
#include "src/gpu/GrTextureResolveManager.h"
class GrOpFlushState;
class GrOpList;
@ -47,7 +48,8 @@ public:
/*
* Notify this GrRenderTask that it relies on the contents of 'dependedOn'
*/
void addDependency(GrSurfaceProxy* dependedOn, const GrCaps& caps);
void addDependency(GrSurfaceProxy* dependedOn, GrMipMapped, GrTextureResolveManager,
const GrCaps& caps);
/*
* Does this renderTask depend on 'dependedOn'?

View File

@ -160,9 +160,11 @@ bool GrTextureOpList::copySurface(GrRecordingContext* context,
return false;
}
GrTextureResolveManager textureResolveManager(context->priv().drawingManager());
const GrCaps* caps = context->priv().caps();
auto addDependency = [ caps, this ] (GrSurfaceProxy* p, GrMipMapped) {
this->addDependency(p, *caps);
auto addDependency = [ textureResolveManager, caps, this ] (
GrSurfaceProxy* p, GrMipMapped mipmapped) {
this->addDependency(p, mipmapped, textureResolveManager, *caps);
};
op->visitProxies(addDependency);

View File

@ -0,0 +1,44 @@
/*
* Copyright 2019 Google LLC
*
* Use of this source code is governed by a BSD-style license that can be
* found in the LICENSE file.
*/
#ifndef GrTextureResolveManager_DEFINED
#define GrTextureResolveManager_DEFINED
#include "include/core/SkRefCnt.h"
#include "include/gpu/GrTypes.h"
class GrCaps;
class GrDrawingManager;
class GrRenderTask;
class GrTextureProxy;
/*
* This class is a shallow view of the drawing manager. It is passed to render tasks when setting up
* the dependency DAG, and gives them limited access to functionality for making new tasks that
* regenerate mipmaps and/or resolve MSAA.
*/
class GrTextureResolveManager {
public:
explicit GrTextureResolveManager(GrDrawingManager* drawingManager)
: fDrawingManager(drawingManager) {}
enum class ResolveFlags : bool {
kNone = 0,
kMipMaps = 1 << 0,
// TODO: kMSAA = 1 << 1
};
GrRenderTask* newTextureResolveRenderTask(
sk_sp<GrTextureProxy>, ResolveFlags, const GrCaps&) const;
private:
GrDrawingManager* fDrawingManager;
};
GR_MAKE_BITFIELD_CLASS_OPS(GrTextureResolveManager::ResolveFlags);
#endif

View File

@ -221,7 +221,9 @@ DEF_GPUTEST(OpChainTest, reporter, /*ctxInfo*/) {
range.fOffset += pos;
auto op = TestOp::Make(context.get(), value, range, result, &combinable);
op->writeResult(validResult);
opList.addOp(std::move(op), *context->priv().caps());
opList.addOp(std::move(op),
GrTextureResolveManager(context->priv().drawingManager()),
*context->priv().caps());
}
opList.makeClosed(*context->priv().caps());
opList.prepare(&flushState);