Skip to content

Commit

Permalink
[*] Cleanup spdlog messages
Browse files Browse the repository at this point in the history
  • Loading branch information
IAmNotHanni committed May 14, 2022
1 parent 38955aa commit fb86285
Show file tree
Hide file tree
Showing 16 changed files with 412 additions and 415 deletions.
6 changes: 3 additions & 3 deletions example/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,8 @@ int main(int argc, char *argv[]) {

spdlog::set_default_logger(vulkan_renderer_log);

spdlog::debug("Inexor vulkan-renderer, BUILD " + std::string(__DATE__) + ", " + __TIME__);
spdlog::debug("Parsing command line arguments.");
spdlog::trace("Inexor vulkan-renderer, BUILD " + std::string(__DATE__) + ", " + __TIME__);
spdlog::trace("Parsing command line arguments");

std::unique_ptr<inexor::vulkan_renderer::Application> renderer;

Expand All @@ -38,5 +38,5 @@ int main(int argc, char *argv[]) {

renderer->run();
renderer->calculate_memory_budget();
spdlog::debug("Window closed");
spdlog::trace("Window closed");
}
12 changes: 6 additions & 6 deletions include/inexor/vulkan-renderer/wrapper/mesh_buffer.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -74,8 +74,8 @@ class MeshBuffer {
std::size_t vertex_buffer_size = sizeof(VertexType) * vertex_count;
std::size_t index_buffer_size = sizeof(IndexType) * index_count;

spdlog::debug("Creating vertex buffer of size {} for mesh {}.", vertex_buffer_size, name);
spdlog::debug("Creating index buffer of size {} for mesh {}.", index_buffer_size, name);
spdlog::trace("Creating vertex buffer of size {} for mesh {}", vertex_buffer_size, name);
spdlog::trace("Creating index buffer of size {} for mesh {}", index_buffer_size, name);
}

/// @brief Creates a mesh buffer of type VertexType without a corresponding index buffer by specifying the number of
Expand All @@ -96,7 +96,7 @@ class MeshBuffer {

std::size_t vertex_buffer_size = sizeof(VertexType) * vertex_count;

spdlog::debug("Creating vertex buffer of size {} for mesh {}.", vertex_buffer_size, name);
spdlog::trace("Creating vertex buffer of size {} for mesh {}", vertex_buffer_size, name);
}

/// @brief Constructs a mesh buffer of type VertexType with a corresponding index buffer of type IndexType.
Expand All @@ -110,8 +110,8 @@ class MeshBuffer {
std::size_t vertex_buffer_size = sizeof(VertexType) * vertices.size();
std::size_t index_buffer_size = sizeof(IndexType) * indices.size();

spdlog::debug("Creating vertex buffer of size {} for mesh {}.", vertex_buffer_size, name);
spdlog::debug("Creating index buffer of size {} for mesh {}.", index_buffer_size, name);
spdlog::trace("Creating vertex buffer of size {} for mesh {}", vertex_buffer_size, name);
spdlog::trace("Creating index buffer of size {} for mesh {}", index_buffer_size, name);

// Not using an index buffer can decrease performance drastically!
if (index_buffer_size == 0) {
Expand Down Expand Up @@ -148,7 +148,7 @@ class MeshBuffer {
: MeshBuffer(device, name, vertices.size()) {
std::size_t size_of_vertex_buffer = sizeof(VertexType) * vertices.size();

spdlog::debug("Creating vertex buffer of size {} for mesh {}.", size_of_vertex_buffer, name);
spdlog::trace("Creating vertex buffer of size {} for mesh {}", size_of_vertex_buffer, name);

// Not using an index buffer can decrease performance drastically!
spdlog::warn("Creating a vertex buffer without an index buffer!");
Expand Down
104 changes: 51 additions & 53 deletions src/vulkan-renderer/application.cpp

Large diffs are not rendered by default.

10 changes: 5 additions & 5 deletions src/vulkan-renderer/imgui.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ namespace inexor::vulkan_renderer {
ImGUIOverlay::ImGUIOverlay(const wrapper::Device &device, const wrapper::Swapchain &swapchain,
RenderGraph *render_graph, TextureResource *back_buffer)
: m_device(device), m_swapchain(swapchain) {
spdlog::debug("Creating ImGUI context");
spdlog::trace("Creating ImGUI context");
ImGui::CreateContext();

ImGuiStyle &style = ImGui::GetStyle();
Expand All @@ -37,7 +37,7 @@ ImGUIOverlay::ImGUIOverlay(const wrapper::Device &device, const wrapper::Swapcha
ImGuiIO &io = ImGui::GetIO();
io.FontGlobalScale = m_scale;

spdlog::debug("Loading ImGUI shaders");
spdlog::trace("Loading ImGUI shaders");
m_vertex_shader = std::make_unique<wrapper::Shader>(m_device, VK_SHADER_STAGE_VERTEX_BIT, "ImGUI vertex shader",
"shaders/ui.vert.spv");
m_fragment_shader = std::make_unique<wrapper::Shader>(m_device, VK_SHADER_STAGE_FRAGMENT_BIT,
Expand All @@ -49,7 +49,7 @@ ImGUIOverlay::ImGUIOverlay(const wrapper::Device &device, const wrapper::Swapcha
constexpr const char *FONT_FILE_PATH = "assets/fonts/NotoSans-Bold.ttf";
constexpr float FONT_SIZE = 18.0f;

spdlog::debug("Loading front '{}'", FONT_FILE_PATH);
spdlog::trace("Loading front {}", FONT_FILE_PATH);

ImFont *font = io.Fonts->AddFontFromFileTTF(FONT_FILE_PATH, FONT_SIZE);

Expand All @@ -59,10 +59,10 @@ ImGUIOverlay::ImGUIOverlay(const wrapper::Device &device, const wrapper::Swapcha
io.Fonts->GetTexDataAsRGBA32(&font_texture_data, &font_texture_width, &font_texture_height);

if (font == nullptr || font_texture_data == nullptr) {
spdlog::error("Unable to load font {}. Falling back to error texture.", FONT_FILE_PATH);
spdlog::error("Unable to load font {}. Falling back to error texture", FONT_FILE_PATH);
m_imgui_texture = std::make_unique<wrapper::GpuTexture>(m_device, wrapper::CpuTexture());
} else {
spdlog::debug("Creating ImGUI font texture");
spdlog::trace("Creating ImGUI font texture");

// Our font textures always have 4 channels and a single mip level by definition.
constexpr int FONT_TEXTURE_CHANNELS{4};
Expand Down
8 changes: 4 additions & 4 deletions src/vulkan-renderer/io/nxoc_parser.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -64,27 +64,27 @@ std::shared_ptr<world::Cube> NXOCParser::deserialize_impl<0>(const ByteStream &s

ByteStream NXOCParser::serialize(const std::shared_ptr<const world::Cube> cube, const std::uint32_t version) {
if (cube == nullptr) {
throw std::invalid_argument("cube cannot be a nullptr.");
throw std::invalid_argument("cube cannot be a nullptr");
}
switch (version) { // NOLINT
case 0:
return serialize_impl<0>(cube);
default:
throw IoException("Unsupported octree version.");
throw IoException("Unsupported octree version");
}
}

std::shared_ptr<world::Cube> NXOCParser::deserialize(const ByteStream &stream) {
ByteStreamReader reader(stream);
if (reader.read<std::string>(13ull) != "Inexor Octree") {
throw IoException("Wrong identifier.");
throw IoException("Wrong identifier");
}
const auto version = reader.read<std::uint32_t>();
switch (version) { // NOLINT
case 0:
return deserialize_impl<0>(stream);
default:
throw IoException("Unsupported octree version.");
throw IoException("Unsupported octree version");
}
}
} // namespace inexor::vulkan_renderer::io
17 changes: 12 additions & 5 deletions src/vulkan-renderer/render_graph.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -399,20 +399,25 @@ void RenderGraph::compile(const RenderResource *target) {
dfs(stage);
}

m_log->debug("Final stage order:");
m_log->trace("Final stage order:");
for (auto *stage : m_stage_stack) {
m_log->debug(" - {}", stage->m_name);
m_log->trace(" - {}", stage->m_name);
}

// Create physical resources. For now, each buffer or texture resource maps directly to either a VkBuffer or VkImage
// respectively. Every physical resource also has a VmaAllocation.
// TODO: Resource aliasing (i.e. reusing the same physical resource for multiple resources).
m_log->trace("Allocating physical resource for buffers:");

for (auto &buffer_resource : m_buffer_resources) {
m_log->trace("Allocating physical resource for buffer '{}'", buffer_resource->m_name);
m_log->trace(" - {}", buffer_resource->m_name);
buffer_resource->m_physical = std::make_shared<PhysicalBuffer>(m_device.allocator(), m_device.device());
}

m_log->trace("Allocating physical resource for texture:");

for (auto &texture_resource : m_texture_resources) {
m_log->trace("Allocating physical resource for texture '{}'", texture_resource->m_name);
m_log->trace(" - {}", texture_resource->m_name);
// Back buffer gets special handling.
if (texture_resource->m_usage == TextureUsage::BACK_BUFFER) {
// TODO: Move image views from wrapper::Swapchain to PhysicalBackBuffer.
Expand Down Expand Up @@ -481,12 +486,14 @@ void RenderGraph::compile(const RenderResource *target) {
}
}

m_log->trace("Allocating command buffers for stage:");

// Allocate command buffers and finished semaphore.
for (const auto *stage : m_stage_stack) {
auto &physical = *stage->m_physical;
physical.m_finished_semaphore =
std::make_unique<wrapper::Semaphore>(m_device, "Finished semaphore for stage " + stage->m_name);
m_log->trace("Allocating command buffers for stage '{}'", stage->m_name);
m_log->trace(" - {}", stage->m_name);
for (std::uint32_t i = 0; i < m_swapchain.image_count(); i++) {
physical.m_command_buffers.emplace_back(m_device, m_command_pool,
"Command buffer for stage " + stage->m_name);
Expand Down
33 changes: 16 additions & 17 deletions src/vulkan-renderer/renderer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -121,29 +121,28 @@ void VulkanRenderer::render_frame() {

if (auto fps_value = m_fps_counter.update()) {
m_window->set_title("Inexor Vulkan API renderer demo - " + std::to_string(*fps_value) + " FPS");
spdlog::debug("FPS: {}, window size: {} x {}.", *fps_value, m_window->width(), m_window->height());
spdlog::trace("FPS: {}, window size: {} x {}", *fps_value, m_window->width(), m_window->height());
}
}

void VulkanRenderer::calculate_memory_budget() {
VmaStats memory_stats;
vmaCalculateStats(m_device->allocator(), &memory_stats);

spdlog::debug("-------------VMA stats-------------");
spdlog::debug("Number of `VkDeviceMemory` (physical memory) blocks allocated: {} still alive, {} in total",
memory_stats.memoryHeap->blockCount, memory_stats.total.blockCount);
spdlog::debug("Number of VmaAlllocation objects allocated (requested memory): {} still alive, {} in total",
memory_stats.memoryHeap->allocationCount, memory_stats.total.allocationCount);
spdlog::debug("Number of free ranges of memory between allocations: {}", memory_stats.memoryHeap->unusedRangeCount);
spdlog::debug("Total number of bytes occupied by all allocations: {}", memory_stats.memoryHeap->usedBytes);
spdlog::debug("Total number of bytes occupied by unused ranges: {}", memory_stats.memoryHeap->unusedBytes);
spdlog::debug("memory_stats.memoryHeap->allocationSizeMin: {}", memory_stats.memoryHeap->allocationSizeMin);
spdlog::debug("memory_stats.memoryHeap->allocationSizeAvg: {}", memory_stats.memoryHeap->allocationSizeAvg);
spdlog::debug("memory_stats.memoryHeap->allocationSizeMax: {}", memory_stats.memoryHeap->allocationSizeMax);
spdlog::debug("memory_stats.memoryHeap->unusedRangeSizeMin: {}", memory_stats.memoryHeap->unusedRangeSizeMin);
spdlog::debug("memory_stats.memoryHeap->unusedRangeSizeAvg: {}", memory_stats.memoryHeap->unusedRangeSizeAvg);
spdlog::debug("memory_stats.memoryHeap->unusedRangeSizeMax: {}", memory_stats.memoryHeap->unusedRangeSizeMax);
spdlog::debug("-------------VMA stats-------------");
spdlog::trace("Vulkan Memory Allocator statistics:");
spdlog::trace(" total.blockCount: {}", memory_stats.total.blockCount);
spdlog::trace(" total.allocationCount: {}", memory_stats.total.allocationCount);
spdlog::trace(" memoryHeap->blockCount: {}", memory_stats.memoryHeap->blockCount);
spdlog::trace(" memoryHeap->allocationCount: {}", memory_stats.memoryHeap->allocationCount);
spdlog::trace(" memoryHeap->unusedRangeCount: {}", memory_stats.memoryHeap->unusedRangeCount);
spdlog::trace(" memoryHeap->usedBytes: {}", memory_stats.memoryHeap->usedBytes);
spdlog::trace(" memoryHeap->unusedBytes: {}", memory_stats.memoryHeap->unusedBytes);
spdlog::trace(" memoryHeap->allocationSizeMin: {}", memory_stats.memoryHeap->allocationSizeMin);
spdlog::trace(" memoryHeap->allocationSizeAvg: {}", memory_stats.memoryHeap->allocationSizeAvg);
spdlog::trace(" memoryHeap->allocationSizeMax: {}", memory_stats.memoryHeap->allocationSizeMax);
spdlog::trace(" memoryHeap->unusedRangeSizeMin: {}", memory_stats.memoryHeap->unusedRangeSizeMin);
spdlog::trace(" memoryHeap->unusedRangeSizeAvg: {}", memory_stats.memoryHeap->unusedRangeSizeAvg);
spdlog::trace(" memoryHeap->unusedRangeSizeMax: {}", memory_stats.memoryHeap->unusedRangeSizeMax);

char *vma_stats_string = nullptr;
vmaBuildStatsString(m_device->allocator(), &vma_stats_string, VK_TRUE);
Expand All @@ -157,7 +156,7 @@ void VulkanRenderer::calculate_memory_budget() {
}

VulkanRenderer::~VulkanRenderer() {
spdlog::debug("Shutting down vulkan renderer");
spdlog::trace("Shutting down vulkan renderer");

if (m_device == nullptr) {
return;
Expand Down
Loading

0 comments on commit fb86285

Please sign in to comment.