blob: 0dd4e22ecc6fa737760527e1460e605e3737a919 [file] [log] [blame]
Jason Samse448dd12010-07-09 15:34:32 -07001/*
2 * Copyright (C) 2007 The Android Open Source Project
3 *
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
7 *
8 * http://www.apache.org/licenses/LICENSE-2.0
9 *
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
15 */
16
17#include <stdlib.h>
18#include <stdio.h>
19#include <time.h>
20#include <sched.h>
21#include <sys/resource.h>
Andy McFaddena5c381f2010-07-12 09:17:13 -070022#include <string.h>
Jason Samse448dd12010-07-09 15:34:32 -070023
24#include <GLES2/gl2.h>
25#include <GLES2/gl2ext.h>
26#include <utils/Timers.h>
27#include <EGL/egl.h>
Jason Sams79209872010-07-20 19:37:58 -070028#include <utils/Log.h>
Jason Samse448dd12010-07-09 15:34:32 -070029
30
31using namespace android;
32
Jason Samse448dd12010-07-09 15:34:32 -070033
Jason Sams79209872010-07-20 19:37:58 -070034#include "fill_common.cpp"
Jason Samse448dd12010-07-09 15:34:32 -070035
36static void doSingleTest(uint32_t w, uint32_t h,
37 bool useVarColor,
38 int texCount,
39 bool modulateFirstTex,
40 int extraMath,
41 int tex0, int tex1) {
42 char *pgmTxt = genShader(useVarColor, texCount, modulateFirstTex, extraMath);
43 int pgm = createProgram(gVertexShader, pgmTxt);
44 if (!pgm) {
45 printf("error running test\n");
46 return;
47 }
48 int loc = glGetUniformLocation(pgm, "u_tex0");
Jason Samse448dd12010-07-09 15:34:32 -070049 if (loc >= 0) glUniform1i(loc, 0);
50 loc = glGetUniformLocation(pgm, "u_tex1");
51 if (loc >= 0) glUniform1i(loc, 1);
52
Jason Samse448dd12010-07-09 15:34:32 -070053 glActiveTexture(GL_TEXTURE0);
54 glBindTexture(GL_TEXTURE_2D, tex0);
55 glActiveTexture(GL_TEXTURE1);
56 glBindTexture(GL_TEXTURE_2D, tex1);
57 glActiveTexture(GL_TEXTURE0);
58
59 char str2[1024];
60
61 glBlendFunc(GL_ONE, GL_ONE);
62 glDisable(GL_BLEND);
Jason Sams79209872010-07-20 19:37:58 -070063 //sprintf(str2, "%i, %i, %i, %i, %i, 0",
64 //useVarColor, texCount, modulateFirstTex, extraMath, tex0);
65 //doLoop(true, pgm, w, h, str2);
66 //doLoop(false, pgm, w, h, str2);
Jason Samse448dd12010-07-09 15:34:32 -070067
68 glEnable(GL_BLEND);
Jason Samse0f1cff2010-07-12 11:41:46 -070069 sprintf(str2, "%i, %i, %i, %i, %i, 1",
Jason Samse448dd12010-07-09 15:34:32 -070070 useVarColor, texCount, modulateFirstTex, extraMath, tex0);
Jason Sams79209872010-07-20 19:37:58 -070071 doLoop(true, pgm, w, h, str2);
72 doLoop(false, pgm, w, h, str2);
Jason Samse448dd12010-07-09 15:34:32 -070073}
74
75bool doTest(uint32_t w, uint32_t h) {
76 setupVA();
77 genTextures();
78
Jason Samse0f1cff2010-07-12 11:41:46 -070079 printf("\nvarColor, texCount, modulate, extraMath, texSize, blend, Mpps, DC60\n");
80
Jason Sams79209872010-07-20 19:37:58 -070081 for (int texCount = 0; texCount < 2; texCount++) {
Jason Samse448dd12010-07-09 15:34:32 -070082 for (int extraMath = 0; extraMath < 5; extraMath++) {
83
84 doSingleTest(w, h, false, texCount, false, extraMath, 1, 1);
85 doSingleTest(w, h, true, texCount, false, extraMath, 1, 1);
86 if (texCount) {
87 doSingleTest(w, h, false, texCount, true, extraMath, 1, 1);
88 doSingleTest(w, h, true, texCount, true, extraMath, 1, 1);
89
90 doSingleTest(w, h, false, texCount, false, extraMath, 2, 2);
91 doSingleTest(w, h, true, texCount, false, extraMath, 2, 2);
92 doSingleTest(w, h, false, texCount, true, extraMath, 2, 2);
93 doSingleTest(w, h, true, texCount, true, extraMath, 2, 2);
94 }
95 }
96 }
97
98 exit(0);
99 return true;
100}