This page documents every method onDocumentation 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.
Device<T>, organized by category. Methods are grouped into four areas: backend queries (inspecting driver capabilities), buffer object creation (allocating GPU-visible memory), surface creation (allocating scanout-backed render targets), and buffer import (wrapping foreign buffers from Wayland, EGL, and DMA-BUF sources). For type-level documentation — struct definition, trait implementations, and the Device::new constructor — see Device.
Backend Queries
These methods interrogate the GBM backend and the underlying driver for capability and format information. They take&self and are inexpensive to call.
backend_name
"drm". The string is owned by the native library and lives for the duration of the device.
is_format_supported
format for the specified combination of usage flags. Always call this before allocating buffers with non-universal formats.
The DRM fourcc pixel format to test (re-exported from
drm_fourcc as
DrmFourcc). For example Format::Argb8888 or Format::Xrgb8888.A bitfield of intended usages such as
SCANOUT, RENDERING, WRITE, or
CURSOR. The query returns true only if all requested flags are satisfiable
together.format_modifier_plane_count
format and tiling modifier. Returns None when the combination does not have a defined or fixed plane count — for example when Modifier::Invalid is passed.
The DRM fourcc pixel format to query.
The DRM format modifier (re-exported from
drm_fourcc as DrmModifier)
representing a vendor-specific tiling layout. Pass Modifier::Linear for
linear layouts.Buffer Object Creation
Buffer objects (BufferObject<U>) are GPU-visible memory allocations. The U type parameter is a user-data slot — use () if you do not need to attach custom metadata. All creation methods return IoResult<BufferObject<U>>, propagating the OS errno on failure.
create_buffer_object
Width of the buffer in pixels.
Height of the buffer in pixels.
DRM fourcc pixel format for the allocation.
Intended usage flags. Common combinations:
SCANOUT | WRITE— CPU-writable scanout bufferSCANOUT | RENDERING— GPU-rendered scanout bufferCURSOR— hardware cursor plane buffer
create_buffer_object_with_modifiers
BufferObjectFlags — use create_buffer_object_with_modifiers2 when you need both modifiers and usage flags.
An iterator of acceptable DRM format modifiers. The driver selects the first
modifier from the list it supports. Commonly sourced from a compositor’s DMA-BUF
feedback or from
drmGetFormatModifierPlaneCount.create_buffer_object_with_modifiers2
BufferObjectFlags.
An iterator of acceptable DRM format modifiers.
Intended usage flags passed alongside the modifier hint.
Surface Creation
ASurface<U> wraps a GBM surface used as the backing store for an EGL window surface or similar render target. The API mirrors buffer object creation closely, with the same modifier-based variants.
create_surface
Width of the surface in pixels.
Height of the surface in pixels.
DRM fourcc pixel format for the surface buffers.
Intended usage flags for the surface’s buffer objects.
create_surface_with_modifiers
An iterator of acceptable DRM format modifiers for the surface’s backing
buffer objects.
create_surface_with_modifiers2
An iterator of acceptable DRM format modifiers.
Intended usage flags for the surface’s buffer objects.
Buffer Import
These methods import foreign buffer handles — from Wayland, EGL, or DMA-BUF — and wrap them in aBufferObject<U>. The resulting buffer object shares the underlying pixel memory with the foreign object but has an independent lifetime; dropping the BufferObject does not destroy the foreign buffer.
import_buffer_object_from_wayland
wl_buffer and wraps it as a GBM buffer object. This enables a Wayland compositor to hand a client-submitted buffer off to KMS for direct scanout without an extra copy.
This method is only available when the
import-wayland Cargo feature is
enabled:A reference to the Wayland buffer resource submitted by a client. Sourced
from the
wl_buffer protocol object via wayland-server.Intended usage flags for the imported buffer object. Typically
BufferObjectFlags::SCANOUT for direct scanout.import_buffer_object_from_egl
EGLImage, a *mut c_void) and wraps it as a GBM buffer object. Useful when an EGL renderer produces an EGLImage that needs to be scanned out via KMS.
Requires the
import-egl Cargo feature:A valid, non-null EGL image handle. The type alias
gbm::EGLImage is
*mut libc::c_void.Intended usage flags for the imported buffer object.
import_buffer_object_from_dma_buf
import_buffer_object_from_dma_buf_with_modifiers for multi-plane or modifier-aware imports.
A borrowed file descriptor referencing the DMA-BUF to import. The GBM
driver duplicates the fd internally; the caller retains ownership of the
original.
Width of the buffer in pixels.
Height of the buffer in pixels.
Row stride in bytes (bytes per scanline, including any padding).
DRM fourcc pixel format of the DMA-BUF data.
Intended usage flags for the imported buffer object.
import_buffer_object_from_dma_buf_with_modifiers
buffers array holds up to four plane file descriptors (None entries are passed to libgbm as -1). This is the correct import path for tiled formats such as NV12 and for any buffer whose modifier was negotiated via DMA-BUF feedback.
The number of valid (non-
None) planes present in buffers. Must be ≤ 4.An array of exactly four slots. Fill the first
len slots with the plane
file descriptors; set the remaining slots to None.Width of the buffer in pixels.
Height of the buffer in pixels.
DRM fourcc pixel format describing the multi-plane layout.
Intended usage flags for the imported buffer object.
Per-plane row strides in bytes. Unused plane slots should be set to
0.Per-plane byte offsets from the start of each DMA-BUF. Unused plane slots
should be set to
0.The DRM format modifier describing the tiling layout that applies to all
planes. Must match the modifier used when the buffer was originally
allocated.