13c827367444ee418f129b2c238299f49d3264554Jarkko Poyry/*------------------------------------------------------------------------- 23c827367444ee418f129b2c238299f49d3264554Jarkko Poyry * drawElements Quality Program EGL Module 33c827367444ee418f129b2c238299f49d3264554Jarkko Poyry * --------------------------------------- 43c827367444ee418f129b2c238299f49d3264554Jarkko Poyry * 53c827367444ee418f129b2c238299f49d3264554Jarkko Poyry * Copyright 2014 The Android Open Source Project 63c827367444ee418f129b2c238299f49d3264554Jarkko Poyry * 73c827367444ee418f129b2c238299f49d3264554Jarkko Poyry * Licensed under the Apache License, Version 2.0 (the "License"); 83c827367444ee418f129b2c238299f49d3264554Jarkko Poyry * you may not use this file except in compliance with the License. 93c827367444ee418f129b2c238299f49d3264554Jarkko Poyry * You may obtain a copy of the License at 103c827367444ee418f129b2c238299f49d3264554Jarkko Poyry * 113c827367444ee418f129b2c238299f49d3264554Jarkko Poyry * http://www.apache.org/licenses/LICENSE-2.0 123c827367444ee418f129b2c238299f49d3264554Jarkko Poyry * 133c827367444ee418f129b2c238299f49d3264554Jarkko Poyry * Unless required by applicable law or agreed to in writing, software 143c827367444ee418f129b2c238299f49d3264554Jarkko Poyry * distributed under the License is distributed on an "AS IS" BASIS, 153c827367444ee418f129b2c238299f49d3264554Jarkko Poyry * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 163c827367444ee418f129b2c238299f49d3264554Jarkko Poyry * See the License for the specific language governing permissions and 173c827367444ee418f129b2c238299f49d3264554Jarkko Poyry * limitations under the License. 183c827367444ee418f129b2c238299f49d3264554Jarkko Poyry * 193c827367444ee418f129b2c238299f49d3264554Jarkko Poyry *//*! 203c827367444ee418f129b2c238299f49d3264554Jarkko Poyry * \file 213c827367444ee418f129b2c238299f49d3264554Jarkko Poyry * \brief Multi threaded EGL tests 223c827367444ee418f129b2c238299f49d3264554Jarkko Poyry *//*--------------------------------------------------------------------*/ 233c827367444ee418f129b2c238299f49d3264554Jarkko Poyry#include "teglMultiThreadTests.hpp" 243c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 253c827367444ee418f129b2c238299f49d3264554Jarkko Poyry#include "egluNativeWindow.hpp" 263c827367444ee418f129b2c238299f49d3264554Jarkko Poyry#include "egluNativePixmap.hpp" 273c827367444ee418f129b2c238299f49d3264554Jarkko Poyry#include "egluUtil.hpp" 283c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 293c827367444ee418f129b2c238299f49d3264554Jarkko Poyry#include "tcuTestLog.hpp" 303c827367444ee418f129b2c238299f49d3264554Jarkko Poyry#include "tcuCommandLine.hpp" 313c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 323c827367444ee418f129b2c238299f49d3264554Jarkko Poyry#include "deRandom.hpp" 333c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 343c827367444ee418f129b2c238299f49d3264554Jarkko Poyry#include "deThread.hpp" 353c827367444ee418f129b2c238299f49d3264554Jarkko Poyry#include "deMutex.hpp" 363c827367444ee418f129b2c238299f49d3264554Jarkko Poyry#include "deSemaphore.hpp" 373c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 383c827367444ee418f129b2c238299f49d3264554Jarkko Poyry#include "deAtomic.h" 393c827367444ee418f129b2c238299f49d3264554Jarkko Poyry#include "deClock.h" 403c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 413c827367444ee418f129b2c238299f49d3264554Jarkko Poyry#include <vector> 423c827367444ee418f129b2c238299f49d3264554Jarkko Poyry#include <string> 433c827367444ee418f129b2c238299f49d3264554Jarkko Poyry#include <sstream> 443c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 453c827367444ee418f129b2c238299f49d3264554Jarkko Poyryusing std::vector; 463c827367444ee418f129b2c238299f49d3264554Jarkko Poyryusing std::string; 473c827367444ee418f129b2c238299f49d3264554Jarkko Poyryusing std::pair; 483c827367444ee418f129b2c238299f49d3264554Jarkko Poyryusing std::ostringstream; 493c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 503c827367444ee418f129b2c238299f49d3264554Jarkko Poyrynamespace deqp 513c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{ 523c827367444ee418f129b2c238299f49d3264554Jarkko Poyrynamespace egl 533c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{ 543c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 553c827367444ee418f129b2c238299f49d3264554Jarkko Poyryclass ThreadLog 563c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{ 573c827367444ee418f129b2c238299f49d3264554Jarkko Poyrypublic: 583c827367444ee418f129b2c238299f49d3264554Jarkko Poyry class BeginMessageToken {}; 593c827367444ee418f129b2c238299f49d3264554Jarkko Poyry class EndMessageToken {}; 603c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 613c827367444ee418f129b2c238299f49d3264554Jarkko Poyry struct Message 623c827367444ee418f129b2c238299f49d3264554Jarkko Poyry { 633c827367444ee418f129b2c238299f49d3264554Jarkko Poyry Message (deUint64 timeUs_, const char* msg_) : timeUs(timeUs_), msg(msg_) {} 643c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 653c827367444ee418f129b2c238299f49d3264554Jarkko Poyry deUint64 timeUs; 663c827367444ee418f129b2c238299f49d3264554Jarkko Poyry string msg; 673c827367444ee418f129b2c238299f49d3264554Jarkko Poyry }; 683c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 693c827367444ee418f129b2c238299f49d3264554Jarkko Poyry ThreadLog (void) { m_messages.reserve(100); } 703c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 713c827367444ee418f129b2c238299f49d3264554Jarkko Poyry ThreadLog& operator<< (const BeginMessageToken&) { return *this; } 723c827367444ee418f129b2c238299f49d3264554Jarkko Poyry ThreadLog& operator<< (const EndMessageToken&); 733c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 743c827367444ee418f129b2c238299f49d3264554Jarkko Poyry template<class T> 753c827367444ee418f129b2c238299f49d3264554Jarkko Poyry ThreadLog& operator<< (const T& t) { m_message << t; return *this; } 763c827367444ee418f129b2c238299f49d3264554Jarkko Poyry const vector<Message>& getMessages (void) const { return m_messages; } 773c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 783c827367444ee418f129b2c238299f49d3264554Jarkko Poyry static BeginMessageToken BeginMessage; 793c827367444ee418f129b2c238299f49d3264554Jarkko Poyry static EndMessageToken EndMessage; 803c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 813c827367444ee418f129b2c238299f49d3264554Jarkko Poyryprivate: 823c827367444ee418f129b2c238299f49d3264554Jarkko Poyry ostringstream m_message; 833c827367444ee418f129b2c238299f49d3264554Jarkko Poyry vector<Message> m_messages; 843c827367444ee418f129b2c238299f49d3264554Jarkko Poyry}; 853c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 863c827367444ee418f129b2c238299f49d3264554Jarkko PoyryThreadLog& ThreadLog::operator<< (const EndMessageToken&) 873c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{ 883c827367444ee418f129b2c238299f49d3264554Jarkko Poyry m_messages.push_back(Message(deGetMicroseconds(), m_message.str().c_str())); 893c827367444ee418f129b2c238299f49d3264554Jarkko Poyry m_message.str(""); 903c827367444ee418f129b2c238299f49d3264554Jarkko Poyry return *this; 913c827367444ee418f129b2c238299f49d3264554Jarkko Poyry} 923c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 933c827367444ee418f129b2c238299f49d3264554Jarkko PoyryThreadLog::BeginMessageToken ThreadLog::BeginMessage; 943c827367444ee418f129b2c238299f49d3264554Jarkko PoyryThreadLog::EndMessageToken ThreadLog::EndMessage; 953c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 963c827367444ee418f129b2c238299f49d3264554Jarkko Poyryclass MultiThreadedTest; 973c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 983c827367444ee418f129b2c238299f49d3264554Jarkko Poyryclass TestThread : public de::Thread 993c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{ 1003c827367444ee418f129b2c238299f49d3264554Jarkko Poyrypublic: 1013c827367444ee418f129b2c238299f49d3264554Jarkko Poyry enum ThreadStatus 1023c827367444ee418f129b2c238299f49d3264554Jarkko Poyry { 1033c827367444ee418f129b2c238299f49d3264554Jarkko Poyry THREADSTATUS_NOT_STARTED = 0, 1043c827367444ee418f129b2c238299f49d3264554Jarkko Poyry THREADSTATUS_RUNNING, 1053c827367444ee418f129b2c238299f49d3264554Jarkko Poyry THREADSTATUS_READY, 1063c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 1073c827367444ee418f129b2c238299f49d3264554Jarkko Poyry THREADSTATUS_NOT_SUPPORTED, 1083c827367444ee418f129b2c238299f49d3264554Jarkko Poyry THREADSTATUS_ERROR 1093c827367444ee418f129b2c238299f49d3264554Jarkko Poyry }; 1103c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 1113c827367444ee418f129b2c238299f49d3264554Jarkko Poyry TestThread (MultiThreadedTest& test, int id); 1123c827367444ee418f129b2c238299f49d3264554Jarkko Poyry void run (void); 1133c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 1143c827367444ee418f129b2c238299f49d3264554Jarkko Poyry ThreadStatus getStatus (void) const { return m_status; } 1153c827367444ee418f129b2c238299f49d3264554Jarkko Poyry ThreadLog& getLog (void) { return m_log; } 1163c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 1173c827367444ee418f129b2c238299f49d3264554Jarkko Poyry int getId (void) const { return m_id; } 1183c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 1193c827367444ee418f129b2c238299f49d3264554Jarkko Poyry void setStatus (ThreadStatus status) { m_status = status; } 1203c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 1213c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 1223c827367444ee418f129b2c238299f49d3264554Jarkko Poyry // Test has stopped 1233c827367444ee418f129b2c238299f49d3264554Jarkko Poyry class TestStop {}; 1243c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 1253c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 1263c827367444ee418f129b2c238299f49d3264554Jarkko Poyryprivate: 1273c827367444ee418f129b2c238299f49d3264554Jarkko Poyry MultiThreadedTest& m_test; 1283c827367444ee418f129b2c238299f49d3264554Jarkko Poyry const int m_id; 1293c827367444ee418f129b2c238299f49d3264554Jarkko Poyry ThreadStatus m_status; 1303c827367444ee418f129b2c238299f49d3264554Jarkko Poyry ThreadLog m_log; 1313c827367444ee418f129b2c238299f49d3264554Jarkko Poyry}; 1323c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 1333c827367444ee418f129b2c238299f49d3264554Jarkko Poyryclass MultiThreadedTest : public TestCase 1343c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{ 1353c827367444ee418f129b2c238299f49d3264554Jarkko Poyrypublic: 1363c827367444ee418f129b2c238299f49d3264554Jarkko Poyry MultiThreadedTest (EglTestContext& eglTestCtx, const char* name, const char* description, int threadCount, deUint64 timeoutUs); 1373c827367444ee418f129b2c238299f49d3264554Jarkko Poyry virtual ~MultiThreadedTest (void); 1383c827367444ee418f129b2c238299f49d3264554Jarkko Poyry virtual void deinit (void) {} 1393c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 1403c827367444ee418f129b2c238299f49d3264554Jarkko Poyry virtual bool runThread (TestThread& thread) = 0; 1413c827367444ee418f129b2c238299f49d3264554Jarkko Poyry virtual IterateResult iterate (void); 1423c827367444ee418f129b2c238299f49d3264554Jarkko Poyry bool execTest (TestThread& thread); 1433c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 1443c827367444ee418f129b2c238299f49d3264554Jarkko Poyryprotected: 1453c827367444ee418f129b2c238299f49d3264554Jarkko Poyry void barrier (TestThread& thread); 1463c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 1473c827367444ee418f129b2c238299f49d3264554Jarkko Poyryprivate: 1483c827367444ee418f129b2c238299f49d3264554Jarkko Poyry int m_threadCount; 1493c827367444ee418f129b2c238299f49d3264554Jarkko Poyry bool m_initialized; 1503c827367444ee418f129b2c238299f49d3264554Jarkko Poyry deUint64 m_startTimeUs; 1513c827367444ee418f129b2c238299f49d3264554Jarkko Poyry const deUint64 m_timeoutUs; 1523c827367444ee418f129b2c238299f49d3264554Jarkko Poyry vector<TestThread*> m_threads; 1533c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 1543c827367444ee418f129b2c238299f49d3264554Jarkko Poyry volatile deInt32 m_barrierWaiters; 1553c827367444ee418f129b2c238299f49d3264554Jarkko Poyry de::Semaphore m_barrierSemaphore1; 1563c827367444ee418f129b2c238299f49d3264554Jarkko Poyry de::Semaphore m_barrierSemaphore2; 1573c827367444ee418f129b2c238299f49d3264554Jarkko Poyry}; 1583c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 1593c827367444ee418f129b2c238299f49d3264554Jarkko PoyryTestThread::TestThread (MultiThreadedTest& test, int id) 1603c827367444ee418f129b2c238299f49d3264554Jarkko Poyry : m_test (test) 1613c827367444ee418f129b2c238299f49d3264554Jarkko Poyry , m_id (id) 1623c827367444ee418f129b2c238299f49d3264554Jarkko Poyry , m_status (THREADSTATUS_NOT_STARTED) 1633c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{ 1643c827367444ee418f129b2c238299f49d3264554Jarkko Poyry} 1653c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 1663c827367444ee418f129b2c238299f49d3264554Jarkko Poyryvoid TestThread::run (void) 1673c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{ 1683c827367444ee418f129b2c238299f49d3264554Jarkko Poyry m_status = THREADSTATUS_RUNNING; 1693c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 1703c827367444ee418f129b2c238299f49d3264554Jarkko Poyry try 1713c827367444ee418f129b2c238299f49d3264554Jarkko Poyry { 1723c827367444ee418f129b2c238299f49d3264554Jarkko Poyry if (m_test.execTest(*this)) 1733c827367444ee418f129b2c238299f49d3264554Jarkko Poyry m_status = THREADSTATUS_READY; 1743c827367444ee418f129b2c238299f49d3264554Jarkko Poyry else 1753c827367444ee418f129b2c238299f49d3264554Jarkko Poyry m_status = THREADSTATUS_ERROR; 1763c827367444ee418f129b2c238299f49d3264554Jarkko Poyry } 1773c827367444ee418f129b2c238299f49d3264554Jarkko Poyry catch (const TestThread::TestStop&) 1783c827367444ee418f129b2c238299f49d3264554Jarkko Poyry { 1793c827367444ee418f129b2c238299f49d3264554Jarkko Poyry getLog() << ThreadLog::BeginMessage << "Thread stopped" << ThreadLog::EndMessage; 1803c827367444ee418f129b2c238299f49d3264554Jarkko Poyry } 1813c827367444ee418f129b2c238299f49d3264554Jarkko Poyry catch (const tcu::NotSupportedError& e) 1823c827367444ee418f129b2c238299f49d3264554Jarkko Poyry { 1833c827367444ee418f129b2c238299f49d3264554Jarkko Poyry getLog() << ThreadLog::BeginMessage << "Not supported: '" << e.what() << "'" << ThreadLog::EndMessage; 1843c827367444ee418f129b2c238299f49d3264554Jarkko Poyry } 1853c827367444ee418f129b2c238299f49d3264554Jarkko Poyry catch (const std::exception& e) 1863c827367444ee418f129b2c238299f49d3264554Jarkko Poyry { 1873c827367444ee418f129b2c238299f49d3264554Jarkko Poyry getLog() << ThreadLog::BeginMessage << "Got exception: '" << e.what() << "'" << ThreadLog::EndMessage; 1883c827367444ee418f129b2c238299f49d3264554Jarkko Poyry } 1893c827367444ee418f129b2c238299f49d3264554Jarkko Poyry catch (...) 1903c827367444ee418f129b2c238299f49d3264554Jarkko Poyry { 1913c827367444ee418f129b2c238299f49d3264554Jarkko Poyry getLog() << ThreadLog::BeginMessage << "Unknown exception" << ThreadLog::EndMessage; 1923c827367444ee418f129b2c238299f49d3264554Jarkko Poyry } 1933c827367444ee418f129b2c238299f49d3264554Jarkko Poyry} 1943c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 1953c827367444ee418f129b2c238299f49d3264554Jarkko Poyrybool MultiThreadedTest::execTest (TestThread& thread) 1963c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{ 1973c827367444ee418f129b2c238299f49d3264554Jarkko Poyry bool isOk = false; 1983c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 1993c827367444ee418f129b2c238299f49d3264554Jarkko Poyry try 2003c827367444ee418f129b2c238299f49d3264554Jarkko Poyry { 2013c827367444ee418f129b2c238299f49d3264554Jarkko Poyry isOk = runThread(thread); 2023c827367444ee418f129b2c238299f49d3264554Jarkko Poyry } 2033c827367444ee418f129b2c238299f49d3264554Jarkko Poyry catch (const TestThread::TestStop&) 2043c827367444ee418f129b2c238299f49d3264554Jarkko Poyry { 2053c827367444ee418f129b2c238299f49d3264554Jarkko Poyry // Thread exited due to error in other thread 2063c827367444ee418f129b2c238299f49d3264554Jarkko Poyry throw; 2073c827367444ee418f129b2c238299f49d3264554Jarkko Poyry } 2083c827367444ee418f129b2c238299f49d3264554Jarkko Poyry catch (const tcu::NotSupportedError&) 2093c827367444ee418f129b2c238299f49d3264554Jarkko Poyry { 2103c827367444ee418f129b2c238299f49d3264554Jarkko Poyry // Set status of each thread 2113c827367444ee418f129b2c238299f49d3264554Jarkko Poyry for (int threadNdx = 0; threadNdx < (int)m_threads.size(); threadNdx++) 2123c827367444ee418f129b2c238299f49d3264554Jarkko Poyry m_threads[threadNdx]->setStatus(TestThread::THREADSTATUS_NOT_SUPPORTED); 2133c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 2143c827367444ee418f129b2c238299f49d3264554Jarkko Poyry // Release barriers 2153c827367444ee418f129b2c238299f49d3264554Jarkko Poyry for (int threadNdx = 0; threadNdx < (int)m_threads.size(); threadNdx++) 2163c827367444ee418f129b2c238299f49d3264554Jarkko Poyry { 2173c827367444ee418f129b2c238299f49d3264554Jarkko Poyry m_barrierSemaphore1.increment(); 2183c827367444ee418f129b2c238299f49d3264554Jarkko Poyry m_barrierSemaphore2.increment(); 2193c827367444ee418f129b2c238299f49d3264554Jarkko Poyry } 2203c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 2213c827367444ee418f129b2c238299f49d3264554Jarkko Poyry throw; 2223c827367444ee418f129b2c238299f49d3264554Jarkko Poyry } 2233c827367444ee418f129b2c238299f49d3264554Jarkko Poyry catch(...) 2243c827367444ee418f129b2c238299f49d3264554Jarkko Poyry { 2253c827367444ee418f129b2c238299f49d3264554Jarkko Poyry // Set status of each thread 2263c827367444ee418f129b2c238299f49d3264554Jarkko Poyry for (int threadNdx = 0; threadNdx < (int)m_threads.size(); threadNdx++) 2273c827367444ee418f129b2c238299f49d3264554Jarkko Poyry m_threads[threadNdx]->setStatus(TestThread::THREADSTATUS_ERROR); 2283c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 2293c827367444ee418f129b2c238299f49d3264554Jarkko Poyry // Release barriers 2303c827367444ee418f129b2c238299f49d3264554Jarkko Poyry for (int threadNdx = 0; threadNdx < (int)m_threads.size(); threadNdx++) 2313c827367444ee418f129b2c238299f49d3264554Jarkko Poyry { 2323c827367444ee418f129b2c238299f49d3264554Jarkko Poyry m_barrierSemaphore1.increment(); 2333c827367444ee418f129b2c238299f49d3264554Jarkko Poyry m_barrierSemaphore2.increment(); 2343c827367444ee418f129b2c238299f49d3264554Jarkko Poyry } 2353c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 2363c827367444ee418f129b2c238299f49d3264554Jarkko Poyry throw; 2373c827367444ee418f129b2c238299f49d3264554Jarkko Poyry } 2383c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 2393c827367444ee418f129b2c238299f49d3264554Jarkko Poyry return isOk; 2403c827367444ee418f129b2c238299f49d3264554Jarkko Poyry} 2413c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 2423c827367444ee418f129b2c238299f49d3264554Jarkko PoyryMultiThreadedTest::MultiThreadedTest (EglTestContext& eglTestCtx, const char* name, const char* description, int threadCount, deUint64 timeoutUs) 2433c827367444ee418f129b2c238299f49d3264554Jarkko Poyry : TestCase (eglTestCtx, name, description) 2443c827367444ee418f129b2c238299f49d3264554Jarkko Poyry , m_threadCount (threadCount) 2453c827367444ee418f129b2c238299f49d3264554Jarkko Poyry , m_initialized (false) 2463c827367444ee418f129b2c238299f49d3264554Jarkko Poyry , m_startTimeUs (0) 2473c827367444ee418f129b2c238299f49d3264554Jarkko Poyry , m_timeoutUs (timeoutUs) 2483c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 2493c827367444ee418f129b2c238299f49d3264554Jarkko Poyry , m_barrierWaiters (0) 2503c827367444ee418f129b2c238299f49d3264554Jarkko Poyry , m_barrierSemaphore1 (0, 0) 2513c827367444ee418f129b2c238299f49d3264554Jarkko Poyry , m_barrierSemaphore2 (1, 0) 2523c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{ 2533c827367444ee418f129b2c238299f49d3264554Jarkko Poyry} 2543c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 2553c827367444ee418f129b2c238299f49d3264554Jarkko PoyryMultiThreadedTest::~MultiThreadedTest (void) 2563c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{ 2573c827367444ee418f129b2c238299f49d3264554Jarkko Poyry for (int threadNdx = 0; threadNdx < (int)m_threads.size(); threadNdx++) 2583c827367444ee418f129b2c238299f49d3264554Jarkko Poyry delete m_threads[threadNdx]; 2593c827367444ee418f129b2c238299f49d3264554Jarkko Poyry m_threads.clear(); 2603c827367444ee418f129b2c238299f49d3264554Jarkko Poyry} 2613c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 2623c827367444ee418f129b2c238299f49d3264554Jarkko Poyryvoid MultiThreadedTest::barrier (TestThread& thread) 2633c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{ 2643c827367444ee418f129b2c238299f49d3264554Jarkko Poyry { 2653c827367444ee418f129b2c238299f49d3264554Jarkko Poyry const deInt32 waiters = deAtomicIncrement32(&m_barrierWaiters); 2663c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 2673c827367444ee418f129b2c238299f49d3264554Jarkko Poyry if (waiters == m_threadCount) 2683c827367444ee418f129b2c238299f49d3264554Jarkko Poyry { 2693c827367444ee418f129b2c238299f49d3264554Jarkko Poyry m_barrierSemaphore2.decrement(); 2703c827367444ee418f129b2c238299f49d3264554Jarkko Poyry m_barrierSemaphore1.increment(); 2713c827367444ee418f129b2c238299f49d3264554Jarkko Poyry } 2723c827367444ee418f129b2c238299f49d3264554Jarkko Poyry else 2733c827367444ee418f129b2c238299f49d3264554Jarkko Poyry { 2743c827367444ee418f129b2c238299f49d3264554Jarkko Poyry m_barrierSemaphore1.decrement(); 2753c827367444ee418f129b2c238299f49d3264554Jarkko Poyry m_barrierSemaphore1.increment(); 2763c827367444ee418f129b2c238299f49d3264554Jarkko Poyry } 2773c827367444ee418f129b2c238299f49d3264554Jarkko Poyry } 2783c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 2793c827367444ee418f129b2c238299f49d3264554Jarkko Poyry { 2803c827367444ee418f129b2c238299f49d3264554Jarkko Poyry const deInt32 waiters = deAtomicDecrement32(&m_barrierWaiters); 2813c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 2823c827367444ee418f129b2c238299f49d3264554Jarkko Poyry if (waiters == 0) 2833c827367444ee418f129b2c238299f49d3264554Jarkko Poyry { 2843c827367444ee418f129b2c238299f49d3264554Jarkko Poyry m_barrierSemaphore1.decrement(); 2853c827367444ee418f129b2c238299f49d3264554Jarkko Poyry m_barrierSemaphore2.increment(); 2863c827367444ee418f129b2c238299f49d3264554Jarkko Poyry } 2873c827367444ee418f129b2c238299f49d3264554Jarkko Poyry else 2883c827367444ee418f129b2c238299f49d3264554Jarkko Poyry { 2893c827367444ee418f129b2c238299f49d3264554Jarkko Poyry m_barrierSemaphore2.decrement(); 2903c827367444ee418f129b2c238299f49d3264554Jarkko Poyry m_barrierSemaphore2.increment(); 2913c827367444ee418f129b2c238299f49d3264554Jarkko Poyry } 2923c827367444ee418f129b2c238299f49d3264554Jarkko Poyry } 2933c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 2943c827367444ee418f129b2c238299f49d3264554Jarkko Poyry // Barrier was released due an error in other thread 2953c827367444ee418f129b2c238299f49d3264554Jarkko Poyry if (thread.getStatus() != TestThread::THREADSTATUS_RUNNING) 2963c827367444ee418f129b2c238299f49d3264554Jarkko Poyry throw TestThread::TestStop(); 2973c827367444ee418f129b2c238299f49d3264554Jarkko Poyry} 2983c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 2993c827367444ee418f129b2c238299f49d3264554Jarkko PoyryTestCase::IterateResult MultiThreadedTest::iterate (void) 3003c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{ 3013c827367444ee418f129b2c238299f49d3264554Jarkko Poyry if (!m_initialized) 3023c827367444ee418f129b2c238299f49d3264554Jarkko Poyry { 3033c827367444ee418f129b2c238299f49d3264554Jarkko Poyry m_testCtx.getLog() << tcu::TestLog::Message << "Thread timeout limit: " << m_timeoutUs << "us" << tcu::TestLog::EndMessage; 3043c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 3053c827367444ee418f129b2c238299f49d3264554Jarkko Poyry // Create threads 3063c827367444ee418f129b2c238299f49d3264554Jarkko Poyry m_threads.reserve(m_threadCount); 3073c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 3083c827367444ee418f129b2c238299f49d3264554Jarkko Poyry for (int threadNdx = 0; threadNdx < m_threadCount; threadNdx++) 3093c827367444ee418f129b2c238299f49d3264554Jarkko Poyry m_threads.push_back(new TestThread(*this, threadNdx)); 3103c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 3113c827367444ee418f129b2c238299f49d3264554Jarkko Poyry m_startTimeUs = deGetMicroseconds(); 3123c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 3133c827367444ee418f129b2c238299f49d3264554Jarkko Poyry // Run threads 3143c827367444ee418f129b2c238299f49d3264554Jarkko Poyry for (int threadNdx = 0; threadNdx < (int)m_threads.size(); threadNdx++) 3153c827367444ee418f129b2c238299f49d3264554Jarkko Poyry m_threads[threadNdx]->start(); 3163c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 3173c827367444ee418f129b2c238299f49d3264554Jarkko Poyry m_initialized = true; 3183c827367444ee418f129b2c238299f49d3264554Jarkko Poyry } 3193c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 3203c827367444ee418f129b2c238299f49d3264554Jarkko Poyry int readyCount = 0; 3213c827367444ee418f129b2c238299f49d3264554Jarkko Poyry for (int threadNdx = 0; threadNdx < (int)m_threads.size(); threadNdx++) 3223c827367444ee418f129b2c238299f49d3264554Jarkko Poyry { 3233c827367444ee418f129b2c238299f49d3264554Jarkko Poyry if (m_threads[threadNdx]->getStatus() != TestThread::THREADSTATUS_RUNNING) 3243c827367444ee418f129b2c238299f49d3264554Jarkko Poyry readyCount++; 3253c827367444ee418f129b2c238299f49d3264554Jarkko Poyry } 3263c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 3273c827367444ee418f129b2c238299f49d3264554Jarkko Poyry if (readyCount == m_threadCount) 3283c827367444ee418f129b2c238299f49d3264554Jarkko Poyry { 3293c827367444ee418f129b2c238299f49d3264554Jarkko Poyry // Join threads 3303c827367444ee418f129b2c238299f49d3264554Jarkko Poyry for (int threadNdx = 0; threadNdx < (int)m_threads.size(); threadNdx++) 3313c827367444ee418f129b2c238299f49d3264554Jarkko Poyry m_threads[threadNdx]->join(); 3323c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 3333c827367444ee418f129b2c238299f49d3264554Jarkko Poyry bool isOk = true; 3343c827367444ee418f129b2c238299f49d3264554Jarkko Poyry bool notSupported = false; 3353c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 3363c827367444ee418f129b2c238299f49d3264554Jarkko Poyry for (int threadNdx = 0; threadNdx < (int)m_threads.size(); threadNdx++) 3373c827367444ee418f129b2c238299f49d3264554Jarkko Poyry { 3383c827367444ee418f129b2c238299f49d3264554Jarkko Poyry if (m_threads[threadNdx]->getStatus() == TestThread::THREADSTATUS_ERROR) 3393c827367444ee418f129b2c238299f49d3264554Jarkko Poyry isOk = false; 3403c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 3413c827367444ee418f129b2c238299f49d3264554Jarkko Poyry if (m_threads[threadNdx]->getStatus() == TestThread::THREADSTATUS_NOT_SUPPORTED) 3423c827367444ee418f129b2c238299f49d3264554Jarkko Poyry notSupported = true; 3433c827367444ee418f129b2c238299f49d3264554Jarkko Poyry } 3443c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 3453c827367444ee418f129b2c238299f49d3264554Jarkko Poyry // Get logs 3463c827367444ee418f129b2c238299f49d3264554Jarkko Poyry { 3473c827367444ee418f129b2c238299f49d3264554Jarkko Poyry vector<int> messageNdx; 3483c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 3493c827367444ee418f129b2c238299f49d3264554Jarkko Poyry messageNdx.resize(m_threads.size(), 0); 3503c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 3513c827367444ee418f129b2c238299f49d3264554Jarkko Poyry while (true) 3523c827367444ee418f129b2c238299f49d3264554Jarkko Poyry { 3533c827367444ee418f129b2c238299f49d3264554Jarkko Poyry int nextThreadNdx = -1; 3543c827367444ee418f129b2c238299f49d3264554Jarkko Poyry deUint64 nextThreadTimeUs = 0; 3553c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 3563c827367444ee418f129b2c238299f49d3264554Jarkko Poyry for (int threadNdx = 0; threadNdx < (int)m_threads.size(); threadNdx++) 3573c827367444ee418f129b2c238299f49d3264554Jarkko Poyry { 3583c827367444ee418f129b2c238299f49d3264554Jarkko Poyry if (messageNdx[threadNdx] >= (int)m_threads[threadNdx]->getLog().getMessages().size()) 3593c827367444ee418f129b2c238299f49d3264554Jarkko Poyry continue; 3603c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 3613c827367444ee418f129b2c238299f49d3264554Jarkko Poyry if (nextThreadNdx == -1 || nextThreadTimeUs > m_threads[threadNdx]->getLog().getMessages()[messageNdx[threadNdx]].timeUs) 3623c827367444ee418f129b2c238299f49d3264554Jarkko Poyry { 3633c827367444ee418f129b2c238299f49d3264554Jarkko Poyry nextThreadNdx = threadNdx; 3643c827367444ee418f129b2c238299f49d3264554Jarkko Poyry nextThreadTimeUs = m_threads[threadNdx]->getLog().getMessages()[messageNdx[threadNdx]].timeUs; 3653c827367444ee418f129b2c238299f49d3264554Jarkko Poyry } 3663c827367444ee418f129b2c238299f49d3264554Jarkko Poyry } 3673c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 3683c827367444ee418f129b2c238299f49d3264554Jarkko Poyry if (nextThreadNdx == -1) 3693c827367444ee418f129b2c238299f49d3264554Jarkko Poyry break; 3703c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 3713c827367444ee418f129b2c238299f49d3264554Jarkko Poyry m_testCtx.getLog() << tcu::TestLog::Message << "[" << (nextThreadTimeUs - m_startTimeUs) << "] (" << nextThreadNdx << ") " << m_threads[nextThreadNdx]->getLog().getMessages()[messageNdx[nextThreadNdx]].msg << tcu::TestLog::EndMessage; 3723c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 3733c827367444ee418f129b2c238299f49d3264554Jarkko Poyry messageNdx[nextThreadNdx]++; 3743c827367444ee418f129b2c238299f49d3264554Jarkko Poyry } 3753c827367444ee418f129b2c238299f49d3264554Jarkko Poyry } 3763c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 3773c827367444ee418f129b2c238299f49d3264554Jarkko Poyry // Destroy threads 3783c827367444ee418f129b2c238299f49d3264554Jarkko Poyry for (int threadNdx = 0; threadNdx < (int)m_threads.size(); threadNdx++) 3793c827367444ee418f129b2c238299f49d3264554Jarkko Poyry delete m_threads[threadNdx]; 3803c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 3813c827367444ee418f129b2c238299f49d3264554Jarkko Poyry m_threads.clear(); 3823c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 3833c827367444ee418f129b2c238299f49d3264554Jarkko Poyry // Set result 3843c827367444ee418f129b2c238299f49d3264554Jarkko Poyry if (isOk) 3853c827367444ee418f129b2c238299f49d3264554Jarkko Poyry { 3863c827367444ee418f129b2c238299f49d3264554Jarkko Poyry if (notSupported) 3873c827367444ee418f129b2c238299f49d3264554Jarkko Poyry m_testCtx.setTestResult(QP_TEST_RESULT_NOT_SUPPORTED, "Not Supported"); 3883c827367444ee418f129b2c238299f49d3264554Jarkko Poyry else 3893c827367444ee418f129b2c238299f49d3264554Jarkko Poyry m_testCtx.setTestResult(QP_TEST_RESULT_PASS, "Pass"); 3903c827367444ee418f129b2c238299f49d3264554Jarkko Poyry } 3913c827367444ee418f129b2c238299f49d3264554Jarkko Poyry else 3923c827367444ee418f129b2c238299f49d3264554Jarkko Poyry m_testCtx.setTestResult(QP_TEST_RESULT_FAIL, "Fail"); 3933c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 3943c827367444ee418f129b2c238299f49d3264554Jarkko Poyry return STOP; 3953c827367444ee418f129b2c238299f49d3264554Jarkko Poyry } 3963c827367444ee418f129b2c238299f49d3264554Jarkko Poyry else 3973c827367444ee418f129b2c238299f49d3264554Jarkko Poyry { 3983c827367444ee418f129b2c238299f49d3264554Jarkko Poyry // Check for timeout 3993c827367444ee418f129b2c238299f49d3264554Jarkko Poyry const deUint64 currentTimeUs = deGetMicroseconds(); 4003c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 4013c827367444ee418f129b2c238299f49d3264554Jarkko Poyry if (currentTimeUs - m_startTimeUs > m_timeoutUs) 4023c827367444ee418f129b2c238299f49d3264554Jarkko Poyry { 4033c827367444ee418f129b2c238299f49d3264554Jarkko Poyry // Get logs 4043c827367444ee418f129b2c238299f49d3264554Jarkko Poyry { 4053c827367444ee418f129b2c238299f49d3264554Jarkko Poyry vector<int> messageNdx; 4063c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 4073c827367444ee418f129b2c238299f49d3264554Jarkko Poyry messageNdx.resize(m_threads.size(), 0); 4083c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 4093c827367444ee418f129b2c238299f49d3264554Jarkko Poyry while (true) 4103c827367444ee418f129b2c238299f49d3264554Jarkko Poyry { 4113c827367444ee418f129b2c238299f49d3264554Jarkko Poyry int nextThreadNdx = -1; 4123c827367444ee418f129b2c238299f49d3264554Jarkko Poyry deUint64 nextThreadTimeUs = 0; 4133c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 4143c827367444ee418f129b2c238299f49d3264554Jarkko Poyry for (int threadNdx = 0; threadNdx < (int)m_threads.size(); threadNdx++) 4153c827367444ee418f129b2c238299f49d3264554Jarkko Poyry { 4163c827367444ee418f129b2c238299f49d3264554Jarkko Poyry if (messageNdx[threadNdx] >= (int)m_threads[threadNdx]->getLog().getMessages().size()) 4173c827367444ee418f129b2c238299f49d3264554Jarkko Poyry continue; 4183c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 4193c827367444ee418f129b2c238299f49d3264554Jarkko Poyry if (nextThreadNdx == -1 || nextThreadTimeUs > m_threads[threadNdx]->getLog().getMessages()[messageNdx[threadNdx]].timeUs) 4203c827367444ee418f129b2c238299f49d3264554Jarkko Poyry { 4213c827367444ee418f129b2c238299f49d3264554Jarkko Poyry nextThreadNdx = threadNdx; 4223c827367444ee418f129b2c238299f49d3264554Jarkko Poyry nextThreadTimeUs = m_threads[threadNdx]->getLog().getMessages()[messageNdx[threadNdx]].timeUs; 4233c827367444ee418f129b2c238299f49d3264554Jarkko Poyry } 4243c827367444ee418f129b2c238299f49d3264554Jarkko Poyry } 4253c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 4263c827367444ee418f129b2c238299f49d3264554Jarkko Poyry if (nextThreadNdx == -1) 4273c827367444ee418f129b2c238299f49d3264554Jarkko Poyry break; 4283c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 4293c827367444ee418f129b2c238299f49d3264554Jarkko Poyry m_testCtx.getLog() << tcu::TestLog::Message << "[" << (nextThreadTimeUs - m_startTimeUs) << "] (" << nextThreadNdx << ") " << m_threads[nextThreadNdx]->getLog().getMessages()[messageNdx[nextThreadNdx]].msg << tcu::TestLog::EndMessage; 4303c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 4313c827367444ee418f129b2c238299f49d3264554Jarkko Poyry messageNdx[nextThreadNdx]++; 4323c827367444ee418f129b2c238299f49d3264554Jarkko Poyry } 4333c827367444ee418f129b2c238299f49d3264554Jarkko Poyry } 4343c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 4353c827367444ee418f129b2c238299f49d3264554Jarkko Poyry m_testCtx.getLog() << tcu::TestLog::Message << "[" << (currentTimeUs - m_startTimeUs) << "] (-) Timeout, Limit: " << m_timeoutUs << "us" << tcu::TestLog::EndMessage; 4363c827367444ee418f129b2c238299f49d3264554Jarkko Poyry m_testCtx.getLog() << tcu::TestLog::Message << "[" << (currentTimeUs - m_startTimeUs) << "] (-) Trying to perform resource cleanup..." << tcu::TestLog::EndMessage; 4373c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 4383c827367444ee418f129b2c238299f49d3264554Jarkko Poyry m_testCtx.setTestResult(QP_TEST_RESULT_FAIL, "Fail"); 4393c827367444ee418f129b2c238299f49d3264554Jarkko Poyry return STOP; 4403c827367444ee418f129b2c238299f49d3264554Jarkko Poyry } 4413c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 4423c827367444ee418f129b2c238299f49d3264554Jarkko Poyry // Sleep 4433c827367444ee418f129b2c238299f49d3264554Jarkko Poyry deSleep(10); 4443c827367444ee418f129b2c238299f49d3264554Jarkko Poyry } 4453c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 4463c827367444ee418f129b2c238299f49d3264554Jarkko Poyry return CONTINUE; 4473c827367444ee418f129b2c238299f49d3264554Jarkko Poyry} 4483c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 4493c827367444ee418f129b2c238299f49d3264554Jarkko Poyrynamespace 4503c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{ 4513c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 4523c827367444ee418f129b2c238299f49d3264554Jarkko Poyryconst char* configAttributeToString (EGLint e) 4533c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{ 4543c827367444ee418f129b2c238299f49d3264554Jarkko Poyry switch (e) 4553c827367444ee418f129b2c238299f49d3264554Jarkko Poyry { 4563c827367444ee418f129b2c238299f49d3264554Jarkko Poyry case EGL_BUFFER_SIZE: return "EGL_BUFFER_SIZE"; 4573c827367444ee418f129b2c238299f49d3264554Jarkko Poyry case EGL_RED_SIZE: return "EGL_RED_SIZE"; 4583c827367444ee418f129b2c238299f49d3264554Jarkko Poyry case EGL_GREEN_SIZE: return "EGL_GREEN_SIZE"; 4593c827367444ee418f129b2c238299f49d3264554Jarkko Poyry case EGL_BLUE_SIZE: return "EGL_BLUE_SIZE"; 4603c827367444ee418f129b2c238299f49d3264554Jarkko Poyry case EGL_LUMINANCE_SIZE: return "EGL_LUMINANCE_SIZE"; 4613c827367444ee418f129b2c238299f49d3264554Jarkko Poyry case EGL_ALPHA_SIZE: return "EGL_ALPHA_SIZE"; 4623c827367444ee418f129b2c238299f49d3264554Jarkko Poyry case EGL_ALPHA_MASK_SIZE: return "EGL_ALPHA_MASK_SIZE"; 4633c827367444ee418f129b2c238299f49d3264554Jarkko Poyry case EGL_BIND_TO_TEXTURE_RGB: return "EGL_BIND_TO_TEXTURE_RGB"; 4643c827367444ee418f129b2c238299f49d3264554Jarkko Poyry case EGL_BIND_TO_TEXTURE_RGBA: return "EGL_BIND_TO_TEXTURE_RGBA"; 4653c827367444ee418f129b2c238299f49d3264554Jarkko Poyry case EGL_COLOR_BUFFER_TYPE: return "EGL_COLOR_BUFFER_TYPE"; 4663c827367444ee418f129b2c238299f49d3264554Jarkko Poyry case EGL_CONFIG_CAVEAT: return "EGL_CONFIG_CAVEAT"; 4673c827367444ee418f129b2c238299f49d3264554Jarkko Poyry case EGL_CONFIG_ID: return "EGL_CONFIG_ID"; 4683c827367444ee418f129b2c238299f49d3264554Jarkko Poyry case EGL_CONFORMANT: return "EGL_CONFORMANT"; 4693c827367444ee418f129b2c238299f49d3264554Jarkko Poyry case EGL_DEPTH_SIZE: return "EGL_DEPTH_SIZE"; 4703c827367444ee418f129b2c238299f49d3264554Jarkko Poyry case EGL_LEVEL: return "EGL_LEVEL"; 4713c827367444ee418f129b2c238299f49d3264554Jarkko Poyry case EGL_MAX_PBUFFER_WIDTH: return "EGL_MAX_PBUFFER_WIDTH"; 4723c827367444ee418f129b2c238299f49d3264554Jarkko Poyry case EGL_MAX_PBUFFER_HEIGHT: return "EGL_MAX_PBUFFER_HEIGHT"; 4733c827367444ee418f129b2c238299f49d3264554Jarkko Poyry case EGL_MAX_PBUFFER_PIXELS: return "EGL_MAX_PBUFFER_PIXELS"; 4743c827367444ee418f129b2c238299f49d3264554Jarkko Poyry case EGL_MAX_SWAP_INTERVAL: return "EGL_MAX_SWAP_INTERVAL"; 4753c827367444ee418f129b2c238299f49d3264554Jarkko Poyry case EGL_MIN_SWAP_INTERVAL: return "EGL_MIN_SWAP_INTERVAL"; 4763c827367444ee418f129b2c238299f49d3264554Jarkko Poyry case EGL_NATIVE_RENDERABLE: return "EGL_NATIVE_RENDERABLE"; 4773c827367444ee418f129b2c238299f49d3264554Jarkko Poyry case EGL_NATIVE_VISUAL_ID: return "EGL_NATIVE_VISUAL_ID"; 4783c827367444ee418f129b2c238299f49d3264554Jarkko Poyry case EGL_NATIVE_VISUAL_TYPE: return "EGL_NATIVE_VISUAL_TYPE"; 4793c827367444ee418f129b2c238299f49d3264554Jarkko Poyry case EGL_RENDERABLE_TYPE: return "EGL_RENDERABLE_TYPE"; 4803c827367444ee418f129b2c238299f49d3264554Jarkko Poyry case EGL_SAMPLE_BUFFERS: return "EGL_SAMPLE_BUFFERS"; 4813c827367444ee418f129b2c238299f49d3264554Jarkko Poyry case EGL_SAMPLES: return "EGL_SAMPLES"; 4823c827367444ee418f129b2c238299f49d3264554Jarkko Poyry case EGL_STENCIL_SIZE: return "EGL_STENCIL_SIZE"; 4833c827367444ee418f129b2c238299f49d3264554Jarkko Poyry case EGL_SURFACE_TYPE: return "EGL_SURFACE_TYPE"; 4843c827367444ee418f129b2c238299f49d3264554Jarkko Poyry case EGL_TRANSPARENT_TYPE: return "EGL_TRANSPARENT_TYPE"; 4853c827367444ee418f129b2c238299f49d3264554Jarkko Poyry case EGL_TRANSPARENT_RED_VALUE: return "EGL_TRANSPARENT_RED_VALUE"; 4863c827367444ee418f129b2c238299f49d3264554Jarkko Poyry case EGL_TRANSPARENT_GREEN_VALUE: return "EGL_TRANSPARENT_GREEN_VALUE"; 4873c827367444ee418f129b2c238299f49d3264554Jarkko Poyry case EGL_TRANSPARENT_BLUE_VALUE: return "EGL_TRANSPARENT_BLUE_VALUE"; 4883c827367444ee418f129b2c238299f49d3264554Jarkko Poyry default: return "<Unknown>"; 4893c827367444ee418f129b2c238299f49d3264554Jarkko Poyry } 4903c827367444ee418f129b2c238299f49d3264554Jarkko Poyry} 4913c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 4923c827367444ee418f129b2c238299f49d3264554Jarkko Poyry} // anonymous 4933c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 4943c827367444ee418f129b2c238299f49d3264554Jarkko Poyryclass MultiThreadedConfigTest : public MultiThreadedTest 4953c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{ 4963c827367444ee418f129b2c238299f49d3264554Jarkko Poyrypublic: 4973c827367444ee418f129b2c238299f49d3264554Jarkko Poyry MultiThreadedConfigTest (EglTestContext& context, const char* name, const char* description, int getConfigs, int chooseConfigs, int query); 4983c827367444ee418f129b2c238299f49d3264554Jarkko Poyry bool runThread (TestThread& thread); 4993c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 5003c827367444ee418f129b2c238299f49d3264554Jarkko Poyryprivate: 5013c827367444ee418f129b2c238299f49d3264554Jarkko Poyry EGLDisplay m_display; 5023c827367444ee418f129b2c238299f49d3264554Jarkko Poyry const int m_getConfigs; 5033c827367444ee418f129b2c238299f49d3264554Jarkko Poyry const int m_chooseConfigs; 5043c827367444ee418f129b2c238299f49d3264554Jarkko Poyry const int m_query; 5053c827367444ee418f129b2c238299f49d3264554Jarkko Poyry}; 5063c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 5073c827367444ee418f129b2c238299f49d3264554Jarkko PoyryMultiThreadedConfigTest::MultiThreadedConfigTest (EglTestContext& context, const char* name, const char* description, int getConfigs, int chooseConfigs, int query) 5083c827367444ee418f129b2c238299f49d3264554Jarkko Poyry : MultiThreadedTest (context, name, description, 2, 20000000/*us = 20s*/) // \todo [mika] Set timeout to something relevant to frameworks timeout? 5093c827367444ee418f129b2c238299f49d3264554Jarkko Poyry , m_display (EGL_NO_DISPLAY) 5103c827367444ee418f129b2c238299f49d3264554Jarkko Poyry , m_getConfigs (getConfigs) 5113c827367444ee418f129b2c238299f49d3264554Jarkko Poyry , m_chooseConfigs (chooseConfigs) 5123c827367444ee418f129b2c238299f49d3264554Jarkko Poyry , m_query (query) 5133c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{ 5143c827367444ee418f129b2c238299f49d3264554Jarkko Poyry} 5153c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 5163c827367444ee418f129b2c238299f49d3264554Jarkko Poyrybool MultiThreadedConfigTest::runThread (TestThread& thread) 5173c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{ 5183c827367444ee418f129b2c238299f49d3264554Jarkko Poyry de::Random rnd(deInt32Hash(thread.getId() + 10435)); 5193c827367444ee418f129b2c238299f49d3264554Jarkko Poyry vector<EGLConfig> configs; 5203c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 5213c827367444ee418f129b2c238299f49d3264554Jarkko Poyry if (thread.getId() == 0) 5223c827367444ee418f129b2c238299f49d3264554Jarkko Poyry m_display = m_eglTestCtx.getDisplay().getEGLDisplay(); 5233c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 5243c827367444ee418f129b2c238299f49d3264554Jarkko Poyry barrier(thread); 5253c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 5263c827367444ee418f129b2c238299f49d3264554Jarkko Poyry for (int getConfigsNdx = 0; getConfigsNdx < m_getConfigs; getConfigsNdx++) 5273c827367444ee418f129b2c238299f49d3264554Jarkko Poyry { 5283c827367444ee418f129b2c238299f49d3264554Jarkko Poyry EGLint configCount; 5293c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 5303c827367444ee418f129b2c238299f49d3264554Jarkko Poyry // Get number of configs 5313c827367444ee418f129b2c238299f49d3264554Jarkko Poyry { 5323c827367444ee418f129b2c238299f49d3264554Jarkko Poyry EGLBoolean result; 5333c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 5343c827367444ee418f129b2c238299f49d3264554Jarkko Poyry result = eglGetConfigs(m_display, NULL, 0, &configCount); 5353c827367444ee418f129b2c238299f49d3264554Jarkko Poyry thread.getLog() << ThreadLog::BeginMessage << result << " = eglGetConfigs(" << m_display << ", NULL, 0, " << configCount << ")" << ThreadLog::EndMessage; 5363c827367444ee418f129b2c238299f49d3264554Jarkko Poyry TCU_CHECK_EGL_MSG("eglGetConfigs()"); 5373c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 5383c827367444ee418f129b2c238299f49d3264554Jarkko Poyry if (!result) 5393c827367444ee418f129b2c238299f49d3264554Jarkko Poyry return false; 5403c827367444ee418f129b2c238299f49d3264554Jarkko Poyry } 5413c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 5423c827367444ee418f129b2c238299f49d3264554Jarkko Poyry configs.resize(configs.size() + configCount); 5433c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 5443c827367444ee418f129b2c238299f49d3264554Jarkko Poyry // Get configs 5453c827367444ee418f129b2c238299f49d3264554Jarkko Poyry if (configCount != 0) 5463c827367444ee418f129b2c238299f49d3264554Jarkko Poyry { 5473c827367444ee418f129b2c238299f49d3264554Jarkko Poyry EGLBoolean result; 5483c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 5493c827367444ee418f129b2c238299f49d3264554Jarkko Poyry result = eglGetConfigs(m_display, &(configs[configs.size() - configCount]), configCount, &configCount); 5503c827367444ee418f129b2c238299f49d3264554Jarkko Poyry thread.getLog() << ThreadLog::BeginMessage << result << " = eglGetConfigs(" << m_display << ", &configs' " << configCount << ", " << configCount << ")" << ThreadLog::EndMessage; 5513c827367444ee418f129b2c238299f49d3264554Jarkko Poyry TCU_CHECK_EGL_MSG("eglGetConfigs()"); 5523c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 5533c827367444ee418f129b2c238299f49d3264554Jarkko Poyry if (!result) 5543c827367444ee418f129b2c238299f49d3264554Jarkko Poyry return false; 5553c827367444ee418f129b2c238299f49d3264554Jarkko Poyry } 5563c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 5573c827367444ee418f129b2c238299f49d3264554Jarkko Poyry // Pop configs to stop config list growing 5583c827367444ee418f129b2c238299f49d3264554Jarkko Poyry if (configs.size() > 40) 5593c827367444ee418f129b2c238299f49d3264554Jarkko Poyry { 5603c827367444ee418f129b2c238299f49d3264554Jarkko Poyry configs.erase(configs.begin() + 40, configs.end()); 5613c827367444ee418f129b2c238299f49d3264554Jarkko Poyry } 5623c827367444ee418f129b2c238299f49d3264554Jarkko Poyry else 5633c827367444ee418f129b2c238299f49d3264554Jarkko Poyry { 5643c827367444ee418f129b2c238299f49d3264554Jarkko Poyry const int popCount = rnd.getInt(0, (int)(configs.size()-2)); 5653c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 5663c827367444ee418f129b2c238299f49d3264554Jarkko Poyry configs.erase(configs.begin() + (configs.size() - popCount), configs.end()); 5673c827367444ee418f129b2c238299f49d3264554Jarkko Poyry } 5683c827367444ee418f129b2c238299f49d3264554Jarkko Poyry } 5693c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 5703c827367444ee418f129b2c238299f49d3264554Jarkko Poyry for (int chooseConfigsNdx = 0; chooseConfigsNdx < m_chooseConfigs; chooseConfigsNdx++) 5713c827367444ee418f129b2c238299f49d3264554Jarkko Poyry { 5723c827367444ee418f129b2c238299f49d3264554Jarkko Poyry EGLint configCount; 5733c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 5743c827367444ee418f129b2c238299f49d3264554Jarkko Poyry static const EGLint attribList[] = { 5753c827367444ee418f129b2c238299f49d3264554Jarkko Poyry EGL_NONE 5763c827367444ee418f129b2c238299f49d3264554Jarkko Poyry }; 5773c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 5783c827367444ee418f129b2c238299f49d3264554Jarkko Poyry // Get number of configs 5793c827367444ee418f129b2c238299f49d3264554Jarkko Poyry { 5803c827367444ee418f129b2c238299f49d3264554Jarkko Poyry EGLBoolean result; 5813c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 5823c827367444ee418f129b2c238299f49d3264554Jarkko Poyry result = eglChooseConfig(m_display, attribList, NULL, 0, &configCount); 5833c827367444ee418f129b2c238299f49d3264554Jarkko Poyry thread.getLog() << ThreadLog::BeginMessage << result << " = eglChooseConfig(" << m_display << ", { EGL_NONE }, NULL, 0, " << configCount << ")" << ThreadLog::EndMessage; 5843c827367444ee418f129b2c238299f49d3264554Jarkko Poyry TCU_CHECK_EGL_MSG("eglChooseConfig()"); 5853c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 5863c827367444ee418f129b2c238299f49d3264554Jarkko Poyry if (!result) 5873c827367444ee418f129b2c238299f49d3264554Jarkko Poyry return false; 5883c827367444ee418f129b2c238299f49d3264554Jarkko Poyry } 5893c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 5903c827367444ee418f129b2c238299f49d3264554Jarkko Poyry configs.resize(configs.size() + configCount); 5913c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 5923c827367444ee418f129b2c238299f49d3264554Jarkko Poyry // Get configs 5933c827367444ee418f129b2c238299f49d3264554Jarkko Poyry if (configCount != 0) 5943c827367444ee418f129b2c238299f49d3264554Jarkko Poyry { 5953c827367444ee418f129b2c238299f49d3264554Jarkko Poyry EGLBoolean result; 5963c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 5973c827367444ee418f129b2c238299f49d3264554Jarkko Poyry result = eglChooseConfig(m_display, attribList, &(configs[configs.size() - configCount]), configCount, &configCount); 5983c827367444ee418f129b2c238299f49d3264554Jarkko Poyry thread.getLog() << ThreadLog::BeginMessage << result << " = eglChooseConfig(" << m_display << ", { EGL_NONE }, &configs, " << configCount << ", " << configCount << ")" << ThreadLog::EndMessage; 5993c827367444ee418f129b2c238299f49d3264554Jarkko Poyry TCU_CHECK_EGL_MSG("eglChooseConfig()"); 6003c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 6013c827367444ee418f129b2c238299f49d3264554Jarkko Poyry if (!result) 6023c827367444ee418f129b2c238299f49d3264554Jarkko Poyry return false; 6033c827367444ee418f129b2c238299f49d3264554Jarkko Poyry } 6043c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 6053c827367444ee418f129b2c238299f49d3264554Jarkko Poyry // Pop configs to stop config list growing 6063c827367444ee418f129b2c238299f49d3264554Jarkko Poyry if (configs.size() > 40) 6073c827367444ee418f129b2c238299f49d3264554Jarkko Poyry { 6083c827367444ee418f129b2c238299f49d3264554Jarkko Poyry configs.erase(configs.begin() + 40, configs.end()); 6093c827367444ee418f129b2c238299f49d3264554Jarkko Poyry } 6103c827367444ee418f129b2c238299f49d3264554Jarkko Poyry else 6113c827367444ee418f129b2c238299f49d3264554Jarkko Poyry { 6123c827367444ee418f129b2c238299f49d3264554Jarkko Poyry const int popCount = rnd.getInt(0, (int)(configs.size()-2)); 6133c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 6143c827367444ee418f129b2c238299f49d3264554Jarkko Poyry configs.erase(configs.begin() + (configs.size() - popCount), configs.end()); 6153c827367444ee418f129b2c238299f49d3264554Jarkko Poyry } 6163c827367444ee418f129b2c238299f49d3264554Jarkko Poyry } 6173c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 6183c827367444ee418f129b2c238299f49d3264554Jarkko Poyry { 6193c827367444ee418f129b2c238299f49d3264554Jarkko Poyry // Perform queries on configs 6203c827367444ee418f129b2c238299f49d3264554Jarkko Poyry static const EGLint attributes[] = 6213c827367444ee418f129b2c238299f49d3264554Jarkko Poyry { 6223c827367444ee418f129b2c238299f49d3264554Jarkko Poyry EGL_BUFFER_SIZE, 6233c827367444ee418f129b2c238299f49d3264554Jarkko Poyry EGL_RED_SIZE, 6243c827367444ee418f129b2c238299f49d3264554Jarkko Poyry EGL_GREEN_SIZE, 6253c827367444ee418f129b2c238299f49d3264554Jarkko Poyry EGL_BLUE_SIZE, 6263c827367444ee418f129b2c238299f49d3264554Jarkko Poyry EGL_LUMINANCE_SIZE, 6273c827367444ee418f129b2c238299f49d3264554Jarkko Poyry EGL_ALPHA_SIZE, 6283c827367444ee418f129b2c238299f49d3264554Jarkko Poyry EGL_ALPHA_MASK_SIZE, 6293c827367444ee418f129b2c238299f49d3264554Jarkko Poyry EGL_BIND_TO_TEXTURE_RGB, 6303c827367444ee418f129b2c238299f49d3264554Jarkko Poyry EGL_BIND_TO_TEXTURE_RGBA, 6313c827367444ee418f129b2c238299f49d3264554Jarkko Poyry EGL_COLOR_BUFFER_TYPE, 6323c827367444ee418f129b2c238299f49d3264554Jarkko Poyry EGL_CONFIG_CAVEAT, 6333c827367444ee418f129b2c238299f49d3264554Jarkko Poyry EGL_CONFIG_ID, 6343c827367444ee418f129b2c238299f49d3264554Jarkko Poyry EGL_CONFORMANT, 6353c827367444ee418f129b2c238299f49d3264554Jarkko Poyry EGL_DEPTH_SIZE, 6363c827367444ee418f129b2c238299f49d3264554Jarkko Poyry EGL_LEVEL, 6373c827367444ee418f129b2c238299f49d3264554Jarkko Poyry EGL_MAX_PBUFFER_WIDTH, 6383c827367444ee418f129b2c238299f49d3264554Jarkko Poyry EGL_MAX_PBUFFER_HEIGHT, 6393c827367444ee418f129b2c238299f49d3264554Jarkko Poyry EGL_MAX_PBUFFER_PIXELS, 6403c827367444ee418f129b2c238299f49d3264554Jarkko Poyry EGL_MAX_SWAP_INTERVAL, 6413c827367444ee418f129b2c238299f49d3264554Jarkko Poyry EGL_MIN_SWAP_INTERVAL, 6423c827367444ee418f129b2c238299f49d3264554Jarkko Poyry EGL_NATIVE_RENDERABLE, 6433c827367444ee418f129b2c238299f49d3264554Jarkko Poyry EGL_NATIVE_VISUAL_ID, 6443c827367444ee418f129b2c238299f49d3264554Jarkko Poyry EGL_NATIVE_VISUAL_TYPE, 6453c827367444ee418f129b2c238299f49d3264554Jarkko Poyry EGL_RENDERABLE_TYPE, 6463c827367444ee418f129b2c238299f49d3264554Jarkko Poyry EGL_SAMPLE_BUFFERS, 6473c827367444ee418f129b2c238299f49d3264554Jarkko Poyry EGL_SAMPLES, 6483c827367444ee418f129b2c238299f49d3264554Jarkko Poyry EGL_STENCIL_SIZE, 6493c827367444ee418f129b2c238299f49d3264554Jarkko Poyry EGL_SURFACE_TYPE, 6503c827367444ee418f129b2c238299f49d3264554Jarkko Poyry EGL_TRANSPARENT_TYPE, 6513c827367444ee418f129b2c238299f49d3264554Jarkko Poyry EGL_TRANSPARENT_RED_VALUE, 6523c827367444ee418f129b2c238299f49d3264554Jarkko Poyry EGL_TRANSPARENT_GREEN_VALUE, 6533c827367444ee418f129b2c238299f49d3264554Jarkko Poyry EGL_TRANSPARENT_BLUE_VALUE 6543c827367444ee418f129b2c238299f49d3264554Jarkko Poyry }; 6553c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 6563c827367444ee418f129b2c238299f49d3264554Jarkko Poyry for (int queryNdx = 0; queryNdx < m_query; queryNdx++) 6573c827367444ee418f129b2c238299f49d3264554Jarkko Poyry { 6583c827367444ee418f129b2c238299f49d3264554Jarkko Poyry const EGLint attribute = attributes[rnd.getInt(0, DE_LENGTH_OF_ARRAY(attributes)-1)]; 6593c827367444ee418f129b2c238299f49d3264554Jarkko Poyry EGLConfig config = configs[rnd.getInt(0, (int)(configs.size()-1))]; 6603c827367444ee418f129b2c238299f49d3264554Jarkko Poyry EGLint value; 6613c827367444ee418f129b2c238299f49d3264554Jarkko Poyry EGLBoolean result; 6623c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 6633c827367444ee418f129b2c238299f49d3264554Jarkko Poyry result = eglGetConfigAttrib(m_display, config, attribute, &value); 6643c827367444ee418f129b2c238299f49d3264554Jarkko Poyry thread.getLog() << ThreadLog::BeginMessage << result << " = eglGetConfigAttrib(" << m_display << ", " << config << ", " << configAttributeToString(attribute) << ", " << value << ")" << ThreadLog::EndMessage; 6653c827367444ee418f129b2c238299f49d3264554Jarkko Poyry TCU_CHECK_EGL_MSG("eglGetConfigAttrib()"); 6663c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 6673c827367444ee418f129b2c238299f49d3264554Jarkko Poyry if (!result) 6683c827367444ee418f129b2c238299f49d3264554Jarkko Poyry return false; 6693c827367444ee418f129b2c238299f49d3264554Jarkko Poyry } 6703c827367444ee418f129b2c238299f49d3264554Jarkko Poyry } 6713c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 6723c827367444ee418f129b2c238299f49d3264554Jarkko Poyry return true; 6733c827367444ee418f129b2c238299f49d3264554Jarkko Poyry} 6743c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 6753c827367444ee418f129b2c238299f49d3264554Jarkko Poyryclass MultiThreadedObjectTest : public MultiThreadedTest 6763c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{ 6773c827367444ee418f129b2c238299f49d3264554Jarkko Poyrypublic: 6783c827367444ee418f129b2c238299f49d3264554Jarkko Poyry enum Type 6793c827367444ee418f129b2c238299f49d3264554Jarkko Poyry { 6803c827367444ee418f129b2c238299f49d3264554Jarkko Poyry TYPE_PBUFFER = (1<<0), 6813c827367444ee418f129b2c238299f49d3264554Jarkko Poyry TYPE_PIXMAP = (1<<1), 6823c827367444ee418f129b2c238299f49d3264554Jarkko Poyry TYPE_WINDOW = (1<<2), 6833c827367444ee418f129b2c238299f49d3264554Jarkko Poyry TYPE_SINGLE_WINDOW = (1<<3), 6843c827367444ee418f129b2c238299f49d3264554Jarkko Poyry TYPE_CONTEXT = (1<<4) 6853c827367444ee418f129b2c238299f49d3264554Jarkko Poyry }; 6863c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 6873c827367444ee418f129b2c238299f49d3264554Jarkko Poyry MultiThreadedObjectTest (EglTestContext& context, const char* name, const char* description, deUint32 types); 6883c827367444ee418f129b2c238299f49d3264554Jarkko Poyry ~MultiThreadedObjectTest (void); 6893c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 6903c827367444ee418f129b2c238299f49d3264554Jarkko Poyry virtual void deinit (void); 6913c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 6923c827367444ee418f129b2c238299f49d3264554Jarkko Poyry bool runThread (TestThread& thread); 6933c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 6943c827367444ee418f129b2c238299f49d3264554Jarkko Poyry void createDestroyObjects (TestThread& thread, int count); 6953c827367444ee418f129b2c238299f49d3264554Jarkko Poyry void pushObjectsToShared (TestThread& thread); 6963c827367444ee418f129b2c238299f49d3264554Jarkko Poyry void pullObjectsFromShared (TestThread& thread, int pbufferCount, int pixmapCount, int windowCount, int contextCount); 6973c827367444ee418f129b2c238299f49d3264554Jarkko Poyry void querySetSharedObjects (TestThread& thread, int count); 6983c827367444ee418f129b2c238299f49d3264554Jarkko Poyry void destroyObjects (TestThread& thread); 6993c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 7003c827367444ee418f129b2c238299f49d3264554Jarkko Poyryprivate: 7013c827367444ee418f129b2c238299f49d3264554Jarkko Poyry EGLDisplay m_display; 7023c827367444ee418f129b2c238299f49d3264554Jarkko Poyry EGLConfig m_config; 7033c827367444ee418f129b2c238299f49d3264554Jarkko Poyry de::Random m_rnd0; 7043c827367444ee418f129b2c238299f49d3264554Jarkko Poyry de::Random m_rnd1; 7053c827367444ee418f129b2c238299f49d3264554Jarkko Poyry Type m_types; 7063c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 7073c827367444ee418f129b2c238299f49d3264554Jarkko Poyry volatile deUint32 m_hasWindow; 7083c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 7093c827367444ee418f129b2c238299f49d3264554Jarkko Poyry vector<pair<eglu::NativePixmap*, EGLSurface> > m_sharedNativePixmaps; 7103c827367444ee418f129b2c238299f49d3264554Jarkko Poyry vector<pair<eglu::NativePixmap*, EGLSurface> > m_nativePixmaps0; 7113c827367444ee418f129b2c238299f49d3264554Jarkko Poyry vector<pair<eglu::NativePixmap*, EGLSurface> > m_nativePixmaps1; 7123c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 7133c827367444ee418f129b2c238299f49d3264554Jarkko Poyry vector<pair<eglu::NativeWindow*, EGLSurface> > m_sharedNativeWindows; 7143c827367444ee418f129b2c238299f49d3264554Jarkko Poyry vector<pair<eglu::NativeWindow*, EGLSurface> > m_nativeWindows0; 7153c827367444ee418f129b2c238299f49d3264554Jarkko Poyry vector<pair<eglu::NativeWindow*, EGLSurface> > m_nativeWindows1; 7163c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 7173c827367444ee418f129b2c238299f49d3264554Jarkko Poyry vector<EGLSurface> m_sharedPbuffers; 7183c827367444ee418f129b2c238299f49d3264554Jarkko Poyry vector<EGLSurface> m_pbuffers0; 7193c827367444ee418f129b2c238299f49d3264554Jarkko Poyry vector<EGLSurface> m_pbuffers1; 7203c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 7213c827367444ee418f129b2c238299f49d3264554Jarkko Poyry vector<EGLContext> m_sharedContexts; 7223c827367444ee418f129b2c238299f49d3264554Jarkko Poyry vector<EGLContext> m_contexts0; 7233c827367444ee418f129b2c238299f49d3264554Jarkko Poyry vector<EGLContext> m_contexts1; 7243c827367444ee418f129b2c238299f49d3264554Jarkko Poyry}; 7253c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 7263c827367444ee418f129b2c238299f49d3264554Jarkko PoyryMultiThreadedObjectTest::MultiThreadedObjectTest (EglTestContext& context, const char* name, const char* description, deUint32 type) 7273c827367444ee418f129b2c238299f49d3264554Jarkko Poyry : MultiThreadedTest (context, name, description, 2, 20000000/*us = 20s*/) // \todo [mika] Set timeout to something relevant to frameworks timeout? 7283c827367444ee418f129b2c238299f49d3264554Jarkko Poyry , m_display (EGL_NO_DISPLAY) 7293c827367444ee418f129b2c238299f49d3264554Jarkko Poyry , m_config (DE_NULL) 7303c827367444ee418f129b2c238299f49d3264554Jarkko Poyry , m_rnd0 (58204327) 7313c827367444ee418f129b2c238299f49d3264554Jarkko Poyry , m_rnd1 (230983) 7323c827367444ee418f129b2c238299f49d3264554Jarkko Poyry , m_types ((Type)type) 7333c827367444ee418f129b2c238299f49d3264554Jarkko Poyry , m_hasWindow (0) 7343c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{ 7353c827367444ee418f129b2c238299f49d3264554Jarkko Poyry} 7363c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 7373c827367444ee418f129b2c238299f49d3264554Jarkko PoyryMultiThreadedObjectTest::~MultiThreadedObjectTest (void) 7383c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{ 7393c827367444ee418f129b2c238299f49d3264554Jarkko Poyry deinit(); 7403c827367444ee418f129b2c238299f49d3264554Jarkko Poyry} 7413c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 7423c827367444ee418f129b2c238299f49d3264554Jarkko Poyryvoid MultiThreadedObjectTest::deinit (void) 7433c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{ 7443c827367444ee418f129b2c238299f49d3264554Jarkko Poyry // Clear pbuffers 7453c827367444ee418f129b2c238299f49d3264554Jarkko Poyry for (int pbufferNdx = 0; pbufferNdx < (int)m_pbuffers0.size(); pbufferNdx++) 7463c827367444ee418f129b2c238299f49d3264554Jarkko Poyry { 7473c827367444ee418f129b2c238299f49d3264554Jarkko Poyry if (m_pbuffers0[pbufferNdx] != EGL_NO_SURFACE) 7483c827367444ee418f129b2c238299f49d3264554Jarkko Poyry { 7493c827367444ee418f129b2c238299f49d3264554Jarkko Poyry eglDestroySurface(m_display, m_pbuffers0[pbufferNdx]); 7503c827367444ee418f129b2c238299f49d3264554Jarkko Poyry TCU_CHECK_EGL_MSG("eglDestroySurface()"); 7513c827367444ee418f129b2c238299f49d3264554Jarkko Poyry m_pbuffers0[pbufferNdx] = EGL_NO_SURFACE; 7523c827367444ee418f129b2c238299f49d3264554Jarkko Poyry } 7533c827367444ee418f129b2c238299f49d3264554Jarkko Poyry } 7543c827367444ee418f129b2c238299f49d3264554Jarkko Poyry m_pbuffers0.clear(); 7553c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 7563c827367444ee418f129b2c238299f49d3264554Jarkko Poyry for (int pbufferNdx = 0; pbufferNdx < (int)m_pbuffers1.size(); pbufferNdx++) 7573c827367444ee418f129b2c238299f49d3264554Jarkko Poyry { 7583c827367444ee418f129b2c238299f49d3264554Jarkko Poyry if (m_pbuffers1[pbufferNdx] != EGL_NO_SURFACE) 7593c827367444ee418f129b2c238299f49d3264554Jarkko Poyry { 7603c827367444ee418f129b2c238299f49d3264554Jarkko Poyry eglDestroySurface(m_display, m_pbuffers1[pbufferNdx]); 7613c827367444ee418f129b2c238299f49d3264554Jarkko Poyry TCU_CHECK_EGL_MSG("eglDestroySurface()"); 7623c827367444ee418f129b2c238299f49d3264554Jarkko Poyry m_pbuffers1[pbufferNdx] = EGL_NO_SURFACE; 7633c827367444ee418f129b2c238299f49d3264554Jarkko Poyry } 7643c827367444ee418f129b2c238299f49d3264554Jarkko Poyry } 7653c827367444ee418f129b2c238299f49d3264554Jarkko Poyry m_pbuffers1.clear(); 7663c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 7673c827367444ee418f129b2c238299f49d3264554Jarkko Poyry for (int pbufferNdx = 0; pbufferNdx < (int)m_sharedPbuffers.size(); pbufferNdx++) 7683c827367444ee418f129b2c238299f49d3264554Jarkko Poyry { 7693c827367444ee418f129b2c238299f49d3264554Jarkko Poyry if (m_sharedPbuffers[pbufferNdx] != EGL_NO_SURFACE) 7703c827367444ee418f129b2c238299f49d3264554Jarkko Poyry { 7713c827367444ee418f129b2c238299f49d3264554Jarkko Poyry eglDestroySurface(m_display, m_sharedPbuffers[pbufferNdx]); 7723c827367444ee418f129b2c238299f49d3264554Jarkko Poyry TCU_CHECK_EGL_MSG("eglDestroySurface()"); 7733c827367444ee418f129b2c238299f49d3264554Jarkko Poyry m_sharedPbuffers[pbufferNdx] = EGL_NO_SURFACE; 7743c827367444ee418f129b2c238299f49d3264554Jarkko Poyry } 7753c827367444ee418f129b2c238299f49d3264554Jarkko Poyry } 7763c827367444ee418f129b2c238299f49d3264554Jarkko Poyry m_sharedPbuffers.clear(); 7773c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 7783c827367444ee418f129b2c238299f49d3264554Jarkko Poyry for (int contextNdx = 0; contextNdx < (int)m_sharedContexts.size(); contextNdx++) 7793c827367444ee418f129b2c238299f49d3264554Jarkko Poyry { 7803c827367444ee418f129b2c238299f49d3264554Jarkko Poyry if (m_sharedContexts[contextNdx] != EGL_NO_CONTEXT) 7813c827367444ee418f129b2c238299f49d3264554Jarkko Poyry { 7823c827367444ee418f129b2c238299f49d3264554Jarkko Poyry eglDestroyContext(m_display, m_sharedContexts[contextNdx]); 7833c827367444ee418f129b2c238299f49d3264554Jarkko Poyry TCU_CHECK_EGL_MSG("eglDestroyContext()"); 7843c827367444ee418f129b2c238299f49d3264554Jarkko Poyry m_sharedContexts[contextNdx] = EGL_NO_CONTEXT; 7853c827367444ee418f129b2c238299f49d3264554Jarkko Poyry } 7863c827367444ee418f129b2c238299f49d3264554Jarkko Poyry } 7873c827367444ee418f129b2c238299f49d3264554Jarkko Poyry m_sharedContexts.clear(); 7883c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 7893c827367444ee418f129b2c238299f49d3264554Jarkko Poyry for (int contextNdx = 0; contextNdx < (int)m_contexts0.size(); contextNdx++) 7903c827367444ee418f129b2c238299f49d3264554Jarkko Poyry { 7913c827367444ee418f129b2c238299f49d3264554Jarkko Poyry if (m_contexts0[contextNdx] != EGL_NO_CONTEXT) 7923c827367444ee418f129b2c238299f49d3264554Jarkko Poyry { 7933c827367444ee418f129b2c238299f49d3264554Jarkko Poyry eglDestroyContext(m_display, m_contexts0[contextNdx]); 7943c827367444ee418f129b2c238299f49d3264554Jarkko Poyry TCU_CHECK_EGL_MSG("eglDestroyContext()"); 7953c827367444ee418f129b2c238299f49d3264554Jarkko Poyry m_contexts0[contextNdx] = EGL_NO_CONTEXT; 7963c827367444ee418f129b2c238299f49d3264554Jarkko Poyry } 7973c827367444ee418f129b2c238299f49d3264554Jarkko Poyry } 7983c827367444ee418f129b2c238299f49d3264554Jarkko Poyry m_contexts0.clear(); 7993c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 8003c827367444ee418f129b2c238299f49d3264554Jarkko Poyry for (int contextNdx = 0; contextNdx < (int)m_contexts1.size(); contextNdx++) 8013c827367444ee418f129b2c238299f49d3264554Jarkko Poyry { 8023c827367444ee418f129b2c238299f49d3264554Jarkko Poyry if (m_contexts1[contextNdx] != EGL_NO_CONTEXT) 8033c827367444ee418f129b2c238299f49d3264554Jarkko Poyry { 8043c827367444ee418f129b2c238299f49d3264554Jarkko Poyry eglDestroyContext(m_display, m_contexts1[contextNdx]); 8053c827367444ee418f129b2c238299f49d3264554Jarkko Poyry TCU_CHECK_EGL_MSG("eglDestroyContext()"); 8063c827367444ee418f129b2c238299f49d3264554Jarkko Poyry m_contexts1[contextNdx] = EGL_NO_CONTEXT; 8073c827367444ee418f129b2c238299f49d3264554Jarkko Poyry } 8083c827367444ee418f129b2c238299f49d3264554Jarkko Poyry } 8093c827367444ee418f129b2c238299f49d3264554Jarkko Poyry m_contexts1.clear(); 8103c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 8113c827367444ee418f129b2c238299f49d3264554Jarkko Poyry // Clear pixmaps 8123c827367444ee418f129b2c238299f49d3264554Jarkko Poyry for (int pixmapNdx = 0; pixmapNdx < (int)m_nativePixmaps0.size(); pixmapNdx++) 8133c827367444ee418f129b2c238299f49d3264554Jarkko Poyry { 8143c827367444ee418f129b2c238299f49d3264554Jarkko Poyry if (m_nativePixmaps0[pixmapNdx].second != EGL_NO_SURFACE) 8153c827367444ee418f129b2c238299f49d3264554Jarkko Poyry TCU_CHECK_EGL_CALL(eglDestroySurface(m_display, m_nativePixmaps0[pixmapNdx].second)); 8163c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 8173c827367444ee418f129b2c238299f49d3264554Jarkko Poyry m_nativePixmaps0[pixmapNdx].second = EGL_NO_SURFACE; 8183c827367444ee418f129b2c238299f49d3264554Jarkko Poyry delete m_nativePixmaps0[pixmapNdx].first; 8193c827367444ee418f129b2c238299f49d3264554Jarkko Poyry m_nativePixmaps0[pixmapNdx].first = NULL; 8203c827367444ee418f129b2c238299f49d3264554Jarkko Poyry } 8213c827367444ee418f129b2c238299f49d3264554Jarkko Poyry m_nativePixmaps0.clear(); 8223c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 8233c827367444ee418f129b2c238299f49d3264554Jarkko Poyry for (int pixmapNdx = 0; pixmapNdx < (int)m_nativePixmaps1.size(); pixmapNdx++) 8243c827367444ee418f129b2c238299f49d3264554Jarkko Poyry { 8253c827367444ee418f129b2c238299f49d3264554Jarkko Poyry if (m_nativePixmaps1[pixmapNdx].second != EGL_NO_SURFACE) 8263c827367444ee418f129b2c238299f49d3264554Jarkko Poyry TCU_CHECK_EGL_CALL(eglDestroySurface(m_display, m_nativePixmaps1[pixmapNdx].second)); 8273c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 8283c827367444ee418f129b2c238299f49d3264554Jarkko Poyry m_nativePixmaps1[pixmapNdx].second = EGL_NO_SURFACE; 8293c827367444ee418f129b2c238299f49d3264554Jarkko Poyry delete m_nativePixmaps1[pixmapNdx].first; 8303c827367444ee418f129b2c238299f49d3264554Jarkko Poyry m_nativePixmaps1[pixmapNdx].first = NULL; 8313c827367444ee418f129b2c238299f49d3264554Jarkko Poyry } 8323c827367444ee418f129b2c238299f49d3264554Jarkko Poyry m_nativePixmaps1.clear(); 8333c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 8343c827367444ee418f129b2c238299f49d3264554Jarkko Poyry for (int pixmapNdx = 0; pixmapNdx < (int)m_sharedNativePixmaps.size(); pixmapNdx++) 8353c827367444ee418f129b2c238299f49d3264554Jarkko Poyry { 8363c827367444ee418f129b2c238299f49d3264554Jarkko Poyry if (m_sharedNativePixmaps[pixmapNdx].second != EGL_NO_SURFACE) 8373c827367444ee418f129b2c238299f49d3264554Jarkko Poyry TCU_CHECK_EGL_CALL(eglDestroySurface(m_display, m_sharedNativePixmaps[pixmapNdx].second)); 8383c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 8393c827367444ee418f129b2c238299f49d3264554Jarkko Poyry m_sharedNativePixmaps[pixmapNdx].second = EGL_NO_SURFACE; 8403c827367444ee418f129b2c238299f49d3264554Jarkko Poyry delete m_sharedNativePixmaps[pixmapNdx].first; 8413c827367444ee418f129b2c238299f49d3264554Jarkko Poyry m_sharedNativePixmaps[pixmapNdx].first = NULL; 8423c827367444ee418f129b2c238299f49d3264554Jarkko Poyry } 8433c827367444ee418f129b2c238299f49d3264554Jarkko Poyry m_sharedNativePixmaps.clear(); 8443c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 8453c827367444ee418f129b2c238299f49d3264554Jarkko Poyry // Clear windows 8463c827367444ee418f129b2c238299f49d3264554Jarkko Poyry for (int windowNdx = 0; windowNdx < (int)m_nativeWindows1.size(); windowNdx++) 8473c827367444ee418f129b2c238299f49d3264554Jarkko Poyry { 8483c827367444ee418f129b2c238299f49d3264554Jarkko Poyry if (m_nativeWindows1[windowNdx].second != EGL_NO_SURFACE) 8493c827367444ee418f129b2c238299f49d3264554Jarkko Poyry TCU_CHECK_EGL_CALL(eglDestroySurface(m_display, m_nativeWindows1[windowNdx].second)); 8503c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 8513c827367444ee418f129b2c238299f49d3264554Jarkko Poyry m_nativeWindows1[windowNdx].second = EGL_NO_SURFACE; 8523c827367444ee418f129b2c238299f49d3264554Jarkko Poyry delete m_nativeWindows1[windowNdx].first; 8533c827367444ee418f129b2c238299f49d3264554Jarkko Poyry m_nativeWindows1[windowNdx].first = NULL; 8543c827367444ee418f129b2c238299f49d3264554Jarkko Poyry } 8553c827367444ee418f129b2c238299f49d3264554Jarkko Poyry m_nativeWindows1.clear(); 8563c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 8573c827367444ee418f129b2c238299f49d3264554Jarkko Poyry for (int windowNdx = 0; windowNdx < (int)m_nativeWindows0.size(); windowNdx++) 8583c827367444ee418f129b2c238299f49d3264554Jarkko Poyry { 8593c827367444ee418f129b2c238299f49d3264554Jarkko Poyry if (m_nativeWindows0[windowNdx].second != EGL_NO_SURFACE) 8603c827367444ee418f129b2c238299f49d3264554Jarkko Poyry TCU_CHECK_EGL_CALL(eglDestroySurface(m_display, m_nativeWindows0[windowNdx].second)); 8613c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 8623c827367444ee418f129b2c238299f49d3264554Jarkko Poyry m_nativeWindows0[windowNdx].second = EGL_NO_SURFACE; 8633c827367444ee418f129b2c238299f49d3264554Jarkko Poyry delete m_nativeWindows0[windowNdx].first; 8643c827367444ee418f129b2c238299f49d3264554Jarkko Poyry m_nativeWindows0[windowNdx].first = NULL; 8653c827367444ee418f129b2c238299f49d3264554Jarkko Poyry } 8663c827367444ee418f129b2c238299f49d3264554Jarkko Poyry m_nativeWindows0.clear(); 8673c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 8683c827367444ee418f129b2c238299f49d3264554Jarkko Poyry for (int windowNdx = 0; windowNdx < (int)m_sharedNativeWindows.size(); windowNdx++) 8693c827367444ee418f129b2c238299f49d3264554Jarkko Poyry { 8703c827367444ee418f129b2c238299f49d3264554Jarkko Poyry if (m_sharedNativeWindows[windowNdx].second != EGL_NO_SURFACE) 8713c827367444ee418f129b2c238299f49d3264554Jarkko Poyry TCU_CHECK_EGL_CALL(eglDestroySurface(m_display, m_sharedNativeWindows[windowNdx].second)); 8723c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 8733c827367444ee418f129b2c238299f49d3264554Jarkko Poyry m_sharedNativeWindows[windowNdx].second = EGL_NO_SURFACE; 8743c827367444ee418f129b2c238299f49d3264554Jarkko Poyry delete m_sharedNativeWindows[windowNdx].first; 8753c827367444ee418f129b2c238299f49d3264554Jarkko Poyry m_sharedNativeWindows[windowNdx].first = NULL; 8763c827367444ee418f129b2c238299f49d3264554Jarkko Poyry } 8773c827367444ee418f129b2c238299f49d3264554Jarkko Poyry m_sharedNativeWindows.clear(); 8783c827367444ee418f129b2c238299f49d3264554Jarkko Poyry} 8793c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 8803c827367444ee418f129b2c238299f49d3264554Jarkko Poyrybool MultiThreadedObjectTest::runThread (TestThread& thread) 8813c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{ 8823c827367444ee418f129b2c238299f49d3264554Jarkko Poyry if (thread.getId() == 0) 8833c827367444ee418f129b2c238299f49d3264554Jarkko Poyry { 8843c827367444ee418f129b2c238299f49d3264554Jarkko Poyry m_display = m_eglTestCtx.getDisplay().getEGLDisplay(); 8853c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 8863c827367444ee418f129b2c238299f49d3264554Jarkko Poyry EGLint surfaceTypes = 0; 8873c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 8883c827367444ee418f129b2c238299f49d3264554Jarkko Poyry if ((m_types & TYPE_WINDOW) != 0) 8893c827367444ee418f129b2c238299f49d3264554Jarkko Poyry surfaceTypes |= EGL_WINDOW_BIT; 8903c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 8913c827367444ee418f129b2c238299f49d3264554Jarkko Poyry if ((m_types & TYPE_PBUFFER) != 0) 8923c827367444ee418f129b2c238299f49d3264554Jarkko Poyry surfaceTypes |= EGL_PBUFFER_BIT; 8933c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 8943c827367444ee418f129b2c238299f49d3264554Jarkko Poyry if ((m_types & TYPE_PIXMAP) != 0) 8953c827367444ee418f129b2c238299f49d3264554Jarkko Poyry surfaceTypes |= EGL_PIXMAP_BIT; 8963c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 8973c827367444ee418f129b2c238299f49d3264554Jarkko Poyry EGLint configCount; 8983c827367444ee418f129b2c238299f49d3264554Jarkko Poyry EGLint attribList[] = 8993c827367444ee418f129b2c238299f49d3264554Jarkko Poyry { 9003c827367444ee418f129b2c238299f49d3264554Jarkko Poyry EGL_SURFACE_TYPE, surfaceTypes, 9013c827367444ee418f129b2c238299f49d3264554Jarkko Poyry EGL_RENDERABLE_TYPE, EGL_OPENGL_ES2_BIT, 9023c827367444ee418f129b2c238299f49d3264554Jarkko Poyry EGL_NONE 9033c827367444ee418f129b2c238299f49d3264554Jarkko Poyry }; 9043c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 9053c827367444ee418f129b2c238299f49d3264554Jarkko Poyry TCU_CHECK_EGL_CALL(eglChooseConfig(m_display, attribList, &m_config, 1, &configCount)); 9063c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 9073c827367444ee418f129b2c238299f49d3264554Jarkko Poyry if (configCount == 0) 9083c827367444ee418f129b2c238299f49d3264554Jarkko Poyry throw tcu::NotSupportedError("No usable config found", "", __FILE__, __LINE__); 9093c827367444ee418f129b2c238299f49d3264554Jarkko Poyry } 9103c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 9113c827367444ee418f129b2c238299f49d3264554Jarkko Poyry barrier(thread); 9123c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 9133c827367444ee418f129b2c238299f49d3264554Jarkko Poyry // Create / Destroy Objects 9143c827367444ee418f129b2c238299f49d3264554Jarkko Poyry if ((m_types & TYPE_SINGLE_WINDOW) != 0 && (m_types & TYPE_PBUFFER) == 0 && (m_types & TYPE_PIXMAP) == 0 && (m_types & TYPE_CONTEXT) == 0) 9153c827367444ee418f129b2c238299f49d3264554Jarkko Poyry { 9163c827367444ee418f129b2c238299f49d3264554Jarkko Poyry if (thread.getId() == 0) 9173c827367444ee418f129b2c238299f49d3264554Jarkko Poyry createDestroyObjects(thread, 1); 9183c827367444ee418f129b2c238299f49d3264554Jarkko Poyry } 9193c827367444ee418f129b2c238299f49d3264554Jarkko Poyry else 9203c827367444ee418f129b2c238299f49d3264554Jarkko Poyry createDestroyObjects(thread, 100); 9213c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 9223c827367444ee418f129b2c238299f49d3264554Jarkko Poyry // Push first threads objects to shared 9233c827367444ee418f129b2c238299f49d3264554Jarkko Poyry if (thread.getId() == 0) 9243c827367444ee418f129b2c238299f49d3264554Jarkko Poyry pushObjectsToShared(thread); 9253c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 9263c827367444ee418f129b2c238299f49d3264554Jarkko Poyry barrier(thread); 9273c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 9283c827367444ee418f129b2c238299f49d3264554Jarkko Poyry // Push second threads objects to shared 9293c827367444ee418f129b2c238299f49d3264554Jarkko Poyry if (thread.getId() == 1) 9303c827367444ee418f129b2c238299f49d3264554Jarkko Poyry pushObjectsToShared(thread); 9313c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 9323c827367444ee418f129b2c238299f49d3264554Jarkko Poyry barrier(thread); 9333c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 9343c827367444ee418f129b2c238299f49d3264554Jarkko Poyry // Make queries from shared surfaces 9353c827367444ee418f129b2c238299f49d3264554Jarkko Poyry querySetSharedObjects(thread, 100); 9363c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 9373c827367444ee418f129b2c238299f49d3264554Jarkko Poyry barrier(thread); 9383c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 9393c827367444ee418f129b2c238299f49d3264554Jarkko Poyry // Pull surfaces for first thread from shared surfaces 9403c827367444ee418f129b2c238299f49d3264554Jarkko Poyry if (thread.getId() == 0) 9413c827367444ee418f129b2c238299f49d3264554Jarkko Poyry pullObjectsFromShared(thread, (int)(m_sharedPbuffers.size()/2), (int)(m_sharedNativePixmaps.size()/2), (int)(m_sharedNativeWindows.size()/2), (int)(m_sharedContexts.size()/2)); 9423c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 9433c827367444ee418f129b2c238299f49d3264554Jarkko Poyry barrier(thread); 9443c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 9453c827367444ee418f129b2c238299f49d3264554Jarkko Poyry // Pull surfaces for second thread from shared surfaces 9463c827367444ee418f129b2c238299f49d3264554Jarkko Poyry if (thread.getId() == 1) 9473c827367444ee418f129b2c238299f49d3264554Jarkko Poyry pullObjectsFromShared(thread, (int)m_sharedPbuffers.size(), (int)m_sharedNativePixmaps.size(), (int)m_sharedNativeWindows.size(), (int)m_sharedContexts.size()); 9483c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 9493c827367444ee418f129b2c238299f49d3264554Jarkko Poyry barrier(thread); 9503c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 9513c827367444ee418f129b2c238299f49d3264554Jarkko Poyry // Create / Destroy Objects 9523c827367444ee418f129b2c238299f49d3264554Jarkko Poyry if ((m_types & TYPE_SINGLE_WINDOW) == 0) 9533c827367444ee418f129b2c238299f49d3264554Jarkko Poyry createDestroyObjects(thread, 100); 9543c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 9553c827367444ee418f129b2c238299f49d3264554Jarkko Poyry // Destroy surfaces 9563c827367444ee418f129b2c238299f49d3264554Jarkko Poyry destroyObjects(thread); 9573c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 9583c827367444ee418f129b2c238299f49d3264554Jarkko Poyry return true; 9593c827367444ee418f129b2c238299f49d3264554Jarkko Poyry} 9603c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 9613c827367444ee418f129b2c238299f49d3264554Jarkko Poyryvoid MultiThreadedObjectTest::createDestroyObjects (TestThread& thread, int count) 9623c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{ 9633c827367444ee418f129b2c238299f49d3264554Jarkko Poyry de::Random& rnd = (thread.getId() == 0 ? m_rnd0 : m_rnd1); 9643c827367444ee418f129b2c238299f49d3264554Jarkko Poyry vector<EGLSurface>& pbuffers = (thread.getId() == 0 ? m_pbuffers0 : m_pbuffers1); 9653c827367444ee418f129b2c238299f49d3264554Jarkko Poyry vector<pair<eglu::NativeWindow*, EGLSurface> >& windows = (thread.getId() == 0 ? m_nativeWindows0 : m_nativeWindows1); 9663c827367444ee418f129b2c238299f49d3264554Jarkko Poyry vector<pair<eglu::NativePixmap*, EGLSurface> >& pixmaps = (thread.getId() == 0 ? m_nativePixmaps0 : m_nativePixmaps1); 9673c827367444ee418f129b2c238299f49d3264554Jarkko Poyry vector<EGLContext>& contexts = (thread.getId() == 0 ? m_contexts0 : m_contexts1); 9683c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 9693c827367444ee418f129b2c238299f49d3264554Jarkko Poyry vector<Type> objectTypes; 9703c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 9713c827367444ee418f129b2c238299f49d3264554Jarkko Poyry if ((m_types & TYPE_PBUFFER) != 0) 9723c827367444ee418f129b2c238299f49d3264554Jarkko Poyry objectTypes.push_back(TYPE_PBUFFER); 9733c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 9743c827367444ee418f129b2c238299f49d3264554Jarkko Poyry if ((m_types & TYPE_PIXMAP) != 0) 9753c827367444ee418f129b2c238299f49d3264554Jarkko Poyry objectTypes.push_back(TYPE_PIXMAP); 9763c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 9773c827367444ee418f129b2c238299f49d3264554Jarkko Poyry if ((m_types & TYPE_WINDOW) != 0) 9783c827367444ee418f129b2c238299f49d3264554Jarkko Poyry objectTypes.push_back(TYPE_WINDOW); 9793c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 9803c827367444ee418f129b2c238299f49d3264554Jarkko Poyry if ((m_types & TYPE_CONTEXT) != 0) 9813c827367444ee418f129b2c238299f49d3264554Jarkko Poyry objectTypes.push_back(TYPE_CONTEXT); 9823c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 9833c827367444ee418f129b2c238299f49d3264554Jarkko Poyry for (int createDestroyNdx = 0; createDestroyNdx < count; createDestroyNdx++) 9843c827367444ee418f129b2c238299f49d3264554Jarkko Poyry { 9853c827367444ee418f129b2c238299f49d3264554Jarkko Poyry bool create; 9863c827367444ee418f129b2c238299f49d3264554Jarkko Poyry Type type; 9873c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 9883c827367444ee418f129b2c238299f49d3264554Jarkko Poyry if (pbuffers.size() > 5 && ((m_types & TYPE_PBUFFER) != 0)) 9893c827367444ee418f129b2c238299f49d3264554Jarkko Poyry { 9903c827367444ee418f129b2c238299f49d3264554Jarkko Poyry create = false; 9913c827367444ee418f129b2c238299f49d3264554Jarkko Poyry type = TYPE_PBUFFER; 9923c827367444ee418f129b2c238299f49d3264554Jarkko Poyry } 9933c827367444ee418f129b2c238299f49d3264554Jarkko Poyry else if (windows.size() > 5 && ((m_types & TYPE_WINDOW) != 0)) 9943c827367444ee418f129b2c238299f49d3264554Jarkko Poyry { 9953c827367444ee418f129b2c238299f49d3264554Jarkko Poyry create = false; 9963c827367444ee418f129b2c238299f49d3264554Jarkko Poyry type = TYPE_WINDOW; 9973c827367444ee418f129b2c238299f49d3264554Jarkko Poyry } 9983c827367444ee418f129b2c238299f49d3264554Jarkko Poyry else if (pixmaps.size() > 5 && ((m_types & TYPE_PIXMAP) != 0)) 9993c827367444ee418f129b2c238299f49d3264554Jarkko Poyry { 10003c827367444ee418f129b2c238299f49d3264554Jarkko Poyry create = false; 10013c827367444ee418f129b2c238299f49d3264554Jarkko Poyry type = TYPE_PIXMAP; 10023c827367444ee418f129b2c238299f49d3264554Jarkko Poyry } 10033c827367444ee418f129b2c238299f49d3264554Jarkko Poyry else if (contexts.size() > 5 && ((m_types & TYPE_CONTEXT) != 0)) 10043c827367444ee418f129b2c238299f49d3264554Jarkko Poyry { 10053c827367444ee418f129b2c238299f49d3264554Jarkko Poyry create = false; 10063c827367444ee418f129b2c238299f49d3264554Jarkko Poyry type = TYPE_CONTEXT; 10073c827367444ee418f129b2c238299f49d3264554Jarkko Poyry } 10083c827367444ee418f129b2c238299f49d3264554Jarkko Poyry else if (pbuffers.size() < 3 && ((m_types & TYPE_PBUFFER) != 0)) 10093c827367444ee418f129b2c238299f49d3264554Jarkko Poyry { 10103c827367444ee418f129b2c238299f49d3264554Jarkko Poyry create = true; 10113c827367444ee418f129b2c238299f49d3264554Jarkko Poyry type = TYPE_PBUFFER; 10123c827367444ee418f129b2c238299f49d3264554Jarkko Poyry } 10133c827367444ee418f129b2c238299f49d3264554Jarkko Poyry else if (pixmaps.size() < 3 && ((m_types & TYPE_PIXMAP) != 0)) 10143c827367444ee418f129b2c238299f49d3264554Jarkko Poyry { 10153c827367444ee418f129b2c238299f49d3264554Jarkko Poyry create = true; 10163c827367444ee418f129b2c238299f49d3264554Jarkko Poyry type = TYPE_PIXMAP; 10173c827367444ee418f129b2c238299f49d3264554Jarkko Poyry } 10183c827367444ee418f129b2c238299f49d3264554Jarkko Poyry else if (contexts.size() < 3 && ((m_types & TYPE_CONTEXT) != 0)) 10193c827367444ee418f129b2c238299f49d3264554Jarkko Poyry { 10203c827367444ee418f129b2c238299f49d3264554Jarkko Poyry create = true; 10213c827367444ee418f129b2c238299f49d3264554Jarkko Poyry type = TYPE_CONTEXT; 10223c827367444ee418f129b2c238299f49d3264554Jarkko Poyry } 10233c827367444ee418f129b2c238299f49d3264554Jarkko Poyry else if (windows.size() < 3 && ((m_types & TYPE_WINDOW) != 0) && ((m_types & TYPE_SINGLE_WINDOW) == 0)) 10243c827367444ee418f129b2c238299f49d3264554Jarkko Poyry { 10253c827367444ee418f129b2c238299f49d3264554Jarkko Poyry create = true; 10263c827367444ee418f129b2c238299f49d3264554Jarkko Poyry type = TYPE_WINDOW; 10273c827367444ee418f129b2c238299f49d3264554Jarkko Poyry } 10283c827367444ee418f129b2c238299f49d3264554Jarkko Poyry else if (windows.empty() && ((m_types & TYPE_WINDOW) != 0) && ((m_types & TYPE_SINGLE_WINDOW) != 0)) 10293c827367444ee418f129b2c238299f49d3264554Jarkko Poyry { 10303c827367444ee418f129b2c238299f49d3264554Jarkko Poyry create = true; 10313c827367444ee418f129b2c238299f49d3264554Jarkko Poyry type = TYPE_WINDOW; 10323c827367444ee418f129b2c238299f49d3264554Jarkko Poyry } 10333c827367444ee418f129b2c238299f49d3264554Jarkko Poyry else 10343c827367444ee418f129b2c238299f49d3264554Jarkko Poyry { 10353c827367444ee418f129b2c238299f49d3264554Jarkko Poyry create = rnd.getBool(); 10363c827367444ee418f129b2c238299f49d3264554Jarkko Poyry type = rnd.choose<Type>(objectTypes.begin(), objectTypes.end()); 10373c827367444ee418f129b2c238299f49d3264554Jarkko Poyry } 10383c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 10393c827367444ee418f129b2c238299f49d3264554Jarkko Poyry if (create) 10403c827367444ee418f129b2c238299f49d3264554Jarkko Poyry { 10413c827367444ee418f129b2c238299f49d3264554Jarkko Poyry switch (type) 10423c827367444ee418f129b2c238299f49d3264554Jarkko Poyry { 10433c827367444ee418f129b2c238299f49d3264554Jarkko Poyry case TYPE_PBUFFER: 10443c827367444ee418f129b2c238299f49d3264554Jarkko Poyry { 10453c827367444ee418f129b2c238299f49d3264554Jarkko Poyry EGLSurface surface; 10463c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 10473c827367444ee418f129b2c238299f49d3264554Jarkko Poyry const EGLint attributes[] = 10483c827367444ee418f129b2c238299f49d3264554Jarkko Poyry { 10493c827367444ee418f129b2c238299f49d3264554Jarkko Poyry EGL_WIDTH, 64, 10503c827367444ee418f129b2c238299f49d3264554Jarkko Poyry EGL_HEIGHT, 64, 10513c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 10523c827367444ee418f129b2c238299f49d3264554Jarkko Poyry EGL_NONE 10533c827367444ee418f129b2c238299f49d3264554Jarkko Poyry }; 10543c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 10553c827367444ee418f129b2c238299f49d3264554Jarkko Poyry surface = eglCreatePbufferSurface(m_display, m_config, attributes); 10563c827367444ee418f129b2c238299f49d3264554Jarkko Poyry thread.getLog() << ThreadLog::BeginMessage << surface << " = eglCreatePbufferSurface(" << m_display << ", " << m_config << ", { EGL_WIDTH, 64, EGL_HEIGHT, 64, EGL_NONE })" << ThreadLog::EndMessage; 10573c827367444ee418f129b2c238299f49d3264554Jarkko Poyry TCU_CHECK_EGL_MSG("eglCreatePbufferSurface()"); 10583c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 10593c827367444ee418f129b2c238299f49d3264554Jarkko Poyry pbuffers.push_back(surface); 10603c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 10613c827367444ee418f129b2c238299f49d3264554Jarkko Poyry break; 10623c827367444ee418f129b2c238299f49d3264554Jarkko Poyry } 10633c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 10643c827367444ee418f129b2c238299f49d3264554Jarkko Poyry case TYPE_WINDOW: 10653c827367444ee418f129b2c238299f49d3264554Jarkko Poyry { 10663c827367444ee418f129b2c238299f49d3264554Jarkko Poyry if ((m_types & TYPE_SINGLE_WINDOW) != 0) 10673c827367444ee418f129b2c238299f49d3264554Jarkko Poyry { 10683c827367444ee418f129b2c238299f49d3264554Jarkko Poyry if (deAtomicCompareExchange32(&m_hasWindow, 0, 1) == 0) 10693c827367444ee418f129b2c238299f49d3264554Jarkko Poyry { 10703c827367444ee418f129b2c238299f49d3264554Jarkko Poyry eglu::NativeWindow* window = DE_NULL; 10713c827367444ee418f129b2c238299f49d3264554Jarkko Poyry EGLSurface surface = EGL_NO_SURFACE; 10723c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 10733c827367444ee418f129b2c238299f49d3264554Jarkko Poyry try 10743c827367444ee418f129b2c238299f49d3264554Jarkko Poyry { 10753c827367444ee418f129b2c238299f49d3264554Jarkko Poyry window = m_eglTestCtx.createNativeWindow(m_eglTestCtx.getDisplay().getEGLDisplay(), m_config, DE_NULL, 64, 64, eglu::parseWindowVisibility(m_testCtx.getCommandLine())); 10763c827367444ee418f129b2c238299f49d3264554Jarkko Poyry surface = eglu::createWindowSurface(m_eglTestCtx.getNativeDisplay(), *window, m_eglTestCtx.getDisplay().getEGLDisplay(), m_config, DE_NULL); 10773c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 10783c827367444ee418f129b2c238299f49d3264554Jarkko Poyry thread.getLog() << ThreadLog::BeginMessage << surface << " = eglCreateWindowSurface()" << ThreadLog::EndMessage; 10793c827367444ee418f129b2c238299f49d3264554Jarkko Poyry windows.push_back(std::make_pair(window, surface)); 10803c827367444ee418f129b2c238299f49d3264554Jarkko Poyry } 10813c827367444ee418f129b2c238299f49d3264554Jarkko Poyry catch (const std::exception&) 10823c827367444ee418f129b2c238299f49d3264554Jarkko Poyry { 10833c827367444ee418f129b2c238299f49d3264554Jarkko Poyry if (surface != EGL_NO_SURFACE) 10843c827367444ee418f129b2c238299f49d3264554Jarkko Poyry TCU_CHECK_EGL_CALL(eglDestroySurface(m_display, surface)); 10853c827367444ee418f129b2c238299f49d3264554Jarkko Poyry delete window; 10863c827367444ee418f129b2c238299f49d3264554Jarkko Poyry throw; 10873c827367444ee418f129b2c238299f49d3264554Jarkko Poyry } 10883c827367444ee418f129b2c238299f49d3264554Jarkko Poyry } 10893c827367444ee418f129b2c238299f49d3264554Jarkko Poyry else 10903c827367444ee418f129b2c238299f49d3264554Jarkko Poyry { 10913c827367444ee418f129b2c238299f49d3264554Jarkko Poyry createDestroyNdx--; 10923c827367444ee418f129b2c238299f49d3264554Jarkko Poyry } 10933c827367444ee418f129b2c238299f49d3264554Jarkko Poyry } 10943c827367444ee418f129b2c238299f49d3264554Jarkko Poyry else 10953c827367444ee418f129b2c238299f49d3264554Jarkko Poyry { 10963c827367444ee418f129b2c238299f49d3264554Jarkko Poyry eglu::NativeWindow* window = DE_NULL; 10973c827367444ee418f129b2c238299f49d3264554Jarkko Poyry EGLSurface surface = EGL_NO_SURFACE; 10983c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 10993c827367444ee418f129b2c238299f49d3264554Jarkko Poyry try 11003c827367444ee418f129b2c238299f49d3264554Jarkko Poyry { 11013c827367444ee418f129b2c238299f49d3264554Jarkko Poyry window = m_eglTestCtx.createNativeWindow(m_eglTestCtx.getDisplay().getEGLDisplay(), m_config, DE_NULL, 64, 64, eglu::parseWindowVisibility(m_testCtx.getCommandLine())); 11023c827367444ee418f129b2c238299f49d3264554Jarkko Poyry surface = eglu::createWindowSurface(m_eglTestCtx.getNativeDisplay(), *window, m_eglTestCtx.getDisplay().getEGLDisplay(), m_config, DE_NULL); 11033c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 11043c827367444ee418f129b2c238299f49d3264554Jarkko Poyry thread.getLog() << ThreadLog::BeginMessage << surface << " = eglCreateWindowSurface()" << ThreadLog::EndMessage; 11053c827367444ee418f129b2c238299f49d3264554Jarkko Poyry windows.push_back(std::make_pair(window, surface)); 11063c827367444ee418f129b2c238299f49d3264554Jarkko Poyry } 11073c827367444ee418f129b2c238299f49d3264554Jarkko Poyry catch (const std::exception&) 11083c827367444ee418f129b2c238299f49d3264554Jarkko Poyry { 11093c827367444ee418f129b2c238299f49d3264554Jarkko Poyry if (surface != EGL_NO_SURFACE) 11103c827367444ee418f129b2c238299f49d3264554Jarkko Poyry TCU_CHECK_EGL_CALL(eglDestroySurface(m_display, surface)); 11113c827367444ee418f129b2c238299f49d3264554Jarkko Poyry delete window; 11123c827367444ee418f129b2c238299f49d3264554Jarkko Poyry throw; 11133c827367444ee418f129b2c238299f49d3264554Jarkko Poyry } 11143c827367444ee418f129b2c238299f49d3264554Jarkko Poyry } 11153c827367444ee418f129b2c238299f49d3264554Jarkko Poyry break; 11163c827367444ee418f129b2c238299f49d3264554Jarkko Poyry } 11173c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 11183c827367444ee418f129b2c238299f49d3264554Jarkko Poyry case TYPE_PIXMAP: 11193c827367444ee418f129b2c238299f49d3264554Jarkko Poyry { 11203c827367444ee418f129b2c238299f49d3264554Jarkko Poyry eglu::NativePixmap* pixmap = DE_NULL; 11213c827367444ee418f129b2c238299f49d3264554Jarkko Poyry EGLSurface surface = EGL_NO_SURFACE; 11223c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 11233c827367444ee418f129b2c238299f49d3264554Jarkko Poyry try 11243c827367444ee418f129b2c238299f49d3264554Jarkko Poyry { 11253c827367444ee418f129b2c238299f49d3264554Jarkko Poyry pixmap = m_eglTestCtx.createNativePixmap(m_eglTestCtx.getDisplay().getEGLDisplay(), m_config, DE_NULL, 64, 64); 11263c827367444ee418f129b2c238299f49d3264554Jarkko Poyry surface = eglu::createPixmapSurface(m_eglTestCtx.getNativeDisplay(), *pixmap, m_eglTestCtx.getDisplay().getEGLDisplay(), m_config, DE_NULL); 11273c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 11283c827367444ee418f129b2c238299f49d3264554Jarkko Poyry thread.getLog() << ThreadLog::BeginMessage << surface << " = eglCreatePixmapSurface()" << ThreadLog::EndMessage; 11293c827367444ee418f129b2c238299f49d3264554Jarkko Poyry pixmaps.push_back(std::make_pair(pixmap, surface)); 11303c827367444ee418f129b2c238299f49d3264554Jarkko Poyry } 11313c827367444ee418f129b2c238299f49d3264554Jarkko Poyry catch (const std::exception&) 11323c827367444ee418f129b2c238299f49d3264554Jarkko Poyry { 11333c827367444ee418f129b2c238299f49d3264554Jarkko Poyry if (surface != EGL_NO_SURFACE) 11343c827367444ee418f129b2c238299f49d3264554Jarkko Poyry TCU_CHECK_EGL_CALL(eglDestroySurface(m_display, surface)); 11353c827367444ee418f129b2c238299f49d3264554Jarkko Poyry delete pixmap; 11363c827367444ee418f129b2c238299f49d3264554Jarkko Poyry throw; 11373c827367444ee418f129b2c238299f49d3264554Jarkko Poyry } 11383c827367444ee418f129b2c238299f49d3264554Jarkko Poyry break; 11393c827367444ee418f129b2c238299f49d3264554Jarkko Poyry } 11403c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 11413c827367444ee418f129b2c238299f49d3264554Jarkko Poyry case TYPE_CONTEXT: 11423c827367444ee418f129b2c238299f49d3264554Jarkko Poyry { 11433c827367444ee418f129b2c238299f49d3264554Jarkko Poyry EGLContext context; 11443c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 11453c827367444ee418f129b2c238299f49d3264554Jarkko Poyry TCU_CHECK_EGL_CALL(eglBindAPI(EGL_OPENGL_ES_API)); 11463c827367444ee418f129b2c238299f49d3264554Jarkko Poyry thread.getLog() << ThreadLog::BeginMessage << "eglBindAPI(EGL_OPENGL_ES_API)" << ThreadLog::EndMessage; 11473c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 11483c827367444ee418f129b2c238299f49d3264554Jarkko Poyry const EGLint attributes[] = 11493c827367444ee418f129b2c238299f49d3264554Jarkko Poyry { 11503c827367444ee418f129b2c238299f49d3264554Jarkko Poyry EGL_CONTEXT_CLIENT_VERSION, 2, 11513c827367444ee418f129b2c238299f49d3264554Jarkko Poyry EGL_NONE 11523c827367444ee418f129b2c238299f49d3264554Jarkko Poyry }; 11533c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 11543c827367444ee418f129b2c238299f49d3264554Jarkko Poyry context = eglCreateContext(m_display, m_config, EGL_NO_CONTEXT, attributes); 11553c827367444ee418f129b2c238299f49d3264554Jarkko Poyry thread.getLog() << ThreadLog::BeginMessage << context << " = eglCreateContext(" << m_display << ", " << m_config << ", EGL_NO_CONTEXT, { EGL_CONTEXT_CLIENT_VERSION, 2, EGL_NONE })" << ThreadLog::EndMessage; 11563c827367444ee418f129b2c238299f49d3264554Jarkko Poyry TCU_CHECK_EGL_MSG("eglCreateContext()"); 11573c827367444ee418f129b2c238299f49d3264554Jarkko Poyry contexts.push_back(context); 11583c827367444ee418f129b2c238299f49d3264554Jarkko Poyry break; 11593c827367444ee418f129b2c238299f49d3264554Jarkko Poyry } 11603c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 11613c827367444ee418f129b2c238299f49d3264554Jarkko Poyry default: 11623c827367444ee418f129b2c238299f49d3264554Jarkko Poyry DE_ASSERT(false); 11633c827367444ee418f129b2c238299f49d3264554Jarkko Poyry }; 11643c827367444ee418f129b2c238299f49d3264554Jarkko Poyry } 11653c827367444ee418f129b2c238299f49d3264554Jarkko Poyry else 11663c827367444ee418f129b2c238299f49d3264554Jarkko Poyry { 11673c827367444ee418f129b2c238299f49d3264554Jarkko Poyry switch (type) 11683c827367444ee418f129b2c238299f49d3264554Jarkko Poyry { 11693c827367444ee418f129b2c238299f49d3264554Jarkko Poyry case TYPE_PBUFFER: 11703c827367444ee418f129b2c238299f49d3264554Jarkko Poyry { 11713c827367444ee418f129b2c238299f49d3264554Jarkko Poyry const int pbufferNdx = rnd.getInt(0, (int)(pbuffers.size()-1)); 11723c827367444ee418f129b2c238299f49d3264554Jarkko Poyry EGLBoolean result; 11733c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 11743c827367444ee418f129b2c238299f49d3264554Jarkko Poyry result = eglDestroySurface(m_display, pbuffers[pbufferNdx]); 11753c827367444ee418f129b2c238299f49d3264554Jarkko Poyry thread.getLog() << ThreadLog::BeginMessage << result << " = eglDestroySurface(" << m_display << ", " << pbuffers[pbufferNdx] << ")" << ThreadLog::EndMessage; 11763c827367444ee418f129b2c238299f49d3264554Jarkko Poyry TCU_CHECK_EGL_MSG("eglDestroySurface()"); 11773c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 11783c827367444ee418f129b2c238299f49d3264554Jarkko Poyry pbuffers.erase(pbuffers.begin() + pbufferNdx); 11793c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 11803c827367444ee418f129b2c238299f49d3264554Jarkko Poyry break; 11813c827367444ee418f129b2c238299f49d3264554Jarkko Poyry } 11823c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 11833c827367444ee418f129b2c238299f49d3264554Jarkko Poyry case TYPE_WINDOW: 11843c827367444ee418f129b2c238299f49d3264554Jarkko Poyry { 11853c827367444ee418f129b2c238299f49d3264554Jarkko Poyry const int windowNdx = rnd.getInt(0, (int)(windows.size()-1)); 11863c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 11873c827367444ee418f129b2c238299f49d3264554Jarkko Poyry thread.getLog() << ThreadLog::BeginMessage << "eglDestroySurface(" << m_display << ", " << windows[windowNdx].second << ")" << ThreadLog::EndMessage; 11883c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 11893c827367444ee418f129b2c238299f49d3264554Jarkko Poyry TCU_CHECK_EGL_CALL(eglDestroySurface(m_display, windows[windowNdx].second)); 11903c827367444ee418f129b2c238299f49d3264554Jarkko Poyry windows[windowNdx].second = EGL_NO_SURFACE; 11913c827367444ee418f129b2c238299f49d3264554Jarkko Poyry delete windows[windowNdx].first; 11923c827367444ee418f129b2c238299f49d3264554Jarkko Poyry windows[windowNdx].first = DE_NULL; 11933c827367444ee418f129b2c238299f49d3264554Jarkko Poyry windows.erase(windows.begin() + windowNdx); 11943c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 11953c827367444ee418f129b2c238299f49d3264554Jarkko Poyry if ((m_types & TYPE_SINGLE_WINDOW) != 0) 11963c827367444ee418f129b2c238299f49d3264554Jarkko Poyry m_hasWindow = 0; 11973c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 11983c827367444ee418f129b2c238299f49d3264554Jarkko Poyry break; 11993c827367444ee418f129b2c238299f49d3264554Jarkko Poyry } 12003c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 12013c827367444ee418f129b2c238299f49d3264554Jarkko Poyry case TYPE_PIXMAP: 12023c827367444ee418f129b2c238299f49d3264554Jarkko Poyry { 12033c827367444ee418f129b2c238299f49d3264554Jarkko Poyry const int pixmapNdx = rnd.getInt(0, (int)(pixmaps.size()-1)); 12043c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 12053c827367444ee418f129b2c238299f49d3264554Jarkko Poyry thread.getLog() << ThreadLog::BeginMessage << "eglDestroySurface(" << m_display << ", " << pixmaps[pixmapNdx].second << ")" << ThreadLog::EndMessage; 12063c827367444ee418f129b2c238299f49d3264554Jarkko Poyry TCU_CHECK_EGL_CALL(eglDestroySurface(m_display, pixmaps[pixmapNdx].second)); 12073c827367444ee418f129b2c238299f49d3264554Jarkko Poyry pixmaps[pixmapNdx].second = EGL_NO_SURFACE; 12083c827367444ee418f129b2c238299f49d3264554Jarkko Poyry delete pixmaps[pixmapNdx].first; 12093c827367444ee418f129b2c238299f49d3264554Jarkko Poyry pixmaps[pixmapNdx].first = DE_NULL; 12103c827367444ee418f129b2c238299f49d3264554Jarkko Poyry pixmaps.erase(pixmaps.begin() + pixmapNdx); 12113c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 12123c827367444ee418f129b2c238299f49d3264554Jarkko Poyry break; 12133c827367444ee418f129b2c238299f49d3264554Jarkko Poyry } 12143c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 12153c827367444ee418f129b2c238299f49d3264554Jarkko Poyry case TYPE_CONTEXT: 12163c827367444ee418f129b2c238299f49d3264554Jarkko Poyry { 12173c827367444ee418f129b2c238299f49d3264554Jarkko Poyry const int contextNdx = rnd.getInt(0, (int)(contexts.size()-1)); 12183c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 12193c827367444ee418f129b2c238299f49d3264554Jarkko Poyry TCU_CHECK_EGL_CALL(eglDestroyContext(m_display, contexts[contextNdx])); 12203c827367444ee418f129b2c238299f49d3264554Jarkko Poyry thread.getLog() << ThreadLog::BeginMessage << "eglDestroyContext(" << m_display << ", " << contexts[contextNdx] << ")" << ThreadLog::EndMessage; 12213c827367444ee418f129b2c238299f49d3264554Jarkko Poyry contexts.erase(contexts.begin() + contextNdx); 12223c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 12233c827367444ee418f129b2c238299f49d3264554Jarkko Poyry break; 12243c827367444ee418f129b2c238299f49d3264554Jarkko Poyry } 12253c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 12263c827367444ee418f129b2c238299f49d3264554Jarkko Poyry default: 12273c827367444ee418f129b2c238299f49d3264554Jarkko Poyry DE_ASSERT(false); 12283c827367444ee418f129b2c238299f49d3264554Jarkko Poyry } 12293c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 12303c827367444ee418f129b2c238299f49d3264554Jarkko Poyry } 12313c827367444ee418f129b2c238299f49d3264554Jarkko Poyry } 12323c827367444ee418f129b2c238299f49d3264554Jarkko Poyry} 12333c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 12343c827367444ee418f129b2c238299f49d3264554Jarkko Poyryvoid MultiThreadedObjectTest::pushObjectsToShared (TestThread& thread) 12353c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{ 12363c827367444ee418f129b2c238299f49d3264554Jarkko Poyry vector<EGLSurface>& pbuffers = (thread.getId() == 0 ? m_pbuffers0 : m_pbuffers1); 12373c827367444ee418f129b2c238299f49d3264554Jarkko Poyry vector<pair<eglu::NativeWindow*, EGLSurface> >& windows = (thread.getId() == 0 ? m_nativeWindows0 : m_nativeWindows1); 12383c827367444ee418f129b2c238299f49d3264554Jarkko Poyry vector<pair<eglu::NativePixmap*, EGLSurface> >& pixmaps = (thread.getId() == 0 ? m_nativePixmaps0 : m_nativePixmaps1); 12393c827367444ee418f129b2c238299f49d3264554Jarkko Poyry vector<EGLContext>& contexts = (thread.getId() == 0 ? m_contexts0 : m_contexts1); 12403c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 12413c827367444ee418f129b2c238299f49d3264554Jarkko Poyry for (int pbufferNdx = 0; pbufferNdx < (int)pbuffers.size(); pbufferNdx++) 12423c827367444ee418f129b2c238299f49d3264554Jarkko Poyry m_sharedPbuffers.push_back(pbuffers[pbufferNdx]); 12433c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 12443c827367444ee418f129b2c238299f49d3264554Jarkko Poyry pbuffers.clear(); 12453c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 12463c827367444ee418f129b2c238299f49d3264554Jarkko Poyry for (int windowNdx = 0; windowNdx < (int)windows.size(); windowNdx++) 12473c827367444ee418f129b2c238299f49d3264554Jarkko Poyry m_sharedNativeWindows.push_back(windows[windowNdx]); 12483c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 12493c827367444ee418f129b2c238299f49d3264554Jarkko Poyry windows.clear(); 12503c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 12513c827367444ee418f129b2c238299f49d3264554Jarkko Poyry for (int pixmapNdx = 0; pixmapNdx < (int)pixmaps.size(); pixmapNdx++) 12523c827367444ee418f129b2c238299f49d3264554Jarkko Poyry m_sharedNativePixmaps.push_back(pixmaps[pixmapNdx]); 12533c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 12543c827367444ee418f129b2c238299f49d3264554Jarkko Poyry pixmaps.clear(); 12553c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 12563c827367444ee418f129b2c238299f49d3264554Jarkko Poyry for (int contextNdx = 0; contextNdx < (int)contexts.size(); contextNdx++) 12573c827367444ee418f129b2c238299f49d3264554Jarkko Poyry m_sharedContexts.push_back(contexts[contextNdx]); 12583c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 12593c827367444ee418f129b2c238299f49d3264554Jarkko Poyry contexts.clear(); 12603c827367444ee418f129b2c238299f49d3264554Jarkko Poyry} 12613c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 12623c827367444ee418f129b2c238299f49d3264554Jarkko Poyryvoid MultiThreadedObjectTest::pullObjectsFromShared (TestThread& thread, int pbufferCount, int pixmapCount, int windowCount, int contextCount) 12633c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{ 12643c827367444ee418f129b2c238299f49d3264554Jarkko Poyry de::Random& rnd = (thread.getId() == 0 ? m_rnd0 : m_rnd1); 12653c827367444ee418f129b2c238299f49d3264554Jarkko Poyry vector<EGLSurface>& pbuffers = (thread.getId() == 0 ? m_pbuffers0 : m_pbuffers1); 12663c827367444ee418f129b2c238299f49d3264554Jarkko Poyry vector<pair<eglu::NativeWindow*, EGLSurface> >& windows = (thread.getId() == 0 ? m_nativeWindows0 : m_nativeWindows1); 12673c827367444ee418f129b2c238299f49d3264554Jarkko Poyry vector<pair<eglu::NativePixmap*, EGLSurface> >& pixmaps = (thread.getId() == 0 ? m_nativePixmaps0 : m_nativePixmaps1); 12683c827367444ee418f129b2c238299f49d3264554Jarkko Poyry vector<EGLContext>& contexts = (thread.getId() == 0 ? m_contexts0 : m_contexts1); 12693c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 12703c827367444ee418f129b2c238299f49d3264554Jarkko Poyry for (int pbufferNdx = 0; pbufferNdx < pbufferCount; pbufferNdx++) 12713c827367444ee418f129b2c238299f49d3264554Jarkko Poyry { 12723c827367444ee418f129b2c238299f49d3264554Jarkko Poyry const int ndx = rnd.getInt(0, (int)(m_sharedPbuffers.size()-1)); 12733c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 12743c827367444ee418f129b2c238299f49d3264554Jarkko Poyry pbuffers.push_back(m_sharedPbuffers[ndx]); 12753c827367444ee418f129b2c238299f49d3264554Jarkko Poyry m_sharedPbuffers.erase(m_sharedPbuffers.begin() + ndx); 12763c827367444ee418f129b2c238299f49d3264554Jarkko Poyry } 12773c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 12783c827367444ee418f129b2c238299f49d3264554Jarkko Poyry for (int pixmapNdx = 0; pixmapNdx < pixmapCount; pixmapNdx++) 12793c827367444ee418f129b2c238299f49d3264554Jarkko Poyry { 12803c827367444ee418f129b2c238299f49d3264554Jarkko Poyry const int ndx = rnd.getInt(0, (int)(m_sharedNativePixmaps.size()-1)); 12813c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 12823c827367444ee418f129b2c238299f49d3264554Jarkko Poyry pixmaps.push_back(m_sharedNativePixmaps[ndx]); 12833c827367444ee418f129b2c238299f49d3264554Jarkko Poyry m_sharedNativePixmaps.erase(m_sharedNativePixmaps.begin() + ndx); 12843c827367444ee418f129b2c238299f49d3264554Jarkko Poyry } 12853c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 12863c827367444ee418f129b2c238299f49d3264554Jarkko Poyry for (int windowNdx = 0; windowNdx < windowCount; windowNdx++) 12873c827367444ee418f129b2c238299f49d3264554Jarkko Poyry { 12883c827367444ee418f129b2c238299f49d3264554Jarkko Poyry const int ndx = rnd.getInt(0, (int)(m_sharedNativeWindows.size()-1)); 12893c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 12903c827367444ee418f129b2c238299f49d3264554Jarkko Poyry windows.push_back(m_sharedNativeWindows[ndx]); 12913c827367444ee418f129b2c238299f49d3264554Jarkko Poyry m_sharedNativeWindows.erase(m_sharedNativeWindows.begin() + ndx); 12923c827367444ee418f129b2c238299f49d3264554Jarkko Poyry } 12933c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 12943c827367444ee418f129b2c238299f49d3264554Jarkko Poyry for (int contextNdx = 0; contextNdx < contextCount; contextNdx++) 12953c827367444ee418f129b2c238299f49d3264554Jarkko Poyry { 12963c827367444ee418f129b2c238299f49d3264554Jarkko Poyry const int ndx = rnd.getInt(0, (int)(m_sharedContexts.size()-1)); 12973c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 12983c827367444ee418f129b2c238299f49d3264554Jarkko Poyry contexts.push_back(m_sharedContexts[ndx]); 12993c827367444ee418f129b2c238299f49d3264554Jarkko Poyry m_sharedContexts.erase(m_sharedContexts.begin() + ndx); 13003c827367444ee418f129b2c238299f49d3264554Jarkko Poyry } 13013c827367444ee418f129b2c238299f49d3264554Jarkko Poyry} 13023c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 13033c827367444ee418f129b2c238299f49d3264554Jarkko Poyryvoid MultiThreadedObjectTest::querySetSharedObjects (TestThread& thread, int count) 13043c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{ 13053c827367444ee418f129b2c238299f49d3264554Jarkko Poyry de::Random& rnd = (thread.getId() == 0 ? m_rnd0 : m_rnd1); 13063c827367444ee418f129b2c238299f49d3264554Jarkko Poyry vector<Type> objectTypes; 13073c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 13083c827367444ee418f129b2c238299f49d3264554Jarkko Poyry if ((m_types & TYPE_PBUFFER) != 0) 13093c827367444ee418f129b2c238299f49d3264554Jarkko Poyry objectTypes.push_back(TYPE_PBUFFER); 13103c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 13113c827367444ee418f129b2c238299f49d3264554Jarkko Poyry if ((m_types & TYPE_PIXMAP) != 0) 13123c827367444ee418f129b2c238299f49d3264554Jarkko Poyry objectTypes.push_back(TYPE_PIXMAP); 13133c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 13143c827367444ee418f129b2c238299f49d3264554Jarkko Poyry if ((m_types & TYPE_WINDOW) != 0) 13153c827367444ee418f129b2c238299f49d3264554Jarkko Poyry objectTypes.push_back(TYPE_WINDOW); 13163c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 13173c827367444ee418f129b2c238299f49d3264554Jarkko Poyry if ((m_types & TYPE_CONTEXT) != 0) 13183c827367444ee418f129b2c238299f49d3264554Jarkko Poyry objectTypes.push_back(TYPE_CONTEXT); 13193c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 13203c827367444ee418f129b2c238299f49d3264554Jarkko Poyry for (int queryNdx = 0; queryNdx < count; queryNdx++) 13213c827367444ee418f129b2c238299f49d3264554Jarkko Poyry { 13223c827367444ee418f129b2c238299f49d3264554Jarkko Poyry const Type type = rnd.choose<Type>(objectTypes.begin(), objectTypes.end()); 13233c827367444ee418f129b2c238299f49d3264554Jarkko Poyry EGLSurface surface = EGL_NO_SURFACE; 13243c827367444ee418f129b2c238299f49d3264554Jarkko Poyry EGLContext context = EGL_NO_CONTEXT; 13253c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 13263c827367444ee418f129b2c238299f49d3264554Jarkko Poyry switch (type) 13273c827367444ee418f129b2c238299f49d3264554Jarkko Poyry { 13283c827367444ee418f129b2c238299f49d3264554Jarkko Poyry case TYPE_PBUFFER: 13293c827367444ee418f129b2c238299f49d3264554Jarkko Poyry surface = m_sharedPbuffers[rnd.getInt(0, (int)(m_sharedPbuffers.size()-1))]; 13303c827367444ee418f129b2c238299f49d3264554Jarkko Poyry break; 13313c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 13323c827367444ee418f129b2c238299f49d3264554Jarkko Poyry case TYPE_PIXMAP: 13333c827367444ee418f129b2c238299f49d3264554Jarkko Poyry surface = m_sharedNativePixmaps[rnd.getInt(0, (int)(m_sharedNativePixmaps.size()-1))].second; 13343c827367444ee418f129b2c238299f49d3264554Jarkko Poyry break; 13353c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 13363c827367444ee418f129b2c238299f49d3264554Jarkko Poyry case TYPE_WINDOW: 13373c827367444ee418f129b2c238299f49d3264554Jarkko Poyry surface = m_sharedNativeWindows[rnd.getInt(0, (int)(m_sharedNativeWindows.size()-1))].second; 13383c827367444ee418f129b2c238299f49d3264554Jarkko Poyry break; 13393c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 13403c827367444ee418f129b2c238299f49d3264554Jarkko Poyry case TYPE_CONTEXT: 13413c827367444ee418f129b2c238299f49d3264554Jarkko Poyry context = m_sharedContexts[rnd.getInt(0, (int)(m_sharedContexts.size()-1))]; 13423c827367444ee418f129b2c238299f49d3264554Jarkko Poyry break; 13433c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 13443c827367444ee418f129b2c238299f49d3264554Jarkko Poyry default: 13453c827367444ee418f129b2c238299f49d3264554Jarkko Poyry DE_ASSERT(false); 13463c827367444ee418f129b2c238299f49d3264554Jarkko Poyry } 13473c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 13483c827367444ee418f129b2c238299f49d3264554Jarkko Poyry if (surface != EGL_NO_SURFACE) 13493c827367444ee418f129b2c238299f49d3264554Jarkko Poyry { 13503c827367444ee418f129b2c238299f49d3264554Jarkko Poyry static const EGLint queryAttributes[] = 13513c827367444ee418f129b2c238299f49d3264554Jarkko Poyry { 13523c827367444ee418f129b2c238299f49d3264554Jarkko Poyry EGL_LARGEST_PBUFFER, 13533c827367444ee418f129b2c238299f49d3264554Jarkko Poyry EGL_HEIGHT, 13543c827367444ee418f129b2c238299f49d3264554Jarkko Poyry EGL_WIDTH 13553c827367444ee418f129b2c238299f49d3264554Jarkko Poyry }; 13563c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 13573c827367444ee418f129b2c238299f49d3264554Jarkko Poyry const EGLint attribute = queryAttributes[rnd.getInt(0, DE_LENGTH_OF_ARRAY(queryAttributes) - 1)]; 13583c827367444ee418f129b2c238299f49d3264554Jarkko Poyry EGLBoolean result; 13593c827367444ee418f129b2c238299f49d3264554Jarkko Poyry EGLint value; 13603c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 13613c827367444ee418f129b2c238299f49d3264554Jarkko Poyry result = eglQuerySurface(m_display, surface, attribute, &value); 13623c827367444ee418f129b2c238299f49d3264554Jarkko Poyry thread.getLog() << ThreadLog::BeginMessage << result << " = eglQuerySurface(" << m_display << ", " << surface << ", " << attribute << ", " << value << ")" << ThreadLog::EndMessage; 13633c827367444ee418f129b2c238299f49d3264554Jarkko Poyry TCU_CHECK_EGL_MSG("eglQuerySurface()"); 13643c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 13653c827367444ee418f129b2c238299f49d3264554Jarkko Poyry } 13663c827367444ee418f129b2c238299f49d3264554Jarkko Poyry else if (context != EGL_NO_CONTEXT) 13673c827367444ee418f129b2c238299f49d3264554Jarkko Poyry { 13683c827367444ee418f129b2c238299f49d3264554Jarkko Poyry static const EGLint attributes[] = 13693c827367444ee418f129b2c238299f49d3264554Jarkko Poyry { 13703c827367444ee418f129b2c238299f49d3264554Jarkko Poyry EGL_CONFIG_ID, 13713c827367444ee418f129b2c238299f49d3264554Jarkko Poyry EGL_CONTEXT_CLIENT_TYPE, 13723c827367444ee418f129b2c238299f49d3264554Jarkko Poyry EGL_CONTEXT_CLIENT_VERSION, 13733c827367444ee418f129b2c238299f49d3264554Jarkko Poyry EGL_RENDER_BUFFER 13743c827367444ee418f129b2c238299f49d3264554Jarkko Poyry }; 13753c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 13763c827367444ee418f129b2c238299f49d3264554Jarkko Poyry const EGLint attribute = attributes[rnd.getInt(0, DE_LENGTH_OF_ARRAY(attributes)-1)]; 13773c827367444ee418f129b2c238299f49d3264554Jarkko Poyry EGLint value; 13783c827367444ee418f129b2c238299f49d3264554Jarkko Poyry EGLBoolean result; 13793c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 13803c827367444ee418f129b2c238299f49d3264554Jarkko Poyry result = eglQueryContext(m_display, context, attribute, &value); 13813c827367444ee418f129b2c238299f49d3264554Jarkko Poyry thread.getLog() << ThreadLog::BeginMessage << result << " = eglQueryContext(" << m_display << ", " << context << ", " << attribute << ", " << value << ")" << ThreadLog::EndMessage; 13823c827367444ee418f129b2c238299f49d3264554Jarkko Poyry TCU_CHECK_EGL_MSG("eglQueryContext()"); 13833c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 13843c827367444ee418f129b2c238299f49d3264554Jarkko Poyry } 13853c827367444ee418f129b2c238299f49d3264554Jarkko Poyry else 13863c827367444ee418f129b2c238299f49d3264554Jarkko Poyry DE_ASSERT(false); 13873c827367444ee418f129b2c238299f49d3264554Jarkko Poyry } 13883c827367444ee418f129b2c238299f49d3264554Jarkko Poyry} 13893c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 13903c827367444ee418f129b2c238299f49d3264554Jarkko Poyryvoid MultiThreadedObjectTest::destroyObjects (TestThread& thread) 13913c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{ 13923c827367444ee418f129b2c238299f49d3264554Jarkko Poyry vector<EGLSurface>& pbuffers = (thread.getId() == 0 ? m_pbuffers0 : m_pbuffers1); 13933c827367444ee418f129b2c238299f49d3264554Jarkko Poyry vector<pair<eglu::NativeWindow*, EGLSurface> >& windows = (thread.getId() == 0 ? m_nativeWindows0 : m_nativeWindows1); 13943c827367444ee418f129b2c238299f49d3264554Jarkko Poyry vector<pair<eglu::NativePixmap*, EGLSurface> >& pixmaps = (thread.getId() == 0 ? m_nativePixmaps0 : m_nativePixmaps1); 13953c827367444ee418f129b2c238299f49d3264554Jarkko Poyry vector<EGLContext>& contexts = (thread.getId() == 0 ? m_contexts0 : m_contexts1); 13963c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 13973c827367444ee418f129b2c238299f49d3264554Jarkko Poyry for (int pbufferNdx = 0; pbufferNdx < (int)pbuffers.size(); pbufferNdx++) 13983c827367444ee418f129b2c238299f49d3264554Jarkko Poyry { 13993c827367444ee418f129b2c238299f49d3264554Jarkko Poyry if (pbuffers[pbufferNdx] != EGL_NO_SURFACE) 14003c827367444ee418f129b2c238299f49d3264554Jarkko Poyry { 14013c827367444ee418f129b2c238299f49d3264554Jarkko Poyry // Destroy EGLSurface 14023c827367444ee418f129b2c238299f49d3264554Jarkko Poyry EGLBoolean result; 14033c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 14043c827367444ee418f129b2c238299f49d3264554Jarkko Poyry result = eglDestroySurface(m_display, pbuffers[pbufferNdx]); 14053c827367444ee418f129b2c238299f49d3264554Jarkko Poyry thread.getLog() << ThreadLog::BeginMessage << result << " = eglDestroySurface(" << m_display << ", " << pbuffers[pbufferNdx] << ")" << ThreadLog::EndMessage; 14063c827367444ee418f129b2c238299f49d3264554Jarkko Poyry TCU_CHECK_EGL_MSG("eglDestroySurface()"); 14073c827367444ee418f129b2c238299f49d3264554Jarkko Poyry pbuffers[pbufferNdx] = EGL_NO_SURFACE; 14083c827367444ee418f129b2c238299f49d3264554Jarkko Poyry } 14093c827367444ee418f129b2c238299f49d3264554Jarkko Poyry } 14103c827367444ee418f129b2c238299f49d3264554Jarkko Poyry pbuffers.clear(); 14113c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 14123c827367444ee418f129b2c238299f49d3264554Jarkko Poyry for (int windowNdx = 0; windowNdx < (int)windows.size(); windowNdx++) 14133c827367444ee418f129b2c238299f49d3264554Jarkko Poyry { 14143c827367444ee418f129b2c238299f49d3264554Jarkko Poyry if (windows[windowNdx].second != EGL_NO_SURFACE) 14153c827367444ee418f129b2c238299f49d3264554Jarkko Poyry { 14163c827367444ee418f129b2c238299f49d3264554Jarkko Poyry thread.getLog() << ThreadLog::BeginMessage << "eglDestroySurface(" << m_display << ", " << windows[windowNdx].second << ")" << ThreadLog::EndMessage; 14173c827367444ee418f129b2c238299f49d3264554Jarkko Poyry TCU_CHECK_EGL_CALL(eglDestroySurface(m_display, windows[windowNdx].second)); 14183c827367444ee418f129b2c238299f49d3264554Jarkko Poyry windows[windowNdx].second = EGL_NO_SURFACE; 14193c827367444ee418f129b2c238299f49d3264554Jarkko Poyry } 14203c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 14213c827367444ee418f129b2c238299f49d3264554Jarkko Poyry if (windows[windowNdx].first) 14223c827367444ee418f129b2c238299f49d3264554Jarkko Poyry { 14233c827367444ee418f129b2c238299f49d3264554Jarkko Poyry delete windows[windowNdx].first; 14243c827367444ee418f129b2c238299f49d3264554Jarkko Poyry windows[windowNdx].first = NULL; 14253c827367444ee418f129b2c238299f49d3264554Jarkko Poyry } 14263c827367444ee418f129b2c238299f49d3264554Jarkko Poyry } 14273c827367444ee418f129b2c238299f49d3264554Jarkko Poyry windows.clear(); 14283c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 14293c827367444ee418f129b2c238299f49d3264554Jarkko Poyry for (int pixmapNdx = 0; pixmapNdx < (int)pixmaps.size(); pixmapNdx++) 14303c827367444ee418f129b2c238299f49d3264554Jarkko Poyry { 14313c827367444ee418f129b2c238299f49d3264554Jarkko Poyry if (pixmaps[pixmapNdx].first != EGL_NO_SURFACE) 14323c827367444ee418f129b2c238299f49d3264554Jarkko Poyry { 14333c827367444ee418f129b2c238299f49d3264554Jarkko Poyry thread.getLog() << ThreadLog::BeginMessage << "eglDestroySurface(" << m_display << ", " << pixmaps[pixmapNdx].second << ")" << ThreadLog::EndMessage; 14343c827367444ee418f129b2c238299f49d3264554Jarkko Poyry TCU_CHECK_EGL_CALL(eglDestroySurface(m_display, pixmaps[pixmapNdx].second)); 14353c827367444ee418f129b2c238299f49d3264554Jarkko Poyry pixmaps[pixmapNdx].second = EGL_NO_SURFACE; 14363c827367444ee418f129b2c238299f49d3264554Jarkko Poyry } 14373c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 14383c827367444ee418f129b2c238299f49d3264554Jarkko Poyry if (pixmaps[pixmapNdx].first) 14393c827367444ee418f129b2c238299f49d3264554Jarkko Poyry { 14403c827367444ee418f129b2c238299f49d3264554Jarkko Poyry delete pixmaps[pixmapNdx].first; 14413c827367444ee418f129b2c238299f49d3264554Jarkko Poyry pixmaps[pixmapNdx].first = NULL; 14423c827367444ee418f129b2c238299f49d3264554Jarkko Poyry } 14433c827367444ee418f129b2c238299f49d3264554Jarkko Poyry } 14443c827367444ee418f129b2c238299f49d3264554Jarkko Poyry pixmaps.clear(); 14453c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 14463c827367444ee418f129b2c238299f49d3264554Jarkko Poyry for (int contextNdx = 0; contextNdx < (int)contexts.size(); contextNdx++) 14473c827367444ee418f129b2c238299f49d3264554Jarkko Poyry { 14483c827367444ee418f129b2c238299f49d3264554Jarkko Poyry if (contexts[contextNdx] != EGL_NO_CONTEXT) 14493c827367444ee418f129b2c238299f49d3264554Jarkko Poyry { 14503c827367444ee418f129b2c238299f49d3264554Jarkko Poyry TCU_CHECK_EGL_CALL(eglDestroyContext(m_display, contexts[contextNdx])); 14513c827367444ee418f129b2c238299f49d3264554Jarkko Poyry thread.getLog() << ThreadLog::BeginMessage << "eglDestroyContext(" << m_display << ", " << contexts[contextNdx] << ")" << ThreadLog::EndMessage; 14523c827367444ee418f129b2c238299f49d3264554Jarkko Poyry contexts[contextNdx] = EGL_NO_CONTEXT; 14533c827367444ee418f129b2c238299f49d3264554Jarkko Poyry } 14543c827367444ee418f129b2c238299f49d3264554Jarkko Poyry } 14553c827367444ee418f129b2c238299f49d3264554Jarkko Poyry contexts.clear(); 14563c827367444ee418f129b2c238299f49d3264554Jarkko Poyry} 14573c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 14583c827367444ee418f129b2c238299f49d3264554Jarkko PoyryMultiThreadedTests::MultiThreadedTests (EglTestContext& context) 14593c827367444ee418f129b2c238299f49d3264554Jarkko Poyry : TestCaseGroup(context, "multithread", "Multithreaded EGL tests") 14603c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{ 14613c827367444ee418f129b2c238299f49d3264554Jarkko Poyry} 14623c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 14633c827367444ee418f129b2c238299f49d3264554Jarkko Poyryvoid MultiThreadedTests::init (void) 14643c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{ 14653c827367444ee418f129b2c238299f49d3264554Jarkko Poyry // Config tests 14663c827367444ee418f129b2c238299f49d3264554Jarkko Poyry addChild(new MultiThreadedConfigTest(m_eglTestCtx, "config", "", 30, 30, 30)); 14673c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 14683c827367444ee418f129b2c238299f49d3264554Jarkko Poyry // Object tests 14693c827367444ee418f129b2c238299f49d3264554Jarkko Poyry addChild(new MultiThreadedObjectTest(m_eglTestCtx, "pbuffer", "", MultiThreadedObjectTest::TYPE_PBUFFER)); 14703c827367444ee418f129b2c238299f49d3264554Jarkko Poyry addChild(new MultiThreadedObjectTest(m_eglTestCtx, "pixmap", "", MultiThreadedObjectTest::TYPE_PIXMAP)); 14713c827367444ee418f129b2c238299f49d3264554Jarkko Poyry addChild(new MultiThreadedObjectTest(m_eglTestCtx, "window", "", MultiThreadedObjectTest::TYPE_WINDOW)); 14723c827367444ee418f129b2c238299f49d3264554Jarkko Poyry addChild(new MultiThreadedObjectTest(m_eglTestCtx, "single_window", "", MultiThreadedObjectTest::TYPE_WINDOW|MultiThreadedObjectTest::TYPE_SINGLE_WINDOW)); 14733c827367444ee418f129b2c238299f49d3264554Jarkko Poyry addChild(new MultiThreadedObjectTest(m_eglTestCtx, "context", "", MultiThreadedObjectTest::TYPE_CONTEXT)); 14743c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 14753c827367444ee418f129b2c238299f49d3264554Jarkko Poyry addChild(new MultiThreadedObjectTest(m_eglTestCtx, "pbuffer_pixmap", "", MultiThreadedObjectTest::TYPE_PBUFFER|MultiThreadedObjectTest::TYPE_PIXMAP)); 14763c827367444ee418f129b2c238299f49d3264554Jarkko Poyry addChild(new MultiThreadedObjectTest(m_eglTestCtx, "pbuffer_window", "", MultiThreadedObjectTest::TYPE_PBUFFER|MultiThreadedObjectTest::TYPE_WINDOW)); 14773c827367444ee418f129b2c238299f49d3264554Jarkko Poyry addChild(new MultiThreadedObjectTest(m_eglTestCtx, "pbuffer_single_window", "", MultiThreadedObjectTest::TYPE_PBUFFER|MultiThreadedObjectTest::TYPE_WINDOW|MultiThreadedObjectTest::TYPE_SINGLE_WINDOW)); 14783c827367444ee418f129b2c238299f49d3264554Jarkko Poyry addChild(new MultiThreadedObjectTest(m_eglTestCtx, "pbuffer_context", "", MultiThreadedObjectTest::TYPE_PBUFFER|MultiThreadedObjectTest::TYPE_CONTEXT)); 14793c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 14803c827367444ee418f129b2c238299f49d3264554Jarkko Poyry addChild(new MultiThreadedObjectTest(m_eglTestCtx, "pixmap_window", "", MultiThreadedObjectTest::TYPE_PIXMAP|MultiThreadedObjectTest::TYPE_WINDOW)); 14813c827367444ee418f129b2c238299f49d3264554Jarkko Poyry addChild(new MultiThreadedObjectTest(m_eglTestCtx, "pixmap_single_window", "", MultiThreadedObjectTest::TYPE_PIXMAP|MultiThreadedObjectTest::TYPE_WINDOW|MultiThreadedObjectTest::TYPE_SINGLE_WINDOW)); 14823c827367444ee418f129b2c238299f49d3264554Jarkko Poyry addChild(new MultiThreadedObjectTest(m_eglTestCtx, "pixmap_context", "", MultiThreadedObjectTest::TYPE_PIXMAP|MultiThreadedObjectTest::TYPE_CONTEXT)); 14833c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 14843c827367444ee418f129b2c238299f49d3264554Jarkko Poyry addChild(new MultiThreadedObjectTest(m_eglTestCtx, "window_context", "", MultiThreadedObjectTest::TYPE_WINDOW|MultiThreadedObjectTest::TYPE_CONTEXT)); 14853c827367444ee418f129b2c238299f49d3264554Jarkko Poyry addChild(new MultiThreadedObjectTest(m_eglTestCtx, "single_window_context", "", MultiThreadedObjectTest::TYPE_WINDOW|MultiThreadedObjectTest::TYPE_SINGLE_WINDOW|MultiThreadedObjectTest::TYPE_CONTEXT)); 14863c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 14873c827367444ee418f129b2c238299f49d3264554Jarkko Poyry addChild(new MultiThreadedObjectTest(m_eglTestCtx, "pbuffer_pixmap_window", "", MultiThreadedObjectTest::TYPE_PBUFFER|MultiThreadedObjectTest::TYPE_PIXMAP|MultiThreadedObjectTest::TYPE_WINDOW)); 14883c827367444ee418f129b2c238299f49d3264554Jarkko Poyry addChild(new MultiThreadedObjectTest(m_eglTestCtx, "pbuffer_pixmap_single_window", "", MultiThreadedObjectTest::TYPE_PBUFFER|MultiThreadedObjectTest::TYPE_PIXMAP|MultiThreadedObjectTest::TYPE_WINDOW|MultiThreadedObjectTest::TYPE_SINGLE_WINDOW)); 14893c827367444ee418f129b2c238299f49d3264554Jarkko Poyry addChild(new MultiThreadedObjectTest(m_eglTestCtx, "pbuffer_pixmap_context", "", MultiThreadedObjectTest::TYPE_PBUFFER|MultiThreadedObjectTest::TYPE_PIXMAP|MultiThreadedObjectTest::TYPE_CONTEXT)); 14903c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 14913c827367444ee418f129b2c238299f49d3264554Jarkko Poyry addChild(new MultiThreadedObjectTest(m_eglTestCtx, "pbuffer_window_context", "", MultiThreadedObjectTest::TYPE_PBUFFER|MultiThreadedObjectTest::TYPE_WINDOW|MultiThreadedObjectTest::TYPE_CONTEXT)); 14923c827367444ee418f129b2c238299f49d3264554Jarkko Poyry addChild(new MultiThreadedObjectTest(m_eglTestCtx, "pbuffer_single_window_context", "", MultiThreadedObjectTest::TYPE_PBUFFER|MultiThreadedObjectTest::TYPE_WINDOW|MultiThreadedObjectTest::TYPE_SINGLE_WINDOW|MultiThreadedObjectTest::TYPE_CONTEXT)); 14933c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 14943c827367444ee418f129b2c238299f49d3264554Jarkko Poyry addChild(new MultiThreadedObjectTest(m_eglTestCtx, "pixmap_window_context", "", MultiThreadedObjectTest::TYPE_PIXMAP|MultiThreadedObjectTest::TYPE_WINDOW|MultiThreadedObjectTest::TYPE_CONTEXT)); 14953c827367444ee418f129b2c238299f49d3264554Jarkko Poyry addChild(new MultiThreadedObjectTest(m_eglTestCtx, "pixmap_single_window_context", "", MultiThreadedObjectTest::TYPE_PIXMAP|MultiThreadedObjectTest::TYPE_WINDOW|MultiThreadedObjectTest::TYPE_SINGLE_WINDOW|MultiThreadedObjectTest::TYPE_CONTEXT)); 14963c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 14973c827367444ee418f129b2c238299f49d3264554Jarkko Poyry addChild(new MultiThreadedObjectTest(m_eglTestCtx, "pbuffer_pixmap_window_context", "", MultiThreadedObjectTest::TYPE_PBUFFER|MultiThreadedObjectTest::TYPE_PIXMAP|MultiThreadedObjectTest::TYPE_WINDOW|MultiThreadedObjectTest::TYPE_CONTEXT)); 14983c827367444ee418f129b2c238299f49d3264554Jarkko Poyry addChild(new MultiThreadedObjectTest(m_eglTestCtx, "pbuffer_pixmap_single_window_context", "", MultiThreadedObjectTest::TYPE_PBUFFER|MultiThreadedObjectTest::TYPE_PIXMAP|MultiThreadedObjectTest::TYPE_WINDOW|MultiThreadedObjectTest::TYPE_SINGLE_WINDOW|MultiThreadedObjectTest::TYPE_CONTEXT)); 14993c827367444ee418f129b2c238299f49d3264554Jarkko Poyry} 15003c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 15013c827367444ee418f129b2c238299f49d3264554Jarkko Poyry} // egl 15023c827367444ee418f129b2c238299f49d3264554Jarkko Poyry} // deqp 1503