Is it possible to use pixmaps on Android through the Java API for GLES?

I am trying to implement off-screen rendering with OpenGL ES on Android. My ultimate goal is to improve the texture mapping performance that I run in simple Java and Bitmap / int [] APIs. I tried the pbuffer approach, similar to the sample code from the corresponding forum topic . It shows rather poor performance, glReadPixels call takes up to 50 ms on one device and up to 15 ms on another.

There is a more modern approach using Frame Buffers. The code examples are quite complex, and I do not expect much faster transfers from Frame Buffer to Android Bitmaps than with pbuffers. Am I correct with my assessment?

The third approach uses pixmaps. If I understand the documents correctly, they should use a more complex memory exchange between OpenGL and Dalvik memory than a regular copy. The problem is that the corresponding APIs are not available in the Android SDK.

There is no eglCreateImageKHR and EGLImageKHR structure in Java. All C ++ examples that I could find rely on them.

There is eglCreatePixmapSurface , but I cannot figure out how to use it from the docs. It probably gets some kind of bitmap descriptor in the native_pixmap parameter, but I cannot find a way to create such a descriptor. A search for "eglCreatePixmapSurface android" only results in problem reports.

My main question is: can I use pixmaps on Android with Java without writing my own code? If I need to run native, is there any working code that I can use to evaluate performance before diving into OpenGL?

+5
source share
1 answer

The best way to improve texture loading performance on Android is to use the extended extensions EGL and EGL_NATIVE_BUFFER_ANDROID with native code. I have some sample code in this article . I measured major performance improvements with this approach.

Android does not support Pixmaps, and pbuffers do not work on Nvidia Tegra devices. Instead, you should use FBO-attached textures. Thus, the Android SurfaceTexture class is implemented.

If you need alpha textures, this is another reason to use native code. There is a compatibility issue between Bitmap and OpenGL ES with alpha textures.

The use of hardware texture compression formats (ETC / PVR instead of PNG) and mipmaps also significantly improve download performance and the quality of texture rendering, as discussed in this article.

The big problem is glReadPixels (). EGL_NATIVE_BUFFER_ANDROID only works for writing textures, not for reading them into a bitmap image. Android platform code uses glReadPixels () to implement TextureView.getBitmap (), and it is very slow. The best solution is not to copy the texture to the bitmap, but to display the displayed TextureView directly, which avoids glReadPixels ().

I am working with OpenGL ES 2.0, and the situation may have been improved with 3.0.

+6
source

Source: https://habr.com/ru/post/1201145/


All Articles