Module: vkd3d Branch: master Commit: 7b4a1fdfbc192cfd02ffb6cf18c0a86b2f6eaeb4 URL: https://gitlab.winehq.org/wine/vkd3d/-/commit/7b4a1fdfbc192cfd02ffb6cf18c0a8...
Author: Henri Verbeet hverbeet@codeweavers.com Date: Wed Apr 17 18:52:05 2024 +0200
vkd3d: Move the vkd3d_cond implementation to vkd3d-common.
Much like the vkd3d_mutex implementation.
---
Makefile.am | 3 +- configure.ac | 2 +- include/private/vkd3d_common.h | 70 +++++++++++++++++++++++++++++++++++ libs/vkd3d/vkd3d_private.h | 84 ------------------------------------------ 4 files changed, 73 insertions(+), 86 deletions(-)
diff --git a/Makefile.am b/Makefile.am index b901ff6e..564b9644 100644 --- a/Makefile.am +++ b/Makefile.am @@ -519,7 +519,8 @@ dummy-vkd3d-version: ## Cross-compile tests cross_implibs = crosslibs/d3d12 CROSS_CPPFLAGS = -I$(srcdir)/include -I$(srcdir)/include/private -I$(builddir)/include -I$(builddir)/tests -CROSS_CFLAGS = -g -O2 -Wall -municode ${CROSS_CPPFLAGS} -D__USE_MINGW_ANSI_STDIO=0 -DVKD3D_CROSSTEST=1 +CROSS_CFLAGS = -g -O2 -Wall -municode ${CROSS_CPPFLAGS} \ + -D_WIN32_WINNT=0x0600 -D__USE_MINGW_ANSI_STDIO=0 -DVKD3D_CROSSTEST=1 EXTRA_DIST += $(cross_implibs:=.cross32.def) $(cross_implibs:=.cross64.def) EXTRA_DIST += tests/driver.c tests/shader_runner_d3d11.c tests/shader_runner_d3d9.c
diff --git a/configure.ac b/configure.ac index ce263543..10dd7157 100644 --- a/configure.ac +++ b/configure.ac @@ -55,7 +55,7 @@ gl_LD_VERSION_SCRIPT dnl Check compiler specific flags AC_SUBST([VKD3D_CFLAGS]) AS_IF([test "x${GCC}" = "xyes"], - [VKD3D_CFLAGS="-Wall -pipe" + [VKD3D_CFLAGS="-Wall -pipe -D_WIN32_WINNT=0x0600" VKD3D_CHECK_CFLAGS([-std=c99]) VKD3D_CHECK_CFLAGS([-fvisibility=hidden]) VKD3D_CHECK_CFLAGS([-Wdeclaration-after-statement]) diff --git a/include/private/vkd3d_common.h b/include/private/vkd3d_common.h index 10e2afd5..c03ac72e 100644 --- a/include/private/vkd3d_common.h +++ b/include/private/vkd3d_common.h @@ -492,6 +492,76 @@ static inline void vkd3d_mutex_destroy(struct vkd3d_mutex *lock) #endif }
+struct vkd3d_cond +{ +#ifdef _WIN32 + CONDITION_VARIABLE cond; +#else + pthread_cond_t cond; +#endif +}; + +static inline void vkd3d_cond_init(struct vkd3d_cond *cond) +{ +#ifdef _WIN32 + InitializeConditionVariable(&cond->cond); +#else + int ret; + + if ((ret = pthread_cond_init(&cond->cond, NULL))) + ERR("Failed to initialise the condition variable, ret %d.\n", ret); +#endif +} + +static inline void vkd3d_cond_signal(struct vkd3d_cond *cond) +{ +#ifdef _WIN32 + WakeConditionVariable(&cond->cond); +#else + int ret; + + if ((ret = pthread_cond_signal(&cond->cond))) + ERR("Failed to signal the condition variable, ret %d.\n", ret); +#endif +} + +static inline void vkd3d_cond_broadcast(struct vkd3d_cond *cond) +{ +#ifdef _WIN32 + WakeAllConditionVariable(&cond->cond); +#else + int ret; + + if ((ret = pthread_cond_broadcast(&cond->cond))) + ERR("Failed to broadcast the condition variable, ret %d.\n", ret); +#endif +} + +static inline void vkd3d_cond_wait(struct vkd3d_cond *cond, struct vkd3d_mutex *lock) +{ +#ifdef _WIN32 + if (!SleepConditionVariableCS(&cond->cond, &lock->lock, INFINITE)) + ERR("Failed to wait on the condition variable, error %lu.\n", GetLastError()); +#else + int ret; + + if ((ret = pthread_cond_wait(&cond->cond, &lock->lock))) + ERR("Failed to wait on the condition variable, ret %d.\n", ret); +#endif +} + +static inline void vkd3d_cond_destroy(struct vkd3d_cond *cond) +{ +#ifdef _WIN32 + /* Nothing to do. */ +#else + int ret; + + if ((ret = pthread_cond_destroy(&cond->cond))) + ERR("Failed to destroy the condition variable, ret %d.\n", ret); +#endif +} + static inline void vkd3d_parse_version(const char *version, int *major, int *minor) { *major = atoi(version); diff --git a/libs/vkd3d/vkd3d_private.h b/libs/vkd3d/vkd3d_private.h index 9e7d70c3..fa9e1f05 100644 --- a/libs/vkd3d/vkd3d_private.h +++ b/libs/vkd3d/vkd3d_private.h @@ -24,10 +24,6 @@ #define VK_NO_PROTOTYPES #define CONST_VTABLE
-#ifdef _WIN32 -# define _WIN32_WINNT 0x0600 /* for condition variables */ -#endif - #include "vkd3d_common.h" #include "vkd3d_blob.h" #include "vkd3d_memory.h" @@ -205,36 +201,6 @@ union vkd3d_thread_handle void *handle; };
-struct vkd3d_cond -{ - CONDITION_VARIABLE cond; -}; - -static inline void vkd3d_cond_init(struct vkd3d_cond *cond) -{ - InitializeConditionVariable(&cond->cond); -} - -static inline void vkd3d_cond_signal(struct vkd3d_cond *cond) -{ - WakeConditionVariable(&cond->cond); -} - -static inline void vkd3d_cond_broadcast(struct vkd3d_cond *cond) -{ - WakeAllConditionVariable(&cond->cond); -} - -static inline void vkd3d_cond_wait(struct vkd3d_cond *cond, struct vkd3d_mutex *lock) -{ - if (!SleepConditionVariableCS(&cond->cond, &lock->lock, INFINITE)) - ERR("Could not sleep on the condition variable, error %lu.\n", GetLastError()); -} - -static inline void vkd3d_cond_destroy(struct vkd3d_cond *cond) -{ -} - static inline bool vkd3d_atomic_compare_exchange(unsigned int volatile *x, unsigned int cmp, unsigned int xchg) { return InterlockedCompareExchange((LONG volatile *)x, xchg, cmp) == cmp; @@ -265,56 +231,6 @@ union vkd3d_thread_handle void *handle; };
-struct vkd3d_cond -{ - pthread_cond_t cond; -}; - -static inline void vkd3d_cond_init(struct vkd3d_cond *cond) -{ - int ret; - - ret = pthread_cond_init(&cond->cond, NULL); - if (ret) - ERR("Could not initialize the condition variable, error %d.\n", ret); -} - -static inline void vkd3d_cond_signal(struct vkd3d_cond *cond) -{ - int ret; - - ret = pthread_cond_signal(&cond->cond); - if (ret) - ERR("Could not signal the condition variable, error %d.\n", ret); -} - -static inline void vkd3d_cond_broadcast(struct vkd3d_cond *cond) -{ - int ret; - - ret = pthread_cond_broadcast(&cond->cond); - if (ret) - ERR("Could not broadcast the condition variable, error %d.\n", ret); -} - -static inline void vkd3d_cond_wait(struct vkd3d_cond *cond, struct vkd3d_mutex *lock) -{ - int ret; - - ret = pthread_cond_wait(&cond->cond, &lock->lock); - if (ret) - ERR("Could not wait on the condition variable, error %d.\n", ret); -} - -static inline void vkd3d_cond_destroy(struct vkd3d_cond *cond) -{ - int ret; - - ret = pthread_cond_destroy(&cond->cond); - if (ret) - ERR("Could not destroy the condition variable, error %d.\n", ret); -} - # if HAVE_SYNC_BOOL_COMPARE_AND_SWAP static inline bool vkd3d_atomic_compare_exchange(unsigned int volatile *x, unsigned int cmp, unsigned int xchg) {