radeonsi: implement pipe_context.create_video_buffer_with_modifiers

Just pass down the modifier list to vl_video_buffer_create_as_resource,
filtering out DCC modifiers because we don't support these for now.

Signed-off-by: Simon Ser <contact@emersion.fr>
Reviewed-by: Leo Liu <leo.liu@amd.com>
Reviewed-by: Marek Olšák <marek.olsak@amd.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/10237>
This commit is contained in:
Simon Ser 2021-04-09 10:31:44 +02:00 committed by Marge Bot
parent 5f101e8096
commit 4a6b87ceab
3 changed files with 35 additions and 1 deletions

View file

@ -620,6 +620,8 @@ static struct pipe_context *si_create_context(struct pipe_screen *screen, unsign
if (sscreen->info.has_hw_decode) {
sctx->b.create_video_codec = si_uvd_create_decoder;
sctx->b.create_video_buffer = si_video_buffer_create;
if (screen->resource_create_with_modifiers)
sctx->b.create_video_buffer_with_modifiers = si_video_buffer_create_with_modifiers;
} else {
sctx->b.create_video_codec = vl_create_decoder;
sctx->b.create_video_buffer = vl_video_buffer_create;

View file

@ -1586,6 +1586,10 @@ struct pipe_video_codec *si_uvd_create_decoder(struct pipe_context *context,
struct pipe_video_buffer *si_video_buffer_create(struct pipe_context *pipe,
const struct pipe_video_buffer *tmpl);
struct pipe_video_buffer *si_video_buffer_create_with_modifiers(struct pipe_context *pipe,
const struct pipe_video_buffer *tmpl,
const uint64_t *modifiers,
unsigned int modifiers_count);
/* si_viewport.c */
void si_get_small_prim_cull_info(struct si_context *sctx, struct si_small_prim_cull_info *out);

View file

@ -46,7 +46,8 @@ struct pipe_video_buffer *si_video_buffer_create(struct pipe_context *pipe,
int modifiers_count = 0;
uint64_t mod = DRM_FORMAT_MOD_LINEAR;
/* TODO: get tiling working */
/* To get tiled buffers, users need to explicitly provide a list of
* modifiers. */
vidbuf.bind |= PIPE_BIND_LINEAR;
if (pipe->screen->resource_create_with_modifiers) {
@ -58,6 +59,33 @@ struct pipe_video_buffer *si_video_buffer_create(struct pipe_context *pipe,
modifiers_count);
}
struct pipe_video_buffer *si_video_buffer_create_with_modifiers(struct pipe_context *pipe,
const struct pipe_video_buffer *tmpl,
const uint64_t *modifiers,
unsigned int modifiers_count)
{
uint64_t *allowed_modifiers;
unsigned int allowed_modifiers_count, i;
/* Filter out DCC modifiers, because we don't support them for video
* for now. */
allowed_modifiers = calloc(modifiers_count, sizeof(uint64_t));
if (!allowed_modifiers)
return NULL;
allowed_modifiers_count = 0;
for (i = 0; i < modifiers_count; i++) {
if (ac_modifier_has_dcc(modifiers[i]))
continue;
allowed_modifiers[allowed_modifiers_count++] = modifiers[i];
}
struct pipe_video_buffer *buf =
vl_video_buffer_create_as_resource(pipe, tmpl, allowed_modifiers, allowed_modifiers_count);
free(allowed_modifiers);
return buf;
}
/* set the decoding target buffer offsets */
static struct pb_buffer *si_uvd_set_dtb(struct ruvd_msg *msg, struct vl_video_buffer *buf)
{