working on garbage collection, fixing small issues with font destroy

This commit is contained in:
2024-12-14 01:39:50 +01:00
parent f78c3e9f0f
commit 7bd2b9c4c7
9 changed files with 90 additions and 26 deletions

View File

@@ -9,9 +9,9 @@
#define STB_IMAGE_IMPLEMENTATION
#define STBI_ASSERT(x) (mlx::Assert(x, "internal stb assertion " #x))
#define STBI_MALLOC(x) (mlx::MemManager::Get().Malloc(x))
#define STBI_REALLOC(p, x) (mlx::MemManager::Get().Realloc(p, x))
#define STBI_FREE(x) (mlx::MemManager::Get().Free(x))
#define STBI_MALLOC(x) (mlx::MemManager::Malloc(x))
#define STBI_REALLOC(p, x) (mlx::MemManager::Realloc(p, x))
#define STBI_FREE(x) (mlx::MemManager::Free(x))
#ifdef MLX_COMPILER_GCC
#pragma GCC diagnostic push
@@ -295,7 +295,7 @@ namespace mlx
int channels;
std::uint8_t* data = stbi_load(filename.c_str(), &size.x, &size.y, &channels, 4);
CallOnExit defer([=]() { stbi_image_free(data); });
CallOnExit defer([&]() { stbi_image_free(data); });
CPUBuffer buffer(size.x * size.y * 4);
std::memcpy(buffer.GetData(), data, buffer.GetSize());

View File

@@ -59,9 +59,9 @@ namespace mlx
return MemManager::AlignedMalloc(alignment, size);
}
void* VulkanReallocationFunction(void*, void* ptr, std::size_t size, std::size_t, VkSystemAllocationScope)
void* VulkanReallocationFunction(void*, void* ptr, std::size_t size, std::size_t alignment, VkSystemAllocationScope)
{
return MemManager::Realloc(ptr, size);
return MemManager::AlignedRealloc(ptr, alignment, size);
}
void VulkanFreeFunction(void*, void* ptr)

View File

@@ -102,6 +102,7 @@ namespace mlx
VkFence fence = kvfCreateFence(RenderCore::Get().GetDevice());
kvfSubmitSingleTimeCommandBuffer(RenderCore::Get().GetDevice(), cmd, KVF_GRAPHICS_QUEUE, fence);
kvfDestroyFence(RenderCore::Get().GetDevice(), fence);
m_resize = false;
DebugLog("Vulkan: swapchain created");
}
}