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