g3dvl: Wrap macroblock block buffer in a pipe user buffer.
authorYounes Manton <younes.m@gmail.com>
Tue, 3 Nov 2009 03:03:09 +0000 (22:03 -0500)
committerYounes Manton <younes.m@gmail.com>
Tue, 3 Nov 2009 03:03:09 +0000 (22:03 -0500)
src/gallium/auxiliary/vl/vl_mpeg12_mc_renderer.c
src/gallium/include/pipe/p_video_state.h
src/gallium/state_trackers/xorg/xvmc/surface.c

index 6b3614821cc5134785b7ed38d2a192f5f05c1abd..bc4ab5fb3576e4d507cd679141c8fac4b8de31cd 100644 (file)
@@ -1507,6 +1507,8 @@ static void
 grab_macroblock(struct vl_mpeg12_mc_renderer *r,
                 struct pipe_mpeg12_macroblock *mb)
 {
+   void *blocks;
+
    assert(r);
    assert(mb);
    assert(r->num_macroblocks < r->macroblocks_per_batch);
@@ -1514,7 +1516,10 @@ grab_macroblock(struct vl_mpeg12_mc_renderer *r,
    memcpy(&r->macroblock_buf[r->num_macroblocks], mb,
           sizeof(struct pipe_mpeg12_macroblock));
 
-   grab_blocks(r, mb->mbx, mb->mby, mb->dct_type, mb->cbp, mb->blocks);
+   blocks = pipe_buffer_map(r->pipe->screen, mb->blocks,
+                            PIPE_BUFFER_USAGE_CPU_READ);
+   grab_blocks(r, mb->mbx, mb->mby, mb->dct_type, mb->cbp, blocks);
+   pipe_buffer_unmap(r->pipe->screen, mb->blocks);
 
    ++r->num_macroblocks;
 }
index 9ff6bdaa2b63718b8a93e5252152e209c7238997..23f2cb7427039faf30424b18ae06f29ba24b3333 100644 (file)
@@ -108,7 +108,7 @@ struct pipe_mpeg12_macroblock
    enum pipe_mpeg12_dct_type dct_type;
    signed pmv[2][2][2];
    unsigned cbp;
-   void *blocks;
+   struct pipe_buffer *blocks;
 };
 
 #if 0
index e1779eafa27d7e020859a65a90dcfcde835da701..24c413bc04df5204cfb7b81191fe1968e84b7674 100644 (file)
@@ -31,6 +31,7 @@
 #include <pipe/p_video_context.h>
 #include <pipe/p_video_state.h>
 #include <pipe/p_state.h>
+#include <pipe/p_inlines.h>
 #include <util/u_memory.h>
 #include "xvmc_private.h"
 
@@ -132,7 +133,8 @@ CreateOrResizeBackBuffer(struct vl_context *vctx, unsigned int width, unsigned i
 }
 
 static void
-MacroBlocksToPipe(const XvMCMacroBlockArray *xvmc_macroblocks,
+MacroBlocksToPipe(struct pipe_screen *screen,
+                  const XvMCMacroBlockArray *xvmc_macroblocks,
                   const XvMCBlockArray *xvmc_blocks,
                   unsigned int first_macroblock,
                   unsigned int num_macroblocks,
@@ -167,7 +169,8 @@ MacroBlocksToPipe(const XvMCMacroBlockArray *xvmc_macroblocks,
                pipe_macroblocks->pmv[j][k][l] = xvmc_mb->PMV[j][k][l];
 
       pipe_macroblocks->cbp = xvmc_mb->coded_block_pattern;
-      pipe_macroblocks->blocks = xvmc_blocks->blocks + xvmc_mb->index * BLOCK_SIZE_SAMPLES;
+      pipe_macroblocks->blocks = pipe_user_buffer_create(screen, xvmc_blocks->blocks + xvmc_mb->index * BLOCK_SIZE_SAMPLES,
+                                                         BLOCK_SIZE_BYTES);
 
       ++pipe_macroblocks;
       ++xvmc_mb;
@@ -232,6 +235,7 @@ Status XvMCRenderSurface(Display *dpy, XvMCContext *context, unsigned int pictur
    XvMCSurfacePrivate *past_surface_priv;
    XvMCSurfacePrivate *future_surface_priv;
    struct pipe_mpeg12_macroblock pipe_macroblocks[num_macroblocks];
+   unsigned int i;
 
    assert(dpy);
 
@@ -275,13 +279,16 @@ Status XvMCRenderSurface(Display *dpy, XvMCContext *context, unsigned int pictur
    p_vsfc = past_surface ? past_surface_priv->pipe_vsfc : NULL;
    f_vsfc = future_surface ? future_surface_priv->pipe_vsfc : NULL;
 
-   MacroBlocksToPipe(macroblocks, blocks, first_macroblock,
+   MacroBlocksToPipe(vpipe->screen, macroblocks, blocks, first_macroblock,
                      num_macroblocks, pipe_macroblocks);
 
    vpipe->set_decode_target(vpipe, t_vsfc);
    vpipe->decode_macroblocks(vpipe, p_vsfc, f_vsfc, num_macroblocks,
                              &pipe_macroblocks->base, target_surface_priv->render_fence);
 
+   for (i = 0; i < num_macroblocks; ++i)
+      vpipe->screen->buffer_destroy(pipe_macroblocks[i].blocks);
+
    return Success;
 }