From d997f71d3046424e977352d442b4944369ddbe9a Mon Sep 17 00:00:00 2001 From: Jason Sams Date: Wed, 8 Sep 2010 15:22:06 -0700 Subject: Rework gl perf test to focus on important use cases. Change-Id: I82825dbe3b24a520b79f6b05d01f37e1b5008b62 --- opengl/tests/gl_perfapp/jni/gl_code.cpp | 139 ++++++-------------------------- 1 file changed, 24 insertions(+), 115 deletions(-) (limited to 'opengl/tests/gl_perfapp/jni/gl_code.cpp') diff --git a/opengl/tests/gl_perfapp/jni/gl_code.cpp b/opengl/tests/gl_perfapp/jni/gl_code.cpp index e643292..f993371 100644 --- a/opengl/tests/gl_perfapp/jni/gl_code.cpp +++ b/opengl/tests/gl_perfapp/jni/gl_code.cpp @@ -32,82 +32,17 @@ bool done; // Saves the parameters of the test (so we can print them out when we finish the timing.) -char saveBuf[1024]; - int pgm; void ptSwap() { } -static void doSingleTest(uint32_t w, uint32_t h, - bool useVarColor, - int texCount, - bool modulateFirstTex, - int extraMath, - int tex0, int tex1) { - int doSingleTestState = (stateClock / doLoopStates) % doSingleTestStates; - // LOGI("doSingleTest %d\n", doSingleTestState); - switch (doSingleTestState) { - case 0: { - char *pgmTxt = genShader(useVarColor, texCount, modulateFirstTex, extraMath); - pgm = createProgram(gVertexShader, pgmTxt); - if (!pgm) { - LOGE("error running test\n"); - return; - } - int loc = glGetUniformLocation(pgm, "u_tex0"); - if (loc >= 0) glUniform1i(loc, 0); - loc = glGetUniformLocation(pgm, "u_tex1"); - if (loc >= 0) glUniform1i(loc, 1); - - glActiveTexture(GL_TEXTURE0); - glBindTexture(GL_TEXTURE_2D, tex0); - glActiveTexture(GL_TEXTURE1); - glBindTexture(GL_TEXTURE_2D, tex1); - glActiveTexture(GL_TEXTURE0); - - - glBlendFunc(GL_ONE, GL_ONE); - glDisable(GL_BLEND); - char str2[1024]; - sprintf(str2, "%i, %i, %i, %i, %i, 0", - useVarColor, texCount, modulateFirstTex, extraMath, tex0); - - doLoop((stateClock % doLoopStates) != 0, pgm, w, h, str2); - } - break; - case 1: { - char str2[1024]; - glEnable(GL_BLEND); - sprintf(str2, "%i, %i, %i, %i, %i, 1", - useVarColor, texCount, modulateFirstTex, extraMath, tex0); - doLoop((stateClock % doLoopStates) != 0, pgm, w, h, str2); - } - break; - } -} - - -void doTest(uint32_t w, uint32_t h) { - int testState = stateClock / (doLoopStates * doSingleTestStates); - int texCount; - int extraMath; - int testSubState; - const int extraMathCount = 5; - const int texCount0SubTestCount = 2; - const int texCountNSubTestCount = 8; +void doTest() { + uint32_t testNum = stateClock >> 2; + int texSize = ((stateClock >> 1) & 0x1) + 1; - if ( testState < extraMathCount * texCount0SubTestCount) { - texCount = 0; // Only 10 tests for texCount 0 - extraMath = (testState / texCount0SubTestCount) % extraMathCount; - testSubState = testState % texCount0SubTestCount; - } else { - texCount = 1 + (testState - extraMathCount * texCount0SubTestCount) / (extraMathCount * texCountNSubTestCount); - extraMath = (testState / texCountNSubTestCount) % extraMathCount; - testSubState = testState % texCountNSubTestCount; - } - if (texCount >= 3) { + if (testNum >= gFragmentTestCount) { LOGI("done\n"); if (fOut) { fclose(fOut); @@ -117,36 +52,10 @@ void doTest(uint32_t w, uint32_t h) { return; } - // LOGI("doTest %d %d %d\n", texCount, extraMath, testSubState); - switch(testSubState) { - case 0: - doSingleTest(w, h, false, texCount, false, extraMath, 1, 1); - break; - case 1: - doSingleTest(w, h, true, texCount, false, extraMath, 1, 1); - break; - case 2: - doSingleTest(w, h, false, texCount, true, extraMath, 1, 1); - break; - case 3: - doSingleTest(w, h, true, texCount, true, extraMath, 1, 1); - break; - - case 4: - doSingleTest(w, h, false, texCount, false, extraMath, 2, 2); - break; - case 5: - doSingleTest(w, h, true, texCount, false, extraMath, 2, 2); - break; - case 6: - doSingleTest(w, h, false, texCount, true, extraMath, 2, 2); - break; - case 7: - doSingleTest(w, h, true, texCount, true, extraMath, 2, 2); - break; - } +// for (uint32_t num = 0; num < gFragmentTestCount; num++) { + doSingleTest(testNum, texSize); } extern "C" { @@ -156,27 +65,27 @@ extern "C" { JNIEXPORT void JNICALL Java_com_android_glperf_GLPerfLib_init(JNIEnv * env, jobject obj, jint width, jint height) { + gWidth = width; + gHeight = height; if (!done) { - w = width; - h = height; - stateClock = 0; - done = false; - setupVA(); - genTextures(); - const char* fileName = "/sdcard/glperf.csv"; + stateClock = 0; + done = false; + setupVA(); + genTextures(); + const char* fileName = "/sdcard/glperf.csv"; if (fOut != NULL) { LOGI("Closing partially written output.n"); fclose(fOut); fOut = NULL; } - LOGI("Writing to: %s\n",fileName); - fOut = fopen(fileName, "w"); - if (fOut == NULL) { - LOGE("Could not open: %s\n", fileName); - } - - LOGI("\nvarColor, texCount, modulate, extraMath, texSize, blend, Mpps, DC60\n"); - if (fOut) fprintf(fOut,"varColor, texCount, modulate, extraMath, texSize, blend, Mpps, DC60\r\n"); + LOGI("Writing to: %s\n",fileName); + fOut = fopen(fileName, "w"); + if (fOut == NULL) { + LOGE("Could not open: %s\n", fileName); + } + + LOGI("\nvarColor, texCount, modulate, extraMath, texSize, blend, Mpps, DC60\n"); + if (fOut) fprintf(fOut,"varColor, texCount, modulate, extraMath, texSize, blend, Mpps, DC60\r\n"); } } @@ -184,11 +93,11 @@ JNIEXPORT void JNICALL Java_com_android_glperf_GLPerfLib_step(JNIEnv * env, jobj { if (! done) { if (stateClock > 0 && ((stateClock & 1) == 0)) { - endTimer(saveBuf, w, h, 1, 100); + //endTimer(100); } - doTest(w, h); + doTest(); stateClock++; } else { - glClear(GL_DEPTH_BUFFER_BIT | GL_COLOR_BUFFER_BIT); + glClear(GL_DEPTH_BUFFER_BIT | GL_COLOR_BUFFER_BIT); } } -- cgit v1.1