Add onPrePrepareDraws & createProgramInfo methods to GrDrawVerticesOp

This CL also incidentally adds:

1) a GrMeshDrawOp::Target 'outputView' virtual and switches GrOpFlushState over to overriding it.

2) a createProgramInfo helper to GrSimpleMeshDrawOpHelper

Bug: skia:9455
Change-Id: Iecd712d3ac76038651bd2e0512134e310930d527
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/274551
Reviewed-by: Greg Daniel <egdaniel@google.com>
Commit-Queue: Robert Phillips <robertphillips@google.com>
This commit is contained in:
Robert Phillips 2020-03-02 13:46:36 -05:00 committed by Skia Commit-Bot
parent 37f84c05db
commit d3606518fa
23 changed files with 152 additions and 103 deletions

View File

@ -106,7 +106,7 @@ protected:
GrProgramInfo* createProgramInfo(GrOpFlushState* flushState) { GrProgramInfo* createProgramInfo(GrOpFlushState* flushState) {
return this->createProgramInfo(&flushState->caps(), return this->createProgramInfo(&flushState->caps(),
flushState->allocator(), flushState->allocator(),
flushState->view(), flushState->outputView(),
flushState->detachAppliedClip(), flushState->detachAppliedClip(),
flushState->dstProxyView()); flushState->dstProxyView());
} }

View File

@ -178,7 +178,7 @@ private:
GrProgramInfo* createProgramInfo(GrOpFlushState* flushState) const { GrProgramInfo* createProgramInfo(GrOpFlushState* flushState) const {
return this->createProgramInfo(&flushState->caps(), return this->createProgramInfo(&flushState->caps(),
flushState->allocator(), flushState->allocator(),
flushState->view(), flushState->outputView(),
flushState->detachAppliedClip(), flushState->detachAppliedClip(),
flushState->dstProxyView()); flushState->dstProxyView());
} }

View File

@ -186,7 +186,7 @@ private:
GrProgramInfo* createProgramInfo(GrOpFlushState* flushState) const { GrProgramInfo* createProgramInfo(GrOpFlushState* flushState) const {
return this->createProgramInfo(&flushState->caps(), return this->createProgramInfo(&flushState->caps(),
flushState->allocator(), flushState->allocator(),
flushState->view(), flushState->outputView(),
flushState->detachAppliedClip(), flushState->detachAppliedClip(),
flushState->dstProxyView()); flushState->dstProxyView());
} }

View File

@ -262,7 +262,7 @@ private:
GrProgramInfo* createProgramInfo(GrOpFlushState* flushState) const { GrProgramInfo* createProgramInfo(GrOpFlushState* flushState) const {
return this->createProgramInfo(&flushState->caps(), return this->createProgramInfo(&flushState->caps(),
flushState->allocator(), flushState->allocator(),
flushState->view(), flushState->outputView(),
flushState->detachAppliedClip(), flushState->detachAppliedClip(),
flushState->dstProxyView()); flushState->dstProxyView());
} }

View File

@ -333,7 +333,7 @@ private:
} }
GrProgramInfo programInfo(state->proxy()->numSamples(), state->proxy()->numStencilSamples(), GrProgramInfo programInfo(state->proxy()->numSamples(), state->proxy()->numStencilSamples(),
state->proxy()->backendFormat(), state->view()->origin(), state->proxy()->backendFormat(), state->outputView()->origin(),
&pipeline, shader.get(), &fixedDynamicState, nullptr, 0, &pipeline, shader.get(), &fixedDynamicState, nullptr, 0,
GrPrimitiveType::kPatches, tessellationPatchVertexCount); GrPrimitiveType::kPatches, tessellationPatchVertexCount);

View File

@ -46,7 +46,7 @@ void GrOpFlushState::executeDrawsAndUploadsForMeshDrawOp(
GrProgramInfo programInfo(this->proxy()->numSamples(), GrProgramInfo programInfo(this->proxy()->numSamples(),
this->proxy()->numStencilSamples(), this->proxy()->numStencilSamples(),
this->proxy()->backendFormat(), this->proxy()->backendFormat(),
this->view()->origin(), this->outputView()->origin(),
pipeline, pipeline,
fCurrDraw->fGeometryProcessor, fCurrDraw->fGeometryProcessor,
fCurrDraw->fFixedDynamicState, fCurrDraw->fFixedDynamicState,

View File

@ -71,7 +71,7 @@ public:
GrSwizzle outputSwizzle() const { return fSurfaceView->swizzle(); } GrSwizzle outputSwizzle() const { return fSurfaceView->swizzle(); }
GrOp* op() { return fOp; } GrOp* op() { return fOp; }
const GrSurfaceProxyView* view() const { return fSurfaceView; } const GrSurfaceProxyView* outputView() const { return fSurfaceView; }
GrRenderTargetProxy* proxy() const { return fRenderTargetProxy; } GrRenderTargetProxy* proxy() const { return fRenderTargetProxy; }
GrAppliedClip* appliedClip() { return fAppliedClip; } GrAppliedClip* appliedClip() { return fAppliedClip; }
const GrAppliedClip* appliedClip() const { return fAppliedClip; } const GrAppliedClip* appliedClip() const { return fAppliedClip; }
@ -132,7 +132,7 @@ public:
int* actualIndexCount) final; int* actualIndexCount) final;
void putBackIndices(int indexCount) final; void putBackIndices(int indexCount) final;
void putBackVertices(int vertices, size_t vertexStride) final; void putBackVertices(int vertices, size_t vertexStride) final;
const GrSurfaceProxyView* view() const { return this->drawOpArgs().view(); } const GrSurfaceProxyView* outputView() const final { return this->drawOpArgs().outputView(); }
GrRenderTargetProxy* proxy() const final { return this->drawOpArgs().proxy(); } GrRenderTargetProxy* proxy() const final { return this->drawOpArgs().proxy(); }
const GrAppliedClip* appliedClip() const final { return this->drawOpArgs().appliedClip(); } const GrAppliedClip* appliedClip() const final { return this->drawOpArgs().appliedClip(); }
GrAppliedClip detachAppliedClip() final; GrAppliedClip detachAppliedClip() final;

View File

@ -207,7 +207,7 @@ void GrCCCoverageProcessor::draw(
GrProgramInfo programInfo(flushState->proxy()->numSamples(), GrProgramInfo programInfo(flushState->proxy()->numSamples(),
flushState->proxy()->numStencilSamples(), flushState->proxy()->numStencilSamples(),
flushState->proxy()->backendFormat(), flushState->proxy()->backendFormat(),
flushState->view()->origin(), flushState->outputView()->origin(),
&pipeline, &pipeline,
this, this,
nullptr, nullptr,

View File

@ -144,7 +144,7 @@ void GrCCPathProcessor::drawPaths(GrOpFlushState* flushState, const GrPipeline&
GrProgramInfo programInfo(flushState->proxy()->numSamples(), GrProgramInfo programInfo(flushState->proxy()->numSamples(),
flushState->proxy()->numStencilSamples(), flushState->proxy()->numStencilSamples(),
flushState->proxy()->backendFormat(), flushState->proxy()->backendFormat(),
flushState->view()->origin(), flushState->outputView()->origin(),
&pipeline, &pipeline,
this, this,
fixedDynamicState, fixedDynamicState,

View File

@ -782,7 +782,7 @@ void GrCCStroker::flushBufferedMeshesAsStrokes(const GrPrimitiveProcessor& proce
GrProgramInfo programInfo(flushState->proxy()->numSamples(), GrProgramInfo programInfo(flushState->proxy()->numSamples(),
flushState->proxy()->numStencilSamples(), flushState->proxy()->numStencilSamples(),
flushState->proxy()->backendFormat(), flushState->proxy()->backendFormat(),
flushState->view()->origin(), flushState->outputView()->origin(),
&pipeline, &pipeline,
&processor, &processor,
nullptr, nullptr,

View File

@ -157,7 +157,7 @@ void GrStencilAtlasOp::onExecute(GrOpFlushState* flushState, const SkRect& chain
GrProgramInfo programInfo(flushState->proxy()->numSamples(), GrProgramInfo programInfo(flushState->proxy()->numSamples(),
flushState->proxy()->numStencilSamples(), flushState->proxy()->numStencilSamples(),
flushState->proxy()->backendFormat(), flushState->proxy()->backendFormat(),
flushState->view()->origin(), flushState->outputView()->origin(),
&resolvePipeline, &resolvePipeline,
&primProc, &primProc,
&scissorRectState, &scissorRectState,

View File

@ -101,7 +101,7 @@ void GrDrawPathOp::onExecute(GrOpFlushState* flushState, const SkRect& chainBoun
GrProgramInfo programInfo(proxy->numSamples(), GrProgramInfo programInfo(proxy->numSamples(),
proxy->numStencilSamples(), proxy->numStencilSamples(),
proxy->backendFormat(), proxy->backendFormat(),
flushState->view()->origin(), flushState->outputView()->origin(),
pipeline, pipeline,
pathProc.get(), pathProc.get(),
fixedDynamicState, fixedDynamicState,

View File

@ -9,6 +9,7 @@
#include "src/gpu/GrCaps.h" #include "src/gpu/GrCaps.h"
#include "src/gpu/GrDefaultGeoProcFactory.h" #include "src/gpu/GrDefaultGeoProcFactory.h"
#include "src/gpu/GrOpFlushState.h" #include "src/gpu/GrOpFlushState.h"
#include "src/gpu/GrProgramInfo.h"
#include "src/gpu/SkGr.h" #include "src/gpu/SkGr.h"
#include "src/gpu/ops/GrDrawVerticesOp.h" #include "src/gpu/ops/GrDrawVerticesOp.h"
#include "src/gpu/ops/GrSimpleMeshDrawOpHelper.h" #include "src/gpu/ops/GrSimpleMeshDrawOpHelper.h"
@ -47,29 +48,40 @@ private:
kSkColor, kSkColor,
}; };
GrProgramInfo* createProgramInfo(const GrCaps*,
SkArenaAlloc*,
const GrSurfaceProxyView* outputView,
GrAppliedClip&&,
const GrXferProcessor::DstProxyView&);
GrProgramInfo* createProgramInfo(Target* target) {
return this->createProgramInfo(&target->caps(),
target->allocator(),
target->outputView(),
target->detachAppliedClip(),
target->dstProxyView());
}
void onPrePrepareDraws(GrRecordingContext*,
const GrSurfaceProxyView* outputView,
GrAppliedClip*,
const GrXferProcessor::DstProxyView&) override;
void onPrepareDraws(Target*) override; void onPrepareDraws(Target*) override;
void onExecute(GrOpFlushState*, const SkRect& chainBounds) override; void onExecute(GrOpFlushState*, const SkRect& chainBounds) override;
void drawVolatile(Target*); void drawVolatile(Target*, const GrPrimitiveProcessor&);
void drawNonVolatile(Target*); void drawNonVolatile(Target*, const GrPrimitiveProcessor&);
void fillBuffers(bool hasColorAttribute, void fillBuffers(size_t vertexStride,
bool hasLocalCoordsAttribute,
size_t vertexStride,
void* verts, void* verts,
uint16_t* indices) const; uint16_t* indices) const;
void drawVertices(Target*, void createMesh(Target*,
const GrGeometryProcessor*, sk_sp<const GrBuffer> vertexBuffer,
sk_sp<const GrBuffer> vertexBuffer, int firstVertex,
int firstVertex, sk_sp<const GrBuffer> indexBuffer,
sk_sp<const GrBuffer> indexBuffer, int firstIndex);
int firstIndex);
GrGeometryProcessor* makeGP(SkArenaAlloc* arena, GrGeometryProcessor* makeGP(SkArenaAlloc*, const GrShaderCaps*);
const GrShaderCaps* shaderCaps,
bool* hasColorAttribute,
bool* hasLocalCoordAttribute) const;
GrPrimitiveType primitiveType() const { return fPrimitiveType; } GrPrimitiveType primitiveType() const { return fPrimitiveType; }
bool combinablePrimitive() const { bool combinablePrimitive() const {
@ -117,6 +129,11 @@ private:
kRequiresPerVertexColors_Flag = 0x1, kRequiresPerVertexColors_Flag = 0x1,
kAnyMeshHasExplicitLocalCoords_Flag = 0x2, kAnyMeshHasExplicitLocalCoords_Flag = 0x2,
kHasMultipleViewMatrices_Flag = 0x4, kHasMultipleViewMatrices_Flag = 0x4,
// These following flags are set in makeGP
kHasLocalCoordAttribute_Flag = 0x8,
kHasColorAttribute_Flag = 0x10, // should always match kRequiresPerVertexColors
kWasCharacterized_Flag = 0x20,
}; };
Helper fHelper; Helper fHelper;
@ -130,6 +147,9 @@ private:
ColorArrayType fColorArrayType; ColorArrayType fColorArrayType;
sk_sp<GrColorSpaceXform> fColorSpaceXform; sk_sp<GrColorSpaceXform> fColorSpaceXform;
GrMesh* fMesh = nullptr;
GrProgramInfo* fProgramInfo = nullptr;
typedef GrMeshDrawOp INHERITED; typedef GrMeshDrawOp INHERITED;
}; };
@ -230,25 +250,20 @@ GrProcessorSet::Analysis DrawVerticesOp::finalize(
return result; return result;
} }
GrGeometryProcessor* DrawVerticesOp::makeGP(SkArenaAlloc* arena, GrGeometryProcessor* DrawVerticesOp::makeGP(SkArenaAlloc* arena, const GrShaderCaps* shaderCaps) {
const GrShaderCaps* shaderCaps,
bool* hasColorAttribute,
bool* hasLocalCoordAttribute) const {
using namespace GrDefaultGeoProcFactory; using namespace GrDefaultGeoProcFactory;
LocalCoords::Type localCoordsType; LocalCoords::Type localCoordsType;
if (fHelper.usesLocalCoords()) { if (fHelper.usesLocalCoords()) {
// If we have multiple view matrices we will transform the positions into device space. We // If we have multiple view matrices we will transform the positions into device space. We
// must then also provide untransformed positions as local coords. // must then also provide untransformed positions as local coords.
if (this->anyMeshHasExplicitLocalCoords() || this->hasMultipleViewMatrices()) { if (this->anyMeshHasExplicitLocalCoords() || this->hasMultipleViewMatrices()) {
*hasLocalCoordAttribute = true; fFlags |= kHasLocalCoordAttribute_Flag;
localCoordsType = LocalCoords::kHasExplicit_Type; localCoordsType = LocalCoords::kHasExplicit_Type;
} else { } else {
*hasLocalCoordAttribute = false;
localCoordsType = LocalCoords::kUsePosition_Type; localCoordsType = LocalCoords::kUsePosition_Type;
} }
} else { } else {
localCoordsType = LocalCoords::kUnused_Type; localCoordsType = LocalCoords::kUnused_Type;
*hasLocalCoordAttribute = false;
} }
Color color(fMeshes[0].fColor); Color color(fMeshes[0].fColor);
@ -259,13 +274,12 @@ GrGeometryProcessor* DrawVerticesOp::makeGP(SkArenaAlloc* arena,
color.fType = Color::kUnpremulSkColorAttribute_Type; color.fType = Color::kUnpremulSkColorAttribute_Type;
color.fColorSpaceXform = fColorSpaceXform; color.fColorSpaceXform = fColorSpaceXform;
} }
*hasColorAttribute = true; fFlags |= kHasColorAttribute_Flag;
} else {
*hasColorAttribute = false;
} }
const SkMatrix& vm = this->hasMultipleViewMatrices() ? SkMatrix::I() : fMeshes[0].fViewMatrix; const SkMatrix& vm = this->hasMultipleViewMatrices() ? SkMatrix::I() : fMeshes[0].fViewMatrix;
fFlags |= kWasCharacterized_Flag;
return GrDefaultGeoProcFactory::Make(arena, return GrDefaultGeoProcFactory::Make(arena,
shaderCaps, shaderCaps,
color, color,
@ -274,25 +288,52 @@ GrGeometryProcessor* DrawVerticesOp::makeGP(SkArenaAlloc* arena,
vm); vm);
} }
GrProgramInfo* DrawVerticesOp::createProgramInfo(
const GrCaps* caps,
SkArenaAlloc* arena,
const GrSurfaceProxyView* outputView,
GrAppliedClip&& appliedClip,
const GrXferProcessor::DstProxyView& dstProxyView) {
GrGeometryProcessor* gp = this->makeGP(arena, caps->shaderCaps());
return fHelper.createProgramInfo(caps, arena, outputView, std::move(appliedClip), dstProxyView,
gp, this->primitiveType());
}
void DrawVerticesOp::onPrePrepareDraws(GrRecordingContext* context,
const GrSurfaceProxyView* outputView,
GrAppliedClip* clip,
const GrXferProcessor::DstProxyView& dstProxyView) {
SkArenaAlloc* arena = context->priv().recordTimeAllocator();
// This is equivalent to a GrOpFlushState::detachAppliedClip
GrAppliedClip appliedClip = clip ? std::move(*clip) : GrAppliedClip();
fProgramInfo = this->createProgramInfo(context->priv().caps(), arena, outputView,
std::move(appliedClip), dstProxyView);
context->priv().recordProgramInfo(fProgramInfo);
}
void DrawVerticesOp::onPrepareDraws(Target* target) { void DrawVerticesOp::onPrepareDraws(Target* target) {
if (!fProgramInfo) {
// Note: this could be moved to onExecute if draw*Volatile were made to compute
// their own vertex stride and hasColorAttribute and hasLocalCoordsAttribute settings.
fProgramInfo = this->createProgramInfo(target);
}
bool hasMapBufferSupport = GrCaps::kNone_MapFlags != target->caps().mapBufferFlags(); bool hasMapBufferSupport = GrCaps::kNone_MapFlags != target->caps().mapBufferFlags();
if (fMeshes[0].fVertices->isVolatile() || !hasMapBufferSupport) { if (fMeshes[0].fVertices->isVolatile() || !hasMapBufferSupport) {
this->drawVolatile(target); this->drawVolatile(target, fProgramInfo->primProc());
} else { } else {
this->drawNonVolatile(target); this->drawNonVolatile(target, fProgramInfo->primProc());
} }
} }
void DrawVerticesOp::drawVolatile(Target* target) { void DrawVerticesOp::drawVolatile(Target* target, const GrPrimitiveProcessor& gp) {
bool hasColorAttribute;
bool hasLocalCoordsAttribute;
GrGeometryProcessor* gp = this->makeGP(target->allocator(),
target->caps().shaderCaps(),
&hasColorAttribute,
&hasLocalCoordsAttribute);
// Allocate buffers. // Allocate buffers.
size_t vertexStride = gp->vertexStride(); size_t vertexStride = gp.vertexStride();
sk_sp<const GrBuffer> vertexBuffer; sk_sp<const GrBuffer> vertexBuffer;
int firstVertex = 0; int firstVertex = 0;
void* verts = target->makeVertexSpace(vertexStride, fVertexCount, &vertexBuffer, &firstVertex); void* verts = target->makeVertexSpace(vertexStride, fVertexCount, &vertexBuffer, &firstVertex);
@ -312,27 +353,14 @@ void DrawVerticesOp::drawVolatile(Target* target) {
} }
} }
// Fill the buffers. this->fillBuffers(vertexStride, verts, indices);
this->fillBuffers(hasColorAttribute,
hasLocalCoordsAttribute,
vertexStride,
verts,
indices);
// Draw the vertices. this->createMesh(target, std::move(vertexBuffer), firstVertex, indexBuffer, firstIndex);
this->drawVertices(target, gp, std::move(vertexBuffer), firstVertex, indexBuffer, firstIndex);
} }
void DrawVerticesOp::drawNonVolatile(Target* target) { void DrawVerticesOp::drawNonVolatile(Target* target, const GrPrimitiveProcessor& gp) {
static const GrUniqueKey::Domain kDomain = GrUniqueKey::GenerateDomain(); static const GrUniqueKey::Domain kDomain = GrUniqueKey::GenerateDomain();
bool hasColorAttribute;
bool hasLocalCoordsAttribute;
GrGeometryProcessor* gp = this->makeGP(target->allocator(),
target->caps().shaderCaps(),
&hasColorAttribute,
&hasLocalCoordsAttribute);
SkASSERT(fMeshes.count() == 1); // Non-volatile meshes should never combine. SkASSERT(fMeshes.count() == 1); // Non-volatile meshes should never combine.
// Get the resource provider. // Get the resource provider.
@ -355,12 +383,12 @@ void DrawVerticesOp::drawNonVolatile(Target* target) {
// Draw using the cached buffers if possible. // Draw using the cached buffers if possible.
if (vertexBuffer && (!this->isIndexed() || indexBuffer)) { if (vertexBuffer && (!this->isIndexed() || indexBuffer)) {
this->drawVertices(target, gp, std::move(vertexBuffer), 0, std::move(indexBuffer), 0); this->createMesh(target, std::move(vertexBuffer), 0, std::move(indexBuffer), 0);
return; return;
} }
// Allocate vertex buffer. // Allocate vertex buffer.
size_t vertexStride = gp->vertexStride(); size_t vertexStride = gp.vertexStride();
vertexBuffer = rp->createBuffer( vertexBuffer = rp->createBuffer(
fVertexCount * vertexStride, GrGpuBufferType::kVertex, kStatic_GrAccessPattern); fVertexCount * vertexStride, GrGpuBufferType::kVertex, kStatic_GrAccessPattern);
void* verts = vertexBuffer ? vertexBuffer->map() : nullptr; void* verts = vertexBuffer ? vertexBuffer->map() : nullptr;
@ -381,14 +409,8 @@ void DrawVerticesOp::drawNonVolatile(Target* target) {
} }
} }
// Fill the buffers. this->fillBuffers(vertexStride, verts, indices);
this->fillBuffers(hasColorAttribute,
hasLocalCoordsAttribute,
vertexStride,
verts,
indices);
// Unmap the buffers.
vertexBuffer->unmap(); vertexBuffer->unmap();
if (indexBuffer) { if (indexBuffer) {
indexBuffer->unmap(); indexBuffer->unmap();
@ -399,15 +421,15 @@ void DrawVerticesOp::drawNonVolatile(Target* target) {
rp->assignUniqueKeyToResource(indexKey, indexBuffer.get()); rp->assignUniqueKeyToResource(indexKey, indexBuffer.get());
// Draw the vertices. // Draw the vertices.
this->drawVertices(target, gp, std::move(vertexBuffer), 0, std::move(indexBuffer), 0); this->createMesh(target, std::move(vertexBuffer), 0, std::move(indexBuffer), 0);
} }
void DrawVerticesOp::fillBuffers(bool hasColorAttribute, void DrawVerticesOp::fillBuffers(size_t vertexStride, void* verts, uint16_t* indices) const {
bool hasLocalCoordsAttribute,
size_t vertexStride,
void* verts,
uint16_t* indices) const {
int instanceCount = fMeshes.count(); int instanceCount = fMeshes.count();
bool hasColorAttribute = SkToBool(fFlags & kHasColorAttribute_Flag);
bool hasLocalCoordsAttribute = SkToBool(fFlags & kHasLocalCoordAttribute_Flag);
SkASSERT(fFlags & kWasCharacterized_Flag);
SkASSERT(hasColorAttribute == this->requiresPerVertexColors());
// Copy data into the buffers. // Copy data into the buffers.
int vertexOffset = 0; int vertexOffset = 0;
@ -494,27 +516,26 @@ void DrawVerticesOp::fillBuffers(bool hasColorAttribute,
} }
} }
void DrawVerticesOp::drawVertices(Target* target, void DrawVerticesOp::createMesh(Target* target,
const GrGeometryProcessor* gp, sk_sp<const GrBuffer> vertexBuffer,
sk_sp<const GrBuffer> vertexBuffer, int firstVertex,
int firstVertex, sk_sp<const GrBuffer> indexBuffer,
sk_sp<const GrBuffer> indexBuffer, int firstIndex) {
int firstIndex) { SkASSERT(!fMesh);
GrMesh* mesh = target->allocMesh();
fMesh = target->allocMesh();
if (this->isIndexed()) { if (this->isIndexed()) {
mesh->setIndexed(std::move(indexBuffer), fIndexCount, firstIndex, 0, fVertexCount - 1, fMesh->setIndexed(std::move(indexBuffer), fIndexCount, firstIndex, 0, fVertexCount - 1,
GrPrimitiveRestart::kNo); GrPrimitiveRestart::kNo);
} else { } else {
mesh->setNonIndexedNonInstanced(fVertexCount); fMesh->setNonIndexedNonInstanced(fVertexCount);
} }
mesh->setVertexData(std::move(vertexBuffer), firstVertex); fMesh->setVertexData(std::move(vertexBuffer), firstVertex);
target->recordDraw(gp, mesh, 1, this->primitiveType());
} }
void DrawVerticesOp::onExecute(GrOpFlushState* flushState, const SkRect& chainBounds) { void DrawVerticesOp::onExecute(GrOpFlushState* flushState, const SkRect& chainBounds) {
auto pipeline = fHelper.createPipeline(flushState); flushState->opsRenderPass()->bindPipeline(*fProgramInfo, chainBounds);
flushState->opsRenderPass()->drawMeshes(*fProgramInfo, fMesh, 1);
flushState->executeDrawsAndUploadsForMeshDrawOp(this, chainBounds, pipeline);
} }
GrOp::CombineResult DrawVerticesOp::onCombineIfPossible(GrOp* t, GrRecordingContext::Arenas*, GrOp::CombineResult DrawVerticesOp::onCombineIfPossible(GrOp* t, GrRecordingContext::Arenas*,

View File

@ -102,7 +102,7 @@ private:
GrProgramInfo* createProgramInfo(GrOpFlushState* flushState) { GrProgramInfo* createProgramInfo(GrOpFlushState* flushState) {
return this->createProgramInfo(&flushState->caps(), return this->createProgramInfo(&flushState->caps(),
flushState->allocator(), flushState->allocator(),
flushState->view(), flushState->outputView(),
flushState->detachAppliedClip(), flushState->detachAppliedClip(),
flushState->dstProxyView()); flushState->dstProxyView());
} }

View File

@ -191,6 +191,7 @@ public:
} }
virtual GrRenderTargetProxy* proxy() const = 0; virtual GrRenderTargetProxy* proxy() const = 0;
virtual const GrSurfaceProxyView* outputView() const = 0;
virtual const GrAppliedClip* appliedClip() const = 0; virtual const GrAppliedClip* appliedClip() const = 0;
virtual GrAppliedClip detachAppliedClip() = 0; virtual GrAppliedClip detachAppliedClip() = 0;

View File

@ -136,7 +136,7 @@ const GrPipeline* GrSimpleMeshDrawOpHelper::CreatePipeline(
const GrUserStencilSettings* stencilSettings) { const GrUserStencilSettings* stencilSettings) {
return CreatePipeline(&flushState->caps(), return CreatePipeline(&flushState->caps(),
flushState->allocator(), flushState->allocator(),
flushState->view(), flushState->outputView(),
flushState->detachAppliedClip(), flushState->detachAppliedClip(),
flushState->dstProxyView(), flushState->dstProxyView(),
std::move(processorSet), std::move(processorSet),
@ -147,7 +147,7 @@ const GrPipeline* GrSimpleMeshDrawOpHelper::CreatePipeline(
const GrPipeline* GrSimpleMeshDrawOpHelper::createPipeline(GrOpFlushState* flushState) { const GrPipeline* GrSimpleMeshDrawOpHelper::createPipeline(GrOpFlushState* flushState) {
return CreatePipeline(&flushState->caps(), return CreatePipeline(&flushState->caps(),
flushState->allocator(), flushState->allocator(),
flushState->view(), flushState->outputView(),
flushState->detachAppliedClip(), flushState->detachAppliedClip(),
flushState->dstProxyView(), flushState->dstProxyView(),
this->detachProcessorSet(), this->detachProcessorSet(),
@ -196,6 +196,25 @@ GrProgramInfo* GrSimpleMeshDrawOpHelper::CreateProgramInfo(
return tmp; return tmp;
} }
GrProgramInfo* GrSimpleMeshDrawOpHelper::createProgramInfo(
const GrCaps* caps,
SkArenaAlloc* arena,
const GrSurfaceProxyView* outputView,
GrAppliedClip&& appliedClip,
const GrXferProcessor::DstProxyView& dstProxyView,
GrGeometryProcessor* gp,
GrPrimitiveType primType) {
return CreateProgramInfo(caps,
arena,
outputView,
std::move(appliedClip),
dstProxyView,
gp,
this->detachProcessorSet(),
primType,
this->pipelineFlags());
}
#ifdef SK_DEBUG #ifdef SK_DEBUG
static void dump_pipeline_flags(GrPipeline::InputFlags flags, SkString* result) { static void dump_pipeline_flags(GrPipeline::InputFlags flags, SkString* result) {
if (GrPipeline::InputFlags::kNone != flags) { if (GrPipeline::InputFlags::kNone != flags) {

View File

@ -157,6 +157,14 @@ public:
const GrUserStencilSettings* const GrUserStencilSettings*
= &GrUserStencilSettings::kUnused); = &GrUserStencilSettings::kUnused);
GrProgramInfo* createProgramInfo(const GrCaps*,
SkArenaAlloc*,
const GrSurfaceProxyView* outputView,
GrAppliedClip&&,
const GrXferProcessor::DstProxyView&,
GrGeometryProcessor*,
GrPrimitiveType);
GrProcessorSet detachProcessorSet() { GrProcessorSet detachProcessorSet() {
return fProcessors ? std::move(*fProcessors) : GrProcessorSet::MakeEmptySet(); return fProcessors ? std::move(*fProcessors) : GrProcessorSet::MakeEmptySet();
} }

View File

@ -11,7 +11,7 @@ const GrPipeline* GrSimpleMeshDrawOpHelperWithStencil::createPipelineWithStencil
GrOpFlushState* flushState) { GrOpFlushState* flushState) {
return GrSimpleMeshDrawOpHelper::CreatePipeline(&flushState->caps(), return GrSimpleMeshDrawOpHelper::CreatePipeline(&flushState->caps(),
flushState->allocator(), flushState->allocator(),
flushState->view(), flushState->outputView(),
flushState->detachAppliedClip(), flushState->detachAppliedClip(),
flushState->dstProxyView(), flushState->dstProxyView(),
this->detachProcessorSet(), this->detachProcessorSet(),

View File

@ -180,8 +180,8 @@ void GrDrawAtlasPathOp::onExecute(GrOpFlushState* state, const SkRect& chainBoun
SkASSERT(shader.instanceStride() == Instance::Stride(fUsesLocalCoords)); SkASSERT(shader.instanceStride() == Instance::Stride(fUsesLocalCoords));
GrProgramInfo programInfo(state->proxy()->numSamples(), state->proxy()->numStencilSamples(), GrProgramInfo programInfo(state->proxy()->numSamples(), state->proxy()->numStencilSamples(),
state->proxy()->backendFormat(), state->view()->origin(), &pipeline, state->proxy()->backendFormat(), state->outputView()->origin(),
&shader, &fixedDynamicState, nullptr, 0, &pipeline, &shader, &fixedDynamicState, nullptr, 0,
GrPrimitiveType::kTriangleStrip); GrPrimitiveType::kTriangleStrip);
GrMesh mesh; GrMesh mesh;

View File

@ -45,7 +45,7 @@ public:
const GrPipeline::FixedDynamicState* fixedDynamicState, const GrMesh& mesh, const GrPipeline::FixedDynamicState* fixedDynamicState, const GrMesh& mesh,
const SkRect& bounds) { const SkRect& bounds) {
GrProgramInfo programInfo(state->proxy()->numSamples(), state->proxy()->numStencilSamples(), GrProgramInfo programInfo(state->proxy()->numSamples(), state->proxy()->numStencilSamples(),
state->proxy()->backendFormat(), state->view()->origin(), state->proxy()->backendFormat(), state->outputView()->origin(),
pipeline, this, fixedDynamicState, nullptr, 0, pipeline, this, fixedDynamicState, nullptr, 0,
fPrimitiveType, fTessellationPatchVertexCount); fPrimitiveType, fTessellationPatchVertexCount);
state->opsRenderPass()->bindPipeline(programInfo, bounds); state->opsRenderPass()->bindPipeline(programInfo, bounds);

View File

@ -441,7 +441,7 @@ void DrawMeshHelper::drawMesh(const GrMesh& mesh, GrPrimitiveType primitiveType)
GrProgramInfo programInfo(fState->proxy()->numSamples(), GrProgramInfo programInfo(fState->proxy()->numSamples(),
fState->proxy()->numStencilSamples(), fState->proxy()->numStencilSamples(),
fState->proxy()->backendFormat(), fState->proxy()->backendFormat(),
fState->view()->origin(), fState->outputView()->origin(),
pipeline, pipeline,
mtp, mtp,
nullptr, nullptr, 0, primitiveType); nullptr, nullptr, 0, primitiveType);

View File

@ -163,7 +163,7 @@ private:
GrProgramInfo programInfo(flushState->proxy()->numSamples(), GrProgramInfo programInfo(flushState->proxy()->numSamples(),
flushState->proxy()->numStencilSamples(), flushState->proxy()->numStencilSamples(),
flushState->proxy()->backendFormat(), flushState->proxy()->backendFormat(),
flushState->view()->origin(), flushState->outputView()->origin(),
&pipeline, &pipeline,
geomProc, geomProc,
nullptr, nullptr,

View File

@ -110,7 +110,7 @@ private:
GrProgramInfo* createProgramInfo(GrOpFlushState* flushState) { GrProgramInfo* createProgramInfo(GrOpFlushState* flushState) {
return this->createProgramInfo(&flushState->caps(), return this->createProgramInfo(&flushState->caps(),
flushState->allocator(), flushState->allocator(),
flushState->view(), flushState->outputView(),
flushState->detachAppliedClip(), flushState->detachAppliedClip(),
flushState->dstProxyView()); flushState->dstProxyView());
} }