I need to pass a texture generated in OpenGL ES to Vulkan, render some thing on it, then pass back to OpenGL ES. Is there a fast way to do this? Reading to cpu and pass to gpu every frame sounds too slow for a realtime Android app.
Asked
Active
Viewed 1,426 times
4
-
There are extensions to allow Vulkan to access OpenGL objects, assuming your extension supports them. But given that Vulkan renders the same stuff as OpenGL ES, using the same hardware, it's probably better to port this Vulkan code into OpenGL ES than to try to use this dual approach. – Nicol Bolas Jul 10 '19 at 13:27
1 Answers
6
On Android the most widely supported way of doing this will be to use AHardwareBuffer, VK_ANDROID_external_memory_android_hardware_buffer, and VK_KHR_external_semaphore_fd with VK_EXTERNAL_SEMAPHORE_HANDLE_TYPE_SYNC_FD_BIT
handles. These extensions aren't supported widely yet -- but neither is any alternative -- but this what the UI framework (via Skia), will be using, so it should eventually become widespread.
On the OpenGL ES side, you can import the AHardwareBuffer into an EGLImage (EGL_ANDROID_image_native_buffer) and from there into a GL texture (GL_OES_EGL_image_external_essl3). Synchronization import/export is done with EGL_ANDROID_native_fence_sync.

Jesse Hall
- 6,441
- 23
- 29