xref: /aosp_15_r20/external/deqp/modules/egl/teglMemoryStressTests.cpp (revision 35238bce31c2a825756842865a792f8cf7f89930)
1*35238bceSAndroid Build Coastguard Worker /*-------------------------------------------------------------------------
2*35238bceSAndroid Build Coastguard Worker  * drawElements Quality Program EGL Module
3*35238bceSAndroid Build Coastguard Worker  * ---------------------------------------
4*35238bceSAndroid Build Coastguard Worker  *
5*35238bceSAndroid Build Coastguard Worker  * Copyright 2014 The Android Open Source Project
6*35238bceSAndroid Build Coastguard Worker  *
7*35238bceSAndroid Build Coastguard Worker  * Licensed under the Apache License, Version 2.0 (the "License");
8*35238bceSAndroid Build Coastguard Worker  * you may not use this file except in compliance with the License.
9*35238bceSAndroid Build Coastguard Worker  * You may obtain a copy of the License at
10*35238bceSAndroid Build Coastguard Worker  *
11*35238bceSAndroid Build Coastguard Worker  *      http://www.apache.org/licenses/LICENSE-2.0
12*35238bceSAndroid Build Coastguard Worker  *
13*35238bceSAndroid Build Coastguard Worker  * Unless required by applicable law or agreed to in writing, software
14*35238bceSAndroid Build Coastguard Worker  * distributed under the License is distributed on an "AS IS" BASIS,
15*35238bceSAndroid Build Coastguard Worker  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16*35238bceSAndroid Build Coastguard Worker  * See the License for the specific language governing permissions and
17*35238bceSAndroid Build Coastguard Worker  * limitations under the License.
18*35238bceSAndroid Build Coastguard Worker  *
19*35238bceSAndroid Build Coastguard Worker  *//*!
20*35238bceSAndroid Build Coastguard Worker  * \file
21*35238bceSAndroid Build Coastguard Worker  * \brief Memory object allocation stress tests
22*35238bceSAndroid Build Coastguard Worker  *//*--------------------------------------------------------------------*/
23*35238bceSAndroid Build Coastguard Worker 
24*35238bceSAndroid Build Coastguard Worker #include "teglMemoryStressTests.hpp"
25*35238bceSAndroid Build Coastguard Worker 
26*35238bceSAndroid Build Coastguard Worker #include "tcuTestLog.hpp"
27*35238bceSAndroid Build Coastguard Worker #include "tcuCommandLine.hpp"
28*35238bceSAndroid Build Coastguard Worker 
29*35238bceSAndroid Build Coastguard Worker #include "deRandom.hpp"
30*35238bceSAndroid Build Coastguard Worker #include "deClock.h"
31*35238bceSAndroid Build Coastguard Worker #include "deString.h"
32*35238bceSAndroid Build Coastguard Worker 
33*35238bceSAndroid Build Coastguard Worker #include "gluDefs.hpp"
34*35238bceSAndroid Build Coastguard Worker #include "glwFunctions.hpp"
35*35238bceSAndroid Build Coastguard Worker #include "glwDefs.hpp"
36*35238bceSAndroid Build Coastguard Worker #include "glwEnums.hpp"
37*35238bceSAndroid Build Coastguard Worker 
38*35238bceSAndroid Build Coastguard Worker #include "egluUtil.hpp"
39*35238bceSAndroid Build Coastguard Worker 
40*35238bceSAndroid Build Coastguard Worker #include "eglwLibrary.hpp"
41*35238bceSAndroid Build Coastguard Worker #include "eglwEnums.hpp"
42*35238bceSAndroid Build Coastguard Worker 
43*35238bceSAndroid Build Coastguard Worker #include <vector>
44*35238bceSAndroid Build Coastguard Worker #include <string>
45*35238bceSAndroid Build Coastguard Worker 
46*35238bceSAndroid Build Coastguard Worker using std::string;
47*35238bceSAndroid Build Coastguard Worker using std::vector;
48*35238bceSAndroid Build Coastguard Worker using tcu::TestLog;
49*35238bceSAndroid Build Coastguard Worker 
50*35238bceSAndroid Build Coastguard Worker using namespace eglw;
51*35238bceSAndroid Build Coastguard Worker 
52*35238bceSAndroid Build Coastguard Worker namespace deqp
53*35238bceSAndroid Build Coastguard Worker {
54*35238bceSAndroid Build Coastguard Worker namespace egl
55*35238bceSAndroid Build Coastguard Worker {
56*35238bceSAndroid Build Coastguard Worker 
57*35238bceSAndroid Build Coastguard Worker namespace
58*35238bceSAndroid Build Coastguard Worker {
59*35238bceSAndroid Build Coastguard Worker 
60*35238bceSAndroid Build Coastguard Worker enum ObjectType
61*35238bceSAndroid Build Coastguard Worker {
62*35238bceSAndroid Build Coastguard Worker     OBJECTTYPE_PBUFFER = (1 << 0),
63*35238bceSAndroid Build Coastguard Worker     OBJECTTYPE_CONTEXT = (1 << 1),
64*35238bceSAndroid Build Coastguard Worker 
65*35238bceSAndroid Build Coastguard Worker     //    OBJECTTYPE_WINDOW,
66*35238bceSAndroid Build Coastguard Worker     //    OBJECTTYPE_PIXMAP,
67*35238bceSAndroid Build Coastguard Worker };
68*35238bceSAndroid Build Coastguard Worker 
69*35238bceSAndroid Build Coastguard Worker class MemoryAllocator
70*35238bceSAndroid Build Coastguard Worker {
71*35238bceSAndroid Build Coastguard Worker public:
72*35238bceSAndroid Build Coastguard Worker     MemoryAllocator(EglTestContext &eglTestCtx, EGLDisplay display, EGLConfig config, int seed, ObjectType types,
73*35238bceSAndroid Build Coastguard Worker                     int minWidth, int minHeight, int maxWidth, int maxHeight, bool use);
74*35238bceSAndroid Build Coastguard Worker     ~MemoryAllocator(void);
75*35238bceSAndroid Build Coastguard Worker 
76*35238bceSAndroid Build Coastguard Worker     bool allocateUntilFailure(void);
getAllocationCount(void) const77*35238bceSAndroid Build Coastguard Worker     int getAllocationCount(void) const
78*35238bceSAndroid Build Coastguard Worker     {
79*35238bceSAndroid Build Coastguard Worker         return (int)(m_pbuffers.size() + m_contexts.size());
80*35238bceSAndroid Build Coastguard Worker     }
getContextCount(void) const81*35238bceSAndroid Build Coastguard Worker     int getContextCount(void) const
82*35238bceSAndroid Build Coastguard Worker     {
83*35238bceSAndroid Build Coastguard Worker         return (int)m_contexts.size();
84*35238bceSAndroid Build Coastguard Worker     }
getPBufferCount(void) const85*35238bceSAndroid Build Coastguard Worker     int getPBufferCount(void) const
86*35238bceSAndroid Build Coastguard Worker     {
87*35238bceSAndroid Build Coastguard Worker         return (int)m_pbuffers.size();
88*35238bceSAndroid Build Coastguard Worker     }
getErrorString(void) const89*35238bceSAndroid Build Coastguard Worker     const string &getErrorString(void) const
90*35238bceSAndroid Build Coastguard Worker     {
91*35238bceSAndroid Build Coastguard Worker         return m_errorString;
92*35238bceSAndroid Build Coastguard Worker     }
93*35238bceSAndroid Build Coastguard Worker 
94*35238bceSAndroid Build Coastguard Worker private:
95*35238bceSAndroid Build Coastguard Worker     void allocatePBuffer(void);
96*35238bceSAndroid Build Coastguard Worker     void allocateContext(void);
97*35238bceSAndroid Build Coastguard Worker 
98*35238bceSAndroid Build Coastguard Worker     EglTestContext &m_eglTestCtx;
99*35238bceSAndroid Build Coastguard Worker     EGLDisplay m_display;
100*35238bceSAndroid Build Coastguard Worker     EGLConfig m_config;
101*35238bceSAndroid Build Coastguard Worker     glw::Functions m_gl;
102*35238bceSAndroid Build Coastguard Worker 
103*35238bceSAndroid Build Coastguard Worker     de::Random m_rnd;
104*35238bceSAndroid Build Coastguard Worker     bool m_failed;
105*35238bceSAndroid Build Coastguard Worker     string m_errorString;
106*35238bceSAndroid Build Coastguard Worker 
107*35238bceSAndroid Build Coastguard Worker     ObjectType m_types;
108*35238bceSAndroid Build Coastguard Worker     int m_minWidth;
109*35238bceSAndroid Build Coastguard Worker     int m_minHeight;
110*35238bceSAndroid Build Coastguard Worker     int m_maxWidth;
111*35238bceSAndroid Build Coastguard Worker     int m_maxHeight;
112*35238bceSAndroid Build Coastguard Worker     bool m_use;
113*35238bceSAndroid Build Coastguard Worker 
114*35238bceSAndroid Build Coastguard Worker     vector<EGLSurface> m_pbuffers;
115*35238bceSAndroid Build Coastguard Worker     vector<EGLContext> m_contexts;
116*35238bceSAndroid Build Coastguard Worker };
117*35238bceSAndroid Build Coastguard Worker 
MemoryAllocator(EglTestContext & eglTestCtx,EGLDisplay display,EGLConfig config,int seed,ObjectType types,int minWidth,int minHeight,int maxWidth,int maxHeight,bool use)118*35238bceSAndroid Build Coastguard Worker MemoryAllocator::MemoryAllocator(EglTestContext &eglTestCtx, EGLDisplay display, EGLConfig config, int seed,
119*35238bceSAndroid Build Coastguard Worker                                  ObjectType types, int minWidth, int minHeight, int maxWidth, int maxHeight, bool use)
120*35238bceSAndroid Build Coastguard Worker     : m_eglTestCtx(eglTestCtx)
121*35238bceSAndroid Build Coastguard Worker     , m_display(display)
122*35238bceSAndroid Build Coastguard Worker     , m_config(config)
123*35238bceSAndroid Build Coastguard Worker 
124*35238bceSAndroid Build Coastguard Worker     , m_rnd(seed)
125*35238bceSAndroid Build Coastguard Worker     , m_failed(false)
126*35238bceSAndroid Build Coastguard Worker 
127*35238bceSAndroid Build Coastguard Worker     , m_types(types)
128*35238bceSAndroid Build Coastguard Worker     , m_minWidth(minWidth)
129*35238bceSAndroid Build Coastguard Worker     , m_minHeight(minHeight)
130*35238bceSAndroid Build Coastguard Worker     , m_maxWidth(maxWidth)
131*35238bceSAndroid Build Coastguard Worker     , m_maxHeight(maxHeight)
132*35238bceSAndroid Build Coastguard Worker     , m_use(use)
133*35238bceSAndroid Build Coastguard Worker {
134*35238bceSAndroid Build Coastguard Worker     m_eglTestCtx.initGLFunctions(&m_gl, glu::ApiType::es(2, 0));
135*35238bceSAndroid Build Coastguard Worker }
136*35238bceSAndroid Build Coastguard Worker 
~MemoryAllocator(void)137*35238bceSAndroid Build Coastguard Worker MemoryAllocator::~MemoryAllocator(void)
138*35238bceSAndroid Build Coastguard Worker {
139*35238bceSAndroid Build Coastguard Worker     const Library &egl = m_eglTestCtx.getLibrary();
140*35238bceSAndroid Build Coastguard Worker 
141*35238bceSAndroid Build Coastguard Worker     for (vector<EGLSurface>::const_iterator iter = m_pbuffers.begin(); iter != m_pbuffers.end(); ++iter)
142*35238bceSAndroid Build Coastguard Worker         egl.destroySurface(m_display, *iter);
143*35238bceSAndroid Build Coastguard Worker 
144*35238bceSAndroid Build Coastguard Worker     m_pbuffers.clear();
145*35238bceSAndroid Build Coastguard Worker 
146*35238bceSAndroid Build Coastguard Worker     for (vector<EGLContext>::const_iterator iter = m_contexts.begin(); iter != m_contexts.end(); ++iter)
147*35238bceSAndroid Build Coastguard Worker         egl.destroyContext(m_display, *iter);
148*35238bceSAndroid Build Coastguard Worker 
149*35238bceSAndroid Build Coastguard Worker     m_contexts.clear();
150*35238bceSAndroid Build Coastguard Worker }
151*35238bceSAndroid Build Coastguard Worker 
allocateUntilFailure(void)152*35238bceSAndroid Build Coastguard Worker bool MemoryAllocator::allocateUntilFailure(void)
153*35238bceSAndroid Build Coastguard Worker {
154*35238bceSAndroid Build Coastguard Worker     const uint64_t timeLimitUs = 10000000; // 10s
155*35238bceSAndroid Build Coastguard Worker     uint64_t beginTimeUs       = deGetMicroseconds();
156*35238bceSAndroid Build Coastguard Worker     vector<ObjectType> types;
157*35238bceSAndroid Build Coastguard Worker 
158*35238bceSAndroid Build Coastguard Worker     if ((m_types & OBJECTTYPE_CONTEXT) != 0)
159*35238bceSAndroid Build Coastguard Worker         types.push_back(OBJECTTYPE_CONTEXT);
160*35238bceSAndroid Build Coastguard Worker 
161*35238bceSAndroid Build Coastguard Worker     if ((m_types & OBJECTTYPE_PBUFFER) != 0)
162*35238bceSAndroid Build Coastguard Worker         types.push_back(OBJECTTYPE_PBUFFER);
163*35238bceSAndroid Build Coastguard Worker 
164*35238bceSAndroid Build Coastguard Worker     // If objects should be used. Create one of both at beginning to allow using them.
165*35238bceSAndroid Build Coastguard Worker     if (m_contexts.size() == 0 && m_pbuffers.size() == 0 && m_use)
166*35238bceSAndroid Build Coastguard Worker     {
167*35238bceSAndroid Build Coastguard Worker         allocateContext();
168*35238bceSAndroid Build Coastguard Worker         allocatePBuffer();
169*35238bceSAndroid Build Coastguard Worker     }
170*35238bceSAndroid Build Coastguard Worker 
171*35238bceSAndroid Build Coastguard Worker     while (!m_failed)
172*35238bceSAndroid Build Coastguard Worker     {
173*35238bceSAndroid Build Coastguard Worker         ObjectType type = m_rnd.choose<ObjectType>(types.begin(), types.end());
174*35238bceSAndroid Build Coastguard Worker 
175*35238bceSAndroid Build Coastguard Worker         switch (type)
176*35238bceSAndroid Build Coastguard Worker         {
177*35238bceSAndroid Build Coastguard Worker         case OBJECTTYPE_PBUFFER:
178*35238bceSAndroid Build Coastguard Worker             allocatePBuffer();
179*35238bceSAndroid Build Coastguard Worker             break;
180*35238bceSAndroid Build Coastguard Worker 
181*35238bceSAndroid Build Coastguard Worker         case OBJECTTYPE_CONTEXT:
182*35238bceSAndroid Build Coastguard Worker             allocateContext();
183*35238bceSAndroid Build Coastguard Worker             break;
184*35238bceSAndroid Build Coastguard Worker 
185*35238bceSAndroid Build Coastguard Worker         default:
186*35238bceSAndroid Build Coastguard Worker             DE_ASSERT(false);
187*35238bceSAndroid Build Coastguard Worker         }
188*35238bceSAndroid Build Coastguard Worker 
189*35238bceSAndroid Build Coastguard Worker         if (deGetMicroseconds() - beginTimeUs > timeLimitUs)
190*35238bceSAndroid Build Coastguard Worker             return true;
191*35238bceSAndroid Build Coastguard Worker     }
192*35238bceSAndroid Build Coastguard Worker 
193*35238bceSAndroid Build Coastguard Worker     return false;
194*35238bceSAndroid Build Coastguard Worker }
195*35238bceSAndroid Build Coastguard Worker 
allocatePBuffer(void)196*35238bceSAndroid Build Coastguard Worker void MemoryAllocator::allocatePBuffer(void)
197*35238bceSAndroid Build Coastguard Worker {
198*35238bceSAndroid Build Coastguard Worker     // Reserve space for new allocations
199*35238bceSAndroid Build Coastguard Worker     try
200*35238bceSAndroid Build Coastguard Worker     {
201*35238bceSAndroid Build Coastguard Worker         m_pbuffers.reserve(m_pbuffers.size() + 1);
202*35238bceSAndroid Build Coastguard Worker     }
203*35238bceSAndroid Build Coastguard Worker     catch (const std::bad_alloc &)
204*35238bceSAndroid Build Coastguard Worker     {
205*35238bceSAndroid Build Coastguard Worker         m_errorString = "std::bad_alloc when allocating more space for testcase. Out of host memory.";
206*35238bceSAndroid Build Coastguard Worker         m_failed      = true;
207*35238bceSAndroid Build Coastguard Worker         return;
208*35238bceSAndroid Build Coastguard Worker     }
209*35238bceSAndroid Build Coastguard Worker 
210*35238bceSAndroid Build Coastguard Worker     // Allocate pbuffer
211*35238bceSAndroid Build Coastguard Worker     try
212*35238bceSAndroid Build Coastguard Worker     {
213*35238bceSAndroid Build Coastguard Worker         const Library &egl        = m_eglTestCtx.getLibrary();
214*35238bceSAndroid Build Coastguard Worker         const EGLint width        = m_rnd.getInt(m_minWidth, m_maxWidth);
215*35238bceSAndroid Build Coastguard Worker         const EGLint height       = m_rnd.getInt(m_minHeight, m_maxHeight);
216*35238bceSAndroid Build Coastguard Worker         const EGLint attribList[] = {EGL_WIDTH, width, EGL_HEIGHT, height, EGL_NONE};
217*35238bceSAndroid Build Coastguard Worker 
218*35238bceSAndroid Build Coastguard Worker         EGLSurface surface = egl.createPbufferSurface(m_display, m_config, attribList);
219*35238bceSAndroid Build Coastguard Worker         EGLU_CHECK_MSG(egl, "eglCreatePbufferSurface");
220*35238bceSAndroid Build Coastguard Worker 
221*35238bceSAndroid Build Coastguard Worker         DE_ASSERT(surface != EGL_NO_SURFACE);
222*35238bceSAndroid Build Coastguard Worker 
223*35238bceSAndroid Build Coastguard Worker         m_pbuffers.push_back(surface);
224*35238bceSAndroid Build Coastguard Worker 
225*35238bceSAndroid Build Coastguard Worker         if (m_use && m_contexts.size() > 0)
226*35238bceSAndroid Build Coastguard Worker         {
227*35238bceSAndroid Build Coastguard Worker             EGLContext context = m_rnd.choose<EGLContext>(m_contexts.begin(), m_contexts.end());
228*35238bceSAndroid Build Coastguard Worker             const float red    = m_rnd.getFloat();
229*35238bceSAndroid Build Coastguard Worker             const float green  = m_rnd.getFloat();
230*35238bceSAndroid Build Coastguard Worker             const float blue   = m_rnd.getFloat();
231*35238bceSAndroid Build Coastguard Worker             const float alpha  = m_rnd.getFloat();
232*35238bceSAndroid Build Coastguard Worker 
233*35238bceSAndroid Build Coastguard Worker             EGLU_CHECK_CALL(egl, makeCurrent(m_display, surface, surface, context));
234*35238bceSAndroid Build Coastguard Worker 
235*35238bceSAndroid Build Coastguard Worker             m_gl.clearColor(red, green, blue, alpha);
236*35238bceSAndroid Build Coastguard Worker             GLU_EXPECT_NO_ERROR(m_gl.getError(), "glClearColor()");
237*35238bceSAndroid Build Coastguard Worker 
238*35238bceSAndroid Build Coastguard Worker             m_gl.clear(GL_COLOR_BUFFER_BIT);
239*35238bceSAndroid Build Coastguard Worker             GLU_EXPECT_NO_ERROR(m_gl.getError(), "glClear()");
240*35238bceSAndroid Build Coastguard Worker 
241*35238bceSAndroid Build Coastguard Worker             EGLU_CHECK_CALL(egl, makeCurrent(m_display, EGL_NO_SURFACE, EGL_NO_SURFACE, EGL_NO_CONTEXT));
242*35238bceSAndroid Build Coastguard Worker         }
243*35238bceSAndroid Build Coastguard Worker     }
244*35238bceSAndroid Build Coastguard Worker     catch (const eglu::Error &error)
245*35238bceSAndroid Build Coastguard Worker     {
246*35238bceSAndroid Build Coastguard Worker         if (error.getError() == EGL_BAD_ALLOC)
247*35238bceSAndroid Build Coastguard Worker         {
248*35238bceSAndroid Build Coastguard Worker             m_errorString = "eglCreatePbufferSurface returned EGL_BAD_ALLOC";
249*35238bceSAndroid Build Coastguard Worker             m_failed      = true;
250*35238bceSAndroid Build Coastguard Worker             return;
251*35238bceSAndroid Build Coastguard Worker         }
252*35238bceSAndroid Build Coastguard Worker         else
253*35238bceSAndroid Build Coastguard Worker             throw;
254*35238bceSAndroid Build Coastguard Worker     }
255*35238bceSAndroid Build Coastguard Worker }
256*35238bceSAndroid Build Coastguard Worker 
allocateContext(void)257*35238bceSAndroid Build Coastguard Worker void MemoryAllocator::allocateContext(void)
258*35238bceSAndroid Build Coastguard Worker {
259*35238bceSAndroid Build Coastguard Worker     // Reserve space for new allocations
260*35238bceSAndroid Build Coastguard Worker     try
261*35238bceSAndroid Build Coastguard Worker     {
262*35238bceSAndroid Build Coastguard Worker         m_contexts.reserve(m_contexts.size() + 1);
263*35238bceSAndroid Build Coastguard Worker     }
264*35238bceSAndroid Build Coastguard Worker     catch (const std::bad_alloc &)
265*35238bceSAndroid Build Coastguard Worker     {
266*35238bceSAndroid Build Coastguard Worker         m_errorString = "std::bad_alloc when allocating more space for testcase. Out of host memory.";
267*35238bceSAndroid Build Coastguard Worker         m_failed      = true;
268*35238bceSAndroid Build Coastguard Worker         return;
269*35238bceSAndroid Build Coastguard Worker     }
270*35238bceSAndroid Build Coastguard Worker 
271*35238bceSAndroid Build Coastguard Worker     // Allocate context
272*35238bceSAndroid Build Coastguard Worker     try
273*35238bceSAndroid Build Coastguard Worker     {
274*35238bceSAndroid Build Coastguard Worker         const Library &egl        = m_eglTestCtx.getLibrary();
275*35238bceSAndroid Build Coastguard Worker         const EGLint attribList[] = {EGL_CONTEXT_CLIENT_VERSION, 2, EGL_NONE};
276*35238bceSAndroid Build Coastguard Worker 
277*35238bceSAndroid Build Coastguard Worker         EGLU_CHECK_CALL(egl, bindAPI(EGL_OPENGL_ES_API));
278*35238bceSAndroid Build Coastguard Worker         EGLContext context = egl.createContext(m_display, m_config, EGL_NO_CONTEXT, attribList);
279*35238bceSAndroid Build Coastguard Worker         EGLU_CHECK_MSG(egl, "eglCreateContext");
280*35238bceSAndroid Build Coastguard Worker 
281*35238bceSAndroid Build Coastguard Worker         DE_ASSERT(context != EGL_NO_CONTEXT);
282*35238bceSAndroid Build Coastguard Worker 
283*35238bceSAndroid Build Coastguard Worker         m_contexts.push_back(context);
284*35238bceSAndroid Build Coastguard Worker 
285*35238bceSAndroid Build Coastguard Worker         if (m_use && m_pbuffers.size() > 0)
286*35238bceSAndroid Build Coastguard Worker         {
287*35238bceSAndroid Build Coastguard Worker             EGLSurface surface = m_rnd.choose<EGLSurface>(m_pbuffers.begin(), m_pbuffers.end());
288*35238bceSAndroid Build Coastguard Worker             const float red    = m_rnd.getFloat();
289*35238bceSAndroid Build Coastguard Worker             const float green  = m_rnd.getFloat();
290*35238bceSAndroid Build Coastguard Worker             const float blue   = m_rnd.getFloat();
291*35238bceSAndroid Build Coastguard Worker             const float alpha  = m_rnd.getFloat();
292*35238bceSAndroid Build Coastguard Worker 
293*35238bceSAndroid Build Coastguard Worker             EGLU_CHECK_CALL(egl, makeCurrent(m_display, surface, surface, context));
294*35238bceSAndroid Build Coastguard Worker 
295*35238bceSAndroid Build Coastguard Worker             m_gl.clearColor(red, green, blue, alpha);
296*35238bceSAndroid Build Coastguard Worker             GLU_EXPECT_NO_ERROR(m_gl.getError(), "glClearColor()");
297*35238bceSAndroid Build Coastguard Worker 
298*35238bceSAndroid Build Coastguard Worker             m_gl.clear(GL_COLOR_BUFFER_BIT);
299*35238bceSAndroid Build Coastguard Worker             GLU_EXPECT_NO_ERROR(m_gl.getError(), "glClear()");
300*35238bceSAndroid Build Coastguard Worker 
301*35238bceSAndroid Build Coastguard Worker             EGLU_CHECK_CALL(egl, makeCurrent(m_display, EGL_NO_SURFACE, EGL_NO_SURFACE, EGL_NO_CONTEXT));
302*35238bceSAndroid Build Coastguard Worker         }
303*35238bceSAndroid Build Coastguard Worker     }
304*35238bceSAndroid Build Coastguard Worker     catch (const eglu::Error &error)
305*35238bceSAndroid Build Coastguard Worker     {
306*35238bceSAndroid Build Coastguard Worker         if (error.getError() == EGL_BAD_ALLOC)
307*35238bceSAndroid Build Coastguard Worker         {
308*35238bceSAndroid Build Coastguard Worker             m_errorString = "eglCreateContext returned EGL_BAD_ALLOC";
309*35238bceSAndroid Build Coastguard Worker             m_failed      = true;
310*35238bceSAndroid Build Coastguard Worker             return;
311*35238bceSAndroid Build Coastguard Worker         }
312*35238bceSAndroid Build Coastguard Worker         else
313*35238bceSAndroid Build Coastguard Worker             throw;
314*35238bceSAndroid Build Coastguard Worker     }
315*35238bceSAndroid Build Coastguard Worker }
316*35238bceSAndroid Build Coastguard Worker 
317*35238bceSAndroid Build Coastguard Worker } // namespace
318*35238bceSAndroid Build Coastguard Worker 
319*35238bceSAndroid Build Coastguard Worker class MemoryStressCase : public TestCase
320*35238bceSAndroid Build Coastguard Worker {
321*35238bceSAndroid Build Coastguard Worker public:
322*35238bceSAndroid Build Coastguard Worker     struct Spec
323*35238bceSAndroid Build Coastguard Worker     {
324*35238bceSAndroid Build Coastguard Worker         ObjectType types;
325*35238bceSAndroid Build Coastguard Worker         int minWidth;
326*35238bceSAndroid Build Coastguard Worker         int minHeight;
327*35238bceSAndroid Build Coastguard Worker         int maxWidth;
328*35238bceSAndroid Build Coastguard Worker         int maxHeight;
329*35238bceSAndroid Build Coastguard Worker         bool use;
330*35238bceSAndroid Build Coastguard Worker     };
331*35238bceSAndroid Build Coastguard Worker 
332*35238bceSAndroid Build Coastguard Worker     MemoryStressCase(EglTestContext &eglTestCtx, Spec spec, const char *name, const char *description);
333*35238bceSAndroid Build Coastguard Worker     void init(void);
334*35238bceSAndroid Build Coastguard Worker     void deinit(void);
335*35238bceSAndroid Build Coastguard Worker     IterateResult iterate(void);
336*35238bceSAndroid Build Coastguard Worker 
337*35238bceSAndroid Build Coastguard Worker private:
338*35238bceSAndroid Build Coastguard Worker     Spec m_spec;
339*35238bceSAndroid Build Coastguard Worker     vector<int> m_allocationCounts;
340*35238bceSAndroid Build Coastguard Worker     MemoryAllocator *m_allocator;
341*35238bceSAndroid Build Coastguard Worker 
342*35238bceSAndroid Build Coastguard Worker     int m_iteration;
343*35238bceSAndroid Build Coastguard Worker     int m_iterationCount;
344*35238bceSAndroid Build Coastguard Worker     int m_seed;
345*35238bceSAndroid Build Coastguard Worker     EGLDisplay m_display;
346*35238bceSAndroid Build Coastguard Worker     EGLConfig m_config;
347*35238bceSAndroid Build Coastguard Worker };
348*35238bceSAndroid Build Coastguard Worker 
MemoryStressCase(EglTestContext & eglTestCtx,Spec spec,const char * name,const char * description)349*35238bceSAndroid Build Coastguard Worker MemoryStressCase::MemoryStressCase(EglTestContext &eglTestCtx, Spec spec, const char *name, const char *description)
350*35238bceSAndroid Build Coastguard Worker     : TestCase(eglTestCtx, name, description)
351*35238bceSAndroid Build Coastguard Worker     , m_spec(spec)
352*35238bceSAndroid Build Coastguard Worker     , m_allocator(NULL)
353*35238bceSAndroid Build Coastguard Worker     , m_iteration(0)
354*35238bceSAndroid Build Coastguard Worker     , m_iterationCount(10)
355*35238bceSAndroid Build Coastguard Worker     , m_seed(deStringHash(name))
356*35238bceSAndroid Build Coastguard Worker     , m_display(EGL_NO_DISPLAY)
357*35238bceSAndroid Build Coastguard Worker     , m_config(DE_NULL)
358*35238bceSAndroid Build Coastguard Worker {
359*35238bceSAndroid Build Coastguard Worker }
360*35238bceSAndroid Build Coastguard Worker 
init(void)361*35238bceSAndroid Build Coastguard Worker void MemoryStressCase::init(void)
362*35238bceSAndroid Build Coastguard Worker {
363*35238bceSAndroid Build Coastguard Worker     const Library &egl        = m_eglTestCtx.getLibrary();
364*35238bceSAndroid Build Coastguard Worker     EGLint configCount        = 0;
365*35238bceSAndroid Build Coastguard Worker     const EGLint attribList[] = {EGL_SURFACE_TYPE, EGL_PBUFFER_BIT, EGL_RENDERABLE_TYPE, EGL_OPENGL_ES2_BIT, EGL_NONE};
366*35238bceSAndroid Build Coastguard Worker 
367*35238bceSAndroid Build Coastguard Worker     if (!m_testCtx.getCommandLine().isOutOfMemoryTestEnabled())
368*35238bceSAndroid Build Coastguard Worker     {
369*35238bceSAndroid Build Coastguard Worker         m_testCtx.getLog()
370*35238bceSAndroid Build Coastguard Worker             << TestLog::Message
371*35238bceSAndroid Build Coastguard Worker             << "Tests that exhaust memory are disabled, use --deqp-test-oom=enable command line option to enable."
372*35238bceSAndroid Build Coastguard Worker             << TestLog::EndMessage;
373*35238bceSAndroid Build Coastguard Worker         throw tcu::NotSupportedError("OOM tests disabled");
374*35238bceSAndroid Build Coastguard Worker     }
375*35238bceSAndroid Build Coastguard Worker 
376*35238bceSAndroid Build Coastguard Worker     m_display = eglu::getAndInitDisplay(m_eglTestCtx.getNativeDisplay());
377*35238bceSAndroid Build Coastguard Worker 
378*35238bceSAndroid Build Coastguard Worker     EGLU_CHECK_CALL(egl, chooseConfig(m_display, attribList, &m_config, 1, &configCount));
379*35238bceSAndroid Build Coastguard Worker 
380*35238bceSAndroid Build Coastguard Worker     TCU_CHECK(configCount != 0);
381*35238bceSAndroid Build Coastguard Worker }
382*35238bceSAndroid Build Coastguard Worker 
deinit(void)383*35238bceSAndroid Build Coastguard Worker void MemoryStressCase::deinit(void)
384*35238bceSAndroid Build Coastguard Worker {
385*35238bceSAndroid Build Coastguard Worker     delete m_allocator;
386*35238bceSAndroid Build Coastguard Worker     m_allocator = DE_NULL;
387*35238bceSAndroid Build Coastguard Worker 
388*35238bceSAndroid Build Coastguard Worker     if (m_display != EGL_NO_DISPLAY)
389*35238bceSAndroid Build Coastguard Worker     {
390*35238bceSAndroid Build Coastguard Worker         m_eglTestCtx.getLibrary().terminate(m_display);
391*35238bceSAndroid Build Coastguard Worker         m_display = EGL_NO_DISPLAY;
392*35238bceSAndroid Build Coastguard Worker     }
393*35238bceSAndroid Build Coastguard Worker }
394*35238bceSAndroid Build Coastguard Worker 
iterate(void)395*35238bceSAndroid Build Coastguard Worker TestCase::IterateResult MemoryStressCase::iterate(void)
396*35238bceSAndroid Build Coastguard Worker {
397*35238bceSAndroid Build Coastguard Worker     TestLog &log = m_testCtx.getLog();
398*35238bceSAndroid Build Coastguard Worker 
399*35238bceSAndroid Build Coastguard Worker     if (m_iteration < m_iterationCount)
400*35238bceSAndroid Build Coastguard Worker     {
401*35238bceSAndroid Build Coastguard Worker         try
402*35238bceSAndroid Build Coastguard Worker         {
403*35238bceSAndroid Build Coastguard Worker             if (!m_allocator)
404*35238bceSAndroid Build Coastguard Worker                 m_allocator =
405*35238bceSAndroid Build Coastguard Worker                     new MemoryAllocator(m_eglTestCtx, m_display, m_config, m_seed, m_spec.types, m_spec.minWidth,
406*35238bceSAndroid Build Coastguard Worker                                         m_spec.minHeight, m_spec.maxWidth, m_spec.maxHeight, m_spec.use);
407*35238bceSAndroid Build Coastguard Worker 
408*35238bceSAndroid Build Coastguard Worker             if (m_allocator->allocateUntilFailure())
409*35238bceSAndroid Build Coastguard Worker             {
410*35238bceSAndroid Build Coastguard Worker                 log << TestLog::Message << "Couldn't exhaust memory before timeout. Allocated "
411*35238bceSAndroid Build Coastguard Worker                     << m_allocator->getAllocationCount() << " objects." << TestLog::EndMessage;
412*35238bceSAndroid Build Coastguard Worker                 m_testCtx.setTestResult(QP_TEST_RESULT_PASS, "Pass");
413*35238bceSAndroid Build Coastguard Worker 
414*35238bceSAndroid Build Coastguard Worker                 delete m_allocator;
415*35238bceSAndroid Build Coastguard Worker                 m_allocator = NULL;
416*35238bceSAndroid Build Coastguard Worker 
417*35238bceSAndroid Build Coastguard Worker                 return STOP;
418*35238bceSAndroid Build Coastguard Worker             }
419*35238bceSAndroid Build Coastguard Worker 
420*35238bceSAndroid Build Coastguard Worker             log << TestLog::Message << "Iteration " << m_iteration << ": Allocated "
421*35238bceSAndroid Build Coastguard Worker                 << m_allocator->getAllocationCount() << " objects; " << m_allocator->getContextCount() << " contexts, "
422*35238bceSAndroid Build Coastguard Worker                 << m_allocator->getPBufferCount() << " PBuffers." << TestLog::EndMessage;
423*35238bceSAndroid Build Coastguard Worker             log << TestLog::Message << "Got expected error: " << m_allocator->getErrorString() << TestLog::EndMessage;
424*35238bceSAndroid Build Coastguard Worker             m_allocationCounts.push_back(m_allocator->getAllocationCount());
425*35238bceSAndroid Build Coastguard Worker 
426*35238bceSAndroid Build Coastguard Worker             delete m_allocator;
427*35238bceSAndroid Build Coastguard Worker             m_allocator = NULL;
428*35238bceSAndroid Build Coastguard Worker 
429*35238bceSAndroid Build Coastguard Worker             m_iteration++;
430*35238bceSAndroid Build Coastguard Worker 
431*35238bceSAndroid Build Coastguard Worker             return CONTINUE;
432*35238bceSAndroid Build Coastguard Worker         }
433*35238bceSAndroid Build Coastguard Worker         catch (...)
434*35238bceSAndroid Build Coastguard Worker         {
435*35238bceSAndroid Build Coastguard Worker             log << TestLog::Message << "Iteration " << m_iteration << ": Allocated "
436*35238bceSAndroid Build Coastguard Worker                 << m_allocator->getAllocationCount() << " objects; " << m_allocator->getContextCount() << " contexts, "
437*35238bceSAndroid Build Coastguard Worker                 << m_allocator->getPBufferCount() << " PBuffers." << TestLog::EndMessage;
438*35238bceSAndroid Build Coastguard Worker             log << TestLog::Message << "Unexpected error" << TestLog::EndMessage;
439*35238bceSAndroid Build Coastguard Worker             throw;
440*35238bceSAndroid Build Coastguard Worker         }
441*35238bceSAndroid Build Coastguard Worker     }
442*35238bceSAndroid Build Coastguard Worker     else
443*35238bceSAndroid Build Coastguard Worker     {
444*35238bceSAndroid Build Coastguard Worker         // Analyze number of passed allocations.
445*35238bceSAndroid Build Coastguard Worker         int min = m_allocationCounts[0];
446*35238bceSAndroid Build Coastguard Worker         int max = m_allocationCounts[0];
447*35238bceSAndroid Build Coastguard Worker 
448*35238bceSAndroid Build Coastguard Worker         float threshold = 50.0f;
449*35238bceSAndroid Build Coastguard Worker 
450*35238bceSAndroid Build Coastguard Worker         for (int allocNdx = 0; allocNdx < (int)m_allocationCounts.size(); allocNdx++)
451*35238bceSAndroid Build Coastguard Worker         {
452*35238bceSAndroid Build Coastguard Worker             min = deMin32(m_allocationCounts[allocNdx], min);
453*35238bceSAndroid Build Coastguard Worker             max = deMax32(m_allocationCounts[allocNdx], max);
454*35238bceSAndroid Build Coastguard Worker         }
455*35238bceSAndroid Build Coastguard Worker 
456*35238bceSAndroid Build Coastguard Worker         if (min == 0 && max != 0)
457*35238bceSAndroid Build Coastguard Worker         {
458*35238bceSAndroid Build Coastguard Worker             log << TestLog::Message << "Allocation count zero" << TestLog::EndMessage;
459*35238bceSAndroid Build Coastguard Worker             m_testCtx.setTestResult(QP_TEST_RESULT_FAIL, "Fail");
460*35238bceSAndroid Build Coastguard Worker         }
461*35238bceSAndroid Build Coastguard Worker         else
462*35238bceSAndroid Build Coastguard Worker         {
463*35238bceSAndroid Build Coastguard Worker             float change = (float)(min - max) / ((float)(max));
464*35238bceSAndroid Build Coastguard Worker 
465*35238bceSAndroid Build Coastguard Worker             if (change > threshold)
466*35238bceSAndroid Build Coastguard Worker             {
467*35238bceSAndroid Build Coastguard Worker                 log << TestLog::Message << "Allocated objects max: " << max << ", min: " << min
468*35238bceSAndroid Build Coastguard Worker                     << ", difference: " << change << "% threshold: " << threshold << "%" << TestLog::EndMessage;
469*35238bceSAndroid Build Coastguard Worker                 m_testCtx.setTestResult(QP_TEST_RESULT_QUALITY_WARNING, "Allocation count variation");
470*35238bceSAndroid Build Coastguard Worker             }
471*35238bceSAndroid Build Coastguard Worker             else
472*35238bceSAndroid Build Coastguard Worker                 m_testCtx.setTestResult(QP_TEST_RESULT_PASS, "Pass");
473*35238bceSAndroid Build Coastguard Worker         }
474*35238bceSAndroid Build Coastguard Worker 
475*35238bceSAndroid Build Coastguard Worker         return STOP;
476*35238bceSAndroid Build Coastguard Worker     }
477*35238bceSAndroid Build Coastguard Worker }
478*35238bceSAndroid Build Coastguard Worker 
MemoryStressTests(EglTestContext & eglTestCtx)479*35238bceSAndroid Build Coastguard Worker MemoryStressTests::MemoryStressTests(EglTestContext &eglTestCtx)
480*35238bceSAndroid Build Coastguard Worker     : TestCaseGroup(eglTestCtx, "memory", "Memory allocation stress tests")
481*35238bceSAndroid Build Coastguard Worker {
482*35238bceSAndroid Build Coastguard Worker }
483*35238bceSAndroid Build Coastguard Worker 
init(void)484*35238bceSAndroid Build Coastguard Worker void MemoryStressTests::init(void)
485*35238bceSAndroid Build Coastguard Worker {
486*35238bceSAndroid Build Coastguard Worker     // Check small pbuffers 256x256
487*35238bceSAndroid Build Coastguard Worker     {
488*35238bceSAndroid Build Coastguard Worker         MemoryStressCase::Spec spec;
489*35238bceSAndroid Build Coastguard Worker 
490*35238bceSAndroid Build Coastguard Worker         spec.types     = OBJECTTYPE_PBUFFER;
491*35238bceSAndroid Build Coastguard Worker         spec.minWidth  = 256;
492*35238bceSAndroid Build Coastguard Worker         spec.minHeight = 256;
493*35238bceSAndroid Build Coastguard Worker         spec.maxWidth  = 256;
494*35238bceSAndroid Build Coastguard Worker         spec.maxHeight = 256;
495*35238bceSAndroid Build Coastguard Worker         spec.use       = false;
496*35238bceSAndroid Build Coastguard Worker 
497*35238bceSAndroid Build Coastguard Worker         addChild(new MemoryStressCase(m_eglTestCtx, spec, "pbuffer_256x256", "PBuffer allocation stress tests"));
498*35238bceSAndroid Build Coastguard Worker     }
499*35238bceSAndroid Build Coastguard Worker 
500*35238bceSAndroid Build Coastguard Worker     // Check small pbuffers 256x256 and use them
501*35238bceSAndroid Build Coastguard Worker     {
502*35238bceSAndroid Build Coastguard Worker         MemoryStressCase::Spec spec;
503*35238bceSAndroid Build Coastguard Worker 
504*35238bceSAndroid Build Coastguard Worker         spec.types     = OBJECTTYPE_PBUFFER;
505*35238bceSAndroid Build Coastguard Worker         spec.minWidth  = 256;
506*35238bceSAndroid Build Coastguard Worker         spec.minHeight = 256;
507*35238bceSAndroid Build Coastguard Worker         spec.maxWidth  = 256;
508*35238bceSAndroid Build Coastguard Worker         spec.maxHeight = 256;
509*35238bceSAndroid Build Coastguard Worker         spec.use       = true;
510*35238bceSAndroid Build Coastguard Worker 
511*35238bceSAndroid Build Coastguard Worker         addChild(new MemoryStressCase(m_eglTestCtx, spec, "pbuffer_256x256_use", "PBuffer allocation stress tests"));
512*35238bceSAndroid Build Coastguard Worker     }
513*35238bceSAndroid Build Coastguard Worker 
514*35238bceSAndroid Build Coastguard Worker     // Check big pbuffers 1024x1024
515*35238bceSAndroid Build Coastguard Worker     {
516*35238bceSAndroid Build Coastguard Worker         MemoryStressCase::Spec spec;
517*35238bceSAndroid Build Coastguard Worker 
518*35238bceSAndroid Build Coastguard Worker         spec.types     = OBJECTTYPE_PBUFFER;
519*35238bceSAndroid Build Coastguard Worker         spec.minWidth  = 1024;
520*35238bceSAndroid Build Coastguard Worker         spec.minHeight = 1024;
521*35238bceSAndroid Build Coastguard Worker         spec.maxWidth  = 1024;
522*35238bceSAndroid Build Coastguard Worker         spec.maxHeight = 1024;
523*35238bceSAndroid Build Coastguard Worker         spec.use       = false;
524*35238bceSAndroid Build Coastguard Worker 
525*35238bceSAndroid Build Coastguard Worker         addChild(new MemoryStressCase(m_eglTestCtx, spec, "pbuffer_1024x1024", "PBuffer allocation stress tests"));
526*35238bceSAndroid Build Coastguard Worker     }
527*35238bceSAndroid Build Coastguard Worker 
528*35238bceSAndroid Build Coastguard Worker     // Check big pbuffers 1024x1024 and use them
529*35238bceSAndroid Build Coastguard Worker     {
530*35238bceSAndroid Build Coastguard Worker         MemoryStressCase::Spec spec;
531*35238bceSAndroid Build Coastguard Worker 
532*35238bceSAndroid Build Coastguard Worker         spec.types     = OBJECTTYPE_PBUFFER;
533*35238bceSAndroid Build Coastguard Worker         spec.minWidth  = 1024;
534*35238bceSAndroid Build Coastguard Worker         spec.minHeight = 1024;
535*35238bceSAndroid Build Coastguard Worker         spec.maxWidth  = 1024;
536*35238bceSAndroid Build Coastguard Worker         spec.maxHeight = 1024;
537*35238bceSAndroid Build Coastguard Worker         spec.use       = true;
538*35238bceSAndroid Build Coastguard Worker 
539*35238bceSAndroid Build Coastguard Worker         addChild(new MemoryStressCase(m_eglTestCtx, spec, "pbuffer_1024x1024_use", "PBuffer allocation stress tests"));
540*35238bceSAndroid Build Coastguard Worker     }
541*35238bceSAndroid Build Coastguard Worker 
542*35238bceSAndroid Build Coastguard Worker     // Check different sized pbuffers
543*35238bceSAndroid Build Coastguard Worker     {
544*35238bceSAndroid Build Coastguard Worker         MemoryStressCase::Spec spec;
545*35238bceSAndroid Build Coastguard Worker 
546*35238bceSAndroid Build Coastguard Worker         spec.types     = OBJECTTYPE_PBUFFER;
547*35238bceSAndroid Build Coastguard Worker         spec.minWidth  = 64;
548*35238bceSAndroid Build Coastguard Worker         spec.minHeight = 64;
549*35238bceSAndroid Build Coastguard Worker         spec.maxWidth  = 1024;
550*35238bceSAndroid Build Coastguard Worker         spec.maxHeight = 1024;
551*35238bceSAndroid Build Coastguard Worker         spec.use       = false;
552*35238bceSAndroid Build Coastguard Worker 
553*35238bceSAndroid Build Coastguard Worker         addChild(new MemoryStressCase(m_eglTestCtx, spec, "pbuffer", "PBuffer allocation stress tests"));
554*35238bceSAndroid Build Coastguard Worker     }
555*35238bceSAndroid Build Coastguard Worker 
556*35238bceSAndroid Build Coastguard Worker     // Check different sized pbuffers and use them
557*35238bceSAndroid Build Coastguard Worker     {
558*35238bceSAndroid Build Coastguard Worker         MemoryStressCase::Spec spec;
559*35238bceSAndroid Build Coastguard Worker 
560*35238bceSAndroid Build Coastguard Worker         spec.types     = OBJECTTYPE_PBUFFER;
561*35238bceSAndroid Build Coastguard Worker         spec.minWidth  = 64;
562*35238bceSAndroid Build Coastguard Worker         spec.minHeight = 64;
563*35238bceSAndroid Build Coastguard Worker         spec.maxWidth  = 1024;
564*35238bceSAndroid Build Coastguard Worker         spec.maxHeight = 1024;
565*35238bceSAndroid Build Coastguard Worker         spec.use       = true;
566*35238bceSAndroid Build Coastguard Worker 
567*35238bceSAndroid Build Coastguard Worker         addChild(new MemoryStressCase(m_eglTestCtx, spec, "pbuffer_use", "PBuffer allocation stress tests"));
568*35238bceSAndroid Build Coastguard Worker     }
569*35238bceSAndroid Build Coastguard Worker 
570*35238bceSAndroid Build Coastguard Worker     // Check contexts
571*35238bceSAndroid Build Coastguard Worker     {
572*35238bceSAndroid Build Coastguard Worker         MemoryStressCase::Spec spec;
573*35238bceSAndroid Build Coastguard Worker 
574*35238bceSAndroid Build Coastguard Worker         spec.types     = OBJECTTYPE_CONTEXT;
575*35238bceSAndroid Build Coastguard Worker         spec.minWidth  = 1024;
576*35238bceSAndroid Build Coastguard Worker         spec.minHeight = 1024;
577*35238bceSAndroid Build Coastguard Worker         spec.maxWidth  = 1024;
578*35238bceSAndroid Build Coastguard Worker         spec.maxHeight = 1024;
579*35238bceSAndroid Build Coastguard Worker         spec.use       = false;
580*35238bceSAndroid Build Coastguard Worker 
581*35238bceSAndroid Build Coastguard Worker         addChild(new MemoryStressCase(m_eglTestCtx, spec, "context", "Context allocation stress tests"));
582*35238bceSAndroid Build Coastguard Worker     }
583*35238bceSAndroid Build Coastguard Worker 
584*35238bceSAndroid Build Coastguard Worker     // Check contexts and use them
585*35238bceSAndroid Build Coastguard Worker     {
586*35238bceSAndroid Build Coastguard Worker         MemoryStressCase::Spec spec;
587*35238bceSAndroid Build Coastguard Worker 
588*35238bceSAndroid Build Coastguard Worker         spec.types     = OBJECTTYPE_CONTEXT;
589*35238bceSAndroid Build Coastguard Worker         spec.minWidth  = 1024;
590*35238bceSAndroid Build Coastguard Worker         spec.minHeight = 1024;
591*35238bceSAndroid Build Coastguard Worker         spec.maxWidth  = 1024;
592*35238bceSAndroid Build Coastguard Worker         spec.maxHeight = 1024;
593*35238bceSAndroid Build Coastguard Worker         spec.use       = true;
594*35238bceSAndroid Build Coastguard Worker 
595*35238bceSAndroid Build Coastguard Worker         addChild(new MemoryStressCase(m_eglTestCtx, spec, "context_use", "Context allocation stress tests"));
596*35238bceSAndroid Build Coastguard Worker     }
597*35238bceSAndroid Build Coastguard Worker 
598*35238bceSAndroid Build Coastguard Worker     // Check contexts and pbuffers
599*35238bceSAndroid Build Coastguard Worker     {
600*35238bceSAndroid Build Coastguard Worker         MemoryStressCase::Spec spec;
601*35238bceSAndroid Build Coastguard Worker 
602*35238bceSAndroid Build Coastguard Worker         spec.types     = (ObjectType)(OBJECTTYPE_PBUFFER | OBJECTTYPE_CONTEXT);
603*35238bceSAndroid Build Coastguard Worker         spec.minWidth  = 64;
604*35238bceSAndroid Build Coastguard Worker         spec.minHeight = 64;
605*35238bceSAndroid Build Coastguard Worker         spec.maxWidth  = 1024;
606*35238bceSAndroid Build Coastguard Worker         spec.maxHeight = 1024;
607*35238bceSAndroid Build Coastguard Worker         spec.use       = false;
608*35238bceSAndroid Build Coastguard Worker 
609*35238bceSAndroid Build Coastguard Worker         addChild(
610*35238bceSAndroid Build Coastguard Worker             new MemoryStressCase(m_eglTestCtx, spec, "pbuffer_context", "PBuffer and context allocation stress tests"));
611*35238bceSAndroid Build Coastguard Worker     }
612*35238bceSAndroid Build Coastguard Worker 
613*35238bceSAndroid Build Coastguard Worker     // Check contexts and pbuffers and use
614*35238bceSAndroid Build Coastguard Worker     {
615*35238bceSAndroid Build Coastguard Worker         MemoryStressCase::Spec spec;
616*35238bceSAndroid Build Coastguard Worker 
617*35238bceSAndroid Build Coastguard Worker         spec.types     = (ObjectType)(OBJECTTYPE_PBUFFER | OBJECTTYPE_CONTEXT);
618*35238bceSAndroid Build Coastguard Worker         spec.minWidth  = 64;
619*35238bceSAndroid Build Coastguard Worker         spec.minHeight = 64;
620*35238bceSAndroid Build Coastguard Worker         spec.maxWidth  = 1024;
621*35238bceSAndroid Build Coastguard Worker         spec.maxHeight = 1024;
622*35238bceSAndroid Build Coastguard Worker         spec.use       = true;
623*35238bceSAndroid Build Coastguard Worker 
624*35238bceSAndroid Build Coastguard Worker         addChild(new MemoryStressCase(m_eglTestCtx, spec, "pbuffer_context_use",
625*35238bceSAndroid Build Coastguard Worker                                       "PBuffer and context allocation stress tests"));
626*35238bceSAndroid Build Coastguard Worker     }
627*35238bceSAndroid Build Coastguard Worker }
628*35238bceSAndroid Build Coastguard Worker 
629*35238bceSAndroid Build Coastguard Worker } // namespace egl
630*35238bceSAndroid Build Coastguard Worker } // namespace deqp
631