* Allocate space for and store data in a buffer object. Any data that was
* previously stored in the buffer object is lost. If data is NULL,
* memory will be allocated, but no copy will occur.
- * Called via glBufferDataARB().
+ * Called via ctx->Driver.BufferData().
+ * \return GL_TRUE for success, GL_FALSE if out of memory
*/
-static void
+static GLboolean
intel_bufferobj_data(GLcontext * ctx,
GLenum target,
GLsizeiptrARB size,
if (intel_obj->sys_buffer != NULL) {
if (data != NULL)
memcpy(intel_obj->sys_buffer, data, size);
- return;
+ return GL_TRUE;
}
}
#endif
intel_bufferobj_alloc_buffer(intel, intel_obj);
+ if (!intel_obj->buffer)
+ return GL_FALSE;
if (data != NULL)
dri_bo_subdata(intel_obj->buffer, 0, size, data);
}
+
+ return GL_TRUE;
}
* Allocate space for and store data in a buffer object. Any data that was
* previously stored in the buffer object is lost. If data is NULL,
* memory will be allocated, but no copy will occur.
- * Called via glBufferDataARB().
+ * Called via ctx->Driver.BufferData().
+ * \return GL_TRUE for success, GL_FALSE if out of memory
*/
-static void
+static GLboolean
radeonBufferData(GLcontext * ctx,
GLenum target,
GLsizeiptrARB size,
RADEON_GEM_DOMAIN_GTT,
0);
+ if (!radeon_obj->bo)
+ return GL_FALSE;
+
if (data != NULL) {
radeon_bo_map(radeon_obj->bo, GL_TRUE);
radeon_bo_unmap(radeon_obj->bo);
}
}
+ return GL_TRUE;
}
/**
* \param usage Hints about how the data will be used.
* \param bufObj Object to be used.
*
+ * \return GL_TRUE for success, GL_FALSE for failure
* \sa glBufferDataARB, dd_function_table::BufferData.
*/
-static void
+static GLboolean
_mesa_buffer_data( GLcontext *ctx, GLenum target, GLsizeiptrARB size,
const GLvoid * data, GLenum usage,
struct gl_buffer_object * bufObj )
if (data) {
_mesa_memcpy( bufObj->Data, data, size );
}
+
+ return GL_TRUE;
+ }
+ else {
+ return GL_FALSE;
}
}
FLUSH_VERTICES(ctx, _NEW_BUFFER_OBJECT);
- ASSERT(ctx->Driver.BufferData);
-
bufObj->Written = GL_TRUE;
#ifdef VBO_DEBUG
#ifdef BOUNDS_CHECK
size += 100;
#endif
- /* Give the buffer object to the driver! <data> may be null! */
- ctx->Driver.BufferData( ctx, target, size, data, usage, bufObj );
+
+ ASSERT(ctx->Driver.BufferData);
+ if (!ctx->Driver.BufferData( ctx, target, size, data, usage, bufObj )) {
+ _mesa_error(ctx, GL_OUT_OF_MEMORY, "glBufferDataARB(access)");
+ }
}
map = ctx->Driver.MapBuffer( ctx, target, access, bufObj );
if (!map) {
_mesa_error(ctx, GL_OUT_OF_MEMORY, "glMapBufferARB(access)");
+ return NULL;
}
-
- if (map) {
+ else {
/* The driver callback should have set these fields.
* This is important because other modules (like VBO) might call
* the driver function directly.
ASSERT(ctx->Driver.MapBufferRange);
map = ctx->Driver.MapBufferRange(ctx, target, offset, length,
access, bufObj);
- if (map) {
+ if (!map) {
+ _mesa_error(ctx, GL_OUT_OF_MEMORY, "glMapBufferARB(access)");
+ }
+ else {
/* The driver callback should have set all these fields.
* This is important because other modules (like VBO) might call
* the driver function directly.
void (*DeleteBuffer)( GLcontext *ctx, struct gl_buffer_object *obj );
- void (*BufferData)( GLcontext *ctx, GLenum target, GLsizeiptrARB size,
- const GLvoid *data, GLenum usage,
- struct gl_buffer_object *obj );
+ GLboolean (*BufferData)( GLcontext *ctx, GLenum target, GLsizeiptrARB size,
+ const GLvoid *data, GLenum usage,
+ struct gl_buffer_object *obj );
void (*BufferSubData)( GLcontext *ctx, GLenum target, GLintptrARB offset,
GLsizeiptrARB size, const GLvoid *data,
* Allocate space for and store data in a buffer object. Any data that was
* previously stored in the buffer object is lost. If data is NULL,
* memory will be allocated, but no copy will occur.
- * Called via glBufferDataARB().
+ * Called via ctx->Driver.BufferData().
+ * \return GL_TRUE for success, GL_FALSE if out of memory
*/
-static void
+static GLboolean
st_bufferobj_data(GLcontext *ctx,
GLenum target,
GLsizeiptrARB size,
st_obj->buffer = pipe_buffer_create( pipe->screen, 32, buffer_usage, size );
if (!st_obj->buffer) {
- _mesa_error(ctx, GL_OUT_OF_MEMORY, "glBufferDataARB");
- return;
+ return GL_FALSE;
}
if (data)
st_no_flush_pipe_buffer_write(st_context(ctx), st_obj->buffer, 0,
size, data);
+ return GL_TRUE;
}