filltest.cpp revision 7920987182de225959a3bf40f36fd5ee23204cae
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>
22#include <string.h>
23
24#include <GLES2/gl2.h>
25#include <GLES2/gl2ext.h>
26#include <utils/Timers.h>
27#include <EGL/egl.h>
28#include <utils/Log.h>
29
30
31using namespace android;
32
33
34#include "fill_common.cpp"
35
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");
49    if (loc >= 0) glUniform1i(loc, 0);
50    loc = glGetUniformLocation(pgm, "u_tex1");
51    if (loc >= 0) glUniform1i(loc, 1);
52
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);
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);
67
68    glEnable(GL_BLEND);
69    sprintf(str2, "%i, %i, %i, %i, %i, 1",
70            useVarColor, texCount, modulateFirstTex, extraMath, tex0);
71    doLoop(true, pgm, w, h, str2);
72    doLoop(false, pgm, w, h, str2);
73}
74
75bool doTest(uint32_t w, uint32_t h) {
76    setupVA();
77    genTextures();
78
79    printf("\nvarColor, texCount, modulate, extraMath, texSize, blend, Mpps, DC60\n");
80
81    for (int texCount = 0; texCount < 2; texCount++) {
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}
101