[Mesa-dev] [PATCH 14/19] pipe-loader: generate a UUID for drm screens

Andres Rodriguez andresx7 at gmail.com
Fri Jun 30 23:03:07 UTC 2017


When loading a drm screen, also generate a UUID that can be used as a
cross API identifier.

This is useful for vulkan/opengl intertop to make check that external
objects are being imported/exported to the appropriate device.

Signed-off-by: Andres Rodriguez <andresx7 at gmail.com>
---
 src/gallium/auxiliary/pipe-loader/pipe_loader_drm.c | 11 ++++++++++-
 src/gallium/include/pipe/p_defines.h                |  1 +
 src/gallium/include/pipe/p_screen.h                 |  2 ++
 src/loader/loader.c                                 |  8 ++++++++
 src/loader/loader.h                                 |  3 +++
 5 files changed, 24 insertions(+), 1 deletion(-)

diff --git a/src/gallium/auxiliary/pipe-loader/pipe_loader_drm.c b/src/gallium/auxiliary/pipe-loader/pipe_loader_drm.c
index ef446b6..61f8529 100644
--- a/src/gallium/auxiliary/pipe-loader/pipe_loader_drm.c
+++ b/src/gallium/auxiliary/pipe-loader/pipe_loader_drm.c
@@ -39,6 +39,7 @@
 #include "target-helpers/drm_helper_public.h"
 #include "state_tracker/drm_driver.h"
 #include "pipe_loader_priv.h"
+#include "pipe/p_screen.h"
 
 #include "util/u_memory.h"
 #include "util/u_dl.h"
@@ -283,9 +284,17 @@ pipe_loader_drm_configuration(struct pipe_loader_device *dev,
 static struct pipe_screen *
 pipe_loader_drm_create_screen(struct pipe_loader_device *dev, unsigned flags)
 {
+   char *tag;
    struct pipe_loader_drm_device *ddev = pipe_loader_drm_device(dev);
+   struct pipe_screen * screen = ddev->dd->create_screen(ddev->fd, flags);
 
-   return ddev->dd->create_screen(ddev->fd, flags);
+   tag = loader_get_id_path_tag_for_fd(ddev->fd);
+   if (tag && screen) {
+      strncpy(screen->uuid, tag, sizeof(screen->uuid));
+      free(tag);
+   }
+
+   return screen;
 }
 
 static const struct pipe_loader_ops pipe_loader_drm_ops = {
diff --git a/src/gallium/include/pipe/p_defines.h b/src/gallium/include/pipe/p_defines.h
index 2ccdf44..a419c9c 100644
--- a/src/gallium/include/pipe/p_defines.h
+++ b/src/gallium/include/pipe/p_defines.h
@@ -1065,6 +1065,7 @@ enum pipe_debug_type
    PIPE_DEBUG_TYPE_CONFORMANCE,
 };
 
+#define PIPE_UUID_SIZE 16
 
 #ifdef __cplusplus
 }
diff --git a/src/gallium/include/pipe/p_screen.h b/src/gallium/include/pipe/p_screen.h
index 929dc8f..c18c41d 100644
--- a/src/gallium/include/pipe/p_screen.h
+++ b/src/gallium/include/pipe/p_screen.h
@@ -67,6 +67,8 @@ struct disk_cache;
  * context.
  */
 struct pipe_screen {
+   char uuid[PIPE_UUID_SIZE];
+
    void (*destroy)( struct pipe_screen * );
 
    const char *(*get_name)( struct pipe_screen * );
diff --git a/src/loader/loader.c b/src/loader/loader.c
index c3fc961..acf059c 100644
--- a/src/loader/loader.c
+++ b/src/loader/loader.c
@@ -307,6 +307,14 @@ loader_get_pci_id_for_fd(int fd, int *vendor_id, int *chip_id)
    return 0;
 }
 
+char *
+loader_get_id_path_tag_for_fd(int fd)
+{
+#if HAVE_LIBDRM
+   return drm_get_id_path_tag_for_fd(fd);
+#endif
+   return NULL;
+}
 
 #if defined(HAVE_LIBDRM)
 static char *
diff --git a/src/loader/loader.h b/src/loader/loader.h
index 3859b45..347567c 100644
--- a/src/loader/loader.h
+++ b/src/loader/loader.h
@@ -47,6 +47,9 @@ loader_get_driver_for_fd(int fd);
 char *
 loader_get_device_name_for_fd(int fd);
 
+char *
+loader_get_id_path_tag_for_fd(int fd);
+
 /* Function to get a different device than the one we are to use by default,
  * if the user requests so and it is possible. The initial fd will be closed
  * if necessary. The returned fd is potentially a render-node.
-- 
2.9.3



More information about the mesa-dev mailing list