How to get around performance issues with Buffer.put () and Android OpenGL

This is a Java issue in general, although in this particular case I am using Vertex Arrays in Android for OpenGL. To use this basic GL system, you must use the Java Buffer system in native allocation mode. In Java, this is very slow. And about 40-50% of all my application time is spent inside buffer.put ().

Is there a way to speed this up while I am in Java (i.e. not using my own sdk)?

+3
source share
3 answers

Avoid highlighting at all. Use the buffer pool and juggle them as needed. You can have several standard sizes and spend a few bytes at the end in exchange for performance. In addition, when using OpenGL, you usually do not need to rewrite your buffers in each frame (unless you use extensive cropping or animation?). As a rule, you have ready-made arrays, objects are converted using matrices, and what it is.

0
source

I ran into a similar problem when integrating Java and JOGL - my solution was to manage buffer resources in C and use JNI to pass a pointer to the buffer in Java using the method

jobject NewDirectByteBuffer(JNIEnv * env, void * address, jlong capacity); 

jni.h. , , "", java.nio.Buffer. , C, C .

+1

, - , , . , . "", , . , , , .

0

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


All Articles