heLomaN
heLomaN

Reputation: 1794

How to pass a texture between OpenGL ES and Vulkan?

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.

Upvotes: 5

Views: 2081

Answers (1)

Jesse Hall
Jesse Hall

Reputation: 6787

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.

Upvotes: 7

Related Questions