From 4dfdcdb4b394df72da769806a0b64025e475f8b3 Mon Sep 17 00:00:00 2001 From: =?utf8?q?Christian=20K=C3=B6nig?= Date: Thu, 11 Sep 2014 09:38:50 +0200 Subject: [PATCH] radeon/video: use the hw to initial clear the buffers MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit Less CPU overhead and avoids contention over CPU accessible memory on startup. Signed-off-by: Christian König Reviewed-by: Michel Dänzer --- src/gallium/drivers/radeon/radeon_uvd.c | 6 +++--- src/gallium/drivers/radeon/radeon_video.c | 10 ++++------ src/gallium/drivers/radeon/radeon_video.h | 2 +- 3 files changed, 8 insertions(+), 10 deletions(-) diff --git a/src/gallium/drivers/radeon/radeon_uvd.c b/src/gallium/drivers/radeon/radeon_uvd.c index 6ad2d2476f3..69f5cdc6a57 100644 --- a/src/gallium/drivers/radeon/radeon_uvd.c +++ b/src/gallium/drivers/radeon/radeon_uvd.c @@ -830,8 +830,8 @@ struct pipe_video_codec *ruvd_create_decoder(struct pipe_context *context, goto error; } - rvid_clear_buffer(dec->ws, dec->cs, &dec->msg_fb_buffers[i]); - rvid_clear_buffer(dec->ws, dec->cs, &dec->bs_buffers[i]); + rvid_clear_buffer(context, &dec->msg_fb_buffers[i]); + rvid_clear_buffer(context, &dec->bs_buffers[i]); } if (!rvid_create_buffer(dec->screen, &dec->dpb, dpb_size, PIPE_USAGE_DEFAULT)) { @@ -839,7 +839,7 @@ struct pipe_video_codec *ruvd_create_decoder(struct pipe_context *context, goto error; } - rvid_clear_buffer(dec->ws, dec->cs, &dec->dpb); + rvid_clear_buffer(context, &dec->dpb); map_msg_fb_buf(dec); dec->msg->size = sizeof(*dec->msg); diff --git a/src/gallium/drivers/radeon/radeon_video.c b/src/gallium/drivers/radeon/radeon_video.c index 0bc43907005..f6cfdff7aa2 100644 --- a/src/gallium/drivers/radeon/radeon_video.c +++ b/src/gallium/drivers/radeon/radeon_video.c @@ -118,14 +118,12 @@ error: } /* clear the buffer with zeros */ -void rvid_clear_buffer(struct radeon_winsys *ws, struct radeon_winsys_cs *cs, struct rvid_buffer* buffer) +void rvid_clear_buffer(struct pipe_context *context, struct rvid_buffer* buffer) { - void *ptr = ws->buffer_map(buffer->res->cs_buf, cs, PIPE_TRANSFER_WRITE); - if (!ptr) - return; + struct r600_common_context *rctx = (struct r600_common_context*)context; - memset(ptr, 0, buffer->res->buf->size); - ws->buffer_unmap(buffer->res->cs_buf); + rctx->clear_buffer(context, &buffer->res->b.b, 0, buffer->res->buf->size, 0); + context->flush(context, NULL, 0); } /** diff --git a/src/gallium/drivers/radeon/radeon_video.h b/src/gallium/drivers/radeon/radeon_video.h index fe3088a0b96..974ea4f47be 100644 --- a/src/gallium/drivers/radeon/radeon_video.h +++ b/src/gallium/drivers/radeon/radeon_video.h @@ -62,7 +62,7 @@ bool rvid_resize_buffer(struct pipe_screen *screen, struct radeon_winsys_cs *cs, struct rvid_buffer *new_buf, unsigned new_size); /* clear the buffer with zeros */ -void rvid_clear_buffer(struct radeon_winsys *ws, struct radeon_winsys_cs *cs, struct rvid_buffer* buffer); +void rvid_clear_buffer(struct pipe_context *context, struct rvid_buffer* buffer); /* join surfaces into the same buffer with identical tiling params sumup their sizes and replace the backend buffers with a single bo */ -- 2.30.2