cleanup headers

supersedes #32 fixes #42
This commit is contained in:
PancakeTAS 2025-07-10 17:01:17 +02:00
parent 92ca8827db
commit f306c48e6d
No known key found for this signature in database
24 changed files with 82 additions and 59 deletions

View file

@ -8,13 +8,13 @@ Checks:
- "readability-*" - "readability-*"
- "bugprone-*" - "bugprone-*"
- "misc-*" - "misc-*"
- "-misc-include-cleaner"
- "-readability-braces-around-statements" - "-readability-braces-around-statements"
- "-readability-function-cognitive-complexity" - "-readability-function-cognitive-complexity"
- "-readability-identifier-length" - "-readability-identifier-length"
- "-readability-implicit-bool-conversion" - "-readability-implicit-bool-conversion"
- "-readability-magic-numbers" - "-readability-magic-numbers"
- "-readability-math-missing-parentheses" - "-readability-math-missing-parentheses"
- "-readability-named-parameter"
- "-bugprone-easily-swappable-parameters" - "-bugprone-easily-swappable-parameters"
# configure modernization # configure modernization
- "modernize-*" - "modernize-*"
@ -24,3 +24,4 @@ Checks:
- "-cppcoreguidelines-avoid-magic-numbers" - "-cppcoreguidelines-avoid-magic-numbers"
- "-cppcoreguidelines-pro-type-reinterpret-cast" # allows reinterpret_cast - "-cppcoreguidelines-pro-type-reinterpret-cast" # allows reinterpret_cast
- "-cppcoreguidelines-avoid-non-const-global-variables" - "-cppcoreguidelines-avoid-non-const-global-variables"
- "-cppcoreguidelines-pro-type-union-access"

View file

@ -1,5 +1,4 @@
#ifndef CONTEXT_HPP #pragma once
#define CONTEXT_HPP
#include "hooks.hpp" #include "hooks.hpp"
#include "mini/commandbuffer.hpp" #include "mini/commandbuffer.hpp"
@ -7,11 +6,11 @@
#include "mini/image.hpp" #include "mini/image.hpp"
#include "mini/semaphore.hpp" #include "mini/semaphore.hpp"
#include <vulkan/vulkan_core.h>
#include <array> #include <array>
#include <cstdint> #include <cstdint>
#include <memory> #include <memory>
#include <vulkan/vulkan_core.h>
#include <vector> #include <vector>
/// ///
@ -79,5 +78,3 @@ private:
}; // data for a single render pass }; // data for a single render pass
std::array<RenderPassInfo, 8> passInfos; // allocate 8 because why not std::array<RenderPassInfo, 8> passInfos; // allocate 8 because why not
}; };
#endif // CONTEXT_HPP

View file

@ -1,8 +1,8 @@
#ifndef HOOKS_HPP #pragma once
#define HOOKS_HPP
#include <vulkan/vulkan_core.h> #include <vulkan/vulkan_core.h>
#include <cstdint>
#include <unordered_map> #include <unordered_map>
#include <utility> #include <utility>
#include <string> #include <string>
@ -21,5 +21,3 @@ namespace Hooks {
extern std::unordered_map<std::string, PFN_vkVoidFunction> hooks; extern std::unordered_map<std::string, PFN_vkVoidFunction> hooks;
} }
#endif // HOOKS_HPP

View file

@ -1,8 +1,9 @@
#ifndef LAYER_HPP #pragma once
#define LAYER_HPP
#include <vulkan/vulkan_core.h> #include <vulkan/vulkan_core.h>
#include <cstdint>
namespace Layer { namespace Layer {
/// Call to the original vkCreateInstance function. /// Call to the original vkCreateInstance function.
VkResult ovkCreateInstance( VkResult ovkCreateInstance(
@ -216,5 +217,3 @@ namespace Layer {
extern "C" PFN_vkVoidFunction layer_vkGetInstanceProcAddr(VkInstance instance, const char* pName); extern "C" PFN_vkVoidFunction layer_vkGetInstanceProcAddr(VkInstance instance, const char* pName);
/// Symbol definition for Vulkan device layer. /// Symbol definition for Vulkan device layer.
extern "C" PFN_vkVoidFunction layer_vkGetDeviceProcAddr(VkDevice device, const char* pName); extern "C" PFN_vkVoidFunction layer_vkGetDeviceProcAddr(VkDevice device, const char* pName);
#endif // LAYER_HPP

View file

@ -1,8 +1,6 @@
#ifndef COMMANDBUFFER_HPP #pragma once
#define COMMANDBUFFER_HPP
#include "mini/commandpool.hpp" #include "mini/commandpool.hpp"
#include "mini/semaphore.hpp"
#include <vulkan/vulkan_core.h> #include <vulkan/vulkan_core.h>
@ -91,5 +89,3 @@ namespace Mini {
}; };
} }
#endif // COMMANDBUFFER_HPP

View file

@ -1,8 +1,8 @@
#ifndef COMMANDPOOL_HPP #pragma once
#define COMMANDPOOL_HPP
#include <vulkan/vulkan_core.h> #include <vulkan/vulkan_core.h>
#include <cstdint>
#include <memory> #include <memory>
namespace Mini { namespace Mini {
@ -40,5 +40,3 @@ namespace Mini {
}; };
} }
#endif // COMMANDPOOL_HPP

View file

@ -1,5 +1,4 @@
#ifndef IMAGE_HPP #pragma once
#define IMAGE_HPP
#include <vulkan/vulkan_core.h> #include <vulkan/vulkan_core.h>
@ -59,5 +58,3 @@ namespace Mini {
}; };
} }
#endif // IMAGE_HPP

View file

@ -1,5 +1,4 @@
#ifndef SEMAPHORE_HPP #pragma once
#define SEMAPHORE_HPP
#include <vulkan/vulkan_core.h> #include <vulkan/vulkan_core.h>
@ -49,5 +48,3 @@ namespace Mini {
}; };
} }
#endif // SEMAPHORE_HPP

View file

@ -1,11 +1,12 @@
#ifndef LOG_HPP #pragma once
#define LOG_HPP
#include <format> #include <format>
#include <fstream> #include <fstream>
#include <iostream> #include <iostream>
#include <mutex> #include <mutex>
#include <set> #include <set>
#include <string>
#include <string_view>
namespace Log { namespace Log {
@ -26,10 +27,10 @@ namespace Log {
std::format_string<Args...> fmt, Args&&... args) { std::format_string<Args...> fmt, Args&&... args) {
Internal::setup(); Internal::setup();
std::string prefix = std::format("lsfg-vk({}): ", module); const std::string prefix = std::format("lsfg-vk({}): ", module);
std::string message = std::format(fmt, std::forward<Args>(args)...); const std::string message = std::format(fmt, std::forward<Args>(args)...);
std::lock_guard<std::mutex> lock(Internal::logMutex); const std::lock_guard<std::mutex> lock(Internal::logMutex);
std::cerr << color << prefix << message << "\033[0m" << '\n'; std::cerr << color << prefix << message << "\033[0m" << '\n';
if (Internal::logFile.is_open()) { if (Internal::logFile.is_open()) {
Internal::logFile << prefix << message << '\n'; Internal::logFile << prefix << message << '\n';
@ -60,7 +61,7 @@ namespace Log {
#ifdef LSFG_NO_DEBUG #ifdef LSFG_NO_DEBUG
template<typename... Args> template<typename... Args>
void debug(std::string_view, std::format_string<Args...>, Args&&...) {} // NOLINT void debug(std::string_view, std::format_string<Args...>, Args&&...) {}
#else #else
template<typename... Args> template<typename... Args>
void debug(std::string_view module, std::format_string<Args...> fmt, Args&&... args) { void debug(std::string_view module, std::format_string<Args...> fmt, Args&&... args) {
@ -71,5 +72,3 @@ void debug(std::string_view, std::format_string<Args...>, Args&&...) {} // NOLIN
#endif #endif
} }
#endif // LOG_HPP

View file

@ -1,8 +1,9 @@
#ifndef UTILS_HPP #pragma once
#define UTILS_HPP
#include <vulkan/vulkan_core.h> #include <vulkan/vulkan_core.h>
#include <cstdint>
#include <cstddef>
#include <vector> #include <vector>
#include <utility> #include <utility>
@ -59,5 +60,3 @@ namespace Utils {
bool makeSrcPresentable, bool makeDstPresentable); bool makeSrcPresentable, bool makeDstPresentable);
} }
#endif // UTILS_HPP

View file

@ -23,3 +23,4 @@ Checks:
- "-cppcoreguidelines-avoid-magic-numbers" - "-cppcoreguidelines-avoid-magic-numbers"
- "-cppcoreguidelines-pro-type-reinterpret-cast" # allows reinterpret_cast - "-cppcoreguidelines-pro-type-reinterpret-cast" # allows reinterpret_cast
- "-cppcoreguidelines-avoid-non-const-global-variables" - "-cppcoreguidelines-avoid-non-const-global-variables"
- "-cppcoreguidelines-pro-type-union-access"

View file

@ -9,6 +9,8 @@
#include "core/shadermodule.hpp" #include "core/shadermodule.hpp"
#include "utils/utils.hpp" #include "utils/utils.hpp"
#include <vulkan/vulkan_core.h>
#include <array> #include <array>
#include <vector> #include <vector>
#include <cstdint> #include <cstdint>

View file

@ -29,7 +29,7 @@ Core::Buffer ResourcePool::getBuffer(
uint64_t hash = 0; uint64_t hash = 0;
const union { float f; uint32_t i; } u{ const union { float f; uint32_t i; } u{
.f = timestamp }; .f = timestamp };
hash |= u.i; // NOLINT hash |= u.i;
hash |= static_cast<uint64_t>(firstIter) << 32; hash |= static_cast<uint64_t>(firstIter) << 32;
hash |= static_cast<uint64_t>(firstIterS) << 33; hash |= static_cast<uint64_t>(firstIterS) << 33;

View file

@ -1,13 +1,19 @@
#include "context.hpp" #include "context.hpp"
#include "extract/extract.hpp" #include "extract/extract.hpp"
#include "extract/trans.hpp" #include "extract/trans.hpp"
#include "layer.hpp"
#include "utils/log.hpp"
#include "utils/utils.hpp" #include "utils/utils.hpp"
#include "utils/log.hpp"
#include "hooks.hpp"
#include "layer.hpp"
#include <vulkan/vulkan_core.h>
#include <lsfg.hpp> #include <lsfg.hpp>
#include <algorithm>
#include <cstdint>
#include <cstdlib> #include <cstdlib>
#include <string>
#include <memory>
#include <vector> #include <vector>
LsContext::LsContext(const Hooks::DeviceInfo& info, VkSwapchainKHR swapchain, LsContext::LsContext(const Hooks::DeviceInfo& info, VkSwapchainKHR swapchain,
@ -19,7 +25,7 @@ LsContext::LsContext(const Hooks::DeviceInfo& info, VkSwapchainKHR swapchain,
float flowScale = lsfgFlowScaleStr float flowScale = lsfgFlowScaleStr
? std::stof(lsfgFlowScaleStr) ? std::stof(lsfgFlowScaleStr)
: 1.0F; : 1.0F;
flowScale = std::max(0.3F, std::min(flowScale, 1.0F)); flowScale = std::max(0.25F, std::min(flowScale, 1.0F));
const char* lsfgHdrStr = getenv("LSFG_HDR"); const char* lsfgHdrStr = getenv("LSFG_HDR");
const bool isHdr = lsfgHdrStr const bool isHdr = lsfgHdrStr
@ -67,7 +73,7 @@ LsContext::LsContext(const Hooks::DeviceInfo& info, VkSwapchainKHR swapchain,
// initialize lsfg // initialize lsfg
Log::debug("context", "(entering LSFG initialization)"); Log::debug("context", "(entering LSFG initialization)");
setenv("DISABLE_LSFG", "1", 1); setenv("DISABLE_LSFG", "1", 1); // NOLINT
Extract::extractShaders(); Extract::extractShaders();
LSFG::initialize( LSFG::initialize(
Utils::getDeviceUUID(info.physicalDevice), Utils::getDeviceUUID(info.physicalDevice),
@ -78,7 +84,7 @@ LsContext::LsContext(const Hooks::DeviceInfo& info, VkSwapchainKHR swapchain,
return spirv; return spirv;
} }
); );
unsetenv("DISABLE_LSFG"); unsetenv("DISABLE_LSFG"); // NOLINT
Log::debug("context", "(exiting LSFG initialization)"); Log::debug("context", "(exiting LSFG initialization)");
// create lsfg context // create lsfg context

View file

@ -1,8 +1,8 @@
#include "extract/extract.hpp" #include "extract/extract.hpp"
#include <cstdlib>
#include <pe-parse/parse.h> #include <pe-parse/parse.h>
#include <cstdlib>
#include <algorithm> #include <algorithm>
#include <cstdint> #include <cstdint>
#include <stdexcept> #include <stdexcept>
@ -53,7 +53,7 @@ namespace {
return hash; return hash;
} }
int on_resource(void*, const peparse::resource& res) { // NOLINT int on_resource(void*, const peparse::resource& res) {
if (res.type != peparse::RT_RCDATA || res.buf == nullptr || res.buf->bufLen <= 0) if (res.type != peparse::RT_RCDATA || res.buf == nullptr || res.buf->bufLen <= 0)
return 0; return 0;
std::vector<uint8_t> resource_data(res.buf->bufLen); std::vector<uint8_t> resource_data(res.buf->bufLen);

View file

@ -4,6 +4,8 @@
#include <dxbc/dxbc_module.h> #include <dxbc/dxbc_module.h>
#include <dxbc/dxbc_reader.h> #include <dxbc/dxbc_reader.h>
#include <cstdint>
#include <cstddef>
#include <algorithm> #include <algorithm>
#include <vector> #include <vector>

View file

@ -5,10 +5,15 @@
#include "utils/utils.hpp" #include "utils/utils.hpp"
#include <lsfg.hpp> #include <lsfg.hpp>
#include <vulkan/vulkan_core.h>
#include <cstdint>
#include <cstdlib>
#include <algorithm>
#include <exception>
#include <string> #include <string>
#include <unordered_map> #include <unordered_map>
#include <vulkan/vulkan_core.h> #include <vector>
using namespace Hooks; using namespace Hooks;
@ -86,7 +91,7 @@ namespace {
VkResult myvkCreateDevicePost( VkResult myvkCreateDevicePost(
VkPhysicalDevice physicalDevice, VkPhysicalDevice physicalDevice,
VkDeviceCreateInfo* pCreateInfo, VkDeviceCreateInfo* pCreateInfo,
const VkAllocationCallbacks*, // NOLINT const VkAllocationCallbacks*,
VkDevice* pDevice) { VkDevice* pDevice) {
// store device info // store device info
Log::debug("hooks", "Creating device info for device: {:x}", Log::debug("hooks", "Creating device info for device: {:x}",

View file

@ -2,12 +2,11 @@
#include "hooks.hpp" #include "hooks.hpp"
#include "utils/log.hpp" #include "utils/log.hpp"
#include <lsfg.hpp>
#include <vulkan/vk_layer.h> #include <vulkan/vk_layer.h>
#include <vulkan/vulkan_core.h>
#include <string> #include <string>
#include <unordered_map> #include <unordered_map>
#include <vulkan/vulkan_core.h>
namespace { namespace {
PFN_vkCreateInstance next_vkCreateInstance{}; PFN_vkCreateInstance next_vkCreateInstance{};

View file

@ -1,8 +1,15 @@
#include "mini/commandbuffer.hpp" #include "mini/commandbuffer.hpp"
#include "mini/commandpool.hpp"
#include "layer.hpp" #include "layer.hpp"
#include <vulkan/vulkan_core.h>
#include <lsfg.hpp> #include <lsfg.hpp>
#include <cstdint>
#include <memory>
#include <stdexcept>
#include <vector>
using namespace Mini; using namespace Mini;
CommandBuffer::CommandBuffer(VkDevice device, const CommandPool& pool) { CommandBuffer::CommandBuffer(VkDevice device, const CommandPool& pool) {

View file

@ -2,6 +2,10 @@
#include "layer.hpp" #include "layer.hpp"
#include <lsfg.hpp> #include <lsfg.hpp>
#include <vulkan/vulkan_core.h>
#include <cstdint>
#include <memory>
using namespace Mini; using namespace Mini;

View file

@ -1,8 +1,11 @@
#include "mini/image.hpp" #include "mini/image.hpp"
#include "layer.hpp" #include "layer.hpp"
#include <vulkan/vulkan_core.h>
#include <lsfg.hpp> #include <lsfg.hpp>
#include <memory>
#include <cstdint>
#include <optional> #include <optional>
using namespace Mini; using namespace Mini;

View file

@ -2,6 +2,9 @@
#include "layer.hpp" #include "layer.hpp"
#include <lsfg.hpp> #include <lsfg.hpp>
#include <vulkan/vulkan_core.h>
#include <memory>
using namespace Mini; using namespace Mini;

View file

@ -1,8 +1,15 @@
#include "utils/log.hpp" #include "utils/log.hpp"
#include <sstream>
#include <unistd.h> #include <unistd.h>
#include <set>
#include <fstream>
#include <mutex>
#include <cstdlib>
#include <ios>
#include <sstream>
#include <string>
using namespace Log; using namespace Log;
bool Internal::isSetup{}; bool Internal::isSetup{};

View file

@ -2,12 +2,15 @@
#include "utils/log.hpp" #include "utils/log.hpp"
#include "layer.hpp" #include "layer.hpp"
#include <cstring>
#include <lsfg.hpp> #include <lsfg.hpp>
#include <vulkan/vulkan_core.h>
#include <cstdint>
#include <cstring>
#include <algorithm> #include <algorithm>
#include <optional> #include <optional>
#include <vulkan/vulkan_core.h> #include <utility>
#include <vector>
using namespace Utils; using namespace Utils;