Remove FixedDynamicState from GrProgramInfo and GrPipeline

Everybody uses explicit binding now.

Change-Id: Idb6f64104eddd31d28dd2ba19f9743520a4e5170
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/277541
Reviewed-by: Brian Salomon <bsalomon@google.com>
Commit-Queue: Chris Dalton <csmartdalton@google.com>
This commit is contained in:
Chris Dalton 2020-03-17 14:29:06 -06:00 committed by Skia Commit-Bot
parent 1c3bea4593
commit 304e14d883
27 changed files with 60 additions and 196 deletions

View File

@ -310,8 +310,6 @@ private:
void onExecute(GrOpFlushState* state, const SkRect& chainBounds) override { void onExecute(GrOpFlushState* state, const SkRect& chainBounds) override {
GrPipeline pipeline(GrScissorTest::kDisabled, SkBlendMode::kSrc, GrPipeline pipeline(GrScissorTest::kDisabled, SkBlendMode::kSrc,
state->drawOpArgs().outputSwizzle()); state->drawOpArgs().outputSwizzle());
GrPipeline::FixedDynamicState fixedDynamicState;
int tessellationPatchVertexCount; int tessellationPatchVertexCount;
std::unique_ptr<GrGeometryProcessor> shader; std::unique_ptr<GrGeometryProcessor> shader;
if (fTriPositions) { if (fTriPositions) {
@ -329,8 +327,8 @@ private:
GrProgramInfo programInfo(state->proxy()->numSamples(), state->proxy()->numStencilSamples(), GrProgramInfo programInfo(state->proxy()->numSamples(), state->proxy()->numStencilSamples(),
state->proxy()->backendFormat(), state->outputView()->origin(), state->proxy()->backendFormat(), state->outputView()->origin(),
&pipeline, shader.get(), &fixedDynamicState, &pipeline, shader.get(), GrPrimitiveType::kPatches,
GrPrimitiveType::kPatches, tessellationPatchVertexCount); tessellationPatchVertexCount);
state->bindPipeline(programInfo, SkRect::MakeIWH(kWidth, kHeight)); state->bindPipeline(programInfo, SkRect::MakeIWH(kWidth, kHeight));
state->bindBuffers(nullptr, nullptr, fVertexBuffer.get()); state->bindBuffers(nullptr, nullptr, fVertexBuffer.get());

View File

@ -49,17 +49,11 @@ void GrOpFlushState::executeDrawsAndUploadsForMeshDrawOp(
this->outputView()->origin(), this->outputView()->origin(),
pipeline, pipeline,
fCurrDraw->fGeometryProcessor, fCurrDraw->fGeometryProcessor,
fCurrDraw->fFixedDynamicState,
fCurrDraw->fPrimitiveType); fCurrDraw->fPrimitiveType);
fOpsRenderPass->bindPipeline(programInfo, chainBounds); this->bindPipelineAndScissorClip(programInfo, chainBounds);
if (programInfo.hasFixedScissor()) { this->bindTextures(programInfo.primProc(), fCurrDraw->fPrimProcProxies,
fOpsRenderPass->setScissorRect(programInfo.fixedScissor()); programInfo.pipeline());
}
auto primProcTextures = (programInfo.hasFixedPrimProcTextures()) ?
programInfo.fixedPrimProcTextures() : nullptr;
fOpsRenderPass->bindTextures(programInfo.primProc(), primProcTextures,
programInfo.pipeline());
for (int i = 0; i < fCurrDraw->fMeshCnt; ++i) { for (int i = 0; i < fCurrDraw->fMeshCnt; ++i) {
this->drawMesh(fCurrDraw->fMeshes[i]); this->drawMesh(fCurrDraw->fMeshes[i]);
} }
@ -141,20 +135,19 @@ void GrOpFlushState::recordDraw(
const GrGeometryProcessor* gp, const GrGeometryProcessor* gp,
const GrSimpleMesh meshes[], const GrSimpleMesh meshes[],
int meshCnt, int meshCnt,
const GrPipeline::FixedDynamicState* fixedDynamicState, const GrSurfaceProxy* const primProcProxies[],
GrPrimitiveType primitiveType) { GrPrimitiveType primitiveType) {
SkASSERT(fOpArgs); SkASSERT(fOpArgs);
SkDEBUGCODE(fOpArgs->validate()); SkDEBUGCODE(fOpArgs->validate());
bool firstDraw = fDraws.begin() == fDraws.end(); bool firstDraw = fDraws.begin() == fDraws.end();
auto& draw = fDraws.append(&fArena); auto& draw = fDraws.append(&fArena);
GrDeferredUploadToken token = fTokenTracker->issueDrawToken(); GrDeferredUploadToken token = fTokenTracker->issueDrawToken();
if (fixedDynamicState && fixedDynamicState->fPrimitiveProcessorTextures) { for (int i = 0; i < gp->numTextureSamplers(); ++i) {
for (int i = 0; i < gp->numTextureSamplers(); ++i) { SkASSERT(primProcProxies && primProcProxies[i]);
fixedDynamicState->fPrimitiveProcessorTextures[i]->ref(); primProcProxies[i]->ref();
}
} }
draw.fGeometryProcessor = gp; draw.fGeometryProcessor = gp;
draw.fFixedDynamicState = fixedDynamicState; draw.fPrimProcProxies = primProcProxies;
draw.fMeshes = meshes; draw.fMeshes = meshes;
draw.fMeshCnt = meshCnt; draw.fMeshCnt = meshCnt;
draw.fOp = fOpArgs->op(); draw.fOp = fOpArgs->op();
@ -230,9 +223,8 @@ void GrOpFlushState::drawMesh(const GrSimpleMesh& mesh) {
////////////////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////////////////
GrOpFlushState::Draw::~Draw() { GrOpFlushState::Draw::~Draw() {
if (fFixedDynamicState && fFixedDynamicState->fPrimitiveProcessorTextures) { for (int i = 0; i < fGeometryProcessor->numTextureSamplers(); ++i) {
for (int i = 0; i < fGeometryProcessor->numTextureSamplers(); ++i) { SkASSERT(fPrimProcProxies && fPrimProcProxies[i]);
fFixedDynamicState->fPrimitiveProcessorTextures[i]->unref(); fPrimProcProxies[i]->unref();
}
} }
} }

View File

@ -119,7 +119,7 @@ public:
void recordDraw(const GrGeometryProcessor*, void recordDraw(const GrGeometryProcessor*,
const GrSimpleMesh[], const GrSimpleMesh[],
int meshCnt, int meshCnt,
const GrPipeline::FixedDynamicState*, const GrSurfaceProxy* const primProcProxies[],
GrPrimitiveType) final; GrPrimitiveType) final;
void* makeVertexSpace(size_t vertexSize, int vertexCount, sk_sp<const GrBuffer>*, void* makeVertexSpace(size_t vertexSize, int vertexCount, sk_sp<const GrBuffer>*,
int* startVertex) final; int* startVertex) final;
@ -237,7 +237,8 @@ private:
// the stack (for CCPR). In either case this object does not need to manage its // the stack (for CCPR). In either case this object does not need to manage its
// lifetime. // lifetime.
const GrGeometryProcessor* fGeometryProcessor = nullptr; const GrGeometryProcessor* fGeometryProcessor = nullptr;
const GrPipeline::FixedDynamicState* fFixedDynamicState = nullptr; // Must have GrPrimitiveProcessor::numTextureSamplers() entries. Can be null if no samplers.
const GrSurfaceProxy* const* fPrimProcProxies = nullptr;
const GrSimpleMesh* fMeshes = nullptr; const GrSimpleMesh* fMeshes = nullptr;
const GrOp* fOp = nullptr; const GrOp* fOp = nullptr;
int fMeshCnt = 0; int fMeshCnt = 0;

View File

@ -61,5 +61,5 @@ void GrPathRendering::drawPath(GrRenderTarget* renderTarget,
*fGpu->caps())) { *fGpu->caps())) {
fGpu->xferBarrier(renderTarget, barrierType); fGpu->xferBarrier(renderTarget, barrierType);
} }
this->onDrawPath(renderTarget, programInfo, stencilPassSettings, path); this->onDrawPath(stencilPassSettings, path);
} }

View File

@ -124,10 +124,7 @@ protected:
GrPathRendering(GrGpu* gpu) : fGpu(gpu) { } GrPathRendering(GrGpu* gpu) : fGpu(gpu) { }
virtual void onStencilPath(const StencilPathArgs&, const GrPath*) = 0; virtual void onStencilPath(const StencilPathArgs&, const GrPath*) = 0;
virtual void onDrawPath(GrRenderTarget*, virtual void onDrawPath(const GrStencilSettings&, const GrPath*) = 0;
const GrProgramInfo&,
const GrStencilSettings&,
const GrPath*) = 0;
GrGpu* fGpu; GrGpu* fGpu;
private: private:

View File

@ -42,10 +42,7 @@ void GrGLPathRendering::setProjectionMatrix(const SkMatrix&, const SkISize&, GrS
sk_sp<GrPath> GrGLPathRendering::createPath(const SkPath&, const GrStyle&) { return nullptr; } sk_sp<GrPath> GrGLPathRendering::createPath(const SkPath&, const GrStyle&) { return nullptr; }
void GrGLPathRendering::onDrawPath(GrRenderTarget*, void GrGLPathRendering::onDrawPath(const GrStencilSettings&, const GrPath*) {}
const GrProgramInfo&,
const GrStencilSettings&,
const GrPath*) {}
void GrGLPathRendering::onStencilPath(const StencilPathArgs&, const GrPath*) {} void GrGLPathRendering::onStencilPath(const StencilPathArgs&, const GrPath*) {}

View File

@ -74,19 +74,6 @@ public:
GrSwizzle fOutputSwizzle; GrSwizzle fOutputSwizzle;
}; };
/**
* Some state can be changed between GrMeshes without changing GrPipelines. This is generally
* less expensive then using multiple pipelines. Such state is called "dynamic state".
* Use this to specify state that does not vary between GrMeshes.
**/
struct FixedDynamicState {
explicit FixedDynamicState(const SkIRect& scissorRect) : fScissorRect(scissorRect) {}
FixedDynamicState() = default;
SkIRect fScissorRect = SkIRect::MakeEmpty();
// Must have GrPrimitiveProcessor::numTextureSamplers() entries. Can be null if no samplers.
GrSurfaceProxy** fPrimitiveProcessorTextures = nullptr;
};
/** /**
* Creates a simple pipeline with default settings and no processors. The provided blend mode * Creates a simple pipeline with default settings and no processors. The provided blend mode
* must be "Porter Duff" (<= kLastCoeffMode). If using GrScissorTest::kEnabled, the caller must * must be "Porter Duff" (<= kLastCoeffMode). If using GrScissorTest::kEnabled, the caller must

View File

@ -28,53 +28,27 @@ void GrProgramInfo::validate(bool flushTime) const {
if (flushTime) { if (flushTime) {
SkASSERT(fPipeline->allProxiesInstantiated()); SkASSERT(fPipeline->allProxiesInstantiated());
} }
if (this->hasFixedPrimProcTextures()) {
SkASSERT(fPrimProc->numTextureSamplers());
}
if (!fPipeline->isScissorTestEnabled()) {
SkASSERT(!this->hasFixedScissor());
}
} }
void GrProgramInfo::checkAllInstantiated() const { void GrProgramInfo::checkAllInstantiated() const {
if (this->hasFixedPrimProcTextures()) {
auto fixedPrimProcTextures = this->fixedPrimProcTextures();
for (int s = 0; s < this->primProc().numTextureSamplers(); ++s) {
SkASSERT(fixedPrimProcTextures[s]->isInstantiated());
}
}
for (auto [sampler, fp] : GrFragmentProcessor::PipelineTextureSamplerRange(this->pipeline())) { for (auto [sampler, fp] : GrFragmentProcessor::PipelineTextureSamplerRange(this->pipeline())) {
SkASSERT(sampler.proxy()->isInstantiated()); SkASSERT(sampler.proxy()->isInstantiated());
} }
} }
void GrProgramInfo::checkMSAAAndMIPSAreResolved() const { void GrProgramInfo::checkMSAAAndMIPSAreResolved() const {
auto assertResolved = [](GrTexture* tex, GrSamplerState sampler) { for (auto [sampler, fp] : GrFragmentProcessor::PipelineTextureSamplerRange(this->pipeline())) {
GrTexture* tex = sampler.peekTexture();
SkASSERT(tex); SkASSERT(tex);
// Ensure mipmaps were all resolved ahead of time by the DAG. // Ensure mipmaps were all resolved ahead of time by the DAG.
if (GrSamplerState::Filter::kMipMap == sampler.filter() && if (GrSamplerState::Filter::kMipMap == sampler.samplerState().filter() &&
(tex->width() != 1 || tex->height() != 1)) { (tex->width() != 1 || tex->height() != 1)) {
// There are some cases where we might be given a non-mipmapped texture with a mipmap // There are some cases where we might be given a non-mipmapped texture with a mipmap
// filter. See skbug.com/7094. // filter. See skbug.com/7094.
SkASSERT(tex->texturePriv().mipMapped() != GrMipMapped::kYes || SkASSERT(tex->texturePriv().mipMapped() != GrMipMapped::kYes ||
!tex->texturePriv().mipMapsAreDirty()); !tex->texturePriv().mipMapsAreDirty());
} }
};
if (this->hasFixedPrimProcTextures()) {
auto fixedPrimProcTextures = this->fixedPrimProcTextures();
for (int s = 0; s < this->primProc().numTextureSamplers(); ++s) {
auto* tex = fixedPrimProcTextures[s]->peekTexture();
assertResolved(tex, this->primProc().textureSampler(s).samplerState());
}
}
for (auto [sampler, fp] : GrFragmentProcessor::PipelineTextureSamplerRange(this->pipeline())) {
assertResolved(sampler.peekTexture(), sampler.samplerState());
} }
} }

View File

@ -22,7 +22,6 @@ public:
GrSurfaceOrigin origin, GrSurfaceOrigin origin,
const GrPipeline* pipeline, const GrPipeline* pipeline,
const GrPrimitiveProcessor* primProc, const GrPrimitiveProcessor* primProc,
const GrPipeline::FixedDynamicState* fixedDynamicState,
GrPrimitiveType primitiveType, GrPrimitiveType primitiveType,
uint8_t tessellationPatchVertexCount = 0) uint8_t tessellationPatchVertexCount = 0)
: fNumRasterSamples(pipeline->isStencilEnabled() ? numStencilSamples : numSamples) : fNumRasterSamples(pipeline->isStencilEnabled() ? numStencilSamples : numSamples)
@ -31,7 +30,6 @@ public:
, fOrigin(origin) , fOrigin(origin)
, fPipeline(pipeline) , fPipeline(pipeline)
, fPrimProc(primProc) , fPrimProc(primProc)
, fFixedDynamicState(fixedDynamicState)
, fPrimitiveType(primitiveType) , fPrimitiveType(primitiveType)
, fTessellationPatchVertexCount(tessellationPatchVertexCount) { , fTessellationPatchVertexCount(tessellationPatchVertexCount) {
SkASSERT(fNumRasterSamples > 0); SkASSERT(fNumRasterSamples > 0);
@ -55,25 +53,6 @@ public:
GrSurfaceOrigin origin() const { return fOrigin; } GrSurfaceOrigin origin() const { return fOrigin; }
const GrPipeline& pipeline() const { return *fPipeline; } const GrPipeline& pipeline() const { return *fPipeline; }
const GrPrimitiveProcessor& primProc() const { return *fPrimProc; } const GrPrimitiveProcessor& primProc() const { return *fPrimProc; }
const GrPipeline::FixedDynamicState* fixedDynamicState() const { return fFixedDynamicState; }
bool hasFixedScissor() const { return fPipeline->isScissorTestEnabled() && fFixedDynamicState; }
const SkIRect& fixedScissor() const {
SkASSERT(this->hasFixedScissor());
return fFixedDynamicState->fScissorRect;
}
bool hasFixedPrimProcTextures() const {
return fFixedDynamicState && fFixedDynamicState->fPrimitiveProcessorTextures;
}
const GrSurfaceProxy* const* fixedPrimProcTextures() const {
SkASSERT(this->hasFixedPrimProcTextures());
return fFixedDynamicState->fPrimitiveProcessorTextures;
}
GrPrimitiveType primitiveType() const { return fPrimitiveType; } GrPrimitiveType primitiveType() const { return fPrimitiveType; }
uint8_t tessellationPatchVertexCount() const { uint8_t tessellationPatchVertexCount() const {
@ -111,7 +90,6 @@ private:
const GrSurfaceOrigin fOrigin; const GrSurfaceOrigin fOrigin;
const GrPipeline* fPipeline; const GrPipeline* fPipeline;
const GrPrimitiveProcessor* fPrimProc; const GrPrimitiveProcessor* fPrimProc;
const GrPipeline::FixedDynamicState* fFixedDynamicState;
GrProcessor::CustomFeatures fRequestedFeatures; GrProcessor::CustomFeatures fRequestedFeatures;
GrPrimitiveType fPrimitiveType; GrPrimitiveType fPrimitiveType;
uint8_t fTessellationPatchVertexCount; // GrPrimType::kPatches. uint8_t fTessellationPatchVertexCount; // GrPrimType::kPatches.

View File

@ -200,7 +200,7 @@ void GrCCCoverageProcessor::bindPipeline(GrOpFlushState* flushState, const GrPip
GrProgramInfo programInfo(flushState->proxy()->numSamples(), GrProgramInfo programInfo(flushState->proxy()->numSamples(),
flushState->proxy()->numStencilSamples(), flushState->proxy()->numStencilSamples(),
flushState->proxy()->backendFormat(), flushState->proxy()->backendFormat(),
flushState->outputView()->origin(), &pipeline, this, nullptr, flushState->outputView()->origin(), &pipeline, this,
this->primType()); this->primType());
flushState->bindPipeline(programInfo, drawBounds); flushState->bindPipeline(programInfo, drawBounds);
} }

View File

@ -138,7 +138,7 @@ void GrCCPathProcessor::drawPaths(GrOpFlushState* flushState, const GrPipeline&
GrRenderTargetProxy* rtProxy = flushState->proxy(); GrRenderTargetProxy* rtProxy = flushState->proxy();
GrProgramInfo programInfo(rtProxy->numSamples(), rtProxy->numStencilSamples(), GrProgramInfo programInfo(rtProxy->numSamples(), rtProxy->numStencilSamples(),
rtProxy->backendFormat(), flushState->outputView()->origin(), rtProxy->backendFormat(), flushState->outputView()->origin(),
&pipeline, this, nullptr, primitiveType); &pipeline, this, primitiveType);
flushState->bindPipelineAndScissorClip(programInfo, bounds); flushState->bindPipelineAndScissorClip(programInfo, bounds);
flushState->bindTextures(*this, atlasProxy, pipeline); flushState->bindTextures(*this, atlasProxy, pipeline);

View File

@ -738,7 +738,7 @@ void GrCCStroker::drawLog2Strokes(int numSegmentsLog2, GrOpFlushState* flushStat
GrProgramInfo programInfo(flushState->proxy()->numSamples(), GrProgramInfo programInfo(flushState->proxy()->numSamples(),
flushState->proxy()->numStencilSamples(), flushState->proxy()->numStencilSamples(),
flushState->proxy()->backendFormat(), flushState->proxy()->backendFormat(),
flushState->outputView()->origin(), &pipeline, &processor, nullptr, flushState->outputView()->origin(), &pipeline, &processor,
GrPrimitiveType::kTriangleStrip); GrPrimitiveType::kTriangleStrip);
flushState->bindPipeline(programInfo, SkRect::Make(drawBounds)); flushState->bindPipeline(programInfo, SkRect::Make(drawBounds));

View File

@ -152,7 +152,7 @@ void GrStencilAtlasOp::onExecute(GrOpFlushState* flushState, const SkRect& chain
flushState->proxy()->numStencilSamples(), flushState->proxy()->numStencilSamples(),
flushState->proxy()->backendFormat(), flushState->proxy()->backendFormat(),
flushState->outputView()->origin(), &resolvePipeline, &primProc, flushState->outputView()->origin(), &resolvePipeline, &primProc,
nullptr, GrPrimitiveType::kTriangleStrip); GrPrimitiveType::kTriangleStrip);
flushState->bindPipeline(programInfo, SkRect::Make(drawBoundsRect)); flushState->bindPipeline(programInfo, SkRect::Make(drawBoundsRect));
flushState->setScissorRect(drawBoundsRect); flushState->setScissorRect(drawBoundsRect);

View File

@ -109,20 +109,8 @@ void GrGLPathRendering::onStencilPath(const StencilPathArgs& args, const GrPath*
} }
} }
void GrGLPathRendering::onDrawPath(GrRenderTarget* renderTarget, void GrGLPathRendering::onDrawPath(const GrStencilSettings& stencilPassSettings,
const GrProgramInfo& programInfo,
const GrStencilSettings& stencilPassSettings,
const GrPath* path) { const GrPath* path) {
if (!this->gpu()->flushGLState(renderTarget, programInfo)) {
return;
}
if (programInfo.hasFixedScissor()) {
this->gpu()->flushScissorRect(programInfo.fixedScissor(), renderTarget->width(),
renderTarget->height(), programInfo.origin());
}
this->gpu()->currentProgram()->bindTextures(programInfo.primProc(), nullptr,
programInfo.pipeline());
const GrGLPath* glPath = static_cast<const GrGLPath*>(path); const GrGLPath* glPath = static_cast<const GrGLPath*>(path);
this->flushPathStencilSettings(stencilPassSettings); this->flushPathStencilSettings(stencilPassSettings);

View File

@ -65,8 +65,7 @@ public:
protected: protected:
void onStencilPath(const StencilPathArgs&, const GrPath*) override; void onStencilPath(const StencilPathArgs&, const GrPath*) override;
void onDrawPath(GrRenderTarget*, const GrProgramInfo&, const GrStencilSettings&, void onDrawPath(const GrStencilSettings&, const GrPath*) override;
const GrPath*) override;
private: private:
/** /**

View File

@ -305,16 +305,16 @@ void GrAtlasTextOp::onPrepareDraws(Target* target) {
static_assert(GrDistanceFieldA8TextGeoProc::kMaxTextures == kMaxTextures); static_assert(GrDistanceFieldA8TextGeoProc::kMaxTextures == kMaxTextures);
static_assert(GrDistanceFieldLCDTextGeoProc::kMaxTextures == kMaxTextures); static_assert(GrDistanceFieldLCDTextGeoProc::kMaxTextures == kMaxTextures);
auto fixedDynamicState = target->makeFixedDynamicState(kMaxTextures); auto primProcProxies = target->allocPrimProcProxyPtrs(kMaxTextures);
for (unsigned i = 0; i < numActiveViews; ++i) { for (unsigned i = 0; i < numActiveViews; ++i) {
fixedDynamicState->fPrimitiveProcessorTextures[i] = views[i].proxy(); primProcProxies[i] = views[i].proxy();
// This op does not know its atlas proxies when it is added to a GrOpsTasks, so the proxies // This op does not know its atlas proxies when it is added to a GrOpsTasks, so the proxies
// don't get added during the visitProxies call. Thus we add them here. // don't get added during the visitProxies call. Thus we add them here.
target->sampledProxyArray()->push_back(views[i].proxy()); target->sampledProxyArray()->push_back(views[i].proxy());
} }
FlushInfo flushInfo; FlushInfo flushInfo;
flushInfo.fFixedDynamicState = fixedDynamicState; flushInfo.fPrimProcProxies = primProcProxies;
bool vmPerspective = fGeoData[0].fDrawMatrix.hasPerspective(); bool vmPerspective = fGeoData[0].fDrawMatrix.hasPerspective();
if (this->usesDistanceFields()) { if (this->usesDistanceFields()) {
@ -487,13 +487,13 @@ void GrAtlasTextOp::createDrawForGeneratedGlyphs(
// During preparation the number of atlas pages has increased. // During preparation the number of atlas pages has increased.
// Update the proxies used in the GP to match. // Update the proxies used in the GP to match.
for (unsigned i = gp->numTextureSamplers(); i < numActiveViews; ++i) { for (unsigned i = gp->numTextureSamplers(); i < numActiveViews; ++i) {
flushInfo->fFixedDynamicState->fPrimitiveProcessorTextures[i] = views[i].proxy(); flushInfo->fPrimProcProxies[i] = views[i].proxy();
// This op does not know its atlas proxies when it is added to a GrOpsTasks, so the // This op does not know its atlas proxies when it is added to a GrOpsTasks, so the
// proxies don't get added during the visitProxies call. Thus we add them here. // proxies don't get added during the visitProxies call. Thus we add them here.
target->sampledProxyArray()->push_back(views[i].proxy()); target->sampledProxyArray()->push_back(views[i].proxy());
// These will get unreffed when the previously recorded draws destruct. // These will get unreffed when the previously recorded draws destruct.
for (int d = 0; d < flushInfo->fNumDraws; ++d) { for (int d = 0; d < flushInfo->fNumDraws; ++d) {
flushInfo->fFixedDynamicState->fPrimitiveProcessorTextures[i]->ref(); flushInfo->fPrimProcProxies[i]->ref();
} }
} }
if (this->usesDistanceFields()) { if (this->usesDistanceFields()) {
@ -515,7 +515,7 @@ void GrAtlasTextOp::createDrawForGeneratedGlyphs(
mesh->setIndexedPatterned(flushInfo->fIndexBuffer, kIndicesPerGlyph, flushInfo->fGlyphsToFlush, mesh->setIndexedPatterned(flushInfo->fIndexBuffer, kIndicesPerGlyph, flushInfo->fGlyphsToFlush,
maxGlyphsPerDraw, flushInfo->fVertexBuffer, kVerticesPerGlyph, maxGlyphsPerDraw, flushInfo->fVertexBuffer, kVerticesPerGlyph,
flushInfo->fVertexOffset); flushInfo->fVertexOffset);
target->recordDraw(flushInfo->fGeometryProcessor, mesh, 1, flushInfo->fFixedDynamicState, target->recordDraw(flushInfo->fGeometryProcessor, mesh, 1, flushInfo->fPrimProcProxies,
GrPrimitiveType::kTriangles); GrPrimitiveType::kTriangles);
flushInfo->fVertexOffset += kVerticesPerGlyph * flushInfo->fGlyphsToFlush; flushInfo->fVertexOffset += kVerticesPerGlyph * flushInfo->fGlyphsToFlush;
flushInfo->fGlyphsToFlush = 0; flushInfo->fGlyphsToFlush = 0;

View File

@ -105,7 +105,7 @@ private:
sk_sp<const GrBuffer> fVertexBuffer; sk_sp<const GrBuffer> fVertexBuffer;
sk_sp<const GrBuffer> fIndexBuffer; sk_sp<const GrBuffer> fIndexBuffer;
GrGeometryProcessor* fGeometryProcessor; GrGeometryProcessor* fGeometryProcessor;
GrPipeline::FixedDynamicState* fFixedDynamicState; const GrSurfaceProxy** fPrimProcProxies;
int fGlyphsToFlush = 0; int fGlyphsToFlush = 0;
int fVertexOffset = 0; int fVertexOffset = 0;
int fNumDraws = 0; int fNumDraws = 0;

View File

@ -77,14 +77,6 @@ std::unique_ptr<GrDrawOp> GrDrawPathOp::Make(GrRecordingContext* context,
} }
void GrDrawPathOp::onExecute(GrOpFlushState* flushState, const SkRect& chainBounds) { void GrDrawPathOp::onExecute(GrOpFlushState* flushState, const SkRect& chainBounds) {
GrPipeline::FixedDynamicState* fixedDynamicState = nullptr, storage;
const GrAppliedClip* appliedClip = flushState->appliedClip();
if (appliedClip && appliedClip->scissorState().enabled()) {
storage.fScissorRect = appliedClip->scissorState().rect();
fixedDynamicState = &storage;
}
GrPipeline::InputFlags pipelineFlags = GrPipeline::InputFlags::kNone; GrPipeline::InputFlags pipelineFlags = GrPipeline::InputFlags::kNone;
if (this->doAA()) { if (this->doAA()) {
pipelineFlags |= GrPipeline::InputFlags::kHWAntialias; pipelineFlags |= GrPipeline::InputFlags::kHWAntialias;
@ -104,9 +96,11 @@ void GrDrawPathOp::onExecute(GrOpFlushState* flushState, const SkRect& chainBoun
flushState->outputView()->origin(), flushState->outputView()->origin(),
pipeline, pipeline,
pathProc.get(), pathProc.get(),
fixedDynamicState,
GrPrimitiveType::kPath); GrPrimitiveType::kPath);
flushState->bindPipelineAndScissorClip(programInfo, this->bounds());
flushState->bindTextures(programInfo.primProc(), nullptr, programInfo.pipeline());
GrStencilSettings stencil; GrStencilSettings stencil;
init_stencil_pass_settings(*flushState, this->fillType(), &stencil); init_stencil_pass_settings(*flushState, this->fillType(), &stencil);
flushState->gpu()->pathRendering()->drawPath(proxy->peekRenderTarget(), flushState->gpu()->pathRendering()->drawPath(proxy->peekRenderTarget(),

View File

@ -85,8 +85,8 @@ void GrMeshDrawOp::PatternHelper::recordDraw(Target* target, const GrGeometryPro
void GrMeshDrawOp::PatternHelper::recordDraw( void GrMeshDrawOp::PatternHelper::recordDraw(
Target* target, Target* target,
const GrGeometryProcessor* gp, const GrGeometryProcessor* gp,
const GrPipeline::FixedDynamicState* fixedDynamicState) const { const GrSurfaceProxy* const primProcProxies[]) const {
target->recordDraw(gp, fMesh, 1, fixedDynamicState, fPrimitiveType); target->recordDraw(gp, fMesh, 1, primProcProxies, fPrimitiveType);
} }
////////////////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////////////////
@ -102,26 +102,3 @@ GrMeshDrawOp::QuadHelper::QuadHelper(Target* target, size_t vertexStride, int qu
GrResourceProvider::NumIndicesPerNonAAQuad(), quadsToDraw, GrResourceProvider::NumIndicesPerNonAAQuad(), quadsToDraw,
GrResourceProvider::MaxNumNonAAQuads()); GrResourceProvider::MaxNumNonAAQuads());
} }
//////////////////////////////////////////////////////////////////////////////
GrPipeline::FixedDynamicState* GrMeshDrawOp::Target::MakeFixedDynamicState(
SkArenaAlloc* arena, const GrAppliedClip* clip, int numPrimProcTextures) {
bool haveScissor = clip && clip->scissorState().enabled();
if (haveScissor || numPrimProcTextures) {
auto result = arena->make<GrPipeline::FixedDynamicState>();
if (haveScissor) {
result->fScissorRect = clip->scissorState().rect();
}
if (numPrimProcTextures) {
result->fPrimitiveProcessorTextures = arena->makeArrayDefault<GrSurfaceProxy*>(
numPrimProcTextures);
}
return result;
}
return nullptr;
}

View File

@ -57,7 +57,7 @@ protected:
/** Called to issue draws to the GrMeshDrawOp::Target.*/ /** Called to issue draws to the GrMeshDrawOp::Target.*/
void recordDraw(Target*, const GrGeometryProcessor*) const; void recordDraw(Target*, const GrGeometryProcessor*) const;
void recordDraw(Target*, const GrGeometryProcessor*, void recordDraw(Target*, const GrGeometryProcessor*,
const GrPipeline::FixedDynamicState*) const; const GrSurfaceProxy* const primProcProxies[]) const;
void* vertices() const { return fVertices; } void* vertices() const { return fVertices; }
GrSimpleMesh* mesh() { return fMesh; } GrSimpleMesh* mesh() { return fMesh; }
@ -130,24 +130,23 @@ class GrMeshDrawOp::Target {
public: public:
virtual ~Target() {} virtual ~Target() {}
/** Adds a draw of a mesh. */ /** Adds a draw of a mesh. 'primProcProxies' must have
* GrPrimitiveProcessor::numTextureSamplers() entries. Can be null if no samplers.
*/
virtual void recordDraw(const GrGeometryProcessor*, virtual void recordDraw(const GrGeometryProcessor*,
const GrSimpleMesh[], const GrSimpleMesh[],
int meshCnt, int meshCnt,
const GrPipeline::FixedDynamicState*, const GrSurfaceProxy* const primProcProxies[],
GrPrimitiveType) = 0; GrPrimitiveType) = 0;
/** /**
* Helper for drawing GrSimpleMesh(es) with zero primProc textures and no dynamic state besides * Helper for drawing GrSimpleMesh(es) with zero primProc textures.
* the scissor clip.
*/ */
void recordDraw(const GrGeometryProcessor* gp, void recordDraw(const GrGeometryProcessor* gp,
const GrSimpleMesh meshes[], const GrSimpleMesh meshes[],
int meshCnt, int meshCnt,
GrPrimitiveType primitiveType) { GrPrimitiveType primitiveType) {
static constexpr int kZeroPrimProcTextures = 0; this->recordDraw(gp, meshes, meshCnt, nullptr, primitiveType);
auto fixedDynamicState = this->makeFixedDynamicState(kZeroPrimProcTextures);
this->recordDraw(gp, meshes, meshCnt, fixedDynamicState, primitiveType);
} }
/** /**
@ -191,15 +190,8 @@ public:
GrSimpleMesh* allocMesh() { return this->allocator()->make<GrSimpleMesh>(); } GrSimpleMesh* allocMesh() { return this->allocator()->make<GrSimpleMesh>(); }
GrSimpleMesh* allocMeshes(int n) { return this->allocator()->makeArray<GrSimpleMesh>(n); } GrSimpleMesh* allocMeshes(int n) { return this->allocator()->makeArray<GrSimpleMesh>(n); }
const GrSurfaceProxy** allocPrimProcProxyPtrs(int n) {
static GrPipeline::FixedDynamicState* MakeFixedDynamicState(SkArenaAlloc*, return this->allocator()->makeArray<const GrSurfaceProxy*>(n);
const GrAppliedClip* clip,
int numPrimitiveProcessorTextures);
GrPipeline::FixedDynamicState* makeFixedDynamicState(int numPrimitiveProcessorTextures) {
return MakeFixedDynamicState(this->allocator(), this->appliedClip(),
numPrimitiveProcessorTextures);
} }
virtual GrRenderTargetProxy* proxy() const = 0; virtual GrRenderTargetProxy* proxy() const = 0;

View File

@ -164,14 +164,7 @@ GrProgramInfo* GrSimpleMeshDrawOpHelper::CreateProgramInfo(
GrProcessorSet&& processorSet, GrProcessorSet&& processorSet,
GrPrimitiveType primitiveType, GrPrimitiveType primitiveType,
GrPipeline::InputFlags pipelineFlags, GrPipeline::InputFlags pipelineFlags,
const GrUserStencilSettings* stencilSettings, const GrUserStencilSettings* stencilSettings) {
GrPipeline::FixedDynamicState* fixedDynamicState) {
if (!fixedDynamicState) {
static constexpr int kZeroPrimProcTextures = 0;
fixedDynamicState = GrMeshDrawOp::Target::MakeFixedDynamicState(arena, &appliedClip,
kZeroPrimProcTextures);
}
auto pipeline = CreatePipeline(caps, auto pipeline = CreatePipeline(caps,
arena, arena,
outputView, outputView,
@ -189,7 +182,6 @@ GrProgramInfo* GrSimpleMeshDrawOpHelper::CreateProgramInfo(
outputView->origin(), outputView->origin(),
pipeline, pipeline,
geometryProcessor, geometryProcessor,
fixedDynamicState,
primitiveType); primitiveType);
return tmp; return tmp;
} }

View File

@ -154,8 +154,7 @@ public:
GrPipeline::InputFlags pipelineFlags GrPipeline::InputFlags pipelineFlags
= GrPipeline::InputFlags::kNone, = GrPipeline::InputFlags::kNone,
const GrUserStencilSettings* const GrUserStencilSettings*
= &GrUserStencilSettings::kUnused, = &GrUserStencilSettings::kUnused);
GrPipeline::FixedDynamicState* = nullptr);
GrProgramInfo* createProgramInfo(const GrCaps*, GrProgramInfo* createProgramInfo(const GrCaps*,
SkArenaAlloc*, SkArenaAlloc*,

View File

@ -306,7 +306,7 @@ private:
sk_sp<const GrBuffer> fVertexBuffer; sk_sp<const GrBuffer> fVertexBuffer;
sk_sp<const GrBuffer> fIndexBuffer; sk_sp<const GrBuffer> fIndexBuffer;
GrGeometryProcessor* fGeometryProcessor; GrGeometryProcessor* fGeometryProcessor;
GrPipeline::FixedDynamicState* fFixedDynamicState; const GrSurfaceProxy** fPrimProcProxies;
int fVertexOffset; int fVertexOffset;
int fInstancesToFlush; int fInstancesToFlush;
}; };
@ -338,13 +338,13 @@ private:
static_assert(GrBitmapTextGeoProc::kMaxTextures == kMaxTextures); static_assert(GrBitmapTextGeoProc::kMaxTextures == kMaxTextures);
FlushInfo flushInfo; FlushInfo flushInfo;
flushInfo.fFixedDynamicState = target->makeFixedDynamicState(kMaxTextures); flushInfo.fPrimProcProxies = target->allocPrimProcProxyPtrs(kMaxTextures);
int numActiveProxies = fAtlas->numActivePages(); int numActiveProxies = fAtlas->numActivePages();
const auto views = fAtlas->getViews(); const auto views = fAtlas->getViews();
for (int i = 0; i < numActiveProxies; ++i) { for (int i = 0; i < numActiveProxies; ++i) {
// This op does not know its atlas proxies when it is added to a GrOpsTasks, so the // This op does not know its atlas proxies when it is added to a GrOpsTasks, so the
// proxies don't get added during the visitProxies call. Thus we add them here. // proxies don't get added during the visitProxies call. Thus we add them here.
flushInfo.fFixedDynamicState->fPrimitiveProcessorTextures[i] = views[i].proxy(); flushInfo.fPrimProcProxies[i] = views[i].proxy();
target->sampledProxyArray()->push_back(views[i].proxy()); target->sampledProxyArray()->push_back(views[i].proxy());
} }
@ -798,7 +798,7 @@ private:
const auto views = fAtlas->getViews(); const auto views = fAtlas->getViews();
if (gp->numTextureSamplers() != numAtlasTextures) { if (gp->numTextureSamplers() != numAtlasTextures) {
for (int i = gp->numTextureSamplers(); i < numAtlasTextures; ++i) { for (int i = gp->numTextureSamplers(); i < numAtlasTextures; ++i) {
flushInfo->fFixedDynamicState->fPrimitiveProcessorTextures[i] = views[i].proxy(); flushInfo->fPrimProcProxies[i] = views[i].proxy();
// This op does not know its atlas proxies when it is added to a GrOpsTasks, so the // This op does not know its atlas proxies when it is added to a GrOpsTasks, so the
// proxies don't get added during the visitProxies call. Thus we add them here. // proxies don't get added during the visitProxies call. Thus we add them here.
target->sampledProxyArray()->push_back(views[i].proxy()); target->sampledProxyArray()->push_back(views[i].proxy());
@ -825,8 +825,8 @@ private:
flushInfo->fVertexBuffer, flushInfo->fVertexBuffer,
GrResourceProvider::NumVertsPerNonAAQuad(), GrResourceProvider::NumVertsPerNonAAQuad(),
flushInfo->fVertexOffset); flushInfo->fVertexOffset);
target->recordDraw(flushInfo->fGeometryProcessor, mesh, 1, target->recordDraw(flushInfo->fGeometryProcessor, mesh, 1, flushInfo->fPrimProcProxies,
flushInfo->fFixedDynamicState, GrPrimitiveType::kTriangles); GrPrimitiveType::kTriangles);
flushInfo->fVertexOffset += GrResourceProvider::NumVertsPerNonAAQuad() * flushInfo->fVertexOffset += GrResourceProvider::NumVertsPerNonAAQuad() *
flushInfo->fInstancesToFlush; flushInfo->fInstancesToFlush;
flushInfo->fInstancesToFlush = 0; flushInfo->fInstancesToFlush = 0;

View File

@ -173,7 +173,7 @@ void GrDrawAtlasPathOp::onExecute(GrOpFlushState* state, const SkRect& chainBoun
GrProgramInfo programInfo(state->proxy()->numSamples(), state->proxy()->numStencilSamples(), GrProgramInfo programInfo(state->proxy()->numSamples(), state->proxy()->numStencilSamples(),
state->proxy()->backendFormat(), state->outputView()->origin(), state->proxy()->backendFormat(), state->outputView()->origin(),
&pipeline, &shader, nullptr, GrPrimitiveType::kTriangleStrip); &pipeline, &shader, GrPrimitiveType::kTriangleStrip);
state->bindPipelineAndScissorClip(programInfo, this->bounds()); state->bindPipelineAndScissorClip(programInfo, this->bounds());
state->bindTextures(shader, *fAtlasProxy, pipeline); state->bindTextures(shader, *fAtlasProxy, pipeline);

View File

@ -40,7 +40,7 @@ public:
ProgramInfo(const GrRenderTargetProxy* proxy, GrSurfaceOrigin origin, ProgramInfo(const GrRenderTargetProxy* proxy, GrSurfaceOrigin origin,
const GrPipeline* pipeline, const GrPathShader* shader) const GrPipeline* pipeline, const GrPathShader* shader)
: GrProgramInfo(proxy->numSamples(), proxy->numStencilSamples(), : GrProgramInfo(proxy->numSamples(), proxy->numStencilSamples(),
proxy->backendFormat(), origin, pipeline, shader, nullptr, proxy->backendFormat(), origin, pipeline, shader,
shader->fPrimitiveType, shader->fTessellationPatchVertexCount) { shader->fPrimitiveType, shader->fTessellationPatchVertexCount) {
} }
}; };

View File

@ -461,7 +461,7 @@ GrOpsRenderPass* DrawMeshHelper::bindPipeline(GrPrimitiveType primitiveType, boo
GrProgramInfo programInfo(fState->proxy()->numSamples(), fState->proxy()->numStencilSamples(), GrProgramInfo programInfo(fState->proxy()->numSamples(), fState->proxy()->numStencilSamples(),
fState->proxy()->backendFormat(), fState->outputView()->origin(), fState->proxy()->backendFormat(), fState->outputView()->origin(),
pipeline, mtp, nullptr, primitiveType); pipeline, mtp, primitiveType);
fState->opsRenderPass()->bindPipeline(programInfo, SkRect::MakeIWH(kImageWidth, kImageHeight)); fState->opsRenderPass()->bindPipeline(programInfo, SkRect::MakeIWH(kImageWidth, kImageHeight));
return fState->opsRenderPass(); return fState->opsRenderPass();

View File

@ -163,7 +163,6 @@ private:
flushState->outputView()->origin(), flushState->outputView()->origin(),
&pipeline, &pipeline,
geomProc, geomProc,
nullptr,
GrPrimitiveType::kTriangleStrip); GrPrimitiveType::kTriangleStrip);
flushState->bindPipeline(programInfo, SkRect::MakeIWH(kScreenSize, kScreenSize)); flushState->bindPipeline(programInfo, SkRect::MakeIWH(kScreenSize, kScreenSize));