[Mesa-dev] [PATCH V2] radeonsi/uvd: fix planar formats broken since f70f6baaa3bb0f8b280ac2eaea69bb
Christian König
ckoenig.leichtzumerken at gmail.com
Sat Sep 30 08:53:31 UTC 2017
Am 29.09.2017 um 21:09 schrieb Benedikt Schemmer:
> From: Benedikt Schemmer <ben at besd.de>
> Date: Fri, 29 Sep 2017 21:02:13 +0200
> Subject: [PATCH V2] radeonsi/uvd: fix planar formats broken since f70f6baaa3bb0f8b280ac2eaea69bb
>
> V2: remove code duplication and one unnessecary variable, minor whitespace fix
>
> ---
> src/gallium/drivers/radeonsi/si_uvd.c | 40 +++++++++++++----------------------
> 1 file changed, 15 insertions(+), 25 deletions(-)
>
> diff --git a/src/gallium/drivers/radeonsi/si_uvd.c b/src/gallium/drivers/radeonsi/si_uvd.c
> index 4e8250664c..c2925ef9cd 100644
> --- a/src/gallium/drivers/radeonsi/si_uvd.c
> +++ b/src/gallium/drivers/radeonsi/si_uvd.c
> @@ -64,30 +64,20 @@ struct pipe_video_buffer *si_video_buffer_create(struct pipe_context *pipe,
> template.width = align(tmpl->width, VL_MACROBLOCK_WIDTH);
> template.height = align(tmpl->height / array_size, VL_MACROBLOCK_HEIGHT);
>
> - vl_video_buffer_template(&templ, &template, resource_formats[0], 1, array_size, PIPE_USAGE_DEFAULT, 0);
> /* TODO: get tiling working */
> - templ.bind = PIPE_BIND_LINEAR;
> - resources[0] = (struct r600_texture *)
> - pipe->screen->resource_create(pipe->screen, &templ);
> - if (!resources[0])
> - goto error;
> -
> - if (resource_formats[1] != PIPE_FORMAT_NONE) {
> - vl_video_buffer_template(&templ, &template, resource_formats[1], 1, array_size, PIPE_USAGE_DEFAULT, 1);
> - templ.bind = PIPE_BIND_LINEAR;
> - resources[1] = (struct r600_texture *)
> - pipe->screen->resource_create(pipe->screen, &templ);
> - if (!resources[1])
> - goto error;
> - }
> -
> - if (resource_formats[2] != PIPE_FORMAT_NONE) {
> - vl_video_buffer_template(&templ, &template, resource_formats[2], 1, array_size, PIPE_USAGE_DEFAULT, 2);
> - templ.bind = PIPE_BIND_LINEAR;
> - resources[2] = (struct r600_texture *)
> - pipe->screen->resource_create(pipe->screen, &templ);
> - if (!resources[2])
> - goto error;
> +
> + for (i = 0; i < VL_NUM_COMPONENTS; ++i) {
> + if (resource_formats[i] != PIPE_FORMAT_NONE) {
It should be handled as an error if resource_formats[0] is PIPE_FORMAT_NONE.
Better write this as:
if (resource_formats[i] == PIPE_FORMAT_NONE) {
if (i == 0)
gotot error;
continue;
}
...
> + vl_video_buffer_template(&templ, &template,
> + resource_formats[i], 1,
> + array_size, PIPE_USAGE_DEFAULT, i);
> + /* Set PIPE_BIND_SHARED to avoid reallocation in r600_texture_get_handle,
> + * which can't handle joined surfaces. */
> + templ.bind = PIPE_BIND_LINEAR | PIPE_BIND_SHARED;
> + resources[i] = (struct r600_texture *)
> + pipe->screen->resource_create(pipe->screen, &templ);
> + if (!resources[i]) goto error;
The "goto error" should be on a new line.
> + }
> }
>
> for (i = 0; i < VL_NUM_COMPONENTS; ++i) {
> @@ -159,8 +149,8 @@ struct pipe_video_codec *si_uvd_create_decoder(struct pipe_context *context,
> struct si_context *ctx = (struct si_context *)context;
> bool vcn = (ctx->b.family == CHIP_RAVEN) ? true : false;
>
> - if (templ->entrypoint == PIPE_VIDEO_ENTRYPOINT_ENCODE)
> - return si_vce_create_encoder(context, templ, ctx->b.ws, si_vce_get_buffer);
> + if (templ->entrypoint == PIPE_VIDEO_ENTRYPOINT_ENCODE)
> + return si_vce_create_encoder(context, templ, ctx->b.ws, si_vce_get_buffer);
>
> return (vcn) ? radeon_create_decoder(context, templ) :
> si_common_uvd_create_decoder(context, templ, si_uvd_set_dtb);
More information about the mesa-dev
mailing list