mirror of
https://gitlab.winehq.org/wine/vkd3d.git
synced 2024-11-21 16:46:41 -08:00
vkd3d: Move the vkd3d_cond implementation to vkd3d-common.
Much like the vkd3d_mutex implementation.
This commit is contained in:
parent
8345b9b6f5
commit
7b4a1fdfbc
Notes:
Alexandre Julliard
2024-04-22 23:39:23 +02:00
Approved-by: Giovanni Mascellani (@giomasce) Approved-by: Alexandre Julliard (@julliard) Merge-Request: https://gitlab.winehq.org/wine/vkd3d/-/merge_requests/818
@ -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
|
||||
|
||||
|
@ -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])
|
||||
|
@ -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);
|
||||
|
@ -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)
|
||||
{
|
||||
|
Loading…
Reference in New Issue
Block a user