mirror of
https://github.com/PancakeTAS/lsfg-vk.git
synced 2026-05-10 11:11:40 +00:00
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:
parent
e611c5b27d
commit
a75da595e3
6 changed files with 6 additions and 170 deletions
|
|
@ -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")
|
||||
|
|
|
|||
|
|
@ -2,18 +2,15 @@
|
|||
|
||||
#include "library.hpp"
|
||||
#include "library/dll.hpp"
|
||||
#include "utility/logger.hpp"
|
||||
#include "utility/vkhelper.hpp"
|
||||
|
||||
#include <array>
|
||||
#include <cstdint>
|
||||
#include <filesystem>
|
||||
#include <iomanip>
|
||||
#include <stdexcept>
|
||||
#include <string>
|
||||
#include <string_view>
|
||||
#include <utility>
|
||||
#include <vector>
|
||||
|
||||
/// All base shaders in the library.
|
||||
const std::array<std::pair<std::string_view, uint32_t>, 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")
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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 <algorithm>
|
||||
#include <array>
|
||||
#include <cstddef>
|
||||
#include <cstdint>
|
||||
#include <ios>
|
||||
#include <memory>
|
||||
#include <numeric>
|
||||
#include <stdexcept>
|
||||
|
|
@ -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<vk::ComputePipelineCreateInfo> 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<std::string_view, uint32_t> 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(
|
||||
|
|
|
|||
|
|
@ -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();
|
||||
}
|
||||
|
|
@ -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
|
||||
|
||||
}
|
||||
|
|
@ -21,7 +21,12 @@ namespace vk {
|
|||
template<typename T>
|
||||
Buffer(const vk::Vulkan& vk, const T& data,
|
||||
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
|
||||
/// @param vk the vulkan instance
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue