radeonsi/uvd: make format modifiers-aware

When format modifiers are supported, use
resource_create_with_modifiers instead of resource_create. This
allows radeonsi to set the modifier field, and allows VA-API
clients to have a proper modifier instead of
DRM_FORMAT_MOD_INVALID.

Signed-off-by: Simon Ser <contact@emersion.fr>
Reviewed-by: Bas Nieuwenhuizen <bas@basnieuwenhuizen.nl>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/9308>
This commit is contained in:
Simon Ser 2021-02-26 16:49:17 +01:00 committed by Marge Bot
parent f1207229f9
commit 364857ffe8
3 changed files with 24 additions and 4 deletions

View File

@ -466,7 +466,9 @@ vl_video_buffer_create_ex2(struct pipe_context *pipe,
/* Create pipe_video_buffer by using resource_create with planar formats. */
struct pipe_video_buffer *
vl_video_buffer_create_as_resource(struct pipe_context *pipe,
const struct pipe_video_buffer *tmpl)
const struct pipe_video_buffer *tmpl,
const uint64_t *modifiers,
int modifiers_count)
{
struct pipe_resource templ, *resources[VL_NUM_COMPONENTS] = {0};
unsigned array_size = tmpl->interlaced ? 2 : 1;
@ -487,7 +489,12 @@ vl_video_buffer_create_as_resource(struct pipe_context *pipe,
else
templ.format = tmpl->buffer_format;
resources[0] = pipe->screen->resource_create(pipe->screen, &templ);
if (modifiers)
resources[0] = pipe->screen->resource_create_with_modifiers(pipe->screen,
&templ, modifiers,
modifiers_count);
else
resources[0] = pipe->screen->resource_create(pipe->screen, &templ);
if (!resources[0])
return NULL;

View File

@ -150,6 +150,8 @@ vl_video_buffer_create_ex2(struct pipe_context *pipe,
/* Create pipe_video_buffer by using resource_create with planar formats. */
struct pipe_video_buffer *
vl_video_buffer_create_as_resource(struct pipe_context *pipe,
const struct pipe_video_buffer *tmpl);
const struct pipe_video_buffer *tmpl,
const uint64_t *modifiers,
int modifiers_count);
#endif /* vl_video_buffer_h */

View File

@ -25,6 +25,7 @@
*
**************************************************************************/
#include "drm-uapi/drm_fourcc.h"
#include "radeon/radeon_uvd.h"
#include "radeon/radeon_uvd_enc.h"
#include "radeon/radeon_vce.h"
@ -41,10 +42,20 @@ struct pipe_video_buffer *si_video_buffer_create(struct pipe_context *pipe,
const struct pipe_video_buffer *tmpl)
{
struct pipe_video_buffer vidbuf = *tmpl;
uint64_t *modifiers = NULL;
int modifiers_count = 0;
uint64_t mod = DRM_FORMAT_MOD_LINEAR;
/* TODO: get tiling working */
vidbuf.bind |= PIPE_BIND_LINEAR;
return vl_video_buffer_create_as_resource(pipe, &vidbuf);
if (pipe->screen->resource_create_with_modifiers) {
modifiers = &mod;
modifiers_count = 1;
}
return vl_video_buffer_create_as_resource(pipe, &vidbuf, modifiers,
modifiers_count);
}
/* set the decoding target buffer offsets */