1 /*-------------------------------------------------------------------------
2 * drawElements Quality Program EGL Module
3 * ---------------------------------------
5 * Copyright 2014 The Android Open Source Project
7 * Licensed under the Apache License, Version 2.0 (the "License");
8 * you may not use this file except in compliance with the License.
9 * You may obtain a copy of the License at
11 * http://www.apache.org/licenses/LICENSE-2.0
13 * Unless required by applicable law or agreed to in writing, software
14 * distributed under the License is distributed on an "AS IS" BASIS,
15 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16 * See the License for the specific language governing permissions and
17 * limitations under the License.
21 * \brief GLES2 resource sharing performnace tests.
22 *//*--------------------------------------------------------------------*/
24 #include "teglGLES2SharedRenderingPerfTests.hpp"
26 #include "tcuTestLog.hpp"
28 #include "egluUtil.hpp"
29 #include "eglwLibrary.hpp"
30 #include "eglwEnums.hpp"
32 #include "gluDefs.hpp"
33 #include "glwDefs.hpp"
34 #include "glwEnums.hpp"
35 #include "glwFunctions.hpp"
37 #include "deThread.hpp"
39 #include "deStringUtil.hpp"
40 #include "deSTLUtil.hpp"
66 TEXTURETYPE_TEXTURE = 0,
67 TEXTURETYPE_SHARED_TEXTURE,
69 TEXTURETYPE_SHARED_IMAGE,
70 TEXTURETYPE_SHARED_IMAGE_TEXTURE
74 int perThreadContextCount;
83 bool sharedCoordBuffer;
87 bool sharedIndexBuffer;
90 TextureType textureType;
104 TestContext (EglTestContext& eglTestCtx, EGLDisplay display, EGLConfig eglConfig, const TestConfig& config, bool share, TestContext* parent);
109 EGLContext getEGLContext (void) { return m_eglContext; }
111 GLuint getCoordBuffer (void) const { return m_coordBuffer; }
112 GLuint getIndexBuffer (void) const { return m_indexBuffer; }
113 GLuint getTexture (void) const { return m_texture; }
114 GLuint getProgram (void) const { return m_program; }
115 EGLImageKHR getEGLImage (void) const { return m_eglImage; }
118 TestContext* m_parent;
119 EglTestContext& m_testCtx;
122 EGLDisplay m_eglDisplay;
123 EGLContext m_eglContext;
124 EGLSurface m_eglSurface;
128 GLuint m_coordBuffer;
129 GLuint m_indexBuffer;
133 EGLImageKHR m_eglImage;
138 vector<float> m_coordData;
139 vector<deUint16> m_indexData;
141 EGLImageKHR createEGLImage (void);
142 GLuint createTextureFromImage (EGLImageKHR image);
145 TestContext& operator= (const TestContext&);
146 TestContext (const TestContext&);
152 void createCoordData (vector<float>& data, const TestConfig& config)
154 if (config.useIndices)
156 for (int triangleNdx = 0; triangleNdx < 2; triangleNdx++)
158 const float x1 = -1.0f;
159 const float y1 = -1.0f;
161 const float x2 = 1.0f;
162 const float y2 = 1.0f;
164 const float side = ((triangleNdx % 2) == 0 ? 1.0f : -1.0f);
166 data.push_back(side * x1);
167 data.push_back(side * y1);
169 data.push_back(side * x2);
170 data.push_back(side * y1);
172 data.push_back(side * x2);
173 data.push_back(side * y2);
178 data.reserve(config.triangleCount * 3 * 2);
180 for (int triangleNdx = 0; triangleNdx < config.triangleCount; triangleNdx++)
182 const float x1 = -1.0f;
183 const float y1 = -1.0f;
185 const float x2 = 1.0f;
186 const float y2 = 1.0f;
188 const float side = ((triangleNdx % 2) == 0 ? 1.0f : -1.0f);
190 data.push_back(side * x1);
191 data.push_back(side * y1);
193 data.push_back(side * x2);
194 data.push_back(side * y1);
196 data.push_back(side * x2);
197 data.push_back(side * y2);
202 GLuint createCoordBuffer (const glw::Functions& gl, const TestConfig& config)
207 createCoordData(data, config);
209 gl.genBuffers(1, &buffer);
210 GLU_EXPECT_NO_ERROR(gl.getError(), "glGenBuffers()");
211 gl.bindBuffer(GL_ARRAY_BUFFER, buffer);
212 GLU_EXPECT_NO_ERROR(gl.getError(), "glBindBuffer()");
213 gl.bufferData(GL_ARRAY_BUFFER, (GLsizei)(data.size() * sizeof(float)), &(data[0]), GL_STATIC_DRAW);
214 GLU_EXPECT_NO_ERROR(gl.getError(), "glBufferData()");
215 gl.bindBuffer(GL_ARRAY_BUFFER, 0);
216 GLU_EXPECT_NO_ERROR(gl.getError(), "glBindBuffer()");
221 void createIndexData (vector<deUint16>& data, const TestConfig& config)
223 for (int triangleNdx = 0; triangleNdx < config.triangleCount; triangleNdx++)
225 if ((triangleNdx % 2) == 0)
240 GLuint createIndexBuffer (const glw::Functions& gl, const TestConfig& config)
243 vector<deUint16> data;
245 createIndexData(data, config);
247 gl.genBuffers(1, &buffer);
248 GLU_EXPECT_NO_ERROR(gl.getError(), "glGenBuffers()");
249 gl.bindBuffer(GL_ELEMENT_ARRAY_BUFFER, buffer);
250 GLU_EXPECT_NO_ERROR(gl.getError(), "glBindBuffer()");
251 gl.bufferData(GL_ELEMENT_ARRAY_BUFFER, (GLsizei)(data.size() * sizeof(deUint16)), &(data[0]), GL_STATIC_DRAW);
252 GLU_EXPECT_NO_ERROR(gl.getError(), "glBufferData()");
253 gl.bindBuffer(GL_ELEMENT_ARRAY_BUFFER, 0);
254 GLU_EXPECT_NO_ERROR(gl.getError(), "glBindBuffer()");
259 void createTextureData (vector<deUint8>& data, const TestConfig& config)
261 for (int x = 0; x < config.textureWidth; x++)
263 for (int y = 0; y < config.textureHeight; y++)
265 data.push_back((deUint8)((255*x)/255));
266 data.push_back((deUint8)((255*y)/255));
267 data.push_back((deUint8)((255*x*y)/(255*255)));
273 GLuint createTexture (const glw::Functions& gl, const TestConfig& config)
276 vector<deUint8> data;
278 createTextureData(data, config);
280 gl.genTextures(1, &texture);
281 GLU_EXPECT_NO_ERROR(gl.getError(), "glGenTextures()");
282 gl.bindTexture(GL_TEXTURE_2D, texture);
283 GLU_EXPECT_NO_ERROR(gl.getError(), "glBindTexture()");
284 gl.texParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
285 GLU_EXPECT_NO_ERROR(gl.getError(), "glTexParameteri");
286 gl.texParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
287 GLU_EXPECT_NO_ERROR(gl.getError(), "glTexParameteri");
288 gl.texParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE);
289 GLU_EXPECT_NO_ERROR(gl.getError(), "glTexParameteri");
290 gl.texParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE);
291 GLU_EXPECT_NO_ERROR(gl.getError(), "glTexParameteri");
292 gl.texImage2D(GL_TEXTURE_2D, 0, GL_RGBA, config.textureWidth, config.textureWidth, 0, GL_RGBA, GL_UNSIGNED_BYTE, &(data[0]));
293 GLU_EXPECT_NO_ERROR(gl.getError(), "glTexImage2D()");
294 gl.bindTexture(GL_TEXTURE_2D, 0);
295 GLU_EXPECT_NO_ERROR(gl.getError(), "glBindTexture()");
300 GLuint createProgram (const glw::Functions& gl, const TestConfig& config)
302 GLuint vertexShader = gl.createShader(GL_VERTEX_SHADER);
303 GLuint fragmentShader = gl.createShader(GL_FRAGMENT_SHADER);
305 if (config.useTexture)
307 const char* vertexShaderSource =
308 "attribute mediump vec2 a_coord;\n"
309 "varying mediump vec2 v_texCoord;\n"
312 "\tv_texCoord = 0.5 * a_coord + vec2(0.5);\n"
313 "\tgl_Position = vec4(a_coord, 0.0, 1.0);\n"
316 const char* fragmentShaderSource =
317 "uniform sampler2D u_sampler;\n"
318 "varying mediump vec2 v_texCoord;\n"
321 "\tgl_FragColor = texture2D(u_sampler, v_texCoord);\n"
324 gl.shaderSource(vertexShader, 1, &vertexShaderSource, DE_NULL);
325 GLU_EXPECT_NO_ERROR(gl.getError(), "glShaderSource()");
326 gl.shaderSource(fragmentShader, 1, &fragmentShaderSource, DE_NULL);
327 GLU_EXPECT_NO_ERROR(gl.getError(), "glShaderSource()");
331 const char* vertexShaderSource =
332 "attribute mediump vec2 a_coord;\n"
333 "varying mediump vec4 v_color;\n"
336 "\tv_color = vec4(0.5 * a_coord + vec2(0.5), 0.5, 1.0);\n"
337 "\tgl_Position = vec4(a_coord, 0.0, 1.0);\n"
340 const char* fragmentShaderSource =
341 "varying mediump vec4 v_color;\n"
344 "\tgl_FragColor = v_color;\n"
347 gl.shaderSource(vertexShader, 1, &vertexShaderSource, DE_NULL);
348 GLU_EXPECT_NO_ERROR(gl.getError(), "glShaderSource()");
349 gl.shaderSource(fragmentShader, 1, &fragmentShaderSource, DE_NULL);
350 GLU_EXPECT_NO_ERROR(gl.getError(), "glShaderSource()");
353 gl.compileShader(vertexShader);
354 GLU_EXPECT_NO_ERROR(gl.getError(), "glCompileShader()");
355 gl.compileShader(fragmentShader);
356 GLU_EXPECT_NO_ERROR(gl.getError(), "glCompileShader()");
361 gl.getShaderiv(vertexShader, GL_COMPILE_STATUS, &status);
362 GLU_EXPECT_NO_ERROR(gl.getError(), "glGetShaderiv()");
369 gl.getShaderiv(vertexShader, GL_INFO_LOG_LENGTH, &length);
370 GLU_EXPECT_NO_ERROR(gl.getError(), "glGetShaderiv()");
371 log.resize(length, 0);
373 gl.getShaderInfoLog(vertexShader, (GLsizei)log.size(), &length, &(log[0]));
374 GLU_EXPECT_NO_ERROR(gl.getError(), "glGetShaderInfoLog()");
376 throw std::runtime_error(log.c_str());
383 gl.getShaderiv(fragmentShader, GL_COMPILE_STATUS, &status);
384 GLU_EXPECT_NO_ERROR(gl.getError(), "glGetShaderiv()");
391 gl.getShaderiv(fragmentShader, GL_INFO_LOG_LENGTH, &length);
392 GLU_EXPECT_NO_ERROR(gl.getError(), "glGetShaderiv()");
393 log.resize(length, 0);
395 gl.getShaderInfoLog(fragmentShader, (GLsizei)log.size(), &length, &(log[0]));
396 GLU_EXPECT_NO_ERROR(gl.getError(), "glGetShaderInfoLog()");
398 throw std::runtime_error(log.c_str());
403 GLuint program = gl.createProgram();
405 gl.attachShader(program, vertexShader);
406 GLU_EXPECT_NO_ERROR(gl.getError(), "glAttachShader()");
407 gl.attachShader(program, fragmentShader);
408 GLU_EXPECT_NO_ERROR(gl.getError(), "glAttachShader()");
410 gl.linkProgram(program);
411 GLU_EXPECT_NO_ERROR(gl.getError(), "glLinkProgram()");
416 gl.getProgramiv(program, GL_LINK_STATUS, &status);
417 GLU_EXPECT_NO_ERROR(gl.getError(), "glGetProgramiv()");
424 gl.getProgramInfoLog(program, 0, &length, DE_NULL);
425 GLU_EXPECT_NO_ERROR(gl.getError(), "glGetProgramInfoLog()");
426 log.resize(length, 0);
428 gl.getProgramInfoLog(program, (GLsizei)log.size(), &length, &(log[0]));
429 GLU_EXPECT_NO_ERROR(gl.getError(), "glGetProgramInfoLog()");
431 throw std::runtime_error(log.c_str());
435 gl.deleteShader(vertexShader);
436 GLU_EXPECT_NO_ERROR(gl.getError(), "glDeleteShader()");
437 gl.deleteShader(fragmentShader);
438 GLU_EXPECT_NO_ERROR(gl.getError(), "glDeleteShader()");
444 EGLContext createEGLContext (EglTestContext& testCtx, EGLDisplay eglDisplay, EGLConfig eglConfig, EGLContext share)
446 const Library& egl = testCtx.getLibrary();
447 const EGLint attribList[] =
449 EGL_CONTEXT_CLIENT_VERSION, 2,
453 EGLU_CHECK_CALL(egl, bindAPI(EGL_OPENGL_ES_API));
455 EGLContext context = egl.createContext(eglDisplay, eglConfig, share, attribList);
456 EGLU_CHECK_MSG(egl, "eglCreateContext()");
461 EGLSurface createEGLSurface (EglTestContext& testCtx, EGLDisplay display, EGLConfig eglConfig, const TestConfig& config)
463 const Library& egl = testCtx.getLibrary();
464 const EGLint attribList[] =
466 EGL_WIDTH, config.surfaceWidth,
467 EGL_HEIGHT, config.surfaceHeight,
471 EGLSurface surface = egl.createPbufferSurface(display, eglConfig, attribList);
472 EGLU_CHECK_MSG(egl, "eglCreatePbufferSurface()");
479 TestContext::TestContext (EglTestContext& testCtx, EGLDisplay eglDisplay, EGLConfig eglConfig, const TestConfig& config, bool share, TestContext* parent)
481 , m_testCtx (testCtx)
483 , m_eglDisplay (eglDisplay)
484 , m_eglContext (EGL_NO_CONTEXT)
485 , m_eglSurface (EGL_NO_SURFACE)
490 , m_eglImage (EGL_NO_IMAGE_KHR)
492 const Library& egl = m_testCtx.getLibrary();
494 if (m_config.textureType == TestConfig::TEXTURETYPE_IMAGE
495 || m_config.textureType == TestConfig::TEXTURETYPE_SHARED_IMAGE
496 || m_config.textureType == TestConfig::TEXTURETYPE_SHARED_IMAGE_TEXTURE)
498 const vector<string> extensions = eglu::getDisplayExtensions(egl, m_eglDisplay);
500 if (!de::contains(extensions.begin(), extensions.end(), "EGL_KHR_image_base") ||
501 !de::contains(extensions.begin(), extensions.end(), "EGL_KHR_gl_texture_2D_image"))
502 TCU_THROW(NotSupportedError, "EGL_KHR_image_base extensions not supported");
505 m_eglContext = createEGLContext(m_testCtx, m_eglDisplay, eglConfig, (share && parent ? parent->getEGLContext() : EGL_NO_CONTEXT));
506 m_eglSurface = createEGLSurface(m_testCtx, m_eglDisplay, eglConfig, config);
508 EGLU_CHECK_CALL(egl, makeCurrent(m_eglDisplay, m_eglSurface, m_eglSurface, m_eglContext));
511 const char* reqExts[] = { "GL_OES_EGL_image" };
512 m_testCtx.initGLFunctions(&m_gl, glu::ApiType::es(2,0), DE_LENGTH_OF_ARRAY(reqExts), reqExts);
515 if (m_config.textureType == TestConfig::TEXTURETYPE_IMAGE
516 || m_config.textureType == TestConfig::TEXTURETYPE_SHARED_IMAGE
517 || m_config.textureType == TestConfig::TEXTURETYPE_SHARED_IMAGE_TEXTURE)
519 vector<string> glExts = de::splitString((const char*)m_gl.getString(GL_EXTENSIONS), ' ');
521 if (!de::contains(glExts.begin(), glExts.end(), "GL_OES_EGL_image"))
522 TCU_THROW(NotSupportedError, "GL_OES_EGL_image extensions not supported");
524 TCU_CHECK(m_gl.eglImageTargetTexture2DOES);
527 if (m_config.useCoordBuffer && (!m_config.sharedCoordBuffer || !parent))
528 m_coordBuffer = createCoordBuffer(m_gl, m_config);
529 else if (m_config.useCoordBuffer && m_config.sharedCoordBuffer)
530 m_coordBuffer = parent->getCoordBuffer();
532 createCoordData(m_coordData, m_config);
534 if (m_config.useIndexBuffer && (!m_config.sharedIndexBuffer || !parent))
535 m_indexBuffer = createIndexBuffer(m_gl, m_config);
536 else if (m_config.useIndexBuffer && m_config.sharedIndexBuffer)
537 m_indexBuffer = parent->getIndexBuffer();
538 else if (m_config.useIndices)
539 createIndexData(m_indexData, m_config);
541 if (m_config.useTexture)
543 if (m_config.textureType == TestConfig::TEXTURETYPE_TEXTURE)
544 m_texture = createTexture(m_gl, m_config);
545 else if (m_config.textureType == TestConfig::TEXTURETYPE_SHARED_TEXTURE)
548 m_texture = parent->getTexture();
550 m_texture = createTexture(m_gl, m_config);
552 else if (m_config.textureType == TestConfig::TEXTURETYPE_IMAGE)
554 m_eglImage = createEGLImage();
555 m_texture = createTextureFromImage(m_eglImage);
557 else if (m_config.textureType == TestConfig::TEXTURETYPE_SHARED_IMAGE)
560 m_eglImage = parent->getEGLImage();
562 m_eglImage = createEGLImage();
564 m_texture = createTextureFromImage(m_eglImage);
566 else if (m_config.textureType == TestConfig::TEXTURETYPE_SHARED_IMAGE_TEXTURE)
569 m_texture = parent->getTexture();
572 m_eglImage = createEGLImage();
573 m_texture = createTextureFromImage(m_eglImage);
578 if (!m_config.sharedProgram || !parent)
579 m_program = createProgram(m_gl, m_config);
580 else if (m_config.sharedProgram)
581 m_program = parent->getProgram();
583 m_coordLoc = m_gl.getAttribLocation(m_program, "a_coord");
585 if (m_config.useTexture)
586 m_textureLoc = m_gl.getUniformLocation(m_program, "u_sampler");
588 EGLU_CHECK_CALL(egl, makeCurrent(m_eglDisplay, EGL_NO_SURFACE, EGL_NO_SURFACE, EGL_NO_CONTEXT));
591 EGLImageKHR TestContext::createEGLImage (void)
593 GLuint sourceTexture = createTexture(m_gl, m_config);
597 const Library& egl = m_testCtx.getLibrary();
598 const EGLint attribList[] =
600 EGL_GL_TEXTURE_LEVEL_KHR, 0,
604 EGLImageKHR image = egl.createImageKHR(m_eglDisplay, m_eglContext, EGL_GL_TEXTURE_2D_KHR, (EGLClientBuffer)(deUintptr)sourceTexture, attribList);
605 EGLU_CHECK_MSG(egl, "eglCreateImageKHR()");
607 m_gl.deleteTextures(1, &sourceTexture);
608 GLU_EXPECT_NO_ERROR(m_gl.getError(), "eglCreateImageKHR()");
614 m_gl.deleteTextures(1, &sourceTexture);
619 GLuint TestContext::createTextureFromImage (EGLImageKHR image)
625 m_gl.genTextures(1, &texture);
626 m_gl.bindTexture(GL_TEXTURE_2D, texture);
627 m_gl.eglImageTargetTexture2DOES(GL_TEXTURE_2D, image);
628 m_gl.bindTexture(GL_TEXTURE_2D, 0);
629 GLU_EXPECT_NO_ERROR(m_gl.getError(), "Creating texture from image");
635 m_gl.deleteTextures(1, &texture);
641 TestContext::~TestContext (void)
643 const Library& egl = m_testCtx.getLibrary();
645 EGLU_CHECK_CALL(egl, makeCurrent(m_eglDisplay, m_eglSurface, m_eglSurface, m_eglContext));
647 if (m_parent == DE_NULL && m_eglImage)
648 EGLU_CHECK_CALL(egl, destroyImageKHR(m_eglDisplay, m_eglImage));
650 EGLU_CHECK_CALL(egl, makeCurrent(m_eglDisplay, EGL_NO_SURFACE, EGL_NO_SURFACE, EGL_NO_CONTEXT));
651 EGLU_CHECK_CALL(egl, destroyContext(m_eglDisplay, m_eglContext));
652 EGLU_CHECK_CALL(egl, destroySurface(m_eglDisplay, m_eglSurface));
655 void TestContext::render (void)
657 const Library& egl = m_testCtx.getLibrary();
659 egl.makeCurrent(m_eglDisplay, m_eglSurface, m_eglSurface, m_eglContext);
661 for (int frameNdx = 0; frameNdx < m_config.frameCount; frameNdx++)
663 m_gl.clearColor(0.75f, 0.6f, 0.5f, 1.0f);
664 m_gl.clear(GL_COLOR_BUFFER_BIT|GL_DEPTH_BUFFER_BIT);
666 for (int callNdx = 0; callNdx < m_config.drawCallCount; callNdx++)
668 m_gl.useProgram(m_program);
669 m_gl.enableVertexAttribArray(m_coordLoc);
671 if (m_config.useCoordBuffer)
673 m_gl.bindBuffer(GL_ARRAY_BUFFER, m_coordBuffer);
674 m_gl.vertexAttribPointer(m_coordLoc, 2, GL_FLOAT, GL_FALSE, 0, 0);
675 m_gl.bindBuffer(GL_ARRAY_BUFFER, 0);
678 m_gl.vertexAttribPointer(m_coordLoc, 2, GL_FLOAT, GL_FALSE, 0, &(m_coordData[0]));
680 if (m_config.useTexture)
682 m_gl.bindTexture(GL_TEXTURE_2D, m_texture);
683 m_gl.uniform1i(m_textureLoc, 0);
686 if (m_config.useIndices)
688 if (m_config.useIndexBuffer)
690 m_gl.bindBuffer(GL_ELEMENT_ARRAY_BUFFER, m_indexBuffer);
691 m_gl.drawElements(GL_TRIANGLES, m_config.triangleCount, GL_UNSIGNED_SHORT, 0);
694 m_gl.drawElements(GL_TRIANGLES, m_config.triangleCount, GL_UNSIGNED_SHORT, &(m_indexData[0]));
697 m_gl.drawArrays(GL_TRIANGLES, 0, m_config.triangleCount);
700 if (m_config.useTexture)
701 m_gl.bindTexture(GL_TEXTURE_2D, 0);
703 m_gl.disableVertexAttribArray(m_coordLoc);
709 egl.swapBuffers(m_eglDisplay, m_eglSurface);
713 GLU_EXPECT_NO_ERROR(m_gl.getError(), "glFinish()");
714 EGLU_CHECK_CALL(egl, makeCurrent(m_eglDisplay, EGL_NO_SURFACE, EGL_NO_SURFACE, EGL_NO_CONTEXT));
717 class TestThread : de::Thread
720 TestThread (const vector<TestContext*> contexts);
725 void log (TestLog& log);
727 bool resultOk (void) { return m_isOk; }
730 vector<TestContext*> m_contexts;
732 string m_errorString;
734 deUint64 m_beginTimeUs;
735 deUint64 m_endTimeUs;
737 deUint64 m_joinBeginUs;
738 deUint64 m_joinEndUs;
740 deUint64 m_startBeginUs;
741 deUint64 m_startEndUs;
744 virtual void run (void);
746 TestThread& operator= (const TestThread&);
747 TestThread (const TestThread&);
750 TestThread::TestThread (const vector<TestContext*> contexts)
751 : m_contexts (contexts)
763 TestThread::~TestThread (void)
768 void TestThread::log (TestLog& testLog)
771 testLog << TestLog::Message << "Thread failed: " << m_errorString << TestLog::EndMessage;
774 void TestThread::start (void)
776 m_startBeginUs = deGetMicroseconds();
778 m_startEndUs = deGetMicroseconds();
781 void TestThread::join (void)
783 m_joinBeginUs = deGetMicroseconds();
785 m_joinEndUs = deGetMicroseconds();
788 void TestThread::run (void)
792 m_beginTimeUs = deGetMicroseconds();
794 for (int contextNdx = 0; contextNdx < (int)m_contexts.size(); contextNdx++)
795 m_contexts[contextNdx]->render();
798 m_endTimeUs = deGetMicroseconds();
800 catch (const std::runtime_error& error)
803 m_errorString = error.what();
808 m_errorString = "Got unknown exception";
812 class SharedRenderingPerfCase : public TestCase
815 SharedRenderingPerfCase (EglTestContext& eglTestCtx, const TestConfig& config, const char* name, const char* description);
816 ~SharedRenderingPerfCase (void);
820 IterateResult iterate (void);
824 const int m_iterationCount;
826 EGLDisplay m_display;
827 vector<TestContext*> m_contexts;
828 vector<deUint64> m_results;
830 SharedRenderingPerfCase& operator= (const SharedRenderingPerfCase&);
831 SharedRenderingPerfCase (const SharedRenderingPerfCase&);
834 SharedRenderingPerfCase::SharedRenderingPerfCase (EglTestContext& eglTestCtx, const TestConfig& config, const char* name, const char* description)
835 : TestCase (eglTestCtx, tcu::NODETYPE_PERFORMANCE, name, description)
837 , m_iterationCount (30)
838 , m_display (EGL_NO_DISPLAY)
842 SharedRenderingPerfCase::~SharedRenderingPerfCase (void)
847 void SharedRenderingPerfCase::init (void)
849 m_display = eglu::getAndInitDisplay(m_eglTestCtx.getNativeDisplay());
852 const Library& egl = m_eglTestCtx.getLibrary();
853 const EGLint attribList[] =
855 EGL_SURFACE_TYPE, EGL_PBUFFER_BIT,
856 EGL_RENDERABLE_TYPE, EGL_OPENGL_ES2_BIT,
859 EGLConfig eglConfig = eglu::chooseSingleConfig(egl, m_display, attribList);
861 // Create contexts and resources
862 for (int threadNdx = 0; threadNdx < m_config.threadCount * m_config.perThreadContextCount; threadNdx++)
863 m_contexts.push_back(new TestContext(m_eglTestCtx, m_display, eglConfig, m_config, m_config.sharedContexts, (threadNdx == 0 ? DE_NULL : m_contexts[threadNdx-1])));
867 void SharedRenderingPerfCase::deinit (void)
869 // Destroy resources and contexts
870 for (int threadNdx = 0; threadNdx < (int)m_contexts.size(); threadNdx++)
872 delete m_contexts[threadNdx];
873 m_contexts[threadNdx] = DE_NULL;
879 if (m_display != EGL_NO_DISPLAY)
881 m_eglTestCtx.getLibrary().terminate(m_display);
882 m_display = EGL_NO_DISPLAY;
889 void createThreads (vector<TestThread*>& threads, int threadCount, int perThreadContextCount, vector<TestContext*>& contexts)
891 DE_ASSERT(threadCount * perThreadContextCount == (int)contexts.size());
892 DE_ASSERT(threads.empty());
894 vector<TestContext*> threadContexts;
896 for (int threadNdx = 0; threadNdx < threadCount; threadNdx++)
898 for (int contextNdx = 0; contextNdx < perThreadContextCount; contextNdx++)
899 threadContexts.push_back(contexts[threadNdx * perThreadContextCount + contextNdx]);
901 threads.push_back(new TestThread(threadContexts));
903 threadContexts.clear();
907 void destroyThreads (vector<TestThread*>& threads)
909 for (int threadNdx = 0; threadNdx < (int)threads.size(); threadNdx++)
911 delete threads[threadNdx];
912 threads[threadNdx] = DE_NULL;
918 void startThreads (vector<TestThread*>& threads)
920 for (int threadNdx = 0; threadNdx < (int)threads.size(); threadNdx++)
921 threads[threadNdx]->start();
924 void joinThreads (vector<TestThread*>& threads)
926 for (int threadNdx = 0; threadNdx < (int)threads.size(); threadNdx++)
927 threads[threadNdx]->join();
930 bool threadResultsOk (const vector<TestThread*>& threads)
932 for (int threadNdx = 0; threadNdx < (int)threads.size(); threadNdx++)
934 if (!threads[threadNdx]->resultOk())
941 void logAndSetResults (tcu::TestContext& testCtx, const vector<deUint64>& r)
943 TestLog& log = testCtx.getLog();
944 vector<deUint64> resultsUs = r;
950 log << TestLog::SampleList("Result", "Result")
951 << TestLog::SampleInfo << TestLog::ValueInfo("Time", "Time", "us", QP_SAMPLE_VALUE_TAG_RESPONSE)
952 << TestLog::EndSampleInfo;
954 for (int resultNdx = 0; resultNdx < (int)resultsUs.size(); resultNdx++)
955 log << TestLog::Sample << deInt64(resultsUs[resultNdx]) << TestLog::EndSample;
957 log << TestLog::EndSampleList;
959 std::sort(resultsUs.begin(), resultsUs.end());
961 for (int resultNdx = 0; resultNdx < (int)resultsUs.size(); resultNdx++)
962 sum += resultsUs[resultNdx];
964 average = sum / resultsUs.size();
965 median = resultsUs[resultsUs.size() / 2];
968 for (int resultNdx = 0; resultNdx < (int)resultsUs.size(); resultNdx++)
969 deviation += (double)((resultsUs[resultNdx] - average) * (resultsUs[resultNdx] - average));
971 deviation = std::sqrt(deviation/(double)resultsUs.size());
974 tcu::ScopedLogSection section(log, "Statistics from results", "Statistics from results");
976 log << TestLog::Message
977 << "Average: " << ((double)average/1000.0) << "ms\n"
978 << "Standard deviation: " << ((double)deviation/1000.0) << "ms\n"
979 << "Standard error of mean: " << (((double)deviation/std::sqrt((double)resultsUs.size()))/1000.0) << "ms\n"
980 << "Median: " << ((double)median/1000.0) << "ms\n"
981 << TestLog::EndMessage;
984 testCtx.setTestResult(QP_TEST_RESULT_PASS, de::floatToString((float)((double)average/1000.0), 2).c_str());
987 void logTestConfig (TestLog& log, const TestConfig& config)
989 tcu::ScopedLogSection threadSection(log, "Test info", "Test information");
991 log << TestLog::Message << "Total triangles rendered: : " << config.triangleCount * config.drawCallCount * config.frameCount * config.perThreadContextCount * config.threadCount << TestLog::EndMessage;
992 log << TestLog::Message << "Number of threads: " << config.threadCount << TestLog::EndMessage;
993 log << TestLog::Message << "Number of contexts used to render with each thread: " << config.perThreadContextCount << TestLog::EndMessage;
994 log << TestLog::Message << "Number of frames rendered with each context: " << config.frameCount << TestLog::EndMessage;
995 log << TestLog::Message << "Number of draw calls performed by each frame: " << config.drawCallCount << TestLog::EndMessage;
996 log << TestLog::Message << "Number of triangles rendered by each draw call: " << config.triangleCount << TestLog::EndMessage;
998 if (config.sharedContexts)
999 log << TestLog::Message << "Shared contexts." << TestLog::EndMessage;
1001 log << TestLog::Message << "No shared contexts." << TestLog::EndMessage;
1003 if (config.useCoordBuffer)
1004 log << TestLog::Message << (config.sharedCoordBuffer ? "Shared " : "") << "Coordinate buffer" << TestLog::EndMessage;
1006 log << TestLog::Message << "Coordinates from pointer" << TestLog::EndMessage;
1008 if (config.useIndices)
1009 log << TestLog::Message << "Using glDrawElements with indices from " << (config.sharedIndexBuffer ? "shared " : "") << (config.useIndexBuffer ? "buffer." : "pointer.") << TestLog::EndMessage;
1011 if (config.useTexture)
1013 if (config.textureType == TestConfig::TEXTURETYPE_TEXTURE)
1014 log << TestLog::Message << "Use texture." << TestLog::EndMessage;
1015 else if (config.textureType == TestConfig::TEXTURETYPE_SHARED_TEXTURE)
1016 log << TestLog::Message << "Use shared texture." << TestLog::EndMessage;
1017 else if (config.textureType == TestConfig::TEXTURETYPE_IMAGE)
1018 log << TestLog::Message << "Use texture created from EGLImage." << TestLog::EndMessage;
1019 else if (config.textureType == TestConfig::TEXTURETYPE_SHARED_IMAGE)
1020 log << TestLog::Message << "Use texture created from shared EGLImage." << TestLog::EndMessage;
1021 else if (config.textureType == TestConfig::TEXTURETYPE_SHARED_IMAGE_TEXTURE)
1022 log << TestLog::Message << "Use shared texture created from EGLImage." << TestLog::EndMessage;
1026 log << TestLog::Message << "Texture size: " << config.textureWidth << "x" << config.textureHeight << TestLog::EndMessage;
1029 if (config.sharedProgram)
1030 log << TestLog::Message << "Shared program." << TestLog::EndMessage;
1032 log << TestLog::Message << "Surface size: " << config.surfaceWidth << "x" << config.surfaceHeight << TestLog::EndMessage;
1037 TestCase::IterateResult SharedRenderingPerfCase::iterate (void)
1039 deUint64 beginTimeUs;
1041 vector<TestThread*> threads;
1043 if (m_results.empty())
1044 logTestConfig(m_testCtx.getLog(), m_config);
1046 createThreads(threads, m_config.threadCount, m_config.perThreadContextCount, m_contexts);
1048 beginTimeUs = deGetMicroseconds();
1050 startThreads(threads);
1051 joinThreads(threads);
1053 endTimeUs = deGetMicroseconds();
1055 if (!threadResultsOk(threads))
1057 m_testCtx.setTestResult(QP_TEST_RESULT_FAIL, "Fail");
1061 destroyThreads(threads);
1063 m_results.push_back(endTimeUs - beginTimeUs);
1065 if ((int)m_results.size() == m_iterationCount)
1067 logAndSetResults(m_testCtx, m_results);
1074 string createTestName(int threads, int perThreadContextCount)
1076 std::ostringstream stream;
1078 stream << threads << (threads == 1 ? "_thread_" : "_threads_") << perThreadContextCount << (perThreadContextCount == 1 ? "_context" : "_contexts");
1080 return stream.str();
1085 GLES2SharedRenderingPerfTests::GLES2SharedRenderingPerfTests (EglTestContext& eglTestCtx)
1086 : TestCaseGroup(eglTestCtx, "gles2_shared_render", "")
1090 void GLES2SharedRenderingPerfTests::init (void)
1092 TestConfig basicConfig;
1094 basicConfig.threadCount = 1;
1095 basicConfig.perThreadContextCount = 1;
1097 basicConfig.sharedContexts = true;
1098 basicConfig.frameCount = 10;
1099 basicConfig.drawCallCount = 10;
1100 basicConfig.triangleCount = 100;
1102 basicConfig.useCoordBuffer = true;
1103 basicConfig.sharedCoordBuffer = false;
1105 basicConfig.useIndices = true;
1106 basicConfig.useIndexBuffer = true;
1107 basicConfig.sharedIndexBuffer = false;
1109 basicConfig.useTexture = true;
1110 basicConfig.textureType = TestConfig::TEXTURETYPE_TEXTURE;
1112 basicConfig.sharedProgram = false;
1114 basicConfig.textureWidth = 128;
1115 basicConfig.textureHeight = 128;
1117 basicConfig.surfaceWidth = 256;
1118 basicConfig.surfaceHeight = 256;
1120 const int threadCounts[] = { 1, 2, 4 };
1121 const int perThreadContextCounts[] = { 1, 2, 4 };
1123 // Add no sharing tests
1125 TestCaseGroup* sharedNoneGroup = new TestCaseGroup(m_eglTestCtx, "no_shared_context", "Tests without sharing contexts.");
1127 for (int threadCountNdx = 0; threadCountNdx < DE_LENGTH_OF_ARRAY(threadCounts); threadCountNdx++)
1129 int threadCount = threadCounts[threadCountNdx];
1131 for (int contextCountNdx = 0; contextCountNdx < DE_LENGTH_OF_ARRAY(perThreadContextCounts); contextCountNdx++)
1133 int contextCount = perThreadContextCounts[contextCountNdx];
1135 if (threadCount * contextCount != 4 && threadCount * contextCount != 1)
1138 TestConfig config = basicConfig;
1139 config.threadCount = threadCount;
1140 config.perThreadContextCount = contextCount;
1141 config.sharedContexts = false;
1144 TestConfig smallConfig = config;
1145 smallConfig.triangleCount = 1;
1146 smallConfig.drawCallCount = 1000;
1147 smallConfig.frameCount = 10;
1149 if (threadCount * contextCount == 1)
1150 smallConfig.frameCount *= 4;
1152 sharedNoneGroup->addChild(new SharedRenderingPerfCase(m_eglTestCtx, smallConfig, (createTestName(threadCount, contextCount) + "_small_call").c_str(), ""));
1156 TestConfig bigConfig = config;
1157 bigConfig.triangleCount = 1000;
1158 bigConfig.drawCallCount = 1;
1159 bigConfig.frameCount = 10;
1161 if (threadCount * contextCount == 1)
1162 bigConfig.frameCount *= 4;
1164 sharedNoneGroup->addChild(new SharedRenderingPerfCase(m_eglTestCtx, bigConfig, (createTestName(threadCount, contextCount) + "_big_call").c_str(), ""));
1169 addChild(sharedNoneGroup);
1172 // Add no resource sharing tests
1174 TestCaseGroup* sharedNoneGroup = new TestCaseGroup(m_eglTestCtx, "no_shared_resource", "Tests without shared resources.");
1176 for (int threadCountNdx = 0; threadCountNdx < DE_LENGTH_OF_ARRAY(threadCounts); threadCountNdx++)
1178 int threadCount = threadCounts[threadCountNdx];
1180 for (int contextCountNdx = 0; contextCountNdx < DE_LENGTH_OF_ARRAY(perThreadContextCounts); contextCountNdx++)
1182 int contextCount = perThreadContextCounts[contextCountNdx];
1184 if (threadCount * contextCount != 4 && threadCount * contextCount != 1)
1187 TestConfig config = basicConfig;
1188 config.threadCount = threadCount;
1189 config.perThreadContextCount = contextCount;
1192 TestConfig smallConfig = config;
1193 smallConfig.triangleCount = 1;
1194 smallConfig.drawCallCount = 1000;
1195 smallConfig.frameCount = 10;
1197 if (threadCount * contextCount == 1)
1198 smallConfig.frameCount *= 4;
1200 sharedNoneGroup->addChild(new SharedRenderingPerfCase(m_eglTestCtx, smallConfig, (createTestName(threadCount, contextCount) + "_small_call").c_str(), ""));
1204 TestConfig bigConfig = config;
1205 bigConfig.triangleCount = 1000;
1206 bigConfig.drawCallCount = 1;
1207 bigConfig.frameCount = 10;
1209 if (threadCount * contextCount == 1)
1210 bigConfig.frameCount *= 4;
1212 sharedNoneGroup->addChild(new SharedRenderingPerfCase(m_eglTestCtx, bigConfig, (createTestName(threadCount, contextCount) + "_big_call").c_str(), ""));
1217 addChild(sharedNoneGroup);
1220 // Add shared coord buffer tests
1222 TestCaseGroup* sharedCoordBufferGroup = new TestCaseGroup(m_eglTestCtx, "shared_coord_buffer", "Shared coordinate bufffer");
1224 for (int threadCountNdx = 0; threadCountNdx < DE_LENGTH_OF_ARRAY(threadCounts); threadCountNdx++)
1226 int threadCount = threadCounts[threadCountNdx];
1228 for (int contextCountNdx = 0; contextCountNdx < DE_LENGTH_OF_ARRAY(perThreadContextCounts); contextCountNdx++)
1230 int contextCount = perThreadContextCounts[contextCountNdx];
1232 if (threadCount * contextCount != 4 && threadCount * contextCount != 1)
1235 TestConfig config = basicConfig;
1236 config.sharedCoordBuffer = true;
1237 config.threadCount = threadCount;
1238 config.perThreadContextCount = contextCount;
1241 TestConfig smallConfig = config;
1242 smallConfig.triangleCount = 1;
1243 smallConfig.drawCallCount = 1000;
1244 smallConfig.frameCount = 10;
1246 if (threadCount * contextCount == 1)
1247 smallConfig.frameCount *= 4;
1249 sharedCoordBufferGroup->addChild(new SharedRenderingPerfCase(m_eglTestCtx, smallConfig, (createTestName(threadCount, contextCount) + "_small_call").c_str(), ""));
1253 TestConfig bigConfig = config;
1254 bigConfig.triangleCount = 1000;
1255 bigConfig.drawCallCount = 1;
1256 bigConfig.frameCount = 10;
1258 if (threadCount * contextCount == 1)
1259 bigConfig.frameCount *= 4;
1261 sharedCoordBufferGroup->addChild(new SharedRenderingPerfCase(m_eglTestCtx, bigConfig, (createTestName(threadCount, contextCount) + "_big_call").c_str(), ""));
1266 addChild(sharedCoordBufferGroup);
1269 // Add shared index buffer tests
1271 TestCaseGroup* sharedIndexBufferGroup = new TestCaseGroup(m_eglTestCtx, "shared_index_buffer", "Shared index bufffer");
1273 for (int threadCountNdx = 0; threadCountNdx < DE_LENGTH_OF_ARRAY(threadCounts); threadCountNdx++)
1275 int threadCount = threadCounts[threadCountNdx];
1277 for (int contextCountNdx = 0; contextCountNdx < DE_LENGTH_OF_ARRAY(perThreadContextCounts); contextCountNdx++)
1279 int contextCount = perThreadContextCounts[contextCountNdx];
1281 if (threadCount * contextCount != 4 && threadCount * contextCount != 1)
1284 TestConfig config = basicConfig;
1285 config.sharedIndexBuffer = true;
1286 config.threadCount = threadCount;
1287 config.perThreadContextCount = contextCount;
1290 TestConfig smallConfig = config;
1291 smallConfig.triangleCount = 1;
1292 smallConfig.drawCallCount = 1000;
1293 smallConfig.frameCount = 10;
1295 if (threadCount * contextCount == 1)
1296 smallConfig.frameCount *= 4;
1298 sharedIndexBufferGroup->addChild(new SharedRenderingPerfCase(m_eglTestCtx, smallConfig, (createTestName(threadCount, contextCount) + "_small_call").c_str(), ""));
1302 TestConfig bigConfig = config;
1303 bigConfig.triangleCount = 1000;
1304 bigConfig.drawCallCount = 1;
1305 bigConfig.frameCount = 10;
1307 if (threadCount * contextCount == 1)
1308 bigConfig.frameCount *= 4;
1310 sharedIndexBufferGroup->addChild(new SharedRenderingPerfCase(m_eglTestCtx, bigConfig, (createTestName(threadCount, contextCount) + "_big_call").c_str(), ""));
1315 addChild(sharedIndexBufferGroup);
1318 // Add shared texture tests
1320 TestCaseGroup* sharedTextureGroup = new TestCaseGroup(m_eglTestCtx, "shared_texture", "Shared texture tests.");
1322 for (int threadCountNdx = 0; threadCountNdx < DE_LENGTH_OF_ARRAY(threadCounts); threadCountNdx++)
1324 int threadCount = threadCounts[threadCountNdx];
1326 for (int contextCountNdx = 0; contextCountNdx < DE_LENGTH_OF_ARRAY(perThreadContextCounts); contextCountNdx++)
1328 int contextCount = perThreadContextCounts[contextCountNdx];
1330 if (threadCount * contextCount != 4 && threadCount * contextCount != 1)
1333 TestConfig config = basicConfig;
1334 config.textureType = TestConfig::TEXTURETYPE_SHARED_TEXTURE;
1335 config.threadCount = threadCount;
1336 config.perThreadContextCount = contextCount;
1339 TestConfig smallConfig = config;
1340 smallConfig.triangleCount = 1;
1341 smallConfig.drawCallCount = 1000;
1342 smallConfig.frameCount = 10;
1344 if (threadCount * contextCount == 1)
1345 smallConfig.frameCount *= 4;
1347 sharedTextureGroup->addChild(new SharedRenderingPerfCase(m_eglTestCtx, smallConfig, (createTestName(threadCount, contextCount) + "_small_call").c_str(), ""));
1351 TestConfig bigConfig = config;
1352 bigConfig.triangleCount = 1000;
1353 bigConfig.drawCallCount = 1;
1354 bigConfig.frameCount = 10;
1356 if (threadCount * contextCount == 1)
1357 bigConfig.frameCount *= 4;
1359 sharedTextureGroup->addChild(new SharedRenderingPerfCase(m_eglTestCtx, bigConfig, (createTestName(threadCount, contextCount) + "_big_call").c_str(), ""));
1364 addChild(sharedTextureGroup);
1367 // Add shared program tests
1369 TestCaseGroup* sharedProgramGroup = new TestCaseGroup(m_eglTestCtx, "shared_program", "Shared program tests.");
1371 for (int threadCountNdx = 0; threadCountNdx < DE_LENGTH_OF_ARRAY(threadCounts); threadCountNdx++)
1373 int threadCount = threadCounts[threadCountNdx];
1375 for (int contextCountNdx = 0; contextCountNdx < DE_LENGTH_OF_ARRAY(perThreadContextCounts); contextCountNdx++)
1377 int contextCount = perThreadContextCounts[contextCountNdx];
1379 if (threadCount * contextCount != 4 && threadCount * contextCount != 1)
1382 TestConfig config = basicConfig;
1383 config.sharedProgram = true;
1384 config.threadCount = threadCount;
1385 config.perThreadContextCount = contextCount;
1388 TestConfig smallConfig = config;
1389 smallConfig.triangleCount = 1;
1390 smallConfig.drawCallCount = 1000;
1391 smallConfig.frameCount = 10;
1393 if (threadCount * contextCount == 1)
1394 smallConfig.frameCount *= 4;
1396 sharedProgramGroup->addChild(new SharedRenderingPerfCase(m_eglTestCtx, smallConfig, (createTestName(threadCount, contextCount) + "_small_call").c_str(), ""));
1400 TestConfig bigConfig = config;
1401 bigConfig.triangleCount = 1000;
1402 bigConfig.drawCallCount = 1;
1403 bigConfig.frameCount = 10;
1405 if (threadCount * contextCount == 1)
1406 bigConfig.frameCount *= 4;
1408 sharedProgramGroup->addChild(new SharedRenderingPerfCase(m_eglTestCtx, bigConfig, (createTestName(threadCount, contextCount) + "_big_call").c_str(), ""));
1413 addChild(sharedProgramGroup);
1416 // Add shared all tests
1418 TestCaseGroup* sharedallGroup = new TestCaseGroup(m_eglTestCtx, "shared_all", "Share all possible resources.");
1420 for (int threadCountNdx = 0; threadCountNdx < DE_LENGTH_OF_ARRAY(threadCounts); threadCountNdx++)
1422 int threadCount = threadCounts[threadCountNdx];
1424 for (int contextCountNdx = 0; contextCountNdx < DE_LENGTH_OF_ARRAY(perThreadContextCounts); contextCountNdx++)
1426 int contextCount = perThreadContextCounts[contextCountNdx];
1428 if (threadCount * contextCount != 4 && threadCount * contextCount != 1)
1431 TestConfig config = basicConfig;
1432 config.sharedCoordBuffer = true;
1433 config.sharedIndexBuffer = true;
1434 config.sharedProgram = true;
1435 config.textureType = TestConfig::TEXTURETYPE_SHARED_TEXTURE;
1436 config.threadCount = threadCount;
1437 config.perThreadContextCount = contextCount;
1440 TestConfig smallConfig = config;
1441 smallConfig.triangleCount = 1;
1442 smallConfig.drawCallCount = 1000;
1443 smallConfig.frameCount = 10;
1445 if (threadCount * contextCount == 1)
1446 smallConfig.frameCount *= 4;
1448 sharedallGroup->addChild(new SharedRenderingPerfCase(m_eglTestCtx, smallConfig, (createTestName(threadCount, contextCount) + "_small_call").c_str(), ""));
1452 TestConfig bigConfig = config;
1453 bigConfig.triangleCount = 1000;
1454 bigConfig.drawCallCount = 1;
1455 bigConfig.frameCount = 10;
1457 if (threadCount * contextCount == 1)
1458 bigConfig.frameCount *= 4;
1460 sharedallGroup->addChild(new SharedRenderingPerfCase(m_eglTestCtx, bigConfig, (createTestName(threadCount, contextCount) + "_big_call").c_str(), ""));
1465 addChild(sharedallGroup);
1468 // Add EGLImage tests
1470 TestCaseGroup* sharedTextureGroup = new TestCaseGroup(m_eglTestCtx, "egl_image", "EGL image tests.");
1472 for (int threadCountNdx = 0; threadCountNdx < DE_LENGTH_OF_ARRAY(threadCounts); threadCountNdx++)
1474 int threadCount = threadCounts[threadCountNdx];
1476 for (int contextCountNdx = 0; contextCountNdx < DE_LENGTH_OF_ARRAY(perThreadContextCounts); contextCountNdx++)
1478 int contextCount = perThreadContextCounts[contextCountNdx];
1480 if (threadCount * contextCount != 4 && threadCount * contextCount != 1)
1483 TestConfig config = basicConfig;
1485 config.textureType = TestConfig::TEXTURETYPE_IMAGE;
1486 config.threadCount = threadCount;
1487 config.perThreadContextCount = contextCount;
1488 config.sharedContexts = false;
1491 TestConfig smallConfig = config;
1492 smallConfig.triangleCount = 1;
1493 smallConfig.drawCallCount = 1000;
1494 smallConfig.frameCount = 10;
1496 if (threadCount * contextCount == 1)
1497 smallConfig.frameCount *= 4;
1499 sharedTextureGroup->addChild(new SharedRenderingPerfCase(m_eglTestCtx, smallConfig, (createTestName(threadCount, contextCount) + "_small_call").c_str(), ""));
1503 TestConfig bigConfig = config;
1504 bigConfig.triangleCount = 1000;
1505 bigConfig.drawCallCount = 1;
1506 bigConfig.frameCount = 10;
1508 if (threadCount * contextCount == 1)
1509 bigConfig.frameCount *= 4;
1511 sharedTextureGroup->addChild(new SharedRenderingPerfCase(m_eglTestCtx, bigConfig, (createTestName(threadCount, contextCount) + "_big_call").c_str(), ""));
1516 addChild(sharedTextureGroup);
1519 // Add shared EGLImage tests
1521 TestCaseGroup* sharedTextureGroup = new TestCaseGroup(m_eglTestCtx, "shared_egl_image", "Shared EGLImage tests.");
1523 for (int threadCountNdx = 0; threadCountNdx < DE_LENGTH_OF_ARRAY(threadCounts); threadCountNdx++)
1525 int threadCount = threadCounts[threadCountNdx];
1527 for (int contextCountNdx = 0; contextCountNdx < DE_LENGTH_OF_ARRAY(perThreadContextCounts); contextCountNdx++)
1529 int contextCount = perThreadContextCounts[contextCountNdx];
1531 if (threadCount * contextCount != 4 && threadCount * contextCount != 1)
1534 TestConfig config = basicConfig;
1536 config.textureType = TestConfig::TEXTURETYPE_SHARED_IMAGE;
1537 config.threadCount = threadCount;
1538 config.perThreadContextCount = contextCount;
1539 config.sharedContexts = false;
1542 TestConfig smallConfig = config;
1543 smallConfig.triangleCount = 1;
1544 smallConfig.drawCallCount = 1000;
1545 smallConfig.frameCount = 10;
1547 if (threadCount * contextCount == 1)
1548 smallConfig.frameCount *= 4;
1550 sharedTextureGroup->addChild(new SharedRenderingPerfCase(m_eglTestCtx, smallConfig, (createTestName(threadCount, contextCount) + "_small_call").c_str(), ""));
1554 TestConfig bigConfig = config;
1555 bigConfig.triangleCount = 1000;
1556 bigConfig.drawCallCount = 1;
1557 bigConfig.frameCount = 10;
1559 if (threadCount * contextCount == 1)
1560 bigConfig.frameCount *= 4;
1562 sharedTextureGroup->addChild(new SharedRenderingPerfCase(m_eglTestCtx, bigConfig, (createTestName(threadCount, contextCount) + "_big_call").c_str(), ""));
1567 addChild(sharedTextureGroup);
1570 // Shared EGLImage texture test
1572 TestCaseGroup* sharedTextureGroup = new TestCaseGroup(m_eglTestCtx, "shared_egl_image_texture", "Shared EGLImage texture tests.");
1574 for (int threadCountNdx = 0; threadCountNdx < DE_LENGTH_OF_ARRAY(threadCounts); threadCountNdx++)
1576 int threadCount = threadCounts[threadCountNdx];
1578 for (int contextCountNdx = 0; contextCountNdx < DE_LENGTH_OF_ARRAY(perThreadContextCounts); contextCountNdx++)
1580 int contextCount = perThreadContextCounts[contextCountNdx];
1582 if (threadCount * contextCount != 4 && threadCount * contextCount != 1)
1585 TestConfig config = basicConfig;
1586 config.textureType = TestConfig::TEXTURETYPE_SHARED_IMAGE_TEXTURE;
1587 config.threadCount = threadCount;
1588 config.perThreadContextCount = contextCount;
1591 TestConfig smallConfig = config;
1592 smallConfig.triangleCount = 1;
1593 smallConfig.drawCallCount = 1000;
1594 smallConfig.frameCount = 10;
1596 if (threadCount * contextCount == 1)
1597 smallConfig.frameCount *= 4;
1599 sharedTextureGroup->addChild(new SharedRenderingPerfCase(m_eglTestCtx, smallConfig, (createTestName(threadCount, contextCount) + "_small_call").c_str(), ""));
1603 TestConfig bigConfig = config;
1604 bigConfig.triangleCount = 1000;
1605 bigConfig.drawCallCount = 1;
1606 bigConfig.frameCount = 10;
1608 if (threadCount * contextCount == 1)
1609 bigConfig.frameCount *= 4;
1611 sharedTextureGroup->addChild(new SharedRenderingPerfCase(m_eglTestCtx, bigConfig, (createTestName(threadCount, contextCount) + "_big_call").c_str(), ""));
1616 addChild(sharedTextureGroup);