From 58c3d85d439a60d21e8f85e99c84fb486c73b68a Mon Sep 17 00:00:00 2001 From: nokyan Date: Wed, 4 Dec 2024 01:18:16 +0100 Subject: [PATCH 1/4] Fix GPU usage data obtained from the GPU itself being divided by 100 once too often --- src/utils/gpu/mod.rs | 19 +++++-------------- 1 file changed, 5 insertions(+), 14 deletions(-) diff --git a/src/utils/gpu/mod.rs b/src/utils/gpu/mod.rs index 94d82ef4..c269ab07 100644 --- a/src/utils/gpu/mod.rs +++ b/src/utils/gpu/mod.rs @@ -56,20 +56,11 @@ impl GpuData { pub fn new(gpu: &Gpu) -> Self { let pci_slot = gpu.pci_slot(); - let usage_fraction = gpu - .usage() - .map(|usage| (usage / 100.0).clamp(0.0, 1.0)) - .ok(); - - let encode_fraction = gpu - .encode_usage() - .map(|usage| (usage / 100.0).clamp(0.0, 1.0)) - .ok(); - - let decode_fraction = gpu - .decode_usage() - .map(|usage| (usage / 100.0).clamp(0.0, 1.0)) - .ok(); + let usage_fraction = gpu.usage().map(|usage| usage.clamp(0.0, 1.0)).ok(); + + let encode_fraction = gpu.encode_usage().map(|usage| usage.clamp(0.0, 1.0)).ok(); + + let decode_fraction = gpu.decode_usage().map(|usage| usage.clamp(0.0, 1.0)).ok(); let total_vram = gpu.total_vram().ok(); let used_vram = gpu.used_vram().ok(); From c773bd1a1a9ba22df978aab833186233b3ccf6b8 Mon Sep 17 00:00:00 2001 From: nokyan Date: Thu, 5 Dec 2024 12:51:44 +0100 Subject: [PATCH 2/4] Don't look for GPUs twice --- src/ui/window.rs | 14 +++++--------- 1 file changed, 5 insertions(+), 9 deletions(-) diff --git a/src/ui/window.rs b/src/ui/window.rs index 88c30996..3e183e57 100644 --- a/src/ui/window.rs +++ b/src/ui/window.rs @@ -297,11 +297,9 @@ impl MainWindow { } } - fn init_gpu_pages(self: &MainWindow) -> Vec { + fn init_gpu_pages(self: &MainWindow, gpus: &[Gpu]) { let imp = self.imp(); - let gpus = Gpu::get_gpus().unwrap_or_default(); - for (i, gpu) in gpus.iter().enumerate() { let page = ResGPU::new(); @@ -325,8 +323,6 @@ impl MainWindow { .borrow_mut() .insert(gpu.pci_slot(), (gpu.clone(), added_page)); } - - gpus } fn init_npu_pages(self: &MainWindow) -> Vec { @@ -366,6 +362,10 @@ impl MainWindow { let gpus = Gpu::get_gpus().unwrap_or_default(); + if !ARGS.disable_gpu_monitoring { + self.init_gpu_pages(&gpus); + } + imp.resources_sidebar.set_stack(&imp.content_stack); if SETTINGS.show_search_on_start() { @@ -411,10 +411,6 @@ impl MainWindow { imp.memory.init(); } - if !ARGS.disable_gpu_monitoring { - self.init_gpu_pages(); - } - if !ARGS.disable_npu_monitoring { self.init_npu_pages(); } From 55c0d6b388a5c4f52377edafbe98cbb453a08b20 Mon Sep 17 00:00:00 2001 From: nokyan Date: Thu, 5 Dec 2024 15:47:30 +0100 Subject: [PATCH 3/4] Put the version string into the titlebar when in Devel mode --- src/application.rs | 2 +- src/ui/window.rs | 4 ++++ 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/src/application.rs b/src/application.rs index a0ff5a2b..c88f28b3 100644 --- a/src/application.rs +++ b/src/application.rs @@ -283,7 +283,7 @@ impl Application { pub fn run(&self) { info!("Resources ({})", APP_ID); - info!("Version: {} ({})", VERSION, PROFILE); + info!("Version: {}", VERSION); info!("Datadir: {}", PKGDATADIR); if PROFILE == "Devel" { diff --git a/src/ui/window.rs b/src/ui/window.rs index 3e183e57..5c4602ef 100644 --- a/src/ui/window.rs +++ b/src/ui/window.rs @@ -44,6 +44,7 @@ mod imp { use std::{cell::RefCell, collections::HashMap}; use crate::{ + config::VERSION, ui::{ pages::{ applications::ResApplications, cpu::ResCPU, memory::ResMemory, @@ -158,6 +159,9 @@ mod imp { // Devel Profile if PROFILE == "Devel" { obj.add_css_class("devel"); + obj.set_title(Some( + &format!("{} ({})", obj.title().unwrap_or_default(), VERSION).trim(), + )); } // Load latest window state From 6ef05e86736d52260696063662766fe024f0979d Mon Sep 17 00:00:00 2001 From: nokyan Date: Thu, 5 Dec 2024 15:47:38 +0100 Subject: [PATCH 4/4] Include branch name in version string --- meson.build | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/meson.build b/meson.build index 3918d487..472fd6d8 100644 --- a/meson.build +++ b/meson.build @@ -37,10 +37,11 @@ gettext_package = meson.project_name() if get_option('profile') == 'development' profile = 'Devel' vcs_tag = run_command('git', 'rev-parse', '--short', 'HEAD').stdout().strip() - if vcs_tag == '' + vcs_branch = run_command('git', 'rev-parse', '--abbrev-ref', 'HEAD').stdout().strip() + if vcs_tag == '' or vcs_branch == '' version_suffix = '-devel' else - version_suffix = '-@0@'.format(vcs_tag) + version_suffix = '-@0@/@1@'.format(vcs_branch, vcs_tag) endif application_id = '@0@.@1@'.format(base_id, profile) else