[Mesa-dev] [PATCH 1/2] r600/uvd: fix mapping of UVD surfaces for readback
Marek Olšák
maraeo at gmail.com
Fri Oct 11 17:30:01 CEST 2013
On Wed, Oct 9, 2013 at 10:19 PM, Grigori Goronzy <greg at chown.ath.cx> wrote:
> R600_RESOURCE_FLAG_TRANSFER forces direct mapping, and reading from
> VRAM is simply too slow. VDPAU GetBitsYCbCr is unusuable. Change to
> the new PIPE_BIND_LINEAR and adjust r600_transfer_map so that it uses
> a staging texture.
> ---
> src/gallium/drivers/r600/r600_uvd.c | 6 +++---
> src/gallium/drivers/radeon/r600_texture.c | 6 ++++++
> 2 files changed, 9 insertions(+), 3 deletions(-)
>
> diff --git a/src/gallium/drivers/r600/r600_uvd.c b/src/gallium/drivers/r600/r600_uvd.c
> index 05d2ad0..300bccb 100644
> --- a/src/gallium/drivers/r600/r600_uvd.c
> +++ b/src/gallium/drivers/r600/r600_uvd.c
> @@ -77,7 +77,7 @@ struct pipe_video_buffer *r600_video_buffer_create(struct pipe_context *pipe,
>
> vl_video_buffer_template(&templ, &template, resource_formats[0], 1, array_size, PIPE_USAGE_STATIC, 0);
> if (ctx->b.chip_class < EVERGREEN || tmpl->interlaced)
> - templ.flags = R600_RESOURCE_FLAG_TRANSFER;
> + templ.bind = PIPE_BIND_LINEAR;
> resources[0] = (struct r600_texture *)
> pipe->screen->resource_create(pipe->screen, &templ);
> if (!resources[0])
> @@ -86,7 +86,7 @@ struct pipe_video_buffer *r600_video_buffer_create(struct pipe_context *pipe,
> if (resource_formats[1] != PIPE_FORMAT_NONE) {
> vl_video_buffer_template(&templ, &template, resource_formats[1], 1, array_size, PIPE_USAGE_STATIC, 1);
> if (ctx->b.chip_class < EVERGREEN || tmpl->interlaced)
> - templ.flags = R600_RESOURCE_FLAG_TRANSFER;
> + templ.bind = PIPE_BIND_LINEAR;
> resources[1] = (struct r600_texture *)
> pipe->screen->resource_create(pipe->screen, &templ);
> if (!resources[1])
> @@ -96,7 +96,7 @@ struct pipe_video_buffer *r600_video_buffer_create(struct pipe_context *pipe,
> if (resource_formats[2] != PIPE_FORMAT_NONE) {
> vl_video_buffer_template(&templ, &template, resource_formats[2], 1, array_size, PIPE_USAGE_STATIC, 2);
> if (ctx->b.chip_class < EVERGREEN || tmpl->interlaced)
> - templ.flags = R600_RESOURCE_FLAG_TRANSFER;
> + templ.bind = PIPE_BIND_LINEAR;
> resources[2] = (struct r600_texture *)
> pipe->screen->resource_create(pipe->screen, &templ);
> if (!resources[2])
> diff --git a/src/gallium/drivers/radeon/r600_texture.c b/src/gallium/drivers/radeon/r600_texture.c
> index ebb70906..2ab174a 100644
> --- a/src/gallium/drivers/radeon/r600_texture.c
> +++ b/src/gallium/drivers/radeon/r600_texture.c
> @@ -852,6 +852,12 @@ static void *r600_texture_transfer_map(struct pipe_context *ctx,
> if (rtex->surface.level[level].mode >= RADEON_SURF_MODE_1D)
> use_staging_texture = TRUE;
>
> + /* Untiled buffers likely in VRAM, which is slow for CPU reads */
> + if ((usage & PIPE_TRANSFER_READ) && !(usage & PIPE_TRANSFER_MAP_DIRECTLY) &&
> + (texture->usage & PIPE_USAGE_STATIC)) {
> + use_staging_texture = TRUE;
> + }
This is wrong. texture->usage is not a bitfield, it's a number
containing exactly one USAGE flag. Anyway, please check
r600_resource::domains instead, which is a bitfield, or you can use
the GEM_BUSY ioctl to query the actual buffer placement.
Marek
More information about the mesa-dev
mailing list