diff --git a/include/private/vkd3d_common.h b/include/private/vkd3d_common.h index 1ac8a63b..14414b74 100644 --- a/include/private/vkd3d_common.h +++ b/include/private/vkd3d_common.h @@ -26,6 +26,10 @@ #include #include +#ifdef _MSC_VER +#include +#endif + #ifndef ARRAY_SIZE # define ARRAY_SIZE(x) (sizeof(x) / sizeof(*(x))) #endif @@ -51,7 +55,9 @@ static inline size_t align(size_t addr, size_t alignment) static inline unsigned int vkd3d_popcount(unsigned int v) { -#ifdef HAVE_BUILTIN_POPCOUNT +#ifdef _MSC_VER + return __popcnt(v); +#elif defined(HAVE_BUILTIN_POPCOUNT) return __builtin_popcount(v); #else v -= (v >> 1) & 0x55555555; @@ -78,7 +84,11 @@ static inline bool vkd3d_bitmask_is_contiguous(unsigned int mask) /* Undefined for x == 0. */ static inline unsigned int vkd3d_log2i(unsigned int x) { -#ifdef HAVE_BUILTIN_CLZ +#ifdef _MSC_VER + unsigned long result; + _BitScanForward(&result, x); + return (unsigned int)x; +#elif defined(HAVE_BUILTIN_CLZ) return __builtin_clz(x) ^ 0x1f; #else static const unsigned int l[] = @@ -152,8 +162,8 @@ static inline LONG InterlockedDecrement(LONG volatile *x) #if HAVE_SYNC_ADD_AND_FETCH # define atomic_add_fetch(ptr, val) __sync_add_and_fetch(ptr, val) -#else -# error "atomic_add_fetch() not implemented for this platform" +#elif defined(_MSC_VER) +# define atomic_add_fetch(ptr, val) InterlockedAdd(ptr, val) #endif /* HAVE_SYNC_ADD_AND_FETCH */ static inline void vkd3d_parse_version(const char *version, int *major, int *minor) diff --git a/include/private/vkd3d_debug.h b/include/private/vkd3d_debug.h index 1a44cb9a..c37c841a 100644 --- a/include/private/vkd3d_debug.h +++ b/include/private/vkd3d_debug.h @@ -67,8 +67,8 @@ const char *debugstr_w(const WCHAR *wstr, size_t wchar_size) DECLSPEC_HIDDEN; vkd3d_dbg_next_time = true; \ VKD3D_DBG_PRINTF -#define VKD3D_DBG_PRINTF(args...) \ - vkd3d_dbg_printf(vkd3d_dbg_level, __FUNCTION__, args); } while (0) +#define VKD3D_DBG_PRINTF(...) \ + vkd3d_dbg_printf(vkd3d_dbg_level, __FUNCTION__, __VA_ARGS__); } while (0) #ifndef TRACE #define TRACE VKD3D_DBG_LOG(TRACE) diff --git a/include/private/vkd3d_threads.h b/include/private/vkd3d_threads.h new file mode 100644 index 00000000..65ba48e1 --- /dev/null +++ b/include/private/vkd3d_threads.h @@ -0,0 +1,220 @@ +/* + * Copyright 2019 Hans-Kristian Arntzen for Valve + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA + */ + +#ifndef __VKD3D_THREADS_H +#define __VKD3D_THREADS_H + +#include "config.h" + +#if defined(HAVE_PTHREAD_H) +#include + +typedef struct vkd3d_pthread +{ + pthread_t thread; +} vkd3d_pthread_t; + +typedef struct vkd3d_pthread_mutex +{ + pthread_mutex_t lock; +} vkd3d_pthread_mutex_t; + +typedef struct vkd3d_pthread_cond +{ + pthread_cond_t cond; +} vkd3d_pthread_cond_t; + +static inline int vkd3d_pthread_create(vkd3d_pthread_t *thread, void * (*thread_fun)(void *), void *arg) +{ + return pthread_create(&thread->thread, NULL, thread_fun, arg); +} + +static inline int vkd3d_pthread_join(vkd3d_pthread_t thread) +{ + return pthread_join(thread.thread, NULL); +} + +static inline int vkd3d_pthread_mutex_init(vkd3d_pthread_mutex_t *lock) +{ + return pthread_mutex_init(&lock->lock, NULL); +} + +static inline int vkd3d_pthread_mutex_destroy(vkd3d_pthread_mutex_t *lock) +{ + return pthread_mutex_destroy(&lock->lock); +} + +static inline int vkd3d_pthread_mutex_lock(vkd3d_pthread_mutex_t *lock) +{ + return pthread_mutex_lock(&lock->lock); +} + +static inline int vkd3d_pthread_mutex_unlock(vkd3d_pthread_mutex_t *lock) +{ + return pthread_mutex_unlock(&lock->lock); +} + +static inline int vkd3d_pthread_cond_init(vkd3d_pthread_cond_t *cond) +{ + return pthread_cond_init(&cond->cond, NULL); +} + +static inline int vkd3d_pthread_cond_destroy(vkd3d_pthread_cond_t *cond) +{ + return pthread_cond_destroy(&cond->cond); +} + +static inline int vkd3d_pthread_cond_signal(vkd3d_pthread_cond_t *cond) +{ + return pthread_cond_signal(&cond->cond); +} + +static inline int vkd3d_pthread_cond_broadcast(vkd3d_pthread_cond_t *cond) +{ + return pthread_cond_broadcast(&cond->cond); +} + +static inline int vkd3d_pthread_cond_wait(vkd3d_pthread_cond_t *cond, vkd3d_pthread_mutex_t *lock) +{ + return pthread_cond_wait(&cond->cond, &lock->lock); +} + +#elif defined(_WIN32) /* HAVE_PTHREAD_H */ + +#define WIN32_LEAN_AND_MEAN +#include + +typedef struct vkd3d_pthread +{ + HANDLE thread; + DWORD id; +} vkd3d_pthread_t; + +typedef struct vkd3d_pthread_mutex +{ + CRITICAL_SECTION *lock; +} vkd3d_pthread_mutex_t; + +typedef struct vkd3d_pthread_cond +{ + CONDITION_VARIABLE *cond; +} vkd3d_pthread_cond_t; + +struct vkd3d_pthread_wrapper_struct +{ + void * (*routine)(void *); + void *arg; +}; + +static DWORD WINAPI win32_thread_wrapper_routine(struct vkd3d_pthread_wrapper_struct *wrapper) +{ + wrapper->routine(wrapper->arg); + vkd3d_free(wrapper); + return 0; +} + +static inline int vkd3d_pthread_create(vkd3d_pthread_t *thread, void * (*thread_fun)(void *), void *arg) +{ + struct vkd3d_pthread_wrapper_struct *wrapper = vkd3d_malloc(sizeof(*wrapper)); + wrapper->routine = thread_fun; + wrapper->arg = arg; + thread->thread = CreateThread(NULL, 0, win32_thread_wrapper_routine, wrapper, 0, &thread->id); + return 0; +} + +static inline int vkd3d_pthread_join(vkd3d_pthread_t thread) +{ + int success = WaitForSingleObject(thread.thread, INFINITE) == WAIT_OBJECT_0; + CloseHandle(thread.thread); + return success ? 0 : -1; +} + +static inline int vkd3d_pthread_mutex_init(vkd3d_pthread_mutex_t *lock) +{ + lock->lock = vkd3d_malloc(sizeof(CRITICAL_SECTION)); + InitializeCriticalSection(lock->lock); + return 0; +} + +static inline int vkd3d_pthread_mutex_lock(vkd3d_pthread_mutex_t *lock) +{ + EnterCriticalSection(lock->lock); + return 0; +} + +static inline int vkd3d_pthread_mutex_unlock(vkd3d_pthread_mutex_t *lock) +{ + LeaveCriticalSection(lock->lock); + return 0; +} + +static inline int vkd3d_pthread_mutex_destroy(vkd3d_pthread_mutex_t *lock) +{ + DeleteCriticalSection(lock->lock); + vkd3d_free(lock->lock); + return 0; +} + +static inline int vkd3d_pthread_cond_init(vkd3d_pthread_cond_t *cond) +{ + cond->cond = vkd3d_malloc(sizeof(CONDITION_VARIABLE)); + InitializeConditionVariable(cond->cond); + return 0; +} + +static inline void vkd3d_pthread_cond_destroy(vkd3d_pthread_cond_t *cond) +{ + vkd3d_free(cond->cond); +} + +static inline int vkd3d_pthread_cond_signal(vkd3d_pthread_cond_t *cond) +{ + WakeConditionVariable(cond->cond); + return 0; +} + +static inline int vkd3d_pthread_cond_broadcast(vkd3d_pthread_cond_t *cond) +{ + WakeAllConditionVariable(cond->cond); + return 0; +} + +static inline int vkd3d_pthread_cond_wait(vkd3d_pthread_cond_t *cond, vkd3d_pthread_mutex_t *lock) +{ + bool ret = SleepConditionVariableCS(cond->cond, lock->lock, INFINITE); + return ret ? 0 : -1; +} + +#else /* HAVE_PTHREAD_H */ +#error "Threads are not supported. Cannot build." +#endif /* HAVE_PTHREAD_H */ + +static inline void vkd3d_set_thread_name(const char *name) +{ +#if defined(_MSC_VER) + (void)name; +#elif defined(HAVE_PTHREAD_SETNAME_NP_2) + pthread_setname_np(pthread_self(), name); +#elif defined(HAVE_PTHREAD_SETNAME_NP_1) + pthread_setname_np(name); +#else + (void)name; +#endif +} + +#endif /* __VKD3D_THREADS_H */ diff --git a/libs/vkd3d-shader/spirv.c b/libs/vkd3d-shader/spirv.c index fe8935cf..580230f5 100644 --- a/libs/vkd3d-shader/spirv.c +++ b/libs/vkd3d-shader/spirv.c @@ -4540,7 +4540,7 @@ static void vkd3d_dxbc_compiler_emit_store_shader_output(struct vkd3d_dxbc_compi static void vkd3d_dxbc_compiler_emit_shader_epilogue_function(struct vkd3d_dxbc_compiler *compiler) { - uint32_t param_type_id[MAX_REG_OUTPUT + 1], param_id[MAX_REG_OUTPUT + 1] = {}; + uint32_t param_type_id[MAX_REG_OUTPUT + 1], param_id[MAX_REG_OUTPUT + 1] = {0}; uint32_t void_id, type_id, ptr_type_id, function_type_id, function_id; struct vkd3d_spirv_builder *builder = &compiler->spirv_builder; const struct vkd3d_shader_signature *signature; diff --git a/libs/vkd3d-shader/vkd3d_shader_private.h b/libs/vkd3d-shader/vkd3d_shader_private.h index 47764e57..53e863cf 100644 --- a/libs/vkd3d-shader/vkd3d_shader_private.h +++ b/libs/vkd3d-shader/vkd3d_shader_private.h @@ -56,7 +56,7 @@ #include #include #include -#include +//#include #define VKD3D_VEC4_SIZE 4 diff --git a/libs/vkd3d/command.c b/libs/vkd3d/command.c index ae88910a..1f796df2 100644 --- a/libs/vkd3d/command.c +++ b/libs/vkd3d/command.c @@ -31,7 +31,7 @@ HRESULT vkd3d_queue_create(struct d3d12_device *device, if (!(object = vkd3d_malloc(sizeof(*object)))) return E_OUTOFMEMORY; - if ((rc = pthread_mutex_init(&object->mutex, NULL))) + if ((rc = vkd3d_pthread_mutex_init(&object->mutex))) { ERR("Failed to initialize mutex, error %d.\n", rc); vkd3d_free(object); @@ -66,7 +66,7 @@ void vkd3d_queue_destroy(struct vkd3d_queue *queue, struct d3d12_device *device) unsigned int i; int rc; - if ((rc = pthread_mutex_lock(&queue->mutex))) + if ((rc = vkd3d_pthread_mutex_lock(&queue->mutex))) ERR("Failed to lock mutex, error %d.\n", rc); for (i = 0; i < queue->semaphore_count; ++i) @@ -81,9 +81,9 @@ void vkd3d_queue_destroy(struct vkd3d_queue *queue, struct d3d12_device *device) } if (!rc) - pthread_mutex_unlock(&queue->mutex); + vkd3d_pthread_mutex_unlock(&queue->mutex); - pthread_mutex_destroy(&queue->mutex); + vkd3d_pthread_mutex_destroy(&queue->mutex); vkd3d_free(queue); } @@ -93,7 +93,7 @@ VkQueue vkd3d_queue_acquire(struct vkd3d_queue *queue) TRACE("queue %p.\n", queue); - if ((rc = pthread_mutex_lock(&queue->mutex))) + if ((rc = vkd3d_pthread_mutex_lock(&queue->mutex))) { ERR("Failed to lock mutex, error %d.\n", rc); return VK_NULL_HANDLE; @@ -107,7 +107,7 @@ void vkd3d_queue_release(struct vkd3d_queue *queue) { TRACE("queue %p.\n", queue); - pthread_mutex_unlock(&queue->mutex); + vkd3d_pthread_mutex_unlock(&queue->mutex); } static VkResult vkd3d_queue_wait_idle(struct vkd3d_queue *queue, @@ -143,7 +143,7 @@ static void vkd3d_queue_update_sequence_number(struct vkd3d_queue *queue, unsigned int i, j; int rc; - if ((rc = pthread_mutex_lock(&queue->mutex))) + if ((rc = vkd3d_pthread_mutex_lock(&queue->mutex))) { ERR("Failed to lock mutex, error %d.\n", rc); return; @@ -188,7 +188,7 @@ static void vkd3d_queue_update_sequence_number(struct vkd3d_queue *queue, if (destroyed_semaphore_count) TRACE("Destroyed %u Vulkan semaphores.\n", destroyed_semaphore_count); - pthread_mutex_unlock(&queue->mutex); + vkd3d_pthread_mutex_unlock(&queue->mutex); } static uint64_t vkd3d_queue_reset_sequence_number_locked(struct vkd3d_queue *queue) @@ -252,7 +252,7 @@ static HRESULT vkd3d_enqueue_gpu_fence(struct vkd3d_fence_worker *worker, TRACE("worker %p, fence %p, value %#"PRIx64".\n", worker, fence, value); - if ((rc = pthread_mutex_lock(&worker->mutex))) + if ((rc = vkd3d_pthread_mutex_lock(&worker->mutex))) { ERR("Failed to lock mutex, error %d.\n", rc); return hresult_from_errno(rc); @@ -262,7 +262,7 @@ static HRESULT vkd3d_enqueue_gpu_fence(struct vkd3d_fence_worker *worker, worker->enqueued_fence_count + 1, sizeof(*worker->enqueued_fences))) { ERR("Failed to add GPU fence.\n"); - pthread_mutex_unlock(&worker->mutex); + vkd3d_pthread_mutex_unlock(&worker->mutex); return E_OUTOFMEMORY; } @@ -276,8 +276,8 @@ static HRESULT vkd3d_enqueue_gpu_fence(struct vkd3d_fence_worker *worker, InterlockedIncrement(&fence->pending_worker_operation_count); - pthread_cond_signal(&worker->cond); - pthread_mutex_unlock(&worker->mutex); + vkd3d_pthread_cond_signal(&worker->cond); + vkd3d_pthread_mutex_unlock(&worker->mutex); return S_OK; } @@ -292,7 +292,7 @@ static void vkd3d_fence_worker_remove_fence(struct vkd3d_fence_worker *worker, s WARN("Waiting for %u pending fence operations (fence %p).\n", count, fence); - if ((rc = pthread_mutex_lock(&worker->mutex))) + if ((rc = vkd3d_pthread_mutex_lock(&worker->mutex))) { ERR("Failed to lock mutex, error %d.\n", rc); return; @@ -303,14 +303,14 @@ static void vkd3d_fence_worker_remove_fence(struct vkd3d_fence_worker *worker, s TRACE("Still waiting for %u pending fence operations (fence %p).\n", count, fence); worker->pending_fence_destruction = true; - pthread_cond_signal(&worker->cond); + vkd3d_pthread_cond_signal(&worker->cond); - pthread_cond_wait(&worker->fence_destruction_cond, &worker->mutex); + vkd3d_pthread_cond_wait(&worker->fence_destruction_cond, &worker->mutex); } TRACE("Removed fence %p.\n", fence); - pthread_mutex_unlock(&worker->mutex); + vkd3d_pthread_mutex_unlock(&worker->mutex); } static void vkd3d_fence_worker_move_enqueued_fences_locked(struct vkd3d_fence_worker *worker) @@ -411,7 +411,7 @@ static void *vkd3d_fence_worker_main(void *arg) if (!worker->fence_count || atomic_add_fetch(&worker->enqueued_fence_count, 0)) { - if ((rc = pthread_mutex_lock(&worker->mutex))) + if ((rc = vkd3d_pthread_mutex_lock(&worker->mutex))) { ERR("Failed to lock mutex, error %d.\n", rc); break; @@ -419,7 +419,7 @@ static void *vkd3d_fence_worker_main(void *arg) if (worker->pending_fence_destruction) { - pthread_cond_broadcast(&worker->fence_destruction_cond); + vkd3d_pthread_cond_broadcast(&worker->fence_destruction_cond); worker->pending_fence_destruction = false; } @@ -431,19 +431,19 @@ static void *vkd3d_fence_worker_main(void *arg) { if (worker->should_exit) { - pthread_mutex_unlock(&worker->mutex); + vkd3d_pthread_mutex_unlock(&worker->mutex); break; } - if ((rc = pthread_cond_wait(&worker->cond, &worker->mutex))) + if ((rc = vkd3d_pthread_cond_wait(&worker->cond, &worker->mutex))) { ERR("Failed to wait on condition variable, error %d.\n", rc); - pthread_mutex_unlock(&worker->mutex); + vkd3d_pthread_mutex_unlock(&worker->mutex); break; } } - pthread_mutex_unlock(&worker->mutex); + vkd3d_pthread_mutex_unlock(&worker->mutex); } } @@ -473,33 +473,33 @@ HRESULT vkd3d_fence_worker_start(struct vkd3d_fence_worker *worker, worker->fences = NULL; worker->fences_size = 0; - if ((rc = pthread_mutex_init(&worker->mutex, NULL))) + if ((rc = vkd3d_pthread_mutex_init(&worker->mutex))) { ERR("Failed to initialize mutex, error %d.\n", rc); return hresult_from_errno(rc); } - if ((rc = pthread_cond_init(&worker->cond, NULL))) + if ((rc = vkd3d_pthread_cond_init(&worker->cond))) { ERR("Failed to initialize condition variable, error %d.\n", rc); - pthread_mutex_destroy(&worker->mutex); + vkd3d_pthread_mutex_destroy(&worker->mutex); return hresult_from_errno(rc); } - if ((rc = pthread_cond_init(&worker->fence_destruction_cond, NULL))) + if ((rc = vkd3d_pthread_cond_init(&worker->fence_destruction_cond))) { ERR("Failed to initialize condition variable, error %d.\n", rc); - pthread_mutex_destroy(&worker->mutex); - pthread_cond_destroy(&worker->cond); + vkd3d_pthread_mutex_destroy(&worker->mutex); + vkd3d_pthread_cond_destroy(&worker->cond); return hresult_from_errno(rc); } if (FAILED(hr = vkd3d_create_thread(device->vkd3d_instance, vkd3d_fence_worker_main, worker, &worker->thread))) { - pthread_mutex_destroy(&worker->mutex); - pthread_cond_destroy(&worker->cond); - pthread_cond_destroy(&worker->fence_destruction_cond); + vkd3d_pthread_mutex_destroy(&worker->mutex); + vkd3d_pthread_cond_destroy(&worker->cond); + vkd3d_pthread_cond_destroy(&worker->fence_destruction_cond); } return hr; @@ -513,23 +513,23 @@ HRESULT vkd3d_fence_worker_stop(struct vkd3d_fence_worker *worker, TRACE("worker %p.\n", worker); - if ((rc = pthread_mutex_lock(&worker->mutex))) + if ((rc = vkd3d_pthread_mutex_lock(&worker->mutex))) { ERR("Failed to lock mutex, error %d.\n", rc); return hresult_from_errno(rc); } worker->should_exit = true; - pthread_cond_signal(&worker->cond); + vkd3d_pthread_cond_signal(&worker->cond); - pthread_mutex_unlock(&worker->mutex); + vkd3d_pthread_mutex_unlock(&worker->mutex); if (FAILED(hr = vkd3d_join_thread(device->vkd3d_instance, &worker->thread))) return hr; - pthread_mutex_destroy(&worker->mutex); - pthread_cond_destroy(&worker->cond); - pthread_cond_destroy(&worker->fence_destruction_cond); + vkd3d_pthread_mutex_destroy(&worker->mutex); + vkd3d_pthread_cond_destroy(&worker->cond); + vkd3d_pthread_cond_destroy(&worker->fence_destruction_cond); vkd3d_free(worker->enqueued_fences); vkd3d_free(worker->vk_fences); @@ -588,7 +588,7 @@ static VkResult d3d12_fence_create_vk_fence(struct d3d12_fence *fence, VkFence * *vk_fence = VK_NULL_HANDLE; - if ((rc = pthread_mutex_lock(&fence->mutex))) + if ((rc = vkd3d_pthread_mutex_lock(&fence->mutex))) { ERR("Failed to lock mutex, error %d.\n", rc); goto create_fence; @@ -603,7 +603,7 @@ static VkResult d3d12_fence_create_vk_fence(struct d3d12_fence *fence, VkFence * } } - pthread_mutex_unlock(&fence->mutex); + vkd3d_pthread_mutex_unlock(&fence->mutex); if (*vk_fence) return VK_SUCCESS; @@ -667,7 +667,7 @@ static void d3d12_fence_destroy_vk_objects(struct d3d12_fence *fence) unsigned int i; int rc; - if ((rc = pthread_mutex_lock(&fence->mutex))) + if ((rc = vkd3d_pthread_mutex_lock(&fence->mutex))) { ERR("Failed to lock mutex, error %d.\n", rc); return; @@ -684,7 +684,7 @@ static void d3d12_fence_destroy_vk_objects(struct d3d12_fence *fence) d3d12_fence_garbage_collect_vk_semaphores_locked(fence, true); - pthread_mutex_unlock(&fence->mutex); + vkd3d_pthread_mutex_unlock(&fence->mutex); } static struct vkd3d_signaled_semaphore *d3d12_fence_acquire_vk_semaphore(struct d3d12_fence *fence, @@ -697,7 +697,7 @@ static struct vkd3d_signaled_semaphore *d3d12_fence_acquire_vk_semaphore(struct TRACE("fence %p, value %#"PRIx64".\n", fence, value); - if ((rc = pthread_mutex_lock(&fence->mutex))) + if ((rc = vkd3d_pthread_mutex_lock(&fence->mutex))) { ERR("Failed to lock mutex, error %d.\n", rc); return VK_NULL_HANDLE; @@ -723,7 +723,7 @@ static struct vkd3d_signaled_semaphore *d3d12_fence_acquire_vk_semaphore(struct *completed_value = fence->value; - pthread_mutex_unlock(&fence->mutex); + vkd3d_pthread_mutex_unlock(&fence->mutex); return semaphore; } @@ -732,7 +732,7 @@ static void d3d12_fence_remove_vk_semaphore(struct d3d12_fence *fence, struct vk { int rc; - if ((rc = pthread_mutex_lock(&fence->mutex))) + if ((rc = vkd3d_pthread_mutex_lock(&fence->mutex))) { ERR("Failed to lock mutex, error %d.\n", rc); return; @@ -745,14 +745,14 @@ static void d3d12_fence_remove_vk_semaphore(struct d3d12_fence *fence, struct vk --fence->semaphore_count; - pthread_mutex_unlock(&fence->mutex); + vkd3d_pthread_mutex_unlock(&fence->mutex); } static void d3d12_fence_release_vk_semaphore(struct d3d12_fence *fence, struct vkd3d_signaled_semaphore *semaphore) { int rc; - if ((rc = pthread_mutex_lock(&fence->mutex))) + if ((rc = vkd3d_pthread_mutex_lock(&fence->mutex))) { ERR("Failed to lock mutex, error %d.\n", rc); return; @@ -761,7 +761,7 @@ static void d3d12_fence_release_vk_semaphore(struct d3d12_fence *fence, struct v assert(semaphore->is_acquired); semaphore->is_acquired = false; - pthread_mutex_unlock(&fence->mutex); + vkd3d_pthread_mutex_unlock(&fence->mutex); } static HRESULT d3d12_fence_add_vk_semaphore(struct d3d12_fence *fence, @@ -779,7 +779,7 @@ static HRESULT d3d12_fence_add_vk_semaphore(struct d3d12_fence *fence, return E_OUTOFMEMORY; } - if ((rc = pthread_mutex_lock(&fence->mutex))) + if ((rc = vkd3d_pthread_mutex_lock(&fence->mutex))) { ERR("Failed to lock mutex, error %d.\n", rc); vkd3d_free(semaphore); @@ -796,7 +796,7 @@ static HRESULT d3d12_fence_add_vk_semaphore(struct d3d12_fence *fence, list_add_tail(&fence->semaphores, &semaphore->entry); ++fence->semaphore_count; - pthread_mutex_unlock(&fence->mutex); + vkd3d_pthread_mutex_unlock(&fence->mutex); return hr; } @@ -808,7 +808,7 @@ static HRESULT d3d12_fence_signal(struct d3d12_fence *fence, uint64_t value, VkF unsigned int i, j; int rc; - if ((rc = pthread_mutex_lock(&fence->mutex))) + if ((rc = vkd3d_pthread_mutex_lock(&fence->mutex))) { ERR("Failed to lock mutex, error %d.\n", rc); return hresult_from_errno(rc); @@ -857,7 +857,7 @@ static HRESULT d3d12_fence_signal(struct d3d12_fence *fence, uint64_t value, VkF VK_CALL(vkDestroyFence(device->vk_device, vk_fence, NULL)); } - pthread_mutex_unlock(&fence->mutex); + vkd3d_pthread_mutex_unlock(&fence->mutex); return S_OK; } @@ -913,7 +913,7 @@ static ULONG STDMETHODCALLTYPE d3d12_fence_Release(ID3D12Fence *iface) d3d12_fence_destroy_vk_objects(fence); vkd3d_free(fence->events); - if ((rc = pthread_mutex_destroy(&fence->mutex))) + if ((rc = vkd3d_pthread_mutex_destroy(&fence->mutex))) ERR("Failed to destroy mutex, error %d.\n", rc); vkd3d_free(fence); @@ -981,13 +981,13 @@ static UINT64 STDMETHODCALLTYPE d3d12_fence_GetCompletedValue(ID3D12Fence *iface TRACE("iface %p.\n", iface); - if ((rc = pthread_mutex_lock(&fence->mutex))) + if ((rc = vkd3d_pthread_mutex_lock(&fence->mutex))) { ERR("Failed to lock mutex, error %d.\n", rc); return 0; } completed_value = fence->value; - pthread_mutex_unlock(&fence->mutex); + vkd3d_pthread_mutex_unlock(&fence->mutex); return completed_value; } @@ -1000,7 +1000,7 @@ static HRESULT STDMETHODCALLTYPE d3d12_fence_SetEventOnCompletion(ID3D12Fence *i TRACE("iface %p, value %#"PRIx64", event %p.\n", iface, value, event); - if ((rc = pthread_mutex_lock(&fence->mutex))) + if ((rc = vkd3d_pthread_mutex_lock(&fence->mutex))) { ERR("Failed to lock mutex, error %d.\n", rc); return hresult_from_errno(rc); @@ -1009,7 +1009,7 @@ static HRESULT STDMETHODCALLTYPE d3d12_fence_SetEventOnCompletion(ID3D12Fence *i if (value <= fence->value) { fence->device->signal_event(event); - pthread_mutex_unlock(&fence->mutex); + vkd3d_pthread_mutex_unlock(&fence->mutex); return S_OK; } @@ -1020,7 +1020,7 @@ static HRESULT STDMETHODCALLTYPE d3d12_fence_SetEventOnCompletion(ID3D12Fence *i { WARN("Event completion for (%p, %#"PRIx64") is already in the list.\n", event, value); - pthread_mutex_unlock(&fence->mutex); + vkd3d_pthread_mutex_unlock(&fence->mutex); return S_OK; } } @@ -1029,7 +1029,7 @@ static HRESULT STDMETHODCALLTYPE d3d12_fence_SetEventOnCompletion(ID3D12Fence *i fence->event_count + 1, sizeof(*fence->events))) { WARN("Failed to add event.\n"); - pthread_mutex_unlock(&fence->mutex); + vkd3d_pthread_mutex_unlock(&fence->mutex); return E_OUTOFMEMORY; } @@ -1037,7 +1037,7 @@ static HRESULT STDMETHODCALLTYPE d3d12_fence_SetEventOnCompletion(ID3D12Fence *i fence->events[fence->event_count].event = event; ++fence->event_count; - pthread_mutex_unlock(&fence->mutex); + vkd3d_pthread_mutex_unlock(&fence->mutex); return S_OK; } @@ -1088,7 +1088,7 @@ static HRESULT d3d12_fence_init(struct d3d12_fence *fence, struct d3d12_device * fence->value = initial_value; - if ((rc = pthread_mutex_init(&fence->mutex, NULL))) + if ((rc = vkd3d_pthread_mutex_init(&fence->mutex))) { ERR("Failed to initialize mutex, error %d.\n", rc); return hresult_from_errno(rc); @@ -1110,7 +1110,7 @@ static HRESULT d3d12_fence_init(struct d3d12_fence *fence, struct d3d12_device * if (FAILED(hr = vkd3d_private_store_init(&fence->private_store))) { - pthread_mutex_destroy(&fence->mutex); + vkd3d_pthread_mutex_destroy(&fence->mutex); return hr; } diff --git a/libs/vkd3d/device.c b/libs/vkd3d/device.c index dc0fa0aa..7c46abdb 100644 --- a/libs/vkd3d/device.c +++ b/libs/vkd3d/device.c @@ -453,7 +453,7 @@ static HRESULT vkd3d_instance_init(struct vkd3d_instance *instance, bool *user_extension_supported = NULL; VkApplicationInfo application_info; VkInstanceCreateInfo instance_info; - char application_name[PATH_MAX]; + char application_name[VKD3D_PATH_MAX]; uint32_t extension_count; const char **extensions; VkInstance vk_instance; @@ -1791,7 +1791,7 @@ static HRESULT d3d12_device_init_pipeline_cache(struct d3d12_device *device) VkResult vr; int rc; - if ((rc = pthread_mutex_init(&device->mutex, NULL))) + if ((rc = vkd3d_pthread_mutex_init(&device->mutex))) { ERR("Failed to initialize mutex, error %d.\n", rc); return hresult_from_errno(rc); @@ -1819,7 +1819,7 @@ static void d3d12_device_destroy_pipeline_cache(struct d3d12_device *device) if (device->vk_pipeline_cache) VK_CALL(vkDestroyPipelineCache(device->vk_device, device->vk_pipeline_cache, NULL)); - pthread_mutex_destroy(&device->mutex); + vkd3d_pthread_mutex_destroy(&device->mutex); } D3D12_GPU_VIRTUAL_ADDRESS vkd3d_gpu_va_allocator_allocate(struct vkd3d_gpu_va_allocator *allocator, @@ -1829,7 +1829,7 @@ D3D12_GPU_VIRTUAL_ADDRESS vkd3d_gpu_va_allocator_allocate(struct vkd3d_gpu_va_al struct vkd3d_gpu_va_allocation *allocation; int rc; - if ((rc = pthread_mutex_lock(&allocator->mutex))) + if ((rc = vkd3d_pthread_mutex_lock(&allocator->mutex))) { ERR("Failed to lock mutex, error %d.\n", rc); return 0; @@ -1838,13 +1838,13 @@ D3D12_GPU_VIRTUAL_ADDRESS vkd3d_gpu_va_allocator_allocate(struct vkd3d_gpu_va_al if (!vkd3d_array_reserve((void **)&allocator->allocations, &allocator->allocations_size, allocator->allocation_count + 1, sizeof(*allocator->allocations))) { - pthread_mutex_unlock(&allocator->mutex); + vkd3d_pthread_mutex_unlock(&allocator->mutex); return 0; } if (size > ceiling || ceiling - size < allocator->floor) { - pthread_mutex_unlock(&allocator->mutex); + vkd3d_pthread_mutex_unlock(&allocator->mutex); return 0; } @@ -1855,7 +1855,7 @@ D3D12_GPU_VIRTUAL_ADDRESS vkd3d_gpu_va_allocator_allocate(struct vkd3d_gpu_va_al allocator->floor += size; - pthread_mutex_unlock(&allocator->mutex); + vkd3d_pthread_mutex_unlock(&allocator->mutex); return allocation->base; } @@ -1878,7 +1878,7 @@ void *vkd3d_gpu_va_allocator_dereference(struct vkd3d_gpu_va_allocator *allocato struct vkd3d_gpu_va_allocation *allocation; int rc; - if ((rc = pthread_mutex_lock(&allocator->mutex))) + if ((rc = vkd3d_pthread_mutex_lock(&allocator->mutex))) { ERR("Failed to lock mutex, error %d.\n", rc); return NULL; @@ -1887,7 +1887,7 @@ void *vkd3d_gpu_va_allocator_dereference(struct vkd3d_gpu_va_allocator *allocato allocation = bsearch(&address, allocator->allocations, allocator->allocation_count, sizeof(*allocation), vkd3d_gpu_va_allocation_compare); - pthread_mutex_unlock(&allocator->mutex); + vkd3d_pthread_mutex_unlock(&allocator->mutex); return allocation ? allocation->ptr : NULL; } @@ -1898,7 +1898,7 @@ void vkd3d_gpu_va_allocator_free(struct vkd3d_gpu_va_allocator *allocator, D3D12 unsigned int index; int rc; - if ((rc = pthread_mutex_lock(&allocator->mutex))) + if ((rc = vkd3d_pthread_mutex_lock(&allocator->mutex))) { ERR("Failed to lock mutex, error %d.\n", rc); return; @@ -1917,7 +1917,7 @@ void vkd3d_gpu_va_allocator_free(struct vkd3d_gpu_va_allocator *allocator, D3D12 } } - pthread_mutex_unlock(&allocator->mutex); + vkd3d_pthread_mutex_unlock(&allocator->mutex); } static bool vkd3d_gpu_va_allocator_init(struct vkd3d_gpu_va_allocator *allocator) @@ -1927,7 +1927,7 @@ static bool vkd3d_gpu_va_allocator_init(struct vkd3d_gpu_va_allocator *allocator memset(allocator, 0, sizeof(*allocator)); allocator->floor = 0x1000; - if ((rc = pthread_mutex_init(&allocator->mutex, NULL))) + if ((rc = vkd3d_pthread_mutex_init(&allocator->mutex))) { ERR("Failed to initialize mutex, error %d.\n", rc); return false; @@ -1940,14 +1940,14 @@ static void vkd3d_gpu_va_allocator_cleanup(struct vkd3d_gpu_va_allocator *alloca { int rc; - if ((rc = pthread_mutex_lock(&allocator->mutex))) + if ((rc = vkd3d_pthread_mutex_lock(&allocator->mutex))) { ERR("Failed to lock mutex, error %d.\n", rc); return; } vkd3d_free(allocator->allocations); - pthread_mutex_unlock(&allocator->mutex); - pthread_mutex_destroy(&allocator->mutex); + vkd3d_pthread_mutex_unlock(&allocator->mutex); + vkd3d_pthread_mutex_destroy(&allocator->mutex); } /* ID3D12Device */ @@ -3309,7 +3309,7 @@ HRESULT vkd3d_create_thread(struct vkd3d_instance *instance, } else { - if ((rc = pthread_create(&thread->pthread, NULL, thread_main, data))) + if ((rc = vkd3d_pthread_create(&thread->pthread, thread_main, data))) { ERR("Failed to create thread, error %d.\n", rc); hr = hresult_from_errno(rc); @@ -3331,7 +3331,7 @@ HRESULT vkd3d_join_thread(struct vkd3d_instance *instance, union vkd3d_thread_ha } else { - if ((rc = pthread_join(thread->pthread, NULL))) + if ((rc = vkd3d_pthread_join(thread->pthread))) { ERR("Failed to join thread, error %d.\n", rc); hr = hresult_from_errno(rc); diff --git a/libs/vkd3d/resource.c b/libs/vkd3d/resource.c index 463f373b..9745a6d4 100644 --- a/libs/vkd3d/resource.c +++ b/libs/vkd3d/resource.c @@ -302,7 +302,7 @@ static void d3d12_heap_destroy(struct d3d12_heap *heap) VK_CALL(vkFreeMemory(device->vk_device, heap->vk_memory, NULL)); - pthread_mutex_destroy(&heap->mutex); + vkd3d_pthread_mutex_destroy(&heap->mutex); if (heap->is_private) device = NULL; @@ -419,7 +419,7 @@ static HRESULT d3d12_heap_map(struct d3d12_heap *heap, uint64_t offset, VkResult vr; int rc; - if ((rc = pthread_mutex_lock(&heap->mutex))) + if ((rc = vkd3d_pthread_mutex_lock(&heap->mutex))) { ERR("Failed to lock mutex, error %d.\n", rc); *data = NULL; @@ -464,7 +464,7 @@ static HRESULT d3d12_heap_map(struct d3d12_heap *heap, uint64_t offset, *data = NULL; } - pthread_mutex_unlock(&heap->mutex); + vkd3d_pthread_mutex_unlock(&heap->mutex); return hr; } @@ -474,7 +474,7 @@ static void d3d12_heap_unmap(struct d3d12_heap *heap, struct d3d12_resource *res struct d3d12_device *device = heap->device; int rc; - if ((rc = pthread_mutex_lock(&heap->mutex))) + if ((rc = vkd3d_pthread_mutex_lock(&heap->mutex))) { ERR("Failed to lock mutex, error %d.\n", rc); return; @@ -508,7 +508,7 @@ static void d3d12_heap_unmap(struct d3d12_heap *heap, struct d3d12_resource *res } done: - pthread_mutex_unlock(&heap->mutex); + vkd3d_pthread_mutex_unlock(&heap->mutex); } static HRESULT validate_heap_desc(const D3D12_HEAP_DESC *desc, const struct d3d12_resource *resource) @@ -567,7 +567,7 @@ static HRESULT d3d12_heap_init(struct d3d12_heap *heap, if (FAILED(hr = validate_heap_desc(&heap->desc, resource))) return hr; - if ((rc = pthread_mutex_init(&heap->mutex, NULL))) + if ((rc = vkd3d_pthread_mutex_init(&heap->mutex))) { ERR("Failed to initialize mutex, error %d.\n", rc); return hresult_from_errno(rc); @@ -575,7 +575,7 @@ static HRESULT d3d12_heap_init(struct d3d12_heap *heap, if (FAILED(hr = vkd3d_private_store_init(&heap->private_store))) { - pthread_mutex_destroy(&heap->mutex); + vkd3d_pthread_mutex_destroy(&heap->mutex); return hr; } @@ -609,7 +609,7 @@ static HRESULT d3d12_heap_init(struct d3d12_heap *heap, if (FAILED(hr)) { vkd3d_private_store_destroy(&heap->private_store); - pthread_mutex_destroy(&heap->mutex); + vkd3d_pthread_mutex_destroy(&heap->mutex); return hr; } @@ -1387,7 +1387,7 @@ static HRESULT STDMETHODCALLTYPE d3d12_resource_ReadFromSubresource(ID3D12Resour size = (box.right - box.left) / format->block_width * format->byte_count * format->block_byte_count; for (z = box.front; z < box.back; ++z) { - dst = dst_data + (z - box.front) * dst_slice_pitch; + dst = (uint8_t *)dst_data + (z - box.front) * dst_slice_pitch; src = src_data + z * vk_layout.depthPitch + box.top / format->block_height * vk_layout.rowPitch; for (y = box.top; y < box.bottom; y += format->block_height) { diff --git a/libs/vkd3d/state.c b/libs/vkd3d/state.c index 12a711b4..b7d9703e 100644 --- a/libs/vkd3d/state.c +++ b/libs/vkd3d/state.c @@ -1089,7 +1089,7 @@ HRESULT vkd3d_render_pass_cache_find(struct vkd3d_render_pass_cache *cache, unsigned int i; int rc; - if ((rc = pthread_mutex_lock(&device->mutex))) + if ((rc = vkd3d_pthread_mutex_lock(&device->mutex))) { ERR("Failed to lock mutex, error %d.\n", rc); *vk_render_pass = VK_NULL_HANDLE; @@ -1111,7 +1111,7 @@ HRESULT vkd3d_render_pass_cache_find(struct vkd3d_render_pass_cache *cache, if (!found) hr = vkd3d_render_pass_cache_create_pass_locked(cache, device, key, vk_render_pass); - pthread_mutex_unlock(&device->mutex); + vkd3d_pthread_mutex_unlock(&device->mutex); return hr; } @@ -1342,7 +1342,7 @@ static HRESULT create_shader_stage(struct d3d12_device *device, struct vkd3d_shader_code dxbc = {code->pShaderBytecode, code->BytecodeLength}; const struct vkd3d_vk_device_procs *vk_procs = &device->vk_procs; struct VkShaderModuleCreateInfo shader_desc; - struct vkd3d_shader_code spirv = {}; + struct vkd3d_shader_code spirv = {0}; VkResult vr; int ret; @@ -2560,7 +2560,7 @@ static VkPipeline d3d12_pipeline_state_find_compiled_pipeline(const struct d3d12 *vk_render_pass = VK_NULL_HANDLE; - if (!(rc = pthread_mutex_lock(&device->mutex))) + if (!(rc = vkd3d_pthread_mutex_lock(&device->mutex))) { LIST_FOR_EACH_ENTRY(current, &graphics->compiled_pipelines, struct vkd3d_compiled_pipeline, entry) { @@ -2571,7 +2571,7 @@ static VkPipeline d3d12_pipeline_state_find_compiled_pipeline(const struct d3d12 break; } } - pthread_mutex_unlock(&device->mutex); + vkd3d_pthread_mutex_unlock(&device->mutex); } else { @@ -2596,7 +2596,7 @@ static bool d3d12_pipeline_state_put_pipeline_to_cache(struct d3d12_pipeline_sta compiled_pipeline->vk_pipeline = vk_pipeline; compiled_pipeline->vk_render_pass = vk_render_pass; - if ((rc = pthread_mutex_lock(&device->mutex))) + if ((rc = vkd3d_pthread_mutex_lock(&device->mutex))) { ERR("Failed to lock mutex, error %d.\n", rc); vkd3d_free(compiled_pipeline); @@ -2616,7 +2616,7 @@ static bool d3d12_pipeline_state_put_pipeline_to_cache(struct d3d12_pipeline_sta if (compiled_pipeline) list_add_tail(&graphics->compiled_pipelines, &compiled_pipeline->entry); - pthread_mutex_unlock(&device->mutex); + vkd3d_pthread_mutex_unlock(&device->mutex); return compiled_pipeline; } diff --git a/libs/vkd3d/utils.c b/libs/vkd3d/utils.c index 6a910a79..bcb123e3 100644 --- a/libs/vkd3d/utils.c +++ b/libs/vkd3d/utils.c @@ -804,7 +804,7 @@ HRESULT vkd3d_load_vk_device_procs(struct vkd3d_vk_device_procs *procs, return S_OK; } -#ifdef _GNU_SOURCE +#if defined(_GNU_SOURCE) && !defined(_WIN32) bool vkd3d_get_program_name(char program_name[PATH_MAX]) { @@ -840,7 +840,7 @@ bool vkd3d_get_program_name(char program_name[PATH_MAX]) #else -bool vkd3d_get_program_name(char program_name[PATH_MAX]) +bool vkd3d_get_program_name(char program_name[VKD3D_PATH_MAX]) { *program_name = '\0'; return false; @@ -914,7 +914,7 @@ HRESULT vkd3d_get_private_data(struct vkd3d_private_store *store, if (!out_size) return E_INVALIDARG; - if ((rc = pthread_mutex_lock(&store->mutex))) + if ((rc = vkd3d_pthread_mutex_lock(&store->mutex))) { ERR("Failed to lock mutex, error %d.\n", rc); return hresult_from_errno(rc); @@ -943,7 +943,7 @@ HRESULT vkd3d_get_private_data(struct vkd3d_private_store *store, memcpy(out, data->u.data, data->size); done: - pthread_mutex_unlock(&store->mutex); + vkd3d_pthread_mutex_unlock(&store->mutex); return hr; } @@ -953,7 +953,7 @@ HRESULT vkd3d_set_private_data(struct vkd3d_private_store *store, HRESULT hr; int rc; - if ((rc = pthread_mutex_lock(&store->mutex))) + if ((rc = vkd3d_pthread_mutex_lock(&store->mutex))) { ERR("Failed to lock mutex, error %d.\n", rc); return hresult_from_errno(rc); @@ -961,7 +961,7 @@ HRESULT vkd3d_set_private_data(struct vkd3d_private_store *store, hr = vkd3d_private_store_set_private_data(store, tag, data, data_size, false); - pthread_mutex_unlock(&store->mutex); + vkd3d_pthread_mutex_unlock(&store->mutex); return hr; } @@ -972,7 +972,7 @@ HRESULT vkd3d_set_private_data_interface(struct vkd3d_private_store *store, HRESULT hr; int rc; - if ((rc = pthread_mutex_lock(&store->mutex))) + if ((rc = vkd3d_pthread_mutex_lock(&store->mutex))) { ERR("Failed to lock mutex, error %d.\n", rc); return hresult_from_errno(rc); @@ -980,7 +980,7 @@ HRESULT vkd3d_set_private_data_interface(struct vkd3d_private_store *store, hr = vkd3d_private_store_set_private_data(store, tag, data, sizeof(object), !!object); - pthread_mutex_unlock(&store->mutex); + vkd3d_pthread_mutex_unlock(&store->mutex); return hr; } diff --git a/libs/vkd3d/vkd3d_private.h b/libs/vkd3d/vkd3d_private.h index 294e6771..22598afd 100644 --- a/libs/vkd3d/vkd3d_private.h +++ b/libs/vkd3d/vkd3d_private.h @@ -31,11 +31,11 @@ #include "vkd3d.h" #include "vkd3d_shader.h" +#include "vkd3d_threads.h" #include #include #include -#include #include #define VK_CALL(f) (vk_procs->f) @@ -155,7 +155,7 @@ struct vkd3d_instance union vkd3d_thread_handle { - pthread_t pthread; + vkd3d_pthread_t pthread; void *handle; }; @@ -174,9 +174,9 @@ struct vkd3d_waiting_fence struct vkd3d_fence_worker { union vkd3d_thread_handle thread; - pthread_mutex_t mutex; - pthread_cond_t cond; - pthread_cond_t fence_destruction_cond; + vkd3d_pthread_mutex_t mutex; + vkd3d_pthread_cond_t cond; + vkd3d_pthread_cond_t fence_destruction_cond; bool should_exit; bool pending_fence_destruction; @@ -204,7 +204,7 @@ HRESULT vkd3d_fence_worker_stop(struct vkd3d_fence_worker *worker, struct vkd3d_gpu_va_allocator { - pthread_mutex_t mutex; + vkd3d_pthread_mutex_t mutex; D3D12_GPU_VIRTUAL_ADDRESS floor; @@ -254,7 +254,7 @@ void vkd3d_render_pass_cache_init(struct vkd3d_render_pass_cache *cache) DECLSPE struct vkd3d_private_store { - pthread_mutex_t mutex; + vkd3d_pthread_mutex_t mutex; struct list content; }; @@ -287,7 +287,7 @@ static inline HRESULT vkd3d_private_store_init(struct vkd3d_private_store *store list_init(&store->content); - if ((rc = pthread_mutex_init(&store->mutex, NULL))) + if ((rc = vkd3d_pthread_mutex_init(&store->mutex))) ERR("Failed to initialize mutex, error %d.\n", rc); return hresult_from_errno(rc); @@ -302,7 +302,7 @@ static inline void vkd3d_private_store_destroy(struct vkd3d_private_store *store vkd3d_private_data_destroy(data); } - pthread_mutex_destroy(&store->mutex); + vkd3d_pthread_mutex_destroy(&store->mutex); } HRESULT vkd3d_get_private_data(struct vkd3d_private_store *store, @@ -328,7 +328,7 @@ struct d3d12_fence LONG refcount; uint64_t value; - pthread_mutex_t mutex; + vkd3d_pthread_mutex_t mutex; struct vkd3d_waiting_event { @@ -362,7 +362,7 @@ struct d3d12_heap bool is_private; D3D12_HEAP_DESC desc; - pthread_mutex_t mutex; + vkd3d_pthread_mutex_t mutex; VkDeviceMemory vk_memory; void *map_ptr; @@ -941,7 +941,7 @@ HRESULT d3d12_command_list_create(struct d3d12_device *device, struct vkd3d_queue { /* Access to VkQueue must be externally synchronized. */ - pthread_mutex_t mutex; + vkd3d_pthread_mutex_t mutex; VkQueue vk_queue; @@ -1051,7 +1051,7 @@ struct d3d12_device struct vkd3d_gpu_va_allocator gpu_va_allocator; struct vkd3d_fence_worker fence_worker; - pthread_mutex_t mutex; + vkd3d_pthread_mutex_t mutex; struct vkd3d_render_pass_cache render_pass_cache; VkPipelineCache vk_pipeline_cache; @@ -1215,16 +1215,13 @@ HRESULT vkd3d_load_vk_device_procs(struct vkd3d_vk_device_procs *procs, extern const char vkd3d_build[]; -bool vkd3d_get_program_name(char program_name[PATH_MAX]) DECLSPEC_HIDDEN; - -static inline void vkd3d_set_thread_name(const char *name) -{ -#if defined(HAVE_PTHREAD_SETNAME_NP_2) - pthread_setname_np(pthread_self(), name); -#elif defined(HAVE_PTHREAD_SETNAME_NP_1) - pthread_setname_np(name); +#ifdef PATH_MAX +#define VKD3D_PATH_MAX PATH_MAX +#else +#define VKD3D_PATH_MAX 256 #endif -} + +bool vkd3d_get_program_name(char program_name[VKD3D_PATH_MAX]) DECLSPEC_HIDDEN; VkResult vkd3d_set_vk_object_name_utf8(struct d3d12_device *device, uint64_t vk_object, VkDebugReportObjectTypeEXT vk_object_type, const char *name) DECLSPEC_HIDDEN; diff --git a/libs/vkd3d/vulkan_procs.h b/libs/vkd3d/vulkan_procs.h index 702cfd2d..ec29eb45 100644 --- a/libs/vkd3d/vulkan_procs.h +++ b/libs/vkd3d/vulkan_procs.h @@ -178,8 +178,8 @@ VK_DEVICE_PFN(vkUpdateDescriptorSets) VK_DEVICE_PFN(vkWaitForFences) /* VK_KHR_draw_indirect_count */ -VK_DEVICE_EXT_PFN(vkCmdDrawIndirectCountKHR); -VK_DEVICE_EXT_PFN(vkCmdDrawIndexedIndirectCountKHR); +VK_DEVICE_EXT_PFN(vkCmdDrawIndirectCountKHR) +VK_DEVICE_EXT_PFN(vkCmdDrawIndexedIndirectCountKHR) /* VK_KHR_get_memory_requirements2 */ VK_DEVICE_EXT_PFN(vkGetBufferMemoryRequirements2KHR)