Add support for instanced draws
Adds an instance buffer to GrMesh and instance attribs to
GrPrimitiveProcessor. Implements support in GL and Vulkan. Adds unit
tests for instanced rendering with GrMesh.
Bug: skia:
Change-Id: If1a9920feb9366f346b8c37cf914713c49129b3a
Reviewed-on: https://skia-review.googlesource.com/16200
Reviewed-by: Brian Salomon <bsalomon@google.com>
Commit-Queue: Chris Dalton <csmartdalton@google.com>
diff --git a/src/gpu/ops/GrMSAAPathRenderer.cpp b/src/gpu/ops/GrMSAAPathRenderer.cpp
index 36faf2f..50a839d7b 100644
--- a/src/gpu/ops/GrMSAAPathRenderer.cpp
+++ b/src/gpu/ops/GrMSAAPathRenderer.cpp
@@ -337,7 +337,7 @@
const GrBuffer* lineVertexBuffer;
int firstLineVertex;
MSAALineVertices lines;
- size_t lineVertexStride = sizeof(MSAALineVertices::Vertex);
+ int lineVertexStride = sizeof(MSAALineVertices::Vertex);
lines.vertices = (MSAALineVertices::Vertex*) target->makeVertexSpace(lineVertexStride,
fMaxLineVertices,
&lineVertexBuffer,
@@ -350,7 +350,7 @@
SkDEBUGCODE(lines.verticesEnd = lines.vertices + fMaxLineVertices;)
MSAAQuadVertices quads;
- size_t quadVertexStride = sizeof(MSAAQuadVertices::Vertex);
+ int quadVertexStride = sizeof(MSAAQuadVertices::Vertex);
SkAutoMalloc quadVertexPtr(fMaxQuadVertices * quadVertexStride);
quads.vertices = (MSAAQuadVertices::Vertex*) quadVertexPtr.get();
quads.nextVertex = quads.vertices;
@@ -412,7 +412,7 @@
GrMesh lineMeshes(primitiveType);
if (!fIsIndexed) {
- lineMeshes.setNonIndexed(lineVertexOffset);
+ lineMeshes.setNonIndexedNonInstanced(lineVertexOffset);
} else {
lineMeshes.setIndexed(lineIndexBuffer, lineIndexOffset, firstLineIndex,
0, lineVertexOffset - 1);
@@ -439,7 +439,7 @@
memcpy(quadVertices, quads.vertices, quadVertexStride * quadVertexOffset);
GrMesh quadMeshes(kTriangles_GrPrimitiveType);
if (!fIsIndexed) {
- quadMeshes.setNonIndexed(quadVertexOffset);
+ quadMeshes.setNonIndexedNonInstanced(quadVertexOffset);
} else {
const GrBuffer* quadIndexBuffer;
int firstQuadIndex;