mesa/st: Accelerate ARB_clear_buffer_object with clear_buffer

Signed-off-by: Ilia Mirkin <imirkin@alum.mit.edu>
Reviewed-by: Marek Olšák <marek.olsak@amd.com>
This commit is contained in:
Ilia Mirkin 2014-03-25 17:02:48 -04:00
parent 24b86cb304
commit f5ba1a1f7f
3 changed files with 38 additions and 3 deletions

View File

@ -665,7 +665,7 @@ _mesa_buffer_get_subdata( struct gl_context *ctx, GLintptrARB offset,
* \sa glClearBufferSubData, glClearBufferData and
* dd_function_table::ClearBufferSubData.
*/
static void
void
_mesa_buffer_clear_subdata(struct gl_context *ctx,
GLintptr offset, GLsizeiptr size,
const GLvoid *clearValue,
@ -1458,7 +1458,7 @@ _mesa_ClearBufferData(GLenum target, GLenum internalformat, GLenum format,
if (data == NULL) {
/* clear to zeros, per the spec */
ctx->Driver.ClearBufferSubData(ctx, 0, bufObj->Size,
NULL, 0, bufObj);
NULL, clearValueSize, bufObj);
return;
}
@ -1510,7 +1510,7 @@ _mesa_ClearBufferSubData(GLenum target, GLenum internalformat,
/* clear to zeros, per the spec */
if (size > 0) {
ctx->Driver.ClearBufferSubData(ctx, offset, size,
NULL, 0, bufObj);
NULL, clearValueSize, bufObj);
}
return;
}

View File

@ -115,6 +115,13 @@ extern void
_mesa_buffer_unmap_all_mappings(struct gl_context *ctx,
struct gl_buffer_object *bufObj);
extern void
_mesa_buffer_clear_subdata(struct gl_context *ctx,
GLintptr offset, GLsizeiptr size,
const GLvoid *clearValue,
GLsizeiptr clearValueSize,
struct gl_buffer_object *bufObj);
/*
* API functions
*/

View File

@ -447,6 +447,33 @@ st_copy_buffer_subdata(struct gl_context *ctx,
srcObj->buffer, 0, &box);
}
/**
* Called via glClearBufferSubData().
*/
static void
st_clear_buffer_subdata(struct gl_context *ctx,
GLintptr offset, GLsizeiptr size,
const GLvoid *clearValue,
GLsizeiptr clearValueSize,
struct gl_buffer_object *bufObj)
{
struct pipe_context *pipe = st_context(ctx)->pipe;
struct st_buffer_object *buf = st_buffer_object(bufObj);
static const char zeros[16] = {0};
if (!pipe->clear_buffer) {
_mesa_buffer_clear_subdata(ctx, offset, size,
clearValue, clearValueSize, bufObj);
return;
}
if (!clearValue)
clearValue = zeros;
pipe->clear_buffer(pipe, buf->buffer, offset, size,
clearValue, clearValueSize);
}
/* TODO: if buffer wasn't created with appropriate usage flags, need
* to recreate it now and copy contents -- or possibly create a
@ -476,6 +503,7 @@ st_init_bufferobject_functions(struct dd_function_table *functions)
functions->FlushMappedBufferRange = st_bufferobj_flush_mapped_range;
functions->UnmapBuffer = st_bufferobj_unmap;
functions->CopyBufferSubData = st_copy_buffer_subdata;
functions->ClearBufferSubData = st_clear_buffer_subdata;
/* For GL_APPLE_vertex_array_object */
functions->NewArrayObject = _mesa_new_vao;