From a75da595e3a7ffaa82e3bce8395f069ff03f330c Mon Sep 17 00:00:00 2001 From: PancakeTAS Date: Sun, 26 Apr 2026 01:19:20 +0200 Subject: [PATCH] feat(bindless): Remove logging temporarily This is a temporary commit, such that the console is not filled with message that cannot be turned off --- lsfg-vk-backend/CMakeLists.txt | 1 - lsfg-vk-backend/src/modules/library.cpp | 22 -------- lsfg-vk-backend/src/modules/pipeline.cpp | 37 ------------ lsfg-vk-backend/src/utility/logger.cpp | 53 ------------------ lsfg-vk-backend/src/utility/logger.hpp | 56 ------------------- .../include/lsfg-vk-common/vulkan/buffer.hpp | 7 ++- 6 files changed, 6 insertions(+), 170 deletions(-) delete mode 100644 lsfg-vk-backend/src/utility/logger.cpp delete mode 100644 lsfg-vk-backend/src/utility/logger.hpp diff --git a/lsfg-vk-backend/CMakeLists.txt b/lsfg-vk-backend/CMakeLists.txt index 9130ee0..a92decf 100644 --- a/lsfg-vk-backend/CMakeLists.txt +++ b/lsfg-vk-backend/CMakeLists.txt @@ -2,7 +2,6 @@ set(BACKEND_SOURCES "src/modules/library/dll.cpp" "src/modules/library.cpp" "src/modules/pipeline.cpp" - "src/utility/logger.cpp" "src/utility/pipelines.cpp" "src/utility/vkhelper.cpp" "src/lsfgvk.cpp") diff --git a/lsfg-vk-backend/src/modules/library.cpp b/lsfg-vk-backend/src/modules/library.cpp index a4d93c2..31f52bb 100644 --- a/lsfg-vk-backend/src/modules/library.cpp +++ b/lsfg-vk-backend/src/modules/library.cpp @@ -2,18 +2,15 @@ #include "library.hpp" #include "library/dll.hpp" -#include "utility/logger.hpp" #include "utility/vkhelper.hpp" #include #include #include -#include #include #include #include #include -#include /// All base shaders in the library. const std::array, 3> BASE_LIBRARY{{ @@ -58,8 +55,6 @@ ShaderLibrary::ShaderLibrary( bool halfPrecision, const std::filesystem::path& dll ) { - LOG_DEBUG("Loading shader library from DLL: " << dll) - if (!std::filesystem::exists(dll)) { throw std::runtime_error("The specified shader DLL does not exist"); } @@ -74,11 +69,6 @@ ShaderLibrary::ShaderLibrary( "Unable to find base shader '" + std::string(name) + "' in DLL" ); - LOG_DEBUG(" " << std::setw(2) << idx - << ": name=" << name - << ", rid=" << rid - << ", size=" << (it->second.size() * 4) << " bytes") - this->m_baseShaders[name] = vkhelper::createShaderModule(dld, device, it->second); } @@ -95,19 +85,7 @@ ShaderLibrary::ShaderLibrary( "Unable to find shader '" + std::string(name) + "' in DLL" ); - LOG_DEBUG(" " << std::setw(2) << idx - << ": name=" << std::setw(8) << name - << ", [Q] " - << "rid="<< std::setw(2) << rid.first - << ", size="<< std::setw(5) << (qit->second.size() * 4) << " bytes" - << ", [P] " - << "rid="<< std::setw(2) << rid.second - << ", size="<< std::setw(5) << (pit->second.size() * 4) << " bytes") - this->m_qualityShaders[name] = vkhelper::createShaderModule(dld, device, qit->second); this->m_performanceShaders[name] = vkhelper::createShaderModule(dld, device, pit->second); - } - - LOG_DEBUG("Finished loading shader library") } diff --git a/lsfg-vk-backend/src/modules/pipeline.cpp b/lsfg-vk-backend/src/modules/pipeline.cpp index 450c8ac..163346f 100644 --- a/lsfg-vk-backend/src/modules/pipeline.cpp +++ b/lsfg-vk-backend/src/modules/pipeline.cpp @@ -6,14 +6,12 @@ #include "modules/pipeline/signature/helpers.hpp" #include "modules/pipeline/signature/image.hpp" #include "modules/pipeline/signature/pass.hpp" -#include "utility/logger.hpp" #include "utility/vkhelper.hpp" #include #include #include #include -#include #include #include #include @@ -54,10 +52,6 @@ Pipeline::Pipeline( bool perf, bool hdr ) { - LOG_DEBUG("Building pipeline for " - << extent.width << "x" << extent.height - << " at " << flow << " flow") - // Build the Vulkan descriptor set layout uint32_t sampledImageCount{}; uint32_t storageImageCount{}; @@ -115,10 +109,6 @@ Pipeline::Pipeline( .pipelineLayout = std::move(pipelineLayout) }; - LOG_DEBUG(" Built descriptor set layout with " << bindings.size() << " bindings (" - << sampledImageCount << " sampled images, " - << storageImageCount << " storage images)") - // Create the Vulkan images size_t alignment{}; uint32_t types{~0U}; @@ -186,12 +176,6 @@ Pipeline::Pipeline( }); } - LOG_DEBUG(" Allocated memory of size " - << [&]() { - const auto& reqs{device.getImageMemoryRequirements(*subimage, dld)}; - return reqs.size; - }() << " for external image " << imageIdx) - image.subimages.push_back({ .image = std::move(subimage) }); @@ -230,9 +214,6 @@ Pipeline::Pipeline( if (types == 0) throw std::runtime_error("No compatible memory type found for pipeline images"); - LOG_DEBUG(" Created " << this->m_images.size() << " images with common alignment " - << alignment << " and memory type bits " << std::hex << types << std::dec) - // Fill in image sizes in respect to alignment for (auto& image : this->m_images) { if (image.signature.flags & (ImageFlag::ExternalInput | ImageFlag::ExternalOutput)) @@ -324,8 +305,6 @@ Pipeline::Pipeline( } } - LOG_DEBUG(" Computed " << this->m_allocations.size() << " memory allocations") - // Allocate the memory & bind the images for (auto& allocation : this->m_allocations) { allocation.memory = vkhelper::allocateMemory( @@ -351,9 +330,6 @@ Pipeline::Pipeline( ); } } - - LOG_DEBUG(" Allocated memory of size " << allocation.size << " for " - << allocation.segments.size() << " segments") } // Create image views @@ -496,8 +472,6 @@ Pipeline::Pipeline( device.updateDescriptorSets(writeInfos, {}, dld); - LOG_DEBUG(" Updated descriptor set with " << writeInfos.size() << " bindings") - // Build all shader pipelines std::vector pipelineCreateInfos; for (const auto& [name, variant] : signature.shaders) { @@ -535,8 +509,6 @@ Pipeline::Pipeline( }; if (!isCacheValid) { - LOG_DEBUG(" Pipeline cache is not valid, persisting new cache data") - vkhelper::persistPipelineCache( dld, device, @@ -552,8 +524,6 @@ Pipeline::Pipeline( this->m_pipelines.emplace(name, std::move(pipelines.at(i))); } - LOG_DEBUG(" Created " << this->m_pipelines.size() << " pipelines") - // Build pipeline stages std::unordered_map indices; for (const auto& stageSignature : signature.stages) { @@ -589,8 +559,6 @@ Pipeline::Pipeline( } } - LOG_DEBUG(" Built " << this->m_stages.size() << " pipeline stages") - // Transition all images into general layout this->m_pool = vkhelper::createCommandPool( dld, @@ -637,8 +605,6 @@ Pipeline::Pipeline( throw std::runtime_error("Failed to wait for image layout transition fence"); } - LOG_DEBUG(" Transitioned all " << this->m_images.size() << " images into general layout") - for (size_t i = 0; i < signature.splitIndices.size() + 1; i++) { auto& cmdbuf{this->m_cmdbufs.emplace_back()}; cmdbuf = vkhelper::createCommandBuffer(dld, device, *this->m_pool); @@ -801,9 +767,6 @@ Pipeline::Pipeline( for (auto& cmdbuf : this->m_cmdbufs) { cmdbuf->end(dld); } - - LOG_DEBUG(" Recorded command buffers for pipeline execution") - LOG_DEBUG("Finished building pipeline") } vk::CommandBuffer Pipeline::buildTransCmdbuf( diff --git a/lsfg-vk-backend/src/utility/logger.cpp b/lsfg-vk-backend/src/utility/logger.cpp deleted file mode 100644 index 4b3eaec..0000000 --- a/lsfg-vk-backend/src/utility/logger.cpp +++ /dev/null @@ -1,53 +0,0 @@ -/* SPDX-License-Identifier: GPL-3.0-or-later */ - -#include "logger.hpp" - -#include -#include -#include -#include - -using namespace lsfgvk; -using namespace lsfgvk::logger; - -namespace { - /// Get the current minimum log level - Level& currentLevel() { - static Level level{Level::Debug}; - return level; - } - - /// Format a log level as a string - constexpr std::string_view formatLevel(Level level) { - switch (level) { - case Level::Debug: - return "DEBUG"; - case Level::Info: - return "INFO "; - case Level::Warning: - return "WARN "; - case Level::Error: - return "ERROR"; - } - } -} - -void logger::setLevel(Level level) { -#ifdef NDEBUG - if (level == Level::Debug) { - LOG_WARNING("Release builds do not support debug log level, defaulting to info"); - level = Level::Info; - } -#endif - currentLevel() = level; -} - -void logger::log(Level level, const std::string& message) { - if (level < currentLevel()) - return; - - std::ostringstream log; - log << "(lsfg-vk) [" << formatLevel(level) << "] " << message << '\n'; - - std::cerr << log.str(); -} diff --git a/lsfg-vk-backend/src/utility/logger.hpp b/lsfg-vk-backend/src/utility/logger.hpp deleted file mode 100644 index a900571..0000000 --- a/lsfg-vk-backend/src/utility/logger.hpp +++ /dev/null @@ -1,56 +0,0 @@ -/* SPDX-License-Identifier: GPL-3.0-or-later */ - -#pragma once - -#include -#include // IWYU pragma: keep -#include -#include // IWYU pragma: keep - -namespace lsfgvk::logger { - - /// Various levels for log messages - enum class Level : uint8_t { - /// Detailed debugging information - Debug, - /// General informational messages - Info, - /// Potentially problematic situations - Warning, - /// Irrecoverable errors - Error - }; - - /// - /// Set the minimum log level - /// - /// @param level Inclusive minimum log level - /// - void setLevel(Level level); - - /// - /// Log a message - /// - /// @param level Log level - /// @param message Log message - /// - void log(Level level, const std::string& message); - - // NOLINTBEGIN (macro parentheses) - #define LOG(level, msg) { \ - std::ostringstream _oss; \ - _oss << msg; \ - lsfgvk::logger::log(level, _oss.str()); \ - } - - #define LOG_INFO(msg) LOG(lsfgvk::logger::Level::Info, msg) - #define LOG_WARNING(msg) LOG(lsfgvk::logger::Level::Warning, msg) - #define LOG_ERROR(msg) LOG(lsfgvk::logger::Level::Error, msg) -#ifdef NDEBUG - #define LOG_DEBUG(msg) -#else - #define LOG_DEBUG(msg) LOG(lsfgvk::logger::Level::Debug, msg) -#endif - // NOLINTEND - -} diff --git a/lsfg-vk-common/include/lsfg-vk-common/vulkan/buffer.hpp b/lsfg-vk-common/include/lsfg-vk-common/vulkan/buffer.hpp index 7fabeb2..ed762db 100644 --- a/lsfg-vk-common/include/lsfg-vk-common/vulkan/buffer.hpp +++ b/lsfg-vk-common/include/lsfg-vk-common/vulkan/buffer.hpp @@ -21,7 +21,12 @@ namespace vk { template Buffer(const vk::Vulkan& vk, const T& data, VkBufferUsageFlags usage = VK_BUFFER_USAGE_UNIFORM_BUFFER_BIT) - : Buffer(vk, reinterpret_cast(&data), sizeof(T), usage) {} + : Buffer( + vk, + reinterpret_cast(&data), // NOLINT (unsafe cast) + sizeof(T), + usage + ) {} /// create a buffer /// @param vk the vulkan instance