freedreno: Centralize UUID generation into new files freedreno_uuid.c/h
authorEduardo Lima Mitev <elima@igalia.com>
Thu, 9 Apr 2020 10:56:08 +0000 (12:56 +0200)
committerMarge Bot <eric+marge@anholt.net>
Thu, 14 May 2020 19:05:02 +0000 (19:05 +0000)
The new files are created under a 'common' folder under 'src/freedreno',
where shared functionality between GL and Vulkan drivers (that is not
registers, layout or compiler) will be placed.

Reviewed-by: Rob Clark <robdclark@chromium.org>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/4847>

src/freedreno/common/README.rst [new file with mode: 0644]
src/freedreno/common/freedreno_uuid.c [new file with mode: 0644]
src/freedreno/common/freedreno_uuid.h [new file with mode: 0644]
src/freedreno/common/meson.build [new file with mode: 0644]
src/freedreno/meson.build
src/freedreno/vulkan/meson.build
src/freedreno/vulkan/tu_device.c

diff --git a/src/freedreno/common/README.rst b/src/freedreno/common/README.rst
new file mode 100644 (file)
index 0000000..7d07ba4
--- /dev/null
@@ -0,0 +1,5 @@
+Overview
+========
+
+Common functionality shared between freedreno drivers (that are not
+registers, layout or the compiler), e.g UUID generation.
diff --git a/src/freedreno/common/freedreno_uuid.c b/src/freedreno/common/freedreno_uuid.c
new file mode 100644 (file)
index 0000000..c84c90d
--- /dev/null
@@ -0,0 +1,42 @@
+/*
+ * Copyright © 2020 Igalia S.L.
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a
+ * copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice (including the next
+ * paragraph) shall be included in all copies or substantial portions of the
+ * Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO EVENT SHALL
+ * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+ * SOFTWARE.
+ */
+
+#include "freedreno_uuid.h"
+#include <stdio.h>
+#include <string.h>
+
+/* (Re)define UUID_SIZE to avoid including vulkan.h (or p_defines.h) here. */
+#define UUID_SIZE 16
+
+void
+fd_get_driver_uuid(void *uuid)
+{
+       memset(uuid, 0, UUID_SIZE);
+       snprintf(uuid, UUID_SIZE, "freedreno");
+}
+
+void
+fd_get_device_uuid(void *uuid)
+{
+       memset(uuid, 0, UUID_SIZE);
+}
diff --git a/src/freedreno/common/freedreno_uuid.h b/src/freedreno/common/freedreno_uuid.h
new file mode 100644 (file)
index 0000000..c4f2321
--- /dev/null
@@ -0,0 +1,30 @@
+/*
+ * Copyright © 2020 Igalia S.L.
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a
+ * copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice (including the next
+ * paragraph) shall be included in all copies or substantial portions of the
+ * Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO EVENT SHALL
+ * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+ * SOFTWARE.
+ */
+
+#ifndef __FREEDRENO_UUID_H__
+#define __FREEDRENO_UUID_H__
+
+void fd_get_driver_uuid(void *uuid);
+void fd_get_device_uuid(void *uuid);
+
+#endif /* __FREEDRENO_UUID_H__ */
diff --git a/src/freedreno/common/meson.build b/src/freedreno/common/meson.build
new file mode 100644 (file)
index 0000000..5c83a81
--- /dev/null
@@ -0,0 +1,35 @@
+# Copyright © 2020 Igalia S.L
+
+# Permission is hereby granted, free of charge, to any person obtaining a copy
+# of this software and associated documentation files (the "Software"), to deal
+# in the Software without restriction, including without limitation the rights
+# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+# copies of the Software, and to permit persons to whom the Software is
+# furnished to do so, subject to the following conditions:
+
+# The above copyright notice and this permission notice shall be included in
+# all copies or substantial portions of the Software.
+
+# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+# SOFTWARE.
+
+libfreedreno_common = static_library(
+  'freedreno_common',
+  [
+    'freedreno_uuid.c',
+    'freedreno_uuid.h',
+  ],
+  include_directories : [inc_freedreno],
+  c_args : [c_vis_args, no_override_init_args],
+  build_by_default : true,
+  dependencies: [idep_mesautil]
+)
+
+idep_libfreedreno_common = declare_dependency(
+  link_with: [libfreedreno_common],
+)
index 942fa3c444d71c2dc6071fa198d944e1cb0cd333..12d787fd75b84d451406dfd8f057c718c499f7c6 100644 (file)
@@ -20,6 +20,7 @@
 
 inc_freedreno = include_directories(['.', './registers'])
 
+subdir('common')
 subdir('registers')
 subdir('drm')
 subdir('ir3')
index 2510b161c658f03484378346037f21bcd874e57b..bafce3d06d77cefacf795479818d0823b43566d6 100644 (file)
@@ -118,6 +118,7 @@ libvulkan_freedreno = shared_library(
     libfreedreno_layout,
   ],
   dependencies : [
+    idep_libfreedreno_common,
     dep_dl,
     dep_elf,
     dep_libdrm,
index 3e685e0518eee5e37bf7055bc3ca54d90a00fa42..6d1a885bebcd642ef6482d43cfb0dacf5df4422a 100644 (file)
@@ -45,6 +45,9 @@
 
 #include "drm-uapi/msm_drm.h"
 
+/* for fd_get_driver/device_uuid() */
+#include "freedreno/common/freedreno_uuid.h"
+
 static int
 tu_device_get_cache_uuid(uint16_t family, void *uuid)
 {
@@ -61,19 +64,6 @@ tu_device_get_cache_uuid(uint16_t family, void *uuid)
    return 0;
 }
 
-static void
-tu_get_driver_uuid(void *uuid)
-{
-   memset(uuid, 0, VK_UUID_SIZE);
-   snprintf(uuid, VK_UUID_SIZE, "freedreno");
-}
-
-static void
-tu_get_device_uuid(void *uuid)
-{
-   memset(uuid, 0, VK_UUID_SIZE);
-}
-
 static VkResult
 tu_bo_init(struct tu_device *dev,
            struct tu_bo *bo,
@@ -308,8 +298,8 @@ tu_physical_device_init(struct tu_physical_device *device,
    fprintf(stderr, "WARNING: tu is not a conformant vulkan implementation, "
                    "testing use only.\n");
 
-   tu_get_driver_uuid(&device->device_uuid);
-   tu_get_device_uuid(&device->device_uuid);
+   fd_get_driver_uuid(device->driver_uuid);
+   fd_get_device_uuid(device->device_uuid);
 
    tu_physical_device_get_supported_extensions(device, &device->supported_extensions);