aboutsummaryrefslogtreecommitdiff
path: root/mesalib/src/mesa/state_tracker/st_cb_bufferobjects.c
diff options
context:
space:
mode:
Diffstat (limited to 'mesalib/src/mesa/state_tracker/st_cb_bufferobjects.c')
-rw-r--r--mesalib/src/mesa/state_tracker/st_cb_bufferobjects.c19
1 files changed, 18 insertions, 1 deletions
diff --git a/mesalib/src/mesa/state_tracker/st_cb_bufferobjects.c b/mesalib/src/mesa/state_tracker/st_cb_bufferobjects.c
index 8ff32c842..2e5e253a4 100644
--- a/mesalib/src/mesa/state_tracker/st_cb_bufferobjects.c
+++ b/mesalib/src/mesa/state_tracker/st_cb_bufferobjects.c
@@ -182,6 +182,21 @@ st_bufferobj_data(struct gl_context *ctx,
struct st_buffer_object *st_obj = st_buffer_object(obj);
unsigned bind, pipe_usage;
+ if (size && data && st_obj->buffer &&
+ st_obj->Base.Size == size && st_obj->Base.Usage == usage) {
+ /* Just discard the old contents and write new data.
+ * This should be the same as creating a new buffer, but we avoid
+ * a lot of validation in Mesa.
+ */
+ struct pipe_box box;
+
+ u_box_1d(0, size, &box);
+ pipe->transfer_inline_write(pipe, st_obj->buffer, 0,
+ PIPE_TRANSFER_DISCARD_WHOLE_RESOURCE,
+ &box, data, 0, 0);
+ return GL_TRUE;
+ }
+
st_obj->Base.Size = size;
st_obj->Base.Usage = usage;
@@ -247,9 +262,11 @@ st_bufferobj_data(struct gl_context *ctx,
if (data)
pipe_buffer_write(pipe, st_obj->buffer, 0, size, data);
- return GL_TRUE;
}
+ /* BufferData may change an array or uniform buffer, need to update it */
+ st->dirty.st |= ST_NEW_VERTEX_ARRAYS | ST_NEW_UNIFORM_BUFFER;
+
return GL_TRUE;
}