gbm

package
v0.1.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Oct 25, 2026 License: MIT Imports: 8 Imported by: 0 modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Overview

Package gbm allocates GPU buffers for zero-copy screencast frames (wayle-share-preview dmabuf.rs): a gbm device on a DRM render node, buffer objects with a modifier the consumer takes, and their planes as dmabuf fds. libgbm is bound through purego, so the binary stays CGO_ENABLED=0. Everything here is best effort: any failure is an error the caller answers by staying on shared memory.

Index

Constants

View Source
const (
	ModInvalid uint64 = 0x00ffffffffffffff
	ModLinear  uint64 = 0
)

The DRM modifiers every allocator understands: implicit (the driver's choice) and linear.

Variables

View Source
var (
	FormatXRGB8888 = Fourcc('X', 'R', '2', '4')
	FormatARGB8888 = Fourcc('A', 'R', '2', '4')
	FormatXBGR8888 = Fourcc('X', 'B', '2', '4')
	FormatABGR8888 = Fourcc('A', 'B', '2', '4')
)

The packed formats screencopy hands out.

View Source
var RenderNodes = []string{"/dev/dri/renderD128", "/dev/dri/renderD129", "/dev/dri/renderD130"}

RenderNodes are the DRM render nodes tried in order: unprivileged, and the right device for offscreen allocation.

Functions

func Fourcc

func Fourcc(a, b, c, d byte) uint32

Fourcc builds a DRM fourcc code.

func ModifierCandidates

func ModifierCandidates(advertised []uint64) []uint64

ModifierCandidates is the order modifiers are tried in: the consumer's, then implicit and linear, which every driver takes.

Types

type Buffer

type Buffer struct {
	Width, Height uint32
	Fourcc        uint32
	Modifier      uint64
	Planes        []Plane
	// contains filtered or unexported fields
}

Buffer is one allocated buffer object and its exported planes; the plane fds stay open until Release.

func (*Buffer) Release

func (b *Buffer) Release()

Release closes the plane fds and frees the buffer object.

type Device

type Device struct {
	// contains filtered or unexported fields
}

Device is a gbm device on an open render node.

func Open

func Open() (*Device, error)

Open opens a gbm device on the first render node that takes one.

func (*Device) Alloc

func (d *Device) Alloc(fourcc, width, height uint32, modifiers []uint64) (*Buffer, error)

Alloc allocates a width x height buffer in the DRM fourcc, with the first candidate modifier the driver takes, else the driver's own choice.

func (*Device) Close

func (d *Device) Close()

Close destroys the device; its buffers must be released first.

type Plane

type Plane struct {
	Fd             int
	Offset, Stride uint32
}

Plane is one plane of a buffer as a dmabuf.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL