From 142d7b0f360d003d6c3914b198fb37e3e6b4a6cc Mon Sep 17 00:00:00 2001 From: James Park Date: Thu, 26 Nov 2020 19:42:19 -0800 Subject: [PATCH] vulkan: Replace pthread mutex with mtx_t Reviewed-by: Samuel Pitoiset Part-of: --- src/vulkan/util/vk_debug_report.c | 16 ++++++++-------- src/vulkan/util/vk_debug_report.h | 5 ++--- 2 files changed, 10 insertions(+), 11 deletions(-) diff --git a/src/vulkan/util/vk_debug_report.c b/src/vulkan/util/vk_debug_report.c index 78dcfa6..4673e9a 100644 --- a/src/vulkan/util/vk_debug_report.c +++ b/src/vulkan/util/vk_debug_report.c @@ -28,7 +28,7 @@ VkResult vk_debug_report_instance_init(struct vk_debug_report_instance *instance) { - if (pthread_mutex_init(&instance->callbacks_mutex, NULL) != 0) { + if (mtx_init(&instance->callbacks_mutex, mtx_plain) != 0) { return VK_ERROR_INITIALIZATION_FAILED; } @@ -39,7 +39,7 @@ VkResult vk_debug_report_instance_init(struct vk_debug_report_instance *instance void vk_debug_report_instance_destroy(struct vk_debug_report_instance *instance) { - pthread_mutex_destroy(&instance->callbacks_mutex); + mtx_destroy(&instance->callbacks_mutex); } VkResult @@ -62,9 +62,9 @@ vk_create_debug_report_callback(struct vk_debug_report_instance *instance, cb->callback = pCreateInfo->pfnCallback; cb->data = pCreateInfo->pUserData; - pthread_mutex_lock(&instance->callbacks_mutex); + mtx_lock(&instance->callbacks_mutex); list_addtail(&cb->link, &instance->callbacks); - pthread_mutex_unlock(&instance->callbacks_mutex); + mtx_unlock(&instance->callbacks_mutex); *pCallback = (VkDebugReportCallbackEXT)(uintptr_t)cb; @@ -84,10 +84,10 @@ vk_destroy_debug_report_callback(struct vk_debug_report_instance *instance, (struct vk_debug_report_callback *)(uintptr_t)_callback; /* Remove from list and destroy given callback. */ - pthread_mutex_lock(&instance->callbacks_mutex); + mtx_lock(&instance->callbacks_mutex); list_del(&callback->link); vk_free2(instance_allocator, pAllocator, callback); - pthread_mutex_unlock(&instance->callbacks_mutex); + mtx_unlock(&instance->callbacks_mutex); } @@ -105,7 +105,7 @@ vk_debug_report(struct vk_debug_report_instance *instance, if (!instance || list_is_empty(&instance->callbacks)) return; - pthread_mutex_lock(&instance->callbacks_mutex); + mtx_lock(&instance->callbacks_mutex); /* Section 33.2 of the Vulkan 1.0.59 spec says: * @@ -121,5 +121,5 @@ vk_debug_report(struct vk_debug_report_instance *instance, pLayerPrefix, pMessage, cb->data); } - pthread_mutex_unlock(&instance->callbacks_mutex); + mtx_unlock(&instance->callbacks_mutex); } diff --git a/src/vulkan/util/vk_debug_report.h b/src/vulkan/util/vk_debug_report.h index 625ecbb..8cd0941 100644 --- a/src/vulkan/util/vk_debug_report.h +++ b/src/vulkan/util/vk_debug_report.h @@ -26,8 +26,7 @@ #ifndef VK_DEBUG_REPORT_H #define VK_DEBUG_REPORT_H -#include - +#include "c11/threads.h" #include "util/list.h" #include @@ -41,7 +40,7 @@ struct vk_debug_report_callback { struct vk_debug_report_instance { /* VK_EXT_debug_report debug callbacks */ - pthread_mutex_t callbacks_mutex; + mtx_t callbacks_mutex; struct list_head callbacks; }; -- 2.7.4