pixel-array: Allow passing of hints to cogl_buffer_map

This allows you to tell Cogl that you are planning to replace all the
buffer's data once it is mapped with cogl_buffer_map. This means if the
buffer is currently being accessed by the GPU then the driver doesn't
have to stall and wait for it to finish before it can access it from the
CPU and can instead potentially allocate a new buffer with undefined
data and map that.
This commit is contained in:
Robert Bragg
2010-07-05 16:14:00 +01:00
parent 51e4245ce1
commit 92d0322766
4 changed files with 46 additions and 10 deletions

View File

@@ -177,7 +177,8 @@ _cogl_pixel_array_free (CoglPixelArray *buffer)
#if !defined (COGL_HAS_GLES)
static guint8 *
_cogl_pixel_array_map (CoglBuffer *buffer,
CoglBufferAccess access)
CoglBufferAccess access,
CoglBufferMapHint hints)
{
CoglPixelArray *pixel_array = COGL_PIXEL_ARRAY (buffer);
GLenum gl_target;
@@ -194,7 +195,8 @@ _cogl_pixel_array_map (CoglBuffer *buffer,
/* create an empty store if we don't have one yet. creating the store
* lazily allows the user of the CoglBuffer to set a hint before the
* store is created. */
if (!COGL_PIXEL_ARRAY_FLAG_IS_SET (pixel_array, STORE_CREATED))
if (!COGL_PIXEL_ARRAY_FLAG_IS_SET (pixel_array, STORE_CREATED) ||
(hints & COGL_BUFFER_MAP_HINT_DISCARD))
{
GE( glBufferData (gl_target,
buffer->size,
@@ -294,7 +296,8 @@ static const CoglBufferVtable cogl_pixel_array_vtable =
static guint8 *
_cogl_malloc_pixel_array_map (CoglBuffer *buffer,
CoglBufferAccess access)
CoglBufferAccess access,
CoglBufferMapHint hints)
{
COGL_BUFFER_SET_FLAG (buffer, MAPPED);
return buffer->data;