1*35238bceSAndroid Build Coastguard Worker /*-------------------------------------------------------------------------
2*35238bceSAndroid Build Coastguard Worker * drawElements Quality Program EGL Module
3*35238bceSAndroid Build Coastguard Worker * ---------------------------------------
4*35238bceSAndroid Build Coastguard Worker *
5*35238bceSAndroid Build Coastguard Worker * Copyright 2014 The Android Open Source Project
6*35238bceSAndroid Build Coastguard Worker *
7*35238bceSAndroid Build Coastguard Worker * Licensed under the Apache License, Version 2.0 (the "License");
8*35238bceSAndroid Build Coastguard Worker * you may not use this file except in compliance with the License.
9*35238bceSAndroid Build Coastguard Worker * You may obtain a copy of the License at
10*35238bceSAndroid Build Coastguard Worker *
11*35238bceSAndroid Build Coastguard Worker * http://www.apache.org/licenses/LICENSE-2.0
12*35238bceSAndroid Build Coastguard Worker *
13*35238bceSAndroid Build Coastguard Worker * Unless required by applicable law or agreed to in writing, software
14*35238bceSAndroid Build Coastguard Worker * distributed under the License is distributed on an "AS IS" BASIS,
15*35238bceSAndroid Build Coastguard Worker * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16*35238bceSAndroid Build Coastguard Worker * See the License for the specific language governing permissions and
17*35238bceSAndroid Build Coastguard Worker * limitations under the License.
18*35238bceSAndroid Build Coastguard Worker *
19*35238bceSAndroid Build Coastguard Worker *//*!
20*35238bceSAndroid Build Coastguard Worker * \file
21*35238bceSAndroid Build Coastguard Worker * \brief GLES2 resource sharing performnace tests.
22*35238bceSAndroid Build Coastguard Worker *//*--------------------------------------------------------------------*/
23*35238bceSAndroid Build Coastguard Worker
24*35238bceSAndroid Build Coastguard Worker #include "teglGLES2SharedRenderingPerfTests.hpp"
25*35238bceSAndroid Build Coastguard Worker
26*35238bceSAndroid Build Coastguard Worker #include "tcuTestLog.hpp"
27*35238bceSAndroid Build Coastguard Worker
28*35238bceSAndroid Build Coastguard Worker #include "egluUtil.hpp"
29*35238bceSAndroid Build Coastguard Worker #include "eglwLibrary.hpp"
30*35238bceSAndroid Build Coastguard Worker #include "eglwEnums.hpp"
31*35238bceSAndroid Build Coastguard Worker
32*35238bceSAndroid Build Coastguard Worker #include "gluDefs.hpp"
33*35238bceSAndroid Build Coastguard Worker #include "glwDefs.hpp"
34*35238bceSAndroid Build Coastguard Worker #include "glwEnums.hpp"
35*35238bceSAndroid Build Coastguard Worker #include "glwFunctions.hpp"
36*35238bceSAndroid Build Coastguard Worker
37*35238bceSAndroid Build Coastguard Worker #include "deThread.hpp"
38*35238bceSAndroid Build Coastguard Worker #include "deClock.h"
39*35238bceSAndroid Build Coastguard Worker #include "deStringUtil.hpp"
40*35238bceSAndroid Build Coastguard Worker #include "deSTLUtil.hpp"
41*35238bceSAndroid Build Coastguard Worker
42*35238bceSAndroid Build Coastguard Worker #include <vector>
43*35238bceSAndroid Build Coastguard Worker #include <string>
44*35238bceSAndroid Build Coastguard Worker #include <algorithm>
45*35238bceSAndroid Build Coastguard Worker #include <cmath>
46*35238bceSAndroid Build Coastguard Worker
47*35238bceSAndroid Build Coastguard Worker namespace deqp
48*35238bceSAndroid Build Coastguard Worker {
49*35238bceSAndroid Build Coastguard Worker namespace egl
50*35238bceSAndroid Build Coastguard Worker {
51*35238bceSAndroid Build Coastguard Worker
52*35238bceSAndroid Build Coastguard Worker using std::string;
53*35238bceSAndroid Build Coastguard Worker using std::vector;
54*35238bceSAndroid Build Coastguard Worker using tcu::TestLog;
55*35238bceSAndroid Build Coastguard Worker
56*35238bceSAndroid Build Coastguard Worker using namespace glw;
57*35238bceSAndroid Build Coastguard Worker using namespace eglw;
58*35238bceSAndroid Build Coastguard Worker
59*35238bceSAndroid Build Coastguard Worker namespace
60*35238bceSAndroid Build Coastguard Worker {
61*35238bceSAndroid Build Coastguard Worker
62*35238bceSAndroid Build Coastguard Worker struct TestConfig
63*35238bceSAndroid Build Coastguard Worker {
64*35238bceSAndroid Build Coastguard Worker enum TextureType
65*35238bceSAndroid Build Coastguard Worker {
66*35238bceSAndroid Build Coastguard Worker TEXTURETYPE_TEXTURE = 0,
67*35238bceSAndroid Build Coastguard Worker TEXTURETYPE_SHARED_TEXTURE,
68*35238bceSAndroid Build Coastguard Worker TEXTURETYPE_IMAGE,
69*35238bceSAndroid Build Coastguard Worker TEXTURETYPE_SHARED_IMAGE,
70*35238bceSAndroid Build Coastguard Worker TEXTURETYPE_SHARED_IMAGE_TEXTURE
71*35238bceSAndroid Build Coastguard Worker };
72*35238bceSAndroid Build Coastguard Worker
73*35238bceSAndroid Build Coastguard Worker int threadCount;
74*35238bceSAndroid Build Coastguard Worker int perThreadContextCount;
75*35238bceSAndroid Build Coastguard Worker
76*35238bceSAndroid Build Coastguard Worker int frameCount;
77*35238bceSAndroid Build Coastguard Worker int drawCallCount;
78*35238bceSAndroid Build Coastguard Worker int triangleCount;
79*35238bceSAndroid Build Coastguard Worker
80*35238bceSAndroid Build Coastguard Worker bool sharedContexts;
81*35238bceSAndroid Build Coastguard Worker
82*35238bceSAndroid Build Coastguard Worker bool useCoordBuffer;
83*35238bceSAndroid Build Coastguard Worker bool sharedCoordBuffer;
84*35238bceSAndroid Build Coastguard Worker
85*35238bceSAndroid Build Coastguard Worker bool useIndices;
86*35238bceSAndroid Build Coastguard Worker bool useIndexBuffer;
87*35238bceSAndroid Build Coastguard Worker bool sharedIndexBuffer;
88*35238bceSAndroid Build Coastguard Worker
89*35238bceSAndroid Build Coastguard Worker bool useTexture;
90*35238bceSAndroid Build Coastguard Worker TextureType textureType;
91*35238bceSAndroid Build Coastguard Worker
92*35238bceSAndroid Build Coastguard Worker bool sharedProgram;
93*35238bceSAndroid Build Coastguard Worker
94*35238bceSAndroid Build Coastguard Worker int textureWidth;
95*35238bceSAndroid Build Coastguard Worker int textureHeight;
96*35238bceSAndroid Build Coastguard Worker
97*35238bceSAndroid Build Coastguard Worker int surfaceWidth;
98*35238bceSAndroid Build Coastguard Worker int surfaceHeight;
99*35238bceSAndroid Build Coastguard Worker };
100*35238bceSAndroid Build Coastguard Worker
101*35238bceSAndroid Build Coastguard Worker class TestContext
102*35238bceSAndroid Build Coastguard Worker {
103*35238bceSAndroid Build Coastguard Worker public:
104*35238bceSAndroid Build Coastguard Worker TestContext(EglTestContext &eglTestCtx, EGLDisplay display, EGLConfig eglConfig, const TestConfig &config,
105*35238bceSAndroid Build Coastguard Worker bool share, TestContext *parent);
106*35238bceSAndroid Build Coastguard Worker ~TestContext(void);
107*35238bceSAndroid Build Coastguard Worker
108*35238bceSAndroid Build Coastguard Worker void render(void);
109*35238bceSAndroid Build Coastguard Worker
getEGLContext(void)110*35238bceSAndroid Build Coastguard Worker EGLContext getEGLContext(void)
111*35238bceSAndroid Build Coastguard Worker {
112*35238bceSAndroid Build Coastguard Worker return m_eglContext;
113*35238bceSAndroid Build Coastguard Worker }
114*35238bceSAndroid Build Coastguard Worker
getCoordBuffer(void) const115*35238bceSAndroid Build Coastguard Worker GLuint getCoordBuffer(void) const
116*35238bceSAndroid Build Coastguard Worker {
117*35238bceSAndroid Build Coastguard Worker return m_coordBuffer;
118*35238bceSAndroid Build Coastguard Worker }
getIndexBuffer(void) const119*35238bceSAndroid Build Coastguard Worker GLuint getIndexBuffer(void) const
120*35238bceSAndroid Build Coastguard Worker {
121*35238bceSAndroid Build Coastguard Worker return m_indexBuffer;
122*35238bceSAndroid Build Coastguard Worker }
getTexture(void) const123*35238bceSAndroid Build Coastguard Worker GLuint getTexture(void) const
124*35238bceSAndroid Build Coastguard Worker {
125*35238bceSAndroid Build Coastguard Worker return m_texture;
126*35238bceSAndroid Build Coastguard Worker }
getProgram(void) const127*35238bceSAndroid Build Coastguard Worker GLuint getProgram(void) const
128*35238bceSAndroid Build Coastguard Worker {
129*35238bceSAndroid Build Coastguard Worker return m_program;
130*35238bceSAndroid Build Coastguard Worker }
getEGLImage(void) const131*35238bceSAndroid Build Coastguard Worker EGLImageKHR getEGLImage(void) const
132*35238bceSAndroid Build Coastguard Worker {
133*35238bceSAndroid Build Coastguard Worker return m_eglImage;
134*35238bceSAndroid Build Coastguard Worker }
135*35238bceSAndroid Build Coastguard Worker
136*35238bceSAndroid Build Coastguard Worker private:
137*35238bceSAndroid Build Coastguard Worker TestContext *m_parent;
138*35238bceSAndroid Build Coastguard Worker EglTestContext &m_testCtx;
139*35238bceSAndroid Build Coastguard Worker TestConfig m_config;
140*35238bceSAndroid Build Coastguard Worker
141*35238bceSAndroid Build Coastguard Worker EGLDisplay m_eglDisplay;
142*35238bceSAndroid Build Coastguard Worker EGLContext m_eglContext;
143*35238bceSAndroid Build Coastguard Worker EGLSurface m_eglSurface;
144*35238bceSAndroid Build Coastguard Worker
145*35238bceSAndroid Build Coastguard Worker glw::Functions m_gl;
146*35238bceSAndroid Build Coastguard Worker
147*35238bceSAndroid Build Coastguard Worker GLuint m_coordBuffer;
148*35238bceSAndroid Build Coastguard Worker GLuint m_indexBuffer;
149*35238bceSAndroid Build Coastguard Worker GLuint m_texture;
150*35238bceSAndroid Build Coastguard Worker GLuint m_program;
151*35238bceSAndroid Build Coastguard Worker
152*35238bceSAndroid Build Coastguard Worker EGLImageKHR m_eglImage;
153*35238bceSAndroid Build Coastguard Worker
154*35238bceSAndroid Build Coastguard Worker GLuint m_coordLoc;
155*35238bceSAndroid Build Coastguard Worker GLuint m_textureLoc;
156*35238bceSAndroid Build Coastguard Worker
157*35238bceSAndroid Build Coastguard Worker vector<float> m_coordData;
158*35238bceSAndroid Build Coastguard Worker vector<uint16_t> m_indexData;
159*35238bceSAndroid Build Coastguard Worker
160*35238bceSAndroid Build Coastguard Worker EGLImageKHR createEGLImage(void);
161*35238bceSAndroid Build Coastguard Worker GLuint createTextureFromImage(EGLImageKHR image);
162*35238bceSAndroid Build Coastguard Worker
163*35238bceSAndroid Build Coastguard Worker // Not supported
164*35238bceSAndroid Build Coastguard Worker TestContext &operator=(const TestContext &);
165*35238bceSAndroid Build Coastguard Worker TestContext(const TestContext &);
166*35238bceSAndroid Build Coastguard Worker };
167*35238bceSAndroid Build Coastguard Worker
168*35238bceSAndroid Build Coastguard Worker namespace
169*35238bceSAndroid Build Coastguard Worker {
170*35238bceSAndroid Build Coastguard Worker
createCoordData(vector<float> & data,const TestConfig & config)171*35238bceSAndroid Build Coastguard Worker void createCoordData(vector<float> &data, const TestConfig &config)
172*35238bceSAndroid Build Coastguard Worker {
173*35238bceSAndroid Build Coastguard Worker if (config.useIndices)
174*35238bceSAndroid Build Coastguard Worker {
175*35238bceSAndroid Build Coastguard Worker for (int triangleNdx = 0; triangleNdx < 2; triangleNdx++)
176*35238bceSAndroid Build Coastguard Worker {
177*35238bceSAndroid Build Coastguard Worker const float x1 = -1.0f;
178*35238bceSAndroid Build Coastguard Worker const float y1 = -1.0f;
179*35238bceSAndroid Build Coastguard Worker
180*35238bceSAndroid Build Coastguard Worker const float x2 = 1.0f;
181*35238bceSAndroid Build Coastguard Worker const float y2 = 1.0f;
182*35238bceSAndroid Build Coastguard Worker
183*35238bceSAndroid Build Coastguard Worker const float side = ((triangleNdx % 2) == 0 ? 1.0f : -1.0f);
184*35238bceSAndroid Build Coastguard Worker
185*35238bceSAndroid Build Coastguard Worker data.push_back(side * x1);
186*35238bceSAndroid Build Coastguard Worker data.push_back(side * y1);
187*35238bceSAndroid Build Coastguard Worker
188*35238bceSAndroid Build Coastguard Worker data.push_back(side * x2);
189*35238bceSAndroid Build Coastguard Worker data.push_back(side * y1);
190*35238bceSAndroid Build Coastguard Worker
191*35238bceSAndroid Build Coastguard Worker data.push_back(side * x2);
192*35238bceSAndroid Build Coastguard Worker data.push_back(side * y2);
193*35238bceSAndroid Build Coastguard Worker }
194*35238bceSAndroid Build Coastguard Worker }
195*35238bceSAndroid Build Coastguard Worker else
196*35238bceSAndroid Build Coastguard Worker {
197*35238bceSAndroid Build Coastguard Worker data.reserve(config.triangleCount * 3 * 2);
198*35238bceSAndroid Build Coastguard Worker
199*35238bceSAndroid Build Coastguard Worker for (int triangleNdx = 0; triangleNdx < config.triangleCount; triangleNdx++)
200*35238bceSAndroid Build Coastguard Worker {
201*35238bceSAndroid Build Coastguard Worker const float x1 = -1.0f;
202*35238bceSAndroid Build Coastguard Worker const float y1 = -1.0f;
203*35238bceSAndroid Build Coastguard Worker
204*35238bceSAndroid Build Coastguard Worker const float x2 = 1.0f;
205*35238bceSAndroid Build Coastguard Worker const float y2 = 1.0f;
206*35238bceSAndroid Build Coastguard Worker
207*35238bceSAndroid Build Coastguard Worker const float side = ((triangleNdx % 2) == 0 ? 1.0f : -1.0f);
208*35238bceSAndroid Build Coastguard Worker
209*35238bceSAndroid Build Coastguard Worker data.push_back(side * x1);
210*35238bceSAndroid Build Coastguard Worker data.push_back(side * y1);
211*35238bceSAndroid Build Coastguard Worker
212*35238bceSAndroid Build Coastguard Worker data.push_back(side * x2);
213*35238bceSAndroid Build Coastguard Worker data.push_back(side * y1);
214*35238bceSAndroid Build Coastguard Worker
215*35238bceSAndroid Build Coastguard Worker data.push_back(side * x2);
216*35238bceSAndroid Build Coastguard Worker data.push_back(side * y2);
217*35238bceSAndroid Build Coastguard Worker }
218*35238bceSAndroid Build Coastguard Worker }
219*35238bceSAndroid Build Coastguard Worker }
220*35238bceSAndroid Build Coastguard Worker
createCoordBuffer(const glw::Functions & gl,const TestConfig & config)221*35238bceSAndroid Build Coastguard Worker GLuint createCoordBuffer(const glw::Functions &gl, const TestConfig &config)
222*35238bceSAndroid Build Coastguard Worker {
223*35238bceSAndroid Build Coastguard Worker GLuint buffer;
224*35238bceSAndroid Build Coastguard Worker vector<float> data;
225*35238bceSAndroid Build Coastguard Worker
226*35238bceSAndroid Build Coastguard Worker createCoordData(data, config);
227*35238bceSAndroid Build Coastguard Worker
228*35238bceSAndroid Build Coastguard Worker gl.genBuffers(1, &buffer);
229*35238bceSAndroid Build Coastguard Worker GLU_EXPECT_NO_ERROR(gl.getError(), "glGenBuffers()");
230*35238bceSAndroid Build Coastguard Worker gl.bindBuffer(GL_ARRAY_BUFFER, buffer);
231*35238bceSAndroid Build Coastguard Worker GLU_EXPECT_NO_ERROR(gl.getError(), "glBindBuffer()");
232*35238bceSAndroid Build Coastguard Worker gl.bufferData(GL_ARRAY_BUFFER, (GLsizei)(data.size() * sizeof(float)), &(data[0]), GL_STATIC_DRAW);
233*35238bceSAndroid Build Coastguard Worker GLU_EXPECT_NO_ERROR(gl.getError(), "glBufferData()");
234*35238bceSAndroid Build Coastguard Worker gl.bindBuffer(GL_ARRAY_BUFFER, 0);
235*35238bceSAndroid Build Coastguard Worker GLU_EXPECT_NO_ERROR(gl.getError(), "glBindBuffer()");
236*35238bceSAndroid Build Coastguard Worker
237*35238bceSAndroid Build Coastguard Worker return buffer;
238*35238bceSAndroid Build Coastguard Worker }
239*35238bceSAndroid Build Coastguard Worker
createIndexData(vector<uint16_t> & data,const TestConfig & config)240*35238bceSAndroid Build Coastguard Worker void createIndexData(vector<uint16_t> &data, const TestConfig &config)
241*35238bceSAndroid Build Coastguard Worker {
242*35238bceSAndroid Build Coastguard Worker for (int triangleNdx = 0; triangleNdx < config.triangleCount; triangleNdx++)
243*35238bceSAndroid Build Coastguard Worker {
244*35238bceSAndroid Build Coastguard Worker if ((triangleNdx % 2) == 0)
245*35238bceSAndroid Build Coastguard Worker {
246*35238bceSAndroid Build Coastguard Worker data.push_back(0);
247*35238bceSAndroid Build Coastguard Worker data.push_back(1);
248*35238bceSAndroid Build Coastguard Worker data.push_back(2);
249*35238bceSAndroid Build Coastguard Worker }
250*35238bceSAndroid Build Coastguard Worker else
251*35238bceSAndroid Build Coastguard Worker {
252*35238bceSAndroid Build Coastguard Worker data.push_back(2);
253*35238bceSAndroid Build Coastguard Worker data.push_back(3);
254*35238bceSAndroid Build Coastguard Worker data.push_back(0);
255*35238bceSAndroid Build Coastguard Worker }
256*35238bceSAndroid Build Coastguard Worker }
257*35238bceSAndroid Build Coastguard Worker }
258*35238bceSAndroid Build Coastguard Worker
createIndexBuffer(const glw::Functions & gl,const TestConfig & config)259*35238bceSAndroid Build Coastguard Worker GLuint createIndexBuffer(const glw::Functions &gl, const TestConfig &config)
260*35238bceSAndroid Build Coastguard Worker {
261*35238bceSAndroid Build Coastguard Worker GLuint buffer;
262*35238bceSAndroid Build Coastguard Worker vector<uint16_t> data;
263*35238bceSAndroid Build Coastguard Worker
264*35238bceSAndroid Build Coastguard Worker createIndexData(data, config);
265*35238bceSAndroid Build Coastguard Worker
266*35238bceSAndroid Build Coastguard Worker gl.genBuffers(1, &buffer);
267*35238bceSAndroid Build Coastguard Worker GLU_EXPECT_NO_ERROR(gl.getError(), "glGenBuffers()");
268*35238bceSAndroid Build Coastguard Worker gl.bindBuffer(GL_ELEMENT_ARRAY_BUFFER, buffer);
269*35238bceSAndroid Build Coastguard Worker GLU_EXPECT_NO_ERROR(gl.getError(), "glBindBuffer()");
270*35238bceSAndroid Build Coastguard Worker gl.bufferData(GL_ELEMENT_ARRAY_BUFFER, (GLsizei)(data.size() * sizeof(uint16_t)), &(data[0]), GL_STATIC_DRAW);
271*35238bceSAndroid Build Coastguard Worker GLU_EXPECT_NO_ERROR(gl.getError(), "glBufferData()");
272*35238bceSAndroid Build Coastguard Worker gl.bindBuffer(GL_ELEMENT_ARRAY_BUFFER, 0);
273*35238bceSAndroid Build Coastguard Worker GLU_EXPECT_NO_ERROR(gl.getError(), "glBindBuffer()");
274*35238bceSAndroid Build Coastguard Worker
275*35238bceSAndroid Build Coastguard Worker return buffer;
276*35238bceSAndroid Build Coastguard Worker }
277*35238bceSAndroid Build Coastguard Worker
createTextureData(vector<uint8_t> & data,const TestConfig & config)278*35238bceSAndroid Build Coastguard Worker void createTextureData(vector<uint8_t> &data, const TestConfig &config)
279*35238bceSAndroid Build Coastguard Worker {
280*35238bceSAndroid Build Coastguard Worker for (int x = 0; x < config.textureWidth; x++)
281*35238bceSAndroid Build Coastguard Worker {
282*35238bceSAndroid Build Coastguard Worker for (int y = 0; y < config.textureHeight; y++)
283*35238bceSAndroid Build Coastguard Worker {
284*35238bceSAndroid Build Coastguard Worker data.push_back((uint8_t)((255 * x) / 255));
285*35238bceSAndroid Build Coastguard Worker data.push_back((uint8_t)((255 * y) / 255));
286*35238bceSAndroid Build Coastguard Worker data.push_back((uint8_t)((255 * x * y) / (255 * 255)));
287*35238bceSAndroid Build Coastguard Worker data.push_back(255);
288*35238bceSAndroid Build Coastguard Worker }
289*35238bceSAndroid Build Coastguard Worker }
290*35238bceSAndroid Build Coastguard Worker }
291*35238bceSAndroid Build Coastguard Worker
createTexture(const glw::Functions & gl,const TestConfig & config)292*35238bceSAndroid Build Coastguard Worker GLuint createTexture(const glw::Functions &gl, const TestConfig &config)
293*35238bceSAndroid Build Coastguard Worker {
294*35238bceSAndroid Build Coastguard Worker GLuint texture;
295*35238bceSAndroid Build Coastguard Worker vector<uint8_t> data;
296*35238bceSAndroid Build Coastguard Worker
297*35238bceSAndroid Build Coastguard Worker createTextureData(data, config);
298*35238bceSAndroid Build Coastguard Worker
299*35238bceSAndroid Build Coastguard Worker gl.genTextures(1, &texture);
300*35238bceSAndroid Build Coastguard Worker GLU_EXPECT_NO_ERROR(gl.getError(), "glGenTextures()");
301*35238bceSAndroid Build Coastguard Worker gl.bindTexture(GL_TEXTURE_2D, texture);
302*35238bceSAndroid Build Coastguard Worker GLU_EXPECT_NO_ERROR(gl.getError(), "glBindTexture()");
303*35238bceSAndroid Build Coastguard Worker gl.texParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
304*35238bceSAndroid Build Coastguard Worker GLU_EXPECT_NO_ERROR(gl.getError(), "glTexParameteri");
305*35238bceSAndroid Build Coastguard Worker gl.texParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
306*35238bceSAndroid Build Coastguard Worker GLU_EXPECT_NO_ERROR(gl.getError(), "glTexParameteri");
307*35238bceSAndroid Build Coastguard Worker gl.texParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE);
308*35238bceSAndroid Build Coastguard Worker GLU_EXPECT_NO_ERROR(gl.getError(), "glTexParameteri");
309*35238bceSAndroid Build Coastguard Worker gl.texParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE);
310*35238bceSAndroid Build Coastguard Worker GLU_EXPECT_NO_ERROR(gl.getError(), "glTexParameteri");
311*35238bceSAndroid Build Coastguard Worker gl.texImage2D(GL_TEXTURE_2D, 0, GL_RGBA, config.textureWidth, config.textureWidth, 0, GL_RGBA, GL_UNSIGNED_BYTE,
312*35238bceSAndroid Build Coastguard Worker &(data[0]));
313*35238bceSAndroid Build Coastguard Worker GLU_EXPECT_NO_ERROR(gl.getError(), "glTexImage2D()");
314*35238bceSAndroid Build Coastguard Worker gl.bindTexture(GL_TEXTURE_2D, 0);
315*35238bceSAndroid Build Coastguard Worker GLU_EXPECT_NO_ERROR(gl.getError(), "glBindTexture()");
316*35238bceSAndroid Build Coastguard Worker
317*35238bceSAndroid Build Coastguard Worker return texture;
318*35238bceSAndroid Build Coastguard Worker }
319*35238bceSAndroid Build Coastguard Worker
createProgram(const glw::Functions & gl,const TestConfig & config)320*35238bceSAndroid Build Coastguard Worker GLuint createProgram(const glw::Functions &gl, const TestConfig &config)
321*35238bceSAndroid Build Coastguard Worker {
322*35238bceSAndroid Build Coastguard Worker GLuint vertexShader = gl.createShader(GL_VERTEX_SHADER);
323*35238bceSAndroid Build Coastguard Worker GLuint fragmentShader = gl.createShader(GL_FRAGMENT_SHADER);
324*35238bceSAndroid Build Coastguard Worker
325*35238bceSAndroid Build Coastguard Worker if (config.useTexture)
326*35238bceSAndroid Build Coastguard Worker {
327*35238bceSAndroid Build Coastguard Worker const char *vertexShaderSource = "attribute mediump vec2 a_coord;\n"
328*35238bceSAndroid Build Coastguard Worker "varying mediump vec2 v_texCoord;\n"
329*35238bceSAndroid Build Coastguard Worker "void main(void)\n"
330*35238bceSAndroid Build Coastguard Worker "{\n"
331*35238bceSAndroid Build Coastguard Worker "\tv_texCoord = 0.5 * a_coord + vec2(0.5);\n"
332*35238bceSAndroid Build Coastguard Worker "\tgl_Position = vec4(a_coord, 0.0, 1.0);\n"
333*35238bceSAndroid Build Coastguard Worker "}\n";
334*35238bceSAndroid Build Coastguard Worker
335*35238bceSAndroid Build Coastguard Worker const char *fragmentShaderSource = "uniform sampler2D u_sampler;\n"
336*35238bceSAndroid Build Coastguard Worker "varying mediump vec2 v_texCoord;\n"
337*35238bceSAndroid Build Coastguard Worker "void main(void)\n"
338*35238bceSAndroid Build Coastguard Worker "{\n"
339*35238bceSAndroid Build Coastguard Worker "\tgl_FragColor = texture2D(u_sampler, v_texCoord);\n"
340*35238bceSAndroid Build Coastguard Worker "}\n";
341*35238bceSAndroid Build Coastguard Worker
342*35238bceSAndroid Build Coastguard Worker gl.shaderSource(vertexShader, 1, &vertexShaderSource, DE_NULL);
343*35238bceSAndroid Build Coastguard Worker GLU_EXPECT_NO_ERROR(gl.getError(), "glShaderSource()");
344*35238bceSAndroid Build Coastguard Worker gl.shaderSource(fragmentShader, 1, &fragmentShaderSource, DE_NULL);
345*35238bceSAndroid Build Coastguard Worker GLU_EXPECT_NO_ERROR(gl.getError(), "glShaderSource()");
346*35238bceSAndroid Build Coastguard Worker }
347*35238bceSAndroid Build Coastguard Worker else
348*35238bceSAndroid Build Coastguard Worker {
349*35238bceSAndroid Build Coastguard Worker const char *vertexShaderSource = "attribute mediump vec2 a_coord;\n"
350*35238bceSAndroid Build Coastguard Worker "varying mediump vec4 v_color;\n"
351*35238bceSAndroid Build Coastguard Worker "void main(void)\n"
352*35238bceSAndroid Build Coastguard Worker "{\n"
353*35238bceSAndroid Build Coastguard Worker "\tv_color = vec4(0.5 * a_coord + vec2(0.5), 0.5, 1.0);\n"
354*35238bceSAndroid Build Coastguard Worker "\tgl_Position = vec4(a_coord, 0.0, 1.0);\n"
355*35238bceSAndroid Build Coastguard Worker "}\n";
356*35238bceSAndroid Build Coastguard Worker
357*35238bceSAndroid Build Coastguard Worker const char *fragmentShaderSource = "varying mediump vec4 v_color;\n"
358*35238bceSAndroid Build Coastguard Worker "void main(void)\n"
359*35238bceSAndroid Build Coastguard Worker "{\n"
360*35238bceSAndroid Build Coastguard Worker "\tgl_FragColor = v_color;\n"
361*35238bceSAndroid Build Coastguard Worker "}\n";
362*35238bceSAndroid Build Coastguard Worker
363*35238bceSAndroid Build Coastguard Worker gl.shaderSource(vertexShader, 1, &vertexShaderSource, DE_NULL);
364*35238bceSAndroid Build Coastguard Worker GLU_EXPECT_NO_ERROR(gl.getError(), "glShaderSource()");
365*35238bceSAndroid Build Coastguard Worker gl.shaderSource(fragmentShader, 1, &fragmentShaderSource, DE_NULL);
366*35238bceSAndroid Build Coastguard Worker GLU_EXPECT_NO_ERROR(gl.getError(), "glShaderSource()");
367*35238bceSAndroid Build Coastguard Worker }
368*35238bceSAndroid Build Coastguard Worker
369*35238bceSAndroid Build Coastguard Worker gl.compileShader(vertexShader);
370*35238bceSAndroid Build Coastguard Worker GLU_EXPECT_NO_ERROR(gl.getError(), "glCompileShader()");
371*35238bceSAndroid Build Coastguard Worker gl.compileShader(fragmentShader);
372*35238bceSAndroid Build Coastguard Worker GLU_EXPECT_NO_ERROR(gl.getError(), "glCompileShader()");
373*35238bceSAndroid Build Coastguard Worker
374*35238bceSAndroid Build Coastguard Worker {
375*35238bceSAndroid Build Coastguard Worker GLint status;
376*35238bceSAndroid Build Coastguard Worker
377*35238bceSAndroid Build Coastguard Worker gl.getShaderiv(vertexShader, GL_COMPILE_STATUS, &status);
378*35238bceSAndroid Build Coastguard Worker GLU_EXPECT_NO_ERROR(gl.getError(), "glGetShaderiv()");
379*35238bceSAndroid Build Coastguard Worker
380*35238bceSAndroid Build Coastguard Worker if (!status)
381*35238bceSAndroid Build Coastguard Worker {
382*35238bceSAndroid Build Coastguard Worker string log;
383*35238bceSAndroid Build Coastguard Worker GLint length;
384*35238bceSAndroid Build Coastguard Worker
385*35238bceSAndroid Build Coastguard Worker gl.getShaderiv(vertexShader, GL_INFO_LOG_LENGTH, &length);
386*35238bceSAndroid Build Coastguard Worker GLU_EXPECT_NO_ERROR(gl.getError(), "glGetShaderiv()");
387*35238bceSAndroid Build Coastguard Worker log.resize(length, 0);
388*35238bceSAndroid Build Coastguard Worker
389*35238bceSAndroid Build Coastguard Worker gl.getShaderInfoLog(vertexShader, (GLsizei)log.size(), &length, &(log[0]));
390*35238bceSAndroid Build Coastguard Worker GLU_EXPECT_NO_ERROR(gl.getError(), "glGetShaderInfoLog()");
391*35238bceSAndroid Build Coastguard Worker
392*35238bceSAndroid Build Coastguard Worker throw std::runtime_error(log.c_str());
393*35238bceSAndroid Build Coastguard Worker }
394*35238bceSAndroid Build Coastguard Worker }
395*35238bceSAndroid Build Coastguard Worker
396*35238bceSAndroid Build Coastguard Worker {
397*35238bceSAndroid Build Coastguard Worker GLint status;
398*35238bceSAndroid Build Coastguard Worker
399*35238bceSAndroid Build Coastguard Worker gl.getShaderiv(fragmentShader, GL_COMPILE_STATUS, &status);
400*35238bceSAndroid Build Coastguard Worker GLU_EXPECT_NO_ERROR(gl.getError(), "glGetShaderiv()");
401*35238bceSAndroid Build Coastguard Worker
402*35238bceSAndroid Build Coastguard Worker if (!status)
403*35238bceSAndroid Build Coastguard Worker {
404*35238bceSAndroid Build Coastguard Worker string log;
405*35238bceSAndroid Build Coastguard Worker GLint length;
406*35238bceSAndroid Build Coastguard Worker
407*35238bceSAndroid Build Coastguard Worker gl.getShaderiv(fragmentShader, GL_INFO_LOG_LENGTH, &length);
408*35238bceSAndroid Build Coastguard Worker GLU_EXPECT_NO_ERROR(gl.getError(), "glGetShaderiv()");
409*35238bceSAndroid Build Coastguard Worker log.resize(length, 0);
410*35238bceSAndroid Build Coastguard Worker
411*35238bceSAndroid Build Coastguard Worker gl.getShaderInfoLog(fragmentShader, (GLsizei)log.size(), &length, &(log[0]));
412*35238bceSAndroid Build Coastguard Worker GLU_EXPECT_NO_ERROR(gl.getError(), "glGetShaderInfoLog()");
413*35238bceSAndroid Build Coastguard Worker
414*35238bceSAndroid Build Coastguard Worker throw std::runtime_error(log.c_str());
415*35238bceSAndroid Build Coastguard Worker }
416*35238bceSAndroid Build Coastguard Worker }
417*35238bceSAndroid Build Coastguard Worker
418*35238bceSAndroid Build Coastguard Worker {
419*35238bceSAndroid Build Coastguard Worker GLuint program = gl.createProgram();
420*35238bceSAndroid Build Coastguard Worker
421*35238bceSAndroid Build Coastguard Worker gl.attachShader(program, vertexShader);
422*35238bceSAndroid Build Coastguard Worker GLU_EXPECT_NO_ERROR(gl.getError(), "glAttachShader()");
423*35238bceSAndroid Build Coastguard Worker gl.attachShader(program, fragmentShader);
424*35238bceSAndroid Build Coastguard Worker GLU_EXPECT_NO_ERROR(gl.getError(), "glAttachShader()");
425*35238bceSAndroid Build Coastguard Worker
426*35238bceSAndroid Build Coastguard Worker gl.linkProgram(program);
427*35238bceSAndroid Build Coastguard Worker GLU_EXPECT_NO_ERROR(gl.getError(), "glLinkProgram()");
428*35238bceSAndroid Build Coastguard Worker
429*35238bceSAndroid Build Coastguard Worker {
430*35238bceSAndroid Build Coastguard Worker GLint status;
431*35238bceSAndroid Build Coastguard Worker
432*35238bceSAndroid Build Coastguard Worker gl.getProgramiv(program, GL_LINK_STATUS, &status);
433*35238bceSAndroid Build Coastguard Worker GLU_EXPECT_NO_ERROR(gl.getError(), "glGetProgramiv()");
434*35238bceSAndroid Build Coastguard Worker
435*35238bceSAndroid Build Coastguard Worker if (!status)
436*35238bceSAndroid Build Coastguard Worker {
437*35238bceSAndroid Build Coastguard Worker string log;
438*35238bceSAndroid Build Coastguard Worker GLsizei length;
439*35238bceSAndroid Build Coastguard Worker
440*35238bceSAndroid Build Coastguard Worker gl.getProgramInfoLog(program, 0, &length, DE_NULL);
441*35238bceSAndroid Build Coastguard Worker GLU_EXPECT_NO_ERROR(gl.getError(), "glGetProgramInfoLog()");
442*35238bceSAndroid Build Coastguard Worker log.resize(length, 0);
443*35238bceSAndroid Build Coastguard Worker
444*35238bceSAndroid Build Coastguard Worker gl.getProgramInfoLog(program, (GLsizei)log.size(), &length, &(log[0]));
445*35238bceSAndroid Build Coastguard Worker GLU_EXPECT_NO_ERROR(gl.getError(), "glGetProgramInfoLog()");
446*35238bceSAndroid Build Coastguard Worker
447*35238bceSAndroid Build Coastguard Worker throw std::runtime_error(log.c_str());
448*35238bceSAndroid Build Coastguard Worker }
449*35238bceSAndroid Build Coastguard Worker }
450*35238bceSAndroid Build Coastguard Worker
451*35238bceSAndroid Build Coastguard Worker gl.deleteShader(vertexShader);
452*35238bceSAndroid Build Coastguard Worker GLU_EXPECT_NO_ERROR(gl.getError(), "glDeleteShader()");
453*35238bceSAndroid Build Coastguard Worker gl.deleteShader(fragmentShader);
454*35238bceSAndroid Build Coastguard Worker GLU_EXPECT_NO_ERROR(gl.getError(), "glDeleteShader()");
455*35238bceSAndroid Build Coastguard Worker
456*35238bceSAndroid Build Coastguard Worker return program;
457*35238bceSAndroid Build Coastguard Worker }
458*35238bceSAndroid Build Coastguard Worker }
459*35238bceSAndroid Build Coastguard Worker
createEGLContext(EglTestContext & testCtx,EGLDisplay eglDisplay,EGLConfig eglConfig,EGLContext share)460*35238bceSAndroid Build Coastguard Worker EGLContext createEGLContext(EglTestContext &testCtx, EGLDisplay eglDisplay, EGLConfig eglConfig, EGLContext share)
461*35238bceSAndroid Build Coastguard Worker {
462*35238bceSAndroid Build Coastguard Worker const Library &egl = testCtx.getLibrary();
463*35238bceSAndroid Build Coastguard Worker const EGLint attribList[] = {EGL_CONTEXT_CLIENT_VERSION, 2, EGL_NONE};
464*35238bceSAndroid Build Coastguard Worker
465*35238bceSAndroid Build Coastguard Worker EGLU_CHECK_CALL(egl, bindAPI(EGL_OPENGL_ES_API));
466*35238bceSAndroid Build Coastguard Worker
467*35238bceSAndroid Build Coastguard Worker EGLContext context = egl.createContext(eglDisplay, eglConfig, share, attribList);
468*35238bceSAndroid Build Coastguard Worker EGLU_CHECK_MSG(egl, "eglCreateContext()");
469*35238bceSAndroid Build Coastguard Worker
470*35238bceSAndroid Build Coastguard Worker return context;
471*35238bceSAndroid Build Coastguard Worker }
472*35238bceSAndroid Build Coastguard Worker
createEGLSurface(EglTestContext & testCtx,EGLDisplay display,EGLConfig eglConfig,const TestConfig & config)473*35238bceSAndroid Build Coastguard Worker EGLSurface createEGLSurface(EglTestContext &testCtx, EGLDisplay display, EGLConfig eglConfig, const TestConfig &config)
474*35238bceSAndroid Build Coastguard Worker {
475*35238bceSAndroid Build Coastguard Worker const Library &egl = testCtx.getLibrary();
476*35238bceSAndroid Build Coastguard Worker const EGLint attribList[] = {EGL_WIDTH, config.surfaceWidth, EGL_HEIGHT, config.surfaceHeight, EGL_NONE};
477*35238bceSAndroid Build Coastguard Worker
478*35238bceSAndroid Build Coastguard Worker EGLSurface surface = egl.createPbufferSurface(display, eglConfig, attribList);
479*35238bceSAndroid Build Coastguard Worker EGLU_CHECK_MSG(egl, "eglCreatePbufferSurface()");
480*35238bceSAndroid Build Coastguard Worker
481*35238bceSAndroid Build Coastguard Worker return surface;
482*35238bceSAndroid Build Coastguard Worker }
483*35238bceSAndroid Build Coastguard Worker
484*35238bceSAndroid Build Coastguard Worker } // namespace
485*35238bceSAndroid Build Coastguard Worker
TestContext(EglTestContext & testCtx,EGLDisplay eglDisplay,EGLConfig eglConfig,const TestConfig & config,bool share,TestContext * parent)486*35238bceSAndroid Build Coastguard Worker TestContext::TestContext(EglTestContext &testCtx, EGLDisplay eglDisplay, EGLConfig eglConfig, const TestConfig &config,
487*35238bceSAndroid Build Coastguard Worker bool share, TestContext *parent)
488*35238bceSAndroid Build Coastguard Worker : m_parent(parent)
489*35238bceSAndroid Build Coastguard Worker , m_testCtx(testCtx)
490*35238bceSAndroid Build Coastguard Worker , m_config(config)
491*35238bceSAndroid Build Coastguard Worker , m_eglDisplay(eglDisplay)
492*35238bceSAndroid Build Coastguard Worker , m_eglContext(EGL_NO_CONTEXT)
493*35238bceSAndroid Build Coastguard Worker , m_eglSurface(EGL_NO_SURFACE)
494*35238bceSAndroid Build Coastguard Worker , m_coordBuffer(0)
495*35238bceSAndroid Build Coastguard Worker , m_indexBuffer(0)
496*35238bceSAndroid Build Coastguard Worker , m_texture(0)
497*35238bceSAndroid Build Coastguard Worker , m_program(0)
498*35238bceSAndroid Build Coastguard Worker , m_eglImage(EGL_NO_IMAGE_KHR)
499*35238bceSAndroid Build Coastguard Worker {
500*35238bceSAndroid Build Coastguard Worker const Library &egl = m_testCtx.getLibrary();
501*35238bceSAndroid Build Coastguard Worker
502*35238bceSAndroid Build Coastguard Worker if (m_config.textureType == TestConfig::TEXTURETYPE_IMAGE ||
503*35238bceSAndroid Build Coastguard Worker m_config.textureType == TestConfig::TEXTURETYPE_SHARED_IMAGE ||
504*35238bceSAndroid Build Coastguard Worker m_config.textureType == TestConfig::TEXTURETYPE_SHARED_IMAGE_TEXTURE)
505*35238bceSAndroid Build Coastguard Worker {
506*35238bceSAndroid Build Coastguard Worker const vector<string> extensions = eglu::getDisplayExtensions(egl, m_eglDisplay);
507*35238bceSAndroid Build Coastguard Worker
508*35238bceSAndroid Build Coastguard Worker if (!de::contains(extensions.begin(), extensions.end(), "EGL_KHR_image_base") ||
509*35238bceSAndroid Build Coastguard Worker !de::contains(extensions.begin(), extensions.end(), "EGL_KHR_gl_texture_2D_image"))
510*35238bceSAndroid Build Coastguard Worker TCU_THROW(NotSupportedError, "EGL_KHR_image_base extensions not supported");
511*35238bceSAndroid Build Coastguard Worker }
512*35238bceSAndroid Build Coastguard Worker
513*35238bceSAndroid Build Coastguard Worker m_eglContext = createEGLContext(m_testCtx, m_eglDisplay, eglConfig,
514*35238bceSAndroid Build Coastguard Worker (share && parent ? parent->getEGLContext() : EGL_NO_CONTEXT));
515*35238bceSAndroid Build Coastguard Worker m_eglSurface = createEGLSurface(m_testCtx, m_eglDisplay, eglConfig, config);
516*35238bceSAndroid Build Coastguard Worker
517*35238bceSAndroid Build Coastguard Worker EGLU_CHECK_CALL(egl, makeCurrent(m_eglDisplay, m_eglSurface, m_eglSurface, m_eglContext));
518*35238bceSAndroid Build Coastguard Worker
519*35238bceSAndroid Build Coastguard Worker {
520*35238bceSAndroid Build Coastguard Worker const char *reqExts[] = {"GL_OES_EGL_image"};
521*35238bceSAndroid Build Coastguard Worker m_testCtx.initGLFunctions(&m_gl, glu::ApiType::es(2, 0), DE_LENGTH_OF_ARRAY(reqExts), reqExts);
522*35238bceSAndroid Build Coastguard Worker }
523*35238bceSAndroid Build Coastguard Worker
524*35238bceSAndroid Build Coastguard Worker if (m_config.textureType == TestConfig::TEXTURETYPE_IMAGE ||
525*35238bceSAndroid Build Coastguard Worker m_config.textureType == TestConfig::TEXTURETYPE_SHARED_IMAGE ||
526*35238bceSAndroid Build Coastguard Worker m_config.textureType == TestConfig::TEXTURETYPE_SHARED_IMAGE_TEXTURE)
527*35238bceSAndroid Build Coastguard Worker {
528*35238bceSAndroid Build Coastguard Worker vector<string> glExts = de::splitString((const char *)m_gl.getString(GL_EXTENSIONS), ' ');
529*35238bceSAndroid Build Coastguard Worker
530*35238bceSAndroid Build Coastguard Worker if (!de::contains(glExts.begin(), glExts.end(), "GL_OES_EGL_image"))
531*35238bceSAndroid Build Coastguard Worker TCU_THROW(NotSupportedError, "GL_OES_EGL_image extensions not supported");
532*35238bceSAndroid Build Coastguard Worker
533*35238bceSAndroid Build Coastguard Worker TCU_CHECK(m_gl.eglImageTargetTexture2DOES);
534*35238bceSAndroid Build Coastguard Worker }
535*35238bceSAndroid Build Coastguard Worker
536*35238bceSAndroid Build Coastguard Worker if (m_config.useCoordBuffer && (!m_config.sharedCoordBuffer || !parent))
537*35238bceSAndroid Build Coastguard Worker m_coordBuffer = createCoordBuffer(m_gl, m_config);
538*35238bceSAndroid Build Coastguard Worker else if (m_config.useCoordBuffer && m_config.sharedCoordBuffer)
539*35238bceSAndroid Build Coastguard Worker m_coordBuffer = parent->getCoordBuffer();
540*35238bceSAndroid Build Coastguard Worker else
541*35238bceSAndroid Build Coastguard Worker createCoordData(m_coordData, m_config);
542*35238bceSAndroid Build Coastguard Worker
543*35238bceSAndroid Build Coastguard Worker if (m_config.useIndexBuffer && (!m_config.sharedIndexBuffer || !parent))
544*35238bceSAndroid Build Coastguard Worker m_indexBuffer = createIndexBuffer(m_gl, m_config);
545*35238bceSAndroid Build Coastguard Worker else if (m_config.useIndexBuffer && m_config.sharedIndexBuffer)
546*35238bceSAndroid Build Coastguard Worker m_indexBuffer = parent->getIndexBuffer();
547*35238bceSAndroid Build Coastguard Worker else if (m_config.useIndices)
548*35238bceSAndroid Build Coastguard Worker createIndexData(m_indexData, m_config);
549*35238bceSAndroid Build Coastguard Worker
550*35238bceSAndroid Build Coastguard Worker if (m_config.useTexture)
551*35238bceSAndroid Build Coastguard Worker {
552*35238bceSAndroid Build Coastguard Worker if (m_config.textureType == TestConfig::TEXTURETYPE_TEXTURE)
553*35238bceSAndroid Build Coastguard Worker m_texture = createTexture(m_gl, m_config);
554*35238bceSAndroid Build Coastguard Worker else if (m_config.textureType == TestConfig::TEXTURETYPE_SHARED_TEXTURE)
555*35238bceSAndroid Build Coastguard Worker {
556*35238bceSAndroid Build Coastguard Worker if (parent)
557*35238bceSAndroid Build Coastguard Worker m_texture = parent->getTexture();
558*35238bceSAndroid Build Coastguard Worker else
559*35238bceSAndroid Build Coastguard Worker m_texture = createTexture(m_gl, m_config);
560*35238bceSAndroid Build Coastguard Worker }
561*35238bceSAndroid Build Coastguard Worker else if (m_config.textureType == TestConfig::TEXTURETYPE_IMAGE)
562*35238bceSAndroid Build Coastguard Worker {
563*35238bceSAndroid Build Coastguard Worker m_eglImage = createEGLImage();
564*35238bceSAndroid Build Coastguard Worker m_texture = createTextureFromImage(m_eglImage);
565*35238bceSAndroid Build Coastguard Worker }
566*35238bceSAndroid Build Coastguard Worker else if (m_config.textureType == TestConfig::TEXTURETYPE_SHARED_IMAGE)
567*35238bceSAndroid Build Coastguard Worker {
568*35238bceSAndroid Build Coastguard Worker if (parent)
569*35238bceSAndroid Build Coastguard Worker m_eglImage = parent->getEGLImage();
570*35238bceSAndroid Build Coastguard Worker else
571*35238bceSAndroid Build Coastguard Worker m_eglImage = createEGLImage();
572*35238bceSAndroid Build Coastguard Worker
573*35238bceSAndroid Build Coastguard Worker m_texture = createTextureFromImage(m_eglImage);
574*35238bceSAndroid Build Coastguard Worker }
575*35238bceSAndroid Build Coastguard Worker else if (m_config.textureType == TestConfig::TEXTURETYPE_SHARED_IMAGE_TEXTURE)
576*35238bceSAndroid Build Coastguard Worker {
577*35238bceSAndroid Build Coastguard Worker if (parent)
578*35238bceSAndroid Build Coastguard Worker m_texture = parent->getTexture();
579*35238bceSAndroid Build Coastguard Worker else
580*35238bceSAndroid Build Coastguard Worker {
581*35238bceSAndroid Build Coastguard Worker m_eglImage = createEGLImage();
582*35238bceSAndroid Build Coastguard Worker m_texture = createTextureFromImage(m_eglImage);
583*35238bceSAndroid Build Coastguard Worker }
584*35238bceSAndroid Build Coastguard Worker }
585*35238bceSAndroid Build Coastguard Worker }
586*35238bceSAndroid Build Coastguard Worker
587*35238bceSAndroid Build Coastguard Worker if (!m_config.sharedProgram || !parent)
588*35238bceSAndroid Build Coastguard Worker m_program = createProgram(m_gl, m_config);
589*35238bceSAndroid Build Coastguard Worker else if (m_config.sharedProgram)
590*35238bceSAndroid Build Coastguard Worker m_program = parent->getProgram();
591*35238bceSAndroid Build Coastguard Worker
592*35238bceSAndroid Build Coastguard Worker m_coordLoc = m_gl.getAttribLocation(m_program, "a_coord");
593*35238bceSAndroid Build Coastguard Worker
594*35238bceSAndroid Build Coastguard Worker if (m_config.useTexture)
595*35238bceSAndroid Build Coastguard Worker m_textureLoc = m_gl.getUniformLocation(m_program, "u_sampler");
596*35238bceSAndroid Build Coastguard Worker
597*35238bceSAndroid Build Coastguard Worker EGLU_CHECK_CALL(egl, makeCurrent(m_eglDisplay, EGL_NO_SURFACE, EGL_NO_SURFACE, EGL_NO_CONTEXT));
598*35238bceSAndroid Build Coastguard Worker }
599*35238bceSAndroid Build Coastguard Worker
createEGLImage(void)600*35238bceSAndroid Build Coastguard Worker EGLImageKHR TestContext::createEGLImage(void)
601*35238bceSAndroid Build Coastguard Worker {
602*35238bceSAndroid Build Coastguard Worker GLuint sourceTexture = createTexture(m_gl, m_config);
603*35238bceSAndroid Build Coastguard Worker
604*35238bceSAndroid Build Coastguard Worker try
605*35238bceSAndroid Build Coastguard Worker {
606*35238bceSAndroid Build Coastguard Worker const Library &egl = m_testCtx.getLibrary();
607*35238bceSAndroid Build Coastguard Worker const EGLint attribList[] = {EGL_GL_TEXTURE_LEVEL_KHR, 0, EGL_NONE};
608*35238bceSAndroid Build Coastguard Worker
609*35238bceSAndroid Build Coastguard Worker EGLImageKHR image = egl.createImageKHR(m_eglDisplay, m_eglContext, EGL_GL_TEXTURE_2D_KHR,
610*35238bceSAndroid Build Coastguard Worker (EGLClientBuffer)(uintptr_t)sourceTexture, attribList);
611*35238bceSAndroid Build Coastguard Worker EGLU_CHECK_MSG(egl, "eglCreateImageKHR()");
612*35238bceSAndroid Build Coastguard Worker
613*35238bceSAndroid Build Coastguard Worker m_gl.deleteTextures(1, &sourceTexture);
614*35238bceSAndroid Build Coastguard Worker GLU_EXPECT_NO_ERROR(m_gl.getError(), "eglCreateImageKHR()");
615*35238bceSAndroid Build Coastguard Worker
616*35238bceSAndroid Build Coastguard Worker return image;
617*35238bceSAndroid Build Coastguard Worker }
618*35238bceSAndroid Build Coastguard Worker catch (...)
619*35238bceSAndroid Build Coastguard Worker {
620*35238bceSAndroid Build Coastguard Worker m_gl.deleteTextures(1, &sourceTexture);
621*35238bceSAndroid Build Coastguard Worker throw;
622*35238bceSAndroid Build Coastguard Worker }
623*35238bceSAndroid Build Coastguard Worker }
624*35238bceSAndroid Build Coastguard Worker
createTextureFromImage(EGLImageKHR image)625*35238bceSAndroid Build Coastguard Worker GLuint TestContext::createTextureFromImage(EGLImageKHR image)
626*35238bceSAndroid Build Coastguard Worker {
627*35238bceSAndroid Build Coastguard Worker GLuint texture = 0;
628*35238bceSAndroid Build Coastguard Worker
629*35238bceSAndroid Build Coastguard Worker try
630*35238bceSAndroid Build Coastguard Worker {
631*35238bceSAndroid Build Coastguard Worker m_gl.genTextures(1, &texture);
632*35238bceSAndroid Build Coastguard Worker m_gl.bindTexture(GL_TEXTURE_2D, texture);
633*35238bceSAndroid Build Coastguard Worker m_gl.eglImageTargetTexture2DOES(GL_TEXTURE_2D, image);
634*35238bceSAndroid Build Coastguard Worker m_gl.bindTexture(GL_TEXTURE_2D, 0);
635*35238bceSAndroid Build Coastguard Worker GLU_EXPECT_NO_ERROR(m_gl.getError(), "Creating texture from image");
636*35238bceSAndroid Build Coastguard Worker
637*35238bceSAndroid Build Coastguard Worker return texture;
638*35238bceSAndroid Build Coastguard Worker }
639*35238bceSAndroid Build Coastguard Worker catch (...)
640*35238bceSAndroid Build Coastguard Worker {
641*35238bceSAndroid Build Coastguard Worker m_gl.deleteTextures(1, &texture);
642*35238bceSAndroid Build Coastguard Worker throw;
643*35238bceSAndroid Build Coastguard Worker }
644*35238bceSAndroid Build Coastguard Worker }
645*35238bceSAndroid Build Coastguard Worker
~TestContext(void)646*35238bceSAndroid Build Coastguard Worker TestContext::~TestContext(void)
647*35238bceSAndroid Build Coastguard Worker {
648*35238bceSAndroid Build Coastguard Worker const Library &egl = m_testCtx.getLibrary();
649*35238bceSAndroid Build Coastguard Worker
650*35238bceSAndroid Build Coastguard Worker EGLU_CHECK_CALL(egl, makeCurrent(m_eglDisplay, m_eglSurface, m_eglSurface, m_eglContext));
651*35238bceSAndroid Build Coastguard Worker
652*35238bceSAndroid Build Coastguard Worker if (m_parent == DE_NULL && m_eglImage)
653*35238bceSAndroid Build Coastguard Worker EGLU_CHECK_CALL(egl, destroyImageKHR(m_eglDisplay, m_eglImage));
654*35238bceSAndroid Build Coastguard Worker
655*35238bceSAndroid Build Coastguard Worker EGLU_CHECK_CALL(egl, makeCurrent(m_eglDisplay, EGL_NO_SURFACE, EGL_NO_SURFACE, EGL_NO_CONTEXT));
656*35238bceSAndroid Build Coastguard Worker EGLU_CHECK_CALL(egl, destroyContext(m_eglDisplay, m_eglContext));
657*35238bceSAndroid Build Coastguard Worker EGLU_CHECK_CALL(egl, destroySurface(m_eglDisplay, m_eglSurface));
658*35238bceSAndroid Build Coastguard Worker }
659*35238bceSAndroid Build Coastguard Worker
render(void)660*35238bceSAndroid Build Coastguard Worker void TestContext::render(void)
661*35238bceSAndroid Build Coastguard Worker {
662*35238bceSAndroid Build Coastguard Worker const Library &egl = m_testCtx.getLibrary();
663*35238bceSAndroid Build Coastguard Worker
664*35238bceSAndroid Build Coastguard Worker egl.makeCurrent(m_eglDisplay, m_eglSurface, m_eglSurface, m_eglContext);
665*35238bceSAndroid Build Coastguard Worker
666*35238bceSAndroid Build Coastguard Worker for (int frameNdx = 0; frameNdx < m_config.frameCount; frameNdx++)
667*35238bceSAndroid Build Coastguard Worker {
668*35238bceSAndroid Build Coastguard Worker m_gl.clearColor(0.75f, 0.6f, 0.5f, 1.0f);
669*35238bceSAndroid Build Coastguard Worker m_gl.clear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
670*35238bceSAndroid Build Coastguard Worker
671*35238bceSAndroid Build Coastguard Worker for (int callNdx = 0; callNdx < m_config.drawCallCount; callNdx++)
672*35238bceSAndroid Build Coastguard Worker {
673*35238bceSAndroid Build Coastguard Worker m_gl.useProgram(m_program);
674*35238bceSAndroid Build Coastguard Worker m_gl.enableVertexAttribArray(m_coordLoc);
675*35238bceSAndroid Build Coastguard Worker
676*35238bceSAndroid Build Coastguard Worker if (m_config.useCoordBuffer)
677*35238bceSAndroid Build Coastguard Worker {
678*35238bceSAndroid Build Coastguard Worker m_gl.bindBuffer(GL_ARRAY_BUFFER, m_coordBuffer);
679*35238bceSAndroid Build Coastguard Worker m_gl.vertexAttribPointer(m_coordLoc, 2, GL_FLOAT, GL_FALSE, 0, 0);
680*35238bceSAndroid Build Coastguard Worker m_gl.bindBuffer(GL_ARRAY_BUFFER, 0);
681*35238bceSAndroid Build Coastguard Worker }
682*35238bceSAndroid Build Coastguard Worker else
683*35238bceSAndroid Build Coastguard Worker m_gl.vertexAttribPointer(m_coordLoc, 2, GL_FLOAT, GL_FALSE, 0, &(m_coordData[0]));
684*35238bceSAndroid Build Coastguard Worker
685*35238bceSAndroid Build Coastguard Worker if (m_config.useTexture)
686*35238bceSAndroid Build Coastguard Worker {
687*35238bceSAndroid Build Coastguard Worker m_gl.bindTexture(GL_TEXTURE_2D, m_texture);
688*35238bceSAndroid Build Coastguard Worker m_gl.uniform1i(m_textureLoc, 0);
689*35238bceSAndroid Build Coastguard Worker }
690*35238bceSAndroid Build Coastguard Worker
691*35238bceSAndroid Build Coastguard Worker if (m_config.useIndices)
692*35238bceSAndroid Build Coastguard Worker {
693*35238bceSAndroid Build Coastguard Worker if (m_config.useIndexBuffer)
694*35238bceSAndroid Build Coastguard Worker {
695*35238bceSAndroid Build Coastguard Worker m_gl.bindBuffer(GL_ELEMENT_ARRAY_BUFFER, m_indexBuffer);
696*35238bceSAndroid Build Coastguard Worker m_gl.drawElements(GL_TRIANGLES, m_config.triangleCount, GL_UNSIGNED_SHORT, 0);
697*35238bceSAndroid Build Coastguard Worker }
698*35238bceSAndroid Build Coastguard Worker else
699*35238bceSAndroid Build Coastguard Worker m_gl.drawElements(GL_TRIANGLES, m_config.triangleCount, GL_UNSIGNED_SHORT, &(m_indexData[0]));
700*35238bceSAndroid Build Coastguard Worker }
701*35238bceSAndroid Build Coastguard Worker else
702*35238bceSAndroid Build Coastguard Worker m_gl.drawArrays(GL_TRIANGLES, 0, m_config.triangleCount);
703*35238bceSAndroid Build Coastguard Worker
704*35238bceSAndroid Build Coastguard Worker if (m_config.useTexture)
705*35238bceSAndroid Build Coastguard Worker m_gl.bindTexture(GL_TEXTURE_2D, 0);
706*35238bceSAndroid Build Coastguard Worker
707*35238bceSAndroid Build Coastguard Worker m_gl.disableVertexAttribArray(m_coordLoc);
708*35238bceSAndroid Build Coastguard Worker
709*35238bceSAndroid Build Coastguard Worker m_gl.useProgram(0);
710*35238bceSAndroid Build Coastguard Worker }
711*35238bceSAndroid Build Coastguard Worker
712*35238bceSAndroid Build Coastguard Worker egl.swapBuffers(m_eglDisplay, m_eglSurface);
713*35238bceSAndroid Build Coastguard Worker }
714*35238bceSAndroid Build Coastguard Worker
715*35238bceSAndroid Build Coastguard Worker m_gl.finish();
716*35238bceSAndroid Build Coastguard Worker GLU_EXPECT_NO_ERROR(m_gl.getError(), "glFinish()");
717*35238bceSAndroid Build Coastguard Worker EGLU_CHECK_CALL(egl, makeCurrent(m_eglDisplay, EGL_NO_SURFACE, EGL_NO_SURFACE, EGL_NO_CONTEXT));
718*35238bceSAndroid Build Coastguard Worker }
719*35238bceSAndroid Build Coastguard Worker
720*35238bceSAndroid Build Coastguard Worker class TestThread : de::Thread
721*35238bceSAndroid Build Coastguard Worker {
722*35238bceSAndroid Build Coastguard Worker public:
723*35238bceSAndroid Build Coastguard Worker TestThread(const vector<TestContext *> contexts, const Library &egl);
724*35238bceSAndroid Build Coastguard Worker ~TestThread(void);
725*35238bceSAndroid Build Coastguard Worker
726*35238bceSAndroid Build Coastguard Worker void start(void);
727*35238bceSAndroid Build Coastguard Worker void join(void);
728*35238bceSAndroid Build Coastguard Worker
resultOk(void)729*35238bceSAndroid Build Coastguard Worker bool resultOk(void)
730*35238bceSAndroid Build Coastguard Worker {
731*35238bceSAndroid Build Coastguard Worker return m_isOk;
732*35238bceSAndroid Build Coastguard Worker }
733*35238bceSAndroid Build Coastguard Worker
734*35238bceSAndroid Build Coastguard Worker private:
735*35238bceSAndroid Build Coastguard Worker vector<TestContext *> m_contexts;
736*35238bceSAndroid Build Coastguard Worker const Library &m_egl;
737*35238bceSAndroid Build Coastguard Worker bool m_isOk;
738*35238bceSAndroid Build Coastguard Worker string m_errorString;
739*35238bceSAndroid Build Coastguard Worker
740*35238bceSAndroid Build Coastguard Worker uint64_t m_beginTimeUs;
741*35238bceSAndroid Build Coastguard Worker uint64_t m_endTimeUs;
742*35238bceSAndroid Build Coastguard Worker
743*35238bceSAndroid Build Coastguard Worker uint64_t m_joinBeginUs;
744*35238bceSAndroid Build Coastguard Worker uint64_t m_joinEndUs;
745*35238bceSAndroid Build Coastguard Worker
746*35238bceSAndroid Build Coastguard Worker uint64_t m_startBeginUs;
747*35238bceSAndroid Build Coastguard Worker uint64_t m_startEndUs;
748*35238bceSAndroid Build Coastguard Worker
749*35238bceSAndroid Build Coastguard Worker virtual void run(void);
750*35238bceSAndroid Build Coastguard Worker
751*35238bceSAndroid Build Coastguard Worker TestThread &operator=(const TestThread &);
752*35238bceSAndroid Build Coastguard Worker TestThread(const TestThread &);
753*35238bceSAndroid Build Coastguard Worker };
754*35238bceSAndroid Build Coastguard Worker
TestThread(const vector<TestContext * > contexts,const Library & egl)755*35238bceSAndroid Build Coastguard Worker TestThread::TestThread(const vector<TestContext *> contexts, const Library &egl)
756*35238bceSAndroid Build Coastguard Worker : m_contexts(contexts)
757*35238bceSAndroid Build Coastguard Worker , m_egl(egl)
758*35238bceSAndroid Build Coastguard Worker , m_isOk(false)
759*35238bceSAndroid Build Coastguard Worker , m_errorString("")
760*35238bceSAndroid Build Coastguard Worker , m_beginTimeUs(0)
761*35238bceSAndroid Build Coastguard Worker , m_endTimeUs(0)
762*35238bceSAndroid Build Coastguard Worker , m_joinBeginUs(0)
763*35238bceSAndroid Build Coastguard Worker , m_joinEndUs(0)
764*35238bceSAndroid Build Coastguard Worker , m_startBeginUs(0)
765*35238bceSAndroid Build Coastguard Worker , m_startEndUs(0)
766*35238bceSAndroid Build Coastguard Worker {
767*35238bceSAndroid Build Coastguard Worker }
768*35238bceSAndroid Build Coastguard Worker
~TestThread(void)769*35238bceSAndroid Build Coastguard Worker TestThread::~TestThread(void)
770*35238bceSAndroid Build Coastguard Worker {
771*35238bceSAndroid Build Coastguard Worker m_contexts.clear();
772*35238bceSAndroid Build Coastguard Worker }
773*35238bceSAndroid Build Coastguard Worker
start(void)774*35238bceSAndroid Build Coastguard Worker void TestThread::start(void)
775*35238bceSAndroid Build Coastguard Worker {
776*35238bceSAndroid Build Coastguard Worker m_startBeginUs = deGetMicroseconds();
777*35238bceSAndroid Build Coastguard Worker de::Thread::start();
778*35238bceSAndroid Build Coastguard Worker m_startEndUs = deGetMicroseconds();
779*35238bceSAndroid Build Coastguard Worker }
780*35238bceSAndroid Build Coastguard Worker
join(void)781*35238bceSAndroid Build Coastguard Worker void TestThread::join(void)
782*35238bceSAndroid Build Coastguard Worker {
783*35238bceSAndroid Build Coastguard Worker m_joinBeginUs = deGetMicroseconds();
784*35238bceSAndroid Build Coastguard Worker de::Thread::join();
785*35238bceSAndroid Build Coastguard Worker m_joinEndUs = deGetMicroseconds();
786*35238bceSAndroid Build Coastguard Worker }
787*35238bceSAndroid Build Coastguard Worker
run(void)788*35238bceSAndroid Build Coastguard Worker void TestThread::run(void)
789*35238bceSAndroid Build Coastguard Worker {
790*35238bceSAndroid Build Coastguard Worker try
791*35238bceSAndroid Build Coastguard Worker {
792*35238bceSAndroid Build Coastguard Worker m_beginTimeUs = deGetMicroseconds();
793*35238bceSAndroid Build Coastguard Worker
794*35238bceSAndroid Build Coastguard Worker for (int contextNdx = 0; contextNdx < (int)m_contexts.size(); contextNdx++)
795*35238bceSAndroid Build Coastguard Worker m_contexts[contextNdx]->render();
796*35238bceSAndroid Build Coastguard Worker
797*35238bceSAndroid Build Coastguard Worker m_isOk = true;
798*35238bceSAndroid Build Coastguard Worker m_endTimeUs = deGetMicroseconds();
799*35238bceSAndroid Build Coastguard Worker }
800*35238bceSAndroid Build Coastguard Worker catch (const std::runtime_error &error)
801*35238bceSAndroid Build Coastguard Worker {
802*35238bceSAndroid Build Coastguard Worker m_isOk = false;
803*35238bceSAndroid Build Coastguard Worker m_errorString = error.what();
804*35238bceSAndroid Build Coastguard Worker }
805*35238bceSAndroid Build Coastguard Worker catch (...)
806*35238bceSAndroid Build Coastguard Worker {
807*35238bceSAndroid Build Coastguard Worker m_isOk = false;
808*35238bceSAndroid Build Coastguard Worker m_errorString = "Got unknown exception";
809*35238bceSAndroid Build Coastguard Worker }
810*35238bceSAndroid Build Coastguard Worker
811*35238bceSAndroid Build Coastguard Worker m_egl.releaseThread();
812*35238bceSAndroid Build Coastguard Worker }
813*35238bceSAndroid Build Coastguard Worker
814*35238bceSAndroid Build Coastguard Worker class SharedRenderingPerfCase : public TestCase
815*35238bceSAndroid Build Coastguard Worker {
816*35238bceSAndroid Build Coastguard Worker public:
817*35238bceSAndroid Build Coastguard Worker SharedRenderingPerfCase(EglTestContext &eglTestCtx, const TestConfig &config, const char *name,
818*35238bceSAndroid Build Coastguard Worker const char *description);
819*35238bceSAndroid Build Coastguard Worker ~SharedRenderingPerfCase(void);
820*35238bceSAndroid Build Coastguard Worker
821*35238bceSAndroid Build Coastguard Worker void init(void);
822*35238bceSAndroid Build Coastguard Worker void deinit(void);
823*35238bceSAndroid Build Coastguard Worker IterateResult iterate(void);
824*35238bceSAndroid Build Coastguard Worker
825*35238bceSAndroid Build Coastguard Worker private:
826*35238bceSAndroid Build Coastguard Worker TestConfig m_config;
827*35238bceSAndroid Build Coastguard Worker const int m_iterationCount;
828*35238bceSAndroid Build Coastguard Worker
829*35238bceSAndroid Build Coastguard Worker EGLDisplay m_display;
830*35238bceSAndroid Build Coastguard Worker vector<TestContext *> m_contexts;
831*35238bceSAndroid Build Coastguard Worker vector<uint64_t> m_results;
832*35238bceSAndroid Build Coastguard Worker
833*35238bceSAndroid Build Coastguard Worker SharedRenderingPerfCase &operator=(const SharedRenderingPerfCase &);
834*35238bceSAndroid Build Coastguard Worker SharedRenderingPerfCase(const SharedRenderingPerfCase &);
835*35238bceSAndroid Build Coastguard Worker };
836*35238bceSAndroid Build Coastguard Worker
SharedRenderingPerfCase(EglTestContext & eglTestCtx,const TestConfig & config,const char * name,const char * description)837*35238bceSAndroid Build Coastguard Worker SharedRenderingPerfCase::SharedRenderingPerfCase(EglTestContext &eglTestCtx, const TestConfig &config, const char *name,
838*35238bceSAndroid Build Coastguard Worker const char *description)
839*35238bceSAndroid Build Coastguard Worker : TestCase(eglTestCtx, tcu::NODETYPE_PERFORMANCE, name, description)
840*35238bceSAndroid Build Coastguard Worker , m_config(config)
841*35238bceSAndroid Build Coastguard Worker , m_iterationCount(30)
842*35238bceSAndroid Build Coastguard Worker , m_display(EGL_NO_DISPLAY)
843*35238bceSAndroid Build Coastguard Worker {
844*35238bceSAndroid Build Coastguard Worker }
845*35238bceSAndroid Build Coastguard Worker
~SharedRenderingPerfCase(void)846*35238bceSAndroid Build Coastguard Worker SharedRenderingPerfCase::~SharedRenderingPerfCase(void)
847*35238bceSAndroid Build Coastguard Worker {
848*35238bceSAndroid Build Coastguard Worker deinit();
849*35238bceSAndroid Build Coastguard Worker }
850*35238bceSAndroid Build Coastguard Worker
init(void)851*35238bceSAndroid Build Coastguard Worker void SharedRenderingPerfCase::init(void)
852*35238bceSAndroid Build Coastguard Worker {
853*35238bceSAndroid Build Coastguard Worker m_display = eglu::getAndInitDisplay(m_eglTestCtx.getNativeDisplay());
854*35238bceSAndroid Build Coastguard Worker
855*35238bceSAndroid Build Coastguard Worker {
856*35238bceSAndroid Build Coastguard Worker const Library &egl = m_eglTestCtx.getLibrary();
857*35238bceSAndroid Build Coastguard Worker const EGLint attribList[] = {EGL_SURFACE_TYPE, EGL_PBUFFER_BIT, EGL_RENDERABLE_TYPE, EGL_OPENGL_ES2_BIT,
858*35238bceSAndroid Build Coastguard Worker EGL_NONE};
859*35238bceSAndroid Build Coastguard Worker EGLConfig eglConfig = eglu::chooseSingleConfig(egl, m_display, attribList);
860*35238bceSAndroid Build Coastguard Worker
861*35238bceSAndroid Build Coastguard Worker // Create contexts and resources
862*35238bceSAndroid Build Coastguard Worker for (int threadNdx = 0; threadNdx < m_config.threadCount * m_config.perThreadContextCount; threadNdx++)
863*35238bceSAndroid Build Coastguard Worker m_contexts.push_back(new TestContext(m_eglTestCtx, m_display, eglConfig, m_config, m_config.sharedContexts,
864*35238bceSAndroid Build Coastguard Worker (threadNdx == 0 ? DE_NULL : m_contexts[threadNdx - 1])));
865*35238bceSAndroid Build Coastguard Worker }
866*35238bceSAndroid Build Coastguard Worker }
867*35238bceSAndroid Build Coastguard Worker
deinit(void)868*35238bceSAndroid Build Coastguard Worker void SharedRenderingPerfCase::deinit(void)
869*35238bceSAndroid Build Coastguard Worker {
870*35238bceSAndroid Build Coastguard Worker // Destroy resources and contexts
871*35238bceSAndroid Build Coastguard Worker for (int threadNdx = 0; threadNdx < (int)m_contexts.size(); threadNdx++)
872*35238bceSAndroid Build Coastguard Worker {
873*35238bceSAndroid Build Coastguard Worker delete m_contexts[threadNdx];
874*35238bceSAndroid Build Coastguard Worker m_contexts[threadNdx] = DE_NULL;
875*35238bceSAndroid Build Coastguard Worker }
876*35238bceSAndroid Build Coastguard Worker
877*35238bceSAndroid Build Coastguard Worker m_contexts.clear();
878*35238bceSAndroid Build Coastguard Worker m_results.clear();
879*35238bceSAndroid Build Coastguard Worker
880*35238bceSAndroid Build Coastguard Worker if (m_display != EGL_NO_DISPLAY)
881*35238bceSAndroid Build Coastguard Worker {
882*35238bceSAndroid Build Coastguard Worker m_eglTestCtx.getLibrary().terminate(m_display);
883*35238bceSAndroid Build Coastguard Worker m_display = EGL_NO_DISPLAY;
884*35238bceSAndroid Build Coastguard Worker }
885*35238bceSAndroid Build Coastguard Worker }
886*35238bceSAndroid Build Coastguard Worker
887*35238bceSAndroid Build Coastguard Worker namespace
888*35238bceSAndroid Build Coastguard Worker {
889*35238bceSAndroid Build Coastguard Worker
createThreads(vector<TestThread * > & threads,int threadCount,int perThreadContextCount,vector<TestContext * > & contexts,const Library & egl)890*35238bceSAndroid Build Coastguard Worker void createThreads(vector<TestThread *> &threads, int threadCount, int perThreadContextCount,
891*35238bceSAndroid Build Coastguard Worker vector<TestContext *> &contexts, const Library &egl)
892*35238bceSAndroid Build Coastguard Worker {
893*35238bceSAndroid Build Coastguard Worker DE_ASSERT(threadCount * perThreadContextCount == (int)contexts.size());
894*35238bceSAndroid Build Coastguard Worker DE_ASSERT(threads.empty());
895*35238bceSAndroid Build Coastguard Worker
896*35238bceSAndroid Build Coastguard Worker vector<TestContext *> threadContexts;
897*35238bceSAndroid Build Coastguard Worker
898*35238bceSAndroid Build Coastguard Worker for (int threadNdx = 0; threadNdx < threadCount; threadNdx++)
899*35238bceSAndroid Build Coastguard Worker {
900*35238bceSAndroid Build Coastguard Worker for (int contextNdx = 0; contextNdx < perThreadContextCount; contextNdx++)
901*35238bceSAndroid Build Coastguard Worker threadContexts.push_back(contexts[threadNdx * perThreadContextCount + contextNdx]);
902*35238bceSAndroid Build Coastguard Worker
903*35238bceSAndroid Build Coastguard Worker threads.push_back(new TestThread(threadContexts, egl));
904*35238bceSAndroid Build Coastguard Worker
905*35238bceSAndroid Build Coastguard Worker threadContexts.clear();
906*35238bceSAndroid Build Coastguard Worker }
907*35238bceSAndroid Build Coastguard Worker }
908*35238bceSAndroid Build Coastguard Worker
destroyThreads(vector<TestThread * > & threads)909*35238bceSAndroid Build Coastguard Worker void destroyThreads(vector<TestThread *> &threads)
910*35238bceSAndroid Build Coastguard Worker {
911*35238bceSAndroid Build Coastguard Worker for (int threadNdx = 0; threadNdx < (int)threads.size(); threadNdx++)
912*35238bceSAndroid Build Coastguard Worker {
913*35238bceSAndroid Build Coastguard Worker delete threads[threadNdx];
914*35238bceSAndroid Build Coastguard Worker threads[threadNdx] = DE_NULL;
915*35238bceSAndroid Build Coastguard Worker }
916*35238bceSAndroid Build Coastguard Worker
917*35238bceSAndroid Build Coastguard Worker threads.clear();
918*35238bceSAndroid Build Coastguard Worker }
919*35238bceSAndroid Build Coastguard Worker
startThreads(vector<TestThread * > & threads)920*35238bceSAndroid Build Coastguard Worker void startThreads(vector<TestThread *> &threads)
921*35238bceSAndroid Build Coastguard Worker {
922*35238bceSAndroid Build Coastguard Worker for (int threadNdx = 0; threadNdx < (int)threads.size(); threadNdx++)
923*35238bceSAndroid Build Coastguard Worker threads[threadNdx]->start();
924*35238bceSAndroid Build Coastguard Worker }
925*35238bceSAndroid Build Coastguard Worker
joinThreads(vector<TestThread * > & threads)926*35238bceSAndroid Build Coastguard Worker void joinThreads(vector<TestThread *> &threads)
927*35238bceSAndroid Build Coastguard Worker {
928*35238bceSAndroid Build Coastguard Worker for (int threadNdx = 0; threadNdx < (int)threads.size(); threadNdx++)
929*35238bceSAndroid Build Coastguard Worker threads[threadNdx]->join();
930*35238bceSAndroid Build Coastguard Worker }
931*35238bceSAndroid Build Coastguard Worker
threadResultsOk(const vector<TestThread * > & threads)932*35238bceSAndroid Build Coastguard Worker bool threadResultsOk(const vector<TestThread *> &threads)
933*35238bceSAndroid Build Coastguard Worker {
934*35238bceSAndroid Build Coastguard Worker for (int threadNdx = 0; threadNdx < (int)threads.size(); threadNdx++)
935*35238bceSAndroid Build Coastguard Worker {
936*35238bceSAndroid Build Coastguard Worker if (!threads[threadNdx]->resultOk())
937*35238bceSAndroid Build Coastguard Worker return false;
938*35238bceSAndroid Build Coastguard Worker }
939*35238bceSAndroid Build Coastguard Worker
940*35238bceSAndroid Build Coastguard Worker return true;
941*35238bceSAndroid Build Coastguard Worker }
942*35238bceSAndroid Build Coastguard Worker
logAndSetResults(tcu::TestContext & testCtx,const vector<uint64_t> & r)943*35238bceSAndroid Build Coastguard Worker void logAndSetResults(tcu::TestContext &testCtx, const vector<uint64_t> &r)
944*35238bceSAndroid Build Coastguard Worker {
945*35238bceSAndroid Build Coastguard Worker TestLog &log = testCtx.getLog();
946*35238bceSAndroid Build Coastguard Worker vector<uint64_t> resultsUs = r;
947*35238bceSAndroid Build Coastguard Worker uint64_t sum = 0;
948*35238bceSAndroid Build Coastguard Worker uint64_t average;
949*35238bceSAndroid Build Coastguard Worker uint64_t median;
950*35238bceSAndroid Build Coastguard Worker double deviation;
951*35238bceSAndroid Build Coastguard Worker
952*35238bceSAndroid Build Coastguard Worker log << TestLog::SampleList("Result", "Result") << TestLog::SampleInfo
953*35238bceSAndroid Build Coastguard Worker << TestLog::ValueInfo("Time", "Time", "us", QP_SAMPLE_VALUE_TAG_RESPONSE) << TestLog::EndSampleInfo;
954*35238bceSAndroid Build Coastguard Worker
955*35238bceSAndroid Build Coastguard Worker for (int resultNdx = 0; resultNdx < (int)resultsUs.size(); resultNdx++)
956*35238bceSAndroid Build Coastguard Worker log << TestLog::Sample << int64_t(resultsUs[resultNdx]) << TestLog::EndSample;
957*35238bceSAndroid Build Coastguard Worker
958*35238bceSAndroid Build Coastguard Worker log << TestLog::EndSampleList;
959*35238bceSAndroid Build Coastguard Worker
960*35238bceSAndroid Build Coastguard Worker std::sort(resultsUs.begin(), resultsUs.end());
961*35238bceSAndroid Build Coastguard Worker
962*35238bceSAndroid Build Coastguard Worker for (int resultNdx = 0; resultNdx < (int)resultsUs.size(); resultNdx++)
963*35238bceSAndroid Build Coastguard Worker sum += resultsUs[resultNdx];
964*35238bceSAndroid Build Coastguard Worker
965*35238bceSAndroid Build Coastguard Worker average = sum / resultsUs.size();
966*35238bceSAndroid Build Coastguard Worker median = resultsUs[resultsUs.size() / 2];
967*35238bceSAndroid Build Coastguard Worker
968*35238bceSAndroid Build Coastguard Worker deviation = 0.0;
969*35238bceSAndroid Build Coastguard Worker for (int resultNdx = 0; resultNdx < (int)resultsUs.size(); resultNdx++)
970*35238bceSAndroid Build Coastguard Worker deviation += (double)((resultsUs[resultNdx] - average) * (resultsUs[resultNdx] - average));
971*35238bceSAndroid Build Coastguard Worker
972*35238bceSAndroid Build Coastguard Worker deviation = std::sqrt(deviation / (double)resultsUs.size());
973*35238bceSAndroid Build Coastguard Worker
974*35238bceSAndroid Build Coastguard Worker {
975*35238bceSAndroid Build Coastguard Worker tcu::ScopedLogSection section(log, "Statistics from results", "Statistics from results");
976*35238bceSAndroid Build Coastguard Worker
977*35238bceSAndroid Build Coastguard Worker log << TestLog::Message << "Average: " << ((double)average / 1000.0) << "ms\n"
978*35238bceSAndroid Build Coastguard Worker << "Standard deviation: " << ((double)deviation / 1000.0) << "ms\n"
979*35238bceSAndroid Build Coastguard Worker << "Standard error of mean: " << (((double)deviation / std::sqrt((double)resultsUs.size())) / 1000.0)
980*35238bceSAndroid Build Coastguard Worker << "ms\n"
981*35238bceSAndroid Build Coastguard Worker << "Median: " << ((double)median / 1000.0) << "ms\n"
982*35238bceSAndroid Build Coastguard Worker << TestLog::EndMessage;
983*35238bceSAndroid Build Coastguard Worker }
984*35238bceSAndroid Build Coastguard Worker
985*35238bceSAndroid Build Coastguard Worker testCtx.setTestResult(QP_TEST_RESULT_PASS, de::floatToString((float)((double)average / 1000.0), 2).c_str());
986*35238bceSAndroid Build Coastguard Worker }
987*35238bceSAndroid Build Coastguard Worker
logTestConfig(TestLog & log,const TestConfig & config)988*35238bceSAndroid Build Coastguard Worker void logTestConfig(TestLog &log, const TestConfig &config)
989*35238bceSAndroid Build Coastguard Worker {
990*35238bceSAndroid Build Coastguard Worker tcu::ScopedLogSection threadSection(log, "Test info", "Test information");
991*35238bceSAndroid Build Coastguard Worker
992*35238bceSAndroid Build Coastguard Worker log << TestLog::Message << "Total triangles rendered: : "
993*35238bceSAndroid Build Coastguard Worker << config.triangleCount * config.drawCallCount * config.frameCount * config.perThreadContextCount *
994*35238bceSAndroid Build Coastguard Worker config.threadCount
995*35238bceSAndroid Build Coastguard Worker << TestLog::EndMessage;
996*35238bceSAndroid Build Coastguard Worker log << TestLog::Message << "Number of threads: " << config.threadCount << TestLog::EndMessage;
997*35238bceSAndroid Build Coastguard Worker log << TestLog::Message << "Number of contexts used to render with each thread: " << config.perThreadContextCount
998*35238bceSAndroid Build Coastguard Worker << TestLog::EndMessage;
999*35238bceSAndroid Build Coastguard Worker log << TestLog::Message << "Number of frames rendered with each context: " << config.frameCount
1000*35238bceSAndroid Build Coastguard Worker << TestLog::EndMessage;
1001*35238bceSAndroid Build Coastguard Worker log << TestLog::Message << "Number of draw calls performed by each frame: " << config.drawCallCount
1002*35238bceSAndroid Build Coastguard Worker << TestLog::EndMessage;
1003*35238bceSAndroid Build Coastguard Worker log << TestLog::Message << "Number of triangles rendered by each draw call: " << config.triangleCount
1004*35238bceSAndroid Build Coastguard Worker << TestLog::EndMessage;
1005*35238bceSAndroid Build Coastguard Worker
1006*35238bceSAndroid Build Coastguard Worker if (config.sharedContexts)
1007*35238bceSAndroid Build Coastguard Worker log << TestLog::Message << "Shared contexts." << TestLog::EndMessage;
1008*35238bceSAndroid Build Coastguard Worker else
1009*35238bceSAndroid Build Coastguard Worker log << TestLog::Message << "No shared contexts." << TestLog::EndMessage;
1010*35238bceSAndroid Build Coastguard Worker
1011*35238bceSAndroid Build Coastguard Worker if (config.useCoordBuffer)
1012*35238bceSAndroid Build Coastguard Worker log << TestLog::Message << (config.sharedCoordBuffer ? "Shared " : "") << "Coordinate buffer"
1013*35238bceSAndroid Build Coastguard Worker << TestLog::EndMessage;
1014*35238bceSAndroid Build Coastguard Worker else
1015*35238bceSAndroid Build Coastguard Worker log << TestLog::Message << "Coordinates from pointer" << TestLog::EndMessage;
1016*35238bceSAndroid Build Coastguard Worker
1017*35238bceSAndroid Build Coastguard Worker if (config.useIndices)
1018*35238bceSAndroid Build Coastguard Worker log << TestLog::Message << "Using glDrawElements with indices from "
1019*35238bceSAndroid Build Coastguard Worker << (config.sharedIndexBuffer ? "shared " : "") << (config.useIndexBuffer ? "buffer." : "pointer.")
1020*35238bceSAndroid Build Coastguard Worker << TestLog::EndMessage;
1021*35238bceSAndroid Build Coastguard Worker
1022*35238bceSAndroid Build Coastguard Worker if (config.useTexture)
1023*35238bceSAndroid Build Coastguard Worker {
1024*35238bceSAndroid Build Coastguard Worker if (config.textureType == TestConfig::TEXTURETYPE_TEXTURE)
1025*35238bceSAndroid Build Coastguard Worker log << TestLog::Message << "Use texture." << TestLog::EndMessage;
1026*35238bceSAndroid Build Coastguard Worker else if (config.textureType == TestConfig::TEXTURETYPE_SHARED_TEXTURE)
1027*35238bceSAndroid Build Coastguard Worker log << TestLog::Message << "Use shared texture." << TestLog::EndMessage;
1028*35238bceSAndroid Build Coastguard Worker else if (config.textureType == TestConfig::TEXTURETYPE_IMAGE)
1029*35238bceSAndroid Build Coastguard Worker log << TestLog::Message << "Use texture created from EGLImage." << TestLog::EndMessage;
1030*35238bceSAndroid Build Coastguard Worker else if (config.textureType == TestConfig::TEXTURETYPE_SHARED_IMAGE)
1031*35238bceSAndroid Build Coastguard Worker log << TestLog::Message << "Use texture created from shared EGLImage." << TestLog::EndMessage;
1032*35238bceSAndroid Build Coastguard Worker else if (config.textureType == TestConfig::TEXTURETYPE_SHARED_IMAGE_TEXTURE)
1033*35238bceSAndroid Build Coastguard Worker log << TestLog::Message << "Use shared texture created from EGLImage." << TestLog::EndMessage;
1034*35238bceSAndroid Build Coastguard Worker else
1035*35238bceSAndroid Build Coastguard Worker DE_ASSERT(false);
1036*35238bceSAndroid Build Coastguard Worker
1037*35238bceSAndroid Build Coastguard Worker log << TestLog::Message << "Texture size: " << config.textureWidth << "x" << config.textureHeight
1038*35238bceSAndroid Build Coastguard Worker << TestLog::EndMessage;
1039*35238bceSAndroid Build Coastguard Worker }
1040*35238bceSAndroid Build Coastguard Worker
1041*35238bceSAndroid Build Coastguard Worker if (config.sharedProgram)
1042*35238bceSAndroid Build Coastguard Worker log << TestLog::Message << "Shared program." << TestLog::EndMessage;
1043*35238bceSAndroid Build Coastguard Worker
1044*35238bceSAndroid Build Coastguard Worker log << TestLog::Message << "Surface size: " << config.surfaceWidth << "x" << config.surfaceHeight
1045*35238bceSAndroid Build Coastguard Worker << TestLog::EndMessage;
1046*35238bceSAndroid Build Coastguard Worker }
1047*35238bceSAndroid Build Coastguard Worker
1048*35238bceSAndroid Build Coastguard Worker } // namespace
1049*35238bceSAndroid Build Coastguard Worker
iterate(void)1050*35238bceSAndroid Build Coastguard Worker TestCase::IterateResult SharedRenderingPerfCase::iterate(void)
1051*35238bceSAndroid Build Coastguard Worker {
1052*35238bceSAndroid Build Coastguard Worker uint64_t beginTimeUs;
1053*35238bceSAndroid Build Coastguard Worker uint64_t endTimeUs;
1054*35238bceSAndroid Build Coastguard Worker vector<TestThread *> threads;
1055*35238bceSAndroid Build Coastguard Worker
1056*35238bceSAndroid Build Coastguard Worker if (m_results.empty())
1057*35238bceSAndroid Build Coastguard Worker logTestConfig(m_testCtx.getLog(), m_config);
1058*35238bceSAndroid Build Coastguard Worker
1059*35238bceSAndroid Build Coastguard Worker createThreads(threads, m_config.threadCount, m_config.perThreadContextCount, m_contexts, m_eglTestCtx.getLibrary());
1060*35238bceSAndroid Build Coastguard Worker
1061*35238bceSAndroid Build Coastguard Worker beginTimeUs = deGetMicroseconds();
1062*35238bceSAndroid Build Coastguard Worker
1063*35238bceSAndroid Build Coastguard Worker startThreads(threads);
1064*35238bceSAndroid Build Coastguard Worker joinThreads(threads);
1065*35238bceSAndroid Build Coastguard Worker
1066*35238bceSAndroid Build Coastguard Worker endTimeUs = deGetMicroseconds();
1067*35238bceSAndroid Build Coastguard Worker
1068*35238bceSAndroid Build Coastguard Worker if (!threadResultsOk(threads))
1069*35238bceSAndroid Build Coastguard Worker {
1070*35238bceSAndroid Build Coastguard Worker m_testCtx.setTestResult(QP_TEST_RESULT_FAIL, "Fail");
1071*35238bceSAndroid Build Coastguard Worker return STOP;
1072*35238bceSAndroid Build Coastguard Worker }
1073*35238bceSAndroid Build Coastguard Worker
1074*35238bceSAndroid Build Coastguard Worker destroyThreads(threads);
1075*35238bceSAndroid Build Coastguard Worker
1076*35238bceSAndroid Build Coastguard Worker m_results.push_back(endTimeUs - beginTimeUs);
1077*35238bceSAndroid Build Coastguard Worker
1078*35238bceSAndroid Build Coastguard Worker if ((int)m_results.size() == m_iterationCount)
1079*35238bceSAndroid Build Coastguard Worker {
1080*35238bceSAndroid Build Coastguard Worker logAndSetResults(m_testCtx, m_results);
1081*35238bceSAndroid Build Coastguard Worker return STOP;
1082*35238bceSAndroid Build Coastguard Worker }
1083*35238bceSAndroid Build Coastguard Worker else
1084*35238bceSAndroid Build Coastguard Worker return CONTINUE;
1085*35238bceSAndroid Build Coastguard Worker }
1086*35238bceSAndroid Build Coastguard Worker
createTestName(int threads,int perThreadContextCount)1087*35238bceSAndroid Build Coastguard Worker string createTestName(int threads, int perThreadContextCount)
1088*35238bceSAndroid Build Coastguard Worker {
1089*35238bceSAndroid Build Coastguard Worker std::ostringstream stream;
1090*35238bceSAndroid Build Coastguard Worker
1091*35238bceSAndroid Build Coastguard Worker stream << threads << (threads == 1 ? "_thread_" : "_threads_") << perThreadContextCount
1092*35238bceSAndroid Build Coastguard Worker << (perThreadContextCount == 1 ? "_context" : "_contexts");
1093*35238bceSAndroid Build Coastguard Worker
1094*35238bceSAndroid Build Coastguard Worker return stream.str();
1095*35238bceSAndroid Build Coastguard Worker }
1096*35238bceSAndroid Build Coastguard Worker
1097*35238bceSAndroid Build Coastguard Worker } // namespace
1098*35238bceSAndroid Build Coastguard Worker
GLES2SharedRenderingPerfTests(EglTestContext & eglTestCtx)1099*35238bceSAndroid Build Coastguard Worker GLES2SharedRenderingPerfTests::GLES2SharedRenderingPerfTests(EglTestContext &eglTestCtx)
1100*35238bceSAndroid Build Coastguard Worker : TestCaseGroup(eglTestCtx, "gles2_shared_render", "")
1101*35238bceSAndroid Build Coastguard Worker {
1102*35238bceSAndroid Build Coastguard Worker }
1103*35238bceSAndroid Build Coastguard Worker
init(void)1104*35238bceSAndroid Build Coastguard Worker void GLES2SharedRenderingPerfTests::init(void)
1105*35238bceSAndroid Build Coastguard Worker {
1106*35238bceSAndroid Build Coastguard Worker TestConfig basicConfig;
1107*35238bceSAndroid Build Coastguard Worker
1108*35238bceSAndroid Build Coastguard Worker basicConfig.threadCount = 1;
1109*35238bceSAndroid Build Coastguard Worker basicConfig.perThreadContextCount = 1;
1110*35238bceSAndroid Build Coastguard Worker
1111*35238bceSAndroid Build Coastguard Worker basicConfig.sharedContexts = true;
1112*35238bceSAndroid Build Coastguard Worker basicConfig.frameCount = 10;
1113*35238bceSAndroid Build Coastguard Worker basicConfig.drawCallCount = 10;
1114*35238bceSAndroid Build Coastguard Worker basicConfig.triangleCount = 100;
1115*35238bceSAndroid Build Coastguard Worker
1116*35238bceSAndroid Build Coastguard Worker basicConfig.useCoordBuffer = true;
1117*35238bceSAndroid Build Coastguard Worker basicConfig.sharedCoordBuffer = false;
1118*35238bceSAndroid Build Coastguard Worker
1119*35238bceSAndroid Build Coastguard Worker basicConfig.useIndices = true;
1120*35238bceSAndroid Build Coastguard Worker basicConfig.useIndexBuffer = true;
1121*35238bceSAndroid Build Coastguard Worker basicConfig.sharedIndexBuffer = false;
1122*35238bceSAndroid Build Coastguard Worker
1123*35238bceSAndroid Build Coastguard Worker basicConfig.useTexture = true;
1124*35238bceSAndroid Build Coastguard Worker basicConfig.textureType = TestConfig::TEXTURETYPE_TEXTURE;
1125*35238bceSAndroid Build Coastguard Worker
1126*35238bceSAndroid Build Coastguard Worker basicConfig.sharedProgram = false;
1127*35238bceSAndroid Build Coastguard Worker
1128*35238bceSAndroid Build Coastguard Worker basicConfig.textureWidth = 128;
1129*35238bceSAndroid Build Coastguard Worker basicConfig.textureHeight = 128;
1130*35238bceSAndroid Build Coastguard Worker
1131*35238bceSAndroid Build Coastguard Worker basicConfig.surfaceWidth = 256;
1132*35238bceSAndroid Build Coastguard Worker basicConfig.surfaceHeight = 256;
1133*35238bceSAndroid Build Coastguard Worker
1134*35238bceSAndroid Build Coastguard Worker const int threadCounts[] = {1, 2, 4};
1135*35238bceSAndroid Build Coastguard Worker const int perThreadContextCounts[] = {1, 2, 4};
1136*35238bceSAndroid Build Coastguard Worker
1137*35238bceSAndroid Build Coastguard Worker // Add no sharing tests
1138*35238bceSAndroid Build Coastguard Worker {
1139*35238bceSAndroid Build Coastguard Worker TestCaseGroup *sharedNoneGroup =
1140*35238bceSAndroid Build Coastguard Worker new TestCaseGroup(m_eglTestCtx, "no_shared_context", "Tests without sharing contexts.");
1141*35238bceSAndroid Build Coastguard Worker
1142*35238bceSAndroid Build Coastguard Worker for (int threadCountNdx = 0; threadCountNdx < DE_LENGTH_OF_ARRAY(threadCounts); threadCountNdx++)
1143*35238bceSAndroid Build Coastguard Worker {
1144*35238bceSAndroid Build Coastguard Worker int threadCount = threadCounts[threadCountNdx];
1145*35238bceSAndroid Build Coastguard Worker
1146*35238bceSAndroid Build Coastguard Worker for (int contextCountNdx = 0; contextCountNdx < DE_LENGTH_OF_ARRAY(perThreadContextCounts);
1147*35238bceSAndroid Build Coastguard Worker contextCountNdx++)
1148*35238bceSAndroid Build Coastguard Worker {
1149*35238bceSAndroid Build Coastguard Worker int contextCount = perThreadContextCounts[contextCountNdx];
1150*35238bceSAndroid Build Coastguard Worker
1151*35238bceSAndroid Build Coastguard Worker if (threadCount * contextCount != 4 && threadCount * contextCount != 1)
1152*35238bceSAndroid Build Coastguard Worker continue;
1153*35238bceSAndroid Build Coastguard Worker
1154*35238bceSAndroid Build Coastguard Worker TestConfig config = basicConfig;
1155*35238bceSAndroid Build Coastguard Worker config.threadCount = threadCount;
1156*35238bceSAndroid Build Coastguard Worker config.perThreadContextCount = contextCount;
1157*35238bceSAndroid Build Coastguard Worker config.sharedContexts = false;
1158*35238bceSAndroid Build Coastguard Worker
1159*35238bceSAndroid Build Coastguard Worker {
1160*35238bceSAndroid Build Coastguard Worker TestConfig smallConfig = config;
1161*35238bceSAndroid Build Coastguard Worker smallConfig.triangleCount = 1;
1162*35238bceSAndroid Build Coastguard Worker smallConfig.drawCallCount = 1000;
1163*35238bceSAndroid Build Coastguard Worker smallConfig.frameCount = 10;
1164*35238bceSAndroid Build Coastguard Worker
1165*35238bceSAndroid Build Coastguard Worker if (threadCount * contextCount == 1)
1166*35238bceSAndroid Build Coastguard Worker smallConfig.frameCount *= 4;
1167*35238bceSAndroid Build Coastguard Worker
1168*35238bceSAndroid Build Coastguard Worker sharedNoneGroup->addChild(new SharedRenderingPerfCase(
1169*35238bceSAndroid Build Coastguard Worker m_eglTestCtx, smallConfig, (createTestName(threadCount, contextCount) + "_small_call").c_str(),
1170*35238bceSAndroid Build Coastguard Worker ""));
1171*35238bceSAndroid Build Coastguard Worker }
1172*35238bceSAndroid Build Coastguard Worker
1173*35238bceSAndroid Build Coastguard Worker {
1174*35238bceSAndroid Build Coastguard Worker TestConfig bigConfig = config;
1175*35238bceSAndroid Build Coastguard Worker bigConfig.triangleCount = 1000;
1176*35238bceSAndroid Build Coastguard Worker bigConfig.drawCallCount = 1;
1177*35238bceSAndroid Build Coastguard Worker bigConfig.frameCount = 10;
1178*35238bceSAndroid Build Coastguard Worker
1179*35238bceSAndroid Build Coastguard Worker if (threadCount * contextCount == 1)
1180*35238bceSAndroid Build Coastguard Worker bigConfig.frameCount *= 4;
1181*35238bceSAndroid Build Coastguard Worker
1182*35238bceSAndroid Build Coastguard Worker sharedNoneGroup->addChild(new SharedRenderingPerfCase(
1183*35238bceSAndroid Build Coastguard Worker m_eglTestCtx, bigConfig, (createTestName(threadCount, contextCount) + "_big_call").c_str(),
1184*35238bceSAndroid Build Coastguard Worker ""));
1185*35238bceSAndroid Build Coastguard Worker }
1186*35238bceSAndroid Build Coastguard Worker }
1187*35238bceSAndroid Build Coastguard Worker }
1188*35238bceSAndroid Build Coastguard Worker
1189*35238bceSAndroid Build Coastguard Worker addChild(sharedNoneGroup);
1190*35238bceSAndroid Build Coastguard Worker }
1191*35238bceSAndroid Build Coastguard Worker
1192*35238bceSAndroid Build Coastguard Worker // Add no resource sharing tests
1193*35238bceSAndroid Build Coastguard Worker {
1194*35238bceSAndroid Build Coastguard Worker TestCaseGroup *sharedNoneGroup =
1195*35238bceSAndroid Build Coastguard Worker new TestCaseGroup(m_eglTestCtx, "no_shared_resource", "Tests without shared resources.");
1196*35238bceSAndroid Build Coastguard Worker
1197*35238bceSAndroid Build Coastguard Worker for (int threadCountNdx = 0; threadCountNdx < DE_LENGTH_OF_ARRAY(threadCounts); threadCountNdx++)
1198*35238bceSAndroid Build Coastguard Worker {
1199*35238bceSAndroid Build Coastguard Worker int threadCount = threadCounts[threadCountNdx];
1200*35238bceSAndroid Build Coastguard Worker
1201*35238bceSAndroid Build Coastguard Worker for (int contextCountNdx = 0; contextCountNdx < DE_LENGTH_OF_ARRAY(perThreadContextCounts);
1202*35238bceSAndroid Build Coastguard Worker contextCountNdx++)
1203*35238bceSAndroid Build Coastguard Worker {
1204*35238bceSAndroid Build Coastguard Worker int contextCount = perThreadContextCounts[contextCountNdx];
1205*35238bceSAndroid Build Coastguard Worker
1206*35238bceSAndroid Build Coastguard Worker if (threadCount * contextCount != 4 && threadCount * contextCount != 1)
1207*35238bceSAndroid Build Coastguard Worker continue;
1208*35238bceSAndroid Build Coastguard Worker
1209*35238bceSAndroid Build Coastguard Worker TestConfig config = basicConfig;
1210*35238bceSAndroid Build Coastguard Worker config.threadCount = threadCount;
1211*35238bceSAndroid Build Coastguard Worker config.perThreadContextCount = contextCount;
1212*35238bceSAndroid Build Coastguard Worker
1213*35238bceSAndroid Build Coastguard Worker {
1214*35238bceSAndroid Build Coastguard Worker TestConfig smallConfig = config;
1215*35238bceSAndroid Build Coastguard Worker smallConfig.triangleCount = 1;
1216*35238bceSAndroid Build Coastguard Worker smallConfig.drawCallCount = 1000;
1217*35238bceSAndroid Build Coastguard Worker smallConfig.frameCount = 10;
1218*35238bceSAndroid Build Coastguard Worker
1219*35238bceSAndroid Build Coastguard Worker if (threadCount * contextCount == 1)
1220*35238bceSAndroid Build Coastguard Worker smallConfig.frameCount *= 4;
1221*35238bceSAndroid Build Coastguard Worker
1222*35238bceSAndroid Build Coastguard Worker sharedNoneGroup->addChild(new SharedRenderingPerfCase(
1223*35238bceSAndroid Build Coastguard Worker m_eglTestCtx, smallConfig, (createTestName(threadCount, contextCount) + "_small_call").c_str(),
1224*35238bceSAndroid Build Coastguard Worker ""));
1225*35238bceSAndroid Build Coastguard Worker }
1226*35238bceSAndroid Build Coastguard Worker
1227*35238bceSAndroid Build Coastguard Worker {
1228*35238bceSAndroid Build Coastguard Worker TestConfig bigConfig = config;
1229*35238bceSAndroid Build Coastguard Worker bigConfig.triangleCount = 1000;
1230*35238bceSAndroid Build Coastguard Worker bigConfig.drawCallCount = 1;
1231*35238bceSAndroid Build Coastguard Worker bigConfig.frameCount = 10;
1232*35238bceSAndroid Build Coastguard Worker
1233*35238bceSAndroid Build Coastguard Worker if (threadCount * contextCount == 1)
1234*35238bceSAndroid Build Coastguard Worker bigConfig.frameCount *= 4;
1235*35238bceSAndroid Build Coastguard Worker
1236*35238bceSAndroid Build Coastguard Worker sharedNoneGroup->addChild(new SharedRenderingPerfCase(
1237*35238bceSAndroid Build Coastguard Worker m_eglTestCtx, bigConfig, (createTestName(threadCount, contextCount) + "_big_call").c_str(),
1238*35238bceSAndroid Build Coastguard Worker ""));
1239*35238bceSAndroid Build Coastguard Worker }
1240*35238bceSAndroid Build Coastguard Worker }
1241*35238bceSAndroid Build Coastguard Worker }
1242*35238bceSAndroid Build Coastguard Worker
1243*35238bceSAndroid Build Coastguard Worker addChild(sharedNoneGroup);
1244*35238bceSAndroid Build Coastguard Worker }
1245*35238bceSAndroid Build Coastguard Worker
1246*35238bceSAndroid Build Coastguard Worker // Add shared coord buffer tests
1247*35238bceSAndroid Build Coastguard Worker {
1248*35238bceSAndroid Build Coastguard Worker TestCaseGroup *sharedCoordBufferGroup =
1249*35238bceSAndroid Build Coastguard Worker new TestCaseGroup(m_eglTestCtx, "shared_coord_buffer", "Shared coordinate bufffer");
1250*35238bceSAndroid Build Coastguard Worker
1251*35238bceSAndroid Build Coastguard Worker for (int threadCountNdx = 0; threadCountNdx < DE_LENGTH_OF_ARRAY(threadCounts); threadCountNdx++)
1252*35238bceSAndroid Build Coastguard Worker {
1253*35238bceSAndroid Build Coastguard Worker int threadCount = threadCounts[threadCountNdx];
1254*35238bceSAndroid Build Coastguard Worker
1255*35238bceSAndroid Build Coastguard Worker for (int contextCountNdx = 0; contextCountNdx < DE_LENGTH_OF_ARRAY(perThreadContextCounts);
1256*35238bceSAndroid Build Coastguard Worker contextCountNdx++)
1257*35238bceSAndroid Build Coastguard Worker {
1258*35238bceSAndroid Build Coastguard Worker int contextCount = perThreadContextCounts[contextCountNdx];
1259*35238bceSAndroid Build Coastguard Worker
1260*35238bceSAndroid Build Coastguard Worker if (threadCount * contextCount != 4 && threadCount * contextCount != 1)
1261*35238bceSAndroid Build Coastguard Worker continue;
1262*35238bceSAndroid Build Coastguard Worker
1263*35238bceSAndroid Build Coastguard Worker TestConfig config = basicConfig;
1264*35238bceSAndroid Build Coastguard Worker config.sharedCoordBuffer = true;
1265*35238bceSAndroid Build Coastguard Worker config.threadCount = threadCount;
1266*35238bceSAndroid Build Coastguard Worker config.perThreadContextCount = contextCount;
1267*35238bceSAndroid Build Coastguard Worker
1268*35238bceSAndroid Build Coastguard Worker {
1269*35238bceSAndroid Build Coastguard Worker TestConfig smallConfig = config;
1270*35238bceSAndroid Build Coastguard Worker smallConfig.triangleCount = 1;
1271*35238bceSAndroid Build Coastguard Worker smallConfig.drawCallCount = 1000;
1272*35238bceSAndroid Build Coastguard Worker smallConfig.frameCount = 10;
1273*35238bceSAndroid Build Coastguard Worker
1274*35238bceSAndroid Build Coastguard Worker if (threadCount * contextCount == 1)
1275*35238bceSAndroid Build Coastguard Worker smallConfig.frameCount *= 4;
1276*35238bceSAndroid Build Coastguard Worker
1277*35238bceSAndroid Build Coastguard Worker sharedCoordBufferGroup->addChild(new SharedRenderingPerfCase(
1278*35238bceSAndroid Build Coastguard Worker m_eglTestCtx, smallConfig, (createTestName(threadCount, contextCount) + "_small_call").c_str(),
1279*35238bceSAndroid Build Coastguard Worker ""));
1280*35238bceSAndroid Build Coastguard Worker }
1281*35238bceSAndroid Build Coastguard Worker
1282*35238bceSAndroid Build Coastguard Worker {
1283*35238bceSAndroid Build Coastguard Worker TestConfig bigConfig = config;
1284*35238bceSAndroid Build Coastguard Worker bigConfig.triangleCount = 1000;
1285*35238bceSAndroid Build Coastguard Worker bigConfig.drawCallCount = 1;
1286*35238bceSAndroid Build Coastguard Worker bigConfig.frameCount = 10;
1287*35238bceSAndroid Build Coastguard Worker
1288*35238bceSAndroid Build Coastguard Worker if (threadCount * contextCount == 1)
1289*35238bceSAndroid Build Coastguard Worker bigConfig.frameCount *= 4;
1290*35238bceSAndroid Build Coastguard Worker
1291*35238bceSAndroid Build Coastguard Worker sharedCoordBufferGroup->addChild(new SharedRenderingPerfCase(
1292*35238bceSAndroid Build Coastguard Worker m_eglTestCtx, bigConfig, (createTestName(threadCount, contextCount) + "_big_call").c_str(),
1293*35238bceSAndroid Build Coastguard Worker ""));
1294*35238bceSAndroid Build Coastguard Worker }
1295*35238bceSAndroid Build Coastguard Worker }
1296*35238bceSAndroid Build Coastguard Worker }
1297*35238bceSAndroid Build Coastguard Worker
1298*35238bceSAndroid Build Coastguard Worker addChild(sharedCoordBufferGroup);
1299*35238bceSAndroid Build Coastguard Worker }
1300*35238bceSAndroid Build Coastguard Worker
1301*35238bceSAndroid Build Coastguard Worker // Add shared index buffer tests
1302*35238bceSAndroid Build Coastguard Worker {
1303*35238bceSAndroid Build Coastguard Worker TestCaseGroup *sharedIndexBufferGroup =
1304*35238bceSAndroid Build Coastguard Worker new TestCaseGroup(m_eglTestCtx, "shared_index_buffer", "Shared index bufffer");
1305*35238bceSAndroid Build Coastguard Worker
1306*35238bceSAndroid Build Coastguard Worker for (int threadCountNdx = 0; threadCountNdx < DE_LENGTH_OF_ARRAY(threadCounts); threadCountNdx++)
1307*35238bceSAndroid Build Coastguard Worker {
1308*35238bceSAndroid Build Coastguard Worker int threadCount = threadCounts[threadCountNdx];
1309*35238bceSAndroid Build Coastguard Worker
1310*35238bceSAndroid Build Coastguard Worker for (int contextCountNdx = 0; contextCountNdx < DE_LENGTH_OF_ARRAY(perThreadContextCounts);
1311*35238bceSAndroid Build Coastguard Worker contextCountNdx++)
1312*35238bceSAndroid Build Coastguard Worker {
1313*35238bceSAndroid Build Coastguard Worker int contextCount = perThreadContextCounts[contextCountNdx];
1314*35238bceSAndroid Build Coastguard Worker
1315*35238bceSAndroid Build Coastguard Worker if (threadCount * contextCount != 4 && threadCount * contextCount != 1)
1316*35238bceSAndroid Build Coastguard Worker continue;
1317*35238bceSAndroid Build Coastguard Worker
1318*35238bceSAndroid Build Coastguard Worker TestConfig config = basicConfig;
1319*35238bceSAndroid Build Coastguard Worker config.sharedIndexBuffer = true;
1320*35238bceSAndroid Build Coastguard Worker config.threadCount = threadCount;
1321*35238bceSAndroid Build Coastguard Worker config.perThreadContextCount = contextCount;
1322*35238bceSAndroid Build Coastguard Worker
1323*35238bceSAndroid Build Coastguard Worker {
1324*35238bceSAndroid Build Coastguard Worker TestConfig smallConfig = config;
1325*35238bceSAndroid Build Coastguard Worker smallConfig.triangleCount = 1;
1326*35238bceSAndroid Build Coastguard Worker smallConfig.drawCallCount = 1000;
1327*35238bceSAndroid Build Coastguard Worker smallConfig.frameCount = 10;
1328*35238bceSAndroid Build Coastguard Worker
1329*35238bceSAndroid Build Coastguard Worker if (threadCount * contextCount == 1)
1330*35238bceSAndroid Build Coastguard Worker smallConfig.frameCount *= 4;
1331*35238bceSAndroid Build Coastguard Worker
1332*35238bceSAndroid Build Coastguard Worker sharedIndexBufferGroup->addChild(new SharedRenderingPerfCase(
1333*35238bceSAndroid Build Coastguard Worker m_eglTestCtx, smallConfig, (createTestName(threadCount, contextCount) + "_small_call").c_str(),
1334*35238bceSAndroid Build Coastguard Worker ""));
1335*35238bceSAndroid Build Coastguard Worker }
1336*35238bceSAndroid Build Coastguard Worker
1337*35238bceSAndroid Build Coastguard Worker {
1338*35238bceSAndroid Build Coastguard Worker TestConfig bigConfig = config;
1339*35238bceSAndroid Build Coastguard Worker bigConfig.triangleCount = 1000;
1340*35238bceSAndroid Build Coastguard Worker bigConfig.drawCallCount = 1;
1341*35238bceSAndroid Build Coastguard Worker bigConfig.frameCount = 10;
1342*35238bceSAndroid Build Coastguard Worker
1343*35238bceSAndroid Build Coastguard Worker if (threadCount * contextCount == 1)
1344*35238bceSAndroid Build Coastguard Worker bigConfig.frameCount *= 4;
1345*35238bceSAndroid Build Coastguard Worker
1346*35238bceSAndroid Build Coastguard Worker sharedIndexBufferGroup->addChild(new SharedRenderingPerfCase(
1347*35238bceSAndroid Build Coastguard Worker m_eglTestCtx, bigConfig, (createTestName(threadCount, contextCount) + "_big_call").c_str(),
1348*35238bceSAndroid Build Coastguard Worker ""));
1349*35238bceSAndroid Build Coastguard Worker }
1350*35238bceSAndroid Build Coastguard Worker }
1351*35238bceSAndroid Build Coastguard Worker }
1352*35238bceSAndroid Build Coastguard Worker
1353*35238bceSAndroid Build Coastguard Worker addChild(sharedIndexBufferGroup);
1354*35238bceSAndroid Build Coastguard Worker }
1355*35238bceSAndroid Build Coastguard Worker
1356*35238bceSAndroid Build Coastguard Worker // Add shared texture tests
1357*35238bceSAndroid Build Coastguard Worker {
1358*35238bceSAndroid Build Coastguard Worker TestCaseGroup *sharedTextureGroup = new TestCaseGroup(m_eglTestCtx, "shared_texture", "Shared texture tests.");
1359*35238bceSAndroid Build Coastguard Worker
1360*35238bceSAndroid Build Coastguard Worker for (int threadCountNdx = 0; threadCountNdx < DE_LENGTH_OF_ARRAY(threadCounts); threadCountNdx++)
1361*35238bceSAndroid Build Coastguard Worker {
1362*35238bceSAndroid Build Coastguard Worker int threadCount = threadCounts[threadCountNdx];
1363*35238bceSAndroid Build Coastguard Worker
1364*35238bceSAndroid Build Coastguard Worker for (int contextCountNdx = 0; contextCountNdx < DE_LENGTH_OF_ARRAY(perThreadContextCounts);
1365*35238bceSAndroid Build Coastguard Worker contextCountNdx++)
1366*35238bceSAndroid Build Coastguard Worker {
1367*35238bceSAndroid Build Coastguard Worker int contextCount = perThreadContextCounts[contextCountNdx];
1368*35238bceSAndroid Build Coastguard Worker
1369*35238bceSAndroid Build Coastguard Worker if (threadCount * contextCount != 4 && threadCount * contextCount != 1)
1370*35238bceSAndroid Build Coastguard Worker continue;
1371*35238bceSAndroid Build Coastguard Worker
1372*35238bceSAndroid Build Coastguard Worker TestConfig config = basicConfig;
1373*35238bceSAndroid Build Coastguard Worker config.textureType = TestConfig::TEXTURETYPE_SHARED_TEXTURE;
1374*35238bceSAndroid Build Coastguard Worker config.threadCount = threadCount;
1375*35238bceSAndroid Build Coastguard Worker config.perThreadContextCount = contextCount;
1376*35238bceSAndroid Build Coastguard Worker
1377*35238bceSAndroid Build Coastguard Worker {
1378*35238bceSAndroid Build Coastguard Worker TestConfig smallConfig = config;
1379*35238bceSAndroid Build Coastguard Worker smallConfig.triangleCount = 1;
1380*35238bceSAndroid Build Coastguard Worker smallConfig.drawCallCount = 1000;
1381*35238bceSAndroid Build Coastguard Worker smallConfig.frameCount = 10;
1382*35238bceSAndroid Build Coastguard Worker
1383*35238bceSAndroid Build Coastguard Worker if (threadCount * contextCount == 1)
1384*35238bceSAndroid Build Coastguard Worker smallConfig.frameCount *= 4;
1385*35238bceSAndroid Build Coastguard Worker
1386*35238bceSAndroid Build Coastguard Worker sharedTextureGroup->addChild(new SharedRenderingPerfCase(
1387*35238bceSAndroid Build Coastguard Worker m_eglTestCtx, smallConfig, (createTestName(threadCount, contextCount) + "_small_call").c_str(),
1388*35238bceSAndroid Build Coastguard Worker ""));
1389*35238bceSAndroid Build Coastguard Worker }
1390*35238bceSAndroid Build Coastguard Worker
1391*35238bceSAndroid Build Coastguard Worker {
1392*35238bceSAndroid Build Coastguard Worker TestConfig bigConfig = config;
1393*35238bceSAndroid Build Coastguard Worker bigConfig.triangleCount = 1000;
1394*35238bceSAndroid Build Coastguard Worker bigConfig.drawCallCount = 1;
1395*35238bceSAndroid Build Coastguard Worker bigConfig.frameCount = 10;
1396*35238bceSAndroid Build Coastguard Worker
1397*35238bceSAndroid Build Coastguard Worker if (threadCount * contextCount == 1)
1398*35238bceSAndroid Build Coastguard Worker bigConfig.frameCount *= 4;
1399*35238bceSAndroid Build Coastguard Worker
1400*35238bceSAndroid Build Coastguard Worker sharedTextureGroup->addChild(new SharedRenderingPerfCase(
1401*35238bceSAndroid Build Coastguard Worker m_eglTestCtx, bigConfig, (createTestName(threadCount, contextCount) + "_big_call").c_str(),
1402*35238bceSAndroid Build Coastguard Worker ""));
1403*35238bceSAndroid Build Coastguard Worker }
1404*35238bceSAndroid Build Coastguard Worker }
1405*35238bceSAndroid Build Coastguard Worker }
1406*35238bceSAndroid Build Coastguard Worker
1407*35238bceSAndroid Build Coastguard Worker addChild(sharedTextureGroup);
1408*35238bceSAndroid Build Coastguard Worker }
1409*35238bceSAndroid Build Coastguard Worker
1410*35238bceSAndroid Build Coastguard Worker // Add shared program tests
1411*35238bceSAndroid Build Coastguard Worker {
1412*35238bceSAndroid Build Coastguard Worker TestCaseGroup *sharedProgramGroup = new TestCaseGroup(m_eglTestCtx, "shared_program", "Shared program tests.");
1413*35238bceSAndroid Build Coastguard Worker
1414*35238bceSAndroid Build Coastguard Worker for (int threadCountNdx = 0; threadCountNdx < DE_LENGTH_OF_ARRAY(threadCounts); threadCountNdx++)
1415*35238bceSAndroid Build Coastguard Worker {
1416*35238bceSAndroid Build Coastguard Worker int threadCount = threadCounts[threadCountNdx];
1417*35238bceSAndroid Build Coastguard Worker
1418*35238bceSAndroid Build Coastguard Worker for (int contextCountNdx = 0; contextCountNdx < DE_LENGTH_OF_ARRAY(perThreadContextCounts);
1419*35238bceSAndroid Build Coastguard Worker contextCountNdx++)
1420*35238bceSAndroid Build Coastguard Worker {
1421*35238bceSAndroid Build Coastguard Worker int contextCount = perThreadContextCounts[contextCountNdx];
1422*35238bceSAndroid Build Coastguard Worker
1423*35238bceSAndroid Build Coastguard Worker if (threadCount * contextCount != 4 && threadCount * contextCount != 1)
1424*35238bceSAndroid Build Coastguard Worker continue;
1425*35238bceSAndroid Build Coastguard Worker
1426*35238bceSAndroid Build Coastguard Worker TestConfig config = basicConfig;
1427*35238bceSAndroid Build Coastguard Worker config.sharedProgram = true;
1428*35238bceSAndroid Build Coastguard Worker config.threadCount = threadCount;
1429*35238bceSAndroid Build Coastguard Worker config.perThreadContextCount = contextCount;
1430*35238bceSAndroid Build Coastguard Worker
1431*35238bceSAndroid Build Coastguard Worker {
1432*35238bceSAndroid Build Coastguard Worker TestConfig smallConfig = config;
1433*35238bceSAndroid Build Coastguard Worker smallConfig.triangleCount = 1;
1434*35238bceSAndroid Build Coastguard Worker smallConfig.drawCallCount = 1000;
1435*35238bceSAndroid Build Coastguard Worker smallConfig.frameCount = 10;
1436*35238bceSAndroid Build Coastguard Worker
1437*35238bceSAndroid Build Coastguard Worker if (threadCount * contextCount == 1)
1438*35238bceSAndroid Build Coastguard Worker smallConfig.frameCount *= 4;
1439*35238bceSAndroid Build Coastguard Worker
1440*35238bceSAndroid Build Coastguard Worker sharedProgramGroup->addChild(new SharedRenderingPerfCase(
1441*35238bceSAndroid Build Coastguard Worker m_eglTestCtx, smallConfig, (createTestName(threadCount, contextCount) + "_small_call").c_str(),
1442*35238bceSAndroid Build Coastguard Worker ""));
1443*35238bceSAndroid Build Coastguard Worker }
1444*35238bceSAndroid Build Coastguard Worker
1445*35238bceSAndroid Build Coastguard Worker {
1446*35238bceSAndroid Build Coastguard Worker TestConfig bigConfig = config;
1447*35238bceSAndroid Build Coastguard Worker bigConfig.triangleCount = 1000;
1448*35238bceSAndroid Build Coastguard Worker bigConfig.drawCallCount = 1;
1449*35238bceSAndroid Build Coastguard Worker bigConfig.frameCount = 10;
1450*35238bceSAndroid Build Coastguard Worker
1451*35238bceSAndroid Build Coastguard Worker if (threadCount * contextCount == 1)
1452*35238bceSAndroid Build Coastguard Worker bigConfig.frameCount *= 4;
1453*35238bceSAndroid Build Coastguard Worker
1454*35238bceSAndroid Build Coastguard Worker sharedProgramGroup->addChild(new SharedRenderingPerfCase(
1455*35238bceSAndroid Build Coastguard Worker m_eglTestCtx, bigConfig, (createTestName(threadCount, contextCount) + "_big_call").c_str(),
1456*35238bceSAndroid Build Coastguard Worker ""));
1457*35238bceSAndroid Build Coastguard Worker }
1458*35238bceSAndroid Build Coastguard Worker }
1459*35238bceSAndroid Build Coastguard Worker }
1460*35238bceSAndroid Build Coastguard Worker
1461*35238bceSAndroid Build Coastguard Worker addChild(sharedProgramGroup);
1462*35238bceSAndroid Build Coastguard Worker }
1463*35238bceSAndroid Build Coastguard Worker
1464*35238bceSAndroid Build Coastguard Worker // Add shared all tests
1465*35238bceSAndroid Build Coastguard Worker {
1466*35238bceSAndroid Build Coastguard Worker TestCaseGroup *sharedallGroup = new TestCaseGroup(m_eglTestCtx, "shared_all", "Share all possible resources.");
1467*35238bceSAndroid Build Coastguard Worker
1468*35238bceSAndroid Build Coastguard Worker for (int threadCountNdx = 0; threadCountNdx < DE_LENGTH_OF_ARRAY(threadCounts); threadCountNdx++)
1469*35238bceSAndroid Build Coastguard Worker {
1470*35238bceSAndroid Build Coastguard Worker int threadCount = threadCounts[threadCountNdx];
1471*35238bceSAndroid Build Coastguard Worker
1472*35238bceSAndroid Build Coastguard Worker for (int contextCountNdx = 0; contextCountNdx < DE_LENGTH_OF_ARRAY(perThreadContextCounts);
1473*35238bceSAndroid Build Coastguard Worker contextCountNdx++)
1474*35238bceSAndroid Build Coastguard Worker {
1475*35238bceSAndroid Build Coastguard Worker int contextCount = perThreadContextCounts[contextCountNdx];
1476*35238bceSAndroid Build Coastguard Worker
1477*35238bceSAndroid Build Coastguard Worker if (threadCount * contextCount != 4 && threadCount * contextCount != 1)
1478*35238bceSAndroid Build Coastguard Worker continue;
1479*35238bceSAndroid Build Coastguard Worker
1480*35238bceSAndroid Build Coastguard Worker TestConfig config = basicConfig;
1481*35238bceSAndroid Build Coastguard Worker config.sharedCoordBuffer = true;
1482*35238bceSAndroid Build Coastguard Worker config.sharedIndexBuffer = true;
1483*35238bceSAndroid Build Coastguard Worker config.sharedProgram = true;
1484*35238bceSAndroid Build Coastguard Worker config.textureType = TestConfig::TEXTURETYPE_SHARED_TEXTURE;
1485*35238bceSAndroid Build Coastguard Worker config.threadCount = threadCount;
1486*35238bceSAndroid Build Coastguard Worker config.perThreadContextCount = contextCount;
1487*35238bceSAndroid Build Coastguard Worker
1488*35238bceSAndroid Build Coastguard Worker {
1489*35238bceSAndroid Build Coastguard Worker TestConfig smallConfig = config;
1490*35238bceSAndroid Build Coastguard Worker smallConfig.triangleCount = 1;
1491*35238bceSAndroid Build Coastguard Worker smallConfig.drawCallCount = 1000;
1492*35238bceSAndroid Build Coastguard Worker smallConfig.frameCount = 10;
1493*35238bceSAndroid Build Coastguard Worker
1494*35238bceSAndroid Build Coastguard Worker if (threadCount * contextCount == 1)
1495*35238bceSAndroid Build Coastguard Worker smallConfig.frameCount *= 4;
1496*35238bceSAndroid Build Coastguard Worker
1497*35238bceSAndroid Build Coastguard Worker sharedallGroup->addChild(new SharedRenderingPerfCase(
1498*35238bceSAndroid Build Coastguard Worker m_eglTestCtx, smallConfig, (createTestName(threadCount, contextCount) + "_small_call").c_str(),
1499*35238bceSAndroid Build Coastguard Worker ""));
1500*35238bceSAndroid Build Coastguard Worker }
1501*35238bceSAndroid Build Coastguard Worker
1502*35238bceSAndroid Build Coastguard Worker {
1503*35238bceSAndroid Build Coastguard Worker TestConfig bigConfig = config;
1504*35238bceSAndroid Build Coastguard Worker bigConfig.triangleCount = 1000;
1505*35238bceSAndroid Build Coastguard Worker bigConfig.drawCallCount = 1;
1506*35238bceSAndroid Build Coastguard Worker bigConfig.frameCount = 10;
1507*35238bceSAndroid Build Coastguard Worker
1508*35238bceSAndroid Build Coastguard Worker if (threadCount * contextCount == 1)
1509*35238bceSAndroid Build Coastguard Worker bigConfig.frameCount *= 4;
1510*35238bceSAndroid Build Coastguard Worker
1511*35238bceSAndroid Build Coastguard Worker sharedallGroup->addChild(new SharedRenderingPerfCase(
1512*35238bceSAndroid Build Coastguard Worker m_eglTestCtx, bigConfig, (createTestName(threadCount, contextCount) + "_big_call").c_str(),
1513*35238bceSAndroid Build Coastguard Worker ""));
1514*35238bceSAndroid Build Coastguard Worker }
1515*35238bceSAndroid Build Coastguard Worker }
1516*35238bceSAndroid Build Coastguard Worker }
1517*35238bceSAndroid Build Coastguard Worker
1518*35238bceSAndroid Build Coastguard Worker addChild(sharedallGroup);
1519*35238bceSAndroid Build Coastguard Worker }
1520*35238bceSAndroid Build Coastguard Worker
1521*35238bceSAndroid Build Coastguard Worker // Add EGLImage tests
1522*35238bceSAndroid Build Coastguard Worker {
1523*35238bceSAndroid Build Coastguard Worker TestCaseGroup *sharedTextureGroup = new TestCaseGroup(m_eglTestCtx, "egl_image", "EGL image tests.");
1524*35238bceSAndroid Build Coastguard Worker
1525*35238bceSAndroid Build Coastguard Worker for (int threadCountNdx = 0; threadCountNdx < DE_LENGTH_OF_ARRAY(threadCounts); threadCountNdx++)
1526*35238bceSAndroid Build Coastguard Worker {
1527*35238bceSAndroid Build Coastguard Worker int threadCount = threadCounts[threadCountNdx];
1528*35238bceSAndroid Build Coastguard Worker
1529*35238bceSAndroid Build Coastguard Worker for (int contextCountNdx = 0; contextCountNdx < DE_LENGTH_OF_ARRAY(perThreadContextCounts);
1530*35238bceSAndroid Build Coastguard Worker contextCountNdx++)
1531*35238bceSAndroid Build Coastguard Worker {
1532*35238bceSAndroid Build Coastguard Worker int contextCount = perThreadContextCounts[contextCountNdx];
1533*35238bceSAndroid Build Coastguard Worker
1534*35238bceSAndroid Build Coastguard Worker if (threadCount * contextCount != 4 && threadCount * contextCount != 1)
1535*35238bceSAndroid Build Coastguard Worker continue;
1536*35238bceSAndroid Build Coastguard Worker
1537*35238bceSAndroid Build Coastguard Worker TestConfig config = basicConfig;
1538*35238bceSAndroid Build Coastguard Worker
1539*35238bceSAndroid Build Coastguard Worker config.textureType = TestConfig::TEXTURETYPE_IMAGE;
1540*35238bceSAndroid Build Coastguard Worker config.threadCount = threadCount;
1541*35238bceSAndroid Build Coastguard Worker config.perThreadContextCount = contextCount;
1542*35238bceSAndroid Build Coastguard Worker config.sharedContexts = false;
1543*35238bceSAndroid Build Coastguard Worker
1544*35238bceSAndroid Build Coastguard Worker {
1545*35238bceSAndroid Build Coastguard Worker TestConfig smallConfig = config;
1546*35238bceSAndroid Build Coastguard Worker smallConfig.triangleCount = 1;
1547*35238bceSAndroid Build Coastguard Worker smallConfig.drawCallCount = 1000;
1548*35238bceSAndroid Build Coastguard Worker smallConfig.frameCount = 10;
1549*35238bceSAndroid Build Coastguard Worker
1550*35238bceSAndroid Build Coastguard Worker if (threadCount * contextCount == 1)
1551*35238bceSAndroid Build Coastguard Worker smallConfig.frameCount *= 4;
1552*35238bceSAndroid Build Coastguard Worker
1553*35238bceSAndroid Build Coastguard Worker sharedTextureGroup->addChild(new SharedRenderingPerfCase(
1554*35238bceSAndroid Build Coastguard Worker m_eglTestCtx, smallConfig, (createTestName(threadCount, contextCount) + "_small_call").c_str(),
1555*35238bceSAndroid Build Coastguard Worker ""));
1556*35238bceSAndroid Build Coastguard Worker }
1557*35238bceSAndroid Build Coastguard Worker
1558*35238bceSAndroid Build Coastguard Worker {
1559*35238bceSAndroid Build Coastguard Worker TestConfig bigConfig = config;
1560*35238bceSAndroid Build Coastguard Worker bigConfig.triangleCount = 1000;
1561*35238bceSAndroid Build Coastguard Worker bigConfig.drawCallCount = 1;
1562*35238bceSAndroid Build Coastguard Worker bigConfig.frameCount = 10;
1563*35238bceSAndroid Build Coastguard Worker
1564*35238bceSAndroid Build Coastguard Worker if (threadCount * contextCount == 1)
1565*35238bceSAndroid Build Coastguard Worker bigConfig.frameCount *= 4;
1566*35238bceSAndroid Build Coastguard Worker
1567*35238bceSAndroid Build Coastguard Worker sharedTextureGroup->addChild(new SharedRenderingPerfCase(
1568*35238bceSAndroid Build Coastguard Worker m_eglTestCtx, bigConfig, (createTestName(threadCount, contextCount) + "_big_call").c_str(),
1569*35238bceSAndroid Build Coastguard Worker ""));
1570*35238bceSAndroid Build Coastguard Worker }
1571*35238bceSAndroid Build Coastguard Worker }
1572*35238bceSAndroid Build Coastguard Worker }
1573*35238bceSAndroid Build Coastguard Worker
1574*35238bceSAndroid Build Coastguard Worker addChild(sharedTextureGroup);
1575*35238bceSAndroid Build Coastguard Worker }
1576*35238bceSAndroid Build Coastguard Worker
1577*35238bceSAndroid Build Coastguard Worker // Add shared EGLImage tests
1578*35238bceSAndroid Build Coastguard Worker {
1579*35238bceSAndroid Build Coastguard Worker TestCaseGroup *sharedTextureGroup =
1580*35238bceSAndroid Build Coastguard Worker new TestCaseGroup(m_eglTestCtx, "shared_egl_image", "Shared EGLImage tests.");
1581*35238bceSAndroid Build Coastguard Worker
1582*35238bceSAndroid Build Coastguard Worker for (int threadCountNdx = 0; threadCountNdx < DE_LENGTH_OF_ARRAY(threadCounts); threadCountNdx++)
1583*35238bceSAndroid Build Coastguard Worker {
1584*35238bceSAndroid Build Coastguard Worker int threadCount = threadCounts[threadCountNdx];
1585*35238bceSAndroid Build Coastguard Worker
1586*35238bceSAndroid Build Coastguard Worker for (int contextCountNdx = 0; contextCountNdx < DE_LENGTH_OF_ARRAY(perThreadContextCounts);
1587*35238bceSAndroid Build Coastguard Worker contextCountNdx++)
1588*35238bceSAndroid Build Coastguard Worker {
1589*35238bceSAndroid Build Coastguard Worker int contextCount = perThreadContextCounts[contextCountNdx];
1590*35238bceSAndroid Build Coastguard Worker
1591*35238bceSAndroid Build Coastguard Worker if (threadCount * contextCount != 4 && threadCount * contextCount != 1)
1592*35238bceSAndroid Build Coastguard Worker continue;
1593*35238bceSAndroid Build Coastguard Worker
1594*35238bceSAndroid Build Coastguard Worker TestConfig config = basicConfig;
1595*35238bceSAndroid Build Coastguard Worker
1596*35238bceSAndroid Build Coastguard Worker config.textureType = TestConfig::TEXTURETYPE_SHARED_IMAGE;
1597*35238bceSAndroid Build Coastguard Worker config.threadCount = threadCount;
1598*35238bceSAndroid Build Coastguard Worker config.perThreadContextCount = contextCount;
1599*35238bceSAndroid Build Coastguard Worker config.sharedContexts = false;
1600*35238bceSAndroid Build Coastguard Worker
1601*35238bceSAndroid Build Coastguard Worker {
1602*35238bceSAndroid Build Coastguard Worker TestConfig smallConfig = config;
1603*35238bceSAndroid Build Coastguard Worker smallConfig.triangleCount = 1;
1604*35238bceSAndroid Build Coastguard Worker smallConfig.drawCallCount = 1000;
1605*35238bceSAndroid Build Coastguard Worker smallConfig.frameCount = 10;
1606*35238bceSAndroid Build Coastguard Worker
1607*35238bceSAndroid Build Coastguard Worker if (threadCount * contextCount == 1)
1608*35238bceSAndroid Build Coastguard Worker smallConfig.frameCount *= 4;
1609*35238bceSAndroid Build Coastguard Worker
1610*35238bceSAndroid Build Coastguard Worker sharedTextureGroup->addChild(new SharedRenderingPerfCase(
1611*35238bceSAndroid Build Coastguard Worker m_eglTestCtx, smallConfig, (createTestName(threadCount, contextCount) + "_small_call").c_str(),
1612*35238bceSAndroid Build Coastguard Worker ""));
1613*35238bceSAndroid Build Coastguard Worker }
1614*35238bceSAndroid Build Coastguard Worker
1615*35238bceSAndroid Build Coastguard Worker {
1616*35238bceSAndroid Build Coastguard Worker TestConfig bigConfig = config;
1617*35238bceSAndroid Build Coastguard Worker bigConfig.triangleCount = 1000;
1618*35238bceSAndroid Build Coastguard Worker bigConfig.drawCallCount = 1;
1619*35238bceSAndroid Build Coastguard Worker bigConfig.frameCount = 10;
1620*35238bceSAndroid Build Coastguard Worker
1621*35238bceSAndroid Build Coastguard Worker if (threadCount * contextCount == 1)
1622*35238bceSAndroid Build Coastguard Worker bigConfig.frameCount *= 4;
1623*35238bceSAndroid Build Coastguard Worker
1624*35238bceSAndroid Build Coastguard Worker sharedTextureGroup->addChild(new SharedRenderingPerfCase(
1625*35238bceSAndroid Build Coastguard Worker m_eglTestCtx, bigConfig, (createTestName(threadCount, contextCount) + "_big_call").c_str(),
1626*35238bceSAndroid Build Coastguard Worker ""));
1627*35238bceSAndroid Build Coastguard Worker }
1628*35238bceSAndroid Build Coastguard Worker }
1629*35238bceSAndroid Build Coastguard Worker }
1630*35238bceSAndroid Build Coastguard Worker
1631*35238bceSAndroid Build Coastguard Worker addChild(sharedTextureGroup);
1632*35238bceSAndroid Build Coastguard Worker }
1633*35238bceSAndroid Build Coastguard Worker
1634*35238bceSAndroid Build Coastguard Worker // Shared EGLImage texture test
1635*35238bceSAndroid Build Coastguard Worker {
1636*35238bceSAndroid Build Coastguard Worker TestCaseGroup *sharedTextureGroup =
1637*35238bceSAndroid Build Coastguard Worker new TestCaseGroup(m_eglTestCtx, "shared_egl_image_texture", "Shared EGLImage texture tests.");
1638*35238bceSAndroid Build Coastguard Worker
1639*35238bceSAndroid Build Coastguard Worker for (int threadCountNdx = 0; threadCountNdx < DE_LENGTH_OF_ARRAY(threadCounts); threadCountNdx++)
1640*35238bceSAndroid Build Coastguard Worker {
1641*35238bceSAndroid Build Coastguard Worker int threadCount = threadCounts[threadCountNdx];
1642*35238bceSAndroid Build Coastguard Worker
1643*35238bceSAndroid Build Coastguard Worker for (int contextCountNdx = 0; contextCountNdx < DE_LENGTH_OF_ARRAY(perThreadContextCounts);
1644*35238bceSAndroid Build Coastguard Worker contextCountNdx++)
1645*35238bceSAndroid Build Coastguard Worker {
1646*35238bceSAndroid Build Coastguard Worker int contextCount = perThreadContextCounts[contextCountNdx];
1647*35238bceSAndroid Build Coastguard Worker
1648*35238bceSAndroid Build Coastguard Worker if (threadCount * contextCount != 4 && threadCount * contextCount != 1)
1649*35238bceSAndroid Build Coastguard Worker continue;
1650*35238bceSAndroid Build Coastguard Worker
1651*35238bceSAndroid Build Coastguard Worker TestConfig config = basicConfig;
1652*35238bceSAndroid Build Coastguard Worker config.textureType = TestConfig::TEXTURETYPE_SHARED_IMAGE_TEXTURE;
1653*35238bceSAndroid Build Coastguard Worker config.threadCount = threadCount;
1654*35238bceSAndroid Build Coastguard Worker config.perThreadContextCount = contextCount;
1655*35238bceSAndroid Build Coastguard Worker
1656*35238bceSAndroid Build Coastguard Worker {
1657*35238bceSAndroid Build Coastguard Worker TestConfig smallConfig = config;
1658*35238bceSAndroid Build Coastguard Worker smallConfig.triangleCount = 1;
1659*35238bceSAndroid Build Coastguard Worker smallConfig.drawCallCount = 1000;
1660*35238bceSAndroid Build Coastguard Worker smallConfig.frameCount = 10;
1661*35238bceSAndroid Build Coastguard Worker
1662*35238bceSAndroid Build Coastguard Worker if (threadCount * contextCount == 1)
1663*35238bceSAndroid Build Coastguard Worker smallConfig.frameCount *= 4;
1664*35238bceSAndroid Build Coastguard Worker
1665*35238bceSAndroid Build Coastguard Worker sharedTextureGroup->addChild(new SharedRenderingPerfCase(
1666*35238bceSAndroid Build Coastguard Worker m_eglTestCtx, smallConfig, (createTestName(threadCount, contextCount) + "_small_call").c_str(),
1667*35238bceSAndroid Build Coastguard Worker ""));
1668*35238bceSAndroid Build Coastguard Worker }
1669*35238bceSAndroid Build Coastguard Worker
1670*35238bceSAndroid Build Coastguard Worker {
1671*35238bceSAndroid Build Coastguard Worker TestConfig bigConfig = config;
1672*35238bceSAndroid Build Coastguard Worker bigConfig.triangleCount = 1000;
1673*35238bceSAndroid Build Coastguard Worker bigConfig.drawCallCount = 1;
1674*35238bceSAndroid Build Coastguard Worker bigConfig.frameCount = 10;
1675*35238bceSAndroid Build Coastguard Worker
1676*35238bceSAndroid Build Coastguard Worker if (threadCount * contextCount == 1)
1677*35238bceSAndroid Build Coastguard Worker bigConfig.frameCount *= 4;
1678*35238bceSAndroid Build Coastguard Worker
1679*35238bceSAndroid Build Coastguard Worker sharedTextureGroup->addChild(new SharedRenderingPerfCase(
1680*35238bceSAndroid Build Coastguard Worker m_eglTestCtx, bigConfig, (createTestName(threadCount, contextCount) + "_big_call").c_str(),
1681*35238bceSAndroid Build Coastguard Worker ""));
1682*35238bceSAndroid Build Coastguard Worker }
1683*35238bceSAndroid Build Coastguard Worker }
1684*35238bceSAndroid Build Coastguard Worker }
1685*35238bceSAndroid Build Coastguard Worker
1686*35238bceSAndroid Build Coastguard Worker addChild(sharedTextureGroup);
1687*35238bceSAndroid Build Coastguard Worker }
1688*35238bceSAndroid Build Coastguard Worker }
1689*35238bceSAndroid Build Coastguard Worker
1690*35238bceSAndroid Build Coastguard Worker } // namespace egl
1691*35238bceSAndroid Build Coastguard Worker } // namespace deqp
1692