diff --git a/runtime/Includes/Core/Logs.h b/runtime/Includes/Core/Logs.h index 4b3746b..5692546 100644 --- a/runtime/Includes/Core/Logs.h +++ b/runtime/Includes/Core/Logs.h @@ -30,11 +30,16 @@ namespace mlx static void Report(LogType type, std::string message); static void Report(LogType type, unsigned int line, std::string_view file, std::string_view function, std::string message); + static void BeginSection(); + static void EndSection(); ~Logs() = delete; + + private: + static std::uint32_t s_nesting; }; - #if defined(DEBUG) + #ifdef DEBUG template void Assert(bool cond, unsigned int line, std::string_view file, std::string_view function, std::string message, const Args&... args); #else diff --git a/runtime/Includes/Core/Logs.inl b/runtime/Includes/Core/Logs.inl index 54983cf..1275383 100644 --- a/runtime/Includes/Core/Logs.inl +++ b/runtime/Includes/Core/Logs.inl @@ -102,7 +102,7 @@ namespace mlx } } - #if defined(DEBUG) + #ifdef DEBUG template void Assert(bool cond, unsigned int line, std::string_view file, std::string_view function, std::string message, const Args&... args) { diff --git a/runtime/Includes/Embedded/2DFragment.nzsl b/runtime/Includes/Embedded/Shader2DFragment.nzsl similarity index 100% rename from runtime/Includes/Embedded/2DFragment.nzsl rename to runtime/Includes/Embedded/Shader2DFragment.nzsl diff --git a/runtime/Includes/Embedded/2DFragment.spv.h b/runtime/Includes/Embedded/Shader2DFragment.spv.h similarity index 100% rename from runtime/Includes/Embedded/2DFragment.spv.h rename to runtime/Includes/Embedded/Shader2DFragment.spv.h diff --git a/runtime/Includes/Embedded/2DVertex.nzsl b/runtime/Includes/Embedded/Shader2DVertex.nzsl similarity index 100% rename from runtime/Includes/Embedded/2DVertex.nzsl rename to runtime/Includes/Embedded/Shader2DVertex.nzsl diff --git a/runtime/Includes/Embedded/2DVertex.spv.h b/runtime/Includes/Embedded/Shader2DVertex.spv.h similarity index 100% rename from runtime/Includes/Embedded/2DVertex.spv.h rename to runtime/Includes/Embedded/Shader2DVertex.spv.h diff --git a/runtime/Includes/Embedded/ScreenFragment.nzsl b/runtime/Includes/Embedded/ShaderScreenFragment.nzsl similarity index 100% rename from runtime/Includes/Embedded/ScreenFragment.nzsl rename to runtime/Includes/Embedded/ShaderScreenFragment.nzsl diff --git a/runtime/Includes/Embedded/ScreenFragment.spv.h b/runtime/Includes/Embedded/ShaderScreenFragment.spv.h similarity index 100% rename from runtime/Includes/Embedded/ScreenFragment.spv.h rename to runtime/Includes/Embedded/ShaderScreenFragment.spv.h diff --git a/runtime/Includes/Embedded/ScreenVertex.nzsl b/runtime/Includes/Embedded/ShaderScreenVertex.nzsl similarity index 100% rename from runtime/Includes/Embedded/ScreenVertex.nzsl rename to runtime/Includes/Embedded/ShaderScreenVertex.nzsl diff --git a/runtime/Includes/Embedded/ScreenVertex.spv.h b/runtime/Includes/Embedded/ShaderScreenVertex.spv.h similarity index 100% rename from runtime/Includes/Embedded/ScreenVertex.spv.h rename to runtime/Includes/Embedded/ShaderScreenVertex.spv.h diff --git a/runtime/Includes/Graphics/Scene.h b/runtime/Includes/Graphics/Scene.h index c4e6d27..149ef7a 100644 --- a/runtime/Includes/Graphics/Scene.h +++ b/runtime/Includes/Graphics/Scene.h @@ -33,13 +33,11 @@ namespace mlx inline const Vec4f& GetClearColor() const noexcept { return m_clear_color; } [[nodiscard]] MLX_FORCEINLINE const std::vector>& GetDrawables() const noexcept { return m_drawables; } - [[nodiscard]] MLX_FORCEINLINE ViewerData& GetViewerData() noexcept { return m_viewer_data; } ~Scene() = default; private: std::vector> m_drawables; - ViewerData m_viewer_data; std::shared_ptr p_bound_font; Vec4f m_clear_color = { 0.0f, 0.0f, 0.0f, 1.0f }; }; diff --git a/runtime/Sources/Core/Logs.cpp b/runtime/Sources/Core/Logs.cpp index 37a301b..df87f31 100644 --- a/runtime/Sources/Core/Logs.cpp +++ b/runtime/Sources/Core/Logs.cpp @@ -12,6 +12,10 @@ namespace mlx }; } + std::uint32_t Logs::s_nesting = 0; + + constexpr int LOGS_TABS_WIDTH = 4; + void Logs::Report(LogType type, std::string message) { Report(type, 0, {}, {}, std::move(message)); @@ -38,7 +42,14 @@ namespace mlx switch(type) { - case LogType::Debug: std::cout << Ansi::blue << "[MLX Debug] " << Ansi::def << code_infos << message << '\n'; break; + case LogType::Debug: + { + std::cout << Ansi::blue << "[MLX Debug] " << Ansi::def << std::flush; + std::printf("%*s", s_nesting * LOGS_TABS_WIDTH, ""); + std::fflush(stdout); + std::cout << code_infos << message << std::endl; + break; + } case LogType::Message: std::cout << Ansi::blue << "[MLX Message] " << Ansi::def << code_infos << message << '\n'; break; case LogType::Warning: std::cout << Ansi::magenta << "[MLX Warning] " << Ansi::def << code_infos << message << '\n'; break; case LogType::Error: std::cerr << Ansi::red << "[MLX Error] " << Ansi::def << code_infos << message << '\n'; break; @@ -52,4 +63,15 @@ namespace mlx EventBus::Send("__MlxApplication", Internal::FatalErrorEvent{}); } } + + void Logs::BeginSection() + { + s_nesting++; + } + + void Logs::EndSection() + { + if(s_nesting > 0) + s_nesting--; + } } diff --git a/runtime/Sources/Renderer/Pipelines/Graphics.cpp b/runtime/Sources/Renderer/Pipelines/Graphics.cpp index 3a7e51d..8913043 100644 --- a/runtime/Sources/Renderer/Pipelines/Graphics.cpp +++ b/runtime/Sources/Renderer/Pipelines/Graphics.cpp @@ -133,15 +133,19 @@ namespace mlx DebugLog("Vulkan: framebuffer destroyed"); } m_framebuffers.clear(); + kvfDestroyPipelineLayout(RenderCore::Get().GetDevice(), m_pipeline_layout); m_pipeline_layout = VK_NULL_HANDLE; DebugLog("Vulkan: graphics pipeline layout destroyed"); + kvfDestroyRenderPass(RenderCore::Get().GetDevice(), m_renderpass); m_renderpass = VK_NULL_HANDLE; DebugLog("Vulkan: renderpass destroyed"); + kvfDestroyPipeline(RenderCore::Get().GetDevice(), m_pipeline); m_pipeline = VK_NULL_HANDLE; DebugLog("Vulkan: graphics pipeline destroyed"); + p_renderer = nullptr; m_clears.clear(); m_attachments.clear(); diff --git a/runtime/Sources/Renderer/RenderCore.cpp b/runtime/Sources/Renderer/RenderCore.cpp index e4abfaf..0d56361 100644 --- a/runtime/Sources/Renderer/RenderCore.cpp +++ b/runtime/Sources/Renderer/RenderCore.cpp @@ -56,6 +56,7 @@ namespace mlx return; s_instance = this; + Logs::BeginSection(); loader = std::make_unique(); LoadKVFGlobalVulkanFunctionPointers(); @@ -79,6 +80,7 @@ namespace mlx VkSurfaceKHR surface = window.CreateVulkanSurface(m_instance); + Logs::BeginSection(); m_physical_device = kvfPickGoodDefaultPhysicalDevice(m_instance, surface); // just for style @@ -94,10 +96,12 @@ namespace mlx loader->LoadDevice(m_device); LoadKVFDeviceVulkanFunctionPointers(); + Logs::EndSection(); vkDestroySurfaceKHR(m_instance, surface, nullptr); m_allocator.Init(); + Logs::EndSection(); } #undef MLX_LOAD_FUNCTION diff --git a/runtime/Sources/Renderer/RenderPasses/2DPass.cpp b/runtime/Sources/Renderer/RenderPasses/2DPass.cpp index 09f4afe..d38ddc9 100644 --- a/runtime/Sources/Renderer/RenderPasses/2DPass.cpp +++ b/runtime/Sources/Renderer/RenderPasses/2DPass.cpp @@ -28,7 +28,7 @@ namespace mlx }, { ShaderPushConstantLayout({ 0, sizeof(SpriteData) }) } ); std::vector vertex_shader_code = { - #include + #include }; p_vertex_shader = std::make_shared(vertex_shader_code, ShaderType::Vertex, std::move(vertex_shader_layout)); ShaderLayout fragment_shader_layout( @@ -41,7 +41,7 @@ namespace mlx }, {} ); std::vector fragment_shader_code = { - #include + #include }; p_fragment_shader = std::make_shared(fragment_shader_code, ShaderType::Fragment, std::move(fragment_shader_layout)); diff --git a/runtime/Sources/Renderer/RenderPasses/FinalPass.cpp b/runtime/Sources/Renderer/RenderPasses/FinalPass.cpp index e59bb5e..ed368f5 100644 --- a/runtime/Sources/Renderer/RenderPasses/FinalPass.cpp +++ b/runtime/Sources/Renderer/RenderPasses/FinalPass.cpp @@ -14,7 +14,7 @@ namespace mlx {}, {} ); std::vector vertex_shader_code = { - #include + #include }; p_vertex_shader = std::make_shared(vertex_shader_code, ShaderType::Vertex, std::move(vertex_shader_layout)); ShaderLayout fragment_shader_layout( @@ -27,7 +27,7 @@ namespace mlx }, {} ); std::vector fragment_shader_code = { - #include + #include }; p_fragment_shader = std::make_shared(fragment_shader_code, ShaderType::Fragment, std::move(fragment_shader_layout));