From 9b75627fab5bf2ea90f27ddd31b60c54895f6de6 Mon Sep 17 00:00:00 2001 From: Thomas Hellstrom Date: Wed, 15 Apr 2009 15:53:34 +0200 Subject: gallium: Make sure we flush before some texture / buffer operations. Also implement context member functions to optimize away those flushes whenever possible. Signed-off-by: Thomas Hellstrom --- src/mesa/state_tracker/st_cb_bufferobjects.c | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) (limited to 'src/mesa/state_tracker/st_cb_bufferobjects.c') diff --git a/src/mesa/state_tracker/st_cb_bufferobjects.c b/src/mesa/state_tracker/st_cb_bufferobjects.c index 3651e4ae7d..fdb800fbd0 100644 --- a/src/mesa/state_tracker/st_cb_bufferobjects.c +++ b/src/mesa/state_tracker/st_cb_bufferobjects.c @@ -32,6 +32,7 @@ #include "st_context.h" #include "st_cb_bufferobjects.h" +#include "st_public.h" #include "pipe/p_context.h" #include "pipe/p_defines.h" @@ -103,6 +104,9 @@ st_bufferobj_subdata(GLcontext *ctx, if (offset >= st_obj->size || size > (st_obj->size - offset)) return; + if (pipe->is_buffer_referenced(pipe, st_obj->buffer)) + st_flush(st_context(ctx), PIPE_FLUSH_RENDER_CACHE, NULL); + pipe_buffer_write(pipe->screen, st_obj->buffer, offset, size, data); } @@ -123,6 +127,10 @@ st_bufferobj_get_subdata(GLcontext *ctx, if (offset >= st_obj->size || size > (st_obj->size - offset)) return; + if (pipe->is_buffer_referenced(pipe, st_obj->buffer) & + PIPE_REFERENCED_FOR_WRITE) + st_flush(st_context(ctx), PIPE_FLUSH_RENDER_CACHE, NULL); + pipe_buffer_read(pipe->screen, st_obj->buffer, offset, size, data); } @@ -171,7 +179,7 @@ st_bufferobj_data(GLcontext *ctx, st_obj->size = size; if (data) - st_bufferobj_subdata(ctx, target, 0, size, data, obj); + pipe_buffer_write(pipe->screen, st_obj->buffer, 0, size, data); } @@ -185,6 +193,7 @@ st_bufferobj_map(GLcontext *ctx, GLenum target, GLenum access, struct pipe_context *pipe = st_context(ctx)->pipe; struct st_buffer_object *st_obj = st_buffer_object(obj); GLuint flags; + unsigned referenced; switch (access) { case GL_WRITE_ONLY: @@ -200,6 +209,11 @@ st_bufferobj_map(GLcontext *ctx, GLenum target, GLenum access, break; } + referenced = pipe->is_buffer_referenced(pipe, st_obj->buffer); + if (referenced && ((referenced & PIPE_REFERENCED_FOR_WRITE) || + (flags & PIPE_BUFFER_USAGE_CPU_WRITE))) + st_flush(st_context(ctx), PIPE_FLUSH_RENDER_CACHE, NULL); + obj->Pointer = pipe_buffer_map(pipe->screen, st_obj->buffer, flags); if(obj->Pointer) { obj->Offset = 0; -- cgit v1.2.3