[Mesa-dev] [PATCH 2/2] st/mesa: Handle GL_MAP_INVALIDATE_BUFFER_BIT in st_bufferobj_map_range().
Henri Verbeet
hverbeet at gmail.com
Sun Jul 17 16:41:04 PDT 2011
Alternatively, individual drivers could actually implement
PIPE_TRANSFER_DISCARD_WHOLE_RESOURCE. As far as I can tell only svga
currently implements that, and st_bufferobj_map_range() seems to be the main
user. I wonder if in general PIPE_TRANSFER_DISCARD_WHOLE_RESOURCE is something
that should just be handled by the state trackers.
As for the actual implementation, we could also try a map with
PIPE_TRANSFER_DONTBLOCK first, and avoid invalidating _NEW_BUFFER_OBJECT in
some cases. I'm not sure if that's worth it without doing more benchmarking
though, since in the typical case GL_MAP_INVALIDATE_BUFFER_BIT will probably
imply that the buffer is in use.
Signed-off-by: Henri Verbeet <hverbeet at gmail.com>
---
src/mesa/state_tracker/st_cb_bufferobjects.c | 15 +++++++++++++++
1 files changed, 15 insertions(+), 0 deletions(-)
diff --git a/src/mesa/state_tracker/st_cb_bufferobjects.c b/src/mesa/state_tracker/st_cb_bufferobjects.c
index 7374bb0..7aa859e 100644
--- a/src/mesa/state_tracker/st_cb_bufferobjects.c
+++ b/src/mesa/state_tracker/st_cb_bufferobjects.c
@@ -332,6 +332,21 @@ st_bufferobj_map_range(struct gl_context *ctx, GLenum target,
obj->Pointer = &st_bufferobj_zero_length;
}
else {
+ if (flags & PIPE_TRANSFER_DISCARD_WHOLE_RESOURCE) {
+ struct pipe_resource *buffer;
+
+ buffer = pipe_buffer_create(pipe->screen,
+ st_obj->buffer->bind,
+ st_obj->buffer->usage,
+ st_obj->buffer->width0);
+ if (buffer) {
+ st_invalidate_state(ctx, _NEW_BUFFER_OBJECT);
+ pipe_resource_reference(&st_obj->buffer, NULL);
+ st_obj->buffer = buffer;
+ flags &= ~PIPE_TRANSFER_DISCARD_WHOLE_RESOURCE;
+ }
+ }
+
obj->Pointer = pipe_buffer_map_range(pipe,
st_obj->buffer,
offset, length,
--
1.7.2.5
More information about the mesa-dev
mailing list