gallium/vl: add chroma_format arg to vl_video_buffer functions

vl_mpeg12_decoder needs to override the chroma_format value to get the
correct size calculated (chroma_format is used by vl_video_buffer_adjust_size).

I'm not sure why it's needed, but this is needed to get correct mpeg decode.

Fixes: 24f2b0a856 ("gallium/video: remove pipe_video_buffer.chroma_format")
Acked-by: Leo Liu <leo.liu@amd.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/6817>
This commit is contained in:
Pierre-Eric Pelloux-Prayer
2020-09-22 14:32:13 +02:00
committed by Marge Bot
parent b121b1b8b8
commit 2584d48b2c
5 changed files with 34 additions and 19 deletions

View File

@@ -983,28 +983,28 @@ init_idct(struct vl_mpeg12_decoder *dec, const struct format_config* format_conf
nr_of_idct_render_targets = 1; nr_of_idct_render_targets = 1;
formats[0] = formats[1] = formats[2] = format_config->idct_source_format; formats[0] = formats[1] = formats[2] = format_config->idct_source_format;
assert(pipe_format_to_chroma_format(formats[0]) == dec->base.chroma_format);
memset(&templat, 0, sizeof(templat)); memset(&templat, 0, sizeof(templat));
templat.width = dec->base.width / 4; templat.width = dec->base.width / 4;
templat.height = dec->base.height; templat.height = dec->base.height;
dec->idct_source = vl_video_buffer_create_ex dec->idct_source = vl_video_buffer_create_ex
( (
dec->context, &templat, dec->context, &templat,
formats, 1, 1, PIPE_USAGE_DEFAULT formats, 1, 1, PIPE_USAGE_DEFAULT,
PIPE_VIDEO_CHROMA_FORMAT_420
); );
if (!dec->idct_source) if (!dec->idct_source)
goto error_idct_source; goto error_idct_source;
formats[0] = formats[1] = formats[2] = format_config->mc_source_format; formats[0] = formats[1] = formats[2] = format_config->mc_source_format;
assert(pipe_format_to_chroma_format(formats[0]) == dec->base.chroma_format);
memset(&templat, 0, sizeof(templat)); memset(&templat, 0, sizeof(templat));
templat.width = dec->base.width / nr_of_idct_render_targets; templat.width = dec->base.width / nr_of_idct_render_targets;
templat.height = dec->base.height / 4; templat.height = dec->base.height / 4;
dec->mc_source = vl_video_buffer_create_ex dec->mc_source = vl_video_buffer_create_ex
( (
dec->context, &templat, dec->context, &templat,
formats, nr_of_idct_render_targets, 1, PIPE_USAGE_DEFAULT formats, nr_of_idct_render_targets, 1, PIPE_USAGE_DEFAULT,
PIPE_VIDEO_CHROMA_FORMAT_420
); );
if (!dec->mc_source) if (!dec->mc_source)
@@ -1055,7 +1055,8 @@ init_mc_source_widthout_idct(struct vl_mpeg12_decoder *dec, const struct format_
dec->mc_source = vl_video_buffer_create_ex dec->mc_source = vl_video_buffer_create_ex
( (
dec->context, &templat, dec->context, &templat,
formats, 1, 1, PIPE_USAGE_DEFAULT formats, 1, 1, PIPE_USAGE_DEFAULT,
PIPE_VIDEO_CHROMA_FORMAT_420
); );
return dec->mc_source != NULL; return dec->mc_source != NULL;

View File

@@ -85,7 +85,8 @@ vl_video_buffer_template(struct pipe_resource *templ,
const struct pipe_video_buffer *tmpl, const struct pipe_video_buffer *tmpl,
enum pipe_format resource_format, enum pipe_format resource_format,
unsigned depth, unsigned array_size, unsigned depth, unsigned array_size,
unsigned usage, unsigned plane) unsigned usage, unsigned plane,
enum pipe_video_chroma_format chroma_format)
{ {
assert(0); assert(0);
} }

View File

@@ -169,7 +169,8 @@ vl_video_buffer_template(struct pipe_resource *templ,
const struct pipe_video_buffer *tmpl, const struct pipe_video_buffer *tmpl,
enum pipe_format resource_format, enum pipe_format resource_format,
unsigned depth, unsigned array_size, unsigned depth, unsigned array_size,
unsigned usage, unsigned plane) unsigned usage, unsigned plane,
enum pipe_video_chroma_format chroma_format)
{ {
unsigned height = tmpl->height; unsigned height = tmpl->height;
@@ -188,7 +189,7 @@ vl_video_buffer_template(struct pipe_resource *templ,
templ->usage = usage; templ->usage = usage;
vl_video_buffer_adjust_size(&templ->width0, &height, plane, vl_video_buffer_adjust_size(&templ->width0, &height, plane,
pipe_format_to_chroma_format(tmpl->buffer_format), false); chroma_format, false);
templ->height0 = height; templ->height0 = height;
} }
@@ -372,7 +373,8 @@ vl_video_buffer_create(struct pipe_context *pipe,
result = vl_video_buffer_create_ex result = vl_video_buffer_create_ex
( (
pipe, &templat, resource_formats, pipe, &templat, resource_formats,
1, tmpl->interlaced ? 2 : 1, PIPE_USAGE_DEFAULT 1, tmpl->interlaced ? 2 : 1, PIPE_USAGE_DEFAULT,
pipe_format_to_chroma_format(templat.buffer_format)
); );
@@ -386,7 +388,8 @@ struct pipe_video_buffer *
vl_video_buffer_create_ex(struct pipe_context *pipe, vl_video_buffer_create_ex(struct pipe_context *pipe,
const struct pipe_video_buffer *tmpl, const struct pipe_video_buffer *tmpl,
const enum pipe_format resource_formats[VL_NUM_COMPONENTS], const enum pipe_format resource_formats[VL_NUM_COMPONENTS],
unsigned depth, unsigned array_size, unsigned usage) unsigned depth, unsigned array_size, unsigned usage,
enum pipe_video_chroma_format chroma_format)
{ {
struct pipe_resource res_tmpl; struct pipe_resource res_tmpl;
struct pipe_resource *resources[VL_NUM_COMPONENTS]; struct pipe_resource *resources[VL_NUM_COMPONENTS];
@@ -396,7 +399,8 @@ vl_video_buffer_create_ex(struct pipe_context *pipe,
memset(resources, 0, sizeof resources); memset(resources, 0, sizeof resources);
vl_video_buffer_template(&res_tmpl, tmpl, resource_formats[0], depth, array_size, usage, 0); vl_video_buffer_template(&res_tmpl, tmpl, resource_formats[0], depth, array_size,
usage, 0, chroma_format);
resources[0] = pipe->screen->resource_create(pipe->screen, &res_tmpl); resources[0] = pipe->screen->resource_create(pipe->screen, &res_tmpl);
if (!resources[0]) if (!resources[0])
goto error; goto error;
@@ -406,7 +410,8 @@ vl_video_buffer_create_ex(struct pipe_context *pipe,
return vl_video_buffer_create_ex2(pipe, tmpl, resources); return vl_video_buffer_create_ex2(pipe, tmpl, resources);
} }
vl_video_buffer_template(&res_tmpl, tmpl, resource_formats[1], depth, array_size, usage, 1); vl_video_buffer_template(&res_tmpl, tmpl, resource_formats[1], depth, array_size,
usage, 1, chroma_format);
resources[1] = pipe->screen->resource_create(pipe->screen, &res_tmpl); resources[1] = pipe->screen->resource_create(pipe->screen, &res_tmpl);
if (!resources[1]) if (!resources[1])
goto error; goto error;
@@ -414,7 +419,8 @@ vl_video_buffer_create_ex(struct pipe_context *pipe,
if (resource_formats[2] == PIPE_FORMAT_NONE) if (resource_formats[2] == PIPE_FORMAT_NONE)
return vl_video_buffer_create_ex2(pipe, tmpl, resources); return vl_video_buffer_create_ex2(pipe, tmpl, resources);
vl_video_buffer_template(&res_tmpl, tmpl, resource_formats[2], depth, array_size, usage, 2); vl_video_buffer_template(&res_tmpl, tmpl, resource_formats[2], depth, array_size,
usage, 2, chroma_format);
resources[2] = pipe->screen->resource_create(pipe->screen, &res_tmpl); resources[2] = pipe->screen->resource_create(pipe->screen, &res_tmpl);
if (!resources[2]) if (!resources[2])
goto error; goto error;

View File

@@ -119,7 +119,8 @@ vl_video_buffer_template(struct pipe_resource *templ,
const struct pipe_video_buffer *templat, const struct pipe_video_buffer *templat,
enum pipe_format resource_format, enum pipe_format resource_format,
unsigned depth, unsigned array_size, unsigned depth, unsigned array_size,
unsigned usage, unsigned plane); unsigned usage, unsigned plane,
enum pipe_video_chroma_format chroma_format);
/** /**
* creates a video buffer, can be used as a standard implementation for pipe->create_video_buffer * creates a video buffer, can be used as a standard implementation for pipe->create_video_buffer
@@ -135,7 +136,8 @@ struct pipe_video_buffer *
vl_video_buffer_create_ex(struct pipe_context *pipe, vl_video_buffer_create_ex(struct pipe_context *pipe,
const struct pipe_video_buffer *templat, const struct pipe_video_buffer *templat,
const enum pipe_format resource_formats[VL_NUM_COMPONENTS], const enum pipe_format resource_formats[VL_NUM_COMPONENTS],
unsigned depth, unsigned array_size, unsigned usage); unsigned depth, unsigned array_size, unsigned usage,
enum pipe_video_chroma_format chroma_format);
/** /**
* even more extended create function, provide the pipe_resource for each plane * even more extended create function, provide the pipe_resource for each plane

View File

@@ -66,6 +66,8 @@ struct pipe_video_buffer *r600_video_buffer_create(struct pipe_context *pipe,
struct pipe_video_buffer template; struct pipe_video_buffer template;
struct pipe_resource templ; struct pipe_resource templ;
unsigned i, array_size; unsigned i, array_size;
enum pipe_video_chroma_format chroma_format =
pipe_format_to_chroma_format(tmpl->buffer_format);
assert(pipe); assert(pipe);
@@ -77,7 +79,8 @@ struct pipe_video_buffer *r600_video_buffer_create(struct pipe_context *pipe,
template.width = align(tmpl->width, VL_MACROBLOCK_WIDTH); template.width = align(tmpl->width, VL_MACROBLOCK_WIDTH);
template.height = align(tmpl->height / array_size, VL_MACROBLOCK_HEIGHT); 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); vl_video_buffer_template(&templ, &template, resource_formats[0], 1, array_size,
PIPE_USAGE_DEFAULT, 0, chroma_format);
if (ctx->b.chip_class < EVERGREEN || tmpl->interlaced || !R600_UVD_ENABLE_TILING) if (ctx->b.chip_class < EVERGREEN || tmpl->interlaced || !R600_UVD_ENABLE_TILING)
templ.bind = PIPE_BIND_LINEAR; templ.bind = PIPE_BIND_LINEAR;
resources[0] = (struct r600_texture *) resources[0] = (struct r600_texture *)
@@ -86,7 +89,8 @@ struct pipe_video_buffer *r600_video_buffer_create(struct pipe_context *pipe,
goto error; goto error;
if (resource_formats[1] != PIPE_FORMAT_NONE) { if (resource_formats[1] != PIPE_FORMAT_NONE) {
vl_video_buffer_template(&templ, &template, resource_formats[1], 1, array_size, PIPE_USAGE_DEFAULT, 1); vl_video_buffer_template(&templ, &template, resource_formats[1], 1, array_size,
PIPE_USAGE_DEFAULT, 1, chroma_format);
if (ctx->b.chip_class < EVERGREEN || tmpl->interlaced || !R600_UVD_ENABLE_TILING) if (ctx->b.chip_class < EVERGREEN || tmpl->interlaced || !R600_UVD_ENABLE_TILING)
templ.bind = PIPE_BIND_LINEAR; templ.bind = PIPE_BIND_LINEAR;
resources[1] = (struct r600_texture *) resources[1] = (struct r600_texture *)
@@ -96,7 +100,8 @@ struct pipe_video_buffer *r600_video_buffer_create(struct pipe_context *pipe,
} }
if (resource_formats[2] != 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); vl_video_buffer_template(&templ, &template, resource_formats[2], 1, array_size,
PIPE_USAGE_DEFAULT, 2, chroma_format);
if (ctx->b.chip_class < EVERGREEN || tmpl->interlaced || !R600_UVD_ENABLE_TILING) if (ctx->b.chip_class < EVERGREEN || tmpl->interlaced || !R600_UVD_ENABLE_TILING)
templ.bind = PIPE_BIND_LINEAR; templ.bind = PIPE_BIND_LINEAR;
resources[2] = (struct r600_texture *) resources[2] = (struct r600_texture *)