gallium: Make sure we flush before some texture / buffer operations.
[mesa.git] / src / mesa / state_tracker / st_cb_drawpixels.c
index 0a4430501f9dc84b5244f1bfaab841646990dac8..c67b026413eebbf232c047c118c98c76b89dca20 100644 (file)
@@ -631,8 +631,6 @@ draw_stencil_pixels(GLcontext *ctx, GLint x, GLint y,
    GLint skipPixels;
    ubyte *stmap;
 
-   pipe->flush(pipe, PIPE_FLUSH_RENDER_CACHE, NULL);
-
    strb = st_renderbuffer(ctx->DrawBuffer->
                           Attachment[BUFFER_STENCIL].Renderbuffer);
 
@@ -640,6 +638,9 @@ draw_stencil_pixels(GLcontext *ctx, GLint x, GLint y,
       y = ctx->DrawBuffer->Height - y - height;
    }
 
+   st_teximage_flush_before_map(ctx->st, strb->texture, 0, 0,
+                               PIPE_TRANSFER_WRITE);
+
    pt = screen->get_tex_transfer(screen, strb->texture, 0, 0, 0,
                                  PIPE_TRANSFER_WRITE, x, y,
                                  width, height);
@@ -825,6 +826,9 @@ copy_stencil_pixels(GLcontext *ctx, GLint srcx, GLint srcy,
                           GL_STENCIL_INDEX, GL_UNSIGNED_BYTE,
                           &ctx->DefaultPacking, buffer);
 
+   st_teximage_flush_before_map(ctx->st, rbDraw->texture, 0, 0,
+                               PIPE_TRANSFER_WRITE);
+
    ptDraw = screen->get_tex_transfer(screen, rbDraw->texture, 0, 0, 0,
                                      PIPE_TRANSFER_WRITE, dstx, dsty,
                                      width, height);