summaryrefslogtreecommitdiff
path: root/src/mesa/state_tracker/st_cb_drawpixels.c
diff options
context:
space:
mode:
authorThomas Hellstrom <thellstrom-at-vmware-dot-com>2009-04-17 11:47:30 +0200
committerThomas Hellstrom <thellstrom-at-vmware-dot-com>2009-04-17 13:18:05 +0200
commite50dd26ca6d0eb0d0f97c2780020ea16e3d4a687 (patch)
tree9f5e533b888576b93fa3d0873d568c81baeed4d8 /src/mesa/state_tracker/st_cb_drawpixels.c
parentee2a5f307a026c1c258d3f7616d46cc7230d77ce (diff)
gallium: Create OGL state tracker wrappers for various CPU access operations.
There are two usage types of buffer CPU accesses: One where we try to use the buffer contents for multiple draw commands in a batch. (batch := sequence of commands that are flushed together), like incrementally adding bitmaps to a bitmap texture that is reallocated on flush. And one where we assume we can safely overwrite the old buffer contexts, like glTexSubImage. In this case we need to make sure all old drawing commands referencing the buffer are flushed before we map the buffer. This is easily forgotten. Add wrappers for the most common of these operations. The first type is prefixed with "st_no_flush" and the second type is prefixed with "st_cond_flush", where "cond" indicates that we attmpt to only flush if there is indeed unflushed draw commands referencing the buffer. Prefixed functions are screen::get_tex_transfer pipe_buffer_write pipe_buffer_read pipe_buffer_map Please use the wrappers whenever possible. Signed-off-by: Thomas Hellstrom <thellstrom-at-vmware-dot-com>
Diffstat (limited to 'src/mesa/state_tracker/st_cb_drawpixels.c')
-rw-r--r--src/mesa/state_tracker/st_cb_drawpixels.c42
1 files changed, 18 insertions, 24 deletions
diff --git a/src/mesa/state_tracker/st_cb_drawpixels.c b/src/mesa/state_tracker/st_cb_drawpixels.c
index c67b026413..acc9240b5d 100644
--- a/src/mesa/state_tracker/st_cb_drawpixels.c
+++ b/src/mesa/state_tracker/st_cb_drawpixels.c
@@ -53,6 +53,8 @@
#include "st_format.h"
#include "st_mesa_to_tgsi.h"
#include "st_texture.h"
+#include "st_inlines.h"
+
#include "pipe/p_context.h"
#include "pipe/p_defines.h"
#include "pipe/p_inlines.h"
@@ -368,9 +370,9 @@ make_texture(struct st_context *st,
/* we'll do pixel transfer in a fragment shader */
ctx->_ImageTransferState = 0x0;
- transfer = screen->get_tex_transfer(screen, pt, 0, 0, 0,
- PIPE_TRANSFER_WRITE, 0, 0,
- width, height);
+ transfer = st_no_flush_get_tex_transfer(st, pt, 0, 0, 0,
+ PIPE_TRANSFER_WRITE, 0, 0,
+ width, height);
/* map texture transfer */
dest = screen->transfer_map(screen, transfer);
@@ -490,7 +492,7 @@ draw_quad(GLcontext *ctx, GLfloat x0, GLfloat y0, GLfloat z,
/* allocate/load buffer object with vertex data */
buf = pipe_buffer_create(pipe->screen, 32, PIPE_BUFFER_USAGE_VERTEX,
sizeof(verts));
- pipe_buffer_write(pipe->screen, buf, 0, sizeof(verts), verts);
+ st_no_flush_pipe_buffer_write(st, buf, 0, sizeof(verts), verts);
util_draw_vertex_buffer(pipe, buf, 0,
PIPE_PRIM_QUADS,
@@ -638,12 +640,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);
+ pt = st_cond_flush_get_tex_transfer(st_context(ctx), strb->texture, 0, 0, 0,
+ PIPE_TRANSFER_WRITE, x, y,
+ width, height);
stmap = screen->transfer_map(screen, pt);
@@ -826,12 +825,10 @@ 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);
+ ptDraw = st_cond_flush_get_tex_transfer(st_context(ctx),
+ rbDraw->texture, 0, 0, 0,
+ PIPE_TRANSFER_WRITE, dstx, dsty,
+ width, height);
assert(ptDraw->block.width == 1);
assert(ptDraw->block.height == 1);
@@ -907,9 +904,6 @@ st_CopyPixels(GLcontext *ctx, GLint srcx, GLint srcy,
GLfloat *color;
enum pipe_format srcFormat, texFormat;
- /* make sure rendering has completed */
- pipe->flush(pipe, PIPE_FLUSH_RENDER_CACHE, NULL);
-
st_validate_state(st);
if (type == GL_STENCIL) {
@@ -981,13 +975,13 @@ st_CopyPixels(GLcontext *ctx, GLint srcx, GLint srcy,
else {
/* CPU-based fallback/conversion */
struct pipe_transfer *ptRead =
- screen->get_tex_transfer(screen, rbRead->texture, 0, 0, 0,
- PIPE_TRANSFER_READ, srcx, srcy, width,
- height);
+ st_cond_flush_get_tex_transfer(st, rbRead->texture, 0, 0, 0,
+ PIPE_TRANSFER_READ, srcx, srcy, width,
+ height);
struct pipe_transfer *ptTex =
- screen->get_tex_transfer(screen, pt, 0, 0, 0, PIPE_TRANSFER_WRITE,
- 0, 0, width, height);
+ st_cond_flush_get_tex_transfer(st, pt, 0, 0, 0, PIPE_TRANSFER_WRITE,
+ 0, 0, width, height);
if (type == GL_COLOR) {
/* alternate path using get/put_tile() */