Top Description Fields Constructors Methods
org.lwjgl.vulkan

public Class EXTImageDrmFormatModifier

extends Object
Class Inheritance
Imports
org.lwjgl.system.*

This extension provides the ability to use DRM format modifiers with images, enabling Vulkan to better integrate with the Linux ecosystem of graphics, video, and display APIs.

Its functionality closely overlaps with EGL_EXT_image_dma_buf_import_modifiers2 and EGL_MESA_image_dma_buf_export3. Unlike the EGL extensions, this extension does not require the use of a specific handle type (such as a dma_buf) for external memory and provides more explicit control of image creation.

Introduction to DRM Format Modifiers

A DRM format modifier is a 64-bit, vendor-prefixed, semi-opaque unsigned integer. Most modifiers represent a concrete, vendor-specific tiling format for images. Some exceptions are DRM_FORMAT_MOD_LINEAR (which is not vendor-specific); DRM_FORMAT_MOD_NONE (which is an alias of DRM_FORMAT_MOD_LINEAR due to historical accident); and DRM_FORMAT_MOD_INVALID (which does not represent a tiling format). The modifier’s vendor prefix consists of the 8 most significant bits. The canonical list of modifiers and vendor prefixes is found in drm_fourcc.h in the Linux kernel source. The other dominant source of modifiers are vendor kernel trees.

One goal of modifiers in the Linux ecosystem is to enumerate for each vendor a reasonably sized set of tiling formats that are appropriate for images shared across processes, APIs, and/or devices, where each participating component may possibly be from different vendors. A non-goal is to enumerate all tiling formats supported by all vendors. Some tiling formats used internally by vendors are inappropriate for sharing; no modifiers should be assigned to such tiling formats.

Modifier values typically do not describe memory layouts. More precisely, a modifier's lower 56 bits usually have no structure. Instead, modifiers name memory layouts; they name a small set of vendor-preferred layouts for image sharing. As a consequence, in each vendor namespace the modifier values are often sequentially allocated starting at 1.

Each modifier is usually supported by a single vendor and its name matches the pattern {VENDOR}_FORMAT_MOD_* or DRM_FORMAT_MOD_{VENDOR}_*. Examples are I915_FORMAT_MOD_X_TILED and DRM_FORMAT_MOD_BROADCOM_VC4_T_TILED. An exception is DRM_FORMAT_MOD_LINEAR, which is supported by most vendors.

Many APIs in Linux use modifiers to negotiate and specify the memory layout of shared images. For example, a Wayland compositor and Wayland client may, by relaying modifiers over the Wayland protocol zwp_linux_dmabuf_v1, negotiate a vendor-specific tiling format for a shared wl_buffer. The client may allocate the underlying memory for the wl_buffer with GBM, providing the chosen modifier to gbm_bo_create_with_modifiers. The client may then import the wl_buffer into Vulkan for producing image content, providing the resource’s dma_buf to VkImportMemoryFdInfoKHR and its modifier to VkImageDrmFormatModifierExplicitCreateInfoEXT. The compositor may then import the wl_buffer into OpenGL for sampling, providing the resource’s dma_buf and modifier to eglCreateImage. The compositor may also bypass OpenGL and submit the wl_buffer directly to the kernel’s display API, providing the dma_buf and modifier through drm_mode_fb_cmd2.

Format Translation

Modifier-capable APIs often pair modifiers with DRM formats, which are defined in drm_fourcc.h. However, VK_EXT_image_drm_format_modifier uses VkFormat instead of DRM formats. The application must convert between VkFormat and DRM format when it sends or receives a DRM format to or from an external API.

The mapping from VkFormat to DRM format is lossy. Therefore, when receiving a DRM format from an external API, often the application must use information from the external API to accurately map the DRM format to a VkFormat. For example, DRM formats do not distinguish between RGB and sRGB (as of 2018-03-28); external information is required to identify the image’s color space.

The mapping between VkFormat and DRM format is also incomplete. For some DRM formats there exist no corresponding Vulkan format, and for some Vulkan formats there exist no corresponding DRM format.

Usage Patterns

Three primary usage patterns are intended for this extension:

Prior Art

Extension EGL_EXT_image_dma_buf_import1 introduced the ability to create an EGLImage by importing for each plane a dma_buf, offset, and row pitch.

Later, extension EGL_EXT_image_dma_buf_import_modifiers2 introduced the ability to query which combination of formats and modifiers the implementation supports and to specify modifiers during creation of the EGLImage.

Extension EGL_MESA_image_dma_buf_export3 is the inverse of EGL_EXT_image_dma_buf_import_modifiers.

The Linux kernel modesetting API (KMS), when configuring the display’s framebuffer with struct drm_mode_fb_cmd24, allows one to specify the framebuffer’s modifier as well as a per-plane memory handle, offset, and row pitch.

GBM, a graphics buffer manager for Linux, allows creation of a gbm_bo (that is, a graphics buffer object) by importing data similar to that in EGL_EXT_image_dma_buf_import_modifiers1; and symmetrically allows exporting the same data from the gbm_bo. See the references to modifier and plane in gbm.h5.

VK_EXT_image_drm_format_modifier
Name String
VK_EXT_image_drm_format_modifier
Extension Type
Device extension
Registered Extension Number
159
Revision
2
Extension and Version Dependencies
VK_KHR_bind_memory2          and          VK_KHR_get_physical_device_properties2          and          VK_KHR_sampler_ycbcr_conversion      or      Version 1.1 and      VK_KHR_image_format_list      or      Version 1.2
Contact
Other Extension Metadata
Last Modified Date
2021-09-30
IP Status
No known IP claims.
Contributors
  • Antoine Labour, Google
  • Bas Nieuwenhuizen, Google
  • Lina Versace, Google
  • James Jones, NVIDIA
  • Faith Ekstrand, Intel
  • Jőrg Wagner, ARM
  • Kristian Høgsberg Kristensen, Google
  • Ray Smith, ARM

Field Summary

Modifier and TypeField and Description
public static final int
public static final String
public static final int
VK_EXT_IMAGE_DRM_FORMAT_MODIFIER_SPEC_VERSION

The extension specification version.

public static final int
VK_IMAGE_ASPECT_MEMORY_PLANE_0_BIT_EXT

Extends VkImageAspectFlagBits.

public static final int
VK_IMAGE_ASPECT_MEMORY_PLANE_1_BIT_EXT

Extends VkImageAspectFlagBits.

public static final int
VK_IMAGE_ASPECT_MEMORY_PLANE_2_BIT_EXT

Extends VkImageAspectFlagBits.

public static final int
VK_IMAGE_ASPECT_MEMORY_PLANE_3_BIT_EXT

Extends VkImageAspectFlagBits.

public static final int
public static final int
public static final int
public static final int
public static final int
public static final int
public static final int

Constructor Summary

AccessConstructor and Description
protected

Method Summary

Modifier and TypeMethod and Description
public static int
nvkGetImageDrmFormatModifierPropertiesEXT(VkDevice device, long image, long pProperties)

Unsafe version of: GetImageDrmFormatModifierPropertiesEXT

public static int
vkGetImageDrmFormatModifierPropertiesEXT(VkDevice
the logical device that owns the image.
device
,
long
the queried image.
image
,
VkImageDrmFormatModifierPropertiesEXT
a pointer to a VkImageDrmFormatModifierPropertiesEXT structure in which properties of the image’s DRM format modifier are returned.
pProperties
)

Returns an image’s DRM format modifier.

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

VK_ERROR_INVALID_DRM_FORMAT_MODIFIER_PLANE_LAYOUT_EXTback to summary
public static final int VK_ERROR_INVALID_DRM_FORMAT_MODIFIER_PLANE_LAYOUT_EXT

Extends VkResult.

VK_EXT_IMAGE_DRM_FORMAT_MODIFIER_EXTENSION_NAMEback to summary
public static final String VK_EXT_IMAGE_DRM_FORMAT_MODIFIER_EXTENSION_NAME

The extension name.

VK_EXT_IMAGE_DRM_FORMAT_MODIFIER_SPEC_VERSIONback to summary
public static final int VK_EXT_IMAGE_DRM_FORMAT_MODIFIER_SPEC_VERSION

The extension specification version.

VK_IMAGE_ASPECT_MEMORY_PLANE_0_BIT_EXTback to summary
public static final int VK_IMAGE_ASPECT_MEMORY_PLANE_0_BIT_EXT

Extends VkImageAspectFlagBits.

Enum values:
VK_IMAGE_ASPECT_MEMORY_PLANE_1_BIT_EXTback to summary
public static final int VK_IMAGE_ASPECT_MEMORY_PLANE_1_BIT_EXT

Extends VkImageAspectFlagBits.

Enum values:
VK_IMAGE_ASPECT_MEMORY_PLANE_2_BIT_EXTback to summary
public static final int VK_IMAGE_ASPECT_MEMORY_PLANE_2_BIT_EXT

Extends VkImageAspectFlagBits.

Enum values:
VK_IMAGE_ASPECT_MEMORY_PLANE_3_BIT_EXTback to summary
public static final int VK_IMAGE_ASPECT_MEMORY_PLANE_3_BIT_EXT

Extends VkImageAspectFlagBits.

Enum values:
VK_IMAGE_TILING_DRM_FORMAT_MODIFIER_EXTback to summary
public static final int VK_IMAGE_TILING_DRM_FORMAT_MODIFIER_EXT

Extends VkImageTiling.

VK_STRUCTURE_TYPE_DRM_FORMAT_MODIFIER_PROPERTIES_LIST_2_EXTback to summary
public static final int VK_STRUCTURE_TYPE_DRM_FORMAT_MODIFIER_PROPERTIES_LIST_2_EXT

Extends VkStructureType.

VK_STRUCTURE_TYPE_DRM_FORMAT_MODIFIER_PROPERTIES_LIST_EXTback to summary
public static final int VK_STRUCTURE_TYPE_DRM_FORMAT_MODIFIER_PROPERTIES_LIST_EXT

Extends VkStructureType.

Enum values:
VK_STRUCTURE_TYPE_IMAGE_DRM_FORMAT_MODIFIER_EXPLICIT_CREATE_INFO_EXTback to summary
public static final int VK_STRUCTURE_TYPE_IMAGE_DRM_FORMAT_MODIFIER_EXPLICIT_CREATE_INFO_EXT

Extends VkStructureType.

Enum values:
VK_STRUCTURE_TYPE_IMAGE_DRM_FORMAT_MODIFIER_LIST_CREATE_INFO_EXTback to summary
public static final int VK_STRUCTURE_TYPE_IMAGE_DRM_FORMAT_MODIFIER_LIST_CREATE_INFO_EXT

Extends VkStructureType.

Enum values:
VK_STRUCTURE_TYPE_IMAGE_DRM_FORMAT_MODIFIER_PROPERTIES_EXTback to summary
public static final int VK_STRUCTURE_TYPE_IMAGE_DRM_FORMAT_MODIFIER_PROPERTIES_EXT

Extends VkStructureType.

Enum values:
VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_IMAGE_DRM_FORMAT_MODIFIER_INFO_EXTback to summary
public static final int VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_IMAGE_DRM_FORMAT_MODIFIER_INFO_EXT

Extends VkStructureType.

Enum values:

Constructor Detail

EXTImageDrmFormatModifierback to summary
protected EXTImageDrmFormatModifier()

Method Detail

nvkGetImageDrmFormatModifierPropertiesEXTback to summary
public static int nvkGetImageDrmFormatModifierPropertiesEXT(VkDevice device, long image, long pProperties)

Unsafe version of: GetImageDrmFormatModifierPropertiesEXT

vkGetImageDrmFormatModifierPropertiesEXTback to summary
public static int vkGetImageDrmFormatModifierPropertiesEXT(VkDevice device, long image, VkImageDrmFormatModifierPropertiesEXT pProperties)

Returns an image’s DRM format modifier.

C Specification

If an image was created with IMAGE_TILING_DRM_FORMAT_MODIFIER_EXT, then the image has a Linux DRM format modifier. To query the modifier, call:


VkResult vkGetImageDrmFormatModifierPropertiesEXT(
    VkDevice                                    device,
    VkImage                                     image,
    VkImageDrmFormatModifierPropertiesEXT*      pProperties);
Valid Usage
Valid Usage (Implicit)
  • device must be a valid VkDevice handle
  • image must be a valid VkImage handle
  • pProperties must be a valid pointer to a VkImageDrmFormatModifierPropertiesEXT structure
  • image must have been created, allocated, or retrieved from device
Return Codes
On success, this command returns
On failure, this command returns
See Also

VkImageDrmFormatModifierPropertiesEXT

Parameters
device:VkDevice

the logical device that owns the image.

image:long

the queried image.

pProperties:VkImageDrmFormatModifierPropertiesEXT

a pointer to a VkImageDrmFormatModifierPropertiesEXT structure in which properties of the image’s DRM format modifier are returned.

Annotations
@NativeType:VkResult