From d9bc4d8305c3f3ee4b82386ae119d72d3a66a4d2 Mon Sep 17 00:00:00 2001 From: =?utf8?q?Nicolai=20H=C3=A4hnle?= Date: Thu, 2 Feb 2017 23:32:48 +0100 Subject: [PATCH] st/mesa: plumbing for sparse buffers MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit Reviewed-by: Marek Olšák --- src/mesa/state_tracker/st_cb_bufferobjects.c | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/src/mesa/state_tracker/st_cb_bufferobjects.c b/src/mesa/state_tracker/st_cb_bufferobjects.c index 7c202ebcc50..5911d1e1604 100644 --- a/src/mesa/state_tracker/st_cb_bufferobjects.c +++ b/src/mesa/state_tracker/st_cb_bufferobjects.c @@ -293,6 +293,8 @@ st_bufferobj_data(struct gl_context *ctx, pipe_flags |= PIPE_RESOURCE_FLAG_MAP_PERSISTENT; if (storageFlags & GL_MAP_COHERENT_BIT) pipe_flags |= PIPE_RESOURCE_FLAG_MAP_COHERENT; + if (storageFlags & GL_SPARSE_STORAGE_BIT_ARB) + pipe_flags |= PIPE_RESOURCE_FLAG_SPARSE; pipe_resource_reference( &st_obj->buffer, NULL ); @@ -559,6 +561,23 @@ st_bufferobj_validate_usage(struct st_context *st, { } +static void +st_bufferobj_page_commitment(struct gl_context *ctx, + struct gl_buffer_object *bufferObj, + GLintptr offset, GLsizeiptr size, + GLboolean commit) +{ + struct pipe_context *pipe = st_context(ctx)->pipe; + struct st_buffer_object *buf = st_buffer_object(bufferObj); + struct pipe_box box; + + u_box_1d(offset, size, &box); + + if (!pipe->resource_commit(pipe, buf->buffer, 0, &box, commit)) { + _mesa_error(ctx, GL_OUT_OF_MEMORY, "glBufferPageCommitmentARB(out of memory)"); + return; + } +} void st_init_bufferobject_functions(struct pipe_screen *screen, @@ -577,6 +596,7 @@ st_init_bufferobject_functions(struct pipe_screen *screen, functions->UnmapBuffer = st_bufferobj_unmap; functions->CopyBufferSubData = st_copy_buffer_subdata; functions->ClearBufferSubData = st_clear_buffer_subdata; + functions->BufferPageCommitment = st_bufferobj_page_commitment; if (screen->get_param(screen, PIPE_CAP_INVALIDATE_BUFFER)) functions->InvalidateBufferSubData = st_bufferobj_invalidate; -- 2.30.2