diff options
author | Marek Olšák <[email protected]> | 2013-04-14 23:28:36 +0200 |
---|---|---|
committer | Marek Olšák <[email protected]> | 2013-04-24 03:23:23 +0200 |
commit | 5649f886f76023532538b8792605a3578cec1ed1 (patch) | |
tree | 39cbe4504df8d243e2b8dd4f9c9ad41210979549 /src | |
parent | d23c7455ae218a522d4a03829a7a7cafa94f6e94 (diff) |
st/mesa: add a simple path to BufferData if it only discards buffer contents
Reviewed-by: Brian Paul <[email protected]>
Diffstat (limited to 'src')
-rw-r--r-- | src/mesa/state_tracker/st_cb_bufferobjects.c | 14 |
1 files changed, 14 insertions, 0 deletions
diff --git a/src/mesa/state_tracker/st_cb_bufferobjects.c b/src/mesa/state_tracker/st_cb_bufferobjects.c index 8ff32c84291..1b3991c3f6d 100644 --- a/src/mesa/state_tracker/st_cb_bufferobjects.c +++ b/src/mesa/state_tracker/st_cb_bufferobjects.c @@ -182,6 +182,20 @@ st_bufferobj_data(struct gl_context *ctx, struct st_buffer_object *st_obj = st_buffer_object(obj); unsigned bind, pipe_usage; + if (st_obj->Base.Size == size && st_obj->Base.Usage == usage && data) { + /* 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; |