C Specification

To obtain the Gralloc usage flag of a swapchain, call:

// Provided by VK_OHOS_native_buffer
VkResult vkGetSwapchainGrallocUsageOHOS(
    VkDevice                                    device,
    VkFormat                                    format,
    VkImageUsageFlags                           imageUsage,
    uint64_t*                                   grallocUsage);

Parameters

  • device is a valid VkDevice object used to create the swapchain image.

  • format is a VkFormat value specifying the format of the given image.

  • grallocUsage is a bitmask for setting a mask of zero or more OH_NativeBuffer_Usage, which is defined in the C APIs references documentation of Open Harmony OS Graphics Module.

Description

Valid Usage (Implicit)
  • VUID-vkGetSwapchainGrallocUsageOHOS-device-parameter
    device must be a valid VkDevice handle

  • VUID-vkGetSwapchainGrallocUsageOHOS-format-parameter
    format must be a valid VkFormat value

  • VUID-vkGetSwapchainGrallocUsageOHOS-imageUsage-parameter
    imageUsage must be a valid combination of VkImageUsageFlagBits values

  • VUID-vkGetSwapchainGrallocUsageOHOS-imageUsage-requiredbitmask
    imageUsage must not be 0

  • VUID-vkGetSwapchainGrallocUsageOHOS-grallocUsage-parameter
    grallocUsage must be a valid pointer to a uint64_t value

Return Codes
On success, this command returns
  • VK_SUCCESS

On failure, this command returns
  • VK_ERROR_INITIALIZATION_FAILED

  • VK_ERROR_UNKNOWN

  • VK_ERROR_VALIDATION_FAILED

See Also

Document Notes

For more information, see the Vulkan Specification.

This page is extracted from the Vulkan Specification. Fixes and changes should be made to the Specification, not directly.

Copyright 2014-2025 The Khronos Group Inc.

SPDX-License-Identifier: CC-BY-4.0