mirror of
https://github.com/seekrs/MacroLibX.git
synced 2026-01-11 06:33:35 +00:00
adding nesting to debug logs
This commit is contained in:
@@ -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<typename... Args>
|
||||
void Assert(bool cond, unsigned int line, std::string_view file, std::string_view function, std::string message, const Args&... args);
|
||||
#else
|
||||
|
||||
@@ -102,7 +102,7 @@ namespace mlx
|
||||
}
|
||||
}
|
||||
|
||||
#if defined(DEBUG)
|
||||
#ifdef DEBUG
|
||||
template<typename... Args>
|
||||
void Assert(bool cond, unsigned int line, std::string_view file, std::string_view function, std::string message, const Args&... args)
|
||||
{
|
||||
|
||||
@@ -33,13 +33,11 @@ namespace mlx
|
||||
inline const Vec4f& GetClearColor() const noexcept { return m_clear_color; }
|
||||
|
||||
[[nodiscard]] MLX_FORCEINLINE const std::vector<std::shared_ptr<Drawable>>& GetDrawables() const noexcept { return m_drawables; }
|
||||
[[nodiscard]] MLX_FORCEINLINE ViewerData& GetViewerData() noexcept { return m_viewer_data; }
|
||||
|
||||
~Scene() = default;
|
||||
|
||||
private:
|
||||
std::vector<std::shared_ptr<Drawable>> m_drawables;
|
||||
ViewerData m_viewer_data;
|
||||
std::shared_ptr<Font> p_bound_font;
|
||||
Vec4f m_clear_color = { 0.0f, 0.0f, 0.0f, 1.0f };
|
||||
};
|
||||
|
||||
@@ -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--;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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();
|
||||
|
||||
@@ -56,6 +56,7 @@ namespace mlx
|
||||
return;
|
||||
s_instance = this;
|
||||
|
||||
Logs::BeginSection();
|
||||
loader = std::make_unique<VulkanLoader>();
|
||||
|
||||
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
|
||||
|
||||
@@ -28,7 +28,7 @@ namespace mlx
|
||||
}, { ShaderPushConstantLayout({ 0, sizeof(SpriteData) }) }
|
||||
);
|
||||
std::vector<std::uint8_t> vertex_shader_code = {
|
||||
#include <Embedded/2DVertex.spv.h>
|
||||
#include <Embedded/Shader2DVertex.spv.h>
|
||||
};
|
||||
p_vertex_shader = std::make_shared<Shader>(vertex_shader_code, ShaderType::Vertex, std::move(vertex_shader_layout));
|
||||
ShaderLayout fragment_shader_layout(
|
||||
@@ -41,7 +41,7 @@ namespace mlx
|
||||
}, {}
|
||||
);
|
||||
std::vector<std::uint8_t> fragment_shader_code = {
|
||||
#include <Embedded/2DFragment.spv.h>
|
||||
#include <Embedded/Shader2DFragment.spv.h>
|
||||
};
|
||||
p_fragment_shader = std::make_shared<Shader>(fragment_shader_code, ShaderType::Fragment, std::move(fragment_shader_layout));
|
||||
|
||||
|
||||
@@ -14,7 +14,7 @@ namespace mlx
|
||||
{}, {}
|
||||
);
|
||||
std::vector<std::uint8_t> vertex_shader_code = {
|
||||
#include <Embedded/ScreenVertex.spv.h>
|
||||
#include <Embedded/ShaderScreenVertex.spv.h>
|
||||
};
|
||||
p_vertex_shader = std::make_shared<Shader>(vertex_shader_code, ShaderType::Vertex, std::move(vertex_shader_layout));
|
||||
ShaderLayout fragment_shader_layout(
|
||||
@@ -27,7 +27,7 @@ namespace mlx
|
||||
}, {}
|
||||
);
|
||||
std::vector<std::uint8_t> fragment_shader_code = {
|
||||
#include <Embedded/ScreenFragment.spv.h>
|
||||
#include <Embedded/ShaderScreenFragment.spv.h>
|
||||
};
|
||||
p_fragment_shader = std::make_shared<Shader>(fragment_shader_code, ShaderType::Fragment, std::move(fragment_shader_layout));
|
||||
|
||||
|
||||
Reference in New Issue
Block a user