Negating some JNI call overhead by doing transformations in Java
Posted by GiGurra on Jul 21, 2011; 10:56am
URL: https://forum.jogamp.org/Negating-some-JNI-call-overhead-by-doing-transformations-in-Java-tp3188212.html
Please excuse me if this might already be implemented or that there is some important reasons why it can't be used :) (but please do explain to me why, I would really appreciate it).
I'm writing this somewhat high performance 2d application using jogl 2 with lots of relative transformations from object A -> object B -> object C. I'm guessing one of the difficult parts with java<->opengl is making sure the jni call overhead doesn't become a big performance hog, especially when lining up a lot of variable translate/rotate/scale operations.
Now I've benchmarked a few glPop/push/loadMatrix/translate/rotate/scale operations here on my laptop (2.4 GHz i5 w intel gpu) and it seems like these operations take somewhere in between 0.5 - 7 microseconds to complete (The loadmatrix is by far the slowest, and the others are around 1 microsecond each).
This does feel like quite a large overhead per call compared to for example a native C program (though I cannot say I have any numbers to compare with, I'm just doing some estimations on what the implications are), and it does seem to match what JNI calls are supposed to take.
Now: Is it possible it would go faster if I used a wrapper for them, let's say I have 10-20 (extreme case but still) transformations that I wan't to do, and I did these things on a temporary matrix in java on cpu, and then just did one JNI call (load matrix) and transfered the result to opengl. Do you think there would be a performance benefit to this?