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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

@ -1,11 +1,12 @@
#ifndef LOG_HPP
#define LOG_HPP
#pragma once
#include <format>
#include <fstream>
#include <iostream>
#include <mutex>
#include <set>
#include <string>
#include <string_view>
namespace Log {
@ -26,10 +27,10 @@ namespace Log {
std::format_string<Args...> fmt, Args&&... args) {
Internal::setup();
std::string prefix = std::format("lsfg-vk({}): ", module);
std::string message = std::format(fmt, std::forward<Args>(args)...);
const std::string prefix = std::format("lsfg-vk({}): ", module);
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';
if (Internal::logFile.is_open()) {
Internal::logFile << prefix << message << '\n';
@ -60,7 +61,7 @@ namespace Log {
#ifdef LSFG_NO_DEBUG
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
template<typename... 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 // LOG_HPP

View file

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

View file

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

View file

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

View file

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

View file

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

View file

@ -1,8 +1,8 @@
#include "extract/extract.hpp"
#include <cstdlib>
#include <pe-parse/parse.h>
#include <cstdlib>
#include <algorithm>
#include <cstdint>
#include <stdexcept>
@ -53,7 +53,7 @@ namespace {
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)
return 0;
std::vector<uint8_t> resource_data(res.buf->bufLen);

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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