[g3dvl] move mapping/unmapping of buffers one layer up
authorChristian König <deathsimple@vodafone.de>
Sun, 5 Dec 2010 21:30:38 +0000 (22:30 +0100)
committerChristian König <deathsimple@vodafone.de>
Sun, 5 Dec 2010 21:30:38 +0000 (22:30 +0100)
src/gallium/auxiliary/vl/vl_idct.c
src/gallium/auxiliary/vl/vl_idct.h
src/gallium/auxiliary/vl/vl_mpeg12_mc_renderer.c

index 66bb140f02ade1d253281c39ddcdc06e5837628b..6aae28d465ce8a749f57606c8f5fe781fc773b70 100644 (file)
@@ -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);
 }
index ccaaf2653de94e82eb8bc3227aa295e096acb83b..96e3d2670465bccf31110e096e39485edfcf553e 100644 (file)
@@ -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
index 064e6c1a2d5d4434e04dd67be5b073e2177a0e88..f97bc47a70ab380ec3fe577cdee98595e6d5e7ee 100644 (file)
@@ -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;
 }