Skip to content

Commit

Permalink
GL|Performance: Improved draw batching
Browse files Browse the repository at this point in the history
Primitives with compatible GL types can be inserted in one batch.
  • Loading branch information
skyjake committed Nov 27, 2018
1 parent a37319b commit 43520e2
Showing 1 changed file with 5 additions and 5 deletions.
10 changes: 5 additions & 5 deletions doomsday/apps/client/src/gl/dgl_draw.cpp
Expand Up @@ -161,7 +161,7 @@ struct DGLDrawState
if (resetPrimitive)
{
DENG2_ASSERT(!vertices.empty());
DENG2_ASSERT(glPrimitive() == GL_TRIANGLE_STRIP);
DENG2_ASSERT(glPrimitive(batchPrimType) == GL_TRIANGLE_STRIP);

// When committing multiple triangle strips, add a disconnection
// between batches.
Expand Down Expand Up @@ -322,7 +322,7 @@ struct DGLDrawState

DENG2_ASSERT(primType == DGL_NO_PRIMITIVE);

if (batchPrimType != primitive)
if (glPrimitive(batchPrimType) != glPrimitive(primitive))
{
++s_primSwitchCount;
flushBatches();
Expand Down Expand Up @@ -578,9 +578,9 @@ struct DGLDrawState
}
}

GLenum glPrimitive() const
GLenum glPrimitive(DGLenum primitive) const
{
switch (batchPrimType)
switch (primitive)
{
case DGL_POINTS: return GL_POINTS;
case DGL_LINES: return GL_TRIANGLE_STRIP;
Expand Down Expand Up @@ -642,7 +642,7 @@ struct DGLDrawState
glBindArrays();
gl->shader.beginUse();
DENG2_ASSERT(gl->shader.validate());
GL.glDrawArrays(glPrimitive(), 0, numVertices()); ++s_drawCallCount;
GL.glDrawArrays(glPrimitive(batchPrimType), 0, numVertices()); ++s_drawCallCount;
gl->shader.endUse();
LIBGUI_ASSERT_GL_OK();
glUnbindArrays();
Expand Down

0 comments on commit 43520e2

Please sign in to comment.