2010-07-19 23:27:54 +00:00
|
|
|
// 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>
|
|
|
|
|
2010-07-21 02:37:58 +00:00
|
|
|
#include "../../gl_perf/fill_common.cpp"
|
2010-07-20 00:39:52 +00:00
|
|
|
|
2010-07-19 23:27:54 +00:00
|
|
|
|
|
|
|
//////////////////////////
|
|
|
|
|
2010-07-20 00:39:52 +00:00
|
|
|
// Width and height of the screen
|
2010-07-19 23:27:54 +00:00
|
|
|
|
|
|
|
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;
|
|
|
|
|
2010-07-20 00:39:52 +00:00
|
|
|
// Saves the parameters of the test (so we can print them out when we finish the timing.)
|
|
|
|
|
2010-07-21 02:37:58 +00:00
|
|
|
|
|
|
|
int pgm;
|
|
|
|
|
|
|
|
void ptSwap() {
|
2010-07-19 23:27:54 +00:00
|
|
|
}
|
|
|
|
|
2010-09-08 22:22:06 +00:00
|
|
|
void doTest() {
|
|
|
|
uint32_t testNum = stateClock >> 2;
|
|
|
|
int texSize = ((stateClock >> 1) & 0x1) + 1;
|
2010-07-20 01:01:39 +00:00
|
|
|
|
2010-09-08 22:22:06 +00:00
|
|
|
if (testNum >= gFragmentTestCount) {
|
2012-01-04 20:05:49 +00:00
|
|
|
ALOGI("done\n");
|
2010-07-21 02:37:58 +00:00
|
|
|
if (fOut) {
|
|
|
|
fclose(fOut);
|
|
|
|
fOut = NULL;
|
2010-07-20 00:39:52 +00:00
|
|
|
}
|
2010-07-19 23:27:54 +00:00
|
|
|
done = true;
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2012-01-04 20:05:49 +00:00
|
|
|
// ALOGI("doTest %d %d %d\n", texCount, extraMath, testSubState);
|
2010-07-20 00:01:25 +00:00
|
|
|
|
2010-09-08 22:22:06 +00:00
|
|
|
// for (uint32_t num = 0; num < gFragmentTestCount; num++) {
|
|
|
|
doSingleTest(testNum, texSize);
|
2010-07-19 23:27:54 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
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)
|
|
|
|
{
|
2010-09-08 22:22:06 +00:00
|
|
|
gWidth = width;
|
|
|
|
gHeight = height;
|
2010-07-20 00:52:12 +00:00
|
|
|
if (!done) {
|
2010-09-08 22:22:06 +00:00
|
|
|
stateClock = 0;
|
|
|
|
done = false;
|
|
|
|
setupVA();
|
|
|
|
genTextures();
|
|
|
|
const char* fileName = "/sdcard/glperf.csv";
|
2010-07-21 02:37:58 +00:00
|
|
|
if (fOut != NULL) {
|
2012-01-04 20:05:49 +00:00
|
|
|
ALOGI("Closing partially written output.n");
|
2010-07-21 02:37:58 +00:00
|
|
|
fclose(fOut);
|
|
|
|
fOut = NULL;
|
2010-07-20 00:52:12 +00:00
|
|
|
}
|
2012-01-04 20:05:49 +00:00
|
|
|
ALOGI("Writing to: %s\n",fileName);
|
2010-09-08 22:22:06 +00:00
|
|
|
fOut = fopen(fileName, "w");
|
|
|
|
if (fOut == NULL) {
|
2012-01-06 19:20:56 +00:00
|
|
|
ALOGE("Could not open: %s\n", fileName);
|
2010-09-08 22:22:06 +00:00
|
|
|
}
|
|
|
|
|
2012-01-04 20:05:49 +00:00
|
|
|
ALOGI("\nvarColor, texCount, modulate, extraMath, texSize, blend, Mpps, DC60\n");
|
2010-09-08 22:22:06 +00:00
|
|
|
if (fOut) fprintf(fOut,"varColor, texCount, modulate, extraMath, texSize, blend, Mpps, DC60\r\n");
|
2010-07-20 00:52:12 +00:00
|
|
|
}
|
2010-07-19 23:27:54 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
JNIEXPORT void JNICALL Java_com_android_glperf_GLPerfLib_step(JNIEnv * env, jobject obj)
|
|
|
|
{
|
|
|
|
if (! done) {
|
2010-07-20 00:01:25 +00:00
|
|
|
if (stateClock > 0 && ((stateClock & 1) == 0)) {
|
2010-09-08 22:22:06 +00:00
|
|
|
//endTimer(100);
|
2010-07-19 23:27:54 +00:00
|
|
|
}
|
2010-09-08 22:22:06 +00:00
|
|
|
doTest();
|
2010-07-19 23:27:54 +00:00
|
|
|
stateClock++;
|
2010-07-20 00:01:25 +00:00
|
|
|
} else {
|
2010-09-08 22:22:06 +00:00
|
|
|
glClear(GL_DEPTH_BUFFER_BIT | GL_COLOR_BUFFER_BIT);
|
2010-07-19 23:27:54 +00:00
|
|
|
}
|
|
|
|
}
|