summaryrefslogtreecommitdiffstats
path: root/src/test
diff options
context:
space:
mode:
authorSven Gothel <[email protected]>2011-10-07 02:40:52 +0200
committerSven Gothel <[email protected]>2011-10-07 02:40:52 +0200
commitf5a2da16645ebc60d4e3da72f702cf682a5c0488 (patch)
tree94a65aadeae42f623bce76a803cab1d76b04d1ba /src/test
parentfa7627f623141c6fa15856c74d26c8ffe82550d0 (diff)
PMVMatrix: Defaults from direct NIO -> array-backed non-direct NIO: Reduced cycles 45% -> 5% (from GearsES2 100%)
- NIO direct access from Java is expensive - default is now array-backed non-direct NIO, which guarantees array useage for Java computation (especially the inverse calculation) - only update Mvi and Mvit if requested in the first place - moved all local matrices to float[]
Diffstat (limited to 'src/test')
-rw-r--r--src/test/com/jogamp/opengl/test/junit/jogl/demos/es2/GearsES2.java21
-rw-r--r--src/test/com/jogamp/opengl/test/junit/jogl/demos/es2/newt/TestGearsES2NEWT.java59
2 files changed, 75 insertions, 5 deletions
diff --git a/src/test/com/jogamp/opengl/test/junit/jogl/demos/es2/GearsES2.java b/src/test/com/jogamp/opengl/test/junit/jogl/demos/es2/GearsES2.java
index 9bff38fce..050d9eb6e 100644
--- a/src/test/com/jogamp/opengl/test/junit/jogl/demos/es2/GearsES2.java
+++ b/src/test/com/jogamp/opengl/test/junit/jogl/demos/es2/GearsES2.java
@@ -56,6 +56,7 @@ public class GearsES2 implements GLEventListener {
private GearsObjectES2 gear1=null, gear2=null, gear3=null;
private float angle = 0.0f;
private int swapInterval = 0;
+ private boolean pmvUseBackingArray = true; // the default for PMVMatrix now, since it's faster
// private MouseListener gearsMouse = new TraceMouseAdapter(new GearsMouseAdapter());
private MouseListener gearsMouse = new GearsMouseAdapter();
private KeyListener gearsKeys = new GearsKeyAdapter();
@@ -70,6 +71,10 @@ public class GearsES2 implements GLEventListener {
this.swapInterval = 1;
}
+ public void setPMVUseBackingArray(boolean pmvUseBackingArray) {
+ this.pmvUseBackingArray = pmvUseBackingArray;
+ }
+
public void setGears(GearsObjectES2 g1, GearsObjectES2 g2, GearsObjectES2 g3) {
gear1 = g1;
gear2 = g2;
@@ -119,7 +124,7 @@ public class GearsES2 implements GLEventListener {
// Use debug pipeline
// drawable.setGL(new DebugGL(drawable.getGL()));
- pmvMatrix = new PMVMatrix();
+ pmvMatrix = new PMVMatrix(pmvUseBackingArray);
st.attachObject("pmvMatrix", pmvMatrix);
pmvMatrixUniform = new GLUniformData("pmvMatrix", 4, 4, pmvMatrix.glGetPMvMvitMatrixf()); // P, Mv, Mvi and Mvit
st.ownUniform(pmvMatrixUniform);
@@ -189,10 +194,22 @@ public class GearsES2 implements GLEventListener {
st.uniform(gl, pmvMatrixUniform);
st.useProgram(gl, false);
+ try {
+ android.os.Debug.startMethodTracing("GearsES2.trace");
+ android.os.Debug.startAllocCounting();
+ useAndroidDebug = true;
+ } catch (NoClassDefFoundError e) {}
+
System.err.println(Thread.currentThread()+" GearsES2.reshape FIN");
}
+ private boolean useAndroidDebug = false;
public void dispose(GLAutoDrawable drawable) {
+ if(useAndroidDebug) {
+ android.os.Debug.stopAllocCounting();
+ android.os.Debug.stopMethodTracing();
+ }
+
System.err.println(Thread.currentThread()+" GearsES2.dispose ... ");
if (drawable instanceof Window) {
Window window = (Window) drawable;
@@ -244,7 +261,7 @@ public class GearsES2 implements GLEventListener {
gear2.draw(gl, 3.1f, -2.0f, -2f * angle - 9.0f, GearsObject.green);
gear3.draw(gl, -3.1f, 4.2f, -2f * angle - 25.0f, GearsObject.blue);
pmvMatrix.glPopMatrix();
- st.useProgram(gl, false);
+ st.useProgram(gl, false);
}
class GearsKeyAdapter extends KeyAdapter {
diff --git a/src/test/com/jogamp/opengl/test/junit/jogl/demos/es2/newt/TestGearsES2NEWT.java b/src/test/com/jogamp/opengl/test/junit/jogl/demos/es2/newt/TestGearsES2NEWT.java
index df86b83d2..64eb518fb 100644
--- a/src/test/com/jogamp/opengl/test/junit/jogl/demos/es2/newt/TestGearsES2NEWT.java
+++ b/src/test/com/jogamp/opengl/test/junit/jogl/demos/es2/newt/TestGearsES2NEWT.java
@@ -28,6 +28,10 @@
package com.jogamp.opengl.test.junit.jogl.demos.es2.newt;
+import java.io.BufferedReader;
+import java.io.IOException;
+import java.io.InputStreamReader;
+
import com.jogamp.newt.event.KeyAdapter;
import com.jogamp.newt.event.KeyEvent;
import com.jogamp.newt.opengl.GLWindow;
@@ -38,7 +42,10 @@ import com.jogamp.opengl.util.Animator;
import com.jogamp.opengl.test.junit.jogl.demos.es2.GearsES2;
+import javax.media.opengl.GLAnimatorControl;
+import javax.media.opengl.GLAutoDrawable;
import javax.media.opengl.GLCapabilities;
+import javax.media.opengl.GLEventListener;
import javax.media.opengl.GLProfile;
import org.junit.Assert;
@@ -78,7 +85,29 @@ public class TestGearsES2NEWT extends UITestCase {
glWindow.setUndecorated(undecorated);
glWindow.setAlwaysOnTop(alwaysOnTop);
glWindow.setFullscreen(fullscreen);
- glWindow.addGLEventListener(new GearsES2());
+ GearsES2 demo = new GearsES2(vsync ? 1 : 0);
+ demo.setPMVUseBackingArray(pmvUseBackingArray);
+ glWindow.addGLEventListener(demo);
+ if(waitForKey) {
+ glWindow.addGLEventListener(new GLEventListener() {
+ public void init(GLAutoDrawable drawable) { }
+ public void dispose(GLAutoDrawable drawable) { }
+ public void display(GLAutoDrawable drawable) {
+ GLAnimatorControl actrl = drawable.getAnimator();
+ if(waitForKey && actrl.getTotalFPSFrames() == 60*3) {
+ BufferedReader stdin = new BufferedReader(new InputStreamReader(System.in));
+ System.err.println("Press enter to continue");
+ try {
+ System.err.println(stdin.readLine());
+ } catch (IOException e) { }
+ actrl.resetFPSCounter();
+ waitForKey = false;
+ }
+ }
+ public void reshape(GLAutoDrawable drawable, int x, int y,
+ int width, int height) { }
+ });
+ }
Animator animator = new Animator(glWindow);
QuitAdapter quitAdapter = new QuitAdapter();
@@ -128,7 +157,7 @@ public class TestGearsES2NEWT extends UITestCase {
System.err.println("size/pos: "+f_glWindow.getX()+"/"+f_glWindow.getY()+" "+f_glWindow.getWidth()+"x"+f_glWindow.getHeight()+", "+f_glWindow.getInsets());
System.err.println("chosen: "+glWindow.getChosenCapabilities());
- animator.setUpdateFPSFrames(1, null);
+ animator.setUpdateFPSFrames(60, System.err);
animator.start();
while(!quitAdapter.shouldQuit() && animator.isAnimating() && animator.getTotalFPSDuration()<duration) {
@@ -151,8 +180,12 @@ public class TestGearsES2NEWT extends UITestCase {
static boolean undecorated = false;
static boolean alwaysOnTop = false;
static boolean fullscreen = false;
+ static boolean pmvUseBackingArray = true;
+ static boolean vsync = false;
+ static boolean waitForKey = false;
- public static void main(String args[]) {
+ public static void main(String args[]) throws IOException {
+
for(int i=0; i<args.length; i++) {
if(args[i].equals("-time")) {
i++;
@@ -167,8 +200,28 @@ public class TestGearsES2NEWT extends UITestCase {
alwaysOnTop = true;
} else if(args[i].equals("-fullscreen")) {
fullscreen = true;
+ } else if(args[i].equals("-pmvDirect")) {
+ pmvUseBackingArray = false;
+ } else if(args[i].equals("-vsync")) {
+ vsync = true;
+ } else if(args[i].equals("-wait")) {
+ waitForKey = true;
}
}
+ System.err.println("translucent "+(!opaque));
+ System.err.println("undecorated "+undecorated);
+ System.err.println("atop "+alwaysOnTop);
+ System.err.println("fullscreen "+fullscreen);
+ System.err.println("pmvDirect "+(!pmvUseBackingArray));
+ System.err.println("vsync "+vsync);
+
+ if(waitForKey) {
+ BufferedReader stdin = new BufferedReader(new InputStreamReader(System.in));
+ System.err.println("Press enter to continue");
+ try {
+ System.err.println(stdin.readLine());
+ } catch (IOException e) { }
+ }
org.junit.runner.JUnitCore.main(TestGearsES2NEWT.class.getName());
}
}