diff options
author | Benedikt Schemmer <[email protected]> | 2017-09-29 21:02:13 +0200 |
---|---|---|
committer | Marek Olšák <[email protected]> | 2017-09-30 19:03:07 +0200 |
commit | 3797a82e785a433245a679b5ad3f84f614380c72 (patch) | |
tree | 171d4b04ede8c7f6ebaf29299ccf242d64445fba | |
parent | e9cf64a67cac9cac34d17fcfc220f5e431c048c0 (diff) |
radeonsi/uvd: clean up si_video_buffer_create
V2: remove code duplication and one unnessecary variable, minor whitespace fix
Signed-off-by: Marek Olšák <[email protected]>
-rw-r--r-- | src/gallium/drivers/radeonsi/si_uvd.c | 47 |
1 files changed, 17 insertions, 30 deletions
diff --git a/src/gallium/drivers/radeonsi/si_uvd.c b/src/gallium/drivers/radeonsi/si_uvd.c index 1a38b26451e..21582d130b4 100644 --- a/src/gallium/drivers/radeonsi/si_uvd.c +++ b/src/gallium/drivers/radeonsi/si_uvd.c @@ -64,35 +64,22 @@ 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 */ - /* Set PIPE_BIND_SHARED to avoid reallocation in r600_texture_get_handle, - * which can't handle joined surfaces. */ - unsigned bind = PIPE_BIND_LINEAR | PIPE_BIND_SHARED; - - templ.bind = bind; - 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 = bind; - resources[1] = (struct r600_texture *) - pipe->screen->resource_create(pipe->screen, &templ); - if (!resources[1]) - goto error; - } + assert(resource_formats[0] != PIPE_FORMAT_NONE); - 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 = bind; - 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) { + 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. */ + /* TODO: get tiling working */ + 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; + } } for (i = 0; i < VL_NUM_COMPONENTS; ++i) { @@ -164,8 +151,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); |