From nobody Wed Dec 15 09:48:04 2021 X-Original-To: dev-commits-ports-main@mlmmj.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mlmmj.nyi.freebsd.org (Postfix) with ESMTP id ECED618D6AEB; Wed, 15 Dec 2021 09:48:04 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "R3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4JDVmN4vk2z4ccl; Wed, 15 Dec 2021 09:48:04 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org (gitrepo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:5]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 83FE119F2C; Wed, 15 Dec 2021 09:48:04 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org ([127.0.1.44]) by gitrepo.freebsd.org (8.16.1/8.16.1) with ESMTP id 1BF9m4g3060720; Wed, 15 Dec 2021 09:48:04 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 1BF9m4K9060718; Wed, 15 Dec 2021 09:48:04 GMT (envelope-from git) Date: Wed, 15 Dec 2021 09:48:04 GMT Message-Id: <202112150948.1BF9m4K9060718@gitrepo.freebsd.org> To: ports-committers@FreeBSD.org, dev-commits-ports-all@FreeBSD.org, dev-commits-ports-main@FreeBSD.org From: Alexey Dokuchaev Subject: git: 423b6f5be5e4 - main - benchmarks/mangohud: the port had been improved (+) List-Id: Commits to the main branch of the FreeBSD ports repository List-Archive: https://lists.freebsd.org/archives/dev-commits-ports-main List-Help: List-Post: List-Subscribe: List-Unsubscribe: Sender: owner-dev-commits-ports-main@freebsd.org X-BeenThere: dev-commits-ports-main@freebsd.org MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: danfe X-Git-Repository: ports X-Git-Refname: refs/heads/main X-Git-Reftype: branch X-Git-Commit: 423b6f5be5e49123a4888fe201c47d9c0edddb5f Auto-Submitted: auto-generated ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1639561684; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=ztLyf4mG7kkNNTxK2FzEs7+eYYn4zn6hzC1Tx515iEY=; b=hGA+BBaEIrQsHggdhz1UEpeHcJPZwzQH4wE9mXxM6VZRq32JqD8ovlfgdtXBzPkMvlmePY Q0kA15WgwxkyScIKnT0qItXRS0ubK9xnl8p2gcmcT835tkvuSam+6jdodvjJlkQGt3mnrO mrMP6y44sc8pfDmklIun77GbcDVeBJ+FHXubSLqI7DBtPz36Bq29znau86aAeW8uWXAaqc dZf7Bjz09a6pwDi2jO1X1Hr3BxM7mky6pOQQuJkxRtVgMt0mb7jWTIgb3xRQm/TpnDeVI6 PWFDRhx+n874+hpbr7yElsZpXX2g2jj4VrgNQ205mH9mF0QnI4bCn4JP9J+H2Q== ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1639561684; a=rsa-sha256; cv=none; b=g8+pPnp8aO1spV+XtIE+YhiIdc/GypE0buOJalUE9jEtA0g2/AiINSBpuDI7Dz1/EJa6Ki Bv635BaZ92oVBzeZkvX4AyCclCLICW9KxVdWH0c9CyRqZ+6sVCEpaV9LSlD2qv8FXeDtx3 Atsmn0E4K/TAfjbCBfZo2cNHkXQQStXOJ6jxw32VqIXco+cqoa8BBu3/jXFBIlBmKueGn4 jjwz773mCk6kgLoGJH3XMCI2uopetS0a+7opqQjGXyKOQP/cV8AiNDvUYffEsgBp4RIA5m Q80R9d2nzwWaeg2iKJ+6JXMGsywr1exOhPNh9p0uHb83s/utyNn6mzc4CkG+fQ== ARC-Authentication-Results: i=1; mx1.freebsd.org; none X-ThisMailContainsUnwantedMimeParts: N The branch main has been updated by danfe: URL: https://cgit.FreeBSD.org/ports/commit/?id=423b6f5be5e49123a4888fe201c47d9c0edddb5f commit 423b6f5be5e49123a4888fe201c47d9c0edddb5f Author: Alexey Dokuchaev AuthorDate: 2021-12-15 09:45:18 +0000 Commit: Alexey Dokuchaev CommitDate: 2021-12-15 09:45:18 +0000 benchmarks/mangohud: the port had been improved (+) - Report CPU frequency and temperature on the HUD - For gathering system information, use sysctlbyname() if possible instead of capturing external programs' output --- benchmarks/mangohud/Makefile | 1 + benchmarks/mangohud/files/patch-src_cpu.cpp | 72 ++++++++++++++++++++++ .../mangohud/files/patch-src_file__utils.cpp | 41 +++++++++++- benchmarks/mangohud/files/patch-src_file__utils.h | 10 +++ benchmarks/mangohud/files/patch-src_overlay.cpp | 16 +++++ benchmarks/mangohud/files/patch-src_vulkan.cpp | 32 +++++----- 6 files changed, 156 insertions(+), 16 deletions(-) diff --git a/benchmarks/mangohud/Makefile b/benchmarks/mangohud/Makefile index 2be3c8377b8f..3ba206c81ed3 100644 --- a/benchmarks/mangohud/Makefile +++ b/benchmarks/mangohud/Makefile @@ -2,6 +2,7 @@ PORTNAME= mangohud PORTVERSION= 0.6.5 +PORTREVISION= 1 DISTVERSIONPREFIX= v CATEGORIES= benchmarks graphics MASTER_SITES= https://wrapdb.mesonbuild.com/v1/projects/imgui/1.81/1/get_zip?dummy=/:igw diff --git a/benchmarks/mangohud/files/patch-src_cpu.cpp b/benchmarks/mangohud/files/patch-src_cpu.cpp new file mode 100644 index 000000000000..8f40b66beeeb --- /dev/null +++ b/benchmarks/mangohud/files/patch-src_cpu.cpp @@ -0,0 +1,72 @@ +--- src/cpu.cpp.orig 2021-07-08 06:23:59 UTC ++++ src/cpu.cpp +@@ -227,6 +227,7 @@ bool CPUStats::UpdateCPUData() + + bool CPUStats::UpdateCoreMhz() { + m_coreMhz.clear(); ++#if defined(__linux__) + std::ifstream cpuInfo(PROCCPUINFOFILE); + std::string row; + size_t i = 0; +@@ -238,6 +239,13 @@ bool CPUStats::UpdateCoreMhz() { + i++; + } + } ++#elif defined(__FreeBSD__) ++ char sysctl_name[32]; ++ for (int i = 0; i < m_cpuData.size(); i++) { ++ snprintf(sysctl_name, sizeof(sysctl_name), "dev.cpu.%d.freq", i); ++ m_cpuData[i].mhz = read_sysctl(sysctl_name); ++ } ++#endif + m_cpuDataTotal.cpu_mhz = 0; + for (auto data : m_cpuData) + m_cpuDataTotal.cpu_mhz += data.mhz; +@@ -246,6 +254,7 @@ bool CPUStats::UpdateCoreMhz() { + } + + bool CPUStats::UpdateCpuTemp() { ++#if defined(__linux__) + if (!m_cpuTempFile) + return false; + +@@ -256,6 +265,23 @@ bool CPUStats::UpdateCpuTemp() { + m_cpuDataTotal.temp = temp / 1000; + + return ret; ++#elif defined(__FreeBSD__) ++ char sysctl_name[32]; ++ int dK, i, temp; ++ for (temp = i = 0; i < m_cpuData.size(); i++) { ++ snprintf(sysctl_name, sizeof(sysctl_name), "dev.cpu.%d.temperature", i); ++ dK = read_sysctl(sysctl_name); ++ if (dK < 0) { ++ // If we could not read some core's temperature, store ++ // the last read (bogus) value and return false early. ++ m_cpuDataTotal.temp = dK; ++ return false; ++ } ++ temp += dK - 2731; ++ } ++ m_cpuDataTotal.temp = temp / (10 * m_cpuData.size()); ++ return m_cpuDataTotal.temp > 0; ++#endif + } + + static bool get_cpu_power_k10temp(CPUPowerData* cpuPowerData, int& power) { +@@ -407,6 +433,7 @@ static bool find_fallback_temp_input(const std::string + return false; + } + ++#ifdef __linux__ + bool CPUStats::GetCpuFile() { + if (m_cpuTempFile) + return true; +@@ -447,6 +474,7 @@ bool CPUStats::GetCpuFile() { + } + return true; + } ++#endif + + static bool find_input(const std::string& path, const char* input_prefix, std::string& input, const std::string& name) + { diff --git a/benchmarks/mangohud/files/patch-src_file__utils.cpp b/benchmarks/mangohud/files/patch-src_file__utils.cpp index 4ae32c1fc2b2..6aeba2b796d7 100644 --- a/benchmarks/mangohud/files/patch-src_file__utils.cpp +++ b/benchmarks/mangohud/files/patch-src_file__utils.cpp @@ -1,7 +1,44 @@ --- src/file_utils.cpp.orig 2021-07-08 06:23:59 UTC +++ src/file_utils.cpp -@@ -109,7 +109,7 @@ std::string read_symlink(const char * link) +@@ -2,6 +2,7 @@ + #include "string_utils.h" + #include + #include ++#include + #include + #include + #include +@@ -107,9 +108,36 @@ std::string read_symlink(const char * link) + return std::string(result, (count > 0) ? count : 0); + } ++template <> ++int read_sysctl(const char* name) ++{ ++ int value; ++ size_t len = sizeof(value); ++ ++ if (sysctlbyname(name, &value, &len, NULL, 0) == 0) ++ return value; ++ else return -1; ++} ++ ++template <> ++std::string read_sysctl(const char* name) ++{ ++ size_t len; ++ ++ // How large buffer do we need? ++ if (sysctlbyname(name, NULL, &len, NULL, 0) != 0) ++ return ""; ++ ++ char value[len]; ++ // Now read the actual value into it. ++ if (sysctlbyname(name, value, &len, NULL, 0) == 0) ++ return value; ++ else return ""; ++} ++ std::string get_exe_path() { - return read_symlink("/proc/self/exe"); @@ -9,7 +46,7 @@ } std::string get_wine_exe_name(bool keep_ext) -@@ -119,14 +119,14 @@ std::string get_wine_exe_name(bool keep_ext) +@@ -119,14 +147,14 @@ std::string get_wine_exe_name(bool keep_ext) return std::string(); } diff --git a/benchmarks/mangohud/files/patch-src_file__utils.h b/benchmarks/mangohud/files/patch-src_file__utils.h new file mode 100644 index 000000000000..b06efb584aa7 --- /dev/null +++ b/benchmarks/mangohud/files/patch-src_file__utils.h @@ -0,0 +1,10 @@ +--- src/file_utils.h.orig 2021-07-08 06:23:59 UTC ++++ src/file_utils.h +@@ -19,6 +19,7 @@ std::vector ls(const char* root, const ch + bool file_exists(const std::string& path); + bool dir_exists(const std::string& path); + std::string read_symlink(const char * link); ++template T read_sysctl(const char*); + std::string get_exe_path(); + std::string get_wine_exe_name(bool keep_ext = false); + std::string get_home_dir(); diff --git a/benchmarks/mangohud/files/patch-src_overlay.cpp b/benchmarks/mangohud/files/patch-src_overlay.cpp new file mode 100644 index 000000000000..2b7a5c69cd11 --- /dev/null +++ b/benchmarks/mangohud/files/patch-src_overlay.cpp @@ -0,0 +1,16 @@ +--- src/overlay.cpp.orig 2021-07-08 06:23:59 UTC ++++ src/overlay.cpp +@@ -28,12 +28,11 @@ void update_hw_info(struct swapchain_stats& sw_stats, + } + if (params.enabled[OVERLAY_PARAM_ENABLED_cpu_stats] || logger->is_active()) { + cpuStats.UpdateCPUData(); +-#ifdef __gnu_linux__ +- + if (params.enabled[OVERLAY_PARAM_ENABLED_core_load] || params.enabled[OVERLAY_PARAM_ENABLED_cpu_mhz]) + cpuStats.UpdateCoreMhz(); + if (params.enabled[OVERLAY_PARAM_ENABLED_cpu_temp] || logger->is_active() || params.enabled[OVERLAY_PARAM_ENABLED_graphs]) + cpuStats.UpdateCpuTemp(); ++#ifdef __gnu_linux__ + if (params.enabled[OVERLAY_PARAM_ENABLED_cpu_power]) + cpuStats.UpdateCpuPower(); + #endif diff --git a/benchmarks/mangohud/files/patch-src_vulkan.cpp b/benchmarks/mangohud/files/patch-src_vulkan.cpp index 7c8876346f01..fcd45bb6b633 100644 --- a/benchmarks/mangohud/files/patch-src_vulkan.cpp +++ b/benchmarks/mangohud/files/patch-src_vulkan.cpp @@ -21,7 +21,7 @@ enabled[OVERLAY_PARAM_ENABLED_cpu_temp] = cpuStats.GetCpuFile() && enabled[OVERLAY_PARAM_ENABLED_cpu_temp]; enabled[OVERLAY_PARAM_ENABLED_cpu_power] = cpuStats.InitCpuPowerData() -@@ -600,21 +600,24 @@ void init_gpu_stats(uint32_t& vendorID, overlay_params +@@ -600,21 +600,21 @@ void init_gpu_stats(uint32_t& vendorID, overlay_params } void init_system_info(){ @@ -31,26 +31,30 @@ unsetenv("LD_PRELOAD"); - ram = exec("cat /proc/meminfo | grep 'MemTotal' | awk '{print $2}'"); -+ ram = exec("grep MemTotal " PROCDIR "/meminfo | awk '{print $2}'"); - trim(ram); +- trim(ram); - cpu = exec("cat /proc/cpuinfo | grep 'model name' | tail -n1 | sed 's/^.*: //' | sed 's/([^)]*)/()/g' | tr -d '(/)'"); -+ cpu = exec("grep 'model name' " PROCDIR "/cpuinfo | tail -n1 | sed 's/^.*: //' | sed 's/([^)]*)/()/g' | tr -d '(/)'"); - trim(cpu); - kernel = exec("uname -r"); - trim(kernel); - os = exec("cat /etc/*-release | grep 'PRETTY_NAME' | cut -d '=' -f 2-"); - os.erase(remove(os.begin(), os.end(), '\"' ), os.end()); - trim(os); +- trim(cpu); +- kernel = exec("uname -r"); +- trim(kernel); +- os = exec("cat /etc/*-release | grep 'PRETTY_NAME' | cut -d '=' -f 2-"); +- os.erase(remove(os.begin(), os.end(), '\"' ), os.end()); +- trim(os); - cpusched = read_line("/sys/devices/system/cpu/cpu0/cpufreq/scaling_governor"); ++ ram = to_string(sysconf(_SC_PHYS_PAGES) * sysconf(_SC_PAGESIZE) ++ / 1024 / 1024) + " MB"; ++ cpu = read_sysctl("hw.model"); ++ kernel = to_string(read_sysctl("kern.osreldate")); ++ os = read_sysctl("kern.ostype") + " " + ++ read_sysctl("kern.osrelease"); + gpu = exec("pciconf -lv | grep -A2 ^vgapci0 | tail -1 | cut -d\\' -f2"); + trim(gpu); + driver = exec("glxinfo -B | grep 'OpenGL version' | sed 's/^.*: //'"); + trim(driver); -+ cpusched = exec("sysctl -b kern.sched.name"); ++ cpusched = read_sysctl("kern.sched.name"); const char* mangohud_recursion = getenv("MANGOHUD_RECURSION"); if (!mangohud_recursion) { -@@ -669,6 +672,8 @@ void init_system_info(){ +@@ -669,6 +669,8 @@ void init_system_info(){ else { wineVersion = ""; } @@ -59,7 +63,7 @@ // check for gamemode and vkbasalt stringstream ss; string line; -@@ -686,6 +691,7 @@ void init_system_info(){ +@@ -686,6 +688,7 @@ void init_system_info(){ if (HUDElements.gamemode_bol && HUDElements.vkbasalt_bol) break; } @@ -67,7 +71,7 @@ if (ld_preload) setenv("LD_PRELOAD", ld_preload, 1); -@@ -697,7 +703,6 @@ void init_system_info(){ +@@ -697,7 +700,6 @@ void init_system_info(){ << "Gpu:" << gpu << "\n" << "Driver:" << driver << "\n" << "CPU Scheduler:" << cpusched << std::endl;