Surface GrDashOp programs on the DDL

Bug: skia:9455
Change-Id: I44d8baea8665cfb44c791c3af56b631d4ecad138
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/275017
Reviewed-by: Greg Daniel <egdaniel@google.com>
Commit-Queue: Robert Phillips <robertphillips@google.com>
This commit is contained in:
Robert Phillips 2020-03-04 10:32:28 -05:00 committed by Skia Commit-Bot
parent 4490d92f70
commit 345af2527d
2 changed files with 83 additions and 21 deletions

View File

@ -71,6 +71,10 @@ private:
// Add to the set of unique program infos required by this DDL
void recordProgramInfo(const GrProgramInfo* programInfo) final {
if (!programInfo) {
return;
}
const GrCaps* caps = this->caps();
if (this->backend() == GrBackendApi::kVulkan ||

View File

@ -17,6 +17,7 @@
#include "src/gpu/GrMemoryPool.h"
#include "src/gpu/GrOpFlushState.h"
#include "src/gpu/GrProcessor.h"
#include "src/gpu/GrProgramInfo.h"
#include "src/gpu/GrRecordingContextPriv.h"
#include "src/gpu/GrStyle.h"
#include "src/gpu/GrVertexWriter.h"
@ -226,7 +227,11 @@ public:
const char* name() const override { return "DashOp"; }
void visitProxies(const VisitProxyFunc& func) const override {
fProcessorSet.visitProxies(func);
if (fProgramInfo) {
fProgramInfo->visitProxies(func);
} else {
fProcessorSet.visitProxies(func);
}
}
#ifdef SK_DEBUG
@ -321,15 +326,17 @@ private:
bool fHasEndRect;
};
void onPrepareDraws(Target* target) override {
int instanceCount = fLines.count();
SkPaint::Cap cap = this->cap();
bool isRoundCap = SkPaint::kRound_Cap == cap;
DashCap capType = isRoundCap ? kRound_DashCap : kNonRound_DashCap;
GrProgramInfo* createProgramInfo(const GrCaps* caps,
SkArenaAlloc* arena,
const GrSurfaceProxyView* outputView,
GrAppliedClip&& appliedClip,
const GrXferProcessor::DstProxyView& dstProxyView) {
DashCap capType = (this->cap() == SkPaint::kRound_Cap) ? kRound_DashCap : kNonRound_DashCap;
GrGeometryProcessor* gp;
if (this->fullDash()) {
gp = make_dash_gp(target->allocator(), this->color(), this->aaMode(), capType,
gp = make_dash_gp(arena, this->color(), this->aaMode(), capType,
this->viewMatrix(), fUsesLocalCoords);
} else {
// Set up the vertex data for the line and start/end dashes
@ -337,8 +344,8 @@ private:
Color color(this->color());
LocalCoords::Type localCoordsType =
fUsesLocalCoords ? LocalCoords::kUsePosition_Type : LocalCoords::kUnused_Type;
gp = MakeForDeviceSpace(target->allocator(),
target->caps().shaderCaps(),
gp = MakeForDeviceSpace(arena,
caps->shaderCaps(),
color,
Coverage::kSolid_Type,
localCoordsType,
@ -347,7 +354,59 @@ private:
if (!gp) {
SkDebugf("Could not create GrGeometryProcessor\n");
return;
return nullptr;
}
auto pipelineFlags = GrPipeline::InputFlags::kNone;
if (AAMode::kCoverageWithMSAA == fAAMode) {
pipelineFlags |= GrPipeline::InputFlags::kHWAntialias;
}
return GrSimpleMeshDrawOpHelper::CreateProgramInfo(caps,
arena,
outputView,
std::move(appliedClip),
dstProxyView,
gp,
std::move(fProcessorSet),
GrPrimitiveType::kTriangles,
pipelineFlags,
fStencilSettings);
}
GrProgramInfo* createProgramInfo(Target* target) {
return this->createProgramInfo(&target->caps(),
target->allocator(),
target->outputView(),
target->detachAppliedClip(),
target->dstProxyView());
}
void onPrePrepareDraws(GrRecordingContext* context,
const GrSurfaceProxyView* outputView,
GrAppliedClip* clip,
const GrXferProcessor::DstProxyView& dstProxyView) override {
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 onPrepareDraws(Target* target) override {
int instanceCount = fLines.count();
SkPaint::Cap cap = this->cap();
DashCap capType = (SkPaint::kRound_Cap == cap) ? kRound_DashCap : kNonRound_DashCap;
if (!fProgramInfo) {
fProgramInfo = this->createProgramInfo(target);
if (!fProgramInfo) {
return;
}
}
// useAA here means Edge AA or MSAA
@ -571,7 +630,7 @@ private:
return;
}
QuadHelper helper(target, gp->vertexStride(), totalRectCount);
QuadHelper helper(target, fProgramInfo->primProc().vertexStride(), totalRectCount);
GrVertexWriter vertices{ helper.vertices() };
if (!vertices.fPtr) {
return;
@ -620,21 +679,17 @@ private:
}
rectIndex++;
}
helper.recordDraw(target, gp);
fMesh = helper.mesh();
}
void onExecute(GrOpFlushState* flushState, const SkRect& chainBounds) override {
auto pipelineFlags = GrPipeline::InputFlags::kNone;
if (AAMode::kCoverageWithMSAA == fAAMode) {
pipelineFlags |= GrPipeline::InputFlags::kHWAntialias;
if (!fProgramInfo || !fMesh) {
return;
}
auto pipeline = GrSimpleMeshDrawOpHelper::CreatePipeline(flushState,
std::move(fProcessorSet),
pipelineFlags,
fStencilSettings);
flushState->executeDrawsAndUploadsForMeshDrawOp(this, chainBounds, pipeline);
flushState->opsRenderPass()->bindPipeline(*fProgramInfo, chainBounds);
flushState->opsRenderPass()->drawMeshes(*fProgramInfo, fMesh, 1);
}
CombineResult onCombineIfPossible(GrOp* t, GrRecordingContext::Arenas*,
@ -688,6 +743,9 @@ private:
GrProcessorSet fProcessorSet;
const GrUserStencilSettings* fStencilSettings;
GrMesh* fMesh = nullptr;
GrProgramInfo* fProgramInfo = nullptr;
typedef GrMeshDrawOp INHERITED;
};