From 6484898752d733a2442b433fbb78325f9021c698 Mon Sep 17 00:00:00 2001 From: =?utf8?q?Christian=20K=C3=B6nig?= Date: Sun, 5 Dec 2010 22:30:38 +0100 Subject: [PATCH] [g3dvl] move mapping/unmapping of buffers one layer up --- src/gallium/auxiliary/vl/vl_idct.c | 70 ++++++++++--------- src/gallium/auxiliary/vl/vl_idct.h | 4 ++ .../auxiliary/vl/vl_mpeg12_mc_renderer.c | 9 +++ 3 files changed, 49 insertions(+), 34 deletions(-) diff --git a/src/gallium/auxiliary/vl/vl_idct.c b/src/gallium/auxiliary/vl/vl_idct.c index 66bb140f02a..6aae28d465c 100644 --- a/src/gallium/auxiliary/vl/vl_idct.c +++ b/src/gallium/auxiliary/vl/vl_idct.c @@ -566,35 +566,6 @@ vl_idct_upload_matrix(struct pipe_context *pipe) return matrix; } -static void -xfer_buffers_map(struct vl_idct *idct) -{ - struct pipe_box rect = - { - 0, 0, 0, - idct->textures.individual.source->width0, - idct->textures.individual.source->height0, - 1 - }; - - idct->tex_transfer = idct->pipe->get_transfer - ( - idct->pipe, idct->textures.individual.source, - u_subresource(0, 0), - PIPE_TRANSFER_WRITE | PIPE_TRANSFER_DISCARD, - &rect - ); - - idct->texels = idct->pipe->transfer_map(idct->pipe, idct->tex_transfer); -} - -static void -xfer_buffers_unmap(struct vl_idct *idct) -{ - idct->pipe->transfer_unmap(idct->pipe, idct->tex_transfer); - idct->pipe->transfer_destroy(idct->pipe, idct->tex_transfer); -} - bool vl_idct_init(struct vl_idct *idct, struct pipe_context *pipe, struct pipe_resource *dst, struct pipe_resource *matrix) { @@ -626,7 +597,7 @@ vl_idct_init(struct vl_idct *idct, struct pipe_context *pipe, struct pipe_resour init_state(idct); - xfer_buffers_map(idct); + vl_idct_map_buffers(idct); return true; } @@ -634,6 +605,8 @@ vl_idct_init(struct vl_idct *idct, struct pipe_context *pipe, struct pipe_resour void vl_idct_cleanup(struct vl_idct *idct) { + vl_idct_unmap_buffers(idct); + vl_vb_cleanup(&idct->blocks); cleanup_shaders(idct); cleanup_buffers(idct); @@ -643,6 +616,30 @@ vl_idct_cleanup(struct vl_idct *idct) pipe_resource_reference(&idct->destination, NULL); } +void +vl_idct_map_buffers(struct vl_idct *idct) +{ + assert(idct); + + struct pipe_box rect = + { + 0, 0, 0, + idct->textures.individual.source->width0, + idct->textures.individual.source->height0, + 1 + }; + + idct->tex_transfer = idct->pipe->get_transfer + ( + idct->pipe, idct->textures.individual.source, + u_subresource(0, 0), + PIPE_TRANSFER_WRITE | PIPE_TRANSFER_DISCARD, + &rect + ); + + idct->texels = idct->pipe->transfer_map(idct->pipe, idct->tex_transfer); +} + void vl_idct_add_block(struct vl_idct *idct, unsigned x, unsigned y, short *block) { @@ -665,6 +662,15 @@ vl_idct_add_block(struct vl_idct *idct, unsigned x, unsigned y, short *block) vl_vb_add_block(&idct->blocks, (float*)&v); } +void +vl_idct_unmap_buffers(struct vl_idct *idct) +{ + assert(idct); + + idct->pipe->transfer_unmap(idct->pipe, idct->tex_transfer); + idct->pipe->transfer_destroy(idct->pipe, idct->tex_transfer); +} + void vl_idct_flush(struct vl_idct *idct) { @@ -686,8 +692,6 @@ vl_idct_flush(struct vl_idct *idct) pipe_buffer_unmap(idct->pipe, idct->vertex_bufs.individual.pos.buffer, vec_transfer); - xfer_buffers_unmap(idct); - if(num_verts > 0) { idct->pipe->bind_rasterizer_state(idct->pipe, idct->rs_state); @@ -711,6 +715,4 @@ vl_idct_flush(struct vl_idct *idct) idct->pipe->bind_fs_state(idct->pipe, idct->transpose_fs); util_draw_arrays(idct->pipe, PIPE_PRIM_QUADS, 0, num_verts); } - - xfer_buffers_map(idct); } diff --git a/src/gallium/auxiliary/vl/vl_idct.h b/src/gallium/auxiliary/vl/vl_idct.h index ccaaf2653de..96e3d267046 100644 --- a/src/gallium/auxiliary/vl/vl_idct.h +++ b/src/gallium/auxiliary/vl/vl_idct.h @@ -97,8 +97,12 @@ bool vl_idct_init(struct vl_idct *idct, struct pipe_context *pipe, struct pipe_r void vl_idct_cleanup(struct vl_idct *idct); +void vl_idct_map_buffers(struct vl_idct *idct); + void vl_idct_add_block(struct vl_idct *idct, unsigned x, unsigned y, short *block); +void vl_idct_unmap_buffers(struct vl_idct *idct); + void vl_idct_flush(struct vl_idct *idct); #endif diff --git a/src/gallium/auxiliary/vl/vl_mpeg12_mc_renderer.c b/src/gallium/auxiliary/vl/vl_mpeg12_mc_renderer.c index 064e6c1a2d5..f97bc47a70a 100644 --- a/src/gallium/auxiliary/vl/vl_mpeg12_mc_renderer.c +++ b/src/gallium/auxiliary/vl/vl_mpeg12_mc_renderer.c @@ -950,6 +950,10 @@ flush(struct vl_mpeg12_mc_renderer *r) assert(r); assert(r->num_macroblocks == r->macroblocks_per_batch); + vl_idct_unmap_buffers(&r->idct_y); + vl_idct_unmap_buffers(&r->idct_cr); + vl_idct_unmap_buffers(&r->idct_cb); + vl_idct_flush(&r->idct_y); vl_idct_flush(&r->idct_cr); vl_idct_flush(&r->idct_cb); @@ -965,8 +969,13 @@ flush(struct vl_mpeg12_mc_renderer *r) vb_start += flush_mbtype_handler(r, i, vb_start, num_verts[i]); } + r->pipe->flush(r->pipe, PIPE_FLUSH_RENDER_CACHE, r->fence); + vl_idct_map_buffers(&r->idct_y); + vl_idct_map_buffers(&r->idct_cr); + vl_idct_map_buffers(&r->idct_cb); + r->num_macroblocks = 0; } -- 2.30.2