From f1bbd41e326ce7a90e9b5956195203eee537cbc7 Mon Sep 17 00:00:00 2001 From: Younes Manton Date: Fri, 12 Mar 2010 13:36:52 -0500 Subject: [PATCH] vl: Don't wrap blocks in pipe_user_buffers. Mallocing/free eat up a noticeable amount of CPU time for no practical benefit. --- .../auxiliary/vl/vl_mpeg12_mc_renderer.c | 22 ++++++++++--------- src/gallium/include/pipe/p_video_state.h | 2 +- .../state_trackers/xorg/xvmc/surface.c | 6 +---- 3 files changed, 14 insertions(+), 16 deletions(-) diff --git a/src/gallium/auxiliary/vl/vl_mpeg12_mc_renderer.c b/src/gallium/auxiliary/vl/vl_mpeg12_mc_renderer.c index 2e611fca96b..769ee38c46b 100644 --- a/src/gallium/auxiliary/vl/vl_mpeg12_mc_renderer.c +++ b/src/gallium/auxiliary/vl/vl_mpeg12_mc_renderer.c @@ -1235,19 +1235,15 @@ static void grab_macroblock(struct vl_mpeg12_mc_renderer *r, struct pipe_mpeg12_macroblock *mb) { - void *blocks; - assert(r); assert(mb); + assert(mb->blocks); assert(r->num_macroblocks < r->macroblocks_per_batch); memcpy(&r->macroblock_buf[r->num_macroblocks], mb, sizeof(struct pipe_mpeg12_macroblock)); - 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); + grab_blocks(r, mb->mbx, mb->mby, mb->dct_type, mb->cbp, mb->blocks); ++r->num_macroblocks; } @@ -1318,6 +1314,10 @@ vl_mpeg12_mc_renderer_cleanup(struct vl_mpeg12_mc_renderer *renderer) cleanup_pipe_state(renderer); cleanup_shaders(renderer); cleanup_buffers(renderer); + + pipe_surface_reference(&renderer->surface, NULL); + pipe_surface_reference(&renderer->past, NULL); + pipe_surface_reference(&renderer->future, NULL); } void @@ -1356,9 +1356,9 @@ vl_mpeg12_mc_renderer_render_macroblocks(struct vl_mpeg12_mc_renderer new_surface = true; if (new_surface) { - renderer->surface = surface; - renderer->past = past; - renderer->future = future; + pipe_surface_reference(&renderer->surface, surface); + pipe_surface_reference(&renderer->past, past); + pipe_surface_reference(&renderer->future, future); renderer->fence = fence; renderer->surface_tex_inv_size.x = 1.0f / surface->width; renderer->surface_tex_inv_size.y = 1.0f / surface->height; @@ -1381,7 +1381,9 @@ vl_mpeg12_mc_renderer_render_macroblocks(struct vl_mpeg12_mc_renderer flush(renderer); xfer_buffers_map(renderer); /* Next time we get this surface it may have new ref frames */ - renderer->surface = NULL; + pipe_surface_reference(&renderer->surface, NULL); + pipe_surface_reference(&renderer->past, NULL); + pipe_surface_reference(&renderer->future, NULL); } } } diff --git a/src/gallium/include/pipe/p_video_state.h b/src/gallium/include/pipe/p_video_state.h index 79ce174701b..5eb96352139 100644 --- a/src/gallium/include/pipe/p_video_state.h +++ b/src/gallium/include/pipe/p_video_state.h @@ -90,7 +90,7 @@ struct pipe_mpeg12_macroblock enum pipe_mpeg12_dct_type dct_type; signed pmv[2][2][2]; unsigned cbp; - struct pipe_buffer *blocks; + short *blocks; }; #if 0 diff --git a/src/gallium/state_trackers/xorg/xvmc/surface.c b/src/gallium/state_trackers/xorg/xvmc/surface.c index a2d71b5c14e..d2c4e5f19ca 100644 --- a/src/gallium/state_trackers/xorg/xvmc/surface.c +++ b/src/gallium/state_trackers/xorg/xvmc/surface.c @@ -178,8 +178,7 @@ MacroBlocksToPipe(struct pipe_screen *screen, pipe_macroblocks->pmv[j][k][l] = xvmc_mb->PMV[j][k][l]; pipe_macroblocks->cbp = xvmc_mb->coded_block_pattern; - pipe_macroblocks->blocks = pipe_user_buffer_create(screen, xvmc_blocks->blocks + xvmc_mb->index * BLOCK_SIZE_SAMPLES, - BLOCK_SIZE_BYTES); + pipe_macroblocks->blocks = xvmc_blocks->blocks + xvmc_mb->index * BLOCK_SIZE_SAMPLES; ++pipe_macroblocks; ++xvmc_mb; @@ -320,9 +319,6 @@ Status XvMCRenderSurface(Display *dpy, XvMCContext *context, unsigned int pictur 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); - XVMC_MSG(XVMC_TRACE, "[XvMC] Submitted surface %p for rendering.\n", target_surface); return Success; -- 2.30.2