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 <thellstrom-at-vmware-dot-com>
This commit is contained in:
Thomas Hellstrom
2009-04-15 15:53:34 +02:00
parent f94053eb7d
commit 9b75627fab
22 changed files with 466 additions and 12 deletions

View File

@@ -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;