#amd-gpu #linux-kernel #libdrm #drm #bindings #driver #ported

sys libdrm_amdgpu_sys

libdrm_amdgpu bindings for Rust, and some methods ported from Mesa3D

24 releases

new 0.8.1 Jan 4, 2025
0.7.7 Dec 13, 2024
0.7.6 Nov 28, 2024
0.7.4 Jul 17, 2024
0.1.0 May 28, 2022

#139 in Graphics APIs

Download history 2087/week @ 2024-09-17 2152/week @ 2024-09-24 1073/week @ 2024-10-01 940/week @ 2024-10-08 1027/week @ 2024-10-15 1043/week @ 2024-10-22 929/week @ 2024-10-29 1452/week @ 2024-11-05 3327/week @ 2024-11-12 1468/week @ 2024-11-19 1176/week @ 2024-11-26 929/week @ 2024-12-03 1308/week @ 2024-12-10 1375/week @ 2024-12-17 1090/week @ 2024-12-24 1201/week @ 2024-12-31

5,092 downloads per month
Used in 5 crates (via libamdgpu_top)

MIT license

5.5MB
109K SLoC

libdrm-amdgpu-sys-rs

libdrm_amdgpu bindings for Rust, and some methods ported from Mesa3D (mainly ac_gpu_info.c).

Reference

License

  • MIT License

Documentation

Dependent dynamic libraries

  • libdrm
  • libdrm_amdgpu

Distribution specific instructions

Debian/Ubuntu

sudo apt install libdrm-dev

Examples

use libdrm_amdgpu_sys::LibDrmAmdgpu;
use libdrm_amdgpu_sys::AMDGPU::DeviceHandle;
use libdrm_amdgpu_sys::AMDGPU::GPU_INFO;

let libdrm_amdgpu = LibDrmAmdgpu::new().unwrap();
let (amdgpu_dev, drm_major, drm_minor) = {
    use std::fs::OpenOptions;
    use std::os::fd::IntoRawFd;

    let fd = OpenOptions::new().read(true).write(true).open("/dev/dri/renderD128").unwrap();

    libdrm_amdgpu.init_device_handle(fd.into_raw_fd()).unwrap()
};
let device_info = amdgpu_dev.device_info().unwrap();
let device_name = device_info.find_device_name_or_default();

Dynamic Loading

Cargo.toml

libdrm_amdgpu_sys = { version = "0.8", default-features = false, features = ["dynamic_loading"] }

amdgpu_info

cargo run --example amdgpu_info

vbios_dump

cargo run --example vbios_dump

gpu_metrics

cargo run --example gpu_metrics

Build

To generate a new bindings/drm.rs .

cargo build --features=buildtime_bindgen

Dependencies

~0–4.5MB