diff --git a/rpcs3/Emu/RSX/VK/VKHelpers.h b/rpcs3/Emu/RSX/VK/VKHelpers.h index 7baf5698d5..dbbc22cb5b 100644 --- a/rpcs3/Emu/RSX/VK/VKHelpers.h +++ b/rpcs3/Emu/RSX/VK/VKHelpers.h @@ -22,16 +22,8 @@ #include "../display.h" #include "../rsx_utils.h" -#define VMA_ATOMIC_UINT32 atomic_t -#define VMA_ATOMIC_UINT64 atomic_t -#define compare_exchange_strong compare_exchange -#define compare_exchange_weak compare_exchange - #include "3rdparty/GPUOpen/include/vk_mem_alloc.h" -#undef compare_exchange_strong -#undef compare_exchange_weak - #ifdef __APPLE__ #define VK_DISABLE_COMPONENT_SWIZZLE 1 #else diff --git a/rpcs3/Emu/RSX/VK/VKMemAlloc.cpp b/rpcs3/Emu/RSX/VK/VKMemAlloc.cpp index 9c82751ef3..9be348e403 100644 --- a/rpcs3/Emu/RSX/VK/VKMemAlloc.cpp +++ b/rpcs3/Emu/RSX/VK/VKMemAlloc.cpp @@ -1,12 +1,40 @@ #define VMA_IMPLEMENTATION #include "util/atomic.hpp" +#include "Utilities/mutex.h" +// Protect some STL headers from macro (add more if it fails to compile) +#include +#include +#include +#include + +// Replace VMA atomics with atomic_t #define VMA_ATOMIC_UINT32 atomic_t #define VMA_ATOMIC_UINT64 atomic_t #define compare_exchange_strong compare_exchange #define compare_exchange_weak compare_exchange +// Replace VMA mutex with shared_mutex +class VmaRWMutex +{ +public: + void LockRead() { m_mutex.lock_shared(); } + void UnlockRead() { m_mutex.unlock_shared(); } + bool TryLockRead() { return m_mutex.try_lock_shared(); } + void LockWrite() { m_mutex.lock(); } + void UnlockWrite() { m_mutex.unlock(); } + bool TryLockWrite() { return m_mutex.try_lock(); } + void Lock() { m_mutex.lock(); } + void Unlock() { m_mutex.unlock(); } + bool TryLock() { return m_mutex.try_lock(); } +private: + shared_mutex m_mutex; +}; + +#define VMA_RW_MUTEX VmaRWMutex +#define VMA_MUTEX VmaRWMutex + #ifdef _MSC_VER #pragma warning(push, 0) #else