package demos.es2.perftst; import java.nio.*; import javax.media.opengl.*; import com.sun.opengl.util.*; import com.sun.javafx.newt.*; import com.sun.javafx.newt.opengl.*; public class PerfUniLoad extends PerfModule { static final int MAX_ARRAYS = 12; static final int MAX_ARRAY_ELEM = 16; GLUniformData[] dummyA, dummyB, dummyC; final int dataType=GL.GL_FLOAT; public PerfUniLoad() { } public void initShaderState(GL2ES2 gl) { initShaderState(gl, "uni-vert-col", "fcolor"); } protected void runOneSet(GLAutoDrawable drawable, int numObjs, int numArrayElem, int loops) { GL2ES2 gl = drawable.getGL().getGL2ES2(); // // Vertices Data setup // if(numObjs>MAX_ARRAYS) { throw new GLException("numObjs must be within 0.."+MAX_ARRAYS); } if(numArrayElem>MAX_ARRAY_ELEM) { throw new GLException("numArrayElem must be within 0.."+MAX_ARRAY_ELEM); } st.glUseProgram(gl, true); GLArrayDataServer vertices = GLArrayDataServer.createGLSL(gl, "mgl_Vertex", 3, GL.GL_FLOAT, true, 4, GL.GL_STATIC_DRAW); { 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); vb.put(1f); vb.put(1f); vb.put(0f); } vertices.seal(gl, true); GLArrayDataServer colors = GLArrayDataServer.createGLSL(gl, "mgl_Color", 4, GL.GL_FLOAT, true, 4, GL.GL_STATIC_DRAW); { 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); cb.put(0f); cb.put(0f); cb.put(1f); cb.put(1f); } colors.seal(gl, true); // // Uniform Data setup // GLUniformData[] dummyUni = new GLUniformData[numObjs]; float x=0f, y=0f, z=0f, w=0f; for(int i=0; i1f) { x=0f; y=0f; z+=0.01f; } } fb.flip(); 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]; for(int i=0; i8) { runOneSet(drawable, MAX_ARRAYS, 1, loops); runOneSet(drawable, 1, MAX_ARRAYS, loops); } runOneSet(drawable, 1, 16, loops); runOneSet(drawable, 2, 16, loops); runOneSet(drawable, 4, 16, loops); runOneSet(drawable, 8, 16, loops); if(MAX_ARRAYS>8) { runOneSet(drawable, MAX_ARRAYS, 16, loops); } } }