From 504213c9a74bf243bccd68a605cbecf0ac02ee50 Mon Sep 17 00:00:00 2001 From: Jacek Caban Date: Tue, 13 Apr 2021 00:53:31 +0200 Subject: [PATCH] winevulkan: Use pthread_rwlock_t in VkInstance_T. Signed-off-by: Jacek Caban Signed-off-by: Alexandre Julliard --- dlls/winevulkan/Makefile.in | 1 + dlls/winevulkan/vulkan.c | 15 ++++++++------- dlls/winevulkan/vulkan_private.h | 4 +++- 3 files changed, 12 insertions(+), 8 deletions(-) diff --git a/dlls/winevulkan/Makefile.in b/dlls/winevulkan/Makefile.in index f95a1e3113a..61ab6a127a5 100644 --- a/dlls/winevulkan/Makefile.in +++ b/dlls/winevulkan/Makefile.in @@ -1,6 +1,7 @@ MODULE = winevulkan.dll IMPORTLIB = winevulkan IMPORTS = user32 gdi32 advapi32 setupapi +EXTRALIBS = $(PTHREAD_LIBS) C_SRCS = \ vulkan.c \ diff --git a/dlls/winevulkan/vulkan.c b/dlls/winevulkan/vulkan.c index 220528a8b86..0b47aa1d3e2 100644 --- a/dlls/winevulkan/vulkan.c +++ b/dlls/winevulkan/vulkan.c @@ -91,9 +91,9 @@ static void wine_vk_add_handle_mapping(struct VkInstance_T *instance, uint64_t { mapping->native_handle = native_handle; mapping->wine_wrapped_handle = wrapped_handle; - AcquireSRWLockExclusive(&instance->wrapper_lock); + pthread_rwlock_wrlock(&instance->wrapper_lock); list_add_tail(&instance->wrappers, &mapping->link); - ReleaseSRWLockExclusive(&instance->wrapper_lock); + pthread_rwlock_unlock(&instance->wrapper_lock); } } @@ -103,9 +103,9 @@ static void wine_vk_remove_handle_mapping(struct VkInstance_T *instance, struct { if (instance->enable_wrapper_list) { - AcquireSRWLockExclusive(&instance->wrapper_lock); + pthread_rwlock_wrlock(&instance->wrapper_lock); list_remove(&mapping->link); - ReleaseSRWLockExclusive(&instance->wrapper_lock); + pthread_rwlock_unlock(&instance->wrapper_lock); } } @@ -114,7 +114,7 @@ static uint64_t wine_vk_get_wrapper(struct VkInstance_T *instance, uint64_t nati struct wine_vk_mapping *mapping; uint64_t result = 0; - AcquireSRWLockShared(&instance->wrapper_lock); + pthread_rwlock_rdlock(&instance->wrapper_lock); LIST_FOR_EACH_ENTRY(mapping, &instance->wrappers, struct wine_vk_mapping, link) { if (mapping->native_handle == native_handle) @@ -123,7 +123,7 @@ static uint64_t wine_vk_get_wrapper(struct VkInstance_T *instance, uint64_t nati break; } } - ReleaseSRWLockShared(&instance->wrapper_lock); + pthread_rwlock_unlock(&instance->wrapper_lock); return result; } @@ -666,6 +666,7 @@ static void wine_vk_instance_free(struct VkInstance_T *instance) WINE_VK_REMOVE_HANDLE_MAPPING(instance, instance); } + pthread_rwlock_destroy(&instance->wrapper_lock); free(instance->utils_messengers); free(instance); @@ -882,7 +883,7 @@ VkResult WINAPI wine_vkCreateInstance(const VkInstanceCreateInfo *create_info, } object->base.loader_magic = VULKAN_ICD_MAGIC_VALUE; list_init(&object->wrappers); - InitializeSRWLock(&object->wrapper_lock); + pthread_rwlock_init(&object->wrapper_lock, NULL); res = wine_vk_instance_convert_create_info(create_info, &create_info_host, object); if (res != VK_SUCCESS) diff --git a/dlls/winevulkan/vulkan_private.h b/dlls/winevulkan/vulkan_private.h index 322d27079ea..6574d282eea 100644 --- a/dlls/winevulkan/vulkan_private.h +++ b/dlls/winevulkan/vulkan_private.h @@ -25,6 +25,8 @@ #define USE_STRUCT_CONVERSION #endif +#include + #include "wine/debug.h" #include "wine/heap.h" #include "wine/list.h" @@ -123,7 +125,7 @@ struct VkInstance_T VkBool32 enable_wrapper_list; struct list wrappers; - SRWLOCK wrapper_lock; + pthread_rwlock_t wrapper_lock; struct wine_debug_utils_messenger *utils_messengers; uint32_t utils_messenger_count;