summaryrefslogtreecommitdiff
path: root/cogl/cogl-journal-private.h
diff options
context:
space:
mode:
authorNeil Roberts <neil@linux.intel.com>2011-06-01 14:30:45 +0100
committerNeil Roberts <neil@linux.intel.com>2011-06-01 14:41:59 +0100
commitefadc439a46206252c279a1cef72cdaab673107c (patch)
treedea279d7d272964360e69fe9851ce6b3c2a7bc5d /cogl/cogl-journal-private.h
parent54f94a0ed07e2d01e719f21120cb92ea3e492269 (diff)
downloadcogl-efadc439a46206252c279a1cef72cdaab673107c.tar.gz
cogl-journal: Use a pool of vertex arrays
Previously whenever the journal is flushed a new vertex array would be created to contain the vertices. To avoid the overhead of reallocating a buffer every time, this patch makes it use a pool of 8 buffers which are cycled in turn. The buffers are never destroyed but instead the data is replaced. The journal should only ever be using one buffer at a time but we cache more than one buffer anyway in case the GL driver is internally using the buffer in which case mapping the buffer may cause it to create a new buffer anyway.
Diffstat (limited to 'cogl/cogl-journal-private.h')
-rw-r--r--cogl/cogl-journal-private.h12
1 files changed, 12 insertions, 0 deletions
diff --git a/cogl/cogl-journal-private.h b/cogl/cogl-journal-private.h
index 7212dca4..6eb7a2df 100644
--- a/cogl/cogl-journal-private.h
+++ b/cogl/cogl-journal-private.h
@@ -28,6 +28,8 @@
#include "cogl-handle.h"
#include "cogl-clip-stack.h"
+#define COGL_JOURNAL_VBO_POOL_SIZE 8
+
typedef struct _CoglJournal
{
CoglObject _parent;
@@ -36,6 +38,16 @@ typedef struct _CoglJournal
GArray *vertices;
size_t needed_vbo_len;
+ /* A pool of attribute buffers is used so that we can avoid repeatedly
+ reallocating buffers. Only one of these buffers at a time will be
+ used by Cogl but we keep more than one alive anyway in case the
+ GL driver is internally using the buffer and it would have to
+ allocate a new one when we start writing to it */
+ CoglAttributeBuffer *vbo_pool[COGL_JOURNAL_VBO_POOL_SIZE];
+ /* The next vbo to use from the pool. We just cycle through them in
+ order */
+ unsigned int next_vbo_in_pool;
+
int fast_read_pixel_count;
} CoglJournal;