🏹 Interact with the kernel drm
Find a file
2025-09-13 02:39:03 +02:00
.github/workflows Add a basic ci action 2025-03-10 10:48:27 +01:00
.vscode Enable all features during development 2025-02-14 21:51:51 +01:00
examples Allow wgpu example to work on non compliant drivers 2025-02-24 18:45:30 +01:00
gen Update generated bindings 2025-09-13 02:39:03 +02:00
src Update generated bindings 2025-09-13 02:39:03 +02:00
.gitignore Use custom generated bindings 2025-02-13 18:26:00 +01:00
Cargo.lock Update dependencies 2025-09-13 02:19:40 +02:00
Cargo.toml Update dependencies 2025-09-13 02:19:40 +02:00
LICENSE Add license file 2024-06-21 17:22:01 +02:00
README.md Update readme 2024-08-10 15:28:32 +02:00

Diretto

Diretto is a lightweight yet powerful Rust library designed to facilitate interaction with the Linux kernel's Direct Rendering Manager (DRM) interface.

Overview

Diretto offers robust abstractions over both the legacy DRM API and the modern atomic modesetting API. It is purpose-built for Linux environments, bypassing the need for the standard C library (libc) and directly interfacing with the kernel through the Rust-based rustix crate.

One of the unique features of Diretto is its approach to device management. Unlike other libraries, Diretto assumes full ownership of the DRM device,. This design not only simplifies the API but also enhances safety by providing a reliable mechanism to verify that the device being opened supports the necessary DRM ioctls.

Usage

The core of the Diretto library is the Device struct, which serves as the primary entry point for interacting with DRM devices. Although helper APIs are still under development, you can already use Diretto with a more manual approach. The example below demonstrates how to open a file descriptor using rustix and create a new Device instance:

use rustix::fs::{self, OFlags, Mode};
use diretto::Device;

let fd = fs::open(
     "/dev/dri/card0",
     OFlags::RDWR | OFlags::NONBLOCK,
     Mode::empty(),
 )?;
let device = unsafe { Device::new_unchecked(fd) };

For a more advanced usage example, including rendering to the screen with wgpu, refer to the example code.

License

This project is licensed under the Apache-2.0 License. For more information, please see the LICENSE file.