From 854a074cacee7bf72315f1b708ef26f8e21503b3 Mon Sep 17 00:00:00 2001 From: Kbz-8 Date: Thu, 7 Dec 2023 23:19:56 +0100 Subject: [PATCH] fixing memory leaks, begenning xmake support to build on windows --- Makefile | 4 +- src/core/bridge.cpp | 4 +- src/core/memory.cpp | 47 ++++ src/core/memory.h | 38 +++ .../descriptors/vk_descriptor_set.cpp | 2 +- src/renderer/descriptors/vk_descriptor_set.h | 2 +- src/renderer/images/texture_atlas.h | 4 +- src/renderer/text_pipeline.cpp | 22 +- test/memory_dump0.json | 234 ++++++++++++++++++ test/memory_dump1.json | 232 +++++++++++++++++ test/memory_dump2.json | 232 +++++++++++++++++ test/memory_dump3.json | 232 +++++++++++++++++ test/memory_dump4.json | 232 +++++++++++++++++ xmake.lua | 38 +++ 14 files changed, 1306 insertions(+), 17 deletions(-) create mode 100644 src/core/memory.cpp create mode 100644 src/core/memory.h create mode 100644 test/memory_dump0.json create mode 100644 test/memory_dump1.json create mode 100644 test/memory_dump2.json create mode 100644 test/memory_dump3.json create mode 100644 test/memory_dump4.json create mode 100644 xmake.lua diff --git a/Makefile b/Makefile index 295a146..f5c7986 100644 --- a/Makefile +++ b/Makefile @@ -6,7 +6,7 @@ # By: maldavid +#+ +:+ +#+ # # +#+#+#+#+#+ +#+ # # Created: 2022/10/04 16:43:41 by maldavid #+# #+# # -# Updated: 2023/11/24 10:03:17 by maldavid ### ########.fr # +# Updated: 2023/12/07 15:25:52 by kbz_8 ### ########.fr # # # # **************************************************************************** # @@ -17,7 +17,7 @@ SRCS += $(wildcard $(addsuffix /*.cpp, ./src/platform)) SRCS += $(wildcard $(addsuffix /*.cpp, ./src/renderer)) SRCS += $(wildcard $(addsuffix /*.cpp, ./src/renderer/**)) -OBJ_DIR = objs +OBJ_DIR = objs/makefile OBJS = $(addprefix $(OBJ_DIR)/, $(SRCS:.cpp=.o)) OS = $(shell uname -s) diff --git a/src/core/bridge.cpp b/src/core/bridge.cpp index 9b1fb36..9240ddc 100644 --- a/src/core/bridge.cpp +++ b/src/core/bridge.cpp @@ -6,7 +6,7 @@ /* By: maldavid +#+ +:+ +#+ */ /* +#+#+#+#+#+ +#+ */ /* Created: 2022/10/04 17:35:20 by maldavid #+# #+# */ -/* Updated: 2023/11/25 10:12:36 by maldavid ### ########.fr */ +/* Updated: 2023/12/07 23:05:05 by kbz_8 ### ########.fr */ /* */ /* ************************************************************************** */ @@ -26,8 +26,8 @@ extern "C" mlx::core::error::report(e_kind::error, "MLX cannot be initialized multiple times"); return NULL; } - mlx::Render_Core::get().init(); mlx::core::Application* app = new mlx::core::Application; + mlx::Render_Core::get().init(); if(app == nullptr) mlx::core::error::report(e_kind::fatal_error, "Tout a pété"); init = true; diff --git a/src/core/memory.cpp b/src/core/memory.cpp new file mode 100644 index 0000000..69cdd8e --- /dev/null +++ b/src/core/memory.cpp @@ -0,0 +1,47 @@ +/* ************************************************************************** */ +/* */ +/* ::: :::::::: */ +/* memory.cpp :+: :+: :+: */ +/* +:+ +:+ +:+ */ +/* By: kbz_8 +#+ +:+ +#+ */ +/* +#+#+#+#+#+ +#+ */ +/* Created: 2023/12/07 16:32:01 by kbz_8 #+# #+# */ +/* Updated: 2023/12/07 16:43:56 by kbz_8 ### ########.fr */ +/* */ +/* ************************************************************************** */ + +#include +#include +#include +#include + +namespace mlx +{ + void* MemManager::alloc(std::size_t size) + { + void* ptr = std::malloc(size); + if(ptr != nullptr) + _blocks.push_back(ptr); + return ptr; + } + + void MemManager::free(void* ptr) + { + auto it = std::find(_blocks.begin(), _blocks.end(), ptr); + if(it == _blocks.end()) + { + core::error::report(e_kind::error, "Memory Manager : trying to free a pointer not allocated by the memory manager"); + return; + } + std::free(*it); + _blocks.erase(it); + } + + MemManager::~MemManager() + { + std::for_each(_blocks.begin(), _blocks.end(), [](void* ptr) + { + std::free(ptr); + }); + } +} diff --git a/src/core/memory.h b/src/core/memory.h new file mode 100644 index 0000000..a72dea5 --- /dev/null +++ b/src/core/memory.h @@ -0,0 +1,38 @@ +/* ************************************************************************** */ +/* */ +/* ::: :::::::: */ +/* memory.h :+: :+: :+: */ +/* +:+ +:+ +:+ */ +/* By: kbz_8 +#+ +:+ +#+ */ +/* +#+#+#+#+#+ +#+ */ +/* Created: 2023/12/07 16:31:51 by kbz_8 #+# #+# */ +/* Updated: 2023/12/07 16:37:15 by kbz_8 ### ########.fr */ +/* */ +/* ************************************************************************** */ + +#ifndef __MLX_MEMORY__ +#define __MLX_MEMORY__ + +#include +#include + +namespace mlx +{ + class MemManager : public Singleton + { + friend class Singleton; + + public: + void* alloc(std::size_t size); + void free(void* ptr); + + private: + MemManager() = default; + ~MemManager(); + + private: + std::list _blocks; + }; +} + +#endif diff --git a/src/renderer/descriptors/vk_descriptor_set.cpp b/src/renderer/descriptors/vk_descriptor_set.cpp index bde9e16..28bc816 100644 --- a/src/renderer/descriptors/vk_descriptor_set.cpp +++ b/src/renderer/descriptors/vk_descriptor_set.cpp @@ -6,7 +6,7 @@ /* By: maldavid +#+ +:+ +#+ */ /* +#+#+#+#+#+ +#+ */ /* Created: 2023/01/23 18:40:44 by maldavid #+# #+# */ -/* Updated: 2023/11/12 01:14:52 by maldavid ### ########.fr */ +/* Updated: 2023/12/07 20:00:13 by kbz_8 ### ########.fr */ /* */ /* ************************************************************************** */ diff --git a/src/renderer/descriptors/vk_descriptor_set.h b/src/renderer/descriptors/vk_descriptor_set.h index 2a10be0..0d39d72 100644 --- a/src/renderer/descriptors/vk_descriptor_set.h +++ b/src/renderer/descriptors/vk_descriptor_set.h @@ -6,7 +6,7 @@ /* By: maldavid +#+ +:+ +#+ */ /* +#+#+#+#+#+ +#+ */ /* Created: 2023/01/23 18:39:36 by maldavid #+# #+# */ -/* Updated: 2023/03/31 17:28:36 by maldavid ### ########.fr */ +/* Updated: 2023/12/07 19:47:07 by kbz_8 ### ########.fr */ /* */ /* ************************************************************************** */ diff --git a/src/renderer/images/texture_atlas.h b/src/renderer/images/texture_atlas.h index db142c2..74c7c90 100644 --- a/src/renderer/images/texture_atlas.h +++ b/src/renderer/images/texture_atlas.h @@ -6,7 +6,7 @@ /* By: maldavid +#+ +:+ +#+ */ /* +#+#+#+#+#+ +#+ */ /* Created: 2023/04/07 16:36:33 by maldavid #+# #+# */ -/* Updated: 2023/11/14 05:36:30 by maldavid ### ########.fr */ +/* Updated: 2023/12/07 18:50:53 by kbz_8 ### ########.fr */ /* */ /* ************************************************************************** */ @@ -28,7 +28,7 @@ namespace mlx void render(class Renderer& renderer, int x, int y, uint32_t ibo_size); void destroy() noexcept override; - inline void setDescriptor(DescriptorSet set) noexcept { _set = std::move(set); } + inline void setDescriptor(DescriptorSet&& set) noexcept { _set = set; } inline VkDescriptorSet getSet() noexcept { return _set.isInit() ? _set.get() : VK_NULL_HANDLE; } inline void updateSet(int binding) noexcept { _set.writeDescriptor(binding, getImageView(), getSampler()); } diff --git a/src/renderer/text_pipeline.cpp b/src/renderer/text_pipeline.cpp index 7f6866b..48b8f08 100644 --- a/src/renderer/text_pipeline.cpp +++ b/src/renderer/text_pipeline.cpp @@ -6,7 +6,7 @@ /* By: maldavid +#+ +:+ +#+ */ /* +#+#+#+#+#+ +#+ */ /* Created: 2023/04/06 16:41:13 by maldavid #+# #+# */ -/* Updated: 2023/11/25 10:40:39 by maldavid ### ########.fr */ +/* Updated: 2023/12/07 22:29:45 by kbz_8 ### ########.fr */ /* */ /* ************************************************************************** */ @@ -20,7 +20,11 @@ #define STB_RECT_PACK_IMPLEMENTATION #include +#include + #define STB_TRUETYPE_IMPLEMENTATION +#define STB_malloc(x, u) ((void)(u), MemManager::get().alloc(x)) +#define STB_free(x, u) ((void)(u), MemManager::get().free(x)) #include constexpr const int RANGE = 1024; @@ -74,10 +78,10 @@ namespace mlx void TextPutPipeline::init(Renderer* renderer) noexcept { _renderer = renderer; - uint8_t tmp_bitmap[RANGE * RANGE]; - uint8_t vulkan_bitmap[RANGE * RANGE * 4]; + std::vector tmp_bitmap(RANGE * RANGE); + std::vector vulkan_bitmap(RANGE * RANGE * 4); stbtt_pack_context pc; - stbtt_PackBegin(&pc, tmp_bitmap, RANGE, RANGE, RANGE, 1, nullptr); + stbtt_PackBegin(&pc, tmp_bitmap.data(), RANGE, RANGE, RANGE, 1, nullptr); stbtt_PackFontRange(&pc, dogica_ttf, 0, 6.0, 32, 96, _cdata.data()); stbtt_PackEnd(&pc); for(int i = 0, j = 0; i < RANGE * RANGE; i++, j += 4) @@ -87,14 +91,14 @@ namespace mlx vulkan_bitmap[j + 2] = tmp_bitmap[i]; vulkan_bitmap[j + 3] = tmp_bitmap[i]; } - _atlas.create(vulkan_bitmap, RANGE, RANGE, VK_FORMAT_R8G8B8A8_UNORM, "__mlx_texts_pipeline_texture_atlas", true); + _atlas.create(vulkan_bitmap.data(), RANGE, RANGE, VK_FORMAT_R8G8B8A8_UNORM, "__mlx_texts_pipeline_texture_atlas", true); _atlas.setDescriptor(renderer->getFragDescriptorSet().duplicate()); } void TextPutPipeline::loadFont(const std::filesystem::path& filepath, float scale) { - uint8_t tmp_bitmap[RANGE * RANGE]; - uint8_t vulkan_bitmap[RANGE * RANGE * 4]; + std::vector tmp_bitmap(RANGE * RANGE); + std::vector vulkan_bitmap(RANGE * RANGE * 4); std::ifstream file(filepath, std::ios::binary); if(!file.is_open()) @@ -109,7 +113,7 @@ namespace mlx file.close(); stbtt_pack_context pc; - stbtt_PackBegin(&pc, tmp_bitmap, RANGE, RANGE, RANGE, 1, nullptr); + stbtt_PackBegin(&pc, tmp_bitmap.data(), RANGE, RANGE, RANGE, 1, nullptr); stbtt_PackFontRange(&pc, bytes.data(), 0, scale, 32, 96, _cdata.data()); stbtt_PackEnd(&pc); for(int i = 0, j = 0; i < RANGE * RANGE; i++, j += 4) @@ -120,7 +124,7 @@ namespace mlx vulkan_bitmap[j + 3] = tmp_bitmap[i]; } destroy(); - _atlas.create(vulkan_bitmap, RANGE, RANGE, VK_FORMAT_R8G8B8A8_UNORM, "__mlx_texts_pipeline_texture_atlas", true); + _atlas.create(vulkan_bitmap.data(), RANGE, RANGE, VK_FORMAT_R8G8B8A8_UNORM, "__mlx_texts_pipeline_texture_atlas", true); _atlas.setDescriptor(_renderer->getFragDescriptorSet().duplicate()); } diff --git a/test/memory_dump0.json b/test/memory_dump0.json new file mode 100644 index 0000000..a34c0d5 --- /dev/null +++ b/test/memory_dump0.json @@ -0,0 +1,234 @@ +{ + "General": { + "API": "Vulkan", + "apiVersion": "1.3.260", + "GPU": "NVIDIA GeForce GTX 1650", + "deviceType": 2, + "maxMemoryAllocationCount": 4294967295, + "bufferImageGranularity": 1024, + "nonCoherentAtomSize": 64, + "memoryHeapCount": 3, + "memoryTypeCount": 5 + }, + "Total": { + "BlockCount": 5, + "BlockBytes": 73007104, + "AllocationCount": 19, + "AllocationBytes": 2668256, + "UnusedRangeCount": 6, + "AllocationSizeMin": 12, + "AllocationSizeMax": 1048576, + "UnusedRangeSizeMin": 4, + "UnusedRangeSizeMax": 33433984 + }, + "MemoryInfo": { + "Heap 0": { + "Flags": ["DEVICE_LOCAL"], + "Size": 4294967296, + "Budget": { + "BudgetBytes": 3435973836, + "UsageBytes": 35422208 + }, + "Stats": { + "BlockCount": 3, + "BlockBytes": 35422208, + "AllocationCount": 14, + "AllocationBytes": 1988064, + "UnusedRangeCount": 4, + "AllocationSizeMin": 12, + "AllocationSizeMax": 1048576, + "UnusedRangeSizeMin": 4, + "UnusedRangeSizeMax": 33433984 + }, + "MemoryPools": { + "Type 1": { + "Flags": ["DEVICE_LOCAL"], + "Stats": { + "BlockCount": 3, + "BlockBytes": 35422208, + "AllocationCount": 14, + "AllocationBytes": 1988064, + "UnusedRangeCount": 4, + "AllocationSizeMin": 12, + "AllocationSizeMax": 1048576, + "UnusedRangeSizeMin": 4, + "UnusedRangeSizeMax": 33433984 + } + } + } + }, + "Heap 1": { + "Flags": [], + "Size": 6071976960, + "Budget": { + "BudgetBytes": 4857581568, + "UsageBytes": 33554432 + }, + "Stats": { + "BlockCount": 1, + "BlockBytes": 33554432, + "AllocationCount": 2, + "AllocationBytes": 680000, + "UnusedRangeCount": 1, + "AllocationSizeMin": 40000, + "AllocationSizeMax": 640000 + }, + "MemoryPools": { + "Type 0": { + "Flags": [], + "Stats": { + "BlockCount": 0, + "BlockBytes": 0, + "AllocationCount": 0, + "AllocationBytes": 0, + "UnusedRangeCount": 0 + } + }, + "Type 2": { + "Flags": ["HOST_VISIBLE", "HOST_COHERENT"], + "Stats": { + "BlockCount": 1, + "BlockBytes": 33554432, + "AllocationCount": 2, + "AllocationBytes": 680000, + "UnusedRangeCount": 1, + "AllocationSizeMin": 40000, + "AllocationSizeMax": 640000 + } + }, + "Type 3": { + "Flags": ["HOST_VISIBLE", "HOST_COHERENT", "HOST_CACHED"], + "Stats": { + "BlockCount": 0, + "BlockBytes": 0, + "AllocationCount": 0, + "AllocationBytes": 0, + "UnusedRangeCount": 0 + } + } + } + }, + "Heap 2": { + "Flags": ["DEVICE_LOCAL"], + "Size": 257949696, + "Budget": { + "BudgetBytes": 206359756, + "UsageBytes": 4030464 + }, + "Stats": { + "BlockCount": 1, + "BlockBytes": 4030464, + "AllocationCount": 3, + "AllocationBytes": 192, + "UnusedRangeCount": 1, + "AllocationSizeMin": 64, + "AllocationSizeMax": 64 + }, + "MemoryPools": { + "Type 4": { + "Flags": ["DEVICE_LOCAL", "HOST_VISIBLE", "HOST_COHERENT"], + "Stats": { + "BlockCount": 1, + "BlockBytes": 4030464, + "AllocationCount": 3, + "AllocationBytes": 192, + "UnusedRangeCount": 1, + "AllocationSizeMin": 64, + "AllocationSizeMax": 64 + } + } + } + } + }, + "DefaultPools": { + "Type 0": { + "PreferredBlockSize": 268435456, + "Blocks": { + }, + "DedicatedAllocations": [ + ] + }, + "Type 1": { + "PreferredBlockSize": 268435456, + "Blocks": { + "0": { + "MapRefCount": 0, + "TotalBytes": 33554432, + "UnusedBytes": 33434144, + "Allocations": 12, + "UnusedRanges": 4, + "Suballocations": [ + {"Offset": 0, "Type": "BUFFER", "Size": 128, "Usage": 130, "Name": "__mlx_pixel_put_pipeline_texture_GPU_vertex_buffer"}, + {"Offset": 128, "Type": "BUFFER", "Size": 12, "Usage": 66, "Name": "__mlx_pixel_put_pipeline_texture_GPU_index_buffer"}, + {"Offset": 140, "Type": "FREE", "Size": 4}, + {"Offset": 144, "Type": "BUFFER", "Size": 128, "Usage": 130, "Name": "42_logo.png_GPU_vertex_buffer"}, + {"Offset": 272, "Type": "BUFFER", "Size": 12, "Usage": 66, "Name": "42_logo.png_GPU_index_buffer"}, + {"Offset": 284, "Type": "FREE", "Size": 4}, + {"Offset": 288, "Type": "BUFFER", "Size": 128, "Usage": 130, "Name": "__mlx_unamed_user_texture_GPU_vertex_buffer"}, + {"Offset": 416, "Type": "BUFFER", "Size": 12, "Usage": 66, "Name": "__mlx_unamed_user_texture_GPU_index_buffer"}, + {"Offset": 428, "Type": "BUFFER", "Size": 288, "Usage": 66, "Name": "that text will disappear_GPU_index_buffer"}, + {"Offset": 716, "Type": "BUFFER", "Size": 156, "Usage": 66, "Name": "that's a text_GPU_index_buffer"}, + {"Offset": 872, "Type": "FREE", "Size": 152}, + {"Offset": 1024, "Type": "IMAGE_OPTIMAL", "Size": 57344, "Usage": 7, "Name": "42_logo.png"}, + {"Offset": 58368, "Type": "IMAGE_OPTIMAL", "Size": 57344, "Usage": 7, "Name": "__mlx_unamed_user_texture"}, + {"Offset": 115712, "Type": "BUFFER", "Size": 3072, "Usage": 130, "Name": "that text will disappear_GPU_vertex_buffer"}, + {"Offset": 118784, "Type": "BUFFER", "Size": 1664, "Usage": 130, "Name": "that's a text_GPU_vertex_buffer"}, + {"Offset": 120448, "Type": "FREE", "Size": 33433984} + ] + } + }, + "DedicatedAllocations": [ + {"Type": "IMAGE_OPTIMAL", "Size": 819200, "Usage": 7, "Name": "__mlx_pixel_put_pipeline_texture"}, + {"Type": "IMAGE_OPTIMAL", "Size": 1048576, "Usage": 7, "Name": "__mlx_texts_pipeline_texture_atlas"} + ] + }, + "Type 2": { + "PreferredBlockSize": 268435456, + "Blocks": { + "0": { + "MapRefCount": 2, + "TotalBytes": 33554432, + "UnusedBytes": 32874432, + "Allocations": 2, + "UnusedRanges": 1, + "Suballocations": [ + {"Offset": 0, "Type": "BUFFER", "Size": 640000, "Usage": 1, "Name": "__mlx_pixel_put_pipeline_texture_buffer"}, + {"Offset": 640000, "Type": "BUFFER", "Size": 40000, "Usage": 3, "Name": "__mlx_unamed_user_texture_buffer"}, + {"Offset": 680000, "Type": "FREE", "Size": 32874432} + ] + } + }, + "DedicatedAllocations": [ + ] + }, + "Type 3": { + "PreferredBlockSize": 268435456, + "Blocks": { + }, + "DedicatedAllocations": [ + ] + }, + "Type 4": { + "PreferredBlockSize": 32243712, + "Blocks": { + "0": { + "MapRefCount": 3, + "TotalBytes": 4030464, + "UnusedBytes": 4030272, + "Allocations": 3, + "UnusedRanges": 1, + "Suballocations": [ + {"Offset": 0, "Type": "BUFFER", "Size": 64, "Usage": 16, "Name": "__mlx_matrices_uniform_buffer_0_buffer"}, + {"Offset": 64, "Type": "BUFFER", "Size": 64, "Usage": 16, "Name": "__mlx_matrices_uniform_buffer_1_buffer"}, + {"Offset": 128, "Type": "BUFFER", "Size": 64, "Usage": 16, "Name": "__mlx_matrices_uniform_buffer_2_buffer"}, + {"Offset": 192, "Type": "FREE", "Size": 4030272} + ] + } + }, + "DedicatedAllocations": [ + ] + } + }, + "CustomPools": { + } +} \ No newline at end of file diff --git a/test/memory_dump1.json b/test/memory_dump1.json new file mode 100644 index 0000000..96ea825 --- /dev/null +++ b/test/memory_dump1.json @@ -0,0 +1,232 @@ +{ + "General": { + "API": "Vulkan", + "apiVersion": "1.3.260", + "GPU": "NVIDIA GeForce GTX 1650", + "deviceType": 2, + "maxMemoryAllocationCount": 4294967295, + "bufferImageGranularity": 1024, + "nonCoherentAtomSize": 64, + "memoryHeapCount": 3, + "memoryTypeCount": 5 + }, + "Total": { + "BlockCount": 5, + "BlockBytes": 73007104, + "AllocationCount": 17, + "AllocationBytes": 2664896, + "UnusedRangeCount": 6, + "AllocationSizeMin": 12, + "AllocationSizeMax": 1048576, + "UnusedRangeSizeMin": 4, + "UnusedRangeSizeMax": 33437056 + }, + "MemoryInfo": { + "Heap 0": { + "Flags": ["DEVICE_LOCAL"], + "Size": 4294967296, + "Budget": { + "BudgetBytes": 3435973836, + "UsageBytes": 35422208 + }, + "Stats": { + "BlockCount": 3, + "BlockBytes": 35422208, + "AllocationCount": 12, + "AllocationBytes": 1984704, + "UnusedRangeCount": 4, + "AllocationSizeMin": 12, + "AllocationSizeMax": 1048576, + "UnusedRangeSizeMin": 4, + "UnusedRangeSizeMax": 33437056 + }, + "MemoryPools": { + "Type 1": { + "Flags": ["DEVICE_LOCAL"], + "Stats": { + "BlockCount": 3, + "BlockBytes": 35422208, + "AllocationCount": 12, + "AllocationBytes": 1984704, + "UnusedRangeCount": 4, + "AllocationSizeMin": 12, + "AllocationSizeMax": 1048576, + "UnusedRangeSizeMin": 4, + "UnusedRangeSizeMax": 33437056 + } + } + } + }, + "Heap 1": { + "Flags": [], + "Size": 6071976960, + "Budget": { + "BudgetBytes": 4857581568, + "UsageBytes": 33554432 + }, + "Stats": { + "BlockCount": 1, + "BlockBytes": 33554432, + "AllocationCount": 2, + "AllocationBytes": 680000, + "UnusedRangeCount": 1, + "AllocationSizeMin": 40000, + "AllocationSizeMax": 640000 + }, + "MemoryPools": { + "Type 0": { + "Flags": [], + "Stats": { + "BlockCount": 0, + "BlockBytes": 0, + "AllocationCount": 0, + "AllocationBytes": 0, + "UnusedRangeCount": 0 + } + }, + "Type 2": { + "Flags": ["HOST_VISIBLE", "HOST_COHERENT"], + "Stats": { + "BlockCount": 1, + "BlockBytes": 33554432, + "AllocationCount": 2, + "AllocationBytes": 680000, + "UnusedRangeCount": 1, + "AllocationSizeMin": 40000, + "AllocationSizeMax": 640000 + } + }, + "Type 3": { + "Flags": ["HOST_VISIBLE", "HOST_COHERENT", "HOST_CACHED"], + "Stats": { + "BlockCount": 0, + "BlockBytes": 0, + "AllocationCount": 0, + "AllocationBytes": 0, + "UnusedRangeCount": 0 + } + } + } + }, + "Heap 2": { + "Flags": ["DEVICE_LOCAL"], + "Size": 257949696, + "Budget": { + "BudgetBytes": 206359756, + "UsageBytes": 4030464 + }, + "Stats": { + "BlockCount": 1, + "BlockBytes": 4030464, + "AllocationCount": 3, + "AllocationBytes": 192, + "UnusedRangeCount": 1, + "AllocationSizeMin": 64, + "AllocationSizeMax": 64 + }, + "MemoryPools": { + "Type 4": { + "Flags": ["DEVICE_LOCAL", "HOST_VISIBLE", "HOST_COHERENT"], + "Stats": { + "BlockCount": 1, + "BlockBytes": 4030464, + "AllocationCount": 3, + "AllocationBytes": 192, + "UnusedRangeCount": 1, + "AllocationSizeMin": 64, + "AllocationSizeMax": 64 + } + } + } + } + }, + "DefaultPools": { + "Type 0": { + "PreferredBlockSize": 268435456, + "Blocks": { + }, + "DedicatedAllocations": [ + ] + }, + "Type 1": { + "PreferredBlockSize": 268435456, + "Blocks": { + "0": { + "MapRefCount": 0, + "TotalBytes": 33554432, + "UnusedBytes": 33437504, + "Allocations": 10, + "UnusedRanges": 4, + "Suballocations": [ + {"Offset": 0, "Type": "BUFFER", "Size": 128, "Usage": 130, "Name": "__mlx_pixel_put_pipeline_texture_GPU_vertex_buffer"}, + {"Offset": 128, "Type": "BUFFER", "Size": 12, "Usage": 66, "Name": "__mlx_pixel_put_pipeline_texture_GPU_index_buffer"}, + {"Offset": 140, "Type": "FREE", "Size": 4}, + {"Offset": 144, "Type": "BUFFER", "Size": 128, "Usage": 130, "Name": "42_logo.png_GPU_vertex_buffer"}, + {"Offset": 272, "Type": "BUFFER", "Size": 12, "Usage": 66, "Name": "42_logo.png_GPU_index_buffer"}, + {"Offset": 284, "Type": "FREE", "Size": 4}, + {"Offset": 288, "Type": "BUFFER", "Size": 128, "Usage": 130, "Name": "__mlx_unamed_user_texture_GPU_vertex_buffer"}, + {"Offset": 416, "Type": "BUFFER", "Size": 12, "Usage": 66, "Name": "__mlx_unamed_user_texture_GPU_index_buffer"}, + {"Offset": 428, "Type": "BUFFER", "Size": 156, "Usage": 66, "Name": "that's a text_GPU_index_buffer"}, + {"Offset": 584, "Type": "FREE", "Size": 440}, + {"Offset": 1024, "Type": "IMAGE_OPTIMAL", "Size": 57344, "Usage": 7, "Name": "42_logo.png"}, + {"Offset": 58368, "Type": "IMAGE_OPTIMAL", "Size": 57344, "Usage": 7, "Name": "__mlx_unamed_user_texture"}, + {"Offset": 115712, "Type": "BUFFER", "Size": 1664, "Usage": 130, "Name": "that's a text_GPU_vertex_buffer"}, + {"Offset": 117376, "Type": "FREE", "Size": 33437056} + ] + } + }, + "DedicatedAllocations": [ + {"Type": "IMAGE_OPTIMAL", "Size": 819200, "Usage": 7, "Name": "__mlx_pixel_put_pipeline_texture"}, + {"Type": "IMAGE_OPTIMAL", "Size": 1048576, "Usage": 7, "Name": "__mlx_texts_pipeline_texture_atlas"} + ] + }, + "Type 2": { + "PreferredBlockSize": 268435456, + "Blocks": { + "0": { + "MapRefCount": 2, + "TotalBytes": 33554432, + "UnusedBytes": 32874432, + "Allocations": 2, + "UnusedRanges": 1, + "Suballocations": [ + {"Offset": 0, "Type": "BUFFER", "Size": 640000, "Usage": 1, "Name": "__mlx_pixel_put_pipeline_texture_buffer"}, + {"Offset": 640000, "Type": "BUFFER", "Size": 40000, "Usage": 3, "Name": "__mlx_unamed_user_texture_buffer"}, + {"Offset": 680000, "Type": "FREE", "Size": 32874432} + ] + } + }, + "DedicatedAllocations": [ + ] + }, + "Type 3": { + "PreferredBlockSize": 268435456, + "Blocks": { + }, + "DedicatedAllocations": [ + ] + }, + "Type 4": { + "PreferredBlockSize": 32243712, + "Blocks": { + "0": { + "MapRefCount": 3, + "TotalBytes": 4030464, + "UnusedBytes": 4030272, + "Allocations": 3, + "UnusedRanges": 1, + "Suballocations": [ + {"Offset": 0, "Type": "BUFFER", "Size": 64, "Usage": 16, "Name": "__mlx_matrices_uniform_buffer_0_buffer"}, + {"Offset": 64, "Type": "BUFFER", "Size": 64, "Usage": 16, "Name": "__mlx_matrices_uniform_buffer_1_buffer"}, + {"Offset": 128, "Type": "BUFFER", "Size": 64, "Usage": 16, "Name": "__mlx_matrices_uniform_buffer_2_buffer"}, + {"Offset": 192, "Type": "FREE", "Size": 4030272} + ] + } + }, + "DedicatedAllocations": [ + ] + } + }, + "CustomPools": { + } +} \ No newline at end of file diff --git a/test/memory_dump2.json b/test/memory_dump2.json new file mode 100644 index 0000000..96ea825 --- /dev/null +++ b/test/memory_dump2.json @@ -0,0 +1,232 @@ +{ + "General": { + "API": "Vulkan", + "apiVersion": "1.3.260", + "GPU": "NVIDIA GeForce GTX 1650", + "deviceType": 2, + "maxMemoryAllocationCount": 4294967295, + "bufferImageGranularity": 1024, + "nonCoherentAtomSize": 64, + "memoryHeapCount": 3, + "memoryTypeCount": 5 + }, + "Total": { + "BlockCount": 5, + "BlockBytes": 73007104, + "AllocationCount": 17, + "AllocationBytes": 2664896, + "UnusedRangeCount": 6, + "AllocationSizeMin": 12, + "AllocationSizeMax": 1048576, + "UnusedRangeSizeMin": 4, + "UnusedRangeSizeMax": 33437056 + }, + "MemoryInfo": { + "Heap 0": { + "Flags": ["DEVICE_LOCAL"], + "Size": 4294967296, + "Budget": { + "BudgetBytes": 3435973836, + "UsageBytes": 35422208 + }, + "Stats": { + "BlockCount": 3, + "BlockBytes": 35422208, + "AllocationCount": 12, + "AllocationBytes": 1984704, + "UnusedRangeCount": 4, + "AllocationSizeMin": 12, + "AllocationSizeMax": 1048576, + "UnusedRangeSizeMin": 4, + "UnusedRangeSizeMax": 33437056 + }, + "MemoryPools": { + "Type 1": { + "Flags": ["DEVICE_LOCAL"], + "Stats": { + "BlockCount": 3, + "BlockBytes": 35422208, + "AllocationCount": 12, + "AllocationBytes": 1984704, + "UnusedRangeCount": 4, + "AllocationSizeMin": 12, + "AllocationSizeMax": 1048576, + "UnusedRangeSizeMin": 4, + "UnusedRangeSizeMax": 33437056 + } + } + } + }, + "Heap 1": { + "Flags": [], + "Size": 6071976960, + "Budget": { + "BudgetBytes": 4857581568, + "UsageBytes": 33554432 + }, + "Stats": { + "BlockCount": 1, + "BlockBytes": 33554432, + "AllocationCount": 2, + "AllocationBytes": 680000, + "UnusedRangeCount": 1, + "AllocationSizeMin": 40000, + "AllocationSizeMax": 640000 + }, + "MemoryPools": { + "Type 0": { + "Flags": [], + "Stats": { + "BlockCount": 0, + "BlockBytes": 0, + "AllocationCount": 0, + "AllocationBytes": 0, + "UnusedRangeCount": 0 + } + }, + "Type 2": { + "Flags": ["HOST_VISIBLE", "HOST_COHERENT"], + "Stats": { + "BlockCount": 1, + "BlockBytes": 33554432, + "AllocationCount": 2, + "AllocationBytes": 680000, + "UnusedRangeCount": 1, + "AllocationSizeMin": 40000, + "AllocationSizeMax": 640000 + } + }, + "Type 3": { + "Flags": ["HOST_VISIBLE", "HOST_COHERENT", "HOST_CACHED"], + "Stats": { + "BlockCount": 0, + "BlockBytes": 0, + "AllocationCount": 0, + "AllocationBytes": 0, + "UnusedRangeCount": 0 + } + } + } + }, + "Heap 2": { + "Flags": ["DEVICE_LOCAL"], + "Size": 257949696, + "Budget": { + "BudgetBytes": 206359756, + "UsageBytes": 4030464 + }, + "Stats": { + "BlockCount": 1, + "BlockBytes": 4030464, + "AllocationCount": 3, + "AllocationBytes": 192, + "UnusedRangeCount": 1, + "AllocationSizeMin": 64, + "AllocationSizeMax": 64 + }, + "MemoryPools": { + "Type 4": { + "Flags": ["DEVICE_LOCAL", "HOST_VISIBLE", "HOST_COHERENT"], + "Stats": { + "BlockCount": 1, + "BlockBytes": 4030464, + "AllocationCount": 3, + "AllocationBytes": 192, + "UnusedRangeCount": 1, + "AllocationSizeMin": 64, + "AllocationSizeMax": 64 + } + } + } + } + }, + "DefaultPools": { + "Type 0": { + "PreferredBlockSize": 268435456, + "Blocks": { + }, + "DedicatedAllocations": [ + ] + }, + "Type 1": { + "PreferredBlockSize": 268435456, + "Blocks": { + "0": { + "MapRefCount": 0, + "TotalBytes": 33554432, + "UnusedBytes": 33437504, + "Allocations": 10, + "UnusedRanges": 4, + "Suballocations": [ + {"Offset": 0, "Type": "BUFFER", "Size": 128, "Usage": 130, "Name": "__mlx_pixel_put_pipeline_texture_GPU_vertex_buffer"}, + {"Offset": 128, "Type": "BUFFER", "Size": 12, "Usage": 66, "Name": "__mlx_pixel_put_pipeline_texture_GPU_index_buffer"}, + {"Offset": 140, "Type": "FREE", "Size": 4}, + {"Offset": 144, "Type": "BUFFER", "Size": 128, "Usage": 130, "Name": "42_logo.png_GPU_vertex_buffer"}, + {"Offset": 272, "Type": "BUFFER", "Size": 12, "Usage": 66, "Name": "42_logo.png_GPU_index_buffer"}, + {"Offset": 284, "Type": "FREE", "Size": 4}, + {"Offset": 288, "Type": "BUFFER", "Size": 128, "Usage": 130, "Name": "__mlx_unamed_user_texture_GPU_vertex_buffer"}, + {"Offset": 416, "Type": "BUFFER", "Size": 12, "Usage": 66, "Name": "__mlx_unamed_user_texture_GPU_index_buffer"}, + {"Offset": 428, "Type": "BUFFER", "Size": 156, "Usage": 66, "Name": "that's a text_GPU_index_buffer"}, + {"Offset": 584, "Type": "FREE", "Size": 440}, + {"Offset": 1024, "Type": "IMAGE_OPTIMAL", "Size": 57344, "Usage": 7, "Name": "42_logo.png"}, + {"Offset": 58368, "Type": "IMAGE_OPTIMAL", "Size": 57344, "Usage": 7, "Name": "__mlx_unamed_user_texture"}, + {"Offset": 115712, "Type": "BUFFER", "Size": 1664, "Usage": 130, "Name": "that's a text_GPU_vertex_buffer"}, + {"Offset": 117376, "Type": "FREE", "Size": 33437056} + ] + } + }, + "DedicatedAllocations": [ + {"Type": "IMAGE_OPTIMAL", "Size": 819200, "Usage": 7, "Name": "__mlx_pixel_put_pipeline_texture"}, + {"Type": "IMAGE_OPTIMAL", "Size": 1048576, "Usage": 7, "Name": "__mlx_texts_pipeline_texture_atlas"} + ] + }, + "Type 2": { + "PreferredBlockSize": 268435456, + "Blocks": { + "0": { + "MapRefCount": 2, + "TotalBytes": 33554432, + "UnusedBytes": 32874432, + "Allocations": 2, + "UnusedRanges": 1, + "Suballocations": [ + {"Offset": 0, "Type": "BUFFER", "Size": 640000, "Usage": 1, "Name": "__mlx_pixel_put_pipeline_texture_buffer"}, + {"Offset": 640000, "Type": "BUFFER", "Size": 40000, "Usage": 3, "Name": "__mlx_unamed_user_texture_buffer"}, + {"Offset": 680000, "Type": "FREE", "Size": 32874432} + ] + } + }, + "DedicatedAllocations": [ + ] + }, + "Type 3": { + "PreferredBlockSize": 268435456, + "Blocks": { + }, + "DedicatedAllocations": [ + ] + }, + "Type 4": { + "PreferredBlockSize": 32243712, + "Blocks": { + "0": { + "MapRefCount": 3, + "TotalBytes": 4030464, + "UnusedBytes": 4030272, + "Allocations": 3, + "UnusedRanges": 1, + "Suballocations": [ + {"Offset": 0, "Type": "BUFFER", "Size": 64, "Usage": 16, "Name": "__mlx_matrices_uniform_buffer_0_buffer"}, + {"Offset": 64, "Type": "BUFFER", "Size": 64, "Usage": 16, "Name": "__mlx_matrices_uniform_buffer_1_buffer"}, + {"Offset": 128, "Type": "BUFFER", "Size": 64, "Usage": 16, "Name": "__mlx_matrices_uniform_buffer_2_buffer"}, + {"Offset": 192, "Type": "FREE", "Size": 4030272} + ] + } + }, + "DedicatedAllocations": [ + ] + } + }, + "CustomPools": { + } +} \ No newline at end of file diff --git a/test/memory_dump3.json b/test/memory_dump3.json new file mode 100644 index 0000000..96ea825 --- /dev/null +++ b/test/memory_dump3.json @@ -0,0 +1,232 @@ +{ + "General": { + "API": "Vulkan", + "apiVersion": "1.3.260", + "GPU": "NVIDIA GeForce GTX 1650", + "deviceType": 2, + "maxMemoryAllocationCount": 4294967295, + "bufferImageGranularity": 1024, + "nonCoherentAtomSize": 64, + "memoryHeapCount": 3, + "memoryTypeCount": 5 + }, + "Total": { + "BlockCount": 5, + "BlockBytes": 73007104, + "AllocationCount": 17, + "AllocationBytes": 2664896, + "UnusedRangeCount": 6, + "AllocationSizeMin": 12, + "AllocationSizeMax": 1048576, + "UnusedRangeSizeMin": 4, + "UnusedRangeSizeMax": 33437056 + }, + "MemoryInfo": { + "Heap 0": { + "Flags": ["DEVICE_LOCAL"], + "Size": 4294967296, + "Budget": { + "BudgetBytes": 3435973836, + "UsageBytes": 35422208 + }, + "Stats": { + "BlockCount": 3, + "BlockBytes": 35422208, + "AllocationCount": 12, + "AllocationBytes": 1984704, + "UnusedRangeCount": 4, + "AllocationSizeMin": 12, + "AllocationSizeMax": 1048576, + "UnusedRangeSizeMin": 4, + "UnusedRangeSizeMax": 33437056 + }, + "MemoryPools": { + "Type 1": { + "Flags": ["DEVICE_LOCAL"], + "Stats": { + "BlockCount": 3, + "BlockBytes": 35422208, + "AllocationCount": 12, + "AllocationBytes": 1984704, + "UnusedRangeCount": 4, + "AllocationSizeMin": 12, + "AllocationSizeMax": 1048576, + "UnusedRangeSizeMin": 4, + "UnusedRangeSizeMax": 33437056 + } + } + } + }, + "Heap 1": { + "Flags": [], + "Size": 6071976960, + "Budget": { + "BudgetBytes": 4857581568, + "UsageBytes": 33554432 + }, + "Stats": { + "BlockCount": 1, + "BlockBytes": 33554432, + "AllocationCount": 2, + "AllocationBytes": 680000, + "UnusedRangeCount": 1, + "AllocationSizeMin": 40000, + "AllocationSizeMax": 640000 + }, + "MemoryPools": { + "Type 0": { + "Flags": [], + "Stats": { + "BlockCount": 0, + "BlockBytes": 0, + "AllocationCount": 0, + "AllocationBytes": 0, + "UnusedRangeCount": 0 + } + }, + "Type 2": { + "Flags": ["HOST_VISIBLE", "HOST_COHERENT"], + "Stats": { + "BlockCount": 1, + "BlockBytes": 33554432, + "AllocationCount": 2, + "AllocationBytes": 680000, + "UnusedRangeCount": 1, + "AllocationSizeMin": 40000, + "AllocationSizeMax": 640000 + } + }, + "Type 3": { + "Flags": ["HOST_VISIBLE", "HOST_COHERENT", "HOST_CACHED"], + "Stats": { + "BlockCount": 0, + "BlockBytes": 0, + "AllocationCount": 0, + "AllocationBytes": 0, + "UnusedRangeCount": 0 + } + } + } + }, + "Heap 2": { + "Flags": ["DEVICE_LOCAL"], + "Size": 257949696, + "Budget": { + "BudgetBytes": 206359756, + "UsageBytes": 4030464 + }, + "Stats": { + "BlockCount": 1, + "BlockBytes": 4030464, + "AllocationCount": 3, + "AllocationBytes": 192, + "UnusedRangeCount": 1, + "AllocationSizeMin": 64, + "AllocationSizeMax": 64 + }, + "MemoryPools": { + "Type 4": { + "Flags": ["DEVICE_LOCAL", "HOST_VISIBLE", "HOST_COHERENT"], + "Stats": { + "BlockCount": 1, + "BlockBytes": 4030464, + "AllocationCount": 3, + "AllocationBytes": 192, + "UnusedRangeCount": 1, + "AllocationSizeMin": 64, + "AllocationSizeMax": 64 + } + } + } + } + }, + "DefaultPools": { + "Type 0": { + "PreferredBlockSize": 268435456, + "Blocks": { + }, + "DedicatedAllocations": [ + ] + }, + "Type 1": { + "PreferredBlockSize": 268435456, + "Blocks": { + "0": { + "MapRefCount": 0, + "TotalBytes": 33554432, + "UnusedBytes": 33437504, + "Allocations": 10, + "UnusedRanges": 4, + "Suballocations": [ + {"Offset": 0, "Type": "BUFFER", "Size": 128, "Usage": 130, "Name": "__mlx_pixel_put_pipeline_texture_GPU_vertex_buffer"}, + {"Offset": 128, "Type": "BUFFER", "Size": 12, "Usage": 66, "Name": "__mlx_pixel_put_pipeline_texture_GPU_index_buffer"}, + {"Offset": 140, "Type": "FREE", "Size": 4}, + {"Offset": 144, "Type": "BUFFER", "Size": 128, "Usage": 130, "Name": "42_logo.png_GPU_vertex_buffer"}, + {"Offset": 272, "Type": "BUFFER", "Size": 12, "Usage": 66, "Name": "42_logo.png_GPU_index_buffer"}, + {"Offset": 284, "Type": "FREE", "Size": 4}, + {"Offset": 288, "Type": "BUFFER", "Size": 128, "Usage": 130, "Name": "__mlx_unamed_user_texture_GPU_vertex_buffer"}, + {"Offset": 416, "Type": "BUFFER", "Size": 12, "Usage": 66, "Name": "__mlx_unamed_user_texture_GPU_index_buffer"}, + {"Offset": 428, "Type": "BUFFER", "Size": 156, "Usage": 66, "Name": "that's a text_GPU_index_buffer"}, + {"Offset": 584, "Type": "FREE", "Size": 440}, + {"Offset": 1024, "Type": "IMAGE_OPTIMAL", "Size": 57344, "Usage": 7, "Name": "42_logo.png"}, + {"Offset": 58368, "Type": "IMAGE_OPTIMAL", "Size": 57344, "Usage": 7, "Name": "__mlx_unamed_user_texture"}, + {"Offset": 115712, "Type": "BUFFER", "Size": 1664, "Usage": 130, "Name": "that's a text_GPU_vertex_buffer"}, + {"Offset": 117376, "Type": "FREE", "Size": 33437056} + ] + } + }, + "DedicatedAllocations": [ + {"Type": "IMAGE_OPTIMAL", "Size": 819200, "Usage": 7, "Name": "__mlx_pixel_put_pipeline_texture"}, + {"Type": "IMAGE_OPTIMAL", "Size": 1048576, "Usage": 7, "Name": "__mlx_texts_pipeline_texture_atlas"} + ] + }, + "Type 2": { + "PreferredBlockSize": 268435456, + "Blocks": { + "0": { + "MapRefCount": 2, + "TotalBytes": 33554432, + "UnusedBytes": 32874432, + "Allocations": 2, + "UnusedRanges": 1, + "Suballocations": [ + {"Offset": 0, "Type": "BUFFER", "Size": 640000, "Usage": 1, "Name": "__mlx_pixel_put_pipeline_texture_buffer"}, + {"Offset": 640000, "Type": "BUFFER", "Size": 40000, "Usage": 3, "Name": "__mlx_unamed_user_texture_buffer"}, + {"Offset": 680000, "Type": "FREE", "Size": 32874432} + ] + } + }, + "DedicatedAllocations": [ + ] + }, + "Type 3": { + "PreferredBlockSize": 268435456, + "Blocks": { + }, + "DedicatedAllocations": [ + ] + }, + "Type 4": { + "PreferredBlockSize": 32243712, + "Blocks": { + "0": { + "MapRefCount": 3, + "TotalBytes": 4030464, + "UnusedBytes": 4030272, + "Allocations": 3, + "UnusedRanges": 1, + "Suballocations": [ + {"Offset": 0, "Type": "BUFFER", "Size": 64, "Usage": 16, "Name": "__mlx_matrices_uniform_buffer_0_buffer"}, + {"Offset": 64, "Type": "BUFFER", "Size": 64, "Usage": 16, "Name": "__mlx_matrices_uniform_buffer_1_buffer"}, + {"Offset": 128, "Type": "BUFFER", "Size": 64, "Usage": 16, "Name": "__mlx_matrices_uniform_buffer_2_buffer"}, + {"Offset": 192, "Type": "FREE", "Size": 4030272} + ] + } + }, + "DedicatedAllocations": [ + ] + } + }, + "CustomPools": { + } +} \ No newline at end of file diff --git a/test/memory_dump4.json b/test/memory_dump4.json new file mode 100644 index 0000000..96ea825 --- /dev/null +++ b/test/memory_dump4.json @@ -0,0 +1,232 @@ +{ + "General": { + "API": "Vulkan", + "apiVersion": "1.3.260", + "GPU": "NVIDIA GeForce GTX 1650", + "deviceType": 2, + "maxMemoryAllocationCount": 4294967295, + "bufferImageGranularity": 1024, + "nonCoherentAtomSize": 64, + "memoryHeapCount": 3, + "memoryTypeCount": 5 + }, + "Total": { + "BlockCount": 5, + "BlockBytes": 73007104, + "AllocationCount": 17, + "AllocationBytes": 2664896, + "UnusedRangeCount": 6, + "AllocationSizeMin": 12, + "AllocationSizeMax": 1048576, + "UnusedRangeSizeMin": 4, + "UnusedRangeSizeMax": 33437056 + }, + "MemoryInfo": { + "Heap 0": { + "Flags": ["DEVICE_LOCAL"], + "Size": 4294967296, + "Budget": { + "BudgetBytes": 3435973836, + "UsageBytes": 35422208 + }, + "Stats": { + "BlockCount": 3, + "BlockBytes": 35422208, + "AllocationCount": 12, + "AllocationBytes": 1984704, + "UnusedRangeCount": 4, + "AllocationSizeMin": 12, + "AllocationSizeMax": 1048576, + "UnusedRangeSizeMin": 4, + "UnusedRangeSizeMax": 33437056 + }, + "MemoryPools": { + "Type 1": { + "Flags": ["DEVICE_LOCAL"], + "Stats": { + "BlockCount": 3, + "BlockBytes": 35422208, + "AllocationCount": 12, + "AllocationBytes": 1984704, + "UnusedRangeCount": 4, + "AllocationSizeMin": 12, + "AllocationSizeMax": 1048576, + "UnusedRangeSizeMin": 4, + "UnusedRangeSizeMax": 33437056 + } + } + } + }, + "Heap 1": { + "Flags": [], + "Size": 6071976960, + "Budget": { + "BudgetBytes": 4857581568, + "UsageBytes": 33554432 + }, + "Stats": { + "BlockCount": 1, + "BlockBytes": 33554432, + "AllocationCount": 2, + "AllocationBytes": 680000, + "UnusedRangeCount": 1, + "AllocationSizeMin": 40000, + "AllocationSizeMax": 640000 + }, + "MemoryPools": { + "Type 0": { + "Flags": [], + "Stats": { + "BlockCount": 0, + "BlockBytes": 0, + "AllocationCount": 0, + "AllocationBytes": 0, + "UnusedRangeCount": 0 + } + }, + "Type 2": { + "Flags": ["HOST_VISIBLE", "HOST_COHERENT"], + "Stats": { + "BlockCount": 1, + "BlockBytes": 33554432, + "AllocationCount": 2, + "AllocationBytes": 680000, + "UnusedRangeCount": 1, + "AllocationSizeMin": 40000, + "AllocationSizeMax": 640000 + } + }, + "Type 3": { + "Flags": ["HOST_VISIBLE", "HOST_COHERENT", "HOST_CACHED"], + "Stats": { + "BlockCount": 0, + "BlockBytes": 0, + "AllocationCount": 0, + "AllocationBytes": 0, + "UnusedRangeCount": 0 + } + } + } + }, + "Heap 2": { + "Flags": ["DEVICE_LOCAL"], + "Size": 257949696, + "Budget": { + "BudgetBytes": 206359756, + "UsageBytes": 4030464 + }, + "Stats": { + "BlockCount": 1, + "BlockBytes": 4030464, + "AllocationCount": 3, + "AllocationBytes": 192, + "UnusedRangeCount": 1, + "AllocationSizeMin": 64, + "AllocationSizeMax": 64 + }, + "MemoryPools": { + "Type 4": { + "Flags": ["DEVICE_LOCAL", "HOST_VISIBLE", "HOST_COHERENT"], + "Stats": { + "BlockCount": 1, + "BlockBytes": 4030464, + "AllocationCount": 3, + "AllocationBytes": 192, + "UnusedRangeCount": 1, + "AllocationSizeMin": 64, + "AllocationSizeMax": 64 + } + } + } + } + }, + "DefaultPools": { + "Type 0": { + "PreferredBlockSize": 268435456, + "Blocks": { + }, + "DedicatedAllocations": [ + ] + }, + "Type 1": { + "PreferredBlockSize": 268435456, + "Blocks": { + "0": { + "MapRefCount": 0, + "TotalBytes": 33554432, + "UnusedBytes": 33437504, + "Allocations": 10, + "UnusedRanges": 4, + "Suballocations": [ + {"Offset": 0, "Type": "BUFFER", "Size": 128, "Usage": 130, "Name": "__mlx_pixel_put_pipeline_texture_GPU_vertex_buffer"}, + {"Offset": 128, "Type": "BUFFER", "Size": 12, "Usage": 66, "Name": "__mlx_pixel_put_pipeline_texture_GPU_index_buffer"}, + {"Offset": 140, "Type": "FREE", "Size": 4}, + {"Offset": 144, "Type": "BUFFER", "Size": 128, "Usage": 130, "Name": "42_logo.png_GPU_vertex_buffer"}, + {"Offset": 272, "Type": "BUFFER", "Size": 12, "Usage": 66, "Name": "42_logo.png_GPU_index_buffer"}, + {"Offset": 284, "Type": "FREE", "Size": 4}, + {"Offset": 288, "Type": "BUFFER", "Size": 128, "Usage": 130, "Name": "__mlx_unamed_user_texture_GPU_vertex_buffer"}, + {"Offset": 416, "Type": "BUFFER", "Size": 12, "Usage": 66, "Name": "__mlx_unamed_user_texture_GPU_index_buffer"}, + {"Offset": 428, "Type": "BUFFER", "Size": 156, "Usage": 66, "Name": "that's a text_GPU_index_buffer"}, + {"Offset": 584, "Type": "FREE", "Size": 440}, + {"Offset": 1024, "Type": "IMAGE_OPTIMAL", "Size": 57344, "Usage": 7, "Name": "42_logo.png"}, + {"Offset": 58368, "Type": "IMAGE_OPTIMAL", "Size": 57344, "Usage": 7, "Name": "__mlx_unamed_user_texture"}, + {"Offset": 115712, "Type": "BUFFER", "Size": 1664, "Usage": 130, "Name": "that's a text_GPU_vertex_buffer"}, + {"Offset": 117376, "Type": "FREE", "Size": 33437056} + ] + } + }, + "DedicatedAllocations": [ + {"Type": "IMAGE_OPTIMAL", "Size": 819200, "Usage": 7, "Name": "__mlx_pixel_put_pipeline_texture"}, + {"Type": "IMAGE_OPTIMAL", "Size": 1048576, "Usage": 7, "Name": "__mlx_texts_pipeline_texture_atlas"} + ] + }, + "Type 2": { + "PreferredBlockSize": 268435456, + "Blocks": { + "0": { + "MapRefCount": 2, + "TotalBytes": 33554432, + "UnusedBytes": 32874432, + "Allocations": 2, + "UnusedRanges": 1, + "Suballocations": [ + {"Offset": 0, "Type": "BUFFER", "Size": 640000, "Usage": 1, "Name": "__mlx_pixel_put_pipeline_texture_buffer"}, + {"Offset": 640000, "Type": "BUFFER", "Size": 40000, "Usage": 3, "Name": "__mlx_unamed_user_texture_buffer"}, + {"Offset": 680000, "Type": "FREE", "Size": 32874432} + ] + } + }, + "DedicatedAllocations": [ + ] + }, + "Type 3": { + "PreferredBlockSize": 268435456, + "Blocks": { + }, + "DedicatedAllocations": [ + ] + }, + "Type 4": { + "PreferredBlockSize": 32243712, + "Blocks": { + "0": { + "MapRefCount": 3, + "TotalBytes": 4030464, + "UnusedBytes": 4030272, + "Allocations": 3, + "UnusedRanges": 1, + "Suballocations": [ + {"Offset": 0, "Type": "BUFFER", "Size": 64, "Usage": 16, "Name": "__mlx_matrices_uniform_buffer_0_buffer"}, + {"Offset": 64, "Type": "BUFFER", "Size": 64, "Usage": 16, "Name": "__mlx_matrices_uniform_buffer_1_buffer"}, + {"Offset": 128, "Type": "BUFFER", "Size": 64, "Usage": 16, "Name": "__mlx_matrices_uniform_buffer_2_buffer"}, + {"Offset": 192, "Type": "FREE", "Size": 4030272} + ] + } + }, + "DedicatedAllocations": [ + ] + } + }, + "CustomPools": { + } +} \ No newline at end of file diff --git a/xmake.lua b/xmake.lua new file mode 100644 index 0000000..506e27c --- /dev/null +++ b/xmake.lua @@ -0,0 +1,38 @@ +-------------------------------------------------------------------------------- +-- -- +-- ::: :::::::: -- +-- xmake.lua :+: :+: :+: -- +-- +:+ +:+ +:+ -- +-- By: kbz_8 +#+ +:+ +#+ -- +-- +#+#+#+#+#+ +#+ -- +-- Created: 2023/12/07 15:21:38 by kbz_8 #+# #+# -- +-- Updated: 2023/12/07 15:21:38 by kbz_8 ### ########.fr -- +-- -- +-------------------------------------------------------------------------------- + +-- Global settings + +add_requires("libsdl", "vulkan-headers") + +add_rules("mode.debug", "mode.release") +set_languages("cxx17") + +set_objectdir("objs/xmake/$(os)_$(arch)") +set_targetdir("./") + +set_optimize("fastest") + +target("libmlx") + set_default(true) + set_license("MIT") + set_kind("shared") + add_includedirs("includes", "srcs", "third_party") + + add_files("srcs/**.cpp") + + add_packages("libsdl", "vulkan-headers") + + if is_mode("debug") then + add_defines("DEBUG") + end +target_end() -- optional but I think the code is cleaner with this -- optional but I think the code is cleaner with this