Don't do unnecessary vertex buffer orphaning when calling SpriteBatch:unbind() on a SpriteBatch with the static usage hint

This commit is contained in:
Alex Szpakowski
2014-05-06 21:24:26 -03:00
parent ce385ec27a
commit 6a491ed0f0
+12 -4
View File
@@ -182,10 +182,18 @@ void VBO::unmap()
is_bound = true;
}
// "orphan" current buffer to avoid implicit synchronisation on the GPU:
// http://www.seas.upenn.edu/~pcozzi/OpenGLInsights/OpenGLInsights-AsynchronousBufferTransfers.pdf
glBufferDataARB(getTarget(), (GLsizeiptr) getSize(), NULL, getUsage());
glBufferDataARB(getTarget(), (GLsizeiptr) getSize(), memory_map, getUsage());
if (getUsage() == GL_STATIC_DRAW)
{
// Upload the mapped data to the buffer.
glBufferSubDataARB(getTarget(), 0, (GLsizeiptr) getSize(), memory_map);
}
else
{
// "orphan" current buffer to avoid implicit synchronisation on the GPU:
// http://www.seas.upenn.edu/~pcozzi/OpenGLInsights/OpenGLInsights-AsynchronousBufferTransfers.pdf
glBufferDataARB(getTarget(), (GLsizeiptr) getSize(), NULL, getUsage());
glBufferDataARB(getTarget(), (GLsizeiptr) getSize(), memory_map, getUsage());
}
is_mapped = false;
}