buffer: Add a store_created bit field member
This adds a store_created bit field to CoglBuffer so we know if the underlying buffer has been allocated yet. Previously the code was trying to do something really wrong by accidentally using the COGL_PIXEL_ARRAY_FLAG_IS_SET macro (note "PIXEL_ARRAY") and what is more odd was the declaration of a CoglPixelArray *pixel_array in cogl-buffer.c which the buffer was being cast too before calling using the macro. Probably this was the fall-out of some previous code re-factoring.
This commit is contained in:
parent
071253c48b
commit
e18bfd92e4
@ -93,6 +93,8 @@ struct _CoglBuffer
|
|||||||
* the CoglBuffer is a VBO, PBO, ... or
|
* the CoglBuffer is a VBO, PBO, ... or
|
||||||
* points to allocated memory in the
|
* points to allocated memory in the
|
||||||
* fallback paths */
|
* fallback paths */
|
||||||
|
|
||||||
|
guint store_created:1;
|
||||||
};
|
};
|
||||||
|
|
||||||
/* This is used to register a type to the list of handle types that
|
/* This is used to register a type to the list of handle types that
|
||||||
|
@ -136,8 +136,6 @@ bo_map (CoglBuffer *buffer,
|
|||||||
CoglBufferMapHint hints)
|
CoglBufferMapHint hints)
|
||||||
{
|
{
|
||||||
#ifndef COGL_HAS_GLES
|
#ifndef COGL_HAS_GLES
|
||||||
|
|
||||||
CoglPixelArray *pixel_array = COGL_PIXEL_ARRAY (buffer);
|
|
||||||
guint8 *data;
|
guint8 *data;
|
||||||
CoglBufferBindTarget target;
|
CoglBufferBindTarget target;
|
||||||
GLenum gl_target;
|
GLenum gl_target;
|
||||||
@ -152,15 +150,14 @@ bo_map (CoglBuffer *buffer,
|
|||||||
/* create an empty store if we don't have one yet. creating the store
|
/* 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
|
* lazily allows the user of the CoglBuffer to set a hint before the
|
||||||
* store is created. */
|
* store is created. */
|
||||||
if (!COGL_PIXEL_ARRAY_FLAG_IS_SET (pixel_array, STORE_CREATED) ||
|
if (!buffer->store_created || (hints & COGL_BUFFER_MAP_HINT_DISCARD))
|
||||||
(hints & COGL_BUFFER_MAP_HINT_DISCARD))
|
|
||||||
{
|
{
|
||||||
GE( glBufferData (gl_target,
|
GE( glBufferData (gl_target,
|
||||||
buffer->size,
|
buffer->size,
|
||||||
NULL,
|
NULL,
|
||||||
_cogl_buffer_hints_to_gl_enum (buffer->usage_hint,
|
_cogl_buffer_hints_to_gl_enum (buffer->usage_hint,
|
||||||
buffer->update_hint)) );
|
buffer->update_hint)) );
|
||||||
COGL_PIXEL_ARRAY_SET_FLAG (pixel_array, STORE_CREATED);
|
buffer->store_created = TRUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
GE_RET( data, glMapBuffer (gl_target,
|
GE_RET( data, glMapBuffer (gl_target,
|
||||||
@ -202,7 +199,6 @@ bo_set_data (CoglBuffer *buffer,
|
|||||||
const guint8 *data,
|
const guint8 *data,
|
||||||
unsigned int size)
|
unsigned int size)
|
||||||
{
|
{
|
||||||
CoglPixelArray *pixel_array = COGL_PIXEL_ARRAY (buffer);
|
|
||||||
CoglBufferBindTarget target;
|
CoglBufferBindTarget target;
|
||||||
GLenum gl_target;
|
GLenum gl_target;
|
||||||
|
|
||||||
@ -216,14 +212,14 @@ bo_set_data (CoglBuffer *buffer,
|
|||||||
/* create an empty store if we don't have one yet. creating the store
|
/* 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
|
* lazily allows the user of the CoglBuffer to set a hint before the
|
||||||
* store is created. */
|
* store is created. */
|
||||||
if (!COGL_PIXEL_ARRAY_FLAG_IS_SET (pixel_array, STORE_CREATED))
|
if (!buffer->store_created)
|
||||||
{
|
{
|
||||||
GE( glBufferData (gl_target,
|
GE( glBufferData (gl_target,
|
||||||
buffer->size,
|
buffer->size,
|
||||||
NULL,
|
NULL,
|
||||||
_cogl_buffer_hints_to_gl_enum (buffer->usage_hint,
|
_cogl_buffer_hints_to_gl_enum (buffer->usage_hint,
|
||||||
buffer->update_hint)) );
|
buffer->update_hint)) );
|
||||||
COGL_PIXEL_ARRAY_SET_FLAG (pixel_array, STORE_CREATED);
|
buffer->store_created = TRUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
GE( glBufferSubData (gl_target, offset, size, data) );
|
GE( glBufferSubData (gl_target, offset, size, data) );
|
||||||
@ -272,12 +268,13 @@ _cogl_buffer_initialize (CoglBuffer *buffer,
|
|||||||
{
|
{
|
||||||
_COGL_GET_CONTEXT (ctx, NO_RETVAL);
|
_COGL_GET_CONTEXT (ctx, NO_RETVAL);
|
||||||
|
|
||||||
buffer->flags = COGL_BUFFER_FLAG_NONE;
|
buffer->flags = COGL_BUFFER_FLAG_NONE;
|
||||||
buffer->size = size;
|
buffer->store_created = FALSE;
|
||||||
buffer->last_target = default_target;
|
buffer->size = size;
|
||||||
buffer->usage_hint = usage_hint;
|
buffer->last_target = default_target;
|
||||||
buffer->update_hint = update_hint;
|
buffer->usage_hint = usage_hint;
|
||||||
buffer->data = NULL;
|
buffer->update_hint = update_hint;
|
||||||
|
buffer->data = NULL;
|
||||||
|
|
||||||
if (use_malloc)
|
if (use_malloc)
|
||||||
{
|
{
|
||||||
|
Loading…
Reference in New Issue
Block a user