buffer

Header: kmsroots/buffer.h

Table of contents (click to go)

Macros

Enums

  1. kmr_buffer_type

Unions

Structs

  1. kmr_buffer_object

  2. kmr_buffer

  3. kmr_buffer_create_info

Functions

  1. kmr_buffer_create()

  2. kmr_buffer_destroy()

Function Pointers

API Documentation

kmr_buffer_type

enum kmr_buffer_type
KMR_BUFFER_DUMP_BUFFER
KMR_BUFFER_GBM_BUFFER
KMR_BUFFER_GBM_BUFFER_WITH_MODIFIERS
KMR_BUFFER_MAX_TYPE

Buffer allocation options used by kmr_buffer_create()

KMR_BUFFER_DUMP_BUFFER
Value set to 0
KMR_BUFFER_GBM_BUFFER
Value set to 1
KMR_BUFFER_GBM_BUFFER_WITH_MODIFIERS
Value set to 2
KMR_BUFFER_MAX_TYPE
Value set to 3

kmr_buffer_object

struct kmr_buffer_object
struct gbm_bo *bo;
unsigned fbid;
unsigned format;
uint64_t modifier;
unsigned planeCount;
unsigned pitches[4];
unsigned offsets[4];
int dmaBufferFds[4];
int kmsfd;

More information can be found at DrmMode

bo
Handle to some GEM allocated buffer. Used to get GEM handles, DMA buffer fds
(fd associate with GEM buffer), pitches, and offsets for the buffer used by
DRI device (GPU)
fbid
Framebuffer ID
format
The format of an image details how each pixel color channels is laid out in
memory: (i.e. RAM, VRAM, etc…). So, basically the width in bits, type, and
ordering of each pixels color channels.
modifier
The modifier details information on how pixels should be within a buffer for different types
operations such as scan out or rendering. (i.e linear, tiled, compressed, etc…)
planeCount
Number of Planar Formats. The number of dmaBufferFds, offsets, pitches
retrieved per plane. More information can be found : Planar Formats
pitches
width in bytes for each plane
offsets
offset of each plane
dmaBufferFds
(PRIME fd) Stores file descriptors to buffers that can be shared across hardware
kmsfd
File descriptor to open DRI device

kmr_buffer

struct kmr_buffer
struct gbm_device *gbmDevice;
unsigned int bufferCount;
struct kmr_buffer_object *bufferObjects;
gbmDevice
A handle used to allocate gbm buffers & surfaces
bufferCount
Array size of bufferObjects
bufferObjects
Stores an array of struct gbm_bo’s and corresponding information about
the individual buffer.

kmr_buffer_create_info

struct kmr_buffer_create_info
enum kmr_buffer_type bufferType;
unsigned int kmsfd;
unsigned int bufferCount;
unsigned int width;
unsigned int height;
unsigned int bitDepth;
unsigned int bitsPerPixel;
unsigned int gbmBoFlags;
unsigned int pixelFormat;
unsigned int modifierCount;
uint64_t *modifiers;
bufferType
Determines what type of buffer to allocate (i.e Dump Buffer, GBM buffer)
kmsfd
Used by gbm_create_device(). Must be a valid file descriptor
to a DRI device (GPU character device file)
bufferCount
The amount of buffers to allocate.
2 for double buffering
3 for triple buffering
width
Amount of pixels going width wise on screen. Need to allocate buffer of similar size.
height
Amount of pixels going height wise on screen. Need to allocate buffer of similar size.
bitDepth
bitsPerPixel
Pass the amount of bits per pixel
gbmBoFlags
Flags to indicate gbm_bo usage. More info here: gbm.h
pixelFormat
The format of an image details how each pixel color channels is laid out in
memory: (i.e. RAM, VRAM, etc…). So basically the width in bits, type, and
ordering of each pixels color channels.
modifierCount
Number of drm format modifiers passed
modifiers
List of drm format modifiers

kmr_buffer_create

struct kmr_buffer *kmr_buffer_create(struct kmr_buffer_create_info *bufferInfo);

Function creates multiple GPU buffers

Parameters:
bufferInfo
Pointer to a struct kmr_buffer_create_info
Returns:
on success: Pointer to a struct kmr_buffer
on failure: NULL

kmr_buffer_destroy

void kmr_buffer_destroy(struct kmr_buffer *buffer);

Frees any allocated memory and closes FD’s (if open) created after kmr_buffer_create() call.

Parameters:
buffer:
Must pass a valid pointer to a struct kmr_buffer
/* Free'd and file descriptors closed members */
struct kmr_buffer {
        struct gbm_device *gbmDevice;
        struct kmr_buffer_object *bufferObjects {
                struct gbm_bo *bo;
                unsigned dmaBufferFds[4];
                unsigned fbid;
        }
}