freedreno: add query for dmabuf modifiers
authorFritz Koenig <frkoenig@google.com>
Fri, 2 Nov 2018 00:08:39 +0000 (17:08 -0700)
committerRob Clark <robdclark@gmail.com>
Tue, 22 Jan 2019 21:33:27 +0000 (16:33 -0500)
src/gallium/drivers/freedreno/freedreno_screen.c
src/gallium/drivers/freedreno/freedreno_screen.h

index e59922cba473c192dbae9d85e640b387634f1691..b372d5c5596182e69347bff2140bff621b8a818a 100644 (file)
@@ -39,6 +39,7 @@
 
 #include "util/os_time.h"
 
+#include <drm_fourcc.h>
 #include <errno.h>
 #include <stdio.h>
 #include <stdlib.h>
@@ -654,6 +655,37 @@ fd_screen_bo_get_handle(struct pipe_screen *pscreen,
        }
 }
 
+static void
+fd_screen_query_dmabuf_modifiers(struct pipe_screen *pscreen,
+               enum pipe_format format,
+               int max, uint64_t *modifiers,
+               unsigned int *external_only,
+               int *count)
+{
+       struct fd_screen *screen = fd_screen(pscreen);
+       int i, num = 0;
+
+       max = MIN2(max, screen->num_supported_modifiers);
+
+       if (!max) {
+               max = screen->num_supported_modifiers;
+               external_only = NULL;
+               modifiers = NULL;
+       }
+
+       for (i = 0; i < max; i++) {
+               if (modifiers)
+                       modifiers[num] = screen->supported_modifiers[i];
+
+               if (external_only)
+                       external_only[num] = 0;
+
+               num++;
+       }
+
+       *count = num;
+}
+
 struct fd_bo *
 fd_screen_bo_from_handle(struct pipe_screen *pscreen,
                struct winsys_handle *whandle)
@@ -853,6 +885,17 @@ fd_screen_create(struct fd_device *dev)
        pscreen->fence_finish = fd_fence_finish;
        pscreen->fence_get_fd = fd_fence_get_fd;
 
+       pscreen->query_dmabuf_modifiers = fd_screen_query_dmabuf_modifiers;
+
+       if (!screen->supported_modifiers) {
+               static const uint64_t supported_modifiers[] = {
+                       DRM_FORMAT_MOD_LINEAR,
+               };
+
+               screen->supported_modifiers = supported_modifiers;
+               screen->num_supported_modifiers = ARRAY_SIZE(supported_modifiers);
+       }
+
        slab_create_parent(&screen->transfer_pool, sizeof(struct fd_transfer), 16);
 
        return pscreen;
index fedb8ffc9063d17414835f0a41f64ace93f63bb8..243770ffd900ef13306d565e0311f92e25686fc0 100644 (file)
@@ -97,6 +97,9 @@ struct fd_screen {
        bool reorder;
 
        uint16_t rsc_seqno;
+
+       unsigned num_supported_modifiers;
+       const uint64_t *supported_modifiers;
 };
 
 static inline struct fd_screen *