Skip to content

Commit

Permalink
fixing crash when initializing mlx multiple times (#94)
Browse files Browse the repository at this point in the history
  • Loading branch information
Kbz-8 authored Oct 19, 2024
2 parents 4d640ed + ae3be69 commit 226430f
Show file tree
Hide file tree
Showing 21 changed files with 10,722 additions and 1,399 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/fetch_dependencies.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ name: Fetch Dependencies

on:
schedule:
- cron: '0 0 * * *' # Runs daily
- cron: '0 0 * * 0' # Runs weekly

jobs:
update-dependencies:
Expand Down
4 changes: 3 additions & 1 deletion src/core/application.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
/* By: maldavid <kbz_8.dev@akel-engine.com> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2022/10/04 22:10:52 by maldavid #+# #+# */
/* Updated: 2024/04/24 13:52:18 by maldavid ### ########.fr */
/* Updated: 2024/10/19 10:49:21 by maldavid ### ########.fr */
/* */
/* ************************************************************************** */

Expand Down Expand Up @@ -118,7 +118,9 @@ namespace mlx::core
Application::~Application()
{
TextLibrary::get().clearLibrary();
TextLibrary::get().reset();
FontLibrary::get().clearLibrary();
FontLibrary::get().reset();
if(__drop_sdl_responsability)
return;
SDL_QuitSubSystem(SDL_INIT_VIDEO | SDL_INIT_TIMER | SDL_INIT_EVENTS);
Expand Down
3 changes: 2 additions & 1 deletion src/renderer/command/single_time_cmd_manager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
/* By: maldavid <kbz_8.dev@akel-engine.com> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2023/12/15 19:57:49 by maldavid #+# #+# */
/* Updated: 2024/01/11 03:13:21 by maldavid ### ########.fr */
/* Updated: 2024/10/19 10:47:04 by maldavid ### ########.fr */
/* */
/* ************************************************************************** */

Expand Down Expand Up @@ -59,5 +59,6 @@ namespace mlx
buf.destroy();
});
_pool.destroy();
_buffers.clear();
}
}
6 changes: 5 additions & 1 deletion src/renderer/core/render_core.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
/* By: maldavid <kbz_8.dev@akel-engine.com> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2022/12/17 23:33:34 by maldavid #+# #+# */
/* Updated: 2024/04/23 20:32:54 by kiroussa ### ########.fr */
/* Updated: 2024/10/19 10:50:13 by maldavid ### ########.fr */
/* */
/* ************************************************************************** */

Expand Down Expand Up @@ -116,6 +116,8 @@ namespace mlx

void Render_Core::init()
{
if(_is_init)
return;
if(volkInitialize() != VK_SUCCESS)
core::error::report(e_kind::fatal_error, "Vulkan loader : cannot load %s, are you sure Vulkan is installed on your system ?", VULKAN_LIB_NAME);

Expand Down Expand Up @@ -144,6 +146,8 @@ namespace mlx
_layers.destroy();
_instance.destroy();

volkFinalize();

_is_init = false;
}
}
4 changes: 3 additions & 1 deletion src/renderer/texts/font_library.h
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
/* By: maldavid <kbz_8.dev@akel-engine.com> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2024/01/18 09:26:03 by maldavid #+# #+# */
/* Updated: 2024/01/18 09:33:30 by maldavid ### ########.fr */
/* Updated: 2024/10/19 10:47:32 by maldavid ### ########.fr */
/* */
/* ************************************************************************** */

Expand Down Expand Up @@ -38,6 +38,8 @@ namespace mlx

void clearLibrary();

inline void reset() { _cache.clear(); _invalid_ids.clear(); _current_id = 1; }

private:
FontLibrary() = default;
~FontLibrary() = default;
Expand Down
4 changes: 3 additions & 1 deletion src/renderer/texts/text_library.h
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
/* By: maldavid <kbz_8.dev@akel-engine.com> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2023/04/10 11:52:30 by maldavid #+# #+# */
/* Updated: 2024/03/25 16:04:47 by maldavid ### ########.fr */
/* Updated: 2024/10/19 10:49:02 by maldavid ### ########.fr */
/* */
/* ************************************************************************** */

Expand Down Expand Up @@ -39,6 +39,8 @@ namespace mlx

void clearLibrary();

inline void reset() { _cache.clear(); _current_id = 1; }

private:
TextLibrary() = default;
~TextLibrary() = default;
Expand Down
83 changes: 81 additions & 2 deletions third_party/vulkan/vulkan.cppm
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,12 @@

module;

#include <vulkan/vulkan_hpp_macros.hpp>

#if defined( __cpp_lib_modules )
# define VULKAN_HPP_ENABLE_STD_MODULE
#endif

#include <vulkan/vulkan.hpp>
#include <vulkan/vulkan_extension_inspection.hpp>
#include <vulkan/vulkan_format_traits.hpp>
Expand Down Expand Up @@ -879,6 +885,17 @@ export namespace VULKAN_HPP_NAMESPACE
//=== VK_KHR_maintenance7 ===
using VULKAN_HPP_NAMESPACE::PhysicalDeviceLayeredApiKHR;

//=== VK_EXT_device_generated_commands ===
using VULKAN_HPP_NAMESPACE::IndirectCommandsInputModeFlagBitsEXT;
using VULKAN_HPP_NAMESPACE::IndirectCommandsInputModeFlagsEXT;
using VULKAN_HPP_NAMESPACE::IndirectCommandsLayoutUsageFlagBitsEXT;
using VULKAN_HPP_NAMESPACE::IndirectCommandsLayoutUsageFlagsEXT;
using VULKAN_HPP_NAMESPACE::IndirectCommandsTokenTypeEXT;
using VULKAN_HPP_NAMESPACE::IndirectExecutionSetInfoTypeEXT;

//=== VK_EXT_depth_clamp_control ===
using VULKAN_HPP_NAMESPACE::DepthClampModeEXT;

//=========================
//=== Index Type Traits ===
//=========================
Expand Down Expand Up @@ -2149,6 +2166,10 @@ export namespace VULKAN_HPP_NAMESPACE
using VULKAN_HPP_NAMESPACE::KHRFormatFeatureFlags2ExtensionName;
using VULKAN_HPP_NAMESPACE::KHRFormatFeatureFlags2SpecVersion;

//=== VK_EXT_present_mode_fifo_latest_ready ===
using VULKAN_HPP_NAMESPACE::EXTPresentModeFifoLatestReadyExtensionName;
using VULKAN_HPP_NAMESPACE::EXTPresentModeFifoLatestReadySpecVersion;

#if defined( VK_USE_PLATFORM_FUCHSIA )
//=== VK_FUCHSIA_external_memory ===
using VULKAN_HPP_NAMESPACE::FUCHSIAExternalMemoryExtensionName;
Expand Down Expand Up @@ -2572,14 +2593,23 @@ export namespace VULKAN_HPP_NAMESPACE
using VULKAN_HPP_NAMESPACE::NVRayTracingValidationExtensionName;
using VULKAN_HPP_NAMESPACE::NVRayTracingValidationSpecVersion;

//=== VK_EXT_device_generated_commands ===
using VULKAN_HPP_NAMESPACE::EXTDeviceGeneratedCommandsExtensionName;
using VULKAN_HPP_NAMESPACE::EXTDeviceGeneratedCommandsSpecVersion;

//=== VK_MESA_image_alignment_control ===
using VULKAN_HPP_NAMESPACE::MESAImageAlignmentControlExtensionName;
using VULKAN_HPP_NAMESPACE::MESAImageAlignmentControlSpecVersion;

//=== VK_EXT_depth_clamp_control ===
using VULKAN_HPP_NAMESPACE::EXTDepthClampControlExtensionName;
using VULKAN_HPP_NAMESPACE::EXTDepthClampControlSpecVersion;

//========================
//=== CONSTEXPR VALUEs ===
//========================
using VULKAN_HPP_NAMESPACE::HeaderVersion;
using VULKAN_HPP_NAMESPACE::Use64BitPtrDefines;

//=========================
//=== CONSTEXPR CALLEEs ===
Expand Down Expand Up @@ -3991,6 +4021,9 @@ export namespace VULKAN_HPP_NAMESPACE
//=== VK_EXT_primitive_topology_list_restart ===
using VULKAN_HPP_NAMESPACE::PhysicalDevicePrimitiveTopologyListRestartFeaturesEXT;

//=== VK_EXT_present_mode_fifo_latest_ready ===
using VULKAN_HPP_NAMESPACE::PhysicalDevicePresentModeFifoLatestReadyFeaturesEXT;

#if defined( VK_USE_PLATFORM_FUCHSIA )
//=== VK_FUCHSIA_external_memory ===
using VULKAN_HPP_NAMESPACE::ImportMemoryZirconHandleInfoFUCHSIA;
Expand Down Expand Up @@ -4463,11 +4496,41 @@ export namespace VULKAN_HPP_NAMESPACE
//=== VK_NV_ray_tracing_validation ===
using VULKAN_HPP_NAMESPACE::PhysicalDeviceRayTracingValidationFeaturesNV;

//=== VK_EXT_device_generated_commands ===
using VULKAN_HPP_NAMESPACE::BindIndexBufferIndirectCommandEXT;
using VULKAN_HPP_NAMESPACE::BindVertexBufferIndirectCommandEXT;
using VULKAN_HPP_NAMESPACE::DrawIndirectCountIndirectCommandEXT;
using VULKAN_HPP_NAMESPACE::GeneratedCommandsInfoEXT;
using VULKAN_HPP_NAMESPACE::GeneratedCommandsMemoryRequirementsInfoEXT;
using VULKAN_HPP_NAMESPACE::GeneratedCommandsPipelineInfoEXT;
using VULKAN_HPP_NAMESPACE::GeneratedCommandsShaderInfoEXT;
using VULKAN_HPP_NAMESPACE::IndirectCommandsExecutionSetTokenEXT;
using VULKAN_HPP_NAMESPACE::IndirectCommandsIndexBufferTokenEXT;
using VULKAN_HPP_NAMESPACE::IndirectCommandsLayoutCreateInfoEXT;
using VULKAN_HPP_NAMESPACE::IndirectCommandsLayoutTokenEXT;
using VULKAN_HPP_NAMESPACE::IndirectCommandsPushConstantTokenEXT;
using VULKAN_HPP_NAMESPACE::IndirectCommandsTokenDataEXT;
using VULKAN_HPP_NAMESPACE::IndirectCommandsVertexBufferTokenEXT;
using VULKAN_HPP_NAMESPACE::IndirectExecutionSetCreateInfoEXT;
using VULKAN_HPP_NAMESPACE::IndirectExecutionSetInfoEXT;
using VULKAN_HPP_NAMESPACE::IndirectExecutionSetPipelineInfoEXT;
using VULKAN_HPP_NAMESPACE::IndirectExecutionSetShaderInfoEXT;
using VULKAN_HPP_NAMESPACE::IndirectExecutionSetShaderLayoutInfoEXT;
using VULKAN_HPP_NAMESPACE::PhysicalDeviceDeviceGeneratedCommandsFeaturesEXT;
using VULKAN_HPP_NAMESPACE::PhysicalDeviceDeviceGeneratedCommandsPropertiesEXT;
using VULKAN_HPP_NAMESPACE::WriteIndirectExecutionSetPipelineEXT;
using VULKAN_HPP_NAMESPACE::WriteIndirectExecutionSetShaderEXT;

//=== VK_MESA_image_alignment_control ===
using VULKAN_HPP_NAMESPACE::ImageAlignmentControlCreateInfoMESA;
using VULKAN_HPP_NAMESPACE::PhysicalDeviceImageAlignmentControlFeaturesMESA;
using VULKAN_HPP_NAMESPACE::PhysicalDeviceImageAlignmentControlPropertiesMESA;

//=== VK_EXT_depth_clamp_control ===
using VULKAN_HPP_NAMESPACE::DepthClampRangeEXT;
using VULKAN_HPP_NAMESPACE::PhysicalDeviceDepthClampControlFeaturesEXT;
using VULKAN_HPP_NAMESPACE::PipelineViewportDepthClampControlCreateInfoEXT;

//===============
//=== HANDLEs ===
//===============
Expand Down Expand Up @@ -4573,6 +4636,10 @@ export namespace VULKAN_HPP_NAMESPACE
//=== VK_KHR_pipeline_binary ===
using VULKAN_HPP_NAMESPACE::PipelineBinaryKHR;

//=== VK_EXT_device_generated_commands ===
using VULKAN_HPP_NAMESPACE::IndirectCommandsLayoutEXT;
using VULKAN_HPP_NAMESPACE::IndirectExecutionSetEXT;

//======================
//=== UNIQUE HANDLEs ===
//======================
Expand Down Expand Up @@ -4673,8 +4740,12 @@ export namespace VULKAN_HPP_NAMESPACE
using VULKAN_HPP_NAMESPACE::UniqueShaderEXT;

//=== VK_KHR_pipeline_binary ===
using VULKAN_HPP_NAMESPACE::UniqueHandleTraits;
using VULKAN_HPP_NAMESPACE::UniquePipelineBinaryKHR;

//=== VK_EXT_device_generated_commands ===
using VULKAN_HPP_NAMESPACE::UniqueHandleTraits;
using VULKAN_HPP_NAMESPACE::UniqueIndirectCommandsLayoutEXT;
using VULKAN_HPP_NAMESPACE::UniqueIndirectExecutionSetEXT;
#endif /*VULKAN_HPP_NO_SMART_HANDLE*/

//======================
Expand Down Expand Up @@ -4780,8 +4851,12 @@ export namespace VULKAN_HPP_NAMESPACE
using VULKAN_HPP_NAMESPACE::SharedShaderEXT;

//=== VK_KHR_pipeline_binary ===
using VULKAN_HPP_NAMESPACE::SharedHandleTraits;
using VULKAN_HPP_NAMESPACE::SharedPipelineBinaryKHR;

//=== VK_EXT_device_generated_commands ===
using VULKAN_HPP_NAMESPACE::SharedHandleTraits;
using VULKAN_HPP_NAMESPACE::SharedIndirectCommandsLayoutEXT;
using VULKAN_HPP_NAMESPACE::SharedIndirectExecutionSetEXT;
#endif /*VULKAN_HPP_NO_SMART_HANDLE*/

//===========================
Expand Down Expand Up @@ -4966,6 +5041,10 @@ export namespace VULKAN_HPP_NAMESPACE
using VULKAN_HPP_RAII_NAMESPACE::PipelineBinaryKHR;
using VULKAN_HPP_RAII_NAMESPACE::PipelineBinaryKHRs;

//=== VK_EXT_device_generated_commands ===
using VULKAN_HPP_RAII_NAMESPACE::IndirectCommandsLayoutEXT;
using VULKAN_HPP_RAII_NAMESPACE::IndirectExecutionSetEXT;

} // namespace VULKAN_HPP_RAII_NAMESPACE
#endif
} // namespace VULKAN_HPP_NAMESPACE
Loading

0 comments on commit 226430f

Please sign in to comment.