xref: /aosp_15_r20/external/deqp/modules/egl/teglGLES2SharingThreadedTests.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 EGL gles2 sharing threaded tests
22*35238bceSAndroid Build Coastguard Worker  *//*--------------------------------------------------------------------*/
23*35238bceSAndroid Build Coastguard Worker 
24*35238bceSAndroid Build Coastguard Worker #include "teglGLES2SharingThreadedTests.hpp"
25*35238bceSAndroid Build Coastguard Worker 
26*35238bceSAndroid Build Coastguard Worker #include "tcuTestLog.hpp"
27*35238bceSAndroid Build Coastguard Worker #include "tcuThreadUtil.hpp"
28*35238bceSAndroid Build Coastguard Worker 
29*35238bceSAndroid Build Coastguard Worker #include "deRandom.hpp"
30*35238bceSAndroid Build Coastguard Worker #include "deThread.hpp"
31*35238bceSAndroid Build Coastguard Worker #include "deSharedPtr.hpp"
32*35238bceSAndroid Build Coastguard Worker #include "deMutex.hpp"
33*35238bceSAndroid Build Coastguard Worker #include "deSemaphore.hpp"
34*35238bceSAndroid Build Coastguard Worker #include "deStringUtil.hpp"
35*35238bceSAndroid Build Coastguard Worker 
36*35238bceSAndroid Build Coastguard Worker #include "deClock.h"
37*35238bceSAndroid Build Coastguard Worker #include "deString.h"
38*35238bceSAndroid Build Coastguard Worker #include "deMemory.h"
39*35238bceSAndroid Build Coastguard Worker #include "deMath.h"
40*35238bceSAndroid Build Coastguard Worker 
41*35238bceSAndroid Build Coastguard Worker #include "gluDefs.hpp"
42*35238bceSAndroid Build Coastguard Worker 
43*35238bceSAndroid Build Coastguard Worker #include "glwEnums.hpp"
44*35238bceSAndroid Build Coastguard Worker #include "glwFunctions.hpp"
45*35238bceSAndroid Build Coastguard Worker 
46*35238bceSAndroid Build Coastguard Worker #include "egluUtil.hpp"
47*35238bceSAndroid Build Coastguard Worker 
48*35238bceSAndroid Build Coastguard Worker #include "eglwLibrary.hpp"
49*35238bceSAndroid Build Coastguard Worker #include "eglwEnums.hpp"
50*35238bceSAndroid Build Coastguard Worker 
51*35238bceSAndroid Build Coastguard Worker #include <vector>
52*35238bceSAndroid Build Coastguard Worker #include <string>
53*35238bceSAndroid Build Coastguard Worker #include <memory>
54*35238bceSAndroid Build Coastguard Worker #include <sstream>
55*35238bceSAndroid Build Coastguard Worker 
56*35238bceSAndroid Build Coastguard Worker using de::SharedPtr;
57*35238bceSAndroid Build Coastguard Worker using std::string;
58*35238bceSAndroid Build Coastguard Worker using std::vector;
59*35238bceSAndroid Build Coastguard Worker 
60*35238bceSAndroid Build Coastguard Worker using namespace glw;
61*35238bceSAndroid Build Coastguard Worker using namespace eglw;
62*35238bceSAndroid Build Coastguard Worker 
63*35238bceSAndroid Build Coastguard Worker namespace deqp
64*35238bceSAndroid Build Coastguard Worker {
65*35238bceSAndroid Build Coastguard Worker namespace egl
66*35238bceSAndroid Build Coastguard Worker {
67*35238bceSAndroid Build Coastguard Worker 
68*35238bceSAndroid Build Coastguard Worker namespace GLES2ThreadTest
69*35238bceSAndroid Build Coastguard Worker {
70*35238bceSAndroid Build Coastguard Worker 
71*35238bceSAndroid Build Coastguard Worker class Texture;
72*35238bceSAndroid Build Coastguard Worker class Buffer;
73*35238bceSAndroid Build Coastguard Worker class Shader;
74*35238bceSAndroid Build Coastguard Worker class Program;
75*35238bceSAndroid Build Coastguard Worker class GLES2ResourceManager
76*35238bceSAndroid Build Coastguard Worker {
77*35238bceSAndroid Build Coastguard Worker public:
78*35238bceSAndroid Build Coastguard Worker     SharedPtr<Texture> popTexture(int index);
getTexture(int index) const79*35238bceSAndroid Build Coastguard Worker     const SharedPtr<Texture> getTexture(int index) const
80*35238bceSAndroid Build Coastguard Worker     {
81*35238bceSAndroid Build Coastguard Worker         return m_textures[index];
82*35238bceSAndroid Build Coastguard Worker     }
addTexture(SharedPtr<Texture> texture)83*35238bceSAndroid Build Coastguard Worker     void addTexture(SharedPtr<Texture> texture)
84*35238bceSAndroid Build Coastguard Worker     {
85*35238bceSAndroid Build Coastguard Worker         m_textures.push_back(texture);
86*35238bceSAndroid Build Coastguard Worker     }
getTextureCount(void) const87*35238bceSAndroid Build Coastguard Worker     int getTextureCount(void) const
88*35238bceSAndroid Build Coastguard Worker     {
89*35238bceSAndroid Build Coastguard Worker         return (int)m_textures.size();
90*35238bceSAndroid Build Coastguard Worker     }
91*35238bceSAndroid Build Coastguard Worker 
92*35238bceSAndroid Build Coastguard Worker     SharedPtr<Buffer> popBuffer(int index);
getBuffer(int index) const93*35238bceSAndroid Build Coastguard Worker     const SharedPtr<Buffer> getBuffer(int index) const
94*35238bceSAndroid Build Coastguard Worker     {
95*35238bceSAndroid Build Coastguard Worker         return m_buffers[index];
96*35238bceSAndroid Build Coastguard Worker     }
addBuffer(SharedPtr<Buffer> buffer)97*35238bceSAndroid Build Coastguard Worker     void addBuffer(SharedPtr<Buffer> buffer)
98*35238bceSAndroid Build Coastguard Worker     {
99*35238bceSAndroid Build Coastguard Worker         m_buffers.push_back(buffer);
100*35238bceSAndroid Build Coastguard Worker     }
getBufferCount(void) const101*35238bceSAndroid Build Coastguard Worker     int getBufferCount(void) const
102*35238bceSAndroid Build Coastguard Worker     {
103*35238bceSAndroid Build Coastguard Worker         return (int)m_buffers.size();
104*35238bceSAndroid Build Coastguard Worker     }
105*35238bceSAndroid Build Coastguard Worker 
106*35238bceSAndroid Build Coastguard Worker     SharedPtr<Shader> popShader(int index);
getShader(int index) const107*35238bceSAndroid Build Coastguard Worker     const SharedPtr<Shader> getShader(int index) const
108*35238bceSAndroid Build Coastguard Worker     {
109*35238bceSAndroid Build Coastguard Worker         return m_shaders[index];
110*35238bceSAndroid Build Coastguard Worker     }
addShader(SharedPtr<Shader> shader)111*35238bceSAndroid Build Coastguard Worker     void addShader(SharedPtr<Shader> shader)
112*35238bceSAndroid Build Coastguard Worker     {
113*35238bceSAndroid Build Coastguard Worker         m_shaders.push_back(shader);
114*35238bceSAndroid Build Coastguard Worker     }
getShaderCount(void) const115*35238bceSAndroid Build Coastguard Worker     int getShaderCount(void) const
116*35238bceSAndroid Build Coastguard Worker     {
117*35238bceSAndroid Build Coastguard Worker         return (int)m_shaders.size();
118*35238bceSAndroid Build Coastguard Worker     }
119*35238bceSAndroid Build Coastguard Worker 
120*35238bceSAndroid Build Coastguard Worker     SharedPtr<Program> popProgram(int index);
getProgram(int index) const121*35238bceSAndroid Build Coastguard Worker     const SharedPtr<Program> getProgram(int index) const
122*35238bceSAndroid Build Coastguard Worker     {
123*35238bceSAndroid Build Coastguard Worker         return m_programs[index];
124*35238bceSAndroid Build Coastguard Worker     }
addProgram(SharedPtr<Program> program)125*35238bceSAndroid Build Coastguard Worker     void addProgram(SharedPtr<Program> program)
126*35238bceSAndroid Build Coastguard Worker     {
127*35238bceSAndroid Build Coastguard Worker         m_programs.push_back(program);
128*35238bceSAndroid Build Coastguard Worker     }
getProgramCount(void) const129*35238bceSAndroid Build Coastguard Worker     int getProgramCount(void) const
130*35238bceSAndroid Build Coastguard Worker     {
131*35238bceSAndroid Build Coastguard Worker         return (int)m_programs.size();
132*35238bceSAndroid Build Coastguard Worker     }
133*35238bceSAndroid Build Coastguard Worker 
134*35238bceSAndroid Build Coastguard Worker private:
135*35238bceSAndroid Build Coastguard Worker     std::vector<SharedPtr<Texture>> m_textures;
136*35238bceSAndroid Build Coastguard Worker     std::vector<SharedPtr<Buffer>> m_buffers;
137*35238bceSAndroid Build Coastguard Worker     std::vector<SharedPtr<Shader>> m_shaders;
138*35238bceSAndroid Build Coastguard Worker     std::vector<SharedPtr<Program>> m_programs;
139*35238bceSAndroid Build Coastguard Worker };
140*35238bceSAndroid Build Coastguard Worker 
popTexture(int index)141*35238bceSAndroid Build Coastguard Worker SharedPtr<Texture> GLES2ResourceManager::popTexture(int index)
142*35238bceSAndroid Build Coastguard Worker {
143*35238bceSAndroid Build Coastguard Worker     SharedPtr<Texture> texture = m_textures[index];
144*35238bceSAndroid Build Coastguard Worker 
145*35238bceSAndroid Build Coastguard Worker     m_textures.erase(m_textures.begin() + index);
146*35238bceSAndroid Build Coastguard Worker 
147*35238bceSAndroid Build Coastguard Worker     return texture;
148*35238bceSAndroid Build Coastguard Worker }
149*35238bceSAndroid Build Coastguard Worker 
popBuffer(int index)150*35238bceSAndroid Build Coastguard Worker SharedPtr<Buffer> GLES2ResourceManager::popBuffer(int index)
151*35238bceSAndroid Build Coastguard Worker {
152*35238bceSAndroid Build Coastguard Worker     SharedPtr<Buffer> buffer = m_buffers[index];
153*35238bceSAndroid Build Coastguard Worker 
154*35238bceSAndroid Build Coastguard Worker     m_buffers.erase(m_buffers.begin() + index);
155*35238bceSAndroid Build Coastguard Worker 
156*35238bceSAndroid Build Coastguard Worker     return buffer;
157*35238bceSAndroid Build Coastguard Worker }
158*35238bceSAndroid Build Coastguard Worker 
popShader(int index)159*35238bceSAndroid Build Coastguard Worker SharedPtr<Shader> GLES2ResourceManager::popShader(int index)
160*35238bceSAndroid Build Coastguard Worker {
161*35238bceSAndroid Build Coastguard Worker     SharedPtr<Shader> shader = m_shaders[index];
162*35238bceSAndroid Build Coastguard Worker 
163*35238bceSAndroid Build Coastguard Worker     m_shaders.erase(m_shaders.begin() + index);
164*35238bceSAndroid Build Coastguard Worker 
165*35238bceSAndroid Build Coastguard Worker     return shader;
166*35238bceSAndroid Build Coastguard Worker }
167*35238bceSAndroid Build Coastguard Worker 
popProgram(int index)168*35238bceSAndroid Build Coastguard Worker SharedPtr<Program> GLES2ResourceManager::popProgram(int index)
169*35238bceSAndroid Build Coastguard Worker {
170*35238bceSAndroid Build Coastguard Worker     SharedPtr<Program> program = m_programs[index];
171*35238bceSAndroid Build Coastguard Worker 
172*35238bceSAndroid Build Coastguard Worker     m_programs.erase(m_programs.begin() + index);
173*35238bceSAndroid Build Coastguard Worker 
174*35238bceSAndroid Build Coastguard Worker     return program;
175*35238bceSAndroid Build Coastguard Worker }
176*35238bceSAndroid Build Coastguard Worker 
177*35238bceSAndroid Build Coastguard Worker class GLES2Context : public tcu::ThreadUtil::Object
178*35238bceSAndroid Build Coastguard Worker {
179*35238bceSAndroid Build Coastguard Worker public:
180*35238bceSAndroid Build Coastguard Worker     GLES2Context(SharedPtr<tcu::ThreadUtil::Event> event, SharedPtr<GLES2ResourceManager> resourceManager);
181*35238bceSAndroid Build Coastguard Worker     ~GLES2Context(void);
182*35238bceSAndroid Build Coastguard Worker 
183*35238bceSAndroid Build Coastguard Worker     // Call generation time attributes
184*35238bceSAndroid Build Coastguard Worker     SharedPtr<GLES2ResourceManager> resourceManager;
185*35238bceSAndroid Build Coastguard Worker 
186*35238bceSAndroid Build Coastguard Worker     // Run time attributes
187*35238bceSAndroid Build Coastguard Worker     EGLDisplay display;
188*35238bceSAndroid Build Coastguard Worker     EGLContext context;
189*35238bceSAndroid Build Coastguard Worker 
190*35238bceSAndroid Build Coastguard Worker     struct
191*35238bceSAndroid Build Coastguard Worker     {
192*35238bceSAndroid Build Coastguard Worker         glEGLImageTargetTexture2DOESFunc imageTargetTexture2D;
193*35238bceSAndroid Build Coastguard Worker     } glExtensions;
194*35238bceSAndroid Build Coastguard Worker 
195*35238bceSAndroid Build Coastguard Worker private:
196*35238bceSAndroid Build Coastguard Worker     GLES2Context(const GLES2Context &);
197*35238bceSAndroid Build Coastguard Worker     GLES2Context &operator=(const GLES2Context &);
198*35238bceSAndroid Build Coastguard Worker };
199*35238bceSAndroid Build Coastguard Worker 
GLES2Context(SharedPtr<tcu::ThreadUtil::Event> event,SharedPtr<GLES2ResourceManager> resourceManager_)200*35238bceSAndroid Build Coastguard Worker GLES2Context::GLES2Context(SharedPtr<tcu::ThreadUtil::Event> event, SharedPtr<GLES2ResourceManager> resourceManager_)
201*35238bceSAndroid Build Coastguard Worker     : tcu::ThreadUtil::Object("Context", event)
202*35238bceSAndroid Build Coastguard Worker     , resourceManager(resourceManager_)
203*35238bceSAndroid Build Coastguard Worker     , display(EGL_NO_DISPLAY)
204*35238bceSAndroid Build Coastguard Worker     , context(EGL_NO_CONTEXT)
205*35238bceSAndroid Build Coastguard Worker {
206*35238bceSAndroid Build Coastguard Worker     glExtensions.imageTargetTexture2D = DE_NULL;
207*35238bceSAndroid Build Coastguard Worker }
208*35238bceSAndroid Build Coastguard Worker 
~GLES2Context(void)209*35238bceSAndroid Build Coastguard Worker GLES2Context::~GLES2Context(void)
210*35238bceSAndroid Build Coastguard Worker {
211*35238bceSAndroid Build Coastguard Worker }
212*35238bceSAndroid Build Coastguard Worker 
213*35238bceSAndroid Build Coastguard Worker class Surface : public tcu::ThreadUtil::Object
214*35238bceSAndroid Build Coastguard Worker {
215*35238bceSAndroid Build Coastguard Worker public:
216*35238bceSAndroid Build Coastguard Worker     Surface(SharedPtr<tcu::ThreadUtil::Event> event);
217*35238bceSAndroid Build Coastguard Worker     ~Surface(void);
218*35238bceSAndroid Build Coastguard Worker 
219*35238bceSAndroid Build Coastguard Worker     // Run time attributes
220*35238bceSAndroid Build Coastguard Worker     EGLSurface surface;
221*35238bceSAndroid Build Coastguard Worker 
222*35238bceSAndroid Build Coastguard Worker private:
223*35238bceSAndroid Build Coastguard Worker     Surface(const Surface &);
224*35238bceSAndroid Build Coastguard Worker     Surface &operator=(const Surface &);
225*35238bceSAndroid Build Coastguard Worker };
226*35238bceSAndroid Build Coastguard Worker 
Surface(SharedPtr<tcu::ThreadUtil::Event> event)227*35238bceSAndroid Build Coastguard Worker Surface::Surface(SharedPtr<tcu::ThreadUtil::Event> event)
228*35238bceSAndroid Build Coastguard Worker     : tcu::ThreadUtil::Object("Surface", event)
229*35238bceSAndroid Build Coastguard Worker     , surface(EGL_NO_SURFACE)
230*35238bceSAndroid Build Coastguard Worker {
231*35238bceSAndroid Build Coastguard Worker }
232*35238bceSAndroid Build Coastguard Worker 
~Surface(void)233*35238bceSAndroid Build Coastguard Worker Surface::~Surface(void)
234*35238bceSAndroid Build Coastguard Worker {
235*35238bceSAndroid Build Coastguard Worker }
236*35238bceSAndroid Build Coastguard Worker 
237*35238bceSAndroid Build Coastguard Worker // EGL thread with thread specifig state
238*35238bceSAndroid Build Coastguard Worker class EGLThread : public tcu::ThreadUtil::Thread
239*35238bceSAndroid Build Coastguard Worker {
240*35238bceSAndroid Build Coastguard Worker public:
241*35238bceSAndroid Build Coastguard Worker     EGLThread(const Library &egl_, const glw::Functions &gl_, int seed);
242*35238bceSAndroid Build Coastguard Worker     ~EGLThread(void);
243*35238bceSAndroid Build Coastguard Worker     virtual void deinit(void);
244*35238bceSAndroid Build Coastguard Worker 
245*35238bceSAndroid Build Coastguard Worker     const Library &egl;
246*35238bceSAndroid Build Coastguard Worker     const glw::Functions &gl;
247*35238bceSAndroid Build Coastguard Worker 
248*35238bceSAndroid Build Coastguard Worker     // Generation time attributes
249*35238bceSAndroid Build Coastguard Worker     SharedPtr<GLES2Context> context;
250*35238bceSAndroid Build Coastguard Worker     SharedPtr<Surface> surface;
251*35238bceSAndroid Build Coastguard Worker 
252*35238bceSAndroid Build Coastguard Worker     // Runtime attributes
253*35238bceSAndroid Build Coastguard Worker 
254*35238bceSAndroid Build Coastguard Worker     SharedPtr<GLES2Context> runtimeContext;
255*35238bceSAndroid Build Coastguard Worker     EGLSurface eglSurface;
256*35238bceSAndroid Build Coastguard Worker 
257*35238bceSAndroid Build Coastguard Worker private:
258*35238bceSAndroid Build Coastguard Worker };
259*35238bceSAndroid Build Coastguard Worker 
EGLThread(const Library & egl_,const glw::Functions & gl_,int seed)260*35238bceSAndroid Build Coastguard Worker EGLThread::EGLThread(const Library &egl_, const glw::Functions &gl_, int seed)
261*35238bceSAndroid Build Coastguard Worker     : tcu::ThreadUtil::Thread(seed)
262*35238bceSAndroid Build Coastguard Worker     , egl(egl_)
263*35238bceSAndroid Build Coastguard Worker     , gl(gl_)
264*35238bceSAndroid Build Coastguard Worker     , eglSurface(EGL_NO_SURFACE)
265*35238bceSAndroid Build Coastguard Worker {
266*35238bceSAndroid Build Coastguard Worker }
267*35238bceSAndroid Build Coastguard Worker 
deinit(void)268*35238bceSAndroid Build Coastguard Worker void EGLThread::deinit(void)
269*35238bceSAndroid Build Coastguard Worker {
270*35238bceSAndroid Build Coastguard Worker     if (runtimeContext)
271*35238bceSAndroid Build Coastguard Worker     {
272*35238bceSAndroid Build Coastguard Worker         if (runtimeContext->context != EGL_NO_CONTEXT)
273*35238bceSAndroid Build Coastguard Worker             egl.makeCurrent(runtimeContext->display, EGL_NO_SURFACE, EGL_NO_SURFACE, EGL_NO_CONTEXT);
274*35238bceSAndroid Build Coastguard Worker 
275*35238bceSAndroid Build Coastguard Worker         egl.destroyContext(runtimeContext->display, runtimeContext->context);
276*35238bceSAndroid Build Coastguard Worker         runtimeContext->context = EGL_NO_CONTEXT;
277*35238bceSAndroid Build Coastguard Worker 
278*35238bceSAndroid Build Coastguard Worker         egl.destroySurface(runtimeContext->display, eglSurface);
279*35238bceSAndroid Build Coastguard Worker         eglSurface = EGL_NO_SURFACE;
280*35238bceSAndroid Build Coastguard Worker     }
281*35238bceSAndroid Build Coastguard Worker 
282*35238bceSAndroid Build Coastguard Worker     egl.releaseThread();
283*35238bceSAndroid Build Coastguard Worker }
284*35238bceSAndroid Build Coastguard Worker 
~EGLThread(void)285*35238bceSAndroid Build Coastguard Worker EGLThread::~EGLThread(void)
286*35238bceSAndroid Build Coastguard Worker {
287*35238bceSAndroid Build Coastguard Worker     EGLThread::deinit();
288*35238bceSAndroid Build Coastguard Worker }
289*35238bceSAndroid Build Coastguard Worker 
290*35238bceSAndroid Build Coastguard Worker class FenceSync
291*35238bceSAndroid Build Coastguard Worker {
292*35238bceSAndroid Build Coastguard Worker public:
293*35238bceSAndroid Build Coastguard Worker     FenceSync(void);
294*35238bceSAndroid Build Coastguard Worker     ~FenceSync(void);
295*35238bceSAndroid Build Coastguard Worker 
296*35238bceSAndroid Build Coastguard Worker     void init(EGLThread &thread, bool serverSync);
297*35238bceSAndroid Build Coastguard Worker     bool waitReady(EGLThread &thread);
298*35238bceSAndroid Build Coastguard Worker 
299*35238bceSAndroid Build Coastguard Worker     void addWaiter(void);
300*35238bceSAndroid Build Coastguard Worker 
301*35238bceSAndroid Build Coastguard Worker private:
302*35238bceSAndroid Build Coastguard Worker     EGLDisplay m_display;
303*35238bceSAndroid Build Coastguard Worker     EGLSyncKHR m_sync;
304*35238bceSAndroid Build Coastguard Worker     de::Mutex m_lock;
305*35238bceSAndroid Build Coastguard Worker     int m_waiterCount;
306*35238bceSAndroid Build Coastguard Worker     bool m_serverSync;
307*35238bceSAndroid Build Coastguard Worker };
308*35238bceSAndroid Build Coastguard Worker 
FenceSync(void)309*35238bceSAndroid Build Coastguard Worker FenceSync::FenceSync(void) : m_display(EGL_NO_DISPLAY), m_sync(NULL), m_waiterCount(0), m_serverSync(false)
310*35238bceSAndroid Build Coastguard Worker {
311*35238bceSAndroid Build Coastguard Worker }
312*35238bceSAndroid Build Coastguard Worker 
~FenceSync(void)313*35238bceSAndroid Build Coastguard Worker FenceSync::~FenceSync(void)
314*35238bceSAndroid Build Coastguard Worker {
315*35238bceSAndroid Build Coastguard Worker }
316*35238bceSAndroid Build Coastguard Worker 
addWaiter(void)317*35238bceSAndroid Build Coastguard Worker void FenceSync::addWaiter(void)
318*35238bceSAndroid Build Coastguard Worker {
319*35238bceSAndroid Build Coastguard Worker     m_lock.lock();
320*35238bceSAndroid Build Coastguard Worker     m_waiterCount++;
321*35238bceSAndroid Build Coastguard Worker     m_lock.unlock();
322*35238bceSAndroid Build Coastguard Worker }
323*35238bceSAndroid Build Coastguard Worker 
init(EGLThread & thread,bool serverSync)324*35238bceSAndroid Build Coastguard Worker void FenceSync::init(EGLThread &thread, bool serverSync)
325*35238bceSAndroid Build Coastguard Worker {
326*35238bceSAndroid Build Coastguard Worker     m_display    = thread.runtimeContext->display;
327*35238bceSAndroid Build Coastguard Worker     m_serverSync = serverSync;
328*35238bceSAndroid Build Coastguard Worker 
329*35238bceSAndroid Build Coastguard Worker     // Use sync only if somebody will actualy depend on it
330*35238bceSAndroid Build Coastguard Worker     m_lock.lock();
331*35238bceSAndroid Build Coastguard Worker     if (m_waiterCount > 0)
332*35238bceSAndroid Build Coastguard Worker     {
333*35238bceSAndroid Build Coastguard Worker         thread.newMessage() << "Begin -- eglCreateSyncKHR(" << ((size_t)m_display) << ", EGL_SYNC_FENCE_KHR, DE_NULL)"
334*35238bceSAndroid Build Coastguard Worker                             << tcu::ThreadUtil::Message::End;
335*35238bceSAndroid Build Coastguard Worker         m_sync = thread.egl.createSyncKHR(m_display, EGL_SYNC_FENCE_KHR, DE_NULL);
336*35238bceSAndroid Build Coastguard Worker         thread.newMessage() << "End -- " << ((size_t)m_sync) << " = eglCreateSyncKHR()"
337*35238bceSAndroid Build Coastguard Worker                             << tcu::ThreadUtil::Message::End;
338*35238bceSAndroid Build Coastguard Worker         TCU_CHECK(m_sync);
339*35238bceSAndroid Build Coastguard Worker     }
340*35238bceSAndroid Build Coastguard Worker     m_lock.unlock();
341*35238bceSAndroid Build Coastguard Worker }
342*35238bceSAndroid Build Coastguard Worker 
waitReady(EGLThread & thread)343*35238bceSAndroid Build Coastguard Worker bool FenceSync::waitReady(EGLThread &thread)
344*35238bceSAndroid Build Coastguard Worker {
345*35238bceSAndroid Build Coastguard Worker     bool ok = true;
346*35238bceSAndroid Build Coastguard Worker     if (m_serverSync)
347*35238bceSAndroid Build Coastguard Worker     {
348*35238bceSAndroid Build Coastguard Worker         thread.newMessage() << "Begin -- eglWaitSyncKHR(" << ((size_t)m_display) << ", " << ((size_t)m_sync) << ", 0)"
349*35238bceSAndroid Build Coastguard Worker                             << tcu::ThreadUtil::Message::End;
350*35238bceSAndroid Build Coastguard Worker         EGLint result = thread.egl.waitSyncKHR(m_display, m_sync, 0);
351*35238bceSAndroid Build Coastguard Worker         thread.newMessage() << "End -- " << result << " = eglWaitSyncKHR()" << tcu::ThreadUtil::Message::End;
352*35238bceSAndroid Build Coastguard Worker         ok = result == EGL_TRUE;
353*35238bceSAndroid Build Coastguard Worker     }
354*35238bceSAndroid Build Coastguard Worker     else
355*35238bceSAndroid Build Coastguard Worker     {
356*35238bceSAndroid Build Coastguard Worker         thread.newMessage() << "Begin -- eglClientWaitSyncKHR(" << ((size_t)m_display) << ", " << ((size_t)m_sync)
357*35238bceSAndroid Build Coastguard Worker                             << ", EGL_SYNC_FLUSH_COMMANDS_BIT_KHR, 1000 000 000)" << tcu::ThreadUtil::Message::End;
358*35238bceSAndroid Build Coastguard Worker         EGLint result = thread.egl.clientWaitSyncKHR(m_display, m_sync, EGL_SYNC_FLUSH_COMMANDS_BIT_KHR, 1000000000);
359*35238bceSAndroid Build Coastguard Worker         thread.newMessage() << "End -- " << result << " = eglClientWaitSyncKHR()" << tcu::ThreadUtil::Message::End;
360*35238bceSAndroid Build Coastguard Worker         ok = result == EGL_CONDITION_SATISFIED_KHR;
361*35238bceSAndroid Build Coastguard Worker     }
362*35238bceSAndroid Build Coastguard Worker 
363*35238bceSAndroid Build Coastguard Worker     m_lock.lock();
364*35238bceSAndroid Build Coastguard Worker     m_waiterCount--;
365*35238bceSAndroid Build Coastguard Worker     DE_ASSERT(m_waiterCount >= 0);
366*35238bceSAndroid Build Coastguard Worker 
367*35238bceSAndroid Build Coastguard Worker     if (m_waiterCount == 0)
368*35238bceSAndroid Build Coastguard Worker     {
369*35238bceSAndroid Build Coastguard Worker         // \note [mika] This is no longer deterministic and eglDestroySyncKHR might happen in different places and in different threads
370*35238bceSAndroid Build Coastguard Worker         thread.newMessage() << "Begin -- eglDestroySyncKHR(" << ((size_t)m_display) << ", " << ((size_t)m_sync) << ")"
371*35238bceSAndroid Build Coastguard Worker                             << tcu::ThreadUtil::Message::End;
372*35238bceSAndroid Build Coastguard Worker         EGLint destroyResult = thread.egl.destroySyncKHR(m_display, m_sync);
373*35238bceSAndroid Build Coastguard Worker         thread.newMessage() << "End -- " << destroyResult << " = eglDestroySyncKHR()" << tcu::ThreadUtil::Message::End;
374*35238bceSAndroid Build Coastguard Worker         m_sync = DE_NULL;
375*35238bceSAndroid Build Coastguard Worker     }
376*35238bceSAndroid Build Coastguard Worker 
377*35238bceSAndroid Build Coastguard Worker     m_lock.unlock();
378*35238bceSAndroid Build Coastguard Worker 
379*35238bceSAndroid Build Coastguard Worker     return ok;
380*35238bceSAndroid Build Coastguard Worker }
381*35238bceSAndroid Build Coastguard Worker 
382*35238bceSAndroid Build Coastguard Worker class Object : public tcu::ThreadUtil::Object
383*35238bceSAndroid Build Coastguard Worker {
384*35238bceSAndroid Build Coastguard Worker public:
385*35238bceSAndroid Build Coastguard Worker     Object(const char *type, SharedPtr<tcu::ThreadUtil::Event> e, SharedPtr<FenceSync> sync);
386*35238bceSAndroid Build Coastguard Worker     ~Object(void);
387*35238bceSAndroid Build Coastguard Worker 
388*35238bceSAndroid Build Coastguard Worker     void readGL(SharedPtr<FenceSync> sync, std::vector<SharedPtr<FenceSync>> &deps);
389*35238bceSAndroid Build Coastguard Worker     void modifyGL(SharedPtr<FenceSync> sync, std::vector<SharedPtr<FenceSync>> &deps);
390*35238bceSAndroid Build Coastguard Worker 
391*35238bceSAndroid Build Coastguard Worker private:
392*35238bceSAndroid Build Coastguard Worker     SharedPtr<FenceSync> m_modifySync;
393*35238bceSAndroid Build Coastguard Worker     vector<SharedPtr<FenceSync>> m_readSyncs;
394*35238bceSAndroid Build Coastguard Worker };
395*35238bceSAndroid Build Coastguard Worker 
Object(const char * type,SharedPtr<tcu::ThreadUtil::Event> e,SharedPtr<FenceSync> sync)396*35238bceSAndroid Build Coastguard Worker Object::Object(const char *type, SharedPtr<tcu::ThreadUtil::Event> e, SharedPtr<FenceSync> sync)
397*35238bceSAndroid Build Coastguard Worker     : tcu::ThreadUtil::Object(type, e)
398*35238bceSAndroid Build Coastguard Worker     , m_modifySync(sync)
399*35238bceSAndroid Build Coastguard Worker {
400*35238bceSAndroid Build Coastguard Worker }
401*35238bceSAndroid Build Coastguard Worker 
~Object(void)402*35238bceSAndroid Build Coastguard Worker Object::~Object(void)
403*35238bceSAndroid Build Coastguard Worker {
404*35238bceSAndroid Build Coastguard Worker }
405*35238bceSAndroid Build Coastguard Worker 
readGL(SharedPtr<FenceSync> sync,std::vector<SharedPtr<FenceSync>> & deps)406*35238bceSAndroid Build Coastguard Worker void Object::readGL(SharedPtr<FenceSync> sync, std::vector<SharedPtr<FenceSync>> &deps)
407*35238bceSAndroid Build Coastguard Worker {
408*35238bceSAndroid Build Coastguard Worker     if (m_modifySync)
409*35238bceSAndroid Build Coastguard Worker         m_modifySync->addWaiter();
410*35238bceSAndroid Build Coastguard Worker 
411*35238bceSAndroid Build Coastguard Worker     // Make call depend on last modifying call
412*35238bceSAndroid Build Coastguard Worker     deps.push_back(m_modifySync);
413*35238bceSAndroid Build Coastguard Worker 
414*35238bceSAndroid Build Coastguard Worker     // Add read dependency
415*35238bceSAndroid Build Coastguard Worker     m_readSyncs.push_back(sync);
416*35238bceSAndroid Build Coastguard Worker }
417*35238bceSAndroid Build Coastguard Worker 
modifyGL(SharedPtr<FenceSync> sync,std::vector<SharedPtr<FenceSync>> & deps)418*35238bceSAndroid Build Coastguard Worker void Object::modifyGL(SharedPtr<FenceSync> sync, std::vector<SharedPtr<FenceSync>> &deps)
419*35238bceSAndroid Build Coastguard Worker {
420*35238bceSAndroid Build Coastguard Worker     // Make call depend on all reads
421*35238bceSAndroid Build Coastguard Worker     for (int readNdx = 0; readNdx < (int)m_readSyncs.size(); readNdx++)
422*35238bceSAndroid Build Coastguard Worker     {
423*35238bceSAndroid Build Coastguard Worker         if (m_readSyncs[readNdx])
424*35238bceSAndroid Build Coastguard Worker             m_readSyncs[readNdx]->addWaiter();
425*35238bceSAndroid Build Coastguard Worker 
426*35238bceSAndroid Build Coastguard Worker         deps.push_back(m_readSyncs[readNdx]);
427*35238bceSAndroid Build Coastguard Worker     }
428*35238bceSAndroid Build Coastguard Worker 
429*35238bceSAndroid Build Coastguard Worker     if (m_modifySync)
430*35238bceSAndroid Build Coastguard Worker         m_modifySync->addWaiter();
431*35238bceSAndroid Build Coastguard Worker 
432*35238bceSAndroid Build Coastguard Worker     deps.push_back(m_modifySync);
433*35238bceSAndroid Build Coastguard Worker 
434*35238bceSAndroid Build Coastguard Worker     // Update last modifying call
435*35238bceSAndroid Build Coastguard Worker     m_modifySync = sync;
436*35238bceSAndroid Build Coastguard Worker 
437*35238bceSAndroid Build Coastguard Worker     // Clear read dependencies of last "version" of this object
438*35238bceSAndroid Build Coastguard Worker     m_readSyncs.clear();
439*35238bceSAndroid Build Coastguard Worker }
440*35238bceSAndroid Build Coastguard Worker 
441*35238bceSAndroid Build Coastguard Worker class Operation : public tcu::ThreadUtil::Operation
442*35238bceSAndroid Build Coastguard Worker {
443*35238bceSAndroid Build Coastguard Worker public:
444*35238bceSAndroid Build Coastguard Worker     Operation(const char *name, bool useSync, bool serverSync);
445*35238bceSAndroid Build Coastguard Worker     virtual ~Operation(void);
446*35238bceSAndroid Build Coastguard Worker 
getSync(void)447*35238bceSAndroid Build Coastguard Worker     SharedPtr<FenceSync> getSync(void)
448*35238bceSAndroid Build Coastguard Worker     {
449*35238bceSAndroid Build Coastguard Worker         return m_sync;
450*35238bceSAndroid Build Coastguard Worker     }
451*35238bceSAndroid Build Coastguard Worker     void readGLObject(SharedPtr<Object> object);
452*35238bceSAndroid Build Coastguard Worker     void modifyGLObject(SharedPtr<Object> object);
453*35238bceSAndroid Build Coastguard Worker 
454*35238bceSAndroid Build Coastguard Worker     virtual void execute(tcu::ThreadUtil::Thread &thread);
455*35238bceSAndroid Build Coastguard Worker 
456*35238bceSAndroid Build Coastguard Worker private:
457*35238bceSAndroid Build Coastguard Worker     bool m_useSync;
458*35238bceSAndroid Build Coastguard Worker     bool m_serverSync;
459*35238bceSAndroid Build Coastguard Worker     std::vector<SharedPtr<FenceSync>> m_syncDeps;
460*35238bceSAndroid Build Coastguard Worker     SharedPtr<FenceSync> m_sync;
461*35238bceSAndroid Build Coastguard Worker };
462*35238bceSAndroid Build Coastguard Worker 
Operation(const char * name,bool useSync,bool serverSync)463*35238bceSAndroid Build Coastguard Worker Operation::Operation(const char *name, bool useSync, bool serverSync)
464*35238bceSAndroid Build Coastguard Worker     : tcu::ThreadUtil::Operation(name)
465*35238bceSAndroid Build Coastguard Worker     , m_useSync(useSync)
466*35238bceSAndroid Build Coastguard Worker     , m_serverSync(serverSync)
467*35238bceSAndroid Build Coastguard Worker     , m_sync(useSync ? SharedPtr<FenceSync>(new FenceSync()) : SharedPtr<FenceSync>())
468*35238bceSAndroid Build Coastguard Worker {
469*35238bceSAndroid Build Coastguard Worker }
470*35238bceSAndroid Build Coastguard Worker 
~Operation(void)471*35238bceSAndroid Build Coastguard Worker Operation::~Operation(void)
472*35238bceSAndroid Build Coastguard Worker {
473*35238bceSAndroid Build Coastguard Worker }
474*35238bceSAndroid Build Coastguard Worker 
readGLObject(SharedPtr<Object> object)475*35238bceSAndroid Build Coastguard Worker void Operation::readGLObject(SharedPtr<Object> object)
476*35238bceSAndroid Build Coastguard Worker {
477*35238bceSAndroid Build Coastguard Worker     object->read(m_event, m_deps);
478*35238bceSAndroid Build Coastguard Worker     object->readGL(m_sync, m_syncDeps);
479*35238bceSAndroid Build Coastguard Worker }
480*35238bceSAndroid Build Coastguard Worker 
modifyGLObject(SharedPtr<Object> object)481*35238bceSAndroid Build Coastguard Worker void Operation::modifyGLObject(SharedPtr<Object> object)
482*35238bceSAndroid Build Coastguard Worker {
483*35238bceSAndroid Build Coastguard Worker     object->modify(m_event, m_deps);
484*35238bceSAndroid Build Coastguard Worker     object->modifyGL(m_sync, m_syncDeps);
485*35238bceSAndroid Build Coastguard Worker }
486*35238bceSAndroid Build Coastguard Worker 
execute(tcu::ThreadUtil::Thread & t)487*35238bceSAndroid Build Coastguard Worker void Operation::execute(tcu::ThreadUtil::Thread &t)
488*35238bceSAndroid Build Coastguard Worker {
489*35238bceSAndroid Build Coastguard Worker     EGLThread &thread = dynamic_cast<EGLThread &>(t);
490*35238bceSAndroid Build Coastguard Worker 
491*35238bceSAndroid Build Coastguard Worker     bool success = true;
492*35238bceSAndroid Build Coastguard Worker 
493*35238bceSAndroid Build Coastguard Worker     // Wait for dependencies and check that they succeeded
494*35238bceSAndroid Build Coastguard Worker     for (int depNdx = 0; depNdx < (int)m_deps.size(); depNdx++)
495*35238bceSAndroid Build Coastguard Worker     {
496*35238bceSAndroid Build Coastguard Worker         if (!m_deps[depNdx]->waitReady())
497*35238bceSAndroid Build Coastguard Worker             success = false;
498*35238bceSAndroid Build Coastguard Worker     }
499*35238bceSAndroid Build Coastguard Worker 
500*35238bceSAndroid Build Coastguard Worker     // Try execute operation
501*35238bceSAndroid Build Coastguard Worker     if (success)
502*35238bceSAndroid Build Coastguard Worker     {
503*35238bceSAndroid Build Coastguard Worker         try
504*35238bceSAndroid Build Coastguard Worker         {
505*35238bceSAndroid Build Coastguard Worker             if (m_useSync)
506*35238bceSAndroid Build Coastguard Worker             {
507*35238bceSAndroid Build Coastguard Worker                 for (int depNdx = 0; depNdx < (int)m_syncDeps.size(); depNdx++)
508*35238bceSAndroid Build Coastguard Worker                 {
509*35238bceSAndroid Build Coastguard Worker                     EGLThread *eglThread = dynamic_cast<EGLThread *>(&thread);
510*35238bceSAndroid Build Coastguard Worker                     DE_ASSERT(eglThread);
511*35238bceSAndroid Build Coastguard Worker                     if (m_syncDeps[depNdx]->waitReady(*eglThread) != tcu::ThreadUtil::Event::RESULT_OK)
512*35238bceSAndroid Build Coastguard Worker                     {
513*35238bceSAndroid Build Coastguard Worker                         success = false;
514*35238bceSAndroid Build Coastguard Worker                         break;
515*35238bceSAndroid Build Coastguard Worker                     }
516*35238bceSAndroid Build Coastguard Worker                 }
517*35238bceSAndroid Build Coastguard Worker             }
518*35238bceSAndroid Build Coastguard Worker 
519*35238bceSAndroid Build Coastguard Worker             if (success)
520*35238bceSAndroid Build Coastguard Worker             {
521*35238bceSAndroid Build Coastguard Worker                 exec(thread);
522*35238bceSAndroid Build Coastguard Worker                 if (m_useSync)
523*35238bceSAndroid Build Coastguard Worker                 {
524*35238bceSAndroid Build Coastguard Worker                     EGLThread *eglThread = dynamic_cast<EGLThread *>(&thread);
525*35238bceSAndroid Build Coastguard Worker                     DE_ASSERT(eglThread);
526*35238bceSAndroid Build Coastguard Worker                     m_sync->init(*eglThread, m_serverSync);
527*35238bceSAndroid Build Coastguard Worker                     thread.newMessage() << "Begin -- glFlush()" << tcu::ThreadUtil::Message::End;
528*35238bceSAndroid Build Coastguard Worker                     GLU_CHECK_GLW_CALL(thread.gl, flush());
529*35238bceSAndroid Build Coastguard Worker                     thread.newMessage() << "End -- glFlush()" << tcu::ThreadUtil::Message::End;
530*35238bceSAndroid Build Coastguard Worker                 }
531*35238bceSAndroid Build Coastguard Worker                 else
532*35238bceSAndroid Build Coastguard Worker                 {
533*35238bceSAndroid Build Coastguard Worker                     thread.newMessage() << "Begin -- glFinish()" << tcu::ThreadUtil::Message::End;
534*35238bceSAndroid Build Coastguard Worker                     GLU_CHECK_GLW_CALL(thread.gl, finish());
535*35238bceSAndroid Build Coastguard Worker                     thread.newMessage() << "End -- glFinish()" << tcu::ThreadUtil::Message::End;
536*35238bceSAndroid Build Coastguard Worker                 }
537*35238bceSAndroid Build Coastguard Worker             }
538*35238bceSAndroid Build Coastguard Worker         }
539*35238bceSAndroid Build Coastguard Worker         catch (...)
540*35238bceSAndroid Build Coastguard Worker         {
541*35238bceSAndroid Build Coastguard Worker             // Got exception event failed
542*35238bceSAndroid Build Coastguard Worker             m_event->setResult(tcu::ThreadUtil::Event::RESULT_FAILED);
543*35238bceSAndroid Build Coastguard Worker             throw;
544*35238bceSAndroid Build Coastguard Worker         }
545*35238bceSAndroid Build Coastguard Worker     }
546*35238bceSAndroid Build Coastguard Worker 
547*35238bceSAndroid Build Coastguard Worker     if (success)
548*35238bceSAndroid Build Coastguard Worker         m_event->setResult(tcu::ThreadUtil::Event::RESULT_OK);
549*35238bceSAndroid Build Coastguard Worker     else
550*35238bceSAndroid Build Coastguard Worker         m_event->setResult(tcu::ThreadUtil::Event::RESULT_FAILED);
551*35238bceSAndroid Build Coastguard Worker 
552*35238bceSAndroid Build Coastguard Worker     m_deps.clear();
553*35238bceSAndroid Build Coastguard Worker     m_event = SharedPtr<tcu::ThreadUtil::Event>();
554*35238bceSAndroid Build Coastguard Worker     m_syncDeps.clear();
555*35238bceSAndroid Build Coastguard Worker     m_sync = SharedPtr<FenceSync>();
556*35238bceSAndroid Build Coastguard Worker }
557*35238bceSAndroid Build Coastguard Worker 
558*35238bceSAndroid Build Coastguard Worker class EGLImage : public Object
559*35238bceSAndroid Build Coastguard Worker {
560*35238bceSAndroid Build Coastguard Worker public:
561*35238bceSAndroid Build Coastguard Worker     EGLImage(SharedPtr<tcu::ThreadUtil::Event> event, SharedPtr<FenceSync> sync);
~EGLImage(void)562*35238bceSAndroid Build Coastguard Worker     virtual ~EGLImage(void)
563*35238bceSAndroid Build Coastguard Worker     {
564*35238bceSAndroid Build Coastguard Worker     }
565*35238bceSAndroid Build Coastguard Worker 
566*35238bceSAndroid Build Coastguard Worker     EGLImageKHR image;
567*35238bceSAndroid Build Coastguard Worker };
568*35238bceSAndroid Build Coastguard Worker 
569*35238bceSAndroid Build Coastguard Worker // EGLResource manager
570*35238bceSAndroid Build Coastguard Worker class EGLResourceManager
571*35238bceSAndroid Build Coastguard Worker {
572*35238bceSAndroid Build Coastguard Worker public:
addContext(SharedPtr<GLES2Context> context)573*35238bceSAndroid Build Coastguard Worker     void addContext(SharedPtr<GLES2Context> context)
574*35238bceSAndroid Build Coastguard Worker     {
575*35238bceSAndroid Build Coastguard Worker         m_contexts.push_back(context);
576*35238bceSAndroid Build Coastguard Worker     }
addSurface(SharedPtr<Surface> surface)577*35238bceSAndroid Build Coastguard Worker     void addSurface(SharedPtr<Surface> surface)
578*35238bceSAndroid Build Coastguard Worker     {
579*35238bceSAndroid Build Coastguard Worker         m_surfaces.push_back(surface);
580*35238bceSAndroid Build Coastguard Worker     }
addImage(SharedPtr<EGLImage> image)581*35238bceSAndroid Build Coastguard Worker     void addImage(SharedPtr<EGLImage> image)
582*35238bceSAndroid Build Coastguard Worker     {
583*35238bceSAndroid Build Coastguard Worker         m_images.push_back(image);
584*35238bceSAndroid Build Coastguard Worker     }
585*35238bceSAndroid Build Coastguard Worker 
586*35238bceSAndroid Build Coastguard Worker     SharedPtr<Surface> popSurface(int index);
587*35238bceSAndroid Build Coastguard Worker     SharedPtr<GLES2Context> popContext(int index);
588*35238bceSAndroid Build Coastguard Worker     SharedPtr<EGLImage> popImage(int index);
589*35238bceSAndroid Build Coastguard Worker 
getContextCount(void) const590*35238bceSAndroid Build Coastguard Worker     int getContextCount(void) const
591*35238bceSAndroid Build Coastguard Worker     {
592*35238bceSAndroid Build Coastguard Worker         return (int)m_contexts.size();
593*35238bceSAndroid Build Coastguard Worker     }
getSurfaceCount(void) const594*35238bceSAndroid Build Coastguard Worker     int getSurfaceCount(void) const
595*35238bceSAndroid Build Coastguard Worker     {
596*35238bceSAndroid Build Coastguard Worker         return (int)m_surfaces.size();
597*35238bceSAndroid Build Coastguard Worker     }
getImageCount(void) const598*35238bceSAndroid Build Coastguard Worker     int getImageCount(void) const
599*35238bceSAndroid Build Coastguard Worker     {
600*35238bceSAndroid Build Coastguard Worker         return (int)m_images.size();
601*35238bceSAndroid Build Coastguard Worker     }
602*35238bceSAndroid Build Coastguard Worker 
603*35238bceSAndroid Build Coastguard Worker private:
604*35238bceSAndroid Build Coastguard Worker     std::vector<SharedPtr<GLES2Context>> m_contexts;
605*35238bceSAndroid Build Coastguard Worker     std::vector<SharedPtr<Surface>> m_surfaces;
606*35238bceSAndroid Build Coastguard Worker     std::vector<SharedPtr<EGLImage>> m_images;
607*35238bceSAndroid Build Coastguard Worker };
608*35238bceSAndroid Build Coastguard Worker 
popSurface(int index)609*35238bceSAndroid Build Coastguard Worker SharedPtr<Surface> EGLResourceManager::popSurface(int index)
610*35238bceSAndroid Build Coastguard Worker {
611*35238bceSAndroid Build Coastguard Worker     SharedPtr<Surface> surface = m_surfaces[index];
612*35238bceSAndroid Build Coastguard Worker     m_surfaces.erase(m_surfaces.begin() + index);
613*35238bceSAndroid Build Coastguard Worker     return surface;
614*35238bceSAndroid Build Coastguard Worker }
615*35238bceSAndroid Build Coastguard Worker 
popContext(int index)616*35238bceSAndroid Build Coastguard Worker SharedPtr<GLES2Context> EGLResourceManager::popContext(int index)
617*35238bceSAndroid Build Coastguard Worker {
618*35238bceSAndroid Build Coastguard Worker     SharedPtr<GLES2Context> context = m_contexts[index];
619*35238bceSAndroid Build Coastguard Worker     m_contexts.erase(m_contexts.begin() + index);
620*35238bceSAndroid Build Coastguard Worker     return context;
621*35238bceSAndroid Build Coastguard Worker }
622*35238bceSAndroid Build Coastguard Worker 
popImage(int index)623*35238bceSAndroid Build Coastguard Worker SharedPtr<EGLImage> EGLResourceManager::popImage(int index)
624*35238bceSAndroid Build Coastguard Worker {
625*35238bceSAndroid Build Coastguard Worker     SharedPtr<EGLImage> image = m_images[index];
626*35238bceSAndroid Build Coastguard Worker     m_images.erase(m_images.begin() + index);
627*35238bceSAndroid Build Coastguard Worker     return image;
628*35238bceSAndroid Build Coastguard Worker }
629*35238bceSAndroid Build Coastguard Worker 
630*35238bceSAndroid Build Coastguard Worker class CreateContext : public tcu::ThreadUtil::Operation
631*35238bceSAndroid Build Coastguard Worker {
632*35238bceSAndroid Build Coastguard Worker public:
633*35238bceSAndroid Build Coastguard Worker     CreateContext(EGLDisplay display, EGLConfig config, SharedPtr<GLES2Context> shared,
634*35238bceSAndroid Build Coastguard Worker                   SharedPtr<GLES2Context> &context);
635*35238bceSAndroid Build Coastguard Worker 
636*35238bceSAndroid Build Coastguard Worker     void exec(tcu::ThreadUtil::Thread &thread);
637*35238bceSAndroid Build Coastguard Worker 
638*35238bceSAndroid Build Coastguard Worker private:
639*35238bceSAndroid Build Coastguard Worker     EGLDisplay m_display;
640*35238bceSAndroid Build Coastguard Worker     EGLConfig m_config;
641*35238bceSAndroid Build Coastguard Worker     SharedPtr<GLES2Context> m_shared;
642*35238bceSAndroid Build Coastguard Worker     SharedPtr<GLES2Context> m_context;
643*35238bceSAndroid Build Coastguard Worker };
644*35238bceSAndroid Build Coastguard Worker 
CreateContext(EGLDisplay display,EGLConfig config,SharedPtr<GLES2Context> shared,SharedPtr<GLES2Context> & context)645*35238bceSAndroid Build Coastguard Worker CreateContext::CreateContext(EGLDisplay display, EGLConfig config, SharedPtr<GLES2Context> shared,
646*35238bceSAndroid Build Coastguard Worker                              SharedPtr<GLES2Context> &context)
647*35238bceSAndroid Build Coastguard Worker     : tcu::ThreadUtil::Operation("CreateContext")
648*35238bceSAndroid Build Coastguard Worker     , m_display(display)
649*35238bceSAndroid Build Coastguard Worker     , m_config(config)
650*35238bceSAndroid Build Coastguard Worker     , m_shared(shared)
651*35238bceSAndroid Build Coastguard Worker {
652*35238bceSAndroid Build Coastguard Worker     if (shared)
653*35238bceSAndroid Build Coastguard Worker         modifyObject(SharedPtr<tcu::ThreadUtil::Object>(shared));
654*35238bceSAndroid Build Coastguard Worker 
655*35238bceSAndroid Build Coastguard Worker     context   = SharedPtr<GLES2Context>(new GLES2Context(
656*35238bceSAndroid Build Coastguard Worker         getEvent(), (shared ? shared->resourceManager : SharedPtr<GLES2ResourceManager>(new GLES2ResourceManager))));
657*35238bceSAndroid Build Coastguard Worker     m_context = context;
658*35238bceSAndroid Build Coastguard Worker }
659*35238bceSAndroid Build Coastguard Worker 
exec(tcu::ThreadUtil::Thread & t)660*35238bceSAndroid Build Coastguard Worker void CreateContext::exec(tcu::ThreadUtil::Thread &t)
661*35238bceSAndroid Build Coastguard Worker {
662*35238bceSAndroid Build Coastguard Worker     EGLThread &thread  = dynamic_cast<EGLThread &>(t);
663*35238bceSAndroid Build Coastguard Worker     m_context->display = m_display;
664*35238bceSAndroid Build Coastguard Worker 
665*35238bceSAndroid Build Coastguard Worker     const EGLint attriblist[] = {EGL_CONTEXT_CLIENT_VERSION, 2, EGL_NONE};
666*35238bceSAndroid Build Coastguard Worker 
667*35238bceSAndroid Build Coastguard Worker     thread.newMessage() << "Begin -- eglBindAPI(EGL_OPENGL_ES_API)" << tcu::ThreadUtil::Message::End;
668*35238bceSAndroid Build Coastguard Worker     EGLU_CHECK_CALL(thread.egl, bindAPI(EGL_OPENGL_ES_API));
669*35238bceSAndroid Build Coastguard Worker     thread.newMessage() << "End -- eglBindAPI()" << tcu::ThreadUtil::Message::End;
670*35238bceSAndroid Build Coastguard Worker 
671*35238bceSAndroid Build Coastguard Worker     if (m_shared)
672*35238bceSAndroid Build Coastguard Worker     {
673*35238bceSAndroid Build Coastguard Worker         DE_ASSERT(m_shared->context != EGL_NO_CONTEXT);
674*35238bceSAndroid Build Coastguard Worker         DE_ASSERT(m_shared->display != EGL_NO_DISPLAY);
675*35238bceSAndroid Build Coastguard Worker         DE_ASSERT(m_shared->display == m_display);
676*35238bceSAndroid Build Coastguard Worker 
677*35238bceSAndroid Build Coastguard Worker         thread.newMessage() << "Begin -- eglCreateContext(" << m_display << ", " << m_config << ", "
678*35238bceSAndroid Build Coastguard Worker                             << m_shared->context << ", { EGL_CONTEXT_CLIENT_VERSION, 2, EGL_NONE })"
679*35238bceSAndroid Build Coastguard Worker                             << tcu::ThreadUtil::Message::End;
680*35238bceSAndroid Build Coastguard Worker         m_context->context = thread.egl.createContext(m_display, m_config, m_shared->context, attriblist);
681*35238bceSAndroid Build Coastguard Worker         thread.newMessage() << "End -- " << m_context->context << " = eglCreateContext()"
682*35238bceSAndroid Build Coastguard Worker                             << tcu::ThreadUtil::Message::End;
683*35238bceSAndroid Build Coastguard Worker     }
684*35238bceSAndroid Build Coastguard Worker     else
685*35238bceSAndroid Build Coastguard Worker     {
686*35238bceSAndroid Build Coastguard Worker         thread.newMessage() << "Begin -- eglCreateContext(" << m_display << ", " << m_config
687*35238bceSAndroid Build Coastguard Worker                             << ", EGL_NO_CONTEXT, { EGL_CONTEXT_CLIENT_VERSION, 2, EGL_NONE })"
688*35238bceSAndroid Build Coastguard Worker                             << tcu::ThreadUtil::Message::End;
689*35238bceSAndroid Build Coastguard Worker         m_context->context = thread.egl.createContext(m_display, m_config, EGL_NO_CONTEXT, attriblist);
690*35238bceSAndroid Build Coastguard Worker         thread.newMessage() << "End -- " << m_context->context << " = eglCreateContext()"
691*35238bceSAndroid Build Coastguard Worker                             << tcu::ThreadUtil::Message::End;
692*35238bceSAndroid Build Coastguard Worker     }
693*35238bceSAndroid Build Coastguard Worker 
694*35238bceSAndroid Build Coastguard Worker     EGLU_CHECK_MSG(thread.egl, "Failed to create GLES2 context");
695*35238bceSAndroid Build Coastguard Worker     TCU_CHECK(m_context->context != EGL_NO_CONTEXT);
696*35238bceSAndroid Build Coastguard Worker }
697*35238bceSAndroid Build Coastguard Worker 
698*35238bceSAndroid Build Coastguard Worker class DestroyContext : public tcu::ThreadUtil::Operation
699*35238bceSAndroid Build Coastguard Worker {
700*35238bceSAndroid Build Coastguard Worker public:
701*35238bceSAndroid Build Coastguard Worker     DestroyContext(SharedPtr<GLES2Context> contex);
702*35238bceSAndroid Build Coastguard Worker     void exec(tcu::ThreadUtil::Thread &thread);
703*35238bceSAndroid Build Coastguard Worker 
704*35238bceSAndroid Build Coastguard Worker private:
705*35238bceSAndroid Build Coastguard Worker     SharedPtr<GLES2Context> m_context;
706*35238bceSAndroid Build Coastguard Worker };
707*35238bceSAndroid Build Coastguard Worker 
DestroyContext(SharedPtr<GLES2Context> contex)708*35238bceSAndroid Build Coastguard Worker DestroyContext::DestroyContext(SharedPtr<GLES2Context> contex)
709*35238bceSAndroid Build Coastguard Worker     : tcu::ThreadUtil::Operation("DestroyContext")
710*35238bceSAndroid Build Coastguard Worker     , m_context(contex)
711*35238bceSAndroid Build Coastguard Worker {
712*35238bceSAndroid Build Coastguard Worker     modifyObject(SharedPtr<tcu::ThreadUtil::Object>(m_context));
713*35238bceSAndroid Build Coastguard Worker }
714*35238bceSAndroid Build Coastguard Worker 
exec(tcu::ThreadUtil::Thread & t)715*35238bceSAndroid Build Coastguard Worker void DestroyContext::exec(tcu::ThreadUtil::Thread &t)
716*35238bceSAndroid Build Coastguard Worker {
717*35238bceSAndroid Build Coastguard Worker     EGLThread &thread = dynamic_cast<EGLThread &>(t);
718*35238bceSAndroid Build Coastguard Worker 
719*35238bceSAndroid Build Coastguard Worker     thread.newMessage() << "Begin -- eglDestroyContext(" << m_context->display << ", " << m_context->context << ")"
720*35238bceSAndroid Build Coastguard Worker                         << tcu::ThreadUtil::Message::End;
721*35238bceSAndroid Build Coastguard Worker     EGLU_CHECK_CALL(thread.egl, destroyContext(m_context->display, m_context->context));
722*35238bceSAndroid Build Coastguard Worker     thread.newMessage() << "End -- eglDestroyContext()" << tcu::ThreadUtil::Message::End;
723*35238bceSAndroid Build Coastguard Worker     m_context->display = EGL_NO_DISPLAY;
724*35238bceSAndroid Build Coastguard Worker     m_context->context = EGL_NO_CONTEXT;
725*35238bceSAndroid Build Coastguard Worker }
726*35238bceSAndroid Build Coastguard Worker 
727*35238bceSAndroid Build Coastguard Worker class MakeCurrent : public tcu::ThreadUtil::Operation
728*35238bceSAndroid Build Coastguard Worker {
729*35238bceSAndroid Build Coastguard Worker public:
730*35238bceSAndroid Build Coastguard Worker     MakeCurrent(EGLThread &thread, EGLDisplay display, SharedPtr<Surface> surface, SharedPtr<GLES2Context> context);
731*35238bceSAndroid Build Coastguard Worker 
732*35238bceSAndroid Build Coastguard Worker     void exec(tcu::ThreadUtil::Thread &thread);
733*35238bceSAndroid Build Coastguard Worker 
734*35238bceSAndroid Build Coastguard Worker private:
735*35238bceSAndroid Build Coastguard Worker     EGLDisplay m_display;
736*35238bceSAndroid Build Coastguard Worker     SharedPtr<Surface> m_surface;
737*35238bceSAndroid Build Coastguard Worker     SharedPtr<GLES2Context> m_context;
738*35238bceSAndroid Build Coastguard Worker };
739*35238bceSAndroid Build Coastguard Worker 
MakeCurrent(EGLThread & thread,EGLDisplay display,SharedPtr<Surface> surface,SharedPtr<GLES2Context> context)740*35238bceSAndroid Build Coastguard Worker MakeCurrent::MakeCurrent(EGLThread &thread, EGLDisplay display, SharedPtr<Surface> surface,
741*35238bceSAndroid Build Coastguard Worker                          SharedPtr<GLES2Context> context)
742*35238bceSAndroid Build Coastguard Worker     : tcu::ThreadUtil::Operation("MakeCurrent")
743*35238bceSAndroid Build Coastguard Worker     , m_display(display)
744*35238bceSAndroid Build Coastguard Worker     , m_surface(surface)
745*35238bceSAndroid Build Coastguard Worker     , m_context(context)
746*35238bceSAndroid Build Coastguard Worker {
747*35238bceSAndroid Build Coastguard Worker     if (m_context)
748*35238bceSAndroid Build Coastguard Worker         modifyObject(SharedPtr<tcu::ThreadUtil::Object>(m_context));
749*35238bceSAndroid Build Coastguard Worker 
750*35238bceSAndroid Build Coastguard Worker     if (m_surface)
751*35238bceSAndroid Build Coastguard Worker         modifyObject(SharedPtr<tcu::ThreadUtil::Object>(m_surface));
752*35238bceSAndroid Build Coastguard Worker 
753*35238bceSAndroid Build Coastguard Worker     // Release old contexts
754*35238bceSAndroid Build Coastguard Worker     if (thread.context)
755*35238bceSAndroid Build Coastguard Worker     {
756*35238bceSAndroid Build Coastguard Worker         modifyObject(SharedPtr<tcu::ThreadUtil::Object>(thread.context));
757*35238bceSAndroid Build Coastguard Worker     }
758*35238bceSAndroid Build Coastguard Worker 
759*35238bceSAndroid Build Coastguard Worker     // Release old surface
760*35238bceSAndroid Build Coastguard Worker     if (thread.surface)
761*35238bceSAndroid Build Coastguard Worker     {
762*35238bceSAndroid Build Coastguard Worker         modifyObject(SharedPtr<tcu::ThreadUtil::Object>(thread.surface));
763*35238bceSAndroid Build Coastguard Worker     }
764*35238bceSAndroid Build Coastguard Worker 
765*35238bceSAndroid Build Coastguard Worker     thread.context = m_context;
766*35238bceSAndroid Build Coastguard Worker     thread.surface = m_surface;
767*35238bceSAndroid Build Coastguard Worker }
768*35238bceSAndroid Build Coastguard Worker 
exec(tcu::ThreadUtil::Thread & t)769*35238bceSAndroid Build Coastguard Worker void MakeCurrent::exec(tcu::ThreadUtil::Thread &t)
770*35238bceSAndroid Build Coastguard Worker {
771*35238bceSAndroid Build Coastguard Worker     EGLThread &thread = dynamic_cast<EGLThread &>(t);
772*35238bceSAndroid Build Coastguard Worker 
773*35238bceSAndroid Build Coastguard Worker     if (m_context)
774*35238bceSAndroid Build Coastguard Worker     {
775*35238bceSAndroid Build Coastguard Worker         thread.eglSurface     = m_surface->surface;
776*35238bceSAndroid Build Coastguard Worker         thread.runtimeContext = m_context;
777*35238bceSAndroid Build Coastguard Worker 
778*35238bceSAndroid Build Coastguard Worker         DE_ASSERT(m_surface);
779*35238bceSAndroid Build Coastguard Worker         thread.newMessage() << "Begin -- eglMakeCurrent(" << m_display << ", " << m_surface->surface << ", "
780*35238bceSAndroid Build Coastguard Worker                             << m_surface->surface << ", " << m_context->context << ")" << tcu::ThreadUtil::Message::End;
781*35238bceSAndroid Build Coastguard Worker         EGLU_CHECK_CALL(thread.egl, makeCurrent(m_display, m_surface->surface, m_surface->surface, m_context->context));
782*35238bceSAndroid Build Coastguard Worker         thread.newMessage() << "End -- eglMakeCurrent()" << tcu::ThreadUtil::Message::End;
783*35238bceSAndroid Build Coastguard Worker     }
784*35238bceSAndroid Build Coastguard Worker     else
785*35238bceSAndroid Build Coastguard Worker     {
786*35238bceSAndroid Build Coastguard Worker         thread.runtimeContext = m_context;
787*35238bceSAndroid Build Coastguard Worker 
788*35238bceSAndroid Build Coastguard Worker         thread.newMessage() << "Begin -- eglMakeCurrent(" << m_display
789*35238bceSAndroid Build Coastguard Worker                             << ", EGL_NO_SURFACE, EGL_NO_SURFACE, EGL_NO_CONTEXT)" << tcu::ThreadUtil::Message::End;
790*35238bceSAndroid Build Coastguard Worker         EGLU_CHECK_CALL(thread.egl, makeCurrent(m_display, EGL_NO_SURFACE, EGL_NO_SURFACE, EGL_NO_CONTEXT));
791*35238bceSAndroid Build Coastguard Worker         thread.newMessage() << "End -- eglMakeCurrent()" << tcu::ThreadUtil::Message::End;
792*35238bceSAndroid Build Coastguard Worker     }
793*35238bceSAndroid Build Coastguard Worker }
794*35238bceSAndroid Build Coastguard Worker 
795*35238bceSAndroid Build Coastguard Worker class InitGLExtension : public tcu::ThreadUtil::Operation
796*35238bceSAndroid Build Coastguard Worker {
797*35238bceSAndroid Build Coastguard Worker public:
798*35238bceSAndroid Build Coastguard Worker     InitGLExtension(const char *extension);
799*35238bceSAndroid Build Coastguard Worker 
800*35238bceSAndroid Build Coastguard Worker     void exec(tcu::ThreadUtil::Thread &thread);
801*35238bceSAndroid Build Coastguard Worker 
802*35238bceSAndroid Build Coastguard Worker private:
803*35238bceSAndroid Build Coastguard Worker     std::string m_extension;
804*35238bceSAndroid Build Coastguard Worker };
805*35238bceSAndroid Build Coastguard Worker 
InitGLExtension(const char * extension)806*35238bceSAndroid Build Coastguard Worker InitGLExtension::InitGLExtension(const char *extension)
807*35238bceSAndroid Build Coastguard Worker     : tcu::ThreadUtil::Operation("InitGLExtension")
808*35238bceSAndroid Build Coastguard Worker     , m_extension(extension)
809*35238bceSAndroid Build Coastguard Worker {
810*35238bceSAndroid Build Coastguard Worker }
811*35238bceSAndroid Build Coastguard Worker 
exec(tcu::ThreadUtil::Thread & t)812*35238bceSAndroid Build Coastguard Worker void InitGLExtension::exec(tcu::ThreadUtil::Thread &t)
813*35238bceSAndroid Build Coastguard Worker {
814*35238bceSAndroid Build Coastguard Worker     EGLThread &thread = dynamic_cast<EGLThread &>(t);
815*35238bceSAndroid Build Coastguard Worker 
816*35238bceSAndroid Build Coastguard Worker     // Check extensions
817*35238bceSAndroid Build Coastguard Worker     bool found = false;
818*35238bceSAndroid Build Coastguard Worker 
819*35238bceSAndroid Build Coastguard Worker     thread.newMessage() << "Begin -- glGetString(GL_EXTENSIONS)" << tcu::ThreadUtil::Message::End;
820*35238bceSAndroid Build Coastguard Worker     std::string extensions = (const char *)thread.gl.getString(GL_EXTENSIONS);
821*35238bceSAndroid Build Coastguard Worker     thread.newMessage() << "End -- glGetString()" << tcu::ThreadUtil::Message::End;
822*35238bceSAndroid Build Coastguard Worker 
823*35238bceSAndroid Build Coastguard Worker     std::string::size_type pos = extensions.find(" ");
824*35238bceSAndroid Build Coastguard Worker 
825*35238bceSAndroid Build Coastguard Worker     do
826*35238bceSAndroid Build Coastguard Worker     {
827*35238bceSAndroid Build Coastguard Worker         std::string extension;
828*35238bceSAndroid Build Coastguard Worker         if (pos != std::string::npos)
829*35238bceSAndroid Build Coastguard Worker         {
830*35238bceSAndroid Build Coastguard Worker             extension  = extensions.substr(0, pos);
831*35238bceSAndroid Build Coastguard Worker             extensions = extensions.substr(pos + 1);
832*35238bceSAndroid Build Coastguard Worker         }
833*35238bceSAndroid Build Coastguard Worker         else
834*35238bceSAndroid Build Coastguard Worker         {
835*35238bceSAndroid Build Coastguard Worker             extension  = extensions;
836*35238bceSAndroid Build Coastguard Worker             extensions = "";
837*35238bceSAndroid Build Coastguard Worker         }
838*35238bceSAndroid Build Coastguard Worker 
839*35238bceSAndroid Build Coastguard Worker         if (extension == m_extension)
840*35238bceSAndroid Build Coastguard Worker         {
841*35238bceSAndroid Build Coastguard Worker             found = true;
842*35238bceSAndroid Build Coastguard Worker             break;
843*35238bceSAndroid Build Coastguard Worker         }
844*35238bceSAndroid Build Coastguard Worker         pos = extensions.find(" ");
845*35238bceSAndroid Build Coastguard Worker     } while (pos != std::string::npos);
846*35238bceSAndroid Build Coastguard Worker 
847*35238bceSAndroid Build Coastguard Worker     if (!found)
848*35238bceSAndroid Build Coastguard Worker         throw tcu::NotSupportedError((m_extension + " not supported").c_str(), "", __FILE__, __LINE__);
849*35238bceSAndroid Build Coastguard Worker 
850*35238bceSAndroid Build Coastguard Worker     // Query function pointers
851*35238bceSAndroid Build Coastguard Worker     if (m_extension == "GL_OES_EGL_image")
852*35238bceSAndroid Build Coastguard Worker     {
853*35238bceSAndroid Build Coastguard Worker         thread.newMessage() << "Begin -- eglGetProcAddress(\"glEGLImageTargetTexture2DOES\")"
854*35238bceSAndroid Build Coastguard Worker                             << tcu::ThreadUtil::Message::End;
855*35238bceSAndroid Build Coastguard Worker         thread.runtimeContext->glExtensions.imageTargetTexture2D =
856*35238bceSAndroid Build Coastguard Worker             (glEGLImageTargetTexture2DOESFunc)thread.egl.getProcAddress("glEGLImageTargetTexture2DOES");
857*35238bceSAndroid Build Coastguard Worker         thread.newMessage() << "End --  " << ((void *)thread.runtimeContext->glExtensions.imageTargetTexture2D)
858*35238bceSAndroid Build Coastguard Worker                             << " = eglGetProcAddress()" << tcu::ThreadUtil::Message::End;
859*35238bceSAndroid Build Coastguard Worker     }
860*35238bceSAndroid Build Coastguard Worker }
861*35238bceSAndroid Build Coastguard Worker 
862*35238bceSAndroid Build Coastguard Worker class CreatePBufferSurface : public tcu::ThreadUtil::Operation
863*35238bceSAndroid Build Coastguard Worker {
864*35238bceSAndroid Build Coastguard Worker public:
865*35238bceSAndroid Build Coastguard Worker     CreatePBufferSurface(EGLDisplay display, EGLConfig config, EGLint width, EGLint height,
866*35238bceSAndroid Build Coastguard Worker                          SharedPtr<Surface> &surface);
867*35238bceSAndroid Build Coastguard Worker     void exec(tcu::ThreadUtil::Thread &thread);
868*35238bceSAndroid Build Coastguard Worker 
869*35238bceSAndroid Build Coastguard Worker private:
870*35238bceSAndroid Build Coastguard Worker     EGLDisplay m_display;
871*35238bceSAndroid Build Coastguard Worker     EGLConfig m_config;
872*35238bceSAndroid Build Coastguard Worker     EGLint m_width;
873*35238bceSAndroid Build Coastguard Worker     EGLint m_height;
874*35238bceSAndroid Build Coastguard Worker     SharedPtr<Surface> m_surface;
875*35238bceSAndroid Build Coastguard Worker };
876*35238bceSAndroid Build Coastguard Worker 
CreatePBufferSurface(EGLDisplay display,EGLConfig config,EGLint width,EGLint height,SharedPtr<Surface> & surface)877*35238bceSAndroid Build Coastguard Worker CreatePBufferSurface::CreatePBufferSurface(EGLDisplay display, EGLConfig config, EGLint width, EGLint height,
878*35238bceSAndroid Build Coastguard Worker                                            SharedPtr<Surface> &surface)
879*35238bceSAndroid Build Coastguard Worker     : tcu::ThreadUtil::Operation("CreatePBufferSurface")
880*35238bceSAndroid Build Coastguard Worker     , m_display(display)
881*35238bceSAndroid Build Coastguard Worker     , m_config(config)
882*35238bceSAndroid Build Coastguard Worker     , m_width(width)
883*35238bceSAndroid Build Coastguard Worker     , m_height(height)
884*35238bceSAndroid Build Coastguard Worker {
885*35238bceSAndroid Build Coastguard Worker     surface   = SharedPtr<Surface>(new Surface(getEvent()));
886*35238bceSAndroid Build Coastguard Worker     m_surface = surface;
887*35238bceSAndroid Build Coastguard Worker }
888*35238bceSAndroid Build Coastguard Worker 
exec(tcu::ThreadUtil::Thread & t)889*35238bceSAndroid Build Coastguard Worker void CreatePBufferSurface::exec(tcu::ThreadUtil::Thread &t)
890*35238bceSAndroid Build Coastguard Worker {
891*35238bceSAndroid Build Coastguard Worker     EGLThread &thread = dynamic_cast<EGLThread &>(t);
892*35238bceSAndroid Build Coastguard Worker 
893*35238bceSAndroid Build Coastguard Worker     const EGLint attriblist[] = {EGL_WIDTH, m_width, EGL_HEIGHT, m_height, EGL_NONE};
894*35238bceSAndroid Build Coastguard Worker 
895*35238bceSAndroid Build Coastguard Worker     thread.newMessage() << "Begin -- eglCreatePbufferSurface(" << m_display << ", " << m_config << ", { EGL_WIDTH, "
896*35238bceSAndroid Build Coastguard Worker                         << m_width << ", EGL_HEIGHT, " << m_height << ", EGL_NONE })" << tcu::ThreadUtil::Message::End;
897*35238bceSAndroid Build Coastguard Worker     m_surface->surface = thread.egl.createPbufferSurface(m_display, m_config, attriblist);
898*35238bceSAndroid Build Coastguard Worker     thread.newMessage() << "End -- " << m_surface->surface << "= eglCreatePbufferSurface()"
899*35238bceSAndroid Build Coastguard Worker                         << tcu::ThreadUtil::Message::End;
900*35238bceSAndroid Build Coastguard Worker     EGLU_CHECK_MSG(thread.egl, "eglCreatePbufferSurface()");
901*35238bceSAndroid Build Coastguard Worker }
902*35238bceSAndroid Build Coastguard Worker 
903*35238bceSAndroid Build Coastguard Worker class DestroySurface : public tcu::ThreadUtil::Operation
904*35238bceSAndroid Build Coastguard Worker {
905*35238bceSAndroid Build Coastguard Worker public:
906*35238bceSAndroid Build Coastguard Worker     DestroySurface(EGLDisplay display, SharedPtr<Surface> surface);
907*35238bceSAndroid Build Coastguard Worker     void exec(tcu::ThreadUtil::Thread &thread);
908*35238bceSAndroid Build Coastguard Worker 
909*35238bceSAndroid Build Coastguard Worker private:
910*35238bceSAndroid Build Coastguard Worker     EGLDisplay m_display;
911*35238bceSAndroid Build Coastguard Worker     SharedPtr<Surface> m_surface;
912*35238bceSAndroid Build Coastguard Worker };
913*35238bceSAndroid Build Coastguard Worker 
DestroySurface(EGLDisplay display,SharedPtr<Surface> surface)914*35238bceSAndroid Build Coastguard Worker DestroySurface::DestroySurface(EGLDisplay display, SharedPtr<Surface> surface)
915*35238bceSAndroid Build Coastguard Worker     : tcu::ThreadUtil::Operation("DestroySurface")
916*35238bceSAndroid Build Coastguard Worker     , m_display(display)
917*35238bceSAndroid Build Coastguard Worker     , m_surface(surface)
918*35238bceSAndroid Build Coastguard Worker {
919*35238bceSAndroid Build Coastguard Worker     modifyObject(SharedPtr<tcu::ThreadUtil::Object>(m_surface));
920*35238bceSAndroid Build Coastguard Worker }
921*35238bceSAndroid Build Coastguard Worker 
exec(tcu::ThreadUtil::Thread & t)922*35238bceSAndroid Build Coastguard Worker void DestroySurface::exec(tcu::ThreadUtil::Thread &t)
923*35238bceSAndroid Build Coastguard Worker {
924*35238bceSAndroid Build Coastguard Worker     EGLThread &thread = dynamic_cast<EGLThread &>(t);
925*35238bceSAndroid Build Coastguard Worker 
926*35238bceSAndroid Build Coastguard Worker     thread.newMessage() << "Begin -- eglDestroySurface(" << m_display << ",  " << m_surface->surface << ")"
927*35238bceSAndroid Build Coastguard Worker                         << tcu::ThreadUtil::Message::End;
928*35238bceSAndroid Build Coastguard Worker     EGLU_CHECK_CALL(thread.egl, destroySurface(m_display, m_surface->surface));
929*35238bceSAndroid Build Coastguard Worker     thread.newMessage() << "End -- eglDestroySurface()" << tcu::ThreadUtil::Message::End;
930*35238bceSAndroid Build Coastguard Worker }
931*35238bceSAndroid Build Coastguard Worker 
EGLImage(SharedPtr<tcu::ThreadUtil::Event> event,SharedPtr<FenceSync> sync)932*35238bceSAndroid Build Coastguard Worker EGLImage::EGLImage(SharedPtr<tcu::ThreadUtil::Event> event, SharedPtr<FenceSync> sync)
933*35238bceSAndroid Build Coastguard Worker     : Object("EGLImage", event, sync)
934*35238bceSAndroid Build Coastguard Worker     , image(EGL_NO_IMAGE_KHR)
935*35238bceSAndroid Build Coastguard Worker {
936*35238bceSAndroid Build Coastguard Worker }
937*35238bceSAndroid Build Coastguard Worker 
938*35238bceSAndroid Build Coastguard Worker class Texture : public Object
939*35238bceSAndroid Build Coastguard Worker {
940*35238bceSAndroid Build Coastguard Worker public:
941*35238bceSAndroid Build Coastguard Worker     Texture(SharedPtr<tcu::ThreadUtil::Event> event, SharedPtr<FenceSync> sync);
942*35238bceSAndroid Build Coastguard Worker 
943*35238bceSAndroid Build Coastguard Worker     // Runtime parameters
944*35238bceSAndroid Build Coastguard Worker     GLuint texture;
945*35238bceSAndroid Build Coastguard Worker 
946*35238bceSAndroid Build Coastguard Worker     // Call generation time parameters
947*35238bceSAndroid Build Coastguard Worker     bool isDefined;
948*35238bceSAndroid Build Coastguard Worker 
949*35238bceSAndroid Build Coastguard Worker     SharedPtr<EGLImage> sourceImage;
950*35238bceSAndroid Build Coastguard Worker };
951*35238bceSAndroid Build Coastguard Worker 
Texture(SharedPtr<tcu::ThreadUtil::Event> event,SharedPtr<FenceSync> sync)952*35238bceSAndroid Build Coastguard Worker Texture::Texture(SharedPtr<tcu::ThreadUtil::Event> event, SharedPtr<FenceSync> sync)
953*35238bceSAndroid Build Coastguard Worker     : Object("Texture", event, sync)
954*35238bceSAndroid Build Coastguard Worker     , texture(0)
955*35238bceSAndroid Build Coastguard Worker     , isDefined(false)
956*35238bceSAndroid Build Coastguard Worker {
957*35238bceSAndroid Build Coastguard Worker }
958*35238bceSAndroid Build Coastguard Worker 
959*35238bceSAndroid Build Coastguard Worker class CreateTexture : public Operation
960*35238bceSAndroid Build Coastguard Worker {
961*35238bceSAndroid Build Coastguard Worker public:
962*35238bceSAndroid Build Coastguard Worker     CreateTexture(SharedPtr<Texture> &texture, bool useSync, bool serverSync);
963*35238bceSAndroid Build Coastguard Worker     void exec(tcu::ThreadUtil::Thread &thread);
964*35238bceSAndroid Build Coastguard Worker 
965*35238bceSAndroid Build Coastguard Worker private:
966*35238bceSAndroid Build Coastguard Worker     SharedPtr<Texture> m_texture;
967*35238bceSAndroid Build Coastguard Worker };
968*35238bceSAndroid Build Coastguard Worker 
CreateTexture(SharedPtr<Texture> & texture,bool useSync,bool serverSync)969*35238bceSAndroid Build Coastguard Worker CreateTexture::CreateTexture(SharedPtr<Texture> &texture, bool useSync, bool serverSync)
970*35238bceSAndroid Build Coastguard Worker     : Operation("CreateTexture", useSync, serverSync)
971*35238bceSAndroid Build Coastguard Worker {
972*35238bceSAndroid Build Coastguard Worker     texture   = SharedPtr<Texture>(new Texture(getEvent(), getSync()));
973*35238bceSAndroid Build Coastguard Worker     m_texture = texture;
974*35238bceSAndroid Build Coastguard Worker }
975*35238bceSAndroid Build Coastguard Worker 
exec(tcu::ThreadUtil::Thread & t)976*35238bceSAndroid Build Coastguard Worker void CreateTexture::exec(tcu::ThreadUtil::Thread &t)
977*35238bceSAndroid Build Coastguard Worker {
978*35238bceSAndroid Build Coastguard Worker     EGLThread &thread = dynamic_cast<EGLThread &>(t);
979*35238bceSAndroid Build Coastguard Worker     GLuint tex        = 0;
980*35238bceSAndroid Build Coastguard Worker 
981*35238bceSAndroid Build Coastguard Worker     thread.newMessage() << "Begin -- glGenTextures(1, { 0 })" << tcu::ThreadUtil::Message::End;
982*35238bceSAndroid Build Coastguard Worker     GLU_CHECK_GLW_CALL(thread.gl, genTextures(1, &tex));
983*35238bceSAndroid Build Coastguard Worker     thread.newMessage() << "End -- glGenTextures(1, { " << tex << " })" << tcu::ThreadUtil::Message::End;
984*35238bceSAndroid Build Coastguard Worker 
985*35238bceSAndroid Build Coastguard Worker     m_texture->texture = tex;
986*35238bceSAndroid Build Coastguard Worker }
987*35238bceSAndroid Build Coastguard Worker 
988*35238bceSAndroid Build Coastguard Worker class DeleteTexture : public Operation
989*35238bceSAndroid Build Coastguard Worker {
990*35238bceSAndroid Build Coastguard Worker public:
991*35238bceSAndroid Build Coastguard Worker     DeleteTexture(SharedPtr<Texture> texture, bool useSync, bool serverSync);
992*35238bceSAndroid Build Coastguard Worker     void exec(tcu::ThreadUtil::Thread &thread);
993*35238bceSAndroid Build Coastguard Worker 
994*35238bceSAndroid Build Coastguard Worker private:
995*35238bceSAndroid Build Coastguard Worker     SharedPtr<Texture> m_texture;
996*35238bceSAndroid Build Coastguard Worker };
997*35238bceSAndroid Build Coastguard Worker 
DeleteTexture(SharedPtr<Texture> texture,bool useSync,bool serverSync)998*35238bceSAndroid Build Coastguard Worker DeleteTexture::DeleteTexture(SharedPtr<Texture> texture, bool useSync, bool serverSync)
999*35238bceSAndroid Build Coastguard Worker     : Operation("DeleteTexture", useSync, serverSync)
1000*35238bceSAndroid Build Coastguard Worker     , m_texture(texture)
1001*35238bceSAndroid Build Coastguard Worker {
1002*35238bceSAndroid Build Coastguard Worker     modifyGLObject(SharedPtr<Object>(m_texture));
1003*35238bceSAndroid Build Coastguard Worker }
1004*35238bceSAndroid Build Coastguard Worker 
exec(tcu::ThreadUtil::Thread & t)1005*35238bceSAndroid Build Coastguard Worker void DeleteTexture::exec(tcu::ThreadUtil::Thread &t)
1006*35238bceSAndroid Build Coastguard Worker {
1007*35238bceSAndroid Build Coastguard Worker     EGLThread &thread = dynamic_cast<EGLThread &>(t);
1008*35238bceSAndroid Build Coastguard Worker     GLuint tex        = m_texture->texture;
1009*35238bceSAndroid Build Coastguard Worker 
1010*35238bceSAndroid Build Coastguard Worker     thread.newMessage() << "Begin -- glDeleteTextures(1, { " << tex << " })" << tcu::ThreadUtil::Message::End;
1011*35238bceSAndroid Build Coastguard Worker     GLU_CHECK_GLW_CALL(thread.gl, deleteTextures(1, &tex));
1012*35238bceSAndroid Build Coastguard Worker     thread.newMessage() << "End -- glDeleteTextures()" << tcu::ThreadUtil::Message::End;
1013*35238bceSAndroid Build Coastguard Worker 
1014*35238bceSAndroid Build Coastguard Worker     m_texture->texture = 0;
1015*35238bceSAndroid Build Coastguard Worker }
1016*35238bceSAndroid Build Coastguard Worker 
1017*35238bceSAndroid Build Coastguard Worker class TexImage2D : public Operation
1018*35238bceSAndroid Build Coastguard Worker {
1019*35238bceSAndroid Build Coastguard Worker public:
1020*35238bceSAndroid Build Coastguard Worker     TexImage2D(SharedPtr<Texture> texture, GLint level, GLint internalFormat, GLsizei width, GLsizei height,
1021*35238bceSAndroid Build Coastguard Worker                GLenum format, GLenum type, bool useSync, bool serverSync);
1022*35238bceSAndroid Build Coastguard Worker     void exec(tcu::ThreadUtil::Thread &thread);
1023*35238bceSAndroid Build Coastguard Worker 
1024*35238bceSAndroid Build Coastguard Worker private:
1025*35238bceSAndroid Build Coastguard Worker     SharedPtr<Texture> m_texture;
1026*35238bceSAndroid Build Coastguard Worker     GLint m_level;
1027*35238bceSAndroid Build Coastguard Worker     GLint m_internalFormat;
1028*35238bceSAndroid Build Coastguard Worker     GLsizei m_width;
1029*35238bceSAndroid Build Coastguard Worker     GLsizei m_height;
1030*35238bceSAndroid Build Coastguard Worker     GLenum m_format;
1031*35238bceSAndroid Build Coastguard Worker     GLenum m_type;
1032*35238bceSAndroid Build Coastguard Worker };
1033*35238bceSAndroid Build Coastguard Worker 
TexImage2D(SharedPtr<Texture> texture,GLint level,GLint internalFormat,GLsizei width,GLsizei height,GLenum format,GLenum type,bool useSync,bool serverSync)1034*35238bceSAndroid Build Coastguard Worker TexImage2D::TexImage2D(SharedPtr<Texture> texture, GLint level, GLint internalFormat, GLsizei width, GLsizei height,
1035*35238bceSAndroid Build Coastguard Worker                        GLenum format, GLenum type, bool useSync, bool serverSync)
1036*35238bceSAndroid Build Coastguard Worker     : Operation("TexImage2D", useSync, serverSync)
1037*35238bceSAndroid Build Coastguard Worker     , m_texture(texture)
1038*35238bceSAndroid Build Coastguard Worker     , m_level(level)
1039*35238bceSAndroid Build Coastguard Worker     , m_internalFormat(internalFormat)
1040*35238bceSAndroid Build Coastguard Worker     , m_width(width)
1041*35238bceSAndroid Build Coastguard Worker     , m_height(height)
1042*35238bceSAndroid Build Coastguard Worker     , m_format(format)
1043*35238bceSAndroid Build Coastguard Worker     , m_type(type)
1044*35238bceSAndroid Build Coastguard Worker {
1045*35238bceSAndroid Build Coastguard Worker     modifyGLObject(SharedPtr<Object>(m_texture));
1046*35238bceSAndroid Build Coastguard Worker     m_texture->isDefined = true;
1047*35238bceSAndroid Build Coastguard Worker 
1048*35238bceSAndroid Build Coastguard Worker     // Orphang texture
1049*35238bceSAndroid Build Coastguard Worker     texture->sourceImage = SharedPtr<EGLImage>();
1050*35238bceSAndroid Build Coastguard Worker }
1051*35238bceSAndroid Build Coastguard Worker 
exec(tcu::ThreadUtil::Thread & t)1052*35238bceSAndroid Build Coastguard Worker void TexImage2D::exec(tcu::ThreadUtil::Thread &t)
1053*35238bceSAndroid Build Coastguard Worker {
1054*35238bceSAndroid Build Coastguard Worker     EGLThread &thread = dynamic_cast<EGLThread &>(t);
1055*35238bceSAndroid Build Coastguard Worker     void *unusedData  = thread.getUnusedData(m_width * m_height * 4);
1056*35238bceSAndroid Build Coastguard Worker 
1057*35238bceSAndroid Build Coastguard Worker     thread.newMessage() << "Begin -- glBindTexture(GL_TEXTURE_2D, " << m_texture->texture << ")"
1058*35238bceSAndroid Build Coastguard Worker                         << tcu::ThreadUtil::Message::End;
1059*35238bceSAndroid Build Coastguard Worker     GLU_CHECK_GLW_CALL(thread.gl, bindTexture(GL_TEXTURE_2D, m_texture->texture));
1060*35238bceSAndroid Build Coastguard Worker     thread.newMessage() << "End -- glBindTexture()" << tcu::ThreadUtil::Message::End;
1061*35238bceSAndroid Build Coastguard Worker 
1062*35238bceSAndroid Build Coastguard Worker     thread.newMessage() << "Begin -- glTexImage2D(GL_TEXTURE_2D, " << m_level << ", " << m_internalFormat << ", "
1063*35238bceSAndroid Build Coastguard Worker                         << m_width << ", " << m_height << ", 0, " << m_format << ", " << m_type << ", data)"
1064*35238bceSAndroid Build Coastguard Worker                         << tcu::ThreadUtil::Message::End;
1065*35238bceSAndroid Build Coastguard Worker     GLU_CHECK_GLW_CALL(thread.gl, texImage2D(GL_TEXTURE_2D, m_level, m_internalFormat, m_width, m_height, 0, m_format,
1066*35238bceSAndroid Build Coastguard Worker                                              m_type, unusedData));
1067*35238bceSAndroid Build Coastguard Worker     thread.newMessage() << "End -- glTexImage2D()" << tcu::ThreadUtil::Message::End;
1068*35238bceSAndroid Build Coastguard Worker 
1069*35238bceSAndroid Build Coastguard Worker     thread.newMessage() << "Begin -- glBindTexture(GL_TEXTURE_2D, 0)" << tcu::ThreadUtil::Message::End;
1070*35238bceSAndroid Build Coastguard Worker     GLU_CHECK_GLW_CALL(thread.gl, bindTexture(GL_TEXTURE_2D, 0));
1071*35238bceSAndroid Build Coastguard Worker     thread.newMessage() << "End -- glBindTexture()" << tcu::ThreadUtil::Message::End;
1072*35238bceSAndroid Build Coastguard Worker }
1073*35238bceSAndroid Build Coastguard Worker 
1074*35238bceSAndroid Build Coastguard Worker class TexSubImage2D : public Operation
1075*35238bceSAndroid Build Coastguard Worker {
1076*35238bceSAndroid Build Coastguard Worker public:
1077*35238bceSAndroid Build Coastguard Worker     TexSubImage2D(SharedPtr<Texture> texture, GLint level, GLint xoffset, GLint yoffset, GLsizei width, GLsizei height,
1078*35238bceSAndroid Build Coastguard Worker                   GLenum format, GLenum type, bool useSync, bool serverSync);
1079*35238bceSAndroid Build Coastguard Worker     void exec(tcu::ThreadUtil::Thread &thread);
1080*35238bceSAndroid Build Coastguard Worker 
1081*35238bceSAndroid Build Coastguard Worker private:
1082*35238bceSAndroid Build Coastguard Worker     SharedPtr<Texture> m_texture;
1083*35238bceSAndroid Build Coastguard Worker     GLint m_level;
1084*35238bceSAndroid Build Coastguard Worker     GLint m_xoffset;
1085*35238bceSAndroid Build Coastguard Worker     GLint m_yoffset;
1086*35238bceSAndroid Build Coastguard Worker     GLsizei m_width;
1087*35238bceSAndroid Build Coastguard Worker     GLsizei m_height;
1088*35238bceSAndroid Build Coastguard Worker     GLenum m_format;
1089*35238bceSAndroid Build Coastguard Worker     GLenum m_type;
1090*35238bceSAndroid Build Coastguard Worker };
1091*35238bceSAndroid Build Coastguard Worker 
TexSubImage2D(SharedPtr<Texture> texture,GLint level,GLint xoffset,GLint yoffset,GLsizei width,GLsizei height,GLenum format,GLenum type,bool useSync,bool serverSync)1092*35238bceSAndroid Build Coastguard Worker TexSubImage2D::TexSubImage2D(SharedPtr<Texture> texture, GLint level, GLint xoffset, GLint yoffset, GLsizei width,
1093*35238bceSAndroid Build Coastguard Worker                              GLsizei height, GLenum format, GLenum type, bool useSync, bool serverSync)
1094*35238bceSAndroid Build Coastguard Worker     : Operation("TexSubImage2D", useSync, serverSync)
1095*35238bceSAndroid Build Coastguard Worker     , m_texture(texture)
1096*35238bceSAndroid Build Coastguard Worker     , m_level(level)
1097*35238bceSAndroid Build Coastguard Worker     , m_xoffset(xoffset)
1098*35238bceSAndroid Build Coastguard Worker     , m_yoffset(yoffset)
1099*35238bceSAndroid Build Coastguard Worker     , m_width(width)
1100*35238bceSAndroid Build Coastguard Worker     , m_height(height)
1101*35238bceSAndroid Build Coastguard Worker     , m_format(format)
1102*35238bceSAndroid Build Coastguard Worker     , m_type(type)
1103*35238bceSAndroid Build Coastguard Worker {
1104*35238bceSAndroid Build Coastguard Worker     modifyGLObject(SharedPtr<Object>(m_texture));
1105*35238bceSAndroid Build Coastguard Worker 
1106*35238bceSAndroid Build Coastguard Worker     if (m_texture->sourceImage)
1107*35238bceSAndroid Build Coastguard Worker         modifyGLObject(SharedPtr<Object>(m_texture->sourceImage));
1108*35238bceSAndroid Build Coastguard Worker }
1109*35238bceSAndroid Build Coastguard Worker 
exec(tcu::ThreadUtil::Thread & t)1110*35238bceSAndroid Build Coastguard Worker void TexSubImage2D::exec(tcu::ThreadUtil::Thread &t)
1111*35238bceSAndroid Build Coastguard Worker {
1112*35238bceSAndroid Build Coastguard Worker     EGLThread &thread = dynamic_cast<EGLThread &>(t);
1113*35238bceSAndroid Build Coastguard Worker     void *unusedData  = thread.getUnusedData(m_width * m_height * 4);
1114*35238bceSAndroid Build Coastguard Worker 
1115*35238bceSAndroid Build Coastguard Worker     thread.newMessage() << "Begin -- glBindTexture(GL_TEXTURE_2D, " << m_texture->texture << ")"
1116*35238bceSAndroid Build Coastguard Worker                         << tcu::ThreadUtil::Message::End;
1117*35238bceSAndroid Build Coastguard Worker     GLU_CHECK_GLW_CALL(thread.gl, bindTexture(GL_TEXTURE_2D, m_texture->texture));
1118*35238bceSAndroid Build Coastguard Worker     thread.newMessage() << "End -- glBindTexture()" << tcu::ThreadUtil::Message::End;
1119*35238bceSAndroid Build Coastguard Worker 
1120*35238bceSAndroid Build Coastguard Worker     thread.newMessage() << "Begin -- glTexSubImage2D(GL_TEXTURE_2D, " << m_level << ", " << m_xoffset << ", "
1121*35238bceSAndroid Build Coastguard Worker                         << m_yoffset << ", " << m_width << ", " << m_height << ", 0, " << m_format << ", " << m_type
1122*35238bceSAndroid Build Coastguard Worker                         << ", <data>)" << tcu::ThreadUtil::Message::End;
1123*35238bceSAndroid Build Coastguard Worker     GLU_CHECK_GLW_CALL(thread.gl, texSubImage2D(GL_TEXTURE_2D, m_level, m_xoffset, m_yoffset, m_width, m_height,
1124*35238bceSAndroid Build Coastguard Worker                                                 m_format, m_type, unusedData));
1125*35238bceSAndroid Build Coastguard Worker     thread.newMessage() << "End -- glSubTexImage2D()" << tcu::ThreadUtil::Message::End;
1126*35238bceSAndroid Build Coastguard Worker 
1127*35238bceSAndroid Build Coastguard Worker     thread.newMessage() << "Begin -- glBindTexture(GL_TEXTURE_2D, 0)" << tcu::ThreadUtil::Message::End;
1128*35238bceSAndroid Build Coastguard Worker     GLU_CHECK_GLW_CALL(thread.gl, bindTexture(GL_TEXTURE_2D, 0));
1129*35238bceSAndroid Build Coastguard Worker     thread.newMessage() << "End -- glBindTexture()" << tcu::ThreadUtil::Message::End;
1130*35238bceSAndroid Build Coastguard Worker }
1131*35238bceSAndroid Build Coastguard Worker 
1132*35238bceSAndroid Build Coastguard Worker class CopyTexImage2D : public Operation
1133*35238bceSAndroid Build Coastguard Worker {
1134*35238bceSAndroid Build Coastguard Worker public:
1135*35238bceSAndroid Build Coastguard Worker     CopyTexImage2D(SharedPtr<Texture> texture, GLint level, GLint internalFormat, GLint x, GLint y, GLsizei width,
1136*35238bceSAndroid Build Coastguard Worker                    GLsizei height, GLint border, bool useSync, bool serverSync);
1137*35238bceSAndroid Build Coastguard Worker     void exec(tcu::ThreadUtil::Thread &thread);
1138*35238bceSAndroid Build Coastguard Worker 
1139*35238bceSAndroid Build Coastguard Worker private:
1140*35238bceSAndroid Build Coastguard Worker     SharedPtr<Texture> m_texture;
1141*35238bceSAndroid Build Coastguard Worker     GLint m_level;
1142*35238bceSAndroid Build Coastguard Worker     GLint m_internalFormat;
1143*35238bceSAndroid Build Coastguard Worker     GLint m_x;
1144*35238bceSAndroid Build Coastguard Worker     GLint m_y;
1145*35238bceSAndroid Build Coastguard Worker     GLsizei m_width;
1146*35238bceSAndroid Build Coastguard Worker     GLsizei m_height;
1147*35238bceSAndroid Build Coastguard Worker     GLint m_border;
1148*35238bceSAndroid Build Coastguard Worker };
1149*35238bceSAndroid Build Coastguard Worker 
CopyTexImage2D(SharedPtr<Texture> texture,GLint level,GLint internalFormat,GLint x,GLint y,GLsizei width,GLsizei height,GLint border,bool useSync,bool serverSync)1150*35238bceSAndroid Build Coastguard Worker CopyTexImage2D::CopyTexImage2D(SharedPtr<Texture> texture, GLint level, GLint internalFormat, GLint x, GLint y,
1151*35238bceSAndroid Build Coastguard Worker                                GLsizei width, GLsizei height, GLint border, bool useSync, bool serverSync)
1152*35238bceSAndroid Build Coastguard Worker     : Operation("CopyTexImage2D", useSync, serverSync)
1153*35238bceSAndroid Build Coastguard Worker     , m_texture(texture)
1154*35238bceSAndroid Build Coastguard Worker     , m_level(level)
1155*35238bceSAndroid Build Coastguard Worker     , m_internalFormat(internalFormat)
1156*35238bceSAndroid Build Coastguard Worker     , m_x(x)
1157*35238bceSAndroid Build Coastguard Worker     , m_y(y)
1158*35238bceSAndroid Build Coastguard Worker     , m_width(width)
1159*35238bceSAndroid Build Coastguard Worker     , m_height(height)
1160*35238bceSAndroid Build Coastguard Worker     , m_border(border)
1161*35238bceSAndroid Build Coastguard Worker {
1162*35238bceSAndroid Build Coastguard Worker     modifyGLObject(SharedPtr<Object>(m_texture));
1163*35238bceSAndroid Build Coastguard Worker     texture->isDefined = true;
1164*35238bceSAndroid Build Coastguard Worker 
1165*35238bceSAndroid Build Coastguard Worker     // Orphang texture
1166*35238bceSAndroid Build Coastguard Worker     texture->sourceImage = SharedPtr<EGLImage>();
1167*35238bceSAndroid Build Coastguard Worker }
1168*35238bceSAndroid Build Coastguard Worker 
exec(tcu::ThreadUtil::Thread & t)1169*35238bceSAndroid Build Coastguard Worker void CopyTexImage2D::exec(tcu::ThreadUtil::Thread &t)
1170*35238bceSAndroid Build Coastguard Worker {
1171*35238bceSAndroid Build Coastguard Worker     EGLThread &thread = dynamic_cast<EGLThread &>(t);
1172*35238bceSAndroid Build Coastguard Worker 
1173*35238bceSAndroid Build Coastguard Worker     thread.newMessage() << "Begin -- glBindTexture(GL_TEXTURE_2D, " << m_texture->texture << ")"
1174*35238bceSAndroid Build Coastguard Worker                         << tcu::ThreadUtil::Message::End;
1175*35238bceSAndroid Build Coastguard Worker     GLU_CHECK_GLW_CALL(thread.gl, bindTexture(GL_TEXTURE_2D, m_texture->texture));
1176*35238bceSAndroid Build Coastguard Worker     thread.newMessage() << "End -- glBindTexture()" << tcu::ThreadUtil::Message::End;
1177*35238bceSAndroid Build Coastguard Worker 
1178*35238bceSAndroid Build Coastguard Worker     thread.newMessage() << "Begin -- glCopyTexImage2D(GL_TEXTURE_2D, " << m_level << ", " << m_internalFormat << ", "
1179*35238bceSAndroid Build Coastguard Worker                         << m_x << ", " << m_y << ", " << m_width << ", " << m_height << ", " << m_border << ")"
1180*35238bceSAndroid Build Coastguard Worker                         << tcu::ThreadUtil::Message::End;
1181*35238bceSAndroid Build Coastguard Worker     GLU_CHECK_GLW_CALL(thread.gl,
1182*35238bceSAndroid Build Coastguard Worker                        copyTexImage2D(GL_TEXTURE_2D, m_level, m_internalFormat, m_x, m_y, m_width, m_height, m_border));
1183*35238bceSAndroid Build Coastguard Worker     thread.newMessage() << "End -- glCopyTexImage2D()" << tcu::ThreadUtil::Message::End;
1184*35238bceSAndroid Build Coastguard Worker 
1185*35238bceSAndroid Build Coastguard Worker     thread.newMessage() << "Begin -- glBindTexture(GL_TEXTURE_2D, 0)" << tcu::ThreadUtil::Message::End;
1186*35238bceSAndroid Build Coastguard Worker     GLU_CHECK_GLW_CALL(thread.gl, bindTexture(GL_TEXTURE_2D, 0));
1187*35238bceSAndroid Build Coastguard Worker     thread.newMessage() << "End -- glBindTexture()" << tcu::ThreadUtil::Message::End;
1188*35238bceSAndroid Build Coastguard Worker }
1189*35238bceSAndroid Build Coastguard Worker 
1190*35238bceSAndroid Build Coastguard Worker class CopyTexSubImage2D : public Operation
1191*35238bceSAndroid Build Coastguard Worker {
1192*35238bceSAndroid Build Coastguard Worker public:
1193*35238bceSAndroid Build Coastguard Worker     CopyTexSubImage2D(SharedPtr<Texture> texture, GLint level, GLint xoffset, GLint yoffset, GLint x, GLint y,
1194*35238bceSAndroid Build Coastguard Worker                       GLsizei width, GLsizei height, bool useSync, bool serverSync);
1195*35238bceSAndroid Build Coastguard Worker     void exec(tcu::ThreadUtil::Thread &thread);
1196*35238bceSAndroid Build Coastguard Worker 
1197*35238bceSAndroid Build Coastguard Worker private:
1198*35238bceSAndroid Build Coastguard Worker     SharedPtr<Texture> m_texture;
1199*35238bceSAndroid Build Coastguard Worker     GLint m_level;
1200*35238bceSAndroid Build Coastguard Worker     GLint m_xoffset;
1201*35238bceSAndroid Build Coastguard Worker     GLint m_yoffset;
1202*35238bceSAndroid Build Coastguard Worker     GLint m_x;
1203*35238bceSAndroid Build Coastguard Worker     GLint m_y;
1204*35238bceSAndroid Build Coastguard Worker     GLsizei m_width;
1205*35238bceSAndroid Build Coastguard Worker     GLsizei m_height;
1206*35238bceSAndroid Build Coastguard Worker };
1207*35238bceSAndroid Build Coastguard Worker 
CopyTexSubImage2D(SharedPtr<Texture> texture,GLint level,GLint xoffset,GLint yoffset,GLint x,GLint y,GLsizei width,GLsizei height,bool useSync,bool serverSync)1208*35238bceSAndroid Build Coastguard Worker CopyTexSubImage2D::CopyTexSubImage2D(SharedPtr<Texture> texture, GLint level, GLint xoffset, GLint yoffset, GLint x,
1209*35238bceSAndroid Build Coastguard Worker                                      GLint y, GLsizei width, GLsizei height, bool useSync, bool serverSync)
1210*35238bceSAndroid Build Coastguard Worker     : Operation("CopyTexSubImage2D", useSync, serverSync)
1211*35238bceSAndroid Build Coastguard Worker     , m_texture(texture)
1212*35238bceSAndroid Build Coastguard Worker     , m_level(level)
1213*35238bceSAndroid Build Coastguard Worker     , m_xoffset(xoffset)
1214*35238bceSAndroid Build Coastguard Worker     , m_yoffset(yoffset)
1215*35238bceSAndroid Build Coastguard Worker     , m_x(x)
1216*35238bceSAndroid Build Coastguard Worker     , m_y(y)
1217*35238bceSAndroid Build Coastguard Worker     , m_width(width)
1218*35238bceSAndroid Build Coastguard Worker     , m_height(height)
1219*35238bceSAndroid Build Coastguard Worker {
1220*35238bceSAndroid Build Coastguard Worker     modifyGLObject(SharedPtr<Object>(m_texture));
1221*35238bceSAndroid Build Coastguard Worker 
1222*35238bceSAndroid Build Coastguard Worker     if (m_texture->sourceImage)
1223*35238bceSAndroid Build Coastguard Worker         modifyGLObject(SharedPtr<Object>(m_texture->sourceImage));
1224*35238bceSAndroid Build Coastguard Worker }
1225*35238bceSAndroid Build Coastguard Worker 
exec(tcu::ThreadUtil::Thread & t)1226*35238bceSAndroid Build Coastguard Worker void CopyTexSubImage2D::exec(tcu::ThreadUtil::Thread &t)
1227*35238bceSAndroid Build Coastguard Worker {
1228*35238bceSAndroid Build Coastguard Worker     EGLThread &thread = dynamic_cast<EGLThread &>(t);
1229*35238bceSAndroid Build Coastguard Worker 
1230*35238bceSAndroid Build Coastguard Worker     thread.newMessage() << "Begin -- glBindTexture(GL_TEXTURE_2D, " << m_texture->texture << ")"
1231*35238bceSAndroid Build Coastguard Worker                         << tcu::ThreadUtil::Message::End;
1232*35238bceSAndroid Build Coastguard Worker     GLU_CHECK_GLW_CALL(thread.gl, bindTexture(GL_TEXTURE_2D, m_texture->texture));
1233*35238bceSAndroid Build Coastguard Worker     thread.newMessage() << "End -- glBindTexture()" << tcu::ThreadUtil::Message::End;
1234*35238bceSAndroid Build Coastguard Worker 
1235*35238bceSAndroid Build Coastguard Worker     thread.newMessage() << "Begin -- glCopyTexSubImage2D(GL_TEXTURE_2D, " << m_level << ", " << m_xoffset << ", "
1236*35238bceSAndroid Build Coastguard Worker                         << m_yoffset << ", " << m_x << ", " << m_y << ", " << m_width << ", " << m_height << ")"
1237*35238bceSAndroid Build Coastguard Worker                         << tcu::ThreadUtil::Message::End;
1238*35238bceSAndroid Build Coastguard Worker     GLU_CHECK_GLW_CALL(thread.gl,
1239*35238bceSAndroid Build Coastguard Worker                        copyTexSubImage2D(GL_TEXTURE_2D, m_level, m_xoffset, m_yoffset, m_x, m_y, m_width, m_height));
1240*35238bceSAndroid Build Coastguard Worker     thread.newMessage() << "End -- glCopyTexSubImage2D()" << tcu::ThreadUtil::Message::End;
1241*35238bceSAndroid Build Coastguard Worker 
1242*35238bceSAndroid Build Coastguard Worker     thread.newMessage() << "Begin -- glBindTexture(GL_TEXTURE_2D, 0)" << tcu::ThreadUtil::Message::End;
1243*35238bceSAndroid Build Coastguard Worker     GLU_CHECK_GLW_CALL(thread.gl, bindTexture(GL_TEXTURE_2D, 0));
1244*35238bceSAndroid Build Coastguard Worker     thread.newMessage() << "End -- glBindTexture()" << tcu::ThreadUtil::Message::End;
1245*35238bceSAndroid Build Coastguard Worker }
1246*35238bceSAndroid Build Coastguard Worker 
1247*35238bceSAndroid Build Coastguard Worker class Buffer : public Object
1248*35238bceSAndroid Build Coastguard Worker {
1249*35238bceSAndroid Build Coastguard Worker public:
1250*35238bceSAndroid Build Coastguard Worker     Buffer(SharedPtr<tcu::ThreadUtil::Event> event, SharedPtr<FenceSync> sync);
1251*35238bceSAndroid Build Coastguard Worker 
1252*35238bceSAndroid Build Coastguard Worker     // Runtime attributes
1253*35238bceSAndroid Build Coastguard Worker     GLuint buffer;
1254*35238bceSAndroid Build Coastguard Worker     GLsizeiptr size;
1255*35238bceSAndroid Build Coastguard Worker 
1256*35238bceSAndroid Build Coastguard Worker     // Call generation time parameters
1257*35238bceSAndroid Build Coastguard Worker     bool isDefined;
1258*35238bceSAndroid Build Coastguard Worker };
1259*35238bceSAndroid Build Coastguard Worker 
Buffer(SharedPtr<tcu::ThreadUtil::Event> event,SharedPtr<FenceSync> sync)1260*35238bceSAndroid Build Coastguard Worker Buffer::Buffer(SharedPtr<tcu::ThreadUtil::Event> event, SharedPtr<FenceSync> sync)
1261*35238bceSAndroid Build Coastguard Worker     : Object("Buffer", event, sync)
1262*35238bceSAndroid Build Coastguard Worker     , buffer(0)
1263*35238bceSAndroid Build Coastguard Worker     , size(0)
1264*35238bceSAndroid Build Coastguard Worker     , isDefined(false)
1265*35238bceSAndroid Build Coastguard Worker {
1266*35238bceSAndroid Build Coastguard Worker }
1267*35238bceSAndroid Build Coastguard Worker 
1268*35238bceSAndroid Build Coastguard Worker class CreateBuffer : public Operation
1269*35238bceSAndroid Build Coastguard Worker {
1270*35238bceSAndroid Build Coastguard Worker public:
1271*35238bceSAndroid Build Coastguard Worker     CreateBuffer(SharedPtr<Buffer> &buffer, bool useSync, bool serverSync);
1272*35238bceSAndroid Build Coastguard Worker     void exec(tcu::ThreadUtil::Thread &thread);
1273*35238bceSAndroid Build Coastguard Worker 
1274*35238bceSAndroid Build Coastguard Worker private:
1275*35238bceSAndroid Build Coastguard Worker     SharedPtr<Buffer> m_buffer;
1276*35238bceSAndroid Build Coastguard Worker };
1277*35238bceSAndroid Build Coastguard Worker 
CreateBuffer(SharedPtr<Buffer> & buffer,bool useSync,bool serverSync)1278*35238bceSAndroid Build Coastguard Worker CreateBuffer::CreateBuffer(SharedPtr<Buffer> &buffer, bool useSync, bool serverSync)
1279*35238bceSAndroid Build Coastguard Worker     : Operation("CreateBuffer", useSync, serverSync)
1280*35238bceSAndroid Build Coastguard Worker {
1281*35238bceSAndroid Build Coastguard Worker     buffer   = SharedPtr<Buffer>(new Buffer(getEvent(), getSync()));
1282*35238bceSAndroid Build Coastguard Worker     m_buffer = buffer;
1283*35238bceSAndroid Build Coastguard Worker }
1284*35238bceSAndroid Build Coastguard Worker 
exec(tcu::ThreadUtil::Thread & t)1285*35238bceSAndroid Build Coastguard Worker void CreateBuffer::exec(tcu::ThreadUtil::Thread &t)
1286*35238bceSAndroid Build Coastguard Worker {
1287*35238bceSAndroid Build Coastguard Worker     EGLThread &thread = dynamic_cast<EGLThread &>(t);
1288*35238bceSAndroid Build Coastguard Worker     GLuint buffer     = 0;
1289*35238bceSAndroid Build Coastguard Worker 
1290*35238bceSAndroid Build Coastguard Worker     thread.newMessage() << "Begin -- glGenBuffers(1, { 0 })" << tcu::ThreadUtil::Message::End;
1291*35238bceSAndroid Build Coastguard Worker     GLU_CHECK_GLW_CALL(thread.gl, genBuffers(1, &buffer));
1292*35238bceSAndroid Build Coastguard Worker     thread.newMessage() << "End -- glGenBuffers(1, { " << buffer << " })" << tcu::ThreadUtil::Message::End;
1293*35238bceSAndroid Build Coastguard Worker 
1294*35238bceSAndroid Build Coastguard Worker     m_buffer->buffer = buffer;
1295*35238bceSAndroid Build Coastguard Worker }
1296*35238bceSAndroid Build Coastguard Worker 
1297*35238bceSAndroid Build Coastguard Worker class DeleteBuffer : public Operation
1298*35238bceSAndroid Build Coastguard Worker {
1299*35238bceSAndroid Build Coastguard Worker public:
1300*35238bceSAndroid Build Coastguard Worker     DeleteBuffer(SharedPtr<Buffer> buffer, bool useSync, bool serverSync);
1301*35238bceSAndroid Build Coastguard Worker     void exec(tcu::ThreadUtil::Thread &thread);
1302*35238bceSAndroid Build Coastguard Worker 
1303*35238bceSAndroid Build Coastguard Worker private:
1304*35238bceSAndroid Build Coastguard Worker     SharedPtr<Buffer> m_buffer;
1305*35238bceSAndroid Build Coastguard Worker };
1306*35238bceSAndroid Build Coastguard Worker 
DeleteBuffer(SharedPtr<Buffer> buffer,bool useSync,bool serverSync)1307*35238bceSAndroid Build Coastguard Worker DeleteBuffer::DeleteBuffer(SharedPtr<Buffer> buffer, bool useSync, bool serverSync)
1308*35238bceSAndroid Build Coastguard Worker     : Operation("DeleteBuffer", useSync, serverSync)
1309*35238bceSAndroid Build Coastguard Worker     , m_buffer(buffer)
1310*35238bceSAndroid Build Coastguard Worker {
1311*35238bceSAndroid Build Coastguard Worker     modifyGLObject(SharedPtr<Object>(m_buffer));
1312*35238bceSAndroid Build Coastguard Worker }
1313*35238bceSAndroid Build Coastguard Worker 
exec(tcu::ThreadUtil::Thread & t)1314*35238bceSAndroid Build Coastguard Worker void DeleteBuffer::exec(tcu::ThreadUtil::Thread &t)
1315*35238bceSAndroid Build Coastguard Worker {
1316*35238bceSAndroid Build Coastguard Worker     EGLThread &thread = dynamic_cast<EGLThread &>(t);
1317*35238bceSAndroid Build Coastguard Worker     GLuint buffer     = m_buffer->buffer;
1318*35238bceSAndroid Build Coastguard Worker 
1319*35238bceSAndroid Build Coastguard Worker     thread.newMessage() << "Begin -- glDeleteBuffers(1, { " << buffer << " })" << tcu::ThreadUtil::Message::End;
1320*35238bceSAndroid Build Coastguard Worker     GLU_CHECK_GLW_CALL(thread.gl, deleteBuffers(1, &buffer));
1321*35238bceSAndroid Build Coastguard Worker     thread.newMessage() << "End -- glDeleteBuffers()" << tcu::ThreadUtil::Message::End;
1322*35238bceSAndroid Build Coastguard Worker 
1323*35238bceSAndroid Build Coastguard Worker     m_buffer->buffer = 0;
1324*35238bceSAndroid Build Coastguard Worker }
1325*35238bceSAndroid Build Coastguard Worker 
1326*35238bceSAndroid Build Coastguard Worker class BufferData : public Operation
1327*35238bceSAndroid Build Coastguard Worker {
1328*35238bceSAndroid Build Coastguard Worker public:
1329*35238bceSAndroid Build Coastguard Worker     BufferData(SharedPtr<Buffer> buffer, GLenum target, GLsizeiptr size, GLenum usage, bool useSync, bool serverSync);
1330*35238bceSAndroid Build Coastguard Worker     void exec(tcu::ThreadUtil::Thread &thread);
1331*35238bceSAndroid Build Coastguard Worker 
1332*35238bceSAndroid Build Coastguard Worker private:
1333*35238bceSAndroid Build Coastguard Worker     SharedPtr<Buffer> m_buffer;
1334*35238bceSAndroid Build Coastguard Worker     GLenum m_target;
1335*35238bceSAndroid Build Coastguard Worker     GLsizeiptr m_size;
1336*35238bceSAndroid Build Coastguard Worker     GLenum m_usage;
1337*35238bceSAndroid Build Coastguard Worker };
1338*35238bceSAndroid Build Coastguard Worker 
BufferData(SharedPtr<Buffer> buffer,GLenum target,GLsizeiptr size,GLenum usage,bool useSync,bool serverSync)1339*35238bceSAndroid Build Coastguard Worker BufferData::BufferData(SharedPtr<Buffer> buffer, GLenum target, GLsizeiptr size, GLenum usage, bool useSync,
1340*35238bceSAndroid Build Coastguard Worker                        bool serverSync)
1341*35238bceSAndroid Build Coastguard Worker     : Operation("BufferData", useSync, serverSync)
1342*35238bceSAndroid Build Coastguard Worker     , m_buffer(buffer)
1343*35238bceSAndroid Build Coastguard Worker     , m_target(target)
1344*35238bceSAndroid Build Coastguard Worker     , m_size(size)
1345*35238bceSAndroid Build Coastguard Worker     , m_usage(usage)
1346*35238bceSAndroid Build Coastguard Worker {
1347*35238bceSAndroid Build Coastguard Worker     modifyGLObject(SharedPtr<Object>(m_buffer));
1348*35238bceSAndroid Build Coastguard Worker     buffer->isDefined = true;
1349*35238bceSAndroid Build Coastguard Worker     buffer->size      = size;
1350*35238bceSAndroid Build Coastguard Worker }
1351*35238bceSAndroid Build Coastguard Worker 
exec(tcu::ThreadUtil::Thread & t)1352*35238bceSAndroid Build Coastguard Worker void BufferData::exec(tcu::ThreadUtil::Thread &t)
1353*35238bceSAndroid Build Coastguard Worker {
1354*35238bceSAndroid Build Coastguard Worker     EGLThread &thread = dynamic_cast<EGLThread &>(t);
1355*35238bceSAndroid Build Coastguard Worker     void *unusedData  = thread.getUnusedData(m_size);
1356*35238bceSAndroid Build Coastguard Worker 
1357*35238bceSAndroid Build Coastguard Worker     thread.newMessage() << "Begin -- glBindBuffer(" << m_target << ", " << m_buffer->buffer << ")"
1358*35238bceSAndroid Build Coastguard Worker                         << tcu::ThreadUtil::Message::End;
1359*35238bceSAndroid Build Coastguard Worker     GLU_CHECK_GLW_CALL(thread.gl, bindBuffer(m_target, m_buffer->buffer));
1360*35238bceSAndroid Build Coastguard Worker     thread.newMessage() << "End -- glBindBuffer()" << tcu::ThreadUtil::Message::End;
1361*35238bceSAndroid Build Coastguard Worker 
1362*35238bceSAndroid Build Coastguard Worker     thread.newMessage() << "Begin -- glBufferData(" << m_target << ", " << m_size << ", <DATA>, " << m_usage << ")"
1363*35238bceSAndroid Build Coastguard Worker                         << tcu::ThreadUtil::Message::End;
1364*35238bceSAndroid Build Coastguard Worker     GLU_CHECK_GLW_CALL(thread.gl, bufferData(m_target, m_size, unusedData, m_usage));
1365*35238bceSAndroid Build Coastguard Worker     thread.newMessage() << "End -- glBufferData()" << tcu::ThreadUtil::Message::End;
1366*35238bceSAndroid Build Coastguard Worker 
1367*35238bceSAndroid Build Coastguard Worker     thread.newMessage() << "Begin -- glBindBuffer(" << m_target << ", 0)" << tcu::ThreadUtil::Message::End;
1368*35238bceSAndroid Build Coastguard Worker     GLU_CHECK_GLW_CALL(thread.gl, bindBuffer(m_target, 0));
1369*35238bceSAndroid Build Coastguard Worker     thread.newMessage() << "End -- glBindBuffer()" << tcu::ThreadUtil::Message::End;
1370*35238bceSAndroid Build Coastguard Worker }
1371*35238bceSAndroid Build Coastguard Worker 
1372*35238bceSAndroid Build Coastguard Worker class BufferSubData : public Operation
1373*35238bceSAndroid Build Coastguard Worker {
1374*35238bceSAndroid Build Coastguard Worker public:
1375*35238bceSAndroid Build Coastguard Worker     BufferSubData(SharedPtr<Buffer> buffer, GLenum target, GLintptr offset, GLsizeiptr size, bool useSync,
1376*35238bceSAndroid Build Coastguard Worker                   bool serverSync);
1377*35238bceSAndroid Build Coastguard Worker     void exec(tcu::ThreadUtil::Thread &thread);
1378*35238bceSAndroid Build Coastguard Worker 
1379*35238bceSAndroid Build Coastguard Worker private:
1380*35238bceSAndroid Build Coastguard Worker     SharedPtr<Buffer> m_buffer;
1381*35238bceSAndroid Build Coastguard Worker     GLenum m_target;
1382*35238bceSAndroid Build Coastguard Worker     GLintptr m_offset;
1383*35238bceSAndroid Build Coastguard Worker     GLsizeiptr m_size;
1384*35238bceSAndroid Build Coastguard Worker };
1385*35238bceSAndroid Build Coastguard Worker 
BufferSubData(SharedPtr<Buffer> buffer,GLenum target,GLintptr offset,GLsizeiptr size,bool useSync,bool serverSync)1386*35238bceSAndroid Build Coastguard Worker BufferSubData::BufferSubData(SharedPtr<Buffer> buffer, GLenum target, GLintptr offset, GLsizeiptr size, bool useSync,
1387*35238bceSAndroid Build Coastguard Worker                              bool serverSync)
1388*35238bceSAndroid Build Coastguard Worker     : Operation("BufferSubData", useSync, serverSync)
1389*35238bceSAndroid Build Coastguard Worker     , m_buffer(buffer)
1390*35238bceSAndroid Build Coastguard Worker     , m_target(target)
1391*35238bceSAndroid Build Coastguard Worker     , m_offset(offset)
1392*35238bceSAndroid Build Coastguard Worker     , m_size(size)
1393*35238bceSAndroid Build Coastguard Worker {
1394*35238bceSAndroid Build Coastguard Worker     modifyGLObject(SharedPtr<Object>(m_buffer));
1395*35238bceSAndroid Build Coastguard Worker }
1396*35238bceSAndroid Build Coastguard Worker 
exec(tcu::ThreadUtil::Thread & t)1397*35238bceSAndroid Build Coastguard Worker void BufferSubData::exec(tcu::ThreadUtil::Thread &t)
1398*35238bceSAndroid Build Coastguard Worker {
1399*35238bceSAndroid Build Coastguard Worker     EGLThread &thread = dynamic_cast<EGLThread &>(t);
1400*35238bceSAndroid Build Coastguard Worker     void *unusedData  = thread.getUnusedData(m_size);
1401*35238bceSAndroid Build Coastguard Worker 
1402*35238bceSAndroid Build Coastguard Worker     thread.newMessage() << "Begin -- glBindBuffer(" << m_target << ", " << m_buffer->buffer << ")"
1403*35238bceSAndroid Build Coastguard Worker                         << tcu::ThreadUtil::Message::End;
1404*35238bceSAndroid Build Coastguard Worker     GLU_CHECK_GLW_CALL(thread.gl, bindBuffer(m_target, m_buffer->buffer));
1405*35238bceSAndroid Build Coastguard Worker     thread.newMessage() << "End -- glBindBuffer()" << tcu::ThreadUtil::Message::End;
1406*35238bceSAndroid Build Coastguard Worker 
1407*35238bceSAndroid Build Coastguard Worker     thread.newMessage() << "Begin -- glBufferSubData(" << m_target << ", " << m_offset << ", " << m_size << ", <DATA>)"
1408*35238bceSAndroid Build Coastguard Worker                         << tcu::ThreadUtil::Message::End;
1409*35238bceSAndroid Build Coastguard Worker     GLU_CHECK_GLW_CALL(thread.gl, bufferSubData(m_target, m_offset, m_size, unusedData));
1410*35238bceSAndroid Build Coastguard Worker     thread.newMessage() << "End -- glBufferSubData()" << tcu::ThreadUtil::Message::End;
1411*35238bceSAndroid Build Coastguard Worker 
1412*35238bceSAndroid Build Coastguard Worker     thread.newMessage() << "Begin -- glBindBuffer(" << m_target << ", 0)" << tcu::ThreadUtil::Message::End;
1413*35238bceSAndroid Build Coastguard Worker     GLU_CHECK_GLW_CALL(thread.gl, bindBuffer(m_target, 0));
1414*35238bceSAndroid Build Coastguard Worker     thread.newMessage() << "End -- glBindBuffer()" << tcu::ThreadUtil::Message::End;
1415*35238bceSAndroid Build Coastguard Worker }
1416*35238bceSAndroid Build Coastguard Worker 
1417*35238bceSAndroid Build Coastguard Worker class Shader : public Object
1418*35238bceSAndroid Build Coastguard Worker {
1419*35238bceSAndroid Build Coastguard Worker public:
1420*35238bceSAndroid Build Coastguard Worker     Shader(SharedPtr<tcu::ThreadUtil::Event> event, SharedPtr<FenceSync> sync);
1421*35238bceSAndroid Build Coastguard Worker 
1422*35238bceSAndroid Build Coastguard Worker     GLuint shader;
1423*35238bceSAndroid Build Coastguard Worker     GLenum type;
1424*35238bceSAndroid Build Coastguard Worker     bool isDefined;
1425*35238bceSAndroid Build Coastguard Worker     bool compiled;
1426*35238bceSAndroid Build Coastguard Worker };
1427*35238bceSAndroid Build Coastguard Worker 
Shader(SharedPtr<tcu::ThreadUtil::Event> event,SharedPtr<FenceSync> sync)1428*35238bceSAndroid Build Coastguard Worker Shader::Shader(SharedPtr<tcu::ThreadUtil::Event> event, SharedPtr<FenceSync> sync)
1429*35238bceSAndroid Build Coastguard Worker     : Object("Shader", event, sync)
1430*35238bceSAndroid Build Coastguard Worker     , shader(0)
1431*35238bceSAndroid Build Coastguard Worker     , type(GL_NONE)
1432*35238bceSAndroid Build Coastguard Worker     , isDefined(false)
1433*35238bceSAndroid Build Coastguard Worker     , compiled(false)
1434*35238bceSAndroid Build Coastguard Worker {
1435*35238bceSAndroid Build Coastguard Worker }
1436*35238bceSAndroid Build Coastguard Worker 
1437*35238bceSAndroid Build Coastguard Worker class CreateShader : public Operation
1438*35238bceSAndroid Build Coastguard Worker {
1439*35238bceSAndroid Build Coastguard Worker public:
1440*35238bceSAndroid Build Coastguard Worker     CreateShader(GLenum type, SharedPtr<Shader> &shader, bool useSync, bool serverSync);
1441*35238bceSAndroid Build Coastguard Worker     void exec(tcu::ThreadUtil::Thread &thread);
1442*35238bceSAndroid Build Coastguard Worker 
1443*35238bceSAndroid Build Coastguard Worker private:
1444*35238bceSAndroid Build Coastguard Worker     SharedPtr<Shader> m_shader;
1445*35238bceSAndroid Build Coastguard Worker     GLenum m_type;
1446*35238bceSAndroid Build Coastguard Worker };
1447*35238bceSAndroid Build Coastguard Worker 
CreateShader(GLenum type,SharedPtr<Shader> & shader,bool useSync,bool serverSync)1448*35238bceSAndroid Build Coastguard Worker CreateShader::CreateShader(GLenum type, SharedPtr<Shader> &shader, bool useSync, bool serverSync)
1449*35238bceSAndroid Build Coastguard Worker     : Operation("CreateShader", useSync, serverSync)
1450*35238bceSAndroid Build Coastguard Worker     , m_type(type)
1451*35238bceSAndroid Build Coastguard Worker {
1452*35238bceSAndroid Build Coastguard Worker     shader       = SharedPtr<Shader>(new Shader(getEvent(), getSync()));
1453*35238bceSAndroid Build Coastguard Worker     shader->type = type;
1454*35238bceSAndroid Build Coastguard Worker 
1455*35238bceSAndroid Build Coastguard Worker     m_shader = shader;
1456*35238bceSAndroid Build Coastguard Worker }
1457*35238bceSAndroid Build Coastguard Worker 
exec(tcu::ThreadUtil::Thread & t)1458*35238bceSAndroid Build Coastguard Worker void CreateShader::exec(tcu::ThreadUtil::Thread &t)
1459*35238bceSAndroid Build Coastguard Worker {
1460*35238bceSAndroid Build Coastguard Worker     EGLThread &thread = dynamic_cast<EGLThread &>(t);
1461*35238bceSAndroid Build Coastguard Worker     GLuint shader     = 0;
1462*35238bceSAndroid Build Coastguard Worker 
1463*35238bceSAndroid Build Coastguard Worker     thread.newMessage() << "Begin -- glCreateShader(" << m_type << ")" << tcu::ThreadUtil::Message::End;
1464*35238bceSAndroid Build Coastguard Worker     shader = thread.gl.createShader(m_type);
1465*35238bceSAndroid Build Coastguard Worker     GLU_CHECK_GLW_MSG(thread.gl, "glCreateShader()");
1466*35238bceSAndroid Build Coastguard Worker     thread.newMessage() << "End -- " << shader << " = glCreateShader(" << m_type << ")"
1467*35238bceSAndroid Build Coastguard Worker                         << tcu::ThreadUtil::Message::End;
1468*35238bceSAndroid Build Coastguard Worker 
1469*35238bceSAndroid Build Coastguard Worker     m_shader->shader = shader;
1470*35238bceSAndroid Build Coastguard Worker }
1471*35238bceSAndroid Build Coastguard Worker 
1472*35238bceSAndroid Build Coastguard Worker class DeleteShader : public Operation
1473*35238bceSAndroid Build Coastguard Worker {
1474*35238bceSAndroid Build Coastguard Worker public:
1475*35238bceSAndroid Build Coastguard Worker     DeleteShader(SharedPtr<Shader> shader, bool useSync, bool serverSync);
1476*35238bceSAndroid Build Coastguard Worker     void exec(tcu::ThreadUtil::Thread &thread);
1477*35238bceSAndroid Build Coastguard Worker 
1478*35238bceSAndroid Build Coastguard Worker private:
1479*35238bceSAndroid Build Coastguard Worker     SharedPtr<Shader> m_shader;
1480*35238bceSAndroid Build Coastguard Worker };
1481*35238bceSAndroid Build Coastguard Worker 
DeleteShader(SharedPtr<Shader> shader,bool useSync,bool serverSync)1482*35238bceSAndroid Build Coastguard Worker DeleteShader::DeleteShader(SharedPtr<Shader> shader, bool useSync, bool serverSync)
1483*35238bceSAndroid Build Coastguard Worker     : Operation("DeleteShader", useSync, serverSync)
1484*35238bceSAndroid Build Coastguard Worker     , m_shader(shader)
1485*35238bceSAndroid Build Coastguard Worker {
1486*35238bceSAndroid Build Coastguard Worker     modifyGLObject(SharedPtr<Object>(m_shader));
1487*35238bceSAndroid Build Coastguard Worker }
1488*35238bceSAndroid Build Coastguard Worker 
exec(tcu::ThreadUtil::Thread & t)1489*35238bceSAndroid Build Coastguard Worker void DeleteShader::exec(tcu::ThreadUtil::Thread &t)
1490*35238bceSAndroid Build Coastguard Worker {
1491*35238bceSAndroid Build Coastguard Worker     EGLThread &thread = dynamic_cast<EGLThread &>(t);
1492*35238bceSAndroid Build Coastguard Worker     GLuint shader     = m_shader->shader;
1493*35238bceSAndroid Build Coastguard Worker 
1494*35238bceSAndroid Build Coastguard Worker     thread.newMessage() << "Begin -- glDeleteShader(" << shader << ")" << tcu::ThreadUtil::Message::End;
1495*35238bceSAndroid Build Coastguard Worker     GLU_CHECK_GLW_CALL(thread.gl, deleteShader(shader));
1496*35238bceSAndroid Build Coastguard Worker     thread.newMessage() << "End -- glDeleteShader()" << tcu::ThreadUtil::Message::End;
1497*35238bceSAndroid Build Coastguard Worker 
1498*35238bceSAndroid Build Coastguard Worker     m_shader->shader = 0;
1499*35238bceSAndroid Build Coastguard Worker }
1500*35238bceSAndroid Build Coastguard Worker 
1501*35238bceSAndroid Build Coastguard Worker class ShaderSource : public Operation
1502*35238bceSAndroid Build Coastguard Worker {
1503*35238bceSAndroid Build Coastguard Worker public:
1504*35238bceSAndroid Build Coastguard Worker     ShaderSource(SharedPtr<Shader> sharder, const char *source, bool useSync, bool serverSync);
1505*35238bceSAndroid Build Coastguard Worker     void exec(tcu::ThreadUtil::Thread &thread);
1506*35238bceSAndroid Build Coastguard Worker 
1507*35238bceSAndroid Build Coastguard Worker private:
1508*35238bceSAndroid Build Coastguard Worker     SharedPtr<Shader> m_shader;
1509*35238bceSAndroid Build Coastguard Worker     string m_source;
1510*35238bceSAndroid Build Coastguard Worker };
1511*35238bceSAndroid Build Coastguard Worker 
ShaderSource(SharedPtr<Shader> shader,const char * source,bool useSync,bool serverSync)1512*35238bceSAndroid Build Coastguard Worker ShaderSource::ShaderSource(SharedPtr<Shader> shader, const char *source, bool useSync, bool serverSync)
1513*35238bceSAndroid Build Coastguard Worker     : Operation("ShaderSource", useSync, serverSync)
1514*35238bceSAndroid Build Coastguard Worker     , m_shader(shader)
1515*35238bceSAndroid Build Coastguard Worker     , m_source(source)
1516*35238bceSAndroid Build Coastguard Worker {
1517*35238bceSAndroid Build Coastguard Worker     modifyGLObject(SharedPtr<Object>(m_shader));
1518*35238bceSAndroid Build Coastguard Worker     m_shader->isDefined = true;
1519*35238bceSAndroid Build Coastguard Worker }
1520*35238bceSAndroid Build Coastguard Worker 
exec(tcu::ThreadUtil::Thread & t)1521*35238bceSAndroid Build Coastguard Worker void ShaderSource::exec(tcu::ThreadUtil::Thread &t)
1522*35238bceSAndroid Build Coastguard Worker {
1523*35238bceSAndroid Build Coastguard Worker     EGLThread &thread        = dynamic_cast<EGLThread &>(t);
1524*35238bceSAndroid Build Coastguard Worker     const char *shaderSource = m_source.c_str();
1525*35238bceSAndroid Build Coastguard Worker 
1526*35238bceSAndroid Build Coastguard Worker     thread.newMessage() << "Begin -- glShaderSource(" << m_shader->shader << ", 1, \"" << shaderSource << "\", DE_NULL)"
1527*35238bceSAndroid Build Coastguard Worker                         << tcu::ThreadUtil::Message::End;
1528*35238bceSAndroid Build Coastguard Worker     GLU_CHECK_GLW_CALL(thread.gl, shaderSource(m_shader->shader, 1, &shaderSource, DE_NULL));
1529*35238bceSAndroid Build Coastguard Worker     thread.newMessage() << "End -- glShaderSource()" << tcu::ThreadUtil::Message::End;
1530*35238bceSAndroid Build Coastguard Worker }
1531*35238bceSAndroid Build Coastguard Worker 
1532*35238bceSAndroid Build Coastguard Worker class ShaderCompile : public Operation
1533*35238bceSAndroid Build Coastguard Worker {
1534*35238bceSAndroid Build Coastguard Worker public:
1535*35238bceSAndroid Build Coastguard Worker     ShaderCompile(SharedPtr<Shader> sharder, bool useSync, bool serverSync);
1536*35238bceSAndroid Build Coastguard Worker     void exec(tcu::ThreadUtil::Thread &thread);
1537*35238bceSAndroid Build Coastguard Worker 
1538*35238bceSAndroid Build Coastguard Worker private:
1539*35238bceSAndroid Build Coastguard Worker     SharedPtr<Shader> m_shader;
1540*35238bceSAndroid Build Coastguard Worker };
1541*35238bceSAndroid Build Coastguard Worker 
ShaderCompile(SharedPtr<Shader> shader,bool useSync,bool serverSync)1542*35238bceSAndroid Build Coastguard Worker ShaderCompile::ShaderCompile(SharedPtr<Shader> shader, bool useSync, bool serverSync)
1543*35238bceSAndroid Build Coastguard Worker     : Operation("ShaderCompile", useSync, serverSync)
1544*35238bceSAndroid Build Coastguard Worker     , m_shader(shader)
1545*35238bceSAndroid Build Coastguard Worker {
1546*35238bceSAndroid Build Coastguard Worker     m_shader->compiled = true;
1547*35238bceSAndroid Build Coastguard Worker     modifyGLObject(SharedPtr<Object>(m_shader));
1548*35238bceSAndroid Build Coastguard Worker }
1549*35238bceSAndroid Build Coastguard Worker 
exec(tcu::ThreadUtil::Thread & t)1550*35238bceSAndroid Build Coastguard Worker void ShaderCompile::exec(tcu::ThreadUtil::Thread &t)
1551*35238bceSAndroid Build Coastguard Worker {
1552*35238bceSAndroid Build Coastguard Worker     EGLThread &thread = dynamic_cast<EGLThread &>(t);
1553*35238bceSAndroid Build Coastguard Worker 
1554*35238bceSAndroid Build Coastguard Worker     thread.newMessage() << "Begin -- glCompileShader(" << m_shader->shader << ")" << tcu::ThreadUtil::Message::End;
1555*35238bceSAndroid Build Coastguard Worker     GLU_CHECK_GLW_CALL(thread.gl, compileShader(m_shader->shader));
1556*35238bceSAndroid Build Coastguard Worker     thread.newMessage() << "End -- glCompileShader()" << tcu::ThreadUtil::Message::End;
1557*35238bceSAndroid Build Coastguard Worker }
1558*35238bceSAndroid Build Coastguard Worker 
1559*35238bceSAndroid Build Coastguard Worker class Program : public Object
1560*35238bceSAndroid Build Coastguard Worker {
1561*35238bceSAndroid Build Coastguard Worker public:
1562*35238bceSAndroid Build Coastguard Worker     Program(SharedPtr<tcu::ThreadUtil::Event> event, SharedPtr<FenceSync> sync);
1563*35238bceSAndroid Build Coastguard Worker 
1564*35238bceSAndroid Build Coastguard Worker     // Generation time attributes
1565*35238bceSAndroid Build Coastguard Worker     SharedPtr<Shader> vertexShader;
1566*35238bceSAndroid Build Coastguard Worker     SharedPtr<Shader> fragmentShader;
1567*35238bceSAndroid Build Coastguard Worker     bool linked;
1568*35238bceSAndroid Build Coastguard Worker 
1569*35238bceSAndroid Build Coastguard Worker     // Runtime attributes
1570*35238bceSAndroid Build Coastguard Worker     GLuint program;
1571*35238bceSAndroid Build Coastguard Worker     GLuint runtimeVertexShader;
1572*35238bceSAndroid Build Coastguard Worker     GLuint runtimeFragmentShader;
1573*35238bceSAndroid Build Coastguard Worker };
1574*35238bceSAndroid Build Coastguard Worker 
Program(SharedPtr<tcu::ThreadUtil::Event> event,SharedPtr<FenceSync> sync)1575*35238bceSAndroid Build Coastguard Worker Program::Program(SharedPtr<tcu::ThreadUtil::Event> event, SharedPtr<FenceSync> sync)
1576*35238bceSAndroid Build Coastguard Worker     : Object("Program", event, sync)
1577*35238bceSAndroid Build Coastguard Worker     , linked(false)
1578*35238bceSAndroid Build Coastguard Worker     , program(0)
1579*35238bceSAndroid Build Coastguard Worker     , runtimeVertexShader(0)
1580*35238bceSAndroid Build Coastguard Worker     , runtimeFragmentShader(0)
1581*35238bceSAndroid Build Coastguard Worker {
1582*35238bceSAndroid Build Coastguard Worker }
1583*35238bceSAndroid Build Coastguard Worker 
1584*35238bceSAndroid Build Coastguard Worker class CreateProgram : public Operation
1585*35238bceSAndroid Build Coastguard Worker {
1586*35238bceSAndroid Build Coastguard Worker public:
1587*35238bceSAndroid Build Coastguard Worker     CreateProgram(SharedPtr<Program> &program, bool useSync, bool serverSync);
1588*35238bceSAndroid Build Coastguard Worker     void exec(tcu::ThreadUtil::Thread &thread);
1589*35238bceSAndroid Build Coastguard Worker 
1590*35238bceSAndroid Build Coastguard Worker private:
1591*35238bceSAndroid Build Coastguard Worker     SharedPtr<Program> m_program;
1592*35238bceSAndroid Build Coastguard Worker };
1593*35238bceSAndroid Build Coastguard Worker 
CreateProgram(SharedPtr<Program> & program,bool useSync,bool serverSync)1594*35238bceSAndroid Build Coastguard Worker CreateProgram::CreateProgram(SharedPtr<Program> &program, bool useSync, bool serverSync)
1595*35238bceSAndroid Build Coastguard Worker     : Operation("CreateProgram", useSync, serverSync)
1596*35238bceSAndroid Build Coastguard Worker {
1597*35238bceSAndroid Build Coastguard Worker     program   = SharedPtr<Program>(new Program(getEvent(), getSync()));
1598*35238bceSAndroid Build Coastguard Worker     m_program = program;
1599*35238bceSAndroid Build Coastguard Worker }
1600*35238bceSAndroid Build Coastguard Worker 
exec(tcu::ThreadUtil::Thread & t)1601*35238bceSAndroid Build Coastguard Worker void CreateProgram::exec(tcu::ThreadUtil::Thread &t)
1602*35238bceSAndroid Build Coastguard Worker {
1603*35238bceSAndroid Build Coastguard Worker     EGLThread &thread = dynamic_cast<EGLThread &>(t);
1604*35238bceSAndroid Build Coastguard Worker     GLuint program    = 0;
1605*35238bceSAndroid Build Coastguard Worker 
1606*35238bceSAndroid Build Coastguard Worker     thread.newMessage() << "Begin -- glCreateProgram()" << tcu::ThreadUtil::Message::End;
1607*35238bceSAndroid Build Coastguard Worker     program = thread.gl.createProgram();
1608*35238bceSAndroid Build Coastguard Worker     GLU_CHECK_GLW_MSG(thread.gl, "glCreateProgram()");
1609*35238bceSAndroid Build Coastguard Worker     thread.newMessage() << "End -- " << program << " = glCreateProgram()" << tcu::ThreadUtil::Message::End;
1610*35238bceSAndroid Build Coastguard Worker 
1611*35238bceSAndroid Build Coastguard Worker     m_program->program = program;
1612*35238bceSAndroid Build Coastguard Worker }
1613*35238bceSAndroid Build Coastguard Worker 
1614*35238bceSAndroid Build Coastguard Worker class DeleteProgram : public Operation
1615*35238bceSAndroid Build Coastguard Worker {
1616*35238bceSAndroid Build Coastguard Worker public:
1617*35238bceSAndroid Build Coastguard Worker     DeleteProgram(SharedPtr<Program> program, bool useSync, bool serverSync);
1618*35238bceSAndroid Build Coastguard Worker     void exec(tcu::ThreadUtil::Thread &thread);
1619*35238bceSAndroid Build Coastguard Worker 
1620*35238bceSAndroid Build Coastguard Worker private:
1621*35238bceSAndroid Build Coastguard Worker     SharedPtr<Program> m_program;
1622*35238bceSAndroid Build Coastguard Worker };
1623*35238bceSAndroid Build Coastguard Worker 
DeleteProgram(SharedPtr<Program> program,bool useSync,bool serverSync)1624*35238bceSAndroid Build Coastguard Worker DeleteProgram::DeleteProgram(SharedPtr<Program> program, bool useSync, bool serverSync)
1625*35238bceSAndroid Build Coastguard Worker     : Operation("DeleteProgram", useSync, serverSync)
1626*35238bceSAndroid Build Coastguard Worker     , m_program(program)
1627*35238bceSAndroid Build Coastguard Worker {
1628*35238bceSAndroid Build Coastguard Worker     modifyGLObject(SharedPtr<Object>(m_program));
1629*35238bceSAndroid Build Coastguard Worker }
1630*35238bceSAndroid Build Coastguard Worker 
exec(tcu::ThreadUtil::Thread & t)1631*35238bceSAndroid Build Coastguard Worker void DeleteProgram::exec(tcu::ThreadUtil::Thread &t)
1632*35238bceSAndroid Build Coastguard Worker {
1633*35238bceSAndroid Build Coastguard Worker     EGLThread &thread = dynamic_cast<EGLThread &>(t);
1634*35238bceSAndroid Build Coastguard Worker     GLuint program    = m_program->program;
1635*35238bceSAndroid Build Coastguard Worker 
1636*35238bceSAndroid Build Coastguard Worker     thread.newMessage() << "Begin -- glDeleteProgram(" << program << ")" << tcu::ThreadUtil::Message::End;
1637*35238bceSAndroid Build Coastguard Worker     GLU_CHECK_GLW_CALL(thread.gl, deleteProgram(program));
1638*35238bceSAndroid Build Coastguard Worker     thread.newMessage() << "End -- glDeleteProgram()" << tcu::ThreadUtil::Message::End;
1639*35238bceSAndroid Build Coastguard Worker 
1640*35238bceSAndroid Build Coastguard Worker     m_program->program = 0;
1641*35238bceSAndroid Build Coastguard Worker }
1642*35238bceSAndroid Build Coastguard Worker 
1643*35238bceSAndroid Build Coastguard Worker class AttachShader : public Operation
1644*35238bceSAndroid Build Coastguard Worker {
1645*35238bceSAndroid Build Coastguard Worker public:
1646*35238bceSAndroid Build Coastguard Worker     AttachShader(SharedPtr<Program> sharder, SharedPtr<Shader> shader, bool useSync, bool serverSync);
1647*35238bceSAndroid Build Coastguard Worker     void exec(tcu::ThreadUtil::Thread &thread);
1648*35238bceSAndroid Build Coastguard Worker 
1649*35238bceSAndroid Build Coastguard Worker private:
1650*35238bceSAndroid Build Coastguard Worker     SharedPtr<Program> m_program;
1651*35238bceSAndroid Build Coastguard Worker     SharedPtr<Shader> m_shader;
1652*35238bceSAndroid Build Coastguard Worker };
1653*35238bceSAndroid Build Coastguard Worker 
AttachShader(SharedPtr<Program> program,SharedPtr<Shader> shader,bool useSync,bool serverSync)1654*35238bceSAndroid Build Coastguard Worker AttachShader::AttachShader(SharedPtr<Program> program, SharedPtr<Shader> shader, bool useSync, bool serverSync)
1655*35238bceSAndroid Build Coastguard Worker     : Operation("AttachShader", useSync, serverSync)
1656*35238bceSAndroid Build Coastguard Worker     , m_program(program)
1657*35238bceSAndroid Build Coastguard Worker     , m_shader(shader)
1658*35238bceSAndroid Build Coastguard Worker {
1659*35238bceSAndroid Build Coastguard Worker     modifyGLObject(SharedPtr<Object>(m_program));
1660*35238bceSAndroid Build Coastguard Worker     readGLObject(SharedPtr<Object>(m_shader));
1661*35238bceSAndroid Build Coastguard Worker 
1662*35238bceSAndroid Build Coastguard Worker     if (m_shader->type == GL_VERTEX_SHADER)
1663*35238bceSAndroid Build Coastguard Worker         m_program->vertexShader = shader;
1664*35238bceSAndroid Build Coastguard Worker     else if (m_shader->type == GL_FRAGMENT_SHADER)
1665*35238bceSAndroid Build Coastguard Worker         m_program->fragmentShader = shader;
1666*35238bceSAndroid Build Coastguard Worker     else
1667*35238bceSAndroid Build Coastguard Worker         DE_ASSERT(false);
1668*35238bceSAndroid Build Coastguard Worker }
1669*35238bceSAndroid Build Coastguard Worker 
exec(tcu::ThreadUtil::Thread & t)1670*35238bceSAndroid Build Coastguard Worker void AttachShader::exec(tcu::ThreadUtil::Thread &t)
1671*35238bceSAndroid Build Coastguard Worker {
1672*35238bceSAndroid Build Coastguard Worker     EGLThread &thread = dynamic_cast<EGLThread &>(t);
1673*35238bceSAndroid Build Coastguard Worker 
1674*35238bceSAndroid Build Coastguard Worker     thread.newMessage() << "Begin -- glAttachShader(" << m_program->program << ", " << m_shader->shader << ")"
1675*35238bceSAndroid Build Coastguard Worker                         << tcu::ThreadUtil::Message::End;
1676*35238bceSAndroid Build Coastguard Worker     GLU_CHECK_GLW_CALL(thread.gl, attachShader(m_program->program, m_shader->shader));
1677*35238bceSAndroid Build Coastguard Worker     thread.newMessage() << "End -- glAttachShader()" << tcu::ThreadUtil::Message::End;
1678*35238bceSAndroid Build Coastguard Worker 
1679*35238bceSAndroid Build Coastguard Worker     if (m_shader->type == GL_VERTEX_SHADER)
1680*35238bceSAndroid Build Coastguard Worker         m_program->runtimeVertexShader = m_shader->shader;
1681*35238bceSAndroid Build Coastguard Worker     else if (m_shader->type == GL_FRAGMENT_SHADER)
1682*35238bceSAndroid Build Coastguard Worker         m_program->runtimeFragmentShader = m_shader->shader;
1683*35238bceSAndroid Build Coastguard Worker     else
1684*35238bceSAndroid Build Coastguard Worker         DE_ASSERT(false);
1685*35238bceSAndroid Build Coastguard Worker }
1686*35238bceSAndroid Build Coastguard Worker 
1687*35238bceSAndroid Build Coastguard Worker class DetachShader : public Operation
1688*35238bceSAndroid Build Coastguard Worker {
1689*35238bceSAndroid Build Coastguard Worker public:
1690*35238bceSAndroid Build Coastguard Worker     DetachShader(SharedPtr<Program> sharder, GLenum type, bool useSync, bool serverSync);
1691*35238bceSAndroid Build Coastguard Worker     void exec(tcu::ThreadUtil::Thread &thread);
1692*35238bceSAndroid Build Coastguard Worker 
1693*35238bceSAndroid Build Coastguard Worker private:
1694*35238bceSAndroid Build Coastguard Worker     SharedPtr<Program> m_program;
1695*35238bceSAndroid Build Coastguard Worker     GLenum m_type;
1696*35238bceSAndroid Build Coastguard Worker };
1697*35238bceSAndroid Build Coastguard Worker 
DetachShader(SharedPtr<Program> program,GLenum type,bool useSync,bool serverSync)1698*35238bceSAndroid Build Coastguard Worker DetachShader::DetachShader(SharedPtr<Program> program, GLenum type, bool useSync, bool serverSync)
1699*35238bceSAndroid Build Coastguard Worker     : Operation("DetachShader", useSync, serverSync)
1700*35238bceSAndroid Build Coastguard Worker     , m_program(program)
1701*35238bceSAndroid Build Coastguard Worker     , m_type(type)
1702*35238bceSAndroid Build Coastguard Worker {
1703*35238bceSAndroid Build Coastguard Worker     modifyGLObject(SharedPtr<Object>(m_program));
1704*35238bceSAndroid Build Coastguard Worker 
1705*35238bceSAndroid Build Coastguard Worker     if (m_type == GL_VERTEX_SHADER)
1706*35238bceSAndroid Build Coastguard Worker     {
1707*35238bceSAndroid Build Coastguard Worker         DE_ASSERT(m_program->vertexShader);
1708*35238bceSAndroid Build Coastguard Worker         m_program->vertexShader = SharedPtr<Shader>();
1709*35238bceSAndroid Build Coastguard Worker     }
1710*35238bceSAndroid Build Coastguard Worker     else if (m_type == GL_FRAGMENT_SHADER)
1711*35238bceSAndroid Build Coastguard Worker     {
1712*35238bceSAndroid Build Coastguard Worker         DE_ASSERT(m_program->fragmentShader);
1713*35238bceSAndroid Build Coastguard Worker         m_program->fragmentShader = SharedPtr<Shader>();
1714*35238bceSAndroid Build Coastguard Worker     }
1715*35238bceSAndroid Build Coastguard Worker     else
1716*35238bceSAndroid Build Coastguard Worker         DE_ASSERT(false);
1717*35238bceSAndroid Build Coastguard Worker }
1718*35238bceSAndroid Build Coastguard Worker 
exec(tcu::ThreadUtil::Thread & t)1719*35238bceSAndroid Build Coastguard Worker void DetachShader::exec(tcu::ThreadUtil::Thread &t)
1720*35238bceSAndroid Build Coastguard Worker {
1721*35238bceSAndroid Build Coastguard Worker     EGLThread &thread = dynamic_cast<EGLThread &>(t);
1722*35238bceSAndroid Build Coastguard Worker 
1723*35238bceSAndroid Build Coastguard Worker     if (m_type == GL_VERTEX_SHADER)
1724*35238bceSAndroid Build Coastguard Worker     {
1725*35238bceSAndroid Build Coastguard Worker         thread.newMessage() << "Begin -- glDetachShader(" << m_program->program << ", "
1726*35238bceSAndroid Build Coastguard Worker                             << m_program->runtimeVertexShader << ")" << tcu::ThreadUtil::Message::End;
1727*35238bceSAndroid Build Coastguard Worker         GLU_CHECK_GLW_CALL(thread.gl, detachShader(m_program->program, m_program->runtimeVertexShader));
1728*35238bceSAndroid Build Coastguard Worker         thread.newMessage() << "End -- glDetachShader()" << tcu::ThreadUtil::Message::End;
1729*35238bceSAndroid Build Coastguard Worker         m_program->runtimeVertexShader = 0;
1730*35238bceSAndroid Build Coastguard Worker     }
1731*35238bceSAndroid Build Coastguard Worker     else if (m_type == GL_FRAGMENT_SHADER)
1732*35238bceSAndroid Build Coastguard Worker     {
1733*35238bceSAndroid Build Coastguard Worker         thread.newMessage() << "Begin -- glDetachShader(" << m_program->program << ", "
1734*35238bceSAndroid Build Coastguard Worker                             << m_program->runtimeFragmentShader << ")" << tcu::ThreadUtil::Message::End;
1735*35238bceSAndroid Build Coastguard Worker         GLU_CHECK_GLW_CALL(thread.gl, detachShader(m_program->program, m_program->runtimeFragmentShader));
1736*35238bceSAndroid Build Coastguard Worker         thread.newMessage() << "End -- glDetachShader()" << tcu::ThreadUtil::Message::End;
1737*35238bceSAndroid Build Coastguard Worker         m_program->runtimeFragmentShader = 0;
1738*35238bceSAndroid Build Coastguard Worker     }
1739*35238bceSAndroid Build Coastguard Worker     else
1740*35238bceSAndroid Build Coastguard Worker         DE_ASSERT(false);
1741*35238bceSAndroid Build Coastguard Worker }
1742*35238bceSAndroid Build Coastguard Worker 
1743*35238bceSAndroid Build Coastguard Worker class LinkProgram : public Operation
1744*35238bceSAndroid Build Coastguard Worker {
1745*35238bceSAndroid Build Coastguard Worker public:
1746*35238bceSAndroid Build Coastguard Worker     LinkProgram(SharedPtr<Program> program, bool useSync, bool serverSync);
1747*35238bceSAndroid Build Coastguard Worker     void exec(tcu::ThreadUtil::Thread &thread);
1748*35238bceSAndroid Build Coastguard Worker 
1749*35238bceSAndroid Build Coastguard Worker private:
1750*35238bceSAndroid Build Coastguard Worker     SharedPtr<Program> m_program;
1751*35238bceSAndroid Build Coastguard Worker };
1752*35238bceSAndroid Build Coastguard Worker 
LinkProgram(SharedPtr<Program> program,bool useSync,bool serverSync)1753*35238bceSAndroid Build Coastguard Worker LinkProgram::LinkProgram(SharedPtr<Program> program, bool useSync, bool serverSync)
1754*35238bceSAndroid Build Coastguard Worker     : Operation("LinkProgram", useSync, serverSync)
1755*35238bceSAndroid Build Coastguard Worker     , m_program(program)
1756*35238bceSAndroid Build Coastguard Worker {
1757*35238bceSAndroid Build Coastguard Worker     modifyGLObject(SharedPtr<Object>(m_program));
1758*35238bceSAndroid Build Coastguard Worker     program->linked = true;
1759*35238bceSAndroid Build Coastguard Worker }
1760*35238bceSAndroid Build Coastguard Worker 
exec(tcu::ThreadUtil::Thread & t)1761*35238bceSAndroid Build Coastguard Worker void LinkProgram::exec(tcu::ThreadUtil::Thread &t)
1762*35238bceSAndroid Build Coastguard Worker {
1763*35238bceSAndroid Build Coastguard Worker     EGLThread &thread = dynamic_cast<EGLThread &>(t);
1764*35238bceSAndroid Build Coastguard Worker     GLuint program    = m_program->program;
1765*35238bceSAndroid Build Coastguard Worker 
1766*35238bceSAndroid Build Coastguard Worker     thread.newMessage() << "Begin -- glLinkProgram(" << program << ")" << tcu::ThreadUtil::Message::End;
1767*35238bceSAndroid Build Coastguard Worker     GLU_CHECK_GLW_CALL(thread.gl, linkProgram(program));
1768*35238bceSAndroid Build Coastguard Worker     thread.newMessage() << "End -- glLinkProgram()" << tcu::ThreadUtil::Message::End;
1769*35238bceSAndroid Build Coastguard Worker }
1770*35238bceSAndroid Build Coastguard Worker 
1771*35238bceSAndroid Build Coastguard Worker class RenderBuffer : public Operation
1772*35238bceSAndroid Build Coastguard Worker {
1773*35238bceSAndroid Build Coastguard Worker public:
1774*35238bceSAndroid Build Coastguard Worker     RenderBuffer(SharedPtr<Program> program, SharedPtr<Buffer> buffer, bool useSync, bool serverSync);
1775*35238bceSAndroid Build Coastguard Worker     void exec(tcu::ThreadUtil::Thread &thread);
1776*35238bceSAndroid Build Coastguard Worker 
1777*35238bceSAndroid Build Coastguard Worker private:
1778*35238bceSAndroid Build Coastguard Worker     SharedPtr<Program> m_program;
1779*35238bceSAndroid Build Coastguard Worker     SharedPtr<Buffer> m_buffer;
1780*35238bceSAndroid Build Coastguard Worker };
1781*35238bceSAndroid Build Coastguard Worker 
RenderBuffer(SharedPtr<Program> program,SharedPtr<Buffer> buffer,bool useSync,bool serverSync)1782*35238bceSAndroid Build Coastguard Worker RenderBuffer::RenderBuffer(SharedPtr<Program> program, SharedPtr<Buffer> buffer, bool useSync, bool serverSync)
1783*35238bceSAndroid Build Coastguard Worker     : Operation("RenderBuffer", useSync, serverSync)
1784*35238bceSAndroid Build Coastguard Worker     , m_program(program)
1785*35238bceSAndroid Build Coastguard Worker     , m_buffer(buffer)
1786*35238bceSAndroid Build Coastguard Worker {
1787*35238bceSAndroid Build Coastguard Worker     readGLObject(SharedPtr<Object>(program));
1788*35238bceSAndroid Build Coastguard Worker     readGLObject(SharedPtr<Object>(buffer));
1789*35238bceSAndroid Build Coastguard Worker }
1790*35238bceSAndroid Build Coastguard Worker 
exec(tcu::ThreadUtil::Thread & t)1791*35238bceSAndroid Build Coastguard Worker void RenderBuffer::exec(tcu::ThreadUtil::Thread &t)
1792*35238bceSAndroid Build Coastguard Worker {
1793*35238bceSAndroid Build Coastguard Worker     EGLThread &thread = dynamic_cast<EGLThread &>(t);
1794*35238bceSAndroid Build Coastguard Worker 
1795*35238bceSAndroid Build Coastguard Worker     thread.newMessage() << "Begin -- glClearColor(0.5f, 0.5f, 0.5f, 1.0f)" << tcu::ThreadUtil::Message::End;
1796*35238bceSAndroid Build Coastguard Worker     GLU_CHECK_GLW_CALL(thread.gl, clearColor(0.5f, 0.5f, 0.5f, 1.0f));
1797*35238bceSAndroid Build Coastguard Worker     thread.newMessage() << "End -- glClearColor()" << tcu::ThreadUtil::Message::End;
1798*35238bceSAndroid Build Coastguard Worker 
1799*35238bceSAndroid Build Coastguard Worker     thread.newMessage() << "Begin -- glClear(GL_COLOR_BUFFER_BIT)" << tcu::ThreadUtil::Message::End;
1800*35238bceSAndroid Build Coastguard Worker     GLU_CHECK_GLW_CALL(thread.gl, clear(GL_COLOR_BUFFER_BIT));
1801*35238bceSAndroid Build Coastguard Worker     thread.newMessage() << "End -- glClear()" << tcu::ThreadUtil::Message::End;
1802*35238bceSAndroid Build Coastguard Worker 
1803*35238bceSAndroid Build Coastguard Worker     thread.newMessage() << "Begin -- glUseProgram(" << m_program->program << ")" << tcu::ThreadUtil::Message::End;
1804*35238bceSAndroid Build Coastguard Worker     GLU_CHECK_GLW_CALL(thread.gl, useProgram(m_program->program));
1805*35238bceSAndroid Build Coastguard Worker     thread.newMessage() << "End -- glUseProgram()" << tcu::ThreadUtil::Message::End;
1806*35238bceSAndroid Build Coastguard Worker 
1807*35238bceSAndroid Build Coastguard Worker     thread.newMessage() << "Begin -- glGetAttribLocation(" << m_program->program << ", \"a_pos\")"
1808*35238bceSAndroid Build Coastguard Worker                         << tcu::ThreadUtil::Message::End;
1809*35238bceSAndroid Build Coastguard Worker     GLint posLoc = thread.gl.getAttribLocation(m_program->program, "a_pos");
1810*35238bceSAndroid Build Coastguard Worker     GLU_CHECK_GLW_MSG(thread.gl, "glGetAttribLocation()");
1811*35238bceSAndroid Build Coastguard Worker     thread.newMessage() << "End -- " << posLoc << " = glGetAttribLocation()" << tcu::ThreadUtil::Message::End;
1812*35238bceSAndroid Build Coastguard Worker 
1813*35238bceSAndroid Build Coastguard Worker     thread.newMessage() << "Begin -- glEnableVertexAttribArray(" << posLoc << ")" << tcu::ThreadUtil::Message::End;
1814*35238bceSAndroid Build Coastguard Worker     GLU_CHECK_GLW_CALL(thread.gl, enableVertexAttribArray(posLoc));
1815*35238bceSAndroid Build Coastguard Worker     thread.newMessage() << "End -- glEnableVertexAttribArray()" << tcu::ThreadUtil::Message::End;
1816*35238bceSAndroid Build Coastguard Worker 
1817*35238bceSAndroid Build Coastguard Worker     thread.newMessage() << "Begin -- glBindBuffer(GL_ARRAY_BUFFER, " << m_buffer->buffer << ")"
1818*35238bceSAndroid Build Coastguard Worker                         << tcu::ThreadUtil::Message::End;
1819*35238bceSAndroid Build Coastguard Worker     GLU_CHECK_GLW_CALL(thread.gl, bindBuffer(GL_ARRAY_BUFFER, m_buffer->buffer));
1820*35238bceSAndroid Build Coastguard Worker     thread.newMessage() << "End -- glBindBuffer()" << tcu::ThreadUtil::Message::End;
1821*35238bceSAndroid Build Coastguard Worker 
1822*35238bceSAndroid Build Coastguard Worker     thread.newMessage() << "Begin -- glVertexAttribPointer(" << posLoc << ", GL_BYTE, GL_TRUE, 0, 0)"
1823*35238bceSAndroid Build Coastguard Worker                         << tcu::ThreadUtil::Message::End;
1824*35238bceSAndroid Build Coastguard Worker     GLU_CHECK_GLW_CALL(thread.gl, vertexAttribPointer(posLoc, 2, GL_BYTE, GL_TRUE, 0, 0));
1825*35238bceSAndroid Build Coastguard Worker     thread.newMessage() << "End -- glVertexAttribPointer()" << tcu::ThreadUtil::Message::End;
1826*35238bceSAndroid Build Coastguard Worker 
1827*35238bceSAndroid Build Coastguard Worker     thread.newMessage() << "Begin -- glDrawArrays(GL_TRIANGLES, 0, " << (m_buffer->size / 2) << ")"
1828*35238bceSAndroid Build Coastguard Worker                         << tcu::ThreadUtil::Message::End;
1829*35238bceSAndroid Build Coastguard Worker     GLU_CHECK_GLW_CALL(thread.gl, drawArrays(GL_TRIANGLES, 0, (GLsizei)m_buffer->size / 2));
1830*35238bceSAndroid Build Coastguard Worker     thread.newMessage() << "End -- glDrawArrays()" << tcu::ThreadUtil::Message::End;
1831*35238bceSAndroid Build Coastguard Worker 
1832*35238bceSAndroid Build Coastguard Worker     thread.newMessage() << "Begin -- glBindBuffer(GL_ARRAY_BUFFER, 0)" << tcu::ThreadUtil::Message::End;
1833*35238bceSAndroid Build Coastguard Worker     GLU_CHECK_GLW_CALL(thread.gl, bindBuffer(GL_ARRAY_BUFFER, 0));
1834*35238bceSAndroid Build Coastguard Worker     thread.newMessage() << "End -- glBindBuffer()" << tcu::ThreadUtil::Message::End;
1835*35238bceSAndroid Build Coastguard Worker 
1836*35238bceSAndroid Build Coastguard Worker     thread.newMessage() << "Begin -- glDisableVertexAttribArray(" << posLoc << ")" << tcu::ThreadUtil::Message::End;
1837*35238bceSAndroid Build Coastguard Worker     GLU_CHECK_GLW_CALL(thread.gl, disableVertexAttribArray(posLoc));
1838*35238bceSAndroid Build Coastguard Worker     thread.newMessage() << "End -- glDisableVertexAttribArray()" << tcu::ThreadUtil::Message::End;
1839*35238bceSAndroid Build Coastguard Worker 
1840*35238bceSAndroid Build Coastguard Worker     thread.newMessage() << "Begin -- glUseProgram(0)" << tcu::ThreadUtil::Message::End;
1841*35238bceSAndroid Build Coastguard Worker     GLU_CHECK_GLW_CALL(thread.gl, useProgram(0));
1842*35238bceSAndroid Build Coastguard Worker     thread.newMessage() << "End -- glUseProgram()" << tcu::ThreadUtil::Message::End;
1843*35238bceSAndroid Build Coastguard Worker }
1844*35238bceSAndroid Build Coastguard Worker 
1845*35238bceSAndroid Build Coastguard Worker class RenderTexture : public Operation
1846*35238bceSAndroid Build Coastguard Worker {
1847*35238bceSAndroid Build Coastguard Worker public:
1848*35238bceSAndroid Build Coastguard Worker     RenderTexture(SharedPtr<Program> program, SharedPtr<Texture> texture, bool useSync, bool serverSync);
1849*35238bceSAndroid Build Coastguard Worker     void exec(tcu::ThreadUtil::Thread &thread);
1850*35238bceSAndroid Build Coastguard Worker 
1851*35238bceSAndroid Build Coastguard Worker private:
1852*35238bceSAndroid Build Coastguard Worker     SharedPtr<Program> m_program;
1853*35238bceSAndroid Build Coastguard Worker     SharedPtr<Texture> m_texture;
1854*35238bceSAndroid Build Coastguard Worker };
1855*35238bceSAndroid Build Coastguard Worker 
RenderTexture(SharedPtr<Program> program,SharedPtr<Texture> texture,bool useSync,bool serverSync)1856*35238bceSAndroid Build Coastguard Worker RenderTexture::RenderTexture(SharedPtr<Program> program, SharedPtr<Texture> texture, bool useSync, bool serverSync)
1857*35238bceSAndroid Build Coastguard Worker     : Operation("RenderTexture", useSync, serverSync)
1858*35238bceSAndroid Build Coastguard Worker     , m_program(program)
1859*35238bceSAndroid Build Coastguard Worker     , m_texture(texture)
1860*35238bceSAndroid Build Coastguard Worker {
1861*35238bceSAndroid Build Coastguard Worker     readGLObject(SharedPtr<Object>(program));
1862*35238bceSAndroid Build Coastguard Worker     readGLObject(SharedPtr<Object>(texture));
1863*35238bceSAndroid Build Coastguard Worker }
1864*35238bceSAndroid Build Coastguard Worker 
exec(tcu::ThreadUtil::Thread & t)1865*35238bceSAndroid Build Coastguard Worker void RenderTexture::exec(tcu::ThreadUtil::Thread &t)
1866*35238bceSAndroid Build Coastguard Worker {
1867*35238bceSAndroid Build Coastguard Worker     EGLThread &thread = dynamic_cast<EGLThread &>(t);
1868*35238bceSAndroid Build Coastguard Worker 
1869*35238bceSAndroid Build Coastguard Worker     thread.newMessage() << "Begin -- glClearColor(0.5f, 0.5f, 0.5f, 1.0f)" << tcu::ThreadUtil::Message::End;
1870*35238bceSAndroid Build Coastguard Worker     GLU_CHECK_GLW_CALL(thread.gl, clearColor(0.5f, 0.5f, 0.5f, 1.0f));
1871*35238bceSAndroid Build Coastguard Worker     thread.newMessage() << "End -- glClearColor()" << tcu::ThreadUtil::Message::End;
1872*35238bceSAndroid Build Coastguard Worker 
1873*35238bceSAndroid Build Coastguard Worker     thread.newMessage() << "Begin -- glClear(GL_COLOR_BUFFER_BIT)" << tcu::ThreadUtil::Message::End;
1874*35238bceSAndroid Build Coastguard Worker     GLU_CHECK_GLW_CALL(thread.gl, clear(GL_COLOR_BUFFER_BIT));
1875*35238bceSAndroid Build Coastguard Worker     thread.newMessage() << "End -- glClear()" << tcu::ThreadUtil::Message::End;
1876*35238bceSAndroid Build Coastguard Worker 
1877*35238bceSAndroid Build Coastguard Worker     thread.newMessage() << "Begin -- glUseProgram(" << m_program->program << ")" << tcu::ThreadUtil::Message::End;
1878*35238bceSAndroid Build Coastguard Worker     GLU_CHECK_GLW_CALL(thread.gl, useProgram(m_program->program));
1879*35238bceSAndroid Build Coastguard Worker     thread.newMessage() << "End -- glUseProgram()" << tcu::ThreadUtil::Message::End;
1880*35238bceSAndroid Build Coastguard Worker 
1881*35238bceSAndroid Build Coastguard Worker     thread.newMessage() << "Begin -- glBindTexture(GL_TEXTURE_2D, " << m_texture->texture << ")"
1882*35238bceSAndroid Build Coastguard Worker                         << tcu::ThreadUtil::Message::End;
1883*35238bceSAndroid Build Coastguard Worker     GLU_CHECK_GLW_CALL(thread.gl, bindTexture(GL_TEXTURE_2D, m_texture->texture));
1884*35238bceSAndroid Build Coastguard Worker     thread.newMessage() << "End -- glBindTexture()" << tcu::ThreadUtil::Message::End;
1885*35238bceSAndroid Build Coastguard Worker 
1886*35238bceSAndroid Build Coastguard Worker     thread.newMessage() << "Begin -- glGetUniformLocation(" << m_program->program << ", \"u_sampler\")"
1887*35238bceSAndroid Build Coastguard Worker                         << tcu::ThreadUtil::Message::End;
1888*35238bceSAndroid Build Coastguard Worker     GLint samplerPos = thread.gl.getUniformLocation(m_program->program, "u_sampler");
1889*35238bceSAndroid Build Coastguard Worker     GLU_CHECK_GLW_MSG(thread.gl, "glGetUniformLocation()");
1890*35238bceSAndroid Build Coastguard Worker     thread.newMessage() << "End -- glGetUniformLocation()" << tcu::ThreadUtil::Message::End;
1891*35238bceSAndroid Build Coastguard Worker 
1892*35238bceSAndroid Build Coastguard Worker     thread.newMessage() << "Begin -- glUniform1i(" << samplerPos << ", 0)" << tcu::ThreadUtil::Message::End;
1893*35238bceSAndroid Build Coastguard Worker     GLU_CHECK_GLW_CALL(thread.gl, uniform1i(samplerPos, 0));
1894*35238bceSAndroid Build Coastguard Worker     thread.newMessage() << "End -- glUniform1i()" << tcu::ThreadUtil::Message::End;
1895*35238bceSAndroid Build Coastguard Worker 
1896*35238bceSAndroid Build Coastguard Worker     thread.newMessage() << "Begin -- glGetAttribLocation(" << m_program->program << ", \"a_pos\")"
1897*35238bceSAndroid Build Coastguard Worker                         << tcu::ThreadUtil::Message::End;
1898*35238bceSAndroid Build Coastguard Worker     GLint posLoc = thread.gl.getAttribLocation(m_program->program, "a_pos");
1899*35238bceSAndroid Build Coastguard Worker     GLU_CHECK_GLW_MSG(thread.gl, "glGetAttribLocation()");
1900*35238bceSAndroid Build Coastguard Worker     thread.newMessage() << "End -- " << posLoc << " = glGetAttribLocation()" << tcu::ThreadUtil::Message::End;
1901*35238bceSAndroid Build Coastguard Worker 
1902*35238bceSAndroid Build Coastguard Worker     thread.newMessage() << "Begin -- glEnableVertexAttribArray(" << posLoc << ")" << tcu::ThreadUtil::Message::End;
1903*35238bceSAndroid Build Coastguard Worker     GLU_CHECK_GLW_CALL(thread.gl, enableVertexAttribArray(posLoc));
1904*35238bceSAndroid Build Coastguard Worker     thread.newMessage() << "End -- glEnableVertexAttribArray()" << tcu::ThreadUtil::Message::End;
1905*35238bceSAndroid Build Coastguard Worker 
1906*35238bceSAndroid Build Coastguard Worker     thread.newMessage() << "Begin -- glBindBuffer(GL_ARRAY_BUFFER, 0)" << tcu::ThreadUtil::Message::End;
1907*35238bceSAndroid Build Coastguard Worker     GLU_CHECK_GLW_CALL(thread.gl, bindBuffer(GL_ARRAY_BUFFER, 0));
1908*35238bceSAndroid Build Coastguard Worker     thread.newMessage() << "End -- glBindBuffer()" << tcu::ThreadUtil::Message::End;
1909*35238bceSAndroid Build Coastguard Worker 
1910*35238bceSAndroid Build Coastguard Worker     float coords[] = {-1.0, -1.0, 1.0,  -1.0, 1.0,  1.0,
1911*35238bceSAndroid Build Coastguard Worker 
1912*35238bceSAndroid Build Coastguard Worker                       1.0,  1.0,  -1.0, 1.0,  -1.0, -1.0};
1913*35238bceSAndroid Build Coastguard Worker 
1914*35238bceSAndroid Build Coastguard Worker     thread.newMessage() << "Begin -- glVertexAttribPointer(" << posLoc << ", GL_FLOAT, GL_FALSE, 0, <data>)"
1915*35238bceSAndroid Build Coastguard Worker                         << tcu::ThreadUtil::Message::End;
1916*35238bceSAndroid Build Coastguard Worker     GLU_CHECK_GLW_CALL(thread.gl, vertexAttribPointer(posLoc, 2, GL_FLOAT, GL_FALSE, 0, coords));
1917*35238bceSAndroid Build Coastguard Worker     thread.newMessage() << "End -- glVertexAttribPointer()" << tcu::ThreadUtil::Message::End;
1918*35238bceSAndroid Build Coastguard Worker 
1919*35238bceSAndroid Build Coastguard Worker     thread.newMessage() << "Begin -- glDrawArrays(GL_TRIANGLES, 0, 6)" << tcu::ThreadUtil::Message::End;
1920*35238bceSAndroid Build Coastguard Worker     GLU_CHECK_GLW_CALL(thread.gl, drawArrays(GL_TRIANGLES, 0, 6));
1921*35238bceSAndroid Build Coastguard Worker     thread.newMessage() << "End -- glDrawArrays()" << tcu::ThreadUtil::Message::End;
1922*35238bceSAndroid Build Coastguard Worker 
1923*35238bceSAndroid Build Coastguard Worker     thread.newMessage() << "Begin -- glBindBuffer(GL_ARRAY_BUFFER, 0)" << tcu::ThreadUtil::Message::End;
1924*35238bceSAndroid Build Coastguard Worker     GLU_CHECK_GLW_CALL(thread.gl, bindBuffer(GL_ARRAY_BUFFER, 0));
1925*35238bceSAndroid Build Coastguard Worker     thread.newMessage() << "End -- glBindBuffer()" << tcu::ThreadUtil::Message::End;
1926*35238bceSAndroid Build Coastguard Worker 
1927*35238bceSAndroid Build Coastguard Worker     thread.newMessage() << "Begin -- glBindTexture(GL_TEXTURE_2D, 0)" << tcu::ThreadUtil::Message::End;
1928*35238bceSAndroid Build Coastguard Worker     GLU_CHECK_GLW_CALL(thread.gl, bindTexture(GL_TEXTURE_2D, 0));
1929*35238bceSAndroid Build Coastguard Worker     thread.newMessage() << "End -- glBindTexture()" << tcu::ThreadUtil::Message::End;
1930*35238bceSAndroid Build Coastguard Worker 
1931*35238bceSAndroid Build Coastguard Worker     thread.newMessage() << "Begin -- glDisableVertexAttribArray(" << posLoc << ")" << tcu::ThreadUtil::Message::End;
1932*35238bceSAndroid Build Coastguard Worker     GLU_CHECK_GLW_CALL(thread.gl, disableVertexAttribArray(posLoc));
1933*35238bceSAndroid Build Coastguard Worker     thread.newMessage() << "End -- glDisableVertexAttribArray()" << tcu::ThreadUtil::Message::End;
1934*35238bceSAndroid Build Coastguard Worker 
1935*35238bceSAndroid Build Coastguard Worker     thread.newMessage() << "Begin -- glUseProgram(0)" << tcu::ThreadUtil::Message::End;
1936*35238bceSAndroid Build Coastguard Worker     GLU_CHECK_GLW_CALL(thread.gl, useProgram(0));
1937*35238bceSAndroid Build Coastguard Worker     thread.newMessage() << "End -- glUseProgram()" << tcu::ThreadUtil::Message::End;
1938*35238bceSAndroid Build Coastguard Worker }
1939*35238bceSAndroid Build Coastguard Worker 
1940*35238bceSAndroid Build Coastguard Worker class ReadPixels : public Operation
1941*35238bceSAndroid Build Coastguard Worker {
1942*35238bceSAndroid Build Coastguard Worker public:
1943*35238bceSAndroid Build Coastguard Worker     ReadPixels(int x, int y, int width, int height, GLenum format, GLenum type,
1944*35238bceSAndroid Build Coastguard Worker                SharedPtr<tcu::ThreadUtil::DataBlock> &data, bool useSync, bool serverSync);
1945*35238bceSAndroid Build Coastguard Worker     void exec(tcu::ThreadUtil::Thread &thread);
1946*35238bceSAndroid Build Coastguard Worker 
1947*35238bceSAndroid Build Coastguard Worker private:
1948*35238bceSAndroid Build Coastguard Worker     int m_x;
1949*35238bceSAndroid Build Coastguard Worker     int m_y;
1950*35238bceSAndroid Build Coastguard Worker     int m_width;
1951*35238bceSAndroid Build Coastguard Worker     int m_height;
1952*35238bceSAndroid Build Coastguard Worker     GLenum m_format;
1953*35238bceSAndroid Build Coastguard Worker     GLenum m_type;
1954*35238bceSAndroid Build Coastguard Worker     SharedPtr<tcu::ThreadUtil::DataBlock> m_data;
1955*35238bceSAndroid Build Coastguard Worker };
1956*35238bceSAndroid Build Coastguard Worker 
ReadPixels(int x,int y,int width,int height,GLenum format,GLenum type,SharedPtr<tcu::ThreadUtil::DataBlock> & data,bool useSync,bool serverSync)1957*35238bceSAndroid Build Coastguard Worker ReadPixels::ReadPixels(int x, int y, int width, int height, GLenum format, GLenum type,
1958*35238bceSAndroid Build Coastguard Worker                        SharedPtr<tcu::ThreadUtil::DataBlock> &data, bool useSync, bool serverSync)
1959*35238bceSAndroid Build Coastguard Worker     : Operation("ReadPixels", useSync, serverSync)
1960*35238bceSAndroid Build Coastguard Worker     , m_x(x)
1961*35238bceSAndroid Build Coastguard Worker     , m_y(y)
1962*35238bceSAndroid Build Coastguard Worker     , m_width(width)
1963*35238bceSAndroid Build Coastguard Worker     , m_height(height)
1964*35238bceSAndroid Build Coastguard Worker     , m_format(format)
1965*35238bceSAndroid Build Coastguard Worker     , m_type(type)
1966*35238bceSAndroid Build Coastguard Worker {
1967*35238bceSAndroid Build Coastguard Worker     data   = SharedPtr<tcu::ThreadUtil::DataBlock>(new tcu::ThreadUtil::DataBlock(getEvent()));
1968*35238bceSAndroid Build Coastguard Worker     m_data = data;
1969*35238bceSAndroid Build Coastguard Worker }
1970*35238bceSAndroid Build Coastguard Worker 
exec(tcu::ThreadUtil::Thread & t)1971*35238bceSAndroid Build Coastguard Worker void ReadPixels::exec(tcu::ThreadUtil::Thread &t)
1972*35238bceSAndroid Build Coastguard Worker {
1973*35238bceSAndroid Build Coastguard Worker     EGLThread &thread = dynamic_cast<EGLThread &>(t);
1974*35238bceSAndroid Build Coastguard Worker 
1975*35238bceSAndroid Build Coastguard Worker     DE_ASSERT(m_type == GL_UNSIGNED_BYTE);
1976*35238bceSAndroid Build Coastguard Worker     DE_ASSERT(m_format == GL_RGBA);
1977*35238bceSAndroid Build Coastguard Worker 
1978*35238bceSAndroid Build Coastguard Worker     std::vector<uint8_t> data((m_width - m_x) * (m_height - m_y) * 4);
1979*35238bceSAndroid Build Coastguard Worker 
1980*35238bceSAndroid Build Coastguard Worker     thread.newMessage() << "Begin -- glReadPixels(" << m_x << ", " << m_y << ", " << m_width << ", " << m_height << ", "
1981*35238bceSAndroid Build Coastguard Worker                         << m_format << ", " << m_type << ", <data>)" << tcu::ThreadUtil::Message::End;
1982*35238bceSAndroid Build Coastguard Worker     GLU_CHECK_GLW_CALL(thread.gl, readPixels(m_x, m_y, m_width, m_height, m_format, m_type, &(data[0])));
1983*35238bceSAndroid Build Coastguard Worker     thread.newMessage() << "End -- glReadPixels()" << tcu::ThreadUtil::Message::End;
1984*35238bceSAndroid Build Coastguard Worker 
1985*35238bceSAndroid Build Coastguard Worker     m_data->setData(data.size(), &(data[0]));
1986*35238bceSAndroid Build Coastguard Worker }
1987*35238bceSAndroid Build Coastguard Worker 
1988*35238bceSAndroid Build Coastguard Worker class CreateImageFromTexture : public Operation
1989*35238bceSAndroid Build Coastguard Worker {
1990*35238bceSAndroid Build Coastguard Worker public:
1991*35238bceSAndroid Build Coastguard Worker     // \note [mika] Unlike eglCreateImageKHR this operation requires current context and uses it for creating EGLImage
1992*35238bceSAndroid Build Coastguard Worker     //                Current context is required to support EGL sync objects in current tests system
1993*35238bceSAndroid Build Coastguard Worker     CreateImageFromTexture(SharedPtr<EGLImage> &image, SharedPtr<Texture> texture, bool useSync, bool serverSync);
1994*35238bceSAndroid Build Coastguard Worker     void exec(tcu::ThreadUtil::Thread &thread);
1995*35238bceSAndroid Build Coastguard Worker 
1996*35238bceSAndroid Build Coastguard Worker private:
1997*35238bceSAndroid Build Coastguard Worker     SharedPtr<Texture> m_texture;
1998*35238bceSAndroid Build Coastguard Worker     SharedPtr<EGLImage> m_image;
1999*35238bceSAndroid Build Coastguard Worker };
2000*35238bceSAndroid Build Coastguard Worker 
CreateImageFromTexture(SharedPtr<EGLImage> & image,SharedPtr<Texture> texture,bool useSync,bool serverSync)2001*35238bceSAndroid Build Coastguard Worker CreateImageFromTexture::CreateImageFromTexture(SharedPtr<EGLImage> &image, SharedPtr<Texture> texture, bool useSync,
2002*35238bceSAndroid Build Coastguard Worker                                                bool serverSync)
2003*35238bceSAndroid Build Coastguard Worker     : Operation("CreateImageFromTexture", useSync, serverSync)
2004*35238bceSAndroid Build Coastguard Worker {
2005*35238bceSAndroid Build Coastguard Worker     modifyGLObject(SharedPtr<Object>(texture));
2006*35238bceSAndroid Build Coastguard Worker     image = SharedPtr<EGLImage>(new EGLImage(getEvent(), getSync()));
2007*35238bceSAndroid Build Coastguard Worker 
2008*35238bceSAndroid Build Coastguard Worker     m_image                = image;
2009*35238bceSAndroid Build Coastguard Worker     m_texture              = texture;
2010*35238bceSAndroid Build Coastguard Worker     m_texture->sourceImage = m_image;
2011*35238bceSAndroid Build Coastguard Worker }
2012*35238bceSAndroid Build Coastguard Worker 
exec(tcu::ThreadUtil::Thread & t)2013*35238bceSAndroid Build Coastguard Worker void CreateImageFromTexture::exec(tcu::ThreadUtil::Thread &t)
2014*35238bceSAndroid Build Coastguard Worker {
2015*35238bceSAndroid Build Coastguard Worker     EGLThread &thread = dynamic_cast<EGLThread &>(t);
2016*35238bceSAndroid Build Coastguard Worker 
2017*35238bceSAndroid Build Coastguard Worker     EGLint attribList[] = {EGL_GL_TEXTURE_LEVEL_KHR, 0, EGL_NONE};
2018*35238bceSAndroid Build Coastguard Worker 
2019*35238bceSAndroid Build Coastguard Worker     thread.newMessage() << "Begin -- glBindTexture(GL_TEXTURE_2D, " << m_texture->texture << ")"
2020*35238bceSAndroid Build Coastguard Worker                         << tcu::ThreadUtil::Message::End;
2021*35238bceSAndroid Build Coastguard Worker     GLU_CHECK_GLW_CALL(thread.gl, bindTexture(GL_TEXTURE_2D, m_texture->texture));
2022*35238bceSAndroid Build Coastguard Worker     thread.newMessage() << "End -- glBindTexture()" << tcu::ThreadUtil::Message::End;
2023*35238bceSAndroid Build Coastguard Worker 
2024*35238bceSAndroid Build Coastguard Worker     // Make texture image complete...
2025*35238bceSAndroid Build Coastguard Worker     thread.newMessage() << "Begin -- glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR)"
2026*35238bceSAndroid Build Coastguard Worker                         << tcu::ThreadUtil::Message::End;
2027*35238bceSAndroid Build Coastguard Worker     GLU_CHECK_GLW_CALL(thread.gl, texParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR));
2028*35238bceSAndroid Build Coastguard Worker     thread.newMessage() << "End -- glTexParameteri()" << tcu::ThreadUtil::Message::End;
2029*35238bceSAndroid Build Coastguard Worker 
2030*35238bceSAndroid Build Coastguard Worker     thread.newMessage() << "Begin -- glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR)"
2031*35238bceSAndroid Build Coastguard Worker                         << tcu::ThreadUtil::Message::End;
2032*35238bceSAndroid Build Coastguard Worker     GLU_CHECK_GLW_CALL(thread.gl, texParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR));
2033*35238bceSAndroid Build Coastguard Worker     thread.newMessage() << "End -- glTexParameteri()" << tcu::ThreadUtil::Message::End;
2034*35238bceSAndroid Build Coastguard Worker 
2035*35238bceSAndroid Build Coastguard Worker     thread.newMessage() << "Begin -- glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE)"
2036*35238bceSAndroid Build Coastguard Worker                         << tcu::ThreadUtil::Message::End;
2037*35238bceSAndroid Build Coastguard Worker     GLU_CHECK_GLW_CALL(thread.gl, texParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE));
2038*35238bceSAndroid Build Coastguard Worker     thread.newMessage() << "End -- glTexParameteri()" << tcu::ThreadUtil::Message::End;
2039*35238bceSAndroid Build Coastguard Worker 
2040*35238bceSAndroid Build Coastguard Worker     thread.newMessage() << "Begin -- glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE)"
2041*35238bceSAndroid Build Coastguard Worker                         << tcu::ThreadUtil::Message::End;
2042*35238bceSAndroid Build Coastguard Worker     GLU_CHECK_GLW_CALL(thread.gl, texParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE));
2043*35238bceSAndroid Build Coastguard Worker     thread.newMessage() << "End -- glTexParameteri()" << tcu::ThreadUtil::Message::End;
2044*35238bceSAndroid Build Coastguard Worker 
2045*35238bceSAndroid Build Coastguard Worker     thread.newMessage() << "Begin -- eglCreateImageKHR(" << thread.runtimeContext->display << ", "
2046*35238bceSAndroid Build Coastguard Worker                         << thread.runtimeContext->context << ", EGL_GL_TEXTURE_2D_KHR, " << m_texture->texture
2047*35238bceSAndroid Build Coastguard Worker                         << ", { EGL_GL_TEXTURE_LEVEL_KHR, 0, EGL_NONE })" << tcu::ThreadUtil::Message::End;
2048*35238bceSAndroid Build Coastguard Worker     m_image->image =
2049*35238bceSAndroid Build Coastguard Worker         thread.egl.createImageKHR(thread.runtimeContext->display, thread.runtimeContext->context, EGL_GL_TEXTURE_2D_KHR,
2050*35238bceSAndroid Build Coastguard Worker                                   (EGLClientBuffer)(uintptr_t)m_texture->texture, attribList);
2051*35238bceSAndroid Build Coastguard Worker     EGLU_CHECK_MSG(thread.egl, "eglCreateImageKHR()");
2052*35238bceSAndroid Build Coastguard Worker     thread.newMessage() << "End -- " << m_image->image << " = eglCreateImageKHR()" << tcu::ThreadUtil::Message::End;
2053*35238bceSAndroid Build Coastguard Worker 
2054*35238bceSAndroid Build Coastguard Worker     thread.newMessage() << "Begin -- glBindTexture(GL_TEXTURE_2D, 0)" << tcu::ThreadUtil::Message::End;
2055*35238bceSAndroid Build Coastguard Worker     GLU_CHECK_GLW_CALL(thread.gl, bindTexture(GL_TEXTURE_2D, 0));
2056*35238bceSAndroid Build Coastguard Worker     thread.newMessage() << "End -- glBindTexture()" << tcu::ThreadUtil::Message::End;
2057*35238bceSAndroid Build Coastguard Worker }
2058*35238bceSAndroid Build Coastguard Worker 
2059*35238bceSAndroid Build Coastguard Worker class DestroyImage : public Operation
2060*35238bceSAndroid Build Coastguard Worker {
2061*35238bceSAndroid Build Coastguard Worker public:
2062*35238bceSAndroid Build Coastguard Worker     // \note [mika] Unlike eglDestroyImageKHR this operation requires current context and uses it for creating EGLImage
2063*35238bceSAndroid Build Coastguard Worker     //                Current context is required to support EGL sync objects in current tests system
2064*35238bceSAndroid Build Coastguard Worker     DestroyImage(SharedPtr<EGLImage> image, bool useSync, bool serverSync);
2065*35238bceSAndroid Build Coastguard Worker     void exec(tcu::ThreadUtil::Thread &thread);
2066*35238bceSAndroid Build Coastguard Worker 
2067*35238bceSAndroid Build Coastguard Worker private:
2068*35238bceSAndroid Build Coastguard Worker     SharedPtr<EGLImage> m_image;
2069*35238bceSAndroid Build Coastguard Worker };
2070*35238bceSAndroid Build Coastguard Worker 
DestroyImage(SharedPtr<EGLImage> image,bool useSync,bool serverSync)2071*35238bceSAndroid Build Coastguard Worker DestroyImage::DestroyImage(SharedPtr<EGLImage> image, bool useSync, bool serverSync)
2072*35238bceSAndroid Build Coastguard Worker     : Operation("CreateImageFromTexture", useSync, serverSync)
2073*35238bceSAndroid Build Coastguard Worker     , m_image(image)
2074*35238bceSAndroid Build Coastguard Worker {
2075*35238bceSAndroid Build Coastguard Worker     modifyGLObject(SharedPtr<Object>(image));
2076*35238bceSAndroid Build Coastguard Worker }
2077*35238bceSAndroid Build Coastguard Worker 
exec(tcu::ThreadUtil::Thread & t)2078*35238bceSAndroid Build Coastguard Worker void DestroyImage::exec(tcu::ThreadUtil::Thread &t)
2079*35238bceSAndroid Build Coastguard Worker {
2080*35238bceSAndroid Build Coastguard Worker     EGLThread &thread = dynamic_cast<EGLThread &>(t);
2081*35238bceSAndroid Build Coastguard Worker 
2082*35238bceSAndroid Build Coastguard Worker     thread.newMessage() << "Begin -- eglDestroyImageKHR(" << thread.runtimeContext->display << ", " << m_image->image
2083*35238bceSAndroid Build Coastguard Worker                         << ")" << tcu::ThreadUtil::Message::End;
2084*35238bceSAndroid Build Coastguard Worker     thread.egl.destroyImageKHR(thread.runtimeContext->display, m_image->image);
2085*35238bceSAndroid Build Coastguard Worker     m_image->image = EGL_NO_IMAGE_KHR;
2086*35238bceSAndroid Build Coastguard Worker     EGLU_CHECK_MSG(thread.egl, "eglDestroyImageKHR()");
2087*35238bceSAndroid Build Coastguard Worker     thread.newMessage() << "End -- eglDestroyImageKHR()" << tcu::ThreadUtil::Message::End;
2088*35238bceSAndroid Build Coastguard Worker }
2089*35238bceSAndroid Build Coastguard Worker 
2090*35238bceSAndroid Build Coastguard Worker class DefineTextureFromImage : public Operation
2091*35238bceSAndroid Build Coastguard Worker {
2092*35238bceSAndroid Build Coastguard Worker public:
2093*35238bceSAndroid Build Coastguard Worker     DefineTextureFromImage(SharedPtr<Texture> texture, SharedPtr<EGLImage> image, bool useSync, bool serverSync);
2094*35238bceSAndroid Build Coastguard Worker     void exec(tcu::ThreadUtil::Thread &thread);
2095*35238bceSAndroid Build Coastguard Worker 
2096*35238bceSAndroid Build Coastguard Worker private:
2097*35238bceSAndroid Build Coastguard Worker     SharedPtr<Texture> m_texture;
2098*35238bceSAndroid Build Coastguard Worker     SharedPtr<EGLImage> m_image;
2099*35238bceSAndroid Build Coastguard Worker };
2100*35238bceSAndroid Build Coastguard Worker 
DefineTextureFromImage(SharedPtr<Texture> texture,SharedPtr<EGLImage> image,bool useSync,bool serverSync)2101*35238bceSAndroid Build Coastguard Worker DefineTextureFromImage::DefineTextureFromImage(SharedPtr<Texture> texture, SharedPtr<EGLImage> image, bool useSync,
2102*35238bceSAndroid Build Coastguard Worker                                                bool serverSync)
2103*35238bceSAndroid Build Coastguard Worker     : Operation("DefineTextureFromImage", useSync, serverSync)
2104*35238bceSAndroid Build Coastguard Worker {
2105*35238bceSAndroid Build Coastguard Worker     readGLObject(SharedPtr<Object>(image));
2106*35238bceSAndroid Build Coastguard Worker     modifyGLObject(SharedPtr<Object>(texture));
2107*35238bceSAndroid Build Coastguard Worker 
2108*35238bceSAndroid Build Coastguard Worker     texture->isDefined   = true;
2109*35238bceSAndroid Build Coastguard Worker     texture->sourceImage = image;
2110*35238bceSAndroid Build Coastguard Worker 
2111*35238bceSAndroid Build Coastguard Worker     m_image   = image;
2112*35238bceSAndroid Build Coastguard Worker     m_texture = texture;
2113*35238bceSAndroid Build Coastguard Worker }
2114*35238bceSAndroid Build Coastguard Worker 
exec(tcu::ThreadUtil::Thread & t)2115*35238bceSAndroid Build Coastguard Worker void DefineTextureFromImage::exec(tcu::ThreadUtil::Thread &t)
2116*35238bceSAndroid Build Coastguard Worker {
2117*35238bceSAndroid Build Coastguard Worker     EGLThread &thread = dynamic_cast<EGLThread &>(t);
2118*35238bceSAndroid Build Coastguard Worker 
2119*35238bceSAndroid Build Coastguard Worker     thread.newMessage() << "Begin -- glBindTexture(GL_TEXTURE_2D, " << m_texture->texture << ")"
2120*35238bceSAndroid Build Coastguard Worker                         << tcu::ThreadUtil::Message::End;
2121*35238bceSAndroid Build Coastguard Worker     GLU_CHECK_GLW_CALL(thread.gl, bindTexture(GL_TEXTURE_2D, m_texture->texture));
2122*35238bceSAndroid Build Coastguard Worker     thread.newMessage() << "End -- glBindTexture()" << tcu::ThreadUtil::Message::End;
2123*35238bceSAndroid Build Coastguard Worker 
2124*35238bceSAndroid Build Coastguard Worker     thread.newMessage() << "Begin -- glEGLImageTargetTexture2DOES(GL_TEXTURE_2D, " << m_image->image << ")"
2125*35238bceSAndroid Build Coastguard Worker                         << tcu::ThreadUtil::Message::End;
2126*35238bceSAndroid Build Coastguard Worker     thread.runtimeContext->glExtensions.imageTargetTexture2D(GL_TEXTURE_2D, m_image->image);
2127*35238bceSAndroid Build Coastguard Worker     GLU_CHECK_GLW_MSG(thread.gl, "glEGLImageTargetTexture2DOES()");
2128*35238bceSAndroid Build Coastguard Worker     thread.newMessage() << "End -- glEGLImageTargetTexture2DOES()" << tcu::ThreadUtil::Message::End;
2129*35238bceSAndroid Build Coastguard Worker 
2130*35238bceSAndroid Build Coastguard Worker     thread.newMessage() << "Begin -- glBindTexture(GL_TEXTURE_2D, 0)" << tcu::ThreadUtil::Message::End;
2131*35238bceSAndroid Build Coastguard Worker     GLU_CHECK_GLW_CALL(thread.gl, bindTexture(GL_TEXTURE_2D, 0));
2132*35238bceSAndroid Build Coastguard Worker     thread.newMessage() << "End -- glBindTexture()" << tcu::ThreadUtil::Message::End;
2133*35238bceSAndroid Build Coastguard Worker }
2134*35238bceSAndroid Build Coastguard Worker 
2135*35238bceSAndroid Build Coastguard Worker } // namespace GLES2ThreadTest
2136*35238bceSAndroid Build Coastguard Worker 
requireEGLExtension(const Library & egl,EGLDisplay eglDisplay,const char * requiredExtension)2137*35238bceSAndroid Build Coastguard Worker static void requireEGLExtension(const Library &egl, EGLDisplay eglDisplay, const char *requiredExtension)
2138*35238bceSAndroid Build Coastguard Worker {
2139*35238bceSAndroid Build Coastguard Worker     if (!eglu::hasExtension(egl, eglDisplay, requiredExtension))
2140*35238bceSAndroid Build Coastguard Worker         TCU_THROW(NotSupportedError, (string(requiredExtension) + " not supported").c_str());
2141*35238bceSAndroid Build Coastguard Worker }
2142*35238bceSAndroid Build Coastguard Worker 
2143*35238bceSAndroid Build Coastguard Worker enum OperationId
2144*35238bceSAndroid Build Coastguard Worker {
2145*35238bceSAndroid Build Coastguard Worker     THREADOPERATIONID_NONE = 0,
2146*35238bceSAndroid Build Coastguard Worker 
2147*35238bceSAndroid Build Coastguard Worker     THREADOPERATIONID_CREATE_BUFFER,
2148*35238bceSAndroid Build Coastguard Worker     THREADOPERATIONID_DESTROY_BUFFER,
2149*35238bceSAndroid Build Coastguard Worker     THREADOPERATIONID_BUFFER_DATA,
2150*35238bceSAndroid Build Coastguard Worker     THREADOPERATIONID_BUFFER_SUBDATA,
2151*35238bceSAndroid Build Coastguard Worker 
2152*35238bceSAndroid Build Coastguard Worker     THREADOPERATIONID_CREATE_TEXTURE,
2153*35238bceSAndroid Build Coastguard Worker     THREADOPERATIONID_DESTROY_TEXTURE,
2154*35238bceSAndroid Build Coastguard Worker     THREADOPERATIONID_TEXIMAGE2D,
2155*35238bceSAndroid Build Coastguard Worker     THREADOPERATIONID_TEXSUBIMAGE2D,
2156*35238bceSAndroid Build Coastguard Worker     THREADOPERATIONID_COPYTEXIMAGE2D,
2157*35238bceSAndroid Build Coastguard Worker     THREADOPERATIONID_COPYTEXSUBIMAGE2D,
2158*35238bceSAndroid Build Coastguard Worker 
2159*35238bceSAndroid Build Coastguard Worker     THREADOPERATIONID_CREATE_VERTEX_SHADER,
2160*35238bceSAndroid Build Coastguard Worker     THREADOPERATIONID_CREATE_FRAGMENT_SHADER,
2161*35238bceSAndroid Build Coastguard Worker     THREADOPERATIONID_DESTROY_SHADER,
2162*35238bceSAndroid Build Coastguard Worker     THREADOPERATIONID_SHADER_SOURCE,
2163*35238bceSAndroid Build Coastguard Worker     THREADOPERATIONID_SHADER_COMPILE,
2164*35238bceSAndroid Build Coastguard Worker 
2165*35238bceSAndroid Build Coastguard Worker     THREADOPERATIONID_ATTACH_SHADER,
2166*35238bceSAndroid Build Coastguard Worker     THREADOPERATIONID_DETACH_SHADER,
2167*35238bceSAndroid Build Coastguard Worker 
2168*35238bceSAndroid Build Coastguard Worker     THREADOPERATIONID_CREATE_PROGRAM,
2169*35238bceSAndroid Build Coastguard Worker     THREADOPERATIONID_DESTROY_PROGRAM,
2170*35238bceSAndroid Build Coastguard Worker     THREADOPERATIONID_LINK_PROGRAM,
2171*35238bceSAndroid Build Coastguard Worker 
2172*35238bceSAndroid Build Coastguard Worker     THREADOPERATIONID_CREATE_IMAGE_FROM_TEXTURE,
2173*35238bceSAndroid Build Coastguard Worker     THREADOPERATIONID_DESTROY_IMAGE,
2174*35238bceSAndroid Build Coastguard Worker     THREADOPERATIONID_TEXTURE_FROM_IMAGE,
2175*35238bceSAndroid Build Coastguard Worker 
2176*35238bceSAndroid Build Coastguard Worker     THREADOPERATIONID_LAST
2177*35238bceSAndroid Build Coastguard Worker };
2178*35238bceSAndroid Build Coastguard Worker 
2179*35238bceSAndroid Build Coastguard Worker class GLES2SharingRandomTest : public TestCase
2180*35238bceSAndroid Build Coastguard Worker {
2181*35238bceSAndroid Build Coastguard Worker public:
2182*35238bceSAndroid Build Coastguard Worker     struct TestConfig
2183*35238bceSAndroid Build Coastguard Worker     {
2184*35238bceSAndroid Build Coastguard Worker         TestConfig(void);
2185*35238bceSAndroid Build Coastguard Worker         int threadCount;
2186*35238bceSAndroid Build Coastguard Worker         int operationCount;
2187*35238bceSAndroid Build Coastguard Worker         bool serverSync;
2188*35238bceSAndroid Build Coastguard Worker         bool useFenceSync;
2189*35238bceSAndroid Build Coastguard Worker         bool useImages;
2190*35238bceSAndroid Build Coastguard Worker 
2191*35238bceSAndroid Build Coastguard Worker         float probabilities[THREADOPERATIONID_LAST][THREADOPERATIONID_LAST];
2192*35238bceSAndroid Build Coastguard Worker     };
2193*35238bceSAndroid Build Coastguard Worker     GLES2SharingRandomTest(EglTestContext &context, const TestConfig &config, const char *name,
2194*35238bceSAndroid Build Coastguard Worker                            const char *description);
2195*35238bceSAndroid Build Coastguard Worker     ~GLES2SharingRandomTest(void);
2196*35238bceSAndroid Build Coastguard Worker 
2197*35238bceSAndroid Build Coastguard Worker     void init(void);
2198*35238bceSAndroid Build Coastguard Worker     void deinit(void);
2199*35238bceSAndroid Build Coastguard Worker     IterateResult iterate(void);
2200*35238bceSAndroid Build Coastguard Worker 
2201*35238bceSAndroid Build Coastguard Worker     void addRandomOperation(GLES2ThreadTest::EGLResourceManager &resourceManager);
2202*35238bceSAndroid Build Coastguard Worker 
2203*35238bceSAndroid Build Coastguard Worker private:
2204*35238bceSAndroid Build Coastguard Worker     TestConfig m_config;
2205*35238bceSAndroid Build Coastguard Worker     int m_seed;
2206*35238bceSAndroid Build Coastguard Worker     de::Random m_random;
2207*35238bceSAndroid Build Coastguard Worker     tcu::TestLog &m_log;
2208*35238bceSAndroid Build Coastguard Worker     bool m_threadsStarted;
2209*35238bceSAndroid Build Coastguard Worker     bool m_threadsRunning;
2210*35238bceSAndroid Build Coastguard Worker     bool m_executionReady;
2211*35238bceSAndroid Build Coastguard Worker     bool m_requiresRestart;
2212*35238bceSAndroid Build Coastguard Worker     uint64_t m_beginTimeUs;
2213*35238bceSAndroid Build Coastguard Worker     uint64_t m_timeOutUs;
2214*35238bceSAndroid Build Coastguard Worker     uint32_t m_sleepTimeMs;
2215*35238bceSAndroid Build Coastguard Worker     uint64_t m_timeOutTimeUs;
2216*35238bceSAndroid Build Coastguard Worker 
2217*35238bceSAndroid Build Coastguard Worker     std::vector<GLES2ThreadTest::EGLThread *> m_threads;
2218*35238bceSAndroid Build Coastguard Worker 
2219*35238bceSAndroid Build Coastguard Worker     EGLDisplay m_eglDisplay;
2220*35238bceSAndroid Build Coastguard Worker     EGLConfig m_eglConfig;
2221*35238bceSAndroid Build Coastguard Worker     OperationId m_lastOperation;
2222*35238bceSAndroid Build Coastguard Worker 
2223*35238bceSAndroid Build Coastguard Worker     glw::Functions m_gl;
2224*35238bceSAndroid Build Coastguard Worker };
2225*35238bceSAndroid Build Coastguard Worker 
TestConfig(void)2226*35238bceSAndroid Build Coastguard Worker GLES2SharingRandomTest::TestConfig::TestConfig(void)
2227*35238bceSAndroid Build Coastguard Worker     : threadCount(0)
2228*35238bceSAndroid Build Coastguard Worker     , operationCount(0)
2229*35238bceSAndroid Build Coastguard Worker     , serverSync(false)
2230*35238bceSAndroid Build Coastguard Worker     , useFenceSync(false)
2231*35238bceSAndroid Build Coastguard Worker     , useImages(false)
2232*35238bceSAndroid Build Coastguard Worker {
2233*35238bceSAndroid Build Coastguard Worker     deMemset(probabilities, 0, sizeof(probabilities));
2234*35238bceSAndroid Build Coastguard Worker }
2235*35238bceSAndroid Build Coastguard Worker 
GLES2SharingRandomTest(EglTestContext & context,const TestConfig & config,const char * name,const char * description)2236*35238bceSAndroid Build Coastguard Worker GLES2SharingRandomTest::GLES2SharingRandomTest(EglTestContext &context, const TestConfig &config, const char *name,
2237*35238bceSAndroid Build Coastguard Worker                                                const char *description)
2238*35238bceSAndroid Build Coastguard Worker     : TestCase(context, name, description)
2239*35238bceSAndroid Build Coastguard Worker     , m_config(config)
2240*35238bceSAndroid Build Coastguard Worker     , m_seed(deStringHash(name))
2241*35238bceSAndroid Build Coastguard Worker     , m_random(deStringHash(name))
2242*35238bceSAndroid Build Coastguard Worker     , m_log(m_testCtx.getLog())
2243*35238bceSAndroid Build Coastguard Worker     , m_threadsStarted(false)
2244*35238bceSAndroid Build Coastguard Worker     , m_threadsRunning(false)
2245*35238bceSAndroid Build Coastguard Worker     , m_executionReady(false)
2246*35238bceSAndroid Build Coastguard Worker     , m_requiresRestart(false)
2247*35238bceSAndroid Build Coastguard Worker     , m_beginTimeUs(0)
2248*35238bceSAndroid Build Coastguard Worker     , m_timeOutUs(10000000) // 10 seconds
2249*35238bceSAndroid Build Coastguard Worker     , m_sleepTimeMs(1)      // 1 milliseconds
2250*35238bceSAndroid Build Coastguard Worker     , m_timeOutTimeUs(0)
2251*35238bceSAndroid Build Coastguard Worker     , m_eglDisplay(EGL_NO_DISPLAY)
2252*35238bceSAndroid Build Coastguard Worker     , m_eglConfig(0)
2253*35238bceSAndroid Build Coastguard Worker     , m_lastOperation(THREADOPERATIONID_NONE)
2254*35238bceSAndroid Build Coastguard Worker {
2255*35238bceSAndroid Build Coastguard Worker }
2256*35238bceSAndroid Build Coastguard Worker 
~GLES2SharingRandomTest(void)2257*35238bceSAndroid Build Coastguard Worker GLES2SharingRandomTest::~GLES2SharingRandomTest(void)
2258*35238bceSAndroid Build Coastguard Worker {
2259*35238bceSAndroid Build Coastguard Worker     GLES2SharingRandomTest::deinit();
2260*35238bceSAndroid Build Coastguard Worker }
2261*35238bceSAndroid Build Coastguard Worker 
init(void)2262*35238bceSAndroid Build Coastguard Worker void GLES2SharingRandomTest::init(void)
2263*35238bceSAndroid Build Coastguard Worker {
2264*35238bceSAndroid Build Coastguard Worker     const Library &egl = m_eglTestCtx.getLibrary();
2265*35238bceSAndroid Build Coastguard Worker 
2266*35238bceSAndroid Build Coastguard Worker     const EGLint attribList[] = {
2267*35238bceSAndroid Build Coastguard Worker         EGL_RENDERABLE_TYPE, EGL_OPENGL_ES2_BIT, EGL_SURFACE_TYPE, EGL_PBUFFER_BIT, EGL_ALPHA_SIZE, 1, EGL_NONE};
2268*35238bceSAndroid Build Coastguard Worker 
2269*35238bceSAndroid Build Coastguard Worker     m_eglDisplay = eglu::getAndInitDisplay(m_eglTestCtx.getNativeDisplay());
2270*35238bceSAndroid Build Coastguard Worker     m_eglConfig  = eglu::chooseSingleConfig(egl, m_eglDisplay, attribList);
2271*35238bceSAndroid Build Coastguard Worker 
2272*35238bceSAndroid Build Coastguard Worker     m_eglTestCtx.initGLFunctions(&m_gl, glu::ApiType::es(2, 0));
2273*35238bceSAndroid Build Coastguard Worker 
2274*35238bceSAndroid Build Coastguard Worker     // Check extensions
2275*35238bceSAndroid Build Coastguard Worker     if (m_config.useFenceSync)
2276*35238bceSAndroid Build Coastguard Worker         requireEGLExtension(egl, m_eglDisplay, "EGL_KHR_fence_sync");
2277*35238bceSAndroid Build Coastguard Worker 
2278*35238bceSAndroid Build Coastguard Worker     if (m_config.serverSync)
2279*35238bceSAndroid Build Coastguard Worker         requireEGLExtension(egl, m_eglDisplay, "EGL_KHR_wait_sync");
2280*35238bceSAndroid Build Coastguard Worker 
2281*35238bceSAndroid Build Coastguard Worker     if (m_config.useImages)
2282*35238bceSAndroid Build Coastguard Worker     {
2283*35238bceSAndroid Build Coastguard Worker         requireEGLExtension(egl, m_eglDisplay, "EGL_KHR_image_base");
2284*35238bceSAndroid Build Coastguard Worker         requireEGLExtension(egl, m_eglDisplay, "EGL_KHR_gl_texture_2D_image");
2285*35238bceSAndroid Build Coastguard Worker     }
2286*35238bceSAndroid Build Coastguard Worker 
2287*35238bceSAndroid Build Coastguard Worker     GLES2ThreadTest::EGLResourceManager resourceManager;
2288*35238bceSAndroid Build Coastguard Worker     // Create contexts
2289*35238bceSAndroid Build Coastguard Worker     for (int threadNdx = 0; threadNdx < m_config.threadCount; threadNdx++)
2290*35238bceSAndroid Build Coastguard Worker     {
2291*35238bceSAndroid Build Coastguard Worker         m_threads.push_back(new GLES2ThreadTest::EGLThread(egl, m_gl, deInt32Hash(m_seed + threadNdx)));
2292*35238bceSAndroid Build Coastguard Worker         SharedPtr<GLES2ThreadTest::GLES2Context> context;
2293*35238bceSAndroid Build Coastguard Worker         SharedPtr<GLES2ThreadTest::GLES2Context> shared =
2294*35238bceSAndroid Build Coastguard Worker             (threadNdx > 0 ? resourceManager.popContext(0) : SharedPtr<GLES2ThreadTest::GLES2Context>());
2295*35238bceSAndroid Build Coastguard Worker         m_threads[threadNdx]->addOperation(
2296*35238bceSAndroid Build Coastguard Worker             new GLES2ThreadTest::CreateContext(m_eglDisplay, m_eglConfig, shared, context));
2297*35238bceSAndroid Build Coastguard Worker 
2298*35238bceSAndroid Build Coastguard Worker         resourceManager.addContext(context);
2299*35238bceSAndroid Build Coastguard Worker 
2300*35238bceSAndroid Build Coastguard Worker         if (shared)
2301*35238bceSAndroid Build Coastguard Worker             resourceManager.addContext(shared);
2302*35238bceSAndroid Build Coastguard Worker     }
2303*35238bceSAndroid Build Coastguard Worker 
2304*35238bceSAndroid Build Coastguard Worker     // Create surfaces
2305*35238bceSAndroid Build Coastguard Worker     for (int threadNdx = 0; threadNdx < m_config.threadCount; threadNdx++)
2306*35238bceSAndroid Build Coastguard Worker     {
2307*35238bceSAndroid Build Coastguard Worker         SharedPtr<GLES2ThreadTest::Surface> surface;
2308*35238bceSAndroid Build Coastguard Worker         m_threads[threadNdx]->addOperation(
2309*35238bceSAndroid Build Coastguard Worker             new GLES2ThreadTest::CreatePBufferSurface(m_eglDisplay, m_eglConfig, 400, 400, surface));
2310*35238bceSAndroid Build Coastguard Worker         resourceManager.addSurface(surface);
2311*35238bceSAndroid Build Coastguard Worker     }
2312*35238bceSAndroid Build Coastguard Worker 
2313*35238bceSAndroid Build Coastguard Worker     // Make contexts current
2314*35238bceSAndroid Build Coastguard Worker     for (int threadNdx = 0; threadNdx < m_config.threadCount; threadNdx++)
2315*35238bceSAndroid Build Coastguard Worker     {
2316*35238bceSAndroid Build Coastguard Worker         m_threads[threadNdx]->addOperation(new GLES2ThreadTest::MakeCurrent(
2317*35238bceSAndroid Build Coastguard Worker             *m_threads[threadNdx], m_eglDisplay, resourceManager.popSurface(0), resourceManager.popContext(0)));
2318*35238bceSAndroid Build Coastguard Worker     }
2319*35238bceSAndroid Build Coastguard Worker 
2320*35238bceSAndroid Build Coastguard Worker     // Operations to check fence sync support
2321*35238bceSAndroid Build Coastguard Worker     if (m_config.useFenceSync)
2322*35238bceSAndroid Build Coastguard Worker     {
2323*35238bceSAndroid Build Coastguard Worker         for (int threadNdx = 0; threadNdx < m_config.threadCount; threadNdx++)
2324*35238bceSAndroid Build Coastguard Worker         {
2325*35238bceSAndroid Build Coastguard Worker             m_threads[threadNdx]->addOperation(new GLES2ThreadTest::InitGLExtension("GL_OES_EGL_sync"));
2326*35238bceSAndroid Build Coastguard Worker         }
2327*35238bceSAndroid Build Coastguard Worker     }
2328*35238bceSAndroid Build Coastguard Worker 
2329*35238bceSAndroid Build Coastguard Worker     // Init EGLimage support
2330*35238bceSAndroid Build Coastguard Worker     if (m_config.useImages)
2331*35238bceSAndroid Build Coastguard Worker     {
2332*35238bceSAndroid Build Coastguard Worker         for (int threadNdx = 0; threadNdx < m_config.threadCount; threadNdx++)
2333*35238bceSAndroid Build Coastguard Worker         {
2334*35238bceSAndroid Build Coastguard Worker             m_threads[threadNdx]->addOperation(new GLES2ThreadTest::InitGLExtension("GL_OES_EGL_image"));
2335*35238bceSAndroid Build Coastguard Worker         }
2336*35238bceSAndroid Build Coastguard Worker     }
2337*35238bceSAndroid Build Coastguard Worker 
2338*35238bceSAndroid Build Coastguard Worker     // Add random operations
2339*35238bceSAndroid Build Coastguard Worker     for (int operationNdx = 0; operationNdx < m_config.operationCount; operationNdx++)
2340*35238bceSAndroid Build Coastguard Worker         addRandomOperation(resourceManager);
2341*35238bceSAndroid Build Coastguard Worker 
2342*35238bceSAndroid Build Coastguard Worker     {
2343*35238bceSAndroid Build Coastguard Worker         int threadNdx = 0;
2344*35238bceSAndroid Build Coastguard Worker 
2345*35238bceSAndroid Build Coastguard Worker         // Destroy images
2346*35238bceSAndroid Build Coastguard Worker         // \note Android reference counts EGLDisplays so we can't trust the eglTerminate() to clean up resources
2347*35238bceSAndroid Build Coastguard Worker         while (resourceManager.getImageCount() > 0)
2348*35238bceSAndroid Build Coastguard Worker         {
2349*35238bceSAndroid Build Coastguard Worker             const SharedPtr<GLES2ThreadTest::EGLImage> image = resourceManager.popImage(0);
2350*35238bceSAndroid Build Coastguard Worker 
2351*35238bceSAndroid Build Coastguard Worker             m_threads[threadNdx]->addOperation(
2352*35238bceSAndroid Build Coastguard Worker                 new GLES2ThreadTest::DestroyImage(image, m_config.useFenceSync, m_config.serverSync));
2353*35238bceSAndroid Build Coastguard Worker 
2354*35238bceSAndroid Build Coastguard Worker             threadNdx = (threadNdx + 1) % m_config.threadCount;
2355*35238bceSAndroid Build Coastguard Worker         }
2356*35238bceSAndroid Build Coastguard Worker     }
2357*35238bceSAndroid Build Coastguard Worker 
2358*35238bceSAndroid Build Coastguard Worker     // Release contexts
2359*35238bceSAndroid Build Coastguard Worker     for (int threadNdx = 0; threadNdx < m_config.threadCount; threadNdx++)
2360*35238bceSAndroid Build Coastguard Worker     {
2361*35238bceSAndroid Build Coastguard Worker         SharedPtr<GLES2ThreadTest::GLES2Context> context = m_threads[threadNdx]->context;
2362*35238bceSAndroid Build Coastguard Worker         SharedPtr<GLES2ThreadTest::Surface> surface      = m_threads[threadNdx]->surface;
2363*35238bceSAndroid Build Coastguard Worker 
2364*35238bceSAndroid Build Coastguard Worker         m_threads[threadNdx]->addOperation(
2365*35238bceSAndroid Build Coastguard Worker             new GLES2ThreadTest::MakeCurrent(*m_threads[threadNdx], m_eglDisplay, SharedPtr<GLES2ThreadTest::Surface>(),
2366*35238bceSAndroid Build Coastguard Worker                                              SharedPtr<GLES2ThreadTest::GLES2Context>()));
2367*35238bceSAndroid Build Coastguard Worker 
2368*35238bceSAndroid Build Coastguard Worker         resourceManager.addSurface(surface);
2369*35238bceSAndroid Build Coastguard Worker         resourceManager.addContext(context);
2370*35238bceSAndroid Build Coastguard Worker     }
2371*35238bceSAndroid Build Coastguard Worker 
2372*35238bceSAndroid Build Coastguard Worker     // Destroy contexts
2373*35238bceSAndroid Build Coastguard Worker     for (int threadNdx = 0; threadNdx < (int)m_threads.size(); threadNdx++)
2374*35238bceSAndroid Build Coastguard Worker         m_threads[threadNdx]->addOperation(new GLES2ThreadTest::DestroyContext(resourceManager.popContext(0)));
2375*35238bceSAndroid Build Coastguard Worker 
2376*35238bceSAndroid Build Coastguard Worker     // Destroy surfaces
2377*35238bceSAndroid Build Coastguard Worker     for (int threadNdx = 0; threadNdx < m_config.threadCount; threadNdx++)
2378*35238bceSAndroid Build Coastguard Worker         m_threads[threadNdx]->addOperation(
2379*35238bceSAndroid Build Coastguard Worker             new GLES2ThreadTest::DestroySurface(m_eglDisplay, resourceManager.popSurface(0)));
2380*35238bceSAndroid Build Coastguard Worker }
2381*35238bceSAndroid Build Coastguard Worker 
deinit(void)2382*35238bceSAndroid Build Coastguard Worker void GLES2SharingRandomTest::deinit(void)
2383*35238bceSAndroid Build Coastguard Worker {
2384*35238bceSAndroid Build Coastguard Worker     for (int threadNdx = 0; threadNdx < (int)m_threads.size(); threadNdx++)
2385*35238bceSAndroid Build Coastguard Worker     {
2386*35238bceSAndroid Build Coastguard Worker         delete m_threads[threadNdx];
2387*35238bceSAndroid Build Coastguard Worker         m_threads[threadNdx] = DE_NULL;
2388*35238bceSAndroid Build Coastguard Worker     }
2389*35238bceSAndroid Build Coastguard Worker 
2390*35238bceSAndroid Build Coastguard Worker     m_threads.clear();
2391*35238bceSAndroid Build Coastguard Worker 
2392*35238bceSAndroid Build Coastguard Worker     if (m_eglDisplay != EGL_NO_DISPLAY)
2393*35238bceSAndroid Build Coastguard Worker     {
2394*35238bceSAndroid Build Coastguard Worker         m_eglTestCtx.getLibrary().terminate(m_eglDisplay);
2395*35238bceSAndroid Build Coastguard Worker         m_eglDisplay = EGL_NO_DISPLAY;
2396*35238bceSAndroid Build Coastguard Worker     }
2397*35238bceSAndroid Build Coastguard Worker 
2398*35238bceSAndroid Build Coastguard Worker     TCU_CHECK(!m_requiresRestart);
2399*35238bceSAndroid Build Coastguard Worker }
2400*35238bceSAndroid Build Coastguard Worker 
addRandomOperation(GLES2ThreadTest::EGLResourceManager & resourceManager)2401*35238bceSAndroid Build Coastguard Worker void GLES2SharingRandomTest::addRandomOperation(GLES2ThreadTest::EGLResourceManager &resourceManager)
2402*35238bceSAndroid Build Coastguard Worker {
2403*35238bceSAndroid Build Coastguard Worker     int threadNdx = m_random.getUint32() % (uint32_t)m_threads.size();
2404*35238bceSAndroid Build Coastguard Worker 
2405*35238bceSAndroid Build Coastguard Worker     std::vector<OperationId> operations;
2406*35238bceSAndroid Build Coastguard Worker     std::vector<float> weights;
2407*35238bceSAndroid Build Coastguard Worker 
2408*35238bceSAndroid Build Coastguard Worker     operations.push_back(THREADOPERATIONID_CREATE_BUFFER);
2409*35238bceSAndroid Build Coastguard Worker     weights.push_back(m_config.probabilities[m_lastOperation][THREADOPERATIONID_CREATE_BUFFER]);
2410*35238bceSAndroid Build Coastguard Worker 
2411*35238bceSAndroid Build Coastguard Worker     operations.push_back(THREADOPERATIONID_CREATE_TEXTURE);
2412*35238bceSAndroid Build Coastguard Worker     weights.push_back(m_config.probabilities[m_lastOperation][THREADOPERATIONID_CREATE_TEXTURE]);
2413*35238bceSAndroid Build Coastguard Worker 
2414*35238bceSAndroid Build Coastguard Worker     operations.push_back(THREADOPERATIONID_CREATE_VERTEX_SHADER);
2415*35238bceSAndroid Build Coastguard Worker     weights.push_back(m_config.probabilities[m_lastOperation][THREADOPERATIONID_CREATE_VERTEX_SHADER]);
2416*35238bceSAndroid Build Coastguard Worker 
2417*35238bceSAndroid Build Coastguard Worker     operations.push_back(THREADOPERATIONID_CREATE_FRAGMENT_SHADER);
2418*35238bceSAndroid Build Coastguard Worker     weights.push_back(m_config.probabilities[m_lastOperation][THREADOPERATIONID_CREATE_FRAGMENT_SHADER]);
2419*35238bceSAndroid Build Coastguard Worker 
2420*35238bceSAndroid Build Coastguard Worker     operations.push_back(THREADOPERATIONID_CREATE_PROGRAM);
2421*35238bceSAndroid Build Coastguard Worker     weights.push_back(m_config.probabilities[m_lastOperation][THREADOPERATIONID_CREATE_PROGRAM]);
2422*35238bceSAndroid Build Coastguard Worker 
2423*35238bceSAndroid Build Coastguard Worker     int destroyableBufferNdx  = -1;
2424*35238bceSAndroid Build Coastguard Worker     int destroyableTextureNdx = -1;
2425*35238bceSAndroid Build Coastguard Worker     int destroyableShaderNdx  = -1;
2426*35238bceSAndroid Build Coastguard Worker     int destroyableProgramNdx = -1;
2427*35238bceSAndroid Build Coastguard Worker 
2428*35238bceSAndroid Build Coastguard Worker     int vertexShaderNdx   = -1;
2429*35238bceSAndroid Build Coastguard Worker     int fragmentShaderNdx = -1;
2430*35238bceSAndroid Build Coastguard Worker 
2431*35238bceSAndroid Build Coastguard Worker     int definedTextureNdx = -1;
2432*35238bceSAndroid Build Coastguard Worker 
2433*35238bceSAndroid Build Coastguard Worker     int definedBufferNdx = -1;
2434*35238bceSAndroid Build Coastguard Worker 
2435*35238bceSAndroid Build Coastguard Worker     int definedShaderNdx = -1;
2436*35238bceSAndroid Build Coastguard Worker 
2437*35238bceSAndroid Build Coastguard Worker     int detachableProgramNdx = -1;
2438*35238bceSAndroid Build Coastguard Worker     GLenum detachShaderType  = GL_VERTEX_SHADER;
2439*35238bceSAndroid Build Coastguard Worker 
2440*35238bceSAndroid Build Coastguard Worker     int unusedVertexAttachmentProgramNdx   = -1;
2441*35238bceSAndroid Build Coastguard Worker     int unusedFragmentAttachmentProgramNdx = -1;
2442*35238bceSAndroid Build Coastguard Worker 
2443*35238bceSAndroid Build Coastguard Worker     int linkableProgramNdx = -1;
2444*35238bceSAndroid Build Coastguard Worker 
2445*35238bceSAndroid Build Coastguard Worker     int attachProgramNdx = -1;
2446*35238bceSAndroid Build Coastguard Worker     int attachShaderNdx  = -1;
2447*35238bceSAndroid Build Coastguard Worker 
2448*35238bceSAndroid Build Coastguard Worker     int nonSiblingTextureNdx = -1;
2449*35238bceSAndroid Build Coastguard Worker 
2450*35238bceSAndroid Build Coastguard Worker     if (m_threads[threadNdx]->context->resourceManager->getBufferCount() > 0)
2451*35238bceSAndroid Build Coastguard Worker         destroyableBufferNdx = m_random.getUint32() % m_threads[threadNdx]->context->resourceManager->getBufferCount();
2452*35238bceSAndroid Build Coastguard Worker 
2453*35238bceSAndroid Build Coastguard Worker     if (m_threads[threadNdx]->context->resourceManager->getTextureCount() > 0)
2454*35238bceSAndroid Build Coastguard Worker         destroyableTextureNdx =
2455*35238bceSAndroid Build Coastguard Worker             m_random.getUint32() % m_threads[threadNdx]->context->resourceManager->getTextureCount();
2456*35238bceSAndroid Build Coastguard Worker 
2457*35238bceSAndroid Build Coastguard Worker     if (m_threads[threadNdx]->context->resourceManager->getShaderCount() > 0)
2458*35238bceSAndroid Build Coastguard Worker         destroyableShaderNdx = m_random.getUint32() % m_threads[threadNdx]->context->resourceManager->getShaderCount();
2459*35238bceSAndroid Build Coastguard Worker 
2460*35238bceSAndroid Build Coastguard Worker     if (m_threads[threadNdx]->context->resourceManager->getProgramCount() > 0)
2461*35238bceSAndroid Build Coastguard Worker         destroyableProgramNdx =
2462*35238bceSAndroid Build Coastguard Worker             m_random.getUint32() % m_threads[threadNdx]->context->resourceManager->getProgramCount();
2463*35238bceSAndroid Build Coastguard Worker 
2464*35238bceSAndroid Build Coastguard Worker     // Check what kind of buffers we have
2465*35238bceSAndroid Build Coastguard Worker     for (int bufferNdx = 0; bufferNdx < m_threads[threadNdx]->context->resourceManager->getBufferCount(); bufferNdx++)
2466*35238bceSAndroid Build Coastguard Worker     {
2467*35238bceSAndroid Build Coastguard Worker         SharedPtr<GLES2ThreadTest::Buffer> buffer =
2468*35238bceSAndroid Build Coastguard Worker             m_threads[threadNdx]->context->resourceManager->getBuffer(bufferNdx);
2469*35238bceSAndroid Build Coastguard Worker 
2470*35238bceSAndroid Build Coastguard Worker         if (buffer->isDefined)
2471*35238bceSAndroid Build Coastguard Worker         {
2472*35238bceSAndroid Build Coastguard Worker             if (definedBufferNdx == -1)
2473*35238bceSAndroid Build Coastguard Worker                 definedBufferNdx = bufferNdx;
2474*35238bceSAndroid Build Coastguard Worker             else if (m_random.getBool())
2475*35238bceSAndroid Build Coastguard Worker                 definedBufferNdx = bufferNdx;
2476*35238bceSAndroid Build Coastguard Worker         }
2477*35238bceSAndroid Build Coastguard Worker     }
2478*35238bceSAndroid Build Coastguard Worker 
2479*35238bceSAndroid Build Coastguard Worker     // Check what kind of textures we have
2480*35238bceSAndroid Build Coastguard Worker     for (int textureNdx = 0; textureNdx < m_threads[threadNdx]->context->resourceManager->getTextureCount();
2481*35238bceSAndroid Build Coastguard Worker          textureNdx++)
2482*35238bceSAndroid Build Coastguard Worker     {
2483*35238bceSAndroid Build Coastguard Worker         SharedPtr<GLES2ThreadTest::Texture> texture =
2484*35238bceSAndroid Build Coastguard Worker             m_threads[threadNdx]->context->resourceManager->getTexture(textureNdx);
2485*35238bceSAndroid Build Coastguard Worker 
2486*35238bceSAndroid Build Coastguard Worker         if (texture->isDefined)
2487*35238bceSAndroid Build Coastguard Worker         {
2488*35238bceSAndroid Build Coastguard Worker             if (definedTextureNdx == -1)
2489*35238bceSAndroid Build Coastguard Worker                 definedTextureNdx = textureNdx;
2490*35238bceSAndroid Build Coastguard Worker             else if (m_random.getBool())
2491*35238bceSAndroid Build Coastguard Worker                 definedTextureNdx = textureNdx;
2492*35238bceSAndroid Build Coastguard Worker 
2493*35238bceSAndroid Build Coastguard Worker             if (!texture->sourceImage)
2494*35238bceSAndroid Build Coastguard Worker             {
2495*35238bceSAndroid Build Coastguard Worker                 if (nonSiblingTextureNdx == -1)
2496*35238bceSAndroid Build Coastguard Worker                     nonSiblingTextureNdx = textureNdx;
2497*35238bceSAndroid Build Coastguard Worker                 else if (m_random.getBool())
2498*35238bceSAndroid Build Coastguard Worker                     nonSiblingTextureNdx = textureNdx;
2499*35238bceSAndroid Build Coastguard Worker             }
2500*35238bceSAndroid Build Coastguard Worker         }
2501*35238bceSAndroid Build Coastguard Worker     }
2502*35238bceSAndroid Build Coastguard Worker 
2503*35238bceSAndroid Build Coastguard Worker     // Check what kind of shaders we have
2504*35238bceSAndroid Build Coastguard Worker     for (int shaderNdx = 0; shaderNdx < m_threads[threadNdx]->context->resourceManager->getShaderCount(); shaderNdx++)
2505*35238bceSAndroid Build Coastguard Worker     {
2506*35238bceSAndroid Build Coastguard Worker         SharedPtr<GLES2ThreadTest::Shader> shader =
2507*35238bceSAndroid Build Coastguard Worker             m_threads[threadNdx]->context->resourceManager->getShader(shaderNdx);
2508*35238bceSAndroid Build Coastguard Worker 
2509*35238bceSAndroid Build Coastguard Worker         // Defined shader found
2510*35238bceSAndroid Build Coastguard Worker         if (shader->isDefined)
2511*35238bceSAndroid Build Coastguard Worker         {
2512*35238bceSAndroid Build Coastguard Worker             if (definedShaderNdx == -1)
2513*35238bceSAndroid Build Coastguard Worker                 definedShaderNdx = shaderNdx;
2514*35238bceSAndroid Build Coastguard Worker             else if (m_random.getBool())
2515*35238bceSAndroid Build Coastguard Worker                 definedShaderNdx = shaderNdx;
2516*35238bceSAndroid Build Coastguard Worker         }
2517*35238bceSAndroid Build Coastguard Worker 
2518*35238bceSAndroid Build Coastguard Worker         // Vertex shader found
2519*35238bceSAndroid Build Coastguard Worker         if (shader->type == GL_VERTEX_SHADER)
2520*35238bceSAndroid Build Coastguard Worker         {
2521*35238bceSAndroid Build Coastguard Worker             if (vertexShaderNdx == -1)
2522*35238bceSAndroid Build Coastguard Worker                 vertexShaderNdx = shaderNdx;
2523*35238bceSAndroid Build Coastguard Worker             else if (m_random.getBool())
2524*35238bceSAndroid Build Coastguard Worker                 vertexShaderNdx = shaderNdx;
2525*35238bceSAndroid Build Coastguard Worker         }
2526*35238bceSAndroid Build Coastguard Worker 
2527*35238bceSAndroid Build Coastguard Worker         // Fragmet shader found
2528*35238bceSAndroid Build Coastguard Worker         if (shader->type == GL_FRAGMENT_SHADER)
2529*35238bceSAndroid Build Coastguard Worker         {
2530*35238bceSAndroid Build Coastguard Worker             if (fragmentShaderNdx == -1)
2531*35238bceSAndroid Build Coastguard Worker                 fragmentShaderNdx = shaderNdx;
2532*35238bceSAndroid Build Coastguard Worker             else if (m_random.getBool())
2533*35238bceSAndroid Build Coastguard Worker                 fragmentShaderNdx = shaderNdx;
2534*35238bceSAndroid Build Coastguard Worker         }
2535*35238bceSAndroid Build Coastguard Worker     }
2536*35238bceSAndroid Build Coastguard Worker 
2537*35238bceSAndroid Build Coastguard Worker     // Check what kind of programs we have
2538*35238bceSAndroid Build Coastguard Worker     for (int programNdx = 0; programNdx < m_threads[threadNdx]->context->resourceManager->getProgramCount();
2539*35238bceSAndroid Build Coastguard Worker          programNdx++)
2540*35238bceSAndroid Build Coastguard Worker     {
2541*35238bceSAndroid Build Coastguard Worker         SharedPtr<GLES2ThreadTest::Program> program =
2542*35238bceSAndroid Build Coastguard Worker             m_threads[threadNdx]->context->resourceManager->getProgram(programNdx);
2543*35238bceSAndroid Build Coastguard Worker 
2544*35238bceSAndroid Build Coastguard Worker         // Program that can be detached
2545*35238bceSAndroid Build Coastguard Worker         if (program->vertexShader || program->fragmentShader)
2546*35238bceSAndroid Build Coastguard Worker         {
2547*35238bceSAndroid Build Coastguard Worker             if (detachableProgramNdx == -1)
2548*35238bceSAndroid Build Coastguard Worker             {
2549*35238bceSAndroid Build Coastguard Worker                 detachableProgramNdx = programNdx;
2550*35238bceSAndroid Build Coastguard Worker 
2551*35238bceSAndroid Build Coastguard Worker                 if (program->vertexShader)
2552*35238bceSAndroid Build Coastguard Worker                     detachShaderType = GL_VERTEX_SHADER;
2553*35238bceSAndroid Build Coastguard Worker                 else if (program->fragmentShader)
2554*35238bceSAndroid Build Coastguard Worker                     detachShaderType = GL_FRAGMENT_SHADER;
2555*35238bceSAndroid Build Coastguard Worker                 else
2556*35238bceSAndroid Build Coastguard Worker                     DE_ASSERT(false);
2557*35238bceSAndroid Build Coastguard Worker             }
2558*35238bceSAndroid Build Coastguard Worker             else if (m_random.getBool())
2559*35238bceSAndroid Build Coastguard Worker             {
2560*35238bceSAndroid Build Coastguard Worker                 detachableProgramNdx = programNdx;
2561*35238bceSAndroid Build Coastguard Worker 
2562*35238bceSAndroid Build Coastguard Worker                 if (program->vertexShader)
2563*35238bceSAndroid Build Coastguard Worker                     detachShaderType = GL_VERTEX_SHADER;
2564*35238bceSAndroid Build Coastguard Worker                 else if (program->fragmentShader)
2565*35238bceSAndroid Build Coastguard Worker                     detachShaderType = GL_FRAGMENT_SHADER;
2566*35238bceSAndroid Build Coastguard Worker                 else
2567*35238bceSAndroid Build Coastguard Worker                     DE_ASSERT(false);
2568*35238bceSAndroid Build Coastguard Worker             }
2569*35238bceSAndroid Build Coastguard Worker         }
2570*35238bceSAndroid Build Coastguard Worker 
2571*35238bceSAndroid Build Coastguard Worker         // Program that can be attached vertex shader
2572*35238bceSAndroid Build Coastguard Worker         if (!program->vertexShader)
2573*35238bceSAndroid Build Coastguard Worker         {
2574*35238bceSAndroid Build Coastguard Worker             if (unusedVertexAttachmentProgramNdx == -1)
2575*35238bceSAndroid Build Coastguard Worker                 unusedVertexAttachmentProgramNdx = programNdx;
2576*35238bceSAndroid Build Coastguard Worker             else if (m_random.getBool())
2577*35238bceSAndroid Build Coastguard Worker                 unusedVertexAttachmentProgramNdx = programNdx;
2578*35238bceSAndroid Build Coastguard Worker         }
2579*35238bceSAndroid Build Coastguard Worker 
2580*35238bceSAndroid Build Coastguard Worker         // Program that can be attached fragment shader
2581*35238bceSAndroid Build Coastguard Worker         if (!program->fragmentShader)
2582*35238bceSAndroid Build Coastguard Worker         {
2583*35238bceSAndroid Build Coastguard Worker             if (unusedFragmentAttachmentProgramNdx == -1)
2584*35238bceSAndroid Build Coastguard Worker                 unusedFragmentAttachmentProgramNdx = programNdx;
2585*35238bceSAndroid Build Coastguard Worker             else if (m_random.getBool())
2586*35238bceSAndroid Build Coastguard Worker                 unusedFragmentAttachmentProgramNdx = programNdx;
2587*35238bceSAndroid Build Coastguard Worker         }
2588*35238bceSAndroid Build Coastguard Worker 
2589*35238bceSAndroid Build Coastguard Worker         // Program that can be linked
2590*35238bceSAndroid Build Coastguard Worker         if (program->vertexShader && program->fragmentShader)
2591*35238bceSAndroid Build Coastguard Worker         {
2592*35238bceSAndroid Build Coastguard Worker             if (linkableProgramNdx == -1)
2593*35238bceSAndroid Build Coastguard Worker                 linkableProgramNdx = programNdx;
2594*35238bceSAndroid Build Coastguard Worker             else if (m_random.getBool())
2595*35238bceSAndroid Build Coastguard Worker                 linkableProgramNdx = programNdx;
2596*35238bceSAndroid Build Coastguard Worker         }
2597*35238bceSAndroid Build Coastguard Worker     }
2598*35238bceSAndroid Build Coastguard Worker 
2599*35238bceSAndroid Build Coastguard Worker     // Has images
2600*35238bceSAndroid Build Coastguard Worker     if (resourceManager.getImageCount() > 0)
2601*35238bceSAndroid Build Coastguard Worker     {
2602*35238bceSAndroid Build Coastguard Worker         weights.push_back(m_config.probabilities[m_lastOperation][THREADOPERATIONID_DESTROY_IMAGE]);
2603*35238bceSAndroid Build Coastguard Worker         operations.push_back(THREADOPERATIONID_DESTROY_IMAGE);
2604*35238bceSAndroid Build Coastguard Worker 
2605*35238bceSAndroid Build Coastguard Worker         if (m_threads[threadNdx]->context->resourceManager->getTextureCount() > 0)
2606*35238bceSAndroid Build Coastguard Worker         {
2607*35238bceSAndroid Build Coastguard Worker             weights.push_back(m_config.probabilities[m_lastOperation][THREADOPERATIONID_TEXTURE_FROM_IMAGE]);
2608*35238bceSAndroid Build Coastguard Worker             operations.push_back(THREADOPERATIONID_TEXTURE_FROM_IMAGE);
2609*35238bceSAndroid Build Coastguard Worker         }
2610*35238bceSAndroid Build Coastguard Worker     }
2611*35238bceSAndroid Build Coastguard Worker 
2612*35238bceSAndroid Build Coastguard Worker     // Has buffer
2613*35238bceSAndroid Build Coastguard Worker     if (destroyableBufferNdx != -1)
2614*35238bceSAndroid Build Coastguard Worker     {
2615*35238bceSAndroid Build Coastguard Worker         weights.push_back(m_config.probabilities[m_lastOperation][THREADOPERATIONID_DESTROY_BUFFER]);
2616*35238bceSAndroid Build Coastguard Worker         operations.push_back(THREADOPERATIONID_DESTROY_BUFFER);
2617*35238bceSAndroid Build Coastguard Worker 
2618*35238bceSAndroid Build Coastguard Worker         weights.push_back(m_config.probabilities[m_lastOperation][THREADOPERATIONID_BUFFER_DATA]);
2619*35238bceSAndroid Build Coastguard Worker         operations.push_back(THREADOPERATIONID_BUFFER_DATA);
2620*35238bceSAndroid Build Coastguard Worker     }
2621*35238bceSAndroid Build Coastguard Worker 
2622*35238bceSAndroid Build Coastguard Worker     // Has buffer with defined data
2623*35238bceSAndroid Build Coastguard Worker     if (definedBufferNdx != -1)
2624*35238bceSAndroid Build Coastguard Worker     {
2625*35238bceSAndroid Build Coastguard Worker         weights.push_back(m_config.probabilities[m_lastOperation][THREADOPERATIONID_BUFFER_SUBDATA]);
2626*35238bceSAndroid Build Coastguard Worker         operations.push_back(THREADOPERATIONID_BUFFER_SUBDATA);
2627*35238bceSAndroid Build Coastguard Worker     }
2628*35238bceSAndroid Build Coastguard Worker 
2629*35238bceSAndroid Build Coastguard Worker     // Has texture
2630*35238bceSAndroid Build Coastguard Worker     if (destroyableTextureNdx != -1)
2631*35238bceSAndroid Build Coastguard Worker     {
2632*35238bceSAndroid Build Coastguard Worker         weights.push_back(m_config.probabilities[m_lastOperation][THREADOPERATIONID_DESTROY_TEXTURE]);
2633*35238bceSAndroid Build Coastguard Worker         operations.push_back(THREADOPERATIONID_DESTROY_TEXTURE);
2634*35238bceSAndroid Build Coastguard Worker 
2635*35238bceSAndroid Build Coastguard Worker         weights.push_back(m_config.probabilities[m_lastOperation][THREADOPERATIONID_TEXIMAGE2D]);
2636*35238bceSAndroid Build Coastguard Worker         operations.push_back(THREADOPERATIONID_TEXIMAGE2D);
2637*35238bceSAndroid Build Coastguard Worker 
2638*35238bceSAndroid Build Coastguard Worker         weights.push_back(m_config.probabilities[m_lastOperation][THREADOPERATIONID_COPYTEXIMAGE2D]);
2639*35238bceSAndroid Build Coastguard Worker         operations.push_back(THREADOPERATIONID_COPYTEXIMAGE2D);
2640*35238bceSAndroid Build Coastguard Worker     }
2641*35238bceSAndroid Build Coastguard Worker 
2642*35238bceSAndroid Build Coastguard Worker     // Has texture with data
2643*35238bceSAndroid Build Coastguard Worker     if (definedTextureNdx != -1)
2644*35238bceSAndroid Build Coastguard Worker     {
2645*35238bceSAndroid Build Coastguard Worker         weights.push_back(m_config.probabilities[m_lastOperation][THREADOPERATIONID_TEXSUBIMAGE2D]);
2646*35238bceSAndroid Build Coastguard Worker         operations.push_back(THREADOPERATIONID_TEXSUBIMAGE2D);
2647*35238bceSAndroid Build Coastguard Worker 
2648*35238bceSAndroid Build Coastguard Worker         weights.push_back(m_config.probabilities[m_lastOperation][THREADOPERATIONID_COPYTEXSUBIMAGE2D]);
2649*35238bceSAndroid Build Coastguard Worker         operations.push_back(THREADOPERATIONID_COPYTEXSUBIMAGE2D);
2650*35238bceSAndroid Build Coastguard Worker     }
2651*35238bceSAndroid Build Coastguard Worker 
2652*35238bceSAndroid Build Coastguard Worker     // Has texture that can be used as EGLimage source
2653*35238bceSAndroid Build Coastguard Worker     if (nonSiblingTextureNdx != -1)
2654*35238bceSAndroid Build Coastguard Worker     {
2655*35238bceSAndroid Build Coastguard Worker         weights.push_back(m_config.probabilities[m_lastOperation][THREADOPERATIONID_CREATE_IMAGE_FROM_TEXTURE]);
2656*35238bceSAndroid Build Coastguard Worker         operations.push_back(THREADOPERATIONID_CREATE_IMAGE_FROM_TEXTURE);
2657*35238bceSAndroid Build Coastguard Worker     }
2658*35238bceSAndroid Build Coastguard Worker 
2659*35238bceSAndroid Build Coastguard Worker     // Has shader
2660*35238bceSAndroid Build Coastguard Worker     if (destroyableShaderNdx != -1)
2661*35238bceSAndroid Build Coastguard Worker     {
2662*35238bceSAndroid Build Coastguard Worker         weights.push_back(m_config.probabilities[m_lastOperation][THREADOPERATIONID_DESTROY_SHADER]);
2663*35238bceSAndroid Build Coastguard Worker         operations.push_back(THREADOPERATIONID_DESTROY_SHADER);
2664*35238bceSAndroid Build Coastguard Worker 
2665*35238bceSAndroid Build Coastguard Worker         weights.push_back(m_config.probabilities[m_lastOperation][THREADOPERATIONID_SHADER_SOURCE]);
2666*35238bceSAndroid Build Coastguard Worker         operations.push_back(THREADOPERATIONID_SHADER_SOURCE);
2667*35238bceSAndroid Build Coastguard Worker     }
2668*35238bceSAndroid Build Coastguard Worker 
2669*35238bceSAndroid Build Coastguard Worker     // Has shader with defined source
2670*35238bceSAndroid Build Coastguard Worker     if (definedShaderNdx != -1)
2671*35238bceSAndroid Build Coastguard Worker     {
2672*35238bceSAndroid Build Coastguard Worker         weights.push_back(m_config.probabilities[m_lastOperation][THREADOPERATIONID_SHADER_COMPILE]);
2673*35238bceSAndroid Build Coastguard Worker         operations.push_back(THREADOPERATIONID_SHADER_COMPILE);
2674*35238bceSAndroid Build Coastguard Worker     }
2675*35238bceSAndroid Build Coastguard Worker 
2676*35238bceSAndroid Build Coastguard Worker     // Has program
2677*35238bceSAndroid Build Coastguard Worker     if (destroyableProgramNdx != -1)
2678*35238bceSAndroid Build Coastguard Worker     {
2679*35238bceSAndroid Build Coastguard Worker         weights.push_back(m_config.probabilities[m_lastOperation][THREADOPERATIONID_DESTROY_PROGRAM]);
2680*35238bceSAndroid Build Coastguard Worker         operations.push_back(THREADOPERATIONID_DESTROY_PROGRAM);
2681*35238bceSAndroid Build Coastguard Worker     }
2682*35238bceSAndroid Build Coastguard Worker 
2683*35238bceSAndroid Build Coastguard Worker     // Has program that can be linked
2684*35238bceSAndroid Build Coastguard Worker     if (linkableProgramNdx != -1)
2685*35238bceSAndroid Build Coastguard Worker     {
2686*35238bceSAndroid Build Coastguard Worker         weights.push_back(m_config.probabilities[m_lastOperation][THREADOPERATIONID_LINK_PROGRAM]);
2687*35238bceSAndroid Build Coastguard Worker         operations.push_back(THREADOPERATIONID_LINK_PROGRAM);
2688*35238bceSAndroid Build Coastguard Worker     }
2689*35238bceSAndroid Build Coastguard Worker 
2690*35238bceSAndroid Build Coastguard Worker     // has program with attachments
2691*35238bceSAndroid Build Coastguard Worker     if (detachableProgramNdx != -1)
2692*35238bceSAndroid Build Coastguard Worker     {
2693*35238bceSAndroid Build Coastguard Worker         weights.push_back(m_config.probabilities[m_lastOperation][THREADOPERATIONID_DETACH_SHADER]);
2694*35238bceSAndroid Build Coastguard Worker         operations.push_back(THREADOPERATIONID_DETACH_SHADER);
2695*35238bceSAndroid Build Coastguard Worker     }
2696*35238bceSAndroid Build Coastguard Worker 
2697*35238bceSAndroid Build Coastguard Worker     // Has program and shader pair that can be attached
2698*35238bceSAndroid Build Coastguard Worker     if (fragmentShaderNdx != -1 && unusedFragmentAttachmentProgramNdx != -1)
2699*35238bceSAndroid Build Coastguard Worker     {
2700*35238bceSAndroid Build Coastguard Worker         if (attachProgramNdx == -1)
2701*35238bceSAndroid Build Coastguard Worker         {
2702*35238bceSAndroid Build Coastguard Worker             DE_ASSERT(attachShaderNdx == -1);
2703*35238bceSAndroid Build Coastguard Worker             attachProgramNdx = unusedFragmentAttachmentProgramNdx;
2704*35238bceSAndroid Build Coastguard Worker             attachShaderNdx  = fragmentShaderNdx;
2705*35238bceSAndroid Build Coastguard Worker 
2706*35238bceSAndroid Build Coastguard Worker             weights.push_back(m_config.probabilities[m_lastOperation][THREADOPERATIONID_ATTACH_SHADER]);
2707*35238bceSAndroid Build Coastguard Worker             operations.push_back(THREADOPERATIONID_ATTACH_SHADER);
2708*35238bceSAndroid Build Coastguard Worker         }
2709*35238bceSAndroid Build Coastguard Worker         else if (m_random.getBool())
2710*35238bceSAndroid Build Coastguard Worker         {
2711*35238bceSAndroid Build Coastguard Worker             attachProgramNdx = unusedFragmentAttachmentProgramNdx;
2712*35238bceSAndroid Build Coastguard Worker             attachShaderNdx  = fragmentShaderNdx;
2713*35238bceSAndroid Build Coastguard Worker         }
2714*35238bceSAndroid Build Coastguard Worker     }
2715*35238bceSAndroid Build Coastguard Worker 
2716*35238bceSAndroid Build Coastguard Worker     if (vertexShaderNdx != -1 && unusedVertexAttachmentProgramNdx != -1)
2717*35238bceSAndroid Build Coastguard Worker     {
2718*35238bceSAndroid Build Coastguard Worker         if (attachProgramNdx == -1)
2719*35238bceSAndroid Build Coastguard Worker         {
2720*35238bceSAndroid Build Coastguard Worker             DE_ASSERT(attachShaderNdx == -1);
2721*35238bceSAndroid Build Coastguard Worker             attachProgramNdx = unusedVertexAttachmentProgramNdx;
2722*35238bceSAndroid Build Coastguard Worker             attachShaderNdx  = vertexShaderNdx;
2723*35238bceSAndroid Build Coastguard Worker 
2724*35238bceSAndroid Build Coastguard Worker             weights.push_back(m_config.probabilities[m_lastOperation][THREADOPERATIONID_ATTACH_SHADER]);
2725*35238bceSAndroid Build Coastguard Worker             operations.push_back(THREADOPERATIONID_ATTACH_SHADER);
2726*35238bceSAndroid Build Coastguard Worker         }
2727*35238bceSAndroid Build Coastguard Worker         else if (m_random.getBool())
2728*35238bceSAndroid Build Coastguard Worker         {
2729*35238bceSAndroid Build Coastguard Worker             attachProgramNdx = unusedVertexAttachmentProgramNdx;
2730*35238bceSAndroid Build Coastguard Worker             attachShaderNdx  = vertexShaderNdx;
2731*35238bceSAndroid Build Coastguard Worker         }
2732*35238bceSAndroid Build Coastguard Worker     }
2733*35238bceSAndroid Build Coastguard Worker 
2734*35238bceSAndroid Build Coastguard Worker     OperationId op = m_random.chooseWeighted<OperationId, std::vector<OperationId>::iterator>(
2735*35238bceSAndroid Build Coastguard Worker         operations.begin(), operations.end(), weights.begin());
2736*35238bceSAndroid Build Coastguard Worker 
2737*35238bceSAndroid Build Coastguard Worker     switch (op)
2738*35238bceSAndroid Build Coastguard Worker     {
2739*35238bceSAndroid Build Coastguard Worker     case THREADOPERATIONID_CREATE_BUFFER:
2740*35238bceSAndroid Build Coastguard Worker     {
2741*35238bceSAndroid Build Coastguard Worker         SharedPtr<GLES2ThreadTest::Buffer> buffer;
2742*35238bceSAndroid Build Coastguard Worker         m_threads[threadNdx]->addOperation(
2743*35238bceSAndroid Build Coastguard Worker             new GLES2ThreadTest::CreateBuffer(buffer, m_config.useFenceSync, m_config.serverSync));
2744*35238bceSAndroid Build Coastguard Worker         m_threads[threadNdx]->context->resourceManager->addBuffer(buffer);
2745*35238bceSAndroid Build Coastguard Worker         break;
2746*35238bceSAndroid Build Coastguard Worker     }
2747*35238bceSAndroid Build Coastguard Worker 
2748*35238bceSAndroid Build Coastguard Worker     case THREADOPERATIONID_DESTROY_BUFFER:
2749*35238bceSAndroid Build Coastguard Worker     {
2750*35238bceSAndroid Build Coastguard Worker         SharedPtr<GLES2ThreadTest::Buffer> buffer =
2751*35238bceSAndroid Build Coastguard Worker             m_threads[threadNdx]->context->resourceManager->popBuffer(destroyableBufferNdx);
2752*35238bceSAndroid Build Coastguard Worker         m_threads[threadNdx]->addOperation(
2753*35238bceSAndroid Build Coastguard Worker             new GLES2ThreadTest::DeleteBuffer(buffer, m_config.useFenceSync, m_config.serverSync));
2754*35238bceSAndroid Build Coastguard Worker         break;
2755*35238bceSAndroid Build Coastguard Worker     }
2756*35238bceSAndroid Build Coastguard Worker 
2757*35238bceSAndroid Build Coastguard Worker     case THREADOPERATIONID_BUFFER_DATA:
2758*35238bceSAndroid Build Coastguard Worker     {
2759*35238bceSAndroid Build Coastguard Worker         SharedPtr<GLES2ThreadTest::Buffer> buffer =
2760*35238bceSAndroid Build Coastguard Worker             m_threads[threadNdx]->context->resourceManager->popBuffer(destroyableBufferNdx);
2761*35238bceSAndroid Build Coastguard Worker         m_threads[threadNdx]->addOperation(new GLES2ThreadTest::BufferData(
2762*35238bceSAndroid Build Coastguard Worker             buffer, GL_ARRAY_BUFFER, 1024, GL_DYNAMIC_DRAW, m_config.useFenceSync, m_config.serverSync));
2763*35238bceSAndroid Build Coastguard Worker         m_threads[threadNdx]->context->resourceManager->addBuffer(buffer);
2764*35238bceSAndroid Build Coastguard Worker         break;
2765*35238bceSAndroid Build Coastguard Worker     }
2766*35238bceSAndroid Build Coastguard Worker 
2767*35238bceSAndroid Build Coastguard Worker     case THREADOPERATIONID_BUFFER_SUBDATA:
2768*35238bceSAndroid Build Coastguard Worker     {
2769*35238bceSAndroid Build Coastguard Worker         SharedPtr<GLES2ThreadTest::Buffer> buffer =
2770*35238bceSAndroid Build Coastguard Worker             m_threads[threadNdx]->context->resourceManager->popBuffer(definedBufferNdx);
2771*35238bceSAndroid Build Coastguard Worker         m_threads[threadNdx]->addOperation(new GLES2ThreadTest::BufferSubData(
2772*35238bceSAndroid Build Coastguard Worker             buffer, GL_ARRAY_BUFFER, 1, 20, m_config.useFenceSync, m_config.serverSync));
2773*35238bceSAndroid Build Coastguard Worker         m_threads[threadNdx]->context->resourceManager->addBuffer(buffer);
2774*35238bceSAndroid Build Coastguard Worker         break;
2775*35238bceSAndroid Build Coastguard Worker     }
2776*35238bceSAndroid Build Coastguard Worker 
2777*35238bceSAndroid Build Coastguard Worker     case THREADOPERATIONID_CREATE_TEXTURE:
2778*35238bceSAndroid Build Coastguard Worker     {
2779*35238bceSAndroid Build Coastguard Worker         SharedPtr<GLES2ThreadTest::Texture> texture;
2780*35238bceSAndroid Build Coastguard Worker         m_threads[threadNdx]->addOperation(
2781*35238bceSAndroid Build Coastguard Worker             new GLES2ThreadTest::CreateTexture(texture, m_config.useFenceSync, m_config.serverSync));
2782*35238bceSAndroid Build Coastguard Worker         m_threads[threadNdx]->context->resourceManager->addTexture(texture);
2783*35238bceSAndroid Build Coastguard Worker         break;
2784*35238bceSAndroid Build Coastguard Worker     }
2785*35238bceSAndroid Build Coastguard Worker 
2786*35238bceSAndroid Build Coastguard Worker     case THREADOPERATIONID_DESTROY_TEXTURE:
2787*35238bceSAndroid Build Coastguard Worker         m_threads[threadNdx]->addOperation(new GLES2ThreadTest::DeleteTexture(
2788*35238bceSAndroid Build Coastguard Worker             m_threads[threadNdx]->context->resourceManager->popTexture(destroyableTextureNdx), m_config.useFenceSync,
2789*35238bceSAndroid Build Coastguard Worker             m_config.serverSync));
2790*35238bceSAndroid Build Coastguard Worker         break;
2791*35238bceSAndroid Build Coastguard Worker 
2792*35238bceSAndroid Build Coastguard Worker     case THREADOPERATIONID_TEXIMAGE2D:
2793*35238bceSAndroid Build Coastguard Worker     {
2794*35238bceSAndroid Build Coastguard Worker         SharedPtr<GLES2ThreadTest::Texture> texture =
2795*35238bceSAndroid Build Coastguard Worker             m_threads[threadNdx]->context->resourceManager->popTexture(destroyableTextureNdx);
2796*35238bceSAndroid Build Coastguard Worker         m_threads[threadNdx]->addOperation(new GLES2ThreadTest::TexImage2D(
2797*35238bceSAndroid Build Coastguard Worker             texture, 0, GL_RGBA, 400, 400, GL_RGBA, GL_UNSIGNED_BYTE, m_config.useFenceSync, m_config.serverSync));
2798*35238bceSAndroid Build Coastguard Worker         m_threads[threadNdx]->context->resourceManager->addTexture(texture);
2799*35238bceSAndroid Build Coastguard Worker         break;
2800*35238bceSAndroid Build Coastguard Worker     }
2801*35238bceSAndroid Build Coastguard Worker 
2802*35238bceSAndroid Build Coastguard Worker     case THREADOPERATIONID_TEXSUBIMAGE2D:
2803*35238bceSAndroid Build Coastguard Worker     {
2804*35238bceSAndroid Build Coastguard Worker         SharedPtr<GLES2ThreadTest::Texture> texture =
2805*35238bceSAndroid Build Coastguard Worker             m_threads[threadNdx]->context->resourceManager->popTexture(definedTextureNdx);
2806*35238bceSAndroid Build Coastguard Worker         m_threads[threadNdx]->addOperation(new GLES2ThreadTest::TexSubImage2D(
2807*35238bceSAndroid Build Coastguard Worker             texture, 0, 30, 30, 50, 50, GL_RGBA, GL_UNSIGNED_BYTE, m_config.useFenceSync, m_config.serverSync));
2808*35238bceSAndroid Build Coastguard Worker         m_threads[threadNdx]->context->resourceManager->addTexture(texture);
2809*35238bceSAndroid Build Coastguard Worker         break;
2810*35238bceSAndroid Build Coastguard Worker     }
2811*35238bceSAndroid Build Coastguard Worker 
2812*35238bceSAndroid Build Coastguard Worker     case THREADOPERATIONID_COPYTEXIMAGE2D:
2813*35238bceSAndroid Build Coastguard Worker     {
2814*35238bceSAndroid Build Coastguard Worker         SharedPtr<GLES2ThreadTest::Texture> texture =
2815*35238bceSAndroid Build Coastguard Worker             m_threads[threadNdx]->context->resourceManager->popTexture(destroyableTextureNdx);
2816*35238bceSAndroid Build Coastguard Worker         m_threads[threadNdx]->addOperation(new GLES2ThreadTest::CopyTexImage2D(
2817*35238bceSAndroid Build Coastguard Worker             texture, 0, GL_RGBA, 20, 20, 300, 300, 0, m_config.useFenceSync, m_config.serverSync));
2818*35238bceSAndroid Build Coastguard Worker         m_threads[threadNdx]->context->resourceManager->addTexture(texture);
2819*35238bceSAndroid Build Coastguard Worker         break;
2820*35238bceSAndroid Build Coastguard Worker     }
2821*35238bceSAndroid Build Coastguard Worker 
2822*35238bceSAndroid Build Coastguard Worker     case THREADOPERATIONID_COPYTEXSUBIMAGE2D:
2823*35238bceSAndroid Build Coastguard Worker     {
2824*35238bceSAndroid Build Coastguard Worker         SharedPtr<GLES2ThreadTest::Texture> texture =
2825*35238bceSAndroid Build Coastguard Worker             m_threads[threadNdx]->context->resourceManager->popTexture(definedTextureNdx);
2826*35238bceSAndroid Build Coastguard Worker         m_threads[threadNdx]->addOperation(new GLES2ThreadTest::CopyTexSubImage2D(
2827*35238bceSAndroid Build Coastguard Worker             texture, 0, 10, 10, 30, 30, 50, 50, m_config.useFenceSync, m_config.serverSync));
2828*35238bceSAndroid Build Coastguard Worker         m_threads[threadNdx]->context->resourceManager->addTexture(texture);
2829*35238bceSAndroid Build Coastguard Worker         break;
2830*35238bceSAndroid Build Coastguard Worker     }
2831*35238bceSAndroid Build Coastguard Worker 
2832*35238bceSAndroid Build Coastguard Worker     case THREADOPERATIONID_CREATE_VERTEX_SHADER:
2833*35238bceSAndroid Build Coastguard Worker     {
2834*35238bceSAndroid Build Coastguard Worker         SharedPtr<GLES2ThreadTest::Shader> shader;
2835*35238bceSAndroid Build Coastguard Worker         m_threads[threadNdx]->addOperation(
2836*35238bceSAndroid Build Coastguard Worker             new GLES2ThreadTest::CreateShader(GL_VERTEX_SHADER, shader, m_config.useFenceSync, m_config.serverSync));
2837*35238bceSAndroid Build Coastguard Worker         m_threads[threadNdx]->context->resourceManager->addShader(shader);
2838*35238bceSAndroid Build Coastguard Worker         break;
2839*35238bceSAndroid Build Coastguard Worker     }
2840*35238bceSAndroid Build Coastguard Worker 
2841*35238bceSAndroid Build Coastguard Worker     case THREADOPERATIONID_CREATE_FRAGMENT_SHADER:
2842*35238bceSAndroid Build Coastguard Worker     {
2843*35238bceSAndroid Build Coastguard Worker         SharedPtr<GLES2ThreadTest::Shader> shader;
2844*35238bceSAndroid Build Coastguard Worker         m_threads[threadNdx]->addOperation(
2845*35238bceSAndroid Build Coastguard Worker             new GLES2ThreadTest::CreateShader(GL_FRAGMENT_SHADER, shader, m_config.useFenceSync, m_config.serverSync));
2846*35238bceSAndroid Build Coastguard Worker         m_threads[threadNdx]->context->resourceManager->addShader(shader);
2847*35238bceSAndroid Build Coastguard Worker         break;
2848*35238bceSAndroid Build Coastguard Worker     }
2849*35238bceSAndroid Build Coastguard Worker 
2850*35238bceSAndroid Build Coastguard Worker     case THREADOPERATIONID_DESTROY_SHADER:
2851*35238bceSAndroid Build Coastguard Worker         m_threads[threadNdx]->addOperation(new GLES2ThreadTest::DeleteShader(
2852*35238bceSAndroid Build Coastguard Worker             m_threads[threadNdx]->context->resourceManager->popShader(destroyableShaderNdx), m_config.useFenceSync,
2853*35238bceSAndroid Build Coastguard Worker             m_config.serverSync));
2854*35238bceSAndroid Build Coastguard Worker         break;
2855*35238bceSAndroid Build Coastguard Worker 
2856*35238bceSAndroid Build Coastguard Worker     case THREADOPERATIONID_SHADER_SOURCE:
2857*35238bceSAndroid Build Coastguard Worker     {
2858*35238bceSAndroid Build Coastguard Worker         const char *vertexShaderSource = "attribute mediump vec4 a_pos;\n"
2859*35238bceSAndroid Build Coastguard Worker                                          "varying mediump vec4 v_pos;\n"
2860*35238bceSAndroid Build Coastguard Worker                                          "void main (void)\n"
2861*35238bceSAndroid Build Coastguard Worker                                          "{\n"
2862*35238bceSAndroid Build Coastguard Worker                                          "\tv_pos = a_pos;\n"
2863*35238bceSAndroid Build Coastguard Worker                                          "\tgl_Position = a_pos;\n"
2864*35238bceSAndroid Build Coastguard Worker                                          "}\n";
2865*35238bceSAndroid Build Coastguard Worker 
2866*35238bceSAndroid Build Coastguard Worker         const char *fragmentShaderSource = "varying mediump vec4 v_pos;\n"
2867*35238bceSAndroid Build Coastguard Worker                                            "void main (void)\n"
2868*35238bceSAndroid Build Coastguard Worker                                            "{\n"
2869*35238bceSAndroid Build Coastguard Worker                                            "\tgl_FragColor = v_pos;\n"
2870*35238bceSAndroid Build Coastguard Worker                                            "}\n";
2871*35238bceSAndroid Build Coastguard Worker         SharedPtr<GLES2ThreadTest::Shader> shader =
2872*35238bceSAndroid Build Coastguard Worker             m_threads[threadNdx]->context->resourceManager->popShader(destroyableShaderNdx);
2873*35238bceSAndroid Build Coastguard Worker         m_threads[threadNdx]->addOperation(new GLES2ThreadTest::ShaderSource(
2874*35238bceSAndroid Build Coastguard Worker             shader, (shader->type == GL_VERTEX_SHADER ? vertexShaderSource : fragmentShaderSource),
2875*35238bceSAndroid Build Coastguard Worker             m_config.useFenceSync, m_config.serverSync));
2876*35238bceSAndroid Build Coastguard Worker         m_threads[threadNdx]->context->resourceManager->addShader(shader);
2877*35238bceSAndroid Build Coastguard Worker         break;
2878*35238bceSAndroid Build Coastguard Worker     }
2879*35238bceSAndroid Build Coastguard Worker 
2880*35238bceSAndroid Build Coastguard Worker     case THREADOPERATIONID_SHADER_COMPILE:
2881*35238bceSAndroid Build Coastguard Worker     {
2882*35238bceSAndroid Build Coastguard Worker         SharedPtr<GLES2ThreadTest::Shader> shader =
2883*35238bceSAndroid Build Coastguard Worker             m_threads[threadNdx]->context->resourceManager->popShader(definedShaderNdx);
2884*35238bceSAndroid Build Coastguard Worker         m_threads[threadNdx]->addOperation(
2885*35238bceSAndroid Build Coastguard Worker             new GLES2ThreadTest::ShaderCompile(shader, m_config.useFenceSync, m_config.serverSync));
2886*35238bceSAndroid Build Coastguard Worker         m_threads[threadNdx]->context->resourceManager->addShader(shader);
2887*35238bceSAndroid Build Coastguard Worker         break;
2888*35238bceSAndroid Build Coastguard Worker     }
2889*35238bceSAndroid Build Coastguard Worker 
2890*35238bceSAndroid Build Coastguard Worker     case THREADOPERATIONID_CREATE_PROGRAM:
2891*35238bceSAndroid Build Coastguard Worker     {
2892*35238bceSAndroid Build Coastguard Worker         SharedPtr<GLES2ThreadTest::Program> program;
2893*35238bceSAndroid Build Coastguard Worker         m_threads[threadNdx]->addOperation(
2894*35238bceSAndroid Build Coastguard Worker             new GLES2ThreadTest::CreateProgram(program, m_config.useFenceSync, m_config.serverSync));
2895*35238bceSAndroid Build Coastguard Worker         m_threads[threadNdx]->context->resourceManager->addProgram(program);
2896*35238bceSAndroid Build Coastguard Worker         break;
2897*35238bceSAndroid Build Coastguard Worker     }
2898*35238bceSAndroid Build Coastguard Worker 
2899*35238bceSAndroid Build Coastguard Worker     case THREADOPERATIONID_DESTROY_PROGRAM:
2900*35238bceSAndroid Build Coastguard Worker         m_threads[threadNdx]->addOperation(new GLES2ThreadTest::DeleteProgram(
2901*35238bceSAndroid Build Coastguard Worker             m_threads[threadNdx]->context->resourceManager->popProgram(destroyableProgramNdx), m_config.useFenceSync,
2902*35238bceSAndroid Build Coastguard Worker             m_config.serverSync));
2903*35238bceSAndroid Build Coastguard Worker         break;
2904*35238bceSAndroid Build Coastguard Worker 
2905*35238bceSAndroid Build Coastguard Worker     case THREADOPERATIONID_ATTACH_SHADER:
2906*35238bceSAndroid Build Coastguard Worker     {
2907*35238bceSAndroid Build Coastguard Worker         SharedPtr<GLES2ThreadTest::Program> program =
2908*35238bceSAndroid Build Coastguard Worker             m_threads[threadNdx]->context->resourceManager->popProgram(attachProgramNdx);
2909*35238bceSAndroid Build Coastguard Worker         SharedPtr<GLES2ThreadTest::Shader> shader =
2910*35238bceSAndroid Build Coastguard Worker             m_threads[threadNdx]->context->resourceManager->popShader(attachShaderNdx);
2911*35238bceSAndroid Build Coastguard Worker 
2912*35238bceSAndroid Build Coastguard Worker         m_threads[threadNdx]->addOperation(
2913*35238bceSAndroid Build Coastguard Worker             new GLES2ThreadTest::AttachShader(program, shader, m_config.useFenceSync, m_config.serverSync));
2914*35238bceSAndroid Build Coastguard Worker 
2915*35238bceSAndroid Build Coastguard Worker         m_threads[threadNdx]->context->resourceManager->addProgram(program);
2916*35238bceSAndroid Build Coastguard Worker         m_threads[threadNdx]->context->resourceManager->addShader(shader);
2917*35238bceSAndroid Build Coastguard Worker         break;
2918*35238bceSAndroid Build Coastguard Worker     }
2919*35238bceSAndroid Build Coastguard Worker 
2920*35238bceSAndroid Build Coastguard Worker     case THREADOPERATIONID_DETACH_SHADER:
2921*35238bceSAndroid Build Coastguard Worker     {
2922*35238bceSAndroid Build Coastguard Worker         SharedPtr<GLES2ThreadTest::Program> program =
2923*35238bceSAndroid Build Coastguard Worker             m_threads[threadNdx]->context->resourceManager->popProgram(detachableProgramNdx);
2924*35238bceSAndroid Build Coastguard Worker         m_threads[threadNdx]->addOperation(
2925*35238bceSAndroid Build Coastguard Worker             new GLES2ThreadTest::DetachShader(program, detachShaderType, m_config.useFenceSync, m_config.serverSync));
2926*35238bceSAndroid Build Coastguard Worker         m_threads[threadNdx]->context->resourceManager->addProgram(program);
2927*35238bceSAndroid Build Coastguard Worker         break;
2928*35238bceSAndroid Build Coastguard Worker     }
2929*35238bceSAndroid Build Coastguard Worker 
2930*35238bceSAndroid Build Coastguard Worker     case THREADOPERATIONID_LINK_PROGRAM:
2931*35238bceSAndroid Build Coastguard Worker     {
2932*35238bceSAndroid Build Coastguard Worker         SharedPtr<GLES2ThreadTest::Program> program =
2933*35238bceSAndroid Build Coastguard Worker             m_threads[threadNdx]->context->resourceManager->popProgram(linkableProgramNdx);
2934*35238bceSAndroid Build Coastguard Worker         m_threads[threadNdx]->addOperation(
2935*35238bceSAndroid Build Coastguard Worker             new GLES2ThreadTest::LinkProgram(program, m_config.useFenceSync, m_config.serverSync));
2936*35238bceSAndroid Build Coastguard Worker         m_threads[threadNdx]->context->resourceManager->addProgram(program);
2937*35238bceSAndroid Build Coastguard Worker         break;
2938*35238bceSAndroid Build Coastguard Worker     }
2939*35238bceSAndroid Build Coastguard Worker 
2940*35238bceSAndroid Build Coastguard Worker     case THREADOPERATIONID_CREATE_IMAGE_FROM_TEXTURE:
2941*35238bceSAndroid Build Coastguard Worker     {
2942*35238bceSAndroid Build Coastguard Worker         SharedPtr<GLES2ThreadTest::EGLImage> image;
2943*35238bceSAndroid Build Coastguard Worker         SharedPtr<GLES2ThreadTest::Texture> texture =
2944*35238bceSAndroid Build Coastguard Worker             m_threads[threadNdx]->context->resourceManager->popTexture(nonSiblingTextureNdx);
2945*35238bceSAndroid Build Coastguard Worker         m_threads[threadNdx]->addOperation(
2946*35238bceSAndroid Build Coastguard Worker             new GLES2ThreadTest::CreateImageFromTexture(image, texture, m_config.useFenceSync, m_config.serverSync));
2947*35238bceSAndroid Build Coastguard Worker         // \note [mika] Can source be added back to resourceManager?
2948*35238bceSAndroid Build Coastguard Worker         m_threads[threadNdx]->context->resourceManager->addTexture(texture);
2949*35238bceSAndroid Build Coastguard Worker         resourceManager.addImage(image);
2950*35238bceSAndroid Build Coastguard Worker         break;
2951*35238bceSAndroid Build Coastguard Worker     }
2952*35238bceSAndroid Build Coastguard Worker 
2953*35238bceSAndroid Build Coastguard Worker     case THREADOPERATIONID_DESTROY_IMAGE:
2954*35238bceSAndroid Build Coastguard Worker     {
2955*35238bceSAndroid Build Coastguard Worker         int imageNdx                               = m_random.getInt(0, resourceManager.getImageCount() - 1);
2956*35238bceSAndroid Build Coastguard Worker         SharedPtr<GLES2ThreadTest::EGLImage> image = resourceManager.popImage(imageNdx);
2957*35238bceSAndroid Build Coastguard Worker         m_threads[threadNdx]->addOperation(
2958*35238bceSAndroid Build Coastguard Worker             new GLES2ThreadTest::DestroyImage(image, m_config.useFenceSync, m_config.serverSync));
2959*35238bceSAndroid Build Coastguard Worker         break;
2960*35238bceSAndroid Build Coastguard Worker     }
2961*35238bceSAndroid Build Coastguard Worker 
2962*35238bceSAndroid Build Coastguard Worker     case THREADOPERATIONID_TEXTURE_FROM_IMAGE:
2963*35238bceSAndroid Build Coastguard Worker     {
2964*35238bceSAndroid Build Coastguard Worker         int imageNdx = m_random.getInt(0, resourceManager.getImageCount() - 1);
2965*35238bceSAndroid Build Coastguard Worker         SharedPtr<GLES2ThreadTest::Texture> texture =
2966*35238bceSAndroid Build Coastguard Worker             m_threads[threadNdx]->context->resourceManager->popTexture(destroyableTextureNdx);
2967*35238bceSAndroid Build Coastguard Worker         SharedPtr<GLES2ThreadTest::EGLImage> image = resourceManager.popImage(imageNdx);
2968*35238bceSAndroid Build Coastguard Worker         m_threads[threadNdx]->addOperation(
2969*35238bceSAndroid Build Coastguard Worker             new GLES2ThreadTest::DefineTextureFromImage(texture, image, m_config.useFenceSync, m_config.serverSync));
2970*35238bceSAndroid Build Coastguard Worker         m_threads[threadNdx]->context->resourceManager->addTexture(texture);
2971*35238bceSAndroid Build Coastguard Worker         resourceManager.addImage(image);
2972*35238bceSAndroid Build Coastguard Worker         break;
2973*35238bceSAndroid Build Coastguard Worker     }
2974*35238bceSAndroid Build Coastguard Worker 
2975*35238bceSAndroid Build Coastguard Worker     default:
2976*35238bceSAndroid Build Coastguard Worker         DE_ASSERT(false);
2977*35238bceSAndroid Build Coastguard Worker     }
2978*35238bceSAndroid Build Coastguard Worker 
2979*35238bceSAndroid Build Coastguard Worker     m_lastOperation = op;
2980*35238bceSAndroid Build Coastguard Worker }
2981*35238bceSAndroid Build Coastguard Worker 
iterate(void)2982*35238bceSAndroid Build Coastguard Worker tcu::TestCase::IterateResult GLES2SharingRandomTest::iterate(void)
2983*35238bceSAndroid Build Coastguard Worker {
2984*35238bceSAndroid Build Coastguard Worker     if (!m_threadsStarted)
2985*35238bceSAndroid Build Coastguard Worker     {
2986*35238bceSAndroid Build Coastguard Worker         m_beginTimeUs = deGetMicroseconds();
2987*35238bceSAndroid Build Coastguard Worker 
2988*35238bceSAndroid Build Coastguard Worker         // Execute threads
2989*35238bceSAndroid Build Coastguard Worker         for (int threadNdx = 0; threadNdx < (int)m_threads.size(); threadNdx++)
2990*35238bceSAndroid Build Coastguard Worker             m_threads[threadNdx]->exec();
2991*35238bceSAndroid Build Coastguard Worker 
2992*35238bceSAndroid Build Coastguard Worker         m_threadsStarted = true;
2993*35238bceSAndroid Build Coastguard Worker         m_threadsRunning = true;
2994*35238bceSAndroid Build Coastguard Worker     }
2995*35238bceSAndroid Build Coastguard Worker 
2996*35238bceSAndroid Build Coastguard Worker     if (m_threadsRunning)
2997*35238bceSAndroid Build Coastguard Worker     {
2998*35238bceSAndroid Build Coastguard Worker         // Wait threads to finish
2999*35238bceSAndroid Build Coastguard Worker         int readyThreads = 0;
3000*35238bceSAndroid Build Coastguard Worker         for (int threadNdx = 0; threadNdx < (int)m_threads.size(); threadNdx++)
3001*35238bceSAndroid Build Coastguard Worker         {
3002*35238bceSAndroid Build Coastguard Worker             const tcu::ThreadUtil::Thread::ThreadStatus status = m_threads[threadNdx]->getStatus();
3003*35238bceSAndroid Build Coastguard Worker 
3004*35238bceSAndroid Build Coastguard Worker             if (status != tcu::ThreadUtil::Thread::THREADSTATUS_RUNNING &&
3005*35238bceSAndroid Build Coastguard Worker                 status != tcu::ThreadUtil::Thread::THREADSTATUS_NOT_STARTED)
3006*35238bceSAndroid Build Coastguard Worker                 readyThreads++;
3007*35238bceSAndroid Build Coastguard Worker         }
3008*35238bceSAndroid Build Coastguard Worker 
3009*35238bceSAndroid Build Coastguard Worker         if (readyThreads == (int)m_threads.size())
3010*35238bceSAndroid Build Coastguard Worker         {
3011*35238bceSAndroid Build Coastguard Worker             for (int threadNdx = 0; threadNdx < (int)m_threads.size(); threadNdx++)
3012*35238bceSAndroid Build Coastguard Worker                 m_threads[threadNdx]->join();
3013*35238bceSAndroid Build Coastguard Worker 
3014*35238bceSAndroid Build Coastguard Worker             m_executionReady  = true;
3015*35238bceSAndroid Build Coastguard Worker             m_requiresRestart = false;
3016*35238bceSAndroid Build Coastguard Worker         }
3017*35238bceSAndroid Build Coastguard Worker 
3018*35238bceSAndroid Build Coastguard Worker         if (deGetMicroseconds() - m_beginTimeUs > m_timeOutUs)
3019*35238bceSAndroid Build Coastguard Worker         {
3020*35238bceSAndroid Build Coastguard Worker             for (int threadNdx = 0; threadNdx < (int)m_threads.size(); threadNdx++)
3021*35238bceSAndroid Build Coastguard Worker             {
3022*35238bceSAndroid Build Coastguard Worker                 if (m_threads[threadNdx]->getStatus() != tcu::ThreadUtil::Thread::THREADSTATUS_RUNNING)
3023*35238bceSAndroid Build Coastguard Worker                 {
3024*35238bceSAndroid Build Coastguard Worker                     if (m_threads[threadNdx]->isStarted())
3025*35238bceSAndroid Build Coastguard Worker                         m_threads[threadNdx]->join();
3026*35238bceSAndroid Build Coastguard Worker                 }
3027*35238bceSAndroid Build Coastguard Worker             }
3028*35238bceSAndroid Build Coastguard Worker             m_executionReady  = true;
3029*35238bceSAndroid Build Coastguard Worker             m_requiresRestart = true;
3030*35238bceSAndroid Build Coastguard Worker             m_timeOutTimeUs   = deGetMicroseconds();
3031*35238bceSAndroid Build Coastguard Worker         }
3032*35238bceSAndroid Build Coastguard Worker         else
3033*35238bceSAndroid Build Coastguard Worker         {
3034*35238bceSAndroid Build Coastguard Worker             deSleep(m_sleepTimeMs);
3035*35238bceSAndroid Build Coastguard Worker         }
3036*35238bceSAndroid Build Coastguard Worker     }
3037*35238bceSAndroid Build Coastguard Worker 
3038*35238bceSAndroid Build Coastguard Worker     if (m_executionReady)
3039*35238bceSAndroid Build Coastguard Worker     {
3040*35238bceSAndroid Build Coastguard Worker         std::vector<int> indices(m_threads.size(), 0);
3041*35238bceSAndroid Build Coastguard Worker 
3042*35238bceSAndroid Build Coastguard Worker         if (m_timeOutTimeUs != 0)
3043*35238bceSAndroid Build Coastguard Worker             m_log << tcu::TestLog::Message
3044*35238bceSAndroid Build Coastguard Worker                   << "Execution timeout limit reached. Trying to get per thread logs. This is potentially dangerous."
3045*35238bceSAndroid Build Coastguard Worker                   << tcu::TestLog::EndMessage;
3046*35238bceSAndroid Build Coastguard Worker 
3047*35238bceSAndroid Build Coastguard Worker         while (true)
3048*35238bceSAndroid Build Coastguard Worker         {
3049*35238bceSAndroid Build Coastguard Worker             int firstThread = -1;
3050*35238bceSAndroid Build Coastguard Worker 
3051*35238bceSAndroid Build Coastguard Worker             // Find first thread with messages
3052*35238bceSAndroid Build Coastguard Worker             for (int threadNdx = 0; threadNdx < (int)m_threads.size(); threadNdx++)
3053*35238bceSAndroid Build Coastguard Worker             {
3054*35238bceSAndroid Build Coastguard Worker                 if (m_threads[threadNdx]->getMessageCount() > indices[threadNdx])
3055*35238bceSAndroid Build Coastguard Worker                 {
3056*35238bceSAndroid Build Coastguard Worker                     firstThread = threadNdx;
3057*35238bceSAndroid Build Coastguard Worker                     break;
3058*35238bceSAndroid Build Coastguard Worker                 }
3059*35238bceSAndroid Build Coastguard Worker             }
3060*35238bceSAndroid Build Coastguard Worker 
3061*35238bceSAndroid Build Coastguard Worker             // No more messages
3062*35238bceSAndroid Build Coastguard Worker             if (firstThread == -1)
3063*35238bceSAndroid Build Coastguard Worker                 break;
3064*35238bceSAndroid Build Coastguard Worker 
3065*35238bceSAndroid Build Coastguard Worker             for (int threadNdx = 0; threadNdx < (int)m_threads.size(); threadNdx++)
3066*35238bceSAndroid Build Coastguard Worker             {
3067*35238bceSAndroid Build Coastguard Worker                 // No more messages in this thread
3068*35238bceSAndroid Build Coastguard Worker                 if (m_threads[threadNdx]->getMessageCount() <= indices[threadNdx])
3069*35238bceSAndroid Build Coastguard Worker                     continue;
3070*35238bceSAndroid Build Coastguard Worker 
3071*35238bceSAndroid Build Coastguard Worker                 if ((m_threads[threadNdx]->getMessage(indices[threadNdx]).getTime() - m_beginTimeUs) <
3072*35238bceSAndroid Build Coastguard Worker                     (m_threads[firstThread]->getMessage(indices[firstThread]).getTime() - m_beginTimeUs))
3073*35238bceSAndroid Build Coastguard Worker                     firstThread = threadNdx;
3074*35238bceSAndroid Build Coastguard Worker             }
3075*35238bceSAndroid Build Coastguard Worker 
3076*35238bceSAndroid Build Coastguard Worker             tcu::ThreadUtil::Message message = m_threads[firstThread]->getMessage(indices[firstThread]);
3077*35238bceSAndroid Build Coastguard Worker 
3078*35238bceSAndroid Build Coastguard Worker             m_log << tcu::TestLog::Message << "[" << (message.getTime() - m_beginTimeUs) << "] (" << firstThread << ") "
3079*35238bceSAndroid Build Coastguard Worker                   << message.getMessage() << tcu::TestLog::EndMessage;
3080*35238bceSAndroid Build Coastguard Worker             indices[firstThread]++;
3081*35238bceSAndroid Build Coastguard Worker         }
3082*35238bceSAndroid Build Coastguard Worker 
3083*35238bceSAndroid Build Coastguard Worker         if (m_timeOutTimeUs != 0)
3084*35238bceSAndroid Build Coastguard Worker             m_log << tcu::TestLog::Message << "[" << (m_timeOutTimeUs - m_beginTimeUs)
3085*35238bceSAndroid Build Coastguard Worker                   << "] Execution timeout limit reached" << tcu::TestLog::EndMessage;
3086*35238bceSAndroid Build Coastguard Worker 
3087*35238bceSAndroid Build Coastguard Worker         bool isOk         = true;
3088*35238bceSAndroid Build Coastguard Worker         bool notSupported = false;
3089*35238bceSAndroid Build Coastguard Worker 
3090*35238bceSAndroid Build Coastguard Worker         for (int threadNdx = 0; threadNdx < (int)m_threads.size(); threadNdx++)
3091*35238bceSAndroid Build Coastguard Worker         {
3092*35238bceSAndroid Build Coastguard Worker             const tcu::ThreadUtil::Thread::ThreadStatus status = m_threads[threadNdx]->getStatus();
3093*35238bceSAndroid Build Coastguard Worker 
3094*35238bceSAndroid Build Coastguard Worker             switch (status)
3095*35238bceSAndroid Build Coastguard Worker             {
3096*35238bceSAndroid Build Coastguard Worker             case tcu::ThreadUtil::Thread::THREADSTATUS_FAILED:
3097*35238bceSAndroid Build Coastguard Worker             case tcu::ThreadUtil::Thread::THREADSTATUS_INIT_FAILED:
3098*35238bceSAndroid Build Coastguard Worker             case tcu::ThreadUtil::Thread::THREADSTATUS_RUNNING:
3099*35238bceSAndroid Build Coastguard Worker                 isOk = false;
3100*35238bceSAndroid Build Coastguard Worker                 break;
3101*35238bceSAndroid Build Coastguard Worker 
3102*35238bceSAndroid Build Coastguard Worker             case tcu::ThreadUtil::Thread::THREADSTATUS_NOT_SUPPORTED:
3103*35238bceSAndroid Build Coastguard Worker                 notSupported = true;
3104*35238bceSAndroid Build Coastguard Worker                 break;
3105*35238bceSAndroid Build Coastguard Worker 
3106*35238bceSAndroid Build Coastguard Worker             case tcu::ThreadUtil::Thread::THREADSTATUS_READY:
3107*35238bceSAndroid Build Coastguard Worker                 // Nothing
3108*35238bceSAndroid Build Coastguard Worker                 break;
3109*35238bceSAndroid Build Coastguard Worker 
3110*35238bceSAndroid Build Coastguard Worker             default:
3111*35238bceSAndroid Build Coastguard Worker                 DE_ASSERT(false);
3112*35238bceSAndroid Build Coastguard Worker                 isOk = false;
3113*35238bceSAndroid Build Coastguard Worker             }
3114*35238bceSAndroid Build Coastguard Worker         }
3115*35238bceSAndroid Build Coastguard Worker 
3116*35238bceSAndroid Build Coastguard Worker         if (notSupported)
3117*35238bceSAndroid Build Coastguard Worker             throw tcu::NotSupportedError("Thread threw tcu::NotSupportedError", "", __FILE__, __LINE__);
3118*35238bceSAndroid Build Coastguard Worker 
3119*35238bceSAndroid Build Coastguard Worker         if (isOk)
3120*35238bceSAndroid Build Coastguard Worker             m_testCtx.setTestResult(QP_TEST_RESULT_PASS, "Pass");
3121*35238bceSAndroid Build Coastguard Worker         else
3122*35238bceSAndroid Build Coastguard Worker             m_testCtx.setTestResult(QP_TEST_RESULT_FAIL, "Fail");
3123*35238bceSAndroid Build Coastguard Worker 
3124*35238bceSAndroid Build Coastguard Worker         return STOP;
3125*35238bceSAndroid Build Coastguard Worker     }
3126*35238bceSAndroid Build Coastguard Worker 
3127*35238bceSAndroid Build Coastguard Worker     return CONTINUE;
3128*35238bceSAndroid Build Coastguard Worker }
3129*35238bceSAndroid Build Coastguard Worker 
3130*35238bceSAndroid Build Coastguard Worker class GLES2ThreadedSharingTest : public TestCase
3131*35238bceSAndroid Build Coastguard Worker {
3132*35238bceSAndroid Build Coastguard Worker public:
3133*35238bceSAndroid Build Coastguard Worker     struct TestConfig
3134*35238bceSAndroid Build Coastguard Worker     {
3135*35238bceSAndroid Build Coastguard Worker         enum ResourceType
3136*35238bceSAndroid Build Coastguard Worker         {
3137*35238bceSAndroid Build Coastguard Worker             RESOURCETYPE_BUFFER = 0,
3138*35238bceSAndroid Build Coastguard Worker             RESOURCETYPE_TEXTURE,
3139*35238bceSAndroid Build Coastguard Worker             RESOURCETYPE_VERTEX_SHADER,
3140*35238bceSAndroid Build Coastguard Worker             RESOURCETYPE_FRAGMENT_SHADER,
3141*35238bceSAndroid Build Coastguard Worker             RESOURCETYPE_PROGRAM,
3142*35238bceSAndroid Build Coastguard Worker             RESOURCETYPE_IMAGE
3143*35238bceSAndroid Build Coastguard Worker         };
3144*35238bceSAndroid Build Coastguard Worker 
3145*35238bceSAndroid Build Coastguard Worker         ResourceType resourceType;
3146*35238bceSAndroid Build Coastguard Worker         bool singleContext;
3147*35238bceSAndroid Build Coastguard Worker         int define;
3148*35238bceSAndroid Build Coastguard Worker         int modify;
3149*35238bceSAndroid Build Coastguard Worker         bool useFenceSync;
3150*35238bceSAndroid Build Coastguard Worker         bool serverSync;
3151*35238bceSAndroid Build Coastguard Worker         bool render;
3152*35238bceSAndroid Build Coastguard Worker     };
3153*35238bceSAndroid Build Coastguard Worker     GLES2ThreadedSharingTest(EglTestContext &context, const TestConfig &config, const char *name,
3154*35238bceSAndroid Build Coastguard Worker                              const char *description);
3155*35238bceSAndroid Build Coastguard Worker     ~GLES2ThreadedSharingTest(void);
3156*35238bceSAndroid Build Coastguard Worker 
3157*35238bceSAndroid Build Coastguard Worker     void init(void);
3158*35238bceSAndroid Build Coastguard Worker     void deinit(void);
3159*35238bceSAndroid Build Coastguard Worker     IterateResult iterate(void);
3160*35238bceSAndroid Build Coastguard Worker 
3161*35238bceSAndroid Build Coastguard Worker     void addBufferOperations(void);
3162*35238bceSAndroid Build Coastguard Worker     void addTextureOperations(void);
3163*35238bceSAndroid Build Coastguard Worker     void addImageOperations(void);
3164*35238bceSAndroid Build Coastguard Worker     void addShaderOperations(GLenum type);
3165*35238bceSAndroid Build Coastguard Worker     void addProgramOperations(void);
3166*35238bceSAndroid Build Coastguard Worker 
3167*35238bceSAndroid Build Coastguard Worker private:
3168*35238bceSAndroid Build Coastguard Worker     TestConfig m_config;
3169*35238bceSAndroid Build Coastguard Worker     tcu::TestLog &m_log;
3170*35238bceSAndroid Build Coastguard Worker     int m_seed;
3171*35238bceSAndroid Build Coastguard Worker     bool m_threadsStarted;
3172*35238bceSAndroid Build Coastguard Worker     bool m_threadsRunning;
3173*35238bceSAndroid Build Coastguard Worker     bool m_executionReady;
3174*35238bceSAndroid Build Coastguard Worker     bool m_requiresRestart;
3175*35238bceSAndroid Build Coastguard Worker     uint64_t m_beginTimeUs;
3176*35238bceSAndroid Build Coastguard Worker     uint64_t m_timeOutUs;
3177*35238bceSAndroid Build Coastguard Worker     uint32_t m_sleepTimeMs;
3178*35238bceSAndroid Build Coastguard Worker     uint64_t m_timeOutTimeUs;
3179*35238bceSAndroid Build Coastguard Worker 
3180*35238bceSAndroid Build Coastguard Worker     std::vector<GLES2ThreadTest::EGLThread *> m_threads;
3181*35238bceSAndroid Build Coastguard Worker 
3182*35238bceSAndroid Build Coastguard Worker     EGLDisplay m_eglDisplay;
3183*35238bceSAndroid Build Coastguard Worker     EGLConfig m_eglConfig;
3184*35238bceSAndroid Build Coastguard Worker     glw::Functions m_gl;
3185*35238bceSAndroid Build Coastguard Worker };
3186*35238bceSAndroid Build Coastguard Worker 
GLES2ThreadedSharingTest(EglTestContext & context,const TestConfig & config,const char * name,const char * description)3187*35238bceSAndroid Build Coastguard Worker GLES2ThreadedSharingTest::GLES2ThreadedSharingTest(EglTestContext &context, const TestConfig &config, const char *name,
3188*35238bceSAndroid Build Coastguard Worker                                                    const char *description)
3189*35238bceSAndroid Build Coastguard Worker     : TestCase(context, name, description)
3190*35238bceSAndroid Build Coastguard Worker     , m_config(config)
3191*35238bceSAndroid Build Coastguard Worker     , m_log(m_testCtx.getLog())
3192*35238bceSAndroid Build Coastguard Worker     , m_seed(deStringHash(name))
3193*35238bceSAndroid Build Coastguard Worker     , m_threadsStarted(false)
3194*35238bceSAndroid Build Coastguard Worker     , m_threadsRunning(false)
3195*35238bceSAndroid Build Coastguard Worker     , m_executionReady(false)
3196*35238bceSAndroid Build Coastguard Worker     , m_requiresRestart(false)
3197*35238bceSAndroid Build Coastguard Worker     , m_beginTimeUs(0)
3198*35238bceSAndroid Build Coastguard Worker     , m_timeOutUs(10000000) // 10 seconds
3199*35238bceSAndroid Build Coastguard Worker     , m_sleepTimeMs(1)      // 1 milliseconds
3200*35238bceSAndroid Build Coastguard Worker     , m_timeOutTimeUs(0)
3201*35238bceSAndroid Build Coastguard Worker     , m_eglDisplay(EGL_NO_DISPLAY)
3202*35238bceSAndroid Build Coastguard Worker     , m_eglConfig(0)
3203*35238bceSAndroid Build Coastguard Worker {
3204*35238bceSAndroid Build Coastguard Worker }
3205*35238bceSAndroid Build Coastguard Worker 
~GLES2ThreadedSharingTest(void)3206*35238bceSAndroid Build Coastguard Worker GLES2ThreadedSharingTest::~GLES2ThreadedSharingTest(void)
3207*35238bceSAndroid Build Coastguard Worker {
3208*35238bceSAndroid Build Coastguard Worker     GLES2ThreadedSharingTest::deinit();
3209*35238bceSAndroid Build Coastguard Worker }
3210*35238bceSAndroid Build Coastguard Worker 
init(void)3211*35238bceSAndroid Build Coastguard Worker void GLES2ThreadedSharingTest::init(void)
3212*35238bceSAndroid Build Coastguard Worker {
3213*35238bceSAndroid Build Coastguard Worker     const Library &egl = m_eglTestCtx.getLibrary();
3214*35238bceSAndroid Build Coastguard Worker 
3215*35238bceSAndroid Build Coastguard Worker     const EGLint attribList[] = {
3216*35238bceSAndroid Build Coastguard Worker         EGL_RENDERABLE_TYPE, EGL_OPENGL_ES2_BIT, EGL_SURFACE_TYPE, EGL_PBUFFER_BIT, EGL_ALPHA_SIZE, 1, EGL_NONE};
3217*35238bceSAndroid Build Coastguard Worker 
3218*35238bceSAndroid Build Coastguard Worker     m_eglDisplay = eglu::getAndInitDisplay(m_eglTestCtx.getNativeDisplay());
3219*35238bceSAndroid Build Coastguard Worker     m_eglConfig  = eglu::chooseSingleConfig(egl, m_eglDisplay, attribList);
3220*35238bceSAndroid Build Coastguard Worker 
3221*35238bceSAndroid Build Coastguard Worker     m_eglTestCtx.initGLFunctions(&m_gl, glu::ApiType::es(2, 0));
3222*35238bceSAndroid Build Coastguard Worker 
3223*35238bceSAndroid Build Coastguard Worker     // Check extensions
3224*35238bceSAndroid Build Coastguard Worker     if (m_config.useFenceSync)
3225*35238bceSAndroid Build Coastguard Worker         requireEGLExtension(egl, m_eglDisplay, "EGL_KHR_fence_sync");
3226*35238bceSAndroid Build Coastguard Worker 
3227*35238bceSAndroid Build Coastguard Worker     if (m_config.serverSync)
3228*35238bceSAndroid Build Coastguard Worker         requireEGLExtension(egl, m_eglDisplay, "EGL_KHR_wait_sync");
3229*35238bceSAndroid Build Coastguard Worker 
3230*35238bceSAndroid Build Coastguard Worker     if (m_config.resourceType == TestConfig::RESOURCETYPE_IMAGE)
3231*35238bceSAndroid Build Coastguard Worker     {
3232*35238bceSAndroid Build Coastguard Worker         requireEGLExtension(egl, m_eglDisplay, "EGL_KHR_image_base");
3233*35238bceSAndroid Build Coastguard Worker         requireEGLExtension(egl, m_eglDisplay, "EGL_KHR_gl_texture_2D_image");
3234*35238bceSAndroid Build Coastguard Worker     }
3235*35238bceSAndroid Build Coastguard Worker 
3236*35238bceSAndroid Build Coastguard Worker     // Create threads
3237*35238bceSAndroid Build Coastguard Worker     m_threads.push_back(new GLES2ThreadTest::EGLThread(egl, m_gl, deInt32Hash(m_seed)));
3238*35238bceSAndroid Build Coastguard Worker     m_threads.push_back(new GLES2ThreadTest::EGLThread(egl, m_gl, deInt32Hash(~m_seed)));
3239*35238bceSAndroid Build Coastguard Worker 
3240*35238bceSAndroid Build Coastguard Worker     SharedPtr<GLES2ThreadTest::GLES2Context> contex1;
3241*35238bceSAndroid Build Coastguard Worker     SharedPtr<GLES2ThreadTest::GLES2Context> contex2;
3242*35238bceSAndroid Build Coastguard Worker 
3243*35238bceSAndroid Build Coastguard Worker     SharedPtr<GLES2ThreadTest::Surface> surface1;
3244*35238bceSAndroid Build Coastguard Worker     SharedPtr<GLES2ThreadTest::Surface> surface2;
3245*35238bceSAndroid Build Coastguard Worker 
3246*35238bceSAndroid Build Coastguard Worker     // Create contexts
3247*35238bceSAndroid Build Coastguard Worker     m_threads[0]->addOperation(new GLES2ThreadTest::CreateContext(m_eglDisplay, m_eglConfig,
3248*35238bceSAndroid Build Coastguard Worker                                                                   SharedPtr<GLES2ThreadTest::GLES2Context>(), contex1));
3249*35238bceSAndroid Build Coastguard Worker     m_threads[1]->addOperation(new GLES2ThreadTest::CreateContext(m_eglDisplay, m_eglConfig, contex1, contex2));
3250*35238bceSAndroid Build Coastguard Worker 
3251*35238bceSAndroid Build Coastguard Worker     // Create surfaces
3252*35238bceSAndroid Build Coastguard Worker     m_threads[0]->addOperation(
3253*35238bceSAndroid Build Coastguard Worker         new GLES2ThreadTest::CreatePBufferSurface(m_eglDisplay, m_eglConfig, 400, 400, surface1));
3254*35238bceSAndroid Build Coastguard Worker     m_threads[1]->addOperation(
3255*35238bceSAndroid Build Coastguard Worker         new GLES2ThreadTest::CreatePBufferSurface(m_eglDisplay, m_eglConfig, 400, 400, surface2));
3256*35238bceSAndroid Build Coastguard Worker 
3257*35238bceSAndroid Build Coastguard Worker     // Make current contexts
3258*35238bceSAndroid Build Coastguard Worker     m_threads[0]->addOperation(new GLES2ThreadTest::MakeCurrent(*m_threads[0], m_eglDisplay, surface1, contex1));
3259*35238bceSAndroid Build Coastguard Worker     m_threads[1]->addOperation(new GLES2ThreadTest::MakeCurrent(*m_threads[1], m_eglDisplay, surface2, contex2));
3260*35238bceSAndroid Build Coastguard Worker     // Operations to check fence sync support
3261*35238bceSAndroid Build Coastguard Worker     if (m_config.useFenceSync)
3262*35238bceSAndroid Build Coastguard Worker     {
3263*35238bceSAndroid Build Coastguard Worker         m_threads[0]->addOperation(new GLES2ThreadTest::InitGLExtension("GL_OES_EGL_sync"));
3264*35238bceSAndroid Build Coastguard Worker         m_threads[1]->addOperation(new GLES2ThreadTest::InitGLExtension("GL_OES_EGL_sync"));
3265*35238bceSAndroid Build Coastguard Worker     }
3266*35238bceSAndroid Build Coastguard Worker 
3267*35238bceSAndroid Build Coastguard Worker     switch (m_config.resourceType)
3268*35238bceSAndroid Build Coastguard Worker     {
3269*35238bceSAndroid Build Coastguard Worker     case TestConfig::RESOURCETYPE_BUFFER:
3270*35238bceSAndroid Build Coastguard Worker         addBufferOperations();
3271*35238bceSAndroid Build Coastguard Worker         break;
3272*35238bceSAndroid Build Coastguard Worker 
3273*35238bceSAndroid Build Coastguard Worker     case TestConfig::RESOURCETYPE_TEXTURE:
3274*35238bceSAndroid Build Coastguard Worker         addTextureOperations();
3275*35238bceSAndroid Build Coastguard Worker         break;
3276*35238bceSAndroid Build Coastguard Worker 
3277*35238bceSAndroid Build Coastguard Worker     case TestConfig::RESOURCETYPE_IMAGE:
3278*35238bceSAndroid Build Coastguard Worker         addImageOperations();
3279*35238bceSAndroid Build Coastguard Worker         break;
3280*35238bceSAndroid Build Coastguard Worker 
3281*35238bceSAndroid Build Coastguard Worker     case TestConfig::RESOURCETYPE_VERTEX_SHADER:
3282*35238bceSAndroid Build Coastguard Worker         addShaderOperations(GL_VERTEX_SHADER);
3283*35238bceSAndroid Build Coastguard Worker         break;
3284*35238bceSAndroid Build Coastguard Worker 
3285*35238bceSAndroid Build Coastguard Worker     case TestConfig::RESOURCETYPE_FRAGMENT_SHADER:
3286*35238bceSAndroid Build Coastguard Worker         addShaderOperations(GL_FRAGMENT_SHADER);
3287*35238bceSAndroid Build Coastguard Worker         break;
3288*35238bceSAndroid Build Coastguard Worker 
3289*35238bceSAndroid Build Coastguard Worker     case TestConfig::RESOURCETYPE_PROGRAM:
3290*35238bceSAndroid Build Coastguard Worker         addProgramOperations();
3291*35238bceSAndroid Build Coastguard Worker         break;
3292*35238bceSAndroid Build Coastguard Worker 
3293*35238bceSAndroid Build Coastguard Worker     default:
3294*35238bceSAndroid Build Coastguard Worker         DE_ASSERT(false);
3295*35238bceSAndroid Build Coastguard Worker     }
3296*35238bceSAndroid Build Coastguard Worker 
3297*35238bceSAndroid Build Coastguard Worker     // Relaese contexts
3298*35238bceSAndroid Build Coastguard Worker     m_threads[0]->addOperation(new GLES2ThreadTest::MakeCurrent(*m_threads[0], m_eglDisplay,
3299*35238bceSAndroid Build Coastguard Worker                                                                 SharedPtr<GLES2ThreadTest::Surface>(),
3300*35238bceSAndroid Build Coastguard Worker                                                                 SharedPtr<GLES2ThreadTest::GLES2Context>()));
3301*35238bceSAndroid Build Coastguard Worker     m_threads[1]->addOperation(new GLES2ThreadTest::MakeCurrent(*m_threads[0], m_eglDisplay,
3302*35238bceSAndroid Build Coastguard Worker                                                                 SharedPtr<GLES2ThreadTest::Surface>(),
3303*35238bceSAndroid Build Coastguard Worker                                                                 SharedPtr<GLES2ThreadTest::GLES2Context>()));
3304*35238bceSAndroid Build Coastguard Worker 
3305*35238bceSAndroid Build Coastguard Worker     // Destory context
3306*35238bceSAndroid Build Coastguard Worker     m_threads[0]->addOperation(new GLES2ThreadTest::DestroyContext(contex1));
3307*35238bceSAndroid Build Coastguard Worker     m_threads[1]->addOperation(new GLES2ThreadTest::DestroyContext(contex2));
3308*35238bceSAndroid Build Coastguard Worker 
3309*35238bceSAndroid Build Coastguard Worker     // Destroy surfaces
3310*35238bceSAndroid Build Coastguard Worker     m_threads[0]->addOperation(new GLES2ThreadTest::DestroySurface(m_eglDisplay, surface1));
3311*35238bceSAndroid Build Coastguard Worker     m_threads[1]->addOperation(new GLES2ThreadTest::DestroySurface(m_eglDisplay, surface2));
3312*35238bceSAndroid Build Coastguard Worker }
3313*35238bceSAndroid Build Coastguard Worker 
addBufferOperations(void)3314*35238bceSAndroid Build Coastguard Worker void GLES2ThreadedSharingTest::addBufferOperations(void)
3315*35238bceSAndroid Build Coastguard Worker {
3316*35238bceSAndroid Build Coastguard Worker     // Add operations for verify
3317*35238bceSAndroid Build Coastguard Worker     SharedPtr<GLES2ThreadTest::Shader> vertexShader;
3318*35238bceSAndroid Build Coastguard Worker     SharedPtr<GLES2ThreadTest::Shader> fragmentShader;
3319*35238bceSAndroid Build Coastguard Worker     SharedPtr<GLES2ThreadTest::Program> program;
3320*35238bceSAndroid Build Coastguard Worker 
3321*35238bceSAndroid Build Coastguard Worker     if (m_config.render)
3322*35238bceSAndroid Build Coastguard Worker     {
3323*35238bceSAndroid Build Coastguard Worker         const char *vertexShaderSource = "attribute highp vec2 a_pos;\n"
3324*35238bceSAndroid Build Coastguard Worker                                          "varying mediump vec2 v_pos;\n"
3325*35238bceSAndroid Build Coastguard Worker                                          "void main(void)\n"
3326*35238bceSAndroid Build Coastguard Worker                                          "{\n"
3327*35238bceSAndroid Build Coastguard Worker                                          "\tv_pos = a_pos;\n"
3328*35238bceSAndroid Build Coastguard Worker                                          "\tgl_Position = vec4(a_pos, 0.0, 1.0);\n"
3329*35238bceSAndroid Build Coastguard Worker                                          "}\n";
3330*35238bceSAndroid Build Coastguard Worker 
3331*35238bceSAndroid Build Coastguard Worker         const char *fragmentShaderSource = "varying mediump vec2 v_pos;\n"
3332*35238bceSAndroid Build Coastguard Worker                                            "void main(void)\n"
3333*35238bceSAndroid Build Coastguard Worker                                            "{\n"
3334*35238bceSAndroid Build Coastguard Worker                                            "\tgl_FragColor = vec4(v_pos, 0.5, 1.0);\n"
3335*35238bceSAndroid Build Coastguard Worker                                            "}\n";
3336*35238bceSAndroid Build Coastguard Worker 
3337*35238bceSAndroid Build Coastguard Worker         m_threads[0]->addOperation(new GLES2ThreadTest::CreateShader(GL_VERTEX_SHADER, vertexShader,
3338*35238bceSAndroid Build Coastguard Worker                                                                      m_config.useFenceSync, m_config.serverSync));
3339*35238bceSAndroid Build Coastguard Worker         m_threads[0]->addOperation(new GLES2ThreadTest::ShaderSource(vertexShader, vertexShaderSource,
3340*35238bceSAndroid Build Coastguard Worker                                                                      m_config.useFenceSync, m_config.serverSync));
3341*35238bceSAndroid Build Coastguard Worker         m_threads[0]->addOperation(
3342*35238bceSAndroid Build Coastguard Worker             new GLES2ThreadTest::ShaderCompile(vertexShader, m_config.useFenceSync, m_config.serverSync));
3343*35238bceSAndroid Build Coastguard Worker 
3344*35238bceSAndroid Build Coastguard Worker         m_threads[0]->addOperation(new GLES2ThreadTest::CreateShader(GL_FRAGMENT_SHADER, fragmentShader,
3345*35238bceSAndroid Build Coastguard Worker                                                                      m_config.useFenceSync, m_config.serverSync));
3346*35238bceSAndroid Build Coastguard Worker         m_threads[0]->addOperation(new GLES2ThreadTest::ShaderSource(fragmentShader, fragmentShaderSource,
3347*35238bceSAndroid Build Coastguard Worker                                                                      m_config.useFenceSync, m_config.serverSync));
3348*35238bceSAndroid Build Coastguard Worker         m_threads[0]->addOperation(
3349*35238bceSAndroid Build Coastguard Worker             new GLES2ThreadTest::ShaderCompile(fragmentShader, m_config.useFenceSync, m_config.serverSync));
3350*35238bceSAndroid Build Coastguard Worker 
3351*35238bceSAndroid Build Coastguard Worker         m_threads[0]->addOperation(
3352*35238bceSAndroid Build Coastguard Worker             new GLES2ThreadTest::CreateProgram(program, m_config.useFenceSync, m_config.serverSync));
3353*35238bceSAndroid Build Coastguard Worker         m_threads[0]->addOperation(
3354*35238bceSAndroid Build Coastguard Worker             new GLES2ThreadTest::AttachShader(program, fragmentShader, m_config.useFenceSync, m_config.serverSync));
3355*35238bceSAndroid Build Coastguard Worker         m_threads[0]->addOperation(
3356*35238bceSAndroid Build Coastguard Worker             new GLES2ThreadTest::AttachShader(program, vertexShader, m_config.useFenceSync, m_config.serverSync));
3357*35238bceSAndroid Build Coastguard Worker 
3358*35238bceSAndroid Build Coastguard Worker         m_threads[0]->addOperation(
3359*35238bceSAndroid Build Coastguard Worker             new GLES2ThreadTest::LinkProgram(program, m_config.useFenceSync, m_config.serverSync));
3360*35238bceSAndroid Build Coastguard Worker     }
3361*35238bceSAndroid Build Coastguard Worker 
3362*35238bceSAndroid Build Coastguard Worker     SharedPtr<GLES2ThreadTest::Buffer> buffer;
3363*35238bceSAndroid Build Coastguard Worker 
3364*35238bceSAndroid Build Coastguard Worker     m_threads[0]->addOperation(new GLES2ThreadTest::CreateBuffer(buffer, m_config.useFenceSync, m_config.serverSync));
3365*35238bceSAndroid Build Coastguard Worker 
3366*35238bceSAndroid Build Coastguard Worker     if (m_config.define)
3367*35238bceSAndroid Build Coastguard Worker     {
3368*35238bceSAndroid Build Coastguard Worker         if (m_config.modify || m_config.render)
3369*35238bceSAndroid Build Coastguard Worker             m_threads[0]->addOperation(new GLES2ThreadTest::BufferData(buffer, GL_ARRAY_BUFFER, 1024, GL_DYNAMIC_DRAW,
3370*35238bceSAndroid Build Coastguard Worker                                                                        m_config.useFenceSync, m_config.serverSync));
3371*35238bceSAndroid Build Coastguard Worker         else
3372*35238bceSAndroid Build Coastguard Worker             m_threads[1]->addOperation(new GLES2ThreadTest::BufferData(buffer, GL_ARRAY_BUFFER, 1024, GL_DYNAMIC_DRAW,
3373*35238bceSAndroid Build Coastguard Worker                                                                        m_config.useFenceSync, m_config.serverSync));
3374*35238bceSAndroid Build Coastguard Worker     }
3375*35238bceSAndroid Build Coastguard Worker 
3376*35238bceSAndroid Build Coastguard Worker     if (m_config.modify)
3377*35238bceSAndroid Build Coastguard Worker     {
3378*35238bceSAndroid Build Coastguard Worker         if (m_config.render)
3379*35238bceSAndroid Build Coastguard Worker             m_threads[0]->addOperation(new GLES2ThreadTest::BufferSubData(buffer, GL_ARRAY_BUFFER, 17, 17,
3380*35238bceSAndroid Build Coastguard Worker                                                                           m_config.useFenceSync, m_config.serverSync));
3381*35238bceSAndroid Build Coastguard Worker         else
3382*35238bceSAndroid Build Coastguard Worker             m_threads[1]->addOperation(new GLES2ThreadTest::BufferSubData(buffer, GL_ARRAY_BUFFER, 17, 17,
3383*35238bceSAndroid Build Coastguard Worker                                                                           m_config.useFenceSync, m_config.serverSync));
3384*35238bceSAndroid Build Coastguard Worker     }
3385*35238bceSAndroid Build Coastguard Worker 
3386*35238bceSAndroid Build Coastguard Worker     if (m_config.render)
3387*35238bceSAndroid Build Coastguard Worker     {
3388*35238bceSAndroid Build Coastguard Worker         m_threads[0]->addOperation(
3389*35238bceSAndroid Build Coastguard Worker             new GLES2ThreadTest::RenderBuffer(program, buffer, m_config.useFenceSync, m_config.serverSync));
3390*35238bceSAndroid Build Coastguard Worker         m_threads[1]->addOperation(
3391*35238bceSAndroid Build Coastguard Worker             new GLES2ThreadTest::RenderBuffer(program, buffer, m_config.useFenceSync, m_config.serverSync));
3392*35238bceSAndroid Build Coastguard Worker 
3393*35238bceSAndroid Build Coastguard Worker         SharedPtr<tcu::ThreadUtil::DataBlock> pixels1;
3394*35238bceSAndroid Build Coastguard Worker         SharedPtr<tcu::ThreadUtil::DataBlock> pixels2;
3395*35238bceSAndroid Build Coastguard Worker 
3396*35238bceSAndroid Build Coastguard Worker         m_threads[0]->addOperation(new GLES2ThreadTest::ReadPixels(0, 0, 400, 400, GL_RGBA, GL_UNSIGNED_BYTE, pixels1,
3397*35238bceSAndroid Build Coastguard Worker                                                                    m_config.useFenceSync, m_config.serverSync));
3398*35238bceSAndroid Build Coastguard Worker         m_threads[1]->addOperation(new GLES2ThreadTest::ReadPixels(0, 0, 400, 400, GL_RGBA, GL_UNSIGNED_BYTE, pixels2,
3399*35238bceSAndroid Build Coastguard Worker                                                                    m_config.useFenceSync, m_config.serverSync));
3400*35238bceSAndroid Build Coastguard Worker 
3401*35238bceSAndroid Build Coastguard Worker         m_threads[0]->addOperation(new tcu::ThreadUtil::CompareData(pixels1, pixels2));
3402*35238bceSAndroid Build Coastguard Worker     }
3403*35238bceSAndroid Build Coastguard Worker 
3404*35238bceSAndroid Build Coastguard Worker     if (m_config.modify || m_config.render)
3405*35238bceSAndroid Build Coastguard Worker         m_threads[0]->addOperation(
3406*35238bceSAndroid Build Coastguard Worker             new GLES2ThreadTest::DeleteBuffer(buffer, m_config.useFenceSync, m_config.serverSync));
3407*35238bceSAndroid Build Coastguard Worker     else
3408*35238bceSAndroid Build Coastguard Worker         m_threads[1]->addOperation(
3409*35238bceSAndroid Build Coastguard Worker             new GLES2ThreadTest::DeleteBuffer(buffer, m_config.useFenceSync, m_config.serverSync));
3410*35238bceSAndroid Build Coastguard Worker 
3411*35238bceSAndroid Build Coastguard Worker     if (m_config.render)
3412*35238bceSAndroid Build Coastguard Worker     {
3413*35238bceSAndroid Build Coastguard Worker         m_threads[0]->addOperation(
3414*35238bceSAndroid Build Coastguard Worker             new GLES2ThreadTest::DeleteShader(vertexShader, m_config.useFenceSync, m_config.serverSync));
3415*35238bceSAndroid Build Coastguard Worker         m_threads[0]->addOperation(
3416*35238bceSAndroid Build Coastguard Worker             new GLES2ThreadTest::DeleteShader(fragmentShader, m_config.useFenceSync, m_config.serverSync));
3417*35238bceSAndroid Build Coastguard Worker         m_threads[0]->addOperation(
3418*35238bceSAndroid Build Coastguard Worker             new GLES2ThreadTest::DeleteProgram(program, m_config.useFenceSync, m_config.serverSync));
3419*35238bceSAndroid Build Coastguard Worker     }
3420*35238bceSAndroid Build Coastguard Worker }
3421*35238bceSAndroid Build Coastguard Worker 
addTextureOperations(void)3422*35238bceSAndroid Build Coastguard Worker void GLES2ThreadedSharingTest::addTextureOperations(void)
3423*35238bceSAndroid Build Coastguard Worker {
3424*35238bceSAndroid Build Coastguard Worker     // Add operations for verify
3425*35238bceSAndroid Build Coastguard Worker     SharedPtr<GLES2ThreadTest::Shader> vertexShader;
3426*35238bceSAndroid Build Coastguard Worker     SharedPtr<GLES2ThreadTest::Shader> fragmentShader;
3427*35238bceSAndroid Build Coastguard Worker     SharedPtr<GLES2ThreadTest::Program> program;
3428*35238bceSAndroid Build Coastguard Worker 
3429*35238bceSAndroid Build Coastguard Worker     if (m_config.render)
3430*35238bceSAndroid Build Coastguard Worker     {
3431*35238bceSAndroid Build Coastguard Worker         const char *vertexShaderSource = "attribute highp vec2 a_pos;\n"
3432*35238bceSAndroid Build Coastguard Worker                                          "varying mediump vec2 v_pos;\n"
3433*35238bceSAndroid Build Coastguard Worker                                          "void main(void)\n"
3434*35238bceSAndroid Build Coastguard Worker                                          "{\n"
3435*35238bceSAndroid Build Coastguard Worker                                          "\tv_pos = a_pos;\n"
3436*35238bceSAndroid Build Coastguard Worker                                          "\tgl_Position = vec4(a_pos, 0.0, 1.0);\n"
3437*35238bceSAndroid Build Coastguard Worker                                          "}\n";
3438*35238bceSAndroid Build Coastguard Worker 
3439*35238bceSAndroid Build Coastguard Worker         const char *fragmentShaderSource = "varying mediump vec2 v_pos;\n"
3440*35238bceSAndroid Build Coastguard Worker                                            "uniform sampler2D u_sampler;\n"
3441*35238bceSAndroid Build Coastguard Worker                                            "void main(void)\n"
3442*35238bceSAndroid Build Coastguard Worker                                            "{\n"
3443*35238bceSAndroid Build Coastguard Worker                                            "\tgl_FragColor = texture2D(u_sampler, v_pos);\n"
3444*35238bceSAndroid Build Coastguard Worker                                            "}\n";
3445*35238bceSAndroid Build Coastguard Worker 
3446*35238bceSAndroid Build Coastguard Worker         m_threads[0]->addOperation(new GLES2ThreadTest::CreateShader(GL_VERTEX_SHADER, vertexShader,
3447*35238bceSAndroid Build Coastguard Worker                                                                      m_config.useFenceSync, m_config.serverSync));
3448*35238bceSAndroid Build Coastguard Worker         m_threads[0]->addOperation(new GLES2ThreadTest::ShaderSource(vertexShader, vertexShaderSource,
3449*35238bceSAndroid Build Coastguard Worker                                                                      m_config.useFenceSync, m_config.serverSync));
3450*35238bceSAndroid Build Coastguard Worker         m_threads[0]->addOperation(
3451*35238bceSAndroid Build Coastguard Worker             new GLES2ThreadTest::ShaderCompile(vertexShader, m_config.useFenceSync, m_config.serverSync));
3452*35238bceSAndroid Build Coastguard Worker 
3453*35238bceSAndroid Build Coastguard Worker         m_threads[0]->addOperation(new GLES2ThreadTest::CreateShader(GL_FRAGMENT_SHADER, fragmentShader,
3454*35238bceSAndroid Build Coastguard Worker                                                                      m_config.useFenceSync, m_config.serverSync));
3455*35238bceSAndroid Build Coastguard Worker         m_threads[0]->addOperation(new GLES2ThreadTest::ShaderSource(fragmentShader, fragmentShaderSource,
3456*35238bceSAndroid Build Coastguard Worker                                                                      m_config.useFenceSync, m_config.serverSync));
3457*35238bceSAndroid Build Coastguard Worker         m_threads[0]->addOperation(
3458*35238bceSAndroid Build Coastguard Worker             new GLES2ThreadTest::ShaderCompile(fragmentShader, m_config.useFenceSync, m_config.serverSync));
3459*35238bceSAndroid Build Coastguard Worker 
3460*35238bceSAndroid Build Coastguard Worker         m_threads[0]->addOperation(
3461*35238bceSAndroid Build Coastguard Worker             new GLES2ThreadTest::CreateProgram(program, m_config.useFenceSync, m_config.serverSync));
3462*35238bceSAndroid Build Coastguard Worker         m_threads[0]->addOperation(
3463*35238bceSAndroid Build Coastguard Worker             new GLES2ThreadTest::AttachShader(program, fragmentShader, m_config.useFenceSync, m_config.serverSync));
3464*35238bceSAndroid Build Coastguard Worker         m_threads[0]->addOperation(
3465*35238bceSAndroid Build Coastguard Worker             new GLES2ThreadTest::AttachShader(program, vertexShader, m_config.useFenceSync, m_config.serverSync));
3466*35238bceSAndroid Build Coastguard Worker 
3467*35238bceSAndroid Build Coastguard Worker         m_threads[0]->addOperation(
3468*35238bceSAndroid Build Coastguard Worker             new GLES2ThreadTest::LinkProgram(program, m_config.useFenceSync, m_config.serverSync));
3469*35238bceSAndroid Build Coastguard Worker     }
3470*35238bceSAndroid Build Coastguard Worker 
3471*35238bceSAndroid Build Coastguard Worker     SharedPtr<GLES2ThreadTest::Texture> texture;
3472*35238bceSAndroid Build Coastguard Worker 
3473*35238bceSAndroid Build Coastguard Worker     m_threads[0]->addOperation(new GLES2ThreadTest::CreateTexture(texture, m_config.useFenceSync, m_config.serverSync));
3474*35238bceSAndroid Build Coastguard Worker 
3475*35238bceSAndroid Build Coastguard Worker     if (m_config.define == 1)
3476*35238bceSAndroid Build Coastguard Worker     {
3477*35238bceSAndroid Build Coastguard Worker         if (m_config.modify || m_config.render)
3478*35238bceSAndroid Build Coastguard Worker             m_threads[0]->addOperation(new GLES2ThreadTest::TexImage2D(
3479*35238bceSAndroid Build Coastguard Worker                 texture, 0, GL_RGBA, 256, 256, GL_RGBA, GL_UNSIGNED_BYTE, m_config.useFenceSync, m_config.serverSync));
3480*35238bceSAndroid Build Coastguard Worker         else
3481*35238bceSAndroid Build Coastguard Worker             m_threads[1]->addOperation(new GLES2ThreadTest::TexImage2D(
3482*35238bceSAndroid Build Coastguard Worker                 texture, 0, GL_RGBA, 256, 256, GL_RGBA, GL_UNSIGNED_BYTE, m_config.useFenceSync, m_config.serverSync));
3483*35238bceSAndroid Build Coastguard Worker     }
3484*35238bceSAndroid Build Coastguard Worker 
3485*35238bceSAndroid Build Coastguard Worker     if (m_config.define == 2)
3486*35238bceSAndroid Build Coastguard Worker     {
3487*35238bceSAndroid Build Coastguard Worker         if (m_config.modify || m_config.render)
3488*35238bceSAndroid Build Coastguard Worker             m_threads[0]->addOperation(new GLES2ThreadTest::CopyTexImage2D(texture, 0, GL_RGBA, 17, 17, 256, 256, 0,
3489*35238bceSAndroid Build Coastguard Worker                                                                            m_config.useFenceSync, m_config.serverSync));
3490*35238bceSAndroid Build Coastguard Worker         else
3491*35238bceSAndroid Build Coastguard Worker             m_threads[1]->addOperation(new GLES2ThreadTest::CopyTexImage2D(texture, 0, GL_RGBA, 17, 17, 256, 256, 0,
3492*35238bceSAndroid Build Coastguard Worker                                                                            m_config.useFenceSync, m_config.serverSync));
3493*35238bceSAndroid Build Coastguard Worker     }
3494*35238bceSAndroid Build Coastguard Worker 
3495*35238bceSAndroid Build Coastguard Worker     if (m_config.modify == 1)
3496*35238bceSAndroid Build Coastguard Worker     {
3497*35238bceSAndroid Build Coastguard Worker         if (m_config.render)
3498*35238bceSAndroid Build Coastguard Worker             m_threads[0]->addOperation(new GLES2ThreadTest::TexSubImage2D(
3499*35238bceSAndroid Build Coastguard Worker                 texture, 0, 17, 17, 29, 29, GL_RGBA, GL_UNSIGNED_BYTE, m_config.useFenceSync, m_config.serverSync));
3500*35238bceSAndroid Build Coastguard Worker         else
3501*35238bceSAndroid Build Coastguard Worker             m_threads[1]->addOperation(new GLES2ThreadTest::TexSubImage2D(
3502*35238bceSAndroid Build Coastguard Worker                 texture, 0, 17, 17, 29, 29, GL_RGBA, GL_UNSIGNED_BYTE, m_config.useFenceSync, m_config.serverSync));
3503*35238bceSAndroid Build Coastguard Worker     }
3504*35238bceSAndroid Build Coastguard Worker 
3505*35238bceSAndroid Build Coastguard Worker     if (m_config.modify == 2)
3506*35238bceSAndroid Build Coastguard Worker     {
3507*35238bceSAndroid Build Coastguard Worker         if (m_config.render)
3508*35238bceSAndroid Build Coastguard Worker             m_threads[0]->addOperation(new GLES2ThreadTest::CopyTexSubImage2D(
3509*35238bceSAndroid Build Coastguard Worker                 texture, 0, 7, 7, 17, 17, 29, 29, m_config.useFenceSync, m_config.serverSync));
3510*35238bceSAndroid Build Coastguard Worker         else
3511*35238bceSAndroid Build Coastguard Worker             m_threads[1]->addOperation(new GLES2ThreadTest::CopyTexSubImage2D(
3512*35238bceSAndroid Build Coastguard Worker                 texture, 0, 7, 7, 17, 17, 29, 29, m_config.useFenceSync, m_config.serverSync));
3513*35238bceSAndroid Build Coastguard Worker     }
3514*35238bceSAndroid Build Coastguard Worker 
3515*35238bceSAndroid Build Coastguard Worker     if (m_config.render)
3516*35238bceSAndroid Build Coastguard Worker     {
3517*35238bceSAndroid Build Coastguard Worker         SharedPtr<tcu::ThreadUtil::DataBlock> pixels1;
3518*35238bceSAndroid Build Coastguard Worker         SharedPtr<tcu::ThreadUtil::DataBlock> pixels2;
3519*35238bceSAndroid Build Coastguard Worker 
3520*35238bceSAndroid Build Coastguard Worker         m_threads[0]->addOperation(
3521*35238bceSAndroid Build Coastguard Worker             new GLES2ThreadTest::RenderTexture(program, texture, m_config.useFenceSync, m_config.serverSync));
3522*35238bceSAndroid Build Coastguard Worker         m_threads[1]->addOperation(
3523*35238bceSAndroid Build Coastguard Worker             new GLES2ThreadTest::RenderTexture(program, texture, m_config.useFenceSync, m_config.serverSync));
3524*35238bceSAndroid Build Coastguard Worker 
3525*35238bceSAndroid Build Coastguard Worker         m_threads[0]->addOperation(new GLES2ThreadTest::ReadPixels(0, 0, 400, 400, GL_RGBA, GL_UNSIGNED_BYTE, pixels1,
3526*35238bceSAndroid Build Coastguard Worker                                                                    m_config.useFenceSync, m_config.serverSync));
3527*35238bceSAndroid Build Coastguard Worker         m_threads[1]->addOperation(new GLES2ThreadTest::ReadPixels(0, 0, 400, 400, GL_RGBA, GL_UNSIGNED_BYTE, pixels2,
3528*35238bceSAndroid Build Coastguard Worker                                                                    m_config.useFenceSync, m_config.serverSync));
3529*35238bceSAndroid Build Coastguard Worker 
3530*35238bceSAndroid Build Coastguard Worker         m_threads[0]->addOperation(new tcu::ThreadUtil::CompareData(pixels1, pixels2));
3531*35238bceSAndroid Build Coastguard Worker     }
3532*35238bceSAndroid Build Coastguard Worker 
3533*35238bceSAndroid Build Coastguard Worker     if (m_config.modify || m_config.render)
3534*35238bceSAndroid Build Coastguard Worker         m_threads[0]->addOperation(
3535*35238bceSAndroid Build Coastguard Worker             new GLES2ThreadTest::DeleteTexture(texture, m_config.useFenceSync, m_config.serverSync));
3536*35238bceSAndroid Build Coastguard Worker     else
3537*35238bceSAndroid Build Coastguard Worker         m_threads[1]->addOperation(
3538*35238bceSAndroid Build Coastguard Worker             new GLES2ThreadTest::DeleteTexture(texture, m_config.useFenceSync, m_config.serverSync));
3539*35238bceSAndroid Build Coastguard Worker 
3540*35238bceSAndroid Build Coastguard Worker     if (m_config.render)
3541*35238bceSAndroid Build Coastguard Worker     {
3542*35238bceSAndroid Build Coastguard Worker         m_threads[0]->addOperation(
3543*35238bceSAndroid Build Coastguard Worker             new GLES2ThreadTest::DeleteShader(vertexShader, m_config.useFenceSync, m_config.serverSync));
3544*35238bceSAndroid Build Coastguard Worker         m_threads[0]->addOperation(
3545*35238bceSAndroid Build Coastguard Worker             new GLES2ThreadTest::DeleteShader(fragmentShader, m_config.useFenceSync, m_config.serverSync));
3546*35238bceSAndroid Build Coastguard Worker         m_threads[0]->addOperation(
3547*35238bceSAndroid Build Coastguard Worker             new GLES2ThreadTest::DeleteProgram(program, m_config.useFenceSync, m_config.serverSync));
3548*35238bceSAndroid Build Coastguard Worker     }
3549*35238bceSAndroid Build Coastguard Worker }
3550*35238bceSAndroid Build Coastguard Worker 
addImageOperations(void)3551*35238bceSAndroid Build Coastguard Worker void GLES2ThreadedSharingTest::addImageOperations(void)
3552*35238bceSAndroid Build Coastguard Worker {
3553*35238bceSAndroid Build Coastguard Worker     // Add operations for verify
3554*35238bceSAndroid Build Coastguard Worker     SharedPtr<GLES2ThreadTest::Shader> vertexShader;
3555*35238bceSAndroid Build Coastguard Worker     SharedPtr<GLES2ThreadTest::Shader> fragmentShader;
3556*35238bceSAndroid Build Coastguard Worker     SharedPtr<GLES2ThreadTest::Program> program;
3557*35238bceSAndroid Build Coastguard Worker 
3558*35238bceSAndroid Build Coastguard Worker     m_threads[0]->addOperation(new GLES2ThreadTest::InitGLExtension("GL_OES_EGL_image"));
3559*35238bceSAndroid Build Coastguard Worker     m_threads[1]->addOperation(new GLES2ThreadTest::InitGLExtension("GL_OES_EGL_image"));
3560*35238bceSAndroid Build Coastguard Worker 
3561*35238bceSAndroid Build Coastguard Worker     if (m_config.render)
3562*35238bceSAndroid Build Coastguard Worker     {
3563*35238bceSAndroid Build Coastguard Worker         const char *vertexShaderSource = "attribute highp vec2 a_pos;\n"
3564*35238bceSAndroid Build Coastguard Worker                                          "varying mediump vec2 v_pos;\n"
3565*35238bceSAndroid Build Coastguard Worker                                          "void main(void)\n"
3566*35238bceSAndroid Build Coastguard Worker                                          "{\n"
3567*35238bceSAndroid Build Coastguard Worker                                          "\tv_pos = a_pos;\n"
3568*35238bceSAndroid Build Coastguard Worker                                          "\tgl_Position = vec4(a_pos, 0.0, 1.0);\n"
3569*35238bceSAndroid Build Coastguard Worker                                          "}\n";
3570*35238bceSAndroid Build Coastguard Worker 
3571*35238bceSAndroid Build Coastguard Worker         const char *fragmentShaderSource = "varying mediump vec2 v_pos;\n"
3572*35238bceSAndroid Build Coastguard Worker                                            "uniform sampler2D u_sampler;\n"
3573*35238bceSAndroid Build Coastguard Worker                                            "void main(void)\n"
3574*35238bceSAndroid Build Coastguard Worker                                            "{\n"
3575*35238bceSAndroid Build Coastguard Worker                                            "\tgl_FragColor = texture2D(u_sampler, v_pos);\n"
3576*35238bceSAndroid Build Coastguard Worker                                            "}\n";
3577*35238bceSAndroid Build Coastguard Worker 
3578*35238bceSAndroid Build Coastguard Worker         m_threads[0]->addOperation(new GLES2ThreadTest::CreateShader(GL_VERTEX_SHADER, vertexShader,
3579*35238bceSAndroid Build Coastguard Worker                                                                      m_config.useFenceSync, m_config.serverSync));
3580*35238bceSAndroid Build Coastguard Worker         m_threads[0]->addOperation(new GLES2ThreadTest::ShaderSource(vertexShader, vertexShaderSource,
3581*35238bceSAndroid Build Coastguard Worker                                                                      m_config.useFenceSync, m_config.serverSync));
3582*35238bceSAndroid Build Coastguard Worker         m_threads[0]->addOperation(
3583*35238bceSAndroid Build Coastguard Worker             new GLES2ThreadTest::ShaderCompile(vertexShader, m_config.useFenceSync, m_config.serverSync));
3584*35238bceSAndroid Build Coastguard Worker 
3585*35238bceSAndroid Build Coastguard Worker         m_threads[0]->addOperation(new GLES2ThreadTest::CreateShader(GL_FRAGMENT_SHADER, fragmentShader,
3586*35238bceSAndroid Build Coastguard Worker                                                                      m_config.useFenceSync, m_config.serverSync));
3587*35238bceSAndroid Build Coastguard Worker         m_threads[0]->addOperation(new GLES2ThreadTest::ShaderSource(fragmentShader, fragmentShaderSource,
3588*35238bceSAndroid Build Coastguard Worker                                                                      m_config.useFenceSync, m_config.serverSync));
3589*35238bceSAndroid Build Coastguard Worker         m_threads[0]->addOperation(
3590*35238bceSAndroid Build Coastguard Worker             new GLES2ThreadTest::ShaderCompile(fragmentShader, m_config.useFenceSync, m_config.serverSync));
3591*35238bceSAndroid Build Coastguard Worker 
3592*35238bceSAndroid Build Coastguard Worker         m_threads[0]->addOperation(
3593*35238bceSAndroid Build Coastguard Worker             new GLES2ThreadTest::CreateProgram(program, m_config.useFenceSync, m_config.serverSync));
3594*35238bceSAndroid Build Coastguard Worker         m_threads[0]->addOperation(
3595*35238bceSAndroid Build Coastguard Worker             new GLES2ThreadTest::AttachShader(program, fragmentShader, m_config.useFenceSync, m_config.serverSync));
3596*35238bceSAndroid Build Coastguard Worker         m_threads[0]->addOperation(
3597*35238bceSAndroid Build Coastguard Worker             new GLES2ThreadTest::AttachShader(program, vertexShader, m_config.useFenceSync, m_config.serverSync));
3598*35238bceSAndroid Build Coastguard Worker 
3599*35238bceSAndroid Build Coastguard Worker         m_threads[0]->addOperation(
3600*35238bceSAndroid Build Coastguard Worker             new GLES2ThreadTest::LinkProgram(program, m_config.useFenceSync, m_config.serverSync));
3601*35238bceSAndroid Build Coastguard Worker     }
3602*35238bceSAndroid Build Coastguard Worker 
3603*35238bceSAndroid Build Coastguard Worker     SharedPtr<GLES2ThreadTest::Texture> sourceTexture;
3604*35238bceSAndroid Build Coastguard Worker     SharedPtr<GLES2ThreadTest::Texture> texture;
3605*35238bceSAndroid Build Coastguard Worker     SharedPtr<GLES2ThreadTest::EGLImage> image;
3606*35238bceSAndroid Build Coastguard Worker 
3607*35238bceSAndroid Build Coastguard Worker     m_threads[0]->addOperation(
3608*35238bceSAndroid Build Coastguard Worker         new GLES2ThreadTest::CreateTexture(sourceTexture, m_config.useFenceSync, m_config.serverSync));
3609*35238bceSAndroid Build Coastguard Worker     m_threads[0]->addOperation(new GLES2ThreadTest::TexImage2D(
3610*35238bceSAndroid Build Coastguard Worker         sourceTexture, 0, GL_RGBA, 256, 256, GL_RGBA, GL_UNSIGNED_BYTE, m_config.useFenceSync, m_config.serverSync));
3611*35238bceSAndroid Build Coastguard Worker 
3612*35238bceSAndroid Build Coastguard Worker     if (m_config.define == 1)
3613*35238bceSAndroid Build Coastguard Worker     {
3614*35238bceSAndroid Build Coastguard Worker         if (m_config.modify || m_config.render)
3615*35238bceSAndroid Build Coastguard Worker             m_threads[0]->addOperation(new GLES2ThreadTest::CreateImageFromTexture(
3616*35238bceSAndroid Build Coastguard Worker                 image, sourceTexture, m_config.useFenceSync, m_config.serverSync));
3617*35238bceSAndroid Build Coastguard Worker         else
3618*35238bceSAndroid Build Coastguard Worker             m_threads[1]->addOperation(new GLES2ThreadTest::CreateImageFromTexture(
3619*35238bceSAndroid Build Coastguard Worker                 image, sourceTexture, m_config.useFenceSync, m_config.serverSync));
3620*35238bceSAndroid Build Coastguard Worker     }
3621*35238bceSAndroid Build Coastguard Worker 
3622*35238bceSAndroid Build Coastguard Worker     if (m_config.define == 2)
3623*35238bceSAndroid Build Coastguard Worker     {
3624*35238bceSAndroid Build Coastguard Worker         m_threads[0]->addOperation(new GLES2ThreadTest::CreateImageFromTexture(
3625*35238bceSAndroid Build Coastguard Worker             image, sourceTexture, m_config.useFenceSync, m_config.serverSync));
3626*35238bceSAndroid Build Coastguard Worker         m_threads[0]->addOperation(
3627*35238bceSAndroid Build Coastguard Worker             new GLES2ThreadTest::CreateTexture(texture, m_config.useFenceSync, m_config.serverSync));
3628*35238bceSAndroid Build Coastguard Worker 
3629*35238bceSAndroid Build Coastguard Worker         if (m_config.modify || m_config.render)
3630*35238bceSAndroid Build Coastguard Worker             m_threads[0]->addOperation(new GLES2ThreadTest::DefineTextureFromImage(
3631*35238bceSAndroid Build Coastguard Worker                 texture, image, m_config.useFenceSync, m_config.serverSync));
3632*35238bceSAndroid Build Coastguard Worker         else
3633*35238bceSAndroid Build Coastguard Worker             m_threads[1]->addOperation(new GLES2ThreadTest::DefineTextureFromImage(
3634*35238bceSAndroid Build Coastguard Worker                 texture, image, m_config.useFenceSync, m_config.serverSync));
3635*35238bceSAndroid Build Coastguard Worker     }
3636*35238bceSAndroid Build Coastguard Worker 
3637*35238bceSAndroid Build Coastguard Worker     m_threads[0]->addOperation(
3638*35238bceSAndroid Build Coastguard Worker         new GLES2ThreadTest::DeleteTexture(sourceTexture, m_config.useFenceSync, m_config.serverSync));
3639*35238bceSAndroid Build Coastguard Worker 
3640*35238bceSAndroid Build Coastguard Worker     if (m_config.modify == 1)
3641*35238bceSAndroid Build Coastguard Worker     {
3642*35238bceSAndroid Build Coastguard Worker         DE_ASSERT(m_config.define != 1);
3643*35238bceSAndroid Build Coastguard Worker 
3644*35238bceSAndroid Build Coastguard Worker         if (m_config.render)
3645*35238bceSAndroid Build Coastguard Worker             m_threads[0]->addOperation(new GLES2ThreadTest::TexSubImage2D(
3646*35238bceSAndroid Build Coastguard Worker                 texture, 0, 17, 17, 29, 29, GL_RGBA, GL_UNSIGNED_BYTE, m_config.useFenceSync, m_config.serverSync));
3647*35238bceSAndroid Build Coastguard Worker         else
3648*35238bceSAndroid Build Coastguard Worker             m_threads[1]->addOperation(new GLES2ThreadTest::TexSubImage2D(
3649*35238bceSAndroid Build Coastguard Worker                 texture, 0, 17, 17, 29, 29, GL_RGBA, GL_UNSIGNED_BYTE, m_config.useFenceSync, m_config.serverSync));
3650*35238bceSAndroid Build Coastguard Worker     }
3651*35238bceSAndroid Build Coastguard Worker 
3652*35238bceSAndroid Build Coastguard Worker     if (m_config.modify == 2)
3653*35238bceSAndroid Build Coastguard Worker     {
3654*35238bceSAndroid Build Coastguard Worker         DE_ASSERT(m_config.define != 1);
3655*35238bceSAndroid Build Coastguard Worker 
3656*35238bceSAndroid Build Coastguard Worker         if (m_config.render)
3657*35238bceSAndroid Build Coastguard Worker             m_threads[0]->addOperation(new GLES2ThreadTest::CopyTexSubImage2D(
3658*35238bceSAndroid Build Coastguard Worker                 texture, 0, 7, 7, 17, 17, 29, 29, m_config.useFenceSync, m_config.serverSync));
3659*35238bceSAndroid Build Coastguard Worker         else
3660*35238bceSAndroid Build Coastguard Worker             m_threads[1]->addOperation(new GLES2ThreadTest::CopyTexSubImage2D(
3661*35238bceSAndroid Build Coastguard Worker                 texture, 0, 7, 7, 17, 17, 29, 29, m_config.useFenceSync, m_config.serverSync));
3662*35238bceSAndroid Build Coastguard Worker     }
3663*35238bceSAndroid Build Coastguard Worker 
3664*35238bceSAndroid Build Coastguard Worker     if (m_config.modify == 3)
3665*35238bceSAndroid Build Coastguard Worker     {
3666*35238bceSAndroid Build Coastguard Worker         DE_ASSERT(m_config.define != 1);
3667*35238bceSAndroid Build Coastguard Worker 
3668*35238bceSAndroid Build Coastguard Worker         if (m_config.render)
3669*35238bceSAndroid Build Coastguard Worker             m_threads[0]->addOperation(new GLES2ThreadTest::TexImage2D(
3670*35238bceSAndroid Build Coastguard Worker                 texture, 0, GL_RGBA, 256, 256, GL_RGBA, GL_UNSIGNED_BYTE, m_config.useFenceSync, m_config.serverSync));
3671*35238bceSAndroid Build Coastguard Worker         else
3672*35238bceSAndroid Build Coastguard Worker             m_threads[1]->addOperation(new GLES2ThreadTest::TexImage2D(
3673*35238bceSAndroid Build Coastguard Worker                 texture, 0, GL_RGBA, 256, 256, GL_RGBA, GL_UNSIGNED_BYTE, m_config.useFenceSync, m_config.serverSync));
3674*35238bceSAndroid Build Coastguard Worker     }
3675*35238bceSAndroid Build Coastguard Worker 
3676*35238bceSAndroid Build Coastguard Worker     if (m_config.modify == 4)
3677*35238bceSAndroid Build Coastguard Worker     {
3678*35238bceSAndroid Build Coastguard Worker         DE_ASSERT(m_config.define != 1);
3679*35238bceSAndroid Build Coastguard Worker 
3680*35238bceSAndroid Build Coastguard Worker         if (m_config.render)
3681*35238bceSAndroid Build Coastguard Worker             m_threads[0]->addOperation(new GLES2ThreadTest::CopyTexImage2D(texture, 0, GL_RGBA, 7, 7, 256, 256, 0,
3682*35238bceSAndroid Build Coastguard Worker                                                                            m_config.useFenceSync, m_config.serverSync));
3683*35238bceSAndroid Build Coastguard Worker         else
3684*35238bceSAndroid Build Coastguard Worker             m_threads[1]->addOperation(new GLES2ThreadTest::CopyTexImage2D(texture, 0, GL_RGBA, 7, 7, 256, 256, 0,
3685*35238bceSAndroid Build Coastguard Worker                                                                            m_config.useFenceSync, m_config.serverSync));
3686*35238bceSAndroid Build Coastguard Worker     }
3687*35238bceSAndroid Build Coastguard Worker 
3688*35238bceSAndroid Build Coastguard Worker     if (m_config.render)
3689*35238bceSAndroid Build Coastguard Worker     {
3690*35238bceSAndroid Build Coastguard Worker         DE_ASSERT(m_config.define != 1);
3691*35238bceSAndroid Build Coastguard Worker 
3692*35238bceSAndroid Build Coastguard Worker         SharedPtr<tcu::ThreadUtil::DataBlock> pixels1;
3693*35238bceSAndroid Build Coastguard Worker         SharedPtr<tcu::ThreadUtil::DataBlock> pixels2;
3694*35238bceSAndroid Build Coastguard Worker 
3695*35238bceSAndroid Build Coastguard Worker         m_threads[0]->addOperation(
3696*35238bceSAndroid Build Coastguard Worker             new GLES2ThreadTest::RenderTexture(program, texture, m_config.useFenceSync, m_config.serverSync));
3697*35238bceSAndroid Build Coastguard Worker         m_threads[1]->addOperation(
3698*35238bceSAndroid Build Coastguard Worker             new GLES2ThreadTest::RenderTexture(program, texture, m_config.useFenceSync, m_config.serverSync));
3699*35238bceSAndroid Build Coastguard Worker 
3700*35238bceSAndroid Build Coastguard Worker         m_threads[0]->addOperation(new GLES2ThreadTest::ReadPixels(0, 0, 400, 400, GL_RGBA, GL_UNSIGNED_BYTE, pixels1,
3701*35238bceSAndroid Build Coastguard Worker                                                                    m_config.useFenceSync, m_config.serverSync));
3702*35238bceSAndroid Build Coastguard Worker         m_threads[1]->addOperation(new GLES2ThreadTest::ReadPixels(0, 0, 400, 400, GL_RGBA, GL_UNSIGNED_BYTE, pixels2,
3703*35238bceSAndroid Build Coastguard Worker                                                                    m_config.useFenceSync, m_config.serverSync));
3704*35238bceSAndroid Build Coastguard Worker 
3705*35238bceSAndroid Build Coastguard Worker         m_threads[0]->addOperation(new tcu::ThreadUtil::CompareData(pixels1, pixels2));
3706*35238bceSAndroid Build Coastguard Worker     }
3707*35238bceSAndroid Build Coastguard Worker 
3708*35238bceSAndroid Build Coastguard Worker     if (texture)
3709*35238bceSAndroid Build Coastguard Worker     {
3710*35238bceSAndroid Build Coastguard Worker         if (m_config.modify || m_config.render)
3711*35238bceSAndroid Build Coastguard Worker             m_threads[0]->addOperation(
3712*35238bceSAndroid Build Coastguard Worker                 new GLES2ThreadTest::DeleteTexture(texture, m_config.useFenceSync, m_config.serverSync));
3713*35238bceSAndroid Build Coastguard Worker         else
3714*35238bceSAndroid Build Coastguard Worker             m_threads[1]->addOperation(
3715*35238bceSAndroid Build Coastguard Worker                 new GLES2ThreadTest::DeleteTexture(texture, m_config.useFenceSync, m_config.serverSync));
3716*35238bceSAndroid Build Coastguard Worker     }
3717*35238bceSAndroid Build Coastguard Worker 
3718*35238bceSAndroid Build Coastguard Worker     if (m_config.modify || m_config.render)
3719*35238bceSAndroid Build Coastguard Worker         m_threads[0]->addOperation(
3720*35238bceSAndroid Build Coastguard Worker             new GLES2ThreadTest::DestroyImage(image, m_config.useFenceSync, m_config.serverSync));
3721*35238bceSAndroid Build Coastguard Worker     else
3722*35238bceSAndroid Build Coastguard Worker         m_threads[1]->addOperation(
3723*35238bceSAndroid Build Coastguard Worker             new GLES2ThreadTest::DestroyImage(image, m_config.useFenceSync, m_config.serverSync));
3724*35238bceSAndroid Build Coastguard Worker 
3725*35238bceSAndroid Build Coastguard Worker     if (m_config.render)
3726*35238bceSAndroid Build Coastguard Worker     {
3727*35238bceSAndroid Build Coastguard Worker         m_threads[0]->addOperation(
3728*35238bceSAndroid Build Coastguard Worker             new GLES2ThreadTest::DeleteShader(vertexShader, m_config.useFenceSync, m_config.serverSync));
3729*35238bceSAndroid Build Coastguard Worker         m_threads[0]->addOperation(
3730*35238bceSAndroid Build Coastguard Worker             new GLES2ThreadTest::DeleteShader(fragmentShader, m_config.useFenceSync, m_config.serverSync));
3731*35238bceSAndroid Build Coastguard Worker         m_threads[0]->addOperation(
3732*35238bceSAndroid Build Coastguard Worker             new GLES2ThreadTest::DeleteProgram(program, m_config.useFenceSync, m_config.serverSync));
3733*35238bceSAndroid Build Coastguard Worker     }
3734*35238bceSAndroid Build Coastguard Worker }
3735*35238bceSAndroid Build Coastguard Worker 
addShaderOperations(GLenum type)3736*35238bceSAndroid Build Coastguard Worker void GLES2ThreadedSharingTest::addShaderOperations(GLenum type)
3737*35238bceSAndroid Build Coastguard Worker {
3738*35238bceSAndroid Build Coastguard Worker     SharedPtr<GLES2ThreadTest::Shader> shader;
3739*35238bceSAndroid Build Coastguard Worker 
3740*35238bceSAndroid Build Coastguard Worker     m_threads[0]->addOperation(
3741*35238bceSAndroid Build Coastguard Worker         new GLES2ThreadTest::CreateShader(type, shader, m_config.useFenceSync, m_config.serverSync));
3742*35238bceSAndroid Build Coastguard Worker 
3743*35238bceSAndroid Build Coastguard Worker     if (m_config.define)
3744*35238bceSAndroid Build Coastguard Worker     {
3745*35238bceSAndroid Build Coastguard Worker         const char *vertexShaderSource = "attribute mediump vec4 a_pos;\n"
3746*35238bceSAndroid Build Coastguard Worker                                          "void main(void)\n"
3747*35238bceSAndroid Build Coastguard Worker                                          "{\n"
3748*35238bceSAndroid Build Coastguard Worker                                          "\tgl_Position = a_pos;\n"
3749*35238bceSAndroid Build Coastguard Worker                                          "}";
3750*35238bceSAndroid Build Coastguard Worker 
3751*35238bceSAndroid Build Coastguard Worker         const char *fragmentShaderSource = "void main(void)\n"
3752*35238bceSAndroid Build Coastguard Worker                                            "{\n"
3753*35238bceSAndroid Build Coastguard Worker                                            "\tgl_FragColor = vec4(1.0, 0.0, 0.0, 1.0);\n"
3754*35238bceSAndroid Build Coastguard Worker                                            "}";
3755*35238bceSAndroid Build Coastguard Worker 
3756*35238bceSAndroid Build Coastguard Worker         if (m_config.modify || m_config.render)
3757*35238bceSAndroid Build Coastguard Worker             m_threads[0]->addOperation(new GLES2ThreadTest::ShaderSource(
3758*35238bceSAndroid Build Coastguard Worker                 shader, (type == GL_VERTEX_SHADER ? vertexShaderSource : fragmentShaderSource), m_config.useFenceSync,
3759*35238bceSAndroid Build Coastguard Worker                 m_config.serverSync));
3760*35238bceSAndroid Build Coastguard Worker         else
3761*35238bceSAndroid Build Coastguard Worker             m_threads[1]->addOperation(new GLES2ThreadTest::ShaderSource(
3762*35238bceSAndroid Build Coastguard Worker                 shader, (type == GL_VERTEX_SHADER ? vertexShaderSource : fragmentShaderSource), m_config.useFenceSync,
3763*35238bceSAndroid Build Coastguard Worker                 m_config.serverSync));
3764*35238bceSAndroid Build Coastguard Worker     }
3765*35238bceSAndroid Build Coastguard Worker 
3766*35238bceSAndroid Build Coastguard Worker     if (m_config.modify)
3767*35238bceSAndroid Build Coastguard Worker     {
3768*35238bceSAndroid Build Coastguard Worker         if (m_config.render)
3769*35238bceSAndroid Build Coastguard Worker             m_threads[0]->addOperation(
3770*35238bceSAndroid Build Coastguard Worker                 new GLES2ThreadTest::ShaderCompile(shader, m_config.useFenceSync, m_config.serverSync));
3771*35238bceSAndroid Build Coastguard Worker         else
3772*35238bceSAndroid Build Coastguard Worker             m_threads[1]->addOperation(
3773*35238bceSAndroid Build Coastguard Worker                 new GLES2ThreadTest::ShaderCompile(shader, m_config.useFenceSync, m_config.serverSync));
3774*35238bceSAndroid Build Coastguard Worker     }
3775*35238bceSAndroid Build Coastguard Worker 
3776*35238bceSAndroid Build Coastguard Worker     DE_ASSERT(!m_config.render);
3777*35238bceSAndroid Build Coastguard Worker 
3778*35238bceSAndroid Build Coastguard Worker     if (m_config.modify || m_config.render)
3779*35238bceSAndroid Build Coastguard Worker         m_threads[0]->addOperation(
3780*35238bceSAndroid Build Coastguard Worker             new GLES2ThreadTest::DeleteShader(shader, m_config.useFenceSync, m_config.serverSync));
3781*35238bceSAndroid Build Coastguard Worker     else
3782*35238bceSAndroid Build Coastguard Worker         m_threads[1]->addOperation(
3783*35238bceSAndroid Build Coastguard Worker             new GLES2ThreadTest::DeleteShader(shader, m_config.useFenceSync, m_config.serverSync));
3784*35238bceSAndroid Build Coastguard Worker }
3785*35238bceSAndroid Build Coastguard Worker 
addProgramOperations(void)3786*35238bceSAndroid Build Coastguard Worker void GLES2ThreadedSharingTest::addProgramOperations(void)
3787*35238bceSAndroid Build Coastguard Worker {
3788*35238bceSAndroid Build Coastguard Worker     // Add operations for verify
3789*35238bceSAndroid Build Coastguard Worker     SharedPtr<GLES2ThreadTest::Shader> vertexShader;
3790*35238bceSAndroid Build Coastguard Worker     SharedPtr<GLES2ThreadTest::Shader> fragmentShader;
3791*35238bceSAndroid Build Coastguard Worker 
3792*35238bceSAndroid Build Coastguard Worker     if (m_config.define)
3793*35238bceSAndroid Build Coastguard Worker     {
3794*35238bceSAndroid Build Coastguard Worker         const char *vertexShaderSource = "attribute highp vec2 a_pos;\n"
3795*35238bceSAndroid Build Coastguard Worker                                          "varying mediump vec2 v_pos;\n"
3796*35238bceSAndroid Build Coastguard Worker                                          "void main(void)\n"
3797*35238bceSAndroid Build Coastguard Worker                                          "{\n"
3798*35238bceSAndroid Build Coastguard Worker                                          "\tv_pos = a_pos;\n"
3799*35238bceSAndroid Build Coastguard Worker                                          "\tgl_Position = vec4(a_pos, 0.0, 1.0);\n"
3800*35238bceSAndroid Build Coastguard Worker                                          "}\n";
3801*35238bceSAndroid Build Coastguard Worker 
3802*35238bceSAndroid Build Coastguard Worker         const char *fragmentShaderSource = "varying mediump vec2 v_pos;\n"
3803*35238bceSAndroid Build Coastguard Worker                                            "void main(void)\n"
3804*35238bceSAndroid Build Coastguard Worker                                            "{\n"
3805*35238bceSAndroid Build Coastguard Worker                                            "\tgl_FragColor = vec4(v_pos, 0.5, 1.0);\n"
3806*35238bceSAndroid Build Coastguard Worker                                            "}\n";
3807*35238bceSAndroid Build Coastguard Worker 
3808*35238bceSAndroid Build Coastguard Worker         m_threads[0]->addOperation(new GLES2ThreadTest::CreateShader(GL_VERTEX_SHADER, vertexShader,
3809*35238bceSAndroid Build Coastguard Worker                                                                      m_config.useFenceSync, m_config.serverSync));
3810*35238bceSAndroid Build Coastguard Worker         m_threads[0]->addOperation(new GLES2ThreadTest::ShaderSource(vertexShader, vertexShaderSource,
3811*35238bceSAndroid Build Coastguard Worker                                                                      m_config.useFenceSync, m_config.serverSync));
3812*35238bceSAndroid Build Coastguard Worker         m_threads[0]->addOperation(
3813*35238bceSAndroid Build Coastguard Worker             new GLES2ThreadTest::ShaderCompile(vertexShader, m_config.useFenceSync, m_config.serverSync));
3814*35238bceSAndroid Build Coastguard Worker 
3815*35238bceSAndroid Build Coastguard Worker         m_threads[0]->addOperation(new GLES2ThreadTest::CreateShader(GL_FRAGMENT_SHADER, fragmentShader,
3816*35238bceSAndroid Build Coastguard Worker                                                                      m_config.useFenceSync, m_config.serverSync));
3817*35238bceSAndroid Build Coastguard Worker         m_threads[0]->addOperation(new GLES2ThreadTest::ShaderSource(fragmentShader, fragmentShaderSource,
3818*35238bceSAndroid Build Coastguard Worker                                                                      m_config.useFenceSync, m_config.serverSync));
3819*35238bceSAndroid Build Coastguard Worker         m_threads[0]->addOperation(
3820*35238bceSAndroid Build Coastguard Worker             new GLES2ThreadTest::ShaderCompile(fragmentShader, m_config.useFenceSync, m_config.serverSync));
3821*35238bceSAndroid Build Coastguard Worker     }
3822*35238bceSAndroid Build Coastguard Worker 
3823*35238bceSAndroid Build Coastguard Worker     SharedPtr<GLES2ThreadTest::Program> program;
3824*35238bceSAndroid Build Coastguard Worker 
3825*35238bceSAndroid Build Coastguard Worker     m_threads[0]->addOperation(new GLES2ThreadTest::CreateProgram(program, m_config.useFenceSync, m_config.serverSync));
3826*35238bceSAndroid Build Coastguard Worker 
3827*35238bceSAndroid Build Coastguard Worker     if (m_config.define)
3828*35238bceSAndroid Build Coastguard Worker     {
3829*35238bceSAndroid Build Coastguard Worker         // Attach shaders
3830*35238bceSAndroid Build Coastguard Worker         if (m_config.modify || m_config.render)
3831*35238bceSAndroid Build Coastguard Worker         {
3832*35238bceSAndroid Build Coastguard Worker             m_threads[0]->addOperation(
3833*35238bceSAndroid Build Coastguard Worker                 new GLES2ThreadTest::AttachShader(program, vertexShader, m_config.useFenceSync, m_config.serverSync));
3834*35238bceSAndroid Build Coastguard Worker             m_threads[0]->addOperation(
3835*35238bceSAndroid Build Coastguard Worker                 new GLES2ThreadTest::AttachShader(program, fragmentShader, m_config.useFenceSync, m_config.serverSync));
3836*35238bceSAndroid Build Coastguard Worker         }
3837*35238bceSAndroid Build Coastguard Worker         else
3838*35238bceSAndroid Build Coastguard Worker         {
3839*35238bceSAndroid Build Coastguard Worker             m_threads[1]->addOperation(
3840*35238bceSAndroid Build Coastguard Worker                 new GLES2ThreadTest::AttachShader(program, vertexShader, m_config.useFenceSync, m_config.serverSync));
3841*35238bceSAndroid Build Coastguard Worker             m_threads[1]->addOperation(
3842*35238bceSAndroid Build Coastguard Worker                 new GLES2ThreadTest::AttachShader(program, fragmentShader, m_config.useFenceSync, m_config.serverSync));
3843*35238bceSAndroid Build Coastguard Worker         }
3844*35238bceSAndroid Build Coastguard Worker     }
3845*35238bceSAndroid Build Coastguard Worker 
3846*35238bceSAndroid Build Coastguard Worker     if (m_config.modify == 1)
3847*35238bceSAndroid Build Coastguard Worker     {
3848*35238bceSAndroid Build Coastguard Worker         // Link program
3849*35238bceSAndroid Build Coastguard Worker         if (m_config.render)
3850*35238bceSAndroid Build Coastguard Worker             m_threads[0]->addOperation(
3851*35238bceSAndroid Build Coastguard Worker                 new GLES2ThreadTest::LinkProgram(program, m_config.useFenceSync, m_config.serverSync));
3852*35238bceSAndroid Build Coastguard Worker         else
3853*35238bceSAndroid Build Coastguard Worker             m_threads[1]->addOperation(
3854*35238bceSAndroid Build Coastguard Worker                 new GLES2ThreadTest::LinkProgram(program, m_config.useFenceSync, m_config.serverSync));
3855*35238bceSAndroid Build Coastguard Worker     }
3856*35238bceSAndroid Build Coastguard Worker 
3857*35238bceSAndroid Build Coastguard Worker     if (m_config.modify == 2)
3858*35238bceSAndroid Build Coastguard Worker     {
3859*35238bceSAndroid Build Coastguard Worker         // Link program
3860*35238bceSAndroid Build Coastguard Worker         if (m_config.render)
3861*35238bceSAndroid Build Coastguard Worker         {
3862*35238bceSAndroid Build Coastguard Worker             m_threads[0]->addOperation(new GLES2ThreadTest::DetachShader(program, GL_VERTEX_SHADER,
3863*35238bceSAndroid Build Coastguard Worker                                                                          m_config.useFenceSync, m_config.serverSync));
3864*35238bceSAndroid Build Coastguard Worker             m_threads[0]->addOperation(new GLES2ThreadTest::DetachShader(program, GL_FRAGMENT_SHADER,
3865*35238bceSAndroid Build Coastguard Worker                                                                          m_config.useFenceSync, m_config.serverSync));
3866*35238bceSAndroid Build Coastguard Worker         }
3867*35238bceSAndroid Build Coastguard Worker         else
3868*35238bceSAndroid Build Coastguard Worker         {
3869*35238bceSAndroid Build Coastguard Worker             m_threads[1]->addOperation(new GLES2ThreadTest::DetachShader(program, GL_VERTEX_SHADER,
3870*35238bceSAndroid Build Coastguard Worker                                                                          m_config.useFenceSync, m_config.serverSync));
3871*35238bceSAndroid Build Coastguard Worker             m_threads[1]->addOperation(new GLES2ThreadTest::DetachShader(program, GL_FRAGMENT_SHADER,
3872*35238bceSAndroid Build Coastguard Worker                                                                          m_config.useFenceSync, m_config.serverSync));
3873*35238bceSAndroid Build Coastguard Worker         }
3874*35238bceSAndroid Build Coastguard Worker     }
3875*35238bceSAndroid Build Coastguard Worker 
3876*35238bceSAndroid Build Coastguard Worker     if (m_config.render)
3877*35238bceSAndroid Build Coastguard Worker     {
3878*35238bceSAndroid Build Coastguard Worker         DE_ASSERT(false);
3879*35238bceSAndroid Build Coastguard Worker     }
3880*35238bceSAndroid Build Coastguard Worker 
3881*35238bceSAndroid Build Coastguard Worker     if (m_config.modify || m_config.render)
3882*35238bceSAndroid Build Coastguard Worker         m_threads[0]->addOperation(
3883*35238bceSAndroid Build Coastguard Worker             new GLES2ThreadTest::DeleteProgram(program, m_config.useFenceSync, m_config.serverSync));
3884*35238bceSAndroid Build Coastguard Worker     else
3885*35238bceSAndroid Build Coastguard Worker         m_threads[1]->addOperation(
3886*35238bceSAndroid Build Coastguard Worker             new GLES2ThreadTest::DeleteProgram(program, m_config.useFenceSync, m_config.serverSync));
3887*35238bceSAndroid Build Coastguard Worker 
3888*35238bceSAndroid Build Coastguard Worker     if (m_config.render)
3889*35238bceSAndroid Build Coastguard Worker     {
3890*35238bceSAndroid Build Coastguard Worker         m_threads[0]->addOperation(
3891*35238bceSAndroid Build Coastguard Worker             new GLES2ThreadTest::DeleteShader(vertexShader, m_config.useFenceSync, m_config.serverSync));
3892*35238bceSAndroid Build Coastguard Worker         m_threads[0]->addOperation(
3893*35238bceSAndroid Build Coastguard Worker             new GLES2ThreadTest::DeleteShader(fragmentShader, m_config.useFenceSync, m_config.serverSync));
3894*35238bceSAndroid Build Coastguard Worker     }
3895*35238bceSAndroid Build Coastguard Worker }
3896*35238bceSAndroid Build Coastguard Worker 
deinit(void)3897*35238bceSAndroid Build Coastguard Worker void GLES2ThreadedSharingTest::deinit(void)
3898*35238bceSAndroid Build Coastguard Worker {
3899*35238bceSAndroid Build Coastguard Worker     for (int threadNdx = 0; threadNdx < (int)m_threads.size(); threadNdx++)
3900*35238bceSAndroid Build Coastguard Worker     {
3901*35238bceSAndroid Build Coastguard Worker         delete m_threads[threadNdx];
3902*35238bceSAndroid Build Coastguard Worker         m_threads[threadNdx] = DE_NULL;
3903*35238bceSAndroid Build Coastguard Worker     }
3904*35238bceSAndroid Build Coastguard Worker 
3905*35238bceSAndroid Build Coastguard Worker     m_threads.clear();
3906*35238bceSAndroid Build Coastguard Worker 
3907*35238bceSAndroid Build Coastguard Worker     if (m_eglDisplay != EGL_NO_DISPLAY)
3908*35238bceSAndroid Build Coastguard Worker     {
3909*35238bceSAndroid Build Coastguard Worker         m_eglTestCtx.getLibrary().terminate(m_eglDisplay);
3910*35238bceSAndroid Build Coastguard Worker         m_eglDisplay = EGL_NO_DISPLAY;
3911*35238bceSAndroid Build Coastguard Worker     }
3912*35238bceSAndroid Build Coastguard Worker 
3913*35238bceSAndroid Build Coastguard Worker     TCU_CHECK(!m_requiresRestart);
3914*35238bceSAndroid Build Coastguard Worker }
3915*35238bceSAndroid Build Coastguard Worker 
iterate(void)3916*35238bceSAndroid Build Coastguard Worker tcu::TestCase::IterateResult GLES2ThreadedSharingTest::iterate(void)
3917*35238bceSAndroid Build Coastguard Worker {
3918*35238bceSAndroid Build Coastguard Worker     if (!m_threadsStarted)
3919*35238bceSAndroid Build Coastguard Worker     {
3920*35238bceSAndroid Build Coastguard Worker         m_beginTimeUs = deGetMicroseconds();
3921*35238bceSAndroid Build Coastguard Worker 
3922*35238bceSAndroid Build Coastguard Worker         // Execute threads
3923*35238bceSAndroid Build Coastguard Worker         for (int threadNdx = 0; threadNdx < (int)m_threads.size(); threadNdx++)
3924*35238bceSAndroid Build Coastguard Worker             m_threads[threadNdx]->exec();
3925*35238bceSAndroid Build Coastguard Worker 
3926*35238bceSAndroid Build Coastguard Worker         m_threadsStarted = true;
3927*35238bceSAndroid Build Coastguard Worker         m_threadsRunning = true;
3928*35238bceSAndroid Build Coastguard Worker     }
3929*35238bceSAndroid Build Coastguard Worker 
3930*35238bceSAndroid Build Coastguard Worker     if (m_threadsRunning)
3931*35238bceSAndroid Build Coastguard Worker     {
3932*35238bceSAndroid Build Coastguard Worker         // Wait threads to finish
3933*35238bceSAndroid Build Coastguard Worker         int readyThreads = 0;
3934*35238bceSAndroid Build Coastguard Worker         for (int threadNdx = 0; threadNdx < (int)m_threads.size(); threadNdx++)
3935*35238bceSAndroid Build Coastguard Worker         {
3936*35238bceSAndroid Build Coastguard Worker             const tcu::ThreadUtil::Thread::ThreadStatus status = m_threads[threadNdx]->getStatus();
3937*35238bceSAndroid Build Coastguard Worker 
3938*35238bceSAndroid Build Coastguard Worker             if (status != tcu::ThreadUtil::Thread::THREADSTATUS_RUNNING &&
3939*35238bceSAndroid Build Coastguard Worker                 status != tcu::ThreadUtil::Thread::THREADSTATUS_NOT_STARTED)
3940*35238bceSAndroid Build Coastguard Worker                 readyThreads++;
3941*35238bceSAndroid Build Coastguard Worker         }
3942*35238bceSAndroid Build Coastguard Worker 
3943*35238bceSAndroid Build Coastguard Worker         if (readyThreads == (int)m_threads.size())
3944*35238bceSAndroid Build Coastguard Worker         {
3945*35238bceSAndroid Build Coastguard Worker             for (int threadNdx = 0; threadNdx < (int)m_threads.size(); threadNdx++)
3946*35238bceSAndroid Build Coastguard Worker                 m_threads[threadNdx]->join();
3947*35238bceSAndroid Build Coastguard Worker 
3948*35238bceSAndroid Build Coastguard Worker             m_executionReady  = true;
3949*35238bceSAndroid Build Coastguard Worker             m_requiresRestart = false;
3950*35238bceSAndroid Build Coastguard Worker         }
3951*35238bceSAndroid Build Coastguard Worker 
3952*35238bceSAndroid Build Coastguard Worker         if (deGetMicroseconds() - m_beginTimeUs > m_timeOutUs)
3953*35238bceSAndroid Build Coastguard Worker         {
3954*35238bceSAndroid Build Coastguard Worker             for (int threadNdx = 0; threadNdx < (int)m_threads.size(); threadNdx++)
3955*35238bceSAndroid Build Coastguard Worker             {
3956*35238bceSAndroid Build Coastguard Worker                 if (m_threads[threadNdx]->getStatus() != tcu::ThreadUtil::Thread::THREADSTATUS_RUNNING)
3957*35238bceSAndroid Build Coastguard Worker                     m_threads[threadNdx]->join();
3958*35238bceSAndroid Build Coastguard Worker             }
3959*35238bceSAndroid Build Coastguard Worker             m_executionReady  = true;
3960*35238bceSAndroid Build Coastguard Worker             m_requiresRestart = true;
3961*35238bceSAndroid Build Coastguard Worker             m_timeOutTimeUs   = deGetMicroseconds();
3962*35238bceSAndroid Build Coastguard Worker         }
3963*35238bceSAndroid Build Coastguard Worker         else
3964*35238bceSAndroid Build Coastguard Worker         {
3965*35238bceSAndroid Build Coastguard Worker             deSleep(m_sleepTimeMs);
3966*35238bceSAndroid Build Coastguard Worker         }
3967*35238bceSAndroid Build Coastguard Worker     }
3968*35238bceSAndroid Build Coastguard Worker 
3969*35238bceSAndroid Build Coastguard Worker     if (m_executionReady)
3970*35238bceSAndroid Build Coastguard Worker     {
3971*35238bceSAndroid Build Coastguard Worker         std::vector<int> indices(m_threads.size(), 0);
3972*35238bceSAndroid Build Coastguard Worker 
3973*35238bceSAndroid Build Coastguard Worker         if (m_timeOutTimeUs != 0)
3974*35238bceSAndroid Build Coastguard Worker             m_log << tcu::TestLog::Message
3975*35238bceSAndroid Build Coastguard Worker                   << "Execution timeout limit reached. Trying to get per thread logs. This is potentially dangerous."
3976*35238bceSAndroid Build Coastguard Worker                   << tcu::TestLog::EndMessage;
3977*35238bceSAndroid Build Coastguard Worker 
3978*35238bceSAndroid Build Coastguard Worker         while (true)
3979*35238bceSAndroid Build Coastguard Worker         {
3980*35238bceSAndroid Build Coastguard Worker             int firstThread = -1;
3981*35238bceSAndroid Build Coastguard Worker 
3982*35238bceSAndroid Build Coastguard Worker             // Find first thread with messages
3983*35238bceSAndroid Build Coastguard Worker             for (int threadNdx = 0; threadNdx < (int)m_threads.size(); threadNdx++)
3984*35238bceSAndroid Build Coastguard Worker             {
3985*35238bceSAndroid Build Coastguard Worker                 if (m_threads[threadNdx]->getMessageCount() > indices[threadNdx])
3986*35238bceSAndroid Build Coastguard Worker                 {
3987*35238bceSAndroid Build Coastguard Worker                     firstThread = threadNdx;
3988*35238bceSAndroid Build Coastguard Worker                     break;
3989*35238bceSAndroid Build Coastguard Worker                 }
3990*35238bceSAndroid Build Coastguard Worker             }
3991*35238bceSAndroid Build Coastguard Worker 
3992*35238bceSAndroid Build Coastguard Worker             // No more messages
3993*35238bceSAndroid Build Coastguard Worker             if (firstThread == -1)
3994*35238bceSAndroid Build Coastguard Worker                 break;
3995*35238bceSAndroid Build Coastguard Worker 
3996*35238bceSAndroid Build Coastguard Worker             for (int threadNdx = 0; threadNdx < (int)m_threads.size(); threadNdx++)
3997*35238bceSAndroid Build Coastguard Worker             {
3998*35238bceSAndroid Build Coastguard Worker                 // No more messages in this thread
3999*35238bceSAndroid Build Coastguard Worker                 if (m_threads[threadNdx]->getMessageCount() <= indices[threadNdx])
4000*35238bceSAndroid Build Coastguard Worker                     continue;
4001*35238bceSAndroid Build Coastguard Worker 
4002*35238bceSAndroid Build Coastguard Worker                 if ((m_threads[threadNdx]->getMessage(indices[threadNdx]).getTime() - m_beginTimeUs) <
4003*35238bceSAndroid Build Coastguard Worker                     (m_threads[firstThread]->getMessage(indices[firstThread]).getTime() - m_beginTimeUs))
4004*35238bceSAndroid Build Coastguard Worker                     firstThread = threadNdx;
4005*35238bceSAndroid Build Coastguard Worker             }
4006*35238bceSAndroid Build Coastguard Worker 
4007*35238bceSAndroid Build Coastguard Worker             tcu::ThreadUtil::Message message = m_threads[firstThread]->getMessage(indices[firstThread]);
4008*35238bceSAndroid Build Coastguard Worker 
4009*35238bceSAndroid Build Coastguard Worker             m_log << tcu::TestLog::Message << "[" << (message.getTime() - m_beginTimeUs) << "] (" << firstThread << ") "
4010*35238bceSAndroid Build Coastguard Worker                   << message.getMessage() << tcu::TestLog::EndMessage;
4011*35238bceSAndroid Build Coastguard Worker             indices[firstThread]++;
4012*35238bceSAndroid Build Coastguard Worker         }
4013*35238bceSAndroid Build Coastguard Worker 
4014*35238bceSAndroid Build Coastguard Worker         if (m_timeOutTimeUs != 0)
4015*35238bceSAndroid Build Coastguard Worker             m_log << tcu::TestLog::Message << "[" << (m_timeOutTimeUs - m_beginTimeUs)
4016*35238bceSAndroid Build Coastguard Worker                   << "] Execution timeout limit reached" << tcu::TestLog::EndMessage;
4017*35238bceSAndroid Build Coastguard Worker 
4018*35238bceSAndroid Build Coastguard Worker         bool isOk         = true;
4019*35238bceSAndroid Build Coastguard Worker         bool notSupported = false;
4020*35238bceSAndroid Build Coastguard Worker 
4021*35238bceSAndroid Build Coastguard Worker         for (int threadNdx = 0; threadNdx < (int)m_threads.size(); threadNdx++)
4022*35238bceSAndroid Build Coastguard Worker         {
4023*35238bceSAndroid Build Coastguard Worker             const tcu::ThreadUtil::Thread::ThreadStatus status = m_threads[threadNdx]->getStatus();
4024*35238bceSAndroid Build Coastguard Worker 
4025*35238bceSAndroid Build Coastguard Worker             switch (status)
4026*35238bceSAndroid Build Coastguard Worker             {
4027*35238bceSAndroid Build Coastguard Worker             case tcu::ThreadUtil::Thread::THREADSTATUS_FAILED:
4028*35238bceSAndroid Build Coastguard Worker             case tcu::ThreadUtil::Thread::THREADSTATUS_INIT_FAILED:
4029*35238bceSAndroid Build Coastguard Worker             case tcu::ThreadUtil::Thread::THREADSTATUS_RUNNING:
4030*35238bceSAndroid Build Coastguard Worker                 isOk = false;
4031*35238bceSAndroid Build Coastguard Worker                 break;
4032*35238bceSAndroid Build Coastguard Worker 
4033*35238bceSAndroid Build Coastguard Worker             case tcu::ThreadUtil::Thread::THREADSTATUS_NOT_SUPPORTED:
4034*35238bceSAndroid Build Coastguard Worker                 notSupported = true;
4035*35238bceSAndroid Build Coastguard Worker                 break;
4036*35238bceSAndroid Build Coastguard Worker 
4037*35238bceSAndroid Build Coastguard Worker             case tcu::ThreadUtil::Thread::THREADSTATUS_READY:
4038*35238bceSAndroid Build Coastguard Worker                 // Nothing
4039*35238bceSAndroid Build Coastguard Worker                 break;
4040*35238bceSAndroid Build Coastguard Worker 
4041*35238bceSAndroid Build Coastguard Worker             default:
4042*35238bceSAndroid Build Coastguard Worker                 DE_ASSERT(false);
4043*35238bceSAndroid Build Coastguard Worker                 isOk = false;
4044*35238bceSAndroid Build Coastguard Worker             }
4045*35238bceSAndroid Build Coastguard Worker         }
4046*35238bceSAndroid Build Coastguard Worker 
4047*35238bceSAndroid Build Coastguard Worker         if (notSupported)
4048*35238bceSAndroid Build Coastguard Worker             throw tcu::NotSupportedError("Thread threw tcu::NotSupportedError", "", __FILE__, __LINE__);
4049*35238bceSAndroid Build Coastguard Worker 
4050*35238bceSAndroid Build Coastguard Worker         if (isOk)
4051*35238bceSAndroid Build Coastguard Worker             m_testCtx.setTestResult(QP_TEST_RESULT_PASS, "Pass");
4052*35238bceSAndroid Build Coastguard Worker         else
4053*35238bceSAndroid Build Coastguard Worker             m_testCtx.setTestResult(QP_TEST_RESULT_FAIL, "Fail");
4054*35238bceSAndroid Build Coastguard Worker 
4055*35238bceSAndroid Build Coastguard Worker         return STOP;
4056*35238bceSAndroid Build Coastguard Worker     }
4057*35238bceSAndroid Build Coastguard Worker 
4058*35238bceSAndroid Build Coastguard Worker     return CONTINUE;
4059*35238bceSAndroid Build Coastguard Worker }
4060*35238bceSAndroid Build Coastguard Worker 
addSimpleTests(EglTestContext & ctx,tcu::TestCaseGroup * group,bool useSync,bool serverSync)4061*35238bceSAndroid Build Coastguard Worker static void addSimpleTests(EglTestContext &ctx, tcu::TestCaseGroup *group, bool useSync, bool serverSync)
4062*35238bceSAndroid Build Coastguard Worker {
4063*35238bceSAndroid Build Coastguard Worker     {
4064*35238bceSAndroid Build Coastguard Worker         TestCaseGroup *bufferTests = new TestCaseGroup(ctx, "buffers", "Buffer management tests");
4065*35238bceSAndroid Build Coastguard Worker 
4066*35238bceSAndroid Build Coastguard Worker         {
4067*35238bceSAndroid Build Coastguard Worker             GLES2ThreadedSharingTest::TestConfig config;
4068*35238bceSAndroid Build Coastguard Worker 
4069*35238bceSAndroid Build Coastguard Worker             config.resourceType = GLES2ThreadedSharingTest::TestConfig::RESOURCETYPE_BUFFER;
4070*35238bceSAndroid Build Coastguard Worker             config.useFenceSync = useSync;
4071*35238bceSAndroid Build Coastguard Worker             config.serverSync   = serverSync;
4072*35238bceSAndroid Build Coastguard Worker             config.define       = 0;
4073*35238bceSAndroid Build Coastguard Worker             config.modify       = 0;
4074*35238bceSAndroid Build Coastguard Worker             config.render       = false;
4075*35238bceSAndroid Build Coastguard Worker             bufferTests->addChild(
4076*35238bceSAndroid Build Coastguard Worker                 new GLES2ThreadedSharingTest(ctx, config, "gen_delete", "Generate and delete buffer"));
4077*35238bceSAndroid Build Coastguard Worker         }
4078*35238bceSAndroid Build Coastguard Worker 
4079*35238bceSAndroid Build Coastguard Worker         {
4080*35238bceSAndroid Build Coastguard Worker             GLES2ThreadedSharingTest::TestConfig config;
4081*35238bceSAndroid Build Coastguard Worker 
4082*35238bceSAndroid Build Coastguard Worker             config.resourceType = GLES2ThreadedSharingTest::TestConfig::RESOURCETYPE_BUFFER;
4083*35238bceSAndroid Build Coastguard Worker             config.useFenceSync = useSync;
4084*35238bceSAndroid Build Coastguard Worker             config.serverSync   = serverSync;
4085*35238bceSAndroid Build Coastguard Worker             config.define       = 1;
4086*35238bceSAndroid Build Coastguard Worker             config.modify       = 0;
4087*35238bceSAndroid Build Coastguard Worker             config.render       = false;
4088*35238bceSAndroid Build Coastguard Worker             bufferTests->addChild(
4089*35238bceSAndroid Build Coastguard Worker                 new GLES2ThreadedSharingTest(ctx, config, "bufferdata", "Generate, set data and delete buffer"));
4090*35238bceSAndroid Build Coastguard Worker         }
4091*35238bceSAndroid Build Coastguard Worker 
4092*35238bceSAndroid Build Coastguard Worker         {
4093*35238bceSAndroid Build Coastguard Worker             GLES2ThreadedSharingTest::TestConfig config;
4094*35238bceSAndroid Build Coastguard Worker 
4095*35238bceSAndroid Build Coastguard Worker             config.resourceType = GLES2ThreadedSharingTest::TestConfig::RESOURCETYPE_BUFFER;
4096*35238bceSAndroid Build Coastguard Worker             config.useFenceSync = useSync;
4097*35238bceSAndroid Build Coastguard Worker             config.serverSync   = serverSync;
4098*35238bceSAndroid Build Coastguard Worker             config.define       = 1;
4099*35238bceSAndroid Build Coastguard Worker             config.modify       = 1;
4100*35238bceSAndroid Build Coastguard Worker             config.render       = false;
4101*35238bceSAndroid Build Coastguard Worker             bufferTests->addChild(new GLES2ThreadedSharingTest(ctx, config, "buffersubdata",
4102*35238bceSAndroid Build Coastguard Worker                                                                "Generate, set data, update data and delete buffer"));
4103*35238bceSAndroid Build Coastguard Worker         }
4104*35238bceSAndroid Build Coastguard Worker 
4105*35238bceSAndroid Build Coastguard Worker         {
4106*35238bceSAndroid Build Coastguard Worker             GLES2ThreadedSharingTest::TestConfig config;
4107*35238bceSAndroid Build Coastguard Worker 
4108*35238bceSAndroid Build Coastguard Worker             config.resourceType = GLES2ThreadedSharingTest::TestConfig::RESOURCETYPE_BUFFER;
4109*35238bceSAndroid Build Coastguard Worker             config.useFenceSync = useSync;
4110*35238bceSAndroid Build Coastguard Worker             config.serverSync   = serverSync;
4111*35238bceSAndroid Build Coastguard Worker             config.define       = 1;
4112*35238bceSAndroid Build Coastguard Worker             config.modify       = 0;
4113*35238bceSAndroid Build Coastguard Worker             config.render       = true;
4114*35238bceSAndroid Build Coastguard Worker             bufferTests->addChild(new GLES2ThreadedSharingTest(ctx, config, "bufferdata_render",
4115*35238bceSAndroid Build Coastguard Worker                                                                "Generate, set data, render and delete buffer"));
4116*35238bceSAndroid Build Coastguard Worker         }
4117*35238bceSAndroid Build Coastguard Worker 
4118*35238bceSAndroid Build Coastguard Worker         {
4119*35238bceSAndroid Build Coastguard Worker             GLES2ThreadedSharingTest::TestConfig config;
4120*35238bceSAndroid Build Coastguard Worker 
4121*35238bceSAndroid Build Coastguard Worker             config.resourceType = GLES2ThreadedSharingTest::TestConfig::RESOURCETYPE_BUFFER;
4122*35238bceSAndroid Build Coastguard Worker             config.useFenceSync = useSync;
4123*35238bceSAndroid Build Coastguard Worker             config.serverSync   = serverSync;
4124*35238bceSAndroid Build Coastguard Worker             config.define       = 1;
4125*35238bceSAndroid Build Coastguard Worker             config.modify       = 1;
4126*35238bceSAndroid Build Coastguard Worker             config.render       = true;
4127*35238bceSAndroid Build Coastguard Worker             bufferTests->addChild(new GLES2ThreadedSharingTest(
4128*35238bceSAndroid Build Coastguard Worker                 ctx, config, "buffersubdata_render", "Generate, set data, update data, render and delete buffer"));
4129*35238bceSAndroid Build Coastguard Worker         }
4130*35238bceSAndroid Build Coastguard Worker 
4131*35238bceSAndroid Build Coastguard Worker         group->addChild(bufferTests);
4132*35238bceSAndroid Build Coastguard Worker     }
4133*35238bceSAndroid Build Coastguard Worker 
4134*35238bceSAndroid Build Coastguard Worker     {
4135*35238bceSAndroid Build Coastguard Worker         TestCaseGroup *textureTests = new TestCaseGroup(ctx, "textures", "Texture management tests");
4136*35238bceSAndroid Build Coastguard Worker 
4137*35238bceSAndroid Build Coastguard Worker         {
4138*35238bceSAndroid Build Coastguard Worker             GLES2ThreadedSharingTest::TestConfig config;
4139*35238bceSAndroid Build Coastguard Worker 
4140*35238bceSAndroid Build Coastguard Worker             config.resourceType = GLES2ThreadedSharingTest::TestConfig::RESOURCETYPE_TEXTURE;
4141*35238bceSAndroid Build Coastguard Worker             config.useFenceSync = useSync;
4142*35238bceSAndroid Build Coastguard Worker             config.serverSync   = serverSync;
4143*35238bceSAndroid Build Coastguard Worker             config.define       = 0;
4144*35238bceSAndroid Build Coastguard Worker             config.modify       = 0;
4145*35238bceSAndroid Build Coastguard Worker             config.render       = false;
4146*35238bceSAndroid Build Coastguard Worker             textureTests->addChild(
4147*35238bceSAndroid Build Coastguard Worker                 new GLES2ThreadedSharingTest(ctx, config, "gen_delete", "Generate and delete texture"));
4148*35238bceSAndroid Build Coastguard Worker         }
4149*35238bceSAndroid Build Coastguard Worker 
4150*35238bceSAndroid Build Coastguard Worker         {
4151*35238bceSAndroid Build Coastguard Worker             GLES2ThreadedSharingTest::TestConfig config;
4152*35238bceSAndroid Build Coastguard Worker 
4153*35238bceSAndroid Build Coastguard Worker             config.resourceType = GLES2ThreadedSharingTest::TestConfig::RESOURCETYPE_TEXTURE;
4154*35238bceSAndroid Build Coastguard Worker             config.useFenceSync = useSync;
4155*35238bceSAndroid Build Coastguard Worker             config.serverSync   = serverSync;
4156*35238bceSAndroid Build Coastguard Worker             config.define       = 1;
4157*35238bceSAndroid Build Coastguard Worker             config.modify       = 0;
4158*35238bceSAndroid Build Coastguard Worker             config.render       = false;
4159*35238bceSAndroid Build Coastguard Worker             textureTests->addChild(
4160*35238bceSAndroid Build Coastguard Worker                 new GLES2ThreadedSharingTest(ctx, config, "teximage2d", "Generate, set data and delete texture"));
4161*35238bceSAndroid Build Coastguard Worker         }
4162*35238bceSAndroid Build Coastguard Worker 
4163*35238bceSAndroid Build Coastguard Worker         {
4164*35238bceSAndroid Build Coastguard Worker             GLES2ThreadedSharingTest::TestConfig config;
4165*35238bceSAndroid Build Coastguard Worker 
4166*35238bceSAndroid Build Coastguard Worker             config.resourceType = GLES2ThreadedSharingTest::TestConfig::RESOURCETYPE_TEXTURE;
4167*35238bceSAndroid Build Coastguard Worker             config.useFenceSync = useSync;
4168*35238bceSAndroid Build Coastguard Worker             config.serverSync   = serverSync;
4169*35238bceSAndroid Build Coastguard Worker             config.define       = 1;
4170*35238bceSAndroid Build Coastguard Worker             config.modify       = 1;
4171*35238bceSAndroid Build Coastguard Worker             config.render       = false;
4172*35238bceSAndroid Build Coastguard Worker             textureTests->addChild(new GLES2ThreadedSharingTest(ctx, config, "teximage2d_texsubimage2d",
4173*35238bceSAndroid Build Coastguard Worker                                                                 "Generate, set data, update data and delete texture"));
4174*35238bceSAndroid Build Coastguard Worker         }
4175*35238bceSAndroid Build Coastguard Worker 
4176*35238bceSAndroid Build Coastguard Worker         {
4177*35238bceSAndroid Build Coastguard Worker             GLES2ThreadedSharingTest::TestConfig config;
4178*35238bceSAndroid Build Coastguard Worker 
4179*35238bceSAndroid Build Coastguard Worker             config.resourceType = GLES2ThreadedSharingTest::TestConfig::RESOURCETYPE_TEXTURE;
4180*35238bceSAndroid Build Coastguard Worker             config.useFenceSync = useSync;
4181*35238bceSAndroid Build Coastguard Worker             config.serverSync   = serverSync;
4182*35238bceSAndroid Build Coastguard Worker             config.define       = 1;
4183*35238bceSAndroid Build Coastguard Worker             config.modify       = 2;
4184*35238bceSAndroid Build Coastguard Worker             config.render       = false;
4185*35238bceSAndroid Build Coastguard Worker             textureTests->addChild(new GLES2ThreadedSharingTest(ctx, config, "teximage2d_copytexsubimage2d",
4186*35238bceSAndroid Build Coastguard Worker                                                                 "Generate, set data, update data and delete texture"));
4187*35238bceSAndroid Build Coastguard Worker         }
4188*35238bceSAndroid Build Coastguard Worker 
4189*35238bceSAndroid Build Coastguard Worker         {
4190*35238bceSAndroid Build Coastguard Worker             GLES2ThreadedSharingTest::TestConfig config;
4191*35238bceSAndroid Build Coastguard Worker 
4192*35238bceSAndroid Build Coastguard Worker             config.resourceType = GLES2ThreadedSharingTest::TestConfig::RESOURCETYPE_TEXTURE;
4193*35238bceSAndroid Build Coastguard Worker             config.useFenceSync = useSync;
4194*35238bceSAndroid Build Coastguard Worker             config.serverSync   = serverSync;
4195*35238bceSAndroid Build Coastguard Worker             config.define       = 1;
4196*35238bceSAndroid Build Coastguard Worker             config.modify       = 0;
4197*35238bceSAndroid Build Coastguard Worker             config.render       = true;
4198*35238bceSAndroid Build Coastguard Worker             textureTests->addChild(new GLES2ThreadedSharingTest(ctx, config, "teximage2d_render",
4199*35238bceSAndroid Build Coastguard Worker                                                                 "Generate, set data, render and delete texture"));
4200*35238bceSAndroid Build Coastguard Worker         }
4201*35238bceSAndroid Build Coastguard Worker 
4202*35238bceSAndroid Build Coastguard Worker         {
4203*35238bceSAndroid Build Coastguard Worker             GLES2ThreadedSharingTest::TestConfig config;
4204*35238bceSAndroid Build Coastguard Worker 
4205*35238bceSAndroid Build Coastguard Worker             config.resourceType = GLES2ThreadedSharingTest::TestConfig::RESOURCETYPE_TEXTURE;
4206*35238bceSAndroid Build Coastguard Worker             config.useFenceSync = useSync;
4207*35238bceSAndroid Build Coastguard Worker             config.serverSync   = serverSync;
4208*35238bceSAndroid Build Coastguard Worker             config.define       = 1;
4209*35238bceSAndroid Build Coastguard Worker             config.modify       = 1;
4210*35238bceSAndroid Build Coastguard Worker             config.render       = true;
4211*35238bceSAndroid Build Coastguard Worker             textureTests->addChild(
4212*35238bceSAndroid Build Coastguard Worker                 new GLES2ThreadedSharingTest(ctx, config, "teximage2d_texsubimage2d_render",
4213*35238bceSAndroid Build Coastguard Worker                                              "Generate, set data, update data, render and delete texture"));
4214*35238bceSAndroid Build Coastguard Worker         }
4215*35238bceSAndroid Build Coastguard Worker 
4216*35238bceSAndroid Build Coastguard Worker         {
4217*35238bceSAndroid Build Coastguard Worker             GLES2ThreadedSharingTest::TestConfig config;
4218*35238bceSAndroid Build Coastguard Worker 
4219*35238bceSAndroid Build Coastguard Worker             config.resourceType = GLES2ThreadedSharingTest::TestConfig::RESOURCETYPE_TEXTURE;
4220*35238bceSAndroid Build Coastguard Worker             config.useFenceSync = useSync;
4221*35238bceSAndroid Build Coastguard Worker             config.serverSync   = serverSync;
4222*35238bceSAndroid Build Coastguard Worker             config.define       = 1;
4223*35238bceSAndroid Build Coastguard Worker             config.modify       = 2;
4224*35238bceSAndroid Build Coastguard Worker             config.render       = true;
4225*35238bceSAndroid Build Coastguard Worker             textureTests->addChild(
4226*35238bceSAndroid Build Coastguard Worker                 new GLES2ThreadedSharingTest(ctx, config, "teximage2d_copytexsubimage2d_render",
4227*35238bceSAndroid Build Coastguard Worker                                              "Generate, set data, update data, render and delete texture"));
4228*35238bceSAndroid Build Coastguard Worker         }
4229*35238bceSAndroid Build Coastguard Worker 
4230*35238bceSAndroid Build Coastguard Worker         {
4231*35238bceSAndroid Build Coastguard Worker             GLES2ThreadedSharingTest::TestConfig config;
4232*35238bceSAndroid Build Coastguard Worker 
4233*35238bceSAndroid Build Coastguard Worker             config.resourceType = GLES2ThreadedSharingTest::TestConfig::RESOURCETYPE_TEXTURE;
4234*35238bceSAndroid Build Coastguard Worker             config.useFenceSync = useSync;
4235*35238bceSAndroid Build Coastguard Worker             config.serverSync   = serverSync;
4236*35238bceSAndroid Build Coastguard Worker             config.define       = 2;
4237*35238bceSAndroid Build Coastguard Worker             config.modify       = 0;
4238*35238bceSAndroid Build Coastguard Worker             config.render       = false;
4239*35238bceSAndroid Build Coastguard Worker             textureTests->addChild(
4240*35238bceSAndroid Build Coastguard Worker                 new GLES2ThreadedSharingTest(ctx, config, "copyteximage2d", "Generate, set data and delete texture"));
4241*35238bceSAndroid Build Coastguard Worker         }
4242*35238bceSAndroid Build Coastguard Worker 
4243*35238bceSAndroid Build Coastguard Worker         {
4244*35238bceSAndroid Build Coastguard Worker             GLES2ThreadedSharingTest::TestConfig config;
4245*35238bceSAndroid Build Coastguard Worker 
4246*35238bceSAndroid Build Coastguard Worker             config.resourceType = GLES2ThreadedSharingTest::TestConfig::RESOURCETYPE_TEXTURE;
4247*35238bceSAndroid Build Coastguard Worker             config.useFenceSync = useSync;
4248*35238bceSAndroid Build Coastguard Worker             config.serverSync   = serverSync;
4249*35238bceSAndroid Build Coastguard Worker             config.define       = 2;
4250*35238bceSAndroid Build Coastguard Worker             config.modify       = 1;
4251*35238bceSAndroid Build Coastguard Worker             config.render       = false;
4252*35238bceSAndroid Build Coastguard Worker             textureTests->addChild(new GLES2ThreadedSharingTest(ctx, config, "copyteximage2d_texsubimage2d",
4253*35238bceSAndroid Build Coastguard Worker                                                                 "Generate, set data, update data and delete texture"));
4254*35238bceSAndroid Build Coastguard Worker         }
4255*35238bceSAndroid Build Coastguard Worker 
4256*35238bceSAndroid Build Coastguard Worker         {
4257*35238bceSAndroid Build Coastguard Worker             GLES2ThreadedSharingTest::TestConfig config;
4258*35238bceSAndroid Build Coastguard Worker 
4259*35238bceSAndroid Build Coastguard Worker             config.resourceType = GLES2ThreadedSharingTest::TestConfig::RESOURCETYPE_TEXTURE;
4260*35238bceSAndroid Build Coastguard Worker             config.useFenceSync = useSync;
4261*35238bceSAndroid Build Coastguard Worker             config.serverSync   = serverSync;
4262*35238bceSAndroid Build Coastguard Worker             config.define       = 2;
4263*35238bceSAndroid Build Coastguard Worker             config.modify       = 2;
4264*35238bceSAndroid Build Coastguard Worker             config.render       = false;
4265*35238bceSAndroid Build Coastguard Worker             textureTests->addChild(new GLES2ThreadedSharingTest(ctx, config, "copyteximage2d_copytexsubimage2d",
4266*35238bceSAndroid Build Coastguard Worker                                                                 "Generate, set data, update data and delete texture"));
4267*35238bceSAndroid Build Coastguard Worker         }
4268*35238bceSAndroid Build Coastguard Worker 
4269*35238bceSAndroid Build Coastguard Worker         {
4270*35238bceSAndroid Build Coastguard Worker             GLES2ThreadedSharingTest::TestConfig config;
4271*35238bceSAndroid Build Coastguard Worker 
4272*35238bceSAndroid Build Coastguard Worker             config.resourceType = GLES2ThreadedSharingTest::TestConfig::RESOURCETYPE_TEXTURE;
4273*35238bceSAndroid Build Coastguard Worker             config.useFenceSync = useSync;
4274*35238bceSAndroid Build Coastguard Worker             config.serverSync   = serverSync;
4275*35238bceSAndroid Build Coastguard Worker             config.define       = 2;
4276*35238bceSAndroid Build Coastguard Worker             config.modify       = 0;
4277*35238bceSAndroid Build Coastguard Worker             config.render       = true;
4278*35238bceSAndroid Build Coastguard Worker             textureTests->addChild(new GLES2ThreadedSharingTest(ctx, config, "copyteximage2d_render",
4279*35238bceSAndroid Build Coastguard Worker                                                                 "Generate, set data, render and delete texture"));
4280*35238bceSAndroid Build Coastguard Worker         }
4281*35238bceSAndroid Build Coastguard Worker 
4282*35238bceSAndroid Build Coastguard Worker         {
4283*35238bceSAndroid Build Coastguard Worker             GLES2ThreadedSharingTest::TestConfig config;
4284*35238bceSAndroid Build Coastguard Worker 
4285*35238bceSAndroid Build Coastguard Worker             config.resourceType = GLES2ThreadedSharingTest::TestConfig::RESOURCETYPE_TEXTURE;
4286*35238bceSAndroid Build Coastguard Worker             config.useFenceSync = useSync;
4287*35238bceSAndroid Build Coastguard Worker             config.serverSync   = serverSync;
4288*35238bceSAndroid Build Coastguard Worker             config.define       = 2;
4289*35238bceSAndroid Build Coastguard Worker             config.modify       = 1;
4290*35238bceSAndroid Build Coastguard Worker             config.render       = true;
4291*35238bceSAndroid Build Coastguard Worker             textureTests->addChild(
4292*35238bceSAndroid Build Coastguard Worker                 new GLES2ThreadedSharingTest(ctx, config, "copyteximage2d_texsubimage2d_render",
4293*35238bceSAndroid Build Coastguard Worker                                              "Generate, set data, update data, render and delete texture"));
4294*35238bceSAndroid Build Coastguard Worker         }
4295*35238bceSAndroid Build Coastguard Worker 
4296*35238bceSAndroid Build Coastguard Worker         {
4297*35238bceSAndroid Build Coastguard Worker             GLES2ThreadedSharingTest::TestConfig config;
4298*35238bceSAndroid Build Coastguard Worker 
4299*35238bceSAndroid Build Coastguard Worker             config.resourceType = GLES2ThreadedSharingTest::TestConfig::RESOURCETYPE_TEXTURE;
4300*35238bceSAndroid Build Coastguard Worker             config.useFenceSync = useSync;
4301*35238bceSAndroid Build Coastguard Worker             config.serverSync   = serverSync;
4302*35238bceSAndroid Build Coastguard Worker             config.define       = 2;
4303*35238bceSAndroid Build Coastguard Worker             config.modify       = 2;
4304*35238bceSAndroid Build Coastguard Worker             config.render       = true;
4305*35238bceSAndroid Build Coastguard Worker             textureTests->addChild(
4306*35238bceSAndroid Build Coastguard Worker                 new GLES2ThreadedSharingTest(ctx, config, "copyteximage2d_copytexsubimage2d_render",
4307*35238bceSAndroid Build Coastguard Worker                                              "Generate, set data, update data, render and delete texture"));
4308*35238bceSAndroid Build Coastguard Worker         }
4309*35238bceSAndroid Build Coastguard Worker 
4310*35238bceSAndroid Build Coastguard Worker         group->addChild(textureTests);
4311*35238bceSAndroid Build Coastguard Worker     }
4312*35238bceSAndroid Build Coastguard Worker 
4313*35238bceSAndroid Build Coastguard Worker     {
4314*35238bceSAndroid Build Coastguard Worker         TestCaseGroup *shaderTests = new TestCaseGroup(ctx, "shaders", "Shader management tests");
4315*35238bceSAndroid Build Coastguard Worker 
4316*35238bceSAndroid Build Coastguard Worker         {
4317*35238bceSAndroid Build Coastguard Worker             GLES2ThreadedSharingTest::TestConfig config;
4318*35238bceSAndroid Build Coastguard Worker 
4319*35238bceSAndroid Build Coastguard Worker             config.resourceType = GLES2ThreadedSharingTest::TestConfig::RESOURCETYPE_VERTEX_SHADER;
4320*35238bceSAndroid Build Coastguard Worker             config.useFenceSync = useSync;
4321*35238bceSAndroid Build Coastguard Worker             config.serverSync   = serverSync;
4322*35238bceSAndroid Build Coastguard Worker             config.define       = 0;
4323*35238bceSAndroid Build Coastguard Worker             config.modify       = 0;
4324*35238bceSAndroid Build Coastguard Worker             config.render       = false;
4325*35238bceSAndroid Build Coastguard Worker             shaderTests->addChild(
4326*35238bceSAndroid Build Coastguard Worker                 new GLES2ThreadedSharingTest(ctx, config, "vtx_create_destroy", "Create and delete shader"));
4327*35238bceSAndroid Build Coastguard Worker         }
4328*35238bceSAndroid Build Coastguard Worker 
4329*35238bceSAndroid Build Coastguard Worker         {
4330*35238bceSAndroid Build Coastguard Worker             GLES2ThreadedSharingTest::TestConfig config;
4331*35238bceSAndroid Build Coastguard Worker 
4332*35238bceSAndroid Build Coastguard Worker             config.resourceType = GLES2ThreadedSharingTest::TestConfig::RESOURCETYPE_VERTEX_SHADER;
4333*35238bceSAndroid Build Coastguard Worker             config.useFenceSync = useSync;
4334*35238bceSAndroid Build Coastguard Worker             config.serverSync   = serverSync;
4335*35238bceSAndroid Build Coastguard Worker             config.define       = 1;
4336*35238bceSAndroid Build Coastguard Worker             config.modify       = 0;
4337*35238bceSAndroid Build Coastguard Worker             config.render       = false;
4338*35238bceSAndroid Build Coastguard Worker             shaderTests->addChild(
4339*35238bceSAndroid Build Coastguard Worker                 new GLES2ThreadedSharingTest(ctx, config, "vtx_shadersource", "Create, set source and delete shader"));
4340*35238bceSAndroid Build Coastguard Worker         }
4341*35238bceSAndroid Build Coastguard Worker 
4342*35238bceSAndroid Build Coastguard Worker         {
4343*35238bceSAndroid Build Coastguard Worker             GLES2ThreadedSharingTest::TestConfig config;
4344*35238bceSAndroid Build Coastguard Worker 
4345*35238bceSAndroid Build Coastguard Worker             config.resourceType = GLES2ThreadedSharingTest::TestConfig::RESOURCETYPE_VERTEX_SHADER;
4346*35238bceSAndroid Build Coastguard Worker             config.useFenceSync = useSync;
4347*35238bceSAndroid Build Coastguard Worker             config.serverSync   = serverSync;
4348*35238bceSAndroid Build Coastguard Worker             config.define       = 1;
4349*35238bceSAndroid Build Coastguard Worker             config.modify       = 1;
4350*35238bceSAndroid Build Coastguard Worker             config.render       = false;
4351*35238bceSAndroid Build Coastguard Worker             shaderTests->addChild(new GLES2ThreadedSharingTest(ctx, config, "vtx_compile",
4352*35238bceSAndroid Build Coastguard Worker                                                                "Create, set source, compile and delete shader"));
4353*35238bceSAndroid Build Coastguard Worker         }
4354*35238bceSAndroid Build Coastguard Worker 
4355*35238bceSAndroid Build Coastguard Worker         {
4356*35238bceSAndroid Build Coastguard Worker             GLES2ThreadedSharingTest::TestConfig config;
4357*35238bceSAndroid Build Coastguard Worker 
4358*35238bceSAndroid Build Coastguard Worker             config.resourceType = GLES2ThreadedSharingTest::TestConfig::RESOURCETYPE_FRAGMENT_SHADER;
4359*35238bceSAndroid Build Coastguard Worker             config.useFenceSync = useSync;
4360*35238bceSAndroid Build Coastguard Worker             config.serverSync   = serverSync;
4361*35238bceSAndroid Build Coastguard Worker             config.define       = 0;
4362*35238bceSAndroid Build Coastguard Worker             config.modify       = 0;
4363*35238bceSAndroid Build Coastguard Worker             config.render       = false;
4364*35238bceSAndroid Build Coastguard Worker             shaderTests->addChild(
4365*35238bceSAndroid Build Coastguard Worker                 new GLES2ThreadedSharingTest(ctx, config, "frag_create_destroy", "Create and delete shader"));
4366*35238bceSAndroid Build Coastguard Worker         }
4367*35238bceSAndroid Build Coastguard Worker 
4368*35238bceSAndroid Build Coastguard Worker         {
4369*35238bceSAndroid Build Coastguard Worker             GLES2ThreadedSharingTest::TestConfig config;
4370*35238bceSAndroid Build Coastguard Worker 
4371*35238bceSAndroid Build Coastguard Worker             config.resourceType = GLES2ThreadedSharingTest::TestConfig::RESOURCETYPE_FRAGMENT_SHADER;
4372*35238bceSAndroid Build Coastguard Worker             config.useFenceSync = useSync;
4373*35238bceSAndroid Build Coastguard Worker             config.serverSync   = serverSync;
4374*35238bceSAndroid Build Coastguard Worker             config.define       = 1;
4375*35238bceSAndroid Build Coastguard Worker             config.modify       = 0;
4376*35238bceSAndroid Build Coastguard Worker             config.render       = false;
4377*35238bceSAndroid Build Coastguard Worker             shaderTests->addChild(
4378*35238bceSAndroid Build Coastguard Worker                 new GLES2ThreadedSharingTest(ctx, config, "frag_shadersource", "Create, set source and delete shader"));
4379*35238bceSAndroid Build Coastguard Worker         }
4380*35238bceSAndroid Build Coastguard Worker 
4381*35238bceSAndroid Build Coastguard Worker         {
4382*35238bceSAndroid Build Coastguard Worker             GLES2ThreadedSharingTest::TestConfig config;
4383*35238bceSAndroid Build Coastguard Worker 
4384*35238bceSAndroid Build Coastguard Worker             config.resourceType = GLES2ThreadedSharingTest::TestConfig::RESOURCETYPE_FRAGMENT_SHADER;
4385*35238bceSAndroid Build Coastguard Worker             config.useFenceSync = useSync;
4386*35238bceSAndroid Build Coastguard Worker             config.serverSync   = serverSync;
4387*35238bceSAndroid Build Coastguard Worker             config.define       = 1;
4388*35238bceSAndroid Build Coastguard Worker             config.modify       = 1;
4389*35238bceSAndroid Build Coastguard Worker             config.render       = false;
4390*35238bceSAndroid Build Coastguard Worker             shaderTests->addChild(new GLES2ThreadedSharingTest(ctx, config, "frag_compile",
4391*35238bceSAndroid Build Coastguard Worker                                                                "Create, set source, compile and delete shader"));
4392*35238bceSAndroid Build Coastguard Worker         }
4393*35238bceSAndroid Build Coastguard Worker 
4394*35238bceSAndroid Build Coastguard Worker         group->addChild(shaderTests);
4395*35238bceSAndroid Build Coastguard Worker     }
4396*35238bceSAndroid Build Coastguard Worker 
4397*35238bceSAndroid Build Coastguard Worker     {
4398*35238bceSAndroid Build Coastguard Worker         TestCaseGroup *programTests = new TestCaseGroup(ctx, "programs", "Program management tests");
4399*35238bceSAndroid Build Coastguard Worker 
4400*35238bceSAndroid Build Coastguard Worker         {
4401*35238bceSAndroid Build Coastguard Worker             GLES2ThreadedSharingTest::TestConfig config;
4402*35238bceSAndroid Build Coastguard Worker 
4403*35238bceSAndroid Build Coastguard Worker             config.resourceType = GLES2ThreadedSharingTest::TestConfig::RESOURCETYPE_PROGRAM;
4404*35238bceSAndroid Build Coastguard Worker             config.useFenceSync = useSync;
4405*35238bceSAndroid Build Coastguard Worker             config.serverSync   = serverSync;
4406*35238bceSAndroid Build Coastguard Worker             config.define       = 0;
4407*35238bceSAndroid Build Coastguard Worker             config.modify       = 0;
4408*35238bceSAndroid Build Coastguard Worker             config.render       = false;
4409*35238bceSAndroid Build Coastguard Worker             programTests->addChild(
4410*35238bceSAndroid Build Coastguard Worker                 new GLES2ThreadedSharingTest(ctx, config, "create_destroy", "Create and delete program"));
4411*35238bceSAndroid Build Coastguard Worker         }
4412*35238bceSAndroid Build Coastguard Worker 
4413*35238bceSAndroid Build Coastguard Worker         {
4414*35238bceSAndroid Build Coastguard Worker             GLES2ThreadedSharingTest::TestConfig config;
4415*35238bceSAndroid Build Coastguard Worker 
4416*35238bceSAndroid Build Coastguard Worker             config.resourceType = GLES2ThreadedSharingTest::TestConfig::RESOURCETYPE_PROGRAM;
4417*35238bceSAndroid Build Coastguard Worker             config.useFenceSync = useSync;
4418*35238bceSAndroid Build Coastguard Worker             config.serverSync   = serverSync;
4419*35238bceSAndroid Build Coastguard Worker             config.define       = 1;
4420*35238bceSAndroid Build Coastguard Worker             config.modify       = 0;
4421*35238bceSAndroid Build Coastguard Worker             config.render       = false;
4422*35238bceSAndroid Build Coastguard Worker             programTests->addChild(
4423*35238bceSAndroid Build Coastguard Worker                 new GLES2ThreadedSharingTest(ctx, config, "attach", "Create, attach shaders and delete program"));
4424*35238bceSAndroid Build Coastguard Worker         }
4425*35238bceSAndroid Build Coastguard Worker 
4426*35238bceSAndroid Build Coastguard Worker         {
4427*35238bceSAndroid Build Coastguard Worker             GLES2ThreadedSharingTest::TestConfig config;
4428*35238bceSAndroid Build Coastguard Worker 
4429*35238bceSAndroid Build Coastguard Worker             config.resourceType = GLES2ThreadedSharingTest::TestConfig::RESOURCETYPE_PROGRAM;
4430*35238bceSAndroid Build Coastguard Worker             config.useFenceSync = useSync;
4431*35238bceSAndroid Build Coastguard Worker             config.serverSync   = serverSync;
4432*35238bceSAndroid Build Coastguard Worker             config.define       = 1;
4433*35238bceSAndroid Build Coastguard Worker             config.modify       = 1;
4434*35238bceSAndroid Build Coastguard Worker             config.render       = false;
4435*35238bceSAndroid Build Coastguard Worker             programTests->addChild(
4436*35238bceSAndroid Build Coastguard Worker                 new GLES2ThreadedSharingTest(ctx, config, "link", "Create, attach shaders, link and delete program"));
4437*35238bceSAndroid Build Coastguard Worker         }
4438*35238bceSAndroid Build Coastguard Worker 
4439*35238bceSAndroid Build Coastguard Worker         group->addChild(programTests);
4440*35238bceSAndroid Build Coastguard Worker     }
4441*35238bceSAndroid Build Coastguard Worker 
4442*35238bceSAndroid Build Coastguard Worker     {
4443*35238bceSAndroid Build Coastguard Worker         TestCaseGroup *imageTests = new TestCaseGroup(ctx, "images", "Image management tests");
4444*35238bceSAndroid Build Coastguard Worker 
4445*35238bceSAndroid Build Coastguard Worker         TestCaseGroup *textureSourceTests =
4446*35238bceSAndroid Build Coastguard Worker             new TestCaseGroup(ctx, "texture_source", "Image management tests with texture source.");
4447*35238bceSAndroid Build Coastguard Worker         {
4448*35238bceSAndroid Build Coastguard Worker             GLES2ThreadedSharingTest::TestConfig config;
4449*35238bceSAndroid Build Coastguard Worker 
4450*35238bceSAndroid Build Coastguard Worker             config.resourceType = GLES2ThreadedSharingTest::TestConfig::RESOURCETYPE_IMAGE;
4451*35238bceSAndroid Build Coastguard Worker             config.useFenceSync = useSync;
4452*35238bceSAndroid Build Coastguard Worker             config.serverSync   = serverSync;
4453*35238bceSAndroid Build Coastguard Worker             config.define       = 1;
4454*35238bceSAndroid Build Coastguard Worker             config.modify       = 0;
4455*35238bceSAndroid Build Coastguard Worker             config.render       = false;
4456*35238bceSAndroid Build Coastguard Worker             textureSourceTests->addChild(
4457*35238bceSAndroid Build Coastguard Worker                 new GLES2ThreadedSharingTest(ctx, config, "create_destroy", "Create and destroy EGLImage."));
4458*35238bceSAndroid Build Coastguard Worker         }
4459*35238bceSAndroid Build Coastguard Worker 
4460*35238bceSAndroid Build Coastguard Worker         {
4461*35238bceSAndroid Build Coastguard Worker             GLES2ThreadedSharingTest::TestConfig config;
4462*35238bceSAndroid Build Coastguard Worker 
4463*35238bceSAndroid Build Coastguard Worker             config.resourceType = GLES2ThreadedSharingTest::TestConfig::RESOURCETYPE_IMAGE;
4464*35238bceSAndroid Build Coastguard Worker             config.useFenceSync = useSync;
4465*35238bceSAndroid Build Coastguard Worker             config.serverSync   = serverSync;
4466*35238bceSAndroid Build Coastguard Worker             config.define       = 2;
4467*35238bceSAndroid Build Coastguard Worker             config.modify       = 0;
4468*35238bceSAndroid Build Coastguard Worker             config.render       = false;
4469*35238bceSAndroid Build Coastguard Worker             textureSourceTests->addChild(
4470*35238bceSAndroid Build Coastguard Worker                 new GLES2ThreadedSharingTest(ctx, config, "create_texture", "Create texture from image."));
4471*35238bceSAndroid Build Coastguard Worker         }
4472*35238bceSAndroid Build Coastguard Worker 
4473*35238bceSAndroid Build Coastguard Worker         {
4474*35238bceSAndroid Build Coastguard Worker             GLES2ThreadedSharingTest::TestConfig config;
4475*35238bceSAndroid Build Coastguard Worker 
4476*35238bceSAndroid Build Coastguard Worker             config.resourceType = GLES2ThreadedSharingTest::TestConfig::RESOURCETYPE_IMAGE;
4477*35238bceSAndroid Build Coastguard Worker             config.useFenceSync = useSync;
4478*35238bceSAndroid Build Coastguard Worker             config.serverSync   = serverSync;
4479*35238bceSAndroid Build Coastguard Worker             config.define       = 2;
4480*35238bceSAndroid Build Coastguard Worker             config.modify       = 1;
4481*35238bceSAndroid Build Coastguard Worker             config.render       = false;
4482*35238bceSAndroid Build Coastguard Worker             textureSourceTests->addChild(new GLES2ThreadedSharingTest(
4483*35238bceSAndroid Build Coastguard Worker                 ctx, config, "texsubimage2d", "Modify texture created from image with glTexSubImage2D."));
4484*35238bceSAndroid Build Coastguard Worker         }
4485*35238bceSAndroid Build Coastguard Worker 
4486*35238bceSAndroid Build Coastguard Worker         {
4487*35238bceSAndroid Build Coastguard Worker             GLES2ThreadedSharingTest::TestConfig config;
4488*35238bceSAndroid Build Coastguard Worker 
4489*35238bceSAndroid Build Coastguard Worker             config.resourceType = GLES2ThreadedSharingTest::TestConfig::RESOURCETYPE_IMAGE;
4490*35238bceSAndroid Build Coastguard Worker             config.useFenceSync = useSync;
4491*35238bceSAndroid Build Coastguard Worker             config.serverSync   = serverSync;
4492*35238bceSAndroid Build Coastguard Worker             config.define       = 2;
4493*35238bceSAndroid Build Coastguard Worker             config.modify       = 2;
4494*35238bceSAndroid Build Coastguard Worker             config.render       = false;
4495*35238bceSAndroid Build Coastguard Worker             textureSourceTests->addChild(new GLES2ThreadedSharingTest(
4496*35238bceSAndroid Build Coastguard Worker                 ctx, config, "copytexsubimage2d", "Modify texture created from image with glCopyTexSubImage2D."));
4497*35238bceSAndroid Build Coastguard Worker         }
4498*35238bceSAndroid Build Coastguard Worker 
4499*35238bceSAndroid Build Coastguard Worker         {
4500*35238bceSAndroid Build Coastguard Worker             GLES2ThreadedSharingTest::TestConfig config;
4501*35238bceSAndroid Build Coastguard Worker 
4502*35238bceSAndroid Build Coastguard Worker             config.resourceType = GLES2ThreadedSharingTest::TestConfig::RESOURCETYPE_IMAGE;
4503*35238bceSAndroid Build Coastguard Worker             config.useFenceSync = useSync;
4504*35238bceSAndroid Build Coastguard Worker             config.serverSync   = serverSync;
4505*35238bceSAndroid Build Coastguard Worker             config.define       = 2;
4506*35238bceSAndroid Build Coastguard Worker             config.modify       = 3;
4507*35238bceSAndroid Build Coastguard Worker             config.render       = false;
4508*35238bceSAndroid Build Coastguard Worker             textureSourceTests->addChild(new GLES2ThreadedSharingTest(
4509*35238bceSAndroid Build Coastguard Worker                 ctx, config, "teximage2d", "Modify texture created from image with glTexImage2D."));
4510*35238bceSAndroid Build Coastguard Worker         }
4511*35238bceSAndroid Build Coastguard Worker 
4512*35238bceSAndroid Build Coastguard Worker         {
4513*35238bceSAndroid Build Coastguard Worker             GLES2ThreadedSharingTest::TestConfig config;
4514*35238bceSAndroid Build Coastguard Worker 
4515*35238bceSAndroid Build Coastguard Worker             config.resourceType = GLES2ThreadedSharingTest::TestConfig::RESOURCETYPE_IMAGE;
4516*35238bceSAndroid Build Coastguard Worker             config.useFenceSync = useSync;
4517*35238bceSAndroid Build Coastguard Worker             config.serverSync   = serverSync;
4518*35238bceSAndroid Build Coastguard Worker             config.define       = 2;
4519*35238bceSAndroid Build Coastguard Worker             config.modify       = 4;
4520*35238bceSAndroid Build Coastguard Worker             config.render       = false;
4521*35238bceSAndroid Build Coastguard Worker             textureSourceTests->addChild(new GLES2ThreadedSharingTest(
4522*35238bceSAndroid Build Coastguard Worker                 ctx, config, "copyteximage2d", "Modify texture created from image with glCopyTexImage2D."));
4523*35238bceSAndroid Build Coastguard Worker         }
4524*35238bceSAndroid Build Coastguard Worker 
4525*35238bceSAndroid Build Coastguard Worker         {
4526*35238bceSAndroid Build Coastguard Worker             GLES2ThreadedSharingTest::TestConfig config;
4527*35238bceSAndroid Build Coastguard Worker 
4528*35238bceSAndroid Build Coastguard Worker             config.resourceType = GLES2ThreadedSharingTest::TestConfig::RESOURCETYPE_IMAGE;
4529*35238bceSAndroid Build Coastguard Worker             config.useFenceSync = useSync;
4530*35238bceSAndroid Build Coastguard Worker             config.serverSync   = serverSync;
4531*35238bceSAndroid Build Coastguard Worker             config.define       = 2;
4532*35238bceSAndroid Build Coastguard Worker             config.modify       = 0;
4533*35238bceSAndroid Build Coastguard Worker             config.render       = true;
4534*35238bceSAndroid Build Coastguard Worker             textureSourceTests->addChild(new GLES2ThreadedSharingTest(ctx, config, "create_texture_render",
4535*35238bceSAndroid Build Coastguard Worker                                                                       "Create texture from image and render."));
4536*35238bceSAndroid Build Coastguard Worker         }
4537*35238bceSAndroid Build Coastguard Worker 
4538*35238bceSAndroid Build Coastguard Worker         {
4539*35238bceSAndroid Build Coastguard Worker             GLES2ThreadedSharingTest::TestConfig config;
4540*35238bceSAndroid Build Coastguard Worker 
4541*35238bceSAndroid Build Coastguard Worker             config.resourceType = GLES2ThreadedSharingTest::TestConfig::RESOURCETYPE_IMAGE;
4542*35238bceSAndroid Build Coastguard Worker             config.useFenceSync = useSync;
4543*35238bceSAndroid Build Coastguard Worker             config.serverSync   = serverSync;
4544*35238bceSAndroid Build Coastguard Worker             config.define       = 2;
4545*35238bceSAndroid Build Coastguard Worker             config.modify       = 1;
4546*35238bceSAndroid Build Coastguard Worker             config.render       = true;
4547*35238bceSAndroid Build Coastguard Worker             textureSourceTests->addChild(new GLES2ThreadedSharingTest(ctx, config, "texsubimage2d_render",
4548*35238bceSAndroid Build Coastguard Worker                                                                       "Modify texture created from image and render."));
4549*35238bceSAndroid Build Coastguard Worker         }
4550*35238bceSAndroid Build Coastguard Worker 
4551*35238bceSAndroid Build Coastguard Worker         {
4552*35238bceSAndroid Build Coastguard Worker             GLES2ThreadedSharingTest::TestConfig config;
4553*35238bceSAndroid Build Coastguard Worker 
4554*35238bceSAndroid Build Coastguard Worker             config.resourceType = GLES2ThreadedSharingTest::TestConfig::RESOURCETYPE_IMAGE;
4555*35238bceSAndroid Build Coastguard Worker             config.useFenceSync = useSync;
4556*35238bceSAndroid Build Coastguard Worker             config.serverSync   = serverSync;
4557*35238bceSAndroid Build Coastguard Worker             config.define       = 2;
4558*35238bceSAndroid Build Coastguard Worker             config.modify       = 2;
4559*35238bceSAndroid Build Coastguard Worker             config.render       = true;
4560*35238bceSAndroid Build Coastguard Worker             textureSourceTests->addChild(new GLES2ThreadedSharingTest(ctx, config, "copytexsubimage2d_render",
4561*35238bceSAndroid Build Coastguard Worker                                                                       "Modify texture created from image and render."));
4562*35238bceSAndroid Build Coastguard Worker         }
4563*35238bceSAndroid Build Coastguard Worker 
4564*35238bceSAndroid Build Coastguard Worker         {
4565*35238bceSAndroid Build Coastguard Worker             GLES2ThreadedSharingTest::TestConfig config;
4566*35238bceSAndroid Build Coastguard Worker 
4567*35238bceSAndroid Build Coastguard Worker             config.resourceType = GLES2ThreadedSharingTest::TestConfig::RESOURCETYPE_IMAGE;
4568*35238bceSAndroid Build Coastguard Worker             config.useFenceSync = useSync;
4569*35238bceSAndroid Build Coastguard Worker             config.serverSync   = serverSync;
4570*35238bceSAndroid Build Coastguard Worker             config.define       = 2;
4571*35238bceSAndroid Build Coastguard Worker             config.modify       = 3;
4572*35238bceSAndroid Build Coastguard Worker             config.render       = true;
4573*35238bceSAndroid Build Coastguard Worker             textureSourceTests->addChild(new GLES2ThreadedSharingTest(ctx, config, "teximage2d_render",
4574*35238bceSAndroid Build Coastguard Worker                                                                       "Modify texture created from image and render."));
4575*35238bceSAndroid Build Coastguard Worker         }
4576*35238bceSAndroid Build Coastguard Worker 
4577*35238bceSAndroid Build Coastguard Worker         {
4578*35238bceSAndroid Build Coastguard Worker             GLES2ThreadedSharingTest::TestConfig config;
4579*35238bceSAndroid Build Coastguard Worker 
4580*35238bceSAndroid Build Coastguard Worker             config.resourceType = GLES2ThreadedSharingTest::TestConfig::RESOURCETYPE_IMAGE;
4581*35238bceSAndroid Build Coastguard Worker             config.useFenceSync = useSync;
4582*35238bceSAndroid Build Coastguard Worker             config.serverSync   = serverSync;
4583*35238bceSAndroid Build Coastguard Worker             config.define       = 2;
4584*35238bceSAndroid Build Coastguard Worker             config.modify       = 4;
4585*35238bceSAndroid Build Coastguard Worker             config.render       = true;
4586*35238bceSAndroid Build Coastguard Worker             textureSourceTests->addChild(new GLES2ThreadedSharingTest(ctx, config, "copyteximage2d_render",
4587*35238bceSAndroid Build Coastguard Worker                                                                       "Modify texture created from image and render."));
4588*35238bceSAndroid Build Coastguard Worker         }
4589*35238bceSAndroid Build Coastguard Worker 
4590*35238bceSAndroid Build Coastguard Worker         imageTests->addChild(textureSourceTests);
4591*35238bceSAndroid Build Coastguard Worker 
4592*35238bceSAndroid Build Coastguard Worker         group->addChild(imageTests);
4593*35238bceSAndroid Build Coastguard Worker     }
4594*35238bceSAndroid Build Coastguard Worker }
4595*35238bceSAndroid Build Coastguard Worker 
addRandomTests(EglTestContext & ctx,tcu::TestCaseGroup * group,bool useSync,bool serverSync)4596*35238bceSAndroid Build Coastguard Worker static void addRandomTests(EglTestContext &ctx, tcu::TestCaseGroup *group, bool useSync, bool serverSync)
4597*35238bceSAndroid Build Coastguard Worker {
4598*35238bceSAndroid Build Coastguard Worker     {
4599*35238bceSAndroid Build Coastguard Worker         TestCaseGroup *textureTests = new TestCaseGroup(ctx, "textures", "Texture management tests");
4600*35238bceSAndroid Build Coastguard Worker 
4601*35238bceSAndroid Build Coastguard Worker         {
4602*35238bceSAndroid Build Coastguard Worker             TestCaseGroup *genTextureTests = new TestCaseGroup(ctx, "gen_delete", "Texture gen and delete tests");
4603*35238bceSAndroid Build Coastguard Worker 
4604*35238bceSAndroid Build Coastguard Worker             for (int textureTestNdx = 0; textureTestNdx < 20; textureTestNdx++)
4605*35238bceSAndroid Build Coastguard Worker             {
4606*35238bceSAndroid Build Coastguard Worker                 GLES2SharingRandomTest::TestConfig config;
4607*35238bceSAndroid Build Coastguard Worker                 config.useFenceSync   = useSync;
4608*35238bceSAndroid Build Coastguard Worker                 config.serverSync     = serverSync;
4609*35238bceSAndroid Build Coastguard Worker                 config.threadCount    = 2 + textureTestNdx % 5;
4610*35238bceSAndroid Build Coastguard Worker                 config.operationCount = 30 + textureTestNdx;
4611*35238bceSAndroid Build Coastguard Worker 
4612*35238bceSAndroid Build Coastguard Worker                 config.probabilities[THREADOPERATIONID_NONE][THREADOPERATIONID_CREATE_TEXTURE] = 1.0f;
4613*35238bceSAndroid Build Coastguard Worker 
4614*35238bceSAndroid Build Coastguard Worker                 config.probabilities[THREADOPERATIONID_CREATE_TEXTURE][THREADOPERATIONID_DESTROY_TEXTURE] = 0.25f;
4615*35238bceSAndroid Build Coastguard Worker                 config.probabilities[THREADOPERATIONID_CREATE_TEXTURE][THREADOPERATIONID_CREATE_TEXTURE]  = 0.75f;
4616*35238bceSAndroid Build Coastguard Worker 
4617*35238bceSAndroid Build Coastguard Worker                 config.probabilities[THREADOPERATIONID_DESTROY_TEXTURE][THREADOPERATIONID_DESTROY_TEXTURE] = 0.5f;
4618*35238bceSAndroid Build Coastguard Worker                 config.probabilities[THREADOPERATIONID_DESTROY_TEXTURE][THREADOPERATIONID_CREATE_TEXTURE]  = 0.5f;
4619*35238bceSAndroid Build Coastguard Worker 
4620*35238bceSAndroid Build Coastguard Worker                 std::string name = de::toString(textureTestNdx);
4621*35238bceSAndroid Build Coastguard Worker                 genTextureTests->addChild(new GLES2SharingRandomTest(ctx, config, name.c_str(), name.c_str()));
4622*35238bceSAndroid Build Coastguard Worker             }
4623*35238bceSAndroid Build Coastguard Worker 
4624*35238bceSAndroid Build Coastguard Worker             textureTests->addChild(genTextureTests);
4625*35238bceSAndroid Build Coastguard Worker         }
4626*35238bceSAndroid Build Coastguard Worker 
4627*35238bceSAndroid Build Coastguard Worker         {
4628*35238bceSAndroid Build Coastguard Worker             TestCaseGroup *texImage2DTests =
4629*35238bceSAndroid Build Coastguard Worker                 new TestCaseGroup(ctx, "teximage2d", "Texture gen, delete and teximage2D tests");
4630*35238bceSAndroid Build Coastguard Worker 
4631*35238bceSAndroid Build Coastguard Worker             for (int textureTestNdx = 0; textureTestNdx < 20; textureTestNdx++)
4632*35238bceSAndroid Build Coastguard Worker             {
4633*35238bceSAndroid Build Coastguard Worker                 GLES2SharingRandomTest::TestConfig config;
4634*35238bceSAndroid Build Coastguard Worker                 config.useFenceSync   = useSync;
4635*35238bceSAndroid Build Coastguard Worker                 config.serverSync     = serverSync;
4636*35238bceSAndroid Build Coastguard Worker                 config.threadCount    = 2 + textureTestNdx % 5;
4637*35238bceSAndroid Build Coastguard Worker                 config.operationCount = 40 + textureTestNdx;
4638*35238bceSAndroid Build Coastguard Worker 
4639*35238bceSAndroid Build Coastguard Worker                 config.probabilities[THREADOPERATIONID_NONE][THREADOPERATIONID_CREATE_TEXTURE] = 1.0f;
4640*35238bceSAndroid Build Coastguard Worker 
4641*35238bceSAndroid Build Coastguard Worker                 config.probabilities[THREADOPERATIONID_CREATE_TEXTURE][THREADOPERATIONID_DESTROY_TEXTURE] = 0.10f;
4642*35238bceSAndroid Build Coastguard Worker                 config.probabilities[THREADOPERATIONID_CREATE_TEXTURE][THREADOPERATIONID_CREATE_TEXTURE]  = 0.10f;
4643*35238bceSAndroid Build Coastguard Worker                 config.probabilities[THREADOPERATIONID_CREATE_TEXTURE][THREADOPERATIONID_TEXIMAGE2D]      = 0.80f;
4644*35238bceSAndroid Build Coastguard Worker 
4645*35238bceSAndroid Build Coastguard Worker                 config.probabilities[THREADOPERATIONID_DESTROY_TEXTURE][THREADOPERATIONID_DESTROY_TEXTURE] = 0.30f;
4646*35238bceSAndroid Build Coastguard Worker                 config.probabilities[THREADOPERATIONID_DESTROY_TEXTURE][THREADOPERATIONID_CREATE_TEXTURE]  = 0.40f;
4647*35238bceSAndroid Build Coastguard Worker                 config.probabilities[THREADOPERATIONID_DESTROY_TEXTURE][THREADOPERATIONID_TEXIMAGE2D]      = 0.30f;
4648*35238bceSAndroid Build Coastguard Worker 
4649*35238bceSAndroid Build Coastguard Worker                 config.probabilities[THREADOPERATIONID_TEXIMAGE2D][THREADOPERATIONID_DESTROY_TEXTURE] = 0.40f;
4650*35238bceSAndroid Build Coastguard Worker                 config.probabilities[THREADOPERATIONID_TEXIMAGE2D][THREADOPERATIONID_CREATE_TEXTURE]  = 0.40f;
4651*35238bceSAndroid Build Coastguard Worker                 config.probabilities[THREADOPERATIONID_TEXIMAGE2D][THREADOPERATIONID_TEXIMAGE2D]      = 0.20f;
4652*35238bceSAndroid Build Coastguard Worker 
4653*35238bceSAndroid Build Coastguard Worker                 std::string name = de::toString(textureTestNdx);
4654*35238bceSAndroid Build Coastguard Worker                 texImage2DTests->addChild(new GLES2SharingRandomTest(ctx, config, name.c_str(), name.c_str()));
4655*35238bceSAndroid Build Coastguard Worker             }
4656*35238bceSAndroid Build Coastguard Worker 
4657*35238bceSAndroid Build Coastguard Worker             textureTests->addChild(texImage2DTests);
4658*35238bceSAndroid Build Coastguard Worker         }
4659*35238bceSAndroid Build Coastguard Worker 
4660*35238bceSAndroid Build Coastguard Worker         {
4661*35238bceSAndroid Build Coastguard Worker             TestCaseGroup *texSubImage2DTests =
4662*35238bceSAndroid Build Coastguard Worker                 new TestCaseGroup(ctx, "texsubimage2d", "Texture gen, delete, teximage2D and texsubimage2d tests");
4663*35238bceSAndroid Build Coastguard Worker 
4664*35238bceSAndroid Build Coastguard Worker             for (int textureTestNdx = 0; textureTestNdx < 20; textureTestNdx++)
4665*35238bceSAndroid Build Coastguard Worker             {
4666*35238bceSAndroid Build Coastguard Worker                 GLES2SharingRandomTest::TestConfig config;
4667*35238bceSAndroid Build Coastguard Worker                 config.useFenceSync   = useSync;
4668*35238bceSAndroid Build Coastguard Worker                 config.serverSync     = serverSync;
4669*35238bceSAndroid Build Coastguard Worker                 config.threadCount    = 2 + textureTestNdx % 5;
4670*35238bceSAndroid Build Coastguard Worker                 config.operationCount = 50 + textureTestNdx;
4671*35238bceSAndroid Build Coastguard Worker 
4672*35238bceSAndroid Build Coastguard Worker                 config.probabilities[THREADOPERATIONID_NONE][THREADOPERATIONID_CREATE_TEXTURE] = 1.0f;
4673*35238bceSAndroid Build Coastguard Worker 
4674*35238bceSAndroid Build Coastguard Worker                 config.probabilities[THREADOPERATIONID_CREATE_TEXTURE][THREADOPERATIONID_DESTROY_TEXTURE] = 0.05f;
4675*35238bceSAndroid Build Coastguard Worker                 config.probabilities[THREADOPERATIONID_CREATE_TEXTURE][THREADOPERATIONID_CREATE_TEXTURE]  = 0.10f;
4676*35238bceSAndroid Build Coastguard Worker                 config.probabilities[THREADOPERATIONID_CREATE_TEXTURE][THREADOPERATIONID_TEXIMAGE2D]      = 0.80f;
4677*35238bceSAndroid Build Coastguard Worker                 config.probabilities[THREADOPERATIONID_CREATE_TEXTURE][THREADOPERATIONID_TEXSUBIMAGE2D]   = 0.05f;
4678*35238bceSAndroid Build Coastguard Worker 
4679*35238bceSAndroid Build Coastguard Worker                 config.probabilities[THREADOPERATIONID_DESTROY_TEXTURE][THREADOPERATIONID_DESTROY_TEXTURE] = 0.30f;
4680*35238bceSAndroid Build Coastguard Worker                 config.probabilities[THREADOPERATIONID_DESTROY_TEXTURE][THREADOPERATIONID_CREATE_TEXTURE]  = 0.40f;
4681*35238bceSAndroid Build Coastguard Worker                 config.probabilities[THREADOPERATIONID_DESTROY_TEXTURE][THREADOPERATIONID_TEXIMAGE2D]      = 0.20f;
4682*35238bceSAndroid Build Coastguard Worker                 config.probabilities[THREADOPERATIONID_DESTROY_TEXTURE][THREADOPERATIONID_TEXSUBIMAGE2D]   = 0.10f;
4683*35238bceSAndroid Build Coastguard Worker 
4684*35238bceSAndroid Build Coastguard Worker                 config.probabilities[THREADOPERATIONID_TEXIMAGE2D][THREADOPERATIONID_DESTROY_TEXTURE] = 0.20f;
4685*35238bceSAndroid Build Coastguard Worker                 config.probabilities[THREADOPERATIONID_TEXIMAGE2D][THREADOPERATIONID_CREATE_TEXTURE]  = 0.20f;
4686*35238bceSAndroid Build Coastguard Worker                 config.probabilities[THREADOPERATIONID_TEXIMAGE2D][THREADOPERATIONID_TEXIMAGE2D]      = 0.10f;
4687*35238bceSAndroid Build Coastguard Worker                 config.probabilities[THREADOPERATIONID_TEXIMAGE2D][THREADOPERATIONID_TEXSUBIMAGE2D]   = 0.50f;
4688*35238bceSAndroid Build Coastguard Worker 
4689*35238bceSAndroid Build Coastguard Worker                 config.probabilities[THREADOPERATIONID_TEXSUBIMAGE2D][THREADOPERATIONID_DESTROY_TEXTURE] = 0.20f;
4690*35238bceSAndroid Build Coastguard Worker                 config.probabilities[THREADOPERATIONID_TEXSUBIMAGE2D][THREADOPERATIONID_CREATE_TEXTURE]  = 0.25f;
4691*35238bceSAndroid Build Coastguard Worker                 config.probabilities[THREADOPERATIONID_TEXSUBIMAGE2D][THREADOPERATIONID_TEXIMAGE2D]      = 0.25f;
4692*35238bceSAndroid Build Coastguard Worker                 config.probabilities[THREADOPERATIONID_TEXSUBIMAGE2D][THREADOPERATIONID_TEXSUBIMAGE2D]   = 0.30f;
4693*35238bceSAndroid Build Coastguard Worker 
4694*35238bceSAndroid Build Coastguard Worker                 std::string name = de::toString(textureTestNdx);
4695*35238bceSAndroid Build Coastguard Worker                 texSubImage2DTests->addChild(new GLES2SharingRandomTest(ctx, config, name.c_str(), name.c_str()));
4696*35238bceSAndroid Build Coastguard Worker             }
4697*35238bceSAndroid Build Coastguard Worker 
4698*35238bceSAndroid Build Coastguard Worker             textureTests->addChild(texSubImage2DTests);
4699*35238bceSAndroid Build Coastguard Worker         }
4700*35238bceSAndroid Build Coastguard Worker 
4701*35238bceSAndroid Build Coastguard Worker         {
4702*35238bceSAndroid Build Coastguard Worker             TestCaseGroup *copyTexImage2DTests =
4703*35238bceSAndroid Build Coastguard Worker                 new TestCaseGroup(ctx, "copyteximage2d", "Texture gen, delete and copyteximage2d tests");
4704*35238bceSAndroid Build Coastguard Worker 
4705*35238bceSAndroid Build Coastguard Worker             for (int textureTestNdx = 0; textureTestNdx < 20; textureTestNdx++)
4706*35238bceSAndroid Build Coastguard Worker             {
4707*35238bceSAndroid Build Coastguard Worker                 GLES2SharingRandomTest::TestConfig config;
4708*35238bceSAndroid Build Coastguard Worker                 config.useFenceSync   = useSync;
4709*35238bceSAndroid Build Coastguard Worker                 config.serverSync     = serverSync;
4710*35238bceSAndroid Build Coastguard Worker                 config.threadCount    = 2 + textureTestNdx % 5;
4711*35238bceSAndroid Build Coastguard Worker                 config.operationCount = 40 + textureTestNdx;
4712*35238bceSAndroid Build Coastguard Worker 
4713*35238bceSAndroid Build Coastguard Worker                 config.probabilities[THREADOPERATIONID_NONE][THREADOPERATIONID_CREATE_TEXTURE] = 1.0f;
4714*35238bceSAndroid Build Coastguard Worker 
4715*35238bceSAndroid Build Coastguard Worker                 config.probabilities[THREADOPERATIONID_CREATE_TEXTURE][THREADOPERATIONID_DESTROY_TEXTURE] = 0.10f;
4716*35238bceSAndroid Build Coastguard Worker                 config.probabilities[THREADOPERATIONID_CREATE_TEXTURE][THREADOPERATIONID_CREATE_TEXTURE]  = 0.10f;
4717*35238bceSAndroid Build Coastguard Worker                 config.probabilities[THREADOPERATIONID_CREATE_TEXTURE][THREADOPERATIONID_COPYTEXIMAGE2D]  = 0.80f;
4718*35238bceSAndroid Build Coastguard Worker 
4719*35238bceSAndroid Build Coastguard Worker                 config.probabilities[THREADOPERATIONID_DESTROY_TEXTURE][THREADOPERATIONID_DESTROY_TEXTURE] = 0.30f;
4720*35238bceSAndroid Build Coastguard Worker                 config.probabilities[THREADOPERATIONID_DESTROY_TEXTURE][THREADOPERATIONID_CREATE_TEXTURE]  = 0.40f;
4721*35238bceSAndroid Build Coastguard Worker                 config.probabilities[THREADOPERATIONID_DESTROY_TEXTURE][THREADOPERATIONID_COPYTEXIMAGE2D]  = 0.30f;
4722*35238bceSAndroid Build Coastguard Worker 
4723*35238bceSAndroid Build Coastguard Worker                 config.probabilities[THREADOPERATIONID_COPYTEXIMAGE2D][THREADOPERATIONID_DESTROY_TEXTURE] = 0.40f;
4724*35238bceSAndroid Build Coastguard Worker                 config.probabilities[THREADOPERATIONID_COPYTEXIMAGE2D][THREADOPERATIONID_CREATE_TEXTURE]  = 0.40f;
4725*35238bceSAndroid Build Coastguard Worker                 config.probabilities[THREADOPERATIONID_COPYTEXIMAGE2D][THREADOPERATIONID_COPYTEXIMAGE2D]  = 0.20f;
4726*35238bceSAndroid Build Coastguard Worker 
4727*35238bceSAndroid Build Coastguard Worker                 std::string name = de::toString(textureTestNdx);
4728*35238bceSAndroid Build Coastguard Worker                 copyTexImage2DTests->addChild(new GLES2SharingRandomTest(ctx, config, name.c_str(), name.c_str()));
4729*35238bceSAndroid Build Coastguard Worker             }
4730*35238bceSAndroid Build Coastguard Worker 
4731*35238bceSAndroid Build Coastguard Worker             textureTests->addChild(copyTexImage2DTests);
4732*35238bceSAndroid Build Coastguard Worker         }
4733*35238bceSAndroid Build Coastguard Worker 
4734*35238bceSAndroid Build Coastguard Worker         {
4735*35238bceSAndroid Build Coastguard Worker             TestCaseGroup *copyTexSubImage2DTests = new TestCaseGroup(
4736*35238bceSAndroid Build Coastguard Worker                 ctx, "copytexsubimage2d", "Texture gen, delete, teximage2D and copytexsubimage2d tests");
4737*35238bceSAndroid Build Coastguard Worker 
4738*35238bceSAndroid Build Coastguard Worker             for (int textureTestNdx = 0; textureTestNdx < 20; textureTestNdx++)
4739*35238bceSAndroid Build Coastguard Worker             {
4740*35238bceSAndroid Build Coastguard Worker                 GLES2SharingRandomTest::TestConfig config;
4741*35238bceSAndroid Build Coastguard Worker                 config.useFenceSync   = useSync;
4742*35238bceSAndroid Build Coastguard Worker                 config.serverSync     = serverSync;
4743*35238bceSAndroid Build Coastguard Worker                 config.threadCount    = 2 + textureTestNdx % 5;
4744*35238bceSAndroid Build Coastguard Worker                 config.operationCount = 50 + textureTestNdx;
4745*35238bceSAndroid Build Coastguard Worker 
4746*35238bceSAndroid Build Coastguard Worker                 config.probabilities[THREADOPERATIONID_NONE][THREADOPERATIONID_CREATE_TEXTURE] = 1.0f;
4747*35238bceSAndroid Build Coastguard Worker 
4748*35238bceSAndroid Build Coastguard Worker                 config.probabilities[THREADOPERATIONID_CREATE_TEXTURE][THREADOPERATIONID_DESTROY_TEXTURE]   = 0.05f;
4749*35238bceSAndroid Build Coastguard Worker                 config.probabilities[THREADOPERATIONID_CREATE_TEXTURE][THREADOPERATIONID_CREATE_TEXTURE]    = 0.10f;
4750*35238bceSAndroid Build Coastguard Worker                 config.probabilities[THREADOPERATIONID_CREATE_TEXTURE][THREADOPERATIONID_TEXIMAGE2D]        = 0.80f;
4751*35238bceSAndroid Build Coastguard Worker                 config.probabilities[THREADOPERATIONID_CREATE_TEXTURE][THREADOPERATIONID_COPYTEXSUBIMAGE2D] = 0.05f;
4752*35238bceSAndroid Build Coastguard Worker 
4753*35238bceSAndroid Build Coastguard Worker                 config.probabilities[THREADOPERATIONID_DESTROY_TEXTURE][THREADOPERATIONID_DESTROY_TEXTURE]   = 0.30f;
4754*35238bceSAndroid Build Coastguard Worker                 config.probabilities[THREADOPERATIONID_DESTROY_TEXTURE][THREADOPERATIONID_CREATE_TEXTURE]    = 0.40f;
4755*35238bceSAndroid Build Coastguard Worker                 config.probabilities[THREADOPERATIONID_DESTROY_TEXTURE][THREADOPERATIONID_TEXIMAGE2D]        = 0.20f;
4756*35238bceSAndroid Build Coastguard Worker                 config.probabilities[THREADOPERATIONID_DESTROY_TEXTURE][THREADOPERATIONID_COPYTEXSUBIMAGE2D] = 0.10f;
4757*35238bceSAndroid Build Coastguard Worker 
4758*35238bceSAndroid Build Coastguard Worker                 config.probabilities[THREADOPERATIONID_TEXIMAGE2D][THREADOPERATIONID_DESTROY_TEXTURE]   = 0.20f;
4759*35238bceSAndroid Build Coastguard Worker                 config.probabilities[THREADOPERATIONID_TEXIMAGE2D][THREADOPERATIONID_CREATE_TEXTURE]    = 0.20f;
4760*35238bceSAndroid Build Coastguard Worker                 config.probabilities[THREADOPERATIONID_TEXIMAGE2D][THREADOPERATIONID_TEXIMAGE2D]        = 0.10f;
4761*35238bceSAndroid Build Coastguard Worker                 config.probabilities[THREADOPERATIONID_TEXIMAGE2D][THREADOPERATIONID_COPYTEXSUBIMAGE2D] = 0.50f;
4762*35238bceSAndroid Build Coastguard Worker 
4763*35238bceSAndroid Build Coastguard Worker                 config.probabilities[THREADOPERATIONID_COPYTEXSUBIMAGE2D][THREADOPERATIONID_DESTROY_TEXTURE]   = 0.20f;
4764*35238bceSAndroid Build Coastguard Worker                 config.probabilities[THREADOPERATIONID_COPYTEXSUBIMAGE2D][THREADOPERATIONID_CREATE_TEXTURE]    = 0.25f;
4765*35238bceSAndroid Build Coastguard Worker                 config.probabilities[THREADOPERATIONID_COPYTEXSUBIMAGE2D][THREADOPERATIONID_TEXIMAGE2D]        = 0.25f;
4766*35238bceSAndroid Build Coastguard Worker                 config.probabilities[THREADOPERATIONID_COPYTEXSUBIMAGE2D][THREADOPERATIONID_COPYTEXSUBIMAGE2D] = 0.30f;
4767*35238bceSAndroid Build Coastguard Worker 
4768*35238bceSAndroid Build Coastguard Worker                 std::string name = de::toString(textureTestNdx);
4769*35238bceSAndroid Build Coastguard Worker                 copyTexSubImage2DTests->addChild(new GLES2SharingRandomTest(ctx, config, name.c_str(), name.c_str()));
4770*35238bceSAndroid Build Coastguard Worker             }
4771*35238bceSAndroid Build Coastguard Worker 
4772*35238bceSAndroid Build Coastguard Worker             textureTests->addChild(copyTexSubImage2DTests);
4773*35238bceSAndroid Build Coastguard Worker         }
4774*35238bceSAndroid Build Coastguard Worker 
4775*35238bceSAndroid Build Coastguard Worker         group->addChild(textureTests);
4776*35238bceSAndroid Build Coastguard Worker 
4777*35238bceSAndroid Build Coastguard Worker         TestCaseGroup *bufferTests = new TestCaseGroup(ctx, "buffers", "Buffer management tests");
4778*35238bceSAndroid Build Coastguard Worker 
4779*35238bceSAndroid Build Coastguard Worker         {
4780*35238bceSAndroid Build Coastguard Worker             TestCaseGroup *genBufferTests = new TestCaseGroup(ctx, "gen_delete", "Buffer gen and delete tests");
4781*35238bceSAndroid Build Coastguard Worker 
4782*35238bceSAndroid Build Coastguard Worker             for (int bufferTestNdx = 0; bufferTestNdx < 20; bufferTestNdx++)
4783*35238bceSAndroid Build Coastguard Worker             {
4784*35238bceSAndroid Build Coastguard Worker                 GLES2SharingRandomTest::TestConfig config;
4785*35238bceSAndroid Build Coastguard Worker                 config.useFenceSync   = useSync;
4786*35238bceSAndroid Build Coastguard Worker                 config.serverSync     = serverSync;
4787*35238bceSAndroid Build Coastguard Worker                 config.threadCount    = 2 + bufferTestNdx % 5;
4788*35238bceSAndroid Build Coastguard Worker                 config.operationCount = 30 + bufferTestNdx;
4789*35238bceSAndroid Build Coastguard Worker 
4790*35238bceSAndroid Build Coastguard Worker                 config.probabilities[THREADOPERATIONID_NONE][THREADOPERATIONID_CREATE_BUFFER] = 1.0f;
4791*35238bceSAndroid Build Coastguard Worker 
4792*35238bceSAndroid Build Coastguard Worker                 config.probabilities[THREADOPERATIONID_CREATE_BUFFER][THREADOPERATIONID_DESTROY_BUFFER] = 0.25f;
4793*35238bceSAndroid Build Coastguard Worker                 config.probabilities[THREADOPERATIONID_CREATE_BUFFER][THREADOPERATIONID_CREATE_BUFFER]  = 0.75f;
4794*35238bceSAndroid Build Coastguard Worker 
4795*35238bceSAndroid Build Coastguard Worker                 config.probabilities[THREADOPERATIONID_DESTROY_BUFFER][THREADOPERATIONID_DESTROY_BUFFER] = 0.5f;
4796*35238bceSAndroid Build Coastguard Worker                 config.probabilities[THREADOPERATIONID_DESTROY_BUFFER][THREADOPERATIONID_CREATE_BUFFER]  = 0.5f;
4797*35238bceSAndroid Build Coastguard Worker 
4798*35238bceSAndroid Build Coastguard Worker                 std::string name = de::toString(bufferTestNdx);
4799*35238bceSAndroid Build Coastguard Worker                 genBufferTests->addChild(new GLES2SharingRandomTest(ctx, config, name.c_str(), name.c_str()));
4800*35238bceSAndroid Build Coastguard Worker             }
4801*35238bceSAndroid Build Coastguard Worker 
4802*35238bceSAndroid Build Coastguard Worker             bufferTests->addChild(genBufferTests);
4803*35238bceSAndroid Build Coastguard Worker         }
4804*35238bceSAndroid Build Coastguard Worker 
4805*35238bceSAndroid Build Coastguard Worker         {
4806*35238bceSAndroid Build Coastguard Worker             TestCaseGroup *texImage2DTests =
4807*35238bceSAndroid Build Coastguard Worker                 new TestCaseGroup(ctx, "bufferdata", "Buffer gen, delete and bufferdata tests");
4808*35238bceSAndroid Build Coastguard Worker 
4809*35238bceSAndroid Build Coastguard Worker             for (int bufferTestNdx = 0; bufferTestNdx < 20; bufferTestNdx++)
4810*35238bceSAndroid Build Coastguard Worker             {
4811*35238bceSAndroid Build Coastguard Worker                 GLES2SharingRandomTest::TestConfig config;
4812*35238bceSAndroid Build Coastguard Worker                 config.useFenceSync   = useSync;
4813*35238bceSAndroid Build Coastguard Worker                 config.serverSync     = serverSync;
4814*35238bceSAndroid Build Coastguard Worker                 config.threadCount    = 2 + bufferTestNdx % 5;
4815*35238bceSAndroid Build Coastguard Worker                 config.operationCount = 40 + bufferTestNdx;
4816*35238bceSAndroid Build Coastguard Worker 
4817*35238bceSAndroid Build Coastguard Worker                 config.probabilities[THREADOPERATIONID_NONE][THREADOPERATIONID_CREATE_BUFFER] = 1.0f;
4818*35238bceSAndroid Build Coastguard Worker 
4819*35238bceSAndroid Build Coastguard Worker                 config.probabilities[THREADOPERATIONID_CREATE_BUFFER][THREADOPERATIONID_DESTROY_BUFFER] = 0.10f;
4820*35238bceSAndroid Build Coastguard Worker                 config.probabilities[THREADOPERATIONID_CREATE_BUFFER][THREADOPERATIONID_CREATE_BUFFER]  = 0.10f;
4821*35238bceSAndroid Build Coastguard Worker                 config.probabilities[THREADOPERATIONID_CREATE_BUFFER][THREADOPERATIONID_BUFFER_DATA]    = 0.80f;
4822*35238bceSAndroid Build Coastguard Worker 
4823*35238bceSAndroid Build Coastguard Worker                 config.probabilities[THREADOPERATIONID_DESTROY_BUFFER][THREADOPERATIONID_DESTROY_BUFFER] = 0.30f;
4824*35238bceSAndroid Build Coastguard Worker                 config.probabilities[THREADOPERATIONID_DESTROY_BUFFER][THREADOPERATIONID_CREATE_BUFFER]  = 0.40f;
4825*35238bceSAndroid Build Coastguard Worker                 config.probabilities[THREADOPERATIONID_DESTROY_BUFFER][THREADOPERATIONID_BUFFER_DATA]    = 0.30f;
4826*35238bceSAndroid Build Coastguard Worker 
4827*35238bceSAndroid Build Coastguard Worker                 config.probabilities[THREADOPERATIONID_BUFFER_DATA][THREADOPERATIONID_DESTROY_BUFFER] = 0.40f;
4828*35238bceSAndroid Build Coastguard Worker                 config.probabilities[THREADOPERATIONID_BUFFER_DATA][THREADOPERATIONID_CREATE_BUFFER]  = 0.40f;
4829*35238bceSAndroid Build Coastguard Worker                 config.probabilities[THREADOPERATIONID_BUFFER_DATA][THREADOPERATIONID_BUFFER_DATA]    = 0.20f;
4830*35238bceSAndroid Build Coastguard Worker 
4831*35238bceSAndroid Build Coastguard Worker                 std::string name = de::toString(bufferTestNdx);
4832*35238bceSAndroid Build Coastguard Worker                 texImage2DTests->addChild(new GLES2SharingRandomTest(ctx, config, name.c_str(), name.c_str()));
4833*35238bceSAndroid Build Coastguard Worker             }
4834*35238bceSAndroid Build Coastguard Worker 
4835*35238bceSAndroid Build Coastguard Worker             bufferTests->addChild(texImage2DTests);
4836*35238bceSAndroid Build Coastguard Worker         }
4837*35238bceSAndroid Build Coastguard Worker 
4838*35238bceSAndroid Build Coastguard Worker         {
4839*35238bceSAndroid Build Coastguard Worker             TestCaseGroup *texSubImage2DTests =
4840*35238bceSAndroid Build Coastguard Worker                 new TestCaseGroup(ctx, "buffersubdata", "Buffer gen, delete, bufferdata and bufferdata tests");
4841*35238bceSAndroid Build Coastguard Worker 
4842*35238bceSAndroid Build Coastguard Worker             for (int bufferTestNdx = 0; bufferTestNdx < 20; bufferTestNdx++)
4843*35238bceSAndroid Build Coastguard Worker             {
4844*35238bceSAndroid Build Coastguard Worker                 GLES2SharingRandomTest::TestConfig config;
4845*35238bceSAndroid Build Coastguard Worker                 config.useFenceSync   = useSync;
4846*35238bceSAndroid Build Coastguard Worker                 config.serverSync     = serverSync;
4847*35238bceSAndroid Build Coastguard Worker                 config.threadCount    = 2 + bufferTestNdx % 5;
4848*35238bceSAndroid Build Coastguard Worker                 config.operationCount = 50 + bufferTestNdx;
4849*35238bceSAndroid Build Coastguard Worker 
4850*35238bceSAndroid Build Coastguard Worker                 config.probabilities[THREADOPERATIONID_NONE][THREADOPERATIONID_CREATE_BUFFER] = 1.0f;
4851*35238bceSAndroid Build Coastguard Worker 
4852*35238bceSAndroid Build Coastguard Worker                 config.probabilities[THREADOPERATIONID_CREATE_BUFFER][THREADOPERATIONID_DESTROY_BUFFER] = 0.05f;
4853*35238bceSAndroid Build Coastguard Worker                 config.probabilities[THREADOPERATIONID_CREATE_BUFFER][THREADOPERATIONID_CREATE_BUFFER]  = 0.10f;
4854*35238bceSAndroid Build Coastguard Worker                 config.probabilities[THREADOPERATIONID_CREATE_BUFFER][THREADOPERATIONID_BUFFER_DATA]    = 0.80f;
4855*35238bceSAndroid Build Coastguard Worker                 config.probabilities[THREADOPERATIONID_CREATE_BUFFER][THREADOPERATIONID_BUFFER_SUBDATA] = 0.05f;
4856*35238bceSAndroid Build Coastguard Worker 
4857*35238bceSAndroid Build Coastguard Worker                 config.probabilities[THREADOPERATIONID_DESTROY_BUFFER][THREADOPERATIONID_DESTROY_BUFFER] = 0.30f;
4858*35238bceSAndroid Build Coastguard Worker                 config.probabilities[THREADOPERATIONID_DESTROY_BUFFER][THREADOPERATIONID_CREATE_BUFFER]  = 0.40f;
4859*35238bceSAndroid Build Coastguard Worker                 config.probabilities[THREADOPERATIONID_DESTROY_BUFFER][THREADOPERATIONID_BUFFER_DATA]    = 0.20f;
4860*35238bceSAndroid Build Coastguard Worker                 config.probabilities[THREADOPERATIONID_DESTROY_BUFFER][THREADOPERATIONID_BUFFER_SUBDATA] = 0.10f;
4861*35238bceSAndroid Build Coastguard Worker 
4862*35238bceSAndroid Build Coastguard Worker                 config.probabilities[THREADOPERATIONID_BUFFER_DATA][THREADOPERATIONID_DESTROY_BUFFER] = 0.20f;
4863*35238bceSAndroid Build Coastguard Worker                 config.probabilities[THREADOPERATIONID_BUFFER_DATA][THREADOPERATIONID_CREATE_BUFFER]  = 0.20f;
4864*35238bceSAndroid Build Coastguard Worker                 config.probabilities[THREADOPERATIONID_BUFFER_DATA][THREADOPERATIONID_BUFFER_DATA]    = 0.10f;
4865*35238bceSAndroid Build Coastguard Worker                 config.probabilities[THREADOPERATIONID_BUFFER_DATA][THREADOPERATIONID_BUFFER_SUBDATA] = 0.50f;
4866*35238bceSAndroid Build Coastguard Worker 
4867*35238bceSAndroid Build Coastguard Worker                 config.probabilities[THREADOPERATIONID_BUFFER_SUBDATA][THREADOPERATIONID_DESTROY_BUFFER] = 0.20f;
4868*35238bceSAndroid Build Coastguard Worker                 config.probabilities[THREADOPERATIONID_BUFFER_SUBDATA][THREADOPERATIONID_CREATE_BUFFER]  = 0.25f;
4869*35238bceSAndroid Build Coastguard Worker                 config.probabilities[THREADOPERATIONID_BUFFER_SUBDATA][THREADOPERATIONID_BUFFER_DATA]    = 0.25f;
4870*35238bceSAndroid Build Coastguard Worker                 config.probabilities[THREADOPERATIONID_BUFFER_SUBDATA][THREADOPERATIONID_BUFFER_SUBDATA] = 0.30f;
4871*35238bceSAndroid Build Coastguard Worker 
4872*35238bceSAndroid Build Coastguard Worker                 std::string name = de::toString(bufferTestNdx);
4873*35238bceSAndroid Build Coastguard Worker                 texSubImage2DTests->addChild(new GLES2SharingRandomTest(ctx, config, name.c_str(), name.c_str()));
4874*35238bceSAndroid Build Coastguard Worker             }
4875*35238bceSAndroid Build Coastguard Worker 
4876*35238bceSAndroid Build Coastguard Worker             bufferTests->addChild(texSubImage2DTests);
4877*35238bceSAndroid Build Coastguard Worker         }
4878*35238bceSAndroid Build Coastguard Worker 
4879*35238bceSAndroid Build Coastguard Worker         group->addChild(bufferTests);
4880*35238bceSAndroid Build Coastguard Worker 
4881*35238bceSAndroid Build Coastguard Worker         TestCaseGroup *shaderTests = new TestCaseGroup(ctx, "shaders", "Shader management tests");
4882*35238bceSAndroid Build Coastguard Worker 
4883*35238bceSAndroid Build Coastguard Worker         {
4884*35238bceSAndroid Build Coastguard Worker             TestCaseGroup *createShaderTests =
4885*35238bceSAndroid Build Coastguard Worker                 new TestCaseGroup(ctx, "create_destroy", "Shader create and destroy tests");
4886*35238bceSAndroid Build Coastguard Worker 
4887*35238bceSAndroid Build Coastguard Worker             for (int shaderTestNdx = 0; shaderTestNdx < 20; shaderTestNdx++)
4888*35238bceSAndroid Build Coastguard Worker             {
4889*35238bceSAndroid Build Coastguard Worker                 GLES2SharingRandomTest::TestConfig config;
4890*35238bceSAndroid Build Coastguard Worker                 config.useFenceSync   = useSync;
4891*35238bceSAndroid Build Coastguard Worker                 config.serverSync     = serverSync;
4892*35238bceSAndroid Build Coastguard Worker                 config.threadCount    = 2 + shaderTestNdx % 5;
4893*35238bceSAndroid Build Coastguard Worker                 config.operationCount = 30 + shaderTestNdx;
4894*35238bceSAndroid Build Coastguard Worker 
4895*35238bceSAndroid Build Coastguard Worker                 config.probabilities[THREADOPERATIONID_NONE][THREADOPERATIONID_CREATE_VERTEX_SHADER]   = 0.5f;
4896*35238bceSAndroid Build Coastguard Worker                 config.probabilities[THREADOPERATIONID_NONE][THREADOPERATIONID_CREATE_FRAGMENT_SHADER] = 0.5f;
4897*35238bceSAndroid Build Coastguard Worker 
4898*35238bceSAndroid Build Coastguard Worker                 config.probabilities[THREADOPERATIONID_CREATE_VERTEX_SHADER][THREADOPERATIONID_DESTROY_SHADER] = 0.20f;
4899*35238bceSAndroid Build Coastguard Worker                 config.probabilities[THREADOPERATIONID_CREATE_VERTEX_SHADER][THREADOPERATIONID_CREATE_VERTEX_SHADER] =
4900*35238bceSAndroid Build Coastguard Worker                     0.40f;
4901*35238bceSAndroid Build Coastguard Worker                 config.probabilities[THREADOPERATIONID_CREATE_VERTEX_SHADER][THREADOPERATIONID_CREATE_FRAGMENT_SHADER] =
4902*35238bceSAndroid Build Coastguard Worker                     0.40f;
4903*35238bceSAndroid Build Coastguard Worker 
4904*35238bceSAndroid Build Coastguard Worker                 config.probabilities[THREADOPERATIONID_CREATE_FRAGMENT_SHADER][THREADOPERATIONID_DESTROY_SHADER] =
4905*35238bceSAndroid Build Coastguard Worker                     0.20f;
4906*35238bceSAndroid Build Coastguard Worker                 config.probabilities[THREADOPERATIONID_CREATE_FRAGMENT_SHADER][THREADOPERATIONID_CREATE_VERTEX_SHADER] =
4907*35238bceSAndroid Build Coastguard Worker                     0.40f;
4908*35238bceSAndroid Build Coastguard Worker                 config
4909*35238bceSAndroid Build Coastguard Worker                     .probabilities[THREADOPERATIONID_CREATE_FRAGMENT_SHADER][THREADOPERATIONID_CREATE_FRAGMENT_SHADER] =
4910*35238bceSAndroid Build Coastguard Worker                     0.40f;
4911*35238bceSAndroid Build Coastguard Worker 
4912*35238bceSAndroid Build Coastguard Worker                 config.probabilities[THREADOPERATIONID_DESTROY_SHADER][THREADOPERATIONID_DESTROY_SHADER]       = 0.5f;
4913*35238bceSAndroid Build Coastguard Worker                 config.probabilities[THREADOPERATIONID_DESTROY_SHADER][THREADOPERATIONID_CREATE_VERTEX_SHADER] = 0.25f;
4914*35238bceSAndroid Build Coastguard Worker                 config.probabilities[THREADOPERATIONID_DESTROY_SHADER][THREADOPERATIONID_CREATE_FRAGMENT_SHADER] =
4915*35238bceSAndroid Build Coastguard Worker                     0.25f;
4916*35238bceSAndroid Build Coastguard Worker 
4917*35238bceSAndroid Build Coastguard Worker                 std::string name = de::toString(shaderTestNdx);
4918*35238bceSAndroid Build Coastguard Worker                 createShaderTests->addChild(new GLES2SharingRandomTest(ctx, config, name.c_str(), name.c_str()));
4919*35238bceSAndroid Build Coastguard Worker             }
4920*35238bceSAndroid Build Coastguard Worker 
4921*35238bceSAndroid Build Coastguard Worker             shaderTests->addChild(createShaderTests);
4922*35238bceSAndroid Build Coastguard Worker         }
4923*35238bceSAndroid Build Coastguard Worker 
4924*35238bceSAndroid Build Coastguard Worker         {
4925*35238bceSAndroid Build Coastguard Worker             TestCaseGroup *texImage2DTests =
4926*35238bceSAndroid Build Coastguard Worker                 new TestCaseGroup(ctx, "source", "Shader create, destroy and source tests");
4927*35238bceSAndroid Build Coastguard Worker 
4928*35238bceSAndroid Build Coastguard Worker             for (int shaderTestNdx = 0; shaderTestNdx < 20; shaderTestNdx++)
4929*35238bceSAndroid Build Coastguard Worker             {
4930*35238bceSAndroid Build Coastguard Worker                 GLES2SharingRandomTest::TestConfig config;
4931*35238bceSAndroid Build Coastguard Worker                 config.useFenceSync   = useSync;
4932*35238bceSAndroid Build Coastguard Worker                 config.serverSync     = serverSync;
4933*35238bceSAndroid Build Coastguard Worker                 config.threadCount    = 2 + shaderTestNdx % 5;
4934*35238bceSAndroid Build Coastguard Worker                 config.operationCount = 40 + shaderTestNdx;
4935*35238bceSAndroid Build Coastguard Worker 
4936*35238bceSAndroid Build Coastguard Worker                 config.probabilities[THREADOPERATIONID_NONE][THREADOPERATIONID_CREATE_VERTEX_SHADER]   = 0.5f;
4937*35238bceSAndroid Build Coastguard Worker                 config.probabilities[THREADOPERATIONID_NONE][THREADOPERATIONID_CREATE_FRAGMENT_SHADER] = 0.5f;
4938*35238bceSAndroid Build Coastguard Worker 
4939*35238bceSAndroid Build Coastguard Worker                 config.probabilities[THREADOPERATIONID_CREATE_VERTEX_SHADER][THREADOPERATIONID_DESTROY_SHADER] = 0.10f;
4940*35238bceSAndroid Build Coastguard Worker                 config.probabilities[THREADOPERATIONID_CREATE_VERTEX_SHADER][THREADOPERATIONID_CREATE_VERTEX_SHADER] =
4941*35238bceSAndroid Build Coastguard Worker                     0.20f;
4942*35238bceSAndroid Build Coastguard Worker                 config.probabilities[THREADOPERATIONID_CREATE_VERTEX_SHADER][THREADOPERATIONID_CREATE_FRAGMENT_SHADER] =
4943*35238bceSAndroid Build Coastguard Worker                     0.20f;
4944*35238bceSAndroid Build Coastguard Worker                 config.probabilities[THREADOPERATIONID_CREATE_VERTEX_SHADER][THREADOPERATIONID_SHADER_SOURCE] = 0.50f;
4945*35238bceSAndroid Build Coastguard Worker 
4946*35238bceSAndroid Build Coastguard Worker                 config.probabilities[THREADOPERATIONID_CREATE_FRAGMENT_SHADER][THREADOPERATIONID_DESTROY_SHADER] =
4947*35238bceSAndroid Build Coastguard Worker                     0.10f;
4948*35238bceSAndroid Build Coastguard Worker                 config.probabilities[THREADOPERATIONID_CREATE_FRAGMENT_SHADER][THREADOPERATIONID_CREATE_VERTEX_SHADER] =
4949*35238bceSAndroid Build Coastguard Worker                     0.20f;
4950*35238bceSAndroid Build Coastguard Worker                 config
4951*35238bceSAndroid Build Coastguard Worker                     .probabilities[THREADOPERATIONID_CREATE_FRAGMENT_SHADER][THREADOPERATIONID_CREATE_FRAGMENT_SHADER] =
4952*35238bceSAndroid Build Coastguard Worker                     0.20f;
4953*35238bceSAndroid Build Coastguard Worker                 config.probabilities[THREADOPERATIONID_CREATE_FRAGMENT_SHADER][THREADOPERATIONID_SHADER_SOURCE] = 0.50f;
4954*35238bceSAndroid Build Coastguard Worker 
4955*35238bceSAndroid Build Coastguard Worker                 config.probabilities[THREADOPERATIONID_DESTROY_SHADER][THREADOPERATIONID_DESTROY_SHADER]       = 0.30f;
4956*35238bceSAndroid Build Coastguard Worker                 config.probabilities[THREADOPERATIONID_DESTROY_SHADER][THREADOPERATIONID_CREATE_VERTEX_SHADER] = 0.30f;
4957*35238bceSAndroid Build Coastguard Worker                 config.probabilities[THREADOPERATIONID_DESTROY_SHADER][THREADOPERATIONID_CREATE_FRAGMENT_SHADER] =
4958*35238bceSAndroid Build Coastguard Worker                     0.30f;
4959*35238bceSAndroid Build Coastguard Worker                 config.probabilities[THREADOPERATIONID_DESTROY_SHADER][THREADOPERATIONID_SHADER_SOURCE] = 0.10f;
4960*35238bceSAndroid Build Coastguard Worker 
4961*35238bceSAndroid Build Coastguard Worker                 config.probabilities[THREADOPERATIONID_SHADER_SOURCE][THREADOPERATIONID_DESTROY_SHADER]         = 0.20f;
4962*35238bceSAndroid Build Coastguard Worker                 config.probabilities[THREADOPERATIONID_SHADER_SOURCE][THREADOPERATIONID_CREATE_VERTEX_SHADER]   = 0.20f;
4963*35238bceSAndroid Build Coastguard Worker                 config.probabilities[THREADOPERATIONID_SHADER_SOURCE][THREADOPERATIONID_CREATE_FRAGMENT_SHADER] = 0.20f;
4964*35238bceSAndroid Build Coastguard Worker                 config.probabilities[THREADOPERATIONID_SHADER_SOURCE][THREADOPERATIONID_SHADER_SOURCE]          = 0.40f;
4965*35238bceSAndroid Build Coastguard Worker 
4966*35238bceSAndroid Build Coastguard Worker                 std::string name = de::toString(shaderTestNdx);
4967*35238bceSAndroid Build Coastguard Worker                 texImage2DTests->addChild(new GLES2SharingRandomTest(ctx, config, name.c_str(), name.c_str()));
4968*35238bceSAndroid Build Coastguard Worker             }
4969*35238bceSAndroid Build Coastguard Worker 
4970*35238bceSAndroid Build Coastguard Worker             shaderTests->addChild(texImage2DTests);
4971*35238bceSAndroid Build Coastguard Worker         }
4972*35238bceSAndroid Build Coastguard Worker 
4973*35238bceSAndroid Build Coastguard Worker         {
4974*35238bceSAndroid Build Coastguard Worker             TestCaseGroup *texSubImage2DTests =
4975*35238bceSAndroid Build Coastguard Worker                 new TestCaseGroup(ctx, "compile", "Shader create, destroy, source and compile tests");
4976*35238bceSAndroid Build Coastguard Worker 
4977*35238bceSAndroid Build Coastguard Worker             for (int shaderTestNdx = 0; shaderTestNdx < 20; shaderTestNdx++)
4978*35238bceSAndroid Build Coastguard Worker             {
4979*35238bceSAndroid Build Coastguard Worker                 GLES2SharingRandomTest::TestConfig config;
4980*35238bceSAndroid Build Coastguard Worker                 config.useFenceSync   = useSync;
4981*35238bceSAndroid Build Coastguard Worker                 config.serverSync     = serverSync;
4982*35238bceSAndroid Build Coastguard Worker                 config.threadCount    = 2 + shaderTestNdx % 5;
4983*35238bceSAndroid Build Coastguard Worker                 config.operationCount = 50 + shaderTestNdx;
4984*35238bceSAndroid Build Coastguard Worker 
4985*35238bceSAndroid Build Coastguard Worker                 config.probabilities[THREADOPERATIONID_NONE][THREADOPERATIONID_CREATE_VERTEX_SHADER]   = 0.5f;
4986*35238bceSAndroid Build Coastguard Worker                 config.probabilities[THREADOPERATIONID_NONE][THREADOPERATIONID_CREATE_FRAGMENT_SHADER] = 0.5f;
4987*35238bceSAndroid Build Coastguard Worker 
4988*35238bceSAndroid Build Coastguard Worker                 config.probabilities[THREADOPERATIONID_CREATE_VERTEX_SHADER][THREADOPERATIONID_DESTROY_SHADER] = 0.10f;
4989*35238bceSAndroid Build Coastguard Worker                 config.probabilities[THREADOPERATIONID_CREATE_VERTEX_SHADER][THREADOPERATIONID_CREATE_VERTEX_SHADER] =
4990*35238bceSAndroid Build Coastguard Worker                     0.15f;
4991*35238bceSAndroid Build Coastguard Worker                 config.probabilities[THREADOPERATIONID_CREATE_VERTEX_SHADER][THREADOPERATIONID_CREATE_FRAGMENT_SHADER] =
4992*35238bceSAndroid Build Coastguard Worker                     0.15f;
4993*35238bceSAndroid Build Coastguard Worker                 config.probabilities[THREADOPERATIONID_CREATE_VERTEX_SHADER][THREADOPERATIONID_SHADER_SOURCE]  = 0.50f;
4994*35238bceSAndroid Build Coastguard Worker                 config.probabilities[THREADOPERATIONID_CREATE_VERTEX_SHADER][THREADOPERATIONID_SHADER_COMPILE] = 0.10f;
4995*35238bceSAndroid Build Coastguard Worker 
4996*35238bceSAndroid Build Coastguard Worker                 config.probabilities[THREADOPERATIONID_CREATE_FRAGMENT_SHADER][THREADOPERATIONID_DESTROY_SHADER] =
4997*35238bceSAndroid Build Coastguard Worker                     0.10f;
4998*35238bceSAndroid Build Coastguard Worker                 config.probabilities[THREADOPERATIONID_CREATE_FRAGMENT_SHADER][THREADOPERATIONID_CREATE_VERTEX_SHADER] =
4999*35238bceSAndroid Build Coastguard Worker                     0.15f;
5000*35238bceSAndroid Build Coastguard Worker                 config
5001*35238bceSAndroid Build Coastguard Worker                     .probabilities[THREADOPERATIONID_CREATE_FRAGMENT_SHADER][THREADOPERATIONID_CREATE_FRAGMENT_SHADER] =
5002*35238bceSAndroid Build Coastguard Worker                     0.15f;
5003*35238bceSAndroid Build Coastguard Worker                 config.probabilities[THREADOPERATIONID_CREATE_FRAGMENT_SHADER][THREADOPERATIONID_SHADER_SOURCE] = 0.50f;
5004*35238bceSAndroid Build Coastguard Worker                 config.probabilities[THREADOPERATIONID_CREATE_FRAGMENT_SHADER][THREADOPERATIONID_SHADER_COMPILE] =
5005*35238bceSAndroid Build Coastguard Worker                     0.10f;
5006*35238bceSAndroid Build Coastguard Worker 
5007*35238bceSAndroid Build Coastguard Worker                 config.probabilities[THREADOPERATIONID_DESTROY_SHADER][THREADOPERATIONID_DESTROY_SHADER]       = 0.30f;
5008*35238bceSAndroid Build Coastguard Worker                 config.probabilities[THREADOPERATIONID_DESTROY_SHADER][THREADOPERATIONID_CREATE_VERTEX_SHADER] = 0.25f;
5009*35238bceSAndroid Build Coastguard Worker                 config.probabilities[THREADOPERATIONID_DESTROY_SHADER][THREADOPERATIONID_CREATE_FRAGMENT_SHADER] =
5010*35238bceSAndroid Build Coastguard Worker                     0.25f;
5011*35238bceSAndroid Build Coastguard Worker                 config.probabilities[THREADOPERATIONID_DESTROY_SHADER][THREADOPERATIONID_SHADER_SOURCE]  = 0.10f;
5012*35238bceSAndroid Build Coastguard Worker                 config.probabilities[THREADOPERATIONID_DESTROY_SHADER][THREADOPERATIONID_SHADER_COMPILE] = 0.10f;
5013*35238bceSAndroid Build Coastguard Worker 
5014*35238bceSAndroid Build Coastguard Worker                 config.probabilities[THREADOPERATIONID_SHADER_SOURCE][THREADOPERATIONID_DESTROY_SHADER]         = 0.10f;
5015*35238bceSAndroid Build Coastguard Worker                 config.probabilities[THREADOPERATIONID_SHADER_SOURCE][THREADOPERATIONID_CREATE_VERTEX_SHADER]   = 0.10f;
5016*35238bceSAndroid Build Coastguard Worker                 config.probabilities[THREADOPERATIONID_SHADER_SOURCE][THREADOPERATIONID_CREATE_FRAGMENT_SHADER] = 0.10f;
5017*35238bceSAndroid Build Coastguard Worker                 config.probabilities[THREADOPERATIONID_SHADER_SOURCE][THREADOPERATIONID_SHADER_SOURCE]          = 0.20f;
5018*35238bceSAndroid Build Coastguard Worker                 config.probabilities[THREADOPERATIONID_SHADER_SOURCE][THREADOPERATIONID_SHADER_COMPILE]         = 0.50f;
5019*35238bceSAndroid Build Coastguard Worker 
5020*35238bceSAndroid Build Coastguard Worker                 config.probabilities[THREADOPERATIONID_SHADER_COMPILE][THREADOPERATIONID_DESTROY_SHADER]       = 0.15f;
5021*35238bceSAndroid Build Coastguard Worker                 config.probabilities[THREADOPERATIONID_SHADER_COMPILE][THREADOPERATIONID_CREATE_VERTEX_SHADER] = 0.15f;
5022*35238bceSAndroid Build Coastguard Worker                 config.probabilities[THREADOPERATIONID_SHADER_COMPILE][THREADOPERATIONID_CREATE_FRAGMENT_SHADER] =
5023*35238bceSAndroid Build Coastguard Worker                     0.15f;
5024*35238bceSAndroid Build Coastguard Worker                 config.probabilities[THREADOPERATIONID_SHADER_COMPILE][THREADOPERATIONID_SHADER_SOURCE]  = 0.30f;
5025*35238bceSAndroid Build Coastguard Worker                 config.probabilities[THREADOPERATIONID_SHADER_COMPILE][THREADOPERATIONID_SHADER_COMPILE] = 0.30f;
5026*35238bceSAndroid Build Coastguard Worker 
5027*35238bceSAndroid Build Coastguard Worker                 std::string name = de::toString(shaderTestNdx);
5028*35238bceSAndroid Build Coastguard Worker                 texSubImage2DTests->addChild(new GLES2SharingRandomTest(ctx, config, name.c_str(), name.c_str()));
5029*35238bceSAndroid Build Coastguard Worker             }
5030*35238bceSAndroid Build Coastguard Worker 
5031*35238bceSAndroid Build Coastguard Worker             shaderTests->addChild(texSubImage2DTests);
5032*35238bceSAndroid Build Coastguard Worker         }
5033*35238bceSAndroid Build Coastguard Worker 
5034*35238bceSAndroid Build Coastguard Worker         group->addChild(shaderTests);
5035*35238bceSAndroid Build Coastguard Worker 
5036*35238bceSAndroid Build Coastguard Worker         TestCaseGroup *programTests = new TestCaseGroup(ctx, "programs", "Program management tests");
5037*35238bceSAndroid Build Coastguard Worker 
5038*35238bceSAndroid Build Coastguard Worker         {
5039*35238bceSAndroid Build Coastguard Worker             TestCaseGroup *createProgramTests =
5040*35238bceSAndroid Build Coastguard Worker                 new TestCaseGroup(ctx, "create_destroy", "Program create and destroy tests");
5041*35238bceSAndroid Build Coastguard Worker 
5042*35238bceSAndroid Build Coastguard Worker             for (int programTestNdx = 0; programTestNdx < 20; programTestNdx++)
5043*35238bceSAndroid Build Coastguard Worker             {
5044*35238bceSAndroid Build Coastguard Worker                 GLES2SharingRandomTest::TestConfig config;
5045*35238bceSAndroid Build Coastguard Worker                 config.useFenceSync   = useSync;
5046*35238bceSAndroid Build Coastguard Worker                 config.serverSync     = serverSync;
5047*35238bceSAndroid Build Coastguard Worker                 config.threadCount    = 2 + programTestNdx % 5;
5048*35238bceSAndroid Build Coastguard Worker                 config.operationCount = 30 + programTestNdx;
5049*35238bceSAndroid Build Coastguard Worker 
5050*35238bceSAndroid Build Coastguard Worker                 config.probabilities[THREADOPERATIONID_NONE][THREADOPERATIONID_CREATE_PROGRAM] = 1.0f;
5051*35238bceSAndroid Build Coastguard Worker 
5052*35238bceSAndroid Build Coastguard Worker                 config.probabilities[THREADOPERATIONID_CREATE_PROGRAM][THREADOPERATIONID_DESTROY_PROGRAM] = 0.25f;
5053*35238bceSAndroid Build Coastguard Worker                 config.probabilities[THREADOPERATIONID_CREATE_PROGRAM][THREADOPERATIONID_CREATE_PROGRAM]  = 0.75f;
5054*35238bceSAndroid Build Coastguard Worker 
5055*35238bceSAndroid Build Coastguard Worker                 config.probabilities[THREADOPERATIONID_DESTROY_PROGRAM][THREADOPERATIONID_DESTROY_PROGRAM] = 0.5f;
5056*35238bceSAndroid Build Coastguard Worker                 config.probabilities[THREADOPERATIONID_DESTROY_PROGRAM][THREADOPERATIONID_CREATE_PROGRAM]  = 0.5f;
5057*35238bceSAndroid Build Coastguard Worker 
5058*35238bceSAndroid Build Coastguard Worker                 std::string name = de::toString(programTestNdx);
5059*35238bceSAndroid Build Coastguard Worker                 createProgramTests->addChild(new GLES2SharingRandomTest(ctx, config, name.c_str(), name.c_str()));
5060*35238bceSAndroid Build Coastguard Worker             }
5061*35238bceSAndroid Build Coastguard Worker 
5062*35238bceSAndroid Build Coastguard Worker             programTests->addChild(createProgramTests);
5063*35238bceSAndroid Build Coastguard Worker         }
5064*35238bceSAndroid Build Coastguard Worker 
5065*35238bceSAndroid Build Coastguard Worker         {
5066*35238bceSAndroid Build Coastguard Worker             TestCaseGroup *texImage2DTests =
5067*35238bceSAndroid Build Coastguard Worker                 new TestCaseGroup(ctx, "attach_detach", "Program create, destroy, attach and detach tests");
5068*35238bceSAndroid Build Coastguard Worker 
5069*35238bceSAndroid Build Coastguard Worker             for (int programTestNdx = 0; programTestNdx < 20; programTestNdx++)
5070*35238bceSAndroid Build Coastguard Worker             {
5071*35238bceSAndroid Build Coastguard Worker                 GLES2SharingRandomTest::TestConfig config;
5072*35238bceSAndroid Build Coastguard Worker                 config.useFenceSync   = useSync;
5073*35238bceSAndroid Build Coastguard Worker                 config.serverSync     = serverSync;
5074*35238bceSAndroid Build Coastguard Worker                 config.threadCount    = 2 + programTestNdx % 5;
5075*35238bceSAndroid Build Coastguard Worker                 config.operationCount = 60 + programTestNdx;
5076*35238bceSAndroid Build Coastguard Worker 
5077*35238bceSAndroid Build Coastguard Worker                 config.probabilities[THREADOPERATIONID_NONE][THREADOPERATIONID_CREATE_VERTEX_SHADER]   = 0.35f;
5078*35238bceSAndroid Build Coastguard Worker                 config.probabilities[THREADOPERATIONID_NONE][THREADOPERATIONID_CREATE_FRAGMENT_SHADER] = 0.35f;
5079*35238bceSAndroid Build Coastguard Worker                 config.probabilities[THREADOPERATIONID_NONE][THREADOPERATIONID_CREATE_PROGRAM]         = 0.30f;
5080*35238bceSAndroid Build Coastguard Worker 
5081*35238bceSAndroid Build Coastguard Worker                 config.probabilities[THREADOPERATIONID_CREATE_VERTEX_SHADER][THREADOPERATIONID_DESTROY_SHADER] = 0.10f;
5082*35238bceSAndroid Build Coastguard Worker                 config.probabilities[THREADOPERATIONID_CREATE_VERTEX_SHADER][THREADOPERATIONID_CREATE_VERTEX_SHADER] =
5083*35238bceSAndroid Build Coastguard Worker                     0.10f;
5084*35238bceSAndroid Build Coastguard Worker                 config.probabilities[THREADOPERATIONID_CREATE_VERTEX_SHADER][THREADOPERATIONID_CREATE_FRAGMENT_SHADER] =
5085*35238bceSAndroid Build Coastguard Worker                     0.10f;
5086*35238bceSAndroid Build Coastguard Worker                 config.probabilities[THREADOPERATIONID_CREATE_VERTEX_SHADER][THREADOPERATIONID_SHADER_SOURCE]   = 0.30f;
5087*35238bceSAndroid Build Coastguard Worker                 config.probabilities[THREADOPERATIONID_CREATE_VERTEX_SHADER][THREADOPERATIONID_SHADER_COMPILE]  = 0.10f;
5088*35238bceSAndroid Build Coastguard Worker                 config.probabilities[THREADOPERATIONID_CREATE_VERTEX_SHADER][THREADOPERATIONID_CREATE_PROGRAM]  = 0.10f;
5089*35238bceSAndroid Build Coastguard Worker                 config.probabilities[THREADOPERATIONID_CREATE_VERTEX_SHADER][THREADOPERATIONID_DESTROY_PROGRAM] = 0.05f;
5090*35238bceSAndroid Build Coastguard Worker                 config.probabilities[THREADOPERATIONID_CREATE_VERTEX_SHADER][THREADOPERATIONID_ATTACH_SHADER]   = 0.15f;
5091*35238bceSAndroid Build Coastguard Worker 
5092*35238bceSAndroid Build Coastguard Worker                 config.probabilities[THREADOPERATIONID_CREATE_FRAGMENT_SHADER][THREADOPERATIONID_DESTROY_SHADER] =
5093*35238bceSAndroid Build Coastguard Worker                     0.10f;
5094*35238bceSAndroid Build Coastguard Worker                 config.probabilities[THREADOPERATIONID_CREATE_FRAGMENT_SHADER][THREADOPERATIONID_CREATE_VERTEX_SHADER] =
5095*35238bceSAndroid Build Coastguard Worker                     0.10f;
5096*35238bceSAndroid Build Coastguard Worker                 config
5097*35238bceSAndroid Build Coastguard Worker                     .probabilities[THREADOPERATIONID_CREATE_FRAGMENT_SHADER][THREADOPERATIONID_CREATE_FRAGMENT_SHADER] =
5098*35238bceSAndroid Build Coastguard Worker                     0.10f;
5099*35238bceSAndroid Build Coastguard Worker                 config.probabilities[THREADOPERATIONID_CREATE_FRAGMENT_SHADER][THREADOPERATIONID_SHADER_SOURCE] = 0.30f;
5100*35238bceSAndroid Build Coastguard Worker                 config.probabilities[THREADOPERATIONID_CREATE_FRAGMENT_SHADER][THREADOPERATIONID_SHADER_COMPILE] =
5101*35238bceSAndroid Build Coastguard Worker                     0.10f;
5102*35238bceSAndroid Build Coastguard Worker                 config.probabilities[THREADOPERATIONID_CREATE_FRAGMENT_SHADER][THREADOPERATIONID_CREATE_PROGRAM] =
5103*35238bceSAndroid Build Coastguard Worker                     0.10f;
5104*35238bceSAndroid Build Coastguard Worker                 config.probabilities[THREADOPERATIONID_CREATE_FRAGMENT_SHADER][THREADOPERATIONID_DESTROY_PROGRAM] =
5105*35238bceSAndroid Build Coastguard Worker                     0.05f;
5106*35238bceSAndroid Build Coastguard Worker                 config.probabilities[THREADOPERATIONID_CREATE_FRAGMENT_SHADER][THREADOPERATIONID_ATTACH_SHADER] = 0.15f;
5107*35238bceSAndroid Build Coastguard Worker 
5108*35238bceSAndroid Build Coastguard Worker                 config.probabilities[THREADOPERATIONID_DESTROY_SHADER][THREADOPERATIONID_DESTROY_SHADER]       = 0.20f;
5109*35238bceSAndroid Build Coastguard Worker                 config.probabilities[THREADOPERATIONID_DESTROY_SHADER][THREADOPERATIONID_CREATE_VERTEX_SHADER] = 0.20f;
5110*35238bceSAndroid Build Coastguard Worker                 config.probabilities[THREADOPERATIONID_DESTROY_SHADER][THREADOPERATIONID_CREATE_FRAGMENT_SHADER] =
5111*35238bceSAndroid Build Coastguard Worker                     0.20f;
5112*35238bceSAndroid Build Coastguard Worker                 config.probabilities[THREADOPERATIONID_DESTROY_SHADER][THREADOPERATIONID_SHADER_SOURCE]   = 0.10f;
5113*35238bceSAndroid Build Coastguard Worker                 config.probabilities[THREADOPERATIONID_DESTROY_SHADER][THREADOPERATIONID_SHADER_COMPILE]  = 0.10f;
5114*35238bceSAndroid Build Coastguard Worker                 config.probabilities[THREADOPERATIONID_DESTROY_SHADER][THREADOPERATIONID_CREATE_PROGRAM]  = 0.15f;
5115*35238bceSAndroid Build Coastguard Worker                 config.probabilities[THREADOPERATIONID_DESTROY_SHADER][THREADOPERATIONID_DESTROY_PROGRAM] = 0.15f;
5116*35238bceSAndroid Build Coastguard Worker                 config.probabilities[THREADOPERATIONID_DESTROY_SHADER][THREADOPERATIONID_ATTACH_SHADER]   = 0.15f;
5117*35238bceSAndroid Build Coastguard Worker 
5118*35238bceSAndroid Build Coastguard Worker                 config.probabilities[THREADOPERATIONID_SHADER_SOURCE][THREADOPERATIONID_DESTROY_SHADER]         = 0.10f;
5119*35238bceSAndroid Build Coastguard Worker                 config.probabilities[THREADOPERATIONID_SHADER_SOURCE][THREADOPERATIONID_CREATE_VERTEX_SHADER]   = 0.10f;
5120*35238bceSAndroid Build Coastguard Worker                 config.probabilities[THREADOPERATIONID_SHADER_SOURCE][THREADOPERATIONID_CREATE_FRAGMENT_SHADER] = 0.10f;
5121*35238bceSAndroid Build Coastguard Worker                 config.probabilities[THREADOPERATIONID_SHADER_SOURCE][THREADOPERATIONID_SHADER_SOURCE]          = 0.20f;
5122*35238bceSAndroid Build Coastguard Worker                 config.probabilities[THREADOPERATIONID_SHADER_SOURCE][THREADOPERATIONID_SHADER_COMPILE]         = 0.50f;
5123*35238bceSAndroid Build Coastguard Worker                 config.probabilities[THREADOPERATIONID_SHADER_SOURCE][THREADOPERATIONID_CREATE_PROGRAM]         = 0.10f;
5124*35238bceSAndroid Build Coastguard Worker                 config.probabilities[THREADOPERATIONID_SHADER_SOURCE][THREADOPERATIONID_DESTROY_PROGRAM]        = 0.10f;
5125*35238bceSAndroid Build Coastguard Worker                 config.probabilities[THREADOPERATIONID_SHADER_SOURCE][THREADOPERATIONID_ATTACH_SHADER]          = 0.25f;
5126*35238bceSAndroid Build Coastguard Worker 
5127*35238bceSAndroid Build Coastguard Worker                 config.probabilities[THREADOPERATIONID_SHADER_COMPILE][THREADOPERATIONID_DESTROY_SHADER]       = 0.15f;
5128*35238bceSAndroid Build Coastguard Worker                 config.probabilities[THREADOPERATIONID_SHADER_COMPILE][THREADOPERATIONID_CREATE_VERTEX_SHADER] = 0.15f;
5129*35238bceSAndroid Build Coastguard Worker                 config.probabilities[THREADOPERATIONID_SHADER_COMPILE][THREADOPERATIONID_CREATE_FRAGMENT_SHADER] =
5130*35238bceSAndroid Build Coastguard Worker                     0.15f;
5131*35238bceSAndroid Build Coastguard Worker                 config.probabilities[THREADOPERATIONID_SHADER_COMPILE][THREADOPERATIONID_SHADER_SOURCE]   = 0.30f;
5132*35238bceSAndroid Build Coastguard Worker                 config.probabilities[THREADOPERATIONID_SHADER_COMPILE][THREADOPERATIONID_SHADER_COMPILE]  = 0.30f;
5133*35238bceSAndroid Build Coastguard Worker                 config.probabilities[THREADOPERATIONID_SHADER_COMPILE][THREADOPERATIONID_CREATE_PROGRAM]  = 0.10f;
5134*35238bceSAndroid Build Coastguard Worker                 config.probabilities[THREADOPERATIONID_SHADER_COMPILE][THREADOPERATIONID_DESTROY_PROGRAM] = 0.10f;
5135*35238bceSAndroid Build Coastguard Worker                 config.probabilities[THREADOPERATIONID_SHADER_COMPILE][THREADOPERATIONID_ATTACH_SHADER]   = 0.35f;
5136*35238bceSAndroid Build Coastguard Worker 
5137*35238bceSAndroid Build Coastguard Worker                 config.probabilities[THREADOPERATIONID_CREATE_PROGRAM][THREADOPERATIONID_DESTROY_SHADER]       = 0.10f;
5138*35238bceSAndroid Build Coastguard Worker                 config.probabilities[THREADOPERATIONID_CREATE_PROGRAM][THREADOPERATIONID_CREATE_VERTEX_SHADER] = 0.20f;
5139*35238bceSAndroid Build Coastguard Worker                 config.probabilities[THREADOPERATIONID_CREATE_PROGRAM][THREADOPERATIONID_CREATE_FRAGMENT_SHADER] =
5140*35238bceSAndroid Build Coastguard Worker                     0.20f;
5141*35238bceSAndroid Build Coastguard Worker                 config.probabilities[THREADOPERATIONID_CREATE_PROGRAM][THREADOPERATIONID_SHADER_SOURCE]   = 0.05f;
5142*35238bceSAndroid Build Coastguard Worker                 config.probabilities[THREADOPERATIONID_CREATE_PROGRAM][THREADOPERATIONID_SHADER_COMPILE]  = 0.05f;
5143*35238bceSAndroid Build Coastguard Worker                 config.probabilities[THREADOPERATIONID_CREATE_PROGRAM][THREADOPERATIONID_CREATE_PROGRAM]  = 0.15f;
5144*35238bceSAndroid Build Coastguard Worker                 config.probabilities[THREADOPERATIONID_CREATE_PROGRAM][THREADOPERATIONID_DESTROY_PROGRAM] = 0.05f;
5145*35238bceSAndroid Build Coastguard Worker                 config.probabilities[THREADOPERATIONID_CREATE_PROGRAM][THREADOPERATIONID_ATTACH_SHADER]   = 0.40f;
5146*35238bceSAndroid Build Coastguard Worker 
5147*35238bceSAndroid Build Coastguard Worker                 config.probabilities[THREADOPERATIONID_DESTROY_PROGRAM][THREADOPERATIONID_DESTROY_SHADER]       = 0.20f;
5148*35238bceSAndroid Build Coastguard Worker                 config.probabilities[THREADOPERATIONID_DESTROY_PROGRAM][THREADOPERATIONID_CREATE_VERTEX_SHADER] = 0.20f;
5149*35238bceSAndroid Build Coastguard Worker                 config.probabilities[THREADOPERATIONID_DESTROY_PROGRAM][THREADOPERATIONID_CREATE_FRAGMENT_SHADER] =
5150*35238bceSAndroid Build Coastguard Worker                     0.20f;
5151*35238bceSAndroid Build Coastguard Worker                 config.probabilities[THREADOPERATIONID_DESTROY_PROGRAM][THREADOPERATIONID_SHADER_SOURCE]   = 0.10f;
5152*35238bceSAndroid Build Coastguard Worker                 config.probabilities[THREADOPERATIONID_DESTROY_PROGRAM][THREADOPERATIONID_SHADER_COMPILE]  = 0.10f;
5153*35238bceSAndroid Build Coastguard Worker                 config.probabilities[THREADOPERATIONID_DESTROY_PROGRAM][THREADOPERATIONID_CREATE_PROGRAM]  = 0.20f;
5154*35238bceSAndroid Build Coastguard Worker                 config.probabilities[THREADOPERATIONID_DESTROY_PROGRAM][THREADOPERATIONID_DESTROY_PROGRAM] = 0.15f;
5155*35238bceSAndroid Build Coastguard Worker                 config.probabilities[THREADOPERATIONID_DESTROY_PROGRAM][THREADOPERATIONID_ATTACH_SHADER]   = 0.10f;
5156*35238bceSAndroid Build Coastguard Worker 
5157*35238bceSAndroid Build Coastguard Worker                 config.probabilities[THREADOPERATIONID_ATTACH_SHADER][THREADOPERATIONID_DESTROY_SHADER]         = 0.20f;
5158*35238bceSAndroid Build Coastguard Worker                 config.probabilities[THREADOPERATIONID_ATTACH_SHADER][THREADOPERATIONID_CREATE_VERTEX_SHADER]   = 0.20f;
5159*35238bceSAndroid Build Coastguard Worker                 config.probabilities[THREADOPERATIONID_ATTACH_SHADER][THREADOPERATIONID_CREATE_FRAGMENT_SHADER] = 0.20f;
5160*35238bceSAndroid Build Coastguard Worker                 config.probabilities[THREADOPERATIONID_ATTACH_SHADER][THREADOPERATIONID_SHADER_SOURCE]          = 0.10f;
5161*35238bceSAndroid Build Coastguard Worker                 config.probabilities[THREADOPERATIONID_ATTACH_SHADER][THREADOPERATIONID_SHADER_COMPILE]         = 0.10f;
5162*35238bceSAndroid Build Coastguard Worker                 config.probabilities[THREADOPERATIONID_ATTACH_SHADER][THREADOPERATIONID_CREATE_PROGRAM]         = 0.15f;
5163*35238bceSAndroid Build Coastguard Worker                 config.probabilities[THREADOPERATIONID_ATTACH_SHADER][THREADOPERATIONID_DESTROY_PROGRAM]        = 0.15f;
5164*35238bceSAndroid Build Coastguard Worker                 config.probabilities[THREADOPERATIONID_ATTACH_SHADER][THREADOPERATIONID_ATTACH_SHADER]          = 0.30f;
5165*35238bceSAndroid Build Coastguard Worker 
5166*35238bceSAndroid Build Coastguard Worker                 std::string name = de::toString(programTestNdx);
5167*35238bceSAndroid Build Coastguard Worker                 texImage2DTests->addChild(new GLES2SharingRandomTest(ctx, config, name.c_str(), name.c_str()));
5168*35238bceSAndroid Build Coastguard Worker             }
5169*35238bceSAndroid Build Coastguard Worker 
5170*35238bceSAndroid Build Coastguard Worker             programTests->addChild(texImage2DTests);
5171*35238bceSAndroid Build Coastguard Worker         }
5172*35238bceSAndroid Build Coastguard Worker 
5173*35238bceSAndroid Build Coastguard Worker         {
5174*35238bceSAndroid Build Coastguard Worker             TestCaseGroup *texSubImage2DTests =
5175*35238bceSAndroid Build Coastguard Worker                 new TestCaseGroup(ctx, "link", "Program create, destroy, attach and link tests");
5176*35238bceSAndroid Build Coastguard Worker 
5177*35238bceSAndroid Build Coastguard Worker             for (int programTestNdx = 0; programTestNdx < 20; programTestNdx++)
5178*35238bceSAndroid Build Coastguard Worker             {
5179*35238bceSAndroid Build Coastguard Worker                 GLES2SharingRandomTest::TestConfig config;
5180*35238bceSAndroid Build Coastguard Worker                 config.useFenceSync   = useSync;
5181*35238bceSAndroid Build Coastguard Worker                 config.serverSync     = serverSync;
5182*35238bceSAndroid Build Coastguard Worker                 config.threadCount    = 2 + programTestNdx % 5;
5183*35238bceSAndroid Build Coastguard Worker                 config.operationCount = 70 + programTestNdx;
5184*35238bceSAndroid Build Coastguard Worker 
5185*35238bceSAndroid Build Coastguard Worker                 config.probabilities[THREADOPERATIONID_NONE][THREADOPERATIONID_CREATE_VERTEX_SHADER]   = 0.35f;
5186*35238bceSAndroid Build Coastguard Worker                 config.probabilities[THREADOPERATIONID_NONE][THREADOPERATIONID_CREATE_FRAGMENT_SHADER] = 0.35f;
5187*35238bceSAndroid Build Coastguard Worker                 config.probabilities[THREADOPERATIONID_NONE][THREADOPERATIONID_CREATE_PROGRAM]         = 0.30f;
5188*35238bceSAndroid Build Coastguard Worker 
5189*35238bceSAndroid Build Coastguard Worker                 config.probabilities[THREADOPERATIONID_CREATE_VERTEX_SHADER][THREADOPERATIONID_DESTROY_SHADER] = 0.10f;
5190*35238bceSAndroid Build Coastguard Worker                 config.probabilities[THREADOPERATIONID_CREATE_VERTEX_SHADER][THREADOPERATIONID_CREATE_VERTEX_SHADER] =
5191*35238bceSAndroid Build Coastguard Worker                     0.10f;
5192*35238bceSAndroid Build Coastguard Worker                 config.probabilities[THREADOPERATIONID_CREATE_VERTEX_SHADER][THREADOPERATIONID_CREATE_FRAGMENT_SHADER] =
5193*35238bceSAndroid Build Coastguard Worker                     0.10f;
5194*35238bceSAndroid Build Coastguard Worker                 config.probabilities[THREADOPERATIONID_CREATE_VERTEX_SHADER][THREADOPERATIONID_SHADER_SOURCE]   = 0.30f;
5195*35238bceSAndroid Build Coastguard Worker                 config.probabilities[THREADOPERATIONID_CREATE_VERTEX_SHADER][THREADOPERATIONID_SHADER_COMPILE]  = 0.10f;
5196*35238bceSAndroid Build Coastguard Worker                 config.probabilities[THREADOPERATIONID_CREATE_VERTEX_SHADER][THREADOPERATIONID_CREATE_PROGRAM]  = 0.10f;
5197*35238bceSAndroid Build Coastguard Worker                 config.probabilities[THREADOPERATIONID_CREATE_VERTEX_SHADER][THREADOPERATIONID_DESTROY_PROGRAM] = 0.05f;
5198*35238bceSAndroid Build Coastguard Worker                 config.probabilities[THREADOPERATIONID_CREATE_VERTEX_SHADER][THREADOPERATIONID_ATTACH_SHADER]   = 0.15f;
5199*35238bceSAndroid Build Coastguard Worker                 config.probabilities[THREADOPERATIONID_CREATE_VERTEX_SHADER][THREADOPERATIONID_LINK_PROGRAM]    = 0.10f;
5200*35238bceSAndroid Build Coastguard Worker 
5201*35238bceSAndroid Build Coastguard Worker                 config.probabilities[THREADOPERATIONID_CREATE_FRAGMENT_SHADER][THREADOPERATIONID_DESTROY_SHADER] =
5202*35238bceSAndroid Build Coastguard Worker                     0.10f;
5203*35238bceSAndroid Build Coastguard Worker                 config.probabilities[THREADOPERATIONID_CREATE_FRAGMENT_SHADER][THREADOPERATIONID_CREATE_VERTEX_SHADER] =
5204*35238bceSAndroid Build Coastguard Worker                     0.10f;
5205*35238bceSAndroid Build Coastguard Worker                 config
5206*35238bceSAndroid Build Coastguard Worker                     .probabilities[THREADOPERATIONID_CREATE_FRAGMENT_SHADER][THREADOPERATIONID_CREATE_FRAGMENT_SHADER] =
5207*35238bceSAndroid Build Coastguard Worker                     0.10f;
5208*35238bceSAndroid Build Coastguard Worker                 config.probabilities[THREADOPERATIONID_CREATE_FRAGMENT_SHADER][THREADOPERATIONID_SHADER_SOURCE] = 0.30f;
5209*35238bceSAndroid Build Coastguard Worker                 config.probabilities[THREADOPERATIONID_CREATE_FRAGMENT_SHADER][THREADOPERATIONID_SHADER_COMPILE] =
5210*35238bceSAndroid Build Coastguard Worker                     0.10f;
5211*35238bceSAndroid Build Coastguard Worker                 config.probabilities[THREADOPERATIONID_CREATE_FRAGMENT_SHADER][THREADOPERATIONID_CREATE_PROGRAM] =
5212*35238bceSAndroid Build Coastguard Worker                     0.10f;
5213*35238bceSAndroid Build Coastguard Worker                 config.probabilities[THREADOPERATIONID_CREATE_FRAGMENT_SHADER][THREADOPERATIONID_DESTROY_PROGRAM] =
5214*35238bceSAndroid Build Coastguard Worker                     0.05f;
5215*35238bceSAndroid Build Coastguard Worker                 config.probabilities[THREADOPERATIONID_CREATE_FRAGMENT_SHADER][THREADOPERATIONID_ATTACH_SHADER] = 0.15f;
5216*35238bceSAndroid Build Coastguard Worker                 config.probabilities[THREADOPERATIONID_CREATE_FRAGMENT_SHADER][THREADOPERATIONID_LINK_PROGRAM]  = 0.10f;
5217*35238bceSAndroid Build Coastguard Worker 
5218*35238bceSAndroid Build Coastguard Worker                 config.probabilities[THREADOPERATIONID_DESTROY_SHADER][THREADOPERATIONID_DESTROY_SHADER]       = 0.20f;
5219*35238bceSAndroid Build Coastguard Worker                 config.probabilities[THREADOPERATIONID_DESTROY_SHADER][THREADOPERATIONID_CREATE_VERTEX_SHADER] = 0.20f;
5220*35238bceSAndroid Build Coastguard Worker                 config.probabilities[THREADOPERATIONID_DESTROY_SHADER][THREADOPERATIONID_CREATE_FRAGMENT_SHADER] =
5221*35238bceSAndroid Build Coastguard Worker                     0.20f;
5222*35238bceSAndroid Build Coastguard Worker                 config.probabilities[THREADOPERATIONID_DESTROY_SHADER][THREADOPERATIONID_SHADER_SOURCE]   = 0.10f;
5223*35238bceSAndroid Build Coastguard Worker                 config.probabilities[THREADOPERATIONID_DESTROY_SHADER][THREADOPERATIONID_SHADER_COMPILE]  = 0.10f;
5224*35238bceSAndroid Build Coastguard Worker                 config.probabilities[THREADOPERATIONID_DESTROY_SHADER][THREADOPERATIONID_CREATE_PROGRAM]  = 0.15f;
5225*35238bceSAndroid Build Coastguard Worker                 config.probabilities[THREADOPERATIONID_DESTROY_SHADER][THREADOPERATIONID_DESTROY_PROGRAM] = 0.15f;
5226*35238bceSAndroid Build Coastguard Worker                 config.probabilities[THREADOPERATIONID_DESTROY_SHADER][THREADOPERATIONID_ATTACH_SHADER]   = 0.15f;
5227*35238bceSAndroid Build Coastguard Worker                 config.probabilities[THREADOPERATIONID_DESTROY_SHADER][THREADOPERATIONID_LINK_PROGRAM]    = 0.10f;
5228*35238bceSAndroid Build Coastguard Worker 
5229*35238bceSAndroid Build Coastguard Worker                 config.probabilities[THREADOPERATIONID_SHADER_SOURCE][THREADOPERATIONID_DESTROY_SHADER]         = 0.10f;
5230*35238bceSAndroid Build Coastguard Worker                 config.probabilities[THREADOPERATIONID_SHADER_SOURCE][THREADOPERATIONID_CREATE_VERTEX_SHADER]   = 0.10f;
5231*35238bceSAndroid Build Coastguard Worker                 config.probabilities[THREADOPERATIONID_SHADER_SOURCE][THREADOPERATIONID_CREATE_FRAGMENT_SHADER] = 0.10f;
5232*35238bceSAndroid Build Coastguard Worker                 config.probabilities[THREADOPERATIONID_SHADER_SOURCE][THREADOPERATIONID_SHADER_SOURCE]          = 0.20f;
5233*35238bceSAndroid Build Coastguard Worker                 config.probabilities[THREADOPERATIONID_SHADER_SOURCE][THREADOPERATIONID_SHADER_COMPILE]         = 0.50f;
5234*35238bceSAndroid Build Coastguard Worker                 config.probabilities[THREADOPERATIONID_SHADER_SOURCE][THREADOPERATIONID_CREATE_PROGRAM]         = 0.10f;
5235*35238bceSAndroid Build Coastguard Worker                 config.probabilities[THREADOPERATIONID_SHADER_SOURCE][THREADOPERATIONID_DESTROY_PROGRAM]        = 0.10f;
5236*35238bceSAndroid Build Coastguard Worker                 config.probabilities[THREADOPERATIONID_SHADER_SOURCE][THREADOPERATIONID_ATTACH_SHADER]          = 0.25f;
5237*35238bceSAndroid Build Coastguard Worker                 config.probabilities[THREADOPERATIONID_SHADER_SOURCE][THREADOPERATIONID_LINK_PROGRAM]           = 0.20f;
5238*35238bceSAndroid Build Coastguard Worker 
5239*35238bceSAndroid Build Coastguard Worker                 config.probabilities[THREADOPERATIONID_SHADER_COMPILE][THREADOPERATIONID_DESTROY_SHADER]       = 0.15f;
5240*35238bceSAndroid Build Coastguard Worker                 config.probabilities[THREADOPERATIONID_SHADER_COMPILE][THREADOPERATIONID_CREATE_VERTEX_SHADER] = 0.15f;
5241*35238bceSAndroid Build Coastguard Worker                 config.probabilities[THREADOPERATIONID_SHADER_COMPILE][THREADOPERATIONID_CREATE_FRAGMENT_SHADER] =
5242*35238bceSAndroid Build Coastguard Worker                     0.15f;
5243*35238bceSAndroid Build Coastguard Worker                 config.probabilities[THREADOPERATIONID_SHADER_COMPILE][THREADOPERATIONID_SHADER_SOURCE]   = 0.30f;
5244*35238bceSAndroid Build Coastguard Worker                 config.probabilities[THREADOPERATIONID_SHADER_COMPILE][THREADOPERATIONID_SHADER_COMPILE]  = 0.30f;
5245*35238bceSAndroid Build Coastguard Worker                 config.probabilities[THREADOPERATIONID_SHADER_COMPILE][THREADOPERATIONID_CREATE_PROGRAM]  = 0.10f;
5246*35238bceSAndroid Build Coastguard Worker                 config.probabilities[THREADOPERATIONID_SHADER_COMPILE][THREADOPERATIONID_DESTROY_PROGRAM] = 0.10f;
5247*35238bceSAndroid Build Coastguard Worker                 config.probabilities[THREADOPERATIONID_SHADER_COMPILE][THREADOPERATIONID_ATTACH_SHADER]   = 0.35f;
5248*35238bceSAndroid Build Coastguard Worker                 config.probabilities[THREADOPERATIONID_SHADER_COMPILE][THREADOPERATIONID_LINK_PROGRAM]    = 0.20f;
5249*35238bceSAndroid Build Coastguard Worker 
5250*35238bceSAndroid Build Coastguard Worker                 config.probabilities[THREADOPERATIONID_CREATE_PROGRAM][THREADOPERATIONID_DESTROY_SHADER]       = 0.10f;
5251*35238bceSAndroid Build Coastguard Worker                 config.probabilities[THREADOPERATIONID_CREATE_PROGRAM][THREADOPERATIONID_CREATE_VERTEX_SHADER] = 0.20f;
5252*35238bceSAndroid Build Coastguard Worker                 config.probabilities[THREADOPERATIONID_CREATE_PROGRAM][THREADOPERATIONID_CREATE_FRAGMENT_SHADER] =
5253*35238bceSAndroid Build Coastguard Worker                     0.20f;
5254*35238bceSAndroid Build Coastguard Worker                 config.probabilities[THREADOPERATIONID_CREATE_PROGRAM][THREADOPERATIONID_SHADER_SOURCE]   = 0.05f;
5255*35238bceSAndroid Build Coastguard Worker                 config.probabilities[THREADOPERATIONID_CREATE_PROGRAM][THREADOPERATIONID_SHADER_COMPILE]  = 0.05f;
5256*35238bceSAndroid Build Coastguard Worker                 config.probabilities[THREADOPERATIONID_CREATE_PROGRAM][THREADOPERATIONID_CREATE_PROGRAM]  = 0.15f;
5257*35238bceSAndroid Build Coastguard Worker                 config.probabilities[THREADOPERATIONID_CREATE_PROGRAM][THREADOPERATIONID_DESTROY_PROGRAM] = 0.05f;
5258*35238bceSAndroid Build Coastguard Worker                 config.probabilities[THREADOPERATIONID_CREATE_PROGRAM][THREADOPERATIONID_ATTACH_SHADER]   = 0.40f;
5259*35238bceSAndroid Build Coastguard Worker                 config.probabilities[THREADOPERATIONID_CREATE_PROGRAM][THREADOPERATIONID_LINK_PROGRAM]    = 0.05f;
5260*35238bceSAndroid Build Coastguard Worker 
5261*35238bceSAndroid Build Coastguard Worker                 config.probabilities[THREADOPERATIONID_DESTROY_PROGRAM][THREADOPERATIONID_DESTROY_SHADER]       = 0.20f;
5262*35238bceSAndroid Build Coastguard Worker                 config.probabilities[THREADOPERATIONID_DESTROY_PROGRAM][THREADOPERATIONID_CREATE_VERTEX_SHADER] = 0.20f;
5263*35238bceSAndroid Build Coastguard Worker                 config.probabilities[THREADOPERATIONID_DESTROY_PROGRAM][THREADOPERATIONID_CREATE_FRAGMENT_SHADER] =
5264*35238bceSAndroid Build Coastguard Worker                     0.20f;
5265*35238bceSAndroid Build Coastguard Worker                 config.probabilities[THREADOPERATIONID_DESTROY_PROGRAM][THREADOPERATIONID_SHADER_SOURCE]   = 0.10f;
5266*35238bceSAndroid Build Coastguard Worker                 config.probabilities[THREADOPERATIONID_DESTROY_PROGRAM][THREADOPERATIONID_SHADER_COMPILE]  = 0.10f;
5267*35238bceSAndroid Build Coastguard Worker                 config.probabilities[THREADOPERATIONID_DESTROY_PROGRAM][THREADOPERATIONID_CREATE_PROGRAM]  = 0.20f;
5268*35238bceSAndroid Build Coastguard Worker                 config.probabilities[THREADOPERATIONID_DESTROY_PROGRAM][THREADOPERATIONID_DESTROY_PROGRAM] = 0.15f;
5269*35238bceSAndroid Build Coastguard Worker                 config.probabilities[THREADOPERATIONID_DESTROY_PROGRAM][THREADOPERATIONID_ATTACH_SHADER]   = 0.10f;
5270*35238bceSAndroid Build Coastguard Worker                 config.probabilities[THREADOPERATIONID_DESTROY_PROGRAM][THREADOPERATIONID_LINK_PROGRAM]    = 0.05f;
5271*35238bceSAndroid Build Coastguard Worker 
5272*35238bceSAndroid Build Coastguard Worker                 config.probabilities[THREADOPERATIONID_ATTACH_SHADER][THREADOPERATIONID_DESTROY_SHADER]         = 0.20f;
5273*35238bceSAndroid Build Coastguard Worker                 config.probabilities[THREADOPERATIONID_ATTACH_SHADER][THREADOPERATIONID_CREATE_VERTEX_SHADER]   = 0.20f;
5274*35238bceSAndroid Build Coastguard Worker                 config.probabilities[THREADOPERATIONID_ATTACH_SHADER][THREADOPERATIONID_CREATE_FRAGMENT_SHADER] = 0.20f;
5275*35238bceSAndroid Build Coastguard Worker                 config.probabilities[THREADOPERATIONID_ATTACH_SHADER][THREADOPERATIONID_SHADER_SOURCE]          = 0.10f;
5276*35238bceSAndroid Build Coastguard Worker                 config.probabilities[THREADOPERATIONID_ATTACH_SHADER][THREADOPERATIONID_SHADER_COMPILE]         = 0.10f;
5277*35238bceSAndroid Build Coastguard Worker                 config.probabilities[THREADOPERATIONID_ATTACH_SHADER][THREADOPERATIONID_CREATE_PROGRAM]         = 0.15f;
5278*35238bceSAndroid Build Coastguard Worker                 config.probabilities[THREADOPERATIONID_ATTACH_SHADER][THREADOPERATIONID_DESTROY_PROGRAM]        = 0.15f;
5279*35238bceSAndroid Build Coastguard Worker                 config.probabilities[THREADOPERATIONID_ATTACH_SHADER][THREADOPERATIONID_ATTACH_SHADER]          = 0.30f;
5280*35238bceSAndroid Build Coastguard Worker                 config.probabilities[THREADOPERATIONID_ATTACH_SHADER][THREADOPERATIONID_LINK_PROGRAM]           = 0.30f;
5281*35238bceSAndroid Build Coastguard Worker 
5282*35238bceSAndroid Build Coastguard Worker                 config.probabilities[THREADOPERATIONID_LINK_PROGRAM][THREADOPERATIONID_DESTROY_SHADER]         = 0.20f;
5283*35238bceSAndroid Build Coastguard Worker                 config.probabilities[THREADOPERATIONID_LINK_PROGRAM][THREADOPERATIONID_CREATE_VERTEX_SHADER]   = 0.20f;
5284*35238bceSAndroid Build Coastguard Worker                 config.probabilities[THREADOPERATIONID_LINK_PROGRAM][THREADOPERATIONID_CREATE_FRAGMENT_SHADER] = 0.20f;
5285*35238bceSAndroid Build Coastguard Worker                 config.probabilities[THREADOPERATIONID_LINK_PROGRAM][THREADOPERATIONID_SHADER_SOURCE]          = 0.10f;
5286*35238bceSAndroid Build Coastguard Worker                 config.probabilities[THREADOPERATIONID_LINK_PROGRAM][THREADOPERATIONID_SHADER_COMPILE]         = 0.10f;
5287*35238bceSAndroid Build Coastguard Worker                 config.probabilities[THREADOPERATIONID_LINK_PROGRAM][THREADOPERATIONID_CREATE_PROGRAM]         = 0.20f;
5288*35238bceSAndroid Build Coastguard Worker                 config.probabilities[THREADOPERATIONID_LINK_PROGRAM][THREADOPERATIONID_DESTROY_PROGRAM]        = 0.15f;
5289*35238bceSAndroid Build Coastguard Worker                 config.probabilities[THREADOPERATIONID_LINK_PROGRAM][THREADOPERATIONID_ATTACH_SHADER]          = 0.10f;
5290*35238bceSAndroid Build Coastguard Worker                 config.probabilities[THREADOPERATIONID_LINK_PROGRAM][THREADOPERATIONID_LINK_PROGRAM]           = 0.05f;
5291*35238bceSAndroid Build Coastguard Worker 
5292*35238bceSAndroid Build Coastguard Worker                 std::string name = de::toString(programTestNdx);
5293*35238bceSAndroid Build Coastguard Worker                 texSubImage2DTests->addChild(new GLES2SharingRandomTest(ctx, config, name.c_str(), name.c_str()));
5294*35238bceSAndroid Build Coastguard Worker             }
5295*35238bceSAndroid Build Coastguard Worker 
5296*35238bceSAndroid Build Coastguard Worker             programTests->addChild(texSubImage2DTests);
5297*35238bceSAndroid Build Coastguard Worker         }
5298*35238bceSAndroid Build Coastguard Worker 
5299*35238bceSAndroid Build Coastguard Worker         group->addChild(programTests);
5300*35238bceSAndroid Build Coastguard Worker 
5301*35238bceSAndroid Build Coastguard Worker         TestCaseGroup *imageTests = new TestCaseGroup(ctx, "images", "Image management tests");
5302*35238bceSAndroid Build Coastguard Worker 
5303*35238bceSAndroid Build Coastguard Worker         {
5304*35238bceSAndroid Build Coastguard Worker             TestCaseGroup *texImage2DTests =
5305*35238bceSAndroid Build Coastguard Worker                 new TestCaseGroup(ctx, "create_destroy", "Image gen, delete and teximage2D tests");
5306*35238bceSAndroid Build Coastguard Worker 
5307*35238bceSAndroid Build Coastguard Worker             for (int imageTestNdx = 0; imageTestNdx < 20; imageTestNdx++)
5308*35238bceSAndroid Build Coastguard Worker             {
5309*35238bceSAndroid Build Coastguard Worker                 GLES2SharingRandomTest::TestConfig config;
5310*35238bceSAndroid Build Coastguard Worker                 config.useFenceSync   = useSync;
5311*35238bceSAndroid Build Coastguard Worker                 config.serverSync     = serverSync;
5312*35238bceSAndroid Build Coastguard Worker                 config.threadCount    = 2 + imageTestNdx % 5;
5313*35238bceSAndroid Build Coastguard Worker                 config.operationCount = 70 + imageTestNdx;
5314*35238bceSAndroid Build Coastguard Worker                 config.useImages      = true;
5315*35238bceSAndroid Build Coastguard Worker 
5316*35238bceSAndroid Build Coastguard Worker                 config.probabilities[THREADOPERATIONID_NONE][THREADOPERATIONID_CREATE_TEXTURE] = 1.0f;
5317*35238bceSAndroid Build Coastguard Worker 
5318*35238bceSAndroid Build Coastguard Worker                 config.probabilities[THREADOPERATIONID_CREATE_TEXTURE][THREADOPERATIONID_DESTROY_TEXTURE] = 0.10f;
5319*35238bceSAndroid Build Coastguard Worker                 config.probabilities[THREADOPERATIONID_CREATE_TEXTURE][THREADOPERATIONID_CREATE_TEXTURE]  = 0.15f;
5320*35238bceSAndroid Build Coastguard Worker                 config.probabilities[THREADOPERATIONID_CREATE_TEXTURE][THREADOPERATIONID_CREATE_IMAGE_FROM_TEXTURE] =
5321*35238bceSAndroid Build Coastguard Worker                     0.40f;
5322*35238bceSAndroid Build Coastguard Worker                 config.probabilities[THREADOPERATIONID_CREATE_TEXTURE][THREADOPERATIONID_DESTROY_IMAGE] = 0.35f;
5323*35238bceSAndroid Build Coastguard Worker                 config.probabilities[THREADOPERATIONID_CREATE_TEXTURE][THREADOPERATIONID_TEXIMAGE2D]    = 0.30f;
5324*35238bceSAndroid Build Coastguard Worker 
5325*35238bceSAndroid Build Coastguard Worker                 config.probabilities[THREADOPERATIONID_DESTROY_TEXTURE][THREADOPERATIONID_DESTROY_TEXTURE] = 0.15f;
5326*35238bceSAndroid Build Coastguard Worker                 config.probabilities[THREADOPERATIONID_DESTROY_TEXTURE][THREADOPERATIONID_CREATE_TEXTURE]  = 0.20f;
5327*35238bceSAndroid Build Coastguard Worker                 config.probabilities[THREADOPERATIONID_DESTROY_TEXTURE][THREADOPERATIONID_CREATE_IMAGE_FROM_TEXTURE] =
5328*35238bceSAndroid Build Coastguard Worker                     0.40f;
5329*35238bceSAndroid Build Coastguard Worker                 config.probabilities[THREADOPERATIONID_DESTROY_TEXTURE][THREADOPERATIONID_DESTROY_IMAGE] = 0.35f;
5330*35238bceSAndroid Build Coastguard Worker                 config.probabilities[THREADOPERATIONID_DESTROY_TEXTURE][THREADOPERATIONID_TEXIMAGE2D]    = 0.15f;
5331*35238bceSAndroid Build Coastguard Worker 
5332*35238bceSAndroid Build Coastguard Worker                 config.probabilities[THREADOPERATIONID_CREATE_IMAGE_FROM_TEXTURE][THREADOPERATIONID_DESTROY_TEXTURE] =
5333*35238bceSAndroid Build Coastguard Worker                     0.25f;
5334*35238bceSAndroid Build Coastguard Worker                 config.probabilities[THREADOPERATIONID_CREATE_IMAGE_FROM_TEXTURE][THREADOPERATIONID_CREATE_TEXTURE] =
5335*35238bceSAndroid Build Coastguard Worker                     0.25f;
5336*35238bceSAndroid Build Coastguard Worker                 config.probabilities[THREADOPERATIONID_CREATE_IMAGE_FROM_TEXTURE]
5337*35238bceSAndroid Build Coastguard Worker                                     [THREADOPERATIONID_CREATE_IMAGE_FROM_TEXTURE] = 0.40f;
5338*35238bceSAndroid Build Coastguard Worker                 config.probabilities[THREADOPERATIONID_CREATE_IMAGE_FROM_TEXTURE][THREADOPERATIONID_DESTROY_IMAGE] =
5339*35238bceSAndroid Build Coastguard Worker                     0.35f;
5340*35238bceSAndroid Build Coastguard Worker                 config.probabilities[THREADOPERATIONID_CREATE_IMAGE_FROM_TEXTURE][THREADOPERATIONID_TEXIMAGE2D] = 0.15f;
5341*35238bceSAndroid Build Coastguard Worker 
5342*35238bceSAndroid Build Coastguard Worker                 config.probabilities[THREADOPERATIONID_DESTROY_IMAGE][THREADOPERATIONID_DESTROY_TEXTURE] = 0.25f;
5343*35238bceSAndroid Build Coastguard Worker                 config.probabilities[THREADOPERATIONID_DESTROY_IMAGE][THREADOPERATIONID_CREATE_TEXTURE]  = 0.25f;
5344*35238bceSAndroid Build Coastguard Worker                 config.probabilities[THREADOPERATIONID_DESTROY_IMAGE][THREADOPERATIONID_CREATE_IMAGE_FROM_TEXTURE] =
5345*35238bceSAndroid Build Coastguard Worker                     0.40f;
5346*35238bceSAndroid Build Coastguard Worker                 config.probabilities[THREADOPERATIONID_DESTROY_IMAGE][THREADOPERATIONID_DESTROY_IMAGE] = 0.35f;
5347*35238bceSAndroid Build Coastguard Worker                 config.probabilities[THREADOPERATIONID_DESTROY_IMAGE][THREADOPERATIONID_TEXIMAGE2D]    = 0.15f;
5348*35238bceSAndroid Build Coastguard Worker 
5349*35238bceSAndroid Build Coastguard Worker                 config.probabilities[THREADOPERATIONID_TEXIMAGE2D][THREADOPERATIONID_DESTROY_TEXTURE]           = 0.25f;
5350*35238bceSAndroid Build Coastguard Worker                 config.probabilities[THREADOPERATIONID_TEXIMAGE2D][THREADOPERATIONID_CREATE_TEXTURE]            = 0.25f;
5351*35238bceSAndroid Build Coastguard Worker                 config.probabilities[THREADOPERATIONID_TEXIMAGE2D][THREADOPERATIONID_CREATE_IMAGE_FROM_TEXTURE] = 0.40f;
5352*35238bceSAndroid Build Coastguard Worker                 config.probabilities[THREADOPERATIONID_TEXIMAGE2D][THREADOPERATIONID_DESTROY_IMAGE]             = 0.35f;
5353*35238bceSAndroid Build Coastguard Worker                 config.probabilities[THREADOPERATIONID_TEXIMAGE2D][THREADOPERATIONID_TEXIMAGE2D]                = 0.15f;
5354*35238bceSAndroid Build Coastguard Worker 
5355*35238bceSAndroid Build Coastguard Worker                 config.probabilities[THREADOPERATIONID_TEXTURE_FROM_IMAGE][THREADOPERATIONID_DESTROY_TEXTURE] = 0.25f;
5356*35238bceSAndroid Build Coastguard Worker                 config.probabilities[THREADOPERATIONID_TEXTURE_FROM_IMAGE][THREADOPERATIONID_CREATE_TEXTURE]  = 0.25f;
5357*35238bceSAndroid Build Coastguard Worker                 config
5358*35238bceSAndroid Build Coastguard Worker                     .probabilities[THREADOPERATIONID_TEXTURE_FROM_IMAGE][THREADOPERATIONID_CREATE_IMAGE_FROM_TEXTURE] =
5359*35238bceSAndroid Build Coastguard Worker                     0.30f;
5360*35238bceSAndroid Build Coastguard Worker                 config.probabilities[THREADOPERATIONID_TEXTURE_FROM_IMAGE][THREADOPERATIONID_DESTROY_IMAGE] = 0.15f;
5361*35238bceSAndroid Build Coastguard Worker                 config.probabilities[THREADOPERATIONID_TEXTURE_FROM_IMAGE][THREADOPERATIONID_TEXIMAGE2D]    = 0.15f;
5362*35238bceSAndroid Build Coastguard Worker 
5363*35238bceSAndroid Build Coastguard Worker                 std::string name = de::toString(imageTestNdx);
5364*35238bceSAndroid Build Coastguard Worker                 texImage2DTests->addChild(new GLES2SharingRandomTest(ctx, config, name.c_str(), name.c_str()));
5365*35238bceSAndroid Build Coastguard Worker             }
5366*35238bceSAndroid Build Coastguard Worker 
5367*35238bceSAndroid Build Coastguard Worker             imageTests->addChild(texImage2DTests);
5368*35238bceSAndroid Build Coastguard Worker         }
5369*35238bceSAndroid Build Coastguard Worker 
5370*35238bceSAndroid Build Coastguard Worker         {
5371*35238bceSAndroid Build Coastguard Worker             TestCaseGroup *texImage2DTests =
5372*35238bceSAndroid Build Coastguard Worker                 new TestCaseGroup(ctx, "teximage2d", "Image gen, delete and teximage2D tests");
5373*35238bceSAndroid Build Coastguard Worker 
5374*35238bceSAndroid Build Coastguard Worker             for (int imageTestNdx = 0; imageTestNdx < 20; imageTestNdx++)
5375*35238bceSAndroid Build Coastguard Worker             {
5376*35238bceSAndroid Build Coastguard Worker                 GLES2SharingRandomTest::TestConfig config;
5377*35238bceSAndroid Build Coastguard Worker                 config.useFenceSync   = useSync;
5378*35238bceSAndroid Build Coastguard Worker                 config.serverSync     = serverSync;
5379*35238bceSAndroid Build Coastguard Worker                 config.threadCount    = 2 + imageTestNdx % 5;
5380*35238bceSAndroid Build Coastguard Worker                 config.operationCount = 70 + imageTestNdx;
5381*35238bceSAndroid Build Coastguard Worker                 config.useImages      = true;
5382*35238bceSAndroid Build Coastguard Worker 
5383*35238bceSAndroid Build Coastguard Worker                 config.probabilities[THREADOPERATIONID_NONE][THREADOPERATIONID_CREATE_TEXTURE] = 1.0f;
5384*35238bceSAndroid Build Coastguard Worker 
5385*35238bceSAndroid Build Coastguard Worker                 config.probabilities[THREADOPERATIONID_CREATE_TEXTURE][THREADOPERATIONID_DESTROY_TEXTURE] = 0.10f;
5386*35238bceSAndroid Build Coastguard Worker                 config.probabilities[THREADOPERATIONID_CREATE_TEXTURE][THREADOPERATIONID_CREATE_TEXTURE]  = 0.15f;
5387*35238bceSAndroid Build Coastguard Worker                 config.probabilities[THREADOPERATIONID_CREATE_TEXTURE][THREADOPERATIONID_CREATE_IMAGE_FROM_TEXTURE] =
5388*35238bceSAndroid Build Coastguard Worker                     0.20f;
5389*35238bceSAndroid Build Coastguard Worker                 config.probabilities[THREADOPERATIONID_CREATE_TEXTURE][THREADOPERATIONID_DESTROY_IMAGE]      = 0.15f;
5390*35238bceSAndroid Build Coastguard Worker                 config.probabilities[THREADOPERATIONID_CREATE_TEXTURE][THREADOPERATIONID_TEXIMAGE2D]         = 0.30f;
5391*35238bceSAndroid Build Coastguard Worker                 config.probabilities[THREADOPERATIONID_CREATE_TEXTURE][THREADOPERATIONID_TEXTURE_FROM_IMAGE] = 0.20f;
5392*35238bceSAndroid Build Coastguard Worker 
5393*35238bceSAndroid Build Coastguard Worker                 config.probabilities[THREADOPERATIONID_DESTROY_TEXTURE][THREADOPERATIONID_DESTROY_TEXTURE] = 0.15f;
5394*35238bceSAndroid Build Coastguard Worker                 config.probabilities[THREADOPERATIONID_DESTROY_TEXTURE][THREADOPERATIONID_CREATE_TEXTURE]  = 0.20f;
5395*35238bceSAndroid Build Coastguard Worker                 config.probabilities[THREADOPERATIONID_DESTROY_TEXTURE][THREADOPERATIONID_CREATE_IMAGE_FROM_TEXTURE] =
5396*35238bceSAndroid Build Coastguard Worker                     0.15f;
5397*35238bceSAndroid Build Coastguard Worker                 config.probabilities[THREADOPERATIONID_DESTROY_TEXTURE][THREADOPERATIONID_DESTROY_IMAGE]      = 0.15f;
5398*35238bceSAndroid Build Coastguard Worker                 config.probabilities[THREADOPERATIONID_DESTROY_TEXTURE][THREADOPERATIONID_TEXIMAGE2D]         = 0.15f;
5399*35238bceSAndroid Build Coastguard Worker                 config.probabilities[THREADOPERATIONID_DESTROY_TEXTURE][THREADOPERATIONID_TEXTURE_FROM_IMAGE] = 0.15f;
5400*35238bceSAndroid Build Coastguard Worker 
5401*35238bceSAndroid Build Coastguard Worker                 config.probabilities[THREADOPERATIONID_CREATE_IMAGE_FROM_TEXTURE][THREADOPERATIONID_DESTROY_TEXTURE] =
5402*35238bceSAndroid Build Coastguard Worker                     0.25f;
5403*35238bceSAndroid Build Coastguard Worker                 config.probabilities[THREADOPERATIONID_CREATE_IMAGE_FROM_TEXTURE][THREADOPERATIONID_CREATE_TEXTURE] =
5404*35238bceSAndroid Build Coastguard Worker                     0.25f;
5405*35238bceSAndroid Build Coastguard Worker                 config.probabilities[THREADOPERATIONID_CREATE_IMAGE_FROM_TEXTURE]
5406*35238bceSAndroid Build Coastguard Worker                                     [THREADOPERATIONID_CREATE_IMAGE_FROM_TEXTURE] = 0.25f;
5407*35238bceSAndroid Build Coastguard Worker                 config.probabilities[THREADOPERATIONID_CREATE_IMAGE_FROM_TEXTURE][THREADOPERATIONID_DESTROY_IMAGE] =
5408*35238bceSAndroid Build Coastguard Worker                     0.25f;
5409*35238bceSAndroid Build Coastguard Worker                 config.probabilities[THREADOPERATIONID_CREATE_IMAGE_FROM_TEXTURE][THREADOPERATIONID_TEXIMAGE2D] = 0.15f;
5410*35238bceSAndroid Build Coastguard Worker                 config
5411*35238bceSAndroid Build Coastguard Worker                     .probabilities[THREADOPERATIONID_CREATE_IMAGE_FROM_TEXTURE][THREADOPERATIONID_TEXTURE_FROM_IMAGE] =
5412*35238bceSAndroid Build Coastguard Worker                     0.15f;
5413*35238bceSAndroid Build Coastguard Worker 
5414*35238bceSAndroid Build Coastguard Worker                 config.probabilities[THREADOPERATIONID_DESTROY_IMAGE][THREADOPERATIONID_DESTROY_TEXTURE] = 0.25f;
5415*35238bceSAndroid Build Coastguard Worker                 config.probabilities[THREADOPERATIONID_DESTROY_IMAGE][THREADOPERATIONID_CREATE_TEXTURE]  = 0.25f;
5416*35238bceSAndroid Build Coastguard Worker                 config.probabilities[THREADOPERATIONID_DESTROY_IMAGE][THREADOPERATIONID_CREATE_IMAGE_FROM_TEXTURE] =
5417*35238bceSAndroid Build Coastguard Worker                     0.25f;
5418*35238bceSAndroid Build Coastguard Worker                 config.probabilities[THREADOPERATIONID_DESTROY_IMAGE][THREADOPERATIONID_DESTROY_IMAGE]      = 0.25f;
5419*35238bceSAndroid Build Coastguard Worker                 config.probabilities[THREADOPERATIONID_DESTROY_IMAGE][THREADOPERATIONID_TEXIMAGE2D]         = 0.15f;
5420*35238bceSAndroid Build Coastguard Worker                 config.probabilities[THREADOPERATIONID_DESTROY_IMAGE][THREADOPERATIONID_TEXTURE_FROM_IMAGE] = 0.15f;
5421*35238bceSAndroid Build Coastguard Worker 
5422*35238bceSAndroid Build Coastguard Worker                 config.probabilities[THREADOPERATIONID_TEXIMAGE2D][THREADOPERATIONID_DESTROY_TEXTURE]           = 0.25f;
5423*35238bceSAndroid Build Coastguard Worker                 config.probabilities[THREADOPERATIONID_TEXIMAGE2D][THREADOPERATIONID_CREATE_TEXTURE]            = 0.25f;
5424*35238bceSAndroid Build Coastguard Worker                 config.probabilities[THREADOPERATIONID_TEXIMAGE2D][THREADOPERATIONID_CREATE_IMAGE_FROM_TEXTURE] = 0.25f;
5425*35238bceSAndroid Build Coastguard Worker                 config.probabilities[THREADOPERATIONID_TEXIMAGE2D][THREADOPERATIONID_DESTROY_IMAGE]             = 0.25f;
5426*35238bceSAndroid Build Coastguard Worker                 config.probabilities[THREADOPERATIONID_TEXIMAGE2D][THREADOPERATIONID_TEXIMAGE2D]                = 0.15f;
5427*35238bceSAndroid Build Coastguard Worker                 config.probabilities[THREADOPERATIONID_TEXIMAGE2D][THREADOPERATIONID_TEXTURE_FROM_IMAGE]        = 0.15f;
5428*35238bceSAndroid Build Coastguard Worker 
5429*35238bceSAndroid Build Coastguard Worker                 config.probabilities[THREADOPERATIONID_TEXTURE_FROM_IMAGE][THREADOPERATIONID_DESTROY_TEXTURE] = 0.25f;
5430*35238bceSAndroid Build Coastguard Worker                 config.probabilities[THREADOPERATIONID_TEXTURE_FROM_IMAGE][THREADOPERATIONID_CREATE_TEXTURE]  = 0.25f;
5431*35238bceSAndroid Build Coastguard Worker                 config
5432*35238bceSAndroid Build Coastguard Worker                     .probabilities[THREADOPERATIONID_TEXTURE_FROM_IMAGE][THREADOPERATIONID_CREATE_IMAGE_FROM_TEXTURE] =
5433*35238bceSAndroid Build Coastguard Worker                     0.25f;
5434*35238bceSAndroid Build Coastguard Worker                 config.probabilities[THREADOPERATIONID_TEXTURE_FROM_IMAGE][THREADOPERATIONID_DESTROY_IMAGE] = 0.25f;
5435*35238bceSAndroid Build Coastguard Worker                 config.probabilities[THREADOPERATIONID_TEXTURE_FROM_IMAGE][THREADOPERATIONID_TEXIMAGE2D]    = 0.15f;
5436*35238bceSAndroid Build Coastguard Worker                 config.probabilities[THREADOPERATIONID_TEXTURE_FROM_IMAGE][THREADOPERATIONID_TEXTURE_FROM_IMAGE] =
5437*35238bceSAndroid Build Coastguard Worker                     0.15f;
5438*35238bceSAndroid Build Coastguard Worker 
5439*35238bceSAndroid Build Coastguard Worker                 std::string name = de::toString(imageTestNdx);
5440*35238bceSAndroid Build Coastguard Worker                 texImage2DTests->addChild(new GLES2SharingRandomTest(ctx, config, name.c_str(), name.c_str()));
5441*35238bceSAndroid Build Coastguard Worker             }
5442*35238bceSAndroid Build Coastguard Worker 
5443*35238bceSAndroid Build Coastguard Worker             imageTests->addChild(texImage2DTests);
5444*35238bceSAndroid Build Coastguard Worker         }
5445*35238bceSAndroid Build Coastguard Worker 
5446*35238bceSAndroid Build Coastguard Worker         {
5447*35238bceSAndroid Build Coastguard Worker             TestCaseGroup *texSubImage2DTests =
5448*35238bceSAndroid Build Coastguard Worker                 new TestCaseGroup(ctx, "texsubimage2d", "Image gen, delete, teximage2D and texsubimage2d tests");
5449*35238bceSAndroid Build Coastguard Worker 
5450*35238bceSAndroid Build Coastguard Worker             for (int imageTestNdx = 0; imageTestNdx < 20; imageTestNdx++)
5451*35238bceSAndroid Build Coastguard Worker             {
5452*35238bceSAndroid Build Coastguard Worker                 GLES2SharingRandomTest::TestConfig config;
5453*35238bceSAndroid Build Coastguard Worker                 config.useFenceSync   = useSync;
5454*35238bceSAndroid Build Coastguard Worker                 config.serverSync     = serverSync;
5455*35238bceSAndroid Build Coastguard Worker                 config.threadCount    = 2 + imageTestNdx % 5;
5456*35238bceSAndroid Build Coastguard Worker                 config.operationCount = 70 + imageTestNdx;
5457*35238bceSAndroid Build Coastguard Worker                 config.useImages      = true;
5458*35238bceSAndroid Build Coastguard Worker 
5459*35238bceSAndroid Build Coastguard Worker                 config.probabilities[THREADOPERATIONID_NONE][THREADOPERATIONID_CREATE_TEXTURE] = 1.0f;
5460*35238bceSAndroid Build Coastguard Worker 
5461*35238bceSAndroid Build Coastguard Worker                 config.probabilities[THREADOPERATIONID_CREATE_TEXTURE][THREADOPERATIONID_DESTROY_TEXTURE] = 0.10f;
5462*35238bceSAndroid Build Coastguard Worker                 config.probabilities[THREADOPERATIONID_CREATE_TEXTURE][THREADOPERATIONID_CREATE_TEXTURE]  = 0.15f;
5463*35238bceSAndroid Build Coastguard Worker                 config.probabilities[THREADOPERATIONID_CREATE_TEXTURE][THREADOPERATIONID_CREATE_IMAGE_FROM_TEXTURE] =
5464*35238bceSAndroid Build Coastguard Worker                     0.20f;
5465*35238bceSAndroid Build Coastguard Worker                 config.probabilities[THREADOPERATIONID_CREATE_TEXTURE][THREADOPERATIONID_DESTROY_IMAGE]      = 0.15f;
5466*35238bceSAndroid Build Coastguard Worker                 config.probabilities[THREADOPERATIONID_CREATE_TEXTURE][THREADOPERATIONID_TEXIMAGE2D]         = 0.30f;
5467*35238bceSAndroid Build Coastguard Worker                 config.probabilities[THREADOPERATIONID_CREATE_TEXTURE][THREADOPERATIONID_TEXTURE_FROM_IMAGE] = 0.20f;
5468*35238bceSAndroid Build Coastguard Worker                 config.probabilities[THREADOPERATIONID_CREATE_TEXTURE][THREADOPERATIONID_TEXSUBIMAGE2D]      = 0.10f;
5469*35238bceSAndroid Build Coastguard Worker 
5470*35238bceSAndroid Build Coastguard Worker                 config.probabilities[THREADOPERATIONID_DESTROY_TEXTURE][THREADOPERATIONID_DESTROY_TEXTURE] = 0.15f;
5471*35238bceSAndroid Build Coastguard Worker                 config.probabilities[THREADOPERATIONID_DESTROY_TEXTURE][THREADOPERATIONID_CREATE_TEXTURE]  = 0.20f;
5472*35238bceSAndroid Build Coastguard Worker                 config.probabilities[THREADOPERATIONID_DESTROY_TEXTURE][THREADOPERATIONID_CREATE_IMAGE_FROM_TEXTURE] =
5473*35238bceSAndroid Build Coastguard Worker                     0.15f;
5474*35238bceSAndroid Build Coastguard Worker                 config.probabilities[THREADOPERATIONID_DESTROY_TEXTURE][THREADOPERATIONID_DESTROY_IMAGE]      = 0.15f;
5475*35238bceSAndroid Build Coastguard Worker                 config.probabilities[THREADOPERATIONID_DESTROY_TEXTURE][THREADOPERATIONID_TEXIMAGE2D]         = 0.15f;
5476*35238bceSAndroid Build Coastguard Worker                 config.probabilities[THREADOPERATIONID_DESTROY_TEXTURE][THREADOPERATIONID_TEXTURE_FROM_IMAGE] = 0.15f;
5477*35238bceSAndroid Build Coastguard Worker                 config.probabilities[THREADOPERATIONID_DESTROY_TEXTURE][THREADOPERATIONID_TEXSUBIMAGE2D]      = 0.10f;
5478*35238bceSAndroid Build Coastguard Worker 
5479*35238bceSAndroid Build Coastguard Worker                 config.probabilities[THREADOPERATIONID_CREATE_IMAGE_FROM_TEXTURE][THREADOPERATIONID_DESTROY_TEXTURE] =
5480*35238bceSAndroid Build Coastguard Worker                     0.25f;
5481*35238bceSAndroid Build Coastguard Worker                 config.probabilities[THREADOPERATIONID_CREATE_IMAGE_FROM_TEXTURE][THREADOPERATIONID_CREATE_TEXTURE] =
5482*35238bceSAndroid Build Coastguard Worker                     0.25f;
5483*35238bceSAndroid Build Coastguard Worker                 config.probabilities[THREADOPERATIONID_CREATE_IMAGE_FROM_TEXTURE]
5484*35238bceSAndroid Build Coastguard Worker                                     [THREADOPERATIONID_CREATE_IMAGE_FROM_TEXTURE] = 0.25f;
5485*35238bceSAndroid Build Coastguard Worker                 config.probabilities[THREADOPERATIONID_CREATE_IMAGE_FROM_TEXTURE][THREADOPERATIONID_DESTROY_IMAGE] =
5486*35238bceSAndroid Build Coastguard Worker                     0.25f;
5487*35238bceSAndroid Build Coastguard Worker                 config.probabilities[THREADOPERATIONID_CREATE_IMAGE_FROM_TEXTURE][THREADOPERATIONID_TEXIMAGE2D] = 0.15f;
5488*35238bceSAndroid Build Coastguard Worker                 config
5489*35238bceSAndroid Build Coastguard Worker                     .probabilities[THREADOPERATIONID_CREATE_IMAGE_FROM_TEXTURE][THREADOPERATIONID_TEXTURE_FROM_IMAGE] =
5490*35238bceSAndroid Build Coastguard Worker                     0.15f;
5491*35238bceSAndroid Build Coastguard Worker                 config.probabilities[THREADOPERATIONID_CREATE_IMAGE_FROM_TEXTURE][THREADOPERATIONID_TEXSUBIMAGE2D] =
5492*35238bceSAndroid Build Coastguard Worker                     0.10f;
5493*35238bceSAndroid Build Coastguard Worker 
5494*35238bceSAndroid Build Coastguard Worker                 config.probabilities[THREADOPERATIONID_DESTROY_IMAGE][THREADOPERATIONID_DESTROY_TEXTURE] = 0.25f;
5495*35238bceSAndroid Build Coastguard Worker                 config.probabilities[THREADOPERATIONID_DESTROY_IMAGE][THREADOPERATIONID_CREATE_TEXTURE]  = 0.25f;
5496*35238bceSAndroid Build Coastguard Worker                 config.probabilities[THREADOPERATIONID_DESTROY_IMAGE][THREADOPERATIONID_CREATE_IMAGE_FROM_TEXTURE] =
5497*35238bceSAndroid Build Coastguard Worker                     0.25f;
5498*35238bceSAndroid Build Coastguard Worker                 config.probabilities[THREADOPERATIONID_DESTROY_IMAGE][THREADOPERATIONID_DESTROY_IMAGE]      = 0.25f;
5499*35238bceSAndroid Build Coastguard Worker                 config.probabilities[THREADOPERATIONID_DESTROY_IMAGE][THREADOPERATIONID_TEXIMAGE2D]         = 0.15f;
5500*35238bceSAndroid Build Coastguard Worker                 config.probabilities[THREADOPERATIONID_DESTROY_IMAGE][THREADOPERATIONID_TEXTURE_FROM_IMAGE] = 0.15f;
5501*35238bceSAndroid Build Coastguard Worker                 config.probabilities[THREADOPERATIONID_DESTROY_IMAGE][THREADOPERATIONID_TEXSUBIMAGE2D]      = 0.10f;
5502*35238bceSAndroid Build Coastguard Worker 
5503*35238bceSAndroid Build Coastguard Worker                 config.probabilities[THREADOPERATIONID_TEXIMAGE2D][THREADOPERATIONID_DESTROY_TEXTURE]           = 0.25f;
5504*35238bceSAndroid Build Coastguard Worker                 config.probabilities[THREADOPERATIONID_TEXIMAGE2D][THREADOPERATIONID_CREATE_TEXTURE]            = 0.25f;
5505*35238bceSAndroid Build Coastguard Worker                 config.probabilities[THREADOPERATIONID_TEXIMAGE2D][THREADOPERATIONID_CREATE_IMAGE_FROM_TEXTURE] = 0.25f;
5506*35238bceSAndroid Build Coastguard Worker                 config.probabilities[THREADOPERATIONID_TEXIMAGE2D][THREADOPERATIONID_DESTROY_IMAGE]             = 0.25f;
5507*35238bceSAndroid Build Coastguard Worker                 config.probabilities[THREADOPERATIONID_TEXIMAGE2D][THREADOPERATIONID_TEXIMAGE2D]                = 0.15f;
5508*35238bceSAndroid Build Coastguard Worker                 config.probabilities[THREADOPERATIONID_TEXIMAGE2D][THREADOPERATIONID_TEXTURE_FROM_IMAGE]        = 0.15f;
5509*35238bceSAndroid Build Coastguard Worker                 config.probabilities[THREADOPERATIONID_TEXIMAGE2D][THREADOPERATIONID_TEXSUBIMAGE2D]             = 0.10f;
5510*35238bceSAndroid Build Coastguard Worker 
5511*35238bceSAndroid Build Coastguard Worker                 config.probabilities[THREADOPERATIONID_TEXTURE_FROM_IMAGE][THREADOPERATIONID_DESTROY_TEXTURE] = 0.25f;
5512*35238bceSAndroid Build Coastguard Worker                 config.probabilities[THREADOPERATIONID_TEXTURE_FROM_IMAGE][THREADOPERATIONID_CREATE_TEXTURE]  = 0.25f;
5513*35238bceSAndroid Build Coastguard Worker                 config
5514*35238bceSAndroid Build Coastguard Worker                     .probabilities[THREADOPERATIONID_TEXTURE_FROM_IMAGE][THREADOPERATIONID_CREATE_IMAGE_FROM_TEXTURE] =
5515*35238bceSAndroid Build Coastguard Worker                     0.25f;
5516*35238bceSAndroid Build Coastguard Worker                 config.probabilities[THREADOPERATIONID_TEXTURE_FROM_IMAGE][THREADOPERATIONID_DESTROY_IMAGE] = 0.25f;
5517*35238bceSAndroid Build Coastguard Worker                 config.probabilities[THREADOPERATIONID_TEXTURE_FROM_IMAGE][THREADOPERATIONID_TEXIMAGE2D]    = 0.15f;
5518*35238bceSAndroid Build Coastguard Worker                 config.probabilities[THREADOPERATIONID_TEXTURE_FROM_IMAGE][THREADOPERATIONID_TEXTURE_FROM_IMAGE] =
5519*35238bceSAndroid Build Coastguard Worker                     0.15f;
5520*35238bceSAndroid Build Coastguard Worker                 config.probabilities[THREADOPERATIONID_TEXTURE_FROM_IMAGE][THREADOPERATIONID_TEXSUBIMAGE2D] = 0.10f;
5521*35238bceSAndroid Build Coastguard Worker 
5522*35238bceSAndroid Build Coastguard Worker                 config.probabilities[THREADOPERATIONID_TEXSUBIMAGE2D][THREADOPERATIONID_DESTROY_TEXTURE] = 0.25f;
5523*35238bceSAndroid Build Coastguard Worker                 config.probabilities[THREADOPERATIONID_TEXSUBIMAGE2D][THREADOPERATIONID_CREATE_TEXTURE]  = 0.25f;
5524*35238bceSAndroid Build Coastguard Worker                 config.probabilities[THREADOPERATIONID_TEXSUBIMAGE2D][THREADOPERATIONID_CREATE_IMAGE_FROM_TEXTURE] =
5525*35238bceSAndroid Build Coastguard Worker                     0.25f;
5526*35238bceSAndroid Build Coastguard Worker                 config.probabilities[THREADOPERATIONID_TEXSUBIMAGE2D][THREADOPERATIONID_DESTROY_IMAGE]      = 0.25f;
5527*35238bceSAndroid Build Coastguard Worker                 config.probabilities[THREADOPERATIONID_TEXSUBIMAGE2D][THREADOPERATIONID_TEXIMAGE2D]         = 0.15f;
5528*35238bceSAndroid Build Coastguard Worker                 config.probabilities[THREADOPERATIONID_TEXSUBIMAGE2D][THREADOPERATIONID_TEXTURE_FROM_IMAGE] = 0.15f;
5529*35238bceSAndroid Build Coastguard Worker                 config.probabilities[THREADOPERATIONID_TEXSUBIMAGE2D][THREADOPERATIONID_TEXSUBIMAGE2D]      = 0.10f;
5530*35238bceSAndroid Build Coastguard Worker 
5531*35238bceSAndroid Build Coastguard Worker                 std::string name = de::toString(imageTestNdx);
5532*35238bceSAndroid Build Coastguard Worker                 texSubImage2DTests->addChild(new GLES2SharingRandomTest(ctx, config, name.c_str(), name.c_str()));
5533*35238bceSAndroid Build Coastguard Worker             }
5534*35238bceSAndroid Build Coastguard Worker 
5535*35238bceSAndroid Build Coastguard Worker             imageTests->addChild(texSubImage2DTests);
5536*35238bceSAndroid Build Coastguard Worker         }
5537*35238bceSAndroid Build Coastguard Worker 
5538*35238bceSAndroid Build Coastguard Worker         {
5539*35238bceSAndroid Build Coastguard Worker             TestCaseGroup *copyTexImage2DTests =
5540*35238bceSAndroid Build Coastguard Worker                 new TestCaseGroup(ctx, "copyteximage2d", "Image gen, delete and copyteximage2d tests");
5541*35238bceSAndroid Build Coastguard Worker 
5542*35238bceSAndroid Build Coastguard Worker             for (int imageTestNdx = 0; imageTestNdx < 20; imageTestNdx++)
5543*35238bceSAndroid Build Coastguard Worker             {
5544*35238bceSAndroid Build Coastguard Worker                 GLES2SharingRandomTest::TestConfig config;
5545*35238bceSAndroid Build Coastguard Worker                 config.useFenceSync   = useSync;
5546*35238bceSAndroid Build Coastguard Worker                 config.serverSync     = serverSync;
5547*35238bceSAndroid Build Coastguard Worker                 config.threadCount    = 2 + imageTestNdx % 5;
5548*35238bceSAndroid Build Coastguard Worker                 config.operationCount = 70 + imageTestNdx;
5549*35238bceSAndroid Build Coastguard Worker                 config.useImages      = true;
5550*35238bceSAndroid Build Coastguard Worker 
5551*35238bceSAndroid Build Coastguard Worker                 config.probabilities[THREADOPERATIONID_NONE][THREADOPERATIONID_CREATE_TEXTURE] = 1.0f;
5552*35238bceSAndroid Build Coastguard Worker 
5553*35238bceSAndroid Build Coastguard Worker                 config.probabilities[THREADOPERATIONID_CREATE_TEXTURE][THREADOPERATIONID_DESTROY_TEXTURE] = 0.10f;
5554*35238bceSAndroid Build Coastguard Worker                 config.probabilities[THREADOPERATIONID_CREATE_TEXTURE][THREADOPERATIONID_CREATE_TEXTURE]  = 0.15f;
5555*35238bceSAndroid Build Coastguard Worker                 config.probabilities[THREADOPERATIONID_CREATE_TEXTURE][THREADOPERATIONID_CREATE_IMAGE_FROM_TEXTURE] =
5556*35238bceSAndroid Build Coastguard Worker                     0.20f;
5557*35238bceSAndroid Build Coastguard Worker                 config.probabilities[THREADOPERATIONID_CREATE_TEXTURE][THREADOPERATIONID_DESTROY_IMAGE]      = 0.15f;
5558*35238bceSAndroid Build Coastguard Worker                 config.probabilities[THREADOPERATIONID_CREATE_TEXTURE][THREADOPERATIONID_COPYTEXIMAGE2D]     = 0.30f;
5559*35238bceSAndroid Build Coastguard Worker                 config.probabilities[THREADOPERATIONID_CREATE_TEXTURE][THREADOPERATIONID_TEXTURE_FROM_IMAGE] = 0.20f;
5560*35238bceSAndroid Build Coastguard Worker 
5561*35238bceSAndroid Build Coastguard Worker                 config.probabilities[THREADOPERATIONID_DESTROY_TEXTURE][THREADOPERATIONID_DESTROY_TEXTURE] = 0.15f;
5562*35238bceSAndroid Build Coastguard Worker                 config.probabilities[THREADOPERATIONID_DESTROY_TEXTURE][THREADOPERATIONID_CREATE_TEXTURE]  = 0.20f;
5563*35238bceSAndroid Build Coastguard Worker                 config.probabilities[THREADOPERATIONID_DESTROY_TEXTURE][THREADOPERATIONID_CREATE_IMAGE_FROM_TEXTURE] =
5564*35238bceSAndroid Build Coastguard Worker                     0.15f;
5565*35238bceSAndroid Build Coastguard Worker                 config.probabilities[THREADOPERATIONID_DESTROY_TEXTURE][THREADOPERATIONID_DESTROY_IMAGE]      = 0.15f;
5566*35238bceSAndroid Build Coastguard Worker                 config.probabilities[THREADOPERATIONID_DESTROY_TEXTURE][THREADOPERATIONID_COPYTEXIMAGE2D]     = 0.15f;
5567*35238bceSAndroid Build Coastguard Worker                 config.probabilities[THREADOPERATIONID_DESTROY_TEXTURE][THREADOPERATIONID_TEXTURE_FROM_IMAGE] = 0.15f;
5568*35238bceSAndroid Build Coastguard Worker 
5569*35238bceSAndroid Build Coastguard Worker                 config.probabilities[THREADOPERATIONID_CREATE_IMAGE_FROM_TEXTURE][THREADOPERATIONID_DESTROY_TEXTURE] =
5570*35238bceSAndroid Build Coastguard Worker                     0.25f;
5571*35238bceSAndroid Build Coastguard Worker                 config.probabilities[THREADOPERATIONID_CREATE_IMAGE_FROM_TEXTURE][THREADOPERATIONID_CREATE_TEXTURE] =
5572*35238bceSAndroid Build Coastguard Worker                     0.25f;
5573*35238bceSAndroid Build Coastguard Worker                 config.probabilities[THREADOPERATIONID_CREATE_IMAGE_FROM_TEXTURE]
5574*35238bceSAndroid Build Coastguard Worker                                     [THREADOPERATIONID_CREATE_IMAGE_FROM_TEXTURE] = 0.25f;
5575*35238bceSAndroid Build Coastguard Worker                 config.probabilities[THREADOPERATIONID_CREATE_IMAGE_FROM_TEXTURE][THREADOPERATIONID_DESTROY_IMAGE] =
5576*35238bceSAndroid Build Coastguard Worker                     0.25f;
5577*35238bceSAndroid Build Coastguard Worker                 config.probabilities[THREADOPERATIONID_CREATE_IMAGE_FROM_TEXTURE][THREADOPERATIONID_COPYTEXIMAGE2D] =
5578*35238bceSAndroid Build Coastguard Worker                     0.15f;
5579*35238bceSAndroid Build Coastguard Worker                 config
5580*35238bceSAndroid Build Coastguard Worker                     .probabilities[THREADOPERATIONID_CREATE_IMAGE_FROM_TEXTURE][THREADOPERATIONID_TEXTURE_FROM_IMAGE] =
5581*35238bceSAndroid Build Coastguard Worker                     0.15f;
5582*35238bceSAndroid Build Coastguard Worker 
5583*35238bceSAndroid Build Coastguard Worker                 config.probabilities[THREADOPERATIONID_DESTROY_IMAGE][THREADOPERATIONID_DESTROY_TEXTURE] = 0.25f;
5584*35238bceSAndroid Build Coastguard Worker                 config.probabilities[THREADOPERATIONID_DESTROY_IMAGE][THREADOPERATIONID_CREATE_TEXTURE]  = 0.25f;
5585*35238bceSAndroid Build Coastguard Worker                 config.probabilities[THREADOPERATIONID_DESTROY_IMAGE][THREADOPERATIONID_CREATE_IMAGE_FROM_TEXTURE] =
5586*35238bceSAndroid Build Coastguard Worker                     0.25f;
5587*35238bceSAndroid Build Coastguard Worker                 config.probabilities[THREADOPERATIONID_DESTROY_IMAGE][THREADOPERATIONID_DESTROY_IMAGE]      = 0.25f;
5588*35238bceSAndroid Build Coastguard Worker                 config.probabilities[THREADOPERATIONID_DESTROY_IMAGE][THREADOPERATIONID_COPYTEXIMAGE2D]     = 0.15f;
5589*35238bceSAndroid Build Coastguard Worker                 config.probabilities[THREADOPERATIONID_DESTROY_IMAGE][THREADOPERATIONID_TEXTURE_FROM_IMAGE] = 0.15f;
5590*35238bceSAndroid Build Coastguard Worker 
5591*35238bceSAndroid Build Coastguard Worker                 config.probabilities[THREADOPERATIONID_COPYTEXIMAGE2D][THREADOPERATIONID_DESTROY_TEXTURE] = 0.25f;
5592*35238bceSAndroid Build Coastguard Worker                 config.probabilities[THREADOPERATIONID_COPYTEXIMAGE2D][THREADOPERATIONID_CREATE_TEXTURE]  = 0.25f;
5593*35238bceSAndroid Build Coastguard Worker                 config.probabilities[THREADOPERATIONID_COPYTEXIMAGE2D][THREADOPERATIONID_CREATE_IMAGE_FROM_TEXTURE] =
5594*35238bceSAndroid Build Coastguard Worker                     0.25f;
5595*35238bceSAndroid Build Coastguard Worker                 config.probabilities[THREADOPERATIONID_COPYTEXIMAGE2D][THREADOPERATIONID_DESTROY_IMAGE]      = 0.25f;
5596*35238bceSAndroid Build Coastguard Worker                 config.probabilities[THREADOPERATIONID_COPYTEXIMAGE2D][THREADOPERATIONID_COPYTEXIMAGE2D]     = 0.15f;
5597*35238bceSAndroid Build Coastguard Worker                 config.probabilities[THREADOPERATIONID_COPYTEXIMAGE2D][THREADOPERATIONID_TEXTURE_FROM_IMAGE] = 0.15f;
5598*35238bceSAndroid Build Coastguard Worker 
5599*35238bceSAndroid Build Coastguard Worker                 config.probabilities[THREADOPERATIONID_TEXTURE_FROM_IMAGE][THREADOPERATIONID_DESTROY_TEXTURE] = 0.25f;
5600*35238bceSAndroid Build Coastguard Worker                 config.probabilities[THREADOPERATIONID_TEXTURE_FROM_IMAGE][THREADOPERATIONID_CREATE_TEXTURE]  = 0.25f;
5601*35238bceSAndroid Build Coastguard Worker                 config
5602*35238bceSAndroid Build Coastguard Worker                     .probabilities[THREADOPERATIONID_TEXTURE_FROM_IMAGE][THREADOPERATIONID_CREATE_IMAGE_FROM_TEXTURE] =
5603*35238bceSAndroid Build Coastguard Worker                     0.25f;
5604*35238bceSAndroid Build Coastguard Worker                 config.probabilities[THREADOPERATIONID_TEXTURE_FROM_IMAGE][THREADOPERATIONID_DESTROY_IMAGE]  = 0.25f;
5605*35238bceSAndroid Build Coastguard Worker                 config.probabilities[THREADOPERATIONID_TEXTURE_FROM_IMAGE][THREADOPERATIONID_COPYTEXIMAGE2D] = 0.15f;
5606*35238bceSAndroid Build Coastguard Worker                 config.probabilities[THREADOPERATIONID_TEXTURE_FROM_IMAGE][THREADOPERATIONID_TEXTURE_FROM_IMAGE] =
5607*35238bceSAndroid Build Coastguard Worker                     0.15f;
5608*35238bceSAndroid Build Coastguard Worker 
5609*35238bceSAndroid Build Coastguard Worker                 std::string name = de::toString(imageTestNdx);
5610*35238bceSAndroid Build Coastguard Worker                 copyTexImage2DTests->addChild(new GLES2SharingRandomTest(ctx, config, name.c_str(), name.c_str()));
5611*35238bceSAndroid Build Coastguard Worker             }
5612*35238bceSAndroid Build Coastguard Worker 
5613*35238bceSAndroid Build Coastguard Worker             imageTests->addChild(copyTexImage2DTests);
5614*35238bceSAndroid Build Coastguard Worker         }
5615*35238bceSAndroid Build Coastguard Worker 
5616*35238bceSAndroid Build Coastguard Worker         {
5617*35238bceSAndroid Build Coastguard Worker             TestCaseGroup *copyTexSubImage2DTests = new TestCaseGroup(
5618*35238bceSAndroid Build Coastguard Worker                 ctx, "copytexsubimage2d", "Image gen, delete, teximage2D and copytexsubimage2d tests");
5619*35238bceSAndroid Build Coastguard Worker 
5620*35238bceSAndroid Build Coastguard Worker             for (int imageTestNdx = 0; imageTestNdx < 20; imageTestNdx++)
5621*35238bceSAndroid Build Coastguard Worker             {
5622*35238bceSAndroid Build Coastguard Worker                 GLES2SharingRandomTest::TestConfig config;
5623*35238bceSAndroid Build Coastguard Worker                 config.useFenceSync   = useSync;
5624*35238bceSAndroid Build Coastguard Worker                 config.serverSync     = serverSync;
5625*35238bceSAndroid Build Coastguard Worker                 config.threadCount    = 2 + imageTestNdx % 5;
5626*35238bceSAndroid Build Coastguard Worker                 config.operationCount = 70 + imageTestNdx;
5627*35238bceSAndroid Build Coastguard Worker                 config.useImages      = true;
5628*35238bceSAndroid Build Coastguard Worker 
5629*35238bceSAndroid Build Coastguard Worker                 config.probabilities[THREADOPERATIONID_NONE][THREADOPERATIONID_CREATE_TEXTURE] = 1.0f;
5630*35238bceSAndroid Build Coastguard Worker 
5631*35238bceSAndroid Build Coastguard Worker                 config.probabilities[THREADOPERATIONID_CREATE_TEXTURE][THREADOPERATIONID_DESTROY_TEXTURE] = 0.10f;
5632*35238bceSAndroid Build Coastguard Worker                 config.probabilities[THREADOPERATIONID_CREATE_TEXTURE][THREADOPERATIONID_CREATE_TEXTURE]  = 0.15f;
5633*35238bceSAndroid Build Coastguard Worker                 config.probabilities[THREADOPERATIONID_CREATE_TEXTURE][THREADOPERATIONID_CREATE_IMAGE_FROM_TEXTURE] =
5634*35238bceSAndroid Build Coastguard Worker                     0.20f;
5635*35238bceSAndroid Build Coastguard Worker                 config.probabilities[THREADOPERATIONID_CREATE_TEXTURE][THREADOPERATIONID_DESTROY_IMAGE]      = 0.15f;
5636*35238bceSAndroid Build Coastguard Worker                 config.probabilities[THREADOPERATIONID_CREATE_TEXTURE][THREADOPERATIONID_TEXIMAGE2D]         = 0.30f;
5637*35238bceSAndroid Build Coastguard Worker                 config.probabilities[THREADOPERATIONID_CREATE_TEXTURE][THREADOPERATIONID_TEXTURE_FROM_IMAGE] = 0.20f;
5638*35238bceSAndroid Build Coastguard Worker                 config.probabilities[THREADOPERATIONID_CREATE_TEXTURE][THREADOPERATIONID_COPYTEXSUBIMAGE2D]  = 0.10f;
5639*35238bceSAndroid Build Coastguard Worker 
5640*35238bceSAndroid Build Coastguard Worker                 config.probabilities[THREADOPERATIONID_DESTROY_TEXTURE][THREADOPERATIONID_DESTROY_TEXTURE] = 0.15f;
5641*35238bceSAndroid Build Coastguard Worker                 config.probabilities[THREADOPERATIONID_DESTROY_TEXTURE][THREADOPERATIONID_CREATE_TEXTURE]  = 0.20f;
5642*35238bceSAndroid Build Coastguard Worker                 config.probabilities[THREADOPERATIONID_DESTROY_TEXTURE][THREADOPERATIONID_CREATE_IMAGE_FROM_TEXTURE] =
5643*35238bceSAndroid Build Coastguard Worker                     0.15f;
5644*35238bceSAndroid Build Coastguard Worker                 config.probabilities[THREADOPERATIONID_DESTROY_TEXTURE][THREADOPERATIONID_DESTROY_IMAGE]      = 0.15f;
5645*35238bceSAndroid Build Coastguard Worker                 config.probabilities[THREADOPERATIONID_DESTROY_TEXTURE][THREADOPERATIONID_TEXIMAGE2D]         = 0.15f;
5646*35238bceSAndroid Build Coastguard Worker                 config.probabilities[THREADOPERATIONID_DESTROY_TEXTURE][THREADOPERATIONID_TEXTURE_FROM_IMAGE] = 0.15f;
5647*35238bceSAndroid Build Coastguard Worker                 config.probabilities[THREADOPERATIONID_DESTROY_TEXTURE][THREADOPERATIONID_COPYTEXSUBIMAGE2D]  = 0.10f;
5648*35238bceSAndroid Build Coastguard Worker 
5649*35238bceSAndroid Build Coastguard Worker                 config.probabilities[THREADOPERATIONID_CREATE_IMAGE_FROM_TEXTURE][THREADOPERATIONID_DESTROY_TEXTURE] =
5650*35238bceSAndroid Build Coastguard Worker                     0.25f;
5651*35238bceSAndroid Build Coastguard Worker                 config.probabilities[THREADOPERATIONID_CREATE_IMAGE_FROM_TEXTURE][THREADOPERATIONID_CREATE_TEXTURE] =
5652*35238bceSAndroid Build Coastguard Worker                     0.25f;
5653*35238bceSAndroid Build Coastguard Worker                 config.probabilities[THREADOPERATIONID_CREATE_IMAGE_FROM_TEXTURE]
5654*35238bceSAndroid Build Coastguard Worker                                     [THREADOPERATIONID_CREATE_IMAGE_FROM_TEXTURE] = 0.25f;
5655*35238bceSAndroid Build Coastguard Worker                 config.probabilities[THREADOPERATIONID_CREATE_IMAGE_FROM_TEXTURE][THREADOPERATIONID_DESTROY_IMAGE] =
5656*35238bceSAndroid Build Coastguard Worker                     0.25f;
5657*35238bceSAndroid Build Coastguard Worker                 config.probabilities[THREADOPERATIONID_CREATE_IMAGE_FROM_TEXTURE][THREADOPERATIONID_TEXIMAGE2D] = 0.15f;
5658*35238bceSAndroid Build Coastguard Worker                 config
5659*35238bceSAndroid Build Coastguard Worker                     .probabilities[THREADOPERATIONID_CREATE_IMAGE_FROM_TEXTURE][THREADOPERATIONID_TEXTURE_FROM_IMAGE] =
5660*35238bceSAndroid Build Coastguard Worker                     0.15f;
5661*35238bceSAndroid Build Coastguard Worker                 config.probabilities[THREADOPERATIONID_CREATE_IMAGE_FROM_TEXTURE][THREADOPERATIONID_COPYTEXSUBIMAGE2D] =
5662*35238bceSAndroid Build Coastguard Worker                     0.10f;
5663*35238bceSAndroid Build Coastguard Worker 
5664*35238bceSAndroid Build Coastguard Worker                 config.probabilities[THREADOPERATIONID_DESTROY_IMAGE][THREADOPERATIONID_DESTROY_TEXTURE] = 0.25f;
5665*35238bceSAndroid Build Coastguard Worker                 config.probabilities[THREADOPERATIONID_DESTROY_IMAGE][THREADOPERATIONID_CREATE_TEXTURE]  = 0.25f;
5666*35238bceSAndroid Build Coastguard Worker                 config.probabilities[THREADOPERATIONID_DESTROY_IMAGE][THREADOPERATIONID_CREATE_IMAGE_FROM_TEXTURE] =
5667*35238bceSAndroid Build Coastguard Worker                     0.25f;
5668*35238bceSAndroid Build Coastguard Worker                 config.probabilities[THREADOPERATIONID_DESTROY_IMAGE][THREADOPERATIONID_DESTROY_IMAGE]      = 0.25f;
5669*35238bceSAndroid Build Coastguard Worker                 config.probabilities[THREADOPERATIONID_DESTROY_IMAGE][THREADOPERATIONID_TEXIMAGE2D]         = 0.15f;
5670*35238bceSAndroid Build Coastguard Worker                 config.probabilities[THREADOPERATIONID_DESTROY_IMAGE][THREADOPERATIONID_TEXTURE_FROM_IMAGE] = 0.15f;
5671*35238bceSAndroid Build Coastguard Worker                 config.probabilities[THREADOPERATIONID_DESTROY_IMAGE][THREADOPERATIONID_COPYTEXSUBIMAGE2D]  = 0.10f;
5672*35238bceSAndroid Build Coastguard Worker 
5673*35238bceSAndroid Build Coastguard Worker                 config.probabilities[THREADOPERATIONID_TEXIMAGE2D][THREADOPERATIONID_DESTROY_TEXTURE]           = 0.25f;
5674*35238bceSAndroid Build Coastguard Worker                 config.probabilities[THREADOPERATIONID_TEXIMAGE2D][THREADOPERATIONID_CREATE_TEXTURE]            = 0.25f;
5675*35238bceSAndroid Build Coastguard Worker                 config.probabilities[THREADOPERATIONID_TEXIMAGE2D][THREADOPERATIONID_CREATE_IMAGE_FROM_TEXTURE] = 0.25f;
5676*35238bceSAndroid Build Coastguard Worker                 config.probabilities[THREADOPERATIONID_TEXIMAGE2D][THREADOPERATIONID_DESTROY_IMAGE]             = 0.25f;
5677*35238bceSAndroid Build Coastguard Worker                 config.probabilities[THREADOPERATIONID_TEXIMAGE2D][THREADOPERATIONID_TEXIMAGE2D]                = 0.15f;
5678*35238bceSAndroid Build Coastguard Worker                 config.probabilities[THREADOPERATIONID_TEXIMAGE2D][THREADOPERATIONID_TEXTURE_FROM_IMAGE]        = 0.15f;
5679*35238bceSAndroid Build Coastguard Worker                 config.probabilities[THREADOPERATIONID_TEXIMAGE2D][THREADOPERATIONID_COPYTEXSUBIMAGE2D]         = 0.10f;
5680*35238bceSAndroid Build Coastguard Worker 
5681*35238bceSAndroid Build Coastguard Worker                 config.probabilities[THREADOPERATIONID_TEXTURE_FROM_IMAGE][THREADOPERATIONID_DESTROY_TEXTURE] = 0.25f;
5682*35238bceSAndroid Build Coastguard Worker                 config.probabilities[THREADOPERATIONID_TEXTURE_FROM_IMAGE][THREADOPERATIONID_CREATE_TEXTURE]  = 0.25f;
5683*35238bceSAndroid Build Coastguard Worker                 config
5684*35238bceSAndroid Build Coastguard Worker                     .probabilities[THREADOPERATIONID_TEXTURE_FROM_IMAGE][THREADOPERATIONID_CREATE_IMAGE_FROM_TEXTURE] =
5685*35238bceSAndroid Build Coastguard Worker                     0.25f;
5686*35238bceSAndroid Build Coastguard Worker                 config.probabilities[THREADOPERATIONID_TEXTURE_FROM_IMAGE][THREADOPERATIONID_DESTROY_IMAGE] = 0.25f;
5687*35238bceSAndroid Build Coastguard Worker                 config.probabilities[THREADOPERATIONID_TEXTURE_FROM_IMAGE][THREADOPERATIONID_TEXIMAGE2D]    = 0.15f;
5688*35238bceSAndroid Build Coastguard Worker                 config.probabilities[THREADOPERATIONID_TEXTURE_FROM_IMAGE][THREADOPERATIONID_TEXTURE_FROM_IMAGE] =
5689*35238bceSAndroid Build Coastguard Worker                     0.15f;
5690*35238bceSAndroid Build Coastguard Worker                 config.probabilities[THREADOPERATIONID_TEXTURE_FROM_IMAGE][THREADOPERATIONID_COPYTEXSUBIMAGE2D] = 0.10f;
5691*35238bceSAndroid Build Coastguard Worker 
5692*35238bceSAndroid Build Coastguard Worker                 config.probabilities[THREADOPERATIONID_COPYTEXSUBIMAGE2D][THREADOPERATIONID_DESTROY_TEXTURE] = 0.25f;
5693*35238bceSAndroid Build Coastguard Worker                 config.probabilities[THREADOPERATIONID_COPYTEXSUBIMAGE2D][THREADOPERATIONID_CREATE_TEXTURE]  = 0.25f;
5694*35238bceSAndroid Build Coastguard Worker                 config.probabilities[THREADOPERATIONID_COPYTEXSUBIMAGE2D][THREADOPERATIONID_CREATE_IMAGE_FROM_TEXTURE] =
5695*35238bceSAndroid Build Coastguard Worker                     0.25f;
5696*35238bceSAndroid Build Coastguard Worker                 config.probabilities[THREADOPERATIONID_COPYTEXSUBIMAGE2D][THREADOPERATIONID_DESTROY_IMAGE]      = 0.25f;
5697*35238bceSAndroid Build Coastguard Worker                 config.probabilities[THREADOPERATIONID_COPYTEXSUBIMAGE2D][THREADOPERATIONID_TEXIMAGE2D]         = 0.15f;
5698*35238bceSAndroid Build Coastguard Worker                 config.probabilities[THREADOPERATIONID_COPYTEXSUBIMAGE2D][THREADOPERATIONID_TEXTURE_FROM_IMAGE] = 0.15f;
5699*35238bceSAndroid Build Coastguard Worker                 config.probabilities[THREADOPERATIONID_COPYTEXSUBIMAGE2D][THREADOPERATIONID_COPYTEXSUBIMAGE2D]  = 0.10f;
5700*35238bceSAndroid Build Coastguard Worker 
5701*35238bceSAndroid Build Coastguard Worker                 std::string name = de::toString(imageTestNdx);
5702*35238bceSAndroid Build Coastguard Worker                 copyTexSubImage2DTests->addChild(new GLES2SharingRandomTest(ctx, config, name.c_str(), name.c_str()));
5703*35238bceSAndroid Build Coastguard Worker             }
5704*35238bceSAndroid Build Coastguard Worker 
5705*35238bceSAndroid Build Coastguard Worker             imageTests->addChild(copyTexSubImage2DTests);
5706*35238bceSAndroid Build Coastguard Worker         }
5707*35238bceSAndroid Build Coastguard Worker 
5708*35238bceSAndroid Build Coastguard Worker         group->addChild(imageTests);
5709*35238bceSAndroid Build Coastguard Worker     }
5710*35238bceSAndroid Build Coastguard Worker }
5711*35238bceSAndroid Build Coastguard Worker 
GLES2SharingThreadedTests(EglTestContext & eglTestCtx)5712*35238bceSAndroid Build Coastguard Worker GLES2SharingThreadedTests::GLES2SharingThreadedTests(EglTestContext &eglTestCtx)
5713*35238bceSAndroid Build Coastguard Worker     : TestCaseGroup(eglTestCtx, "multithread", "EGL GLES2 sharing multithread tests")
5714*35238bceSAndroid Build Coastguard Worker {
5715*35238bceSAndroid Build Coastguard Worker }
5716*35238bceSAndroid Build Coastguard Worker 
init(void)5717*35238bceSAndroid Build Coastguard Worker void GLES2SharingThreadedTests::init(void)
5718*35238bceSAndroid Build Coastguard Worker {
5719*35238bceSAndroid Build Coastguard Worker     tcu::TestCaseGroup *simpleTests = new TestCaseGroup(m_eglTestCtx, "simple", "Simple multithreaded tests");
5720*35238bceSAndroid Build Coastguard Worker     addSimpleTests(m_eglTestCtx, simpleTests, false, false);
5721*35238bceSAndroid Build Coastguard Worker     addChild(simpleTests);
5722*35238bceSAndroid Build Coastguard Worker 
5723*35238bceSAndroid Build Coastguard Worker     TestCaseGroup *randomTests = new TestCaseGroup(m_eglTestCtx, "random", "Random tests");
5724*35238bceSAndroid Build Coastguard Worker     addRandomTests(m_eglTestCtx, randomTests, false, false);
5725*35238bceSAndroid Build Coastguard Worker     addChild(randomTests);
5726*35238bceSAndroid Build Coastguard Worker 
5727*35238bceSAndroid Build Coastguard Worker     tcu::TestCaseGroup *simpleTestsSync =
5728*35238bceSAndroid Build Coastguard Worker         new TestCaseGroup(m_eglTestCtx, "simple_egl_sync", "Simple multithreaded tests with EGL_KHR_fence_sync");
5729*35238bceSAndroid Build Coastguard Worker     addSimpleTests(m_eglTestCtx, simpleTestsSync, true, false);
5730*35238bceSAndroid Build Coastguard Worker     addChild(simpleTestsSync);
5731*35238bceSAndroid Build Coastguard Worker 
5732*35238bceSAndroid Build Coastguard Worker     TestCaseGroup *randomTestsSync =
5733*35238bceSAndroid Build Coastguard Worker         new TestCaseGroup(m_eglTestCtx, "random_egl_sync", "Random tests with EGL_KHR_fence_sync");
5734*35238bceSAndroid Build Coastguard Worker     addRandomTests(m_eglTestCtx, randomTestsSync, true, false);
5735*35238bceSAndroid Build Coastguard Worker     addChild(randomTestsSync);
5736*35238bceSAndroid Build Coastguard Worker 
5737*35238bceSAndroid Build Coastguard Worker     tcu::TestCaseGroup *simpleTestsServerSync =
5738*35238bceSAndroid Build Coastguard Worker         new TestCaseGroup(m_eglTestCtx, "simple_egl_server_sync",
5739*35238bceSAndroid Build Coastguard Worker                           "Simple multithreaded tests with EGL_KHR_fence_sync and EGL_KHR_wait_sync");
5740*35238bceSAndroid Build Coastguard Worker     addSimpleTests(m_eglTestCtx, simpleTestsServerSync, true, true);
5741*35238bceSAndroid Build Coastguard Worker     addChild(simpleTestsServerSync);
5742*35238bceSAndroid Build Coastguard Worker 
5743*35238bceSAndroid Build Coastguard Worker     TestCaseGroup *randomTestsServerSync = new TestCaseGroup(
5744*35238bceSAndroid Build Coastguard Worker         m_eglTestCtx, "random_egl_server_sync", "Random tests with EGL_KHR_fence_sync and EGL_KHR_wait_sync");
5745*35238bceSAndroid Build Coastguard Worker     addRandomTests(m_eglTestCtx, randomTestsServerSync, true, true);
5746*35238bceSAndroid Build Coastguard Worker     addChild(randomTestsServerSync);
5747*35238bceSAndroid Build Coastguard Worker }
5748*35238bceSAndroid Build Coastguard Worker 
5749*35238bceSAndroid Build Coastguard Worker } // namespace egl
5750*35238bceSAndroid Build Coastguard Worker } // namespace deqp
5751