DmabufTextureBuilder


Object Hierarchy:

Gdk.DmabufTextureBuilder Gdk.DmabufTextureBuilder Gdk.DmabufTextureBuilder GLib.Object GLib.Object GLib.Object->Gdk.DmabufTextureBuilder

Description:

[ CCode ( type_id = "gdk_dmabuf_texture_builder_get_type ()" ) ]
[ Version ( since = "4.14" ) ]
public sealed class DmabufTextureBuilder : Object

`GdkDmabufTextureBuilder` is a builder used to construct [class@Gdk.

Texture] objects from DMA buffers.

DMA buffers are commonly called **_dma-bufs_**.

DMA buffers are a feature of the Linux kernel to enable efficient buffer and memory sharing between hardware such as codecs, GPUs, displays, cameras and the kernel drivers controlling them. For example, a decoder may want its output to be directly shared with the display server for rendering without a copy.

Any device driver which participates in DMA buffer sharing, can do so as either the exporter or importer of buffers (or both).

The memory that is shared via DMA buffers is usually stored in non-system memory (maybe in device's local memory or something else not directly accessible by the CPU), and accessing this memory from the CPU may have higher-than-usual overhead.

In particular for graphics data, it is not uncommon that data consists of multiple separate blocks of memory, for example one block for each of the red, green and blue channels. These blocks are called **_planes_**. DMA buffers can have up to four planes. Even if the memory is a single block, the data can be organized in multiple planes, by specifying offsets from the beginning of the data.

DMA buffers are exposed to user-space as file descriptors allowing to pass them between processes. If a DMA buffer has multiple planes, there is one file descriptor per plane.

The format of the data (for graphics data, essentially its colorspace) is described by a 32-bit integer. These format identifiers are defined in the header file `drm_fourcc.h` and commonly referred to as **_fourcc_** values, since they are identified by 4 ASCII characters. Additionally, each DMA buffer has a **_modifier_**, which is a 64-bit integer that describes driver-specific details of the memory layout, such as tiling or compression.

For historical reasons, some producers of dma-bufs don't provide an explicit modifier, but instead return `DMA_FORMAT_MOD_INVALID` to indicate that their modifier is **_implicit_**. GTK tries to accommodate this situation by accepting `DMA_FORMAT_MOD_INVALID` as modifier.

The operation of `GdkDmabufTextureBuilder` is quite simple: Create a texture builder, set all the necessary properties, and then call [ method@Gdk.DmabufTextureBuilder.build] to create the new texture.

The required properties for a dma-buf texture are

* The width and height in pixels

* The `fourcc` code and `modifier` which identify the format and memory layout of the dma-buf

* The file descriptor, offset and stride for each of the planes

`GdkDmabufTextureBuilder` can be used for quick one-shot construction of textures as well as kept around and reused to construct multiple textures.

For further information, see

* The Linux kernel documentation

* The header file drm_fourcc.h


Namespace: Gdk
Package: gtk4

Content:

Properties:

Creation methods:

Methods:

Inherited Members: