diff options
author | Marek Olšák <maraeo@gmail.com> | 2012-10-08 04:06:42 +0200 |
---|---|---|
committer | Marek Olšák <maraeo@gmail.com> | 2012-10-11 21:12:16 +0200 |
commit | 369e46888904c6d379b8b477d9242cff1608e30e (patch) | |
tree | 528b10f900f23af3acd22a0edcf50fde0eeee86e /src/gallium/drivers/softpipe/sp_tile_cache.c | |
parent | ec4c74a9dc10039d97ad24c4f16bd2400517991d (diff) |
gallium: unify transfer functions
"get_transfer + transfer_map" becomes "transfer_map".
"transfer_unmap + transfer_destroy" becomes "transfer_unmap".
transfer_map must create and return the transfer object and transfer_unmap
must destroy it.
transfer_map is successful if the returned buffer pointer is not NULL.
If transfer_map fails, the pointer to the transfer object remains unchanged
(i.e. doesn't have to be NULL).
Acked-by: Brian Paul <brianp@vmware.com>
Diffstat (limited to 'src/gallium/drivers/softpipe/sp_tile_cache.c')
-rw-r--r-- | src/gallium/drivers/softpipe/sp_tile_cache.c | 74 |
1 files changed, 26 insertions, 48 deletions
diff --git a/src/gallium/drivers/softpipe/sp_tile_cache.c b/src/gallium/drivers/softpipe/sp_tile_cache.c index 659ac58e5b0..8d581112fcd 100644 --- a/src/gallium/drivers/softpipe/sp_tile_cache.c +++ b/src/gallium/drivers/softpipe/sp_tile_cache.c @@ -141,7 +141,7 @@ sp_destroy_tile_cache(struct softpipe_tile_cache *tc) FREE( tc->tile ); if (tc->transfer) { - tc->pipe->transfer_destroy(tc->pipe, tc->transfer); + tc->pipe->transfer_unmap(tc->pipe, tc->transfer); } FREE( tc ); @@ -158,27 +158,24 @@ sp_tile_cache_set_surface(struct softpipe_tile_cache *tc, { struct pipe_context *pipe = tc->pipe; - if (tc->transfer) { + if (tc->transfer_map) { if (ps == tc->surface) return; - if (tc->transfer_map) { - pipe->transfer_unmap(pipe, tc->transfer); - tc->transfer_map = NULL; - } - - pipe->transfer_destroy(pipe, tc->transfer); + pipe->transfer_unmap(pipe, tc->transfer); tc->transfer = NULL; + tc->transfer_map = NULL; } tc->surface = ps; if (ps) { - tc->transfer = pipe_get_transfer(pipe, ps->texture, - ps->u.tex.level, ps->u.tex.first_layer, - PIPE_TRANSFER_READ_WRITE | - PIPE_TRANSFER_UNSYNCHRONIZED, - 0, 0, ps->width, ps->height); + tc->transfer_map = pipe_transfer_map(pipe, ps->texture, + ps->u.tex.level, ps->u.tex.first_layer, + PIPE_TRANSFER_READ_WRITE | + PIPE_TRANSFER_UNSYNCHRONIZED, + 0, 0, ps->width, ps->height, + &tc->transfer); tc->depth_stencil = util_format_is_depth_or_stencil(ps->format); } @@ -195,24 +192,6 @@ sp_tile_cache_get_surface(struct softpipe_tile_cache *tc) } -void -sp_tile_cache_map_transfers(struct softpipe_tile_cache *tc) -{ - if (tc->transfer && !tc->transfer_map) - tc->transfer_map = tc->pipe->transfer_map(tc->pipe, tc->transfer); -} - - -void -sp_tile_cache_unmap_transfers(struct softpipe_tile_cache *tc) -{ - if (tc->transfer_map) { - tc->pipe->transfer_unmap(tc->pipe, tc->transfer); - tc->transfer_map = NULL; - } -} - - /** * Set pixels in a tile to the given clear color/value, float. */ @@ -349,24 +328,23 @@ sp_tile_cache_flush_clear(struct softpipe_tile_cache *tc) if (is_clear_flag_set(tc->clear_flags, addr)) { /* write the scratch tile to the surface */ if (tc->depth_stencil) { - pipe_put_tile_raw(tc->pipe, - pt, + pipe_put_tile_raw(pt, tc->transfer_map, x, y, TILE_SIZE, TILE_SIZE, tc->tile->data.any, 0/*STRIDE*/); } else { if (util_format_is_pure_uint(tc->surface->format)) { - pipe_put_tile_ui_format(tc->pipe, pt, + pipe_put_tile_ui_format(pt, tc->transfer_map, x, y, TILE_SIZE, TILE_SIZE, pt->resource->format, (unsigned *) tc->tile->data.colorui128); } else if (util_format_is_pure_sint(tc->surface->format)) { - pipe_put_tile_i_format(tc->pipe, pt, + pipe_put_tile_i_format(pt, tc->transfer_map, x, y, TILE_SIZE, TILE_SIZE, pt->resource->format, (int *) tc->tile->data.colori128); } else { - pipe_put_tile_rgba(tc->pipe, pt, + pipe_put_tile_rgba(pt, tc->transfer_map, x, y, TILE_SIZE, TILE_SIZE, (float *) tc->tile->data.color); } @@ -389,7 +367,7 @@ sp_flush_tile(struct softpipe_tile_cache* tc, unsigned pos) { if (!tc->tile_addrs[pos].bits.invalid) { if (tc->depth_stencil) { - pipe_put_tile_raw(tc->pipe, tc->transfer, + pipe_put_tile_raw(tc->transfer, tc->transfer_map, tc->tile_addrs[pos].bits.x * TILE_SIZE, tc->tile_addrs[pos].bits.y * TILE_SIZE, TILE_SIZE, TILE_SIZE, @@ -397,21 +375,21 @@ sp_flush_tile(struct softpipe_tile_cache* tc, unsigned pos) } else { if (util_format_is_pure_uint(tc->surface->format)) { - pipe_put_tile_ui_format(tc->pipe, tc->transfer, + pipe_put_tile_ui_format(tc->transfer, tc->transfer_map, tc->tile_addrs[pos].bits.x * TILE_SIZE, tc->tile_addrs[pos].bits.y * TILE_SIZE, TILE_SIZE, TILE_SIZE, tc->surface->format, (unsigned *) tc->entries[pos]->data.colorui128); } else if (util_format_is_pure_sint(tc->surface->format)) { - pipe_put_tile_i_format(tc->pipe, tc->transfer, + pipe_put_tile_i_format(tc->transfer, tc->transfer_map, tc->tile_addrs[pos].bits.x * TILE_SIZE, tc->tile_addrs[pos].bits.y * TILE_SIZE, TILE_SIZE, TILE_SIZE, tc->surface->format, (int *) tc->entries[pos]->data.colori128); } else { - pipe_put_tile_rgba_format(tc->pipe, tc->transfer, + pipe_put_tile_rgba_format(tc->transfer, tc->transfer_map, tc->tile_addrs[pos].bits.x * TILE_SIZE, tc->tile_addrs[pos].bits.y * TILE_SIZE, TILE_SIZE, TILE_SIZE, @@ -516,7 +494,7 @@ sp_find_cached_tile(struct softpipe_tile_cache *tc, if (tc->tile_addrs[pos].bits.invalid == 0) { /* put dirty tile back in framebuffer */ if (tc->depth_stencil) { - pipe_put_tile_raw(tc->pipe, pt, + pipe_put_tile_raw(pt, tc->transfer_map, tc->tile_addrs[pos].bits.x * TILE_SIZE, tc->tile_addrs[pos].bits.y * TILE_SIZE, TILE_SIZE, TILE_SIZE, @@ -524,21 +502,21 @@ sp_find_cached_tile(struct softpipe_tile_cache *tc, } else { if (util_format_is_pure_uint(tc->surface->format)) { - pipe_put_tile_ui_format(tc->pipe, pt, + pipe_put_tile_ui_format(pt, tc->transfer_map, tc->tile_addrs[pos].bits.x * TILE_SIZE, tc->tile_addrs[pos].bits.y * TILE_SIZE, TILE_SIZE, TILE_SIZE, tc->surface->format, (unsigned *) tile->data.colorui128); } else if (util_format_is_pure_sint(tc->surface->format)) { - pipe_put_tile_i_format(tc->pipe, pt, + pipe_put_tile_i_format(pt, tc->transfer_map, tc->tile_addrs[pos].bits.x * TILE_SIZE, tc->tile_addrs[pos].bits.y * TILE_SIZE, TILE_SIZE, TILE_SIZE, tc->surface->format, (int *) tile->data.colori128); } else { - pipe_put_tile_rgba_format(tc->pipe, pt, + pipe_put_tile_rgba_format(pt, tc->transfer_map, tc->tile_addrs[pos].bits.x * TILE_SIZE, tc->tile_addrs[pos].bits.y * TILE_SIZE, TILE_SIZE, TILE_SIZE, @@ -563,7 +541,7 @@ sp_find_cached_tile(struct softpipe_tile_cache *tc, else { /* get new tile data from transfer */ if (tc->depth_stencil) { - pipe_get_tile_raw(tc->pipe, pt, + pipe_get_tile_raw(pt, tc->transfer_map, tc->tile_addrs[pos].bits.x * TILE_SIZE, tc->tile_addrs[pos].bits.y * TILE_SIZE, TILE_SIZE, TILE_SIZE, @@ -571,21 +549,21 @@ sp_find_cached_tile(struct softpipe_tile_cache *tc, } else { if (util_format_is_pure_uint(tc->surface->format)) { - pipe_get_tile_ui_format(tc->pipe, pt, + pipe_get_tile_ui_format(pt, tc->transfer_map, tc->tile_addrs[pos].bits.x * TILE_SIZE, tc->tile_addrs[pos].bits.y * TILE_SIZE, TILE_SIZE, TILE_SIZE, tc->surface->format, (unsigned *) tile->data.colorui128); } else if (util_format_is_pure_sint(tc->surface->format)) { - pipe_get_tile_i_format(tc->pipe, pt, + pipe_get_tile_i_format(pt, tc->transfer_map, tc->tile_addrs[pos].bits.x * TILE_SIZE, tc->tile_addrs[pos].bits.y * TILE_SIZE, TILE_SIZE, TILE_SIZE, tc->surface->format, (int *) tile->data.colori128); } else { - pipe_get_tile_rgba_format(tc->pipe, pt, + pipe_get_tile_rgba_format(pt, tc->transfer_map, tc->tile_addrs[pos].bits.x * TILE_SIZE, tc->tile_addrs[pos].bits.y * TILE_SIZE, TILE_SIZE, TILE_SIZE, |