Update To 11.40.268.0
[platform/framework/web/crosswalk.git] / src / third_party / angle / tests / perf_tests / SimpleBenchmarks.cpp
1 //
2 // Copyright (c) 2014 The ANGLE Project Authors. All rights reserved.
3 // Use of this source code is governed by a BSD-style license that can be
4 // found in the LICENSE file.
5 //
6
7 #include "SimpleBenchmark.h"
8 #include "BufferSubData.h"
9 #include "TexSubImage.h"
10 #include "PointSprites.h"
11
12 EGLint platforms[] =
13 {
14     EGL_PLATFORM_ANGLE_TYPE_D3D9_ANGLE,
15     EGL_PLATFORM_ANGLE_TYPE_D3D11_ANGLE
16 };
17
18 GLenum vertexTypes[] = { GL_FLOAT };
19 GLint componentCounts[] = { 4 };
20 GLboolean vertexNorms[] = { GL_FALSE };
21 GLsizeiptr updateSizes[] = { 300 };
22 GLsizeiptr bufferSizes[] = { 1024 * 1024 };
23 unsigned int iterationCounts[] = { 10 };
24 unsigned int updatesEveryNFrames[] = { 1, 4 };
25
26 int main(int argc, char **argv)
27 {
28     std::vector<BufferSubDataParams> subDataParams;
29
30     for (size_t platIt = 0; platIt < ArraySize(platforms); platIt++)
31     {
32         for (size_t typeIt = 0; typeIt < ArraySize(vertexTypes); typeIt++)
33         {
34             for (size_t compIt = 0; compIt < ArraySize(componentCounts); compIt++)
35             {
36                 for (size_t normIt = 0; normIt < ArraySize(vertexNorms); normIt++)
37                 {
38                     // No normalized float data
39                     if (vertexTypes[typeIt] == GL_FLOAT && vertexNorms[normIt] == GL_TRUE)
40                     {
41                         continue;
42                     }
43
44                     for (size_t updateIt = 0; updateIt < ArraySize(updateSizes); updateIt++)
45                     {
46                         for (size_t bufszIt = 0; bufszIt < ArraySize(bufferSizes); bufszIt++)
47                         {
48                             for (size_t itIt = 0; itIt < ArraySize(iterationCounts); itIt++)
49                             {
50                                 for (size_t nfrIt = 0; nfrIt < ArraySize(updatesEveryNFrames); nfrIt++)
51                                 {
52                                     BufferSubDataParams params;
53                                     params.requestedRenderer = platforms[platIt];
54                                     params.vertexType = vertexTypes[typeIt];
55                                     params.vertexComponentCount = componentCounts[compIt];
56                                     params.vertexNormalized = vertexNorms[normIt];
57                                     params.updateSize = updateSizes[updateIt];
58                                     params.bufferSize = bufferSizes[bufszIt];
59                                     params.iterations = iterationCounts[itIt];
60                                     params.updatesEveryNFrames = updatesEveryNFrames[nfrIt];
61
62                                     if (updateSizes[updateIt] == 0)
63                                     {
64                                         if (nfrIt > 0)
65                                         {
66                                             continue;
67                                         }
68                                         else
69                                         {
70                                             params.updatesEveryNFrames = 1;
71                                         }
72                                     }
73
74                                     subDataParams.push_back(params);
75                                 }
76                             }
77                         }
78                     }
79                 }
80             }
81         }
82     }
83
84     // Enumerates permutations
85     RunBenchmarks<BufferSubDataBenchmark>(subDataParams);
86
87     std::vector<TexSubImageParams> subImageParams;
88
89     for (size_t platIt = 0; platIt < ArraySize(platforms); platIt++)
90     {
91         TexSubImageParams params;
92
93         params.requestedRenderer = platforms[platIt];
94         params.imageWidth = 1024;
95         params.imageHeight = 1024;
96         params.subImageHeight = 64;
97         params.subImageWidth = 64;
98         params.iterations = 10;
99
100         subImageParams.push_back(params);
101     }
102
103     RunBenchmarks<TexSubImageBenchmark>(subImageParams);
104
105     std::vector<PointSpritesParams> pointSpriteParams;
106
107     for (size_t platIt = 0; platIt < ArraySize(platforms); platIt++)
108     {
109         PointSpritesParams params;
110
111         params.requestedRenderer = platforms[platIt];
112         params.iterations = 10;
113         params.count = 10;
114         params.size = 3.0f;
115         params.numVaryings = 3;
116
117         pointSpriteParams.push_back(params);
118     }
119
120     RunBenchmarks<PointSpritesBenchmark>(pointSpriteParams);
121 }