mirror of
https://github.com/seekrs/MacroLibX.git
synced 2026-01-11 14:43:34 +00:00
fixing memory management issue, VMA uses custom asserts
This commit is contained in:
@@ -10,6 +10,8 @@
|
||||
/* */
|
||||
/* ************************************************************************** */
|
||||
|
||||
#include <core/application.h>
|
||||
|
||||
namespace mlx::core
|
||||
{
|
||||
void Application::getMousePos(int* x, int* y) noexcept
|
||||
|
||||
@@ -6,7 +6,7 @@
|
||||
/* By: maldavid <kbz_8.dev@akel-engine.com> +#+ +:+ +#+ */
|
||||
/* +#+#+#+#+#+ +#+ */
|
||||
/* Created: 2022/10/04 17:35:20 by maldavid #+# #+# */
|
||||
/* Updated: 2023/04/25 15:23:05 by maldavid ### ########.fr */
|
||||
/* Updated: 2023/11/14 11:43:30 by maldavid ### ########.fr */
|
||||
/* */
|
||||
/* ************************************************************************** */
|
||||
|
||||
@@ -20,7 +20,14 @@ extern "C"
|
||||
{
|
||||
void* mlx_init()
|
||||
{
|
||||
static bool init = false;
|
||||
if(init)
|
||||
{
|
||||
mlx::core::error::report(e_kind::error, "MLX cannot be initialized multiple times");
|
||||
return NULL;
|
||||
}
|
||||
mlx::Render_Core::get().init();
|
||||
init = true;
|
||||
return new mlx::core::Application();
|
||||
}
|
||||
|
||||
|
||||
@@ -6,7 +6,7 @@
|
||||
/* By: maldavid <kbz_8.dev@akel-engine.com> +#+ +:+ +#+ */
|
||||
/* +#+#+#+#+#+ +#+ */
|
||||
/* Created: 2023/04/02 14:49:49 by maldavid #+# #+# */
|
||||
/* Updated: 2023/11/08 20:41:29 by maldavid ### ########.fr */
|
||||
/* Updated: 2023/11/14 11:39:55 by maldavid ### ########.fr */
|
||||
/* */
|
||||
/* ************************************************************************** */
|
||||
|
||||
@@ -38,13 +38,12 @@ namespace mlx
|
||||
inline std::shared_ptr<MLX_Window> getWindow();
|
||||
|
||||
inline void beginRender() noexcept;
|
||||
void endRender() noexcept;
|
||||
|
||||
inline void clearRenderData() noexcept;
|
||||
inline void pixelPut(int x, int y, uint32_t color) noexcept;
|
||||
inline void stringPut(int x, int y, int color, std::string str);
|
||||
inline void texturePut(Texture* texture, int x, int y);
|
||||
|
||||
void endRender() noexcept;
|
||||
|
||||
~GraphicsSupport();
|
||||
|
||||
|
||||
@@ -6,7 +6,7 @@
|
||||
/* By: maldavid <kbz_8.dev@akel-engine.com> +#+ +:+ +#+ */
|
||||
/* +#+#+#+#+#+ +#+ */
|
||||
/* Created: 2022/10/08 18:55:57 by maldavid #+# #+# */
|
||||
/* Updated: 2023/11/14 07:35:22 by maldavid ### ########.fr */
|
||||
/* Updated: 2023/11/14 09:31:58 by maldavid ### ########.fr */
|
||||
/* */
|
||||
/* ************************************************************************** */
|
||||
|
||||
@@ -54,7 +54,9 @@ namespace mlx
|
||||
{
|
||||
if(_is_mapped)
|
||||
unmapMem();
|
||||
Render_Core::get().getAllocator().destroyBuffer(_allocation, _buffer);
|
||||
if(_buffer != VK_NULL_HANDLE)
|
||||
Render_Core::get().getAllocator().destroyBuffer(_allocation, _buffer);
|
||||
_buffer = VK_NULL_HANDLE;
|
||||
}
|
||||
|
||||
void Buffer::createBuffer(VkBufferUsageFlags usage, VmaAllocationCreateInfo info, VkDeviceSize size, const char* name)
|
||||
|
||||
@@ -6,16 +6,18 @@
|
||||
/* By: kbz_8 <kbz_8.dev@akel-engine.com> +#+ +:+ +#+ */
|
||||
/* +#+#+#+#+#+ +#+ */
|
||||
/* Created: 2023/10/20 22:02:37 by kbz_8 #+# #+# */
|
||||
/* Updated: 2023/11/14 06:25:19 by maldavid ### ########.fr */
|
||||
/* Updated: 2023/11/14 12:45:29 by maldavid ### ########.fr */
|
||||
/* */
|
||||
/* ************************************************************************** */
|
||||
|
||||
#include <core/profile.h>
|
||||
#include <core/errors.h>
|
||||
#include <cstdio>
|
||||
|
||||
#define VMA_STATIC_VULKAN_FUNCTIONS 0
|
||||
#define VMA_DYNAMIC_VULKAN_FUNCTIONS 0
|
||||
#define VMA_VULKAN_VERSION 1002000
|
||||
#define VMA_ASSERT(expr) (static_cast<bool>(expr) ? void(0) : mlx::core::error::report(e_kind::fatal_error, "Graphics allocator : an assertion has been catched : '%s'", #expr))
|
||||
#define VMA_IMPLEMENTATION
|
||||
|
||||
#ifdef MLX_COMPILER_CLANG
|
||||
@@ -87,6 +89,7 @@ namespace mlx
|
||||
|
||||
void GPUallocator::destroyBuffer(VmaAllocation allocation, VkBuffer buffer) noexcept
|
||||
{
|
||||
vkDeviceWaitIdle(Render_Core::get().getDevice().get());
|
||||
vmaDestroyBuffer(_allocator, buffer, allocation);
|
||||
#ifdef DEBUG
|
||||
core::error::report(e_kind::message, "Graphics Allocator : destroyed buffer");
|
||||
@@ -108,6 +111,7 @@ namespace mlx
|
||||
|
||||
void GPUallocator::destroyImage(VmaAllocation allocation, VkImage image) noexcept
|
||||
{
|
||||
vkDeviceWaitIdle(Render_Core::get().getDevice().get());
|
||||
vmaDestroyImage(_allocator, image, allocation);
|
||||
#ifdef DEBUG
|
||||
core::error::report(e_kind::message, "Graphics Allocator : destroyed image");
|
||||
|
||||
@@ -6,7 +6,7 @@
|
||||
/* By: maldavid <kbz_8.dev@akel-engine.com> +#+ +:+ +#+ */
|
||||
/* +#+#+#+#+#+ +#+ */
|
||||
/* Created: 2023/10/20 02:13:03 by maldavid #+# #+# */
|
||||
/* Updated: 2023/11/14 03:12:59 by maldavid ### ########.fr */
|
||||
/* Updated: 2023/11/14 09:46:32 by maldavid ### ########.fr */
|
||||
/* */
|
||||
/* ************************************************************************** */
|
||||
|
||||
@@ -15,7 +15,6 @@
|
||||
|
||||
#include <volk.h>
|
||||
#include <vma.h>
|
||||
#include <cstdint>
|
||||
|
||||
namespace mlx
|
||||
{
|
||||
|
||||
@@ -6,7 +6,7 @@
|
||||
/* By: maldavid <kbz_8.dev@akel-engine.com> +#+ +:+ +#+ */
|
||||
/* +#+#+#+#+#+ +#+ */
|
||||
/* Created: 2022/12/17 23:33:34 by maldavid #+# #+# */
|
||||
/* Updated: 2023/10/21 00:06:36 by kbz_8 ### ########.fr */
|
||||
/* Updated: 2023/11/14 08:15:42 by maldavid ### ########.fr */
|
||||
/* */
|
||||
/* ************************************************************************** */
|
||||
|
||||
@@ -24,7 +24,7 @@
|
||||
#include <mutex>
|
||||
|
||||
#ifdef DEBUG
|
||||
#warning "MLX is being compiled in debug mode, this activates Vulkan's validation layers and debug messages which may impact rendering performances"
|
||||
#warning MLX is being compiled in debug mode, this activates Vulkan's validation layers and debug messages which may impact rendering performances
|
||||
#endif
|
||||
|
||||
namespace mlx
|
||||
|
||||
@@ -6,7 +6,7 @@
|
||||
/* By: maldavid <kbz_8.dev@akel-engine.com> +#+ +:+ +#+ */
|
||||
/* +#+#+#+#+#+ +#+ */
|
||||
/* Created: 2023/01/25 11:59:07 by maldavid #+# #+# */
|
||||
/* Updated: 2023/11/14 03:15:33 by maldavid ### ########.fr */
|
||||
/* Updated: 2023/11/14 09:31:39 by maldavid ### ########.fr */
|
||||
/* */
|
||||
/* ************************************************************************** */
|
||||
|
||||
@@ -200,7 +200,9 @@ namespace mlx
|
||||
if(_image_view != VK_NULL_HANDLE)
|
||||
vkDestroyImageView(Render_Core::get().getDevice().get(), _image_view, nullptr);
|
||||
|
||||
Render_Core::get().getAllocator().destroyImage(_allocation, _image);
|
||||
if(_image != VK_NULL_HANDLE)
|
||||
Render_Core::get().getAllocator().destroyImage(_allocation, _image);
|
||||
_image = VK_NULL_HANDLE;
|
||||
if(_transfer_cmd.isInit())
|
||||
_transfer_cmd.destroy();
|
||||
_pool.destroy();
|
||||
|
||||
@@ -6,7 +6,7 @@
|
||||
/* By: maldavid <kbz_8.dev@akel-engine.com> +#+ +:+ +#+ */
|
||||
/* +#+#+#+#+#+ +#+ */
|
||||
/* Created: 2023/04/06 16:24:11 by maldavid #+# #+# */
|
||||
/* Updated: 2023/04/12 13:25:33 by maldavid ### ########.fr */
|
||||
/* Updated: 2023/11/14 12:43:45 by maldavid ### ########.fr */
|
||||
/* */
|
||||
/* ************************************************************************** */
|
||||
|
||||
@@ -59,7 +59,7 @@ namespace mlx
|
||||
void init(Renderer* renderer) noexcept;
|
||||
void put(int x, int y, int color, std::string str);
|
||||
inline VkDescriptorSet getDescriptorSet() noexcept { return _atlas.getSet(); }
|
||||
inline void clear() { _drawlist.clear(); }
|
||||
inline void clear() { _drawlist.clear(); _library.clearLibrary(); }
|
||||
void render();
|
||||
void destroy() noexcept;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user