aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/gpu/ccpr
diff options
context:
space:
mode:
authorGravatar Brian Salomon <bsalomon@google.com>2018-06-26 09:12:38 -0400
committerGravatar Skia Commit-Bot <skia-commit-bot@chromium.org>2018-06-26 15:35:12 +0000
commit493489054f85d1b7725412ad7a3cdc70c7ec5466 (patch)
tree45223f5039eefd3aba721d737cb70549baaa8d0d /src/gpu/ccpr
parentd5506cb888858bd19fa54be50714a8d661cedf33 (diff)
Refactor GrPipeline dynamic state.
Remove scissor rect from GrPipeline. Draws can specify "fixed dynamic state" which doesn't use the dynamism at all or can specify dynamic state arrays with an entry per GrMesh. When we state other than scissor rects this will allow the caller to use a mix of truly dynamic and fixed dynamic state. So a caller that only has dynamic scissor rects doesn't need to store its remaining unvarying state in an array. Change-Id: I8fcc07eb600c72a26cc712b185755c2116021a8a Reviewed-on: https://skia-review.googlesource.com/137223 Reviewed-by: Chris Dalton <csmartdalton@google.com> Commit-Queue: Brian Salomon <bsalomon@google.com>
Diffstat (limited to 'src/gpu/ccpr')
-rw-r--r--src/gpu/ccpr/GrCCCoverageProcessor.cpp10
-rw-r--r--src/gpu/ccpr/GrCCCoverageProcessor.h2
-rw-r--r--src/gpu/ccpr/GrCCDrawPathsOp.cpp8
-rw-r--r--src/gpu/ccpr/GrCCPathParser.cpp18
-rw-r--r--src/gpu/ccpr/GrCCPathParser.h2
-rw-r--r--src/gpu/ccpr/GrCCPathProcessor.cpp4
-rw-r--r--src/gpu/ccpr/GrCCPathProcessor.h9
-rw-r--r--src/gpu/ccpr/GrCCPerFlushResources.cpp2
8 files changed, 31 insertions, 24 deletions
diff --git a/src/gpu/ccpr/GrCCCoverageProcessor.cpp b/src/gpu/ccpr/GrCCCoverageProcessor.cpp
index 94b027abe9..e9720213ec 100644
--- a/src/gpu/ccpr/GrCCCoverageProcessor.cpp
+++ b/src/gpu/ccpr/GrCCCoverageProcessor.cpp
@@ -224,16 +224,18 @@ void GrCCCoverageProcessor::Shader::emitFragmentCode(const GrCCCoverageProcessor
}
void GrCCCoverageProcessor::draw(GrOpFlushState* flushState, const GrPipeline& pipeline,
- const GrMesh meshes[],
- const GrPipeline::DynamicState dynamicStates[], int meshCount,
+ const SkIRect scissorRects[], const GrMesh meshes[], int meshCount,
const SkRect& drawBounds) const {
+ GrPipeline::DynamicStateArrays dynamicStateArrays;
+ dynamicStateArrays.fScissorRects = scissorRects;
GrGpuRTCommandBuffer* cmdBuff = flushState->rtCommandBuffer();
- cmdBuff->draw(*this, pipeline, meshes, dynamicStates, meshCount, drawBounds);
+ cmdBuff->draw(*this, pipeline, nullptr, &dynamicStateArrays, meshes, meshCount, drawBounds);
// Geometry shader backend draws primitives in two subpasses.
if (Impl::kGeometryShader == fImpl) {
SkASSERT(GSSubpass::kHulls == fGSSubpass);
GrCCCoverageProcessor cornerProc(*this, GSSubpass::kCorners);
- cmdBuff->draw(cornerProc, pipeline, meshes, dynamicStates, meshCount, drawBounds);
+ cmdBuff->draw(cornerProc, pipeline, nullptr, &dynamicStateArrays, meshes, meshCount,
+ drawBounds);
}
}
diff --git a/src/gpu/ccpr/GrCCCoverageProcessor.h b/src/gpu/ccpr/GrCCCoverageProcessor.h
index 89890486d3..e5b6bc1119 100644
--- a/src/gpu/ccpr/GrCCCoverageProcessor.h
+++ b/src/gpu/ccpr/GrCCCoverageProcessor.h
@@ -105,7 +105,7 @@ public:
}
}
- void draw(GrOpFlushState*, const GrPipeline&, const GrMesh[], const GrPipeline::DynamicState[],
+ void draw(GrOpFlushState*, const GrPipeline&, const SkIRect scissorRects[], const GrMesh[],
int meshCount, const SkRect& drawBounds) const;
// The Shader provides code to calculate each pixel's coverage in a RenderPass. It also
diff --git a/src/gpu/ccpr/GrCCDrawPathsOp.cpp b/src/gpu/ccpr/GrCCDrawPathsOp.cpp
index db5ea355aa..bbe3df29eb 100644
--- a/src/gpu/ccpr/GrCCDrawPathsOp.cpp
+++ b/src/gpu/ccpr/GrCCDrawPathsOp.cpp
@@ -337,7 +337,9 @@ void GrCCDrawPathsOp::onExecute(GrOpFlushState* flushState) {
initArgs.fCaps = &flushState->caps();
initArgs.fResourceProvider = flushState->resourceProvider();
initArgs.fDstProxy = flushState->drawOpArgs().fDstProxy;
- GrPipeline pipeline(initArgs, std::move(fProcessors), flushState->detachAppliedClip());
+ auto clip = flushState->detachAppliedClip();
+ GrPipeline::FixedDynamicState fixedDynamicState(clip.scissorState().rect());
+ GrPipeline pipeline(initArgs, std::move(fProcessors), std::move(clip));
int baseInstance = fBaseInstance;
SkASSERT(baseInstance >= 0); // Make sure setupResources() has been called.
@@ -347,8 +349,8 @@ void GrCCDrawPathsOp::onExecute(GrOpFlushState* flushState) {
GrCCPathProcessor pathProc(flushState->resourceProvider(), sk_ref_sp(range.fAtlasProxy),
fViewMatrixIfUsingLocalCoords);
- pathProc.drawPaths(flushState, pipeline, *resources, baseInstance, range.fEndInstanceIdx,
- this->bounds());
+ pathProc.drawPaths(flushState, pipeline, &fixedDynamicState, *resources, baseInstance,
+ range.fEndInstanceIdx, this->bounds());
baseInstance = range.fEndInstanceIdx;
}
diff --git a/src/gpu/ccpr/GrCCPathParser.cpp b/src/gpu/ccpr/GrCCPathParser.cpp
index 6f9b2240d7..1935385eeb 100644
--- a/src/gpu/ccpr/GrCCPathParser.cpp
+++ b/src/gpu/ccpr/GrCCPathParser.cpp
@@ -517,7 +517,7 @@ bool GrCCPathParser::finalize(GrOnFlushResourceProvider* onFlushRP) {
SkASSERT(instanceIndices[1].fConics == quadEndIdx);
fMeshesScratchBuffer.reserve(fMaxMeshesPerDraw);
- fDynamicStatesScratchBuffer.reserve(fMaxMeshesPerDraw);
+ fScissorRectScratchBuffer.reserve(fMaxMeshesPerDraw);
return true;
}
@@ -564,11 +564,11 @@ void GrCCPathParser::drawPrimitives(GrOpFlushState* flushState, const GrPipeline
GrCCCoverageProcessor::PrimitiveType primitiveType,
int PrimitiveTallies::*instanceType,
const SkIRect& drawBounds) const {
- SkASSERT(pipeline.getScissorState().enabled());
+ SkASSERT(pipeline.isScissorEnabled());
// Don't call reset(), as that also resets the reserve count.
fMeshesScratchBuffer.pop_back_n(fMeshesScratchBuffer.count());
- fDynamicStatesScratchBuffer.pop_back_n(fDynamicStatesScratchBuffer.count());
+ fScissorRectScratchBuffer.pop_back_n(fScissorRectScratchBuffer.count());
GrCCCoverageProcessor proc(flushState->resourceProvider(), primitiveType);
@@ -584,8 +584,8 @@ void GrCCPathParser::drawPrimitives(GrOpFlushState* flushState, const GrPipeline
int baseInstance = fBaseInstances[(int)ScissorMode::kNonScissored].*instanceType +
previousBatch.fEndNonScissorIndices.*instanceType;
proc.appendMesh(fInstanceBuffer.get(), instanceCount, baseInstance, &fMeshesScratchBuffer);
- fDynamicStatesScratchBuffer.push_back().fScissorRect.setXYWH(0, 0, drawBounds.width(),
- drawBounds.height());
+ fScissorRectScratchBuffer.push_back().setXYWH(0, 0, drawBounds.width(),
+ drawBounds.height());
SkDEBUGCODE(totalInstanceCount += instanceCount);
}
@@ -603,17 +603,17 @@ void GrCCPathParser::drawPrimitives(GrOpFlushState* flushState, const GrPipeline
SkASSERT(instanceCount > 0);
proc.appendMesh(fInstanceBuffer.get(), instanceCount,
baseScissorInstance + startIndex, &fMeshesScratchBuffer);
- fDynamicStatesScratchBuffer.push_back().fScissorRect = scissorSubBatch.fScissor;
+ fScissorRectScratchBuffer.push_back() = scissorSubBatch.fScissor;
SkDEBUGCODE(totalInstanceCount += instanceCount);
}
- SkASSERT(fMeshesScratchBuffer.count() == fDynamicStatesScratchBuffer.count());
+ SkASSERT(fMeshesScratchBuffer.count() == fScissorRectScratchBuffer.count());
SkASSERT(fMeshesScratchBuffer.count() <= fMaxMeshesPerDraw);
SkASSERT(totalInstanceCount == batch.fTotalPrimitiveCounts.*instanceType);
if (!fMeshesScratchBuffer.empty()) {
- proc.draw(flushState, pipeline, fMeshesScratchBuffer.begin(),
- fDynamicStatesScratchBuffer.begin(), fMeshesScratchBuffer.count(),
+ proc.draw(flushState, pipeline, fScissorRectScratchBuffer.begin(),
+ fMeshesScratchBuffer.begin(), fMeshesScratchBuffer.count(),
SkRect::Make(drawBounds));
}
}
diff --git a/src/gpu/ccpr/GrCCPathParser.h b/src/gpu/ccpr/GrCCPathParser.h
index 1c09b98024..57b1ce6e97 100644
--- a/src/gpu/ccpr/GrCCPathParser.h
+++ b/src/gpu/ccpr/GrCCPathParser.h
@@ -157,7 +157,7 @@ private:
sk_sp<GrBuffer> fInstanceBuffer;
PrimitiveTallies fBaseInstances[kNumScissorModes];
mutable SkSTArray<32, GrMesh> fMeshesScratchBuffer;
- mutable SkSTArray<32, GrPipeline::DynamicState> fDynamicStatesScratchBuffer;
+ mutable SkSTArray<32, SkIRect> fScissorRectScratchBuffer;
};
inline void GrCCPathParser::PathStats::statPath(const SkPath& path) {
diff --git a/src/gpu/ccpr/GrCCPathProcessor.cpp b/src/gpu/ccpr/GrCCPathProcessor.cpp
index e1a508619a..450b74c6a2 100644
--- a/src/gpu/ccpr/GrCCPathProcessor.cpp
+++ b/src/gpu/ccpr/GrCCPathProcessor.cpp
@@ -130,6 +130,7 @@ GrGLSLPrimitiveProcessor* GrCCPathProcessor::createGLSLInstance(const GrShaderCa
}
void GrCCPathProcessor::drawPaths(GrOpFlushState* flushState, const GrPipeline& pipeline,
+ const GrPipeline::FixedDynamicState* fixedDynamicState,
const GrCCPerFlushResources& resources, int baseInstance,
int endInstance, const SkRect& bounds) const {
const GrCaps& caps = flushState->caps();
@@ -147,7 +148,8 @@ void GrCCPathProcessor::drawPaths(GrOpFlushState* flushState, const GrPipeline&
enablePrimitiveRestart);
mesh.setVertexData(resources.vertexBuffer());
- flushState->rtCommandBuffer()->draw(*this, pipeline, &mesh, nullptr, 1, bounds);
+ flushState->rtCommandBuffer()->draw(*this, pipeline, fixedDynamicState, nullptr, &mesh, 1,
+ bounds);
}
void GLSLPathProcessor::onEmitCode(EmitArgs& args, GrGPArgs* gpArgs) {
diff --git a/src/gpu/ccpr/GrCCPathProcessor.h b/src/gpu/ccpr/GrCCPathProcessor.h
index 54c1b7e2ed..878cd1c76d 100644
--- a/src/gpu/ccpr/GrCCPathProcessor.h
+++ b/src/gpu/ccpr/GrCCPathProcessor.h
@@ -8,16 +8,16 @@
#ifndef GrCCPathProcessor_DEFINED
#define GrCCPathProcessor_DEFINED
+#include <array>
#include "GrCaps.h"
#include "GrGeometryProcessor.h"
+#include "GrPipeline.h"
#include "SkPath.h"
-#include <array>
class GrCCPathCacheEntry;
class GrCCPerFlushResources;
class GrOnFlushResourceProvider;
class GrOpFlushState;
-class GrPipeline;
/**
* This class draws AA paths using the coverage count masks produced by GrCCCoverageProcessor.
@@ -86,8 +86,9 @@ public:
void getGLSLProcessorKey(const GrShaderCaps&, GrProcessorKeyBuilder*) const override {}
GrGLSLPrimitiveProcessor* createGLSLInstance(const GrShaderCaps&) const override;
- void drawPaths(GrOpFlushState*, const GrPipeline&, const GrCCPerFlushResources&,
- int baseInstance, int endInstance, const SkRect& bounds) const;
+ void drawPaths(GrOpFlushState*, const GrPipeline&, const GrPipeline::FixedDynamicState*,
+ const GrCCPerFlushResources&, int baseInstance, int endInstance,
+ const SkRect& bounds) const;
private:
const Attribute& onVertexAttribute(int i) const override { return kEdgeNormsAttrib; }
diff --git a/src/gpu/ccpr/GrCCPerFlushResources.cpp b/src/gpu/ccpr/GrCCPerFlushResources.cpp
index 362ae77d79..dd0bf1b473 100644
--- a/src/gpu/ccpr/GrCCPerFlushResources.cpp
+++ b/src/gpu/ccpr/GrCCPerFlushResources.cpp
@@ -67,7 +67,7 @@ public:
GrPipeline pipeline(flushState->proxy(), GrPipeline::ScissorState::kDisabled,
SkBlendMode::kSrc);
GrCCPathProcessor pathProc(flushState->resourceProvider(), std::move(fStashedAtlasProxy));
- pathProc.drawPaths(flushState, pipeline, *fResources, fBaseInstance, fEndInstance,
+ pathProc.drawPaths(flushState, pipeline, nullptr, *fResources, fBaseInstance, fEndInstance,
this->bounds());
// Ensure we released the stashed atlas proxy. This allows its underlying texture to be
// reused as the current flush's mainline CCPR atlas if needed.