Pull creation of GrPipeline explicitly into the Ops' onExecute methods

This is a first step towards pulling the creation of the GrProgramInfos explicitly into the Ops' onExecute methods. We need this behavior so programInfo creation can be moved forward to onPrePrepare.

For now, pipeline creation is a static member on GrSimpleMeshDrawOpHelper so GrPipeline creation can be bottle-neckedOps for Ops that don't use the helper. In some future world CreatePipeline could become non-static to reduce some of the duplicate code.

Bug: skia:9455
Change-Id: I2d35dd223db824e84616f5df0f1dca34c1b6e412
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/258003
Reviewed-by: Michael Ludwig <michaelludwig@google.com>
Commit-Queue: Robert Phillips <robertphillips@google.com>
This commit is contained in:
Robert Phillips 2019-12-05 16:40:31 -05:00 committed by Skia Commit-Bot
parent a746fc19ce
commit 3968fcbc3a
30 changed files with 239 additions and 110 deletions

View File

@ -23,6 +23,7 @@
#include "src/gpu/glsl/GrGLSLVarying.h"
#include "src/gpu/glsl/GrGLSLVertexGeoBuilder.h"
#include "src/gpu/ops/GrMeshDrawOp.h"
#include "src/gpu/ops/GrSimpleMeshDrawOpHelper.h"
namespace {
@ -235,8 +236,11 @@ private:
}
void onExecute(GrOpFlushState* flushState, const SkRect& chainBounds) override {
flushState->executeDrawsAndUploadsForMeshDrawOp(
this, chainBounds, GrProcessorSet::MakeEmptySet());
auto pipeline = GrSimpleMeshDrawOpHelper::CreatePipeline(flushState,
GrProcessorSet::MakeEmptySet(),
GrPipeline::InputFlags::kNone);
flushState->executeDrawsAndUploadsForMeshDrawOp(this, chainBounds, pipeline);
}
Mode fMode;

View File

@ -46,6 +46,7 @@
#include "src/gpu/ops/GrDrawOp.h"
#include "src/gpu/ops/GrMeshDrawOp.h"
#include "src/gpu/ops/GrOp.h"
#include "src/gpu/ops/GrSimpleMeshDrawOpHelper.h"
#include <memory>
#include <utility>
@ -81,8 +82,11 @@ protected:
}
void onExecute(GrOpFlushState* flushState, const SkRect& chainBounds) override {
flushState->executeDrawsAndUploadsForMeshDrawOp(
this, chainBounds, std::move(fProcessorSet));
auto pipeline = GrSimpleMeshDrawOpHelper::CreatePipeline(flushState,
std::move(fProcessorSet),
GrPipeline::InputFlags::kNone);
flushState->executeDrawsAndUploadsForMeshDrawOp(this, chainBounds, pipeline);
}
GrClipEdgeType edgeType() const { return fEdgeType; }

View File

@ -32,20 +32,9 @@ const GrCaps& GrOpFlushState::caps() const {
}
void GrOpFlushState::executeDrawsAndUploadsForMeshDrawOp(
const GrOp* op, const SkRect& chainBounds, GrProcessorSet&& processorSet,
GrPipeline::InputFlags pipelineFlags, const GrUserStencilSettings* stencilSettings) {
const GrOp* op, const SkRect& chainBounds, const GrPipeline* pipeline) {
SkASSERT(this->opsRenderPass());
GrPipeline::InitArgs pipelineArgs;
pipelineArgs.fInputFlags = pipelineFlags;
pipelineArgs.fDstProxyView = this->dstProxyView();
pipelineArgs.fCaps = &this->caps();
pipelineArgs.fUserStencil = stencilSettings;
pipelineArgs.fOutputSwizzle = this->drawOpArgs().outputSwizzle();
auto pipeline = this->allocator()->make<GrPipeline>(pipelineArgs,
std::move(processorSet),
this->detachAppliedClip());
while (fCurrDraw != fDraws.end() && fCurrDraw->fOp == op) {
GrDeferredUploadToken drawToken = fTokenTracker->nextTokenToFlush();
while (fCurrUpload != fInlineUploads.end() &&

View File

@ -44,10 +44,8 @@ public:
void doUpload(GrDeferredTextureUploadFn&, bool shouldPrepareSurfaceForSampling = false);
/** Called as ops are executed. Must be called in the same order as the ops were prepared. */
void executeDrawsAndUploadsForMeshDrawOp(
const GrOp* op, const SkRect& chainBounds, GrProcessorSet&&,
GrPipeline::InputFlags = GrPipeline::InputFlags::kNone,
const GrUserStencilSettings* = &GrUserStencilSettings::kUnused);
void executeDrawsAndUploadsForMeshDrawOp(const GrOp* op, const SkRect& chainBounds,
const GrPipeline*);
GrOpsRenderPass* opsRenderPass() { return fOpsRenderPass; }
void setOpsRenderPass(GrOpsRenderPass* renderPass) { fOpsRenderPass = renderPass; }

View File

@ -119,10 +119,9 @@ static constexpr GrUserStencilSettings kResolveStencilCoverageAndReset(
void GrStencilAtlasOp::onExecute(GrOpFlushState* flushState, const SkRect& chainBounds) {
SkIRect drawBoundsRect = SkIRect::MakeWH(fDrawBounds.width(), fDrawBounds.height());
GrPipeline pipeline(
GrScissorTest::kEnabled, GrDisableColorXPFactory::MakeXferProcessor(),
flushState->drawOpArgs().outputSwizzle(), GrPipeline::InputFlags::kHWAntialias,
&kIncrDecrStencil);
GrPipeline pipeline(GrScissorTest::kEnabled, GrDisableColorXPFactory::MakeXferProcessor(),
flushState->drawOpArgs().outputSwizzle(),
GrPipeline::InputFlags::kHWAntialias, &kIncrDecrStencil);
GrSampleMaskProcessor sampleMaskProc;

View File

@ -821,7 +821,12 @@ private:
}
void onExecute(GrOpFlushState* flushState, const SkRect& chainBounds) override {
fHelper.executeDrawsAndUploads(this, flushState, chainBounds);
auto pipeline = GrSimpleMeshDrawOpHelper::CreatePipeline(flushState,
fHelper.detachProcessorSet(),
fHelper.pipelineFlags(),
fHelper.stencilSettings());
flushState->executeDrawsAndUploadsForMeshDrawOp(this, chainBounds, pipeline);
}
CombineResult onCombineIfPossible(GrOp* t, const GrCaps& caps) override {

View File

@ -1105,7 +1105,12 @@ void AAHairlineOp::onPrepareDraws(Target* target) {
}
void AAHairlineOp::onExecute(GrOpFlushState* flushState, const SkRect& chainBounds) {
fHelper.executeDrawsAndUploads(this, flushState, chainBounds);
auto pipeline = GrSimpleMeshDrawOpHelper::CreatePipeline(flushState,
fHelper.detachProcessorSet(),
fHelper.pipelineFlags(),
fHelper.stencilSettings());
flushState->executeDrawsAndUploadsForMeshDrawOp(this, chainBounds, pipeline);
}
bool GrAAHairLinePathRenderer::onDrawPath(const DrawPathArgs& args) {

View File

@ -304,7 +304,12 @@ private:
}
void onExecute(GrOpFlushState* flushState, const SkRect& chainBounds) override {
fHelper.executeDrawsAndUploads(this, flushState, chainBounds);
auto pipeline = GrSimpleMeshDrawOpHelper::CreatePipeline(flushState,
fHelper.detachProcessorSet(),
fHelper.pipelineFlags(),
fHelper.stencilSettings());
flushState->executeDrawsAndUploadsForMeshDrawOp(this, chainBounds, pipeline);
}
CombineResult onCombineIfPossible(GrOp* t, const GrCaps& caps) override {

View File

@ -19,6 +19,7 @@
#include "src/gpu/GrResourceProvider.h"
#include "src/gpu/effects/GrBitmapTextGeoProc.h"
#include "src/gpu/effects/GrDistanceFieldGeoProc.h"
#include "src/gpu/ops/GrSimpleMeshDrawOpHelper.h"
#include "src/gpu/text/GrAtlasManager.h"
#include "src/gpu/text/GrStrikeCache.h"
@ -393,8 +394,11 @@ void GrAtlasTextOp::onPrepareDraws(Target* target) {
}
void GrAtlasTextOp::onExecute(GrOpFlushState* flushState, const SkRect& chainBounds) {
flushState->executeDrawsAndUploadsForMeshDrawOp(
this, chainBounds, std::move(fProcessors), GrPipeline::InputFlags::kNone);
auto pipeline = GrSimpleMeshDrawOpHelper::CreatePipeline(flushState,
std::move(fProcessors),
GrPipeline::InputFlags::kNone);
flushState->executeDrawsAndUploadsForMeshDrawOp(this, chainBounds, pipeline);
}
void GrAtlasTextOp::flush(GrMeshDrawOp::Target* target, FlushInfo* flushInfo) const {

View File

@ -30,6 +30,7 @@
#include "src/gpu/glsl/GrGLSLVertexGeoBuilder.h"
#include "src/gpu/ops/GrDashOp.h"
#include "src/gpu/ops/GrMeshDrawOp.h"
#include "src/gpu/ops/GrSimpleMeshDrawOpHelper.h"
using AAMode = GrDashOp::AAMode;
@ -632,8 +633,13 @@ private:
if (AAMode::kCoverageWithMSAA == fAAMode) {
pipelineFlags |= GrPipeline::InputFlags::kHWAntialias;
}
flushState->executeDrawsAndUploadsForMeshDrawOp(
this, chainBounds, std::move(fProcessorSet), pipelineFlags, fStencilSettings);
auto pipeline = GrSimpleMeshDrawOpHelper::CreatePipeline(flushState,
std::move(fProcessorSet),
pipelineFlags,
fStencilSettings);
flushState->executeDrawsAndUploadsForMeshDrawOp(this, chainBounds, pipeline);
}
CombineResult onCombineIfPossible(GrOp* t, const GrCaps& caps) override {

View File

@ -442,7 +442,12 @@ private:
}
void onExecute(GrOpFlushState* flushState, const SkRect& chainBounds) override {
fHelper.executeDrawsAndUploads(this, flushState, chainBounds);
auto pipeline = GrSimpleMeshDrawOpHelper::CreatePipeline(flushState,
fHelper.detachProcessorSet(),
fHelper.pipelineFlags(),
fHelper.stencilSettings());
flushState->executeDrawsAndUploadsForMeshDrawOp(this, chainBounds, pipeline);
}
CombineResult onCombineIfPossible(GrOp* t, const GrCaps& caps) override {

View File

@ -214,7 +214,11 @@ void DrawAtlasOp::onPrepareDraws(Target* target) {
}
void DrawAtlasOp::onExecute(GrOpFlushState* flushState, const SkRect& chainBounds) {
fHelper.executeDrawsAndUploads(this, flushState, chainBounds);
auto pipeline = GrSimpleMeshDrawOpHelper::CreatePipeline(flushState,
fHelper.detachProcessorSet(),
fHelper.pipelineFlags());
flushState->executeDrawsAndUploadsForMeshDrawOp(this, chainBounds, pipeline);
}
GrOp::CombineResult DrawAtlasOp::onCombineIfPossible(GrOp* t, const GrCaps& caps) {

View File

@ -14,6 +14,7 @@
#include "src/gpu/GrRenderTargetContext.h"
#include "src/gpu/GrRenderTargetPriv.h"
#include "src/gpu/ops/GrDrawPathOp.h"
#include "src/gpu/ops/GrSimpleMeshDrawOpHelper.h"
static constexpr GrUserStencilSettings kCoverPass{
GrUserStencilSettings::StaticInit<
@ -43,18 +44,6 @@ SkString GrDrawPathOp::dumpInfo() const {
}
#endif
GrPipeline::InitArgs GrDrawPathOpBase::pipelineInitArgs(const GrOpFlushState& state) {
GrPipeline::InitArgs args;
if (fDoAA) {
args.fInputFlags |= GrPipeline::InputFlags::kHWAntialias;
}
args.fUserStencil = &kCoverPass;
args.fCaps = &state.caps();
args.fDstProxyView = state.drawOpArgs().dstProxyView();
args.fOutputSwizzle = state.drawOpArgs().outputSwizzle();
return args;
}
const GrProcessorSet::Analysis& GrDrawPathOpBase::doProcessorAnalysis(
const GrCaps& caps, const GrAppliedClip* clip, bool hasMixedSampledCoverage,
GrClampType clampType) {
@ -87,34 +76,42 @@ std::unique_ptr<GrDrawOp> GrDrawPathOp::Make(GrRecordingContext* context,
return pool->allocate<GrDrawPathOp>(viewMatrix, std::move(paint), aa, std::move(path));
}
void GrDrawPathOp::onExecute(GrOpFlushState* state, const SkRect& chainBounds) {
GrAppliedClip appliedClip = state->detachAppliedClip();
void GrDrawPathOp::onExecute(GrOpFlushState* flushState, const SkRect& chainBounds) {
GrPipeline::FixedDynamicState* fixedDynamicState = nullptr, storage;
if (appliedClip.scissorState().enabled()) {
storage.fScissorRect = appliedClip.scissorState().rect();
const GrAppliedClip* appliedClip = flushState->appliedClip();
if (appliedClip && appliedClip->scissorState().enabled()) {
storage.fScissorRect = appliedClip->scissorState().rect();
fixedDynamicState = &storage;
}
GrPipeline pipeline(this->pipelineInitArgs(*state), this->detachProcessors(),
std::move(appliedClip));
GrPipeline::InputFlags pipelineFlags = GrPipeline::InputFlags::kNone;
if (this->doAA()) {
pipelineFlags |= GrPipeline::InputFlags::kHWAntialias;
}
auto pipeline = GrSimpleMeshDrawOpHelper::CreatePipeline(flushState,
this->detachProcessorSet(),
pipelineFlags,
&kCoverPass);
sk_sp<GrPathProcessor> pathProc(GrPathProcessor::Create(this->color(), this->viewMatrix()));
GrProgramInfo programInfo(state->proxy()->numSamples(),
state->proxy()->numStencilSamples(),
state->proxy()->backendFormat(),
state->view()->origin(),
&pipeline,
GrRenderTargetProxy* proxy = flushState->proxy();
GrProgramInfo programInfo(proxy->numSamples(),
proxy->numStencilSamples(),
proxy->backendFormat(),
flushState->view()->origin(),
pipeline,
pathProc.get(),
fixedDynamicState,
nullptr, 0,
GrPrimitiveType::kPath);
GrStencilSettings stencil;
init_stencil_pass_settings(*state, this->fillType(), &stencil);
state->gpu()->pathRendering()->drawPath(state->drawOpArgs().proxy()->peekRenderTarget(),
programInfo, stencil, fPath.get());
init_stencil_pass_settings(*flushState, this->fillType(), &stencil);
flushState->gpu()->pathRendering()->drawPath(proxy->peekRenderTarget(),
programInfo, stencil, fPath.get());
}
//////////////////////////////////////////////////////////////////////////////

View File

@ -43,9 +43,9 @@ protected:
const SkMatrix& viewMatrix() const { return fViewMatrix; }
const SkPMColor4f& color() const { return fInputColor; }
GrPathRendering::FillType fillType() const { return fFillType; }
bool doAA() const { return fDoAA; }
const GrProcessorSet& processors() const { return fProcessorSet; }
GrProcessorSet detachProcessors() { return std::move(fProcessorSet); }
inline GrPipeline::InitArgs pipelineInitArgs(const GrOpFlushState&);
GrProcessorSet detachProcessorSet() { return std::move(fProcessorSet); }
const GrProcessorSet::Analysis& doProcessorAnalysis(
const GrCaps&, const GrAppliedClip*, bool hasMixedSampledCoverage, GrClampType);
const GrProcessorSet::Analysis& processorAnalysis() const {

View File

@ -512,7 +512,11 @@ void DrawVerticesOp::drawVertices(Target* target,
}
void DrawVerticesOp::onExecute(GrOpFlushState* flushState, const SkRect& chainBounds) {
fHelper.executeDrawsAndUploads(this, flushState, chainBounds);
auto pipeline = GrSimpleMeshDrawOpHelper::CreatePipeline(flushState,
fHelper.detachProcessorSet(),
fHelper.pipelineFlags());
flushState->executeDrawsAndUploadsForMeshDrawOp(this, chainBounds, pipeline);
}
GrOp::CombineResult DrawVerticesOp::onCombineIfPossible(GrOp* t, const GrCaps& caps) {

View File

@ -281,7 +281,12 @@ private:
}
void onExecute(GrOpFlushState* flushState, const SkRect& chainBounds) override {
fHelper.executeDrawsAndUploads(this, flushState, chainBounds);
auto pipeline = GrSimpleMeshDrawOpHelper::CreatePipeline(flushState,
fHelper.detachProcessorSet(),
fHelper.pipelineFlags(),
fHelper.stencilSettings());
flushState->executeDrawsAndUploadsForMeshDrawOp(this, chainBounds, pipeline);
}
CombineResult onCombineIfPossible(GrOp* t, const GrCaps& caps) override {

View File

@ -290,7 +290,11 @@ private:
}
void onExecute(GrOpFlushState* flushState, const SkRect& chainBounds) override {
fHelper.executeDrawsAndUploads(this, flushState, chainBounds);
auto pipeline = GrSimpleMeshDrawOpHelper::CreatePipeline(flushState,
fHelper.detachProcessorSet(),
fHelper.pipelineFlags());
flushState->executeDrawsAndUploadsForMeshDrawOp(this, chainBounds, pipeline);
}
CombineResult onCombineIfPossible(GrOp* t, const GrCaps& caps) override {

View File

@ -1399,7 +1399,11 @@ private:
}
void onExecute(GrOpFlushState* flushState, const SkRect& chainBounds) override {
fHelper.executeDrawsAndUploads(this, flushState, chainBounds);
auto pipeline = GrSimpleMeshDrawOpHelper::CreatePipeline(flushState,
fHelper.detachProcessorSet(),
fHelper.pipelineFlags());
flushState->executeDrawsAndUploadsForMeshDrawOp(this, chainBounds, pipeline);
}
CombineResult onCombineIfPossible(GrOp* t, const GrCaps& caps) override {
@ -1690,7 +1694,11 @@ private:
}
void onExecute(GrOpFlushState* flushState, const SkRect& chainBounds) override {
fHelper.executeDrawsAndUploads(this, flushState, chainBounds);
auto pipeline = GrSimpleMeshDrawOpHelper::CreatePipeline(flushState,
fHelper.detachProcessorSet(),
fHelper.pipelineFlags());
flushState->executeDrawsAndUploadsForMeshDrawOp(this, chainBounds, pipeline);
}
CombineResult onCombineIfPossible(GrOp* t, const GrCaps& caps) override {
@ -1945,7 +1953,11 @@ private:
}
void onExecute(GrOpFlushState* flushState, const SkRect& chainBounds) override {
fHelper.executeDrawsAndUploads(this, flushState, chainBounds);
auto pipeline = GrSimpleMeshDrawOpHelper::CreatePipeline(flushState,
fHelper.detachProcessorSet(),
fHelper.pipelineFlags());
flushState->executeDrawsAndUploadsForMeshDrawOp(this, chainBounds, pipeline);
}
CombineResult onCombineIfPossible(GrOp* t, const GrCaps& caps) override {
@ -2182,7 +2194,11 @@ private:
}
void onExecute(GrOpFlushState* flushState, const SkRect& chainBounds) override {
fHelper.executeDrawsAndUploads(this, flushState, chainBounds);
auto pipeline = GrSimpleMeshDrawOpHelper::CreatePipeline(flushState,
fHelper.detachProcessorSet(),
fHelper.pipelineFlags());
flushState->executeDrawsAndUploadsForMeshDrawOp(this, chainBounds, pipeline);
}
CombineResult onCombineIfPossible(GrOp* t, const GrCaps& caps) override {
@ -2613,7 +2629,11 @@ private:
}
void onExecute(GrOpFlushState* flushState, const SkRect& chainBounds) override {
fHelper.executeDrawsAndUploads(this, flushState, chainBounds);
auto pipeline = GrSimpleMeshDrawOpHelper::CreatePipeline(flushState,
fHelper.detachProcessorSet(),
fHelper.pipelineFlags());
flushState->executeDrawsAndUploadsForMeshDrawOp(this, chainBounds, pipeline);
}
CombineResult onCombineIfPossible(GrOp* t, const GrCaps& caps) override {
@ -2895,7 +2915,11 @@ private:
}
void onExecute(GrOpFlushState* flushState, const SkRect& chainBounds) override {
fHelper.executeDrawsAndUploads(this, flushState, chainBounds);
auto pipeline = GrSimpleMeshDrawOpHelper::CreatePipeline(flushState,
fHelper.detachProcessorSet(),
fHelper.pipelineFlags());
flushState->executeDrawsAndUploadsForMeshDrawOp(this, chainBounds, pipeline);
}
CombineResult onCombineIfPossible(GrOp* t, const GrCaps& caps) override {

View File

@ -133,7 +133,12 @@ private:
}
void onExecute(GrOpFlushState* flushState, const SkRect& chainBounds) override {
fHelper.executeDrawsAndUploads(this, flushState, chainBounds);
auto pipeline = GrSimpleMeshDrawOpHelper::CreatePipeline(flushState,
fHelper.detachProcessorSet(),
fHelper.pipelineFlags(),
fHelper.stencilSettings());
flushState->executeDrawsAndUploadsForMeshDrawOp(this, chainBounds, pipeline);
}
CombineResult onCombineIfPossible(GrOp* t, const GrCaps& caps) override {

View File

@ -15,6 +15,7 @@
#include "src/gpu/GrProxyProvider.h"
#include "src/gpu/GrRecordingContextPriv.h"
#include "src/gpu/effects/GrShadowGeoProc.h"
#include "src/gpu/ops/GrSimpleMeshDrawOpHelper.h"
///////////////////////////////////////////////////////////////////////////////
// Circle Data
@ -602,8 +603,11 @@ private:
}
void onExecute(GrOpFlushState* flushState, const SkRect& chainBounds) override {
flushState->executeDrawsAndUploadsForMeshDrawOp(
this, chainBounds, GrProcessorSet::MakeEmptySet());
auto pipeline = GrSimpleMeshDrawOpHelper::CreatePipeline(flushState,
GrProcessorSet::MakeEmptySet(),
GrPipeline::InputFlags::kNone);
flushState->executeDrawsAndUploadsForMeshDrawOp(this, chainBounds, pipeline);
}
CombineResult onCombineIfPossible(GrOp* t, const GrCaps& caps) override {

View File

@ -106,15 +106,22 @@ GrProcessorSet::Analysis GrSimpleMeshDrawOpHelper::finalizeProcessors(
return analysis;
}
void GrSimpleMeshDrawOpHelper::executeDrawsAndUploads(
const GrOp* op, GrOpFlushState* flushState, const SkRect& chainBounds) {
if (fProcessors) {
flushState->executeDrawsAndUploadsForMeshDrawOp(
op, chainBounds, std::move(*fProcessors), fPipelineFlags);
} else {
flushState->executeDrawsAndUploadsForMeshDrawOp(
op, chainBounds, GrProcessorSet::MakeEmptySet(), fPipelineFlags);
}
const GrPipeline* GrSimpleMeshDrawOpHelper::CreatePipeline(
GrOpFlushState* flushState,
GrProcessorSet&& processorSet,
GrPipeline::InputFlags pipelineFlags,
const GrUserStencilSettings* stencilSettings) {
GrPipeline::InitArgs pipelineArgs;
pipelineArgs.fInputFlags = pipelineFlags;
pipelineArgs.fDstProxyView = flushState->dstProxyView();
pipelineArgs.fCaps = &flushState->caps();
pipelineArgs.fUserStencil = stencilSettings;
pipelineArgs.fOutputSwizzle = flushState->view()->swizzle();
return flushState->allocator()->make<GrPipeline>(pipelineArgs,
std::move(processorSet),
flushState->detachAppliedClip());
}
#ifdef SK_DEBUG
@ -186,17 +193,6 @@ bool GrSimpleMeshDrawOpHelperWithStencil::isCompatible(
fStencilSettings == that.fStencilSettings;
}
void GrSimpleMeshDrawOpHelperWithStencil::executeDrawsAndUploads(
const GrOp* op, GrOpFlushState* flushState, const SkRect& chainBounds) {
if (fProcessors) {
flushState->executeDrawsAndUploadsForMeshDrawOp(
op, chainBounds, std::move(*fProcessors), fPipelineFlags, fStencilSettings);
} else {
flushState->executeDrawsAndUploadsForMeshDrawOp(
op, chainBounds, GrProcessorSet::MakeEmptySet(), fPipelineFlags, fStencilSettings);
}
}
#ifdef SK_DEBUG
SkString GrSimpleMeshDrawOpHelperWithStencil::dumpInfo() const {
SkString result = INHERITED::dumpInfo();

View File

@ -122,11 +122,19 @@ public:
fAAType = static_cast<unsigned>(aaType);
}
void executeDrawsAndUploads(const GrOp*, GrOpFlushState*, const SkRect& chainBounds);
static const GrPipeline* CreatePipeline(
GrOpFlushState*,
GrProcessorSet&&,
GrPipeline::InputFlags fPipelineFlags,
const GrUserStencilSettings* = &GrUserStencilSettings::kUnused);
GrProcessorSet detachProcessorSet() {
return fProcessors ? std::move(*fProcessors) : GrProcessorSet::MakeEmptySet();
}
protected:
GrPipeline::InputFlags pipelineFlags() const { return fPipelineFlags; }
protected:
GrProcessorSet::Analysis finalizeProcessors(
const GrCaps& caps, const GrAppliedClip*, const GrUserStencilSettings*,
bool hasMixedSampledCoverage, GrClampType, GrProcessorAnalysisCoverage geometryCoverage,
@ -185,17 +193,19 @@ public:
using GrSimpleMeshDrawOpHelper::isTrivial;
using GrSimpleMeshDrawOpHelper::usesLocalCoords;
using GrSimpleMeshDrawOpHelper::compatibleWithCoverageAsAlpha;
using GrSimpleMeshDrawOpHelper::detachProcessorSet;
using GrSimpleMeshDrawOpHelper::pipelineFlags;
bool isCompatible(const GrSimpleMeshDrawOpHelperWithStencil& that, const GrCaps&,
const SkRect& thisBounds, const SkRect& thatBounds,
bool ignoreAAType = false) const;
void executeDrawsAndUploads(const GrOp*, GrOpFlushState*, const SkRect& chainBounds);
#ifdef SK_DEBUG
SkString dumpInfo() const;
#endif
const GrUserStencilSettings* stencilSettings() const { return fStencilSettings; }
private:
const GrUserStencilSettings* fStencilSettings;
typedef GrSimpleMeshDrawOpHelper INHERITED;

View File

@ -812,7 +812,12 @@ private:
}
void onExecute(GrOpFlushState* flushState, const SkRect& chainBounds) override {
fHelper.executeDrawsAndUploads(this, flushState, chainBounds);
auto pipeline = GrSimpleMeshDrawOpHelper::CreatePipeline(flushState,
fHelper.detachProcessorSet(),
fHelper.pipelineFlags(),
fHelper.stencilSettings());
flushState->executeDrawsAndUploadsForMeshDrawOp(this, chainBounds, pipeline);
}
const SkPMColor4f& color() const { return fShapes[0].fColor; }

View File

@ -228,7 +228,11 @@ private:
}
void onExecute(GrOpFlushState* flushState, const SkRect& chainBounds) override {
fHelper.executeDrawsAndUploads(this, flushState, chainBounds);
auto pipeline = GrSimpleMeshDrawOpHelper::CreatePipeline(flushState,
fHelper.detachProcessorSet(),
fHelper.pipelineFlags());
flushState->executeDrawsAndUploadsForMeshDrawOp(this, chainBounds, pipeline);
}
// TODO: override onCombineIfPossible
@ -520,7 +524,11 @@ void AAStrokeRectOp::onPrepareDraws(Target* target) {
}
void AAStrokeRectOp::onExecute(GrOpFlushState* flushState, const SkRect& chainBounds) {
fHelper.executeDrawsAndUploads(this, flushState, chainBounds);
auto pipeline = GrSimpleMeshDrawOpHelper::CreatePipeline(flushState,
fHelper.detachProcessorSet(),
fHelper.pipelineFlags());
flushState->executeDrawsAndUploadsForMeshDrawOp(this, chainBounds, pipeline);
}
sk_sp<const GrGpuBuffer> AAStrokeRectOp::GetIndexBuffer(GrResourceProvider* resourceProvider,

View File

@ -382,7 +382,12 @@ private:
}
void onExecute(GrOpFlushState* flushState, const SkRect& chainBounds) override {
fHelper.executeDrawsAndUploads(this, flushState, chainBounds);
auto pipeline = GrSimpleMeshDrawOpHelper::CreatePipeline(flushState,
fHelper.detachProcessorSet(),
fHelper.pipelineFlags(),
fHelper.stencilSettings());
flushState->executeDrawsAndUploadsForMeshDrawOp(this, chainBounds, pipeline);
}
Helper fHelper;

View File

@ -39,6 +39,7 @@
#include "src/gpu/ops/GrFillRectOp.h"
#include "src/gpu/ops/GrMeshDrawOp.h"
#include "src/gpu/ops/GrQuadPerEdgeAA.h"
#include "src/gpu/ops/GrSimpleMeshDrawOpHelper.h"
#include "src/gpu/ops/GrTextureOp.h"
namespace {
@ -883,8 +884,12 @@ private:
auto pipelineFlags = (GrAAType::kMSAA == fMetadata.aaType())
? GrPipeline::InputFlags::kHWAntialias
: GrPipeline::InputFlags::kNone;
flushState->executeDrawsAndUploadsForMeshDrawOp(
this, chainBounds, GrProcessorSet::MakeEmptySet(), pipelineFlags);
auto pipeline = GrSimpleMeshDrawOpHelper::CreatePipeline(flushState,
GrProcessorSet::MakeEmptySet(),
pipelineFlags);
flushState->executeDrawsAndUploadsForMeshDrawOp(this, chainBounds, pipeline);
}
CombineResult onCombineIfPossible(GrOp* t, const GrCaps& caps) override {

View File

@ -28,6 +28,7 @@
#include "src/gpu/glsl/GrGLSLGeometryProcessor.h"
#include "src/gpu/glsl/GrGLSLVarying.h"
#include "src/gpu/glsl/GrGLSLVertexGeoBuilder.h"
#include "src/gpu/ops/GrSimpleMeshDrawOpHelper.h"
GR_DECLARE_STATIC_UNIQUE_KEY(gIndexBufferKey);
@ -417,7 +418,22 @@ sk_sp<const GrBuffer> DrawMeshHelper::getIndexBuffer() {
}
void DrawMeshHelper::drawMesh(const GrMesh& mesh, GrPrimitiveType primitiveType) {
GrPipeline pipeline(GrScissorTest::kDisabled, SkBlendMode::kSrc, GrSwizzle::RGBA());
GrProcessorSet processorSet(SkBlendMode::kSrc);
// TODO: add a GrProcessorSet testing helper to make this easier
SkPMColor4f overrideColor;
processorSet.finalize(GrProcessorAnalysisColor(),
GrProcessorAnalysisCoverage::kNone,
fState->appliedClip(),
nullptr,
false,
fState->caps(),
GrClampType::kAuto,
&overrideColor);
auto pipeline = GrSimpleMeshDrawOpHelper::CreatePipeline(fState,
std::move(processorSet),
GrPipeline::InputFlags::kNone);
GrGeometryProcessor* mtp = GrMeshTestProcessor::Make(fState->allocator(),
mesh.isInstanced(), mesh.hasVertexData());
@ -426,7 +442,7 @@ void DrawMeshHelper::drawMesh(const GrMesh& mesh, GrPrimitiveType primitiveType)
fState->proxy()->numStencilSamples(),
fState->proxy()->backendFormat(),
fState->view()->origin(),
&pipeline,
pipeline,
mtp,
nullptr, nullptr, 0, primitiveType);

View File

@ -166,7 +166,11 @@ private:
}
void onExecute(GrOpFlushState* flushState, const SkRect& chainBounds) override {
fHelper.executeDrawsAndUploads(this, flushState, chainBounds);
auto pipeline = GrSimpleMeshDrawOpHelper::CreatePipeline(flushState,
fHelper.detachProcessorSet(),
fHelper.pipelineFlags());
flushState->executeDrawsAndUploadsForMeshDrawOp(this, chainBounds, pipeline);
}
Helper fHelper;

View File

@ -24,6 +24,7 @@
#include "src/gpu/glsl/GrGLSLGeometryProcessor.h"
#include "src/gpu/glsl/GrGLSLVarying.h"
#include "src/gpu/ops/GrMeshDrawOp.h"
#include "src/gpu/ops/GrSimpleMeshDrawOpHelper.h"
namespace {
class Op : public GrMeshDrawOp {
@ -124,8 +125,11 @@ private:
}
void onExecute(GrOpFlushState* flushState, const SkRect& chainBounds) override {
flushState->executeDrawsAndUploadsForMeshDrawOp(
this, chainBounds, GrProcessorSet::MakeEmptySet());
auto pipeline = GrSimpleMeshDrawOpHelper::CreatePipeline(flushState,
GrProcessorSet::MakeEmptySet(),
GrPipeline::InputFlags::kNone);
flushState->executeDrawsAndUploadsForMeshDrawOp(this, chainBounds, pipeline);
}
int fNumAttribs;

View File

@ -17,6 +17,7 @@
#include "src/gpu/glsl/GrGLSLGeometryProcessor.h"
#include "src/gpu/glsl/GrGLSLVarying.h"
#include "src/gpu/glsl/GrGLSLVertexGeoBuilder.h"
#include "src/gpu/ops/GrSimpleMeshDrawOpHelper.h"
namespace {
@ -160,7 +161,11 @@ void TestRectOp::onPrepareDraws(Target* target) {
}
void TestRectOp::onExecute(GrOpFlushState* flushState, const SkRect& chainBounds) {
flushState->executeDrawsAndUploadsForMeshDrawOp(this, chainBounds, std::move(fProcessorSet));
auto pipeline = GrSimpleMeshDrawOpHelper::CreatePipeline(flushState,
std::move(fProcessorSet),
GrPipeline::InputFlags::kNone);
flushState->executeDrawsAndUploadsForMeshDrawOp(this, chainBounds, pipeline);
}
} // anonymous namespace