package demos.es2.perftst; import com.jogamp.common.nio.Buffers; import java.nio.*; import com.jogamp.opengl.*; import com.jogamp.opengl.util.*; import com.jogamp.opengl.util.glsl.ShaderState; 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() { } @Override public ShaderState initShaderState(final GL2ES2 gl) { return initShaderState(gl, "uni-vert-col", "fcolor"); } protected void runOneSet(final GLAutoDrawable drawable, final int numObjs, final int numArrayElem, final int loops) { final 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.useProgram(gl, true); final GLArrayDataServer vertices = GLArrayDataServer.createGLSL("mgl_Vertex", 3, GL.GL_FLOAT, true, 4, GL.GL_STATIC_DRAW); { 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); vb.put(1f); vb.put(1f); vb.put(0f); } vertices.seal(gl, true); final GLArrayDataServer colors = GLArrayDataServer.createGLSL("mgl_Color", 4, GL.GL_FLOAT, true, 4, GL.GL_STATIC_DRAW); { 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); cb.put(0f); cb.put(0f); cb.put(1f); cb.put(1f); } colors.seal(gl, true); // // Uniform Data setup // final GLUniformData[] dummyUni = new GLUniformData[numObjs]; float x=0f, y=0f, z=0f; final float 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; 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; 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); } } }