Skip to main content

Documentation Index

Fetch the complete documentation index at: https://mintlify.com/Smithay/gbm.rs/llms.txt

Use this file to discover all available pages before exploring further.

gbm.rs wraps the C libgbm library in safe, ergonomic Rust types. It lets you allocate GPU-backed buffers, import external buffers from Wayland or EGL, and hook into DRM/KMS display pipelines — all without touching raw pointers or unsafe code in your application. The library is part of the Smithay ecosystem and works seamlessly alongside drm-rs.

Installation

Add gbm.rs to your Cargo.toml and choose the right feature flags for your use case.

Quickstart

Allocate your first GPU buffer and display it on screen in minutes.

Core Concepts

Understand Device, BufferObject, Surface, and how they relate to DRM/KMS.

API Reference

Full type signatures and parameter documentation for every public API.

What is the Generic Buffer Manager?

The Generic Buffer Manager (GBM) is a platform abstraction layer for GPU buffer allocation. It sits between your application and the kernel’s DRM subsystem, providing a portable interface for requesting memory buffers that the GPU can render into and the display controller can scan out. gbm.rs exposes this abstraction as safe Rust types with automatic reference counting and deterministic cleanup.

DRM Integration

Use GBM buffers directly as KMS framebuffers with drm-rs.

Wayland Import

Import Wayland client buffers into GBM for display composition.

EGL Rendering

Create GBM surfaces for OpenGL ES rendering via EGL.

DMA-BUF Import

Import external DMA-BUF file descriptors as GBM buffer objects.

Cargo Features

Enable or disable Wayland, EGL, DRM, serde, and bindgen support.

Formats & Modifiers

DRM FourCC pixel formats and tiling modifiers explained.

Get Started in 3 Steps

1

Add gbm to Cargo.toml

Cargo.toml
[dependencies]
gbm = "0.18.0"
2

Open a DRM device and create a GBM Device

use gbm::Device;
use std::fs::File;

let drm_file = File::open("/dev/dri/card0").unwrap();
let gbm = Device::new(drm_file).unwrap();
3

Allocate a buffer and use it

use gbm::{BufferObjectFlags, Format};

let bo = gbm
    .create_buffer_object::<()>(1920, 1080, Format::Argb8888, BufferObjectFlags::SCANOUT)
    .unwrap();

println!("Allocated {}x{} buffer", bo.width(), bo.height());

Build docs developers (and LLMs) love