Skip to main content

Crate drmkit_gbm

Crate drmkit_gbm 

Source
Expand description

GBM buffer allocation.

A thin layer over libgbm, in the shape the rest of drmkit expects: errors as a typed enum, formats as drmkit FourCCs, and a buffer that hands out the descriptor a scanout path needs.

GBM is how a GPU-rendered surface becomes something KMS can scan out. Where drmkit-dumb allocates plain linear memory the CPU writes, this asks the driver for memory its renderer can target — which on real hardware means tiled or compressed layouts, and a modifier saying which.

On a driver with no render engine the drm backend falls back to dumb allocation, so this still works against vkms: linear, one plane, and a dma-buf that exports. That is what makes it testable without a GPU.

§libgbm is opened, not linked

The library is loaded on the first GbmDevice, so building needs no libgbm at all and a machine without one gets GbmError::NotGbmCapable rather than a binary that will not start. Which modifier entry points it has is read there too, so one build runs against Mesa and against a vendor libgbm that predates gbm_bo_create_with_modifiers2.

GbmDevice::from_fd takes any DRM descriptor. With the default drmkit-core feature off, that is the only way in, and this crate needs nothing of drmkit’s.

Structs§

GbmBuffer
A GBM buffer: one this crate allocated, or one locked from a GbmSurface.
GbmDevice
A GBM allocator bound to a DRM device.
GbmSurface
A GBM swap chain: what a GL or Vulkan producer renders into, and what the scene locks finished frames out of.

Enums§

GbmError
What went wrong allocating or exporting.
MapAccess
How a CPU mapping will be used.

Constants§

HIDE_ENV
Optional entry points to treat as missing, comma-separated, read once when libgbm is opened: DRMKIT_GBM_HIDE_SYMBOLS=gbm_bo_create_with_modifiers2, gbm_surface_create_with_modifiers2 is the SA8155P’s libgbm on a Mesa machine. For testing the older paths where the library is newer; a required entry point cannot be hidden, and naming one does nothing.