new branch for error management

This commit is contained in:
Kbz-8
2023-12-16 18:51:51 +01:00
parent 68d2c63694
commit 80e938c019
11 changed files with 86 additions and 41 deletions

View File

@@ -6,7 +6,7 @@
/* By: kbz_8 <kbz_8.dev@akel-engine.com> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2023/10/20 22:02:37 by kbz_8 #+# #+# */
/* Updated: 2023/12/10 22:44:55 by kbz_8 ### ########.fr */
/* Updated: 2023/12/16 14:47:53 by maldavid ### ########.fr */
/* */
/* ************************************************************************** */
@@ -17,7 +17,11 @@
#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))
#ifdef DEBUG
#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))
#else
#define VMA_ASSERT(expr) ((void)0)
#endif
#define VMA_IMPLEMENTATION
#ifdef MLX_COMPILER_CLANG
@@ -93,6 +97,7 @@ namespace mlx
#ifdef DEBUG
core::error::report(e_kind::message, "Graphics Allocator : created new buffer");
#endif
_active_allocations++;
return allocation;
}
@@ -103,6 +108,7 @@ namespace mlx
#ifdef DEBUG
core::error::report(e_kind::message, "Graphics Allocator : destroyed buffer");
#endif
_active_allocations--;
}
VmaAllocation GPUallocator::createImage(const VkImageCreateInfo* iminfo, const VmaAllocationCreateInfo* vinfo, VkImage& image, const char* name) noexcept
@@ -115,6 +121,7 @@ namespace mlx
#ifdef DEBUG
core::error::report(e_kind::message, "Graphics Allocator : created new image");
#endif
_active_allocations++;
return allocation;
}
@@ -125,6 +132,7 @@ namespace mlx
#ifdef DEBUG
core::error::report(e_kind::message, "Graphics Allocator : destroyed image");
#endif
_active_allocations--;
}
void GPUallocator::mapMemory(VmaAllocation allocation, void** data) noexcept
@@ -164,6 +172,8 @@ namespace mlx
void GPUallocator::destroy() noexcept
{
if(_active_allocations != 0)
core::error::report(e_kind::error, "Graphics allocator : some allocations were not freed before destroying the display (%d active allocations)", _active_allocations);
vmaDestroyAllocator(_allocator);
}
}