diff options
Diffstat (limited to 'src/demos/es2/perftst')
-rwxr-xr-x | src/demos/es2/perftst/PerfTextLoad.java | 48 | ||||
-rwxr-xr-x | src/demos/es2/perftst/PerfUniLoad.java | 59 | ||||
-rwxr-xr-x | src/demos/es2/perftst/PerfVBOLoad.java | 68 |
3 files changed, 93 insertions, 82 deletions
diff --git a/src/demos/es2/perftst/PerfTextLoad.java b/src/demos/es2/perftst/PerfTextLoad.java index 971ab32..677b742 100755 --- a/src/demos/es2/perftst/PerfTextLoad.java +++ b/src/demos/es2/perftst/PerfTextLoad.java @@ -24,15 +24,15 @@ public class PerfTextLoad extends PerfModule { } @Override - public ShaderState initShaderState(GL2ES2 gl) { + public ShaderState initShaderState(final GL2ES2 gl) { return initShaderState(gl, "vbo-vert-text", "ftext"); } Texture[] textures = null; TextureData[] textDatas = null; - protected void runOneSet(GLAutoDrawable drawable, String textBaseName, int numObjs, int numTextures, int loops) { - GL2ES2 gl = drawable.getGL().getGL2ES2(); + protected void runOneSet(final GLAutoDrawable drawable, final String textBaseName, final int numObjs, final int numTextures, final int loops) { + final GL2ES2 gl = drawable.getGL().getGL2ES2(); if(numTextures>MAX_TEXTURE_ENGINES) { throw new GLException("numTextures must be within 1.."+MAX_TEXTURE_ENGINES); @@ -44,7 +44,7 @@ public class PerfTextLoad extends PerfModule { try { for(int i=0; i<numObjs; i++) { textName = "data/"+textBaseName+"."+(i+1)+".tga"; - URLConnection connText = IOUtil.getResource(textName, Perftst.class.getClassLoader(), Perftst.class); + final URLConnection connText = IOUtil.getResource(textName, Perftst.class.getClassLoader(), Perftst.class); if(connText==null) { throw new RuntimeException("couldn't fetch "+textName); } @@ -61,7 +61,7 @@ public class PerfTextLoad extends PerfModule { gl.glActiveTexture(i); textures[i] = new Texture(GL.GL_TEXTURE_2D); } - } catch (IOException ioe) { + } catch (final IOException ioe) { System.err.println("couldn't fetch "+textName); throw new RuntimeException(ioe); } @@ -72,9 +72,9 @@ public class PerfTextLoad extends PerfModule { st.useProgram(gl, true); - GLArrayDataServer vertices = GLArrayDataServer.createGLSL("mgl_Vertex", 2, GL.GL_FLOAT, true, 4, GL.GL_STATIC_DRAW); + final GLArrayDataServer vertices = GLArrayDataServer.createGLSL("mgl_Vertex", 2, GL.GL_FLOAT, true, 4, GL.GL_STATIC_DRAW); { - FloatBuffer vb = (FloatBuffer)vertices.getBuffer(); + final FloatBuffer vb = (FloatBuffer)vertices.getBuffer(); vb.put(0f); vb.put(0f); vb.put(1f); vb.put(0f); vb.put(0f); vb.put(1f); @@ -82,9 +82,9 @@ public class PerfTextLoad extends PerfModule { } vertices.seal(gl, true); - GLArrayDataServer texCoords = GLArrayDataServer.createGLSL("mgl_MultiTexCoord0", 2, GL.GL_FLOAT, true, 4, GL.GL_STATIC_DRAW); + final GLArrayDataServer texCoords = GLArrayDataServer.createGLSL("mgl_MultiTexCoord0", 2, GL.GL_FLOAT, true, 4, GL.GL_STATIC_DRAW); { - FloatBuffer cb = (FloatBuffer)texCoords.getBuffer(); + final FloatBuffer cb = (FloatBuffer)texCoords.getBuffer(); cb.put(0f); cb.put(0f); cb.put(1f); cb.put(0f); cb.put(0f); cb.put(1f); @@ -95,7 +95,7 @@ public class PerfTextLoad extends PerfModule { // // texture setup // - long[] tU = new long[numObjs+1]; + final long[] tU = new long[numObjs+1]; tU[0] = System.currentTimeMillis(); for(int j=0; j<numTextures; j++) { gl.glActiveTexture(j); @@ -103,27 +103,29 @@ public class PerfTextLoad extends PerfModule { tU[j+1] = System.currentTimeMillis(); } - GLUniformData activeTexture = new GLUniformData("mgl_ActiveTexture", 0); + final GLUniformData activeTexture = new GLUniformData("mgl_ActiveTexture", 0); st.uniform(gl, activeTexture); // // run loops // - long dtC, dt, dt2, dt3, dtF, dtS, dtT; - long[][] tC = new long[loops][numObjs]; - long[][] t0 = new long[loops][numObjs]; - long[][][] t1 = new long[loops][numObjs][numTextures]; - long[][][] t2 = new long[loops][numObjs][numTextures]; - long[][][] t3 = new long[loops][numObjs][numTextures]; - long[][] tF = new long[loops][numObjs]; - long[][] tS = new long[loops][numObjs]; + long dtC, dt; + final long dt2, dt3; + long dtF, dtS, dtT; + final long[][] tC = new long[loops][numObjs]; + final long[][] t0 = new long[loops][numObjs]; + final long[][][] t1 = new long[loops][numObjs][numTextures]; + final long[][][] t2 = new long[loops][numObjs][numTextures]; + final long[][][] t3 = new long[loops][numObjs][numTextures]; + final long[][] tF = new long[loops][numObjs]; + final long[][] tS = new long[loops][numObjs]; for(int i=0; i<loops; i++) { for(int j=0; j<numObjs; j++) { tC[i][j] = System.currentTimeMillis(); - gl.glClear(gl.GL_COLOR_BUFFER_BIT | gl.GL_DEPTH_BUFFER_BIT); + gl.glClear(GL.GL_COLOR_BUFFER_BIT | GL.GL_DEPTH_BUFFER_BIT); t0[i][j] = System.currentTimeMillis(); @@ -140,7 +142,7 @@ public class PerfTextLoad extends PerfModule { t2[i][j][k] = System.currentTimeMillis(); - gl.glDrawArrays(GL.GL_TRIANGLE_STRIP, 0, vertices.getElementCount()); + gl.glDrawArrays(GL.GL_TRIANGLE_STRIP, 0, vertices.getElemCount()); t3[i][j][k] = System.currentTimeMillis(); } @@ -217,12 +219,12 @@ public class PerfTextLoad extends PerfModule { System.gc(); try { Thread.sleep(100); - } catch (Exception e) {} + } catch (final Exception e) {} System.gc(); } @Override - public void run(GLAutoDrawable drawable, int loops) { + public void run(final GLAutoDrawable drawable, final int loops) { runOneSet(drawable, "bob2.64x64", 33, 1, loops); runOneSet(drawable, "bob2.128x128", 33, 1, loops); runOneSet(drawable, "bob2.128x128", 4, 1, loops); diff --git a/src/demos/es2/perftst/PerfUniLoad.java b/src/demos/es2/perftst/PerfUniLoad.java index ae5e98a..94849a3 100755 --- a/src/demos/es2/perftst/PerfUniLoad.java +++ b/src/demos/es2/perftst/PerfUniLoad.java @@ -13,18 +13,19 @@ public class PerfUniLoad extends PerfModule { GLUniformData[] dummyA, dummyB, dummyC; final int dataType=GL.GL_FLOAT; - + public PerfUniLoad() { } - public ShaderState initShaderState(GL2ES2 gl) { + @Override + public ShaderState initShaderState(final GL2ES2 gl) { return initShaderState(gl, "uni-vert-col", "fcolor"); } - protected void runOneSet(GLAutoDrawable drawable, int numObjs, int numArrayElem, int loops) { - GL2ES2 gl = drawable.getGL().getGL2ES2(); + protected void runOneSet(final GLAutoDrawable drawable, final int numObjs, final int numArrayElem, final int loops) { + final GL2ES2 gl = drawable.getGL().getGL2ES2(); - // + // // Vertices Data setup // @@ -38,9 +39,9 @@ public class PerfUniLoad extends PerfModule { st.useProgram(gl, true); - GLArrayDataServer vertices = GLArrayDataServer.createGLSL("mgl_Vertex", 3, GL.GL_FLOAT, true, 4, GL.GL_STATIC_DRAW); + final GLArrayDataServer vertices = GLArrayDataServer.createGLSL("mgl_Vertex", 3, GL.GL_FLOAT, true, 4, GL.GL_STATIC_DRAW); { - FloatBuffer vb = (FloatBuffer)vertices.getBuffer(); + final FloatBuffer vb = (FloatBuffer)vertices.getBuffer(); vb.put(0f); vb.put(0f); vb.put(0f); vb.put(1f); vb.put(0f); vb.put(0f); vb.put(0f); vb.put(1f); vb.put(0f); @@ -48,9 +49,9 @@ public class PerfUniLoad extends PerfModule { } vertices.seal(gl, true); - GLArrayDataServer colors = GLArrayDataServer.createGLSL("mgl_Color", 4, GL.GL_FLOAT, true, 4, GL.GL_STATIC_DRAW); + final GLArrayDataServer colors = GLArrayDataServer.createGLSL("mgl_Color", 4, GL.GL_FLOAT, true, 4, GL.GL_STATIC_DRAW); { - FloatBuffer cb = (FloatBuffer)colors.getBuffer(); + final FloatBuffer cb = (FloatBuffer)colors.getBuffer(); cb.put(0f); cb.put(0f); cb.put(0f); cb.put(1f); cb.put(1f); cb.put(0f); cb.put(0f); cb.put(1f); cb.put(0f); cb.put(1f); cb.put(0f); cb.put(1f); @@ -62,12 +63,13 @@ public class PerfUniLoad extends PerfModule { // Uniform Data setup // - GLUniformData[] dummyUni = new GLUniformData[numObjs]; + final GLUniformData[] dummyUni = new GLUniformData[numObjs]; - float x=0f, y=0f, z=0f, w=0f; + float x=0f, y=0f, z=0f; + final float w=0f; for(int i=0; i<numObjs; i++) { - FloatBuffer fb = Buffers.newDirectFloatBuffer(4*numArrayElem); + final FloatBuffer fb = Buffers.newDirectFloatBuffer(4*numArrayElem); for(int j=0; j<numArrayElem; j++) { // Fill them up @@ -84,22 +86,24 @@ public class PerfUniLoad extends PerfModule { dummyUni[i] = new GLUniformData("mgl_Dummy"+i, 4, fb); } - // + // // run loops // - long dtC, dt, dt2, dt3, dtF, dtS, dtT; - long[] tC = new long[loops]; - long[] t0 = new long[loops]; - long[][] t1 = new long[loops][numObjs]; - long[][] t2 = new long[loops][numObjs]; - long[] tF = new long[loops]; - long[] tS = new long[loops]; + long dtC, dt; + final long dt2, dt3; + long dtF, dtS, dtT; + final long[] tC = new long[loops]; + final long[] t0 = new long[loops]; + final long[][] t1 = new long[loops][numObjs]; + final long[][] t2 = new long[loops][numObjs]; + final long[] tF = new long[loops]; + final long[] tS = new long[loops]; for(int i=0; i<loops; i++) { tC[i] = System.currentTimeMillis(); - gl.glClear(gl.GL_COLOR_BUFFER_BIT | gl.GL_DEPTH_BUFFER_BIT); + gl.glClear(GL.GL_COLOR_BUFFER_BIT | GL.GL_DEPTH_BUFFER_BIT); t0[i] = System.currentTimeMillis(); @@ -108,7 +112,7 @@ public class PerfUniLoad extends PerfModule { t1[i][j] = System.currentTimeMillis(); - gl.glDrawArrays(GL.GL_LINE_STRIP, 0, vertices.getElementCount()); + gl.glDrawArrays(GL.GL_LINE_STRIP, 0, vertices.getElemCount()); t2[i][j] = System.currentTimeMillis(); } @@ -122,8 +126,8 @@ public class PerfUniLoad extends PerfModule { tS[i] = System.currentTimeMillis(); } - int uniElements = numObjs * numArrayElem ; - int uniBytes = uniElements * Buffers.SIZEOF_FLOAT; + final int uniElements = numObjs * numArrayElem ; + final int uniBytes = uniElements * Buffers.SIZEOF_FLOAT; dt = 0; for(int i=1; i<loops; i++) { @@ -136,7 +140,7 @@ public class PerfUniLoad extends PerfModule { ",\n total elements "+uniElements+ ", total bytes "+uniBytes+", total time: "+dt + "ms, fps(-1): "+(((loops-1)*1000)/dt)+ - ",\n uni elem/s: " + ((double)(loops*uniElements)/((double)dt/1000.0))); + ",\n uni elem/s: " + (loops*uniElements/(dt/1000.0))); for(int i=0; i<loops; i++) { dtC= t0[i] - tC[i]; @@ -160,10 +164,11 @@ public class PerfUniLoad extends PerfModule { try { Thread.sleep(100); - } catch (Exception e) {} + } catch (final Exception e) {} } - public void run(GLAutoDrawable drawable, int loops) { + @Override + public void run(final GLAutoDrawable drawable, final int loops) { runOneSet(drawable, 1, 1, loops); runOneSet(drawable, 4, 1, loops); diff --git a/src/demos/es2/perftst/PerfVBOLoad.java b/src/demos/es2/perftst/PerfVBOLoad.java index 325b9a6..44dc81b 100755 --- a/src/demos/es2/perftst/PerfVBOLoad.java +++ b/src/demos/es2/perftst/PerfVBOLoad.java @@ -11,14 +11,15 @@ public class PerfVBOLoad extends PerfModule { public PerfVBOLoad() { } - public ShaderState initShaderState(GL2ES2 gl) { + @Override + public ShaderState initShaderState(final GL2ES2 gl) { return initShaderState(gl, "vbo-vert-col", "fcolor"); } - protected void runOneSet(GLAutoDrawable drawable, int dataType, int numObjs, int numVertices, int loops, boolean useVBO) { - GL2ES2 gl = drawable.getGL().getGL2ES2(); + protected void runOneSet(final GLAutoDrawable drawable, final int dataType, final int numObjs, final int numVertices, final int loops, final boolean useVBO) { + final GL2ES2 gl = drawable.getGL().getGL2ES2(); - // + // // data setup // @@ -32,7 +33,7 @@ public class PerfVBOLoad extends PerfModule { vertices[i] = GLArrayDataServer.createGLSL("mgl_Vertex", 3, dataType, true, numVertices, GL.GL_STATIC_DRAW); vertices[i].setVBOEnabled(useVBO); { - Buffer verticeb = vertices[i].getBuffer(); + final Buffer verticeb = vertices[i].getBuffer(); for(int j=0; j<numVertices; j++) { // Fill them up put(verticeb, dataType, x); @@ -47,7 +48,7 @@ public class PerfVBOLoad extends PerfModule { colors[i].setVBOEnabled(useVBO); { // Fill them up - Buffer colorb = colors[i].getBuffer(); + final Buffer colorb = colors[i].getBuffer(); for(int j =0; j<numVertices; j++) { put(colorb, dataType, r); put(colorb, dataType, g); @@ -56,31 +57,33 @@ public class PerfVBOLoad extends PerfModule { if(r<=1f) r+=0.01f; else if(g<=1f) g+=0.01f; else if(b<=1f) b+=0.01f; - else { r=0f; g=0f; b=0f; } + else { r=0f; g=0f; b=0f; } } } } - // + // // run loops // - long dtC, dt, dt2, dt3, dtF, dtS, dtT; - long[] tC = new long[loops]; - long[] t0 = new long[loops]; - long[][] t1 = new long[loops][numObjs]; - long[][] t2 = new long[loops][numObjs]; - long[][] t3 = new long[loops][numObjs]; - long[] tF = new long[loops]; - long[] tS = new long[loops]; - - // Push the 1st uniform down the path + long dtC, dt; + final long dt2, dt3; + long dtF, dtS, dtT; + final long[] tC = new long[loops]; + final long[] t0 = new long[loops]; + final long[][] t1 = new long[loops][numObjs]; + final long[][] t2 = new long[loops][numObjs]; + final long[][] t3 = new long[loops][numObjs]; + final long[] tF = new long[loops]; + final long[] tS = new long[loops]; + + // Push the 1st uniform down the path st.useProgram(gl, true); for(int i=0; i<loops; i++) { tC[i] = System.currentTimeMillis(); - gl.glClear(gl.GL_COLOR_BUFFER_BIT | gl.GL_DEPTH_BUFFER_BIT); + gl.glClear(GL.GL_COLOR_BUFFER_BIT | GL.GL_DEPTH_BUFFER_BIT); t0[i] = System.currentTimeMillis(); @@ -89,7 +92,7 @@ public class PerfVBOLoad extends PerfModule { vertices[j].seal(gl, true); } else if(numObjs>1) { // we need to re-enable the buffer, - // incl. the vertex attribute refresh + // incl. the vertex attribute refresh // in case we switch to another buffer vertices[j].enableBuffer(gl, true); } @@ -104,7 +107,7 @@ public class PerfVBOLoad extends PerfModule { t2[i][j] = System.currentTimeMillis(); - gl.glDrawArrays(GL.GL_LINE_STRIP, 0, vertices[j].getElementCount()); + gl.glDrawArrays(GL.GL_LINE_STRIP, 0, vertices[j].getElemCount()); if(numObjs>1) { vertices[j].enableBuffer(gl, false); @@ -128,10 +131,10 @@ public class PerfVBOLoad extends PerfModule { colors[0].enableBuffer(gl, false); } - int verticesElements = vertices[0].getElementCount() * numObjs; - int verticesBytes = verticesElements * vertices[0].getComponentSizeInBytes()* vertices[0].getComponentCount(); - int colorsElements = colors[0].getElementCount() * colors.length; - int colorsBytes = colorsElements * colors[0].getComponentSizeInBytes()* colors[0].getComponentCount(); + final int verticesElements = vertices[0].getElemCount() * numObjs; + final int verticesBytes = verticesElements * vertices[0].getBytesPerComp()* vertices[0].getCompsPerElem(); + final int colorsElements = colors[0].getElemCount() * colors.length; + final int colorsBytes = colorsElements * colors[0].getBytesPerComp()* colors[0].getCompsPerElem(); dt = 0; for(int i=1; i<loops; i++) { @@ -140,12 +143,12 @@ public class PerfVBOLoad extends PerfModule { System.out.println(""); System.out.println("Loops "+loops+", useVBO "+useVBO+", objects "+numObjs+", type "+getTypeName(dataType)+ - ", vertices p.o. "+vertices[0].getElementCount()+ - ", colors p.o. "+colors[0].getElementCount()+ + ", vertices p.o. "+vertices[0].getElemCount()+ + ", colors p.o. "+colors[0].getElemCount()+ ",\n total elements "+(verticesElements+colorsElements)+ ", total bytes "+(verticesBytes+colorsBytes)+", total time: "+dt + "ms, fps(-1): "+(((loops-1)*1000)/dt)+ - ",\n col.vert./s: " + ((double)(loops*verticesElements)/((double)dt/1000.0))); + ",\n col.vert./s: " + (loops*verticesElements/(dt/1000.0))); for(int i=0; i<loops; i++) { dtC= t0[i] - tC[i]; @@ -179,10 +182,10 @@ public class PerfVBOLoad extends PerfModule { try { Thread.sleep(100); - } catch (Exception e) {} + } catch (final Exception e) {} } - protected void runOneSet(GLAutoDrawable drawable, int numObjs, int numVertices, int loops) { + protected void runOneSet(final GLAutoDrawable drawable, final int numObjs, final int numVertices, final int loops) { runOneSet(drawable, GL.GL_UNSIGNED_BYTE, numObjs, numVertices, loops, true); runOneSet(drawable, GL.GL_UNSIGNED_BYTE, numObjs, numVertices, loops, false); runOneSet(drawable, GL.GL_BYTE, numObjs, numVertices, loops, true); @@ -194,14 +197,15 @@ public class PerfVBOLoad extends PerfModule { runOneSet(drawable, GL.GL_FLOAT, numObjs, numVertices, loops, true); runOneSet(drawable, GL.GL_FLOAT, numObjs, numVertices, loops, false); - GL2ES2 gl = drawable.getGL().getGL2ES2(); + final GL2ES2 gl = drawable.getGL().getGL2ES2(); if(gl.isGLES2()) { runOneSet(drawable, GL.GL_FIXED, numObjs, numVertices, loops, true); runOneSet(drawable, GL.GL_FIXED, numObjs, numVertices, loops, false); } } - public void run(GLAutoDrawable drawable, int loops) { + @Override + public void run(final GLAutoDrawable drawable, final int loops) { runOneSet(drawable, 1, 100, loops); runOneSet(drawable, 3, 100, loops); |