mirror of
https://gitlab.freedesktop.org/mesa/mesa.git
synced 2026-05-06 07:18:17 +02:00
vulkan/wsi: Refactor out wsi_init_pthread_cond_monotonic.
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>
This commit is contained in:
parent
0aba2c604e
commit
339c0f6a7e
3 changed files with 32 additions and 25 deletions
|
|
@ -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,
|
||||
|
|
|
|||
|
|
@ -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.
|
||||
|
|
|
|||
|
|
@ -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 */
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue