Jason Sams | e448dd1 | 2010-07-09 15:34:32 -0700 | [diff] [blame] | 1 | /* |
| 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 McFadden | a5c381f | 2010-07-12 09:17:13 -0700 | [diff] [blame] | 22 | #include <string.h> |
Jason Sams | e448dd1 | 2010-07-09 15:34:32 -0700 | [diff] [blame] | 23 | |
| 24 | #include <GLES2/gl2.h> |
| 25 | #include <GLES2/gl2ext.h> |
| 26 | #include <utils/Timers.h> |
| 27 | #include <EGL/egl.h> |
Jason Sams | 7920987 | 2010-07-20 19:37:58 -0700 | [diff] [blame] | 28 | #include <utils/Log.h> |
Jason Sams | e448dd1 | 2010-07-09 15:34:32 -0700 | [diff] [blame] | 29 | |
| 30 | |
| 31 | using namespace android; |
| 32 | |
Jason Sams | e448dd1 | 2010-07-09 15:34:32 -0700 | [diff] [blame] | 33 | |
Jason Sams | 7920987 | 2010-07-20 19:37:58 -0700 | [diff] [blame] | 34 | #include "fill_common.cpp" |
Jason Sams | e448dd1 | 2010-07-09 15:34:32 -0700 | [diff] [blame] | 35 | |
| 36 | static 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 Sams | e448dd1 | 2010-07-09 15:34:32 -0700 | [diff] [blame] | 49 | if (loc >= 0) glUniform1i(loc, 0); |
| 50 | loc = glGetUniformLocation(pgm, "u_tex1"); |
| 51 | if (loc >= 0) glUniform1i(loc, 1); |
| 52 | |
Jason Sams | e448dd1 | 2010-07-09 15:34:32 -0700 | [diff] [blame] | 53 | 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 Sams | 7920987 | 2010-07-20 19:37:58 -0700 | [diff] [blame] | 63 | //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 Sams | e448dd1 | 2010-07-09 15:34:32 -0700 | [diff] [blame] | 67 | |
| 68 | glEnable(GL_BLEND); |
Jason Sams | e0f1cff | 2010-07-12 11:41:46 -0700 | [diff] [blame] | 69 | sprintf(str2, "%i, %i, %i, %i, %i, 1", |
Jason Sams | e448dd1 | 2010-07-09 15:34:32 -0700 | [diff] [blame] | 70 | useVarColor, texCount, modulateFirstTex, extraMath, tex0); |
Jason Sams | 7920987 | 2010-07-20 19:37:58 -0700 | [diff] [blame] | 71 | doLoop(true, pgm, w, h, str2); |
| 72 | doLoop(false, pgm, w, h, str2); |
Jason Sams | e448dd1 | 2010-07-09 15:34:32 -0700 | [diff] [blame] | 73 | } |
| 74 | |
| 75 | bool doTest(uint32_t w, uint32_t h) { |
| 76 | setupVA(); |
| 77 | genTextures(); |
| 78 | |
Jason Sams | e0f1cff | 2010-07-12 11:41:46 -0700 | [diff] [blame] | 79 | printf("\nvarColor, texCount, modulate, extraMath, texSize, blend, Mpps, DC60\n"); |
| 80 | |
Jason Sams | 7920987 | 2010-07-20 19:37:58 -0700 | [diff] [blame] | 81 | for (int texCount = 0; texCount < 2; texCount++) { |
Jason Sams | e448dd1 | 2010-07-09 15:34:32 -0700 | [diff] [blame] | 82 | 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 | } |