diff --git a/.gitignore b/.gitignore index e15b6bc7..c54beb33 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/README.md b/README.md index 5d384ec0..e99b997c 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: ``` 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 . diff --git a/build.sh b/build.sh index 3c74400e..6c4eaea2 100755 --- a/build.sh +++ b/build.sh @@ -217,7 +217,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 diff --git a/meson.build b/meson.build index 9dcf9ef6..1554c132 100644 --- a/meson.build +++ b/meson.build @@ -222,5 +222,11 @@ if cc.sizeof('void*') == 4 pre_args += '-DMANGOHUD_ARCH="32bit"' endif +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 4de3b4f3..b9de6b83 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 b42fd02c..c9fb7bae 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/logging.h b/src/logging.h index da04f464..12329b2c 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,37 +27,43 @@ 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); 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){ + 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) + if (params->log_duration && (elapsedLog) >= params->log_duration * 1000000) loggingOn = false; - - this_thread::sleep_for(chrono::milliseconds(log_period)); + else + this_thread::sleep_for(chrono::milliseconds(log_period)); } - // writeFile(date); - out.close(); + + writeFile(params->output_file + date); return NULL; -} \ No newline at end of file +} diff --git a/src/meson.build b/src/meson.build index 220c29b7..7a997e3f 100644 --- a/src/meson.build +++ b/src/meson.build @@ -117,6 +117,7 @@ vklayer_mesa_overlay = shared_library( cpp_args : [ pre_args, cpp_vis_args, + cpp_nvml_args, vulkan_wsi_args ], dependencies : [