mirror of
https://github.com/ilya-zlobintsev/LACT.git
synced 2025-02-25 18:55:26 -06:00
feat: use drm for getting the gpu device name when possible (#288)
This commit is contained in:
parent
a8711802f0
commit
e74155515d
4
Cargo.lock
generated
4
Cargo.lock
generated
@ -1392,9 +1392,9 @@ checksum = "9c198f91728a82281a64e1f4f9eeb25d82cb32a5de251c6bd1b5154d63a8e7bd"
|
|||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "libdrm_amdgpu_sys"
|
name = "libdrm_amdgpu_sys"
|
||||||
version = "0.5.0"
|
version = "0.6.0"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "1f52800820eaea512331abeb04797f480eae5ed8967531aa37629aca797520b5"
|
checksum = "10ae56b30464d68a6d7b5383ace9f5981ba945cbf708c49a13cb8def83ace61d"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"libc",
|
"libc",
|
||||||
]
|
]
|
||||||
|
@ -33,7 +33,7 @@ tokio = { version = "1.35.1", features = [
|
|||||||
vulkano = { version = "0.34.1", default-features = false }
|
vulkano = { version = "0.34.1", default-features = false }
|
||||||
futures = { version = "0.3.30", default-features = false }
|
futures = { version = "0.3.30", default-features = false }
|
||||||
zbus = { version = "4.1.2", default-features = false, features = ["tokio"] }
|
zbus = { version = "4.1.2", default-features = false, features = ["tokio"] }
|
||||||
libdrm_amdgpu_sys = { optional = true, version = "0.5.0" }
|
libdrm_amdgpu_sys = { optional = true, version = "0.6.0" }
|
||||||
tar = "0.4.40"
|
tar = "0.4.40"
|
||||||
libflate = "2.0.0"
|
libflate = "2.0.0"
|
||||||
chrono = "0.4.31"
|
chrono = "0.4.31"
|
||||||
|
@ -201,9 +201,10 @@ impl GpuController {
|
|||||||
cpu_accessible_total: memory_info.cpu_accessible_vram.total_heap_size,
|
cpu_accessible_total: memory_info.cpu_accessible_vram.total_heap_size,
|
||||||
});
|
});
|
||||||
|
|
||||||
drm_handle
|
match drm_handle {
|
||||||
.and_then(|handle| handle.device_info().ok())
|
Some(handle) => handle.device_info().ok().map(|drm_info| DrmInfo {
|
||||||
.map(|drm_info| DrmInfo {
|
device_name: drm_info.find_device_name(),
|
||||||
|
pci_revision_id: Some(drm_info.pci_rev_id()),
|
||||||
family_name: drm_info.get_family_name().to_string(),
|
family_name: drm_info.get_family_name().to_string(),
|
||||||
family_id: drm_info.family_id(),
|
family_id: drm_info.family_id(),
|
||||||
asic_name: drm_info.get_asic_name().to_string(),
|
asic_name: drm_info.get_asic_name().to_string(),
|
||||||
@ -216,7 +217,9 @@ impl GpuController {
|
|||||||
l2_cache: drm_info.calc_l2_cache_size(),
|
l2_cache: drm_info.calc_l2_cache_size(),
|
||||||
l3_cache_mb: drm_info.calc_l3_cache_size_mb(),
|
l3_cache_mb: drm_info.calc_l3_cache_size_mb(),
|
||||||
memory_info: drm_memory_info,
|
memory_info: drm_memory_info,
|
||||||
})
|
}),
|
||||||
|
None => None,
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#[cfg(not(feature = "libdrm_amdgpu_sys"))]
|
#[cfg(not(feature = "libdrm_amdgpu_sys"))]
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
use gtk::glib::{self, object::ObjectExt, subclass::object::DerivedObjectProperties, Object};
|
use gtk::glib::{self, object::ObjectExt, subclass::object::DerivedObjectProperties, Object};
|
||||||
use lact_client::schema::{DeviceInfo, DeviceStats};
|
use lact_client::schema::{DeviceInfo, DeviceStats, DrmInfo};
|
||||||
use std::fmt::Write;
|
use std::fmt::Write;
|
||||||
|
|
||||||
glib::wrapper! {
|
glib::wrapper! {
|
||||||
@ -17,17 +17,34 @@ impl HardwareInfoSection {
|
|||||||
self.reset();
|
self.reset();
|
||||||
|
|
||||||
if let Some(pci_info) = &info.pci_info {
|
if let Some(pci_info) = &info.pci_info {
|
||||||
let mut gpu_model = pci_info
|
let mut gpu_model = info
|
||||||
.device_pci_info
|
.drm_info
|
||||||
.model
|
.as_ref()
|
||||||
.as_deref()
|
.and_then(|drm| drm.device_name.as_deref())
|
||||||
|
.or_else(|| pci_info.device_pci_info.model.as_deref())
|
||||||
.unwrap_or("Unknown")
|
.unwrap_or("Unknown")
|
||||||
.to_owned();
|
.to_owned();
|
||||||
let _ = write!(
|
|
||||||
gpu_model,
|
match &info.drm_info {
|
||||||
" (0x{}:0x{})",
|
Some(DrmInfo {
|
||||||
pci_info.device_pci_info.vendor_id, pci_info.device_pci_info.model_id
|
pci_revision_id: Some(pci_rev),
|
||||||
);
|
..
|
||||||
|
}) => {
|
||||||
|
let _ = write!(
|
||||||
|
gpu_model,
|
||||||
|
" (0x{}:0x{}:0x{pci_rev:X})",
|
||||||
|
pci_info.device_pci_info.vendor_id, pci_info.device_pci_info.model_id,
|
||||||
|
);
|
||||||
|
}
|
||||||
|
_ => {
|
||||||
|
let _ = write!(
|
||||||
|
gpu_model,
|
||||||
|
" (0x{}:0x{})",
|
||||||
|
pci_info.device_pci_info.vendor_id, pci_info.device_pci_info.model_id
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
self.set_gpu_model(gpu_model);
|
self.set_gpu_model(gpu_model);
|
||||||
|
|
||||||
let mut card_manufacturer = pci_info
|
let mut card_manufacturer = pci_info
|
||||||
|
@ -91,6 +91,8 @@ pub struct DeviceInfo<'a> {
|
|||||||
|
|
||||||
#[derive(Serialize, Deserialize, Debug, Clone)]
|
#[derive(Serialize, Deserialize, Debug, Clone)]
|
||||||
pub struct DrmInfo {
|
pub struct DrmInfo {
|
||||||
|
pub device_name: Option<String>,
|
||||||
|
pub pci_revision_id: Option<u32>,
|
||||||
pub family_name: String,
|
pub family_name: String,
|
||||||
#[serde(default)]
|
#[serde(default)]
|
||||||
pub family_id: u32,
|
pub family_id: u32,
|
||||||
|
Loading…
Reference in New Issue
Block a user