xref: /aosp_15_r20/external/deqp/modules/egl/teglMultiThreadTests.cpp (revision 35238bce31c2a825756842865a792f8cf7f89930)
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 Multi threaded EGL tests
22*35238bceSAndroid Build Coastguard Worker  *//*--------------------------------------------------------------------*/
23*35238bceSAndroid Build Coastguard Worker #include "teglMultiThreadTests.hpp"
24*35238bceSAndroid Build Coastguard Worker 
25*35238bceSAndroid Build Coastguard Worker #include "egluNativeWindow.hpp"
26*35238bceSAndroid Build Coastguard Worker #include "egluNativePixmap.hpp"
27*35238bceSAndroid Build Coastguard Worker #include "egluUtil.hpp"
28*35238bceSAndroid Build Coastguard Worker 
29*35238bceSAndroid Build Coastguard Worker #include "tcuTestLog.hpp"
30*35238bceSAndroid Build Coastguard Worker #include "tcuCommandLine.hpp"
31*35238bceSAndroid Build Coastguard Worker 
32*35238bceSAndroid Build Coastguard Worker #include "deRandom.hpp"
33*35238bceSAndroid Build Coastguard Worker 
34*35238bceSAndroid Build Coastguard Worker #include "deThread.hpp"
35*35238bceSAndroid Build Coastguard Worker #include "deMutex.hpp"
36*35238bceSAndroid Build Coastguard Worker #include "deSemaphore.hpp"
37*35238bceSAndroid Build Coastguard Worker 
38*35238bceSAndroid Build Coastguard Worker #include "deAtomic.h"
39*35238bceSAndroid Build Coastguard Worker #include "deClock.h"
40*35238bceSAndroid Build Coastguard Worker 
41*35238bceSAndroid Build Coastguard Worker #include "eglwLibrary.hpp"
42*35238bceSAndroid Build Coastguard Worker #include "eglwEnums.hpp"
43*35238bceSAndroid Build Coastguard Worker 
44*35238bceSAndroid Build Coastguard Worker #include <vector>
45*35238bceSAndroid Build Coastguard Worker #include <set>
46*35238bceSAndroid Build Coastguard Worker #include <string>
47*35238bceSAndroid Build Coastguard Worker #include <sstream>
48*35238bceSAndroid Build Coastguard Worker 
49*35238bceSAndroid Build Coastguard Worker using std::ostringstream;
50*35238bceSAndroid Build Coastguard Worker using std::pair;
51*35238bceSAndroid Build Coastguard Worker using std::set;
52*35238bceSAndroid Build Coastguard Worker using std::string;
53*35238bceSAndroid Build Coastguard Worker using std::vector;
54*35238bceSAndroid Build Coastguard Worker 
55*35238bceSAndroid Build Coastguard Worker using namespace eglw;
56*35238bceSAndroid Build Coastguard Worker 
57*35238bceSAndroid Build Coastguard Worker namespace deqp
58*35238bceSAndroid Build Coastguard Worker {
59*35238bceSAndroid Build Coastguard Worker namespace egl
60*35238bceSAndroid Build Coastguard Worker {
61*35238bceSAndroid Build Coastguard Worker 
62*35238bceSAndroid Build Coastguard Worker class ThreadLog
63*35238bceSAndroid Build Coastguard Worker {
64*35238bceSAndroid Build Coastguard Worker public:
65*35238bceSAndroid Build Coastguard Worker     class BeginMessageToken
66*35238bceSAndroid Build Coastguard Worker     {
67*35238bceSAndroid Build Coastguard Worker     };
68*35238bceSAndroid Build Coastguard Worker     class EndMessageToken
69*35238bceSAndroid Build Coastguard Worker     {
70*35238bceSAndroid Build Coastguard Worker     };
71*35238bceSAndroid Build Coastguard Worker 
72*35238bceSAndroid Build Coastguard Worker     struct Message
73*35238bceSAndroid Build Coastguard Worker     {
Messagedeqp::egl::ThreadLog::Message74*35238bceSAndroid Build Coastguard Worker         Message(uint64_t timeUs_, const char *msg_) : timeUs(timeUs_), msg(msg_)
75*35238bceSAndroid Build Coastguard Worker         {
76*35238bceSAndroid Build Coastguard Worker         }
77*35238bceSAndroid Build Coastguard Worker 
78*35238bceSAndroid Build Coastguard Worker         uint64_t timeUs;
79*35238bceSAndroid Build Coastguard Worker         string msg;
80*35238bceSAndroid Build Coastguard Worker     };
81*35238bceSAndroid Build Coastguard Worker 
ThreadLog(void)82*35238bceSAndroid Build Coastguard Worker     ThreadLog(void)
83*35238bceSAndroid Build Coastguard Worker     {
84*35238bceSAndroid Build Coastguard Worker         m_messages.reserve(100);
85*35238bceSAndroid Build Coastguard Worker     }
86*35238bceSAndroid Build Coastguard Worker 
operator <<(const BeginMessageToken &)87*35238bceSAndroid Build Coastguard Worker     ThreadLog &operator<<(const BeginMessageToken &)
88*35238bceSAndroid Build Coastguard Worker     {
89*35238bceSAndroid Build Coastguard Worker         return *this;
90*35238bceSAndroid Build Coastguard Worker     }
91*35238bceSAndroid Build Coastguard Worker     ThreadLog &operator<<(const EndMessageToken &);
92*35238bceSAndroid Build Coastguard Worker 
93*35238bceSAndroid Build Coastguard Worker     template <class T>
operator <<(const T & t)94*35238bceSAndroid Build Coastguard Worker     ThreadLog &operator<<(const T &t)
95*35238bceSAndroid Build Coastguard Worker     {
96*35238bceSAndroid Build Coastguard Worker         m_message << t;
97*35238bceSAndroid Build Coastguard Worker         return *this;
98*35238bceSAndroid Build Coastguard Worker     }
getMessages(void) const99*35238bceSAndroid Build Coastguard Worker     const vector<Message> &getMessages(void) const
100*35238bceSAndroid Build Coastguard Worker     {
101*35238bceSAndroid Build Coastguard Worker         return m_messages;
102*35238bceSAndroid Build Coastguard Worker     }
103*35238bceSAndroid Build Coastguard Worker 
104*35238bceSAndroid Build Coastguard Worker     static BeginMessageToken BeginMessage;
105*35238bceSAndroid Build Coastguard Worker     static EndMessageToken EndMessage;
106*35238bceSAndroid Build Coastguard Worker 
107*35238bceSAndroid Build Coastguard Worker private:
108*35238bceSAndroid Build Coastguard Worker     ostringstream m_message;
109*35238bceSAndroid Build Coastguard Worker     vector<Message> m_messages;
110*35238bceSAndroid Build Coastguard Worker };
111*35238bceSAndroid Build Coastguard Worker 
operator <<(const EndMessageToken &)112*35238bceSAndroid Build Coastguard Worker ThreadLog &ThreadLog::operator<<(const EndMessageToken &)
113*35238bceSAndroid Build Coastguard Worker {
114*35238bceSAndroid Build Coastguard Worker     m_messages.push_back(Message(deGetMicroseconds(), m_message.str().c_str()));
115*35238bceSAndroid Build Coastguard Worker     m_message.str("");
116*35238bceSAndroid Build Coastguard Worker     return *this;
117*35238bceSAndroid Build Coastguard Worker }
118*35238bceSAndroid Build Coastguard Worker 
119*35238bceSAndroid Build Coastguard Worker ThreadLog::BeginMessageToken ThreadLog::BeginMessage;
120*35238bceSAndroid Build Coastguard Worker ThreadLog::EndMessageToken ThreadLog::EndMessage;
121*35238bceSAndroid Build Coastguard Worker 
122*35238bceSAndroid Build Coastguard Worker class MultiThreadedTest;
123*35238bceSAndroid Build Coastguard Worker 
124*35238bceSAndroid Build Coastguard Worker class TestThread : public de::Thread
125*35238bceSAndroid Build Coastguard Worker {
126*35238bceSAndroid Build Coastguard Worker public:
127*35238bceSAndroid Build Coastguard Worker     enum ThreadStatus
128*35238bceSAndroid Build Coastguard Worker     {
129*35238bceSAndroid Build Coastguard Worker         THREADSTATUS_NOT_STARTED = 0,
130*35238bceSAndroid Build Coastguard Worker         THREADSTATUS_RUNNING,
131*35238bceSAndroid Build Coastguard Worker         THREADSTATUS_READY,
132*35238bceSAndroid Build Coastguard Worker     };
133*35238bceSAndroid Build Coastguard Worker 
134*35238bceSAndroid Build Coastguard Worker     TestThread(MultiThreadedTest &test, int id);
135*35238bceSAndroid Build Coastguard Worker     void run(void);
136*35238bceSAndroid Build Coastguard Worker 
getStatus(void) const137*35238bceSAndroid Build Coastguard Worker     ThreadStatus getStatus(void) const
138*35238bceSAndroid Build Coastguard Worker     {
139*35238bceSAndroid Build Coastguard Worker         return m_status;
140*35238bceSAndroid Build Coastguard Worker     }
getLog(void)141*35238bceSAndroid Build Coastguard Worker     ThreadLog &getLog(void)
142*35238bceSAndroid Build Coastguard Worker     {
143*35238bceSAndroid Build Coastguard Worker         return m_log;
144*35238bceSAndroid Build Coastguard Worker     }
145*35238bceSAndroid Build Coastguard Worker 
getId(void) const146*35238bceSAndroid Build Coastguard Worker     int getId(void) const
147*35238bceSAndroid Build Coastguard Worker     {
148*35238bceSAndroid Build Coastguard Worker         return m_id;
149*35238bceSAndroid Build Coastguard Worker     }
150*35238bceSAndroid Build Coastguard Worker 
setStatus(ThreadStatus status)151*35238bceSAndroid Build Coastguard Worker     void setStatus(ThreadStatus status)
152*35238bceSAndroid Build Coastguard Worker     {
153*35238bceSAndroid Build Coastguard Worker         m_status = status;
154*35238bceSAndroid Build Coastguard Worker     }
155*35238bceSAndroid Build Coastguard Worker 
156*35238bceSAndroid Build Coastguard Worker     const Library &getLibrary(void) const;
157*35238bceSAndroid Build Coastguard Worker 
158*35238bceSAndroid Build Coastguard Worker     // Test has stopped
159*35238bceSAndroid Build Coastguard Worker     class TestStop
160*35238bceSAndroid Build Coastguard Worker     {
161*35238bceSAndroid Build Coastguard Worker     };
162*35238bceSAndroid Build Coastguard Worker 
163*35238bceSAndroid Build Coastguard Worker private:
164*35238bceSAndroid Build Coastguard Worker     MultiThreadedTest &m_test;
165*35238bceSAndroid Build Coastguard Worker     const int m_id;
166*35238bceSAndroid Build Coastguard Worker     ThreadStatus m_status;
167*35238bceSAndroid Build Coastguard Worker     ThreadLog m_log;
168*35238bceSAndroid Build Coastguard Worker };
169*35238bceSAndroid Build Coastguard Worker 
170*35238bceSAndroid Build Coastguard Worker class MultiThreadedTest : public TestCase
171*35238bceSAndroid Build Coastguard Worker {
172*35238bceSAndroid Build Coastguard Worker public:
173*35238bceSAndroid Build Coastguard Worker     MultiThreadedTest(EglTestContext &eglTestCtx, const char *name, const char *description, int threadCount,
174*35238bceSAndroid Build Coastguard Worker                       uint64_t timeoutUs);
175*35238bceSAndroid Build Coastguard Worker     virtual ~MultiThreadedTest(void);
176*35238bceSAndroid Build Coastguard Worker 
177*35238bceSAndroid Build Coastguard Worker     void init(void);
178*35238bceSAndroid Build Coastguard Worker     void deinit(void);
179*35238bceSAndroid Build Coastguard Worker 
180*35238bceSAndroid Build Coastguard Worker     virtual bool runThread(TestThread &thread) = 0;
181*35238bceSAndroid Build Coastguard Worker     virtual IterateResult iterate(void);
182*35238bceSAndroid Build Coastguard Worker     void execTest(TestThread &thread);
183*35238bceSAndroid Build Coastguard Worker 
getLibrary(void) const184*35238bceSAndroid Build Coastguard Worker     const Library &getLibrary(void) const
185*35238bceSAndroid Build Coastguard Worker     {
186*35238bceSAndroid Build Coastguard Worker         return m_eglTestCtx.getLibrary();
187*35238bceSAndroid Build Coastguard Worker     }
188*35238bceSAndroid Build Coastguard Worker 
189*35238bceSAndroid Build Coastguard Worker protected:
190*35238bceSAndroid Build Coastguard Worker     void barrier(void);
191*35238bceSAndroid Build Coastguard Worker 
192*35238bceSAndroid Build Coastguard Worker private:
193*35238bceSAndroid Build Coastguard Worker     int m_threadCount;
194*35238bceSAndroid Build Coastguard Worker     bool m_initialized;
195*35238bceSAndroid Build Coastguard Worker     uint64_t m_startTimeUs;
196*35238bceSAndroid Build Coastguard Worker     const uint64_t m_timeoutUs;
197*35238bceSAndroid Build Coastguard Worker     bool m_ok;
198*35238bceSAndroid Build Coastguard Worker     bool m_supported;
199*35238bceSAndroid Build Coastguard Worker     vector<TestThread *> m_threads;
200*35238bceSAndroid Build Coastguard Worker 
201*35238bceSAndroid Build Coastguard Worker     volatile int32_t m_barrierWaiters;
202*35238bceSAndroid Build Coastguard Worker     de::Semaphore m_barrierSemaphore1;
203*35238bceSAndroid Build Coastguard Worker     de::Semaphore m_barrierSemaphore2;
204*35238bceSAndroid Build Coastguard Worker 
205*35238bceSAndroid Build Coastguard Worker protected:
206*35238bceSAndroid Build Coastguard Worker     EGLDisplay m_display;
207*35238bceSAndroid Build Coastguard Worker };
208*35238bceSAndroid Build Coastguard Worker 
getLibrary(void) const209*35238bceSAndroid Build Coastguard Worker inline const Library &TestThread::getLibrary(void) const
210*35238bceSAndroid Build Coastguard Worker {
211*35238bceSAndroid Build Coastguard Worker     return m_test.getLibrary();
212*35238bceSAndroid Build Coastguard Worker }
213*35238bceSAndroid Build Coastguard Worker 
TestThread(MultiThreadedTest & test,int id)214*35238bceSAndroid Build Coastguard Worker TestThread::TestThread(MultiThreadedTest &test, int id) : m_test(test), m_id(id), m_status(THREADSTATUS_NOT_STARTED)
215*35238bceSAndroid Build Coastguard Worker {
216*35238bceSAndroid Build Coastguard Worker }
217*35238bceSAndroid Build Coastguard Worker 
run(void)218*35238bceSAndroid Build Coastguard Worker void TestThread::run(void)
219*35238bceSAndroid Build Coastguard Worker {
220*35238bceSAndroid Build Coastguard Worker     m_status = THREADSTATUS_RUNNING;
221*35238bceSAndroid Build Coastguard Worker 
222*35238bceSAndroid Build Coastguard Worker     try
223*35238bceSAndroid Build Coastguard Worker     {
224*35238bceSAndroid Build Coastguard Worker         m_test.execTest(*this);
225*35238bceSAndroid Build Coastguard Worker     }
226*35238bceSAndroid Build Coastguard Worker     catch (const TestThread::TestStop &)
227*35238bceSAndroid Build Coastguard Worker     {
228*35238bceSAndroid Build Coastguard Worker         getLog() << ThreadLog::BeginMessage << "Thread stopped" << ThreadLog::EndMessage;
229*35238bceSAndroid Build Coastguard Worker     }
230*35238bceSAndroid Build Coastguard Worker     catch (const tcu::NotSupportedError &e)
231*35238bceSAndroid Build Coastguard Worker     {
232*35238bceSAndroid Build Coastguard Worker         getLog() << ThreadLog::BeginMessage << "Not supported: '" << e.what() << "'" << ThreadLog::EndMessage;
233*35238bceSAndroid Build Coastguard Worker     }
234*35238bceSAndroid Build Coastguard Worker     catch (const std::exception &e)
235*35238bceSAndroid Build Coastguard Worker     {
236*35238bceSAndroid Build Coastguard Worker         getLog() << ThreadLog::BeginMessage << "Got exception: '" << e.what() << "'" << ThreadLog::EndMessage;
237*35238bceSAndroid Build Coastguard Worker     }
238*35238bceSAndroid Build Coastguard Worker     catch (...)
239*35238bceSAndroid Build Coastguard Worker     {
240*35238bceSAndroid Build Coastguard Worker         getLog() << ThreadLog::BeginMessage << "Unknown exception" << ThreadLog::EndMessage;
241*35238bceSAndroid Build Coastguard Worker     }
242*35238bceSAndroid Build Coastguard Worker 
243*35238bceSAndroid Build Coastguard Worker     getLibrary().releaseThread();
244*35238bceSAndroid Build Coastguard Worker     m_status = THREADSTATUS_READY;
245*35238bceSAndroid Build Coastguard Worker }
246*35238bceSAndroid Build Coastguard Worker 
execTest(TestThread & thread)247*35238bceSAndroid Build Coastguard Worker void MultiThreadedTest::execTest(TestThread &thread)
248*35238bceSAndroid Build Coastguard Worker {
249*35238bceSAndroid Build Coastguard Worker     try
250*35238bceSAndroid Build Coastguard Worker     {
251*35238bceSAndroid Build Coastguard Worker         if (!runThread(thread))
252*35238bceSAndroid Build Coastguard Worker             m_ok = false;
253*35238bceSAndroid Build Coastguard Worker     }
254*35238bceSAndroid Build Coastguard Worker     catch (const TestThread::TestStop &)
255*35238bceSAndroid Build Coastguard Worker     {
256*35238bceSAndroid Build Coastguard Worker         // Thread exited due to error in other thread
257*35238bceSAndroid Build Coastguard Worker         throw;
258*35238bceSAndroid Build Coastguard Worker     }
259*35238bceSAndroid Build Coastguard Worker     catch (const tcu::NotSupportedError &)
260*35238bceSAndroid Build Coastguard Worker     {
261*35238bceSAndroid Build Coastguard Worker         m_supported = false;
262*35238bceSAndroid Build Coastguard Worker 
263*35238bceSAndroid Build Coastguard Worker         // Release barriers
264*35238bceSAndroid Build Coastguard Worker         for (int threadNdx = 0; threadNdx < (int)m_threads.size(); threadNdx++)
265*35238bceSAndroid Build Coastguard Worker         {
266*35238bceSAndroid Build Coastguard Worker             m_barrierSemaphore1.increment();
267*35238bceSAndroid Build Coastguard Worker             m_barrierSemaphore2.increment();
268*35238bceSAndroid Build Coastguard Worker         }
269*35238bceSAndroid Build Coastguard Worker 
270*35238bceSAndroid Build Coastguard Worker         throw;
271*35238bceSAndroid Build Coastguard Worker     }
272*35238bceSAndroid Build Coastguard Worker     catch (...)
273*35238bceSAndroid Build Coastguard Worker     {
274*35238bceSAndroid Build Coastguard Worker         m_ok = false;
275*35238bceSAndroid Build Coastguard Worker 
276*35238bceSAndroid Build Coastguard Worker         // Release barriers
277*35238bceSAndroid Build Coastguard Worker         for (int threadNdx = 0; threadNdx < (int)m_threads.size(); threadNdx++)
278*35238bceSAndroid Build Coastguard Worker         {
279*35238bceSAndroid Build Coastguard Worker             m_barrierSemaphore1.increment();
280*35238bceSAndroid Build Coastguard Worker             m_barrierSemaphore2.increment();
281*35238bceSAndroid Build Coastguard Worker         }
282*35238bceSAndroid Build Coastguard Worker 
283*35238bceSAndroid Build Coastguard Worker         throw;
284*35238bceSAndroid Build Coastguard Worker     }
285*35238bceSAndroid Build Coastguard Worker }
286*35238bceSAndroid Build Coastguard Worker 
MultiThreadedTest(EglTestContext & eglTestCtx,const char * name,const char * description,int threadCount,uint64_t timeoutUs)287*35238bceSAndroid Build Coastguard Worker MultiThreadedTest::MultiThreadedTest(EglTestContext &eglTestCtx, const char *name, const char *description,
288*35238bceSAndroid Build Coastguard Worker                                      int threadCount, uint64_t timeoutUs)
289*35238bceSAndroid Build Coastguard Worker     : TestCase(eglTestCtx, name, description)
290*35238bceSAndroid Build Coastguard Worker     , m_threadCount(threadCount)
291*35238bceSAndroid Build Coastguard Worker     , m_initialized(false)
292*35238bceSAndroid Build Coastguard Worker     , m_startTimeUs(0)
293*35238bceSAndroid Build Coastguard Worker     , m_timeoutUs(timeoutUs)
294*35238bceSAndroid Build Coastguard Worker     , m_ok(true)
295*35238bceSAndroid Build Coastguard Worker     , m_supported(true)
296*35238bceSAndroid Build Coastguard Worker     , m_barrierWaiters(0)
297*35238bceSAndroid Build Coastguard Worker     , m_barrierSemaphore1(0, 0)
298*35238bceSAndroid Build Coastguard Worker     , m_barrierSemaphore2(1, 0)
299*35238bceSAndroid Build Coastguard Worker 
300*35238bceSAndroid Build Coastguard Worker     , m_display(EGL_NO_DISPLAY)
301*35238bceSAndroid Build Coastguard Worker {
302*35238bceSAndroid Build Coastguard Worker }
303*35238bceSAndroid Build Coastguard Worker 
~MultiThreadedTest(void)304*35238bceSAndroid Build Coastguard Worker MultiThreadedTest::~MultiThreadedTest(void)
305*35238bceSAndroid Build Coastguard Worker {
306*35238bceSAndroid Build Coastguard Worker     for (int threadNdx = 0; threadNdx < (int)m_threads.size(); threadNdx++)
307*35238bceSAndroid Build Coastguard Worker         delete m_threads[threadNdx];
308*35238bceSAndroid Build Coastguard Worker     m_threads.clear();
309*35238bceSAndroid Build Coastguard Worker }
310*35238bceSAndroid Build Coastguard Worker 
init(void)311*35238bceSAndroid Build Coastguard Worker void MultiThreadedTest::init(void)
312*35238bceSAndroid Build Coastguard Worker {
313*35238bceSAndroid Build Coastguard Worker     m_display = eglu::getAndInitDisplay(m_eglTestCtx.getNativeDisplay());
314*35238bceSAndroid Build Coastguard Worker }
315*35238bceSAndroid Build Coastguard Worker 
deinit(void)316*35238bceSAndroid Build Coastguard Worker void MultiThreadedTest::deinit(void)
317*35238bceSAndroid Build Coastguard Worker {
318*35238bceSAndroid Build Coastguard Worker     if (m_display != EGL_NO_DISPLAY)
319*35238bceSAndroid Build Coastguard Worker     {
320*35238bceSAndroid Build Coastguard Worker         m_eglTestCtx.getLibrary().terminate(m_display);
321*35238bceSAndroid Build Coastguard Worker         m_display = EGL_NO_DISPLAY;
322*35238bceSAndroid Build Coastguard Worker     }
323*35238bceSAndroid Build Coastguard Worker }
324*35238bceSAndroid Build Coastguard Worker 
barrier(void)325*35238bceSAndroid Build Coastguard Worker void MultiThreadedTest::barrier(void)
326*35238bceSAndroid Build Coastguard Worker {
327*35238bceSAndroid Build Coastguard Worker     {
328*35238bceSAndroid Build Coastguard Worker         const int32_t waiters = deAtomicIncrement32(&m_barrierWaiters);
329*35238bceSAndroid Build Coastguard Worker 
330*35238bceSAndroid Build Coastguard Worker         if (waiters == m_threadCount)
331*35238bceSAndroid Build Coastguard Worker         {
332*35238bceSAndroid Build Coastguard Worker             m_barrierSemaphore2.decrement();
333*35238bceSAndroid Build Coastguard Worker             m_barrierSemaphore1.increment();
334*35238bceSAndroid Build Coastguard Worker         }
335*35238bceSAndroid Build Coastguard Worker         else
336*35238bceSAndroid Build Coastguard Worker         {
337*35238bceSAndroid Build Coastguard Worker             m_barrierSemaphore1.decrement();
338*35238bceSAndroid Build Coastguard Worker             m_barrierSemaphore1.increment();
339*35238bceSAndroid Build Coastguard Worker         }
340*35238bceSAndroid Build Coastguard Worker     }
341*35238bceSAndroid Build Coastguard Worker 
342*35238bceSAndroid Build Coastguard Worker     {
343*35238bceSAndroid Build Coastguard Worker         const int32_t waiters = deAtomicDecrement32(&m_barrierWaiters);
344*35238bceSAndroid Build Coastguard Worker 
345*35238bceSAndroid Build Coastguard Worker         if (waiters == 0)
346*35238bceSAndroid Build Coastguard Worker         {
347*35238bceSAndroid Build Coastguard Worker             m_barrierSemaphore1.decrement();
348*35238bceSAndroid Build Coastguard Worker             m_barrierSemaphore2.increment();
349*35238bceSAndroid Build Coastguard Worker         }
350*35238bceSAndroid Build Coastguard Worker         else
351*35238bceSAndroid Build Coastguard Worker         {
352*35238bceSAndroid Build Coastguard Worker             m_barrierSemaphore2.decrement();
353*35238bceSAndroid Build Coastguard Worker             m_barrierSemaphore2.increment();
354*35238bceSAndroid Build Coastguard Worker         }
355*35238bceSAndroid Build Coastguard Worker     }
356*35238bceSAndroid Build Coastguard Worker 
357*35238bceSAndroid Build Coastguard Worker     // Barrier was released due an error in other thread
358*35238bceSAndroid Build Coastguard Worker     if (!m_ok || !m_supported)
359*35238bceSAndroid Build Coastguard Worker         throw TestThread::TestStop();
360*35238bceSAndroid Build Coastguard Worker }
361*35238bceSAndroid Build Coastguard Worker 
iterate(void)362*35238bceSAndroid Build Coastguard Worker TestCase::IterateResult MultiThreadedTest::iterate(void)
363*35238bceSAndroid Build Coastguard Worker {
364*35238bceSAndroid Build Coastguard Worker     if (!m_initialized)
365*35238bceSAndroid Build Coastguard Worker     {
366*35238bceSAndroid Build Coastguard Worker         m_testCtx.getLog() << tcu::TestLog::Message << "Thread timeout limit: " << m_timeoutUs << "us"
367*35238bceSAndroid Build Coastguard Worker                            << tcu::TestLog::EndMessage;
368*35238bceSAndroid Build Coastguard Worker 
369*35238bceSAndroid Build Coastguard Worker         m_ok        = true;
370*35238bceSAndroid Build Coastguard Worker         m_supported = true;
371*35238bceSAndroid Build Coastguard Worker 
372*35238bceSAndroid Build Coastguard Worker         // Create threads
373*35238bceSAndroid Build Coastguard Worker         m_threads.reserve(m_threadCount);
374*35238bceSAndroid Build Coastguard Worker 
375*35238bceSAndroid Build Coastguard Worker         for (int threadNdx = 0; threadNdx < m_threadCount; threadNdx++)
376*35238bceSAndroid Build Coastguard Worker             m_threads.push_back(new TestThread(*this, threadNdx));
377*35238bceSAndroid Build Coastguard Worker 
378*35238bceSAndroid Build Coastguard Worker         m_startTimeUs = deGetMicroseconds();
379*35238bceSAndroid Build Coastguard Worker 
380*35238bceSAndroid Build Coastguard Worker         // Run threads
381*35238bceSAndroid Build Coastguard Worker         for (int threadNdx = 0; threadNdx < (int)m_threads.size(); threadNdx++)
382*35238bceSAndroid Build Coastguard Worker             m_threads[threadNdx]->start();
383*35238bceSAndroid Build Coastguard Worker 
384*35238bceSAndroid Build Coastguard Worker         m_initialized = true;
385*35238bceSAndroid Build Coastguard Worker     }
386*35238bceSAndroid Build Coastguard Worker 
387*35238bceSAndroid Build Coastguard Worker     int readyCount = 0;
388*35238bceSAndroid Build Coastguard Worker     for (int threadNdx = 0; threadNdx < (int)m_threads.size(); threadNdx++)
389*35238bceSAndroid Build Coastguard Worker     {
390*35238bceSAndroid Build Coastguard Worker         if (m_threads[threadNdx]->getStatus() != TestThread::THREADSTATUS_RUNNING)
391*35238bceSAndroid Build Coastguard Worker             readyCount++;
392*35238bceSAndroid Build Coastguard Worker     }
393*35238bceSAndroid Build Coastguard Worker 
394*35238bceSAndroid Build Coastguard Worker     if (readyCount == m_threadCount)
395*35238bceSAndroid Build Coastguard Worker     {
396*35238bceSAndroid Build Coastguard Worker         // Join threads
397*35238bceSAndroid Build Coastguard Worker         for (int threadNdx = 0; threadNdx < (int)m_threads.size(); threadNdx++)
398*35238bceSAndroid Build Coastguard Worker             m_threads[threadNdx]->join();
399*35238bceSAndroid Build Coastguard Worker 
400*35238bceSAndroid Build Coastguard Worker         // Get logs
401*35238bceSAndroid Build Coastguard Worker         {
402*35238bceSAndroid Build Coastguard Worker             vector<int> messageNdx;
403*35238bceSAndroid Build Coastguard Worker 
404*35238bceSAndroid Build Coastguard Worker             messageNdx.resize(m_threads.size(), 0);
405*35238bceSAndroid Build Coastguard Worker 
406*35238bceSAndroid Build Coastguard Worker             while (true)
407*35238bceSAndroid Build Coastguard Worker             {
408*35238bceSAndroid Build Coastguard Worker                 int nextThreadNdx         = -1;
409*35238bceSAndroid Build Coastguard Worker                 uint64_t nextThreadTimeUs = 0;
410*35238bceSAndroid Build Coastguard Worker 
411*35238bceSAndroid Build Coastguard Worker                 for (int threadNdx = 0; threadNdx < (int)m_threads.size(); threadNdx++)
412*35238bceSAndroid Build Coastguard Worker                 {
413*35238bceSAndroid Build Coastguard Worker                     if (messageNdx[threadNdx] >= (int)m_threads[threadNdx]->getLog().getMessages().size())
414*35238bceSAndroid Build Coastguard Worker                         continue;
415*35238bceSAndroid Build Coastguard Worker 
416*35238bceSAndroid Build Coastguard Worker                     if (nextThreadNdx == -1 ||
417*35238bceSAndroid Build Coastguard Worker                         nextThreadTimeUs > m_threads[threadNdx]->getLog().getMessages()[messageNdx[threadNdx]].timeUs)
418*35238bceSAndroid Build Coastguard Worker                     {
419*35238bceSAndroid Build Coastguard Worker                         nextThreadNdx    = threadNdx;
420*35238bceSAndroid Build Coastguard Worker                         nextThreadTimeUs = m_threads[threadNdx]->getLog().getMessages()[messageNdx[threadNdx]].timeUs;
421*35238bceSAndroid Build Coastguard Worker                     }
422*35238bceSAndroid Build Coastguard Worker                 }
423*35238bceSAndroid Build Coastguard Worker 
424*35238bceSAndroid Build Coastguard Worker                 if (nextThreadNdx == -1)
425*35238bceSAndroid Build Coastguard Worker                     break;
426*35238bceSAndroid Build Coastguard Worker 
427*35238bceSAndroid Build Coastguard Worker                 m_testCtx.getLog() << tcu::TestLog::Message << "[" << (nextThreadTimeUs - m_startTimeUs) << "] ("
428*35238bceSAndroid Build Coastguard Worker                                    << nextThreadNdx << ") "
429*35238bceSAndroid Build Coastguard Worker                                    << m_threads[nextThreadNdx]->getLog().getMessages()[messageNdx[nextThreadNdx]].msg
430*35238bceSAndroid Build Coastguard Worker                                    << tcu::TestLog::EndMessage;
431*35238bceSAndroid Build Coastguard Worker 
432*35238bceSAndroid Build Coastguard Worker                 messageNdx[nextThreadNdx]++;
433*35238bceSAndroid Build Coastguard Worker             }
434*35238bceSAndroid Build Coastguard Worker         }
435*35238bceSAndroid Build Coastguard Worker 
436*35238bceSAndroid Build Coastguard Worker         // Destroy threads
437*35238bceSAndroid Build Coastguard Worker         for (int threadNdx = 0; threadNdx < (int)m_threads.size(); threadNdx++)
438*35238bceSAndroid Build Coastguard Worker             delete m_threads[threadNdx];
439*35238bceSAndroid Build Coastguard Worker 
440*35238bceSAndroid Build Coastguard Worker         m_threads.clear();
441*35238bceSAndroid Build Coastguard Worker 
442*35238bceSAndroid Build Coastguard Worker         // Set result
443*35238bceSAndroid Build Coastguard Worker         if (m_ok)
444*35238bceSAndroid Build Coastguard Worker         {
445*35238bceSAndroid Build Coastguard Worker             if (!m_supported)
446*35238bceSAndroid Build Coastguard Worker                 m_testCtx.setTestResult(QP_TEST_RESULT_NOT_SUPPORTED, "Not Supported");
447*35238bceSAndroid Build Coastguard Worker             else
448*35238bceSAndroid Build Coastguard Worker                 m_testCtx.setTestResult(QP_TEST_RESULT_PASS, "Pass");
449*35238bceSAndroid Build Coastguard Worker         }
450*35238bceSAndroid Build Coastguard Worker         else
451*35238bceSAndroid Build Coastguard Worker             m_testCtx.setTestResult(QP_TEST_RESULT_FAIL, "Fail");
452*35238bceSAndroid Build Coastguard Worker 
453*35238bceSAndroid Build Coastguard Worker         return STOP;
454*35238bceSAndroid Build Coastguard Worker     }
455*35238bceSAndroid Build Coastguard Worker     else
456*35238bceSAndroid Build Coastguard Worker     {
457*35238bceSAndroid Build Coastguard Worker         // Check for timeout
458*35238bceSAndroid Build Coastguard Worker         const uint64_t currentTimeUs = deGetMicroseconds();
459*35238bceSAndroid Build Coastguard Worker 
460*35238bceSAndroid Build Coastguard Worker         if (currentTimeUs - m_startTimeUs > m_timeoutUs)
461*35238bceSAndroid Build Coastguard Worker         {
462*35238bceSAndroid Build Coastguard Worker             // Get logs
463*35238bceSAndroid Build Coastguard Worker             {
464*35238bceSAndroid Build Coastguard Worker                 vector<int> messageNdx;
465*35238bceSAndroid Build Coastguard Worker 
466*35238bceSAndroid Build Coastguard Worker                 messageNdx.resize(m_threads.size(), 0);
467*35238bceSAndroid Build Coastguard Worker 
468*35238bceSAndroid Build Coastguard Worker                 while (true)
469*35238bceSAndroid Build Coastguard Worker                 {
470*35238bceSAndroid Build Coastguard Worker                     int nextThreadNdx         = -1;
471*35238bceSAndroid Build Coastguard Worker                     uint64_t nextThreadTimeUs = 0;
472*35238bceSAndroid Build Coastguard Worker 
473*35238bceSAndroid Build Coastguard Worker                     for (int threadNdx = 0; threadNdx < (int)m_threads.size(); threadNdx++)
474*35238bceSAndroid Build Coastguard Worker                     {
475*35238bceSAndroid Build Coastguard Worker                         if (messageNdx[threadNdx] >= (int)m_threads[threadNdx]->getLog().getMessages().size())
476*35238bceSAndroid Build Coastguard Worker                             continue;
477*35238bceSAndroid Build Coastguard Worker 
478*35238bceSAndroid Build Coastguard Worker                         if (nextThreadNdx == -1 ||
479*35238bceSAndroid Build Coastguard Worker                             nextThreadTimeUs >
480*35238bceSAndroid Build Coastguard Worker                                 m_threads[threadNdx]->getLog().getMessages()[messageNdx[threadNdx]].timeUs)
481*35238bceSAndroid Build Coastguard Worker                         {
482*35238bceSAndroid Build Coastguard Worker                             nextThreadNdx = threadNdx;
483*35238bceSAndroid Build Coastguard Worker                             nextThreadTimeUs =
484*35238bceSAndroid Build Coastguard Worker                                 m_threads[threadNdx]->getLog().getMessages()[messageNdx[threadNdx]].timeUs;
485*35238bceSAndroid Build Coastguard Worker                         }
486*35238bceSAndroid Build Coastguard Worker                     }
487*35238bceSAndroid Build Coastguard Worker 
488*35238bceSAndroid Build Coastguard Worker                     if (nextThreadNdx == -1)
489*35238bceSAndroid Build Coastguard Worker                         break;
490*35238bceSAndroid Build Coastguard Worker 
491*35238bceSAndroid Build Coastguard Worker                     m_testCtx.getLog() << tcu::TestLog::Message << "[" << (nextThreadTimeUs - m_startTimeUs) << "] ("
492*35238bceSAndroid Build Coastguard Worker                                        << nextThreadNdx << ") "
493*35238bceSAndroid Build Coastguard Worker                                        << m_threads[nextThreadNdx]
494*35238bceSAndroid Build Coastguard Worker                                               ->getLog()
495*35238bceSAndroid Build Coastguard Worker                                               .getMessages()[messageNdx[nextThreadNdx]]
496*35238bceSAndroid Build Coastguard Worker                                               .msg
497*35238bceSAndroid Build Coastguard Worker                                        << tcu::TestLog::EndMessage;
498*35238bceSAndroid Build Coastguard Worker 
499*35238bceSAndroid Build Coastguard Worker                     messageNdx[nextThreadNdx]++;
500*35238bceSAndroid Build Coastguard Worker                 }
501*35238bceSAndroid Build Coastguard Worker             }
502*35238bceSAndroid Build Coastguard Worker 
503*35238bceSAndroid Build Coastguard Worker             m_testCtx.getLog() << tcu::TestLog::Message << "[" << (currentTimeUs - m_startTimeUs)
504*35238bceSAndroid Build Coastguard Worker                                << "] (-) Timeout, Limit: " << m_timeoutUs << "us" << tcu::TestLog::EndMessage;
505*35238bceSAndroid Build Coastguard Worker             m_testCtx.getLog() << tcu::TestLog::Message << "[" << (currentTimeUs - m_startTimeUs)
506*35238bceSAndroid Build Coastguard Worker                                << "] (-) Trying to perform resource cleanup..." << tcu::TestLog::EndMessage;
507*35238bceSAndroid Build Coastguard Worker 
508*35238bceSAndroid Build Coastguard Worker             m_testCtx.setTestResult(QP_TEST_RESULT_FAIL, "Fail");
509*35238bceSAndroid Build Coastguard Worker             return STOP;
510*35238bceSAndroid Build Coastguard Worker         }
511*35238bceSAndroid Build Coastguard Worker 
512*35238bceSAndroid Build Coastguard Worker         // Sleep
513*35238bceSAndroid Build Coastguard Worker         deSleep(10);
514*35238bceSAndroid Build Coastguard Worker     }
515*35238bceSAndroid Build Coastguard Worker 
516*35238bceSAndroid Build Coastguard Worker     return CONTINUE;
517*35238bceSAndroid Build Coastguard Worker }
518*35238bceSAndroid Build Coastguard Worker 
519*35238bceSAndroid Build Coastguard Worker namespace
520*35238bceSAndroid Build Coastguard Worker {
521*35238bceSAndroid Build Coastguard Worker 
configAttributeToString(EGLint e)522*35238bceSAndroid Build Coastguard Worker const char *configAttributeToString(EGLint e)
523*35238bceSAndroid Build Coastguard Worker {
524*35238bceSAndroid Build Coastguard Worker     switch (e)
525*35238bceSAndroid Build Coastguard Worker     {
526*35238bceSAndroid Build Coastguard Worker     case EGL_BUFFER_SIZE:
527*35238bceSAndroid Build Coastguard Worker         return "EGL_BUFFER_SIZE";
528*35238bceSAndroid Build Coastguard Worker     case EGL_RED_SIZE:
529*35238bceSAndroid Build Coastguard Worker         return "EGL_RED_SIZE";
530*35238bceSAndroid Build Coastguard Worker     case EGL_GREEN_SIZE:
531*35238bceSAndroid Build Coastguard Worker         return "EGL_GREEN_SIZE";
532*35238bceSAndroid Build Coastguard Worker     case EGL_BLUE_SIZE:
533*35238bceSAndroid Build Coastguard Worker         return "EGL_BLUE_SIZE";
534*35238bceSAndroid Build Coastguard Worker     case EGL_LUMINANCE_SIZE:
535*35238bceSAndroid Build Coastguard Worker         return "EGL_LUMINANCE_SIZE";
536*35238bceSAndroid Build Coastguard Worker     case EGL_ALPHA_SIZE:
537*35238bceSAndroid Build Coastguard Worker         return "EGL_ALPHA_SIZE";
538*35238bceSAndroid Build Coastguard Worker     case EGL_ALPHA_MASK_SIZE:
539*35238bceSAndroid Build Coastguard Worker         return "EGL_ALPHA_MASK_SIZE";
540*35238bceSAndroid Build Coastguard Worker     case EGL_BIND_TO_TEXTURE_RGB:
541*35238bceSAndroid Build Coastguard Worker         return "EGL_BIND_TO_TEXTURE_RGB";
542*35238bceSAndroid Build Coastguard Worker     case EGL_BIND_TO_TEXTURE_RGBA:
543*35238bceSAndroid Build Coastguard Worker         return "EGL_BIND_TO_TEXTURE_RGBA";
544*35238bceSAndroid Build Coastguard Worker     case EGL_COLOR_BUFFER_TYPE:
545*35238bceSAndroid Build Coastguard Worker         return "EGL_COLOR_BUFFER_TYPE";
546*35238bceSAndroid Build Coastguard Worker     case EGL_CONFIG_CAVEAT:
547*35238bceSAndroid Build Coastguard Worker         return "EGL_CONFIG_CAVEAT";
548*35238bceSAndroid Build Coastguard Worker     case EGL_CONFIG_ID:
549*35238bceSAndroid Build Coastguard Worker         return "EGL_CONFIG_ID";
550*35238bceSAndroid Build Coastguard Worker     case EGL_CONFORMANT:
551*35238bceSAndroid Build Coastguard Worker         return "EGL_CONFORMANT";
552*35238bceSAndroid Build Coastguard Worker     case EGL_DEPTH_SIZE:
553*35238bceSAndroid Build Coastguard Worker         return "EGL_DEPTH_SIZE";
554*35238bceSAndroid Build Coastguard Worker     case EGL_LEVEL:
555*35238bceSAndroid Build Coastguard Worker         return "EGL_LEVEL";
556*35238bceSAndroid Build Coastguard Worker     case EGL_MAX_PBUFFER_WIDTH:
557*35238bceSAndroid Build Coastguard Worker         return "EGL_MAX_PBUFFER_WIDTH";
558*35238bceSAndroid Build Coastguard Worker     case EGL_MAX_PBUFFER_HEIGHT:
559*35238bceSAndroid Build Coastguard Worker         return "EGL_MAX_PBUFFER_HEIGHT";
560*35238bceSAndroid Build Coastguard Worker     case EGL_MAX_PBUFFER_PIXELS:
561*35238bceSAndroid Build Coastguard Worker         return "EGL_MAX_PBUFFER_PIXELS";
562*35238bceSAndroid Build Coastguard Worker     case EGL_MAX_SWAP_INTERVAL:
563*35238bceSAndroid Build Coastguard Worker         return "EGL_MAX_SWAP_INTERVAL";
564*35238bceSAndroid Build Coastguard Worker     case EGL_MIN_SWAP_INTERVAL:
565*35238bceSAndroid Build Coastguard Worker         return "EGL_MIN_SWAP_INTERVAL";
566*35238bceSAndroid Build Coastguard Worker     case EGL_NATIVE_RENDERABLE:
567*35238bceSAndroid Build Coastguard Worker         return "EGL_NATIVE_RENDERABLE";
568*35238bceSAndroid Build Coastguard Worker     case EGL_NATIVE_VISUAL_ID:
569*35238bceSAndroid Build Coastguard Worker         return "EGL_NATIVE_VISUAL_ID";
570*35238bceSAndroid Build Coastguard Worker     case EGL_NATIVE_VISUAL_TYPE:
571*35238bceSAndroid Build Coastguard Worker         return "EGL_NATIVE_VISUAL_TYPE";
572*35238bceSAndroid Build Coastguard Worker     case EGL_RENDERABLE_TYPE:
573*35238bceSAndroid Build Coastguard Worker         return "EGL_RENDERABLE_TYPE";
574*35238bceSAndroid Build Coastguard Worker     case EGL_SAMPLE_BUFFERS:
575*35238bceSAndroid Build Coastguard Worker         return "EGL_SAMPLE_BUFFERS";
576*35238bceSAndroid Build Coastguard Worker     case EGL_SAMPLES:
577*35238bceSAndroid Build Coastguard Worker         return "EGL_SAMPLES";
578*35238bceSAndroid Build Coastguard Worker     case EGL_STENCIL_SIZE:
579*35238bceSAndroid Build Coastguard Worker         return "EGL_STENCIL_SIZE";
580*35238bceSAndroid Build Coastguard Worker     case EGL_SURFACE_TYPE:
581*35238bceSAndroid Build Coastguard Worker         return "EGL_SURFACE_TYPE";
582*35238bceSAndroid Build Coastguard Worker     case EGL_TRANSPARENT_TYPE:
583*35238bceSAndroid Build Coastguard Worker         return "EGL_TRANSPARENT_TYPE";
584*35238bceSAndroid Build Coastguard Worker     case EGL_TRANSPARENT_RED_VALUE:
585*35238bceSAndroid Build Coastguard Worker         return "EGL_TRANSPARENT_RED_VALUE";
586*35238bceSAndroid Build Coastguard Worker     case EGL_TRANSPARENT_GREEN_VALUE:
587*35238bceSAndroid Build Coastguard Worker         return "EGL_TRANSPARENT_GREEN_VALUE";
588*35238bceSAndroid Build Coastguard Worker     case EGL_TRANSPARENT_BLUE_VALUE:
589*35238bceSAndroid Build Coastguard Worker         return "EGL_TRANSPARENT_BLUE_VALUE";
590*35238bceSAndroid Build Coastguard Worker     case EGL_RECORDABLE_ANDROID:
591*35238bceSAndroid Build Coastguard Worker         return "EGL_RECORDABLE_ANDROID";
592*35238bceSAndroid Build Coastguard Worker     default:
593*35238bceSAndroid Build Coastguard Worker         return "<Unknown>";
594*35238bceSAndroid Build Coastguard Worker     }
595*35238bceSAndroid Build Coastguard Worker }
596*35238bceSAndroid Build Coastguard Worker 
597*35238bceSAndroid Build Coastguard Worker } // namespace
598*35238bceSAndroid Build Coastguard Worker 
599*35238bceSAndroid Build Coastguard Worker class MultiThreadedConfigTest : public MultiThreadedTest
600*35238bceSAndroid Build Coastguard Worker {
601*35238bceSAndroid Build Coastguard Worker public:
602*35238bceSAndroid Build Coastguard Worker     MultiThreadedConfigTest(EglTestContext &context, const char *name, const char *description, int getConfigs,
603*35238bceSAndroid Build Coastguard Worker                             int chooseConfigs, int query);
604*35238bceSAndroid Build Coastguard Worker     bool runThread(TestThread &thread);
605*35238bceSAndroid Build Coastguard Worker 
606*35238bceSAndroid Build Coastguard Worker private:
607*35238bceSAndroid Build Coastguard Worker     const int m_getConfigs;
608*35238bceSAndroid Build Coastguard Worker     const int m_chooseConfigs;
609*35238bceSAndroid Build Coastguard Worker     const int m_query;
610*35238bceSAndroid Build Coastguard Worker };
611*35238bceSAndroid Build Coastguard Worker 
MultiThreadedConfigTest(EglTestContext & context,const char * name,const char * description,int getConfigs,int chooseConfigs,int query)612*35238bceSAndroid Build Coastguard Worker MultiThreadedConfigTest::MultiThreadedConfigTest(EglTestContext &context, const char *name, const char *description,
613*35238bceSAndroid Build Coastguard Worker                                                  int getConfigs, int chooseConfigs, int query)
614*35238bceSAndroid Build Coastguard Worker     : MultiThreadedTest(context, name, description, 2,
615*35238bceSAndroid Build Coastguard Worker                         20000000 /*us = 20s*/) // \todo [mika] Set timeout to something relevant to frameworks timeout?
616*35238bceSAndroid Build Coastguard Worker     , m_getConfigs(getConfigs)
617*35238bceSAndroid Build Coastguard Worker     , m_chooseConfigs(chooseConfigs)
618*35238bceSAndroid Build Coastguard Worker     , m_query(query)
619*35238bceSAndroid Build Coastguard Worker {
620*35238bceSAndroid Build Coastguard Worker }
621*35238bceSAndroid Build Coastguard Worker 
runThread(TestThread & thread)622*35238bceSAndroid Build Coastguard Worker bool MultiThreadedConfigTest::runThread(TestThread &thread)
623*35238bceSAndroid Build Coastguard Worker {
624*35238bceSAndroid Build Coastguard Worker     const Library &egl = getLibrary();
625*35238bceSAndroid Build Coastguard Worker     de::Random rnd(deInt32Hash(thread.getId() + 10435));
626*35238bceSAndroid Build Coastguard Worker     vector<EGLConfig> configs;
627*35238bceSAndroid Build Coastguard Worker 
628*35238bceSAndroid Build Coastguard Worker     barrier();
629*35238bceSAndroid Build Coastguard Worker 
630*35238bceSAndroid Build Coastguard Worker     for (int getConfigsNdx = 0; getConfigsNdx < m_getConfigs; getConfigsNdx++)
631*35238bceSAndroid Build Coastguard Worker     {
632*35238bceSAndroid Build Coastguard Worker         EGLint configCount;
633*35238bceSAndroid Build Coastguard Worker 
634*35238bceSAndroid Build Coastguard Worker         // Get number of configs
635*35238bceSAndroid Build Coastguard Worker         {
636*35238bceSAndroid Build Coastguard Worker             EGLBoolean result;
637*35238bceSAndroid Build Coastguard Worker 
638*35238bceSAndroid Build Coastguard Worker             result = egl.getConfigs(m_display, NULL, 0, &configCount);
639*35238bceSAndroid Build Coastguard Worker             thread.getLog() << ThreadLog::BeginMessage << result << " = eglGetConfigs(" << m_display << ", NULL, 0, "
640*35238bceSAndroid Build Coastguard Worker                             << configCount << ")" << ThreadLog::EndMessage;
641*35238bceSAndroid Build Coastguard Worker             EGLU_CHECK_MSG(egl, "eglGetConfigs()");
642*35238bceSAndroid Build Coastguard Worker 
643*35238bceSAndroid Build Coastguard Worker             if (!result)
644*35238bceSAndroid Build Coastguard Worker                 return false;
645*35238bceSAndroid Build Coastguard Worker         }
646*35238bceSAndroid Build Coastguard Worker 
647*35238bceSAndroid Build Coastguard Worker         configs.resize(configs.size() + configCount);
648*35238bceSAndroid Build Coastguard Worker 
649*35238bceSAndroid Build Coastguard Worker         // Get configs
650*35238bceSAndroid Build Coastguard Worker         if (configCount != 0)
651*35238bceSAndroid Build Coastguard Worker         {
652*35238bceSAndroid Build Coastguard Worker             EGLBoolean result;
653*35238bceSAndroid Build Coastguard Worker 
654*35238bceSAndroid Build Coastguard Worker             result = egl.getConfigs(m_display, &(configs[configs.size() - configCount]), configCount, &configCount);
655*35238bceSAndroid Build Coastguard Worker             thread.getLog() << ThreadLog::BeginMessage << result << " = eglGetConfigs(" << m_display << ", &configs' "
656*35238bceSAndroid Build Coastguard Worker                             << configCount << ", " << configCount << ")" << ThreadLog::EndMessage;
657*35238bceSAndroid Build Coastguard Worker             EGLU_CHECK_MSG(egl, "eglGetConfigs()");
658*35238bceSAndroid Build Coastguard Worker 
659*35238bceSAndroid Build Coastguard Worker             if (!result)
660*35238bceSAndroid Build Coastguard Worker                 return false;
661*35238bceSAndroid Build Coastguard Worker         }
662*35238bceSAndroid Build Coastguard Worker 
663*35238bceSAndroid Build Coastguard Worker         // Pop configs to stop config list growing
664*35238bceSAndroid Build Coastguard Worker         if (configs.size() > 40)
665*35238bceSAndroid Build Coastguard Worker         {
666*35238bceSAndroid Build Coastguard Worker             configs.erase(configs.begin() + 40, configs.end());
667*35238bceSAndroid Build Coastguard Worker         }
668*35238bceSAndroid Build Coastguard Worker         else
669*35238bceSAndroid Build Coastguard Worker         {
670*35238bceSAndroid Build Coastguard Worker             const int popCount = rnd.getInt(0, (int)(configs.size() - 2));
671*35238bceSAndroid Build Coastguard Worker 
672*35238bceSAndroid Build Coastguard Worker             configs.erase(configs.begin() + (configs.size() - popCount), configs.end());
673*35238bceSAndroid Build Coastguard Worker         }
674*35238bceSAndroid Build Coastguard Worker     }
675*35238bceSAndroid Build Coastguard Worker 
676*35238bceSAndroid Build Coastguard Worker     for (int chooseConfigsNdx = 0; chooseConfigsNdx < m_chooseConfigs; chooseConfigsNdx++)
677*35238bceSAndroid Build Coastguard Worker     {
678*35238bceSAndroid Build Coastguard Worker         EGLint configCount;
679*35238bceSAndroid Build Coastguard Worker 
680*35238bceSAndroid Build Coastguard Worker         static const EGLint attribList[] = {EGL_NONE};
681*35238bceSAndroid Build Coastguard Worker 
682*35238bceSAndroid Build Coastguard Worker         // Get number of configs
683*35238bceSAndroid Build Coastguard Worker         {
684*35238bceSAndroid Build Coastguard Worker             EGLBoolean result;
685*35238bceSAndroid Build Coastguard Worker 
686*35238bceSAndroid Build Coastguard Worker             result = egl.chooseConfig(m_display, attribList, NULL, 0, &configCount);
687*35238bceSAndroid Build Coastguard Worker             thread.getLog() << ThreadLog::BeginMessage << result << " = eglChooseConfig(" << m_display
688*35238bceSAndroid Build Coastguard Worker                             << ", { EGL_NONE }, NULL, 0, " << configCount << ")" << ThreadLog::EndMessage;
689*35238bceSAndroid Build Coastguard Worker             EGLU_CHECK_MSG(egl, "eglChooseConfig()");
690*35238bceSAndroid Build Coastguard Worker 
691*35238bceSAndroid Build Coastguard Worker             if (!result)
692*35238bceSAndroid Build Coastguard Worker                 return false;
693*35238bceSAndroid Build Coastguard Worker         }
694*35238bceSAndroid Build Coastguard Worker 
695*35238bceSAndroid Build Coastguard Worker         configs.resize(configs.size() + configCount);
696*35238bceSAndroid Build Coastguard Worker 
697*35238bceSAndroid Build Coastguard Worker         // Get configs
698*35238bceSAndroid Build Coastguard Worker         if (configCount != 0)
699*35238bceSAndroid Build Coastguard Worker         {
700*35238bceSAndroid Build Coastguard Worker             EGLBoolean result;
701*35238bceSAndroid Build Coastguard Worker 
702*35238bceSAndroid Build Coastguard Worker             result = egl.chooseConfig(m_display, attribList, &(configs[configs.size() - configCount]), configCount,
703*35238bceSAndroid Build Coastguard Worker                                       &configCount);
704*35238bceSAndroid Build Coastguard Worker             thread.getLog() << ThreadLog::BeginMessage << result << " = eglChooseConfig(" << m_display
705*35238bceSAndroid Build Coastguard Worker                             << ", { EGL_NONE }, &configs, " << configCount << ", " << configCount << ")"
706*35238bceSAndroid Build Coastguard Worker                             << ThreadLog::EndMessage;
707*35238bceSAndroid Build Coastguard Worker             EGLU_CHECK_MSG(egl, "eglChooseConfig()");
708*35238bceSAndroid Build Coastguard Worker 
709*35238bceSAndroid Build Coastguard Worker             if (!result)
710*35238bceSAndroid Build Coastguard Worker                 return false;
711*35238bceSAndroid Build Coastguard Worker         }
712*35238bceSAndroid Build Coastguard Worker 
713*35238bceSAndroid Build Coastguard Worker         // Pop configs to stop config list growing
714*35238bceSAndroid Build Coastguard Worker         if (configs.size() > 40)
715*35238bceSAndroid Build Coastguard Worker         {
716*35238bceSAndroid Build Coastguard Worker             configs.erase(configs.begin() + 40, configs.end());
717*35238bceSAndroid Build Coastguard Worker         }
718*35238bceSAndroid Build Coastguard Worker         else
719*35238bceSAndroid Build Coastguard Worker         {
720*35238bceSAndroid Build Coastguard Worker             const int popCount = rnd.getInt(0, (int)(configs.size() - 2));
721*35238bceSAndroid Build Coastguard Worker 
722*35238bceSAndroid Build Coastguard Worker             configs.erase(configs.begin() + (configs.size() - popCount), configs.end());
723*35238bceSAndroid Build Coastguard Worker         }
724*35238bceSAndroid Build Coastguard Worker     }
725*35238bceSAndroid Build Coastguard Worker 
726*35238bceSAndroid Build Coastguard Worker     {
727*35238bceSAndroid Build Coastguard Worker         // Perform queries on configs
728*35238bceSAndroid Build Coastguard Worker         std::vector<EGLint> attributes = {
729*35238bceSAndroid Build Coastguard Worker             EGL_BUFFER_SIZE,
730*35238bceSAndroid Build Coastguard Worker             EGL_RED_SIZE,
731*35238bceSAndroid Build Coastguard Worker             EGL_GREEN_SIZE,
732*35238bceSAndroid Build Coastguard Worker             EGL_BLUE_SIZE,
733*35238bceSAndroid Build Coastguard Worker             EGL_LUMINANCE_SIZE,
734*35238bceSAndroid Build Coastguard Worker             EGL_ALPHA_SIZE,
735*35238bceSAndroid Build Coastguard Worker             EGL_ALPHA_MASK_SIZE,
736*35238bceSAndroid Build Coastguard Worker             EGL_BIND_TO_TEXTURE_RGB,
737*35238bceSAndroid Build Coastguard Worker             EGL_BIND_TO_TEXTURE_RGBA,
738*35238bceSAndroid Build Coastguard Worker             EGL_COLOR_BUFFER_TYPE,
739*35238bceSAndroid Build Coastguard Worker             EGL_CONFIG_CAVEAT,
740*35238bceSAndroid Build Coastguard Worker             EGL_CONFIG_ID,
741*35238bceSAndroid Build Coastguard Worker             EGL_CONFORMANT,
742*35238bceSAndroid Build Coastguard Worker             EGL_DEPTH_SIZE,
743*35238bceSAndroid Build Coastguard Worker             EGL_LEVEL,
744*35238bceSAndroid Build Coastguard Worker             EGL_MAX_PBUFFER_WIDTH,
745*35238bceSAndroid Build Coastguard Worker             EGL_MAX_PBUFFER_HEIGHT,
746*35238bceSAndroid Build Coastguard Worker             EGL_MAX_PBUFFER_PIXELS,
747*35238bceSAndroid Build Coastguard Worker             EGL_MAX_SWAP_INTERVAL,
748*35238bceSAndroid Build Coastguard Worker             EGL_MIN_SWAP_INTERVAL,
749*35238bceSAndroid Build Coastguard Worker             EGL_NATIVE_RENDERABLE,
750*35238bceSAndroid Build Coastguard Worker             EGL_NATIVE_VISUAL_ID,
751*35238bceSAndroid Build Coastguard Worker             EGL_NATIVE_VISUAL_TYPE,
752*35238bceSAndroid Build Coastguard Worker             EGL_RENDERABLE_TYPE,
753*35238bceSAndroid Build Coastguard Worker             EGL_SAMPLE_BUFFERS,
754*35238bceSAndroid Build Coastguard Worker             EGL_SAMPLES,
755*35238bceSAndroid Build Coastguard Worker             EGL_STENCIL_SIZE,
756*35238bceSAndroid Build Coastguard Worker             EGL_SURFACE_TYPE,
757*35238bceSAndroid Build Coastguard Worker             EGL_TRANSPARENT_TYPE,
758*35238bceSAndroid Build Coastguard Worker             EGL_TRANSPARENT_RED_VALUE,
759*35238bceSAndroid Build Coastguard Worker             EGL_TRANSPARENT_GREEN_VALUE,
760*35238bceSAndroid Build Coastguard Worker             EGL_TRANSPARENT_BLUE_VALUE,
761*35238bceSAndroid Build Coastguard Worker         };
762*35238bceSAndroid Build Coastguard Worker 
763*35238bceSAndroid Build Coastguard Worker         if (eglu::hasExtension(egl, m_display, "EGL_ANDROID_recordable"))
764*35238bceSAndroid Build Coastguard Worker             attributes.emplace_back(EGL_RECORDABLE_ANDROID);
765*35238bceSAndroid Build Coastguard Worker 
766*35238bceSAndroid Build Coastguard Worker         for (int queryNdx = 0; queryNdx < m_query; queryNdx++)
767*35238bceSAndroid Build Coastguard Worker         {
768*35238bceSAndroid Build Coastguard Worker             const EGLint attribute = attributes[rnd.getInt(0, static_cast<int>(attributes.size()) - 1)];
769*35238bceSAndroid Build Coastguard Worker             EGLConfig config       = configs[rnd.getInt(0, (int)(configs.size() - 1))];
770*35238bceSAndroid Build Coastguard Worker             EGLint value;
771*35238bceSAndroid Build Coastguard Worker             EGLBoolean result;
772*35238bceSAndroid Build Coastguard Worker 
773*35238bceSAndroid Build Coastguard Worker             result = egl.getConfigAttrib(m_display, config, attribute, &value);
774*35238bceSAndroid Build Coastguard Worker             thread.getLog() << ThreadLog::BeginMessage << result << " = eglGetConfigAttrib(" << m_display << ", "
775*35238bceSAndroid Build Coastguard Worker                             << config << ", " << configAttributeToString(attribute) << ", " << value << ")"
776*35238bceSAndroid Build Coastguard Worker                             << ThreadLog::EndMessage;
777*35238bceSAndroid Build Coastguard Worker             EGLU_CHECK_MSG(egl, "eglGetConfigAttrib()");
778*35238bceSAndroid Build Coastguard Worker 
779*35238bceSAndroid Build Coastguard Worker             if (!result)
780*35238bceSAndroid Build Coastguard Worker                 return false;
781*35238bceSAndroid Build Coastguard Worker         }
782*35238bceSAndroid Build Coastguard Worker     }
783*35238bceSAndroid Build Coastguard Worker 
784*35238bceSAndroid Build Coastguard Worker     return true;
785*35238bceSAndroid Build Coastguard Worker }
786*35238bceSAndroid Build Coastguard Worker 
787*35238bceSAndroid Build Coastguard Worker class MultiThreadedObjectTest : public MultiThreadedTest
788*35238bceSAndroid Build Coastguard Worker {
789*35238bceSAndroid Build Coastguard Worker public:
790*35238bceSAndroid Build Coastguard Worker     enum Type
791*35238bceSAndroid Build Coastguard Worker     {
792*35238bceSAndroid Build Coastguard Worker         TYPE_PBUFFER       = (1 << 0),
793*35238bceSAndroid Build Coastguard Worker         TYPE_PIXMAP        = (1 << 1),
794*35238bceSAndroid Build Coastguard Worker         TYPE_WINDOW        = (1 << 2),
795*35238bceSAndroid Build Coastguard Worker         TYPE_SINGLE_WINDOW = (1 << 3),
796*35238bceSAndroid Build Coastguard Worker         TYPE_CONTEXT       = (1 << 4)
797*35238bceSAndroid Build Coastguard Worker     };
798*35238bceSAndroid Build Coastguard Worker 
799*35238bceSAndroid Build Coastguard Worker     MultiThreadedObjectTest(EglTestContext &context, const char *name, const char *description, uint32_t types);
800*35238bceSAndroid Build Coastguard Worker     ~MultiThreadedObjectTest(void);
801*35238bceSAndroid Build Coastguard Worker 
802*35238bceSAndroid Build Coastguard Worker     virtual void deinit(void);
803*35238bceSAndroid Build Coastguard Worker 
804*35238bceSAndroid Build Coastguard Worker     bool runThread(TestThread &thread);
805*35238bceSAndroid Build Coastguard Worker 
806*35238bceSAndroid Build Coastguard Worker     void createDestroyObjects(TestThread &thread, int count);
807*35238bceSAndroid Build Coastguard Worker     void pushObjectsToShared(TestThread &thread);
808*35238bceSAndroid Build Coastguard Worker     void pullObjectsFromShared(TestThread &thread, int pbufferCount, int pixmapCount, int windowCount,
809*35238bceSAndroid Build Coastguard Worker                                int contextCount);
810*35238bceSAndroid Build Coastguard Worker     void querySetSharedObjects(TestThread &thread, int count);
811*35238bceSAndroid Build Coastguard Worker     void destroyObjects(TestThread &thread);
812*35238bceSAndroid Build Coastguard Worker 
813*35238bceSAndroid Build Coastguard Worker private:
814*35238bceSAndroid Build Coastguard Worker     EGLConfig m_config;
815*35238bceSAndroid Build Coastguard Worker     de::Random m_rnd0;
816*35238bceSAndroid Build Coastguard Worker     de::Random m_rnd1;
817*35238bceSAndroid Build Coastguard Worker     Type m_types;
818*35238bceSAndroid Build Coastguard Worker 
819*35238bceSAndroid Build Coastguard Worker     volatile uint32_t m_hasWindow;
820*35238bceSAndroid Build Coastguard Worker 
821*35238bceSAndroid Build Coastguard Worker     vector<pair<eglu::NativePixmap *, EGLSurface>> m_sharedNativePixmaps;
822*35238bceSAndroid Build Coastguard Worker     vector<pair<eglu::NativePixmap *, EGLSurface>> m_nativePixmaps0;
823*35238bceSAndroid Build Coastguard Worker     vector<pair<eglu::NativePixmap *, EGLSurface>> m_nativePixmaps1;
824*35238bceSAndroid Build Coastguard Worker 
825*35238bceSAndroid Build Coastguard Worker     vector<pair<eglu::NativeWindow *, EGLSurface>> m_sharedNativeWindows;
826*35238bceSAndroid Build Coastguard Worker     vector<pair<eglu::NativeWindow *, EGLSurface>> m_nativeWindows0;
827*35238bceSAndroid Build Coastguard Worker     vector<pair<eglu::NativeWindow *, EGLSurface>> m_nativeWindows1;
828*35238bceSAndroid Build Coastguard Worker 
829*35238bceSAndroid Build Coastguard Worker     vector<EGLSurface> m_sharedPbuffers;
830*35238bceSAndroid Build Coastguard Worker     vector<EGLSurface> m_pbuffers0;
831*35238bceSAndroid Build Coastguard Worker     vector<EGLSurface> m_pbuffers1;
832*35238bceSAndroid Build Coastguard Worker 
833*35238bceSAndroid Build Coastguard Worker     vector<EGLContext> m_sharedContexts;
834*35238bceSAndroid Build Coastguard Worker     vector<EGLContext> m_contexts0;
835*35238bceSAndroid Build Coastguard Worker     vector<EGLContext> m_contexts1;
836*35238bceSAndroid Build Coastguard Worker };
837*35238bceSAndroid Build Coastguard Worker 
MultiThreadedObjectTest(EglTestContext & context,const char * name,const char * description,uint32_t type)838*35238bceSAndroid Build Coastguard Worker MultiThreadedObjectTest::MultiThreadedObjectTest(EglTestContext &context, const char *name, const char *description,
839*35238bceSAndroid Build Coastguard Worker                                                  uint32_t type)
840*35238bceSAndroid Build Coastguard Worker     : MultiThreadedTest(context, name, description, 2,
841*35238bceSAndroid Build Coastguard Worker                         20000000 /*us = 20s*/) // \todo [mika] Set timeout to something relevant to frameworks timeout?
842*35238bceSAndroid Build Coastguard Worker     , m_config(DE_NULL)
843*35238bceSAndroid Build Coastguard Worker     , m_rnd0(58204327)
844*35238bceSAndroid Build Coastguard Worker     , m_rnd1(230983)
845*35238bceSAndroid Build Coastguard Worker     , m_types((Type)type)
846*35238bceSAndroid Build Coastguard Worker     , m_hasWindow(0)
847*35238bceSAndroid Build Coastguard Worker {
848*35238bceSAndroid Build Coastguard Worker }
849*35238bceSAndroid Build Coastguard Worker 
~MultiThreadedObjectTest(void)850*35238bceSAndroid Build Coastguard Worker MultiThreadedObjectTest::~MultiThreadedObjectTest(void)
851*35238bceSAndroid Build Coastguard Worker {
852*35238bceSAndroid Build Coastguard Worker     deinit();
853*35238bceSAndroid Build Coastguard Worker }
854*35238bceSAndroid Build Coastguard Worker 
deinit(void)855*35238bceSAndroid Build Coastguard Worker void MultiThreadedObjectTest::deinit(void)
856*35238bceSAndroid Build Coastguard Worker {
857*35238bceSAndroid Build Coastguard Worker     const Library &egl = getLibrary();
858*35238bceSAndroid Build Coastguard Worker 
859*35238bceSAndroid Build Coastguard Worker     // Clear pbuffers
860*35238bceSAndroid Build Coastguard Worker     for (int pbufferNdx = 0; pbufferNdx < (int)m_pbuffers0.size(); pbufferNdx++)
861*35238bceSAndroid Build Coastguard Worker     {
862*35238bceSAndroid Build Coastguard Worker         if (m_pbuffers0[pbufferNdx] != EGL_NO_SURFACE)
863*35238bceSAndroid Build Coastguard Worker         {
864*35238bceSAndroid Build Coastguard Worker             egl.destroySurface(m_display, m_pbuffers0[pbufferNdx]);
865*35238bceSAndroid Build Coastguard Worker             EGLU_CHECK_MSG(egl, "eglDestroySurface()");
866*35238bceSAndroid Build Coastguard Worker             m_pbuffers0[pbufferNdx] = EGL_NO_SURFACE;
867*35238bceSAndroid Build Coastguard Worker         }
868*35238bceSAndroid Build Coastguard Worker     }
869*35238bceSAndroid Build Coastguard Worker     m_pbuffers0.clear();
870*35238bceSAndroid Build Coastguard Worker 
871*35238bceSAndroid Build Coastguard Worker     for (int pbufferNdx = 0; pbufferNdx < (int)m_pbuffers1.size(); pbufferNdx++)
872*35238bceSAndroid Build Coastguard Worker     {
873*35238bceSAndroid Build Coastguard Worker         if (m_pbuffers1[pbufferNdx] != EGL_NO_SURFACE)
874*35238bceSAndroid Build Coastguard Worker         {
875*35238bceSAndroid Build Coastguard Worker             egl.destroySurface(m_display, m_pbuffers1[pbufferNdx]);
876*35238bceSAndroid Build Coastguard Worker             EGLU_CHECK_MSG(egl, "eglDestroySurface()");
877*35238bceSAndroid Build Coastguard Worker             m_pbuffers1[pbufferNdx] = EGL_NO_SURFACE;
878*35238bceSAndroid Build Coastguard Worker         }
879*35238bceSAndroid Build Coastguard Worker     }
880*35238bceSAndroid Build Coastguard Worker     m_pbuffers1.clear();
881*35238bceSAndroid Build Coastguard Worker 
882*35238bceSAndroid Build Coastguard Worker     for (int pbufferNdx = 0; pbufferNdx < (int)m_sharedPbuffers.size(); pbufferNdx++)
883*35238bceSAndroid Build Coastguard Worker     {
884*35238bceSAndroid Build Coastguard Worker         if (m_sharedPbuffers[pbufferNdx] != EGL_NO_SURFACE)
885*35238bceSAndroid Build Coastguard Worker         {
886*35238bceSAndroid Build Coastguard Worker             egl.destroySurface(m_display, m_sharedPbuffers[pbufferNdx]);
887*35238bceSAndroid Build Coastguard Worker             EGLU_CHECK_MSG(egl, "eglDestroySurface()");
888*35238bceSAndroid Build Coastguard Worker             m_sharedPbuffers[pbufferNdx] = EGL_NO_SURFACE;
889*35238bceSAndroid Build Coastguard Worker         }
890*35238bceSAndroid Build Coastguard Worker     }
891*35238bceSAndroid Build Coastguard Worker     m_sharedPbuffers.clear();
892*35238bceSAndroid Build Coastguard Worker 
893*35238bceSAndroid Build Coastguard Worker     for (int contextNdx = 0; contextNdx < (int)m_sharedContexts.size(); contextNdx++)
894*35238bceSAndroid Build Coastguard Worker     {
895*35238bceSAndroid Build Coastguard Worker         if (m_sharedContexts[contextNdx] != EGL_NO_CONTEXT)
896*35238bceSAndroid Build Coastguard Worker         {
897*35238bceSAndroid Build Coastguard Worker             egl.destroyContext(m_display, m_sharedContexts[contextNdx]);
898*35238bceSAndroid Build Coastguard Worker             EGLU_CHECK_MSG(egl, "eglDestroyContext()");
899*35238bceSAndroid Build Coastguard Worker             m_sharedContexts[contextNdx] = EGL_NO_CONTEXT;
900*35238bceSAndroid Build Coastguard Worker         }
901*35238bceSAndroid Build Coastguard Worker     }
902*35238bceSAndroid Build Coastguard Worker     m_sharedContexts.clear();
903*35238bceSAndroid Build Coastguard Worker 
904*35238bceSAndroid Build Coastguard Worker     for (int contextNdx = 0; contextNdx < (int)m_contexts0.size(); contextNdx++)
905*35238bceSAndroid Build Coastguard Worker     {
906*35238bceSAndroid Build Coastguard Worker         if (m_contexts0[contextNdx] != EGL_NO_CONTEXT)
907*35238bceSAndroid Build Coastguard Worker         {
908*35238bceSAndroid Build Coastguard Worker             egl.destroyContext(m_display, m_contexts0[contextNdx]);
909*35238bceSAndroid Build Coastguard Worker             EGLU_CHECK_MSG(egl, "eglDestroyContext()");
910*35238bceSAndroid Build Coastguard Worker             m_contexts0[contextNdx] = EGL_NO_CONTEXT;
911*35238bceSAndroid Build Coastguard Worker         }
912*35238bceSAndroid Build Coastguard Worker     }
913*35238bceSAndroid Build Coastguard Worker     m_contexts0.clear();
914*35238bceSAndroid Build Coastguard Worker 
915*35238bceSAndroid Build Coastguard Worker     for (int contextNdx = 0; contextNdx < (int)m_contexts1.size(); contextNdx++)
916*35238bceSAndroid Build Coastguard Worker     {
917*35238bceSAndroid Build Coastguard Worker         if (m_contexts1[contextNdx] != EGL_NO_CONTEXT)
918*35238bceSAndroid Build Coastguard Worker         {
919*35238bceSAndroid Build Coastguard Worker             egl.destroyContext(m_display, m_contexts1[contextNdx]);
920*35238bceSAndroid Build Coastguard Worker             EGLU_CHECK_MSG(egl, "eglDestroyContext()");
921*35238bceSAndroid Build Coastguard Worker             m_contexts1[contextNdx] = EGL_NO_CONTEXT;
922*35238bceSAndroid Build Coastguard Worker         }
923*35238bceSAndroid Build Coastguard Worker     }
924*35238bceSAndroid Build Coastguard Worker     m_contexts1.clear();
925*35238bceSAndroid Build Coastguard Worker 
926*35238bceSAndroid Build Coastguard Worker     // Clear pixmaps
927*35238bceSAndroid Build Coastguard Worker     for (int pixmapNdx = 0; pixmapNdx < (int)m_nativePixmaps0.size(); pixmapNdx++)
928*35238bceSAndroid Build Coastguard Worker     {
929*35238bceSAndroid Build Coastguard Worker         if (m_nativePixmaps0[pixmapNdx].second != EGL_NO_SURFACE)
930*35238bceSAndroid Build Coastguard Worker             EGLU_CHECK_CALL(egl, destroySurface(m_display, m_nativePixmaps0[pixmapNdx].second));
931*35238bceSAndroid Build Coastguard Worker 
932*35238bceSAndroid Build Coastguard Worker         m_nativePixmaps0[pixmapNdx].second = EGL_NO_SURFACE;
933*35238bceSAndroid Build Coastguard Worker         delete m_nativePixmaps0[pixmapNdx].first;
934*35238bceSAndroid Build Coastguard Worker         m_nativePixmaps0[pixmapNdx].first = NULL;
935*35238bceSAndroid Build Coastguard Worker     }
936*35238bceSAndroid Build Coastguard Worker     m_nativePixmaps0.clear();
937*35238bceSAndroid Build Coastguard Worker 
938*35238bceSAndroid Build Coastguard Worker     for (int pixmapNdx = 0; pixmapNdx < (int)m_nativePixmaps1.size(); pixmapNdx++)
939*35238bceSAndroid Build Coastguard Worker     {
940*35238bceSAndroid Build Coastguard Worker         if (m_nativePixmaps1[pixmapNdx].second != EGL_NO_SURFACE)
941*35238bceSAndroid Build Coastguard Worker             EGLU_CHECK_CALL(egl, destroySurface(m_display, m_nativePixmaps1[pixmapNdx].second));
942*35238bceSAndroid Build Coastguard Worker 
943*35238bceSAndroid Build Coastguard Worker         m_nativePixmaps1[pixmapNdx].second = EGL_NO_SURFACE;
944*35238bceSAndroid Build Coastguard Worker         delete m_nativePixmaps1[pixmapNdx].first;
945*35238bceSAndroid Build Coastguard Worker         m_nativePixmaps1[pixmapNdx].first = NULL;
946*35238bceSAndroid Build Coastguard Worker     }
947*35238bceSAndroid Build Coastguard Worker     m_nativePixmaps1.clear();
948*35238bceSAndroid Build Coastguard Worker 
949*35238bceSAndroid Build Coastguard Worker     for (int pixmapNdx = 0; pixmapNdx < (int)m_sharedNativePixmaps.size(); pixmapNdx++)
950*35238bceSAndroid Build Coastguard Worker     {
951*35238bceSAndroid Build Coastguard Worker         if (m_sharedNativePixmaps[pixmapNdx].second != EGL_NO_SURFACE)
952*35238bceSAndroid Build Coastguard Worker             EGLU_CHECK_CALL(egl, destroySurface(m_display, m_sharedNativePixmaps[pixmapNdx].second));
953*35238bceSAndroid Build Coastguard Worker 
954*35238bceSAndroid Build Coastguard Worker         m_sharedNativePixmaps[pixmapNdx].second = EGL_NO_SURFACE;
955*35238bceSAndroid Build Coastguard Worker         delete m_sharedNativePixmaps[pixmapNdx].first;
956*35238bceSAndroid Build Coastguard Worker         m_sharedNativePixmaps[pixmapNdx].first = NULL;
957*35238bceSAndroid Build Coastguard Worker     }
958*35238bceSAndroid Build Coastguard Worker     m_sharedNativePixmaps.clear();
959*35238bceSAndroid Build Coastguard Worker 
960*35238bceSAndroid Build Coastguard Worker     // Clear windows
961*35238bceSAndroid Build Coastguard Worker     for (int windowNdx = 0; windowNdx < (int)m_nativeWindows1.size(); windowNdx++)
962*35238bceSAndroid Build Coastguard Worker     {
963*35238bceSAndroid Build Coastguard Worker         if (m_nativeWindows1[windowNdx].second != EGL_NO_SURFACE)
964*35238bceSAndroid Build Coastguard Worker             EGLU_CHECK_CALL(egl, destroySurface(m_display, m_nativeWindows1[windowNdx].second));
965*35238bceSAndroid Build Coastguard Worker 
966*35238bceSAndroid Build Coastguard Worker         m_nativeWindows1[windowNdx].second = EGL_NO_SURFACE;
967*35238bceSAndroid Build Coastguard Worker         delete m_nativeWindows1[windowNdx].first;
968*35238bceSAndroid Build Coastguard Worker         m_nativeWindows1[windowNdx].first = NULL;
969*35238bceSAndroid Build Coastguard Worker     }
970*35238bceSAndroid Build Coastguard Worker     m_nativeWindows1.clear();
971*35238bceSAndroid Build Coastguard Worker 
972*35238bceSAndroid Build Coastguard Worker     for (int windowNdx = 0; windowNdx < (int)m_nativeWindows0.size(); windowNdx++)
973*35238bceSAndroid Build Coastguard Worker     {
974*35238bceSAndroid Build Coastguard Worker         if (m_nativeWindows0[windowNdx].second != EGL_NO_SURFACE)
975*35238bceSAndroid Build Coastguard Worker             EGLU_CHECK_CALL(egl, destroySurface(m_display, m_nativeWindows0[windowNdx].second));
976*35238bceSAndroid Build Coastguard Worker 
977*35238bceSAndroid Build Coastguard Worker         m_nativeWindows0[windowNdx].second = EGL_NO_SURFACE;
978*35238bceSAndroid Build Coastguard Worker         delete m_nativeWindows0[windowNdx].first;
979*35238bceSAndroid Build Coastguard Worker         m_nativeWindows0[windowNdx].first = NULL;
980*35238bceSAndroid Build Coastguard Worker     }
981*35238bceSAndroid Build Coastguard Worker     m_nativeWindows0.clear();
982*35238bceSAndroid Build Coastguard Worker 
983*35238bceSAndroid Build Coastguard Worker     for (int windowNdx = 0; windowNdx < (int)m_sharedNativeWindows.size(); windowNdx++)
984*35238bceSAndroid Build Coastguard Worker     {
985*35238bceSAndroid Build Coastguard Worker         if (m_sharedNativeWindows[windowNdx].second != EGL_NO_SURFACE)
986*35238bceSAndroid Build Coastguard Worker             EGLU_CHECK_CALL(egl, destroySurface(m_display, m_sharedNativeWindows[windowNdx].second));
987*35238bceSAndroid Build Coastguard Worker 
988*35238bceSAndroid Build Coastguard Worker         m_sharedNativeWindows[windowNdx].second = EGL_NO_SURFACE;
989*35238bceSAndroid Build Coastguard Worker         delete m_sharedNativeWindows[windowNdx].first;
990*35238bceSAndroid Build Coastguard Worker         m_sharedNativeWindows[windowNdx].first = NULL;
991*35238bceSAndroid Build Coastguard Worker     }
992*35238bceSAndroid Build Coastguard Worker     m_sharedNativeWindows.clear();
993*35238bceSAndroid Build Coastguard Worker 
994*35238bceSAndroid Build Coastguard Worker     MultiThreadedTest::deinit();
995*35238bceSAndroid Build Coastguard Worker }
996*35238bceSAndroid Build Coastguard Worker 
runThread(TestThread & thread)997*35238bceSAndroid Build Coastguard Worker bool MultiThreadedObjectTest::runThread(TestThread &thread)
998*35238bceSAndroid Build Coastguard Worker {
999*35238bceSAndroid Build Coastguard Worker     const Library &egl = getLibrary();
1000*35238bceSAndroid Build Coastguard Worker 
1001*35238bceSAndroid Build Coastguard Worker     if (thread.getId() == 0)
1002*35238bceSAndroid Build Coastguard Worker     {
1003*35238bceSAndroid Build Coastguard Worker         EGLint surfaceTypes = 0;
1004*35238bceSAndroid Build Coastguard Worker 
1005*35238bceSAndroid Build Coastguard Worker         if ((m_types & TYPE_WINDOW) != 0)
1006*35238bceSAndroid Build Coastguard Worker             surfaceTypes |= EGL_WINDOW_BIT;
1007*35238bceSAndroid Build Coastguard Worker 
1008*35238bceSAndroid Build Coastguard Worker         if ((m_types & TYPE_PBUFFER) != 0)
1009*35238bceSAndroid Build Coastguard Worker             surfaceTypes |= EGL_PBUFFER_BIT;
1010*35238bceSAndroid Build Coastguard Worker 
1011*35238bceSAndroid Build Coastguard Worker         if ((m_types & TYPE_PIXMAP) != 0)
1012*35238bceSAndroid Build Coastguard Worker             surfaceTypes |= EGL_PIXMAP_BIT;
1013*35238bceSAndroid Build Coastguard Worker 
1014*35238bceSAndroid Build Coastguard Worker         EGLint configCount;
1015*35238bceSAndroid Build Coastguard Worker         EGLint attribList[] = {EGL_SURFACE_TYPE, surfaceTypes, EGL_RENDERABLE_TYPE, EGL_OPENGL_ES2_BIT, EGL_NONE};
1016*35238bceSAndroid Build Coastguard Worker 
1017*35238bceSAndroid Build Coastguard Worker         EGLU_CHECK_CALL(egl, chooseConfig(m_display, attribList, &m_config, 1, &configCount));
1018*35238bceSAndroid Build Coastguard Worker 
1019*35238bceSAndroid Build Coastguard Worker         if (configCount == 0)
1020*35238bceSAndroid Build Coastguard Worker             TCU_THROW(NotSupportedError, "No usable config found");
1021*35238bceSAndroid Build Coastguard Worker     }
1022*35238bceSAndroid Build Coastguard Worker 
1023*35238bceSAndroid Build Coastguard Worker     barrier();
1024*35238bceSAndroid Build Coastguard Worker 
1025*35238bceSAndroid Build Coastguard Worker     // Create / Destroy Objects
1026*35238bceSAndroid Build Coastguard Worker     if ((m_types & TYPE_SINGLE_WINDOW) != 0 && (m_types & TYPE_PBUFFER) == 0 && (m_types & TYPE_PIXMAP) == 0 &&
1027*35238bceSAndroid Build Coastguard Worker         (m_types & TYPE_CONTEXT) == 0)
1028*35238bceSAndroid Build Coastguard Worker     {
1029*35238bceSAndroid Build Coastguard Worker         if (thread.getId() == 0)
1030*35238bceSAndroid Build Coastguard Worker             createDestroyObjects(thread, 1);
1031*35238bceSAndroid Build Coastguard Worker     }
1032*35238bceSAndroid Build Coastguard Worker     else
1033*35238bceSAndroid Build Coastguard Worker         createDestroyObjects(thread, 100);
1034*35238bceSAndroid Build Coastguard Worker 
1035*35238bceSAndroid Build Coastguard Worker     // Push first threads objects to shared
1036*35238bceSAndroid Build Coastguard Worker     if (thread.getId() == 0)
1037*35238bceSAndroid Build Coastguard Worker         pushObjectsToShared(thread);
1038*35238bceSAndroid Build Coastguard Worker 
1039*35238bceSAndroid Build Coastguard Worker     barrier();
1040*35238bceSAndroid Build Coastguard Worker 
1041*35238bceSAndroid Build Coastguard Worker     // Push second threads objects to shared
1042*35238bceSAndroid Build Coastguard Worker     if (thread.getId() == 1)
1043*35238bceSAndroid Build Coastguard Worker         pushObjectsToShared(thread);
1044*35238bceSAndroid Build Coastguard Worker 
1045*35238bceSAndroid Build Coastguard Worker     barrier();
1046*35238bceSAndroid Build Coastguard Worker 
1047*35238bceSAndroid Build Coastguard Worker     // Make queries from shared surfaces
1048*35238bceSAndroid Build Coastguard Worker     querySetSharedObjects(thread, 100);
1049*35238bceSAndroid Build Coastguard Worker 
1050*35238bceSAndroid Build Coastguard Worker     barrier();
1051*35238bceSAndroid Build Coastguard Worker 
1052*35238bceSAndroid Build Coastguard Worker     // Pull surfaces for first thread from shared surfaces
1053*35238bceSAndroid Build Coastguard Worker     if (thread.getId() == 0)
1054*35238bceSAndroid Build Coastguard Worker         pullObjectsFromShared(thread, (int)(m_sharedPbuffers.size() / 2), (int)(m_sharedNativePixmaps.size() / 2),
1055*35238bceSAndroid Build Coastguard Worker                               (int)(m_sharedNativeWindows.size() / 2), (int)(m_sharedContexts.size() / 2));
1056*35238bceSAndroid Build Coastguard Worker 
1057*35238bceSAndroid Build Coastguard Worker     barrier();
1058*35238bceSAndroid Build Coastguard Worker 
1059*35238bceSAndroid Build Coastguard Worker     // Pull surfaces for second thread from shared surfaces
1060*35238bceSAndroid Build Coastguard Worker     if (thread.getId() == 1)
1061*35238bceSAndroid Build Coastguard Worker         pullObjectsFromShared(thread, (int)m_sharedPbuffers.size(), (int)m_sharedNativePixmaps.size(),
1062*35238bceSAndroid Build Coastguard Worker                               (int)m_sharedNativeWindows.size(), (int)m_sharedContexts.size());
1063*35238bceSAndroid Build Coastguard Worker 
1064*35238bceSAndroid Build Coastguard Worker     barrier();
1065*35238bceSAndroid Build Coastguard Worker 
1066*35238bceSAndroid Build Coastguard Worker     // Create / Destroy Objects
1067*35238bceSAndroid Build Coastguard Worker     if ((m_types & TYPE_SINGLE_WINDOW) == 0)
1068*35238bceSAndroid Build Coastguard Worker         createDestroyObjects(thread, 100);
1069*35238bceSAndroid Build Coastguard Worker 
1070*35238bceSAndroid Build Coastguard Worker     // Destroy surfaces
1071*35238bceSAndroid Build Coastguard Worker     destroyObjects(thread);
1072*35238bceSAndroid Build Coastguard Worker 
1073*35238bceSAndroid Build Coastguard Worker     return true;
1074*35238bceSAndroid Build Coastguard Worker }
1075*35238bceSAndroid Build Coastguard Worker 
createDestroyObjects(TestThread & thread,int count)1076*35238bceSAndroid Build Coastguard Worker void MultiThreadedObjectTest::createDestroyObjects(TestThread &thread, int count)
1077*35238bceSAndroid Build Coastguard Worker {
1078*35238bceSAndroid Build Coastguard Worker     const Library &egl           = getLibrary();
1079*35238bceSAndroid Build Coastguard Worker     de::Random &rnd              = (thread.getId() == 0 ? m_rnd0 : m_rnd1);
1080*35238bceSAndroid Build Coastguard Worker     vector<EGLSurface> &pbuffers = (thread.getId() == 0 ? m_pbuffers0 : m_pbuffers1);
1081*35238bceSAndroid Build Coastguard Worker     vector<pair<eglu::NativeWindow *, EGLSurface>> &windows =
1082*35238bceSAndroid Build Coastguard Worker         (thread.getId() == 0 ? m_nativeWindows0 : m_nativeWindows1);
1083*35238bceSAndroid Build Coastguard Worker     vector<pair<eglu::NativePixmap *, EGLSurface>> &pixmaps =
1084*35238bceSAndroid Build Coastguard Worker         (thread.getId() == 0 ? m_nativePixmaps0 : m_nativePixmaps1);
1085*35238bceSAndroid Build Coastguard Worker     vector<EGLContext> &contexts = (thread.getId() == 0 ? m_contexts0 : m_contexts1);
1086*35238bceSAndroid Build Coastguard Worker     set<Type> objectTypes;
1087*35238bceSAndroid Build Coastguard Worker 
1088*35238bceSAndroid Build Coastguard Worker     if ((m_types & TYPE_PBUFFER) != 0)
1089*35238bceSAndroid Build Coastguard Worker         objectTypes.insert(TYPE_PBUFFER);
1090*35238bceSAndroid Build Coastguard Worker 
1091*35238bceSAndroid Build Coastguard Worker     if ((m_types & TYPE_PIXMAP) != 0)
1092*35238bceSAndroid Build Coastguard Worker         objectTypes.insert(TYPE_PIXMAP);
1093*35238bceSAndroid Build Coastguard Worker 
1094*35238bceSAndroid Build Coastguard Worker     if ((m_types & TYPE_WINDOW) != 0)
1095*35238bceSAndroid Build Coastguard Worker         objectTypes.insert(TYPE_WINDOW);
1096*35238bceSAndroid Build Coastguard Worker 
1097*35238bceSAndroid Build Coastguard Worker     if ((m_types & TYPE_CONTEXT) != 0)
1098*35238bceSAndroid Build Coastguard Worker         objectTypes.insert(TYPE_CONTEXT);
1099*35238bceSAndroid Build Coastguard Worker 
1100*35238bceSAndroid Build Coastguard Worker     for (int createDestroyNdx = 0; createDestroyNdx < count; createDestroyNdx++)
1101*35238bceSAndroid Build Coastguard Worker     {
1102*35238bceSAndroid Build Coastguard Worker         bool create;
1103*35238bceSAndroid Build Coastguard Worker         Type type;
1104*35238bceSAndroid Build Coastguard Worker 
1105*35238bceSAndroid Build Coastguard Worker         if (pbuffers.size() > 5 && ((m_types & TYPE_PBUFFER) != 0))
1106*35238bceSAndroid Build Coastguard Worker         {
1107*35238bceSAndroid Build Coastguard Worker             create = false;
1108*35238bceSAndroid Build Coastguard Worker             type   = TYPE_PBUFFER;
1109*35238bceSAndroid Build Coastguard Worker         }
1110*35238bceSAndroid Build Coastguard Worker         else if (windows.size() > 5 && ((m_types & TYPE_WINDOW) != 0))
1111*35238bceSAndroid Build Coastguard Worker         {
1112*35238bceSAndroid Build Coastguard Worker             create = false;
1113*35238bceSAndroid Build Coastguard Worker             type   = TYPE_WINDOW;
1114*35238bceSAndroid Build Coastguard Worker         }
1115*35238bceSAndroid Build Coastguard Worker         else if (pixmaps.size() > 5 && ((m_types & TYPE_PIXMAP) != 0))
1116*35238bceSAndroid Build Coastguard Worker         {
1117*35238bceSAndroid Build Coastguard Worker             create = false;
1118*35238bceSAndroid Build Coastguard Worker             type   = TYPE_PIXMAP;
1119*35238bceSAndroid Build Coastguard Worker         }
1120*35238bceSAndroid Build Coastguard Worker         else if (contexts.size() > 5 && ((m_types & TYPE_CONTEXT) != 0))
1121*35238bceSAndroid Build Coastguard Worker         {
1122*35238bceSAndroid Build Coastguard Worker             create = false;
1123*35238bceSAndroid Build Coastguard Worker             type   = TYPE_CONTEXT;
1124*35238bceSAndroid Build Coastguard Worker         }
1125*35238bceSAndroid Build Coastguard Worker         else if (pbuffers.size() < 3 && ((m_types & TYPE_PBUFFER) != 0))
1126*35238bceSAndroid Build Coastguard Worker         {
1127*35238bceSAndroid Build Coastguard Worker             create = true;
1128*35238bceSAndroid Build Coastguard Worker             type   = TYPE_PBUFFER;
1129*35238bceSAndroid Build Coastguard Worker         }
1130*35238bceSAndroid Build Coastguard Worker         else if (pixmaps.size() < 3 && ((m_types & TYPE_PIXMAP) != 0))
1131*35238bceSAndroid Build Coastguard Worker         {
1132*35238bceSAndroid Build Coastguard Worker             create = true;
1133*35238bceSAndroid Build Coastguard Worker             type   = TYPE_PIXMAP;
1134*35238bceSAndroid Build Coastguard Worker         }
1135*35238bceSAndroid Build Coastguard Worker         else if (contexts.size() < 3 && ((m_types & TYPE_CONTEXT) != 0))
1136*35238bceSAndroid Build Coastguard Worker         {
1137*35238bceSAndroid Build Coastguard Worker             create = true;
1138*35238bceSAndroid Build Coastguard Worker             type   = TYPE_CONTEXT;
1139*35238bceSAndroid Build Coastguard Worker         }
1140*35238bceSAndroid Build Coastguard Worker         else if (windows.size() < 3 && ((m_types & TYPE_WINDOW) != 0) && ((m_types & TYPE_SINGLE_WINDOW) == 0))
1141*35238bceSAndroid Build Coastguard Worker         {
1142*35238bceSAndroid Build Coastguard Worker             create = true;
1143*35238bceSAndroid Build Coastguard Worker             type   = TYPE_WINDOW;
1144*35238bceSAndroid Build Coastguard Worker         }
1145*35238bceSAndroid Build Coastguard Worker         else if (windows.empty() && (m_hasWindow == 0) && ((m_types & TYPE_WINDOW) != 0) &&
1146*35238bceSAndroid Build Coastguard Worker                  ((m_types & TYPE_SINGLE_WINDOW) != 0))
1147*35238bceSAndroid Build Coastguard Worker         {
1148*35238bceSAndroid Build Coastguard Worker             create = true;
1149*35238bceSAndroid Build Coastguard Worker             type   = TYPE_WINDOW;
1150*35238bceSAndroid Build Coastguard Worker         }
1151*35238bceSAndroid Build Coastguard Worker         else
1152*35238bceSAndroid Build Coastguard Worker         {
1153*35238bceSAndroid Build Coastguard Worker             create = rnd.getBool();
1154*35238bceSAndroid Build Coastguard Worker 
1155*35238bceSAndroid Build Coastguard Worker             if (!create && windows.empty())
1156*35238bceSAndroid Build Coastguard Worker                 objectTypes.erase(TYPE_WINDOW);
1157*35238bceSAndroid Build Coastguard Worker 
1158*35238bceSAndroid Build Coastguard Worker             type = rnd.choose<Type>(objectTypes.begin(), objectTypes.end());
1159*35238bceSAndroid Build Coastguard Worker         }
1160*35238bceSAndroid Build Coastguard Worker 
1161*35238bceSAndroid Build Coastguard Worker         if (create)
1162*35238bceSAndroid Build Coastguard Worker         {
1163*35238bceSAndroid Build Coastguard Worker             switch (type)
1164*35238bceSAndroid Build Coastguard Worker             {
1165*35238bceSAndroid Build Coastguard Worker             case TYPE_PBUFFER:
1166*35238bceSAndroid Build Coastguard Worker             {
1167*35238bceSAndroid Build Coastguard Worker                 EGLSurface surface;
1168*35238bceSAndroid Build Coastguard Worker 
1169*35238bceSAndroid Build Coastguard Worker                 const EGLint attributes[] = {EGL_WIDTH, 64, EGL_HEIGHT, 64,
1170*35238bceSAndroid Build Coastguard Worker 
1171*35238bceSAndroid Build Coastguard Worker                                              EGL_NONE};
1172*35238bceSAndroid Build Coastguard Worker 
1173*35238bceSAndroid Build Coastguard Worker                 surface = egl.createPbufferSurface(m_display, m_config, attributes);
1174*35238bceSAndroid Build Coastguard Worker                 thread.getLog() << ThreadLog::BeginMessage << surface << " = eglCreatePbufferSurface(" << m_display
1175*35238bceSAndroid Build Coastguard Worker                                 << ", " << m_config << ", { EGL_WIDTH, 64, EGL_HEIGHT, 64, EGL_NONE })"
1176*35238bceSAndroid Build Coastguard Worker                                 << ThreadLog::EndMessage;
1177*35238bceSAndroid Build Coastguard Worker                 EGLU_CHECK_MSG(egl, "eglCreatePbufferSurface()");
1178*35238bceSAndroid Build Coastguard Worker 
1179*35238bceSAndroid Build Coastguard Worker                 pbuffers.push_back(surface);
1180*35238bceSAndroid Build Coastguard Worker 
1181*35238bceSAndroid Build Coastguard Worker                 break;
1182*35238bceSAndroid Build Coastguard Worker             }
1183*35238bceSAndroid Build Coastguard Worker 
1184*35238bceSAndroid Build Coastguard Worker             case TYPE_WINDOW:
1185*35238bceSAndroid Build Coastguard Worker             {
1186*35238bceSAndroid Build Coastguard Worker                 const eglu::NativeWindowFactory &windowFactory =
1187*35238bceSAndroid Build Coastguard Worker                     eglu::selectNativeWindowFactory(m_eglTestCtx.getNativeDisplayFactory(), m_testCtx.getCommandLine());
1188*35238bceSAndroid Build Coastguard Worker 
1189*35238bceSAndroid Build Coastguard Worker                 if ((m_types & TYPE_SINGLE_WINDOW) != 0)
1190*35238bceSAndroid Build Coastguard Worker                 {
1191*35238bceSAndroid Build Coastguard Worker                     if (deAtomicCompareExchange32(&m_hasWindow, 0, 1) == 0)
1192*35238bceSAndroid Build Coastguard Worker                     {
1193*35238bceSAndroid Build Coastguard Worker                         eglu::NativeWindow *window = DE_NULL;
1194*35238bceSAndroid Build Coastguard Worker                         EGLSurface surface         = EGL_NO_SURFACE;
1195*35238bceSAndroid Build Coastguard Worker 
1196*35238bceSAndroid Build Coastguard Worker                         try
1197*35238bceSAndroid Build Coastguard Worker                         {
1198*35238bceSAndroid Build Coastguard Worker                             window = windowFactory.createWindow(
1199*35238bceSAndroid Build Coastguard Worker                                 &m_eglTestCtx.getNativeDisplay(), m_display, m_config, DE_NULL,
1200*35238bceSAndroid Build Coastguard Worker                                 eglu::WindowParams(64, 64, eglu::parseWindowVisibility(m_testCtx.getCommandLine())));
1201*35238bceSAndroid Build Coastguard Worker                             surface = eglu::createWindowSurface(m_eglTestCtx.getNativeDisplay(), *window, m_display,
1202*35238bceSAndroid Build Coastguard Worker                                                                 m_config, DE_NULL);
1203*35238bceSAndroid Build Coastguard Worker 
1204*35238bceSAndroid Build Coastguard Worker                             thread.getLog() << ThreadLog::BeginMessage << surface << " = eglCreateWindowSurface()"
1205*35238bceSAndroid Build Coastguard Worker                                             << ThreadLog::EndMessage;
1206*35238bceSAndroid Build Coastguard Worker                             windows.push_back(std::make_pair(window, surface));
1207*35238bceSAndroid Build Coastguard Worker                         }
1208*35238bceSAndroid Build Coastguard Worker                         catch (const std::exception &)
1209*35238bceSAndroid Build Coastguard Worker                         {
1210*35238bceSAndroid Build Coastguard Worker                             if (surface != EGL_NO_SURFACE)
1211*35238bceSAndroid Build Coastguard Worker                                 EGLU_CHECK_CALL(egl, destroySurface(m_display, surface));
1212*35238bceSAndroid Build Coastguard Worker                             delete window;
1213*35238bceSAndroid Build Coastguard Worker                             m_hasWindow = 0;
1214*35238bceSAndroid Build Coastguard Worker                             throw;
1215*35238bceSAndroid Build Coastguard Worker                         }
1216*35238bceSAndroid Build Coastguard Worker                     }
1217*35238bceSAndroid Build Coastguard Worker                     else
1218*35238bceSAndroid Build Coastguard Worker                     {
1219*35238bceSAndroid Build Coastguard Worker                         createDestroyNdx--;
1220*35238bceSAndroid Build Coastguard Worker                     }
1221*35238bceSAndroid Build Coastguard Worker                 }
1222*35238bceSAndroid Build Coastguard Worker                 else
1223*35238bceSAndroid Build Coastguard Worker                 {
1224*35238bceSAndroid Build Coastguard Worker                     eglu::NativeWindow *window = DE_NULL;
1225*35238bceSAndroid Build Coastguard Worker                     EGLSurface surface         = EGL_NO_SURFACE;
1226*35238bceSAndroid Build Coastguard Worker 
1227*35238bceSAndroid Build Coastguard Worker                     try
1228*35238bceSAndroid Build Coastguard Worker                     {
1229*35238bceSAndroid Build Coastguard Worker                         window = windowFactory.createWindow(
1230*35238bceSAndroid Build Coastguard Worker                             &m_eglTestCtx.getNativeDisplay(), m_display, m_config, DE_NULL,
1231*35238bceSAndroid Build Coastguard Worker                             eglu::WindowParams(64, 64, eglu::parseWindowVisibility(m_testCtx.getCommandLine())));
1232*35238bceSAndroid Build Coastguard Worker                         surface = eglu::createWindowSurface(m_eglTestCtx.getNativeDisplay(), *window, m_display,
1233*35238bceSAndroid Build Coastguard Worker                                                             m_config, DE_NULL);
1234*35238bceSAndroid Build Coastguard Worker 
1235*35238bceSAndroid Build Coastguard Worker                         thread.getLog() << ThreadLog::BeginMessage << surface << " = eglCreateWindowSurface()"
1236*35238bceSAndroid Build Coastguard Worker                                         << ThreadLog::EndMessage;
1237*35238bceSAndroid Build Coastguard Worker                         windows.push_back(std::make_pair(window, surface));
1238*35238bceSAndroid Build Coastguard Worker                     }
1239*35238bceSAndroid Build Coastguard Worker                     catch (const std::exception &)
1240*35238bceSAndroid Build Coastguard Worker                     {
1241*35238bceSAndroid Build Coastguard Worker                         if (surface != EGL_NO_SURFACE)
1242*35238bceSAndroid Build Coastguard Worker                             EGLU_CHECK_CALL(egl, destroySurface(m_display, surface));
1243*35238bceSAndroid Build Coastguard Worker                         delete window;
1244*35238bceSAndroid Build Coastguard Worker                         throw;
1245*35238bceSAndroid Build Coastguard Worker                     }
1246*35238bceSAndroid Build Coastguard Worker                 }
1247*35238bceSAndroid Build Coastguard Worker                 break;
1248*35238bceSAndroid Build Coastguard Worker             }
1249*35238bceSAndroid Build Coastguard Worker 
1250*35238bceSAndroid Build Coastguard Worker             case TYPE_PIXMAP:
1251*35238bceSAndroid Build Coastguard Worker             {
1252*35238bceSAndroid Build Coastguard Worker                 const eglu::NativePixmapFactory &pixmapFactory =
1253*35238bceSAndroid Build Coastguard Worker                     eglu::selectNativePixmapFactory(m_eglTestCtx.getNativeDisplayFactory(), m_testCtx.getCommandLine());
1254*35238bceSAndroid Build Coastguard Worker                 eglu::NativePixmap *pixmap = DE_NULL;
1255*35238bceSAndroid Build Coastguard Worker                 EGLSurface surface         = EGL_NO_SURFACE;
1256*35238bceSAndroid Build Coastguard Worker 
1257*35238bceSAndroid Build Coastguard Worker                 try
1258*35238bceSAndroid Build Coastguard Worker                 {
1259*35238bceSAndroid Build Coastguard Worker                     pixmap  = pixmapFactory.createPixmap(&m_eglTestCtx.getNativeDisplay(), m_display, m_config, DE_NULL,
1260*35238bceSAndroid Build Coastguard Worker                                                          64, 64);
1261*35238bceSAndroid Build Coastguard Worker                     surface = eglu::createPixmapSurface(m_eglTestCtx.getNativeDisplay(), *pixmap, m_display, m_config,
1262*35238bceSAndroid Build Coastguard Worker                                                         DE_NULL);
1263*35238bceSAndroid Build Coastguard Worker 
1264*35238bceSAndroid Build Coastguard Worker                     thread.getLog() << ThreadLog::BeginMessage << surface << " = eglCreatePixmapSurface()"
1265*35238bceSAndroid Build Coastguard Worker                                     << ThreadLog::EndMessage;
1266*35238bceSAndroid Build Coastguard Worker                     pixmaps.push_back(std::make_pair(pixmap, surface));
1267*35238bceSAndroid Build Coastguard Worker                 }
1268*35238bceSAndroid Build Coastguard Worker                 catch (const std::exception &)
1269*35238bceSAndroid Build Coastguard Worker                 {
1270*35238bceSAndroid Build Coastguard Worker                     if (surface != EGL_NO_SURFACE)
1271*35238bceSAndroid Build Coastguard Worker                         EGLU_CHECK_CALL(egl, destroySurface(m_display, surface));
1272*35238bceSAndroid Build Coastguard Worker                     delete pixmap;
1273*35238bceSAndroid Build Coastguard Worker                     throw;
1274*35238bceSAndroid Build Coastguard Worker                 }
1275*35238bceSAndroid Build Coastguard Worker                 break;
1276*35238bceSAndroid Build Coastguard Worker             }
1277*35238bceSAndroid Build Coastguard Worker 
1278*35238bceSAndroid Build Coastguard Worker             case TYPE_CONTEXT:
1279*35238bceSAndroid Build Coastguard Worker             {
1280*35238bceSAndroid Build Coastguard Worker                 EGLContext context;
1281*35238bceSAndroid Build Coastguard Worker 
1282*35238bceSAndroid Build Coastguard Worker                 EGLU_CHECK_CALL(egl, bindAPI(EGL_OPENGL_ES_API));
1283*35238bceSAndroid Build Coastguard Worker                 thread.getLog() << ThreadLog::BeginMessage << "eglBindAPI(EGL_OPENGL_ES_API)" << ThreadLog::EndMessage;
1284*35238bceSAndroid Build Coastguard Worker 
1285*35238bceSAndroid Build Coastguard Worker                 const EGLint attributes[] = {EGL_CONTEXT_CLIENT_VERSION, 2, EGL_NONE};
1286*35238bceSAndroid Build Coastguard Worker 
1287*35238bceSAndroid Build Coastguard Worker                 context = egl.createContext(m_display, m_config, EGL_NO_CONTEXT, attributes);
1288*35238bceSAndroid Build Coastguard Worker                 thread.getLog() << ThreadLog::BeginMessage << context << " = eglCreateContext(" << m_display << ", "
1289*35238bceSAndroid Build Coastguard Worker                                 << m_config << ", EGL_NO_CONTEXT, { EGL_CONTEXT_CLIENT_VERSION, 2, EGL_NONE })"
1290*35238bceSAndroid Build Coastguard Worker                                 << ThreadLog::EndMessage;
1291*35238bceSAndroid Build Coastguard Worker                 EGLU_CHECK_MSG(egl, "eglCreateContext()");
1292*35238bceSAndroid Build Coastguard Worker                 contexts.push_back(context);
1293*35238bceSAndroid Build Coastguard Worker                 break;
1294*35238bceSAndroid Build Coastguard Worker             }
1295*35238bceSAndroid Build Coastguard Worker 
1296*35238bceSAndroid Build Coastguard Worker             default:
1297*35238bceSAndroid Build Coastguard Worker                 DE_ASSERT(false);
1298*35238bceSAndroid Build Coastguard Worker             }
1299*35238bceSAndroid Build Coastguard Worker         }
1300*35238bceSAndroid Build Coastguard Worker         else
1301*35238bceSAndroid Build Coastguard Worker         {
1302*35238bceSAndroid Build Coastguard Worker             switch (type)
1303*35238bceSAndroid Build Coastguard Worker             {
1304*35238bceSAndroid Build Coastguard Worker             case TYPE_PBUFFER:
1305*35238bceSAndroid Build Coastguard Worker             {
1306*35238bceSAndroid Build Coastguard Worker                 const int pbufferNdx = rnd.getInt(0, (int)(pbuffers.size() - 1));
1307*35238bceSAndroid Build Coastguard Worker                 EGLBoolean result;
1308*35238bceSAndroid Build Coastguard Worker 
1309*35238bceSAndroid Build Coastguard Worker                 result = egl.destroySurface(m_display, pbuffers[pbufferNdx]);
1310*35238bceSAndroid Build Coastguard Worker                 thread.getLog() << ThreadLog::BeginMessage << result << " = eglDestroySurface(" << m_display << ", "
1311*35238bceSAndroid Build Coastguard Worker                                 << pbuffers[pbufferNdx] << ")" << ThreadLog::EndMessage;
1312*35238bceSAndroid Build Coastguard Worker                 EGLU_CHECK_MSG(egl, "eglDestroySurface()");
1313*35238bceSAndroid Build Coastguard Worker 
1314*35238bceSAndroid Build Coastguard Worker                 pbuffers.erase(pbuffers.begin() + pbufferNdx);
1315*35238bceSAndroid Build Coastguard Worker 
1316*35238bceSAndroid Build Coastguard Worker                 break;
1317*35238bceSAndroid Build Coastguard Worker             }
1318*35238bceSAndroid Build Coastguard Worker 
1319*35238bceSAndroid Build Coastguard Worker             case TYPE_WINDOW:
1320*35238bceSAndroid Build Coastguard Worker             {
1321*35238bceSAndroid Build Coastguard Worker                 const int windowNdx = rnd.getInt(0, (int)(windows.size() - 1));
1322*35238bceSAndroid Build Coastguard Worker 
1323*35238bceSAndroid Build Coastguard Worker                 thread.getLog() << ThreadLog::BeginMessage << "eglDestroySurface(" << m_display << ", "
1324*35238bceSAndroid Build Coastguard Worker                                 << windows[windowNdx].second << ")" << ThreadLog::EndMessage;
1325*35238bceSAndroid Build Coastguard Worker 
1326*35238bceSAndroid Build Coastguard Worker                 EGLU_CHECK_CALL(egl, destroySurface(m_display, windows[windowNdx].second));
1327*35238bceSAndroid Build Coastguard Worker                 windows[windowNdx].second = EGL_NO_SURFACE;
1328*35238bceSAndroid Build Coastguard Worker                 delete windows[windowNdx].first;
1329*35238bceSAndroid Build Coastguard Worker                 windows[windowNdx].first = DE_NULL;
1330*35238bceSAndroid Build Coastguard Worker                 windows.erase(windows.begin() + windowNdx);
1331*35238bceSAndroid Build Coastguard Worker 
1332*35238bceSAndroid Build Coastguard Worker                 if ((m_types & TYPE_SINGLE_WINDOW) != 0)
1333*35238bceSAndroid Build Coastguard Worker                     m_hasWindow = 0;
1334*35238bceSAndroid Build Coastguard Worker 
1335*35238bceSAndroid Build Coastguard Worker                 break;
1336*35238bceSAndroid Build Coastguard Worker             }
1337*35238bceSAndroid Build Coastguard Worker 
1338*35238bceSAndroid Build Coastguard Worker             case TYPE_PIXMAP:
1339*35238bceSAndroid Build Coastguard Worker             {
1340*35238bceSAndroid Build Coastguard Worker                 const int pixmapNdx = rnd.getInt(0, (int)(pixmaps.size() - 1));
1341*35238bceSAndroid Build Coastguard Worker 
1342*35238bceSAndroid Build Coastguard Worker                 thread.getLog() << ThreadLog::BeginMessage << "eglDestroySurface(" << m_display << ", "
1343*35238bceSAndroid Build Coastguard Worker                                 << pixmaps[pixmapNdx].second << ")" << ThreadLog::EndMessage;
1344*35238bceSAndroid Build Coastguard Worker                 EGLU_CHECK_CALL(egl, destroySurface(m_display, pixmaps[pixmapNdx].second));
1345*35238bceSAndroid Build Coastguard Worker                 pixmaps[pixmapNdx].second = EGL_NO_SURFACE;
1346*35238bceSAndroid Build Coastguard Worker                 delete pixmaps[pixmapNdx].first;
1347*35238bceSAndroid Build Coastguard Worker                 pixmaps[pixmapNdx].first = DE_NULL;
1348*35238bceSAndroid Build Coastguard Worker                 pixmaps.erase(pixmaps.begin() + pixmapNdx);
1349*35238bceSAndroid Build Coastguard Worker 
1350*35238bceSAndroid Build Coastguard Worker                 break;
1351*35238bceSAndroid Build Coastguard Worker             }
1352*35238bceSAndroid Build Coastguard Worker 
1353*35238bceSAndroid Build Coastguard Worker             case TYPE_CONTEXT:
1354*35238bceSAndroid Build Coastguard Worker             {
1355*35238bceSAndroid Build Coastguard Worker                 const int contextNdx = rnd.getInt(0, (int)(contexts.size() - 1));
1356*35238bceSAndroid Build Coastguard Worker 
1357*35238bceSAndroid Build Coastguard Worker                 EGLU_CHECK_CALL(egl, destroyContext(m_display, contexts[contextNdx]));
1358*35238bceSAndroid Build Coastguard Worker                 thread.getLog() << ThreadLog::BeginMessage << "eglDestroyContext(" << m_display << ", "
1359*35238bceSAndroid Build Coastguard Worker                                 << contexts[contextNdx] << ")" << ThreadLog::EndMessage;
1360*35238bceSAndroid Build Coastguard Worker                 contexts.erase(contexts.begin() + contextNdx);
1361*35238bceSAndroid Build Coastguard Worker 
1362*35238bceSAndroid Build Coastguard Worker                 break;
1363*35238bceSAndroid Build Coastguard Worker             }
1364*35238bceSAndroid Build Coastguard Worker 
1365*35238bceSAndroid Build Coastguard Worker             default:
1366*35238bceSAndroid Build Coastguard Worker                 DE_ASSERT(false);
1367*35238bceSAndroid Build Coastguard Worker             }
1368*35238bceSAndroid Build Coastguard Worker         }
1369*35238bceSAndroid Build Coastguard Worker     }
1370*35238bceSAndroid Build Coastguard Worker }
1371*35238bceSAndroid Build Coastguard Worker 
pushObjectsToShared(TestThread & thread)1372*35238bceSAndroid Build Coastguard Worker void MultiThreadedObjectTest::pushObjectsToShared(TestThread &thread)
1373*35238bceSAndroid Build Coastguard Worker {
1374*35238bceSAndroid Build Coastguard Worker     vector<EGLSurface> &pbuffers = (thread.getId() == 0 ? m_pbuffers0 : m_pbuffers1);
1375*35238bceSAndroid Build Coastguard Worker     vector<pair<eglu::NativeWindow *, EGLSurface>> &windows =
1376*35238bceSAndroid Build Coastguard Worker         (thread.getId() == 0 ? m_nativeWindows0 : m_nativeWindows1);
1377*35238bceSAndroid Build Coastguard Worker     vector<pair<eglu::NativePixmap *, EGLSurface>> &pixmaps =
1378*35238bceSAndroid Build Coastguard Worker         (thread.getId() == 0 ? m_nativePixmaps0 : m_nativePixmaps1);
1379*35238bceSAndroid Build Coastguard Worker     vector<EGLContext> &contexts = (thread.getId() == 0 ? m_contexts0 : m_contexts1);
1380*35238bceSAndroid Build Coastguard Worker 
1381*35238bceSAndroid Build Coastguard Worker     for (int pbufferNdx = 0; pbufferNdx < (int)pbuffers.size(); pbufferNdx++)
1382*35238bceSAndroid Build Coastguard Worker         m_sharedPbuffers.push_back(pbuffers[pbufferNdx]);
1383*35238bceSAndroid Build Coastguard Worker 
1384*35238bceSAndroid Build Coastguard Worker     pbuffers.clear();
1385*35238bceSAndroid Build Coastguard Worker 
1386*35238bceSAndroid Build Coastguard Worker     for (int windowNdx = 0; windowNdx < (int)windows.size(); windowNdx++)
1387*35238bceSAndroid Build Coastguard Worker         m_sharedNativeWindows.push_back(windows[windowNdx]);
1388*35238bceSAndroid Build Coastguard Worker 
1389*35238bceSAndroid Build Coastguard Worker     windows.clear();
1390*35238bceSAndroid Build Coastguard Worker 
1391*35238bceSAndroid Build Coastguard Worker     for (int pixmapNdx = 0; pixmapNdx < (int)pixmaps.size(); pixmapNdx++)
1392*35238bceSAndroid Build Coastguard Worker         m_sharedNativePixmaps.push_back(pixmaps[pixmapNdx]);
1393*35238bceSAndroid Build Coastguard Worker 
1394*35238bceSAndroid Build Coastguard Worker     pixmaps.clear();
1395*35238bceSAndroid Build Coastguard Worker 
1396*35238bceSAndroid Build Coastguard Worker     for (int contextNdx = 0; contextNdx < (int)contexts.size(); contextNdx++)
1397*35238bceSAndroid Build Coastguard Worker         m_sharedContexts.push_back(contexts[contextNdx]);
1398*35238bceSAndroid Build Coastguard Worker 
1399*35238bceSAndroid Build Coastguard Worker     contexts.clear();
1400*35238bceSAndroid Build Coastguard Worker }
1401*35238bceSAndroid Build Coastguard Worker 
pullObjectsFromShared(TestThread & thread,int pbufferCount,int pixmapCount,int windowCount,int contextCount)1402*35238bceSAndroid Build Coastguard Worker void MultiThreadedObjectTest::pullObjectsFromShared(TestThread &thread, int pbufferCount, int pixmapCount,
1403*35238bceSAndroid Build Coastguard Worker                                                     int windowCount, int contextCount)
1404*35238bceSAndroid Build Coastguard Worker {
1405*35238bceSAndroid Build Coastguard Worker     de::Random &rnd              = (thread.getId() == 0 ? m_rnd0 : m_rnd1);
1406*35238bceSAndroid Build Coastguard Worker     vector<EGLSurface> &pbuffers = (thread.getId() == 0 ? m_pbuffers0 : m_pbuffers1);
1407*35238bceSAndroid Build Coastguard Worker     vector<pair<eglu::NativeWindow *, EGLSurface>> &windows =
1408*35238bceSAndroid Build Coastguard Worker         (thread.getId() == 0 ? m_nativeWindows0 : m_nativeWindows1);
1409*35238bceSAndroid Build Coastguard Worker     vector<pair<eglu::NativePixmap *, EGLSurface>> &pixmaps =
1410*35238bceSAndroid Build Coastguard Worker         (thread.getId() == 0 ? m_nativePixmaps0 : m_nativePixmaps1);
1411*35238bceSAndroid Build Coastguard Worker     vector<EGLContext> &contexts = (thread.getId() == 0 ? m_contexts0 : m_contexts1);
1412*35238bceSAndroid Build Coastguard Worker 
1413*35238bceSAndroid Build Coastguard Worker     for (int pbufferNdx = 0; pbufferNdx < pbufferCount; pbufferNdx++)
1414*35238bceSAndroid Build Coastguard Worker     {
1415*35238bceSAndroid Build Coastguard Worker         const int ndx = rnd.getInt(0, (int)(m_sharedPbuffers.size() - 1));
1416*35238bceSAndroid Build Coastguard Worker 
1417*35238bceSAndroid Build Coastguard Worker         pbuffers.push_back(m_sharedPbuffers[ndx]);
1418*35238bceSAndroid Build Coastguard Worker         m_sharedPbuffers.erase(m_sharedPbuffers.begin() + ndx);
1419*35238bceSAndroid Build Coastguard Worker     }
1420*35238bceSAndroid Build Coastguard Worker 
1421*35238bceSAndroid Build Coastguard Worker     for (int pixmapNdx = 0; pixmapNdx < pixmapCount; pixmapNdx++)
1422*35238bceSAndroid Build Coastguard Worker     {
1423*35238bceSAndroid Build Coastguard Worker         const int ndx = rnd.getInt(0, (int)(m_sharedNativePixmaps.size() - 1));
1424*35238bceSAndroid Build Coastguard Worker 
1425*35238bceSAndroid Build Coastguard Worker         pixmaps.push_back(m_sharedNativePixmaps[ndx]);
1426*35238bceSAndroid Build Coastguard Worker         m_sharedNativePixmaps.erase(m_sharedNativePixmaps.begin() + ndx);
1427*35238bceSAndroid Build Coastguard Worker     }
1428*35238bceSAndroid Build Coastguard Worker 
1429*35238bceSAndroid Build Coastguard Worker     for (int windowNdx = 0; windowNdx < windowCount; windowNdx++)
1430*35238bceSAndroid Build Coastguard Worker     {
1431*35238bceSAndroid Build Coastguard Worker         const int ndx = rnd.getInt(0, (int)(m_sharedNativeWindows.size() - 1));
1432*35238bceSAndroid Build Coastguard Worker 
1433*35238bceSAndroid Build Coastguard Worker         windows.push_back(m_sharedNativeWindows[ndx]);
1434*35238bceSAndroid Build Coastguard Worker         m_sharedNativeWindows.erase(m_sharedNativeWindows.begin() + ndx);
1435*35238bceSAndroid Build Coastguard Worker     }
1436*35238bceSAndroid Build Coastguard Worker 
1437*35238bceSAndroid Build Coastguard Worker     for (int contextNdx = 0; contextNdx < contextCount; contextNdx++)
1438*35238bceSAndroid Build Coastguard Worker     {
1439*35238bceSAndroid Build Coastguard Worker         const int ndx = rnd.getInt(0, (int)(m_sharedContexts.size() - 1));
1440*35238bceSAndroid Build Coastguard Worker 
1441*35238bceSAndroid Build Coastguard Worker         contexts.push_back(m_sharedContexts[ndx]);
1442*35238bceSAndroid Build Coastguard Worker         m_sharedContexts.erase(m_sharedContexts.begin() + ndx);
1443*35238bceSAndroid Build Coastguard Worker     }
1444*35238bceSAndroid Build Coastguard Worker }
1445*35238bceSAndroid Build Coastguard Worker 
querySetSharedObjects(TestThread & thread,int count)1446*35238bceSAndroid Build Coastguard Worker void MultiThreadedObjectTest::querySetSharedObjects(TestThread &thread, int count)
1447*35238bceSAndroid Build Coastguard Worker {
1448*35238bceSAndroid Build Coastguard Worker     const Library &egl = getLibrary();
1449*35238bceSAndroid Build Coastguard Worker     de::Random &rnd    = (thread.getId() == 0 ? m_rnd0 : m_rnd1);
1450*35238bceSAndroid Build Coastguard Worker     vector<Type> objectTypes;
1451*35238bceSAndroid Build Coastguard Worker 
1452*35238bceSAndroid Build Coastguard Worker     if ((m_types & TYPE_PBUFFER) != 0)
1453*35238bceSAndroid Build Coastguard Worker         objectTypes.push_back(TYPE_PBUFFER);
1454*35238bceSAndroid Build Coastguard Worker 
1455*35238bceSAndroid Build Coastguard Worker     if ((m_types & TYPE_PIXMAP) != 0)
1456*35238bceSAndroid Build Coastguard Worker         objectTypes.push_back(TYPE_PIXMAP);
1457*35238bceSAndroid Build Coastguard Worker 
1458*35238bceSAndroid Build Coastguard Worker     if (!m_sharedNativeWindows.empty() && (m_types & TYPE_WINDOW) != 0)
1459*35238bceSAndroid Build Coastguard Worker         objectTypes.push_back(TYPE_WINDOW);
1460*35238bceSAndroid Build Coastguard Worker 
1461*35238bceSAndroid Build Coastguard Worker     if ((m_types & TYPE_CONTEXT) != 0)
1462*35238bceSAndroid Build Coastguard Worker         objectTypes.push_back(TYPE_CONTEXT);
1463*35238bceSAndroid Build Coastguard Worker 
1464*35238bceSAndroid Build Coastguard Worker     for (int queryNdx = 0; queryNdx < count; queryNdx++)
1465*35238bceSAndroid Build Coastguard Worker     {
1466*35238bceSAndroid Build Coastguard Worker         const Type type    = rnd.choose<Type>(objectTypes.begin(), objectTypes.end());
1467*35238bceSAndroid Build Coastguard Worker         EGLSurface surface = EGL_NO_SURFACE;
1468*35238bceSAndroid Build Coastguard Worker         EGLContext context = EGL_NO_CONTEXT;
1469*35238bceSAndroid Build Coastguard Worker 
1470*35238bceSAndroid Build Coastguard Worker         switch (type)
1471*35238bceSAndroid Build Coastguard Worker         {
1472*35238bceSAndroid Build Coastguard Worker         case TYPE_PBUFFER:
1473*35238bceSAndroid Build Coastguard Worker             surface = m_sharedPbuffers[rnd.getInt(0, (int)(m_sharedPbuffers.size() - 1))];
1474*35238bceSAndroid Build Coastguard Worker             break;
1475*35238bceSAndroid Build Coastguard Worker 
1476*35238bceSAndroid Build Coastguard Worker         case TYPE_PIXMAP:
1477*35238bceSAndroid Build Coastguard Worker             surface = m_sharedNativePixmaps[rnd.getInt(0, (int)(m_sharedNativePixmaps.size() - 1))].second;
1478*35238bceSAndroid Build Coastguard Worker             break;
1479*35238bceSAndroid Build Coastguard Worker 
1480*35238bceSAndroid Build Coastguard Worker         case TYPE_WINDOW:
1481*35238bceSAndroid Build Coastguard Worker             surface = m_sharedNativeWindows[rnd.getInt(0, (int)(m_sharedNativeWindows.size() - 1))].second;
1482*35238bceSAndroid Build Coastguard Worker             break;
1483*35238bceSAndroid Build Coastguard Worker 
1484*35238bceSAndroid Build Coastguard Worker         case TYPE_CONTEXT:
1485*35238bceSAndroid Build Coastguard Worker             context = m_sharedContexts[rnd.getInt(0, (int)(m_sharedContexts.size() - 1))];
1486*35238bceSAndroid Build Coastguard Worker             break;
1487*35238bceSAndroid Build Coastguard Worker 
1488*35238bceSAndroid Build Coastguard Worker         default:
1489*35238bceSAndroid Build Coastguard Worker             DE_ASSERT(false);
1490*35238bceSAndroid Build Coastguard Worker         }
1491*35238bceSAndroid Build Coastguard Worker 
1492*35238bceSAndroid Build Coastguard Worker         if (surface != EGL_NO_SURFACE)
1493*35238bceSAndroid Build Coastguard Worker         {
1494*35238bceSAndroid Build Coastguard Worker             static const EGLint queryAttributes[] = {EGL_LARGEST_PBUFFER, EGL_HEIGHT, EGL_WIDTH};
1495*35238bceSAndroid Build Coastguard Worker 
1496*35238bceSAndroid Build Coastguard Worker             const EGLint attribute = queryAttributes[rnd.getInt(0, DE_LENGTH_OF_ARRAY(queryAttributes) - 1)];
1497*35238bceSAndroid Build Coastguard Worker             EGLBoolean result;
1498*35238bceSAndroid Build Coastguard Worker             EGLint value;
1499*35238bceSAndroid Build Coastguard Worker 
1500*35238bceSAndroid Build Coastguard Worker             result = egl.querySurface(m_display, surface, attribute, &value);
1501*35238bceSAndroid Build Coastguard Worker             thread.getLog() << ThreadLog::BeginMessage << result << " = eglQuerySurface(" << m_display << ", "
1502*35238bceSAndroid Build Coastguard Worker                             << surface << ", " << attribute << ", " << value << ")" << ThreadLog::EndMessage;
1503*35238bceSAndroid Build Coastguard Worker             EGLU_CHECK_MSG(egl, "eglQuerySurface()");
1504*35238bceSAndroid Build Coastguard Worker         }
1505*35238bceSAndroid Build Coastguard Worker         else if (context != EGL_NO_CONTEXT)
1506*35238bceSAndroid Build Coastguard Worker         {
1507*35238bceSAndroid Build Coastguard Worker             static const EGLint attributes[] = {EGL_CONFIG_ID, EGL_CONTEXT_CLIENT_TYPE, EGL_CONTEXT_CLIENT_VERSION,
1508*35238bceSAndroid Build Coastguard Worker                                                 EGL_RENDER_BUFFER};
1509*35238bceSAndroid Build Coastguard Worker 
1510*35238bceSAndroid Build Coastguard Worker             const EGLint attribute = attributes[rnd.getInt(0, DE_LENGTH_OF_ARRAY(attributes) - 1)];
1511*35238bceSAndroid Build Coastguard Worker             EGLint value;
1512*35238bceSAndroid Build Coastguard Worker             EGLBoolean result;
1513*35238bceSAndroid Build Coastguard Worker 
1514*35238bceSAndroid Build Coastguard Worker             result = egl.queryContext(m_display, context, attribute, &value);
1515*35238bceSAndroid Build Coastguard Worker             thread.getLog() << ThreadLog::BeginMessage << result << " = eglQueryContext(" << m_display << ", "
1516*35238bceSAndroid Build Coastguard Worker                             << context << ", " << attribute << ", " << value << ")" << ThreadLog::EndMessage;
1517*35238bceSAndroid Build Coastguard Worker             EGLU_CHECK_MSG(egl, "eglQueryContext()");
1518*35238bceSAndroid Build Coastguard Worker         }
1519*35238bceSAndroid Build Coastguard Worker         else
1520*35238bceSAndroid Build Coastguard Worker             DE_ASSERT(false);
1521*35238bceSAndroid Build Coastguard Worker     }
1522*35238bceSAndroid Build Coastguard Worker }
1523*35238bceSAndroid Build Coastguard Worker 
destroyObjects(TestThread & thread)1524*35238bceSAndroid Build Coastguard Worker void MultiThreadedObjectTest::destroyObjects(TestThread &thread)
1525*35238bceSAndroid Build Coastguard Worker {
1526*35238bceSAndroid Build Coastguard Worker     const Library &egl           = getLibrary();
1527*35238bceSAndroid Build Coastguard Worker     vector<EGLSurface> &pbuffers = (thread.getId() == 0 ? m_pbuffers0 : m_pbuffers1);
1528*35238bceSAndroid Build Coastguard Worker     vector<pair<eglu::NativeWindow *, EGLSurface>> &windows =
1529*35238bceSAndroid Build Coastguard Worker         (thread.getId() == 0 ? m_nativeWindows0 : m_nativeWindows1);
1530*35238bceSAndroid Build Coastguard Worker     vector<pair<eglu::NativePixmap *, EGLSurface>> &pixmaps =
1531*35238bceSAndroid Build Coastguard Worker         (thread.getId() == 0 ? m_nativePixmaps0 : m_nativePixmaps1);
1532*35238bceSAndroid Build Coastguard Worker     vector<EGLContext> &contexts = (thread.getId() == 0 ? m_contexts0 : m_contexts1);
1533*35238bceSAndroid Build Coastguard Worker 
1534*35238bceSAndroid Build Coastguard Worker     for (int pbufferNdx = 0; pbufferNdx < (int)pbuffers.size(); pbufferNdx++)
1535*35238bceSAndroid Build Coastguard Worker     {
1536*35238bceSAndroid Build Coastguard Worker         if (pbuffers[pbufferNdx] != EGL_NO_SURFACE)
1537*35238bceSAndroid Build Coastguard Worker         {
1538*35238bceSAndroid Build Coastguard Worker             // Destroy EGLSurface
1539*35238bceSAndroid Build Coastguard Worker             EGLBoolean result;
1540*35238bceSAndroid Build Coastguard Worker 
1541*35238bceSAndroid Build Coastguard Worker             result = egl.destroySurface(m_display, pbuffers[pbufferNdx]);
1542*35238bceSAndroid Build Coastguard Worker             thread.getLog() << ThreadLog::BeginMessage << result << " = eglDestroySurface(" << m_display << ", "
1543*35238bceSAndroid Build Coastguard Worker                             << pbuffers[pbufferNdx] << ")" << ThreadLog::EndMessage;
1544*35238bceSAndroid Build Coastguard Worker             EGLU_CHECK_MSG(egl, "eglDestroySurface()");
1545*35238bceSAndroid Build Coastguard Worker             pbuffers[pbufferNdx] = EGL_NO_SURFACE;
1546*35238bceSAndroid Build Coastguard Worker         }
1547*35238bceSAndroid Build Coastguard Worker     }
1548*35238bceSAndroid Build Coastguard Worker     pbuffers.clear();
1549*35238bceSAndroid Build Coastguard Worker 
1550*35238bceSAndroid Build Coastguard Worker     for (int windowNdx = 0; windowNdx < (int)windows.size(); windowNdx++)
1551*35238bceSAndroid Build Coastguard Worker     {
1552*35238bceSAndroid Build Coastguard Worker         if (windows[windowNdx].second != EGL_NO_SURFACE)
1553*35238bceSAndroid Build Coastguard Worker         {
1554*35238bceSAndroid Build Coastguard Worker             thread.getLog() << ThreadLog::BeginMessage << "eglDestroySurface(" << m_display << ", "
1555*35238bceSAndroid Build Coastguard Worker                             << windows[windowNdx].second << ")" << ThreadLog::EndMessage;
1556*35238bceSAndroid Build Coastguard Worker             EGLU_CHECK_CALL(egl, destroySurface(m_display, windows[windowNdx].second));
1557*35238bceSAndroid Build Coastguard Worker             windows[windowNdx].second = EGL_NO_SURFACE;
1558*35238bceSAndroid Build Coastguard Worker         }
1559*35238bceSAndroid Build Coastguard Worker 
1560*35238bceSAndroid Build Coastguard Worker         if (windows[windowNdx].first)
1561*35238bceSAndroid Build Coastguard Worker         {
1562*35238bceSAndroid Build Coastguard Worker             delete windows[windowNdx].first;
1563*35238bceSAndroid Build Coastguard Worker             windows[windowNdx].first = NULL;
1564*35238bceSAndroid Build Coastguard Worker         }
1565*35238bceSAndroid Build Coastguard Worker     }
1566*35238bceSAndroid Build Coastguard Worker     windows.clear();
1567*35238bceSAndroid Build Coastguard Worker 
1568*35238bceSAndroid Build Coastguard Worker     for (int pixmapNdx = 0; pixmapNdx < (int)pixmaps.size(); pixmapNdx++)
1569*35238bceSAndroid Build Coastguard Worker     {
1570*35238bceSAndroid Build Coastguard Worker         if (pixmaps[pixmapNdx].first != EGL_NO_SURFACE)
1571*35238bceSAndroid Build Coastguard Worker         {
1572*35238bceSAndroid Build Coastguard Worker             thread.getLog() << ThreadLog::BeginMessage << "eglDestroySurface(" << m_display << ", "
1573*35238bceSAndroid Build Coastguard Worker                             << pixmaps[pixmapNdx].second << ")" << ThreadLog::EndMessage;
1574*35238bceSAndroid Build Coastguard Worker             EGLU_CHECK_CALL(egl, destroySurface(m_display, pixmaps[pixmapNdx].second));
1575*35238bceSAndroid Build Coastguard Worker             pixmaps[pixmapNdx].second = EGL_NO_SURFACE;
1576*35238bceSAndroid Build Coastguard Worker         }
1577*35238bceSAndroid Build Coastguard Worker 
1578*35238bceSAndroid Build Coastguard Worker         if (pixmaps[pixmapNdx].first)
1579*35238bceSAndroid Build Coastguard Worker         {
1580*35238bceSAndroid Build Coastguard Worker             delete pixmaps[pixmapNdx].first;
1581*35238bceSAndroid Build Coastguard Worker             pixmaps[pixmapNdx].first = NULL;
1582*35238bceSAndroid Build Coastguard Worker         }
1583*35238bceSAndroid Build Coastguard Worker     }
1584*35238bceSAndroid Build Coastguard Worker     pixmaps.clear();
1585*35238bceSAndroid Build Coastguard Worker 
1586*35238bceSAndroid Build Coastguard Worker     for (int contextNdx = 0; contextNdx < (int)contexts.size(); contextNdx++)
1587*35238bceSAndroid Build Coastguard Worker     {
1588*35238bceSAndroid Build Coastguard Worker         if (contexts[contextNdx] != EGL_NO_CONTEXT)
1589*35238bceSAndroid Build Coastguard Worker         {
1590*35238bceSAndroid Build Coastguard Worker             EGLU_CHECK_CALL(egl, destroyContext(m_display, contexts[contextNdx]));
1591*35238bceSAndroid Build Coastguard Worker             thread.getLog() << ThreadLog::BeginMessage << "eglDestroyContext(" << m_display << ", "
1592*35238bceSAndroid Build Coastguard Worker                             << contexts[contextNdx] << ")" << ThreadLog::EndMessage;
1593*35238bceSAndroid Build Coastguard Worker             contexts[contextNdx] = EGL_NO_CONTEXT;
1594*35238bceSAndroid Build Coastguard Worker         }
1595*35238bceSAndroid Build Coastguard Worker     }
1596*35238bceSAndroid Build Coastguard Worker     contexts.clear();
1597*35238bceSAndroid Build Coastguard Worker }
1598*35238bceSAndroid Build Coastguard Worker 
MultiThreadedTests(EglTestContext & context)1599*35238bceSAndroid Build Coastguard Worker MultiThreadedTests::MultiThreadedTests(EglTestContext &context)
1600*35238bceSAndroid Build Coastguard Worker     : TestCaseGroup(context, "multithread", "Multithreaded EGL tests")
1601*35238bceSAndroid Build Coastguard Worker {
1602*35238bceSAndroid Build Coastguard Worker }
1603*35238bceSAndroid Build Coastguard Worker 
init(void)1604*35238bceSAndroid Build Coastguard Worker void MultiThreadedTests::init(void)
1605*35238bceSAndroid Build Coastguard Worker {
1606*35238bceSAndroid Build Coastguard Worker     // Config tests
1607*35238bceSAndroid Build Coastguard Worker     addChild(new MultiThreadedConfigTest(m_eglTestCtx, "config", "", 30, 30, 30));
1608*35238bceSAndroid Build Coastguard Worker 
1609*35238bceSAndroid Build Coastguard Worker     // Object tests
1610*35238bceSAndroid Build Coastguard Worker     addChild(new MultiThreadedObjectTest(m_eglTestCtx, "pbuffer", "", MultiThreadedObjectTest::TYPE_PBUFFER));
1611*35238bceSAndroid Build Coastguard Worker     addChild(new MultiThreadedObjectTest(m_eglTestCtx, "pixmap", "", MultiThreadedObjectTest::TYPE_PIXMAP));
1612*35238bceSAndroid Build Coastguard Worker     addChild(new MultiThreadedObjectTest(m_eglTestCtx, "window", "", MultiThreadedObjectTest::TYPE_WINDOW));
1613*35238bceSAndroid Build Coastguard Worker     addChild(new MultiThreadedObjectTest(m_eglTestCtx, "single_window", "",
1614*35238bceSAndroid Build Coastguard Worker                                          MultiThreadedObjectTest::TYPE_WINDOW |
1615*35238bceSAndroid Build Coastguard Worker                                              MultiThreadedObjectTest::TYPE_SINGLE_WINDOW));
1616*35238bceSAndroid Build Coastguard Worker     addChild(new MultiThreadedObjectTest(m_eglTestCtx, "context", "", MultiThreadedObjectTest::TYPE_CONTEXT));
1617*35238bceSAndroid Build Coastguard Worker 
1618*35238bceSAndroid Build Coastguard Worker     addChild(new MultiThreadedObjectTest(m_eglTestCtx, "pbuffer_pixmap", "",
1619*35238bceSAndroid Build Coastguard Worker                                          MultiThreadedObjectTest::TYPE_PBUFFER | MultiThreadedObjectTest::TYPE_PIXMAP));
1620*35238bceSAndroid Build Coastguard Worker     addChild(new MultiThreadedObjectTest(m_eglTestCtx, "pbuffer_window", "",
1621*35238bceSAndroid Build Coastguard Worker                                          MultiThreadedObjectTest::TYPE_PBUFFER | MultiThreadedObjectTest::TYPE_WINDOW));
1622*35238bceSAndroid Build Coastguard Worker     addChild(new MultiThreadedObjectTest(m_eglTestCtx, "pbuffer_single_window", "",
1623*35238bceSAndroid Build Coastguard Worker                                          MultiThreadedObjectTest::TYPE_PBUFFER | MultiThreadedObjectTest::TYPE_WINDOW |
1624*35238bceSAndroid Build Coastguard Worker                                              MultiThreadedObjectTest::TYPE_SINGLE_WINDOW));
1625*35238bceSAndroid Build Coastguard Worker     addChild(
1626*35238bceSAndroid Build Coastguard Worker         new MultiThreadedObjectTest(m_eglTestCtx, "pbuffer_context", "",
1627*35238bceSAndroid Build Coastguard Worker                                     MultiThreadedObjectTest::TYPE_PBUFFER | MultiThreadedObjectTest::TYPE_CONTEXT));
1628*35238bceSAndroid Build Coastguard Worker 
1629*35238bceSAndroid Build Coastguard Worker     addChild(new MultiThreadedObjectTest(m_eglTestCtx, "pixmap_window", "",
1630*35238bceSAndroid Build Coastguard Worker                                          MultiThreadedObjectTest::TYPE_PIXMAP | MultiThreadedObjectTest::TYPE_WINDOW));
1631*35238bceSAndroid Build Coastguard Worker     addChild(new MultiThreadedObjectTest(m_eglTestCtx, "pixmap_single_window", "",
1632*35238bceSAndroid Build Coastguard Worker                                          MultiThreadedObjectTest::TYPE_PIXMAP | MultiThreadedObjectTest::TYPE_WINDOW |
1633*35238bceSAndroid Build Coastguard Worker                                              MultiThreadedObjectTest::TYPE_SINGLE_WINDOW));
1634*35238bceSAndroid Build Coastguard Worker     addChild(new MultiThreadedObjectTest(m_eglTestCtx, "pixmap_context", "",
1635*35238bceSAndroid Build Coastguard Worker                                          MultiThreadedObjectTest::TYPE_PIXMAP | MultiThreadedObjectTest::TYPE_CONTEXT));
1636*35238bceSAndroid Build Coastguard Worker 
1637*35238bceSAndroid Build Coastguard Worker     addChild(new MultiThreadedObjectTest(m_eglTestCtx, "window_context", "",
1638*35238bceSAndroid Build Coastguard Worker                                          MultiThreadedObjectTest::TYPE_WINDOW | MultiThreadedObjectTest::TYPE_CONTEXT));
1639*35238bceSAndroid Build Coastguard Worker     addChild(new MultiThreadedObjectTest(m_eglTestCtx, "single_window_context", "",
1640*35238bceSAndroid Build Coastguard Worker                                          MultiThreadedObjectTest::TYPE_WINDOW |
1641*35238bceSAndroid Build Coastguard Worker                                              MultiThreadedObjectTest::TYPE_SINGLE_WINDOW |
1642*35238bceSAndroid Build Coastguard Worker                                              MultiThreadedObjectTest::TYPE_CONTEXT));
1643*35238bceSAndroid Build Coastguard Worker 
1644*35238bceSAndroid Build Coastguard Worker     addChild(new MultiThreadedObjectTest(m_eglTestCtx, "pbuffer_pixmap_window", "",
1645*35238bceSAndroid Build Coastguard Worker                                          MultiThreadedObjectTest::TYPE_PBUFFER | MultiThreadedObjectTest::TYPE_PIXMAP |
1646*35238bceSAndroid Build Coastguard Worker                                              MultiThreadedObjectTest::TYPE_WINDOW));
1647*35238bceSAndroid Build Coastguard Worker     addChild(new MultiThreadedObjectTest(m_eglTestCtx, "pbuffer_pixmap_single_window", "",
1648*35238bceSAndroid Build Coastguard Worker                                          MultiThreadedObjectTest::TYPE_PBUFFER | MultiThreadedObjectTest::TYPE_PIXMAP |
1649*35238bceSAndroid Build Coastguard Worker                                              MultiThreadedObjectTest::TYPE_WINDOW |
1650*35238bceSAndroid Build Coastguard Worker                                              MultiThreadedObjectTest::TYPE_SINGLE_WINDOW));
1651*35238bceSAndroid Build Coastguard Worker     addChild(new MultiThreadedObjectTest(m_eglTestCtx, "pbuffer_pixmap_context", "",
1652*35238bceSAndroid Build Coastguard Worker                                          MultiThreadedObjectTest::TYPE_PBUFFER | MultiThreadedObjectTest::TYPE_PIXMAP |
1653*35238bceSAndroid Build Coastguard Worker                                              MultiThreadedObjectTest::TYPE_CONTEXT));
1654*35238bceSAndroid Build Coastguard Worker 
1655*35238bceSAndroid Build Coastguard Worker     addChild(new MultiThreadedObjectTest(m_eglTestCtx, "pbuffer_window_context", "",
1656*35238bceSAndroid Build Coastguard Worker                                          MultiThreadedObjectTest::TYPE_PBUFFER | MultiThreadedObjectTest::TYPE_WINDOW |
1657*35238bceSAndroid Build Coastguard Worker                                              MultiThreadedObjectTest::TYPE_CONTEXT));
1658*35238bceSAndroid Build Coastguard Worker     addChild(new MultiThreadedObjectTest(m_eglTestCtx, "pbuffer_single_window_context", "",
1659*35238bceSAndroid Build Coastguard Worker                                          MultiThreadedObjectTest::TYPE_PBUFFER | MultiThreadedObjectTest::TYPE_WINDOW |
1660*35238bceSAndroid Build Coastguard Worker                                              MultiThreadedObjectTest::TYPE_SINGLE_WINDOW |
1661*35238bceSAndroid Build Coastguard Worker                                              MultiThreadedObjectTest::TYPE_CONTEXT));
1662*35238bceSAndroid Build Coastguard Worker 
1663*35238bceSAndroid Build Coastguard Worker     addChild(new MultiThreadedObjectTest(m_eglTestCtx, "pixmap_window_context", "",
1664*35238bceSAndroid Build Coastguard Worker                                          MultiThreadedObjectTest::TYPE_PIXMAP | MultiThreadedObjectTest::TYPE_WINDOW |
1665*35238bceSAndroid Build Coastguard Worker                                              MultiThreadedObjectTest::TYPE_CONTEXT));
1666*35238bceSAndroid Build Coastguard Worker     addChild(new MultiThreadedObjectTest(m_eglTestCtx, "pixmap_single_window_context", "",
1667*35238bceSAndroid Build Coastguard Worker                                          MultiThreadedObjectTest::TYPE_PIXMAP | MultiThreadedObjectTest::TYPE_WINDOW |
1668*35238bceSAndroid Build Coastguard Worker                                              MultiThreadedObjectTest::TYPE_SINGLE_WINDOW |
1669*35238bceSAndroid Build Coastguard Worker                                              MultiThreadedObjectTest::TYPE_CONTEXT));
1670*35238bceSAndroid Build Coastguard Worker 
1671*35238bceSAndroid Build Coastguard Worker     addChild(new MultiThreadedObjectTest(m_eglTestCtx, "pbuffer_pixmap_window_context", "",
1672*35238bceSAndroid Build Coastguard Worker                                          MultiThreadedObjectTest::TYPE_PBUFFER | MultiThreadedObjectTest::TYPE_PIXMAP |
1673*35238bceSAndroid Build Coastguard Worker                                              MultiThreadedObjectTest::TYPE_WINDOW |
1674*35238bceSAndroid Build Coastguard Worker                                              MultiThreadedObjectTest::TYPE_CONTEXT));
1675*35238bceSAndroid Build Coastguard Worker     addChild(new MultiThreadedObjectTest(m_eglTestCtx, "pbuffer_pixmap_single_window_context", "",
1676*35238bceSAndroid Build Coastguard Worker                                          MultiThreadedObjectTest::TYPE_PBUFFER | MultiThreadedObjectTest::TYPE_PIXMAP |
1677*35238bceSAndroid Build Coastguard Worker                                              MultiThreadedObjectTest::TYPE_WINDOW |
1678*35238bceSAndroid Build Coastguard Worker                                              MultiThreadedObjectTest::TYPE_SINGLE_WINDOW |
1679*35238bceSAndroid Build Coastguard Worker                                              MultiThreadedObjectTest::TYPE_CONTEXT));
1680*35238bceSAndroid Build Coastguard Worker }
1681*35238bceSAndroid Build Coastguard Worker 
1682*35238bceSAndroid Build Coastguard Worker } // namespace egl
1683*35238bceSAndroid Build Coastguard Worker } // namespace deqp
1684