Misc batch->op cleanup Part 1 of 2
Change-Id: I80f951976558a284e55386e0a368f08bd835d8ca
Reviewed-on: https://skia-review.googlesource.com/6359
Commit-Queue: Brian Salomon <bsalomon@google.com>
Reviewed-by: Brian Osman <brianosman@google.com>
diff --git a/src/gpu/GrContext.cpp b/src/gpu/GrContext.cpp
index f1a080f..8cbe701 100644
--- a/src/gpu/GrContext.cpp
+++ b/src/gpu/GrContext.cpp
@@ -94,9 +94,9 @@
fDidTestPMConversions = false;
GrRenderTargetOpList::Options rtOpListOptions;
- rtOpListOptions.fClipBatchToBounds = options.fClipBatchToBounds;
- rtOpListOptions.fMaxBatchLookback = options.fMaxBatchLookback;
- rtOpListOptions.fMaxBatchLookahead = options.fMaxBatchLookahead;
+ rtOpListOptions.fClipDrawOpsToBounds = options.fClipDrawOpsToBounds;
+ rtOpListOptions.fMaxOpCombineLookback = options.fMaxOpCombineLookback;
+ rtOpListOptions.fMaxOpCombineLookahead = options.fMaxOpCombineLookahead;
GrPathRendererChain::Options prcOptions;
prcOptions.fDisableDistanceFieldRenderer = options.fDisableDistanceFieldPaths;
prcOptions.fAllowPathMaskCaching = options.fAllowPathMaskCaching;
diff --git a/src/gpu/GrDefaultGeoProcFactory.h b/src/gpu/GrDefaultGeoProcFactory.h
index 022930b6..688fcc9 100644
--- a/src/gpu/GrDefaultGeoProcFactory.h
+++ b/src/gpu/GrDefaultGeoProcFactory.h
@@ -12,9 +12,7 @@
/*
* A factory for creating default Geometry Processors which simply multiply position by the uniform
- * view matrix and wire through color, coverage, UV coords if requested. Right now this is only
- * used in the creation of optimized draw states because adding default GPs to the drawstate can
- * interfere with batching due to updating the drawstate.
+ * view matrix and wire through color, coverage, UV coords if requested.
*/
namespace GrDefaultGeoProcFactory {
// Structs for adding vertex attributes
diff --git a/src/gpu/GrDrawingManager.cpp b/src/gpu/GrDrawingManager.cpp
index 9cbdbbe..515e26e 100644
--- a/src/gpu/GrDrawingManager.cpp
+++ b/src/gpu/GrDrawingManager.cpp
@@ -83,8 +83,8 @@
fOpLists[i]->prepareOps(&fFlushState);
}
- // Enable this to print out verbose batching information
#if 0
+ // Enable this to print out verbose GrOp information
for (int i = 0; i < fOpLists.count(); ++i) {
SkDEBUGCODE(fOpLists[i]->dump();)
}
diff --git a/src/gpu/GrGeometryProcessor.h b/src/gpu/GrGeometryProcessor.h
index bc6f6eb..2711b9a 100644
--- a/src/gpu/GrGeometryProcessor.h
+++ b/src/gpu/GrGeometryProcessor.h
@@ -64,7 +64,6 @@
* 1) LocalCoordTransform * Position - in Shader
* 2) LocalCoordTransform * ExplicitLocalCoords- in Shader
* 3) A transformation on the CPU uploaded via vertex attribute
- * TODO make this GrBatches responsibility
*/
enum LocalCoordsType {
kUnused_LocalCoordsType,
diff --git a/src/gpu/GrGpuCommandBuffer.h b/src/gpu/GrGpuCommandBuffer.h
index 879de49..332b0e5 100644
--- a/src/gpu/GrGpuCommandBuffer.h
+++ b/src/gpu/GrGpuCommandBuffer.h
@@ -24,7 +24,7 @@
/**
* The GrGpuCommandBuffer is a series of commands (draws, clears, and discards), which all target
* the same render target. It is possible that these commands execute immediately (GL), or get
- * buffered up for later execution (Vulkan). GrBatches will execute their draw commands into a
+ * buffered up for later execution (Vulkan). GrOps will execute their draw commands into a
* GrGpuCommandBuffer.
*
* Ideally we'd know the GrRenderTarget, or at least its properties when the GrGpuCommandBuffer, is
diff --git a/src/gpu/GrOpFlushState.h b/src/gpu/GrOpFlushState.h
index 16d3968..ed77c3b 100644
--- a/src/gpu/GrOpFlushState.h
+++ b/src/gpu/GrOpFlushState.h
@@ -5,8 +5,8 @@
* found in the LICENSE file.
*/
-#ifndef GrBatchBuffer_DEFINED
-#define GrBatchBuffer_DEFINED
+#ifndef GrOpFlushState_DEFINED
+#define GrOpFlushState_DEFINED
#include "GrBufferAllocPool.h"
#include "GrGpu.h"
diff --git a/src/gpu/GrPipeline.h b/src/gpu/GrPipeline.h
index e95c7c2..e49dad4 100644
--- a/src/gpu/GrPipeline.h
+++ b/src/gpu/GrPipeline.h
@@ -96,9 +96,9 @@
static bool AreEqual(const GrPipeline& a, const GrPipeline& b);
/**
- * Allows a GrOp subclass to determine whether two GrBatches can combine. This is a stricter
- * test than isEqual because it also considers blend barriers when the two batches' bounds
- * overlap
+ * Allows a GrOp subclass to determine whether two GrOp instances can combine. This is a
+ * stricter test than isEqual because it also considers blend barriers when the two ops'
+ * bounds overlap
*/
static bool CanCombine(const GrPipeline& a, const SkRect& aBounds,
const GrPipeline& b, const SkRect& bBounds,
diff --git a/src/gpu/GrPipelineBuilder.h b/src/gpu/GrPipelineBuilder.h
index f5f159f..1bc9002 100644
--- a/src/gpu/GrPipelineBuilder.h
+++ b/src/gpu/GrPipelineBuilder.h
@@ -292,7 +292,7 @@
///////////////////////////////////////////////////////////////////////////
- bool usePLSDstRead(const GrDrawOp* batch) const;
+ bool usePLSDstRead(const GrDrawOp*) const;
private:
// Some of the auto restore objects assume that no effects are removed during their lifetime.
diff --git a/src/gpu/GrPrimitiveProcessor.h b/src/gpu/GrPrimitiveProcessor.h
index 4cc1112..ed2b2e3 100644
--- a/src/gpu/GrPrimitiveProcessor.h
+++ b/src/gpu/GrPrimitiveProcessor.h
@@ -18,7 +18,7 @@
* responsible for providing a color and coverage input into the Ganesh rendering pipeline. Through
* optimization, Ganesh may decide a different color, no color, and / or no coverage are required
* from the GrPrimitiveProcessor, so the GrPrimitiveProcessor must be able to support this
- * functionality. We also use the GrPrimitiveProcessor to make batching decisions.
+ * functionality.
*
* There are two feedback loops between the GrFragmentProcessors, the GrXferProcessor, and the
* GrPrimitiveProcessor. These loops run on the CPU and compute any invariant components which
diff --git a/src/gpu/GrRenderTargetOpList.cpp b/src/gpu/GrRenderTargetOpList.cpp
index 4eeef57..0d380a1 100644
--- a/src/gpu/GrRenderTargetOpList.cpp
+++ b/src/gpu/GrRenderTargetOpList.cpp
@@ -42,9 +42,9 @@
////////////////////////////////////////////////////////////////////////////////
-// Experimentally we have found that most batching occurs within the first 10 comparisons.
-static const int kDefaultMaxBatchLookback = 10;
-static const int kDefaultMaxBatchLookahead = 10;
+// Experimentally we have found that most combining occurs within the first 10 comparisons.
+static const int kDefaultMaxOpLookback = 10;
+static const int kDefaultMaxOpLookahead = 10;
GrRenderTargetOpList::GrRenderTargetOpList(GrRenderTargetProxy* rtp, GrGpu* gpu,
GrResourceProvider* resourceProvider,
@@ -57,11 +57,11 @@
// TODO: Stop extracting the context (currently needed by GrClip)
fContext = fGpu->getContext();
- fClipOpToBounds = options.fClipBatchToBounds;
- fMaxOpLookback = (options.fMaxBatchLookback < 0) ? kDefaultMaxBatchLookback :
- options.fMaxBatchLookback;
- fMaxOpLookahead = (options.fMaxBatchLookahead < 0) ? kDefaultMaxBatchLookahead :
- options.fMaxBatchLookahead;
+ fClipOpToBounds = options.fClipDrawOpsToBounds;
+ fMaxOpLookback = (options.fMaxOpCombineLookback < 0) ? kDefaultMaxOpLookback
+ : options.fMaxOpCombineLookback;
+ fMaxOpLookahead = (options.fMaxOpCombineLookahead < 0) ? kDefaultMaxOpLookahead
+ : options.fMaxOpCombineLookahead;
if (GrCaps::InstancedSupport::kNone != this->caps()->instancedSupport()) {
fInstancedRendering.reset(fGpu->createInstancedRendering());
@@ -98,9 +98,9 @@
void GrRenderTargetOpList::setupDstTexture(GrRenderTarget* rt,
const GrClip& clip,
- const SkRect& batchBounds,
+ const SkRect& opBounds,
GrXferProcessor::DstTexture* dstTexture) {
- SkRect bounds = batchBounds;
+ SkRect bounds = opBounds;
bounds.outset(0.5f, 0.5f);
if (this->caps()->textureBarrierSupport()) {
@@ -235,10 +235,10 @@
}
}
-static void batch_bounds(SkRect* bounds, const GrOp* batch) {
- *bounds = batch->bounds();
- if (batch->hasZeroArea()) {
- if (batch->hasAABloat()) {
+static void op_bounds(SkRect* bounds, const GrOp* op) {
+ *bounds = op->bounds();
+ if (op->hasZeroArea()) {
+ if (op->hasAABloat()) {
bounds->outset(0.5f, 0.5f);
} else {
// We don't know which way the particular GPU will snap lines or points at integer
@@ -267,7 +267,7 @@
sk_sp<GrDrawOp> op) {
// Setup clip
SkRect bounds;
- batch_bounds(&bounds, op.get());
+ op_bounds(&bounds, op.get());
GrAppliedClip appliedClip(bounds);
if (!clip.apply(fContext, renderTargetContext, pipelineBuilder.isHWAntialias(),
pipelineBuilder.hasUserStencilSettings(), &appliedClip)) {
@@ -554,7 +554,7 @@
}
++j;
if (j > maxCandidateIdx) {
- GrOP_INFO("\t\tReached max lookahead or end of batch array %d\n", i);
+ GrOP_INFO("\t\tReached max lookahead or end of op array %d\n", i);
break;
}
}
diff --git a/src/gpu/GrRenderTargetOpList.h b/src/gpu/GrRenderTargetOpList.h
index 5b2e5e1..a2b323f 100644
--- a/src/gpu/GrRenderTargetOpList.h
+++ b/src/gpu/GrRenderTargetOpList.h
@@ -41,13 +41,9 @@
public:
/** Options for GrRenderTargetOpList behavior. */
struct Options {
- Options ()
- : fClipBatchToBounds(false)
- , fMaxBatchLookback(-1)
- , fMaxBatchLookahead(-1) {}
- bool fClipBatchToBounds;
- int fMaxBatchLookback;
- int fMaxBatchLookahead;
+ bool fClipDrawOpsToBounds = false;
+ int fMaxOpCombineLookback = -1;
+ int fMaxOpCombineLookahead = -1;
};
GrRenderTargetOpList(GrRenderTargetProxy*, GrGpu*, GrResourceProvider*,
@@ -150,7 +146,7 @@
// a texture copy could not be made.
void setupDstTexture(GrRenderTarget*,
const GrClip&,
- const SkRect& drawOpBounds,
+ const SkRect& opBounds,
GrXferProcessor::DstTexture*);
// Used only via GrRenderTargetContextPriv.
diff --git a/src/gpu/GrResourceProvider.cpp b/src/gpu/GrResourceProvider.cpp
index e18718e..d74807a 100644
--- a/src/gpu/GrResourceProvider.cpp
+++ b/src/gpu/GrResourceProvider.cpp
@@ -33,7 +33,7 @@
const GrUniqueKey& key) {
size_t bufferSize = patternSize * reps * sizeof(uint16_t);
- // This is typically used in GrBatchs, so we assume kNoPendingIO.
+ // This is typically used in GrMeshDrawOps, so we assume kNoPendingIO.
GrBuffer* buffer = this->createBuffer(bufferSize, kIndex_GrBufferType, kStatic_GrAccessPattern,
kNoPendingIO_Flag);
if (!buffer) {
diff --git a/src/gpu/SkGpuDevice.cpp b/src/gpu/SkGpuDevice.cpp
index 8adc76e..b082241 100644
--- a/src/gpu/SkGpuDevice.cpp
+++ b/src/gpu/SkGpuDevice.cpp
@@ -666,8 +666,8 @@
// Path-based stroking looks better for thin rects
SkScalar strokeWidth = draw.fMatrix->getMaxScale() * paint.getStrokeWidth();
if (strokeWidth >= 1.0f) {
- // Round capping support is currently disabled b.c. it would require
- // a RRect batch that takes a localMatrix.
+ // Round capping support is currently disabled b.c. it would require a RRect
+ // GrDrawOp that takes a localMatrix.
this->drawStrokedLine(points, draw, paint);
return;
}
diff --git a/src/gpu/SkGpuDevice_drawTexture.cpp b/src/gpu/SkGpuDevice_drawTexture.cpp
index 7dc0893..9556146 100644
--- a/src/gpu/SkGpuDevice_drawTexture.cpp
+++ b/src/gpu/SkGpuDevice_drawTexture.cpp
@@ -152,10 +152,10 @@
const SkMatrix& srcToDstMatrix,
const GrClip& clip,
const SkPaint& paint) {
- // Specifying the texture coords as local coordinates is an attempt to enable more batching
- // by not baking anything about the srcRect, dstRect, or viewMatrix, into the texture FP. In
- // the future this should be an opaque optimization enabled by the combination of batch/GP and
- // FP.
+ // Specifying the texture coords as local coordinates is an attempt to enable more GrDrawOp
+ // combining by not baking anything about the srcRect, dstRect, or viewMatrix, into the texture
+ // FP. In the future this should be an opaque optimization enabled by the combination of
+ // GrDrawOp/GP and FP.
const SkMaskFilter* mf = paint.getMaskFilter();
// The shader expects proper local coords, so we can't replace local coords with texture coords
// if the shader will be used. If we have a mask filter we will change the underlying geometry
diff --git a/src/gpu/gl/GrGLCaps.cpp b/src/gpu/gl/GrGLCaps.cpp
index 5a0864e..d3adc28 100644
--- a/src/gpu/gl/GrGLCaps.cpp
+++ b/src/gpu/gl/GrGLCaps.cpp
@@ -436,10 +436,10 @@
// On many GPUs, map memory is very expensive, so we effectively disable it here by setting the
// threshold to the maximum unless the client gives us a hint that map memory is cheap.
if (fBufferMapThreshold < 0) {
- // We think mapping on Chromium will be cheaper once we know ahead of time how much space
- // we will use for all GrBatchs. Right now we might wind up mapping a large buffer and using
- // a small subset.
#if 0
+ // We think mapping on Chromium will be cheaper once we know ahead of time how much space
+ // we will use for all GrMeshDrawOps. Right now we might wind up mapping a large buffer and
+ // using a small subset.
fBufferMapThreshold = kChromium_GrGLDriver == ctxInfo.driver() ? 0 : SK_MaxS32;
#else
fBufferMapThreshold = SK_MaxS32;
diff --git a/src/gpu/gl/GrGLGpu.cpp b/src/gpu/gl/GrGLGpu.cpp
index 80c7f61..577aca8 100644
--- a/src/gpu/gl/GrGLGpu.cpp
+++ b/src/gpu/gl/GrGLGpu.cpp
@@ -2810,7 +2810,7 @@
sizeof(uint16_t) * nonInstMesh->startIndex());
// info.startVertex() was accounted for by setupGeometry.
if (this->glCaps().drawRangeElementsSupport()) {
- // We assume here that the batch that generated the mesh used the full
+ // We assume here that the GrMeshDrawOps that generated the mesh used the full
// 0..vertexCount()-1 range.
int start = 0;
int end = nonInstMesh->vertexCount() - 1;
diff --git a/src/gpu/ops/GrAtlasTextOp.cpp b/src/gpu/ops/GrAtlasTextOp.cpp
index bd05d44..c4c9170 100644
--- a/src/gpu/ops/GrAtlasTextOp.cpp
+++ b/src/gpu/ops/GrAtlasTextOp.cpp
@@ -131,9 +131,9 @@
size_t byteCount;
void* blobVertices;
int subRunGlyphCount;
- blob->regenInBatch(target, fFontCache, &helper, args.fRun, args.fSubRun, &glyphCache,
- vertexStride, args.fViewMatrix, args.fX, args.fY, args.fColor,
- &blobVertices, &byteCount, &subRunGlyphCount);
+ blob->regenInOp(target, fFontCache, &helper, args.fRun, args.fSubRun, &glyphCache,
+ vertexStride, args.fViewMatrix, args.fX, args.fY, args.fColor,
+ &blobVertices, &byteCount, &subRunGlyphCount);
// now copy all vertices
memcpy(currVertex, blobVertices, byteCount);
diff --git a/src/gpu/text/GrAtlasTextBlob.cpp b/src/gpu/text/GrAtlasTextBlob.cpp
index bf42d5d..9aca37a 100644
--- a/src/gpu/text/GrAtlasTextBlob.cpp
+++ b/src/gpu/text/GrAtlasTextBlob.cpp
@@ -268,7 +268,7 @@
subRunColor = color;
}
- sk_sp<GrAtlasTextOp> batch;
+ sk_sp<GrAtlasTextOp> op;
if (info.drawAsDistanceFields()) {
SkColor filteredColor;
SkColorFilter* colorFilter = skPaint.getColorFilter();
@@ -278,13 +278,13 @@
filteredColor = skPaint.getColor();
}
bool useBGR = SkPixelGeometryIsBGR(props.pixelGeometry());
- batch = GrAtlasTextOp::MakeDistanceField(glyphCount, cache, distanceAdjustTable,
- useGammaCorrectDistanceTable, filteredColor,
- info.hasUseLCDText(), useBGR);
+ op = GrAtlasTextOp::MakeDistanceField(glyphCount, cache, distanceAdjustTable,
+ useGammaCorrectDistanceTable, filteredColor,
+ info.hasUseLCDText(), useBGR);
} else {
- batch = GrAtlasTextOp::MakeBitmap(format, glyphCount, cache);
+ op = GrAtlasTextOp::MakeBitmap(format, glyphCount, cache);
}
- GrAtlasTextOp::Geometry& geometry = batch->geometry();
+ GrAtlasTextOp::Geometry& geometry = op->geometry();
geometry.fViewMatrix = viewMatrix;
geometry.fBlob = SkRef(this);
geometry.fRun = run;
@@ -292,9 +292,9 @@
geometry.fColor = subRunColor;
geometry.fX = x;
geometry.fY = y;
- batch->init();
+ op->init();
- return std::move(batch);
+ return std::move(op);
}
inline
diff --git a/src/gpu/text/GrAtlasTextBlob.h b/src/gpu/text/GrAtlasTextBlob.h
index 0028cc1..9b3f59c 100644
--- a/src/gpu/text/GrAtlasTextBlob.h
+++ b/src/gpu/text/GrAtlasTextBlob.h
@@ -260,14 +260,14 @@
}
/**
- * Consecutive calls to regenInBatch often use the same SkGlyphCache. If the same instance of
- * SkAutoGlyphCache is passed to multiple calls of regenInBatch then it can save the cost of
+ * Consecutive calls to regenInOp often use the same SkGlyphCache. If the same instance of
+ * SkAutoGlyphCache is passed to multiple calls of regenInOp then it can save the cost of
* multiple detach/attach operations of SkGlyphCache.
*/
- void regenInBatch(GrDrawOp::Target* target, GrAtlasGlyphCache* fontCache,
- GrBlobRegenHelper *helper, int run, int subRun, SkAutoGlyphCache*,
- size_t vertexStride, const SkMatrix& viewMatrix, SkScalar x, SkScalar y,
- GrColor color, void** vertices, size_t* byteCount, int* glyphCount);
+ void regenInOp(GrDrawOp::Target* target, GrAtlasGlyphCache* fontCache,
+ GrBlobRegenHelper* helper, int run, int subRun, SkAutoGlyphCache*,
+ size_t vertexStride, const SkMatrix& viewMatrix, SkScalar x, SkScalar y,
+ GrColor color, void** vertices, size_t* byteCount, int* glyphCount);
const Key& key() const { return fKey; }
diff --git a/src/gpu/text/GrAtlasTextBlob_regenInBatch.cpp b/src/gpu/text/GrAtlasTextBlob_regenInOp.cpp
similarity index 95%
rename from src/gpu/text/GrAtlasTextBlob_regenInBatch.cpp
rename to src/gpu/text/GrAtlasTextBlob_regenInOp.cpp
index 9a37e42..3150988 100644
--- a/src/gpu/text/GrAtlasTextBlob_regenInBatch.cpp
+++ b/src/gpu/text/GrAtlasTextBlob_regenInOp.cpp
@@ -241,13 +241,13 @@
#define REGEN_ARGS target, fontCache, helper, &run, &info, lazyCache, \
*glyphCount, vertexStride, color, transX, transY
-void GrAtlasTextBlob::regenInBatch(GrDrawOp::Target* target,
- GrAtlasGlyphCache* fontCache,
- GrBlobRegenHelper *helper,
- int runIndex, int subRunIndex, SkAutoGlyphCache* lazyCache,
- size_t vertexStride, const SkMatrix& viewMatrix,
- SkScalar x, SkScalar y, GrColor color,
- void** vertices, size_t* byteCount, int* glyphCount) {
+void GrAtlasTextBlob::regenInOp(GrDrawOp::Target* target,
+ GrAtlasGlyphCache* fontCache,
+ GrBlobRegenHelper* helper,
+ int runIndex, int subRunIndex, SkAutoGlyphCache* lazyCache,
+ size_t vertexStride, const SkMatrix& viewMatrix,
+ SkScalar x, SkScalar y, GrColor color,
+ void** vertices, size_t* byteCount, int* glyphCount) {
Run& run = fRuns[runIndex];
Run::SubRunInfo& info = run.fSubRunInfo[subRunIndex];
diff --git a/src/gpu/text/GrAtlasTextContext.cpp b/src/gpu/text/GrAtlasTextContext.cpp
index e1a3675..3c155e3 100644
--- a/src/gpu/text/GrAtlasTextContext.cpp
+++ b/src/gpu/text/GrAtlasTextContext.cpp
@@ -417,8 +417,8 @@
SkScalar x = SkIntToScalar(xInt);
SkScalar y = SkIntToScalar(yInt);
- // right now we don't handle textblobs, nor do we handle drawPosText. Since we only
- // intend to test the batch with this unit test, that is okay.
+ // right now we don't handle textblobs, nor do we handle drawPosText. Since we only intend to
+ // test the text op with this unit test, that is okay.
sk_sp<GrAtlasTextBlob> blob(GrAtlasTextContext::CreateDrawTextBlob(
context->getTextBlobCache(), context->getAtlasGlyphCache(),
*context->caps()->shaderCaps(), grPaint, skPaint,
diff --git a/src/gpu/text/GrStencilAndCoverTextContext.cpp b/src/gpu/text/GrStencilAndCoverTextContext.cpp
index ed77e5c..e3ad1a7 100644
--- a/src/gpu/text/GrStencilAndCoverTextContext.cpp
+++ b/src/gpu/text/GrStencilAndCoverTextContext.cpp
@@ -629,7 +629,7 @@
// the entire dst. Realistically this is a moot point, because any context that supports
// NV_path_rendering will also support NV_blend_equation_advanced.
// For clipping we'll just skip any optimizations based on the bounds. This does, however,
- // hurt batching.
+ // hurt GrOp combining.
const SkRect bounds = SkRect::MakeIWH(renderTargetContext->width(),
renderTargetContext->height());