feat(bindless): Remove logging temporarily

This is a temporary commit, such that the console is not filled with message that cannot be turned off
This commit is contained in:
PancakeTAS 2026-04-26 01:19:20 +02:00
parent e611c5b27d
commit a75da595e3
No known key found for this signature in database
6 changed files with 6 additions and 170 deletions

View file

@ -2,7 +2,6 @@ set(BACKEND_SOURCES
"src/modules/library/dll.cpp" "src/modules/library/dll.cpp"
"src/modules/library.cpp" "src/modules/library.cpp"
"src/modules/pipeline.cpp" "src/modules/pipeline.cpp"
"src/utility/logger.cpp"
"src/utility/pipelines.cpp" "src/utility/pipelines.cpp"
"src/utility/vkhelper.cpp" "src/utility/vkhelper.cpp"
"src/lsfgvk.cpp") "src/lsfgvk.cpp")

View file

@ -2,18 +2,15 @@
#include "library.hpp" #include "library.hpp"
#include "library/dll.hpp" #include "library/dll.hpp"
#include "utility/logger.hpp"
#include "utility/vkhelper.hpp" #include "utility/vkhelper.hpp"
#include <array> #include <array>
#include <cstdint> #include <cstdint>
#include <filesystem> #include <filesystem>
#include <iomanip>
#include <stdexcept> #include <stdexcept>
#include <string> #include <string>
#include <string_view> #include <string_view>
#include <utility> #include <utility>
#include <vector>
/// All base shaders in the library. /// All base shaders in the library.
const std::array<std::pair<std::string_view, uint32_t>, 3> BASE_LIBRARY{{ const std::array<std::pair<std::string_view, uint32_t>, 3> BASE_LIBRARY{{
@ -58,8 +55,6 @@ ShaderLibrary::ShaderLibrary(
bool halfPrecision, bool halfPrecision,
const std::filesystem::path& dll const std::filesystem::path& dll
) { ) {
LOG_DEBUG("Loading shader library from DLL: " << dll)
if (!std::filesystem::exists(dll)) { if (!std::filesystem::exists(dll)) {
throw std::runtime_error("The specified shader DLL does not exist"); 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" "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); 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" "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_qualityShaders[name] = vkhelper::createShaderModule(dld, device, qit->second);
this->m_performanceShaders[name] = vkhelper::createShaderModule(dld, device, pit->second); this->m_performanceShaders[name] = vkhelper::createShaderModule(dld, device, pit->second);
} }
LOG_DEBUG("Finished loading shader library")
} }

View file

@ -6,14 +6,12 @@
#include "modules/pipeline/signature/helpers.hpp" #include "modules/pipeline/signature/helpers.hpp"
#include "modules/pipeline/signature/image.hpp" #include "modules/pipeline/signature/image.hpp"
#include "modules/pipeline/signature/pass.hpp" #include "modules/pipeline/signature/pass.hpp"
#include "utility/logger.hpp"
#include "utility/vkhelper.hpp" #include "utility/vkhelper.hpp"
#include <algorithm> #include <algorithm>
#include <array> #include <array>
#include <cstddef> #include <cstddef>
#include <cstdint> #include <cstdint>
#include <ios>
#include <memory> #include <memory>
#include <numeric> #include <numeric>
#include <stdexcept> #include <stdexcept>
@ -54,10 +52,6 @@ Pipeline::Pipeline(
bool perf, bool perf,
bool hdr bool hdr
) { ) {
LOG_DEBUG("Building pipeline for "
<< extent.width << "x" << extent.height
<< " at " << flow << " flow")
// Build the Vulkan descriptor set layout // Build the Vulkan descriptor set layout
uint32_t sampledImageCount{}; uint32_t sampledImageCount{};
uint32_t storageImageCount{}; uint32_t storageImageCount{};
@ -115,10 +109,6 @@ Pipeline::Pipeline(
.pipelineLayout = std::move(pipelineLayout) .pipelineLayout = std::move(pipelineLayout)
}; };
LOG_DEBUG(" Built descriptor set layout with " << bindings.size() << " bindings ("
<< sampledImageCount << " sampled images, "
<< storageImageCount << " storage images)")
// Create the Vulkan images // Create the Vulkan images
size_t alignment{}; size_t alignment{};
uint32_t types{~0U}; 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.subimages.push_back({
.image = std::move(subimage) .image = std::move(subimage)
}); });
@ -230,9 +214,6 @@ Pipeline::Pipeline(
if (types == 0) if (types == 0)
throw std::runtime_error("No compatible memory type found for pipeline images"); 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 // Fill in image sizes in respect to alignment
for (auto& image : this->m_images) { for (auto& image : this->m_images) {
if (image.signature.flags & (ImageFlag::ExternalInput | ImageFlag::ExternalOutput)) 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 // Allocate the memory & bind the images
for (auto& allocation : this->m_allocations) { for (auto& allocation : this->m_allocations) {
allocation.memory = vkhelper::allocateMemory( 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 // Create image views
@ -496,8 +472,6 @@ Pipeline::Pipeline(
device.updateDescriptorSets(writeInfos, {}, dld); device.updateDescriptorSets(writeInfos, {}, dld);
LOG_DEBUG(" Updated descriptor set with " << writeInfos.size() << " bindings")
// Build all shader pipelines // Build all shader pipelines
std::vector<vk::ComputePipelineCreateInfo> pipelineCreateInfos; std::vector<vk::ComputePipelineCreateInfo> pipelineCreateInfos;
for (const auto& [name, variant] : signature.shaders) { for (const auto& [name, variant] : signature.shaders) {
@ -535,8 +509,6 @@ Pipeline::Pipeline(
}; };
if (!isCacheValid) { if (!isCacheValid) {
LOG_DEBUG(" Pipeline cache is not valid, persisting new cache data")
vkhelper::persistPipelineCache( vkhelper::persistPipelineCache(
dld, dld,
device, device,
@ -552,8 +524,6 @@ Pipeline::Pipeline(
this->m_pipelines.emplace(name, std::move(pipelines.at(i))); this->m_pipelines.emplace(name, std::move(pipelines.at(i)));
} }
LOG_DEBUG(" Created " << this->m_pipelines.size() << " pipelines")
// Build pipeline stages // Build pipeline stages
std::unordered_map<std::string_view, uint32_t> indices; std::unordered_map<std::string_view, uint32_t> indices;
for (const auto& stageSignature : signature.stages) { 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 // Transition all images into general layout
this->m_pool = vkhelper::createCommandPool( this->m_pool = vkhelper::createCommandPool(
dld, dld,
@ -637,8 +605,6 @@ Pipeline::Pipeline(
throw std::runtime_error("Failed to wait for image layout transition fence"); 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++) { for (size_t i = 0; i < signature.splitIndices.size() + 1; i++) {
auto& cmdbuf{this->m_cmdbufs.emplace_back()}; auto& cmdbuf{this->m_cmdbufs.emplace_back()};
cmdbuf = vkhelper::createCommandBuffer(dld, device, *this->m_pool); cmdbuf = vkhelper::createCommandBuffer(dld, device, *this->m_pool);
@ -801,9 +767,6 @@ Pipeline::Pipeline(
for (auto& cmdbuf : this->m_cmdbufs) { for (auto& cmdbuf : this->m_cmdbufs) {
cmdbuf->end(dld); cmdbuf->end(dld);
} }
LOG_DEBUG(" Recorded command buffers for pipeline execution")
LOG_DEBUG("Finished building pipeline")
} }
vk::CommandBuffer Pipeline::buildTransCmdbuf( vk::CommandBuffer Pipeline::buildTransCmdbuf(

View file

@ -1,53 +0,0 @@
/* SPDX-License-Identifier: GPL-3.0-or-later */
#include "logger.hpp"
#include <iostream>
#include <sstream>
#include <string>
#include <string_view>
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();
}

View file

@ -1,56 +0,0 @@
/* SPDX-License-Identifier: GPL-3.0-or-later */
#pragma once
#include <cstdint>
#include <sstream> // IWYU pragma: keep
#include <string>
#include <string_view> // 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
}

View file

@ -21,7 +21,12 @@ namespace vk {
template<typename T> template<typename T>
Buffer(const vk::Vulkan& vk, const T& data, Buffer(const vk::Vulkan& vk, const T& data,
VkBufferUsageFlags usage = VK_BUFFER_USAGE_UNIFORM_BUFFER_BIT) VkBufferUsageFlags usage = VK_BUFFER_USAGE_UNIFORM_BUFFER_BIT)
: Buffer(vk, reinterpret_cast<const void*>(&data), sizeof(T), usage) {} : Buffer(
vk,
reinterpret_cast<const void*>(&data), // NOLINT (unsafe cast)
sizeof(T),
usage
) {}
/// create a buffer /// create a buffer
/// @param vk the vulkan instance /// @param vk the vulkan instance