[Mesa-dev] [PATCH 2/3] gallium, st/mesa: implement InvalidateBufferSubData

Marek Olšák maraeo at gmail.com
Sun Mar 16 10:00:53 PDT 2014


From: Marek Olšák <marek.olsak at amd.com>

---
 src/gallium/include/pipe/p_context.h         | 14 ++++++++++++++
 src/mesa/state_tracker/st_cb_bufferobjects.c | 21 +++++++++++++++++++++
 2 files changed, 35 insertions(+)

diff --git a/src/gallium/include/pipe/p_context.h b/src/gallium/include/pipe/p_context.h
index fe3045a..37f85b6 100644
--- a/src/gallium/include/pipe/p_context.h
+++ b/src/gallium/include/pipe/p_context.h
@@ -536,6 +536,20 @@ struct pipe_context {
     */
    void (*flush_resource)(struct pipe_context *ctx,
                           struct pipe_resource *resource);
+
+   /**
+    * Invalidate the resource storage. This is equivalent to setting
+    * the PIPE_TRANSFER_DISCARD_* flags in transfer_map.
+    * Whether the whole resource or a subset of the resource is invalidated
+    * is determined by the box.
+    *
+    * \param ctc        context
+    * \param resource   resource
+    * \param box        resource region to invalidate
+    */
+   void (*resource_invalidate)(struct pipe_context *ctx,
+                               struct pipe_resource *resource,
+                               struct pipe_box *box);
 };
 
 
diff --git a/src/mesa/state_tracker/st_cb_bufferobjects.c b/src/mesa/state_tracker/st_cb_bufferobjects.c
index 49c4b90..9be8444 100644
--- a/src/mesa/state_tracker/st_cb_bufferobjects.c
+++ b/src/mesa/state_tracker/st_cb_bufferobjects.c
@@ -458,6 +458,26 @@ st_bufferobj_validate_usage(struct st_context *st,
 			    struct st_buffer_object *obj,
 			    unsigned usage)
 {
+
+}
+
+
+/**
+ * Called via ctx->Driver.InvalidateBufferSubData.
+ */
+static void
+st_invalidate_buffer_subdata(struct gl_context *ctx,
+                             struct gl_buffer_object *bufObj,
+                             unsigned offset, unsigned length)
+{
+   struct pipe_context *pipe = st_context(ctx)->pipe;
+   struct st_buffer_object *obj = st_buffer_object(bufObj);
+   struct pipe_box box;
+
+   if (pipe->resource_invalidate) {
+      u_box_1d(offset, length, &box);
+      pipe->resource_invalidate(pipe, obj->buffer, &box);
+   }
 }
 
 
@@ -476,6 +496,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->InvalidateBufferSubData = st_invalidate_buffer_subdata;
 
    /* For GL_APPLE_vertex_array_object */
    functions->NewArrayObject = _mesa_new_vao;
-- 
1.8.3.2



More information about the mesa-dev mailing list