aboutsummaryrefslogtreecommitdiffhomepage
path: root/src
diff options
context:
space:
mode:
authorGravatar bsalomon <bsalomon@google.com>2015-05-07 11:35:55 -0700
committerGravatar Commit bot <commit-bot@chromium.org>2015-05-07 11:35:55 -0700
commite64eb570a5b9480bc24d0656ccabcff1ab13a229 (patch)
tree63b3e4e6bb0533a35f33b00a65e77c37d638c00a /src
parent3b58d75170508567436cce259384d336949407d4 (diff)
Iterate over instanced draws in GrGpu rather than above GrBatchTarget
Diffstat (limited to 'src')
-rw-r--r--src/gpu/GrAAConvexPathRenderer.cpp17
-rwxr-xr-xsrc/gpu/GrAADistanceFieldPathRenderer.cpp7
-rw-r--r--src/gpu/GrAAHairLinePathRenderer.cpp48
-rw-r--r--src/gpu/GrAARectRenderer.cpp4
-rw-r--r--src/gpu/GrAtlasTextContext.cpp7
-rw-r--r--src/gpu/GrBatch.cpp9
-rw-r--r--src/gpu/GrBatch.h12
-rw-r--r--src/gpu/GrGpu.cpp7
-rw-r--r--src/gpu/GrGpu.h3
-rw-r--r--src/gpu/GrOvalRenderer.cpp10
-rw-r--r--src/gpu/GrRectBatch.cpp2
-rw-r--r--src/gpu/GrTest.cpp2
-rw-r--r--src/gpu/GrVertices.h124
-rw-r--r--src/gpu/effects/GrDashingEffect.cpp2
-rw-r--r--src/gpu/gl/GrGLGpu.cpp12
-rw-r--r--src/gpu/gl/GrGLGpu.h6
16 files changed, 136 insertions, 136 deletions
diff --git a/src/gpu/GrAAConvexPathRenderer.cpp b/src/gpu/GrAAConvexPathRenderer.cpp
index 046ef80dc9..a9a3c29612 100644
--- a/src/gpu/GrAAConvexPathRenderer.cpp
+++ b/src/gpu/GrAAConvexPathRenderer.cpp
@@ -794,9 +794,10 @@ public:
int firstVertex;
size_t vertexStride = quadProcessor->getVertexStride();
- void *vertices = batchTarget->makeVertSpace(vertexStride, vertexCount,
- &vertexBuffer, &firstVertex);
- if (!vertices) {
+ QuadVertex* verts = reinterpret_cast<QuadVertex*>(batchTarget->makeVertSpace(
+ vertexStride, vertexCount, &vertexBuffer, &firstVertex));
+
+ if (!verts) {
SkDebugf("Could not allocate vertices\n");
return;
}
@@ -810,18 +811,16 @@ public:
return;
}
- QuadVertex* verts = reinterpret_cast<QuadVertex*>(vertices);
-
SkSTArray<kPreallocDrawCnt, Draw, true> draws;
create_vertices(segments, fanPt, &draws, verts, idxs);
- GrVertices info;
+ GrVertices vertices;
for (int i = 0; i < draws.count(); ++i) {
const Draw& draw = draws[i];
- info.initIndexed(kTriangles_GrPrimitiveType, vertexBuffer, indexBuffer, firstVertex,
- firstIndex, draw.fVertexCnt, draw.fIndexCnt);
- batchTarget->draw(info);
+ vertices.initIndexed(kTriangles_GrPrimitiveType, vertexBuffer, indexBuffer,
+ firstVertex, firstIndex, draw.fVertexCnt, draw.fIndexCnt);
+ batchTarget->draw(vertices);
firstVertex += draw.fVertexCnt;
firstIndex += draw.fIndexCnt;
}
diff --git a/src/gpu/GrAADistanceFieldPathRenderer.cpp b/src/gpu/GrAADistanceFieldPathRenderer.cpp
index fc4ab1647b..3d4a89b0c0 100755
--- a/src/gpu/GrAADistanceFieldPathRenderer.cpp
+++ b/src/gpu/GrAADistanceFieldPathRenderer.cpp
@@ -507,14 +507,11 @@ private:
void flush(GrBatchTarget* batchTarget, FlushInfo* flushInfo) {
GrVertices vertices;
- int instancesToFlush = flushInfo->fInstancesToFlush;
int maxInstancesPerDraw = flushInfo->fIndexBuffer->maxQuads();
vertices.initInstanced(kTriangles_GrPrimitiveType, flushInfo->fVertexBuffer,
flushInfo->fIndexBuffer, flushInfo->fVertexOffset, kVerticesPerQuad,
- kIndicesPerQuad, &instancesToFlush, maxInstancesPerDraw);
- do {
- batchTarget->draw(vertices);
- } while (vertices.nextInstances(&instancesToFlush, maxInstancesPerDraw));
+ kIndicesPerQuad, flushInfo->fInstancesToFlush, maxInstancesPerDraw);
+ batchTarget->draw(vertices);
flushInfo->fVertexOffset += kVerticesPerQuad * flushInfo->fInstancesToFlush;
flushInfo->fInstancesToFlush = 0;
}
diff --git a/src/gpu/GrAAHairLinePathRenderer.cpp b/src/gpu/GrAAHairLinePathRenderer.cpp
index 6101c9ba5b..c5d8ae1126 100644
--- a/src/gpu/GrAAHairLinePathRenderer.cpp
+++ b/src/gpu/GrAAHairLinePathRenderer.cpp
@@ -869,30 +869,26 @@ void AAHairlineBatch::generateGeometry(GrBatchTarget* batchTarget, const GrPipel
size_t vertexStride = lineGP->getVertexStride();
int vertexCount = kLineSegNumVertices * lineCount;
- void *vertices = batchTarget->makeVertSpace(vertexStride, vertexCount,
- &vertexBuffer, &firstVertex);
+ LineVertex* verts = reinterpret_cast<LineVertex*>(
+ batchTarget->makeVertSpace(vertexStride, vertexCount, &vertexBuffer, &firstVertex));
- if (!vertices || !linesIndexBuffer) {
+ if (!verts|| !linesIndexBuffer) {
SkDebugf("Could not allocate vertices\n");
return;
}
SkASSERT(lineGP->getVertexStride() == sizeof(LineVertex));
- LineVertex* verts = reinterpret_cast<LineVertex*>(vertices);
for (int i = 0; i < lineCount; ++i) {
add_line(&lines[2*i], toSrc, this->coverage(), &verts);
}
{
- int linesLeft = lineCount;
- GrVertices info;
- info.initInstanced(kTriangles_GrPrimitiveType, vertexBuffer, linesIndexBuffer,
- firstVertex, kLineSegNumVertices, kIdxsPerLineSeg, &linesLeft,
- kLineSegsNumInIdxBuffer);
- do {
- batchTarget->draw(info);
- } while (info.nextInstances(&linesLeft, kLineSegsNumInIdxBuffer));
+ GrVertices vertices;
+ vertices.initInstanced(kTriangles_GrPrimitiveType, vertexBuffer, linesIndexBuffer,
+ firstVertex, kLineSegNumVertices, kIdxsPerLineSeg, lineCount,
+ kLineSegsNumInIdxBuffer);
+ batchTarget->draw(vertices);
}
}
@@ -939,15 +935,12 @@ void AAHairlineBatch::generateGeometry(GrBatchTarget* batchTarget, const GrPipel
quadGP->initBatchTracker(batchTarget->currentBatchTracker(), init);
{
- int quadsLeft = quadCount;
- GrVertices info;
- info.initInstanced(kTriangles_GrPrimitiveType, vertexBuffer, quadsIndexBuffer,
- firstVertex, kQuadNumVertices, kIdxsPerQuad, &quadsLeft,
- kQuadsNumInIdxBuffer);
- do {
- batchTarget->draw(info);
- } while (info.nextInstances(&quadsLeft, kQuadsNumInIdxBuffer));
- firstVertex += quadCount * kQuadNumVertices;
+ GrVertices verts;
+ verts.initInstanced(kTriangles_GrPrimitiveType, vertexBuffer, quadsIndexBuffer,
+ firstVertex, kQuadNumVertices, kIdxsPerQuad, quadCount,
+ kQuadsNumInIdxBuffer);
+ batchTarget->draw(verts);
+ firstVertex += quadCount * kQuadNumVertices;
}
}
@@ -963,14 +956,11 @@ void AAHairlineBatch::generateGeometry(GrBatchTarget* batchTarget, const GrPipel
conicGP->initBatchTracker(batchTarget->currentBatchTracker(), init);
{
- int conicsLeft = conicCount;
- GrVertices info;
- info.initInstanced(kTriangles_GrPrimitiveType, vertexBuffer, quadsIndexBuffer,
- firstVertex, kQuadNumVertices, kIdxsPerQuad, &conicsLeft,
- kQuadsNumInIdxBuffer);
- do {
- batchTarget->draw(info);
- } while (info.nextInstances(&conicsLeft, kQuadsNumInIdxBuffer));
+ GrVertices verts;
+ verts.initInstanced(kTriangles_GrPrimitiveType, vertexBuffer, quadsIndexBuffer,
+ firstVertex, kQuadNumVertices, kIdxsPerQuad, conicCount,
+ kQuadsNumInIdxBuffer);
+ batchTarget->draw(verts);
}
}
}
diff --git a/src/gpu/GrAARectRenderer.cpp b/src/gpu/GrAARectRenderer.cpp
index 7940e96b84..d208597fbb 100644
--- a/src/gpu/GrAARectRenderer.cpp
+++ b/src/gpu/GrAARectRenderer.cpp
@@ -140,7 +140,7 @@ public:
canTweakAlphaForCoverage);
}
- helper.issueDraws(batchTarget);
+ helper.issueDraw(batchTarget);
}
SkSTArray<1, Geometry, true>* geoData() { return &fGeoData; }
@@ -505,7 +505,7 @@ public:
args.fMiterStroke,
canTweakAlphaForCoverage);
}
- helper.issueDraws(batchTarget);
+ helper.issueDraw(batchTarget);
}
SkSTArray<1, Geometry, true>* geoData() { return &fGeoData; }
diff --git a/src/gpu/GrAtlasTextContext.cpp b/src/gpu/GrAtlasTextContext.cpp
index 9b90f8ac41..bfe938131b 100644
--- a/src/gpu/GrAtlasTextContext.cpp
+++ b/src/gpu/GrAtlasTextContext.cpp
@@ -1838,15 +1838,12 @@ private:
void flush(GrBatchTarget* batchTarget, FlushInfo* flushInfo) {
GrVertices vertices;
- int glyphsToFlush = flushInfo->fGlyphsToFlush;
int maxGlyphsPerDraw = flushInfo->fIndexBuffer->maxQuads();
vertices.initInstanced(kTriangles_GrPrimitiveType, flushInfo->fVertexBuffer,
flushInfo->fIndexBuffer, flushInfo->fVertexOffset,
- kVerticesPerGlyph, kIndicesPerGlyph, &glyphsToFlush,
+ kVerticesPerGlyph, kIndicesPerGlyph, flushInfo->fGlyphsToFlush,
maxGlyphsPerDraw);
- do {
- batchTarget->draw(vertices);
- } while (vertices.nextInstances(&glyphsToFlush, maxGlyphsPerDraw));
+ batchTarget->draw(vertices);
flushInfo->fVertexOffset += kVerticesPerGlyph * flushInfo->fGlyphsToFlush;
flushInfo->fGlyphsToFlush = 0;
}
diff --git a/src/gpu/GrBatch.cpp b/src/gpu/GrBatch.cpp
index 0655a4cd9d..e69819e2d3 100644
--- a/src/gpu/GrBatch.cpp
+++ b/src/gpu/GrBatch.cpp
@@ -50,7 +50,6 @@ void* GrBatch::InstancedHelper::init(GrBatchTarget* batchTarget, GrPrimitiveType
size_t vertexStride, const GrIndexBuffer* indexBuffer,
int verticesPerInstance, int indicesPerInstance,
int instancesToDraw) {
- SkASSERT(!fInstancesRemaining);
SkASSERT(batchTarget);
if (!indexBuffer) {
return NULL;
@@ -65,14 +64,12 @@ void* GrBatch::InstancedHelper::init(GrBatchTarget* batchTarget, GrPrimitiveType
return NULL;
}
SkASSERT(vertexBuffer);
- fInstancesRemaining = instancesToDraw;
size_t ibSize = indexBuffer->gpuMemorySize();
- fMaxInstancesPerDraw = static_cast<int>(ibSize / (sizeof(uint16_t) * indicesPerInstance));
+ int maxInstancesPerDraw = static_cast<int>(ibSize / (sizeof(uint16_t) * indicesPerInstance));
fVertices.initInstanced(primType, vertexBuffer, indexBuffer,
- firstVertex, verticesPerInstance, indicesPerInstance, &fInstancesRemaining,
- fMaxInstancesPerDraw);
- SkASSERT(fMaxInstancesPerDraw > 0);
+ firstVertex, verticesPerInstance, indicesPerInstance, instancesToDraw,
+ maxInstancesPerDraw);
return vertices;
}
diff --git a/src/gpu/GrBatch.h b/src/gpu/GrBatch.h
index 1da964b7fc..9c1647d2df 100644
--- a/src/gpu/GrBatch.h
+++ b/src/gpu/GrBatch.h
@@ -114,7 +114,7 @@ protected:
space for the vertices and flushes the draws to the batch target.*/
class InstancedHelper {
public:
- InstancedHelper() : fInstancesRemaining(0) {}
+ InstancedHelper() {}
/** Returns the allocated storage for the vertices. The caller should populate the before
vertices before calling issueDraws(). */
void* init(GrBatchTarget* batchTarget, GrPrimitiveType, size_t vertexStride,
@@ -122,15 +122,11 @@ protected:
int instancesToDraw);
/** Call after init() to issue draws to the batch target.*/
- void issueDraws(GrBatchTarget* batchTarget) {
+ void issueDraw(GrBatchTarget* batchTarget) {
SkASSERT(fVertices.instanceCount());
- do {
- batchTarget->draw(fVertices);
- } while (fVertices.nextInstances(&fInstancesRemaining, fMaxInstancesPerDraw));
+ batchTarget->draw(fVertices);
}
private:
- int fInstancesRemaining;
- int fMaxInstancesPerDraw;
GrVertices fVertices;
};
@@ -146,7 +142,7 @@ protected:
calling issueDraws(). */
void* init(GrBatchTarget* batchTarget, size_t vertexStride, int quadsToDraw);
- using InstancedHelper::issueDraws;
+ using InstancedHelper::issueDraw;
private:
typedef InstancedHelper INHERITED;
diff --git a/src/gpu/GrGpu.cpp b/src/gpu/GrGpu.cpp
index 8222504b0e..15e4b28c3a 100644
--- a/src/gpu/GrGpu.cpp
+++ b/src/gpu/GrGpu.cpp
@@ -29,6 +29,7 @@ GrVertices& GrVertices::operator =(const GrVertices& di) {
fInstanceCount = di.fInstanceCount;
fVerticesPerInstance = di.fVerticesPerInstance;
fIndicesPerInstance = di.fIndicesPerInstance;
+ fMaxInstancesPerDraw = di.fMaxInstancesPerDraw;
fVertexBuffer.reset(di.vertexBuffer());
fIndexBuffer.reset(di.indexBuffer());
@@ -288,7 +289,11 @@ void GrGpu::removeGpuTraceMarker(const GrGpuTraceMarker* marker) {
void GrGpu::draw(const DrawArgs& args, const GrVertices& vertices) {
this->handleDirtyContext();
- this->onDraw(args, vertices);
+ GrVertices::Iterator iter;
+ const GrNonInstancedVertices* verts = iter.init(vertices);
+ do {
+ this->onDraw(args, *verts);
+ } while ((verts = iter.next()));
}
void GrGpu::stencilPath(const GrPath* path, const StencilPathState& state) {
diff --git a/src/gpu/GrGpu.h b/src/gpu/GrGpu.h
index b580f483ae..83f6c992fc 100644
--- a/src/gpu/GrGpu.h
+++ b/src/gpu/GrGpu.h
@@ -14,6 +14,7 @@
#include "SkPath.h"
class GrContext;
+class GrNonInstancedVertices;
class GrPath;
class GrPathRange;
class GrPathRenderer;
@@ -433,7 +434,7 @@ private:
virtual void onClearStencilClip(GrRenderTarget*, const SkIRect& rect, bool insideClip) = 0;
// overridden by backend-specific derived class to perform the draw call.
- virtual void onDraw(const DrawArgs&, const GrVertices&) = 0;
+ virtual void onDraw(const DrawArgs&, const GrNonInstancedVertices&) = 0;
virtual void onStencilPath(const GrPath*, const StencilPathState&) = 0;
virtual void onDrawPath(const DrawArgs&, const GrPath*, const GrStencilSettings&) = 0;
diff --git a/src/gpu/GrOvalRenderer.cpp b/src/gpu/GrOvalRenderer.cpp
index 966a9498a9..886159cdac 100644
--- a/src/gpu/GrOvalRenderer.cpp
+++ b/src/gpu/GrOvalRenderer.cpp
@@ -784,7 +784,7 @@ public:
verts += kVerticesPerQuad;
}
- helper.issueDraws(batchTarget);
+ helper.issueDraw(batchTarget);
}
SkSTArray<1, Geometry, true>* geoData() { return &fGeoData; }
@@ -1013,7 +1013,7 @@ public:
verts += kVerticesPerQuad;
}
- helper.issueDraws(batchTarget);
+ helper.issueDraw(batchTarget);
}
SkSTArray<1, Geometry, true>* geoData() { return &fGeoData; }
@@ -1277,7 +1277,7 @@ public:
verts += kVerticesPerQuad;
}
- helper.issueDraws(batchTarget);
+ helper.issueDraw(batchTarget);
}
SkSTArray<1, Geometry, true>* geoData() { return &fGeoData; }
@@ -1661,7 +1661,7 @@ public:
}
}
- helper.issueDraws(batchTarget);
+ helper.issueDraw(batchTarget);
}
SkSTArray<1, Geometry, true>* geoData() { return &fGeoData; }
@@ -1853,7 +1853,7 @@ public:
verts++;
}
}
- helper.issueDraws(batchTarget);
+ helper.issueDraw(batchTarget);
}
SkSTArray<1, Geometry, true>* geoData() { return &fGeoData; }
diff --git a/src/gpu/GrRectBatch.cpp b/src/gpu/GrRectBatch.cpp
index ba63db1e0f..ab9ce4febc 100644
--- a/src/gpu/GrRectBatch.cpp
+++ b/src/gpu/GrRectBatch.cpp
@@ -156,7 +156,7 @@ public:
}
}
- helper.issueDraws(batchTarget);
+ helper.issueDraw(batchTarget);
}
SkSTArray<1, Geometry, true>* geoData() { return &fGeoData; }
diff --git a/src/gpu/GrTest.cpp b/src/gpu/GrTest.cpp
index 727fbbc662..1017273031 100644
--- a/src/gpu/GrTest.cpp
+++ b/src/gpu/GrTest.cpp
@@ -199,7 +199,7 @@ private:
void onClearStencilClip(GrRenderTarget*, const SkIRect& rect, bool insideClip) override {}
- void onDraw(const DrawArgs&, const GrVertices&) override {}
+ void onDraw(const DrawArgs&, const GrNonInstancedVertices&) override {}
void onStencilPath(const GrPath* path, const StencilPathState& state) override {}
diff --git a/src/gpu/GrVertices.h b/src/gpu/GrVertices.h
index f03482662e..10b2679da4 100644
--- a/src/gpu/GrVertices.h
+++ b/src/gpu/GrVertices.h
@@ -11,13 +11,36 @@
#include "GrIndexBuffer.h"
#include "GrVertexBuffer.h"
+class GrNonInstancedVertices {
+public:
+ GrPrimitiveType primitiveType() const { return fPrimitiveType; }
+ int startVertex() const { return fStartVertex; }
+ int startIndex() const { return fStartIndex; }
+ int vertexCount() const { return fVertexCount; }
+ int indexCount() const { return fIndexCount; }
+ bool isIndexed() const { return fIndexCount > 0; }
+
+ const GrVertexBuffer* vertexBuffer() const { return fVertexBuffer.get(); }
+ const GrIndexBuffer* indexBuffer() const { return fIndexBuffer.get(); }
+
+protected:
+ GrPrimitiveType fPrimitiveType;
+ int fStartVertex;
+ int fStartIndex;
+ int fVertexCount;
+ int fIndexCount;
+ GrPendingIOResource<const GrVertexBuffer, kRead_GrIOType> fVertexBuffer;
+ GrPendingIOResource<const GrIndexBuffer, kRead_GrIOType> fIndexBuffer;
+ friend class GrVertices;
+};
+
/**
* Used to communicate index and vertex buffers, counts, and offsets for a draw from GrBatch to
* GrGpu. It also holds the primitive type for the draw. TODO: Consider moving ownership of this
* and draw-issuing responsibility to GrPrimitiveProcessor. The rest of the vertex info lives there
* already (stride, attribute mappings).
*/
-class GrVertices {
+class GrVertices : public GrNonInstancedVertices {
public:
GrVertices() {}
GrVertices(const GrVertices& di) { (*this) = di; }
@@ -38,6 +61,7 @@ public:
fInstanceCount = 0;
fVerticesPerInstance = 0;
fIndicesPerInstance = 0;
+ fMaxInstancesPerDraw = 0;
}
void initIndexed(GrPrimitiveType primType,
@@ -63,15 +87,21 @@ public:
fInstanceCount = 0;
fVerticesPerInstance = 0;
fIndicesPerInstance = 0;
+ fMaxInstancesPerDraw = 0;
}
+
+ /** Variation of the above that may be used when the total number of instances may exceed
+ the number of instances supported by the index buffer. To be used with
+ nextInstances() to draw in max-sized batches.*/
void initInstanced(GrPrimitiveType primType,
const GrVertexBuffer* vertexBuffer,
const GrIndexBuffer* indexBuffer,
int startVertex,
int verticesPerInstance,
int indicesPerInstance,
- int instanceCount) {
+ int instanceCount,
+ int maxInstancesPerDraw) {
SkASSERT(vertexBuffer);
SkASSERT(indexBuffer);
SkASSERT(instanceCount);
@@ -88,74 +118,62 @@ public:
fInstanceCount = instanceCount;
fVertexCount = instanceCount * fVerticesPerInstance;
fIndexCount = instanceCount * fIndicesPerInstance;
+ fMaxInstancesPerDraw = maxInstancesPerDraw;
}
- /** Variation of the above that may be used when the total number of instances may exceed
- the number of instances supported by the index buffer. To be used with
- nextInstances() to draw in max-sized batches.*/
- void initInstanced(GrPrimitiveType primType,
- const GrVertexBuffer* vertexBuffer,
- const GrIndexBuffer* indexBuffer,
- int startVertex,
- int verticesPerInstance,
- int indicesPerInstance,
- int* instancesRemaining,
- int maxInstancesPerDraw) {
- int instanceCount = SkTMin(*instancesRemaining, maxInstancesPerDraw);
- *instancesRemaining -= instanceCount;
- this->initInstanced(primType, vertexBuffer, indexBuffer, startVertex,
- verticesPerInstance, indicesPerInstance, instanceCount);
- }
-
- GrPrimitiveType primitiveType() const { return fPrimitiveType; }
- int startVertex() const { return fStartVertex; }
- int startIndex() const { return fStartIndex; }
- int vertexCount() const { return fVertexCount; }
- int indexCount() const { return fIndexCount; }
/** These return 0 if initInstanced was not used to initialize the GrVertices. */
int verticesPerInstance() const { return fVerticesPerInstance; }
int indicesPerInstance() const { return fIndicesPerInstance; }
int instanceCount() const { return fInstanceCount; }
- bool isIndexed() const { return fIndexCount > 0; }
bool isInstanced() const { return fInstanceCount > 0; }
- /** Called after using this draw info to draw the next set of instances.
- The vertex offset is advanced while the index buffer is reused at the same
- position. instancesRemaining is number of instances that remain, maxInstances is
- the most number of instances that can be used with the index buffer. If there
- are no instances remaining, the GrVertices is unmodified and false is returned.*/
- bool nextInstances(int* instancesRemaining, int maxInstances) {
- SkASSERT(this->isInstanced());
- if (!*instancesRemaining) {
- return false;
+ class Iterator {
+ public:
+ const GrNonInstancedVertices* init(const GrVertices& vertices) {
+ fVertices = &vertices;
+ if (vertices.fInstanceCount <= vertices.fMaxInstancesPerDraw) {
+ fInstancesRemaining = 0;
+ // Note, this also covers the non-instanced case!
+ return &vertices;
+ }
+ SkASSERT(vertices.isInstanced());
+ fInstanceBatch.fIndexBuffer.reset(vertices.fIndexBuffer.get());
+ fInstanceBatch.fVertexBuffer.reset(vertices.fVertexBuffer.get());
+ fInstanceBatch.fIndexCount = vertices.fMaxInstancesPerDraw *
+ vertices.fIndicesPerInstance;
+ fInstanceBatch.fVertexCount = vertices.fMaxInstancesPerDraw *
+ vertices.fVerticesPerInstance;
+ fInstanceBatch.fPrimitiveType = vertices.fPrimitiveType;
+ fInstanceBatch.fStartIndex = vertices.fStartIndex;
+ fInstanceBatch.fStartVertex = vertices.fStartVertex;
+ fInstancesRemaining = vertices.fInstanceCount - vertices.fMaxInstancesPerDraw;
+ return &fInstanceBatch;
}
- fStartVertex += fVertexCount;
- fInstanceCount = SkTMin(*instancesRemaining, maxInstances);
- fVertexCount = fInstanceCount * fVerticesPerInstance;
- fIndexCount = fInstanceCount * fIndicesPerInstance;
- *instancesRemaining -= fInstanceCount;
- return true;
- }
- const GrVertexBuffer* vertexBuffer() const { return fVertexBuffer.get(); }
- const GrIndexBuffer* indexBuffer() const { return fIndexBuffer.get(); }
+ const GrNonInstancedVertices* next() {
+ if (!fInstancesRemaining) {
+ return NULL;
+ }
+ fInstanceBatch.fStartVertex += fInstanceBatch.fVertexCount;
+ int instances = SkTMin(fInstancesRemaining, fVertices->fMaxInstancesPerDraw);
+ fInstanceBatch.fIndexCount = instances * fVertices->fIndicesPerInstance;
+ fInstanceBatch.fVertexCount = instances * fVertices->fVerticesPerInstance;
+ fInstancesRemaining -= instances;
+ return &fInstanceBatch;
+ }
+ private:
+ GrNonInstancedVertices fInstanceBatch;
+ const GrVertices* fVertices;
+ int fInstancesRemaining;
+ };
private:
- GrPrimitiveType fPrimitiveType;
-
- int fStartVertex;
- int fStartIndex;
- int fVertexCount;
- int fIndexCount;
-
int fInstanceCount;
int fVerticesPerInstance;
int fIndicesPerInstance;
-
- GrPendingIOResource<const GrVertexBuffer, kRead_GrIOType> fVertexBuffer;
- GrPendingIOResource<const GrIndexBuffer, kRead_GrIOType> fIndexBuffer;
+ int fMaxInstancesPerDraw;
};
#endif
diff --git a/src/gpu/effects/GrDashingEffect.cpp b/src/gpu/effects/GrDashingEffect.cpp
index e5fb218d7b..bd2997cdf3 100644
--- a/src/gpu/effects/GrDashingEffect.cpp
+++ b/src/gpu/effects/GrDashingEffect.cpp
@@ -599,7 +599,7 @@ public:
rectIndex++;
}
SkASSERT(0 == (curVIdx % 4) && (curVIdx / 4) == totalRectCount);
- helper.issueDraws(batchTarget);
+ helper.issueDraw(batchTarget);
}
SkSTArray<1, Geometry, true>* geoData() { return &fGeoData; }
diff --git a/src/gpu/gl/GrGLGpu.cpp b/src/gpu/gl/GrGLGpu.cpp
index 8b83dc0d71..a212b2bfff 100644
--- a/src/gpu/gl/GrGLGpu.cpp
+++ b/src/gpu/gl/GrGLGpu.cpp
@@ -1452,20 +1452,20 @@ bool GrGLGpu::flushGLState(const DrawArgs& args) {
}
void GrGLGpu::setupGeometry(const GrPrimitiveProcessor& primProc,
- const GrVertices& info,
+ const GrNonInstancedVertices& vertices,
size_t* indexOffsetInBytes) {
GrGLVertexBuffer* vbuf;
- vbuf = (GrGLVertexBuffer*) info.vertexBuffer();
+ vbuf = (GrGLVertexBuffer*) vertices.vertexBuffer();
SkASSERT(vbuf);
SkASSERT(!vbuf->isMapped());
GrGLIndexBuffer* ibuf = NULL;
- if (info.isIndexed()) {
+ if (vertices.isIndexed()) {
SkASSERT(indexOffsetInBytes);
*indexOffsetInBytes = 0;
- ibuf = (GrGLIndexBuffer*)info.indexBuffer();
+ ibuf = (GrGLIndexBuffer*)vertices.indexBuffer();
SkASSERT(ibuf);
SkASSERT(!ibuf->isMapped());
@@ -1479,7 +1479,7 @@ void GrGLGpu::setupGeometry(const GrPrimitiveProcessor& primProc,
GrGLsizei stride = static_cast<GrGLsizei>(primProc.getVertexStride());
- size_t vertexOffsetInBytes = stride * info.startVertex();
+ size_t vertexOffsetInBytes = stride * vertices.startVertex();
vertexOffsetInBytes += vbuf->baseOffset();
@@ -1895,7 +1895,7 @@ GrGLenum gPrimitiveType2GLMode[] = {
#endif
#endif
-void GrGLGpu::onDraw(const DrawArgs& args, const GrVertices& vertices) {
+void GrGLGpu::onDraw(const DrawArgs& args, const GrNonInstancedVertices& vertices) {
if (!this->flushGLState(args)) {
return;
}
diff --git a/src/gpu/gl/GrGLGpu.h b/src/gpu/gl/GrGLGpu.h
index 4d26ad8f7e..016547fad3 100644
--- a/src/gpu/gl/GrGLGpu.h
+++ b/src/gpu/gl/GrGLGpu.h
@@ -24,7 +24,7 @@
#include "SkTypes.h"
class GrPipeline;
-class GrVertices;
+class GrNonInstancedVertices;
#ifdef SK_DEVELOPER
#define PROGRAM_CACHE_STATS
@@ -149,7 +149,7 @@ private:
void onResolveRenderTarget(GrRenderTarget* target) override;
- void onDraw(const DrawArgs&, const GrVertices&) override;
+ void onDraw(const DrawArgs&, const GrNonInstancedVertices&) override;
void onStencilPath(const GrPath*, const StencilPathState&) override;
void onDrawPath(const DrawArgs&, const GrPath*, const GrStencilSettings&) override;
void onDrawPaths(const DrawArgs&,
@@ -177,7 +177,7 @@ private:
// an into the index buffer. It does not account for vertices.startIndex() but rather the start
// index is relative to the returned offset.
void setupGeometry(const GrPrimitiveProcessor&,
- const GrVertices& vertices,
+ const GrNonInstancedVertices& vertices,
size_t* indexOffsetInBytes);
// Subclasses should call this to flush the blend state.