radeonsi/uvd: make format modifiers-aware
authorSimon Ser <contact@emersion.fr>
Fri, 26 Feb 2021 15:49:17 +0000 (16:49 +0100)
committerMarge Bot <eric+marge@anholt.net>
Sun, 28 Feb 2021 18:21:29 +0000 (18:21 +0000)
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>

src/gallium/auxiliary/vl/vl_video_buffer.c
src/gallium/auxiliary/vl/vl_video_buffer.h
src/gallium/drivers/radeonsi/si_uvd.c

index 54cc0c5..eb13f89 100644 (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;
 
index 2045f04..f777ddb 100644 (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 */
index 0f38cce..b6656fd 100644 (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 */