summaryrefslogtreecommitdiffstats
path: root/src/mesa/state_tracker/st_cb_bufferobjects.c
diff options
context:
space:
mode:
authorNicolai Hähnle <[email protected]>2016-01-09 18:05:58 -0500
committerNicolai Hähnle <[email protected]>2016-01-14 09:39:57 -0500
commit70e66c57bbff930f7caa8606e75cfc91417bbc67 (patch)
tree2b5a4aa8e7d5d6045507eabdfb85f55d1d4d7bed /src/mesa/state_tracker/st_cb_bufferobjects.c
parent9e2240e892cb893d60561bf7be157ad8939b3ea8 (diff)
st/mesa: implement Driver.InvalidateBufferSubData
Reviewed-by: Marek Olšák <[email protected]>
Diffstat (limited to 'src/mesa/state_tracker/st_cb_bufferobjects.c')
-rw-r--r--src/mesa/state_tracker/st_cb_bufferobjects.c31
1 files changed, 30 insertions, 1 deletions
diff --git a/src/mesa/state_tracker/st_cb_bufferobjects.c b/src/mesa/state_tracker/st_cb_bufferobjects.c
index 0c5fecea51f..68be8ba64ac 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;
}