[Mesa-dev] [PATCH 07/21] st/mesa: plumbing for sparse buffers
Nicolai Hähnle
nhaehnle at gmail.com
Wed Feb 8 12:42:49 UTC 2017
From: Nicolai Hähnle <nicolai.haehnle at amd.com>
---
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 7c202eb..5911d1e 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.9.3
More information about the mesa-dev
mailing list