vulkan: Replace pthread mutex with mtx_t

Reviewed-by: Samuel Pitoiset <samuel.pitoiset@gmail.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/7783>
This commit is contained in:
James Park
2020-11-26 19:42:19 -08:00
committed by Marge Bot
parent 440952f152
commit 142d7b0f36
2 changed files with 10 additions and 11 deletions

View File

@@ -28,7 +28,7 @@
VkResult vk_debug_report_instance_init(struct vk_debug_report_instance *instance) 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; 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) void vk_debug_report_instance_destroy(struct vk_debug_report_instance *instance)
{ {
pthread_mutex_destroy(&instance->callbacks_mutex); mtx_destroy(&instance->callbacks_mutex);
} }
VkResult VkResult
@@ -62,9 +62,9 @@ vk_create_debug_report_callback(struct vk_debug_report_instance *instance,
cb->callback = pCreateInfo->pfnCallback; cb->callback = pCreateInfo->pfnCallback;
cb->data = pCreateInfo->pUserData; cb->data = pCreateInfo->pUserData;
pthread_mutex_lock(&instance->callbacks_mutex); mtx_lock(&instance->callbacks_mutex);
list_addtail(&cb->link, &instance->callbacks); list_addtail(&cb->link, &instance->callbacks);
pthread_mutex_unlock(&instance->callbacks_mutex); mtx_unlock(&instance->callbacks_mutex);
*pCallback = (VkDebugReportCallbackEXT)(uintptr_t)cb; *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; (struct vk_debug_report_callback *)(uintptr_t)_callback;
/* Remove from list and destroy given callback. */ /* Remove from list and destroy given callback. */
pthread_mutex_lock(&instance->callbacks_mutex); mtx_lock(&instance->callbacks_mutex);
list_del(&callback->link); list_del(&callback->link);
vk_free2(instance_allocator, pAllocator, callback); 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)) if (!instance || list_is_empty(&instance->callbacks))
return; return;
pthread_mutex_lock(&instance->callbacks_mutex); mtx_lock(&instance->callbacks_mutex);
/* Section 33.2 of the Vulkan 1.0.59 spec says: /* 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); pLayerPrefix, pMessage, cb->data);
} }
pthread_mutex_unlock(&instance->callbacks_mutex); mtx_unlock(&instance->callbacks_mutex);
} }

View File

@@ -26,8 +26,7 @@
#ifndef VK_DEBUG_REPORT_H #ifndef VK_DEBUG_REPORT_H
#define VK_DEBUG_REPORT_H #define VK_DEBUG_REPORT_H
#include <pthread.h> #include "c11/threads.h"
#include "util/list.h" #include "util/list.h"
#include <vulkan/vulkan.h> #include <vulkan/vulkan.h>
@@ -41,7 +40,7 @@ struct vk_debug_report_callback {
struct vk_debug_report_instance { struct vk_debug_report_instance {
/* VK_EXT_debug_report debug callbacks */ /* VK_EXT_debug_report debug callbacks */
pthread_mutex_t callbacks_mutex; mtx_t callbacks_mutex;
struct list_head callbacks; struct list_head callbacks;
}; };