Skip to main content
Version: 14 Oct 2024

Graphics Utilities

Optional graphics utility functionality. More...

Classes

Name
structMLGraphicsImportedMediaSurface
Handles to and information about an imported surface.
structMLMeshingVirtualCameraBufferInfo
Per virtual camera information needed to render depth.
structMLMeshingDepthBufferInfo
To be passed to PopulateDepth.

Types

Name
typedef struct MLGraphicsImportedMediaSurfaceMLGraphicsImportedMediaSurface
Handles to and information about an imported surface.
typedef struct MLMeshingVirtualCameraBufferInfoMLMeshingVirtualCameraBufferInfo
Per virtual camera information needed to render depth.
typedef struct MLMeshingDepthBufferInfoMLMeshingDepthBufferInfo
To be passed to PopulateDepth.

Enums

Name
enumMLMeshingPopulateDepthFlags
{
MLMeshingPopulateDepthFlags_None,
MLMeshingPopulateDepthFlags_EnableVisualization,
MLMeshingPopulateDepthFlags_Ensure32Bits = 0x7FFFFFFF
}
Flags for MLMeshingDepthBufferInfo.

Functions

Name
MLResultMLGraphicsEnumerateRequiredVkDeviceExtensionsForMediaHandleImport(VkExtensionProperties out_required_extension_properties, uint32_t out_extension_property_count)
Returns a list of required VkDevice extension names.
MLResultMLGraphicsImportVkImageFromMediaHandle(const VkDevice vulkan_logical_device, uint64_t media_handle, MLGraphicsImportedMediaSurface * out_imported_surface_info)
Import a surface as a VkImage from a media api handle.
MLResultMLMeshingPopulateDepth(MLHandle client_handle, const MLMeshingDepthBufferInfo info, const MLMeshingMesh meshes)
Populates the depth buffer (passed as a Texture2D array) with the meshes given by a user. It has to be called after MLGraphicsBeginFrame which provides the handles for the depth/color buffers.

Detailed Description

Optional graphics utility functionality.

  • The graphics utility library is not necessary to create an application using the ML SDK. It contains a collection of useful code that can optionally be used to make development easier.
Warning

THIS API IS DEPRECATED IN FAVOR OF OPENXR APIs: https://registry.khronos.org/OpenXR/specs/1.0/html/xrspec.html

Attention

EXPERIMENTAL.

Shared Object:

  • graphics_utils.magicleap*

Enums Documentation

MLMeshingPopulateDepthFlags

EnumeratorValueDescription
MLMeshingPopulateDepthFlags_NoneNone.
MLMeshingPopulateDepthFlags_EnableVisualizationIf set, will fill the color buffer.
MLMeshingPopulateDepthFlags_Ensure32Bits0x7FFFFFFFEnsure enum is represented as 32 bits.

Flags for MLMeshingDepthBufferInfo.

Deprecated

Deprecated since 1.2.0. Scheduled for removal.


Types Documentation

MLGraphicsImportedMediaSurface

typedef struct MLGraphicsImportedMediaSurface MLGraphicsImportedMediaSurface;

Handles to and information about an imported surface.

Populated by MLGraphicsImportVkImageFromMediaHandle. Provides all information, necessary for creating a VkImageView and VkSampler for the imported surface.

Refer to the Vulkan specification's equivalent parameters in VkAndroidHardwareBufferFormatPropertiesANDROID. Also refer to usage of VkExternalFormatANDROID and VkSamplerYcbcrConversionCreateInfo.

More Info

Deprecated

Deprecated since 1.6.0. Scheduled for removal.


MLMeshingVirtualCameraBufferInfo

typedef struct MLMeshingVirtualCameraBufferInfo MLMeshingVirtualCameraBufferInfo;

Per virtual camera information needed to render depth.

More Info

Deprecated

Deprecated since 1.2.0. Scheduled for removal.


MLMeshingDepthBufferInfo

typedef struct MLMeshingDepthBufferInfo MLMeshingDepthBufferInfo;

To be passed to PopulateDepth.

More Info

Deprecated

Deprecated since 1.2.0. Scheduled for removal.


Functions Documentation

MLGraphicsEnumerateRequiredVkDeviceExtensionsForMediaHandleImport

MLResult MLGraphicsEnumerateRequiredVkDeviceExtensionsForMediaHandleImport(
VkExtensionProperties * out_required_extension_properties,
uint32_t * out_extension_property_count
)

Returns a list of required VkDevice extension names.

Parameters

VkExtensionProperties *out_required_extension_propertiesEither NULL or a pointer to an array of VkExtensionProperties.
uint32_t *out_extension_property_countA pointer to an integer related to the number of extensions required or queried.

Returns

MLResultMLResult_InvalidParamThe query failed due to an invalid parameter.
MLResultMLResult_OkThe list of extensions or number of required extensions was returned successfully.

Required Permissions:

  • None

If out_required_extension_properties is NULL then the number of required extension is returned in out_extension_property_count. Otherwise, out_extension_property_count must point to a variable set to the number of elements in the out_required_extension_properties array, and on return the variable is overwritten with the number of strings actually written to out_required_extension_properties.

Deprecated

Deprecated since 1.6.0. Scheduled for removal.


MLGraphicsImportVkImageFromMediaHandle

MLResult MLGraphicsImportVkImageFromMediaHandle(
const VkDevice vulkan_logical_device,
uint64_t media_handle,
MLGraphicsImportedMediaSurface * out_imported_surface_info
)

Import a surface as a VkImage from a media api handle.

Parameters

const VkDevicevulkan_logical_deviceThe Vulkan logical device to use for resource creation.
uint64_tmedia_handleThe media api handle referring to the surface to import.
MLGraphicsImportedMediaSurface *out_imported_surface_infoA struct containing the resulting resource handles and information for sampler creation.

Returns

MLResultMLResult_InvalidParamImport was not performed due to an invalid parameter.
MLResultMLResult_OkSurface was imported successfully.
MLResultMLResult_UnspecifiedFailureImport was not performed due to an unknown error.

Required Permissions:

  • None

Creates VkImage and VkDeviceMemory objects refrencing a surface referred to by a handle obtained from a media API. The resulting image will be owned by the VkDevice provided.This VkDevice must be created with the extensions specified by MLGraphicsEnumerateRequiredVkDeviceExtensionsForMediaHandleImport enabled. This call does not depend on a Graphics Client and can be used independent of other graphics APIs.

Deprecated

Deprecated since 1.6.0. Scheduled for removal.


MLMeshingPopulateDepth

MLResult MLMeshingPopulateDepth(
MLHandle client_handle,
const MLMeshingDepthBufferInfo * info,
const MLMeshingMesh * meshes
)

Populates the depth buffer (passed as a Texture2D array) with the meshes given by a user. It has to be called after MLGraphicsBeginFrame which provides the handles for the depth/color buffers.

Parameters

MLHandleclient_handleThe handle to the created client.
const MLMeshingDepthBufferInfo *infoThe per virtual camera info for rendering depth.
const MLMeshingMesh *meshesThe meshes for which the depth info needs to be populated.

Returns

MLResultMLResult_InvalidParamDepth buffers were not populated due to an invalid parameter.
MLResultMLResult_OkDepth buffer was populated successfully.

Required Permissions:

  • None
Deprecated

Deprecated since 1.2.0. Scheduled for removal.