aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/gpu/gl
diff options
context:
space:
mode:
authorGravatar Chris Dalton <csmartdalton@google.com>2017-05-03 14:36:54 -0400
committerGravatar Skia Commit-Bot <skia-commit-bot@chromium.org>2017-05-03 19:08:40 +0000
commitff926502069d0ddafaecc18dc08973762e4befd2 (patch)
tree5c8c4335c6a3b71006ce2e3646987930ecb2e28e /src/gpu/gl
parent85591831b2fc0f67968116d73c79ee1232a59935 (diff)
Convert GrMesh to a struct
Converts GrMesh to a struct and changes the names/semantics of its fields to be more inline with their GL counterparts. Also renames the "instancing" feature to "pattern", to avoid ambiguity with hardware instancing. Bug: skia: Change-Id: Ia0999d4f9c83b5dd31f81b9bf4f36ed9abd26286 Reviewed-on: https://skia-review.googlesource.com/15157 Commit-Queue: Chris Dalton <csmartdalton@google.com> Reviewed-by: Brian Salomon <bsalomon@google.com>
Diffstat (limited to 'src/gpu/gl')
-rw-r--r--src/gpu/gl/GrGLGpu.cpp70
-rw-r--r--src/gpu/gl/GrGLGpu.h6
2 files changed, 34 insertions, 42 deletions
diff --git a/src/gpu/gl/GrGLGpu.cpp b/src/gpu/gl/GrGLGpu.cpp
index 4aa19203be..8d76faee88 100644
--- a/src/gpu/gl/GrGLGpu.cpp
+++ b/src/gpu/gl/GrGLGpu.cpp
@@ -1984,34 +1984,29 @@ bool GrGLGpu::flushGLState(const GrPipeline& pipeline, const GrPrimitiveProcesso
}
void GrGLGpu::setupGeometry(const GrPrimitiveProcessor& primProc,
- const GrNonInstancedMesh& mesh,
- size_t* indexOffsetInBytes) {
- const GrBuffer* vbuf = mesh.vertexBuffer();
- SkASSERT(vbuf);
- SkASSERT(!vbuf->isMapped());
-
+ const GrBuffer* indexBuffer,
+ const GrBuffer* vertexBuffer,
+ int baseVertex) {
GrGLAttribArrayState* attribState;
- if (mesh.isIndexed()) {
- SkASSERT(indexOffsetInBytes);
-
- *indexOffsetInBytes = 0;
- const GrBuffer* ibuf = mesh.indexBuffer();
- SkASSERT(ibuf);
- SkASSERT(!ibuf->isMapped());
- *indexOffsetInBytes += ibuf->baseOffset();
- attribState = fHWVertexArrayState.bindInternalVertexArray(this, ibuf);
+ if (indexBuffer) {
+ SkASSERT(indexBuffer);
+ SkASSERT(!indexBuffer->isMapped());
+ attribState = fHWVertexArrayState.bindInternalVertexArray(this, indexBuffer);
} else {
attribState = fHWVertexArrayState.bindInternalVertexArray(this);
}
+ SkASSERT(vertexBuffer);
+ SkASSERT(!vertexBuffer->isMapped());
+
int vaCount = primProc.numAttribs();
if (vaCount > 0) {
GrGLsizei stride = static_cast<GrGLsizei>(primProc.getVertexStride());
- size_t vertexOffsetInBytes = stride * mesh.startVertex();
+ size_t vertexOffsetInBytes = stride * baseVertex;
- vertexOffsetInBytes += vbuf->baseOffset();
+ vertexOffsetInBytes += vertexBuffer->baseOffset();
uint32_t usedAttribArraysMask = 0;
size_t offset = 0;
@@ -2022,7 +2017,7 @@ void GrGLGpu::setupGeometry(const GrPrimitiveProcessor& primProc,
GrVertexAttribType attribType = attrib.fType;
attribState->set(this,
attribIndex,
- vbuf,
+ vertexBuffer,
attribType,
stride,
reinterpret_cast<GrGLvoid*>(vertexOffsetInBytes + offset));
@@ -2646,7 +2641,7 @@ void GrGLGpu::draw(const GrPipeline& pipeline,
bool hasPoints = false;
for (int i = 0; i < meshCount; ++i) {
- if (meshes[i].primitiveType() == kPoints_GrPrimitiveType) {
+ if (meshes[i].fPrimitiveType == kPoints_GrPrimitiveType) {
hasPoints = true;
break;
}
@@ -2661,41 +2656,38 @@ void GrGLGpu::draw(const GrPipeline& pipeline,
}
const GrMesh& mesh = meshes[i];
- GrMesh::Iterator iter;
- const GrNonInstancedMesh* nonInstMesh = iter.init(mesh);
- do {
- size_t indexOffsetInBytes = 0;
- this->setupGeometry(primProc, *nonInstMesh, &indexOffsetInBytes);
- if (nonInstMesh->isIndexed()) {
- GrGLvoid* indices =
- reinterpret_cast<GrGLvoid*>(indexOffsetInBytes +
- sizeof(uint16_t) * nonInstMesh->startIndex());
- // info.startVertex() was accounted for by setupGeometry.
+ for (GrMesh::PatternBatch batch : mesh) {
+ this->setupGeometry(primProc, mesh.fIndexBuffer.get(), mesh.fVertexBuffer.get(),
+ batch.fBaseVertex);
+ if (const GrBuffer* indexBuffer = mesh.fIndexBuffer.get()) {
+ GrGLvoid* indices = reinterpret_cast<void*>(indexBuffer->baseOffset() +
+ sizeof(uint16_t) * mesh.fBaseIndex);
+ // mesh.fBaseVertex was accounted for by setupGeometry.
if (this->glCaps().drawRangeElementsSupport()) {
// 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;
- GL_CALL(DrawRangeElements(gPrimitiveType2GLMode[nonInstMesh->primitiveType()],
+ int end = mesh.fVertexCount * batch.fRepeatCount - 1;
+ GL_CALL(DrawRangeElements(gPrimitiveType2GLMode[mesh.fPrimitiveType],
start, end,
- nonInstMesh->indexCount(),
+ mesh.fIndexCount * batch.fRepeatCount,
GR_GL_UNSIGNED_SHORT,
indices));
} else {
- GL_CALL(DrawElements(gPrimitiveType2GLMode[nonInstMesh->primitiveType()],
- nonInstMesh->indexCount(),
+ GL_CALL(DrawElements(gPrimitiveType2GLMode[mesh.fPrimitiveType],
+ mesh.fIndexCount * batch.fRepeatCount,
GR_GL_UNSIGNED_SHORT,
indices));
}
} else {
// Pass 0 for parameter first. We have to adjust glVertexAttribPointer() to account
- // for startVertex in the DrawElements case. So we always rely on setupGeometry to
- // have accounted for startVertex.
- GL_CALL(DrawArrays(gPrimitiveType2GLMode[nonInstMesh->primitiveType()], 0,
- nonInstMesh->vertexCount()));
+ // for mesh.fBaseVertex in the DrawElements case. So we always rely on setupGeometry
+ // to have accounted for mesh.fBaseVertex.
+ GL_CALL(DrawArrays(gPrimitiveType2GLMode[mesh.fPrimitiveType], 0,
+ mesh.fVertexCount * batch.fRepeatCount));
}
fStats.incNumDraws();
- } while ((nonInstMesh = iter.next()));
+ }
}
#if SWAP_PER_DRAW
diff --git a/src/gpu/gl/GrGLGpu.h b/src/gpu/gl/GrGLGpu.h
index 6108445966..f192c2b5ba 100644
--- a/src/gpu/gl/GrGLGpu.h
+++ b/src/gpu/gl/GrGLGpu.h
@@ -26,7 +26,6 @@
class GrGLBuffer;
class GrPipeline;
-class GrNonInstancedMesh;
class GrSwizzle;
namespace gr_instanced { class GLInstancedRendering; }
@@ -254,8 +253,9 @@ 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 GrNonInstancedMesh& mesh,
- size_t* indexOffsetInBytes);
+ const GrBuffer* indexBuffer,
+ const GrBuffer* vertexBuffer,
+ int baseVertex);
void flushBlend(const GrXferProcessor::BlendInfo& blendInfo, const GrSwizzle&);