vulkan_ohos.h
Overview
The file declares the Vulkan interfaces extended by OpenHarmony.
File to include: <vulkan/vulkan_ohos.h>
Library: libvulkan.so
Since: 10
Related module: Vulkan
Summary
Structs
| Name | typedef Keyword | Description |
|---|---|---|
| VkSurfaceCreateInfoOHOS | VkSurfaceCreateInfoOHOS | Describes the parameters required for creating a Vulkan surface. |
| VkNativeBufferOHOS | VkNativeBufferOHOS | Describes the parameters of the device memory. |
| VkSwapchainImageCreateInfoOHOS | VkSwapchainImageCreateInfoOHOS | Describes the parameters required for creating an image. |
| VkPhysicalDevicePresentationPropertiesOHOS | VkPhysicalDevicePresentationPropertiesOHOS | Describes the parameters of the device display properties. |
| VkNativeBufferUsageOHOS | VkNativeBufferUsageOHOS | Describes the usage of the NativeBuffer. |
| VkNativeBufferPropertiesOHOS | VkNativeBufferPropertiesOHOS | Describes the properties of the NativeBuffer. |
| VkNativeBufferFormatPropertiesOHOS | VkNativeBufferFormatPropertiesOHOS | Describes the format properties of the NativeBuffer. |
| VkImportNativeBufferInfoOHOS | VkImportNativeBufferInfoOHOS | Describes the pointer to an OH_NativeBuffer struct. |
| VkMemoryGetNativeBufferInfoOHOS | VkMemoryGetNativeBufferInfoOHOS | Used to obtain an OH_NativeBuffer from the Vulkan memory. |
| VkExternalFormatOHOS | VkExternalFormatOHOS | Describes an externally defined format. |
| NativeWindow | OHNativeWindow | Describes a native window. |
| OHBufferHandle | - | Describes the buffer handle, which is used to transfer and obtain buffer information. |
| OH_NativeBuffer | - | Describes the OH_NativeBuffer struct. |
Enums
| Name | typedef Keyword | Description |
|---|---|---|
| VkSwapchainImageUsageFlagBitsOHOS | VkSwapchainImageUsageFlagBitsOHOS | Enumerates the image usage flags. |
Macros
| Name | Description |
|---|---|
| VK_OHOS_surface 1 | Surface extension macro definition of OpenHarmony. Since: 10 |
| VK_OHOS_SURFACE_SPEC_VERSION 1 | Surface extension version of OpenHarmony. Since: 10 |
| VK_OHOS_SURFACE_EXTENSION_NAME "VK_OHOS_surface" | Surface extension name of OpenHarmony. Since: 10 |
| VK_OHOS_native_buffer 1 | native_buffer extension macro definition. Since: 10 |
| VK_OHOS_NATIVE_BUFFER_SPEC_VERSION 1 | native_buffer extension version. Since: 10 |
| VK_OHOS_NATIVE_BUFFER_EXTENSION_NAME "VK_OHOS_native_buffer" | native_buffer extension name. Since: 10 |
| VK_OHOS_external_memory 1 | External memory extension macro definition of OpenHarmony. Since: 10 |
| VK_OHOS_EXTERNAL_MEMORY_SPEC_VERSION 1 | External memory extension version of OpenHarmony. Since: 10 |
| VK_OHOS_EXTERNAL_MEMORY_EXTENSION_NAME "VK_OHOS_external_memory" | External memory extension name of OpenHarmony. Since: 10 |
Functions
Enum Description
VkSwapchainImageUsageFlagBitsOHOS
enum VkSwapchainImageUsageFlagBitsOHOS
Description
Enumerates the image usage flags.
Since: 10
| Value | Description |
|---|---|
| VK_SWAPCHAIN_IMAGE_USAGE_SHARED_BIT_OHOS = 0x00000001 | Shared image flag. |
| VK_SWAPCHAIN_IMAGE_USAGE_FLAG_BITS_MAX_ENUM_OHOS = 0x7FFFFFFF | Maximum value. |
Function Description
PFN_vkCreateSurfaceOHOS()
typedef VkResult (VKAPI_PTR *PFN_vkCreateSurfaceOHOS)(VkInstance instance, const VkSurfaceCreateInfoOHOS* pCreateInfo, const VkAllocationCallbacks* pAllocator, VkSurfaceKHR* pSurface)
Description
Defines the function pointer for creating a Vulkan surface.
System capability: SystemCapability.Graphic.Vulkan
Since: 10
Parameters
| Name | Description |
|---|---|
| VkInstance instance | Vulkan instance. |
| const VkSurfaceCreateInfoOHOS* pCreateInfo | Pointer to the VkSurfaceCreateInfoOHOS struct, including the parameters required for creating a Vulkan surface. |
| const VkAllocationCallbacks* pAllocator | Pointer to a callback function for custom memory allocation. If custom memory allocation is not required, pass in NULL, and the default memory allocation function is used. |
| VkSurfaceKHR* pSurface | Pointer to the Vulkan surface created. The type is VkSurfaceKHR. |
Returns
| Type | Description |
|---|---|
| VkResult | VK_SUCCESS. If the operation fails, an error code of the VkResult type is returned. |
vkCreateSurfaceOHOS()
VKAPI_ATTR VkResult VKAPI_CALL vkCreateSurfaceOHOS(VkInstance instance, const VkSurfaceCreateInfoOHOS* pCreateInfo, const VkAllocationCallbacks* pAllocator, VkSurfaceKHR* pSurface)
Description
Creates a Vulkan surface.
System capability: SystemCapability.Graphic.Vulkan
Since: 10
Parameters
| Name | Description |
|---|---|
| VkInstance instance | Vulkan instance. |
| const VkSurfaceCreateInfoOHOS* pCreateInfo | Pointer to the VkSurfaceCreateInfoOHOS struct, including the parameters required for creating a Vulkan surface. |
| const VkAllocationCallbacks* pAllocator | Pointer to a callback function for custom memory allocation. If custom memory allocation is not required, pass in NULL, and the default memory allocation function is used. |
| VkSurfaceKHR* pSurface | Pointer to the Vulkan surface created. The type is VkSurfaceKHR. |
Returns
| Type | Description |
|---|---|
| VkResult | One of the following error codes of the VkResult type: VK_SUCCESS: The operation is successful. VK_ERROR_OUT_OF_HOST_MEMORY: The VkSurfaceKHR memory fails to be allocated. VK_ERROR_SURFACE_LOST_KHR: The NativeWindow operation fails. |
PFN_vkGetNativeBufferPropertiesOHOS()
typedef VkResult (VKAPI_PTR *PFN_vkGetNativeBufferPropertiesOHOS)(VkDevice device, const struct OH_NativeBuffer* buffer, VkNativeBufferPropertiesOHOS* pProperties)
Description
Defines a function pointer used to obtain OH_NativeBuffer properties.
System capability: SystemCapability.Graphic.Vulkan
Since: 10
Parameters
| Name | Description |
|---|---|
| VkDevice device | VkDevice object. |
| const struct OH_NativeBuffer* buffer | Pointer to an OH_NativeBuffer struct. |
| VkNativeBufferPropertiesOHOS* pProperties | Pointer to the struct holding the properties of OH_NativeBuffer. |
Returns
| Type | Description |
|---|---|
| VkResult | VK_SUCCESS. If the operation fails, an error code of the VkResult type is returned. |
PFN_vkGetMemoryNativeBufferOHOS()
typedef VkResult (VKAPI_PTR *PFN_vkGetMemoryNativeBufferOHOS)(VkDevice device, const VkMemoryGetNativeBufferInfoOHOS* pInfo, struct OH_NativeBuffer** pBuffer)
Description
Defines a function pointer used to obtain an OH_NativeBuffer instance.
System capability: SystemCapability.Graphic.Vulkan
Since: 10
Parameters
| Name | Description |
|---|---|
| VkDevice device | VkDevice object. |
| const VkMemoryGetNativeBufferInfoOHOS* pInfo | Pointer to a VkMemoryGetNativeBufferInfoOHOS struct. |
| struct OH_NativeBuffer** pBuffer | Pointer to the OH_NativeBuffer obtained. |
Returns
| Type | Description |
|---|---|
| VkResult | VK_SUCCESS. If the operation fails, an error code of the VkResult type is returned. |
vkGetNativeBufferPropertiesOHOS()
VKAPI_ATTR VkResult VKAPI_CALL vkGetNativeBufferPropertiesOHOS(VkDevice device, const struct OH_NativeBuffer* buffer, VkNativeBufferPropertiesOHOS* pProperties)
Description
Obtains the properties of an OH_NativeBuffer instance.
System capability: SystemCapability.Graphic.Vulkan
Since: 10
Parameters
| Name | Description |
|---|---|
| VkDevice device | VkDevice object. |
| const struct OH_NativeBuffer* buffer | Pointer to an OH_NativeBuffer struct. |
| VkNativeBufferPropertiesOHOS* pProperties | Pointer to the struct holding the properties of OH_NativeBuffer. |
Returns
| Type | Description |
|---|---|
| VkResult | One of the following error codes of the VkResult type: VK_SUCCESS: The operation is successful. VK_ERROR_INVALID_EXTERNAL_HANDLE_KHR: An input parameter is abnormal. VK_ERROR_OUT_OF_DEVICE_MEMORY: The device memory is insufficient. |
vkGetMemoryNativeBufferOHOS()
VKAPI_ATTR VkResult VKAPI_CALL vkGetMemoryNativeBufferOHOS(VkDevice device, const VkMemoryGetNativeBufferInfoOHOS* pInfo, struct OH_NativeBuffer** pBuffer)
Description
Obtains an OH_NativeBuffer instance.
System capability: SystemCapability.Graphic.Vulkan
Since: 10
Parameters
| Name | Description |
|---|---|
| VkDevice device | VkDevice object. |
| const VkMemoryGetNativeBufferInfoOHOS* pInfo | Pointer to a VkMemoryGetNativeBufferInfoOHOS struct. |
| struct OH_NativeBuffer** pBuffer | Pointer to the OH_NativeBuffer obtained. |
Returns
| Type | Description |
|---|---|
| VkResult | One of the following error codes of the VkResult type: VK_SUCCESS: The operation is successful. VK_ERROR_OUT_OF_HOST_MEMORY: The input parameter pInfo is abnormal or the obtained pBuffer is abnormal. |
vkGetSwapchainGrallocUsageOHOS()
VKAPI_ATTR VkResult VKAPI_CALL vkGetSwapchainGrallocUsageOHOS(VkDevice device, VkFormat format, VkImageUsageFlags imageUsage, uint64_t* grallocUsage)
Description
Returns the appropriate gralloc usage flag based on the given Vulkan device, image format, and image usage flag. As an application developer, you do not need to use this function.
System capability: SystemCapability.Graphic.Vulkan
Since: 10
Deprecated from: 23
Parameters
| Name | Description |
|---|---|
| VkDevice device | VkDevice object. |
| VkFormat format | Image format. |
| VkImageUsageFlags imageUsage | Image use flag. |
| uint64_t* grallocUsage | Pointer to the gralloc usage flag. |
Returns
| Type | Description |
|---|---|
| VkResult | One of the following error codes of the VkResult type: VK_SUCCESS: The operation is successful. VK_ERROR_INITIALIZATION_FAILED: An input parameter is abnormal. |
VKAPI_PTR *PFN_vkGetSwapchainGrallocUsageOHOS()
typedef VkResult (VKAPI_PTR *PFN_vkGetSwapchainGrallocUsageOHOS)(VkDevice device, VkFormat format, VkImageUsageFlags imageUsage, uint64_t* grallocUsage)
Description
Returns the appropriate gralloc usage flag based on the given Vulkan device, image format, and image usage flag. As an application developer, you do not need to use this function.
System capability: SystemCapability.Graphic.Vulkan
Since: 10
Deprecated from: 23
Parameters
| Name | Description |
|---|---|
| VkDevice device | VkDevice object. |
| VkFormat format | Image format. |
| VkImageUsageFlags imageUsage | Image use flag. |
| uint64_t* grallocUsage | Pointer to the gralloc usage flag. |
Returns
| Type | Description |
|---|---|
| VkResult | One of the following error codes of the VkResult type: VK_SUCCESS: The operation is successful. VK_ERROR_INITIALIZATION_FAILED: An input parameter is abnormal. |
vkAcquireImageOHOS()
VKAPI_ATTR VkResult VKAPI_CALL vkAcquireImageOHOS(VkDevice device, VkImage image, int32_t nativeFenceFd, VkSemaphore semaphore, VkFence fence)
Description
Obtains the ownership of the swap chain image and imports the fence of the external signal to the VkSemaphore and VkFence objects. As an application developer, you do not need to use this function.
System capability: SystemCapability.Graphic.Vulkan
Since: 10
Deprecated from: 23
Parameters
| Name | Description |
|---|---|
| VkDevice device | VkDevice object. |
| VkImage image | Vulkan image to obtain. |
| int32_t nativeFenceFd | File descriptor of the native fence. |
| VkSemaphore semaphore | Vulkan semaphore indicating that the image is available. |
| VkFence fence | Vulkan fence used for synchronization when the image acquisition is complete. |
Returns
| Type | Description |
|---|---|
| VkResult | One of the following error codes of the VkResult type: VK_SUCCESS: The operation is successful. VK_ERROR_OUT_OF_HOST_MEMORY: The host memory is insufficient. |
VKAPI_PTR *PFN_vkAcquireImageOHOS()
typedef VkResult (VKAPI_PTR *PFN_vkAcquireImageOHOS)(VkDevice device, VkImage image, int32_t nativeFenceFd, VkSemaphore semaphore, VkFence fence)
Description
Obtains the ownership of the swap chain image and imports the fence of the external signal to the VkSemaphore and VkFence objects. As an application developer, you do not need to use this function.
System capability: SystemCapability.Graphic.Vulkan
Since: 10
Deprecated from: 23
Parameters
| Name | Description |
|---|---|
| VkDevice device | VkDevice object. |
| VkImage image | Vulkan image to obtain. |
| int32_t nativeFenceFd | File descriptor of the native fence. |
| VkSemaphore semaphore | Vulkan semaphore indicating that the image is available. |
| VkFence fence | Vulkan fence used for synchronization when the image acquisition is complete. |
Returns
| Type | Description |
|---|---|
| VkResult | One of the following error codes of the VkResult type: VK_SUCCESS: The operation is successful. VK_ERROR_OUT_OF_HOST_MEMORY: The host memory is insufficient. |
vkQueueSignalReleaseImageOHOS()
VKAPI_ATTR VkResult VKAPI_CALL vkQueueSignalReleaseImageOHOS(VkQueue queue, uint32_t waitSemaphoreCount, const VkSemaphore* pWaitSemaphores, VkImage image, int32_t* pNativeFenceFd)
Description
Sends a signal to the system hardware buffer to release an image once it is no longer needed so that other components can access it. As an application developer, you do not need to use this function.
System capability: SystemCapability.Graphic.Vulkan
Since: 10
Deprecated from: 23
Parameters
| Name | Description |
|---|---|
| VkQueue queue | Handle to the Vulkan queue. |
| uint32_t waitSemaphoreCount | Number of semaphores to wait on. |
| const VkSemaphore* pWaitSemaphores | Pointer to the array of semaphores to wait on. |
| VkImage image | Handle to the Vulkan image to be released. |
| int32_t* pNativeFenceFd | Pointer to the file descriptor of the fence. |
Returns
| Type | Description |
|---|---|
| VkResult | One of the following error codes of the VkResult type: VK_SUCCESS: The operation is successful. VK_ERROR_DEVICE_LOST: The Vulkan device link is lost. VK_ERROR_OUT_OF_HOST_MEMORY: The host memory is insufficient. |
VKAPI_PTR *PFN_vkQueueSignalReleaseImageOHOS()
typedef VkResult (VKAPI_PTR *PFN_vkQueueSignalReleaseImageOHOS)(VkQueue queue, uint32_t waitSemaphoreCount, const VkSemaphore* pWaitSemaphores, VkImage image, int32_t* pNativeFenceFd)
Description
Sends a signal to the system hardware buffer to release an image once it is no longer needed so that other components can access it. As an application developer, you do not need to use this function.
System capability: SystemCapability.Graphic.Vulkan
Since: 10
Deprecated from: 23
Parameters
| Name | Description |
|---|---|
| VkQueue queue | Handle to the Vulkan queue. |
| uint32_t waitSemaphoreCount | Number of semaphores to wait on. |
| const VkSemaphore* pWaitSemaphores | Pointer to the array of semaphores to wait on. |
| images | Handle to the Vulkan image to be released. |
| int32_t* pNativeFenceFd | Pointer to the file descriptor of the fence. |
Returns
| Type | Description |
|---|---|
| VkResult | One of the following error codes of the VkResult type: VK_SUCCESS: The operation is successful. VK_ERROR_DEVICE_LOST: The Vulkan device link is lost. VK_ERROR_OUT_OF_HOST_MEMORY: The host memory is insufficient. |
VKAPI_PTR *PFN_vkSetNativeFenceFdOpenHarmony()
typedef VkResult (VKAPI_PTR *PFN_vkSetNativeFenceFdOpenHarmony)(VkDevice device, int32_t nativeFenceFd, VkSemaphore semaphore, VkFence fence)
Description
This API has been deprecated.
Since: 10
Deprecated from: 10
Substitute: PFN_vkAcquireImageOHOS
VKAPI_PTR *PFN_vkGetNativeFenceFdOpenHarmony()
typedef VkResult (VKAPI_PTR *PFN_vkGetNativeFenceFdOpenHarmony)(VkQueue queue, uint32_t waitSemaphoreCount, const VkSemaphore* pWaitSemaphores, VkImage image, int32_t* pNativeFenceFd)
Description
This API has been deprecated.
Since: 10
Deprecated from: 10
Substitute: PFN_vkQueueSignalReleaseImageOHOS
vkSetNativeFenceFdOpenHarmony()
VKAPI_ATTR VkResult VKAPI_CALL vkSetNativeFenceFdOpenHarmony(VkDevice device, int32_t nativeFenceFd, VkSemaphore semaphore, VkFence fence)
Description
This API has been deprecated.
Since: 10
Deprecated from: 10
Substitute: vkAcquireImageOHOS
vkGetNativeFenceFdOpenHarmony()
VKAPI_ATTR VkResult VKAPI_CALL vkGetNativeFenceFdOpenHarmony(VkQueue queue, uint32_t waitSemaphoreCount, const VkSemaphore* pWaitSemaphores, VkImage image, int32_t* pNativeFenceFd)
Description
This API has been deprecated.
Since: 10
Deprecated from: 10
Substitute: vkQueueSignalReleaseImageOHOS