summaryrefslogtreecommitdiff
path: root/src/mesa/state_tracker/st_cb_accum.c
diff options
context:
space:
mode:
authorThomas Hellstrom <thellstrom-at-vmware-dot-com>2009-04-15 15:53:34 +0200
committerThomas Hellstrom <thellstrom-at-vmware-dot-com>2009-04-15 17:16:58 +0200
commit9b75627fab5bf2ea90f27ddd31b60c54895f6de6 (patch)
treeb748494fcd35bde9b8684742dc0b7ba0958acfcb /src/mesa/state_tracker/st_cb_accum.c
parentf94053eb7d3f129e5086f6dc431a13f83c93a189 (diff)
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>
Diffstat (limited to 'src/mesa/state_tracker/st_cb_accum.c')
-rw-r--r--src/mesa/state_tracker/st_cb_accum.c36
1 files changed, 31 insertions, 5 deletions
diff --git a/src/mesa/state_tracker/st_cb_accum.c b/src/mesa/state_tracker/st_cb_accum.c
index 3f9a825a15..1510a1e236 100644
--- a/src/mesa/state_tracker/st_cb_accum.c
+++ b/src/mesa/state_tracker/st_cb_accum.c
@@ -40,6 +40,7 @@
#include "st_draw.h"
#include "st_public.h"
#include "st_format.h"
+#include "st_texture.h"
#include "pipe/p_context.h"
#include "pipe/p_defines.h"
#include "pipe/p_inlines.h"
@@ -118,6 +119,9 @@ st_clear_accum_buffer(GLcontext *ctx, struct gl_renderbuffer *rb)
const GLint height = ctx->DrawBuffer->_Ymax - ypos;
GLubyte *map;
+ st_teximage_flush_before_map(ctx->st, acc_strb->texture, 0, 0,
+ PIPE_TRANSFER_WRITE);
+
acc_pt = screen->get_tex_transfer(screen, acc_strb->texture, 0, 0, 0,
PIPE_TRANSFER_WRITE, xpos, ypos,
width, height);
@@ -163,6 +167,9 @@ accum_mad(GLcontext *ctx, GLfloat scale, GLfloat bias,
struct pipe_transfer *acc_pt;
GLubyte *map;
+ st_teximage_flush_before_map(ctx->st, acc_strb->texture, 0, 0,
+ PIPE_TRANSFER_READ_WRITE);
+
acc_pt = screen->get_tex_transfer(screen, acc_strb->texture, 0, 0, 0,
PIPE_TRANSFER_READ_WRITE, xpos, ypos,
width, height);
@@ -192,20 +199,27 @@ accum_mad(GLcontext *ctx, GLfloat scale, GLfloat bias,
static void
-accum_accum(struct pipe_context *pipe, GLfloat value,
+accum_accum(struct st_context *st, GLfloat value,
GLint xpos, GLint ypos, GLint width, GLint height,
struct st_renderbuffer *acc_strb,
struct st_renderbuffer *color_strb)
{
+ struct pipe_context *pipe = st->pipe;
struct pipe_screen *screen = pipe->screen;
struct pipe_transfer *acc_trans, *color_trans;
GLfloat *colorBuf, *accBuf;
GLint i;
+ st_teximage_flush_before_map(st, acc_strb->texture, 0, 0,
+ PIPE_TRANSFER_READ);
+
acc_trans = screen->get_tex_transfer(screen, acc_strb->texture, 0, 0, 0,
PIPE_TRANSFER_READ, xpos, ypos,
width, height);
+ st_teximage_flush_before_map(st, color_strb->texture, 0, 0,
+ PIPE_TRANSFER_READ);
+
color_trans = screen->get_tex_transfer(screen, color_strb->texture, 0, 0, 0,
PIPE_TRANSFER_READ, xpos, ypos,
width, height);
@@ -235,20 +249,27 @@ accum_accum(struct pipe_context *pipe, GLfloat value,
static void
-accum_load(struct pipe_context *pipe, GLfloat value,
+accum_load(struct st_context *st, GLfloat value,
GLint xpos, GLint ypos, GLint width, GLint height,
struct st_renderbuffer *acc_strb,
struct st_renderbuffer *color_strb)
{
+ struct pipe_context *pipe = st->pipe;
struct pipe_screen *screen = pipe->screen;
struct pipe_transfer *acc_trans, *color_trans;
GLfloat *buf;
GLint i;
+ st_teximage_flush_before_map(st, acc_strb->texture, 0, 0,
+ PIPE_TRANSFER_WRITE);
+
acc_trans = screen->get_tex_transfer(screen, acc_strb->texture, 0, 0, 0,
PIPE_TRANSFER_WRITE, xpos, ypos,
width, height);
+ st_teximage_flush_before_map(st, color_strb->texture, 0, 0,
+ PIPE_TRANSFER_READ);
+
color_trans = screen->get_tex_transfer(screen, color_strb->texture, 0, 0, 0,
PIPE_TRANSFER_READ, xpos, ypos,
width, height);
@@ -284,10 +305,16 @@ accum_return(GLcontext *ctx, GLfloat value,
abuf = (GLfloat *) _mesa_malloc(width * height * 4 * sizeof(GLfloat));
+ st_teximage_flush_before_map(ctx->st, acc_strb->texture, 0, 0,
+ PIPE_TRANSFER_READ);
+
acc_trans = screen->get_tex_transfer(screen, acc_strb->texture, 0, 0, 0,
PIPE_TRANSFER_READ, xpos, ypos,
width, height);
+ st_teximage_flush_before_map(ctx->st, color_strb->texture, 0, 0,
+ PIPE_TRANSFER_READ_WRITE);
+
color_trans = screen->get_tex_transfer(screen, color_strb->texture, 0, 0, 0,
PIPE_TRANSFER_READ_WRITE, xpos, ypos,
width, height);
@@ -325,7 +352,6 @@ static void
st_Accum(GLcontext *ctx, GLenum op, GLfloat value)
{
struct st_context *st = ctx->st;
- struct pipe_context *pipe = st->pipe;
struct st_renderbuffer *acc_strb
= st_renderbuffer(ctx->DrawBuffer->Attachment[BUFFER_ACCUM].Renderbuffer);
struct st_renderbuffer *color_strb
@@ -352,11 +378,11 @@ st_Accum(GLcontext *ctx, GLenum op, GLfloat value)
break;
case GL_ACCUM:
if (value != 0.0F) {
- accum_accum(pipe, value, xpos, ypos, width, height, acc_strb, color_strb);
+ accum_accum(st, value, xpos, ypos, width, height, acc_strb, color_strb);
}
break;
case GL_LOAD:
- accum_load(pipe, value, xpos, ypos, width, height, acc_strb, color_strb);
+ accum_load(st, value, xpos, ypos, width, height, acc_strb, color_strb);
break;
case GL_RETURN:
accum_return(ctx, value, xpos, ypos, width, height, acc_strb, color_strb);