Alexandre Julliard : vkd3d: Implement the synchronization wrappers for Windows.
Alexandre Julliard
julliard at winehq.org
Fri Feb 4 16:06:37 CST 2022
Module: vkd3d
Branch: master
Commit: 2a1470cddf9717e30eff70874205d00dc1ed9064
URL: https://source.winehq.org/git/vkd3d.git/?a=commit;h=2a1470cddf9717e30eff70874205d00dc1ed9064
Author: Alexandre Julliard <julliard at winehq.org>
Date: Fri Feb 4 12:07:03 2022 +0100
vkd3d: Implement the synchronization wrappers for Windows.
Signed-off-by: Alexandre Julliard <julliard at winehq.org>
Signed-off-by: Henri Verbeet <hverbeet at codeweavers.com>
---
libs/vkd3d/vkd3d_private.h | 72 ++++++++++++++++++++++++++++++++++++++++++++++
1 file changed, 72 insertions(+)
diff --git a/libs/vkd3d/vkd3d_private.h b/libs/vkd3d/vkd3d_private.h
index bb7be99..ece1113 100644
--- a/libs/vkd3d/vkd3d_private.h
+++ b/libs/vkd3d/vkd3d_private.h
@@ -23,6 +23,10 @@
#define NONAMELESSUNION
#define VK_NO_PROTOTYPES
+#ifdef _WIN32
+# define _WIN32_WINNT 0x0600 /* for condition variables */
+#endif
+
#include "vkd3d_common.h"
#include "vkd3d_blob.h"
#include "vkd3d_memory.h"
@@ -171,6 +175,72 @@ union vkd3d_thread_handle
void *handle;
};
+#ifdef _WIN32
+
+struct vkd3d_mutex
+{
+ CRITICAL_SECTION lock;
+};
+
+struct vkd3d_cond
+{
+ CONDITION_VARIABLE cond;
+};
+
+static inline int vkd3d_mutex_init(struct vkd3d_mutex *lock)
+{
+ InitializeCriticalSection(&lock->lock);
+ return 0;
+}
+
+static inline int vkd3d_mutex_lock(struct vkd3d_mutex *lock)
+{
+ EnterCriticalSection(&lock->lock);
+ return 0;
+}
+
+static inline int vkd3d_mutex_unlock(struct vkd3d_mutex *lock)
+{
+ LeaveCriticalSection(&lock->lock);
+ return 0;
+}
+
+static inline int vkd3d_mutex_destroy(struct vkd3d_mutex *lock)
+{
+ DeleteCriticalSection(&lock->lock);
+ return 0;
+}
+
+static inline int vkd3d_cond_init(struct vkd3d_cond *cond)
+{
+ InitializeConditionVariable(&cond->cond);
+ return 0;
+}
+
+static inline int vkd3d_cond_signal(struct vkd3d_cond *cond)
+{
+ WakeConditionVariable(&cond->cond);
+ return 0;
+}
+
+static inline int vkd3d_cond_broadcast(struct vkd3d_cond *cond)
+{
+ WakeAllConditionVariable(&cond->cond);
+ return 0;
+}
+
+static inline int vkd3d_cond_wait(struct vkd3d_cond *cond, struct vkd3d_mutex *lock)
+{
+ return !SleepConditionVariableCS(&cond->cond, &lock->lock, INFINITE);
+}
+
+static inline int vkd3d_cond_destroy(struct vkd3d_cond *cond)
+{
+ return 0;
+}
+
+#else /* _WIN32 */
+
struct vkd3d_mutex
{
pthread_mutex_t lock;
@@ -227,6 +297,8 @@ static inline int vkd3d_cond_destroy(struct vkd3d_cond *cond)
return pthread_cond_destroy(&cond->cond);
}
+#endif /* _WIN32 */
+
HRESULT vkd3d_create_thread(struct vkd3d_instance *instance,
PFN_vkd3d_thread thread_main, void *data, union vkd3d_thread_handle *thread);
HRESULT vkd3d_join_thread(struct vkd3d_instance *instance, union vkd3d_thread_handle *thread);
More information about the wine-cvs
mailing list