Skip to content
This repository was archived by the owner on Feb 25, 2025. It is now read-only.

Commit e74cebe

Browse files
csmartdalton86Skia Commit-Bot
authored and
Skia Commit-Bot
committed
Begin implementing onPrePrepare for tessellation ops
Records programInfos for the stroke ops and for the stencil portions of the path ops. We can't prePrepare programInfos for the fill portions yet because it would require multiple GrPipelines that all reference the same GrProcessorSet. And GrProcessorSet is currently designed to be std::moved into one single GrPipeline. Bug: skia:10419 Change-Id: I3b8c061da181e20d3ff68746cf4b9c61f6d73a88 Reviewed-on: https://skia-review.googlesource.com/c/skia/+/319256 Commit-Queue: Chris Dalton <csmartdalton@google.com> Reviewed-by: Robert Phillips <robertphillips@google.com>
1 parent 15a4b18 commit e74cebe

File tree

6 files changed

+353
-180
lines changed

6 files changed

+353
-180
lines changed

bench/TessellateBench.cpp

+10-3
Original file line numberDiff line numberDiff line change
@@ -147,10 +147,14 @@ class GrPathTessellateOp::TestingOnly_Benchmark : public Benchmark {
147147
}
148148
for (int i = 0; i < loops; ++i) {
149149
fOp.fTriangleBuffer.reset();
150-
fOp.fDoStencilTriangleBuffer = false;
150+
fOp.fTriangleVertexCount = 0;
151+
fOp.fSharedStencilPipeline = nullptr;
152+
fOp.fStencilTrianglesProgram = nullptr;
151153
fOp.fDoFillTriangleBuffer = false;
152154
fOp.fCubicBuffer.reset();
153-
fOp.fStencilCubicsShader = nullptr;
155+
fOp.fCubicVertexCount = 0;
156+
// Make fStencilTrianglesProgram non-null to keep assertions happy.
157+
fOp.fStencilCubicsProgram = (GrProgramInfo*)-1;
154158
this->runBench(&fTarget, &fOp);
155159
fTarget.resetAllocator();
156160
}
@@ -175,13 +179,16 @@ class GrPathTessellateOp::TestingOnly_Benchmark : public Benchmark {
175179
GrMeshDrawOp::Target* TARGET, GrPathTessellateOp* op)
176180

177181
DEF_PATH_TESS_BENCH(prepareMiddleOutStencilGeometry, make_cubic_path(), SkMatrix::I(), target, op) {
182+
// Make fStencilTrianglesProgram non-null so we benchmark the tessellation path with separate
183+
// triangles.
184+
op->fStencilTrianglesProgram = (GrProgramInfo*)-1;
178185
op->prepareMiddleOutTrianglesAndCubics(target);
179186
}
180187

181188
DEF_PATH_TESS_BENCH(prepareMiddleOutStencilGeometry_indirect, make_cubic_path(), SkMatrix::I(),
182189
target, op) {
183190
GrResolveLevelCounter resolveLevelCounter;
184-
op->prepareMiddleOutTrianglesAndCubics(target, &resolveLevelCounter, true);
191+
op->prepareMiddleOutTrianglesAndCubics(target, &resolveLevelCounter);
185192
}
186193

187194
DEF_PATH_TESS_BENCH(prepareIndirectOuterCubics, make_cubic_path(), SkMatrix::I(), target, op) {

src/gpu/tessellate/GrPathShader.h

+34-22
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
#ifndef GrPathShader_DEFINED
99
#define GrPathShader_DEFINED
1010

11+
#include "src/core/SkArenaAlloc.h"
1112
#include "src/gpu/GrGeometryProcessor.h"
1213
#include "src/gpu/GrOpFlushState.h"
1314
#include "src/gpu/GrOpsRenderPass.h"
@@ -27,30 +28,41 @@ class GrPathShader : public GrGeometryProcessor {
2728
}
2829
}
2930

31+
GrPrimitiveType primitiveType() const { return fPrimitiveType; }
32+
int tessellationPatchVertexCount() const { return fTessellationPatchVertexCount; }
3033
const SkMatrix& viewMatrix() const { return fViewMatrix; }
3134

32-
// This subclass is used to simplify the argument list for constructing GrProgramInfo from a
33-
// GrPathShader.
34-
class ProgramInfo : public GrProgramInfo {
35-
public:
36-
ProgramInfo(const GrSurfaceProxyView* view,
37-
const GrPipeline* pipeline,
38-
const GrPathShader* shader,
39-
GrXferBarrierFlags renderPassXferBarriers)
40-
: ProgramInfo(view->asRenderTargetProxy(), view->origin(), pipeline, shader,
41-
renderPassXferBarriers) {
42-
}
43-
ProgramInfo(const GrRenderTargetProxy* proxy,
44-
GrSurfaceOrigin origin,
45-
const GrPipeline* pipeline,
46-
const GrPathShader* shader,
47-
GrXferBarrierFlags renderPassXferBarriers)
48-
: GrProgramInfo(proxy->numSamples(), proxy->numStencilSamples(),
49-
proxy->backendFormat(), origin, pipeline, shader,
50-
shader->fPrimitiveType, shader->fTessellationPatchVertexCount,
51-
renderPassXferBarriers) {
52-
}
53-
};
35+
static GrProgramInfo* MakeProgramInfo(const GrPathShader* shader, SkArenaAlloc* arena,
36+
const GrSurfaceProxyView* writeView,
37+
GrPipeline::InputFlags pipelineFlags,
38+
GrProcessorSet&& processors, GrAppliedClip&& appliedClip,
39+
const GrXferProcessor::DstProxyView& dstProxyView,
40+
GrXferBarrierFlags renderPassXferBarriers,
41+
const GrCaps& caps) {
42+
GrPipeline::InitArgs pipelineArgs;
43+
pipelineArgs.fInputFlags = pipelineFlags;
44+
pipelineArgs.fCaps = &caps;
45+
pipelineArgs.fDstProxyView = dstProxyView;
46+
pipelineArgs.fWriteSwizzle = writeView->swizzle();
47+
auto* pipeline = arena->make<GrPipeline>(pipelineArgs, std::move(processors),
48+
std::move(appliedClip));
49+
return MakeProgramInfo(shader, arena, writeView, pipeline, dstProxyView,
50+
renderPassXferBarriers, caps);
51+
}
52+
53+
static GrProgramInfo* MakeProgramInfo(const GrPathShader* shader, SkArenaAlloc* arena,
54+
const GrSurfaceProxyView* writeView,
55+
const GrPipeline* pipeline,
56+
const GrXferProcessor::DstProxyView& dstProxyView,
57+
GrXferBarrierFlags renderPassXferBarriers,
58+
const GrCaps& caps) {
59+
GrRenderTargetProxy* proxy = writeView->asRenderTargetProxy();
60+
return arena->make<GrProgramInfo>(proxy->numSamples(), proxy->numStencilSamples(),
61+
proxy->backendFormat(), writeView->origin(), pipeline,
62+
shader, shader->fPrimitiveType,
63+
shader->fTessellationPatchVertexCount,
64+
renderPassXferBarriers);
65+
}
5466

5567
private:
5668
const SkMatrix fViewMatrix;

0 commit comments

Comments
 (0)