mirror of
https://github.com/ilya-zlobintsev/LACT.git
synced 2025-02-25 18:55:26 -06:00
feat: add drm info (#132)
* wip drm info * feat: gui for drm info * chore: update dependencies in readme * feat: add support for building without drm * doc: add information about building with some features disabled * fix: ci dependencies
This commit is contained in:
2
.github/workflows/rust.yml
vendored
2
.github/workflows/rust.yml
vendored
@@ -19,7 +19,7 @@ jobs:
|
||||
- name: Update repos
|
||||
run: sudo apt update
|
||||
- name: Install dependencies
|
||||
run: sudo apt install libgtk-4-dev pkg-config libvulkan-dev
|
||||
run: sudo apt install libgtk-4-dev pkg-config libvulkan-dev libdrm-dev
|
||||
- name: Build
|
||||
run: cargo build
|
||||
- name: Run tests
|
||||
|
||||
218
Cargo.lock
generated
218
Cargo.lock
generated
@@ -33,6 +33,15 @@ dependencies = [
|
||||
"serde",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "ansi_term"
|
||||
version = "0.12.1"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "d52a9bb7ec0cf484c551830a7ce27bd20d67eac647e1befb56b0be4ee39a55d2"
|
||||
dependencies = [
|
||||
"winapi",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "anyhow"
|
||||
version = "1.0.70"
|
||||
@@ -158,6 +167,17 @@ version = "1.1.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "debc29dde2e69f9e47506b525f639ed42300fc014a3e007832592448fa8e4599"
|
||||
|
||||
[[package]]
|
||||
name = "atty"
|
||||
version = "0.2.14"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "d9b39be18770d11421cdb1b9947a45dd3f37e93092cbf377614828a319d5fee8"
|
||||
dependencies = [
|
||||
"hermit-abi 0.1.19",
|
||||
"libc",
|
||||
"winapi",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "autocfg"
|
||||
version = "1.1.0"
|
||||
@@ -173,6 +193,29 @@ dependencies = [
|
||||
"serde",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "bindgen"
|
||||
version = "0.59.2"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "2bd2a9a458e8f4304c52c43ebb0cfbd520289f8379a52e329a38afda99bf8eb8"
|
||||
dependencies = [
|
||||
"bitflags",
|
||||
"cexpr",
|
||||
"clang-sys",
|
||||
"clap 2.34.0",
|
||||
"env_logger",
|
||||
"lazy_static",
|
||||
"lazycell",
|
||||
"log",
|
||||
"peeking_take_while",
|
||||
"proc-macro2",
|
||||
"quote",
|
||||
"regex",
|
||||
"rustc-hash",
|
||||
"shlex",
|
||||
"which",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "bitflags"
|
||||
version = "1.3.2"
|
||||
@@ -265,6 +308,15 @@ version = "1.0.79"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "50d30906286121d95be3d479533b458f87493b30a4b5f79a607db8f5d11aa91f"
|
||||
|
||||
[[package]]
|
||||
name = "cexpr"
|
||||
version = "0.6.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "6fac387a98bb7c37292057cffc56d62ecb629900026402633ae9160df93a8766"
|
||||
dependencies = [
|
||||
"nom",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "cfg-expr"
|
||||
version = "0.11.0"
|
||||
@@ -280,6 +332,32 @@ version = "1.0.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "baf1de4339761588bc0619e3cbc0120ee582ebb74b53b4efbf79117bd2da40fd"
|
||||
|
||||
[[package]]
|
||||
name = "clang-sys"
|
||||
version = "1.6.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "77ed9a53e5d4d9c573ae844bfac6872b159cb1d1585a83b29e7a64b7eef7332a"
|
||||
dependencies = [
|
||||
"glob",
|
||||
"libc",
|
||||
"libloading",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "clap"
|
||||
version = "2.34.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "a0610544180c38b88101fecf2dd634b174a62eef6946f84dfc6a7127512b381c"
|
||||
dependencies = [
|
||||
"ansi_term",
|
||||
"atty",
|
||||
"bitflags",
|
||||
"strsim 0.8.0",
|
||||
"textwrap",
|
||||
"unicode-width",
|
||||
"vec_map",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "clap"
|
||||
version = "4.1.10"
|
||||
@@ -291,7 +369,7 @@ dependencies = [
|
||||
"clap_lex",
|
||||
"is-terminal",
|
||||
"once_cell",
|
||||
"strsim",
|
||||
"strsim 0.10.0",
|
||||
"termcolor",
|
||||
]
|
||||
|
||||
@@ -428,7 +506,7 @@ dependencies = [
|
||||
"ident_case",
|
||||
"proc-macro2",
|
||||
"quote",
|
||||
"strsim",
|
||||
"strsim 0.10.0",
|
||||
"syn 1.0.109",
|
||||
]
|
||||
|
||||
@@ -490,6 +568,12 @@ dependencies = [
|
||||
"winapi",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "either"
|
||||
version = "1.8.1"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "7fcaabb2fef8c910e7f4c7ce9f67a1283a1715879a7c230ca9d6d1ae31f16d91"
|
||||
|
||||
[[package]]
|
||||
name = "enum_dispatch"
|
||||
version = "0.3.11"
|
||||
@@ -523,6 +607,19 @@ dependencies = [
|
||||
"syn 1.0.109",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "env_logger"
|
||||
version = "0.9.3"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "a12e6657c4c97ebab115a42dcee77225f7f482cdd841cf7088c657a42e9e00e7"
|
||||
dependencies = [
|
||||
"atty",
|
||||
"humantime",
|
||||
"log",
|
||||
"regex",
|
||||
"termcolor",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "errno"
|
||||
version = "0.2.8"
|
||||
@@ -855,6 +952,12 @@ dependencies = [
|
||||
"system-deps",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "glob"
|
||||
version = "0.3.1"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "d2fabcfbdc87f4758337ca535fb41a6d701b65693ce38287d856d1674551ec9b"
|
||||
|
||||
[[package]]
|
||||
name = "gobject-sys"
|
||||
version = "0.17.4"
|
||||
@@ -999,6 +1102,15 @@ version = "0.4.1"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "95505c38b4572b2d910cecb0281560f54b440a19336cbbcb27bf6ce6adc6f5a8"
|
||||
|
||||
[[package]]
|
||||
name = "hermit-abi"
|
||||
version = "0.1.19"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "62b467343b94ba476dcb2500d242dadbb39557df889310ac77c5d99100aaac33"
|
||||
dependencies = [
|
||||
"libc",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "hermit-abi"
|
||||
version = "0.3.1"
|
||||
@@ -1011,6 +1123,12 @@ version = "0.4.3"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "7f24254aa9a54b5c858eaee2f5bccdb46aaf0e486a595ed5fd8f86ba55232a70"
|
||||
|
||||
[[package]]
|
||||
name = "humantime"
|
||||
version = "2.1.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "9a3a5bfb195931eeb336b2a7b4d761daec841b97f947d34394601737a7bba5e4"
|
||||
|
||||
[[package]]
|
||||
name = "ident_case"
|
||||
version = "1.0.1"
|
||||
@@ -1043,7 +1161,7 @@ version = "1.0.7"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "76e86b86ae312accbf05ade23ce76b625e0e47a255712b7414037385a1c05380"
|
||||
dependencies = [
|
||||
"hermit-abi",
|
||||
"hermit-abi 0.3.1",
|
||||
"libc",
|
||||
"windows-sys 0.45.0",
|
||||
]
|
||||
@@ -1054,7 +1172,7 @@ version = "0.4.4"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "21b6b32576413a8e69b90e952e4a026476040d81017b80445deda5f2d3921857"
|
||||
dependencies = [
|
||||
"hermit-abi",
|
||||
"hermit-abi 0.3.1",
|
||||
"io-lifetimes",
|
||||
"rustix",
|
||||
"windows-sys 0.45.0",
|
||||
@@ -1071,7 +1189,7 @@ name = "lact"
|
||||
version = "0.4.0"
|
||||
dependencies = [
|
||||
"anyhow",
|
||||
"clap",
|
||||
"clap 4.1.10",
|
||||
"lact-cli",
|
||||
"lact-daemon",
|
||||
"lact-gui",
|
||||
@@ -1082,7 +1200,7 @@ name = "lact-cli"
|
||||
version = "0.4.0"
|
||||
dependencies = [
|
||||
"anyhow",
|
||||
"clap",
|
||||
"clap 4.1.10",
|
||||
"lact-client",
|
||||
]
|
||||
|
||||
@@ -1106,6 +1224,7 @@ dependencies = [
|
||||
"bincode",
|
||||
"futures",
|
||||
"lact-schema",
|
||||
"libdrm_amdgpu_sys",
|
||||
"nix",
|
||||
"pciid-parser",
|
||||
"serde",
|
||||
@@ -1149,12 +1268,27 @@ version = "1.4.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "e2abad23fbc42b3700f2f279844dc832adb2b2eb069b2df918f455c4e18cc646"
|
||||
|
||||
[[package]]
|
||||
name = "lazycell"
|
||||
version = "1.3.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "830d08ce1d1d941e6b30645f1a0eb5643013d835ce3779a5fc208261dbe10f55"
|
||||
|
||||
[[package]]
|
||||
name = "libc"
|
||||
version = "0.2.140"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "99227334921fae1a979cf0bfdfcc6b3e5ce376ef57e16fb6fb3ea2ed6095f80c"
|
||||
|
||||
[[package]]
|
||||
name = "libdrm_amdgpu_sys"
|
||||
version = "0.1.0"
|
||||
source = "git+https://github.com/Umio-Yasuno/libdrm-amdgpu-sys-rs#ad38ed266573f9e8d970af5d7dcdfc76c1677912"
|
||||
dependencies = [
|
||||
"bindgen",
|
||||
"pkg-config",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "libloading"
|
||||
version = "0.7.4"
|
||||
@@ -1232,6 +1366,12 @@ dependencies = [
|
||||
"autocfg",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "minimal-lexical"
|
||||
version = "0.2.1"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "68354c5c6bd36d73ff3feceb05efa59b6acb7626617f4962be322a825e61f79a"
|
||||
|
||||
[[package]]
|
||||
name = "mio"
|
||||
version = "0.8.6"
|
||||
@@ -1258,6 +1398,16 @@ dependencies = [
|
||||
"static_assertions",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "nom"
|
||||
version = "7.1.3"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "d273983c5a657a70a3e8f2a01329822f3b8c8172b73826411a55751e404a0a4a"
|
||||
dependencies = [
|
||||
"memchr",
|
||||
"minimal-lexical",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "nu-ansi-term"
|
||||
version = "0.46.0"
|
||||
@@ -1379,6 +1529,12 @@ dependencies = [
|
||||
"tracing",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "peeking_take_while"
|
||||
version = "0.1.2"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "19b17cddbe7ec3f8bc800887bab5e717348c95ea2ca0b1bf0837fb964dc67099"
|
||||
|
||||
[[package]]
|
||||
name = "pin-project-lite"
|
||||
version = "0.2.9"
|
||||
@@ -1559,6 +1715,12 @@ version = "0.6.28"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "456c603be3e8d448b072f410900c09faf164fbce2d480456f50eea6e25f9c848"
|
||||
|
||||
[[package]]
|
||||
name = "rustc-hash"
|
||||
version = "1.1.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "08d43f7aa6b08d49f382cde6a7982047c3426db949b1424bc4b7ec9ae12c6ce2"
|
||||
|
||||
[[package]]
|
||||
name = "rustc_version"
|
||||
version = "0.4.0"
|
||||
@@ -1697,6 +1859,12 @@ dependencies = [
|
||||
"lazy_static",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "shlex"
|
||||
version = "1.1.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "43b2853a4d09f215c24cc5489c992ce46052d359b5109343cbafbf26bc62f8a3"
|
||||
|
||||
[[package]]
|
||||
name = "signal-hook-registry"
|
||||
version = "1.4.1"
|
||||
@@ -1737,6 +1905,12 @@ version = "1.1.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "a2eb9349b6444b326872e140eb1cf5e7c522154d69e7a0ffb0fb81c06b37543f"
|
||||
|
||||
[[package]]
|
||||
name = "strsim"
|
||||
version = "0.8.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "8ea5119cdb4c55b55d432abb513a0429384878c15dde60cc77b1c99de1a95a6a"
|
||||
|
||||
[[package]]
|
||||
name = "strsim"
|
||||
version = "0.10.0"
|
||||
@@ -1800,6 +1974,15 @@ dependencies = [
|
||||
"winapi-util",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "textwrap"
|
||||
version = "0.11.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "d326610f408c7a4eb6f51c37c330e496b08506c9457c9d34287ecc38809fb060"
|
||||
dependencies = [
|
||||
"unicode-width",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "thiserror"
|
||||
version = "1.0.40"
|
||||
@@ -1969,6 +2152,12 @@ version = "1.0.8"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "e5464a87b239f13a63a501f2701565754bae92d243d4bb7eb12f6d57d2269bf4"
|
||||
|
||||
[[package]]
|
||||
name = "unicode-width"
|
||||
version = "0.1.10"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "c0edd1e5b14653f783770bce4a4dabb4a5108a5370a5f5d8cfe8710c361f6c8b"
|
||||
|
||||
[[package]]
|
||||
name = "unsafe-libyaml"
|
||||
version = "0.2.7"
|
||||
@@ -1981,6 +2170,12 @@ version = "0.1.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "830b7e5d4d90034032940e4ace0d9a9a057e7a45cd94e6c007832e39edb82f6d"
|
||||
|
||||
[[package]]
|
||||
name = "vec_map"
|
||||
version = "0.8.2"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "f1bddf1187be692e79c5ffeab891132dfb0f236ed36a43c7ed39f1165ee20191"
|
||||
|
||||
[[package]]
|
||||
name = "version-compare"
|
||||
version = "0.1.1"
|
||||
@@ -2053,6 +2248,17 @@ version = "0.11.0+wasi-snapshot-preview1"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "9c8d87e72b64a3b4db28d11ce29237c246188f4f51057d65a7eab63b7987e423"
|
||||
|
||||
[[package]]
|
||||
name = "which"
|
||||
version = "4.4.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "2441c784c52b289a054b7201fc93253e288f094e2f4be9058343127c4226a269"
|
||||
dependencies = [
|
||||
"either",
|
||||
"libc",
|
||||
"once_cell",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "winapi"
|
||||
version = "0.3.9"
|
||||
|
||||
14
README.md
14
README.md
@@ -60,12 +60,26 @@ Dependencies:
|
||||
- pkg-config
|
||||
- make
|
||||
- hwdata
|
||||
- libdrm
|
||||
|
||||
Steps:
|
||||
- `git clone https://github.com/ilya-zlobintsev/LACT && cd LACT`
|
||||
- `make`
|
||||
- `sudo make install`
|
||||
|
||||
It's also possible to build LACT without some of the features by using cargo feature flags.
|
||||
This can be useful if some dependency is not available on your system, or is too old.
|
||||
|
||||
Build without DRM support (some GPU information will not be available):
|
||||
```
|
||||
cargo build --no-default-features -p lact --features=lact-gui
|
||||
```
|
||||
|
||||
Minimal build (no GUI!):
|
||||
```
|
||||
cargo build --no-default-features -p lact
|
||||
```
|
||||
|
||||
# API
|
||||
|
||||
There is an API available over a unix socket. See [here](API.md) for more information.
|
||||
|
||||
@@ -3,7 +3,9 @@ name = "lact-daemon"
|
||||
version = "0.4.0"
|
||||
edition = "2021"
|
||||
|
||||
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
|
||||
[features]
|
||||
default = ["drm"]
|
||||
drm = ["libdrm_amdgpu_sys"]
|
||||
|
||||
[dependencies]
|
||||
anyhow = "1.0"
|
||||
@@ -34,3 +36,4 @@ serde_with = { version = "2.3.1", default-features = false, features = [
|
||||
"macros",
|
||||
] }
|
||||
zbus = "3.11.0"
|
||||
libdrm_amdgpu_sys = { optional = true, git = " https://github.com/Umio-Yasuno/libdrm-amdgpu-sys-rs" }
|
||||
|
||||
@@ -14,8 +14,8 @@ use lact_schema::{
|
||||
hw_mon::{FanControlMethod, HwMon},
|
||||
sysfs::SysFS,
|
||||
},
|
||||
ClocksInfo, ClockspeedStats, DeviceInfo, DeviceStats, FanStats, GpuPciInfo, LinkInfo, PciInfo,
|
||||
PowerStats, VoltageStats, VramStats,
|
||||
ClocksInfo, ClockspeedStats, DeviceInfo, DeviceStats, DrmInfo, FanStats, GpuPciInfo, LinkInfo,
|
||||
PciInfo, PowerStats, VoltageStats, VramStats,
|
||||
};
|
||||
use pciid_parser::Database;
|
||||
use std::{
|
||||
@@ -26,11 +26,19 @@ use std::{
|
||||
};
|
||||
use tokio::{select, sync::Notify, task::JoinHandle, time::sleep};
|
||||
use tracing::{debug, error, trace, warn};
|
||||
#[cfg(feature = "libdrm_amdgpu_sys")]
|
||||
use {
|
||||
lact_schema::DrmMemoryInfo,
|
||||
libdrm_amdgpu_sys::AMDGPU::{DeviceHandle as DrmHandle, GPU_INFO},
|
||||
std::{fs::File, os::fd::IntoRawFd},
|
||||
};
|
||||
|
||||
type FanControlHandle = (Arc<Notify>, JoinHandle<()>);
|
||||
|
||||
pub struct GpuController {
|
||||
pub handle: GpuHandle,
|
||||
#[cfg(feature = "libdrm_amdgpu_sys")]
|
||||
pub drm_handle: Option<DrmHandle>,
|
||||
pub pci_info: Option<GpuPciInfo>,
|
||||
pub fan_control_handle: Mutex<Option<FanControlHandle>>,
|
||||
}
|
||||
@@ -40,6 +48,15 @@ impl GpuController {
|
||||
let handle = GpuHandle::new_from_path(sysfs_path)
|
||||
.map_err(|error| anyhow!("failed to initialize gpu handle: {error}"))?;
|
||||
|
||||
#[cfg(feature = "libdrm_amdgpu_sys")]
|
||||
let drm_handle = match get_drm_handle(&handle) {
|
||||
Ok(handle) => Some(handle),
|
||||
Err(err) => {
|
||||
warn!("Could not get DRM handle: {err}");
|
||||
None
|
||||
}
|
||||
};
|
||||
|
||||
let mut device_pci_info = None;
|
||||
let mut subsystem_pci_info = None;
|
||||
|
||||
@@ -91,6 +108,8 @@ impl GpuController {
|
||||
|
||||
Ok(Self {
|
||||
handle,
|
||||
#[cfg(feature = "libdrm_amdgpu_sys")]
|
||||
drm_handle,
|
||||
pci_info,
|
||||
fan_control_handle: Mutex::new(None),
|
||||
})
|
||||
@@ -140,6 +159,7 @@ impl GpuController {
|
||||
let driver = self.handle.get_driver();
|
||||
let vbios_version = self.handle.get_vbios_version().ok();
|
||||
let link_info = self.get_link_info();
|
||||
let drm_info = self.get_drm_info();
|
||||
|
||||
DeviceInfo {
|
||||
pci_info,
|
||||
@@ -147,9 +167,42 @@ impl GpuController {
|
||||
driver,
|
||||
vbios_version,
|
||||
link_info,
|
||||
drm_info,
|
||||
}
|
||||
}
|
||||
|
||||
#[cfg(feature = "libdrm_amdgpu_sys")]
|
||||
fn get_drm_info(&self) -> Option<DrmInfo> {
|
||||
let drm_handle = self.drm_handle.as_ref();
|
||||
|
||||
let drm_memory_info =
|
||||
drm_handle
|
||||
.and_then(|handle| handle.memory_info().ok())
|
||||
.map(|memory_info| DrmMemoryInfo {
|
||||
cpu_accessible_used: memory_info.cpu_accessible_vram.heap_usage,
|
||||
cpu_accessible_total: memory_info.cpu_accessible_vram.total_heap_size,
|
||||
});
|
||||
|
||||
drm_handle
|
||||
.and_then(|handle| handle.device_info().ok())
|
||||
.map(|drm_info| DrmInfo {
|
||||
family_name: drm_info.get_family_name().to_string(),
|
||||
asic_name: drm_info.get_asic_name().to_string(),
|
||||
chip_class: drm_info.get_chip_class().to_string(),
|
||||
compute_units: drm_info.cu_active_number,
|
||||
vram_type: drm_info.get_vram_type().to_string(),
|
||||
vram_bit_width: drm_info.vram_bit_width,
|
||||
vram_max_bw: drm_info.peak_memory_bw_gb().to_string(),
|
||||
l2_cache: drm_info.calc_l2_cache_size(),
|
||||
memory_info: drm_memory_info,
|
||||
})
|
||||
}
|
||||
|
||||
#[cfg(not(feature = "libdrm_amdgpu_sys"))]
|
||||
fn get_drm_info(&self) -> Option<DrmInfo> {
|
||||
None
|
||||
}
|
||||
|
||||
fn get_link_info(&self) -> LinkInfo {
|
||||
LinkInfo {
|
||||
current_width: self.handle.get_current_link_width().ok(),
|
||||
@@ -396,3 +449,16 @@ impl GpuController {
|
||||
Ok(())
|
||||
}
|
||||
}
|
||||
|
||||
#[cfg(feature = "libdrm_amdgpu_sys")]
|
||||
fn get_drm_handle(handle: &GpuHandle) -> anyhow::Result<DrmHandle> {
|
||||
let slot_name = handle
|
||||
.get_pci_slot_name()
|
||||
.context("Device has no PCI slot name")?;
|
||||
let path = format!("/dev/dri/by-path/pci-{slot_name}-render");
|
||||
let drm_file =
|
||||
File::open(&path).with_context(|| format!("Could not open drm file at {path}"))?;
|
||||
let (handle, _, _) = DrmHandle::init(drm_file.into_raw_fd())
|
||||
.map_err(|err| anyhow!("Could not open drm handle, error code {err}"))?;
|
||||
Ok(handle)
|
||||
}
|
||||
|
||||
@@ -9,21 +9,27 @@ use super::{label_row, section_box, values_grid};
|
||||
|
||||
#[derive(Clone)]
|
||||
pub struct InformationPage {
|
||||
pub container: Box,
|
||||
pub container: ScrolledWindow,
|
||||
gpu_name_label: Label,
|
||||
gpu_manufacturer_label: Label,
|
||||
family_name: Label,
|
||||
asic_name: Label,
|
||||
vbios_version_label: Label,
|
||||
driver_label: Label,
|
||||
vram_size_label: Label,
|
||||
vram_type_label: Label,
|
||||
vram_peak_bw_label: Label,
|
||||
compute_units_label: Label,
|
||||
cpu_accessible_vram_label: Label,
|
||||
link_speed_label: Label,
|
||||
vulkan_info_frame: VulkanInfoFrame,
|
||||
}
|
||||
|
||||
impl InformationPage {
|
||||
pub fn new() -> Self {
|
||||
let container = Box::new(Orientation::Vertical, 15);
|
||||
let vbox = Box::new(Orientation::Vertical, 15);
|
||||
|
||||
let info_container = section_box("Basic Information");
|
||||
let info_container = section_box("Hardware Information");
|
||||
|
||||
let values_grid = values_grid();
|
||||
|
||||
@@ -33,20 +39,32 @@ impl InformationPage {
|
||||
|
||||
let gpu_name_label = label_row("GPU Model:", &values_grid, 0, 0, true);
|
||||
let gpu_manufacturer_label = label_row("GPU Manufacturer:", &values_grid, 1, 0, true);
|
||||
let vbios_version_label = label_row("VBIOS Version:", &values_grid, 2, 0, true);
|
||||
let driver_label = label_row("Driver Used:", &values_grid, 3, 0, true);
|
||||
let vram_size_label = label_row("VRAM Size:", &values_grid, 4, 0, true);
|
||||
let link_speed_label = label_row("Link Speed:", &values_grid, 5, 0, true);
|
||||
let family_name = label_row("GPU Family:", &values_grid, 2, 0, true);
|
||||
let asic_name = label_row("ASIC Name:", &values_grid, 3, 0, true);
|
||||
let compute_units_label = label_row("Compute Units:", &values_grid, 4, 0, true);
|
||||
let vbios_version_label = label_row("VBIOS Version:", &values_grid, 5, 0, true);
|
||||
let driver_label = label_row("Driver Used:", &values_grid, 6, 0, true);
|
||||
let vram_size_label = label_row("VRAM Size:", &values_grid, 7, 0, true);
|
||||
let vram_type_label = label_row("VRAM Type:", &values_grid, 8, 0, true);
|
||||
let vram_peak_bw_label = label_row("Peak VRAM Bandwidth:", &values_grid, 9, 0, true);
|
||||
let cpu_accessible_vram_label =
|
||||
label_row("CPU Accessible VRAM:", &values_grid, 10, 0, true);
|
||||
let link_speed_label = label_row("Link Speed:", &values_grid, 11, 0, true);
|
||||
|
||||
info_container.append(&values_grid);
|
||||
container.append(&info_container);
|
||||
vbox.append(&info_container);
|
||||
|
||||
let vulkan_container = section_box("Vulkan Information");
|
||||
|
||||
let vulkan_info_frame = VulkanInfoFrame::new();
|
||||
|
||||
vulkan_container.append(&vulkan_info_frame.container);
|
||||
container.append(&vulkan_container);
|
||||
vbox.append(&vulkan_container);
|
||||
|
||||
let container = ScrolledWindow::builder()
|
||||
.hscrollbar_policy(PolicyType::Never)
|
||||
.child(&vbox)
|
||||
.build();
|
||||
|
||||
Self {
|
||||
container,
|
||||
@@ -57,6 +75,12 @@ impl InformationPage {
|
||||
vram_size_label,
|
||||
link_speed_label,
|
||||
vulkan_info_frame,
|
||||
family_name,
|
||||
asic_name,
|
||||
vram_type_label,
|
||||
cpu_accessible_vram_label,
|
||||
compute_units_label,
|
||||
vram_peak_bw_label,
|
||||
}
|
||||
}
|
||||
|
||||
@@ -73,7 +97,7 @@ impl InformationPage {
|
||||
})
|
||||
.unwrap_or_default();
|
||||
self.gpu_name_label
|
||||
.set_markup(&format!("<b>{gpu_name}</b>",));
|
||||
.set_markup(&format!("<b>{gpu_name}</b>"));
|
||||
|
||||
let gpu_manufacturer = gpu_info
|
||||
.pci_info
|
||||
@@ -87,11 +111,31 @@ impl InformationPage {
|
||||
})
|
||||
.unwrap_or_default();
|
||||
self.gpu_manufacturer_label
|
||||
.set_markup(&format!("<b>{gpu_manufacturer}</b>",));
|
||||
.set_markup(&format!("<b>{gpu_manufacturer}</b>"));
|
||||
|
||||
if let Some(drm_info) = &gpu_info.drm_info {
|
||||
self.family_name
|
||||
.set_markup(&format!("<b>{}</b>", drm_info.family_name));
|
||||
self.asic_name
|
||||
.set_markup(&format!("<b>{}</b>", drm_info.asic_name));
|
||||
self.compute_units_label
|
||||
.set_markup(&format!("<b>{}</b>", drm_info.compute_units));
|
||||
self.vram_type_label
|
||||
.set_markup(&format!("<b>{}</b>", drm_info.vram_type));
|
||||
self.vram_peak_bw_label
|
||||
.set_markup(&format!("<b>{} GiB/s</b>", drm_info.vram_max_bw));
|
||||
|
||||
if let Some(memory_info) = &drm_info.memory_info {
|
||||
self.cpu_accessible_vram_label.set_markup(&format!(
|
||||
"<b>{} MiB</b>",
|
||||
memory_info.cpu_accessible_total / 1024 / 1024
|
||||
));
|
||||
}
|
||||
}
|
||||
|
||||
let vbios_version = gpu_info.vbios_version.as_deref().unwrap_or("Unknown");
|
||||
self.vbios_version_label
|
||||
.set_markup(&format!("<b>{vbios_version}</b>",));
|
||||
.set_markup(&format!("<b>{vbios_version}</b>"));
|
||||
|
||||
self.driver_label
|
||||
.set_markup(&format!("<b>{}</b>", gpu_info.driver));
|
||||
|
||||
@@ -67,6 +67,26 @@ pub struct DeviceInfo<'a> {
|
||||
pub driver: &'a str,
|
||||
pub vbios_version: Option<String>,
|
||||
pub link_info: LinkInfo,
|
||||
pub drm_info: Option<DrmInfo>,
|
||||
}
|
||||
|
||||
#[derive(Serialize, Deserialize, Debug, Clone)]
|
||||
pub struct DrmInfo {
|
||||
pub family_name: String,
|
||||
pub asic_name: String,
|
||||
pub chip_class: String,
|
||||
pub compute_units: u32,
|
||||
pub vram_type: String,
|
||||
pub vram_bit_width: u32,
|
||||
pub vram_max_bw: String,
|
||||
pub l2_cache: u32,
|
||||
pub memory_info: Option<DrmMemoryInfo>,
|
||||
}
|
||||
|
||||
#[derive(Serialize, Deserialize, Debug, Clone)]
|
||||
pub struct DrmMemoryInfo {
|
||||
pub cpu_accessible_used: u64,
|
||||
pub cpu_accessible_total: u64,
|
||||
}
|
||||
|
||||
#[derive(Serialize, Deserialize, Default, Debug, Clone)]
|
||||
|
||||
@@ -4,10 +4,11 @@ version = "0.4.0"
|
||||
edition = "2021"
|
||||
|
||||
[features]
|
||||
default = ["lact-gui"]
|
||||
default = ["lact-gui", "drm"]
|
||||
drm = ["lact-daemon/drm"]
|
||||
|
||||
[dependencies]
|
||||
lact-daemon = { path = "../lact-daemon" }
|
||||
lact-daemon = { path = "../lact-daemon", default-features = false }
|
||||
lact-cli = { path = "../lact-cli" }
|
||||
lact-gui = { path = "../lact-gui", optional = true }
|
||||
anyhow = "1.0.70"
|
||||
|
||||
@@ -12,11 +12,11 @@ metadata:
|
||||
depends:
|
||||
all: [ hwdata ]
|
||||
debian-12+ubuntu-2204: [ libgtk-4-1 ]
|
||||
fedora-37: [ gtk4 ]
|
||||
fedora-37: [ gtk4, libdrm ]
|
||||
build_depends:
|
||||
all: [ curl, make, dbus ]
|
||||
debian-12+ubuntu-2204: [ libgtk-4-dev, pkg-config, build-essential ]
|
||||
fedora-37: [ gtk4-devel, gcc ]
|
||||
all: [ curl, make, dbus, clang ]
|
||||
debian-12+ubuntu-2204: [ libgtk-4-dev, pkg-config, build-essential, libdrm-dev ]
|
||||
fedora-37: [ gtk4-devel, gcc, libdrm-devel ]
|
||||
all_images: true
|
||||
env:
|
||||
RUSTUP_URL: https://sh.rustup.rs
|
||||
|
||||
Reference in New Issue
Block a user