Render your AR app using Vulkan on Android NDK (C)
Stay organized with collections
Save and categorize content based on your preferences.
When the ArTextureUpdateMode
is set to AR_TEXTURE_UPDATE_MODE_EXPOSE_HARDWARE_BUFFER
, ARCore will provide an Android hardware buffer when ArSession_update()
is called. This hardware buffer can be bound to a Vulkan VkImage
.
View the sample application
Vulkan rendering support is demonstrated in the hello_ar_vulkan_c sample app.
Enable the hardware buffer output mode
The configured ArTextureUpdateMode
determines how ARCore will update the camera texture. When it is set to AR_TEXTURE_UPDATE_MODE_EXPOSE_HARDWARE_BUFFER
, ARCore will provide the camera image through a AHardwareBuffer
.
Configure the session to use AR_TEXTURE_UPDATE_MODE_EXPOSE_HARDWARE_BUFFER
:
ArConfig* ar_config = NULL;
ArConfig_create(ar_session, &ar_config);
ArConfig_setTextureUpdateMode(ar_session, ar_config,
AR_TEXTURE_UPDATE_MODE_EXPOSE_HARDWARE_BUFFER);
CHECK(ArSession_configure(ar_session, ar_config) == AR_SUCCESS);
ArConfig_destroy(ar_config);
Obtain the hardware buffer
When AR_TEXTURE_UPDATE_MODE_EXPOSE_HARDWARE_BUFFER
is enabled, use ArFrame_getHardwareBuffer()
to get the hardware buffer:
void* native_hardware_buffer = NULL;
ArFrame_getHardwareBuffer(ar_session, ar_frame, &native_hardware_buffer);
if ((int64_t)native_hardware_buffer == 0) {
// The hardware buffer isn't ready yet.
return;
}
Use the hardware buffer during Vulkan rendering
See vulkan_handler.cc
for an example of how to render an AR application using Vulkan.
Supported devices
Vulkan rendering support is only available on Android API levels 27 and
above. Additionally, the device must support the VK_ANDROID_external_memory_android_hardware_buffer
extension.
Require Vulkan in your app's manifest
Google Play uses <uses-feature>
declared in your app manifest to filter your
app from devices that don't meet its hardware and software feature requirements.
Devices using Vulkan 1.0 might not support the required extension, but devices
compatible with Vulkan 1.1 must have the required extension starting in Android 10 (API level 29).
Except as otherwise noted, the content of this page is licensed under the Creative Commons Attribution 4.0 License, and code samples are licensed under the Apache 2.0 License. For details, see the Google Developers Site Policies. Java is a registered trademark of Oracle and/or its affiliates.
Last updated 2025-07-14 UTC.
[null,null,["Last updated 2025-07-14 UTC."],[[["\u003cp\u003eARCore can provide the camera image as an Android hardware buffer for efficient Vulkan rendering by setting \u003ccode\u003eArTextureUpdateMode\u003c/code\u003e to \u003ccode\u003eAR_TEXTURE_UPDATE_MODE_EXPOSE_HARDWARE_BUFFER\u003c/code\u003e.\u003c/p\u003e\n"],["\u003cp\u003eThis hardware buffer can be accessed using \u003ccode\u003eArFrame_getHardwareBuffer()\u003c/code\u003e and bound to a Vulkan \u003ccode\u003eVkImage\u003c/code\u003e for rendering.\u003c/p\u003e\n"],["\u003cp\u003eVulkan rendering with ARCore is supported on Android API levels 27 and above, requiring devices to support the \u003ccode\u003eVK_ANDROID_external_memory_android_hardware_buffer\u003c/code\u003e extension.\u003c/p\u003e\n"],["\u003cp\u003eTo ensure compatibility, declare Vulkan requirements in your app's manifest using \u003ccode\u003e<uses-feature>\u003c/code\u003e, targeting devices with Vulkan 1.1 for guaranteed support on Android 10 and above.\u003c/p\u003e\n"],["\u003cp\u003eA sample implementation of Vulkan rendering with ARCore can be found in the \u003ccode\u003ehello_ar_vulkan_c\u003c/code\u003e sample app.\u003c/p\u003e\n"]]],["To enable hardware buffer access, set `ArTextureUpdateMode` to `AR_TEXTURE_UPDATE_MODE_EXPOSE_HARDWARE_BUFFER` using `ArConfig_setTextureUpdateMode`. After calling `ArSession_update()`, use `ArFrame_getHardwareBuffer()` to obtain the `AHardwareBuffer`. If using the buffer beyond the next `ArSession_update()`, call `AHardwareBuffer_acquire()` and `AHardwareBuffer_release()`. Vulkan rendering is supported on Android API 27+ with the `VK_ANDROID_external_memory_android_hardware_buffer` extension. Incompatible devices will return an error.\n"],null,["# Render your AR app using Vulkan on Android NDK (C)\n\nWhen the [`ArTextureUpdateMode`](/ar/reference/c/group/ar-config#artextureupdatemode) is set to [`AR_TEXTURE_UPDATE_MODE_EXPOSE_HARDWARE_BUFFER`](/ar/reference/c/group/ar-config#ar_texture_update_mode_expose_hardware_buffer), ARCore will provide an Android [hardware buffer](https://developer.android.com/ndk/reference/group/a-hardware-buffer) when [`ArSession_update()`](/ar/reference/c/group/ar-session#arsession_update) is called. This hardware buffer can be bound to a Vulkan [`VkImage`](https://registry.khronos.org/vulkan/specs/1.3-extensions/man/html/VkImage.html).\n\nView the sample application\n---------------------------\n\nVulkan rendering support is demonstrated in the [hello_ar_vulkan_c sample app](https://github.com/google-ar/arcore-android-sdk/tree/master/samples/hello_ar_vulkan_c).\n\nEnable the hardware buffer output mode\n--------------------------------------\n\nThe configured [`ArTextureUpdateMode`](/ar/reference/c/group/ar-config#artextureupdatemode) determines how ARCore will update the camera texture. When it is set to [`AR_TEXTURE_UPDATE_MODE_EXPOSE_HARDWARE_BUFFER`](/ar/reference/c/group/ar-config#ar_texture_update_mode_expose_hardware_buffer), ARCore will provide the camera image through a [`AHardwareBuffer`](https://developer.android.com/ndk/reference/group/a-hardware-buffer).\n\nConfigure the session to use [`AR_TEXTURE_UPDATE_MODE_EXPOSE_HARDWARE_BUFFER`](/ar/reference/c/group/ar-config#ar_texture_update_mode_expose_hardware_buffer): \n\n```c\nArConfig* ar_config = NULL;\nArConfig_create(ar_session, &ar_config);\nArConfig_setTextureUpdateMode(ar_session, ar_config,\n AR_TEXTURE_UPDATE_MODE_EXPOSE_HARDWARE_BUFFER);\nCHECK(ArSession_configure(ar_session, ar_config) == AR_SUCCESS);\nArConfig_destroy(ar_config);\n```\n| **Note:** When using [`AR_TEXTURE_UPDATE_MODE_EXPOSE_HARDWARE_BUFFER`](/ar/reference/c/group/ar-config#ar_texture_update_mode_expose_hardware_buffer) on incompatible devices, [`ArSession_configure()`](/ar/reference/c/group/ar-session#arsession_configure) will fail and return [`AR_ERROR_UNSUPPORTED_CONFIGURATION`](/ar/reference/c/group/shared-types#ar_error_unsupported_configuration).\n\nObtain the hardware buffer\n--------------------------\n\nWhen [`AR_TEXTURE_UPDATE_MODE_EXPOSE_HARDWARE_BUFFER`](/ar/reference/c/group/ar-config#ar_texture_update_mode_expose_hardware_buffer) is enabled, use [`ArFrame_getHardwareBuffer()`](/ar/reference/c/group/ar-frame#arframe_gethardwarebuffer) to get the hardware buffer: \n\n```c\nvoid* native_hardware_buffer = NULL;\nArFrame_getHardwareBuffer(ar_session, ar_frame, &native_hardware_buffer);\n\nif ((int64_t)native_hardware_buffer == 0) {\n // The hardware buffer isn't ready yet.\n return;\n}\n```\n| **Note:** This [`AHardwareBuffer`](https://developer.android.com/ndk/reference/group/a-hardware-buffer) is only guaranteed to be valid until the next call to `ArSession_update()`. If you want to use the hardware buffer beyond that, such as for rendering, you must call [`AHardwareBuffer_acquire()`](https://developer.android.com/ndk/reference/group/a-hardware-buffer#ahardwarebuffer_acquire) and then call [`AHardwareBuffer_release()`](https://developer.android.com/ndk/reference/group/a-hardware-buffer#ahardwarebuffer_release) after your rendering is complete.\n\nUse the hardware buffer during Vulkan rendering\n-----------------------------------------------\n\nSee [`vulkan_handler.cc`](https://github.com/google-ar/arcore-android-sdk/blob/master/samples/hello_ar_vulkan_c/app/src/main/cpp/vulkan_handler.cc) for an example of how to render an AR application using Vulkan.\n\nSupported devices\n-----------------\n\nVulkan rendering support is only available on Android API levels **27** and\nabove. Additionally, the device must support the `VK_ANDROID_external_memory_android_hardware_buffer` extension.\n\n### Require Vulkan in your app's manifest\n\nGoogle Play uses `\u003cuses-feature\u003e` declared in your app manifest to filter your\napp from devices that don't meet its hardware and software feature requirements.\nDevices using Vulkan 1.0 **might not** support the required extension, but devices\ncompatible with Vulkan 1.1 **must** have the required extension starting in Android 10 (API level 29)."]]