Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions data/resources/ui/pages/gpu.ui
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,9 @@
<child>
<object class="ResGraphBox" id="vram_usage"/>
</child>
<child>
<object class="ResGraphBox" id="gtt_usage"/>
</child>
<child>
<object class="AdwActionRow" id="gpu_clockspeed">
<property name="title" translatable="yes">GPU Frequency</property>
Expand Down
55 changes: 55 additions & 0 deletions src/ui/pages/gpu.rs
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,8 @@ mod imp {
#[template_child]
pub vram_usage: TemplateChild<ResGraphBox>,
#[template_child]
pub gtt_usage: TemplateChild<ResGraphBox>,
#[template_child]
pub temperature: TemplateChild<ResGraphBox>,
#[template_child]
pub power_usage: TemplateChild<adw::ActionRow>,
Expand Down Expand Up @@ -103,6 +105,7 @@ mod imp {
encode_decode_usage: Default::default(),
encode_decode_combined_usage: Default::default(),
vram_usage: Default::default(),
gtt_usage: Default::default(),
temperature: Default::default(),
power_usage: Default::default(),
gpu_clockspeed: Default::default(),
Expand Down Expand Up @@ -235,6 +238,9 @@ impl ResGPU {

imp.vram_usage.set_title_label(&i18n("Video Memory Usage"));
imp.vram_usage.graph().set_graph_color(0xc0, 0x1c, 0x28);

imp.gtt_usage.set_title_label(&i18n("GTT Memory Usage"));
imp.gtt_usage.graph().set_graph_color(0xc0, 0x1c, 0x28);

imp.temperature.set_title_label(&i18n("Temperature"));
imp.temperature.graph().set_graph_color(0xa5, 0x1d, 0x2d);
Expand All @@ -244,6 +250,9 @@ impl ResGPU {
&gpu.get_vendor()
.map_or_else(|_| i18n("N/A"), |vendor| vendor.name().to_string()),
);




match gpu.gpu_identifier() {
GpuIdentifier::PciSlot(pci_slot) => {
Expand Down Expand Up @@ -283,6 +292,8 @@ impl ResGPU {
decode_fraction,
total_vram,
used_vram,
used_gtt_mem,
total_gtt_mem,
clock_speed,
vram_speed,
temperature,
Expand Down Expand Up @@ -380,6 +391,45 @@ impl ResGPU {

None
};


let gtt_usage_string = if let (Some(total_gtt_mem), Some(used_gtt_mem)) = (total_gtt_mem, used_gtt_mem)
{
let used_gtt_fraction = (*used_gtt_mem as f64 / *total_gtt_mem as f64).finite_or_default();

let gtt_percentage_string = format!("{} %", (used_gtt_fraction * 100.0).round());

let gtt_subtitle = format!(
"{} / {} · {}",
convert_storage(*used_gtt_mem as f64, false),
convert_storage(*total_gtt_mem as f64, false),
gtt_percentage_string
);

imp.gtt_usage.set_subtitle(&gtt_subtitle);
imp.gtt_usage.graph().push_data_point(used_gtt_fraction);
imp.gtt_usage.graph().set_visible(true);
imp.gtt_usage.graph().set_locked_max_y(Some(1.0));

Some(gtt_percentage_string)
} else if let Some(used_gtt_mem) = used_gtt_mem {
let gtt_subtitle = convert_storage(*used_gtt_mem as f64, false);

imp.gtt_usage.set_subtitle(&gtt_subtitle);
imp.gtt_usage.graph().push_data_point(*used_gtt_mem as f64);
imp.gtt_usage.graph().set_visible(true);
imp.gtt_usage.graph().set_locked_max_y(None);

Some(gtt_subtitle)
} else {
imp.gtt_usage.set_subtitle(&i18n("N/A"));

imp.gtt_usage.graph().set_visible(false);

None
};



let mut power_string = power_usage.map_or_else(|| i18n("N/A"), convert_power);

Expand Down Expand Up @@ -414,6 +464,11 @@ impl ResGPU {
// shorter than) 'Memory'
usage_percentage_string.push_str(&i18n_f("Memory: {}", &[&vram_usage_string]));
}

if let Some(gtt_usage_string) = gtt_usage_string {
usage_percentage_string.push_str(" · ");
usage_percentage_string.push_str(&i18n_f("Memory: {}", &[&gtt_usage_string]));
}

imp.temperature.graph().set_visible(temperature.is_some());

Expand Down
10 changes: 9 additions & 1 deletion src/utils/gpu/amd.rs
Original file line number Diff line number Diff line change
Expand Up @@ -164,10 +164,18 @@ impl GpuImpl for AmdGpu {
fn used_vram(&self) -> Result<u64> {
self.drm_used_vram().map(|usage| usage as u64)
}

fn total_vram(&self) -> Result<u64> {
self.drm_total_vram().map(|usage| usage as u64)
}

fn used_gtt_mem(&self)-> Result<u64> {
self.drm_gtt_used_mem().map(|usage| usage as u64)
}

fn total_gtt_mem(&self)-> Result<u64> {
self.drm_gtt_total_mem().map(|usage| usage as u64)
}

fn temperature(&self) -> Result<f64> {
self.hwmon_temperature()
Expand Down
8 changes: 8 additions & 0 deletions src/utils/gpu/intel.rs
Original file line number Diff line number Diff line change
Expand Up @@ -114,6 +114,14 @@ impl GpuImpl for IntelGpu {
fn total_vram(&self) -> Result<u64> {
self.drm_total_vram().map(|usage| usage as u64)
}

fn used_gtt_mem(&self)-> Result<u64> {
self.drm_gtt_used_mem().map(|usage| usage as u64)
}

fn total_gtt_mem(&self)-> Result<u64> {
self.drm_gtt_total_mem().map(|usage| usage as u64)
}

fn temperature(&self) -> Result<f64> {
match self.driver {
Expand Down
19 changes: 18 additions & 1 deletion src/utils/gpu/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,9 @@ pub struct GpuData {

pub total_vram: Option<u64>,
pub used_vram: Option<u64>,

pub used_gtt_mem: Option<u64>,
pub total_gtt_mem: Option<u64>,

pub clock_speed: Option<f64>,
pub vram_speed: Option<f64>,
Expand Down Expand Up @@ -77,7 +80,9 @@ impl GpuData {

let total_vram = gpu.total_vram().ok();
let used_vram = gpu.used_vram().ok();


let used_gtt_mem = gpu.used_gtt_mem().ok();
let total_gtt_mem = gpu.total_gtt_mem().ok();
let clock_speed = gpu.core_frequency().ok();
let vram_speed = gpu.vram_frequency().ok();

Expand All @@ -98,6 +103,8 @@ impl GpuData {
decode_fraction,
total_vram,
used_vram,
used_gtt_mem,
total_gtt_mem,
clock_speed,
vram_speed,
temperature,
Expand Down Expand Up @@ -143,6 +150,8 @@ pub trait GpuImpl {
fn combined_media_engine(&self) -> Result<bool>;
fn used_vram(&self) -> Result<u64>;
fn total_vram(&self) -> Result<u64>;
fn used_gtt_mem(&self) -> Result<u64>;
fn total_gtt_mem(&self) -> Result<u64>;
fn temperature(&self) -> Result<f64>;
fn power_usage(&self) -> Result<f64>;
fn core_frequency(&self) -> Result<f64>;
Expand All @@ -168,6 +177,14 @@ pub trait GpuImpl {
fn drm_total_vram(&self) -> Result<isize> {
read_parsed(self.sysfs_path().join("device/mem_info_vram_total"))
}

fn drm_gtt_used_mem(&self) -> Result<isize> {
read_parsed(self.sysfs_path().join("device/mem_info_gtt_used"))
}

fn drm_gtt_total_mem(&self) -> Result<isize> {
read_parsed(self.sysfs_path().join("device/mem_info_gtt_total"))
}

fn hwmon_path(&self) -> Result<&Path> {
self.first_hwmon().context("no hwmon found")
Expand Down
8 changes: 8 additions & 0 deletions src/utils/gpu/nvidia.rs
Original file line number Diff line number Diff line change
Expand Up @@ -154,6 +154,14 @@ impl GpuImpl for NvidiaGpu {
.map(|memory_info| memory_info.total)
.or_else(|_| self.drm_total_vram().map(|usage| usage as u64))
}

fn used_gtt_mem(&self)-> Result<u64> {
self.drm_gtt_used_mem().map(|usage| usage as u64)
}

fn total_gtt_mem(&self)-> Result<u64> {
self.drm_gtt_total_mem().map(|usage| usage as u64)
}

fn temperature(&self) -> Result<f64> {
Self::nvml_device(&self.pci_slot_string)
Expand Down
8 changes: 8 additions & 0 deletions src/utils/gpu/other.rs
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,14 @@ impl GpuImpl for OtherGpu {
fn total_vram(&self) -> Result<u64> {
self.drm_total_vram().map(|usage| usage as u64)
}

fn used_gtt_mem(&self)-> Result<u64> {
self.drm_gtt_used_mem().map(|usage| usage as u64)
}

fn total_gtt_mem(&self)-> Result<u64> {
self.drm_gtt_total_mem().map(|usage| usage as u64)
}

fn temperature(&self) -> Result<f64> {
self.hwmon_temperature()
Expand Down
8 changes: 8 additions & 0 deletions src/utils/gpu/v3d.rs
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,14 @@ impl GpuImpl for V3dGpu {
fn total_vram(&self) -> Result<u64> {
self.drm_total_vram().map(|usage| usage as u64)
}

fn used_gtt_mem(&self)-> Result<u64> {
self.drm_gtt_used_mem().map(|usage| usage as u64)
}

fn total_gtt_mem(&self)-> Result<u64> {
self.drm_gtt_total_mem().map(|usage| usage as u64)
}

fn temperature(&self) -> Result<f64> {
self.hwmon_temperature()
Expand Down