mirror of
https://github.com/ilya-zlobintsev/LACT.git
synced 2025-02-25 18:55:26 -06:00
feat: display current_gfxclk if available (#250)
* feat: display current_gfxclk if available * fix: check current_gfxclk is not equal u16::MAX * fix: update label
This commit is contained in:
parent
0736664616
commit
28c9f75969
@ -41,7 +41,7 @@ use tracing::{debug, error, trace, warn};
|
||||
#[cfg(feature = "libdrm_amdgpu_sys")]
|
||||
use {
|
||||
lact_schema::DrmMemoryInfo,
|
||||
libdrm_amdgpu_sys::AMDGPU::{DeviceHandle as DrmHandle, GPU_INFO},
|
||||
libdrm_amdgpu_sys::AMDGPU::{DeviceHandle as DrmHandle, GPU_INFO, MetricsInfo},
|
||||
std::{fs::File, os::fd::IntoRawFd},
|
||||
};
|
||||
|
||||
@ -238,6 +238,19 @@ impl GpuController {
|
||||
None
|
||||
}
|
||||
|
||||
#[cfg(feature = "libdrm_amdgpu_sys")]
|
||||
fn get_current_gfxclk(&self) -> Option<u16> {
|
||||
self.drm_handle
|
||||
.as_ref()
|
||||
.and_then(|drm_handle| drm_handle.get_gpu_metrics().ok())
|
||||
.and_then(|metrics| metrics.get_current_gfxclk())
|
||||
}
|
||||
|
||||
#[cfg(not(feature = "libdrm_amdgpu_sys"))]
|
||||
fn get_current_gfxclk(&self) -> Option<u16> {
|
||||
None
|
||||
}
|
||||
|
||||
fn get_link_info(&self) -> LinkInfo {
|
||||
LinkInfo {
|
||||
current_width: self.handle.get_current_link_width().ok(),
|
||||
@ -274,6 +287,7 @@ impl GpuController {
|
||||
},
|
||||
clockspeed: ClockspeedStats {
|
||||
gpu_clockspeed: self.hw_mon_and_then(HwMon::get_gpu_clockspeed),
|
||||
current_gfxclk: self.get_current_gfxclk(),
|
||||
vram_clockspeed: self.hw_mon_and_then(HwMon::get_vram_clockspeed),
|
||||
},
|
||||
voltage: VoltageStats {
|
||||
|
@ -29,6 +29,7 @@ impl GpuStatsSection {
|
||||
|
||||
let clockspeed = stats.clockspeed;
|
||||
self.set_core_clock(format_clockspeed(clockspeed.gpu_clockspeed));
|
||||
self.set_current_core_clock(format_current_gfxclk(clockspeed.current_gfxclk));
|
||||
self.set_vram_clock(format_clockspeed(clockspeed.vram_clockspeed));
|
||||
|
||||
let voltage = format!("{}V", stats.voltage.gpu.unwrap_or(0) as f64 / 1000f64);
|
||||
@ -89,6 +90,8 @@ mod imp {
|
||||
#[property(get, set)]
|
||||
core_clock: RefCell<String>,
|
||||
#[property(get, set)]
|
||||
current_core_clock: RefCell<String>,
|
||||
#[property(get, set)]
|
||||
vram_clock: RefCell<String>,
|
||||
#[property(get, set)]
|
||||
voltage: RefCell<String>,
|
||||
@ -130,3 +133,17 @@ mod imp {
|
||||
fn format_clockspeed(value: Option<u64>) -> String {
|
||||
format!("{}MHz", value.unwrap_or(0))
|
||||
}
|
||||
|
||||
fn format_current_gfxclk(value: Option<u16>) -> String {
|
||||
if let Some(v) = value {
|
||||
// if the APU/GPU dose not acually support current_gfxclk,
|
||||
// the value will be `u16::MAX (65535)`
|
||||
if v == u16::MAX {
|
||||
"N/A".to_string()
|
||||
} else {
|
||||
format!("{v}MHz")
|
||||
}
|
||||
} else {
|
||||
"N/A".to_string()
|
||||
}
|
||||
}
|
||||
|
@ -36,10 +36,15 @@ template $GpuStatsSection: $PageSection {
|
||||
spacing: 5;
|
||||
|
||||
$InfoRow {
|
||||
name: "GPU Core Clock:";
|
||||
name: "GPU Core Clock (Average):";
|
||||
value: bind template.core-clock;
|
||||
}
|
||||
|
||||
$InfoRow {
|
||||
name: "GPU Core Clock (Target):";
|
||||
value: bind template.current-core-clock;
|
||||
}
|
||||
|
||||
$InfoRow {
|
||||
name: "GPU Voltage:";
|
||||
value: bind template.voltage;
|
||||
|
@ -208,6 +208,7 @@ pub struct PmfwInfo {
|
||||
#[derive(Serialize, Deserialize, Debug, Clone, Copy)]
|
||||
pub struct ClockspeedStats {
|
||||
pub gpu_clockspeed: Option<u64>,
|
||||
pub current_gfxclk: Option<u16>,
|
||||
pub vram_clockspeed: Option<u64>,
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user