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;}
Hardware-Puffer beim Vulkan-Rendering verwenden
Unter vulkan_handler.cc finden Sie ein Beispiel für das Rendern einer AR-Anwendung mit Vulkan.
Unterstützte Geräte
Der Vulkan-Rendering-Support ist nur für Android-API-Levels ab 27 verfügbar. Außerdem muss das Gerät die Erweiterung VK_ANDROID_external_memory_android_hardware_buffer unterstützen.
Vulkan im Manifest Ihrer App anfordern
Google Play verwendet die in Ihrem App-Manifest deklarierte <uses-feature>, um Ihre App von Geräten zu filtern, die die Anforderungen an Hardware- und Softwarefunktionen nicht erfüllen.
Geräte mit Vulkan 1.0 unterstützen die erforderliche Erweiterung möglicherweise nicht. Geräte, die mit Vulkan 1.1 kompatibel sind, müssen sie jedoch ab Android 10 (API-Level 29) haben.
[[["Leicht verständlich","easyToUnderstand","thumb-up"],["Mein Problem wurde gelöst","solvedMyProblem","thumb-up"],["Sonstiges","otherUp","thumb-up"]],[["Benötigte Informationen nicht gefunden","missingTheInformationINeed","thumb-down"],["Zu umständlich/zu viele Schritte","tooComplicatedTooManySteps","thumb-down"],["Nicht mehr aktuell","outOfDate","thumb-down"],["Problem mit der Übersetzung","translationIssue","thumb-down"],["Problem mit Beispielen/Code","samplesCodeIssue","thumb-down"],["Sonstiges","otherDown","thumb-down"]],["Zuletzt aktualisiert: 2025-02-28 (UTC)."],[[["ARCore can provide the camera image as an Android hardware buffer for efficient Vulkan rendering by setting `ArTextureUpdateMode` to `AR_TEXTURE_UPDATE_MODE_EXPOSE_HARDWARE_BUFFER`."],["This hardware buffer can be accessed using `ArFrame_getHardwareBuffer()` and bound to a Vulkan `VkImage` for rendering."],["Vulkan rendering with ARCore is supported on Android API levels 27 and above, requiring devices to support the `VK_ANDROID_external_memory_android_hardware_buffer` extension."],["To ensure compatibility, declare Vulkan requirements in your app's manifest using `\u003cuses-feature\u003e`, targeting devices with Vulkan 1.1 for guaranteed support on Android 10 and above."],["A sample implementation of Vulkan rendering with ARCore can be found in the `hello_ar_vulkan_c` sample app."]]],["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"]]