[g3dvl] move buffer mapping/unmapping out of flush
authorChristian König <deathsimple@vodafone.de>
Wed, 8 Dec 2010 21:35:30 +0000 (22:35 +0100)
committerChristian König <deathsimple@vodafone.de>
Wed, 8 Dec 2010 21:35:30 +0000 (22:35 +0100)
src/gallium/auxiliary/vl/vl_mpeg12_mc_renderer.c
src/gallium/auxiliary/vl/vl_mpeg12_mc_renderer.h
src/gallium/drivers/softpipe/sp_video_context.c

index 445e2aae234703969d15822fbf9e8009be8bcfa4..4b3d2d6d55123d72a2867565a4a8faeab9b64008 100644 (file)
@@ -989,8 +989,23 @@ vl_mpeg12_mc_renderer_cleanup(struct vl_mpeg12_mc_renderer *renderer)
 }
 
 void
-vl_mpeg12_mc_renderer_render_macroblocks(struct vl_mpeg12_mc_renderer
-                                         *renderer,
+vl_mpeg12_mc_map_buffer(struct vl_mpeg12_mc_renderer *renderer)
+{
+   unsigned i;
+
+   assert(renderer);
+
+   vl_idct_map_buffers(&renderer->idct_luma, &renderer->idct_y);
+   vl_idct_map_buffers(&renderer->idct_chroma, &renderer->idct_cr);
+   vl_idct_map_buffers(&renderer->idct_chroma, &renderer->idct_cb);
+
+   vl_vb_map(&renderer->pos, renderer->pipe);
+   for(i = 0; i < 4; ++i)
+      vl_vb_map(&renderer->mv[i], renderer->pipe);
+}
+
+void
+vl_mpeg12_mc_renderer_render_macroblocks(struct vl_mpeg12_mc_renderer *renderer,
                                          struct pipe_surface *surface,
                                          struct pipe_surface *past,
                                          struct pipe_surface *future,
@@ -1024,16 +1039,29 @@ vl_mpeg12_mc_renderer_render_macroblocks(struct vl_mpeg12_mc_renderer
       num_macroblocks -= num_to_submit;
 
       if (renderer->num_macroblocks == renderer->macroblocks_per_batch) {
+         vl_mpeg12_mc_unmap_buffer(renderer);
          vl_mpeg12_mc_renderer_flush(renderer);
-
-         /* Next time we get this surface it may have new ref frames */
-         pipe_surface_reference(&renderer->surface, NULL);
-         pipe_surface_reference(&renderer->past, NULL);
-         pipe_surface_reference(&renderer->future, NULL);
+         vl_mpeg12_mc_map_buffer(renderer);
       }
    }
 }
 
+void
+vl_mpeg12_mc_unmap_buffer(struct vl_mpeg12_mc_renderer *renderer)
+{
+   unsigned i;
+
+   assert(renderer);
+
+   vl_idct_unmap_buffers(&renderer->idct_luma, &renderer->idct_y);
+   vl_idct_unmap_buffers(&renderer->idct_chroma, &renderer->idct_cr);
+   vl_idct_unmap_buffers(&renderer->idct_chroma, &renderer->idct_cb);
+
+   vl_vb_unmap(&renderer->pos, renderer->pipe);
+   for(i = 0; i < 4; ++i)
+      vl_vb_unmap(&renderer->mv[i], renderer->pipe);
+}
+
 void
 vl_mpeg12_mc_renderer_flush(struct vl_mpeg12_mc_renderer *renderer)
 {
@@ -1045,20 +1073,13 @@ vl_mpeg12_mc_renderer_flush(struct vl_mpeg12_mc_renderer *renderer)
    if (renderer->num_macroblocks == 0)
       return;
 
-   vl_idct_unmap_buffers(&renderer->idct_luma, &renderer->idct_y);
-   vl_idct_unmap_buffers(&renderer->idct_chroma, &renderer->idct_cr);
-   vl_idct_unmap_buffers(&renderer->idct_chroma, &renderer->idct_cb);
-
    vl_idct_flush(&renderer->idct_luma, &renderer->idct_y);
    vl_idct_flush(&renderer->idct_chroma, &renderer->idct_cr);
    vl_idct_flush(&renderer->idct_chroma, &renderer->idct_cb);
 
-   vl_vb_unmap(&renderer->pos, renderer->pipe);
    vl_vb_restart(&renderer->pos);
-   for(i = 0; i < 4; ++i) {
-      vl_vb_unmap(&renderer->mv[i], renderer->pipe);
+   for(i = 0; i < 4; ++i)
       vl_vb_restart(&renderer->mv[i]);
-   }
 
    renderer->fb_state.cbufs[0] = renderer->surface;
    renderer->pipe->bind_rasterizer_state(renderer->pipe, renderer->rs_state);
@@ -1085,13 +1106,5 @@ vl_mpeg12_mc_renderer_flush(struct vl_mpeg12_mc_renderer *renderer)
 
    renderer->pipe->flush(renderer->pipe, PIPE_FLUSH_RENDER_CACHE, renderer->fence);
 
-   vl_idct_map_buffers(&renderer->idct_luma, &renderer->idct_y);
-   vl_idct_map_buffers(&renderer->idct_chroma, &renderer->idct_cr);
-   vl_idct_map_buffers(&renderer->idct_chroma, &renderer->idct_cb);
-
-   vl_vb_map(&renderer->pos, renderer->pipe);
-   for(i = 0; i < 4; ++i)
-      vl_vb_map(&renderer->mv[i], renderer->pipe);
-
    renderer->num_macroblocks = 0;
 }
index e12ac50ae0d6971ac50abefc62e96c506ee29ae4..2f35bcbcd458cd33186770d1bb9d62879d7c5cc7 100644 (file)
@@ -112,6 +112,8 @@ bool vl_mpeg12_mc_renderer_init(struct vl_mpeg12_mc_renderer *renderer,
 
 void vl_mpeg12_mc_renderer_cleanup(struct vl_mpeg12_mc_renderer *renderer);
 
+void vl_mpeg12_mc_map_buffer(struct vl_mpeg12_mc_renderer *renderer);
+
 void vl_mpeg12_mc_renderer_render_macroblocks(struct vl_mpeg12_mc_renderer *renderer,
                                               struct pipe_surface *surface,
                                               struct pipe_surface *past,
@@ -120,6 +122,8 @@ void vl_mpeg12_mc_renderer_render_macroblocks(struct vl_mpeg12_mc_renderer *rend
                                               struct pipe_mpeg12_macroblock *mpeg12_macroblocks,
                                               struct pipe_fence_handle **fence);
 
+void vl_mpeg12_mc_unmap_buffer(struct vl_mpeg12_mc_renderer *renderer);
+
 void vl_mpeg12_mc_renderer_flush(struct vl_mpeg12_mc_renderer *renderer);
 
 #endif /* vl_mpeg12_mc_renderer_h */
index 35636d8475c366556d1aec21ac05aaf605e5d39c..166c09e20bec49c598d2df6495b8cde85f3aadaf 100644 (file)
@@ -282,7 +282,9 @@ sp_mpeg12_render_picture(struct pipe_video_context     *vpipe,
    assert(dst_surface);
    assert(dst_area);
 
+   vl_mpeg12_mc_unmap_buffer(&ctx->mc_renderer);
    vl_mpeg12_mc_renderer_flush(&ctx->mc_renderer);
+   vl_mpeg12_mc_map_buffer(&ctx->mc_renderer);
 
    vl_compositor_render(&ctx->compositor, src_surface,
                         picture_type, src_area, dst_surface, dst_area, fence);
@@ -328,7 +330,9 @@ sp_mpeg12_set_decode_target(struct pipe_video_context *vpipe,
    assert(dt);
 
    if (ctx->decode_target != dt) {
+      vl_mpeg12_mc_unmap_buffer(&ctx->mc_renderer);
       vl_mpeg12_mc_renderer_flush(&ctx->mc_renderer);
+      vl_mpeg12_mc_map_buffer(&ctx->mc_renderer);
       pipe_surface_reference(&ctx->decode_target, dt);
    }
 }