DRM dumb buffers are the simplest form of GPU-visible memory available in the Linux DRM subsystem. They are allocated by the kernel, backed by anonymous memory, and directly accessible from userspace viaDocumentation Index
Fetch the complete documentation index at: https://mintlify.com/Smithay/drm-rs/llms.txt
Use this file to discover all available pages before exploring further.
mmap. No GPU-specific knowledge is required — any driver that supports the DumbBuffer capability can create them.
Dumb buffers are ideal for:
- Software rendering (writing pixels directly from the CPU)
- Boot screens and splash images
- Simple framebuffer outputs on embedded or virtual hardware
- Learning and prototyping with DRM before moving to hardware-accelerated paths
Checking driver support
Before allocating a dumb buffer, verify that the driver supports the feature:get_driver_capability method returns a u64; a non-zero value means the feature is supported.
Creating a dumb buffer
create_dumb_buffer takes the desired (width, height) in pixels, the pixel format as a DrmFourcc value, and the bits-per-pixel count:
db.pitch() to compute row offsets — do not assume pitch == width * (bpp / 8).
Mapping the buffer and writing pixel data
map_dumb_buffer maps the buffer into the current process’s address space and returns a DumbMapping that holds the mmap region for the lifetime of the object:
DumbMapping implements AsRef<[u8]> and AsMut<[u8]> for read/write slice access, as well as Deref<Target = [u8]> and DerefMut, so you can use it anywhere a byte slice is expected.
Writing a specific pixel at coordinates (x, y) in XRGB8888 format:
Creating a framebuffer from a dumb buffer
ADumbBuffer alone cannot be displayed. You must wrap it in a framebuffer object that the DRM kernel subsystem can attach to a CRTC or plane:
The
depth and bpp parameters to add_framebuffer are separate concepts:bpp(bits per pixel) is the total storage width of one pixel, including unused bits. ForXrgb8888this is 32.depthis the number of bits actually used for colour information. ForXrgb8888, the X channel carries no colour, so depth is 24.
depth=24, bpp=32 for Xrgb8888. Using mismatched values will cause the kernel to reject the framebuffer with EINVAL.Passing the framebuffer to modesetting
With the framebuffer handle in hand, you can pass it toset_crtc (legacy) or include it in an AtomicModeReq (atomic):
Cleaning up
Destroy the framebuffer object first, then the dumb buffer:Card without explicitly destroying these objects will leak them in the kernel until the file descriptor is closed (at which point the kernel reclaims them automatically).
DumbBuffer API reference
DumbBuffer implements the drm::buffer::Buffer trait and exposes:
| Method | Return type | Description |
|---|---|---|
size() | (u32, u32) | Width and height of the buffer in pixels |
pitch() | u32 | Bytes per row, including alignment padding |
format() | DrmFourcc | The pixel format specified at creation time |
handle() | buffer::Handle | Raw GEM handle used by kernel ioctls |
db.pitch() as usize * db.size().1 as usize.
DumbMapping API:
| Trait / Method | Description |
|---|---|
AsRef<[u8]> | Immutable byte-slice view of the mapped region |
AsMut<[u8]> | Mutable byte-slice view of the mapped region |
Deref<Target=[u8]> | Auto-deref to &[u8] |
DerefMut | Auto-deref to &mut [u8] |
Drop | Calls munmap on the region automatically |