From 9623debf48ae7dbea120389eae40d784d22eee24 Mon Sep 17 00:00:00 2001 From: Eduardo Lima Mitev Date: Thu, 9 Apr 2020 12:56:08 +0200 Subject: [PATCH] freedreno: Centralize UUID generation into new files freedreno_uuid.c/h 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 Part-of: --- src/freedreno/common/README.rst | 5 ++++ src/freedreno/common/freedreno_uuid.c | 42 +++++++++++++++++++++++++++ src/freedreno/common/freedreno_uuid.h | 30 +++++++++++++++++++ src/freedreno/common/meson.build | 35 ++++++++++++++++++++++ src/freedreno/meson.build | 1 + src/freedreno/vulkan/meson.build | 1 + src/freedreno/vulkan/tu_device.c | 20 ++++--------- 7 files changed, 119 insertions(+), 15 deletions(-) create mode 100644 src/freedreno/common/README.rst create mode 100644 src/freedreno/common/freedreno_uuid.c create mode 100644 src/freedreno/common/freedreno_uuid.h create mode 100644 src/freedreno/common/meson.build diff --git a/src/freedreno/common/README.rst b/src/freedreno/common/README.rst new file mode 100644 index 00000000000..7d07ba491de --- /dev/null +++ b/src/freedreno/common/README.rst @@ -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 index 00000000000..c84c90db181 --- /dev/null +++ b/src/freedreno/common/freedreno_uuid.c @@ -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 +#include + +/* (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 index 00000000000..c4f232117c8 --- /dev/null +++ b/src/freedreno/common/freedreno_uuid.h @@ -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 index 00000000000..5c83a819120 --- /dev/null +++ b/src/freedreno/common/meson.build @@ -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], +) diff --git a/src/freedreno/meson.build b/src/freedreno/meson.build index 942fa3c444d..12d787fd75b 100644 --- a/src/freedreno/meson.build +++ b/src/freedreno/meson.build @@ -20,6 +20,7 @@ inc_freedreno = include_directories(['.', './registers']) +subdir('common') subdir('registers') subdir('drm') subdir('ir3') diff --git a/src/freedreno/vulkan/meson.build b/src/freedreno/vulkan/meson.build index 2510b161c65..bafce3d06d7 100644 --- a/src/freedreno/vulkan/meson.build +++ b/src/freedreno/vulkan/meson.build @@ -118,6 +118,7 @@ libvulkan_freedreno = shared_library( libfreedreno_layout, ], dependencies : [ + idep_libfreedreno_common, dep_dl, dep_elf, dep_libdrm, diff --git a/src/freedreno/vulkan/tu_device.c b/src/freedreno/vulkan/tu_device.c index 3e685e0518e..6d1a885bebc 100644 --- a/src/freedreno/vulkan/tu_device.c +++ b/src/freedreno/vulkan/tu_device.c @@ -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); -- 2.30.2