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 Memory object allocation stress tests 223c827367444ee418f129b2c238299f49d3264554Jarkko Poyry *//*--------------------------------------------------------------------*/ 233c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 243c827367444ee418f129b2c238299f49d3264554Jarkko Poyry#include "teglMemoryStressTests.hpp" 253c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 263c827367444ee418f129b2c238299f49d3264554Jarkko Poyry#include "gluDefs.hpp" 273c827367444ee418f129b2c238299f49d3264554Jarkko Poyry#include "tcuTestLog.hpp" 283c827367444ee418f129b2c238299f49d3264554Jarkko Poyry#include "tcuCommandLine.hpp" 293c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 303c827367444ee418f129b2c238299f49d3264554Jarkko Poyry#include "deRandom.hpp" 313c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 323c827367444ee418f129b2c238299f49d3264554Jarkko Poyry#include "deClock.h" 333c827367444ee418f129b2c238299f49d3264554Jarkko Poyry#include "deString.h" 343c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 353c827367444ee418f129b2c238299f49d3264554Jarkko Poyry#include "glwFunctions.hpp" 363c827367444ee418f129b2c238299f49d3264554Jarkko Poyry#include "glwDefs.hpp" 373c827367444ee418f129b2c238299f49d3264554Jarkko Poyry#include "glwEnums.hpp" 383c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 393c827367444ee418f129b2c238299f49d3264554Jarkko Poyry#include <vector> 403c827367444ee418f129b2c238299f49d3264554Jarkko Poyry#include <string> 413c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 423c827367444ee418f129b2c238299f49d3264554Jarkko Poyryusing std::vector; 433c827367444ee418f129b2c238299f49d3264554Jarkko Poyryusing std::string; 443c827367444ee418f129b2c238299f49d3264554Jarkko Poyryusing tcu::TestLog; 453c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 463c827367444ee418f129b2c238299f49d3264554Jarkko Poyrynamespace deqp 473c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{ 483c827367444ee418f129b2c238299f49d3264554Jarkko Poyrynamespace egl 493c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{ 503c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 513c827367444ee418f129b2c238299f49d3264554Jarkko Poyrynamespace 523c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{ 533c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 543c827367444ee418f129b2c238299f49d3264554Jarkko Poyryenum ObjectType 553c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{ 563c827367444ee418f129b2c238299f49d3264554Jarkko Poyry OBJECTTYPE_PBUFFER = (1<<0), 573c827367444ee418f129b2c238299f49d3264554Jarkko Poyry OBJECTTYPE_CONTEXT = (1<<1), 583c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 593c827367444ee418f129b2c238299f49d3264554Jarkko Poyry// OBJECTTYPE_WINDOW, 603c827367444ee418f129b2c238299f49d3264554Jarkko Poyry// OBJECTTYPE_PIXMAP, 613c827367444ee418f129b2c238299f49d3264554Jarkko Poyry}; 623c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 633c827367444ee418f129b2c238299f49d3264554Jarkko Poyryclass MemoryAllocator 643c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{ 653c827367444ee418f129b2c238299f49d3264554Jarkko Poyrypublic: 663c827367444ee418f129b2c238299f49d3264554Jarkko Poyry MemoryAllocator (EglTestContext& eglTestCtx, EGLDisplay display, EGLConfig config, int seed, ObjectType types, int minWidth, int minHeight, int maxWidth, int maxHeight, bool use); 673c827367444ee418f129b2c238299f49d3264554Jarkko Poyry ~MemoryAllocator (void); 683c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 693c827367444ee418f129b2c238299f49d3264554Jarkko Poyry bool allocateUntilFailure (void); 703c827367444ee418f129b2c238299f49d3264554Jarkko Poyry int getAllocationCount (void) const { return (int)(m_pbuffers.size() + m_contexts.size()); } 713c827367444ee418f129b2c238299f49d3264554Jarkko Poyry int getContextCount (void) const { return (int)m_contexts.size(); } 723c827367444ee418f129b2c238299f49d3264554Jarkko Poyry int getPBufferCount (void) const { return (int)m_pbuffers.size(); } 733c827367444ee418f129b2c238299f49d3264554Jarkko Poyry const string& getErrorString (void) const { return m_errorString; } 743c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 753c827367444ee418f129b2c238299f49d3264554Jarkko Poyryprivate: 763c827367444ee418f129b2c238299f49d3264554Jarkko Poyry void allocatePBuffer (void); 773c827367444ee418f129b2c238299f49d3264554Jarkko Poyry void allocateContext (void); 783c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 793c827367444ee418f129b2c238299f49d3264554Jarkko Poyry EglTestContext& m_eglTestCtx; 803c827367444ee418f129b2c238299f49d3264554Jarkko Poyry EGLDisplay m_display; 813c827367444ee418f129b2c238299f49d3264554Jarkko Poyry EGLConfig m_config; 823c827367444ee418f129b2c238299f49d3264554Jarkko Poyry glw::Functions m_gl; 833c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 843c827367444ee418f129b2c238299f49d3264554Jarkko Poyry de::Random m_rnd; 853c827367444ee418f129b2c238299f49d3264554Jarkko Poyry bool m_failed; 863c827367444ee418f129b2c238299f49d3264554Jarkko Poyry string m_errorString; 873c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 883c827367444ee418f129b2c238299f49d3264554Jarkko Poyry ObjectType m_types; 893c827367444ee418f129b2c238299f49d3264554Jarkko Poyry int m_minWidth; 903c827367444ee418f129b2c238299f49d3264554Jarkko Poyry int m_minHeight; 913c827367444ee418f129b2c238299f49d3264554Jarkko Poyry int m_maxWidth; 923c827367444ee418f129b2c238299f49d3264554Jarkko Poyry int m_maxHeight; 933c827367444ee418f129b2c238299f49d3264554Jarkko Poyry bool m_use; 943c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 953c827367444ee418f129b2c238299f49d3264554Jarkko Poyry vector<EGLSurface> m_pbuffers; 963c827367444ee418f129b2c238299f49d3264554Jarkko Poyry vector<EGLContext> m_contexts; 973c827367444ee418f129b2c238299f49d3264554Jarkko Poyry}; 983c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 993c827367444ee418f129b2c238299f49d3264554Jarkko PoyryMemoryAllocator::MemoryAllocator (EglTestContext& eglTestCtx, EGLDisplay display, EGLConfig config, int seed, ObjectType types, int minWidth, int minHeight, int maxWidth, int maxHeight, bool use) 1003c827367444ee418f129b2c238299f49d3264554Jarkko Poyry : m_eglTestCtx (eglTestCtx) 1013c827367444ee418f129b2c238299f49d3264554Jarkko Poyry , m_display (display) 1023c827367444ee418f129b2c238299f49d3264554Jarkko Poyry , m_config (config) 1033c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 1043c827367444ee418f129b2c238299f49d3264554Jarkko Poyry , m_rnd (seed) 1053c827367444ee418f129b2c238299f49d3264554Jarkko Poyry , m_failed (false) 1063c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 1073c827367444ee418f129b2c238299f49d3264554Jarkko Poyry , m_types (types) 1083c827367444ee418f129b2c238299f49d3264554Jarkko Poyry , m_minWidth (minWidth) 1093c827367444ee418f129b2c238299f49d3264554Jarkko Poyry , m_minHeight (minHeight) 1103c827367444ee418f129b2c238299f49d3264554Jarkko Poyry , m_maxWidth (maxWidth) 1113c827367444ee418f129b2c238299f49d3264554Jarkko Poyry , m_maxHeight (maxHeight) 1123c827367444ee418f129b2c238299f49d3264554Jarkko Poyry , m_use (use) 1133c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{ 1143c827367444ee418f129b2c238299f49d3264554Jarkko Poyry m_eglTestCtx.getGLFunctions(m_gl, glu::ApiType::es(2,0)); 1153c827367444ee418f129b2c238299f49d3264554Jarkko Poyry} 1163c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 1173c827367444ee418f129b2c238299f49d3264554Jarkko PoyryMemoryAllocator::~MemoryAllocator (void) 1183c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{ 1193c827367444ee418f129b2c238299f49d3264554Jarkko Poyry for (vector<EGLSurface>::const_iterator iter = m_pbuffers.begin(); iter != m_pbuffers.end(); ++iter) 1203c827367444ee418f129b2c238299f49d3264554Jarkko Poyry TCU_CHECK_EGL_CALL(eglDestroySurface(m_display, *iter)); 1213c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 1223c827367444ee418f129b2c238299f49d3264554Jarkko Poyry m_pbuffers.clear(); 1233c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 1243c827367444ee418f129b2c238299f49d3264554Jarkko Poyry for (vector<EGLContext>::const_iterator iter = m_contexts.begin(); iter != m_contexts.end(); ++iter) 1253c827367444ee418f129b2c238299f49d3264554Jarkko Poyry { 1263c827367444ee418f129b2c238299f49d3264554Jarkko Poyry TCU_CHECK_EGL_CALL(eglDestroyContext(m_display, *iter)); 1273c827367444ee418f129b2c238299f49d3264554Jarkko Poyry } 1283c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 1293c827367444ee418f129b2c238299f49d3264554Jarkko Poyry m_contexts.clear(); 1303c827367444ee418f129b2c238299f49d3264554Jarkko Poyry} 1313c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 1323c827367444ee418f129b2c238299f49d3264554Jarkko Poyrybool MemoryAllocator::allocateUntilFailure (void) 1333c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{ 1343c827367444ee418f129b2c238299f49d3264554Jarkko Poyry const deUint64 timeLimitUs = 10000000; // 10s 1353c827367444ee418f129b2c238299f49d3264554Jarkko Poyry deUint64 beginTimeUs = deGetMicroseconds(); 1363c827367444ee418f129b2c238299f49d3264554Jarkko Poyry vector<ObjectType> types; 1373c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 1383c827367444ee418f129b2c238299f49d3264554Jarkko Poyry if ((m_types & OBJECTTYPE_CONTEXT) != 0) 1393c827367444ee418f129b2c238299f49d3264554Jarkko Poyry types.push_back(OBJECTTYPE_CONTEXT); 1403c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 1413c827367444ee418f129b2c238299f49d3264554Jarkko Poyry if ((m_types & OBJECTTYPE_PBUFFER) != 0) 1423c827367444ee418f129b2c238299f49d3264554Jarkko Poyry types.push_back(OBJECTTYPE_PBUFFER); 1433c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 1443c827367444ee418f129b2c238299f49d3264554Jarkko Poyry // If objects should be used. Create one of both at beginning to allow using them. 1453c827367444ee418f129b2c238299f49d3264554Jarkko Poyry if (m_contexts.size() == 0 && m_pbuffers.size() == 0 && m_use) 1463c827367444ee418f129b2c238299f49d3264554Jarkko Poyry { 1473c827367444ee418f129b2c238299f49d3264554Jarkko Poyry allocateContext(); 1483c827367444ee418f129b2c238299f49d3264554Jarkko Poyry allocatePBuffer(); 1493c827367444ee418f129b2c238299f49d3264554Jarkko Poyry } 1503c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 1513c827367444ee418f129b2c238299f49d3264554Jarkko Poyry while (!m_failed) 1523c827367444ee418f129b2c238299f49d3264554Jarkko Poyry { 1533c827367444ee418f129b2c238299f49d3264554Jarkko Poyry ObjectType type = m_rnd.choose<ObjectType>(types.begin(), types.end()); 1543c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 1553c827367444ee418f129b2c238299f49d3264554Jarkko Poyry switch (type) 1563c827367444ee418f129b2c238299f49d3264554Jarkko Poyry { 1573c827367444ee418f129b2c238299f49d3264554Jarkko Poyry case OBJECTTYPE_PBUFFER: 1583c827367444ee418f129b2c238299f49d3264554Jarkko Poyry allocatePBuffer(); 1593c827367444ee418f129b2c238299f49d3264554Jarkko Poyry break; 1603c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 1613c827367444ee418f129b2c238299f49d3264554Jarkko Poyry case OBJECTTYPE_CONTEXT: 1623c827367444ee418f129b2c238299f49d3264554Jarkko Poyry allocateContext(); 1633c827367444ee418f129b2c238299f49d3264554Jarkko Poyry break; 1643c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 1653c827367444ee418f129b2c238299f49d3264554Jarkko Poyry default: 1663c827367444ee418f129b2c238299f49d3264554Jarkko Poyry DE_ASSERT(false); 1673c827367444ee418f129b2c238299f49d3264554Jarkko Poyry } 1683c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 1693c827367444ee418f129b2c238299f49d3264554Jarkko Poyry if (deGetMicroseconds() - beginTimeUs > timeLimitUs) 1703c827367444ee418f129b2c238299f49d3264554Jarkko Poyry return true; 1713c827367444ee418f129b2c238299f49d3264554Jarkko Poyry } 1723c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 1733c827367444ee418f129b2c238299f49d3264554Jarkko Poyry return false; 1743c827367444ee418f129b2c238299f49d3264554Jarkko Poyry} 1753c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 1763c827367444ee418f129b2c238299f49d3264554Jarkko Poyryvoid MemoryAllocator::allocatePBuffer (void) 1773c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{ 1783c827367444ee418f129b2c238299f49d3264554Jarkko Poyry // Reserve space for new allocations 1793c827367444ee418f129b2c238299f49d3264554Jarkko Poyry try 1803c827367444ee418f129b2c238299f49d3264554Jarkko Poyry { 1813c827367444ee418f129b2c238299f49d3264554Jarkko Poyry m_pbuffers.reserve(m_pbuffers.size() + 1); 1823c827367444ee418f129b2c238299f49d3264554Jarkko Poyry } 1833c827367444ee418f129b2c238299f49d3264554Jarkko Poyry catch (const std::bad_alloc&) 1843c827367444ee418f129b2c238299f49d3264554Jarkko Poyry { 1853c827367444ee418f129b2c238299f49d3264554Jarkko Poyry m_errorString = "std::bad_alloc when allocating more space for testcase. Out of host memory."; 1863c827367444ee418f129b2c238299f49d3264554Jarkko Poyry m_failed = true; 1873c827367444ee418f129b2c238299f49d3264554Jarkko Poyry return; 1883c827367444ee418f129b2c238299f49d3264554Jarkko Poyry } 1893c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 1903c827367444ee418f129b2c238299f49d3264554Jarkko Poyry // Allocate pbuffer 1913c827367444ee418f129b2c238299f49d3264554Jarkko Poyry try 1923c827367444ee418f129b2c238299f49d3264554Jarkko Poyry { 1933c827367444ee418f129b2c238299f49d3264554Jarkko Poyry const EGLint width = m_rnd.getInt(m_minWidth, m_maxWidth); 1943c827367444ee418f129b2c238299f49d3264554Jarkko Poyry const EGLint height = m_rnd.getInt(m_minHeight, m_maxHeight); 1953c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 1963c827367444ee418f129b2c238299f49d3264554Jarkko Poyry const EGLint attribList[] = { 1973c827367444ee418f129b2c238299f49d3264554Jarkko Poyry EGL_WIDTH, width, 1983c827367444ee418f129b2c238299f49d3264554Jarkko Poyry EGL_HEIGHT, height, 1993c827367444ee418f129b2c238299f49d3264554Jarkko Poyry EGL_NONE 2003c827367444ee418f129b2c238299f49d3264554Jarkko Poyry }; 2013c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 2023c827367444ee418f129b2c238299f49d3264554Jarkko Poyry EGLSurface surface = eglCreatePbufferSurface(m_display, m_config, attribList); 2033c827367444ee418f129b2c238299f49d3264554Jarkko Poyry TCU_CHECK_EGL_MSG("eglCreatePbufferSurface"); 2043c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 2053c827367444ee418f129b2c238299f49d3264554Jarkko Poyry DE_ASSERT(surface != EGL_NO_SURFACE); 2063c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 2073c827367444ee418f129b2c238299f49d3264554Jarkko Poyry m_pbuffers.push_back(surface); 2083c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 2093c827367444ee418f129b2c238299f49d3264554Jarkko Poyry if (m_use && m_contexts.size() > 0) 2103c827367444ee418f129b2c238299f49d3264554Jarkko Poyry { 2113c827367444ee418f129b2c238299f49d3264554Jarkko Poyry EGLContext context = m_rnd.choose<EGLContext>(m_contexts.begin(), m_contexts.end()); 2123c827367444ee418f129b2c238299f49d3264554Jarkko Poyry const float red = m_rnd.getFloat(); 2133c827367444ee418f129b2c238299f49d3264554Jarkko Poyry const float green = m_rnd.getFloat(); 2143c827367444ee418f129b2c238299f49d3264554Jarkko Poyry const float blue = m_rnd.getFloat(); 2153c827367444ee418f129b2c238299f49d3264554Jarkko Poyry const float alpha = m_rnd.getFloat(); 2163c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 2173c827367444ee418f129b2c238299f49d3264554Jarkko Poyry TCU_CHECK_EGL_CALL(eglMakeCurrent(m_display, surface, surface, context)); 2183c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 2193c827367444ee418f129b2c238299f49d3264554Jarkko Poyry m_gl.clearColor(red, green, blue, alpha); 2203c827367444ee418f129b2c238299f49d3264554Jarkko Poyry GLU_EXPECT_NO_ERROR(m_gl.getError(), "glClearColor()"); 2213c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 2223c827367444ee418f129b2c238299f49d3264554Jarkko Poyry m_gl.clear(GL_COLOR_BUFFER_BIT); 2233c827367444ee418f129b2c238299f49d3264554Jarkko Poyry GLU_EXPECT_NO_ERROR(m_gl.getError(), "glClear()"); 2243c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 2253c827367444ee418f129b2c238299f49d3264554Jarkko Poyry TCU_CHECK_EGL_CALL(eglMakeCurrent(m_display, EGL_NO_SURFACE, EGL_NO_SURFACE, EGL_NO_CONTEXT)); 2263c827367444ee418f129b2c238299f49d3264554Jarkko Poyry } 2273c827367444ee418f129b2c238299f49d3264554Jarkko Poyry } 2283c827367444ee418f129b2c238299f49d3264554Jarkko Poyry catch (const eglu::Error& error) 2293c827367444ee418f129b2c238299f49d3264554Jarkko Poyry { 2303c827367444ee418f129b2c238299f49d3264554Jarkko Poyry if (error.getError() == EGL_BAD_ALLOC) 2313c827367444ee418f129b2c238299f49d3264554Jarkko Poyry { 2323c827367444ee418f129b2c238299f49d3264554Jarkko Poyry m_errorString = "eglCreatePbufferSurface returned EGL_BAD_ALLOC"; 2333c827367444ee418f129b2c238299f49d3264554Jarkko Poyry m_failed = true; 2343c827367444ee418f129b2c238299f49d3264554Jarkko Poyry return; 2353c827367444ee418f129b2c238299f49d3264554Jarkko Poyry } 2363c827367444ee418f129b2c238299f49d3264554Jarkko Poyry else 2373c827367444ee418f129b2c238299f49d3264554Jarkko Poyry throw; 2383c827367444ee418f129b2c238299f49d3264554Jarkko Poyry } 2393c827367444ee418f129b2c238299f49d3264554Jarkko Poyry} 2403c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 2413c827367444ee418f129b2c238299f49d3264554Jarkko Poyryvoid MemoryAllocator::allocateContext (void) 2423c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{ 2433c827367444ee418f129b2c238299f49d3264554Jarkko Poyry // Reserve space for new allocations 2443c827367444ee418f129b2c238299f49d3264554Jarkko Poyry try 2453c827367444ee418f129b2c238299f49d3264554Jarkko Poyry { 2463c827367444ee418f129b2c238299f49d3264554Jarkko Poyry m_contexts.reserve(m_contexts.size() + 1); 2473c827367444ee418f129b2c238299f49d3264554Jarkko Poyry } 2483c827367444ee418f129b2c238299f49d3264554Jarkko Poyry catch (const std::bad_alloc&) 2493c827367444ee418f129b2c238299f49d3264554Jarkko Poyry { 2503c827367444ee418f129b2c238299f49d3264554Jarkko Poyry m_errorString = "std::bad_alloc when allocating more space for testcase. Out of host memory."; 2513c827367444ee418f129b2c238299f49d3264554Jarkko Poyry m_failed = true; 2523c827367444ee418f129b2c238299f49d3264554Jarkko Poyry return; 2533c827367444ee418f129b2c238299f49d3264554Jarkko Poyry } 2543c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 2553c827367444ee418f129b2c238299f49d3264554Jarkko Poyry // Allocate context 2563c827367444ee418f129b2c238299f49d3264554Jarkko Poyry try 2573c827367444ee418f129b2c238299f49d3264554Jarkko Poyry { 2583c827367444ee418f129b2c238299f49d3264554Jarkko Poyry const EGLint attribList[] = { 2593c827367444ee418f129b2c238299f49d3264554Jarkko Poyry EGL_CONTEXT_CLIENT_VERSION, 2, 2603c827367444ee418f129b2c238299f49d3264554Jarkko Poyry EGL_NONE 2613c827367444ee418f129b2c238299f49d3264554Jarkko Poyry }; 2623c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 2633c827367444ee418f129b2c238299f49d3264554Jarkko Poyry TCU_CHECK_EGL_CALL(eglBindAPI(EGL_OPENGL_ES_API)); 2643c827367444ee418f129b2c238299f49d3264554Jarkko Poyry EGLContext context = eglCreateContext(m_display, m_config, EGL_NO_CONTEXT, attribList); 2653c827367444ee418f129b2c238299f49d3264554Jarkko Poyry TCU_CHECK_EGL_MSG("eglCreateContext"); 2663c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 2673c827367444ee418f129b2c238299f49d3264554Jarkko Poyry DE_ASSERT(context != EGL_NO_CONTEXT); 2683c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 2693c827367444ee418f129b2c238299f49d3264554Jarkko Poyry m_contexts.push_back(context); 2703c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 2713c827367444ee418f129b2c238299f49d3264554Jarkko Poyry if (m_use && m_pbuffers.size() > 0) 2723c827367444ee418f129b2c238299f49d3264554Jarkko Poyry { 2733c827367444ee418f129b2c238299f49d3264554Jarkko Poyry EGLSurface surface = m_rnd.choose<EGLSurface>(m_pbuffers.begin(), m_pbuffers.end()); 2743c827367444ee418f129b2c238299f49d3264554Jarkko Poyry const float red = m_rnd.getFloat(); 2753c827367444ee418f129b2c238299f49d3264554Jarkko Poyry const float green = m_rnd.getFloat(); 2763c827367444ee418f129b2c238299f49d3264554Jarkko Poyry const float blue = m_rnd.getFloat(); 2773c827367444ee418f129b2c238299f49d3264554Jarkko Poyry const float alpha = m_rnd.getFloat(); 2783c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 2793c827367444ee418f129b2c238299f49d3264554Jarkko Poyry TCU_CHECK_EGL_CALL(eglMakeCurrent(m_display, surface, surface, context)); 2803c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 2813c827367444ee418f129b2c238299f49d3264554Jarkko Poyry m_gl.clearColor(red, green, blue, alpha); 2823c827367444ee418f129b2c238299f49d3264554Jarkko Poyry GLU_EXPECT_NO_ERROR(m_gl.getError(), "glClearColor()"); 2833c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 2843c827367444ee418f129b2c238299f49d3264554Jarkko Poyry m_gl.clear(GL_COLOR_BUFFER_BIT); 2853c827367444ee418f129b2c238299f49d3264554Jarkko Poyry GLU_EXPECT_NO_ERROR(m_gl.getError(), "glClear()"); 2863c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 2873c827367444ee418f129b2c238299f49d3264554Jarkko Poyry TCU_CHECK_EGL_CALL(eglMakeCurrent(m_display, EGL_NO_SURFACE, EGL_NO_SURFACE, EGL_NO_CONTEXT)); 2883c827367444ee418f129b2c238299f49d3264554Jarkko Poyry } 2893c827367444ee418f129b2c238299f49d3264554Jarkko Poyry } 2903c827367444ee418f129b2c238299f49d3264554Jarkko Poyry catch (const eglu::Error& error) 2913c827367444ee418f129b2c238299f49d3264554Jarkko Poyry { 2923c827367444ee418f129b2c238299f49d3264554Jarkko Poyry if (error.getError() == EGL_BAD_ALLOC) 2933c827367444ee418f129b2c238299f49d3264554Jarkko Poyry { 2943c827367444ee418f129b2c238299f49d3264554Jarkko Poyry m_errorString = "eglCreateContext returned EGL_BAD_ALLOC"; 2953c827367444ee418f129b2c238299f49d3264554Jarkko Poyry m_failed = true; 2963c827367444ee418f129b2c238299f49d3264554Jarkko Poyry return; 2973c827367444ee418f129b2c238299f49d3264554Jarkko Poyry } 2983c827367444ee418f129b2c238299f49d3264554Jarkko Poyry else 2993c827367444ee418f129b2c238299f49d3264554Jarkko Poyry throw; 3003c827367444ee418f129b2c238299f49d3264554Jarkko Poyry } 3013c827367444ee418f129b2c238299f49d3264554Jarkko Poyry} 3023c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 3033c827367444ee418f129b2c238299f49d3264554Jarkko Poyry} // anonymous 3043c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 3053c827367444ee418f129b2c238299f49d3264554Jarkko Poyryclass MemoryStressCase : public TestCase 3063c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{ 3073c827367444ee418f129b2c238299f49d3264554Jarkko Poyrypublic: 3083c827367444ee418f129b2c238299f49d3264554Jarkko Poyry struct Spec 3093c827367444ee418f129b2c238299f49d3264554Jarkko Poyry { 3103c827367444ee418f129b2c238299f49d3264554Jarkko Poyry ObjectType types; 3113c827367444ee418f129b2c238299f49d3264554Jarkko Poyry int minWidth; 3123c827367444ee418f129b2c238299f49d3264554Jarkko Poyry int minHeight; 3133c827367444ee418f129b2c238299f49d3264554Jarkko Poyry int maxWidth; 3143c827367444ee418f129b2c238299f49d3264554Jarkko Poyry int maxHeight; 3153c827367444ee418f129b2c238299f49d3264554Jarkko Poyry bool use; 3163c827367444ee418f129b2c238299f49d3264554Jarkko Poyry }; 3173c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 3183c827367444ee418f129b2c238299f49d3264554Jarkko Poyry MemoryStressCase (EglTestContext& eglTestCtx, Spec spec, const char* name, const char* description); 3193c827367444ee418f129b2c238299f49d3264554Jarkko Poyry void init (void); 3203c827367444ee418f129b2c238299f49d3264554Jarkko Poyry void deinit (void); 3213c827367444ee418f129b2c238299f49d3264554Jarkko Poyry IterateResult iterate (void); 3223c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 3233c827367444ee418f129b2c238299f49d3264554Jarkko Poyryprivate: 3243c827367444ee418f129b2c238299f49d3264554Jarkko Poyry Spec m_spec; 3253c827367444ee418f129b2c238299f49d3264554Jarkko Poyry vector<int> m_allocationCounts; 3263c827367444ee418f129b2c238299f49d3264554Jarkko Poyry MemoryAllocator* m_allocator; 3273c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 3283c827367444ee418f129b2c238299f49d3264554Jarkko Poyry int m_iteration; 3293c827367444ee418f129b2c238299f49d3264554Jarkko Poyry int m_iterationCount; 3303c827367444ee418f129b2c238299f49d3264554Jarkko Poyry int m_seed; 3313c827367444ee418f129b2c238299f49d3264554Jarkko Poyry EGLDisplay m_display; 3323c827367444ee418f129b2c238299f49d3264554Jarkko Poyry EGLConfig m_config; 3333c827367444ee418f129b2c238299f49d3264554Jarkko Poyry}; 3343c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 3353c827367444ee418f129b2c238299f49d3264554Jarkko PoyryMemoryStressCase::MemoryStressCase (EglTestContext& eglTestCtx, Spec spec, const char* name, const char* description) 3363c827367444ee418f129b2c238299f49d3264554Jarkko Poyry : TestCase (eglTestCtx, name, description) 3373c827367444ee418f129b2c238299f49d3264554Jarkko Poyry , m_spec (spec) 3383c827367444ee418f129b2c238299f49d3264554Jarkko Poyry , m_allocator (NULL) 3393c827367444ee418f129b2c238299f49d3264554Jarkko Poyry , m_iteration (0) 3403c827367444ee418f129b2c238299f49d3264554Jarkko Poyry , m_iterationCount (10) 3413c827367444ee418f129b2c238299f49d3264554Jarkko Poyry , m_seed (deStringHash(name)) 3423c827367444ee418f129b2c238299f49d3264554Jarkko Poyry , m_display (EGL_NO_DISPLAY) 3433c827367444ee418f129b2c238299f49d3264554Jarkko Poyry , m_config (DE_NULL) 3443c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{ 3453c827367444ee418f129b2c238299f49d3264554Jarkko Poyry} 3463c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 3473c827367444ee418f129b2c238299f49d3264554Jarkko Poyryvoid MemoryStressCase::init (void) 3483c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{ 3493c827367444ee418f129b2c238299f49d3264554Jarkko Poyry EGLint configCount = 0; 3503c827367444ee418f129b2c238299f49d3264554Jarkko Poyry const EGLint attribList[] = { 3513c827367444ee418f129b2c238299f49d3264554Jarkko Poyry EGL_SURFACE_TYPE, EGL_PBUFFER_BIT, 3523c827367444ee418f129b2c238299f49d3264554Jarkko Poyry EGL_RENDERABLE_TYPE, EGL_OPENGL_ES2_BIT, 3533c827367444ee418f129b2c238299f49d3264554Jarkko Poyry EGL_NONE 3543c827367444ee418f129b2c238299f49d3264554Jarkko Poyry }; 3553c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 3563c827367444ee418f129b2c238299f49d3264554Jarkko Poyry if (!m_testCtx.getCommandLine().isOutOfMemoryTestEnabled()) 3573c827367444ee418f129b2c238299f49d3264554Jarkko Poyry { 3583c827367444ee418f129b2c238299f49d3264554Jarkko Poyry m_testCtx.getLog() << TestLog::Message << "Tests that exhaust memory are disabled, use --deqp-test-oom=enable command line option to enable." << TestLog::EndMessage; 3593c827367444ee418f129b2c238299f49d3264554Jarkko Poyry throw tcu::NotSupportedError("OOM tests disabled"); 3603c827367444ee418f129b2c238299f49d3264554Jarkko Poyry } 3613c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 3623c827367444ee418f129b2c238299f49d3264554Jarkko Poyry m_display = m_eglTestCtx.getDisplay().getEGLDisplay(); 3633c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 3643c827367444ee418f129b2c238299f49d3264554Jarkko Poyry TCU_CHECK_EGL_CALL(eglChooseConfig(m_display, attribList, &m_config, 1, &configCount)); 3653c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 3663c827367444ee418f129b2c238299f49d3264554Jarkko Poyry TCU_CHECK(configCount != 0); 3673c827367444ee418f129b2c238299f49d3264554Jarkko Poyry} 3683c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 3693c827367444ee418f129b2c238299f49d3264554Jarkko Poyryvoid MemoryStressCase::deinit (void) 3703c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{ 3713c827367444ee418f129b2c238299f49d3264554Jarkko Poyry delete m_allocator; 3723c827367444ee418f129b2c238299f49d3264554Jarkko Poyry m_allocator = DE_NULL; 3733c827367444ee418f129b2c238299f49d3264554Jarkko Poyry} 3743c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 3753c827367444ee418f129b2c238299f49d3264554Jarkko PoyryTestCase::IterateResult MemoryStressCase::iterate (void) 3763c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{ 3773c827367444ee418f129b2c238299f49d3264554Jarkko Poyry TestLog& log = m_testCtx.getLog(); 3783c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 3793c827367444ee418f129b2c238299f49d3264554Jarkko Poyry if (m_iteration < m_iterationCount) 3803c827367444ee418f129b2c238299f49d3264554Jarkko Poyry { 3813c827367444ee418f129b2c238299f49d3264554Jarkko Poyry try 3823c827367444ee418f129b2c238299f49d3264554Jarkko Poyry { 3833c827367444ee418f129b2c238299f49d3264554Jarkko Poyry if (!m_allocator) 3843c827367444ee418f129b2c238299f49d3264554Jarkko Poyry m_allocator = new MemoryAllocator(m_eglTestCtx, m_display, m_config, m_seed, m_spec.types, m_spec.minWidth, m_spec.minHeight, m_spec.maxWidth, m_spec.maxHeight, m_spec.use); 3853c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 3863c827367444ee418f129b2c238299f49d3264554Jarkko Poyry if (m_allocator->allocateUntilFailure()) 3873c827367444ee418f129b2c238299f49d3264554Jarkko Poyry { 3883c827367444ee418f129b2c238299f49d3264554Jarkko Poyry log << TestLog::Message << "Couldn't exhaust memory before timeout. Allocated " << m_allocator->getAllocationCount() << " objects." << TestLog::EndMessage; 3893c827367444ee418f129b2c238299f49d3264554Jarkko Poyry m_testCtx.setTestResult(QP_TEST_RESULT_PASS, "Pass"); 3903c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 3913c827367444ee418f129b2c238299f49d3264554Jarkko Poyry delete m_allocator; 3923c827367444ee418f129b2c238299f49d3264554Jarkko Poyry m_allocator = NULL; 3933c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 3943c827367444ee418f129b2c238299f49d3264554Jarkko Poyry return STOP; 3953c827367444ee418f129b2c238299f49d3264554Jarkko Poyry } 3963c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 3973c827367444ee418f129b2c238299f49d3264554Jarkko Poyry log << TestLog::Message << "Iteration " << m_iteration << ": Allocated " << m_allocator->getAllocationCount() << " objects; " << m_allocator->getContextCount() << " contexts, " << m_allocator->getPBufferCount() << " PBuffers." << TestLog::EndMessage; 3983c827367444ee418f129b2c238299f49d3264554Jarkko Poyry log << TestLog::Message << "Got expected error: " << m_allocator->getErrorString() << TestLog::EndMessage; 3993c827367444ee418f129b2c238299f49d3264554Jarkko Poyry m_allocationCounts.push_back(m_allocator->getAllocationCount()); 4003c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 4013c827367444ee418f129b2c238299f49d3264554Jarkko Poyry delete m_allocator; 4023c827367444ee418f129b2c238299f49d3264554Jarkko Poyry m_allocator = NULL; 4033c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 4043c827367444ee418f129b2c238299f49d3264554Jarkko Poyry m_iteration++; 4053c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 4063c827367444ee418f129b2c238299f49d3264554Jarkko Poyry return CONTINUE; 4073c827367444ee418f129b2c238299f49d3264554Jarkko Poyry } catch (...) 4083c827367444ee418f129b2c238299f49d3264554Jarkko Poyry { 4093c827367444ee418f129b2c238299f49d3264554Jarkko Poyry log << TestLog::Message << "Iteration " << m_iteration << ": Allocated " << m_allocator->getAllocationCount() << " objects; " << m_allocator->getContextCount() << " contexts, " << m_allocator->getPBufferCount() << " PBuffers." << TestLog::EndMessage; 4103c827367444ee418f129b2c238299f49d3264554Jarkko Poyry log << TestLog::Message << "Unexpected error" << TestLog::EndMessage; 4113c827367444ee418f129b2c238299f49d3264554Jarkko Poyry throw; 4123c827367444ee418f129b2c238299f49d3264554Jarkko Poyry } 4133c827367444ee418f129b2c238299f49d3264554Jarkko Poyry } 4143c827367444ee418f129b2c238299f49d3264554Jarkko Poyry else 4153c827367444ee418f129b2c238299f49d3264554Jarkko Poyry { 4163c827367444ee418f129b2c238299f49d3264554Jarkko Poyry // Analyze number of passed allocations. 4173c827367444ee418f129b2c238299f49d3264554Jarkko Poyry int min = m_allocationCounts[0]; 4183c827367444ee418f129b2c238299f49d3264554Jarkko Poyry int max = m_allocationCounts[0]; 4193c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 4203c827367444ee418f129b2c238299f49d3264554Jarkko Poyry float threshold = 50.0f; 4213c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 4223c827367444ee418f129b2c238299f49d3264554Jarkko Poyry for (int allocNdx = 0; allocNdx < (int)m_allocationCounts.size(); allocNdx++) 4233c827367444ee418f129b2c238299f49d3264554Jarkko Poyry { 4243c827367444ee418f129b2c238299f49d3264554Jarkko Poyry min = deMin32(m_allocationCounts[allocNdx], min); 4253c827367444ee418f129b2c238299f49d3264554Jarkko Poyry max = deMax32(m_allocationCounts[allocNdx], max); 4263c827367444ee418f129b2c238299f49d3264554Jarkko Poyry } 4273c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 4283c827367444ee418f129b2c238299f49d3264554Jarkko Poyry if (min == 0 && max != 0) 4293c827367444ee418f129b2c238299f49d3264554Jarkko Poyry { 4303c827367444ee418f129b2c238299f49d3264554Jarkko Poyry log << TestLog::Message << "Allocation count zero" << TestLog::EndMessage; 4313c827367444ee418f129b2c238299f49d3264554Jarkko Poyry m_testCtx.setTestResult(QP_TEST_RESULT_FAIL, "Fail"); 4323c827367444ee418f129b2c238299f49d3264554Jarkko Poyry } 4333c827367444ee418f129b2c238299f49d3264554Jarkko Poyry else 4343c827367444ee418f129b2c238299f49d3264554Jarkko Poyry { 4353c827367444ee418f129b2c238299f49d3264554Jarkko Poyry float change = (min - max) / ((float)(max)); 4363c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 4373c827367444ee418f129b2c238299f49d3264554Jarkko Poyry if (change > threshold) 4383c827367444ee418f129b2c238299f49d3264554Jarkko Poyry { 4393c827367444ee418f129b2c238299f49d3264554Jarkko Poyry log << TestLog::Message << "Allocated objects max: " << max << ", min: " << min << ", difference: " << change << "% threshold: " << threshold << "%" << TestLog::EndMessage; 4403c827367444ee418f129b2c238299f49d3264554Jarkko Poyry m_testCtx.setTestResult(QP_TEST_RESULT_QUALITY_WARNING, "Allocation count variation"); 4413c827367444ee418f129b2c238299f49d3264554Jarkko Poyry } 4423c827367444ee418f129b2c238299f49d3264554Jarkko Poyry else 4433c827367444ee418f129b2c238299f49d3264554Jarkko Poyry m_testCtx.setTestResult(QP_TEST_RESULT_PASS, "Pass"); 4443c827367444ee418f129b2c238299f49d3264554Jarkko Poyry } 4453c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 4463c827367444ee418f129b2c238299f49d3264554Jarkko Poyry return STOP; 4473c827367444ee418f129b2c238299f49d3264554Jarkko Poyry } 4483c827367444ee418f129b2c238299f49d3264554Jarkko Poyry} 4493c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 4503c827367444ee418f129b2c238299f49d3264554Jarkko PoyryMemoryStressTests::MemoryStressTests (EglTestContext& eglTestCtx) 4513c827367444ee418f129b2c238299f49d3264554Jarkko Poyry : TestCaseGroup(eglTestCtx, "memory", "Memory allocation stress tests") 4523c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{ 4533c827367444ee418f129b2c238299f49d3264554Jarkko Poyry} 4543c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 4553c827367444ee418f129b2c238299f49d3264554Jarkko Poyryvoid MemoryStressTests::init (void) 4563c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{ 4573c827367444ee418f129b2c238299f49d3264554Jarkko Poyry // Check small pbuffers 256x256 4583c827367444ee418f129b2c238299f49d3264554Jarkko Poyry { 4593c827367444ee418f129b2c238299f49d3264554Jarkko Poyry MemoryStressCase::Spec spec; 4603c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 4613c827367444ee418f129b2c238299f49d3264554Jarkko Poyry spec.types = OBJECTTYPE_PBUFFER; 4623c827367444ee418f129b2c238299f49d3264554Jarkko Poyry spec.minWidth = 256; 4633c827367444ee418f129b2c238299f49d3264554Jarkko Poyry spec.minHeight = 256; 4643c827367444ee418f129b2c238299f49d3264554Jarkko Poyry spec.maxWidth = 256; 4653c827367444ee418f129b2c238299f49d3264554Jarkko Poyry spec.maxHeight = 256; 4663c827367444ee418f129b2c238299f49d3264554Jarkko Poyry spec.use = false; 4673c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 4683c827367444ee418f129b2c238299f49d3264554Jarkko Poyry addChild(new MemoryStressCase(m_eglTestCtx, spec, "pbuffer_256x256", "PBuffer allocation stress tests")); 4693c827367444ee418f129b2c238299f49d3264554Jarkko Poyry } 4703c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 4713c827367444ee418f129b2c238299f49d3264554Jarkko Poyry // Check small pbuffers 256x256 and use them 4723c827367444ee418f129b2c238299f49d3264554Jarkko Poyry { 4733c827367444ee418f129b2c238299f49d3264554Jarkko Poyry MemoryStressCase::Spec spec; 4743c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 4753c827367444ee418f129b2c238299f49d3264554Jarkko Poyry spec.types = OBJECTTYPE_PBUFFER; 4763c827367444ee418f129b2c238299f49d3264554Jarkko Poyry spec.minWidth = 256; 4773c827367444ee418f129b2c238299f49d3264554Jarkko Poyry spec.minHeight = 256; 4783c827367444ee418f129b2c238299f49d3264554Jarkko Poyry spec.maxWidth = 256; 4793c827367444ee418f129b2c238299f49d3264554Jarkko Poyry spec.maxHeight = 256; 4803c827367444ee418f129b2c238299f49d3264554Jarkko Poyry spec.use = true; 4813c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 4823c827367444ee418f129b2c238299f49d3264554Jarkko Poyry addChild(new MemoryStressCase(m_eglTestCtx, spec, "pbuffer_256x256_use", "PBuffer allocation stress tests")); 4833c827367444ee418f129b2c238299f49d3264554Jarkko Poyry } 4843c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 4853c827367444ee418f129b2c238299f49d3264554Jarkko Poyry // Check big pbuffers 1024x1024 4863c827367444ee418f129b2c238299f49d3264554Jarkko Poyry { 4873c827367444ee418f129b2c238299f49d3264554Jarkko Poyry MemoryStressCase::Spec spec; 4883c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 4893c827367444ee418f129b2c238299f49d3264554Jarkko Poyry spec.types = OBJECTTYPE_PBUFFER; 4903c827367444ee418f129b2c238299f49d3264554Jarkko Poyry spec.minWidth = 1024; 4913c827367444ee418f129b2c238299f49d3264554Jarkko Poyry spec.minHeight = 1024; 4923c827367444ee418f129b2c238299f49d3264554Jarkko Poyry spec.maxWidth = 1024; 4933c827367444ee418f129b2c238299f49d3264554Jarkko Poyry spec.maxHeight = 1024; 4943c827367444ee418f129b2c238299f49d3264554Jarkko Poyry spec.use = false; 4953c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 4963c827367444ee418f129b2c238299f49d3264554Jarkko Poyry addChild(new MemoryStressCase(m_eglTestCtx, spec, "pbuffer_1024x1024", "PBuffer allocation stress tests")); 4973c827367444ee418f129b2c238299f49d3264554Jarkko Poyry } 4983c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 4993c827367444ee418f129b2c238299f49d3264554Jarkko Poyry // Check big pbuffers 1024x1024 and use them 5003c827367444ee418f129b2c238299f49d3264554Jarkko Poyry { 5013c827367444ee418f129b2c238299f49d3264554Jarkko Poyry MemoryStressCase::Spec spec; 5023c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 5033c827367444ee418f129b2c238299f49d3264554Jarkko Poyry spec.types = OBJECTTYPE_PBUFFER; 5043c827367444ee418f129b2c238299f49d3264554Jarkko Poyry spec.minWidth = 1024; 5053c827367444ee418f129b2c238299f49d3264554Jarkko Poyry spec.minHeight = 1024; 5063c827367444ee418f129b2c238299f49d3264554Jarkko Poyry spec.maxWidth = 1024; 5073c827367444ee418f129b2c238299f49d3264554Jarkko Poyry spec.maxHeight = 1024; 5083c827367444ee418f129b2c238299f49d3264554Jarkko Poyry spec.use = true; 5093c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 5103c827367444ee418f129b2c238299f49d3264554Jarkko Poyry addChild(new MemoryStressCase(m_eglTestCtx, spec, "pbuffer_1024x1024_use", "PBuffer allocation stress tests")); 5113c827367444ee418f129b2c238299f49d3264554Jarkko Poyry } 5123c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 5133c827367444ee418f129b2c238299f49d3264554Jarkko Poyry // Check different sized pbuffers 5143c827367444ee418f129b2c238299f49d3264554Jarkko Poyry { 5153c827367444ee418f129b2c238299f49d3264554Jarkko Poyry MemoryStressCase::Spec spec; 5163c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 5173c827367444ee418f129b2c238299f49d3264554Jarkko Poyry spec.types = OBJECTTYPE_PBUFFER; 5183c827367444ee418f129b2c238299f49d3264554Jarkko Poyry spec.minWidth = 64; 5193c827367444ee418f129b2c238299f49d3264554Jarkko Poyry spec.minHeight = 64; 5203c827367444ee418f129b2c238299f49d3264554Jarkko Poyry spec.maxWidth = 1024; 5213c827367444ee418f129b2c238299f49d3264554Jarkko Poyry spec.maxHeight = 1024; 5223c827367444ee418f129b2c238299f49d3264554Jarkko Poyry spec.use = false; 5233c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 5243c827367444ee418f129b2c238299f49d3264554Jarkko Poyry addChild(new MemoryStressCase(m_eglTestCtx, spec, "pbuffer", "PBuffer allocation stress tests")); 5253c827367444ee418f129b2c238299f49d3264554Jarkko Poyry } 5263c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 5273c827367444ee418f129b2c238299f49d3264554Jarkko Poyry // Check different sized pbuffers and use them 5283c827367444ee418f129b2c238299f49d3264554Jarkko Poyry { 5293c827367444ee418f129b2c238299f49d3264554Jarkko Poyry MemoryStressCase::Spec spec; 5303c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 5313c827367444ee418f129b2c238299f49d3264554Jarkko Poyry spec.types = OBJECTTYPE_PBUFFER; 5323c827367444ee418f129b2c238299f49d3264554Jarkko Poyry spec.minWidth = 64; 5333c827367444ee418f129b2c238299f49d3264554Jarkko Poyry spec.minHeight = 64; 5343c827367444ee418f129b2c238299f49d3264554Jarkko Poyry spec.maxWidth = 1024; 5353c827367444ee418f129b2c238299f49d3264554Jarkko Poyry spec.maxHeight = 1024; 5363c827367444ee418f129b2c238299f49d3264554Jarkko Poyry spec.use = true; 5373c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 5383c827367444ee418f129b2c238299f49d3264554Jarkko Poyry addChild(new MemoryStressCase(m_eglTestCtx, spec, "pbuffer_use", "PBuffer allocation stress tests")); 5393c827367444ee418f129b2c238299f49d3264554Jarkko Poyry } 5403c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 5413c827367444ee418f129b2c238299f49d3264554Jarkko Poyry // Check contexts 5423c827367444ee418f129b2c238299f49d3264554Jarkko Poyry { 5433c827367444ee418f129b2c238299f49d3264554Jarkko Poyry MemoryStressCase::Spec spec; 5443c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 5453c827367444ee418f129b2c238299f49d3264554Jarkko Poyry spec.types = OBJECTTYPE_CONTEXT; 5463c827367444ee418f129b2c238299f49d3264554Jarkko Poyry spec.minWidth = 1024; 5473c827367444ee418f129b2c238299f49d3264554Jarkko Poyry spec.minHeight = 1024; 5483c827367444ee418f129b2c238299f49d3264554Jarkko Poyry spec.maxWidth = 1024; 5493c827367444ee418f129b2c238299f49d3264554Jarkko Poyry spec.maxHeight = 1024; 5503c827367444ee418f129b2c238299f49d3264554Jarkko Poyry spec.use = false; 5513c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 5523c827367444ee418f129b2c238299f49d3264554Jarkko Poyry addChild(new MemoryStressCase(m_eglTestCtx, spec, "context", "Context allocation stress tests")); 5533c827367444ee418f129b2c238299f49d3264554Jarkko Poyry } 5543c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 5553c827367444ee418f129b2c238299f49d3264554Jarkko Poyry // Check contexts and use them 5563c827367444ee418f129b2c238299f49d3264554Jarkko Poyry { 5573c827367444ee418f129b2c238299f49d3264554Jarkko Poyry MemoryStressCase::Spec spec; 5583c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 5593c827367444ee418f129b2c238299f49d3264554Jarkko Poyry spec.types = OBJECTTYPE_CONTEXT; 5603c827367444ee418f129b2c238299f49d3264554Jarkko Poyry spec.minWidth = 1024; 5613c827367444ee418f129b2c238299f49d3264554Jarkko Poyry spec.minHeight = 1024; 5623c827367444ee418f129b2c238299f49d3264554Jarkko Poyry spec.maxWidth = 1024; 5633c827367444ee418f129b2c238299f49d3264554Jarkko Poyry spec.maxHeight = 1024; 5643c827367444ee418f129b2c238299f49d3264554Jarkko Poyry spec.use = true; 5653c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 5663c827367444ee418f129b2c238299f49d3264554Jarkko Poyry addChild(new MemoryStressCase(m_eglTestCtx, spec, "context_use", "Context allocation stress tests")); 5673c827367444ee418f129b2c238299f49d3264554Jarkko Poyry } 5683c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 5693c827367444ee418f129b2c238299f49d3264554Jarkko Poyry // Check contexts and pbuffers 5703c827367444ee418f129b2c238299f49d3264554Jarkko Poyry { 5713c827367444ee418f129b2c238299f49d3264554Jarkko Poyry MemoryStressCase::Spec spec; 5723c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 5733c827367444ee418f129b2c238299f49d3264554Jarkko Poyry spec.types = (ObjectType)(OBJECTTYPE_PBUFFER|OBJECTTYPE_CONTEXT); 5743c827367444ee418f129b2c238299f49d3264554Jarkko Poyry spec.minWidth = 64; 5753c827367444ee418f129b2c238299f49d3264554Jarkko Poyry spec.minHeight = 64; 5763c827367444ee418f129b2c238299f49d3264554Jarkko Poyry spec.maxWidth = 1024; 5773c827367444ee418f129b2c238299f49d3264554Jarkko Poyry spec.maxHeight = 1024; 5783c827367444ee418f129b2c238299f49d3264554Jarkko Poyry spec.use = false; 5793c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 5803c827367444ee418f129b2c238299f49d3264554Jarkko Poyry addChild(new MemoryStressCase(m_eglTestCtx, spec, "pbuffer_context", "PBuffer and context allocation stress tests")); 5813c827367444ee418f129b2c238299f49d3264554Jarkko Poyry } 5823c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 5833c827367444ee418f129b2c238299f49d3264554Jarkko Poyry // Check contexts and pbuffers and use 5843c827367444ee418f129b2c238299f49d3264554Jarkko Poyry { 5853c827367444ee418f129b2c238299f49d3264554Jarkko Poyry MemoryStressCase::Spec spec; 5863c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 5873c827367444ee418f129b2c238299f49d3264554Jarkko Poyry spec.types = (ObjectType)(OBJECTTYPE_PBUFFER|OBJECTTYPE_CONTEXT); 5883c827367444ee418f129b2c238299f49d3264554Jarkko Poyry spec.minWidth = 64; 5893c827367444ee418f129b2c238299f49d3264554Jarkko Poyry spec.minHeight = 64; 5903c827367444ee418f129b2c238299f49d3264554Jarkko Poyry spec.maxWidth = 1024; 5913c827367444ee418f129b2c238299f49d3264554Jarkko Poyry spec.maxHeight = 1024; 5923c827367444ee418f129b2c238299f49d3264554Jarkko Poyry spec.use = true; 5933c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 5943c827367444ee418f129b2c238299f49d3264554Jarkko Poyry addChild(new MemoryStressCase(m_eglTestCtx, spec, "pbuffer_context_use", "PBuffer and context allocation stress tests")); 5953c827367444ee418f129b2c238299f49d3264554Jarkko Poyry } 5963c827367444ee418f129b2c238299f49d3264554Jarkko Poyry} 5973c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 5983c827367444ee418f129b2c238299f49d3264554Jarkko Poyry} // egl 5993c827367444ee418f129b2c238299f49d3264554Jarkko Poyry} // deqp 600