openharmony 鸿蒙 capi-vulkan-ohos-h

2026-08-25 浏览 (1)

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

Nametypedef KeywordDescription
VkSurfaceCreateInfoOHOSVkSurfaceCreateInfoOHOSDescribes the parameters required for creating a Vulkan surface.
VkNativeBufferOHOSVkNativeBufferOHOSDescribes the parameters of the device memory.
VkSwapchainImageCreateInfoOHOSVkSwapchainImageCreateInfoOHOSDescribes the parameters required for creating an image.
VkPhysicalDevicePresentationPropertiesOHOSVkPhysicalDevicePresentationPropertiesOHOSDescribes the parameters of the device display properties.
VkNativeBufferUsageOHOSVkNativeBufferUsageOHOSDescribes the usage of the NativeBuffer.
VkNativeBufferPropertiesOHOSVkNativeBufferPropertiesOHOSDescribes the properties of the NativeBuffer.
VkNativeBufferFormatPropertiesOHOSVkNativeBufferFormatPropertiesOHOSDescribes the format properties of the NativeBuffer.
VkImportNativeBufferInfoOHOSVkImportNativeBufferInfoOHOSDescribes the pointer to an OH_NativeBuffer struct.
VkMemoryGetNativeBufferInfoOHOSVkMemoryGetNativeBufferInfoOHOSUsed to obtain an OH_NativeBuffer from the Vulkan memory.
VkExternalFormatOHOSVkExternalFormatOHOSDescribes an externally defined format.
NativeWindowOHNativeWindowDescribes 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

Nametypedef KeywordDescription
VkSwapchainImageUsageFlagBitsOHOSVkSwapchainImageUsageFlagBitsOHOSEnumerates the image usage flags.

Macros

NameDescription
VK_OHOS_surface 1Surface extension macro definition of OpenHarmony.
Since: 10
VK_OHOS_SURFACE_SPEC_VERSION 1Surface 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 1native_buffer extension macro definition.
Since: 10
VK_OHOS_NATIVE_BUFFER_SPEC_VERSION 1native_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 1External memory extension macro definition of OpenHarmony.
Since: 10
VK_OHOS_EXTERNAL_MEMORY_SPEC_VERSION 1External 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

Nametypedef KeywordDescription
VkResult (VKAPI_PTR PFN_vkCreateSurfaceOHOS)(VkInstance instance, const VkSurfaceCreateInfoOHOS pCreateInfo, const VkAllocationCallbacks* pAllocator, VkSurfaceKHR* pSurface)PFN_vkCreateSurfaceOHOSDefines the function pointer for creating a Vulkan surface.
VKAPI_ATTR VkResult VKAPI_CALL vkCreateSurfaceOHOS(VkInstance instance, const VkSurfaceCreateInfoOHOS* pCreateInfo, const VkAllocationCallbacks* pAllocator, VkSurfaceKHR* pSurface)-Creates a Vulkan surface.
VkResult (VKAPI_PTR PFN_vkGetNativeBufferPropertiesOHOS)(VkDevice device, const struct OH_NativeBuffer buffer, VkNativeBufferPropertiesOHOS* pProperties)PFN_vkGetNativeBufferPropertiesOHOSDefines a function pointer used to obtain OH_NativeBuffer properties.
VkResult (VKAPI_PTR PFN_vkGetMemoryNativeBufferOHOS)(VkDevice device, const VkMemoryGetNativeBufferInfoOHOS pInfo, struct OH_NativeBuffer** pBuffer)PFN_vkGetMemoryNativeBufferOHOSDefines a function pointer used to obtain an OH_NativeBuffer instance.
VKAPI_ATTR VkResult VKAPI_CALL vkGetNativeBufferPropertiesOHOS(VkDevice device, const struct OH_NativeBuffer* buffer, VkNativeBufferPropertiesOHOS* pProperties)-Obtains the properties of an OH_NativeBuffer instance.
VKAPI_ATTR VkResult VKAPI_CALL vkGetMemoryNativeBufferOHOS(VkDevice device, const VkMemoryGetNativeBufferInfoOHOS* pInfo, struct OH_NativeBuffer** pBuffer)-Obtains an OH_NativeBuffer instance.
VKAPI_ATTR VkResult VKAPI_CALL vkGetSwapchainGrallocUsageOHOS(VkDevice device, VkFormat format, VkImageUsageFlags imageUsage, uint64_t* grallocUsage)-Returns the appropriate gralloc usage flag based on the given Vulkan device, image format, and image usage flag.
VKAPI_ATTR VkResult VKAPI_CALL vkAcquireImageOHOS(VkDevice device, VkImage image, int32_t nativeFenceFd, VkSemaphore semaphore, VkFence fence)-Obtains the ownership of the swap chain image and imports the fence of the external signal to the VkSemaphore and VkFence objects.
VKAPI_ATTR VkResult VKAPI_CALL vkQueueSignalReleaseImageOHOS(VkQueue queue, uint32_t waitSemaphoreCount, const VkSemaphore* pWaitSemaphores, VkImage image, int32_t* pNativeFenceFd)-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.
VkResult (VKAPI_PTR *PFN_vkSetNativeFenceFdOpenHarmony)(VkDevice device, int32_t nativeFenceFd, VkSemaphore semaphore, VkFence fence)VKAPI_PTR *PFN_vkSetNativeFenceFdOpenHarmonyThis API has been deprecated.
typedef VkResult (VKAPI_PTR PFN_vkGetNativeFenceFdOpenHarmony)(VkQueue queue, uint32_t waitSemaphoreCount, const VkSemaphore pWaitSemaphores, VkImage image, int32_t* pNativeFenceFd)VKAPI_PTR *PFN_vkGetNativeFenceFdOpenHarmonyThis API has been deprecated.
VkResult (VKAPI_PTR PFN_vkGetSwapchainGrallocUsageOHOS)(VkDevice device, VkFormat format, VkImageUsageFlags imageUsage, uint64_t grallocUsage)VKAPI_PTR *PFN_vkGetSwapchainGrallocUsageOHOSReturns 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.
VkResult (VKAPI_PTR *PFN_vkAcquireImageOHOS)(VkDevice device, VkImage image, int32_t nativeFenceFd, VkSemaphore semaphore, VkFence fence)VKAPI_PTR *PFN_vkAcquireImageOHOSObtains 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.
typedef VkResult (VKAPI_PTR PFN_vkQueueSignalReleaseImageOHOS)(VkQueue queue, uint32_t waitSemaphoreCount, const VkSemaphore pWaitSemaphores, VkImage image, int32_t* pNativeFenceFd)VKAPI_PTR *PFN_vkQueueSignalReleaseImageOHOSSends 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.
VKAPI_ATTR VkResult VKAPI_CALL vkSetNativeFenceFdOpenHarmony(VkDevice device, int32_t nativeFenceFd, VkSemaphore semaphore, VkFence fence)-This API has been deprecated.
VKAPI_ATTR VkResult VKAPI_CALL vkGetNativeFenceFdOpenHarmony(VkQueue queue, uint32_t waitSemaphoreCount, const VkSemaphore* pWaitSemaphores, VkImage image, int32_t* pNativeFenceFd)-This API has been deprecated.

Enum Description

VkSwapchainImageUsageFlagBitsOHOS

enum VkSwapchainImageUsageFlagBitsOHOS

Description

Enumerates the image usage flags.

Since: 10

ValueDescription
VK_SWAPCHAIN_IMAGE_USAGE_SHARED_BIT_OHOS = 0x00000001Shared image flag.
VK_SWAPCHAIN_IMAGE_USAGE_FLAG_BITS_MAX_ENUM_OHOS = 0x7FFFFFFFMaximum 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

NameDescription
VkInstance instanceVulkan instance.
const VkSurfaceCreateInfoOHOS* pCreateInfoPointer to the VkSurfaceCreateInfoOHOS struct, including the parameters required for creating a Vulkan surface.
const VkAllocationCallbacks* pAllocatorPointer 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* pSurfacePointer to the Vulkan surface created. The type is VkSurfaceKHR.

Returns

TypeDescription
VkResultVK_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

NameDescription
VkInstance instanceVulkan instance.
const VkSurfaceCreateInfoOHOS* pCreateInfoPointer to the VkSurfaceCreateInfoOHOS struct, including the parameters required for creating a Vulkan surface.
const VkAllocationCallbacks* pAllocatorPointer 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* pSurfacePointer to the Vulkan surface created. The type is VkSurfaceKHR.

Returns

TypeDescription
VkResultOne 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

NameDescription
VkDevice deviceVkDevice object.
const struct OH_NativeBuffer* bufferPointer to an OH_NativeBuffer struct.
VkNativeBufferPropertiesOHOS* pPropertiesPointer to the struct holding the properties of OH_NativeBuffer.

Returns

TypeDescription
VkResultVK_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

NameDescription
VkDevice deviceVkDevice object.
const VkMemoryGetNativeBufferInfoOHOS* pInfoPointer to a VkMemoryGetNativeBufferInfoOHOS struct.
struct OH_NativeBuffer** pBufferPointer to the OH_NativeBuffer obtained.

Returns

TypeDescription
VkResultVK_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

NameDescription
VkDevice deviceVkDevice object.
const struct OH_NativeBuffer* bufferPointer to an OH_NativeBuffer struct.
VkNativeBufferPropertiesOHOS* pPropertiesPointer to the struct holding the properties of OH_NativeBuffer.

Returns

TypeDescription
VkResultOne 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

NameDescription
VkDevice deviceVkDevice object.
const VkMemoryGetNativeBufferInfoOHOS* pInfoPointer to a VkMemoryGetNativeBufferInfoOHOS struct.
struct OH_NativeBuffer** pBufferPointer to the OH_NativeBuffer obtained.

Returns

TypeDescription
VkResultOne 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

NameDescription
VkDevice deviceVkDevice object.
VkFormat formatImage format.
VkImageUsageFlags imageUsageImage use flag.
uint64_t* grallocUsagePointer to the gralloc usage flag.

Returns

TypeDescription
VkResultOne 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

NameDescription
VkDevice deviceVkDevice object.
VkFormat formatImage format.
VkImageUsageFlags imageUsageImage use flag.
uint64_t* grallocUsagePointer to the gralloc usage flag.

Returns

TypeDescription
VkResultOne 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

NameDescription
VkDevice deviceVkDevice object.
VkImage imageVulkan image to obtain.
int32_t nativeFenceFdFile descriptor of the native fence.
VkSemaphore semaphoreVulkan semaphore indicating that the image is available.
VkFence fenceVulkan fence used for synchronization when the image acquisition is complete.

Returns

TypeDescription
VkResultOne 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

NameDescription
VkDevice deviceVkDevice object.
VkImage imageVulkan image to obtain.
int32_t nativeFenceFdFile descriptor of the native fence.
VkSemaphore semaphoreVulkan semaphore indicating that the image is available.
VkFence fenceVulkan fence used for synchronization when the image acquisition is complete.

Returns

TypeDescription
VkResultOne 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

NameDescription
VkQueue queueHandle to the Vulkan queue.
uint32_t waitSemaphoreCountNumber of semaphores to wait on.
const VkSemaphore* pWaitSemaphoresPointer to the array of semaphores to wait on.
VkImage imageHandle to the Vulkan image to be released.
int32_t* pNativeFenceFdPointer to the file descriptor of the fence.

Returns

TypeDescription
VkResultOne 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

NameDescription
VkQueue queueHandle to the Vulkan queue.
uint32_t waitSemaphoreCountNumber of semaphores to wait on.
const VkSemaphore* pWaitSemaphoresPointer to the array of semaphores to wait on.
imagesHandle to the Vulkan image to be released.
int32_t* pNativeFenceFdPointer to the file descriptor of the fence.

Returns

TypeDescription
VkResultOne 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

你可能感兴趣的鸿蒙文章

openharmony 鸿蒙 guidance-on-ndk-libc-interfaces-affected-by-permissions

openharmony 鸿蒙 capi-vulkan-ohbufferhandle

openharmony 鸿蒙 vulkan-overview

openharmony 鸿蒙 zlib

openharmony 鸿蒙 icu4c-symbol

openharmony 鸿蒙 musl

openharmony 鸿蒙 capi-vulkan-vkimportnativebufferinfoohos

openharmony 鸿蒙 opengl-symbol

openharmony 鸿蒙 opengl

openharmony 鸿蒙 vulkan

  • 所属分类: 后端技术
  • 本文标签: 软件 鸿蒙
  • 版权声明: 本文链接 https://seaxiang.com/blog/MvtUDHPF