mirror of
https://gitlab.winehq.org/wine/vkd3d.git
synced 2025-01-28 13:05:02 -08:00
vkd3d: Replace atomic_add_fetch() by InterlockedAdd().
By analogy with InterlockedIncrement. It avoids the need for a configure check on Windows platforms. Signed-off-by: Alexandre Julliard <julliard@winehq.org> Signed-off-by: Henri Verbeet <hverbeet@codeweavers.com>
This commit is contained in:
parent
ab3aa96e1f
commit
beafa0914e
@ -201,6 +201,10 @@ static inline LONG InterlockedIncrement(LONG volatile *x)
|
|||||||
{
|
{
|
||||||
return __sync_add_and_fetch(x, 1);
|
return __sync_add_and_fetch(x, 1);
|
||||||
}
|
}
|
||||||
|
static inline LONG InterlockedAdd(LONG volatile *x, LONG val)
|
||||||
|
{
|
||||||
|
return __sync_add_and_fetch(x, val);
|
||||||
|
}
|
||||||
# else
|
# else
|
||||||
# error "InterlockedIncrement() not implemented for this platform"
|
# error "InterlockedIncrement() not implemented for this platform"
|
||||||
# endif /* HAVE_SYNC_ADD_AND_FETCH */
|
# endif /* HAVE_SYNC_ADD_AND_FETCH */
|
||||||
@ -215,15 +219,6 @@ static inline LONG InterlockedDecrement(LONG volatile *x)
|
|||||||
# endif
|
# endif
|
||||||
#endif /* _WIN32 */
|
#endif /* _WIN32 */
|
||||||
|
|
||||||
#if HAVE_SYNC_ADD_AND_FETCH
|
|
||||||
# define atomic_add_fetch(ptr, val) __sync_add_and_fetch(ptr, val)
|
|
||||||
#elif defined(_MSC_VER)
|
|
||||||
/* InterlockedAdd returns value after increment, like add_and_fetch. */
|
|
||||||
# define atomic_add_fetch(ptr, val) InterlockedAdd(ptr, val)
|
|
||||||
#else
|
|
||||||
# error "atomic_add_fetch() not implemented for this platform"
|
|
||||||
#endif /* HAVE_SYNC_ADD_AND_FETCH */
|
|
||||||
|
|
||||||
static inline void vkd3d_parse_version(const char *version, int *major, int *minor)
|
static inline void vkd3d_parse_version(const char *version, int *major, int *minor)
|
||||||
{
|
{
|
||||||
*major = atoi(version);
|
*major = atoi(version);
|
||||||
|
@ -288,7 +288,7 @@ static void vkd3d_fence_worker_remove_fence(struct vkd3d_fence_worker *worker, s
|
|||||||
LONG count;
|
LONG count;
|
||||||
int rc;
|
int rc;
|
||||||
|
|
||||||
if (!(count = atomic_add_fetch(&fence->pending_worker_operation_count, 0)))
|
if (!(count = InterlockedAdd(&fence->pending_worker_operation_count, 0)))
|
||||||
return;
|
return;
|
||||||
|
|
||||||
WARN("Waiting for %u pending fence operations (fence %p).\n", count, fence);
|
WARN("Waiting for %u pending fence operations (fence %p).\n", count, fence);
|
||||||
@ -299,7 +299,7 @@ static void vkd3d_fence_worker_remove_fence(struct vkd3d_fence_worker *worker, s
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
while ((count = atomic_add_fetch(&fence->pending_worker_operation_count, 0)))
|
while ((count = InterlockedAdd(&fence->pending_worker_operation_count, 0)))
|
||||||
{
|
{
|
||||||
TRACE("Still waiting for %u pending fence operations (fence %p).\n", count, fence);
|
TRACE("Still waiting for %u pending fence operations (fence %p).\n", count, fence);
|
||||||
|
|
||||||
@ -410,7 +410,7 @@ static void *vkd3d_fence_worker_main(void *arg)
|
|||||||
{
|
{
|
||||||
vkd3d_wait_for_gpu_fences(worker);
|
vkd3d_wait_for_gpu_fences(worker);
|
||||||
|
|
||||||
if (!worker->fence_count || atomic_add_fetch(&worker->enqueued_fence_count, 0))
|
if (!worker->fence_count || InterlockedAdd(&worker->enqueued_fence_count, 0))
|
||||||
{
|
{
|
||||||
if ((rc = pthread_mutex_lock(&worker->mutex)))
|
if ((rc = pthread_mutex_lock(&worker->mutex)))
|
||||||
{
|
{
|
||||||
|
@ -192,7 +192,7 @@ struct vkd3d_fence_worker
|
|||||||
bool should_exit;
|
bool should_exit;
|
||||||
bool pending_fence_destruction;
|
bool pending_fence_destruction;
|
||||||
|
|
||||||
size_t enqueued_fence_count;
|
LONG enqueued_fence_count;
|
||||||
struct vkd3d_enqueued_fence
|
struct vkd3d_enqueued_fence
|
||||||
{
|
{
|
||||||
VkFence vk_fence;
|
VkFence vk_fence;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user