From a28931ef6b9f822e46e82810cd8531b77f003767 Mon Sep 17 00:00:00 2001 From: larskraemer <24323470+larskraemer@users.noreply.github.com> Date: Mon, 6 Jul 2020 19:31:40 +0200 Subject: [PATCH] General cleanup (#272) * Cleanup unused struct fields, use uniform include guards --- src/blacklist.h | 4 ++++ src/config.h | 6 ++++++ src/cpu.h | 6 ++++++ src/dbus_info.h | 5 +++++ src/file_utils.h | 5 +++++ src/font_default.h | 7 ++++--- src/gl/gl.h | 8 ++++++-- src/gl/imgui_hud.h | 4 ++++ src/gl/imgui_impl_opengl3.h | 4 ++++ src/gpu.h | 6 ++++++ src/iostats.h | 5 +++++ src/keybinds.h | 7 ++++++- src/logging.h | 6 ++++++ src/memory.h | 6 ++++++ src/notify.h | 6 ++++++ src/nvctrl.h | 6 ++++++ src/nvidia_info.h | 6 ++++++ src/overlay.cpp | 30 ------------------------------ src/overlay.h | 4 ++++ src/overlay_params.h | 7 ++++--- src/pci_ids.h | 6 ++++++ src/real_dlsym.h | 4 ++++ src/shared_x11.h | 5 +++++ src/string_utils.h | 5 +++++ src/timing.hpp | 5 ++++- 25 files changed, 123 insertions(+), 40 deletions(-) diff --git a/src/blacklist.h b/src/blacklist.h index b8f57ada..b4105df3 100644 --- a/src/blacklist.h +++ b/src/blacklist.h @@ -1,3 +1,7 @@ #pragma once +#ifndef MANGOHUD_BLACKLIST_H +#define MANGOHUD_BLACKLIST_H bool is_blacklisted(bool force_recheck = false); + +#endif //MANGOHUD_BLACKLIST_H diff --git a/src/config.h b/src/config.h index be03dbac..7e4186ea 100644 --- a/src/config.h +++ b/src/config.h @@ -1,2 +1,8 @@ +#pragma once +#ifndef MANGOHUD_CONFIG_H +#define MANGOHUD_CONFIG_H + #include "overlay_params.h" void parseConfigFile(overlay_params& p); + +#endif //MANGOHUD_CONFIG_H diff --git a/src/cpu.h b/src/cpu.h index 1fdf20c4..1b2c29d8 100644 --- a/src/cpu.h +++ b/src/cpu.h @@ -1,3 +1,7 @@ +#pragma once +#ifndef MANGOHUD_CPU_H +#define MANGOHUD_CPU_H + #include #include #include @@ -68,3 +72,5 @@ private: }; extern CPUStats cpuStats; + +#endif //MANGOHUD_CPU_H diff --git a/src/dbus_info.h b/src/dbus_info.h index ad883a6f..a6cd028b 100644 --- a/src/dbus_info.h +++ b/src/dbus_info.h @@ -1,4 +1,7 @@ #pragma once +#ifndef MANGOHUD_DBUS_INFO_H +#define MANGOHUD_DBUS_INFO_H + #include #include #include @@ -135,3 +138,5 @@ namespace dbusmgr { } bool get_media_player_metadata(dbusmgr::dbus_manager& dbus, const std::string& name, metadata& meta); + +#endif //MANGOHUD_DBUS_INFO_H diff --git a/src/file_utils.h b/src/file_utils.h index 443fad40..43f9f920 100644 --- a/src/file_utils.h +++ b/src/file_utils.h @@ -1,4 +1,7 @@ #pragma once +#ifndef MANGOHUD_FILE_UTILS_H +#define MANGOHUD_FILE_UTILS_H + #include #include @@ -21,3 +24,5 @@ bool get_wine_exe_name(std::string& name, bool keep_ext = false); std::string get_home_dir(); std::string get_data_dir(); std::string get_config_dir(); + +#endif //MANGOHUD_FILE_UTILS_H diff --git a/src/font_default.h b/src/font_default.h index cee83dcb..e72d22ed 100644 --- a/src/font_default.h +++ b/src/font_default.h @@ -1,5 +1,6 @@ -#ifndef FONT_DEFAULT_H -#define FONT_DEFAULT_H +#pragma once +#ifndef MANGOHUD_FONT_DEFAULT_H +#define MANGOHUD_FONT_DEFAULT_H #ifdef __cplusplus extern "C" { @@ -11,4 +12,4 @@ const char* GetDefaultCompressedFontDataTTFBase85(void); } #endif -#endif +#endif // MANGOHUD_FONT_DEFAULT_H diff --git a/src/gl/gl.h b/src/gl/gl.h index 808f1dae..34b8e137 100644 --- a/src/gl/gl.h +++ b/src/gl/gl.h @@ -1,8 +1,10 @@ #pragma once +#ifndef MANGOHUD_GL_GL_H +#define MANGOHUD_GL_GL_H #ifdef __cplusplus extern "C" { -#endif +#endif //__cplusplus void * glXCreateContext(void *, void *, void *, int); void glXDestroyContext(void *, void*); @@ -24,4 +26,6 @@ unsigned int eglSwapBuffers( void*, void* ); #ifdef __cplusplus } -#endif +#endif //__cplusplus + +#endif //MANGOHUD_GL_GL_H diff --git a/src/gl/imgui_hud.h b/src/gl/imgui_hud.h index 23e6039e..b993a746 100644 --- a/src/gl/imgui_hud.h +++ b/src/gl/imgui_hud.h @@ -1,4 +1,6 @@ #pragma once +#ifndef MANGOHUD_GL_IMGUI_HUD_H +#define MANGOHUD_GL_IMGUI_HUD_H #include "overlay.h" #include "imgui_impl_opengl3.h" @@ -13,3 +15,5 @@ void imgui_set_context(void *ctx); void imgui_render(unsigned int width, unsigned int height); }} // namespace + +#endif //MANGOHUD_GL_IMGUI_HUD_H \ No newline at end of file diff --git a/src/gl/imgui_impl_opengl3.h b/src/gl/imgui_impl_opengl3.h index 351d2a4b..4d9d373a 100644 --- a/src/gl/imgui_impl_opengl3.h +++ b/src/gl/imgui_impl_opengl3.h @@ -22,6 +22,8 @@ // Only override if your GL version doesn't handle this GLSL version. See GLSL version table at the top of imgui_impl_opengl3.cpp. #pragma once +#ifndef MANGOHUD_IMGUI_IMPL_OPENGL3_H +#define MANGOHUD_IMGUI_IMPL_OPENGL3_H namespace MangoHud { @@ -40,3 +42,5 @@ IMGUI_IMPL_API void ImGui_ImplOpenGL3_RenderDrawData(ImDrawData* draw_data); //IMGUI_IMPL_API void ImGui_ImplOpenGL3_DestroyDeviceObjects(); } + +#endif //MANGOHUD_IMGUI_IMPL_OPENGL3_H diff --git a/src/gpu.h b/src/gpu.h index eb84c4f0..2c544210 100644 --- a/src/gpu.h +++ b/src/gpu.h @@ -1,3 +1,7 @@ +#pragma once +#ifndef MANGOHUD_GPU_H +#define MANGOHUD_GPU_H + #include #include #include @@ -34,3 +38,5 @@ extern struct gpuInfo gpu_info; void getNvidiaGpuInfo(void); void getAmdGpuInfo(void); + +#endif //MANGOHUD_GPU_H diff --git a/src/iostats.h b/src/iostats.h index 6e48840a..30b59d25 100644 --- a/src/iostats.h +++ b/src/iostats.h @@ -1,4 +1,7 @@ #pragma once +#ifndef MANGOHUD_IOSTATS_H +#define MANGOHUD_IOSTATS_H + #include #include @@ -18,3 +21,5 @@ struct iostats { }; void getIoStats(void *args); + +#endif //MANGOHUD_IOSTATS_H diff --git a/src/keybinds.h b/src/keybinds.h index 8208cddf..3943f830 100644 --- a/src/keybinds.h +++ b/src/keybinds.h @@ -1,4 +1,7 @@ #pragma once +#ifndef MANGOHUD_KEYBINDS_H +#define MANGOHUD_KEYBINDS_H + #include "shared_x11.h" #include "loaders/loader_x11.h" @@ -34,4 +37,6 @@ bool keys_are_pressed(const std::vector& keys) { return false; } -#endif +#endif //HAVE_X11 + +#endif //MANGOHUD_KEYBINDS_H \ No newline at end of file diff --git a/src/logging.h b/src/logging.h index 042e8e49..38478fbe 100644 --- a/src/logging.h +++ b/src/logging.h @@ -1,3 +1,7 @@ +#pragma once +#ifndef MANGOHUD_LOGGING_H +#define MANGOHUD_LOGGING_H + #include #include #include @@ -67,3 +71,5 @@ extern double fps; extern logData currentLogData; string exec(string command); + +#endif //MANGOHUD_LOGGING_H diff --git a/src/memory.h b/src/memory.h index e3ac5b77..8afee519 100644 --- a/src/memory.h +++ b/src/memory.h @@ -1,3 +1,7 @@ +#pragma once +#ifndef MANGOHUD_MEMORY_H +#define MANGOHUD_MEMORY_H + #include #include @@ -13,3 +17,5 @@ struct memory_information { void update_meminfo(void); FILE *open_file(const char *file, int *reported); + +#endif //MANGOHUD_MEMORY_H diff --git a/src/notify.h b/src/notify.h index e66c70bf..559bda4c 100644 --- a/src/notify.h +++ b/src/notify.h @@ -1,3 +1,7 @@ +#pragma once +#ifndef MANGOHUD_NOTIFY_H +#define MANGOHUD_NOTIFY_H + #include #include #include "overlay_params.h" @@ -13,3 +17,5 @@ struct notify_thread bool start_notifier(notify_thread& nt); void stop_notifier(notify_thread& nt); + +#endif //MANGOHUD_NOTIFY_H diff --git a/src/nvctrl.h b/src/nvctrl.h index 55a77bfa..10be0ff4 100644 --- a/src/nvctrl.h +++ b/src/nvctrl.h @@ -1,3 +1,7 @@ +#pragma once +#ifndef MANGOHUD_NVCTRL_H +#define MANGOHUD_NVCTRL_H + struct nvctrlInfo{ int load; int temp; @@ -12,3 +16,5 @@ extern bool nvctrlSuccess; bool checkXNVCtrl(void); void getNvctrlInfo(void); char *get_attr_target_string(int attr, int target_type, int target_id); + +#endif //MANGOHUD_NVCTRL_H diff --git a/src/nvidia_info.h b/src/nvidia_info.h index aa51db70..a21aa8db 100644 --- a/src/nvidia_info.h +++ b/src/nvidia_info.h @@ -1,3 +1,7 @@ +#pragma once +#ifndef MANGOHUD_NVIDIA_INFO_H +#define MANGOHUD_NVIDIA_INFO_H + #include extern nvmlReturn_t result; @@ -9,3 +13,5 @@ extern bool nvmlSuccess; bool checkNVML(const char* pciBusId); bool getNVMLInfo(void); + +#endif //MANGOHUD_NVIDIA_INFO_H diff --git a/src/overlay.cpp b/src/overlay.cpp index e84324be..31f718ab 100644 --- a/src/overlay.cpp +++ b/src/overlay.cpp @@ -79,21 +79,8 @@ struct benchmark_stats benchmark; struct instance_data { struct vk_instance_dispatch_table vtable; VkInstance instance; - struct overlay_params params; - uint32_t api_version; - - bool first_line_printed; - - int control_client; - - /* Dumping of frame stats to a file has been enabled. */ - bool capture_enabled; - - /* Dumping of frame stats to a file has been enabled and started. */ - bool capture_started; - string engineName, engineVersion; notify_thread notifier; }; @@ -192,23 +179,7 @@ struct swapchain_data { ImGuiContext* imgui_context; ImVec2 window_size; - /**/ - uint64_t last_present_time; - - unsigned n_frames_since_update; - uint64_t last_fps_update; - double frametime; - double frametimeDisplay; - const char* cpuString; - const char* gpuString; - struct swapchain_stats sw_stats; - - /* Over a single frame */ - struct frame_stat frame_stats; - - /* Over fps_sampling_period */ - struct frame_stat accumulated_stats; }; // single global lock, for simplicity @@ -358,7 +329,6 @@ static struct instance_data *new_instance_data(VkInstance instance) { struct instance_data *data = new instance_data(); data->instance = instance; - data->control_client = -1; data->params = {}; data->params.control = -1; map_object(HKEY(data->instance), data); diff --git a/src/overlay.h b/src/overlay.h index 67e1a579..ddfdeeea 100644 --- a/src/overlay.h +++ b/src/overlay.h @@ -1,4 +1,6 @@ #pragma once +#ifndef MANGOHUD_OVERLAY_H +#define MANGOHUD_OVERLAY_H #include #include @@ -81,3 +83,5 @@ void imgui_custom_style(struct overlay_params& params); void get_device_name(int32_t vendorID, int32_t deviceID, struct swapchain_stats& sw_stats); void calculate_benchmark_data(void); void create_fonts(const overlay_params& params, ImFont*& small_font, ImFont*& text_font); + +#endif //MANGOHUD_OVERLAY_H diff --git a/src/overlay_params.h b/src/overlay_params.h index 84ebe3b0..351f8f0c 100644 --- a/src/overlay_params.h +++ b/src/overlay_params.h @@ -1,5 +1,6 @@ -#ifndef OVERLAY_PARAMS_H -#define OVERLAY_PARAMS_H +#pragma once +#ifndef MANGOHUD_OVERLAY_PARAMS_H +#define MANGOHUD_OVERLAY_PARAMS_H #include #include @@ -189,4 +190,4 @@ void parse_overlay_config(struct overlay_params *params, } #endif -#endif /* OVERLAY_PARAMS_H */ +#endif /* MANGOHUD_OVERLAY_PARAMS_H */ diff --git a/src/pci_ids.h b/src/pci_ids.h index 82f5d3d0..28ecba5a 100644 --- a/src/pci_ids.h +++ b/src/pci_ids.h @@ -1,3 +1,7 @@ +#pragma once +#ifndef MANGOHUD_PCI_IDS_H +#define MANGOHUD_PCI_IDS_H + #include #include @@ -17,3 +21,5 @@ struct device extern std::map>> pci_ids; void parse_pciids(void); + +#endif //MANGOHUD_PCI_IDS_H diff --git a/src/real_dlsym.h b/src/real_dlsym.h index 865767d0..bcfbc6cb 100644 --- a/src/real_dlsym.h +++ b/src/real_dlsym.h @@ -1,7 +1,11 @@ #pragma once +#ifndef MANGOHUD_REAL_DLSYM_H +#define MANGOHUD_REAL_DLSYM_H #define EXPORT_C_(type) extern "C" __attribute__((__visibility__("default"))) type void *real_dlopen(const char *filename, int flag); void* real_dlsym( void*, const char* ); void* get_proc_address(const char* name); + +#endif //MANGOHUD_REAL_DLSYM_H diff --git a/src/shared_x11.h b/src/shared_x11.h index 6c0db8fe..8379857f 100644 --- a/src/shared_x11.h +++ b/src/shared_x11.h @@ -1,5 +1,10 @@ #pragma once +#ifndef MANGOHUD_SHARED_X11_H +#define MANGOHUD_SHARED_X11_H + #include Display* get_xdisplay(); bool init_x11(); + +#endif //MANGOHUD_SHARED_X11_H diff --git a/src/string_utils.h b/src/string_utils.h index 2b30532c..3c9664e6 100644 --- a/src/string_utils.h +++ b/src/string_utils.h @@ -1,4 +1,7 @@ #pragma once +#ifndef MANGOHUD_STRING_UTILS_H +#define MANGOHUD_STRING_UTILS_H + #include #include #include @@ -107,3 +110,5 @@ static float parse_float(const std::string& s, std::size_t* float_len = nullptr) } #pragma GCC diagnostic pop + +#endif //MANGOHUD_STRING_UTILS_H diff --git a/src/timing.hpp b/src/timing.hpp index ea1757e0..8daa55d7 100644 --- a/src/timing.hpp +++ b/src/timing.hpp @@ -1,5 +1,7 @@ +#pragma once #ifndef MANGOHUD_TIMING_HPP #define MANGOHUD_TIMING_HPP + #include #include "mesa/util/os_time.h" @@ -17,4 +19,5 @@ public: }; using Clock = MesaClock; -#endif //MANGOHUD_TIMING_HPP \ No newline at end of file + +#endif //MANGOHUD_TIMING_HPP