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