fixing valgrind issues, injecting garbage collector inside vulkan's funtions

This commit is contained in:
2024-12-13 02:51:52 +01:00
parent 34ea0822a7
commit f78c3e9f0f
8 changed files with 165 additions and 160 deletions

View File

@@ -9,6 +9,7 @@ namespace mlx
MemManager();
static void* Malloc(std::size_t size);
static void* AlignedMalloc(std::size_t alignment, std::size_t size);
static void* Calloc(std::size_t n, std::size_t size);
static void* Realloc(void* ptr, std::size_t size);
static void Free(void* ptr);

View File

@@ -24,6 +24,8 @@ namespace mlx
void FontRegistry::Reset()
{
for(auto& font: m_fonts_registry)
font->Destroy();
m_fonts_registry.clear();
}
}

View File

@@ -67,10 +67,14 @@
#include <math.h> // sincos
#endif
#include <Core/Memory.h>
#define VMA_STATIC_VULKAN_FUNCTIONS 0
#define VMA_DYNAMIC_VULKAN_FUNCTIONS 0
#define VMA_VULKAN_VERSION 1000000
#define VMA_ASSERT(expr) ((void)0) // Because why not
#define VMA_SYSTEM_ALIGNED_MALLOC(size, alignment) (mlx::MemManager::AlignedMalloc(alignment, size))
#define VMA_SYSTEM_ALIGNED_FREE(ptr) (mlx::MemManager::Free(ptr))
#define VMA_ASSERT_LEAK(expr) ((void)0) // Because why not
#ifdef MLX_COMPILER_CLANG
#pragma clang diagnostic push

View File

@@ -8,7 +8,7 @@ namespace mlx
public:
GPUAllocator() = default;
void Init() noexcept;
void Init(const VkAllocationCallbacks* callbacks) noexcept;
void Destroy() noexcept;
VmaAllocation CreateBuffer(const VkBufferCreateInfo* binfo, const VmaAllocationCreateInfo* vinfo, VkBuffer& buffer, const char* name = nullptr) noexcept;