[journal] Don't resize a singlton VBO; create and destroy a VBO each flush
This simplifies the vertex data uploading in the journal, and could improve performance. Modifying a VBO mid-scene could reqire synchronizing with the GPU or some form of shadowing/copying to avoid modifying data that the GPU is currently processing; the buffer was also being marked as GL_STATIC_DRAW which could have made things worse. Now we simply create a GL_STATIC_DRAW VBO for each flush and and delete it when we are finished.
This commit is contained in:
parent
1ecfd72936
commit
a7974f8e6f
@ -473,10 +473,6 @@ _cogl_journal_flush_vbo_offsets_and_entries (CoglJournalEntry *batch_start,
|
|||||||
_cogl_journal_flush_texcoord_vbo_offsets_and_entries,
|
_cogl_journal_flush_texcoord_vbo_offsets_and_entries,
|
||||||
data);
|
data);
|
||||||
|
|
||||||
#ifndef HAVE_COGL_GL
|
|
||||||
GE (glBindBuffer (GL_ELEMENT_ARRAY_BUFFER, 0));
|
|
||||||
#endif
|
|
||||||
|
|
||||||
/* progress forward through the VBO containing all our vertices */
|
/* progress forward through the VBO containing all our vertices */
|
||||||
state->vbo_offset += (stride * 4 * batch_len);
|
state->vbo_offset += (stride * 4 * batch_len);
|
||||||
if (G_UNLIKELY (cogl_debug_flags & COGL_DEBUG_JOURNAL))
|
if (G_UNLIKELY (cogl_debug_flags & COGL_DEBUG_JOURNAL))
|
||||||
@ -507,30 +503,15 @@ upload_vertices_to_vbo (GArray *vertices, CoglJournalFlushState *state)
|
|||||||
_COGL_GET_CONTEXT (ctx, NO_RETVAL);
|
_COGL_GET_CONTEXT (ctx, NO_RETVAL);
|
||||||
|
|
||||||
needed_vbo_len = vertices->len * sizeof (GLfloat);
|
needed_vbo_len = vertices->len * sizeof (GLfloat);
|
||||||
if (ctx->journal_vbo_len < needed_vbo_len)
|
|
||||||
{
|
|
||||||
GE (glDeleteBuffers (1, &ctx->journal_vbo));
|
|
||||||
|
|
||||||
GE (glGenBuffers (1, &ctx->journal_vbo));
|
g_assert (ctx->journal_vbo == 0);
|
||||||
GE (glBindBuffer (GL_ARRAY_BUFFER, ctx->journal_vbo));
|
g_assert (needed_vbo_len);
|
||||||
GE (glBufferData (GL_ARRAY_BUFFER,
|
GE (glGenBuffers (1, &ctx->journal_vbo));
|
||||||
needed_vbo_len,
|
GE (glBindBuffer (GL_ARRAY_BUFFER, ctx->journal_vbo));
|
||||||
vertices->data,
|
GE (glBufferData (GL_ARRAY_BUFFER,
|
||||||
GL_STATIC_DRAW));
|
needed_vbo_len,
|
||||||
ctx->journal_vbo_len = needed_vbo_len;
|
vertices->data,
|
||||||
}
|
GL_STATIC_DRAW));
|
||||||
else
|
|
||||||
{
|
|
||||||
GE (glBindBuffer (GL_ARRAY_BUFFER, ctx->journal_vbo));
|
|
||||||
GE (glBufferData (GL_ARRAY_BUFFER,
|
|
||||||
needed_vbo_len,
|
|
||||||
NULL,
|
|
||||||
GL_STATIC_DRAW));
|
|
||||||
GE (glBufferSubData (GL_ARRAY_BUFFER,
|
|
||||||
0,
|
|
||||||
needed_vbo_len,
|
|
||||||
vertices->data));
|
|
||||||
}
|
|
||||||
|
|
||||||
/* As we flush the journal entries in batches we walk forward through the
|
/* As we flush the journal entries in batches we walk forward through the
|
||||||
* above VBO starting at offset 0... */
|
* above VBO starting at offset 0... */
|
||||||
@ -613,7 +594,10 @@ _cogl_journal_flush (void)
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (!vbo_fallback)
|
if (!vbo_fallback)
|
||||||
GE (glBindBuffer (GL_ARRAY_BUFFER, 0));
|
{
|
||||||
|
GE (glDeleteBuffers (1, &ctx->journal_vbo));
|
||||||
|
ctx->journal_vbo = 0;
|
||||||
|
}
|
||||||
|
|
||||||
g_array_set_size (ctx->journal, 0);
|
g_array_set_size (ctx->journal, 0);
|
||||||
g_array_set_size (ctx->logged_vertices, 0);
|
g_array_set_size (ctx->logged_vertices, 0);
|
||||||
|
Loading…
Reference in New Issue
Block a user