mirror of
https://github.com/PancakeTAS/lsfg-vk.git
synced 2026-04-27 12:51:52 +00:00
chore: update clang-tidy warnings
This commit is contained in:
parent
58c494b473
commit
034c431d76
19 changed files with 184 additions and 228 deletions
|
|
@ -21,25 +21,24 @@ set(CMAKE_SKIP_RPATH ON)
|
||||||
if(CMAKE_BUILD_TYPE STREQUAL "Debug")
|
if(CMAKE_BUILD_TYPE STREQUAL "Debug")
|
||||||
set(CMAKE_EXPORT_COMPILE_COMMANDS ON)
|
set(CMAKE_EXPORT_COMPILE_COMMANDS ON)
|
||||||
|
|
||||||
if(NOT CMAKE_CXX_COMPILER_ID STREQUAL "Clang")
|
if(CMAKE_CXX_COMPILER_ID STREQUAL "Clang")
|
||||||
message(WARNING "Debug builds should use Clang for better diagnostics")
|
message(STATUS "Building with clang-specific diagnostics")
|
||||||
else()
|
|
||||||
message(STATUS "Building with further diagnostics")
|
|
||||||
|
|
||||||
set(CMAKE_CXX_CLANG_TIDY clang-tidy)
|
set(CMAKE_CXX_CLANG_TIDY clang-tidy) # See .clang-tidy files
|
||||||
|
|
||||||
add_compile_options(
|
add_compile_options(
|
||||||
|
# By default, enable all warnings
|
||||||
-Weverything
|
-Weverything
|
||||||
# disable incompatible warnings
|
# Some warnings are incompatible with each other
|
||||||
-Wno-pre-c++20-compat-pedantic
|
-Wno-pre-c++20-compat-pedantic
|
||||||
-Wno-c++98-compat-pedantic
|
-Wno-c++98-compat-pedantic
|
||||||
-Wno-switch-default
|
-Wno-switch-default
|
||||||
-Wno-switch-enum
|
# Then there's code-style things I don't care about
|
||||||
# disable noisy warnings
|
|
||||||
-Wno-missing-designated-field-initializers
|
-Wno-missing-designated-field-initializers
|
||||||
|
-Wno-shadow
|
||||||
|
# And functional warning I don't care about either
|
||||||
-Wno-cast-function-type-strict
|
-Wno-cast-function-type-strict
|
||||||
-Wno-padded
|
-Wno-padded
|
||||||
-Wno-shadow
|
|
||||||
)
|
)
|
||||||
endif()
|
endif()
|
||||||
endif()
|
endif()
|
||||||
|
|
|
||||||
|
|
@ -1,36 +1,26 @@
|
||||||
Checks:
|
Checks:
|
||||||
# enable basic checks
|
# COMMON: Usually, we keep all checks enabled
|
||||||
- "clang-analyzer-*"
|
|
||||||
# configure performance checks
|
|
||||||
- "performance-*"
|
|
||||||
- "-performance-enum-size"
|
|
||||||
# configure readability and bugprone checks
|
|
||||||
- "readability-*"
|
|
||||||
- "bugprone-*"
|
- "bugprone-*"
|
||||||
- "misc-*"
|
- "clang-analyzer-*"
|
||||||
- "-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-*"
|
|
||||||
- "-modernize-use-trailing-return-type"
|
|
||||||
# configure cppcoreguidelines
|
|
||||||
- "cppcoreguidelines-*"
|
- "cppcoreguidelines-*"
|
||||||
- "-cppcoreguidelines-avoid-magic-numbers"
|
- "misc-*"
|
||||||
- "-cppcoreguidelines-pro-type-reinterpret-cast"
|
- "modernize-*"
|
||||||
- "-cppcoreguidelines-macro-usage"
|
- "performance-*"
|
||||||
# disable slow and pointless checks
|
- "portability-*"
|
||||||
- "-modernize-use-std-numbers"
|
- "readability-*"
|
||||||
- "-modernize-type-traits"
|
# COMMON: Some checks related purely to code-style are disabled
|
||||||
- "-cppcoreguidelines-owning-memory"
|
- -modernize-use-designated-initializers
|
||||||
- "-cppcoreguidelines-macro-to-enum"
|
- -modernize-use-trailing-return-type
|
||||||
- "-readability-container-contains"
|
- -modernize-deprecated-headers
|
||||||
- "-bugprone-reserved-identifier"
|
- -readability-function-cognitive-complexity
|
||||||
- "-bugprone-stringview-nullptr"
|
- -readability-math-missing-parentheses
|
||||||
- "-bugprone-standalone-empty"
|
- -readability-braces-around-statements
|
||||||
- "-misc-unused-using-decls"
|
- -readability-implicit-bool-conversion
|
||||||
|
- -readability-identifier-length
|
||||||
|
- -readability-magic-numbers
|
||||||
|
- -cppcoreguidelines-avoid-magic-numbers
|
||||||
|
- -cppcoreguidelines-macro-usage
|
||||||
|
- -bugprone-easily-swappable-parameters
|
||||||
|
# Vulkan requires the use of reinterpret/const casts in many places
|
||||||
|
- -cppcoreguidelines-pro-type-reinterpret-cast
|
||||||
|
- -cppcoreguidelines-pro-type-const-cast
|
||||||
|
|
|
||||||
|
|
@ -21,24 +21,28 @@ namespace lsfgvk::backend {
|
||||||
///
|
///
|
||||||
/// Primitive exception class that deliveres a detailed error message
|
/// Primitive exception class that deliveres a detailed error message
|
||||||
///
|
///
|
||||||
class [[gnu::visibility("default")]] error : public std::runtime_error { // NOLINT
|
class [[gnu::visibility("default")]] error : public std::runtime_error {
|
||||||
public:
|
public:
|
||||||
///
|
///
|
||||||
/// Construct an error
|
/// Construct an error
|
||||||
///
|
///
|
||||||
/// @param msg Error message.
|
/// @param msg Error message.
|
||||||
/// @param inner Inner exception.
|
/// @param inner Inner exception.
|
||||||
///
|
///
|
||||||
explicit error(const std::string& msg, const std::exception& inner);
|
explicit error(const std::string &msg, const std::exception &inner);
|
||||||
|
|
||||||
///
|
///
|
||||||
/// Construct an error
|
/// Construct an error
|
||||||
///
|
///
|
||||||
/// @param msg Error message.
|
/// @param msg Error message.
|
||||||
///
|
///
|
||||||
explicit error(const std::string& msg);
|
explicit error(const std::string &msg);
|
||||||
|
|
||||||
~error() override;
|
error(const error &) = default;
|
||||||
|
error &operator=(const error &) = default;
|
||||||
|
error(error &&) = default;
|
||||||
|
error &operator=(error &&) = default;
|
||||||
|
~error() override;
|
||||||
};
|
};
|
||||||
|
|
||||||
/// Function type for picking a device based on its name and IDs
|
/// Function type for picking a device based on its name and IDs
|
||||||
|
|
|
||||||
|
|
@ -547,7 +547,7 @@ ContextImpl::ContextImpl(const InstanceImpl& instance,
|
||||||
cmdbuf.submit(ctx.vk); // wait for completion
|
cmdbuf.submit(ctx.vk); // wait for completion
|
||||||
}
|
}
|
||||||
|
|
||||||
void Instance::scheduleFrames(Context& context) { // NOLINT (static)
|
void Instance::scheduleFrames(Context& context) {
|
||||||
#ifdef LSFGVK_TESTING_RENDERDOC
|
#ifdef LSFGVK_TESTING_RENDERDOC
|
||||||
const auto& impl = this->m_impl;
|
const auto& impl = this->m_impl;
|
||||||
if (impl->getRenderDocAPI()) {
|
if (impl->getRenderDocAPI()) {
|
||||||
|
|
@ -645,7 +645,7 @@ Instance::~Instance() = default;
|
||||||
// leaking shenanigans
|
// leaking shenanigans
|
||||||
|
|
||||||
namespace {
|
namespace {
|
||||||
bool leaking{false}; // NOLINT
|
bool leaking{false}; // NOLINT (global variable)
|
||||||
}
|
}
|
||||||
|
|
||||||
InstanceImpl::~InstanceImpl() {
|
InstanceImpl::~InstanceImpl() {
|
||||||
|
|
|
||||||
|
|
@ -1,39 +1,25 @@
|
||||||
Checks:
|
Checks:
|
||||||
# enable basic checks
|
# COMMON: Usually, we keep all checks enabled
|
||||||
- "clang-analyzer-*"
|
|
||||||
# configure performance checks
|
|
||||||
- "performance-*"
|
|
||||||
- "-performance-enum-size"
|
|
||||||
# configure readability and bugprone checks
|
|
||||||
- "readability-*"
|
|
||||||
- "bugprone-*"
|
- "bugprone-*"
|
||||||
- "misc-*"
|
- "clang-analyzer-*"
|
||||||
- "-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"
|
|
||||||
- "-misc-non-private-member-variables-in-classes"
|
|
||||||
# configure modernization
|
|
||||||
- "modernize-*"
|
|
||||||
- "-modernize-use-trailing-return-type"
|
|
||||||
- "-modernize-use-designated-initializers"
|
|
||||||
# configure cppcoreguidelines
|
|
||||||
- "cppcoreguidelines-*"
|
- "cppcoreguidelines-*"
|
||||||
- "-cppcoreguidelines-avoid-magic-numbers"
|
- "misc-*"
|
||||||
- "-cppcoreguidelines-pro-type-reinterpret-cast"
|
- "modernize-*"
|
||||||
- "-cppcoreguidelines-macro-usage"
|
- "performance-*"
|
||||||
- "-cppcoreguidelines-pro-bounds-pointer-arithmetic"
|
- "portability-*"
|
||||||
# disable slow and pointless checks
|
- "readability-*"
|
||||||
- "-modernize-use-std-numbers"
|
# COMMON: Some checks related purely to code-style are disabled
|
||||||
- "-modernize-type-traits"
|
- -modernize-use-designated-initializers
|
||||||
- "-cppcoreguidelines-owning-memory"
|
- -modernize-use-trailing-return-type
|
||||||
- "-cppcoreguidelines-macro-to-enum"
|
- -modernize-deprecated-headers
|
||||||
- "-readability-container-contains"
|
- -readability-function-cognitive-complexity
|
||||||
- "-bugprone-reserved-identifier"
|
- -readability-math-missing-parentheses
|
||||||
- "-bugprone-stringview-nullptr"
|
- -readability-braces-around-statements
|
||||||
- "-bugprone-standalone-empty"
|
- -readability-implicit-bool-conversion
|
||||||
- "-misc-unused-using-decls"
|
- -readability-identifier-length
|
||||||
|
- -readability-magic-numbers
|
||||||
|
- -cppcoreguidelines-avoid-magic-numbers
|
||||||
|
- -cppcoreguidelines-macro-usage
|
||||||
|
- -bugprone-easily-swappable-parameters
|
||||||
|
# Pointer arithmetic is used plenty for parsing cli arguments
|
||||||
|
- -cppcoreguidelines-pro-bounds-pointer-arithmetic
|
||||||
|
|
|
||||||
|
|
@ -12,7 +12,7 @@ target_link_libraries(lsfg-vk-cli
|
||||||
|
|
||||||
target_compile_options(lsfg-vk-cli PRIVATE
|
target_compile_options(lsfg-vk-cli PRIVATE
|
||||||
-Wno-unknown-warning-option
|
-Wno-unknown-warning-option
|
||||||
-Wno-unsafe-buffer-usage)
|
-Wno-unsafe-buffer-usage) # CLI parsing
|
||||||
|
|
||||||
install(TARGETS lsfg-vk-cli
|
install(TARGETS lsfg-vk-cli
|
||||||
RUNTIME DESTINATION "${CMAKE_INSTALL_BINDIR}")
|
RUNTIME DESTINATION "${CMAKE_INSTALL_BINDIR}")
|
||||||
|
|
|
||||||
|
|
@ -11,7 +11,7 @@
|
||||||
#include <optional>
|
#include <optional>
|
||||||
#include <string>
|
#include <string>
|
||||||
|
|
||||||
#include <getopt.h> // NOLINT
|
#include <getopt.h> // NOLINT (IWYU)
|
||||||
#include <bits/getopt_core.h>
|
#include <bits/getopt_core.h>
|
||||||
#include <bits/getopt_ext.h>
|
#include <bits/getopt_ext.h>
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -12,7 +12,6 @@
|
||||||
#include <cstddef>
|
#include <cstddef>
|
||||||
#include <cstdint>
|
#include <cstdint>
|
||||||
#include <cstdlib>
|
#include <cstdlib>
|
||||||
#include <ctime>
|
|
||||||
#include <exception>
|
#include <exception>
|
||||||
#include <filesystem>
|
#include <filesystem>
|
||||||
#include <iomanip>
|
#include <iomanip>
|
||||||
|
|
@ -22,6 +21,8 @@
|
||||||
#include <utility>
|
#include <utility>
|
||||||
#include <vector>
|
#include <vector>
|
||||||
|
|
||||||
|
#include <time.h>
|
||||||
|
#include <bits/time.h>
|
||||||
#include <vulkan/vulkan_core.h>
|
#include <vulkan/vulkan_core.h>
|
||||||
|
|
||||||
using namespace lsfgvk::cli;
|
using namespace lsfgvk::cli;
|
||||||
|
|
@ -31,7 +32,7 @@ namespace {
|
||||||
// get current time in milliseconds
|
// get current time in milliseconds
|
||||||
uint64_t ms() {
|
uint64_t ms() {
|
||||||
struct timespec ts{};
|
struct timespec ts{};
|
||||||
clock_gettime(CLOCK_MONOTONIC, &ts); // NOLINT (IWYU)
|
clock_gettime(CLOCK_MONOTONIC, &ts);
|
||||||
|
|
||||||
return static_cast<uint64_t>(ts.tv_sec) * 1000ULL +
|
return static_cast<uint64_t>(ts.tv_sec) * 1000ULL +
|
||||||
static_cast<uint64_t>(ts.tv_nsec) / 1000000ULL;
|
static_cast<uint64_t>(ts.tv_nsec) / 1000000ULL;
|
||||||
|
|
|
||||||
|
|
@ -1,36 +1,26 @@
|
||||||
Checks:
|
Checks:
|
||||||
# enable basic checks
|
# COMMON: Usually, we keep all checks enabled
|
||||||
- "clang-analyzer-*"
|
|
||||||
# configure performance checks
|
|
||||||
- "performance-*"
|
|
||||||
- "-performance-enum-size"
|
|
||||||
# configure readability and bugprone checks
|
|
||||||
- "readability-*"
|
|
||||||
- "bugprone-*"
|
- "bugprone-*"
|
||||||
- "misc-*"
|
- "clang-analyzer-*"
|
||||||
- "-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-*"
|
|
||||||
- "-modernize-use-trailing-return-type"
|
|
||||||
# configure cppcoreguidelines
|
|
||||||
- "cppcoreguidelines-*"
|
- "cppcoreguidelines-*"
|
||||||
- "-cppcoreguidelines-avoid-magic-numbers"
|
- "misc-*"
|
||||||
- "-cppcoreguidelines-pro-type-reinterpret-cast"
|
- "modernize-*"
|
||||||
- "-cppcoreguidelines-macro-usage"
|
- "performance-*"
|
||||||
# disable slow and pointless checks
|
- "portability-*"
|
||||||
- "-modernize-use-std-numbers"
|
- "readability-*"
|
||||||
- "-modernize-type-traits"
|
# COMMON: Some checks related purely to code-style are disabled
|
||||||
- "-cppcoreguidelines-owning-memory"
|
- -modernize-use-designated-initializers
|
||||||
- "-cppcoreguidelines-macro-to-enum"
|
- -modernize-use-trailing-return-type
|
||||||
- "-readability-container-contains"
|
- -modernize-deprecated-headers
|
||||||
- "-bugprone-reserved-identifier"
|
- -readability-function-cognitive-complexity
|
||||||
- "-bugprone-stringview-nullptr"
|
- -readability-math-missing-parentheses
|
||||||
- "-bugprone-standalone-empty"
|
- -readability-braces-around-statements
|
||||||
- "-misc-unused-using-decls"
|
- -readability-implicit-bool-conversion
|
||||||
|
- -readability-identifier-length
|
||||||
|
- -readability-magic-numbers
|
||||||
|
- -cppcoreguidelines-avoid-magic-numbers
|
||||||
|
- -cppcoreguidelines-macro-usage
|
||||||
|
- -bugprone-easily-swappable-parameters
|
||||||
|
# Vulkan requires the use of reinterpret/const casts in many places
|
||||||
|
- -cppcoreguidelines-pro-type-reinterpret-cast
|
||||||
|
- -cppcoreguidelines-pro-type-const-cast
|
||||||
|
|
|
||||||
|
|
@ -24,7 +24,7 @@ using namespace vk;
|
||||||
namespace {
|
namespace {
|
||||||
/// load libvulkan.so.1 and return its handle
|
/// load libvulkan.so.1 and return its handle
|
||||||
void* get_vulkan_handle() {
|
void* get_vulkan_handle() {
|
||||||
static void* handle{nullptr}; // NOLINT
|
static void* handle{nullptr}; // NOLINT (const correctness)
|
||||||
if (handle) return handle;
|
if (handle) return handle;
|
||||||
|
|
||||||
handle = dlopen("libvulkan.so.1", RTLD_NOW | RTLD_LOCAL);
|
handle = dlopen("libvulkan.so.1", RTLD_NOW | RTLD_LOCAL);
|
||||||
|
|
@ -37,7 +37,7 @@ namespace {
|
||||||
|
|
||||||
/// get the main proc addr function
|
/// get the main proc addr function
|
||||||
PFN_vkGetInstanceProcAddr get_mpa() {
|
PFN_vkGetInstanceProcAddr get_mpa() {
|
||||||
static PFN_vkGetInstanceProcAddr mpa{nullptr}; // NOLINT
|
static PFN_vkGetInstanceProcAddr mpa{nullptr};
|
||||||
if (mpa) return mpa;
|
if (mpa) return mpa;
|
||||||
|
|
||||||
mpa = reinterpret_cast<PFN_vkGetInstanceProcAddr>(
|
mpa = reinterpret_cast<PFN_vkGetInstanceProcAddr>(
|
||||||
|
|
|
||||||
|
|
@ -1,39 +1,30 @@
|
||||||
Checks:
|
Checks:
|
||||||
# enable basic checks
|
# COMMON: Usually, we keep all checks enabled
|
||||||
- "clang-analyzer-*"
|
|
||||||
# configure performance checks
|
|
||||||
- "performance-*"
|
|
||||||
- "-performance-enum-size"
|
|
||||||
# configure readability and bugprone checks
|
|
||||||
- "readability-*"
|
|
||||||
- "bugprone-*"
|
- "bugprone-*"
|
||||||
- "misc-*"
|
- "clang-analyzer-*"
|
||||||
- "-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-*"
|
|
||||||
- "-modernize-use-trailing-return-type"
|
|
||||||
# configure cppcoreguidelines
|
|
||||||
- "cppcoreguidelines-*"
|
- "cppcoreguidelines-*"
|
||||||
- "-cppcoreguidelines-avoid-magic-numbers"
|
- "misc-*"
|
||||||
- "-cppcoreguidelines-pro-type-reinterpret-cast"
|
- "modernize-*"
|
||||||
- "-cppcoreguidelines-macro-usage"
|
- "performance-*"
|
||||||
- "-cppcoreguidelines-pro-type-union-access"
|
- "portability-*"
|
||||||
- "-cppcoreguidelines-avoid-non-const-global-variables"
|
- "readability-*"
|
||||||
- "-cppcoreguidelines-pro-type-const-cast"
|
# COMMON: Some checks related purely to code-style are disabled
|
||||||
# disable slow and pointless checks
|
- -modernize-use-designated-initializers
|
||||||
- "-modernize-use-std-numbers"
|
- -modernize-use-trailing-return-type
|
||||||
- "-modernize-type-traits"
|
- -modernize-deprecated-headers
|
||||||
- "-cppcoreguidelines-owning-memory"
|
- -readability-function-cognitive-complexity
|
||||||
- "-cppcoreguidelines-macro-to-enum"
|
- -readability-math-missing-parentheses
|
||||||
- "-readability-container-contains"
|
- -readability-braces-around-statements
|
||||||
- "-bugprone-reserved-identifier"
|
- -readability-implicit-bool-conversion
|
||||||
- "-bugprone-stringview-nullptr"
|
- -readability-identifier-length
|
||||||
- "-bugprone-standalone-empty"
|
- -readability-magic-numbers
|
||||||
- "-misc-unused-using-decls"
|
- -cppcoreguidelines-avoid-magic-numbers
|
||||||
|
- -cppcoreguidelines-macro-usage
|
||||||
|
- -bugprone-easily-swappable-parameters
|
||||||
|
# Vulkan requires the use of reinterpret/const casts in many places
|
||||||
|
- -cppcoreguidelines-pro-type-reinterpret-cast
|
||||||
|
- -cppcoreguidelines-pro-type-const-cast
|
||||||
|
# Vulkan layers often require C-style memory access
|
||||||
|
- -cppcoreguidelines-pro-bounds-pointer-arithmetic
|
||||||
|
- -cppcoreguidelines-pro-type-union-access
|
||||||
|
- -clang-diagnostic-unsafe-buffer-usage
|
||||||
|
|
|
||||||
|
|
@ -9,6 +9,10 @@ target_link_libraries(lsfg-vk-layer
|
||||||
PUBLIC lsfg-vk-common
|
PUBLIC lsfg-vk-common
|
||||||
PUBLIC lsfg-vk-backend)
|
PUBLIC lsfg-vk-backend)
|
||||||
|
|
||||||
|
target_compile_options(lsfg-vk-layer PRIVATE
|
||||||
|
-Wno-unknown-warning-option
|
||||||
|
-Wno-unsafe-buffer-usage) # Array indexing
|
||||||
|
|
||||||
set_target_properties(lsfg-vk-layer PROPERTIES
|
set_target_properties(lsfg-vk-layer PROPERTIES
|
||||||
CXX_VISIBILITY_PRESET hidden)
|
CXX_VISIBILITY_PRESET hidden)
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -28,7 +28,7 @@ namespace {
|
||||||
PFN_vkGetInstanceProcAddr GetInstanceProcAddr;
|
PFN_vkGetInstanceProcAddr GetInstanceProcAddr;
|
||||||
|
|
||||||
Root root;
|
Root root;
|
||||||
}* layer_info;
|
}* layer_info; // NOLINT (global variable)
|
||||||
|
|
||||||
// instance-wide info initialized at instance creation(s)
|
// instance-wide info initialized at instance creation(s)
|
||||||
struct InstanceInfo {
|
struct InstanceInfo {
|
||||||
|
|
@ -38,7 +38,7 @@ namespace {
|
||||||
std::unordered_map<VkDevice, vk::Vulkan> devices;
|
std::unordered_map<VkDevice, vk::Vulkan> devices;
|
||||||
std::unordered_map<VkSwapchainKHR, ls::R<vk::Vulkan>> swapchains;
|
std::unordered_map<VkSwapchainKHR, ls::R<vk::Vulkan>> swapchains;
|
||||||
std::unordered_map<VkSwapchainKHR, SwapchainInfo> swapchainInfos;
|
std::unordered_map<VkSwapchainKHR, SwapchainInfo> swapchainInfos;
|
||||||
}* instance_info;
|
}* instance_info; // NOLINT (global variable)
|
||||||
|
|
||||||
// create instance
|
// create instance
|
||||||
VkResult myvkCreateInstance(
|
VkResult myvkCreateInstance(
|
||||||
|
|
@ -93,7 +93,7 @@ namespace {
|
||||||
);
|
);
|
||||||
|
|
||||||
if (!instance_info)
|
if (!instance_info)
|
||||||
instance_info = new InstanceInfo{
|
instance_info = new InstanceInfo{ // NOLINT (memory management)
|
||||||
.funcs = vk::initVulkanInstanceFuncs(*instance,
|
.funcs = vk::initVulkanInstanceFuncs(*instance,
|
||||||
layer_info->GetInstanceProcAddr, true),
|
layer_info->GetInstanceProcAddr, true),
|
||||||
};
|
};
|
||||||
|
|
@ -224,7 +224,7 @@ namespace {
|
||||||
|
|
||||||
// destroy instance info if no handles remain
|
// destroy instance info if no handles remain
|
||||||
if (instance_info->handles.empty()) {
|
if (instance_info->handles.empty()) {
|
||||||
delete instance_info;
|
delete instance_info; // NOLINT (memory management)
|
||||||
instance_info = nullptr;
|
instance_info = nullptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -379,7 +379,7 @@ namespace {
|
||||||
|
|
||||||
// present each swapchain
|
// present each swapchain
|
||||||
for (size_t i = 0; i < info->swapchainCount; i++) {
|
for (size_t i = 0; i < info->swapchainCount; i++) {
|
||||||
const auto& swapchain = info->pSwapchains[i]; // NOLINT (array index)
|
const auto& swapchain = info->pSwapchains[i];
|
||||||
|
|
||||||
const auto& it = instance_info->swapchains.find(swapchain);
|
const auto& it = instance_info->swapchains.find(swapchain);
|
||||||
if (it == instance_info->swapchains.end())
|
if (it == instance_info->swapchains.end())
|
||||||
|
|
@ -390,13 +390,13 @@ namespace {
|
||||||
waitSemaphores.reserve(info->waitSemaphoreCount);
|
waitSemaphores.reserve(info->waitSemaphoreCount);
|
||||||
|
|
||||||
for (size_t j = 0; j < info->waitSemaphoreCount; j++)
|
for (size_t j = 0; j < info->waitSemaphoreCount; j++)
|
||||||
waitSemaphores.push_back(info->pWaitSemaphores[j]); // NOLINT (array index)
|
waitSemaphores.push_back(info->pWaitSemaphores[j]);
|
||||||
|
|
||||||
auto& context = layer_info->root.getSwapchainContext(swapchain);
|
auto& context = layer_info->root.getSwapchainContext(swapchain);
|
||||||
result = context.present(it->second,
|
result = context.present(it->second,
|
||||||
queue, swapchain,
|
queue, swapchain,
|
||||||
const_cast<void*>(info->pNext),
|
const_cast<void*>(info->pNext),
|
||||||
info->pImageIndices[i], // NOLINT (array index)
|
info->pImageIndices[i],
|
||||||
{ waitSemaphores.begin(), waitSemaphores.end() }
|
{ waitSemaphores.begin(), waitSemaphores.end() }
|
||||||
);
|
);
|
||||||
} catch (const ls::vulkan_error& e) {
|
} catch (const ls::vulkan_error& e) {
|
||||||
|
|
@ -413,7 +413,7 @@ namespace {
|
||||||
}
|
}
|
||||||
|
|
||||||
if (result != VK_SUCCESS && info->pResults)
|
if (result != VK_SUCCESS && info->pResults)
|
||||||
info->pResults[i] = result; // NOLINT (array index)
|
info->pResults[i] = result;
|
||||||
}
|
}
|
||||||
|
|
||||||
return result;
|
return result;
|
||||||
|
|
@ -463,7 +463,7 @@ VkResult vkNegotiateLoaderLayerInterfaceVersion(VkNegotiateLayerInterface* pVers
|
||||||
|
|
||||||
// load the layer configuration
|
// load the layer configuration
|
||||||
try {
|
try {
|
||||||
layer_info = new LayerInfo {
|
layer_info = new LayerInfo { // NOLINT (memory management)
|
||||||
.map = {
|
.map = {
|
||||||
#define VKPTR(name) reinterpret_cast<PFN_vkVoidFunction>(name)
|
#define VKPTR(name) reinterpret_cast<PFN_vkVoidFunction>(name)
|
||||||
{ "vkCreateInstance", VKPTR(myvkCreateInstance) },
|
{ "vkCreateInstance", VKPTR(myvkCreateInstance) },
|
||||||
|
|
@ -479,7 +479,7 @@ VkResult vkNegotiateLoaderLayerInterfaceVersion(VkNegotiateLayerInterface* pVers
|
||||||
};
|
};
|
||||||
|
|
||||||
if (!layer_info->root.active()) { // skip inactive
|
if (!layer_info->root.active()) { // skip inactive
|
||||||
delete layer_info;
|
delete layer_info; // NOLINT (memory management)
|
||||||
layer_info = nullptr;
|
layer_info = nullptr;
|
||||||
|
|
||||||
return VK_ERROR_INITIALIZATION_FAILED;
|
return VK_ERROR_INITIALIZATION_FAILED;
|
||||||
|
|
|
||||||
|
|
@ -18,6 +18,7 @@
|
||||||
#include <utility>
|
#include <utility>
|
||||||
#include <vector>
|
#include <vector>
|
||||||
|
|
||||||
|
#include <stdlib.h>
|
||||||
#include <vulkan/vulkan_core.h>
|
#include <vulkan/vulkan_core.h>
|
||||||
|
|
||||||
using namespace lsfgvk;
|
using namespace lsfgvk;
|
||||||
|
|
@ -172,7 +173,7 @@ void Root::createSwapchainContext(const vk::Vulkan& vk,
|
||||||
if (!this->backend.has_value()) { // emplace backend late, due to loader bug
|
if (!this->backend.has_value()) { // emplace backend late, due to loader bug
|
||||||
const auto& global = this->config.get().global();
|
const auto& global = this->config.get().global();
|
||||||
|
|
||||||
setenv("DISABLE_LSFGVK", "1", 1); // NOLINT (c++-include)
|
setenv("DISABLE_LSFGVK", "1", 1);
|
||||||
|
|
||||||
try {
|
try {
|
||||||
std::string dll{};
|
std::string dll{};
|
||||||
|
|
@ -197,11 +198,11 @@ void Root::createSwapchainContext(const vk::Vulkan& vk,
|
||||||
dll, global.allow_fp16
|
dll, global.allow_fp16
|
||||||
);
|
);
|
||||||
} catch (const std::exception& e) {
|
} catch (const std::exception& e) {
|
||||||
unsetenv("DISABLE_LSFGVK"); // NOLINT (c++-include)
|
unsetenv("DISABLE_LSFGVK");
|
||||||
throw ls::error("failed to create backend instance", e);
|
throw ls::error("failed to create backend instance", e);
|
||||||
}
|
}
|
||||||
|
|
||||||
unsetenv("DISABLE_LSFGVK"); // NOLINT (c++-include)
|
unsetenv("DISABLE_LSFGVK");
|
||||||
}
|
}
|
||||||
|
|
||||||
this->swapchains.emplace(swapchain,
|
this->swapchains.emplace(swapchain,
|
||||||
|
|
|
||||||
|
|
@ -151,7 +151,7 @@ VkResult Swapchain::present(const vk::Vulkan& vk,
|
||||||
while (info) {
|
while (info) {
|
||||||
if (info->sType == VK_STRUCTURE_TYPE_SWAPCHAIN_PRESENT_MODE_INFO_EXT) {
|
if (info->sType == VK_STRUCTURE_TYPE_SWAPCHAIN_PRESENT_MODE_INFO_EXT) {
|
||||||
for (size_t i = 0; i < info->swapchainCount; i++)
|
for (size_t i = 0; i < info->swapchainCount; i++)
|
||||||
const_cast<VkPresentModeKHR*>(info->pPresentModes)[i] = // NOLINT
|
const_cast<VkPresentModeKHR*>(info->pPresentModes)[i] =
|
||||||
VK_PRESENT_MODE_FIFO_KHR;
|
VK_PRESENT_MODE_FIFO_KHR;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1,38 +1,25 @@
|
||||||
Checks:
|
Checks:
|
||||||
# enable basic checks
|
# COMMON: Usually, we keep all checks enabled
|
||||||
- "clang-analyzer-*"
|
|
||||||
# configure performance checks
|
|
||||||
- "performance-*"
|
|
||||||
- "-performance-enum-size"
|
|
||||||
# configure readability and bugprone checks
|
|
||||||
- "readability-*"
|
|
||||||
- "bugprone-*"
|
- "bugprone-*"
|
||||||
- "misc-*"
|
- "clang-analyzer-*"
|
||||||
- "-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-*"
|
|
||||||
- "-modernize-use-trailing-return-type"
|
|
||||||
# configure cppcoreguidelines
|
|
||||||
- "cppcoreguidelines-*"
|
- "cppcoreguidelines-*"
|
||||||
- "-cppcoreguidelines-avoid-magic-numbers"
|
- "misc-*"
|
||||||
- "-cppcoreguidelines-pro-type-reinterpret-cast"
|
- "modernize-*"
|
||||||
- "-cppcoreguidelines-macro-usage"
|
- "performance-*"
|
||||||
- "-cppcoreguidelines-pro-type-member-init"
|
- "portability-*"
|
||||||
- "-cppcoreguidelines-prefer-member-initializer"
|
- "readability-*"
|
||||||
# disable slow and pointless checks
|
# COMMON: Some checks related purely to code-style are disabled
|
||||||
- "-modernize-use-std-numbers"
|
- -modernize-use-designated-initializers
|
||||||
- "-modernize-type-traits"
|
- -modernize-use-trailing-return-type
|
||||||
- "-cppcoreguidelines-owning-memory"
|
- -modernize-deprecated-headers
|
||||||
- "-cppcoreguidelines-macro-to-enum"
|
- -readability-function-cognitive-complexity
|
||||||
- "-readability-container-contains"
|
- -readability-math-missing-parentheses
|
||||||
- "-bugprone-reserved-identifier"
|
- -readability-braces-around-statements
|
||||||
- "-bugprone-stringview-nullptr"
|
- -readability-implicit-bool-conversion
|
||||||
- "-bugprone-standalone-empty"
|
- -readability-identifier-length
|
||||||
- "-misc-unused-using-decls"
|
- -readability-magic-numbers
|
||||||
|
- -cppcoreguidelines-avoid-magic-numbers
|
||||||
|
- -cppcoreguidelines-macro-usage
|
||||||
|
- -bugprone-easily-swappable-parameters
|
||||||
|
# Qt requires use of raw pointers in many places
|
||||||
|
- -cppcoreguidelines-owning-memory
|
||||||
|
|
|
||||||
|
|
@ -27,7 +27,7 @@ set_target_properties(lsfg-vk-ui PROPERTIES
|
||||||
AUTOMOC ON
|
AUTOMOC ON
|
||||||
AUTOUIC ON)
|
AUTOUIC ON)
|
||||||
|
|
||||||
target_compile_options(lsfg-vk-ui PRIVATE
|
target_compile_options(lsfg-vk-ui PRIVATE # QT-codegen warnings
|
||||||
-Wno-unknown-warning-option
|
-Wno-unknown-warning-option
|
||||||
-Wno-ctad-maybe-unsupported
|
-Wno-ctad-maybe-unsupported
|
||||||
-Wno-unsafe-buffer-usage-in-libc-call
|
-Wno-unsafe-buffer-usage-in-libc-call
|
||||||
|
|
|
||||||
|
|
@ -38,7 +38,7 @@ Backend::Backend() {
|
||||||
this->m_gpu_list = ui::getAvailableGPUs();
|
this->m_gpu_list = ui::getAvailableGPUs();
|
||||||
|
|
||||||
// create profile list model
|
// create profile list model
|
||||||
QStringList profiles; // NOLINT (IWYU)
|
QStringList profiles;
|
||||||
for (const auto& profile : this->m_profiles)
|
for (const auto& profile : this->m_profiles)
|
||||||
profiles.append(QString::fromStdString(profile.name));
|
profiles.append(QString::fromStdString(profile.name));
|
||||||
|
|
||||||
|
|
@ -47,7 +47,7 @@ Backend::Backend() {
|
||||||
// create active_in list models
|
// create active_in list models
|
||||||
this->m_active_in_list_models.reserve(this->m_profiles.size());
|
this->m_active_in_list_models.reserve(this->m_profiles.size());
|
||||||
for (const auto& profile : this->m_profiles) {
|
for (const auto& profile : this->m_profiles) {
|
||||||
QStringList active_in; // NOLINT (IWYU)
|
QStringList active_in;
|
||||||
for (const auto& path : profile.active_in)
|
for (const auto& path : profile.active_in)
|
||||||
active_in.append(QString::fromStdString(path));
|
active_in.append(QString::fromStdString(path));
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1,5 +1,6 @@
|
||||||
/* SPDX-License-Identifier: GPL-3.0-or-later */
|
/* SPDX-License-Identifier: GPL-3.0-or-later */
|
||||||
|
|
||||||
|
#include <QtContainerFwd>
|
||||||
#include <QStringList>
|
#include <QStringList>
|
||||||
#include <QString>
|
#include <QString>
|
||||||
|
|
||||||
|
|
@ -16,7 +17,7 @@
|
||||||
using namespace lsfgvk;
|
using namespace lsfgvk;
|
||||||
using namespace lsfgvk::ui;
|
using namespace lsfgvk::ui;
|
||||||
|
|
||||||
QStringList ui::getAvailableGPUs() { // NOLINT (IWYU)
|
QStringList ui::getAvailableGPUs() {
|
||||||
// list of found GPUs and their optional PCI IDs
|
// list of found GPUs and their optional PCI IDs
|
||||||
std::vector<std::pair<std::string, std::optional<std::string>>> gpus{};
|
std::vector<std::pair<std::string, std::optional<std::string>>> gpus{};
|
||||||
|
|
||||||
|
|
@ -33,16 +34,18 @@ QStringList ui::getAvailableGPUs() { // NOLINT (IWYU)
|
||||||
|
|
||||||
const backend::Instance instance{picker, "/non/existent/path", false};
|
const backend::Instance instance{picker, "/non/existent/path", false};
|
||||||
throw std::runtime_error("???");
|
throw std::runtime_error("???");
|
||||||
} catch (const backend::error&) { // NOLINT
|
} catch (const backend::error&) { // NOLINT (empty catch)
|
||||||
// expected
|
// expected
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// NOLINTBEGIN (ranges) [GCC has some issues with ranges]
|
||||||
// first remove 1:1 duplicates
|
// first remove 1:1 duplicates
|
||||||
std::sort(gpus.begin(), gpus.end()); // NOLINT (ranges [thanks gcc!])
|
std::sort(gpus.begin(), gpus.end());
|
||||||
gpus.erase(std::unique(gpus.begin(), gpus.end()), gpus.end()); // NOLINT
|
gpus.erase(std::unique(gpus.begin(), gpus.end()), gpus.end());
|
||||||
|
// NOLINTEND
|
||||||
|
|
||||||
// build the frontend list
|
// build the frontend list
|
||||||
QStringList list{"Default"}; // NOLINT (IWYU)
|
QStringList list{"Default"};
|
||||||
for (const auto& gpu : gpus) {
|
for (const auto& gpu : gpus) {
|
||||||
// check if GPU is in list more than once
|
// check if GPU is in list more than once
|
||||||
auto count = std::count_if(gpus.begin(), gpus.end(),
|
auto count = std::count_if(gpus.begin(), gpus.end(),
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue