From 10c0f608fdb390ade7cddbf01eeb736c7b52697a Mon Sep 17 00:00:00 2001 From: Alessandro Toia Date: Tue, 3 Oct 2023 17:30:20 -0700 Subject: [PATCH] file_utils: add remove_parentheses function and use it for gpu_name --- src/file_utils.cpp | 6 ++++++ src/file_utils.h | 3 ++- src/gl/gl_hud.cpp | 2 +- src/vulkan.cpp | 3 ++- 4 files changed, 11 insertions(+), 3 deletions(-) diff --git a/src/file_utils.cpp b/src/file_utils.cpp index 5b160ea7..779d5e14 100644 --- a/src/file_utils.cpp +++ b/src/file_utils.cpp @@ -201,4 +201,10 @@ bool lib_loaded(const std::string& lib) { } +std::string remove_parentheses(const std::string& text) { + // Remove parentheses and text between them + std::regex pattern("\\([^)]*\\)"); + return std::regex_replace(text, pattern, ""); +} + #endif // __linux__ diff --git a/src/file_utils.h b/src/file_utils.h index adadfa7a..d2eca575 100644 --- a/src/file_utils.h +++ b/src/file_utils.h @@ -4,7 +4,7 @@ #include #include - +#include enum LS_FLAGS { LS_DIRS = 0x01, @@ -24,5 +24,6 @@ std::string get_home_dir(); std::string get_data_dir(); std::string get_config_dir(); bool lib_loaded(const std::string& lib); +std::string remove_parentheses(const std::string&); #endif //MANGOHUD_FILE_UTILS_H diff --git a/src/gl/gl_hud.cpp b/src/gl/gl_hud.cpp index 3183fecc..55202d3c 100644 --- a/src/gl/gl_hud.cpp +++ b/src/gl/gl_hud.cpp @@ -149,7 +149,7 @@ void imgui_create(void *ctx, const gl_wsi plat) SPDLOG_DEBUG("GL device id: {:04X}", device_id); init_gpu_stats(vendorID, device_id, params); - sw_stats.gpuName = gpu = deviceName; + sw_stats.gpuName = gpu = remove_parentheses(deviceName); SPDLOG_DEBUG("gpu: {}", gpu); // Setup Dear ImGui context IMGUI_CHECKVERSION(); diff --git a/src/vulkan.cpp b/src/vulkan.cpp index 7d7010ac..98297979 100644 --- a/src/vulkan.cpp +++ b/src/vulkan.cpp @@ -50,6 +50,7 @@ #include "notify.h" #include "blacklist.h" #include "pci_ids.h" +#include "file_utils.h" #ifdef __linux__ #include "implot.h" #endif @@ -1550,7 +1551,7 @@ static VkResult overlay_CreateSwapchainKHR( std::string deviceName = prop.deviceName; if (!is_blacklisted()) { #ifdef __linux__ - swapchain_data->sw_stats.gpuName = deviceName; + swapchain_data->sw_stats.gpuName = remove_parentheses(deviceName); #endif } swapchain_data->sw_stats.driverName = driverProps.driverInfo;