From 634adb4b3e1b683804faad90840f20cf4829ee32 Mon Sep 17 00:00:00 2001 From: Newbyte Date: Sat, 21 Mar 2020 15:17:34 +0100 Subject: [PATCH 01/11] build.sh: Improve usage message (#93) * Improve usage message --- build.sh | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/build.sh b/build.sh index 376beb8b..8bc48280 100755 --- a/build.sh +++ b/build.sh @@ -196,7 +196,16 @@ usage() { else echo "$0 requires one argument" fi - echo 'Accepted arguments: "pull", "configure", "build", "package", "install", "clean", "uninstall".' + echo -e "\nUsage: $0 \n" + echo "Available commands:" + echo -e "\tpull\t\tPull latest commits (code) from Git" + echo -e "\tconfigure\tEnsures that dependencies are installed, updates git submodules, and generates files needed for building MangoHud. This is automatically run by the build command" + echo -e "\tbuild\t\tIf needed runs configure and then builds (compiles) MangoHud" + echo -e "\tpackage\t\tRuns build if needed and then builds a tar package from MangoHud" + echo -e "\tinstall\t\tInstall MangoHud onto your system" + echo -e "\tclean\t\tRemoves build directory" + echo -e "\tuninstall\tRemoves installed MangoHud files from your system" + echo -e "\trelease\t\tBuilds a MangoHud release tar package" } for a in $@; do From 76bb50bd010630c0492ce88415770faf3f00b52a Mon Sep 17 00:00:00 2001 From: Faalagorn Date: Sun, 22 Mar 2020 21:08:05 +0100 Subject: [PATCH 02/11] Updated ManogoHud.conf with the recent values Fixes #92 --- bin/MangoHud.conf | 29 +++++++++++++++++++++++++++++ 1 file changed, 29 insertions(+) diff --git a/bin/MangoHud.conf b/bin/MangoHud.conf index adb1c500..b4e60cfd 100644 --- a/bin/MangoHud.conf +++ b/bin/MangoHud.conf @@ -23,6 +23,8 @@ cpu_stats ### Display the current GPU information gpu_stats # gpu_temp +# gpu_core_clock +# gpu_mem_clock ### Display the frametime line graph frame_timing @@ -44,6 +46,10 @@ position=top-left ### Display the current CPU load & frequency for each core # core_load +### IO read and write for the app (not system) +# io_read +# io_write + ### Display system ram / vram usage # ram # vram @@ -61,6 +67,21 @@ position=top-left ### Hud transparency / alpha background_alpha=0.5 +# alpha= + +### Color customization +# text_color #ffffff #ffffff +# gpu_color #2e9762 #2e9762 +# cpu_color #2e97cb #2e97cb +# vram_color #ad64c1 #ad64c1 +# ram_color #c26693 #c26693 +# engine_color #eb5b5b #eb5b5b +# io_color #a491d3 #a491d3 +# frametime_color #00ff00 #00ff00 +# background_color #020202 #020202 + +### Change default font (set location to .TTF/.OTF file ) +# font_file ### Crosshair overlay (default size is 30) # crosshair @@ -72,3 +93,11 @@ background_alpha=0.5 ### Change toggle keybinds for the hud & logging toggle_hud=F12 toggle_logging=F2 +reload_cfg=F4 + +################## LOG ################# + +### Set amount of time in second that the logging will run for +# log_duration +### Define name and location of the output file (Required for logging) +# output_file From 4627c59f226b06bb212e86f419e734676da7eb1e Mon Sep 17 00:00:00 2001 From: gasinvein Date: Mon, 23 Mar 2020 16:11:20 +0300 Subject: [PATCH 03/11] Change flatpak ID in readme --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index fd007665..0dc1192e 100644 --- a/README.md +++ b/README.md @@ -61,7 +61,7 @@ If you are using Flatpaks, you will have to add the [Flathub repository](https:/ ##### For Steam flatpak ``` -flatpak install com.valvesoftware.Steam.VulkanLayer.MangoHud +flatpak install com.valvesoftware.Steam.Utility.MangoHud ``` To enable MangoHud for all Steam games: ``` From f25b0dbea9ea54f0a540474b1a27904fa01fd121 Mon Sep 17 00:00:00 2001 From: Faalagorn Date: Mon, 23 Mar 2020 18:02:48 +0100 Subject: [PATCH 04/11] Updated ManogoHud.conf color usage --- bin/MangoHud.conf | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/bin/MangoHud.conf b/bin/MangoHud.conf index b4e60cfd..6e50704c 100644 --- a/bin/MangoHud.conf +++ b/bin/MangoHud.conf @@ -70,15 +70,15 @@ background_alpha=0.5 # alpha= ### Color customization -# text_color #ffffff #ffffff -# gpu_color #2e9762 #2e9762 -# cpu_color #2e97cb #2e97cb -# vram_color #ad64c1 #ad64c1 -# ram_color #c26693 #c26693 -# engine_color #eb5b5b #eb5b5b -# io_color #a491d3 #a491d3 -# frametime_color #00ff00 #00ff00 -# background_color #020202 #020202 +# text_color=FFFFFF +# gpu_color=2E9762 +# cpu_color=2E97CB +# vram_color=AD64C1 +# ram_color=C26693 +# engine_color=EB5B5B +# io_color=A491D3 +# frametime_color=00FF00 +# background_color=020202 ### Change default font (set location to .TTF/.OTF file ) # font_file From b763dd852f0910379a158b461f3e120b2088fc84 Mon Sep 17 00:00:00 2001 From: Stephan Lachnit Date: Mon, 30 Mar 2020 00:41:21 +0200 Subject: [PATCH 05/11] Add builddir/ to gitignore Signed-off-by: Stephan Lachnit --- .gitignore | 1 + 1 file changed, 1 insertion(+) diff --git a/.gitignore b/.gitignore index 9b91e47e..d293d515 100644 --- a/.gitignore +++ b/.gitignore @@ -1,4 +1,5 @@ build/ +builddir/ __pycache__/ .vscode/ MangoHud*.tar.gz From 4830268a1118d9da2327ee329180fdc2721e62be Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Andr=C3=A9=20Almeida?= Date: Fri, 3 Apr 2020 17:28:45 -0300 Subject: [PATCH 06/11] logging: fix indentation --- src/logging.h | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/src/logging.h b/src/logging.h index da04f464..677093cf 100644 --- a/src/logging.h +++ b/src/logging.h @@ -41,16 +41,21 @@ void *logging(void *params_void){ overlay_params *params = reinterpret_cast(params_void); time_t now_log = time(0); tm *log_time = localtime(&now_log); - string date = to_string(log_time->tm_year + 1900) + "-" + to_string(1 + log_time->tm_mon) + "-" + to_string(log_time->tm_mday) + "_" + to_string(1 + log_time->tm_hour) + "-" + to_string(1 + log_time->tm_min) + "-" + to_string(1 + log_time->tm_sec); + string date = to_string(log_time->tm_year + 1900) + "-" + + to_string(1 + log_time->tm_mon) + "-" + + to_string(log_time->tm_mday) + "_" + + to_string(1 + log_time->tm_hour) + "-" + + to_string(1 + log_time->tm_min) + "-" + + to_string(1 + log_time->tm_sec); log_start = os_time_get(); out.open(params->output_file + date, ios::out | ios::app); out << "os," << "cpu," << "gpu," << "ram," << "kernel," << "driver" << endl; out << os << "," << cpu << "," << gpu << "," << ram << "," << kernel << "," << driver << endl; - while (loggingOn){ + while (loggingOn){ uint64_t now = os_time_get(); elapsedLog = (double)(now - log_start); out << fps << "," << cpuLoadLog << "," << gpuLoadLog << "," << now - log_start << endl; - // logArray.push_back({fps, cpuLoadLog, gpuLoadLog, 0.0f}); + // logArray.push_back({fps, cpuLoadLog, gpuLoadLog, 0.0f}); if ((elapsedLog) >= params->log_duration * 1000000 && params->log_duration) loggingOn = false; @@ -60,4 +65,4 @@ void *logging(void *params_void){ // writeFile(date); out.close(); return NULL; -} \ No newline at end of file +} From 0303f8de28c1e3f5ab59bdb45005884d53e9d93a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Andr=C3=A9=20Almeida?= Date: Wed, 8 Apr 2020 11:53:34 -0300 Subject: [PATCH 07/11] logging: write log to a memory buffer Instead of writing every line of the log to the file (and, consequently, to the disk), write to a memory buffer first and after the log finishes flush from memory to disk. This improve the performance of the tool, since it avoids making the program blocked by disk IO. --- src/logging.h | 39 ++++++++++++++++++++------------------- 1 file changed, 20 insertions(+), 19 deletions(-) diff --git a/src/logging.h b/src/logging.h index 677093cf..126da885 100644 --- a/src/logging.h +++ b/src/logging.h @@ -10,16 +10,16 @@ using namespace std; string os, cpu, gpu, ram, kernel, driver; bool sysInfoFetched = false; -int gpuLoadLog = 0, cpuLoadLog = 0, log_period = 0; +int gpuLoadLog = 0, cpuLoadLog = 0, log_period = 0, elapsedLog; struct logData{ double fps; - double cpu; - double gpu; - double previous; + int cpu; + int gpu; + int previous; }; -double fps, elapsedLog; +double fps; std::vector logArray; ofstream out; const char* log_period_env = std::getenv("LOG_PERIOD"); @@ -27,15 +27,15 @@ int num; bool loggingOn; uint64_t log_start; -// void writeFile(string date){ -// out.open(mangohud_output_env + date, ios::out | ios::app); +void writeFile(string filename){ + out.open(filename, ios::out | ios::app); -// for (size_t i = 0; i < logArray.size(); i++) { -// out << logArray[i].fps << "," << logArray[i].cpu << "," << logArray[i].gpu << endl; -// } -// out.close(); -// logArray.clear(); -// } + for (size_t i = 0; i < logArray.size(); i++) + out << logArray[i].fps << "," << logArray[i].cpu << "," << logArray[i].gpu << "," << logArray[i].previous << endl; + + out.close(); + logArray.clear(); +} void *logging(void *params_void){ overlay_params *params = reinterpret_cast(params_void); @@ -51,18 +51,19 @@ void *logging(void *params_void){ out.open(params->output_file + date, ios::out | ios::app); out << "os," << "cpu," << "gpu," << "ram," << "kernel," << "driver" << endl; out << os << "," << cpu << "," << gpu << "," << ram << "," << kernel << "," << driver << endl; + out.close(); + while (loggingOn){ uint64_t now = os_time_get(); - elapsedLog = (double)(now - log_start); - out << fps << "," << cpuLoadLog << "," << gpuLoadLog << "," << now - log_start << endl; - // logArray.push_back({fps, cpuLoadLog, gpuLoadLog, 0.0f}); + elapsedLog = now - log_start; + logArray.push_back({fps, cpuLoadLog, gpuLoadLog, elapsedLog}); if ((elapsedLog) >= params->log_duration * 1000000 && params->log_duration) loggingOn = false; - + this_thread::sleep_for(chrono::milliseconds(log_period)); } - // writeFile(date); - out.close(); + + writeFile(params->output_file + date); return NULL; } From 0a942512e9c6cc63ecd6d6f63a529ac4c95468b1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Andr=C3=A9=20Almeida?= Date: Wed, 8 Apr 2020 11:55:28 -0300 Subject: [PATCH 08/11] logging: don't sleep if time is over --- src/logging.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/logging.h b/src/logging.h index 126da885..77dc58cc 100644 --- a/src/logging.h +++ b/src/logging.h @@ -60,8 +60,8 @@ void *logging(void *params_void){ if ((elapsedLog) >= params->log_duration * 1000000 && params->log_duration) loggingOn = false; - - this_thread::sleep_for(chrono::milliseconds(log_period)); + else + this_thread::sleep_for(chrono::milliseconds(log_period)); } writeFile(params->output_file + date); From f07aea54b6d705f8e0fecb188dfb45fd30108c24 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Andr=C3=A9=20Almeida?= Date: Thu, 9 Apr 2020 15:58:05 -0300 Subject: [PATCH 09/11] logging: check if duration is enabled before checking if it has expired If we check if log_duration is enabled before checking if it has expired we can save some math and comparison instructions on every log write. --- src/logging.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/logging.h b/src/logging.h index 77dc58cc..12329b2c 100644 --- a/src/logging.h +++ b/src/logging.h @@ -58,7 +58,7 @@ void *logging(void *params_void){ elapsedLog = now - log_start; logArray.push_back({fps, cpuLoadLog, gpuLoadLog, elapsedLog}); - if ((elapsedLog) >= params->log_duration * 1000000 && params->log_duration) + if (params->log_duration && (elapsedLog) >= params->log_duration * 1000000) loggingOn = false; else this_thread::sleep_for(chrono::milliseconds(log_period)); From f860418e7e51e8918f998426087db375cff99806 Mon Sep 17 00:00:00 2001 From: Stephan Lachnit Date: Fri, 10 Apr 2020 11:33:58 +0200 Subject: [PATCH 10/11] Allow system NVML to be used Signed-off-by: Stephan Lachnit --- meson.build | 6 ++++++ meson_options.txt | 1 + src/loaders/loader_nvml.h | 4 ++++ src/meson.build | 3 ++- 4 files changed, 13 insertions(+), 1 deletion(-) diff --git a/meson.build b/meson.build index 2a171328..2685a8b2 100644 --- a/meson.build +++ b/meson.build @@ -212,5 +212,11 @@ util_files = files( 'src/mesa/util/os_time.c', ) +if get_option('use_system_nvml') + cpp_nvml_args = '-DUSE_SYSTEM_NVML' +else + cpp_nvml_args = [] +endif + subdir('modules/ImGui') subdir('src') diff --git a/meson_options.txt b/meson_options.txt index f3166bf4..fdd0c439 100644 --- a/meson_options.txt +++ b/meson_options.txt @@ -1,5 +1,6 @@ option('glibcxx_asserts', type : 'boolean', value : false) option('use_system_vulkan', type : 'feature', value : 'disabled', description: 'Use system vulkan headers instead of the provided ones') +option('use_system_nvml', type : 'boolean', value : false, description : 'Use system nvml headers instead of the provided ones') option('mangohud_prefix', type : 'string', value : '', description: 'Add prefix to cross-compiled library, like "lib32-".') option('append_libdir_mangohud', type : 'boolean', value : true, description: 'Append "mangohud" to libdir path or not.') option('include_doc', type : 'boolean', value : true, description: 'Include the example config') diff --git a/src/loaders/loader_nvml.h b/src/loaders/loader_nvml.h index dfb65d26..eeeeff7b 100644 --- a/src/loaders/loader_nvml.h +++ b/src/loaders/loader_nvml.h @@ -4,7 +4,11 @@ #ifndef LIBRARY_LOADER_NVML_H #define LIBRARY_LOADER_NVML_H +#if USE_SYSTEM_NVML +#include +#else #include "nvml.h" +#endif #define LIBRARY_LOADER_NVML_H_DLOPEN #include diff --git a/src/meson.build b/src/meson.build index 157a7dc1..aba4f65b 100644 --- a/src/meson.build +++ b/src/meson.build @@ -82,6 +82,7 @@ vklayer_mesa_overlay = shared_library( cpp_args : [ pre_args, cpp_vis_args, + cpp_nvml_args, vulkan_wsi_args ], dependencies : [ @@ -123,4 +124,4 @@ if get_option('include_doc') install_dir : join_paths(get_option('datadir'), 'doc', 'mangohud'), rename : ['MangoHud.conf.example'] ) -endif \ No newline at end of file +endif From dc39dc76507585535cccac45ed14296f9a4a53e0 Mon Sep 17 00:00:00 2001 From: Stephan Lachnit Date: Fri, 10 Apr 2020 11:34:45 +0200 Subject: [PATCH 11/11] Create script to release DFSG compliant source Signed-off-by: Stephan Lachnit --- .gitignore | 11 ++++++----- build-source.sh | 8 ++++++++ 2 files changed, 14 insertions(+), 5 deletions(-) create mode 100755 build-source.sh diff --git a/.gitignore b/.gitignore index d293d515..d37848c0 100644 --- a/.gitignore +++ b/.gitignore @@ -1,11 +1,12 @@ -build/ -builddir/ -__pycache__/ -.vscode/ +build +builddir +__pycache__ +.vscode MangoHud*.tar.gz -pkg/* +pkg mangohud*.tar.* lib32-mangohud*.tar.* +v*.tar.gz # Prerequisites *.d diff --git a/build-source.sh b/build-source.sh new file mode 100755 index 00000000..e664d4a7 --- /dev/null +++ b/build-source.sh @@ -0,0 +1,8 @@ +#!/bin/sh + +VERSION=$(git describe --long --tags --always | sed 's/\([^-]*-g\)/r\1/;s/-/./g;s/^v//') + +EXCLUDE_PATTERN="--exclude-vcs --exclude-vcs-ignores" + +tar -cf v$VERSION.tar.gz $EXCLUDE_PATTERN . +tar -cf v$VERSION-DFSG.tar.gz $EXCLUDE_PATTERN --exclude=include/nvml.h .