Mesa (master): gallium: dmabuf support for yuv formats that are not natively supported

GitLab Mirror gitlab-mirror at kemper.freedesktop.org
Wed Jan 22 21:40:25 UTC 2020


Module: Mesa
Branch: master
Commit: ac0219cc5b6afa6d0392a164b58e21ce95079930
URL:    http://cgit.freedesktop.org/mesa/mesa/commit/?id=ac0219cc5b6afa6d0392a164b58e21ce95079930

Author: James Xiong <james.xiong at intel.com>
Date:   Thu Jan 16 10:19:34 2020 -0800

gallium: dmabuf support for yuv formats that are not natively supported

V2 (Kenneth Graunke):
   added a helper function to check if every format is supported

Signed-off-by: James Xiong <james.xiong at intel.com>
Reviewed-by: Kenneth Graunke <kenneth at whitecape.org>
Tested-by: Marge Bot <https://gitlab.freedesktop.org/mesa/mesa/merge_requests/2846>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/merge_requests/2846>

---

 src/gallium/state_trackers/dri/dri2.c        | 15 ++++++---------
 src/gallium/state_trackers/dri/dri_helpers.c | 18 +++++++++++++++++-
 src/gallium/state_trackers/dri/dri_helpers.h |  3 +++
 3 files changed, 26 insertions(+), 10 deletions(-)

diff --git a/src/gallium/state_trackers/dri/dri2.c b/src/gallium/state_trackers/dri/dri2.c
index 82c57b78d99..05ebb4ef1d7 100644
--- a/src/gallium/state_trackers/dri/dri2.c
+++ b/src/gallium/state_trackers/dri/dri2.c
@@ -755,15 +755,7 @@ dri2_create_image_from_winsys(__DRIscreen *_screen,
        * add sampler view usage.
        */
       use_lowered = true;
-      for (i = 0; i < map->nplanes; i++) {
-          if (!pscreen->is_format_supported(pscreen,
-                                            dri2_get_pipe_format_for_dri_format(map->planes[i].dri_format),
-                                            screen->target, 0, 0,
-                                            PIPE_BIND_SAMPLER_VIEW))
-             break;
-      }
-
-      if (i == map->nplanes)
+      if (dri2_yuv_dma_buf_supported(screen, map))
          tex_usage |= PIPE_BIND_SAMPLER_VIEW;
    }
 
@@ -1407,6 +1399,11 @@ dri2_query_dma_buf_modifiers(__DRIscreen *_screen, int fourcc, int max,
       pscreen->query_dmabuf_modifiers(pscreen, format, max, modifiers,
                                       external_only, count);
       return true;
+   } else if (dri2_yuv_dma_buf_supported(screen, map)) {
+      *count = 1;
+      if (modifiers)
+         modifiers[0] = DRM_FORMAT_MOD_NONE;
+      return true;
    }
    return false;
 }
diff --git a/src/gallium/state_trackers/dri/dri_helpers.c b/src/gallium/state_trackers/dri/dri_helpers.c
index d4de8cdc59f..90a8a392fad 100644
--- a/src/gallium/state_trackers/dri/dri_helpers.c
+++ b/src/gallium/state_trackers/dri/dri_helpers.c
@@ -566,6 +566,21 @@ dri2_get_pipe_format_for_dri_format(int format)
    return PIPE_FORMAT_NONE;
 }
 
+boolean
+dri2_yuv_dma_buf_supported(struct dri_screen *screen,
+                           const struct dri2_format_mapping *map)
+{
+   struct pipe_screen *pscreen = screen->base.screen;
+
+   for (unsigned i = 0; i < map->nplanes; i++) {
+      if (!pscreen->is_format_supported(pscreen,
+            dri2_get_pipe_format_for_dri_format(map->planes[i].dri_format),
+            screen->target, 0, 0, PIPE_BIND_SAMPLER_VIEW))
+         return false;
+   }
+   return true;
+}
+
 boolean
 dri2_query_dma_buf_formats(__DRIscreen *_screen, int max, int *formats,
                            int *count)
@@ -589,7 +604,8 @@ dri2_query_dma_buf_formats(__DRIscreen *_screen, int max, int *formats,
                                        PIPE_BIND_RENDER_TARGET) ||
           pscreen->is_format_supported(pscreen, map->pipe_format,
                                        screen->target, 0, 0,
-                                       PIPE_BIND_SAMPLER_VIEW)) {
+                                       PIPE_BIND_SAMPLER_VIEW) ||
+          dri2_yuv_dma_buf_supported(screen, map)) {
          if (j < max)
             formats[j] = map->dri_fourcc;
          j++;
diff --git a/src/gallium/state_trackers/dri/dri_helpers.h b/src/gallium/state_trackers/dri/dri_helpers.h
index f0c1bbf1597..0393a48a8ee 100644
--- a/src/gallium/state_trackers/dri/dri_helpers.h
+++ b/src/gallium/state_trackers/dri/dri_helpers.h
@@ -56,6 +56,9 @@ dri2_get_pipe_format_for_dri_format(int format);
 boolean
 dri2_query_dma_buf_formats(__DRIscreen *_screen, int max, int *formats,
                            int *count);
+boolean
+dri2_yuv_dma_buf_supported(struct dri_screen *screen,
+                           const struct dri2_format_mapping *map);
 
 __DRIimage *
 dri2_lookup_egl_image(struct dri_screen *screen, void *handle);



More information about the mesa-commit mailing list