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