2018-05-23 16:02:35 +02:00
|
|
|
#define VMA_IMPLEMENTATION
|
2019-12-03 23:34:23 +01:00
|
|
|
|
2020-12-10 16:44:17 +01:00
|
|
|
#include "util/atomic.hpp"
|
2025-04-08 18:46:57 +02:00
|
|
|
#include "util/mutex.h"
|
2020-12-10 16:44:17 +01:00
|
|
|
|
2020-12-11 15:52:29 +01:00
|
|
|
// Protect some STL headers from macro (add more if it fails to compile)
|
|
|
|
|
#include <atomic>
|
|
|
|
|
#include <thread>
|
|
|
|
|
#include <memory>
|
|
|
|
|
#include <mutex>
|
|
|
|
|
|
|
|
|
|
// Replace VMA atomics with atomic_t
|
2020-12-10 16:44:17 +01:00
|
|
|
#define VMA_ATOMIC_UINT32 atomic_t<u32>
|
|
|
|
|
#define VMA_ATOMIC_UINT64 atomic_t<u64>
|
|
|
|
|
#define compare_exchange_strong compare_exchange
|
|
|
|
|
#define compare_exchange_weak compare_exchange
|
|
|
|
|
|
2020-12-11 15:52:29 +01:00
|
|
|
// Replace VMA mutex with shared_mutex
|
|
|
|
|
class VmaRWMutex
|
|
|
|
|
{
|
|
|
|
|
public:
|
2025-04-05 21:50:45 +02:00
|
|
|
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();
|
|
|
|
|
}
|
|
|
|
|
|
2020-12-11 15:52:29 +01:00
|
|
|
private:
|
|
|
|
|
shared_mutex m_mutex;
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
#define VMA_RW_MUTEX VmaRWMutex
|
|
|
|
|
#define VMA_MUTEX VmaRWMutex
|
|
|
|
|
|
2019-12-03 23:34:23 +01:00
|
|
|
#ifdef _MSC_VER
|
|
|
|
|
#pragma warning(push, 0)
|
|
|
|
|
#else
|
|
|
|
|
#pragma GCC diagnostic push
|
|
|
|
|
#pragma GCC diagnostic ignored "-Wall"
|
|
|
|
|
#pragma GCC diagnostic ignored "-Wextra"
|
|
|
|
|
#pragma GCC diagnostic ignored "-Wold-style-cast"
|
2021-01-12 11:01:06 +01:00
|
|
|
#pragma GCC diagnostic ignored "-Wunused-variable"
|
2021-02-15 16:45:54 +01:00
|
|
|
#pragma GCC diagnostic ignored "-Wsuggest-override"
|
2021-03-05 20:05:37 +01:00
|
|
|
#pragma GCC diagnostic ignored "-Wunused-parameter"
|
2021-03-08 21:41:23 +01:00
|
|
|
#pragma GCC diagnostic ignored "-Wstrict-aliasing"
|
2024-01-07 12:56:08 +01:00
|
|
|
#pragma GCC diagnostic ignored "-Wimplicit-fallthrough"
|
2021-02-15 16:45:54 +01:00
|
|
|
#ifdef __clang__
|
|
|
|
|
#pragma clang diagnostic ignored "-Winconsistent-missing-override"
|
2023-07-11 20:40:30 +02:00
|
|
|
#else
|
|
|
|
|
#pragma GCC diagnostic ignored "-Wsuggest-attribute=noreturn"
|
2021-02-15 16:45:54 +01:00
|
|
|
#endif
|
2019-12-03 23:34:23 +01:00
|
|
|
#endif
|
2025-03-26 18:42:38 +01:00
|
|
|
#include "3rdparty/GPUOpen/VulkanMemoryAllocator/src/vk_mem_alloc.h"
|
2019-12-03 23:34:23 +01:00
|
|
|
#ifdef _MSC_VER
|
|
|
|
|
#pragma warning(pop)
|
|
|
|
|
#else
|
|
|
|
|
#pragma GCC diagnostic pop
|
|
|
|
|
#endif
|