• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 // OpenGL ES 2.0 code
2 
3 #include <jni.h>
4 #define LOG_TAG "GLPerf gl_code.cpp"
5 #include <utils/Log.h>
6 
7 #include <EGL/egl.h>
8 #include <GLES2/gl2.h>
9 #include <GLES2/gl2ext.h>
10 #include <utils/Timers.h>
11 
12 #include <stdio.h>
13 #include <stdlib.h>
14 #include <math.h>
15 
16 #include "../../gl_perf/fill_common.cpp"
17 
18 
19 //////////////////////////
20 
21 // Width and height of the screen
22 
23 uint32_t w;
24 uint32_t h;
25 
26 // The stateClock starts at zero and increments by 1 every time we draw a frame. It is used to control which phase of the test we are in.
27 
28 int stateClock;
29 bool done;
30 
31 // Saves the parameters of the test (so we can print them out when we finish the timing.)
32 
33 
34 int pgm;
35 
ptSwap()36 void ptSwap() {
37 }
38 
doTest()39 void doTest() {
40     uint32_t testNum = stateClock >> 2;
41     int texSize = ((stateClock >> 1) & 0x1) + 1;
42 
43     if (testNum >= gFragmentTestCount) {
44        ALOGI("done\n");
45        if (fOut) {
46            fclose(fOut);
47            fOut = NULL;
48        }
49        done = true;
50        return;
51     }
52 
53     // ALOGI("doTest %d %d %d\n", texCount, extraMath, testSubState);
54 
55 //        for (uint32_t num = 0; num < gFragmentTestCount; num++) {
56     doSingleTest(testNum, texSize);
57 }
58 
59 extern "C" {
60     JNIEXPORT void JNICALL Java_com_android_glperf_GLPerfLib_init(JNIEnv * env, jobject obj,  jint width, jint height);
61     JNIEXPORT void JNICALL Java_com_android_glperf_GLPerfLib_step(JNIEnv * env, jobject obj);
62 };
63 
Java_com_android_glperf_GLPerfLib_init(JNIEnv *,jobject,jint width,jint height)64 JNIEXPORT void JNICALL Java_com_android_glperf_GLPerfLib_init(JNIEnv * /*env*/, jobject /*obj*/,  jint width, jint height)
65 {
66     gWidth = width;
67     gHeight = height;
68     if (!done) {
69             stateClock = 0;
70             done = false;
71             setupVA();
72             genTextures();
73             const char* fileName = "/sdcard/glperf.csv";
74             if (fOut != NULL) {
75                  ALOGI("Closing partially written output.n");
76                  fclose(fOut);
77                  fOut = NULL;
78             }
79             ALOGI("Writing to: %s\n",fileName);
80             fOut = fopen(fileName, "w");
81             if (fOut == NULL) {
82                 ALOGE("Could not open: %s\n", fileName);
83             }
84 
85             ALOGI("\nvarColor, texCount, modulate, extraMath, texSize, blend, Mpps, DC60\n");
86             if (fOut) fprintf(fOut,"varColor, texCount, modulate, extraMath, texSize, blend, Mpps, DC60\r\n");
87     }
88 }
89 
Java_com_android_glperf_GLPerfLib_step(JNIEnv *,jobject)90 JNIEXPORT void JNICALL Java_com_android_glperf_GLPerfLib_step(JNIEnv * /*env*/, jobject /*obj*/)
91 {
92     if (! done) {
93         if (stateClock > 0 && ((stateClock & 1) == 0)) {
94             //endTimer(100);
95         }
96         doTest();
97         stateClock++;
98     } else {
99             glClear(GL_DEPTH_BUFFER_BIT | GL_COLOR_BUFFER_BIT);
100     }
101 }
102