[Mesa-dev] [PATCH 5/8] st/mesa: implement Driver.InvalidateBufferSubData

Nicolai Hähnle nhaehnle at gmail.com
Tue Jan 12 08:06:27 PST 2016


From: Nicolai Hähnle <nicolai.haehnle at amd.com>

---
 src/mesa/state_tracker/st_cb_bufferobjects.c | 31 +++++++++++++++++++++++++++-
 src/mesa/state_tracker/st_cb_bufferobjects.h |  3 ++-
 src/mesa/state_tracker/st_context.c          |  2 +-
 3 files changed, 33 insertions(+), 3 deletions(-)

diff --git a/src/mesa/state_tracker/st_cb_bufferobjects.c b/src/mesa/state_tracker/st_cb_bufferobjects.c
index 0c5fece..68be8ba 100644
--- a/src/mesa/state_tracker/st_cb_bufferobjects.c
+++ b/src/mesa/state_tracker/st_cb_bufferobjects.c
@@ -333,6 +333,31 @@ st_bufferobj_data(struct gl_context *ctx,
 
 
 /**
+ * Called via glInvalidateBuffer(Sub)Data.
+ */
+static void
+st_bufferobj_invalidate(struct gl_context *ctx,
+                        struct gl_buffer_object *obj,
+                        GLintptr offset,
+                        GLsizeiptr size)
+{
+   struct st_context *st = st_context(ctx);
+   struct pipe_context *pipe = st->pipe;
+   struct st_buffer_object *st_obj = st_buffer_object(obj);
+
+   /* We ignore partial invalidates. */
+   if (offset != 0 || size != obj->Size)
+      return;
+
+   /* Nothing to invalidate. */
+   if (!st_obj->buffer)
+      return;
+
+   pipe->invalidate_resource(pipe, st_obj->buffer);
+}
+
+
+/**
  * Called via glMapBufferRange().
  */
 static void *
@@ -517,7 +542,8 @@ st_bufferobj_validate_usage(struct st_context *st,
 
 
 void
-st_init_bufferobject_functions(struct dd_function_table *functions)
+st_init_bufferobject_functions(struct pipe_screen *screen,
+                               struct dd_function_table *functions)
 {
    /* plug in default driver fallbacks (such as for ClearBufferSubData) */
    _mesa_init_buffer_object_functions(functions);
@@ -532,4 +558,7 @@ st_init_bufferobject_functions(struct dd_function_table *functions)
    functions->UnmapBuffer = st_bufferobj_unmap;
    functions->CopyBufferSubData = st_copy_buffer_subdata;
    functions->ClearBufferSubData = st_clear_buffer_subdata;
+
+   if (screen->get_param(screen, PIPE_CAP_INVALIDATE_BUFFER))
+      functions->InvalidateBufferSubData = st_bufferobj_invalidate;
 }
diff --git a/src/mesa/state_tracker/st_cb_bufferobjects.h b/src/mesa/state_tracker/st_cb_bufferobjects.h
index 647efe4..f55e2ef 100644
--- a/src/mesa/state_tracker/st_cb_bufferobjects.h
+++ b/src/mesa/state_tracker/st_cb_bufferobjects.h
@@ -62,7 +62,8 @@ st_bufferobj_validate_usage(struct st_context *st,
 
 
 extern void
-st_init_bufferobject_functions(struct dd_function_table *functions);
+st_init_bufferobject_functions(struct pipe_screen *screen,
+                               struct dd_function_table *functions);
 
 
 #endif
diff --git a/src/mesa/state_tracker/st_context.c b/src/mesa/state_tracker/st_context.c
index 87193a9..4add50e 100644
--- a/src/mesa/state_tracker/st_context.c
+++ b/src/mesa/state_tracker/st_context.c
@@ -446,7 +446,7 @@ void st_init_driver_functions(struct pipe_screen *screen,
    _mesa_init_sampler_object_functions(functions);
 
    st_init_blit_functions(functions);
-   st_init_bufferobject_functions(functions);
+   st_init_bufferobject_functions(screen, functions);
    st_init_clear_functions(functions);
    st_init_bitmap_functions(functions);
    st_init_copy_image_functions(functions);
-- 
2.5.0



More information about the mesa-dev mailing list