vulkan/wsi: Refactor out wsi_init_pthread_cond_monotonic.
authorHans-Kristian Arntzen <post@arntzen-software.no>
Fri, 21 Oct 2022 13:00:32 +0000 (15:00 +0200)
committerMarge Bot <emma+marge@anholt.net>
Wed, 23 Nov 2022 19:06:12 +0000 (19:06 +0000)
Signed-off-by: Hans-Kristian Arntzen <post@arntzen-software.no>
Reviewed-by: Joshua Ashton <joshua@froggi.es>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/19279>

src/vulkan/wsi/wsi_common.c
src/vulkan/wsi/wsi_common_display.c
src/vulkan/wsi/wsi_common_private.h

index 710d0c9..ae89f55 100644 (file)
@@ -26,6 +26,7 @@
 #include "util/u_debug.h"
 #include "util/macros.h"
 #include "util/os_file.h"
+#include "util/os_time.h"
 #include "util/xmlconfig.h"
 #include "vk_device.h"
 #include "vk_fence.h"
@@ -325,6 +326,32 @@ configure_image(const struct wsi_swapchain *chain,
    }
 }
 
+#if defined(HAVE_PTHREAD) && !defined(_WIN32)
+bool
+wsi_init_pthread_cond_monotonic(pthread_cond_t *cond)
+{
+   pthread_condattr_t condattr;
+   bool ret = false;
+
+   if (pthread_condattr_init(&condattr) != 0)
+      goto fail_attr_init;
+
+   if (pthread_condattr_setclock(&condattr, CLOCK_MONOTONIC) != 0)
+      goto fail_attr_set;
+
+   if (pthread_cond_init(cond, &condattr) != 0)
+      goto fail_cond_init;
+
+   ret = true;
+
+fail_cond_init:
+fail_attr_set:
+   pthread_condattr_destroy(&condattr);
+fail_attr_init:
+   return ret;
+}
+#endif
+
 VkResult
 wsi_swapchain_init(const struct wsi_device *wsi,
                    struct wsi_swapchain *chain,
index 8dd9727..ba15993 100644 (file)
@@ -2015,31 +2015,6 @@ fail_init_images:
    return result;
 }
 
-static bool
-wsi_init_pthread_cond_monotonic(pthread_cond_t *cond)
-{
-   pthread_condattr_t condattr;
-   bool ret = false;
-
-   if (pthread_condattr_init(&condattr) != 0)
-      goto fail_attr_init;
-
-   if (pthread_condattr_setclock(&condattr, CLOCK_MONOTONIC) != 0)
-      goto fail_attr_set;
-
-   if (pthread_cond_init(cond, &condattr) != 0)
-      goto fail_cond_init;
-
-   ret = true;
-
-fail_cond_init:
-fail_attr_set:
-   pthread_condattr_destroy(&condattr);
-fail_attr_init:
-   return ret;
-}
-
-
 /*
  * Local version fo the libdrm helper. Added to avoid depending on bleeding
  * edge version of the library.
index 483b313..1b1ed13 100644 (file)
@@ -336,4 +336,9 @@ wsi_display_setup_syncobj_fd(struct wsi_device *wsi_device,
 VK_DEFINE_NONDISP_HANDLE_CASTS(wsi_swapchain, base, VkSwapchainKHR,
                                VK_OBJECT_TYPE_SWAPCHAIN_KHR)
 
+#if defined(HAVE_PTHREAD) && !defined(_WIN32)
+bool
+wsi_init_pthread_cond_monotonic(pthread_cond_t *cond);
+#endif
+
 #endif /* WSI_COMMON_PRIVATE_H */