refactor(cleanup): be nicer on older compilers

This commit is contained in:
PancakeTAS 2025-12-24 02:18:18 +01:00
parent 1ca46a0003
commit 054d55c741
No known key found for this signature in database
12 changed files with 28 additions and 19 deletions

View file

@ -4,16 +4,17 @@ include(GNUInstallDirs)
# === READ HERE FOR BUILD OPTIONS ===
option(LSFGVK_BUILD_VULKAN_LAYER "Build the Vulkan layer" ON)
option(LSFGVK_BUILD_USER_INTERFACE "Build the user interface" ON)
option(LSFGVK_BUILD_USER_INTERFACE "Build the user interface" OFF)
option(LSFGVK_BUILD_DEBUG_TOOL "Build the debug tool" OFF)
option(LSFGVK_INSTALL_DEVELOP "Install development files" OFF)
option(LSFGVK_INSTALL_XDG_FILES "Install xdg app files" ON)
option(LSFGVK_INSTALL_XDG_FILES "Install xdg app files" OFF)
# === READ HERE FOR BUILD OPTIONS ===
set(CMAKE_CXX_STANDARD 20)
set(CMAKE_CXX_STANDARD_REQUIRED ON)
set(CMAKE_POSITION_INDEPENDENT_CODE ON)
set(CMAKE_SKIP_RPATH ON)
if(CMAKE_BUILD_TYPE STREQUAL "Debug")
set(CMAKE_EXPORT_COMPILE_COMMANDS ON)

View file

@ -72,6 +72,7 @@ struct ResourceDataEntry {
};
#pragma clang diagnostic push
#pragma clang diagnostic ignored "-Wunknown-warning-option"
#pragma clang diagnostic ignored "-Wunsafe-buffer-usage-in-container"
namespace {
/// Safely cast a vector to a pointer of type T

View file

@ -32,6 +32,7 @@ namespace {
/// patch the generate shader
void patchGenerateShader(std::vector<uint8_t>& data, bool hdr) {
#pragma clang diagnostic push
#pragma clang diagnostic ignored "-Wunknown-warning-option"
#pragma clang diagnostic ignored "-Wunsafe-buffer-usage-in-container"
auto* _ptr = data.data();
const std::span<uint32_t> words(

View file

@ -344,6 +344,7 @@ namespace {
VkResult myvkQueuePresentKHR(VkQueue queue, const VkPresentInfoKHR* info) {
#pragma clang diagnostic push
#pragma clang diagnostic ignored "-Wunknown-warning-option"
#pragma clang diagnostic ignored "-Wunsafe-buffer-usage"
VkResult result = VK_SUCCESS;

View file

@ -71,7 +71,7 @@ namespace lsfgvk::layer {
ls::WatchedConfig config;
std::optional<ls::GameConf> active_profile;
ls::lazy<lsfgvk::backend::Instance> backend;
ls::lazy<backend::Instance> backend;
std::unordered_map<VkSwapchainKHR, Swapchain> swapchains;
};

View file

@ -64,7 +64,7 @@ void layer::context_ModifySwapchainCreateInfo(const ls::GameConf& profile, uint3
}
}
Swapchain::Swapchain(const vk::Vulkan& vk, lsfgvk::backend::Instance& backend,
Swapchain::Swapchain(const vk::Vulkan& vk, backend::Instance& backend,
ls::GameConf profile, SwapchainInfo info) :
instance(backend),
profile(std::move(profile)), info(std::move(info)) {
@ -92,13 +92,13 @@ Swapchain::Swapchain(const vk::Vulkan& vk, lsfgvk::backend::Instance& backend,
this->syncSemaphore.emplace(vk, 0, std::nullopt, &syncFd);
try {
this->ctx = ls::owned_ptr<ls::R<lsfgvk::backend::Context>>(
new ls::R(backend.openContext(
this->ctx = ls::owned_ptr<ls::R<backend::Context>>(
new ls::R<backend::Context>(backend.openContext(
{ sourceFds.at(0), sourceFds.at(1) }, destinationFds, syncFd,
extent.width, extent.height,
hdr, this->profile.flow_scale, this->profile.performance_mode
)),
[backend = &backend](ls::R<lsfgvk::backend::Context>& ctx) {
[backend = &backend](ls::R<backend::Context>& ctx) {
backend->closeContext(ctx);
}
);
@ -141,6 +141,7 @@ VkResult Swapchain::present(const vk::Vulkan& vk,
// update present mode when not using pacing
if (this->profile.pacing == ls::Pacing::None) {
#pragma clang diagnostic push
#pragma clang diagnostic ignored "-Wunknown-warning-option"
#pragma clang diagnostic ignored "-Wunsafe-buffer-usage"
auto* info = reinterpret_cast<VkSwapchainPresentModeInfoEXT*>(next_chain);
while (info) {

View file

@ -42,7 +42,7 @@ namespace lsfgvk::layer {
/// @param backend lsfg-vk backend instance
/// @param profile active game profile
/// @param info swapchain info
Swapchain(const vk::Vulkan& vk, lsfgvk::backend::Instance& backend,
Swapchain(const vk::Vulkan& vk, backend::Instance& backend,
ls::GameConf profile, SwapchainInfo info);
/// present a frame
@ -70,8 +70,8 @@ namespace lsfgvk::layer {
std::vector<RenderPass> passes;
std::vector<std::pair<vk::Semaphore, vk::Semaphore>> postCopySemaphores;
ls::R<lsfgvk::backend::Instance> instance;
ls::owned_ptr<ls::R<lsfgvk::backend::Context>> ctx;
ls::R<backend::Instance> instance;
ls::owned_ptr<ls::R<backend::Context>> ctx;
size_t idx{1};
size_t fidx{0}; // real frame index

View file

@ -28,6 +28,7 @@ set_target_properties(lsfg-vk-ui PROPERTIES
AUTOUIC ON)
target_compile_options(lsfg-vk-ui PRIVATE
-Wno-unknown-warning-option
-Wno-ctad-maybe-unsupported
-Wno-unsafe-buffer-usage-in-libc-call
-Wno-global-constructors

View file

@ -1,10 +1,11 @@
#include <QStringListModel>
#include <QStringList>
#include <QString>
#include "backend.hpp"
#include "utils.hpp"
#include "lsfg-vk-common/configuration/config.hpp"
#include <QStringListModel>
#include <QStringList>
#include <QString>
#include <chrono>
#include <exception>
#include <filesystem>

View file

@ -1,10 +1,11 @@
#pragma once
#include "lsfg-vk-common/configuration/config.hpp"
#include <QObject>
#include <QStringListModel>
#include <QString>
#include "lsfg-vk-common/configuration/config.hpp"
#include <atomic>
#include <utility>

View file

@ -1,11 +1,11 @@
#include "backend.hpp"
#include <QIcon>
#include <QGuiApplication>
#include <QQmlApplicationEngine>
#include <QQmlContext>
#include <QUrl>
#include "backend.hpp"
using namespace lsfgvk::ui;
int main(int argc, char* argv[]) {

View file

@ -1,8 +1,9 @@
#include <QStringList>
#include <QString>
#include "utils.hpp"
#include "lsfg-vk-backend/lsfgvk.hpp"
#include <QStringList>
#include <QString>
#include <algorithm>
#include <optional>
#include <stdexcept>