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 Multi threaded EGL tests
22 *//*--------------------------------------------------------------------*/
23 #include "teglMultiThreadTests.hpp"
25 #include "egluNativeWindow.hpp"
26 #include "egluNativePixmap.hpp"
27 #include "egluUtil.hpp"
29 #include "tcuTestLog.hpp"
30 #include "tcuCommandLine.hpp"
32 #include "deRandom.hpp"
34 #include "deThread.hpp"
35 #include "deMutex.hpp"
36 #include "deSemaphore.hpp"
41 #include "eglwLibrary.hpp"
42 #include "eglwEnums.hpp"
53 using std::ostringstream;
65 class BeginMessageToken {};
66 class EndMessageToken {};
70 Message (deUint64 timeUs_, const char* msg_) : timeUs(timeUs_), msg(msg_) {}
76 ThreadLog (void) { m_messages.reserve(100); }
78 ThreadLog& operator<< (const BeginMessageToken&) { return *this; }
79 ThreadLog& operator<< (const EndMessageToken&);
82 ThreadLog& operator<< (const T& t) { m_message << t; return *this; }
83 const vector<Message>& getMessages (void) const { return m_messages; }
85 static BeginMessageToken BeginMessage;
86 static EndMessageToken EndMessage;
89 ostringstream m_message;
90 vector<Message> m_messages;
93 ThreadLog& ThreadLog::operator<< (const EndMessageToken&)
95 m_messages.push_back(Message(deGetMicroseconds(), m_message.str().c_str()));
100 ThreadLog::BeginMessageToken ThreadLog::BeginMessage;
101 ThreadLog::EndMessageToken ThreadLog::EndMessage;
103 class MultiThreadedTest;
105 class TestThread : public de::Thread
110 THREADSTATUS_NOT_STARTED = 0,
111 THREADSTATUS_RUNNING,
115 TestThread (MultiThreadedTest& test, int id);
118 ThreadStatus getStatus (void) const { return m_status; }
119 ThreadLog& getLog (void) { return m_log; }
121 int getId (void) const { return m_id; }
123 void setStatus (ThreadStatus status) { m_status = status; }
125 const Library& getLibrary (void) const;
132 MultiThreadedTest& m_test;
134 ThreadStatus m_status;
138 class MultiThreadedTest : public TestCase
141 MultiThreadedTest (EglTestContext& eglTestCtx, const char* name, const char* description, int threadCount, deUint64 timeoutUs);
142 virtual ~MultiThreadedTest (void);
147 virtual bool runThread (TestThread& thread) = 0;
148 virtual IterateResult iterate (void);
149 void execTest (TestThread& thread);
151 const Library& getLibrary (void) const { return m_eglTestCtx.getLibrary(); }
159 deUint64 m_startTimeUs;
160 const deUint64 m_timeoutUs;
163 vector<TestThread*> m_threads;
165 volatile deInt32 m_barrierWaiters;
166 de::Semaphore m_barrierSemaphore1;
167 de::Semaphore m_barrierSemaphore2;
170 EGLDisplay m_display;
173 inline const Library& TestThread::getLibrary (void) const
175 return m_test.getLibrary();
178 TestThread::TestThread (MultiThreadedTest& test, int id)
181 , m_status (THREADSTATUS_NOT_STARTED)
185 void TestThread::run (void)
187 m_status = THREADSTATUS_RUNNING;
191 m_test.execTest(*this);
193 catch (const TestThread::TestStop&)
195 getLog() << ThreadLog::BeginMessage << "Thread stopped" << ThreadLog::EndMessage;
197 catch (const tcu::NotSupportedError& e)
199 getLog() << ThreadLog::BeginMessage << "Not supported: '" << e.what() << "'" << ThreadLog::EndMessage;
201 catch (const std::exception& e)
203 getLog() << ThreadLog::BeginMessage << "Got exception: '" << e.what() << "'" << ThreadLog::EndMessage;
207 getLog() << ThreadLog::BeginMessage << "Unknown exception" << ThreadLog::EndMessage;
210 getLibrary().releaseThread();
211 m_status = THREADSTATUS_READY;
214 void MultiThreadedTest::execTest (TestThread& thread)
218 if (!runThread(thread))
221 catch (const TestThread::TestStop&)
223 // Thread exited due to error in other thread
226 catch (const tcu::NotSupportedError&)
231 for (int threadNdx = 0; threadNdx < (int)m_threads.size(); threadNdx++)
233 m_barrierSemaphore1.increment();
234 m_barrierSemaphore2.increment();
244 for (int threadNdx = 0; threadNdx < (int)m_threads.size(); threadNdx++)
246 m_barrierSemaphore1.increment();
247 m_barrierSemaphore2.increment();
254 MultiThreadedTest::MultiThreadedTest (EglTestContext& eglTestCtx, const char* name, const char* description, int threadCount, deUint64 timeoutUs)
255 : TestCase (eglTestCtx, name, description)
256 , m_threadCount (threadCount)
257 , m_initialized (false)
259 , m_timeoutUs (timeoutUs)
262 , m_barrierWaiters (0)
263 , m_barrierSemaphore1 (0, 0)
264 , m_barrierSemaphore2 (1, 0)
266 , m_display (EGL_NO_DISPLAY)
270 MultiThreadedTest::~MultiThreadedTest (void)
272 for (int threadNdx = 0; threadNdx < (int)m_threads.size(); threadNdx++)
273 delete m_threads[threadNdx];
277 void MultiThreadedTest::init (void)
279 m_display = eglu::getAndInitDisplay(m_eglTestCtx.getNativeDisplay());
282 void MultiThreadedTest::deinit (void)
284 if (m_display != EGL_NO_DISPLAY)
286 m_eglTestCtx.getLibrary().terminate(m_display);
287 m_display = EGL_NO_DISPLAY;
291 void MultiThreadedTest::barrier (void)
294 const deInt32 waiters = deAtomicIncrement32(&m_barrierWaiters);
296 if (waiters == m_threadCount)
298 m_barrierSemaphore2.decrement();
299 m_barrierSemaphore1.increment();
303 m_barrierSemaphore1.decrement();
304 m_barrierSemaphore1.increment();
309 const deInt32 waiters = deAtomicDecrement32(&m_barrierWaiters);
313 m_barrierSemaphore1.decrement();
314 m_barrierSemaphore2.increment();
318 m_barrierSemaphore2.decrement();
319 m_barrierSemaphore2.increment();
323 // Barrier was released due an error in other thread
324 if (!m_ok || !m_supported)
325 throw TestThread::TestStop();
328 TestCase::IterateResult MultiThreadedTest::iterate (void)
332 m_testCtx.getLog() << tcu::TestLog::Message << "Thread timeout limit: " << m_timeoutUs << "us" << tcu::TestLog::EndMessage;
338 m_threads.reserve(m_threadCount);
340 for (int threadNdx = 0; threadNdx < m_threadCount; threadNdx++)
341 m_threads.push_back(new TestThread(*this, threadNdx));
343 m_startTimeUs = deGetMicroseconds();
346 for (int threadNdx = 0; threadNdx < (int)m_threads.size(); threadNdx++)
347 m_threads[threadNdx]->start();
349 m_initialized = true;
353 for (int threadNdx = 0; threadNdx < (int)m_threads.size(); threadNdx++)
355 if (m_threads[threadNdx]->getStatus() != TestThread::THREADSTATUS_RUNNING)
359 if (readyCount == m_threadCount)
362 for (int threadNdx = 0; threadNdx < (int)m_threads.size(); threadNdx++)
363 m_threads[threadNdx]->join();
367 vector<int> messageNdx;
369 messageNdx.resize(m_threads.size(), 0);
373 int nextThreadNdx = -1;
374 deUint64 nextThreadTimeUs = 0;
376 for (int threadNdx = 0; threadNdx < (int)m_threads.size(); threadNdx++)
378 if (messageNdx[threadNdx] >= (int)m_threads[threadNdx]->getLog().getMessages().size())
381 if (nextThreadNdx == -1 || nextThreadTimeUs > m_threads[threadNdx]->getLog().getMessages()[messageNdx[threadNdx]].timeUs)
383 nextThreadNdx = threadNdx;
384 nextThreadTimeUs = m_threads[threadNdx]->getLog().getMessages()[messageNdx[threadNdx]].timeUs;
388 if (nextThreadNdx == -1)
391 m_testCtx.getLog() << tcu::TestLog::Message << "[" << (nextThreadTimeUs - m_startTimeUs) << "] (" << nextThreadNdx << ") " << m_threads[nextThreadNdx]->getLog().getMessages()[messageNdx[nextThreadNdx]].msg << tcu::TestLog::EndMessage;
393 messageNdx[nextThreadNdx]++;
398 for (int threadNdx = 0; threadNdx < (int)m_threads.size(); threadNdx++)
399 delete m_threads[threadNdx];
407 m_testCtx.setTestResult(QP_TEST_RESULT_NOT_SUPPORTED, "Not Supported");
409 m_testCtx.setTestResult(QP_TEST_RESULT_PASS, "Pass");
412 m_testCtx.setTestResult(QP_TEST_RESULT_FAIL, "Fail");
419 const deUint64 currentTimeUs = deGetMicroseconds();
421 if (currentTimeUs - m_startTimeUs > m_timeoutUs)
425 vector<int> messageNdx;
427 messageNdx.resize(m_threads.size(), 0);
431 int nextThreadNdx = -1;
432 deUint64 nextThreadTimeUs = 0;
434 for (int threadNdx = 0; threadNdx < (int)m_threads.size(); threadNdx++)
436 if (messageNdx[threadNdx] >= (int)m_threads[threadNdx]->getLog().getMessages().size())
439 if (nextThreadNdx == -1 || nextThreadTimeUs > m_threads[threadNdx]->getLog().getMessages()[messageNdx[threadNdx]].timeUs)
441 nextThreadNdx = threadNdx;
442 nextThreadTimeUs = m_threads[threadNdx]->getLog().getMessages()[messageNdx[threadNdx]].timeUs;
446 if (nextThreadNdx == -1)
449 m_testCtx.getLog() << tcu::TestLog::Message << "[" << (nextThreadTimeUs - m_startTimeUs) << "] (" << nextThreadNdx << ") " << m_threads[nextThreadNdx]->getLog().getMessages()[messageNdx[nextThreadNdx]].msg << tcu::TestLog::EndMessage;
451 messageNdx[nextThreadNdx]++;
455 m_testCtx.getLog() << tcu::TestLog::Message << "[" << (currentTimeUs - m_startTimeUs) << "] (-) Timeout, Limit: " << m_timeoutUs << "us" << tcu::TestLog::EndMessage;
456 m_testCtx.getLog() << tcu::TestLog::Message << "[" << (currentTimeUs - m_startTimeUs) << "] (-) Trying to perform resource cleanup..." << tcu::TestLog::EndMessage;
458 m_testCtx.setTestResult(QP_TEST_RESULT_FAIL, "Fail");
472 const char* configAttributeToString (EGLint e)
476 case EGL_BUFFER_SIZE: return "EGL_BUFFER_SIZE";
477 case EGL_RED_SIZE: return "EGL_RED_SIZE";
478 case EGL_GREEN_SIZE: return "EGL_GREEN_SIZE";
479 case EGL_BLUE_SIZE: return "EGL_BLUE_SIZE";
480 case EGL_LUMINANCE_SIZE: return "EGL_LUMINANCE_SIZE";
481 case EGL_ALPHA_SIZE: return "EGL_ALPHA_SIZE";
482 case EGL_ALPHA_MASK_SIZE: return "EGL_ALPHA_MASK_SIZE";
483 case EGL_BIND_TO_TEXTURE_RGB: return "EGL_BIND_TO_TEXTURE_RGB";
484 case EGL_BIND_TO_TEXTURE_RGBA: return "EGL_BIND_TO_TEXTURE_RGBA";
485 case EGL_COLOR_BUFFER_TYPE: return "EGL_COLOR_BUFFER_TYPE";
486 case EGL_CONFIG_CAVEAT: return "EGL_CONFIG_CAVEAT";
487 case EGL_CONFIG_ID: return "EGL_CONFIG_ID";
488 case EGL_CONFORMANT: return "EGL_CONFORMANT";
489 case EGL_DEPTH_SIZE: return "EGL_DEPTH_SIZE";
490 case EGL_LEVEL: return "EGL_LEVEL";
491 case EGL_MAX_PBUFFER_WIDTH: return "EGL_MAX_PBUFFER_WIDTH";
492 case EGL_MAX_PBUFFER_HEIGHT: return "EGL_MAX_PBUFFER_HEIGHT";
493 case EGL_MAX_PBUFFER_PIXELS: return "EGL_MAX_PBUFFER_PIXELS";
494 case EGL_MAX_SWAP_INTERVAL: return "EGL_MAX_SWAP_INTERVAL";
495 case EGL_MIN_SWAP_INTERVAL: return "EGL_MIN_SWAP_INTERVAL";
496 case EGL_NATIVE_RENDERABLE: return "EGL_NATIVE_RENDERABLE";
497 case EGL_NATIVE_VISUAL_ID: return "EGL_NATIVE_VISUAL_ID";
498 case EGL_NATIVE_VISUAL_TYPE: return "EGL_NATIVE_VISUAL_TYPE";
499 case EGL_RENDERABLE_TYPE: return "EGL_RENDERABLE_TYPE";
500 case EGL_SAMPLE_BUFFERS: return "EGL_SAMPLE_BUFFERS";
501 case EGL_SAMPLES: return "EGL_SAMPLES";
502 case EGL_STENCIL_SIZE: return "EGL_STENCIL_SIZE";
503 case EGL_SURFACE_TYPE: return "EGL_SURFACE_TYPE";
504 case EGL_TRANSPARENT_TYPE: return "EGL_TRANSPARENT_TYPE";
505 case EGL_TRANSPARENT_RED_VALUE: return "EGL_TRANSPARENT_RED_VALUE";
506 case EGL_TRANSPARENT_GREEN_VALUE: return "EGL_TRANSPARENT_GREEN_VALUE";
507 case EGL_TRANSPARENT_BLUE_VALUE: return "EGL_TRANSPARENT_BLUE_VALUE";
508 default: return "<Unknown>";
514 class MultiThreadedConfigTest : public MultiThreadedTest
517 MultiThreadedConfigTest (EglTestContext& context, const char* name, const char* description, int getConfigs, int chooseConfigs, int query);
518 bool runThread (TestThread& thread);
521 const int m_getConfigs;
522 const int m_chooseConfigs;
526 MultiThreadedConfigTest::MultiThreadedConfigTest (EglTestContext& context, const char* name, const char* description, int getConfigs, int chooseConfigs, int query)
527 : MultiThreadedTest (context, name, description, 2, 20000000/*us = 20s*/) // \todo [mika] Set timeout to something relevant to frameworks timeout?
528 , m_getConfigs (getConfigs)
529 , m_chooseConfigs (chooseConfigs)
534 bool MultiThreadedConfigTest::runThread (TestThread& thread)
536 const Library& egl = getLibrary();
537 de::Random rnd (deInt32Hash(thread.getId() + 10435));
538 vector<EGLConfig> configs;
542 for (int getConfigsNdx = 0; getConfigsNdx < m_getConfigs; getConfigsNdx++)
546 // Get number of configs
550 result = egl.getConfigs(m_display, NULL, 0, &configCount);
551 thread.getLog() << ThreadLog::BeginMessage << result << " = eglGetConfigs(" << m_display << ", NULL, 0, " << configCount << ")" << ThreadLog::EndMessage;
552 EGLU_CHECK_MSG(egl, "eglGetConfigs()");
558 configs.resize(configs.size() + configCount);
561 if (configCount != 0)
565 result = egl.getConfigs(m_display, &(configs[configs.size() - configCount]), configCount, &configCount);
566 thread.getLog() << ThreadLog::BeginMessage << result << " = eglGetConfigs(" << m_display << ", &configs' " << configCount << ", " << configCount << ")" << ThreadLog::EndMessage;
567 EGLU_CHECK_MSG(egl, "eglGetConfigs()");
573 // Pop configs to stop config list growing
574 if (configs.size() > 40)
576 configs.erase(configs.begin() + 40, configs.end());
580 const int popCount = rnd.getInt(0, (int)(configs.size()-2));
582 configs.erase(configs.begin() + (configs.size() - popCount), configs.end());
586 for (int chooseConfigsNdx = 0; chooseConfigsNdx < m_chooseConfigs; chooseConfigsNdx++)
590 static const EGLint attribList[] = {
594 // Get number of configs
598 result = egl.chooseConfig(m_display, attribList, NULL, 0, &configCount);
599 thread.getLog() << ThreadLog::BeginMessage << result << " = eglChooseConfig(" << m_display << ", { EGL_NONE }, NULL, 0, " << configCount << ")" << ThreadLog::EndMessage;
600 EGLU_CHECK_MSG(egl, "eglChooseConfig()");
606 configs.resize(configs.size() + configCount);
609 if (configCount != 0)
613 result = egl.chooseConfig(m_display, attribList, &(configs[configs.size() - configCount]), configCount, &configCount);
614 thread.getLog() << ThreadLog::BeginMessage << result << " = eglChooseConfig(" << m_display << ", { EGL_NONE }, &configs, " << configCount << ", " << configCount << ")" << ThreadLog::EndMessage;
615 EGLU_CHECK_MSG(egl, "eglChooseConfig()");
621 // Pop configs to stop config list growing
622 if (configs.size() > 40)
624 configs.erase(configs.begin() + 40, configs.end());
628 const int popCount = rnd.getInt(0, (int)(configs.size()-2));
630 configs.erase(configs.begin() + (configs.size() - popCount), configs.end());
635 // Perform queries on configs
636 static const EGLint attributes[] =
645 EGL_BIND_TO_TEXTURE_RGB,
646 EGL_BIND_TO_TEXTURE_RGBA,
647 EGL_COLOR_BUFFER_TYPE,
653 EGL_MAX_PBUFFER_WIDTH,
654 EGL_MAX_PBUFFER_HEIGHT,
655 EGL_MAX_PBUFFER_PIXELS,
656 EGL_MAX_SWAP_INTERVAL,
657 EGL_MIN_SWAP_INTERVAL,
658 EGL_NATIVE_RENDERABLE,
659 EGL_NATIVE_VISUAL_ID,
660 EGL_NATIVE_VISUAL_TYPE,
666 EGL_TRANSPARENT_TYPE,
667 EGL_TRANSPARENT_RED_VALUE,
668 EGL_TRANSPARENT_GREEN_VALUE,
669 EGL_TRANSPARENT_BLUE_VALUE
672 for (int queryNdx = 0; queryNdx < m_query; queryNdx++)
674 const EGLint attribute = attributes[rnd.getInt(0, DE_LENGTH_OF_ARRAY(attributes)-1)];
675 EGLConfig config = configs[rnd.getInt(0, (int)(configs.size()-1))];
679 result = egl.getConfigAttrib(m_display, config, attribute, &value);
680 thread.getLog() << ThreadLog::BeginMessage << result << " = eglGetConfigAttrib(" << m_display << ", " << config << ", " << configAttributeToString(attribute) << ", " << value << ")" << ThreadLog::EndMessage;
681 EGLU_CHECK_MSG(egl, "eglGetConfigAttrib()");
691 class MultiThreadedObjectTest : public MultiThreadedTest
696 TYPE_PBUFFER = (1<<0),
697 TYPE_PIXMAP = (1<<1),
698 TYPE_WINDOW = (1<<2),
699 TYPE_SINGLE_WINDOW = (1<<3),
700 TYPE_CONTEXT = (1<<4)
703 MultiThreadedObjectTest (EglTestContext& context, const char* name, const char* description, deUint32 types);
704 ~MultiThreadedObjectTest (void);
706 virtual void deinit (void);
708 bool runThread (TestThread& thread);
710 void createDestroyObjects (TestThread& thread, int count);
711 void pushObjectsToShared (TestThread& thread);
712 void pullObjectsFromShared (TestThread& thread, int pbufferCount, int pixmapCount, int windowCount, int contextCount);
713 void querySetSharedObjects (TestThread& thread, int count);
714 void destroyObjects (TestThread& thread);
722 volatile deUint32 m_hasWindow;
724 vector<pair<eglu::NativePixmap*, EGLSurface> > m_sharedNativePixmaps;
725 vector<pair<eglu::NativePixmap*, EGLSurface> > m_nativePixmaps0;
726 vector<pair<eglu::NativePixmap*, EGLSurface> > m_nativePixmaps1;
728 vector<pair<eglu::NativeWindow*, EGLSurface> > m_sharedNativeWindows;
729 vector<pair<eglu::NativeWindow*, EGLSurface> > m_nativeWindows0;
730 vector<pair<eglu::NativeWindow*, EGLSurface> > m_nativeWindows1;
732 vector<EGLSurface> m_sharedPbuffers;
733 vector<EGLSurface> m_pbuffers0;
734 vector<EGLSurface> m_pbuffers1;
736 vector<EGLContext> m_sharedContexts;
737 vector<EGLContext> m_contexts0;
738 vector<EGLContext> m_contexts1;
741 MultiThreadedObjectTest::MultiThreadedObjectTest (EglTestContext& context, const char* name, const char* description, deUint32 type)
742 : MultiThreadedTest (context, name, description, 2, 20000000/*us = 20s*/) // \todo [mika] Set timeout to something relevant to frameworks timeout?
746 , m_types ((Type)type)
751 MultiThreadedObjectTest::~MultiThreadedObjectTest (void)
756 void MultiThreadedObjectTest::deinit (void)
758 const Library& egl = getLibrary();
761 for (int pbufferNdx = 0; pbufferNdx < (int)m_pbuffers0.size(); pbufferNdx++)
763 if (m_pbuffers0[pbufferNdx] != EGL_NO_SURFACE)
765 egl.destroySurface(m_display, m_pbuffers0[pbufferNdx]);
766 EGLU_CHECK_MSG(egl, "eglDestroySurface()");
767 m_pbuffers0[pbufferNdx] = EGL_NO_SURFACE;
772 for (int pbufferNdx = 0; pbufferNdx < (int)m_pbuffers1.size(); pbufferNdx++)
774 if (m_pbuffers1[pbufferNdx] != EGL_NO_SURFACE)
776 egl.destroySurface(m_display, m_pbuffers1[pbufferNdx]);
777 EGLU_CHECK_MSG(egl, "eglDestroySurface()");
778 m_pbuffers1[pbufferNdx] = EGL_NO_SURFACE;
783 for (int pbufferNdx = 0; pbufferNdx < (int)m_sharedPbuffers.size(); pbufferNdx++)
785 if (m_sharedPbuffers[pbufferNdx] != EGL_NO_SURFACE)
787 egl.destroySurface(m_display, m_sharedPbuffers[pbufferNdx]);
788 EGLU_CHECK_MSG(egl, "eglDestroySurface()");
789 m_sharedPbuffers[pbufferNdx] = EGL_NO_SURFACE;
792 m_sharedPbuffers.clear();
794 for (int contextNdx = 0; contextNdx < (int)m_sharedContexts.size(); contextNdx++)
796 if (m_sharedContexts[contextNdx] != EGL_NO_CONTEXT)
798 egl.destroyContext(m_display, m_sharedContexts[contextNdx]);
799 EGLU_CHECK_MSG(egl, "eglDestroyContext()");
800 m_sharedContexts[contextNdx] = EGL_NO_CONTEXT;
803 m_sharedContexts.clear();
805 for (int contextNdx = 0; contextNdx < (int)m_contexts0.size(); contextNdx++)
807 if (m_contexts0[contextNdx] != EGL_NO_CONTEXT)
809 egl.destroyContext(m_display, m_contexts0[contextNdx]);
810 EGLU_CHECK_MSG(egl, "eglDestroyContext()");
811 m_contexts0[contextNdx] = EGL_NO_CONTEXT;
816 for (int contextNdx = 0; contextNdx < (int)m_contexts1.size(); contextNdx++)
818 if (m_contexts1[contextNdx] != EGL_NO_CONTEXT)
820 egl.destroyContext(m_display, m_contexts1[contextNdx]);
821 EGLU_CHECK_MSG(egl, "eglDestroyContext()");
822 m_contexts1[contextNdx] = EGL_NO_CONTEXT;
828 for (int pixmapNdx = 0; pixmapNdx < (int)m_nativePixmaps0.size(); pixmapNdx++)
830 if (m_nativePixmaps0[pixmapNdx].second != EGL_NO_SURFACE)
831 EGLU_CHECK_CALL(egl, destroySurface(m_display, m_nativePixmaps0[pixmapNdx].second));
833 m_nativePixmaps0[pixmapNdx].second = EGL_NO_SURFACE;
834 delete m_nativePixmaps0[pixmapNdx].first;
835 m_nativePixmaps0[pixmapNdx].first = NULL;
837 m_nativePixmaps0.clear();
839 for (int pixmapNdx = 0; pixmapNdx < (int)m_nativePixmaps1.size(); pixmapNdx++)
841 if (m_nativePixmaps1[pixmapNdx].second != EGL_NO_SURFACE)
842 EGLU_CHECK_CALL(egl, destroySurface(m_display, m_nativePixmaps1[pixmapNdx].second));
844 m_nativePixmaps1[pixmapNdx].second = EGL_NO_SURFACE;
845 delete m_nativePixmaps1[pixmapNdx].first;
846 m_nativePixmaps1[pixmapNdx].first = NULL;
848 m_nativePixmaps1.clear();
850 for (int pixmapNdx = 0; pixmapNdx < (int)m_sharedNativePixmaps.size(); pixmapNdx++)
852 if (m_sharedNativePixmaps[pixmapNdx].second != EGL_NO_SURFACE)
853 EGLU_CHECK_CALL(egl, destroySurface(m_display, m_sharedNativePixmaps[pixmapNdx].second));
855 m_sharedNativePixmaps[pixmapNdx].second = EGL_NO_SURFACE;
856 delete m_sharedNativePixmaps[pixmapNdx].first;
857 m_sharedNativePixmaps[pixmapNdx].first = NULL;
859 m_sharedNativePixmaps.clear();
862 for (int windowNdx = 0; windowNdx < (int)m_nativeWindows1.size(); windowNdx++)
864 if (m_nativeWindows1[windowNdx].second != EGL_NO_SURFACE)
865 EGLU_CHECK_CALL(egl, destroySurface(m_display, m_nativeWindows1[windowNdx].second));
867 m_nativeWindows1[windowNdx].second = EGL_NO_SURFACE;
868 delete m_nativeWindows1[windowNdx].first;
869 m_nativeWindows1[windowNdx].first = NULL;
871 m_nativeWindows1.clear();
873 for (int windowNdx = 0; windowNdx < (int)m_nativeWindows0.size(); windowNdx++)
875 if (m_nativeWindows0[windowNdx].second != EGL_NO_SURFACE)
876 EGLU_CHECK_CALL(egl, destroySurface(m_display, m_nativeWindows0[windowNdx].second));
878 m_nativeWindows0[windowNdx].second = EGL_NO_SURFACE;
879 delete m_nativeWindows0[windowNdx].first;
880 m_nativeWindows0[windowNdx].first = NULL;
882 m_nativeWindows0.clear();
884 for (int windowNdx = 0; windowNdx < (int)m_sharedNativeWindows.size(); windowNdx++)
886 if (m_sharedNativeWindows[windowNdx].second != EGL_NO_SURFACE)
887 EGLU_CHECK_CALL(egl, destroySurface(m_display, m_sharedNativeWindows[windowNdx].second));
889 m_sharedNativeWindows[windowNdx].second = EGL_NO_SURFACE;
890 delete m_sharedNativeWindows[windowNdx].first;
891 m_sharedNativeWindows[windowNdx].first = NULL;
893 m_sharedNativeWindows.clear();
895 MultiThreadedTest::deinit();
898 bool MultiThreadedObjectTest::runThread (TestThread& thread)
900 const Library& egl = getLibrary();
902 if (thread.getId() == 0)
904 EGLint surfaceTypes = 0;
906 if ((m_types & TYPE_WINDOW) != 0)
907 surfaceTypes |= EGL_WINDOW_BIT;
909 if ((m_types & TYPE_PBUFFER) != 0)
910 surfaceTypes |= EGL_PBUFFER_BIT;
912 if ((m_types & TYPE_PIXMAP) != 0)
913 surfaceTypes |= EGL_PIXMAP_BIT;
916 EGLint attribList[] =
918 EGL_SURFACE_TYPE, surfaceTypes,
919 EGL_RENDERABLE_TYPE, EGL_OPENGL_ES2_BIT,
923 EGLU_CHECK_CALL(egl, chooseConfig(m_display, attribList, &m_config, 1, &configCount));
925 if (configCount == 0)
926 TCU_THROW(NotSupportedError, "No usable config found");
931 // Create / Destroy Objects
932 if ((m_types & TYPE_SINGLE_WINDOW) != 0 && (m_types & TYPE_PBUFFER) == 0 && (m_types & TYPE_PIXMAP) == 0 && (m_types & TYPE_CONTEXT) == 0)
934 if (thread.getId() == 0)
935 createDestroyObjects(thread, 1);
938 createDestroyObjects(thread, 100);
940 // Push first threads objects to shared
941 if (thread.getId() == 0)
942 pushObjectsToShared(thread);
946 // Push second threads objects to shared
947 if (thread.getId() == 1)
948 pushObjectsToShared(thread);
952 // Make queries from shared surfaces
953 querySetSharedObjects(thread, 100);
957 // Pull surfaces for first thread from shared surfaces
958 if (thread.getId() == 0)
959 pullObjectsFromShared(thread, (int)(m_sharedPbuffers.size()/2), (int)(m_sharedNativePixmaps.size()/2), (int)(m_sharedNativeWindows.size()/2), (int)(m_sharedContexts.size()/2));
963 // Pull surfaces for second thread from shared surfaces
964 if (thread.getId() == 1)
965 pullObjectsFromShared(thread, (int)m_sharedPbuffers.size(), (int)m_sharedNativePixmaps.size(), (int)m_sharedNativeWindows.size(), (int)m_sharedContexts.size());
969 // Create / Destroy Objects
970 if ((m_types & TYPE_SINGLE_WINDOW) == 0)
971 createDestroyObjects(thread, 100);
974 destroyObjects(thread);
979 void MultiThreadedObjectTest::createDestroyObjects (TestThread& thread, int count)
981 const Library& egl = getLibrary();
982 de::Random& rnd = (thread.getId() == 0 ? m_rnd0 : m_rnd1);
983 vector<EGLSurface>& pbuffers = (thread.getId() == 0 ? m_pbuffers0 : m_pbuffers1);
984 vector<pair<eglu::NativeWindow*, EGLSurface> >& windows = (thread.getId() == 0 ? m_nativeWindows0 : m_nativeWindows1);
985 vector<pair<eglu::NativePixmap*, EGLSurface> >& pixmaps = (thread.getId() == 0 ? m_nativePixmaps0 : m_nativePixmaps1);
986 vector<EGLContext>& contexts = (thread.getId() == 0 ? m_contexts0 : m_contexts1);
987 set<Type> objectTypes;
989 if ((m_types & TYPE_PBUFFER) != 0)
990 objectTypes.insert(TYPE_PBUFFER);
992 if ((m_types & TYPE_PIXMAP) != 0)
993 objectTypes.insert(TYPE_PIXMAP);
995 if ((m_types & TYPE_WINDOW) != 0)
996 objectTypes.insert(TYPE_WINDOW);
998 if ((m_types & TYPE_CONTEXT) != 0)
999 objectTypes.insert(TYPE_CONTEXT);
1001 for (int createDestroyNdx = 0; createDestroyNdx < count; createDestroyNdx++)
1006 if (pbuffers.size() > 5 && ((m_types & TYPE_PBUFFER) != 0))
1009 type = TYPE_PBUFFER;
1011 else if (windows.size() > 5 && ((m_types & TYPE_WINDOW) != 0))
1016 else if (pixmaps.size() > 5 && ((m_types & TYPE_PIXMAP) != 0))
1021 else if (contexts.size() > 5 && ((m_types & TYPE_CONTEXT) != 0))
1024 type = TYPE_CONTEXT;
1026 else if (pbuffers.size() < 3 && ((m_types & TYPE_PBUFFER) != 0))
1029 type = TYPE_PBUFFER;
1031 else if (pixmaps.size() < 3 && ((m_types & TYPE_PIXMAP) != 0))
1036 else if (contexts.size() < 3 && ((m_types & TYPE_CONTEXT) != 0))
1039 type = TYPE_CONTEXT;
1041 else if (windows.size() < 3 && ((m_types & TYPE_WINDOW) != 0) && ((m_types & TYPE_SINGLE_WINDOW) == 0))
1046 else if (windows.empty() && (m_hasWindow == 0) && ((m_types & TYPE_WINDOW) != 0) && ((m_types & TYPE_SINGLE_WINDOW) != 0))
1053 create = rnd.getBool();
1055 if (!create && windows.empty())
1056 objectTypes.erase(TYPE_WINDOW);
1058 type = rnd.choose<Type>(objectTypes.begin(), objectTypes.end());
1069 const EGLint attributes[] =
1077 surface = egl.createPbufferSurface(m_display, m_config, attributes);
1078 thread.getLog() << ThreadLog::BeginMessage << surface << " = eglCreatePbufferSurface(" << m_display << ", " << m_config << ", { EGL_WIDTH, 64, EGL_HEIGHT, 64, EGL_NONE })" << ThreadLog::EndMessage;
1079 EGLU_CHECK_MSG(egl, "eglCreatePbufferSurface()");
1081 pbuffers.push_back(surface);
1088 const eglu::NativeWindowFactory& windowFactory = eglu::selectNativeWindowFactory(m_eglTestCtx.getNativeDisplayFactory(), m_testCtx.getCommandLine());
1090 if ((m_types & TYPE_SINGLE_WINDOW) != 0)
1092 if (deAtomicCompareExchange32(&m_hasWindow, 0, 1) == 0)
1094 eglu::NativeWindow* window = DE_NULL;
1095 EGLSurface surface = EGL_NO_SURFACE;
1099 window = windowFactory.createWindow(&m_eglTestCtx.getNativeDisplay(), m_display, m_config, DE_NULL, eglu::WindowParams(64, 64, eglu::parseWindowVisibility(m_testCtx.getCommandLine())));
1100 surface = eglu::createWindowSurface(m_eglTestCtx.getNativeDisplay(), *window, m_display, m_config, DE_NULL);
1102 thread.getLog() << ThreadLog::BeginMessage << surface << " = eglCreateWindowSurface()" << ThreadLog::EndMessage;
1103 windows.push_back(std::make_pair(window, surface));
1105 catch (const std::exception&)
1107 if (surface != EGL_NO_SURFACE)
1108 EGLU_CHECK_CALL(egl, destroySurface(m_display, surface));
1121 eglu::NativeWindow* window = DE_NULL;
1122 EGLSurface surface = EGL_NO_SURFACE;
1126 window = windowFactory.createWindow(&m_eglTestCtx.getNativeDisplay(), m_display, m_config, DE_NULL, eglu::WindowParams(64, 64, eglu::parseWindowVisibility(m_testCtx.getCommandLine())));
1127 surface = eglu::createWindowSurface(m_eglTestCtx.getNativeDisplay(), *window, m_display, m_config, DE_NULL);
1129 thread.getLog() << ThreadLog::BeginMessage << surface << " = eglCreateWindowSurface()" << ThreadLog::EndMessage;
1130 windows.push_back(std::make_pair(window, surface));
1132 catch (const std::exception&)
1134 if (surface != EGL_NO_SURFACE)
1135 EGLU_CHECK_CALL(egl, destroySurface(m_display, surface));
1145 const eglu::NativePixmapFactory& pixmapFactory = eglu::selectNativePixmapFactory(m_eglTestCtx.getNativeDisplayFactory(), m_testCtx.getCommandLine());
1146 eglu::NativePixmap* pixmap = DE_NULL;
1147 EGLSurface surface = EGL_NO_SURFACE;
1151 pixmap = pixmapFactory.createPixmap(&m_eglTestCtx.getNativeDisplay(), m_display, m_config, DE_NULL, 64, 64);
1152 surface = eglu::createPixmapSurface(m_eglTestCtx.getNativeDisplay(), *pixmap, m_display, m_config, DE_NULL);
1154 thread.getLog() << ThreadLog::BeginMessage << surface << " = eglCreatePixmapSurface()" << ThreadLog::EndMessage;
1155 pixmaps.push_back(std::make_pair(pixmap, surface));
1157 catch (const std::exception&)
1159 if (surface != EGL_NO_SURFACE)
1160 EGLU_CHECK_CALL(egl, destroySurface(m_display, surface));
1171 EGLU_CHECK_CALL(egl, bindAPI(EGL_OPENGL_ES_API));
1172 thread.getLog() << ThreadLog::BeginMessage << "eglBindAPI(EGL_OPENGL_ES_API)" << ThreadLog::EndMessage;
1174 const EGLint attributes[] =
1176 EGL_CONTEXT_CLIENT_VERSION, 2,
1180 context = egl.createContext(m_display, m_config, EGL_NO_CONTEXT, attributes);
1181 thread.getLog() << ThreadLog::BeginMessage << context << " = eglCreateContext(" << m_display << ", " << m_config << ", EGL_NO_CONTEXT, { EGL_CONTEXT_CLIENT_VERSION, 2, EGL_NONE })" << ThreadLog::EndMessage;
1182 EGLU_CHECK_MSG(egl, "eglCreateContext()");
1183 contexts.push_back(context);
1197 const int pbufferNdx = rnd.getInt(0, (int)(pbuffers.size()-1));
1200 result = egl.destroySurface(m_display, pbuffers[pbufferNdx]);
1201 thread.getLog() << ThreadLog::BeginMessage << result << " = eglDestroySurface(" << m_display << ", " << pbuffers[pbufferNdx] << ")" << ThreadLog::EndMessage;
1202 EGLU_CHECK_MSG(egl, "eglDestroySurface()");
1204 pbuffers.erase(pbuffers.begin() + pbufferNdx);
1211 const int windowNdx = rnd.getInt(0, (int)(windows.size()-1));
1213 thread.getLog() << ThreadLog::BeginMessage << "eglDestroySurface(" << m_display << ", " << windows[windowNdx].second << ")" << ThreadLog::EndMessage;
1215 EGLU_CHECK_CALL(egl, destroySurface(m_display, windows[windowNdx].second));
1216 windows[windowNdx].second = EGL_NO_SURFACE;
1217 delete windows[windowNdx].first;
1218 windows[windowNdx].first = DE_NULL;
1219 windows.erase(windows.begin() + windowNdx);
1221 if ((m_types & TYPE_SINGLE_WINDOW) != 0)
1229 const int pixmapNdx = rnd.getInt(0, (int)(pixmaps.size()-1));
1231 thread.getLog() << ThreadLog::BeginMessage << "eglDestroySurface(" << m_display << ", " << pixmaps[pixmapNdx].second << ")" << ThreadLog::EndMessage;
1232 EGLU_CHECK_CALL(egl, destroySurface(m_display, pixmaps[pixmapNdx].second));
1233 pixmaps[pixmapNdx].second = EGL_NO_SURFACE;
1234 delete pixmaps[pixmapNdx].first;
1235 pixmaps[pixmapNdx].first = DE_NULL;
1236 pixmaps.erase(pixmaps.begin() + pixmapNdx);
1243 const int contextNdx = rnd.getInt(0, (int)(contexts.size()-1));
1245 EGLU_CHECK_CALL(egl, destroyContext(m_display, contexts[contextNdx]));
1246 thread.getLog() << ThreadLog::BeginMessage << "eglDestroyContext(" << m_display << ", " << contexts[contextNdx] << ")" << ThreadLog::EndMessage;
1247 contexts.erase(contexts.begin() + contextNdx);
1260 void MultiThreadedObjectTest::pushObjectsToShared (TestThread& thread)
1262 vector<EGLSurface>& pbuffers = (thread.getId() == 0 ? m_pbuffers0 : m_pbuffers1);
1263 vector<pair<eglu::NativeWindow*, EGLSurface> >& windows = (thread.getId() == 0 ? m_nativeWindows0 : m_nativeWindows1);
1264 vector<pair<eglu::NativePixmap*, EGLSurface> >& pixmaps = (thread.getId() == 0 ? m_nativePixmaps0 : m_nativePixmaps1);
1265 vector<EGLContext>& contexts = (thread.getId() == 0 ? m_contexts0 : m_contexts1);
1267 for (int pbufferNdx = 0; pbufferNdx < (int)pbuffers.size(); pbufferNdx++)
1268 m_sharedPbuffers.push_back(pbuffers[pbufferNdx]);
1272 for (int windowNdx = 0; windowNdx < (int)windows.size(); windowNdx++)
1273 m_sharedNativeWindows.push_back(windows[windowNdx]);
1277 for (int pixmapNdx = 0; pixmapNdx < (int)pixmaps.size(); pixmapNdx++)
1278 m_sharedNativePixmaps.push_back(pixmaps[pixmapNdx]);
1282 for (int contextNdx = 0; contextNdx < (int)contexts.size(); contextNdx++)
1283 m_sharedContexts.push_back(contexts[contextNdx]);
1288 void MultiThreadedObjectTest::pullObjectsFromShared (TestThread& thread, int pbufferCount, int pixmapCount, int windowCount, int contextCount)
1290 de::Random& rnd = (thread.getId() == 0 ? m_rnd0 : m_rnd1);
1291 vector<EGLSurface>& pbuffers = (thread.getId() == 0 ? m_pbuffers0 : m_pbuffers1);
1292 vector<pair<eglu::NativeWindow*, EGLSurface> >& windows = (thread.getId() == 0 ? m_nativeWindows0 : m_nativeWindows1);
1293 vector<pair<eglu::NativePixmap*, EGLSurface> >& pixmaps = (thread.getId() == 0 ? m_nativePixmaps0 : m_nativePixmaps1);
1294 vector<EGLContext>& contexts = (thread.getId() == 0 ? m_contexts0 : m_contexts1);
1296 for (int pbufferNdx = 0; pbufferNdx < pbufferCount; pbufferNdx++)
1298 const int ndx = rnd.getInt(0, (int)(m_sharedPbuffers.size()-1));
1300 pbuffers.push_back(m_sharedPbuffers[ndx]);
1301 m_sharedPbuffers.erase(m_sharedPbuffers.begin() + ndx);
1304 for (int pixmapNdx = 0; pixmapNdx < pixmapCount; pixmapNdx++)
1306 const int ndx = rnd.getInt(0, (int)(m_sharedNativePixmaps.size()-1));
1308 pixmaps.push_back(m_sharedNativePixmaps[ndx]);
1309 m_sharedNativePixmaps.erase(m_sharedNativePixmaps.begin() + ndx);
1312 for (int windowNdx = 0; windowNdx < windowCount; windowNdx++)
1314 const int ndx = rnd.getInt(0, (int)(m_sharedNativeWindows.size()-1));
1316 windows.push_back(m_sharedNativeWindows[ndx]);
1317 m_sharedNativeWindows.erase(m_sharedNativeWindows.begin() + ndx);
1320 for (int contextNdx = 0; contextNdx < contextCount; contextNdx++)
1322 const int ndx = rnd.getInt(0, (int)(m_sharedContexts.size()-1));
1324 contexts.push_back(m_sharedContexts[ndx]);
1325 m_sharedContexts.erase(m_sharedContexts.begin() + ndx);
1329 void MultiThreadedObjectTest::querySetSharedObjects (TestThread& thread, int count)
1331 const Library& egl = getLibrary();
1332 de::Random& rnd = (thread.getId() == 0 ? m_rnd0 : m_rnd1);
1333 vector<Type> objectTypes;
1335 if ((m_types & TYPE_PBUFFER) != 0)
1336 objectTypes.push_back(TYPE_PBUFFER);
1338 if ((m_types & TYPE_PIXMAP) != 0)
1339 objectTypes.push_back(TYPE_PIXMAP);
1341 if (!m_sharedNativeWindows.empty() && (m_types & TYPE_WINDOW) != 0)
1342 objectTypes.push_back(TYPE_WINDOW);
1344 if ((m_types & TYPE_CONTEXT) != 0)
1345 objectTypes.push_back(TYPE_CONTEXT);
1347 for (int queryNdx = 0; queryNdx < count; queryNdx++)
1349 const Type type = rnd.choose<Type>(objectTypes.begin(), objectTypes.end());
1350 EGLSurface surface = EGL_NO_SURFACE;
1351 EGLContext context = EGL_NO_CONTEXT;
1356 surface = m_sharedPbuffers[rnd.getInt(0, (int)(m_sharedPbuffers.size()-1))];
1360 surface = m_sharedNativePixmaps[rnd.getInt(0, (int)(m_sharedNativePixmaps.size()-1))].second;
1364 surface = m_sharedNativeWindows[rnd.getInt(0, (int)(m_sharedNativeWindows.size()-1))].second;
1368 context = m_sharedContexts[rnd.getInt(0, (int)(m_sharedContexts.size()-1))];
1375 if (surface != EGL_NO_SURFACE)
1377 static const EGLint queryAttributes[] =
1379 EGL_LARGEST_PBUFFER,
1384 const EGLint attribute = queryAttributes[rnd.getInt(0, DE_LENGTH_OF_ARRAY(queryAttributes) - 1)];
1388 result = egl.querySurface(m_display, surface, attribute, &value);
1389 thread.getLog() << ThreadLog::BeginMessage << result << " = eglQuerySurface(" << m_display << ", " << surface << ", " << attribute << ", " << value << ")" << ThreadLog::EndMessage;
1390 EGLU_CHECK_MSG(egl, "eglQuerySurface()");
1393 else if (context != EGL_NO_CONTEXT)
1395 static const EGLint attributes[] =
1398 EGL_CONTEXT_CLIENT_TYPE,
1399 EGL_CONTEXT_CLIENT_VERSION,
1403 const EGLint attribute = attributes[rnd.getInt(0, DE_LENGTH_OF_ARRAY(attributes)-1)];
1407 result = egl.queryContext(m_display, context, attribute, &value);
1408 thread.getLog() << ThreadLog::BeginMessage << result << " = eglQueryContext(" << m_display << ", " << context << ", " << attribute << ", " << value << ")" << ThreadLog::EndMessage;
1409 EGLU_CHECK_MSG(egl, "eglQueryContext()");
1417 void MultiThreadedObjectTest::destroyObjects (TestThread& thread)
1419 const Library& egl = getLibrary();
1420 vector<EGLSurface>& pbuffers = (thread.getId() == 0 ? m_pbuffers0 : m_pbuffers1);
1421 vector<pair<eglu::NativeWindow*, EGLSurface> >& windows = (thread.getId() == 0 ? m_nativeWindows0 : m_nativeWindows1);
1422 vector<pair<eglu::NativePixmap*, EGLSurface> >& pixmaps = (thread.getId() == 0 ? m_nativePixmaps0 : m_nativePixmaps1);
1423 vector<EGLContext>& contexts = (thread.getId() == 0 ? m_contexts0 : m_contexts1);
1425 for (int pbufferNdx = 0; pbufferNdx < (int)pbuffers.size(); pbufferNdx++)
1427 if (pbuffers[pbufferNdx] != EGL_NO_SURFACE)
1429 // Destroy EGLSurface
1432 result = egl.destroySurface(m_display, pbuffers[pbufferNdx]);
1433 thread.getLog() << ThreadLog::BeginMessage << result << " = eglDestroySurface(" << m_display << ", " << pbuffers[pbufferNdx] << ")" << ThreadLog::EndMessage;
1434 EGLU_CHECK_MSG(egl, "eglDestroySurface()");
1435 pbuffers[pbufferNdx] = EGL_NO_SURFACE;
1440 for (int windowNdx = 0; windowNdx < (int)windows.size(); windowNdx++)
1442 if (windows[windowNdx].second != EGL_NO_SURFACE)
1444 thread.getLog() << ThreadLog::BeginMessage << "eglDestroySurface(" << m_display << ", " << windows[windowNdx].second << ")" << ThreadLog::EndMessage;
1445 EGLU_CHECK_CALL(egl, destroySurface(m_display, windows[windowNdx].second));
1446 windows[windowNdx].second = EGL_NO_SURFACE;
1449 if (windows[windowNdx].first)
1451 delete windows[windowNdx].first;
1452 windows[windowNdx].first = NULL;
1457 for (int pixmapNdx = 0; pixmapNdx < (int)pixmaps.size(); pixmapNdx++)
1459 if (pixmaps[pixmapNdx].first != EGL_NO_SURFACE)
1461 thread.getLog() << ThreadLog::BeginMessage << "eglDestroySurface(" << m_display << ", " << pixmaps[pixmapNdx].second << ")" << ThreadLog::EndMessage;
1462 EGLU_CHECK_CALL(egl, destroySurface(m_display, pixmaps[pixmapNdx].second));
1463 pixmaps[pixmapNdx].second = EGL_NO_SURFACE;
1466 if (pixmaps[pixmapNdx].first)
1468 delete pixmaps[pixmapNdx].first;
1469 pixmaps[pixmapNdx].first = NULL;
1474 for (int contextNdx = 0; contextNdx < (int)contexts.size(); contextNdx++)
1476 if (contexts[contextNdx] != EGL_NO_CONTEXT)
1478 EGLU_CHECK_CALL(egl, destroyContext(m_display, contexts[contextNdx]));
1479 thread.getLog() << ThreadLog::BeginMessage << "eglDestroyContext(" << m_display << ", " << contexts[contextNdx] << ")" << ThreadLog::EndMessage;
1480 contexts[contextNdx] = EGL_NO_CONTEXT;
1486 MultiThreadedTests::MultiThreadedTests (EglTestContext& context)
1487 : TestCaseGroup(context, "multithread", "Multithreaded EGL tests")
1491 void MultiThreadedTests::init (void)
1494 addChild(new MultiThreadedConfigTest(m_eglTestCtx, "config", "", 30, 30, 30));
1497 addChild(new MultiThreadedObjectTest(m_eglTestCtx, "pbuffer", "", MultiThreadedObjectTest::TYPE_PBUFFER));
1498 addChild(new MultiThreadedObjectTest(m_eglTestCtx, "pixmap", "", MultiThreadedObjectTest::TYPE_PIXMAP));
1499 addChild(new MultiThreadedObjectTest(m_eglTestCtx, "window", "", MultiThreadedObjectTest::TYPE_WINDOW));
1500 addChild(new MultiThreadedObjectTest(m_eglTestCtx, "single_window", "", MultiThreadedObjectTest::TYPE_WINDOW|MultiThreadedObjectTest::TYPE_SINGLE_WINDOW));
1501 addChild(new MultiThreadedObjectTest(m_eglTestCtx, "context", "", MultiThreadedObjectTest::TYPE_CONTEXT));
1503 addChild(new MultiThreadedObjectTest(m_eglTestCtx, "pbuffer_pixmap", "", MultiThreadedObjectTest::TYPE_PBUFFER|MultiThreadedObjectTest::TYPE_PIXMAP));
1504 addChild(new MultiThreadedObjectTest(m_eglTestCtx, "pbuffer_window", "", MultiThreadedObjectTest::TYPE_PBUFFER|MultiThreadedObjectTest::TYPE_WINDOW));
1505 addChild(new MultiThreadedObjectTest(m_eglTestCtx, "pbuffer_single_window", "", MultiThreadedObjectTest::TYPE_PBUFFER|MultiThreadedObjectTest::TYPE_WINDOW|MultiThreadedObjectTest::TYPE_SINGLE_WINDOW));
1506 addChild(new MultiThreadedObjectTest(m_eglTestCtx, "pbuffer_context", "", MultiThreadedObjectTest::TYPE_PBUFFER|MultiThreadedObjectTest::TYPE_CONTEXT));
1508 addChild(new MultiThreadedObjectTest(m_eglTestCtx, "pixmap_window", "", MultiThreadedObjectTest::TYPE_PIXMAP|MultiThreadedObjectTest::TYPE_WINDOW));
1509 addChild(new MultiThreadedObjectTest(m_eglTestCtx, "pixmap_single_window", "", MultiThreadedObjectTest::TYPE_PIXMAP|MultiThreadedObjectTest::TYPE_WINDOW|MultiThreadedObjectTest::TYPE_SINGLE_WINDOW));
1510 addChild(new MultiThreadedObjectTest(m_eglTestCtx, "pixmap_context", "", MultiThreadedObjectTest::TYPE_PIXMAP|MultiThreadedObjectTest::TYPE_CONTEXT));
1512 addChild(new MultiThreadedObjectTest(m_eglTestCtx, "window_context", "", MultiThreadedObjectTest::TYPE_WINDOW|MultiThreadedObjectTest::TYPE_CONTEXT));
1513 addChild(new MultiThreadedObjectTest(m_eglTestCtx, "single_window_context", "", MultiThreadedObjectTest::TYPE_WINDOW|MultiThreadedObjectTest::TYPE_SINGLE_WINDOW|MultiThreadedObjectTest::TYPE_CONTEXT));
1515 addChild(new MultiThreadedObjectTest(m_eglTestCtx, "pbuffer_pixmap_window", "", MultiThreadedObjectTest::TYPE_PBUFFER|MultiThreadedObjectTest::TYPE_PIXMAP|MultiThreadedObjectTest::TYPE_WINDOW));
1516 addChild(new MultiThreadedObjectTest(m_eglTestCtx, "pbuffer_pixmap_single_window", "", MultiThreadedObjectTest::TYPE_PBUFFER|MultiThreadedObjectTest::TYPE_PIXMAP|MultiThreadedObjectTest::TYPE_WINDOW|MultiThreadedObjectTest::TYPE_SINGLE_WINDOW));
1517 addChild(new MultiThreadedObjectTest(m_eglTestCtx, "pbuffer_pixmap_context", "", MultiThreadedObjectTest::TYPE_PBUFFER|MultiThreadedObjectTest::TYPE_PIXMAP|MultiThreadedObjectTest::TYPE_CONTEXT));
1519 addChild(new MultiThreadedObjectTest(m_eglTestCtx, "pbuffer_window_context", "", MultiThreadedObjectTest::TYPE_PBUFFER|MultiThreadedObjectTest::TYPE_WINDOW|MultiThreadedObjectTest::TYPE_CONTEXT));
1520 addChild(new MultiThreadedObjectTest(m_eglTestCtx, "pbuffer_single_window_context", "", MultiThreadedObjectTest::TYPE_PBUFFER|MultiThreadedObjectTest::TYPE_WINDOW|MultiThreadedObjectTest::TYPE_SINGLE_WINDOW|MultiThreadedObjectTest::TYPE_CONTEXT));
1522 addChild(new MultiThreadedObjectTest(m_eglTestCtx, "pixmap_window_context", "", MultiThreadedObjectTest::TYPE_PIXMAP|MultiThreadedObjectTest::TYPE_WINDOW|MultiThreadedObjectTest::TYPE_CONTEXT));
1523 addChild(new MultiThreadedObjectTest(m_eglTestCtx, "pixmap_single_window_context", "", MultiThreadedObjectTest::TYPE_PIXMAP|MultiThreadedObjectTest::TYPE_WINDOW|MultiThreadedObjectTest::TYPE_SINGLE_WINDOW|MultiThreadedObjectTest::TYPE_CONTEXT));
1525 addChild(new MultiThreadedObjectTest(m_eglTestCtx, "pbuffer_pixmap_window_context", "", MultiThreadedObjectTest::TYPE_PBUFFER|MultiThreadedObjectTest::TYPE_PIXMAP|MultiThreadedObjectTest::TYPE_WINDOW|MultiThreadedObjectTest::TYPE_CONTEXT));
1526 addChild(new MultiThreadedObjectTest(m_eglTestCtx, "pbuffer_pixmap_single_window_context", "", MultiThreadedObjectTest::TYPE_PBUFFER|MultiThreadedObjectTest::TYPE_PIXMAP|MultiThreadedObjectTest::TYPE_WINDOW|MultiThreadedObjectTest::TYPE_SINGLE_WINDOW|MultiThreadedObjectTest::TYPE_CONTEXT));