[Mesa-dev] [PATCH v2] st/dri: support format queries

Varad Gautam varadgautam at gmail.com
Fri Apr 14 10:33:23 UTC 2017


From: Varad Gautam <varad.gautam at collabora.com>

ask the driver for supported dmabuf formats

v2: rebase to master.

Signed-off-by: Varad Gautam <varad.gautam at collabora.com>
---
 src/gallium/state_trackers/dri/dri2.c | 14 ++++++++++++++
 1 file changed, 14 insertions(+)

diff --git a/src/gallium/state_trackers/dri/dri2.c b/src/gallium/state_trackers/dri/dri2.c
index dcbd049..6dffb1d 100644
--- a/src/gallium/state_trackers/dri/dri2.c
+++ b/src/gallium/state_trackers/dri/dri2.c
@@ -1263,6 +1263,17 @@ dri2_from_fds(__DRIscreen *screen, int width, int height, int fourcc,
    return img;
 }
 
+static void
+dri2_query_dma_buf_formats(__DRIscreen *_screen, int max, int *formats,
+                           int *count)
+{
+   struct dri_screen *screen = dri_screen(_screen);
+   struct pipe_screen *pscreen = screen->base.screen;
+
+   if (pscreen->get_param(pscreen, PIPE_CAP_QUERY_DMABUF_ATTRIBS))
+      pscreen->query_dmabuf_formats(pscreen, max, formats, count);
+}
+
 static __DRIimage *
 dri2_from_dma_bufs(__DRIscreen *screen,
                    int width, int height, int fourcc,
@@ -1448,6 +1459,7 @@ static __DRIimageExtension dri2ImageExtension = {
     .mapImage                     = dri2_map_image,
     .unmapImage                   = dri2_unmap_image,
     .createImageFromDmaBufs2      = NULL,
+    .queryDmaBufFormats           = NULL,
 };
 
 
@@ -1994,6 +2006,7 @@ dri2_init_screen(__DRIscreen * sPriv)
          dri2ImageExtension.createImageFromFds = dri2_from_fds;
          dri2ImageExtension.createImageFromDmaBufs = dri2_from_dma_bufs;
          dri2ImageExtension.createImageFromDmaBufs2 = dri2_from_dma_bufs2;
+         dri2ImageExtension.queryDmaBufFormats = dri2_query_dma_buf_formats;
       }
    }
 
@@ -2067,6 +2080,7 @@ dri_kms_init_screen(__DRIscreen * sPriv)
       dri2ImageExtension.createImageFromFds = dri2_from_fds;
       dri2ImageExtension.createImageFromDmaBufs = dri2_from_dma_bufs;
       dri2ImageExtension.createImageFromDmaBufs2 = dri2_from_dma_bufs2;
+      dri2ImageExtension.queryDmaBufFormats = dri2_query_dma_buf_formats;
    }
 
    sPriv->extensions = dri_screen_extensions;
-- 
2.10.0



More information about the mesa-dev mailing list