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.
BufferObjectFlags is a bitflags type passed to buffer and surface creation methods to describe the intended uses of a GBM buffer. The combination of flags you provide tells the GBM backend which memory placement, tiling strategy, and hardware paths it must support. Choosing flags that the driver cannot satisfy will cause allocation to fail, so you should always call Device::is_format_supported to validate a format-and-flags pair before creating a buffer.
Type Definition
BufferObjectFlags is built with the bitflags crate. It derives Hash, PartialEq, Eq, PartialOrd, Ord, Clone, Copy, and Debug. When the serde feature is enabled it also derives Serialize and Deserialize (as a transparent u32).
Flags
SCANOUT
drmModeAddFB or equivalent.
CURSOR
CURSOR_64X64.
RENDERING
WRITE
BufferObject::write(). This is guaranteed to work when combined with CURSOR, but the outcome is driver-dependent for other flag combinations. If you need general CPU access, prefer BufferObject::map_mut().
LINEAR
SCANOUT, this may constrain display bandwidth on tiling-capable hardware.
PROTECTED
CURSOR_64X64 (deprecated)
CURSOR, kept for backwards compatibility. The numeric value is identical; use CURSOR in all new code.
Combining Flags
Flags are combined with the| operator. The result is still a BufferObjectFlags value:
Checking Format Support
Before allocating a buffer, verify that the driver supports the requested format-and-flags combination withDevice::is_format_supported:
Serde Support
When theserde feature is enabled in Cargo.toml, BufferObjectFlags implements Serialize and Deserialize as a transparent u32:
Common flag combinations
The most common pairing for a traditional compositor is
| Use case | Recommended flags |
|---|---|
| Display scanout (KMS) | SCANOUT |
| GPU rendering target | RENDERING |
| Scanout + EGL/Vulkan rendering | SCANOUT | RENDERING |
| Hardware cursor with CPU updates | CURSOR | WRITE |
| Software / linear-access buffer | LINEAR |
| Secure encrypted video plane | SCANOUT | PROTECTED |
SCANOUT | RENDERING: the GPU renders into the buffer and the display controller scans it out directly, avoiding any copies.