1 /*-------------------------------------------------------------------------
2 * drawElements Quality Program EGL Module
3 * ---------------------------------------
4 *
5 * Copyright 2014 The Android Open Source Project
6 *
7 * Licensed under the Apache License, Version 2.0 (the "License");
8 * you may not use this file except in compliance with the License.
9 * You may obtain a copy of the License at
10 *
11 * http://www.apache.org/licenses/LICENSE-2.0
12 *
13 * Unless required by applicable law or agreed to in writing, software
14 * distributed under the License is distributed on an "AS IS" BASIS,
15 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16 * See the License for the specific language governing permissions and
17 * limitations under the License.
18 *
19 *//*!
20 * \file
21 * \brief EGL EGL_KHR_fence_sync and EGL_KHR_reusable_sync tests
22 *//*--------------------------------------------------------------------*/
23
24 #include "teglSyncTests.hpp"
25
26 #include "deStringUtil.hpp"
27
28 #include "egluNativeWindow.hpp"
29 #include "egluStrUtil.hpp"
30 #include "egluUtil.hpp"
31
32 #include "eglwLibrary.hpp"
33 #include "eglwEnums.hpp"
34
35 #include "tcuTestLog.hpp"
36 #include "tcuCommandLine.hpp"
37
38 #include "gluDefs.hpp"
39
40 #include "glwFunctions.hpp"
41 #include "glwEnums.hpp"
42
43 #include <vector>
44 #include <string>
45 #include <sstream>
46 #include <set>
47
48 using std::vector;
49 using std::string;
50 using std::set;
51
52 using tcu::TestLog;
53
54 using namespace eglw;
55 using namespace glw;
56
57 #define NO_ERROR 0
58 #define ERROR -1
59
60 #if (DE_OS == DE_OS_ANDROID)
61 #define EGL_SYNC_NATIVE_FENCE_ANDROID 0x3144
62 #endif
63
64 namespace deqp
65 {
66 namespace egl
67 {
68
getSyncTypeName(EGLenum syncType)69 const char* getSyncTypeName (EGLenum syncType)
70 {
71 switch (syncType)
72 {
73 case EGL_SYNC_FENCE_KHR: return "EGL_SYNC_FENCE_KHR";
74 case EGL_SYNC_REUSABLE_KHR: return "EGL_SYNC_REUSABLE_KHR";
75 #if (DE_OS == DE_OS_ANDROID)
76 case EGL_SYNC_NATIVE_FENCE_ANDROID:
77 return "EGL_SYNC_NATIVE_FENCE_ANDROID";
78 #endif
79 default:
80 DE_ASSERT(DE_FALSE);
81 return "<Unknown>";
82 }
83 }
84
85 class SyncTest : public TestCase
86 {
87 public:
88 typedef EGLSync (Library::*createSync)(EGLDisplay, EGLenum, const EGLAttrib *) const ;
89 typedef EGLSyncKHR (Library::*createSyncKHR)(EGLDisplay, EGLenum, const EGLint *) const ;
90 typedef EGLint (Library::*clientWaitSync)(EGLDisplay, EGLSync, EGLint, EGLTime) const ;
91 typedef EGLint (Library::*clientWaitSyncKHR)(EGLDisplay, EGLSyncKHR, EGLint, EGLTimeKHR) const ;
92 typedef EGLBoolean (Library::*getSyncAttrib)(EGLDisplay, EGLSync, EGLint, EGLAttrib *) const ;
93 typedef EGLBoolean (Library::*getSyncAttribKHR)(EGLDisplay, EGLSyncKHR, EGLint, EGLint *) const ;
94 typedef EGLBoolean (Library::*destroySync)(EGLDisplay, EGLSync) const ;
95 typedef EGLBoolean (Library::*destroySyncKHR)(EGLDisplay, EGLSyncKHR) const ;
96 typedef EGLBoolean (Library::*waitSync)(EGLDisplay, EGLSync, EGLint) const ;
97 typedef EGLint (Library::*waitSyncKHR)(EGLDisplay, EGLSyncKHR, EGLint) const ;
98
99 enum FunctionName
100 {
101 FUNC_NAME_CREATE_SYNC,
102 FUNC_NAME_CLIENT_WAIT_SYNC,
103 FUNC_NAME_GET_SYNC_ATTRIB,
104 FUNC_NAME_DESTROY_SYNC,
105 FUNC_NAME_WAIT_SYNC,
106 FUNC_NAME_NUM_NAMES
107 };
108
109 enum Extension
110 {
111 EXTENSION_NONE = 0,
112 EXTENSION_WAIT_SYNC = (0x1 << 0),
113 EXTENSION_FENCE_SYNC = (0x1 << 1),
114 EXTENSION_REUSABLE_SYNC = (0x1 << 2)
115 };
116 SyncTest (EglTestContext& eglTestCtx, EGLenum syncType, Extension extensions, bool useCurrentContext, const char* name, const char* description);
117 virtual ~SyncTest (void);
118
119 virtual void init(void);
120 virtual void deinit (void);
121 bool hasRequiredEGLVersion(int requiredMajor, int requiredMinor);
122 bool hasEGLFenceSyncExtension(void);
123 bool hasEGLWaitSyncExtension(void);
getEglDisplay()124 EGLDisplay getEglDisplay() {return m_eglDisplay;}
125
126 protected:
127 const EGLenum m_syncType;
128 const bool m_useCurrentContext;
129
130 glw::Functions m_gl;
131
132 Extension m_extensions;
133 EGLDisplay m_eglDisplay;
134 EGLConfig m_eglConfig;
135 EGLSurface m_eglSurface;
136 eglu::NativeWindow* m_nativeWindow;
137 EGLContext m_eglContext;
138 EGLSyncKHR m_sync;
139 string m_funcNames[FUNC_NAME_NUM_NAMES];
140 string m_funcNamesKHR[FUNC_NAME_NUM_NAMES];
141 };
142
SyncTest(EglTestContext & eglTestCtx,EGLenum syncType,Extension extensions,bool useCurrentContext,const char * name,const char * description)143 SyncTest::SyncTest (EglTestContext& eglTestCtx, EGLenum syncType, Extension extensions, bool useCurrentContext, const char* name, const char* description)
144 : TestCase (eglTestCtx, name, description)
145 , m_syncType (syncType)
146 , m_useCurrentContext (useCurrentContext)
147 , m_extensions (extensions)
148 , m_eglDisplay (EGL_NO_DISPLAY)
149 , m_eglConfig (((eglw::EGLConfig)0)) // EGL_NO_CONFIG
150 , m_eglSurface (EGL_NO_SURFACE)
151 , m_nativeWindow (DE_NULL)
152 , m_eglContext (EGL_NO_CONTEXT)
153 , m_sync (EGL_NO_SYNC_KHR)
154 {
155 m_funcNames[FUNC_NAME_CREATE_SYNC] = "eglCreateSync";
156 m_funcNames[FUNC_NAME_CLIENT_WAIT_SYNC] = "eglClientWaitSync";
157 m_funcNames[FUNC_NAME_GET_SYNC_ATTRIB] = "eglGetSyncAttrib";
158 m_funcNames[FUNC_NAME_DESTROY_SYNC] = "eglDestroySync";
159 m_funcNames[FUNC_NAME_WAIT_SYNC] = "eglWaitSync";
160
161 m_funcNamesKHR[FUNC_NAME_CREATE_SYNC] = "eglCreateSyncKHR";
162 m_funcNamesKHR[FUNC_NAME_CLIENT_WAIT_SYNC] = "eglClientWaitSyncKHR";
163 m_funcNamesKHR[FUNC_NAME_GET_SYNC_ATTRIB] = "eglGetSyncAttribKHR";
164 m_funcNamesKHR[FUNC_NAME_DESTROY_SYNC] = "eglDestroySyncKHR";
165 m_funcNamesKHR[FUNC_NAME_WAIT_SYNC] = "eglWaitSyncKHR";
166 }
167
~SyncTest(void)168 SyncTest::~SyncTest (void)
169 {
170 SyncTest::deinit();
171 }
172
hasRequiredEGLVersion(int requiredMajor,int requiredMinor)173 bool SyncTest::hasRequiredEGLVersion (int requiredMajor, int requiredMinor)
174 {
175 const Library& egl = m_eglTestCtx.getLibrary();
176 TestLog& log = m_testCtx.getLog();
177 eglu::Version version = eglu::getVersion(egl, m_eglDisplay);
178
179 if (version < eglu::Version(requiredMajor, requiredMinor))
180 {
181 log << TestLog::Message << "Required EGL version is not supported. "
182 "Has: " << version.getMajor() << "." << version.getMinor()
183 << ", Required: " << requiredMajor << "." << requiredMinor << TestLog::EndMessage;
184 return false;
185 }
186
187 return true;
188 }
189
hasEGLFenceSyncExtension(void)190 bool SyncTest::hasEGLFenceSyncExtension (void)
191 {
192 TestLog& log = m_testCtx.getLog();
193
194 if (!eglu::hasExtension(m_eglTestCtx.getLibrary(), m_eglDisplay, "EGL_KHR_fence_sync"))
195 {
196 log << TestLog::Message << "EGL_KHR_fence_sync not supported" << TestLog::EndMessage;
197 return false;
198 }
199
200 return true;
201 }
202
hasEGLWaitSyncExtension(void)203 bool SyncTest::hasEGLWaitSyncExtension (void)
204 {
205 TestLog& log = m_testCtx.getLog();
206
207 if (!eglu::hasExtension(m_eglTestCtx.getLibrary(), m_eglDisplay, "EGL_KHR_wait_sync"))
208 {
209 log << TestLog::Message << "EGL_KHR_wait_sync not supported" << TestLog::EndMessage;
210 return false;
211 }
212
213 return true;
214 }
215
requiredGLESExtensions(const glw::Functions & gl)216 void requiredGLESExtensions (const glw::Functions& gl)
217 {
218 bool found = false;
219 std::istringstream extensionStream((const char*)gl.getString(GL_EXTENSIONS));
220 string extension;
221
222 GLU_CHECK_GLW_MSG(gl, "glGetString(GL_EXTENSIONS)");
223
224 while (std::getline(extensionStream, extension, ' '))
225 {
226 if (extension == "GL_OES_EGL_sync")
227 found = true;
228 }
229
230 if (!found)
231 TCU_THROW(NotSupportedError, "GL_OES_EGL_sync not supported");
232 }
233
getSyncTypeExtension(EGLenum syncType)234 SyncTest::Extension getSyncTypeExtension (EGLenum syncType)
235 {
236 switch (syncType)
237 {
238 case EGL_SYNC_FENCE_KHR: return SyncTest::EXTENSION_FENCE_SYNC;
239 case EGL_SYNC_REUSABLE_KHR: return SyncTest::EXTENSION_REUSABLE_SYNC;
240 default:
241 DE_ASSERT(DE_FALSE);
242 return SyncTest::EXTENSION_NONE;
243 }
244 }
245
init(void)246 void SyncTest::init (void)
247 {
248 const Library& egl = m_eglTestCtx.getLibrary();
249 const eglu::NativeWindowFactory& windowFactory = eglu::selectNativeWindowFactory(m_eglTestCtx.getNativeDisplayFactory(), m_testCtx.getCommandLine());
250
251 const EGLint displayAttribList[] =
252 {
253 EGL_RENDERABLE_TYPE, EGL_OPENGL_ES2_BIT,
254 EGL_SURFACE_TYPE, EGL_WINDOW_BIT,
255 EGL_ALPHA_SIZE, 1,
256 EGL_NONE
257 };
258
259 const EGLint contextAttribList[] =
260 {
261 EGL_CONTEXT_CLIENT_VERSION, 2,
262 EGL_NONE
263 };
264
265 m_eglDisplay = eglu::getAndInitDisplay(m_eglTestCtx.getNativeDisplay());
266 m_eglConfig = eglu::chooseSingleConfig(egl, m_eglDisplay, displayAttribList);
267
268 m_eglTestCtx.initGLFunctions(&m_gl, glu::ApiType::es(2,0));
269
270 m_extensions = (Extension)(m_extensions | getSyncTypeExtension(m_syncType));
271
272 if (m_useCurrentContext)
273 {
274 // Create context
275 EGLU_CHECK_CALL(egl, bindAPI(EGL_OPENGL_ES_API));
276 m_eglContext = egl.createContext(m_eglDisplay, m_eglConfig, EGL_NO_CONTEXT, contextAttribList);
277 EGLU_CHECK_MSG(egl, "Failed to create GLES2 context");
278
279 // Create surface
280 m_nativeWindow = windowFactory.createWindow(&m_eglTestCtx.getNativeDisplay(), m_eglDisplay, m_eglConfig, DE_NULL, eglu::WindowParams(480, 480, eglu::parseWindowVisibility(m_testCtx.getCommandLine())));
281 m_eglSurface = eglu::createWindowSurface(m_eglTestCtx.getNativeDisplay(), *m_nativeWindow, m_eglDisplay, m_eglConfig, DE_NULL);
282
283 EGLU_CHECK_CALL(egl, makeCurrent(m_eglDisplay, m_eglSurface, m_eglSurface, m_eglContext));
284
285 requiredGLESExtensions(m_gl);
286 }
287
288 // Verify EXTENSION_REUSABLE_SYNC is supported before running the tests
289 if (m_syncType == EGL_SYNC_REUSABLE_KHR) {
290 if (!eglu::hasExtension(m_eglTestCtx.getLibrary(), m_eglDisplay, "EGL_KHR_reusable_sync"))
291 {
292 TCU_THROW(NotSupportedError, "EGL_KHR_reusable_sync not supported");
293 }
294 }
295 }
296
deinit(void)297 void SyncTest::deinit (void)
298 {
299 const Library& egl = m_eglTestCtx.getLibrary();
300
301 if (m_eglDisplay != EGL_NO_DISPLAY)
302 {
303 if (m_sync != EGL_NO_SYNC_KHR)
304 {
305 EGLU_CHECK_CALL(egl, destroySyncKHR(m_eglDisplay, m_sync));
306 m_sync = EGL_NO_SYNC_KHR;
307 }
308
309 EGLU_CHECK_CALL(egl, makeCurrent(m_eglDisplay, EGL_NO_SURFACE, EGL_NO_SURFACE, EGL_NO_CONTEXT));
310
311 if (m_eglContext != EGL_NO_CONTEXT)
312 {
313 EGLU_CHECK_CALL(egl, destroyContext(m_eglDisplay, m_eglContext));
314 m_eglContext = EGL_NO_CONTEXT;
315 }
316
317 if (m_eglSurface != EGL_NO_SURFACE)
318 {
319 EGLU_CHECK_CALL(egl, destroySurface(m_eglDisplay, m_eglSurface));
320 m_eglSurface = EGL_NO_SURFACE;
321 }
322
323 delete m_nativeWindow;
324 m_nativeWindow = DE_NULL;
325
326 egl.terminate(m_eglDisplay);
327 m_eglDisplay = EGL_NO_DISPLAY;
328 }
329 }
330
331 static const char* const glsl_cs_long = R"(
332 layout(local_size_x = 1, local_size_y = 1) in;
333 layout(std430) buffer;
334 layout(binding = 0) buffer Output {
335 int elements[2];
336 } output_data;
337
338 void main() {
339 int temp = 0;
340 int value = output_data.elements[1]/100;
341 for (int i = 0; i < value; i++) {
342 for (int j = 0; j < output_data.elements[1]/value; j++) {
343 temp += 1;
344 }
345 }
346 atomicAdd(output_data.elements[0], temp);
347 }
348 )";
349
350 static const char* const kGLSLVer = "#version 310 es\n";
351
352 class CreateLongRunningSyncTest : public SyncTest {
353 GLuint m_buffer = 0;
354 volatile int* m_dataloadstoreptr = NULL;
355 eglw::EGLContext m_sharedcontext = NULL;
356 const int m_total_count = 5000000;
357 const int m_shorter_count = 50000;
358
init(void)359 void init(void) override
360 {
361 const EGLint contextAttribList[] = {EGL_CONTEXT_CLIENT_VERSION,
362 3, EGL_NONE};
363 const EGLint displayAttribList[] = {EGL_RENDERABLE_TYPE,
364 EGL_OPENGL_ES3_BIT_KHR,
365 EGL_SURFACE_TYPE,
366 EGL_WINDOW_BIT,
367 EGL_ALPHA_SIZE,
368 1,
369 EGL_NONE};
370 const Library& egl = m_eglTestCtx.getLibrary();
371 const eglu::NativeWindowFactory& windowFactory =
372 eglu::selectNativeWindowFactory(
373 m_eglTestCtx.getNativeDisplayFactory(),
374 m_testCtx.getCommandLine());
375 TestLog& log = m_testCtx.getLog();
376
377 m_eglDisplay =
378 eglu::getAndInitDisplay(m_eglTestCtx.getNativeDisplay());
379 m_eglConfig = eglu::chooseSingleConfig(egl, m_eglDisplay,
380 displayAttribList);
381
382 m_eglTestCtx.initGLFunctions(&m_gl, glu::ApiType::es(3, 1));
383
384 m_extensions = (Extension)(m_extensions | getSyncTypeExtension(m_syncType));
385
386 // Create context
387 EGLU_CHECK_CALL(egl, bindAPI(EGL_OPENGL_ES_API));
388 m_eglContext = egl.createContext(m_eglDisplay, m_eglConfig, EGL_NO_CONTEXT, contextAttribList);
389 if (egl.getError() != EGL_SUCCESS)
390 TCU_THROW(NotSupportedError, "GLES3 not supported");
391
392 m_nativeWindow = windowFactory.createWindow(&m_eglTestCtx.getNativeDisplay(), m_eglDisplay,
393 m_eglConfig, DE_NULL, eglu::WindowParams(480, 480,
394 eglu::parseWindowVisibility(m_testCtx.getCommandLine())));
395
396 m_eglSurface = eglu::createWindowSurface(m_eglTestCtx.getNativeDisplay(), *m_nativeWindow,
397 m_eglDisplay, m_eglConfig, DE_NULL);
398
399 EGLU_CHECK_CALL(egl, makeCurrent(m_eglDisplay, m_eglSurface, m_eglSurface, m_eglContext));
400
401 requiredGLESExtensions(m_gl);
402
403 m_sharedcontext = egl.createContext(m_eglDisplay, m_eglConfig, m_eglContext, contextAttribList);
404
405 if (m_sharedcontext == EGL_NO_CONTEXT || egl.getError() != EGL_SUCCESS) {
406 log << TestLog::Message << "Error creating a shared context"
407 << TestLog::EndMessage;
408 m_testCtx.setTestResult(QP_TEST_RESULT_FAIL, "Fail");
409 }
410 }
411
deinit(void)412 void deinit(void) override
413 {
414 const Library& egl = m_eglTestCtx.getLibrary();
415
416 m_gl.useProgram(0);
417 if (m_buffer != 0) {
418 m_gl.deleteBuffers(2, &m_buffer);
419 m_buffer = 0;
420 }
421
422 if (m_sharedcontext != EGL_NO_CONTEXT) {
423 EGLU_CHECK_CALL(egl, destroyContext(m_eglDisplay, m_sharedcontext));
424 m_sharedcontext = EGL_NO_CONTEXT;
425 }
426
427 SyncTest::deinit();
428 }
429
CheckProgram(GLuint program,bool * compile_error=NULL)430 bool CheckProgram(GLuint program, bool* compile_error = NULL) {
431 GLint compile_status = GL_TRUE;
432 GLint status;
433 TestLog& logger = m_testCtx.getLog();
434
435 m_gl.getProgramiv(program, GL_LINK_STATUS, &status);
436
437 if (status == GL_FALSE)
438 {
439 GLint attached_shaders = 0;
440 GLint length;
441
442 m_gl.getProgramiv(program, GL_ATTACHED_SHADERS, &attached_shaders);
443
444 if (attached_shaders > 0)
445 {
446 std::vector<GLuint> shaders(attached_shaders);
447 m_gl.getAttachedShaders(program, attached_shaders, NULL, &shaders[0]);
448
449 for (GLint i = 0; i < attached_shaders; ++i)
450 {
451 GLint res;
452 GLenum type;
453 m_gl.getShaderiv(shaders[i], GL_SHADER_TYPE,
454 reinterpret_cast<GLint*>(&type));
455 switch (type) {
456 case GL_VERTEX_SHADER:
457 logger << tcu::TestLog::Message
458 << "*** Vertex Shader ***"
459 << tcu::TestLog::EndMessage;
460 break;
461 case GL_FRAGMENT_SHADER:
462 logger << tcu::TestLog::Message
463 << "*** Fragment Shader ***"
464 << tcu::TestLog::EndMessage;
465 break;
466 case GL_COMPUTE_SHADER:
467 logger << tcu::TestLog::Message
468 << "*** Compute Shader ***"
469 << tcu::TestLog::EndMessage;
470 break;
471 default:
472 logger << tcu::TestLog::Message
473 << "*** Unknown Shader ***"
474 << tcu::TestLog::EndMessage;
475 break;
476 }
477
478 m_gl.getShaderiv(shaders[i], GL_COMPILE_STATUS, &res);
479 if (res != GL_TRUE)
480 compile_status = res;
481
482 length = 0;
483 m_gl.getShaderiv(shaders[i], GL_SHADER_SOURCE_LENGTH, &length);
484 if (length > 0)
485 {
486 std::vector<GLchar> source(length);
487 m_gl.getShaderSource(shaders[i], length, NULL, &source[0]);
488 logger << tcu::TestLog::Message << &source[0]
489 << tcu::TestLog::EndMessage;
490 }
491
492 m_gl.getShaderiv(shaders[i], GL_INFO_LOG_LENGTH, &length);
493 if (length > 0)
494 {
495 std::vector<GLchar> log(length);
496 m_gl.getShaderInfoLog(shaders[i], length, NULL, &log[0]);
497 logger << tcu::TestLog::Message << &log[0] << tcu::TestLog::EndMessage;
498 }
499 }
500 }
501
502 m_gl.getProgramiv(program, GL_INFO_LOG_LENGTH, &length);
503 if (length > 0) {
504 std::vector<GLchar> log(length);
505 m_gl.getProgramInfoLog(program, length, NULL,
506 &log[0]);
507 logger << tcu::TestLog::Message << &log[0]
508 << tcu::TestLog::EndMessage;
509 }
510 }
511
512 if (compile_error)
513 *compile_error = (compile_status == GL_TRUE ? false : true);
514
515 if (compile_status != GL_TRUE)
516 return false;
517
518 return status == GL_TRUE ? true : false;
519 }
520
CreateComputeProgram(const std::string & cs)521 GLuint CreateComputeProgram(const std::string& cs) {
522 const GLuint p = m_gl.createProgram();
523
524 if (!cs.empty())
525 {
526 const GLuint sh = m_gl.createShader(GL_COMPUTE_SHADER);
527 m_gl.attachShader(p, sh);
528 m_gl.deleteShader(sh);
529 const char* const src[2] = {kGLSLVer, cs.c_str()};
530 m_gl.shaderSource(sh, 2, src, NULL);
531 m_gl.compileShader(sh);
532 }
533
534 return p;
535 }
536
537 // Run the test. Return whether validation can continue. If false then the test result must
538 // already be set. Used so that validation can be skipped if some members are left invalid.
RunComputePersistent()539 bool RunComputePersistent() {
540 const Library& egl = m_eglTestCtx.getLibrary();
541 TestLog& log = m_testCtx.getLog();
542 GLbitfield flags = GL_MAP_READ_BIT | GL_MAP_WRITE_BIT |
543 GL_MAP_PERSISTENT_BIT | GL_MAP_COHERENT_BIT;
544 GLuint program = CreateComputeProgram(glsl_cs_long);
545 decltype(glw::Functions::bufferStorage) func;
546
547 m_gl.linkProgram(program);
548 if (!CheckProgram(program))
549 {
550 m_testCtx.setTestResult(QP_TEST_RESULT_FAIL, "Fail");
551 return false;
552 }
553
554 m_gl.useProgram(program);
555 m_gl.genBuffers(2, &m_buffer);
556 m_gl.bindBufferBase(GL_SHADER_STORAGE_BUFFER, 0, m_buffer);
557
558 GLU_EXPECT_NO_ERROR(m_gl.getError(), "Buffer Creation Failed");
559
560 func = reinterpret_cast<decltype(glw::Functions::bufferStorage)>(
561 egl.getProcAddress("glBufferStorageEXT"));
562 if (!func)
563 {
564 log << TestLog::Message
565 << "Error getting the correct function"
566 << TestLog::EndMessage;
567 m_testCtx.setTestResult(QP_TEST_RESULT_NOT_SUPPORTED, "glBufferStorageEXT not supported");
568 return false;
569 }
570
571 func(GL_SHADER_STORAGE_BUFFER, sizeof(int) * 2, NULL, flags);
572 GLU_EXPECT_NO_ERROR(m_gl.getError(), "Buffer Set Persistent Bits");
573
574 m_dataloadstoreptr = static_cast<int*>(m_gl.mapBufferRange(
575 GL_SHADER_STORAGE_BUFFER, 0, sizeof(int) * 2, flags));
576 m_dataloadstoreptr[0] = 0;
577 m_dataloadstoreptr[1] = m_shorter_count;
578
579 for (int i = 0; i < m_total_count/m_shorter_count; i++)
580 m_gl.dispatchCompute(1, 1, 1);
581
582 m_gl.memoryBarrier(GL_ALL_BARRIER_BITS);
583 m_gl.flush();
584 return true;
585 };
586
587 template <typename clientWaitSyncFuncType>
PollClientWait(string funcNames[FUNC_NAME_NUM_NAMES],clientWaitSyncFuncType clientWaitSyncFunc,EGLint flags,const string & flagsName,EGLTime eglTime,const string & eglTimeName,EGLint condSatisfied)588 void PollClientWait(string funcNames[FUNC_NAME_NUM_NAMES],
589 clientWaitSyncFuncType clientWaitSyncFunc,
590 EGLint flags, const string& flagsName,
591 EGLTime eglTime, const string& eglTimeName,
592 EGLint condSatisfied) {
593 TestLog& log = m_testCtx.getLog();
594 const Library& egl = m_eglTestCtx.getLibrary();
595 EGLint status = (egl.*clientWaitSyncFunc)(m_eglDisplay, m_sync, flags, 0);
596
597 log << TestLog::Message << status << " = "
598 << funcNames[FUNC_NAME_CLIENT_WAIT_SYNC] << "("
599 << m_eglDisplay << ", " << m_sync << ", " << flagsName
600 << ", " << eglTimeName << ")" << TestLog::EndMessage;
601
602 while (true)
603 {
604 switch (status)
605 {
606 case EGL_TIMEOUT_EXPIRED_KHR:
607 log << TestLog::Message
608 << "TAGTAG Wait --- GL_TIMEOUT_EXPIRED"
609 << TestLog::EndMessage;
610 break;
611 case EGL_CONDITION_SATISFIED_KHR:
612 log << TestLog::Message
613 << "TAGTAG Wait --- GL_CONDITION_SATISFIED"
614 << TestLog::EndMessage;
615 return;
616 case EGL_FALSE:
617 log << TestLog::Message
618 << "TAGTAG Wait --- EGL_FALSE"
619 << TestLog::EndMessage;
620 return;
621 default:
622 log << TestLog::Message
623 << "TAGTAG Wait --- SOMETHING ELSE"
624 << TestLog::EndMessage;
625 return;
626 }
627 status = (egl.*clientWaitSyncFunc)(m_eglDisplay, m_sync, flags, eglTime);
628 }
629
630 TCU_CHECK(status == condSatisfied);
631 }
632
633 template <typename createSyncFuncType, typename clientWaitSyncFuncType,
634 typename destroySyncFuncType>
test(string funcNames[FUNC_NAME_NUM_NAMES],createSyncFuncType createSyncFunc,clientWaitSyncFuncType clientWaitSyncFunc,destroySyncFuncType destroySyncFunc,EGLenum syncType,EGLint flags,const string & flagsName,EGLTime eglTime,const string & eglTimeName,EGLint condSatisfied)635 void test(string funcNames[FUNC_NAME_NUM_NAMES],
636 createSyncFuncType createSyncFunc,
637 clientWaitSyncFuncType clientWaitSyncFunc,
638 destroySyncFuncType destroySyncFunc, EGLenum syncType,
639 EGLint flags, const string& flagsName, EGLTime eglTime,
640 const string& eglTimeName, EGLint condSatisfied) {
641
642 const Library& egl = m_eglTestCtx.getLibrary();
643 TestLog& log = m_testCtx.getLog();
644 string createSyncMsgChk =
645 funcNames[FUNC_NAME_CREATE_SYNC] + "()";
646 EGLBoolean result;
647
648 // Reset before each test
649 deinit();
650 init();
651
652 result = egl.makeCurrent(m_eglDisplay, m_eglSurface, m_eglSurface,
653 m_sharedcontext);
654
655 if (!result || egl.getError() != EGL_SUCCESS)
656 {
657 log << TestLog::Message
658 << "Error making this context current"
659 << TestLog::EndMessage;
660
661 m_testCtx.setTestResult(QP_TEST_RESULT_FAIL, "Fail");
662
663 return;
664 }
665
666 // The test may already encountered an error before everything was set up properly.
667 // If that has happened then the exit code will already be set and we must exit before
668 // trying to use any of the members because they may not be valid.
669 if (!RunComputePersistent())
670 return;
671
672 m_sync = (egl.*createSyncFunc)(m_eglDisplay, syncType, NULL);
673 log << TestLog::Message << m_sync << " = "
674 << funcNames[FUNC_NAME_CREATE_SYNC] << "(" << m_eglDisplay
675 << ", " << getSyncTypeName(syncType) << ", NULL)"
676 << TestLog::EndMessage;
677
678 EGLU_CHECK_MSG(egl, createSyncMsgChk.c_str());
679
680 PollClientWait<clientWaitSyncFuncType>(
681 funcNames, clientWaitSyncFunc, flags, flagsName, eglTime,
682 eglTimeName, condSatisfied);
683
684 log << TestLog::Message << funcNames[FUNC_NAME_DESTROY_SYNC]
685 << "(" << m_eglDisplay << ", " << m_sync << ")"
686 << TestLog::EndMessage;
687
688 EGLU_CHECK_CALL_FPTR(
689 egl, (egl.*destroySyncFunc)(m_eglDisplay, m_sync));
690
691 m_sync = EGL_NO_SYNC_KHR;
692
693 if (*m_dataloadstoreptr != 5000000) {
694 log << TestLog::Message << "Invalid m_Dataloadstoreptr "
695 << *m_dataloadstoreptr << TestLog::EndMessage;
696 m_testCtx.setTestResult(QP_TEST_RESULT_FAIL, "Fail");
697 return;
698 }
699
700 EGLU_CHECK_CALL(egl, makeCurrent(m_eglDisplay, m_eglSurface,
701 m_eglSurface, m_eglContext));
702 }
703
704 public:
CreateLongRunningSyncTest(EglTestContext & eglTestCtx,EGLenum syncType)705 CreateLongRunningSyncTest(EglTestContext& eglTestCtx, EGLenum syncType)
706 : SyncTest(eglTestCtx, syncType, SyncTest::EXTENSION_NONE, true,
707 "egl_fence_persistent_buffer",
708 "egl_fence_persistent_buffer") {}
709
iterate(void)710 IterateResult iterate(void) override
711 {
712 m_testCtx.setTestResult(QP_TEST_RESULT_PASS, "Pass");
713
714 if (hasRequiredEGLVersion(1, 5))
715 {
716 test<createSync, clientWaitSync, destroySync>(
717 m_funcNames, &Library::createSync,
718 &Library::clientWaitSync, &Library::destroySync,
719 EGL_SYNC_FENCE, EGL_SYNC_FLUSH_COMMANDS_BIT,
720 "EGL_SYNC_FLUSH_COMMANDS_BIT", EGL_FOREVER,
721 "EGL_FOREVER", EGL_CONDITION_SATISFIED);
722 }
723
724 if (hasEGLFenceSyncExtension())
725 {
726 test<createSyncKHR, clientWaitSyncKHR, destroySyncKHR>(
727 m_funcNames, &Library::createSyncKHR,
728 &Library::clientWaitSyncKHR,
729 &Library::destroySyncKHR, EGL_SYNC_FENCE_KHR,
730 EGL_SYNC_FLUSH_COMMANDS_BIT,
731 "EGL_SYNC_FLUSH_COMMANDS_BIT", EGL_FOREVER,
732 "EGL_FOREVER", EGL_CONDITION_SATISFIED);
733
734 #if (DE_OS == DE_OS_ANDROID)
735 test<createSyncKHR, clientWaitSyncKHR, destroySyncKHR>(
736 m_funcNames, &Library::createSyncKHR,
737 &Library::clientWaitSyncKHR,
738 &Library::destroySyncKHR,
739 EGL_SYNC_NATIVE_FENCE_ANDROID,
740 EGL_SYNC_FLUSH_COMMANDS_BIT,
741 "EGL_SYNC_FLUSH_COMMANDS_BIT", EGL_FOREVER,
742 "EGL_FOREVER", EGL_CONDITION_SATISFIED);
743 #endif
744
745 } else if (!hasRequiredEGLVersion(1, 5))
746 {
747 TCU_THROW(NotSupportedError,
748 "Required extensions not supported");
749 }
750
751 return STOP;
752 }
753 };
754
755 class CreateNullAttribsTest : public SyncTest
756 {
757 public:
CreateNullAttribsTest(EglTestContext & eglTestCtx,EGLenum syncType)758 CreateNullAttribsTest (EglTestContext& eglTestCtx, EGLenum syncType)
759 : SyncTest (eglTestCtx, syncType, SyncTest::EXTENSION_NONE, syncType != EGL_SYNC_REUSABLE_KHR, "create_null_attribs", "create_null_attribs")
760 {
761 }
762
763 template <typename createSyncFuncType>
test(string funcNames[FUNC_NAME_NUM_NAMES],createSyncFuncType createSyncFunc)764 void test(string funcNames[FUNC_NAME_NUM_NAMES],
765 createSyncFuncType createSyncFunc)
766 {
767 // Reset before each test
768 deinit();
769 init();
770
771 const Library& egl = m_eglTestCtx.getLibrary();
772 TestLog& log = m_testCtx.getLog();
773 string msgChk = funcNames[FUNC_NAME_CREATE_SYNC] + "()";
774
775 m_sync = (egl.*createSyncFunc)(m_eglDisplay, m_syncType, NULL);
776 log << TestLog::Message << m_sync << " = " << funcNames[FUNC_NAME_CREATE_SYNC] << "(" <<
777 m_eglDisplay << ", " << getSyncTypeName(m_syncType) << ", NULL)" <<
778 TestLog::EndMessage;
779 EGLU_CHECK_MSG(egl, msgChk.c_str());
780 }
781
iterate(void)782 IterateResult iterate(void)
783 {
784 m_testCtx.setTestResult(QP_TEST_RESULT_PASS, "Pass");
785
786 if (hasRequiredEGLVersion(1, 5))
787 {
788 test<createSync>(m_funcNames, &Library::createSync);
789 }
790 if (hasEGLFenceSyncExtension())
791 {
792 test<createSyncKHR>(m_funcNamesKHR, &Library::createSyncKHR);
793 }
794 else if (!hasRequiredEGLVersion(1, 5))
795 {
796 TCU_THROW(NotSupportedError, "Required extensions not supported");
797 }
798
799 return STOP;
800 }
801 };
802
803 class CreateEmptyAttribsTest : public SyncTest
804 {
805 public:
CreateEmptyAttribsTest(EglTestContext & eglTestCtx,EGLenum syncType)806 CreateEmptyAttribsTest (EglTestContext& eglTestCtx, EGLenum syncType)
807 : SyncTest (eglTestCtx, syncType, SyncTest::EXTENSION_NONE, syncType != EGL_SYNC_REUSABLE_KHR, "create_empty_attribs", "create_empty_attribs")
808 {
809 }
810
811 template <typename createSyncFuncType, typename attribType>
test(string funcNames[FUNC_NAME_NUM_NAMES],createSyncFuncType createSyncFunc)812 void test(string funcNames[FUNC_NAME_NUM_NAMES],
813 createSyncFuncType createSyncFunc)
814 {
815 // Reset before each test
816 deinit();
817 init();
818
819 const Library& egl = m_eglTestCtx.getLibrary();
820 TestLog& log = m_testCtx.getLog();
821 string msgChk = funcNames[FUNC_NAME_CREATE_SYNC] + "()";
822 const attribType attribList[] =
823 {
824 EGL_NONE
825 };
826
827 m_sync = (egl.*createSyncFunc)(m_eglDisplay, m_syncType, attribList);
828 log << TestLog::Message << m_sync << " = " << funcNames[FUNC_NAME_CREATE_SYNC] <<
829 "(" << m_eglDisplay << ", " << getSyncTypeName(m_syncType) <<
830 ", { EGL_NONE })" << TestLog::EndMessage;
831 EGLU_CHECK_MSG(egl, msgChk.c_str());
832 }
833
iterate(void)834 IterateResult iterate (void)
835 {
836 m_testCtx.setTestResult(QP_TEST_RESULT_PASS, "Pass");
837
838 if (hasRequiredEGLVersion(1, 5))
839 {
840 test<createSync, EGLAttrib>(m_funcNames, &Library::createSync);
841 }
842 if (hasEGLFenceSyncExtension())
843 {
844 test<createSyncKHR, EGLint>(m_funcNamesKHR, &Library::createSyncKHR);
845 }
846 else if (!hasRequiredEGLVersion(1, 5))
847 {
848 TCU_THROW(NotSupportedError, "Required extensions not supported");
849 }
850
851 return STOP;
852 }
853 };
854
855 class CreateInvalidDisplayTest : public SyncTest
856 {
857 public:
CreateInvalidDisplayTest(EglTestContext & eglTestCtx,EGLenum syncType)858 CreateInvalidDisplayTest (EglTestContext& eglTestCtx, EGLenum syncType)
859 : SyncTest (eglTestCtx, syncType, SyncTest::EXTENSION_NONE, syncType != EGL_SYNC_REUSABLE_KHR, "create_invalid_display", "create_invalid_display")
860 {
861 }
862
863 template <typename createSyncFuncType, typename syncType>
test(string funcNames[FUNC_NAME_NUM_NAMES],createSyncFuncType createSyncFunc,syncType eglNoSync)864 void test(string funcNames[FUNC_NAME_NUM_NAMES],
865 createSyncFuncType createSyncFunc, syncType eglNoSync)
866 {
867 // Reset before each test
868 deinit();
869 init();
870
871 const Library& egl = m_eglTestCtx.getLibrary();
872 TestLog& log = m_testCtx.getLog();
873
874 m_sync = (egl.*createSyncFunc)(EGL_NO_DISPLAY, m_syncType, NULL);
875 log << TestLog::Message << m_sync << " = " << funcNames[FUNC_NAME_CREATE_SYNC] <<
876 "(EGL_NO_DISPLAY, " << getSyncTypeName(m_syncType) << ", NULL)" <<
877 TestLog::EndMessage;
878
879 EGLint error = egl.getError();
880 log << TestLog::Message << error << " = eglGetError()" << TestLog::EndMessage;
881
882 if (error != EGL_BAD_DISPLAY)
883 {
884 log << TestLog::Message << "Unexpected error '" <<
885 eglu::getErrorStr(error) << "' expected EGL_BAD_DISPLAY" <<
886 TestLog::EndMessage;
887 m_testCtx.setTestResult(QP_TEST_RESULT_FAIL, "Fail");
888 return;
889 }
890
891 TCU_CHECK(m_sync == eglNoSync);
892 }
893
iterate(void)894 IterateResult iterate (void)
895 {
896 m_testCtx.setTestResult(QP_TEST_RESULT_PASS, "Pass");
897
898 if (hasRequiredEGLVersion(1, 5))
899 {
900 test<createSync, EGLSync>(m_funcNames, &Library::createSync, EGL_NO_SYNC);
901 }
902 if (hasEGLFenceSyncExtension())
903 {
904 test<createSyncKHR, EGLSyncKHR>(m_funcNamesKHR, &Library::createSyncKHR, EGL_NO_SYNC_KHR);
905 }
906 else if (!hasRequiredEGLVersion(1, 5))
907 {
908 TCU_THROW(NotSupportedError, "Required extensions not supported");
909 }
910
911 return STOP;
912 }
913 };
914
915 class CreateInvalidTypeTest : public SyncTest
916 {
917 public:
CreateInvalidTypeTest(EglTestContext & eglTestCtx,EGLenum syncType)918 CreateInvalidTypeTest (EglTestContext& eglTestCtx, EGLenum syncType)
919 : SyncTest (eglTestCtx, syncType, SyncTest::EXTENSION_NONE, syncType != EGL_SYNC_REUSABLE_KHR, "create_invalid_type", "create_invalid_type")
920 {
921 }
922
923 template <typename createSyncFuncType>
test(string funcNames[FUNC_NAME_NUM_NAMES],createSyncFuncType createSyncFunc,EGLSyncKHR eglNoSync,EGLint syncError,string syncErrorName)924 void test(string funcNames[FUNC_NAME_NUM_NAMES],
925 createSyncFuncType createSyncFunc, EGLSyncKHR eglNoSync,
926 EGLint syncError, string syncErrorName)
927 {
928 // Reset before each test
929 deinit();
930 init();
931
932 const Library& egl = m_eglTestCtx.getLibrary();
933 TestLog& log = m_testCtx.getLog();
934
935 m_sync = (egl.*createSyncFunc)(m_eglDisplay, EGL_NONE, NULL);
936 log << TestLog::Message << m_sync << " = " << funcNames[FUNC_NAME_CREATE_SYNC] << "(" <<
937 m_eglDisplay << ", EGL_NONE, NULL)" << TestLog::EndMessage;
938
939 EGLint error = egl.getError();
940 log << TestLog::Message << error << " = eglGetError()" << TestLog::EndMessage;
941
942 if (error != syncError)
943 {
944 log << TestLog::Message << "Unexpected error '" <<
945 eglu::getErrorStr(error) << "' expected " << syncErrorName << " " <<
946 TestLog::EndMessage;
947 m_testCtx.setTestResult(QP_TEST_RESULT_FAIL, "Fail");
948 return;
949 }
950
951 TCU_CHECK(m_sync == eglNoSync);
952 }
953
iterate(void)954 IterateResult iterate (void)
955 {
956 m_testCtx.setTestResult(QP_TEST_RESULT_PASS, "Pass");
957
958 if (hasRequiredEGLVersion(1, 5))
959 {
960 test<createSync>(m_funcNames, &Library::createSync, EGL_NO_SYNC,
961 EGL_BAD_PARAMETER, "EGL_BAD_PARAMETER");
962 }
963 if (hasEGLFenceSyncExtension())
964 {
965 test<createSyncKHR>(m_funcNamesKHR, &Library::createSyncKHR, EGL_NO_SYNC_KHR,
966 EGL_BAD_ATTRIBUTE, "EGL_BAD_ATTRIBUTE");
967 }
968 else if (!hasRequiredEGLVersion(1, 5))
969 {
970 TCU_THROW(NotSupportedError, "Required extensions not supported");
971 }
972
973 return STOP;
974 }
975 };
976
977 class CreateInvalidAttribsTest : public SyncTest
978 {
979 public:
CreateInvalidAttribsTest(EglTestContext & eglTestCtx,EGLenum syncType)980 CreateInvalidAttribsTest (EglTestContext& eglTestCtx, EGLenum syncType)
981 : SyncTest (eglTestCtx, syncType, SyncTest::EXTENSION_NONE, syncType != EGL_SYNC_REUSABLE_KHR, "create_invalid_attribs", "create_invalid_attribs")
982 {
983 }
984
985 template <typename createSyncFuncType, typename attribType>
test(string funcNames[FUNC_NAME_NUM_NAMES],createSyncFuncType createSyncFunc,EGLSyncKHR eglNoSync)986 void test(string funcNames[FUNC_NAME_NUM_NAMES],
987 createSyncFuncType createSyncFunc, EGLSyncKHR eglNoSync)
988 {
989 // Reset before each test
990 deinit();
991 init();
992
993 const Library& egl = m_eglTestCtx.getLibrary();
994 TestLog& log = m_testCtx.getLog();
995
996 attribType attribs[] = {
997 2, 3, 4, 5,
998 EGL_NONE
999 };
1000
1001 m_sync = (egl.*createSyncFunc)(m_eglDisplay, m_syncType, attribs);
1002 log << TestLog::Message << m_sync << " = " << funcNames[FUNC_NAME_CREATE_SYNC] <<
1003 "(" << m_eglDisplay << ", " << getSyncTypeName(m_syncType) <<
1004 ", { 2, 3, 4, 5, EGL_NONE })" << TestLog::EndMessage;
1005
1006 EGLint error = egl.getError();
1007 log << TestLog::Message << error << " = eglGetError()" << TestLog::EndMessage;
1008
1009 if (error != EGL_BAD_ATTRIBUTE)
1010 {
1011 log << TestLog::Message << "Unexpected error '" << eglu::getErrorStr(error) <<
1012 "' expected EGL_BAD_ATTRIBUTE" << TestLog::EndMessage;
1013 m_testCtx.setTestResult(QP_TEST_RESULT_FAIL, "Fail");
1014 return;
1015 }
1016
1017 TCU_CHECK(m_sync == eglNoSync);
1018 }
1019
iterate(void)1020 IterateResult iterate (void)
1021 {
1022 m_testCtx.setTestResult(QP_TEST_RESULT_PASS, "Pass");
1023
1024 if (hasRequiredEGLVersion(1, 5))
1025 {
1026 test<createSync, EGLAttrib>(m_funcNames, &Library::createSync, EGL_NO_SYNC);
1027 }
1028 if (hasEGLFenceSyncExtension())
1029 {
1030 test<createSyncKHR, EGLint>(m_funcNamesKHR, &Library::createSyncKHR, EGL_NO_SYNC_KHR);
1031 }
1032 else if (!hasRequiredEGLVersion(1, 5))
1033 {
1034 TCU_THROW(NotSupportedError, "Required extensions not supported");
1035 }
1036
1037 return STOP;
1038 }
1039 };
1040
1041 class CreateInvalidContextTest : public SyncTest
1042 {
1043 public:
CreateInvalidContextTest(EglTestContext & eglTestCtx,EGLenum syncType)1044 CreateInvalidContextTest (EglTestContext& eglTestCtx, EGLenum syncType)
1045 : SyncTest (eglTestCtx, syncType, SyncTest::EXTENSION_NONE, syncType != EGL_SYNC_REUSABLE_KHR, "create_invalid_context", "create_invalid_context")
1046 {
1047 }
1048
1049 template <typename createSyncFuncType>
test(string funcNames[FUNC_NAME_NUM_NAMES],createSyncFuncType createSyncFunc,EGLSyncKHR eglNoSync)1050 void test(string funcNames[FUNC_NAME_NUM_NAMES],
1051 createSyncFuncType createSyncFunc, EGLSyncKHR eglNoSync)
1052 {
1053 // Reset before each test
1054 deinit();
1055 init();
1056
1057 const Library& egl = m_eglTestCtx.getLibrary();
1058 TestLog& log = m_testCtx.getLog();
1059
1060 log << TestLog::Message << "eglMakeCurrent(" << m_eglDisplay <<
1061 ", EGL_NO_SURFACE, EGL_NO_SURFACE, EGL_NO_CONTEXT)" << TestLog::EndMessage;
1062 EGLU_CHECK_CALL(egl, makeCurrent(m_eglDisplay, EGL_NO_SURFACE,
1063 EGL_NO_SURFACE, EGL_NO_CONTEXT));
1064
1065 m_sync = (egl.*createSyncFunc)(m_eglDisplay, m_syncType, NULL);
1066 log << TestLog::Message << m_sync << " = " << funcNames[FUNC_NAME_CREATE_SYNC] <<
1067 "(" << m_eglDisplay << ", " << getSyncTypeName(m_syncType) << ", NULL)" <<
1068 TestLog::EndMessage;
1069
1070 EGLint error = egl.getError();
1071 log << TestLog::Message << error << " = eglGetError()" << TestLog::EndMessage;
1072
1073 if (error != EGL_BAD_MATCH)
1074 {
1075 log << TestLog::Message << "Unexpected error '" << eglu::getErrorStr(error) <<
1076 "' expected EGL_BAD_MATCH" << TestLog::EndMessage;
1077 m_testCtx.setTestResult(QP_TEST_RESULT_FAIL, "Fail");
1078 return;
1079 }
1080
1081 TCU_CHECK(m_sync == eglNoSync);
1082 }
1083
iterate(void)1084 IterateResult iterate (void)
1085 {
1086 m_testCtx.setTestResult(QP_TEST_RESULT_PASS, "Pass");
1087
1088 if (hasRequiredEGLVersion(1, 5))
1089 {
1090 test<createSync>(m_funcNames, &Library::createSync, EGL_NO_SYNC);
1091 }
1092 if (hasEGLFenceSyncExtension())
1093 {
1094 test<createSyncKHR>(m_funcNamesKHR, &Library::createSyncKHR, EGL_NO_SYNC_KHR);
1095 }
1096 else if (!hasRequiredEGLVersion(1, 5))
1097 {
1098 TCU_THROW(NotSupportedError, "Required extensions not supported");
1099 }
1100
1101 return STOP;
1102 }
1103 };
1104
1105 class ClientWaitNoTimeoutTest : public SyncTest
1106 {
1107 public:
ClientWaitNoTimeoutTest(EglTestContext & eglTestCtx,EGLenum syncType)1108 ClientWaitNoTimeoutTest (EglTestContext& eglTestCtx, EGLenum syncType)
1109 : SyncTest (eglTestCtx, syncType, SyncTest::EXTENSION_NONE, syncType != EGL_SYNC_REUSABLE_KHR, "wait_no_timeout", "wait_no_timeout")
1110 {
1111 }
1112
1113 template <typename createSyncFuncType, typename clientWaitSyncFuncType>
test(string funcNames[FUNC_NAME_NUM_NAMES],createSyncFuncType createSyncFunc,clientWaitSyncFuncType clientWaitSyncFunc)1114 void test(string funcNames[FUNC_NAME_NUM_NAMES],
1115 createSyncFuncType createSyncFunc,
1116 clientWaitSyncFuncType clientWaitSyncFunc)
1117 {
1118 // Reset before each test
1119 deinit();
1120 init();
1121
1122 const Library& egl = m_eglTestCtx.getLibrary();
1123 TestLog& log = m_testCtx.getLog();
1124 string msgChk = funcNames[FUNC_NAME_CREATE_SYNC] + "()";
1125
1126 m_sync = (egl.*createSyncFunc)(m_eglDisplay, m_syncType, NULL);
1127 log << TestLog::Message << m_sync << " = " << funcNames[FUNC_NAME_CREATE_SYNC] <<
1128 "(" << m_eglDisplay << ", " << getSyncTypeName(m_syncType) << ", NULL)" <<
1129 TestLog::EndMessage;
1130 EGLU_CHECK_MSG(egl, msgChk.c_str());
1131
1132 EGLint status = (egl.*clientWaitSyncFunc)(m_eglDisplay, m_sync, 0, 0);
1133 log << TestLog::Message << status << " = " << funcNames[FUNC_NAME_CLIENT_WAIT_SYNC] <<
1134 "(" << m_eglDisplay << ", " << m_sync << ", 0, 0)" << TestLog::EndMessage;
1135
1136 if (m_syncType == EGL_SYNC_FENCE_KHR)
1137 TCU_CHECK(status == EGL_CONDITION_SATISFIED_KHR || status == EGL_TIMEOUT_EXPIRED_KHR);
1138 else if (m_syncType == EGL_SYNC_REUSABLE_KHR)
1139 TCU_CHECK(status == EGL_TIMEOUT_EXPIRED_KHR);
1140 else
1141 DE_ASSERT(DE_FALSE);
1142 }
1143
iterate(void)1144 IterateResult iterate (void)
1145 {
1146 m_testCtx.setTestResult(QP_TEST_RESULT_PASS, "Pass");
1147
1148 if (hasRequiredEGLVersion(1, 5))
1149 {
1150 test<createSync, clientWaitSync>(m_funcNames, &Library::createSync,
1151 &Library::clientWaitSync);
1152 }
1153 if (hasEGLFenceSyncExtension())
1154 {
1155 test<createSyncKHR, clientWaitSyncKHR>(m_funcNamesKHR, &Library::createSyncKHR,
1156 &Library::clientWaitSyncKHR);
1157 }
1158 else if (!hasRequiredEGLVersion(1, 5))
1159 {
1160 TCU_THROW(NotSupportedError, "Required extensions not supported");
1161 }
1162
1163 return STOP;
1164 }
1165
1166 };
1167
1168 class ClientWaitForeverTest : public SyncTest
1169 {
1170 public:
ClientWaitForeverTest(EglTestContext & eglTestCtx,EGLenum syncType)1171 ClientWaitForeverTest (EglTestContext& eglTestCtx, EGLenum syncType)
1172 : SyncTest (eglTestCtx, syncType, SyncTest::EXTENSION_NONE, syncType != EGL_SYNC_REUSABLE_KHR, "wait_forever", "wait_forever")
1173 {
1174 }
1175
1176 template <typename createSyncFuncType, typename clientWaitSyncFuncType>
test(string funcNames[FUNC_NAME_NUM_NAMES],createSyncFuncType createSyncFunc,clientWaitSyncFuncType clientWaitSyncFunc,EGLTime eglTime,const string & eglTimeName,EGLint condSatisfied)1177 void test(string funcNames[FUNC_NAME_NUM_NAMES],
1178 createSyncFuncType createSyncFunc,
1179 clientWaitSyncFuncType clientWaitSyncFunc,
1180 EGLTime eglTime, const string &eglTimeName,
1181 EGLint condSatisfied)
1182 {
1183 // Reset before each test
1184 deinit();
1185 init();
1186
1187 const Library& egl = m_eglTestCtx.getLibrary();
1188 TestLog& log = m_testCtx.getLog();
1189 string createSyncMsgChk = funcNames[FUNC_NAME_CREATE_SYNC] + "()";
1190 string clientWaitSyncMsgChk = funcNames[FUNC_NAME_CLIENT_WAIT_SYNC] + "()";
1191
1192 m_sync = (egl.*createSyncFunc)(m_eglDisplay, m_syncType, NULL);
1193 log << TestLog::Message << m_sync << " = " << funcNames[FUNC_NAME_CREATE_SYNC] <<
1194 "(" << m_eglDisplay << ", " << getSyncTypeName(m_syncType) << ", NULL)" <<
1195 TestLog::EndMessage;
1196 EGLU_CHECK_MSG(egl, createSyncMsgChk.c_str());
1197
1198 if (m_syncType == EGL_SYNC_REUSABLE_KHR)
1199 {
1200 EGLBoolean ret = egl.signalSyncKHR(m_eglDisplay, m_sync, EGL_SIGNALED_KHR);
1201 log << TestLog::Message << ret << " = eglSignalSyncKHR(" <<
1202 m_eglDisplay << ", " << m_sync << ", EGL_SIGNALED_KHR)" <<
1203 TestLog::EndMessage;
1204 EGLU_CHECK_MSG(egl, "eglSignalSyncKHR()");
1205 }
1206 else if (m_syncType == EGL_SYNC_FENCE_KHR)
1207 {
1208 GLU_CHECK_GLW_CALL(m_gl, flush());
1209 log << TestLog::Message << "glFlush()" << TestLog::EndMessage;
1210 }
1211 else
1212 DE_ASSERT(DE_FALSE);
1213
1214 EGLint status = (egl.*clientWaitSyncFunc)(m_eglDisplay, m_sync, 0, eglTime);
1215 log << TestLog::Message << status << " = " << funcNames[FUNC_NAME_CLIENT_WAIT_SYNC] <<
1216 "(" << m_eglDisplay << ", " << m_sync << ", 0, " << eglTimeName << ")" <<
1217 TestLog::EndMessage;
1218
1219 TCU_CHECK(status == condSatisfied);
1220 EGLU_CHECK_MSG(egl, clientWaitSyncMsgChk.c_str());
1221 }
1222
iterate(void)1223 IterateResult iterate (void)
1224 {
1225 m_testCtx.setTestResult(QP_TEST_RESULT_PASS, "Pass");
1226
1227 if (hasRequiredEGLVersion(1, 5))
1228 {
1229 test<createSync, clientWaitSync>(m_funcNames, &Library::createSync,
1230 &Library::clientWaitSync,
1231 EGL_FOREVER, "EGL_FOREVER",
1232 EGL_CONDITION_SATISFIED);
1233 }
1234 if (hasEGLFenceSyncExtension())
1235 {
1236 test<createSyncKHR, clientWaitSyncKHR>(m_funcNamesKHR, &Library::createSyncKHR,
1237 &Library::clientWaitSyncKHR,
1238 EGL_FOREVER_KHR, "EGL_FOREVER_KHR",
1239 EGL_CONDITION_SATISFIED_KHR);
1240 }
1241 else if (!hasRequiredEGLVersion(1, 5))
1242 {
1243 TCU_THROW(NotSupportedError, "Required extensions not supported");
1244 }
1245
1246 return STOP;
1247 }
1248 };
1249
1250 class ClientWaitNoContextTest : public SyncTest
1251 {
1252 public:
ClientWaitNoContextTest(EglTestContext & eglTestCtx,EGLenum syncType)1253 ClientWaitNoContextTest (EglTestContext& eglTestCtx, EGLenum syncType)
1254 : SyncTest (eglTestCtx, syncType, SyncTest::EXTENSION_NONE, syncType != EGL_SYNC_REUSABLE_KHR, "wait_no_context", "wait_no_Context")
1255 {
1256 }
1257
1258 template <typename createSyncFuncType, typename clientWaitSyncFuncType>
test(string funcNames[FUNC_NAME_NUM_NAMES],createSyncFuncType createSyncFunc,clientWaitSyncFuncType clientWaitSyncFunc,EGLint condSatisfied,EGLTime eglTime,const string & eglTimeName)1259 void test(string funcNames[FUNC_NAME_NUM_NAMES],
1260 createSyncFuncType createSyncFunc,
1261 clientWaitSyncFuncType clientWaitSyncFunc,
1262 EGLint condSatisfied, EGLTime eglTime, const string &eglTimeName)
1263 {
1264 // Reset before each test
1265 deinit();
1266 init();
1267
1268 const Library& egl = m_eglTestCtx.getLibrary();
1269 TestLog& log = m_testCtx.getLog();
1270 string createSyncMsgChk = funcNames[FUNC_NAME_CREATE_SYNC] + "()";
1271
1272 m_sync = (egl.*createSyncFunc)(m_eglDisplay, m_syncType, NULL);
1273 log << TestLog::Message << m_sync << " = " << funcNames[FUNC_NAME_CREATE_SYNC] <<
1274 "(" << m_eglDisplay << ", " << getSyncTypeName(m_syncType) << ", NULL)" <<
1275 TestLog::EndMessage;
1276 EGLU_CHECK_MSG(egl, createSyncMsgChk.c_str());
1277
1278
1279 if (m_syncType == EGL_SYNC_REUSABLE_KHR)
1280 {
1281 EGLBoolean ret = egl.signalSyncKHR(m_eglDisplay, m_sync, EGL_SIGNALED_KHR);
1282 log << TestLog::Message << ret << " = eglSignalSyncKHR(" <<
1283 m_eglDisplay << ", " << m_sync << ", EGL_SIGNALED_KHR)" <<
1284 TestLog::EndMessage;
1285 EGLU_CHECK_MSG(egl, "eglSignalSyncKHR()");
1286 }
1287 else if (m_syncType == EGL_SYNC_FENCE_KHR)
1288 {
1289 GLU_CHECK_GLW_CALL(m_gl, flush());
1290 log << TestLog::Message << "glFlush()" << TestLog::EndMessage;
1291 }
1292 else
1293 DE_ASSERT(DE_FALSE);
1294
1295 log << TestLog::Message << "eglMakeCurrent(" << m_eglDisplay <<
1296 ", EGL_NO_SURFACE, EGL_NO_SURFACE, EGL_NO_CONTEXT)" << TestLog::EndMessage;
1297 EGLU_CHECK_CALL(egl, makeCurrent(m_eglDisplay, EGL_NO_SURFACE,
1298 EGL_NO_SURFACE, EGL_NO_CONTEXT));
1299
1300 EGLint result = (egl.*clientWaitSyncFunc)(m_eglDisplay, m_sync, 0, eglTime);
1301 log << TestLog::Message << result << " = " << funcNames[FUNC_NAME_CLIENT_WAIT_SYNC] <<
1302 "(" << m_eglDisplay << ", " << m_sync << ", 0, " << eglTimeName << ")" <<
1303 TestLog::EndMessage;
1304
1305 TCU_CHECK(result == condSatisfied);
1306 }
1307
iterate(void)1308 IterateResult iterate (void)
1309 {
1310 m_testCtx.setTestResult(QP_TEST_RESULT_PASS, "Pass");
1311
1312 if (hasRequiredEGLVersion(1, 5))
1313 {
1314 test<createSync, clientWaitSync>(m_funcNames, &Library::createSync,
1315 &Library::clientWaitSync,
1316 EGL_CONDITION_SATISFIED, EGL_FOREVER, "EGL_FOREVER");
1317 }
1318 if (hasEGLFenceSyncExtension())
1319 {
1320 test<createSyncKHR, clientWaitSyncKHR>(m_funcNamesKHR, &Library::createSyncKHR,
1321 &Library::clientWaitSyncKHR,
1322 EGL_CONDITION_SATISFIED_KHR, EGL_FOREVER_KHR, "EGL_FOREVER_KHR");
1323 }
1324 else if (!hasRequiredEGLVersion(1, 5))
1325 {
1326 TCU_THROW(NotSupportedError, "Required extensions not supported");
1327 }
1328
1329 return STOP;
1330 }
1331 };
1332
1333 class ClientWaitForeverFlushTest : public SyncTest
1334 {
1335 public:
ClientWaitForeverFlushTest(EglTestContext & eglTestCtx,EGLenum syncType)1336 ClientWaitForeverFlushTest (EglTestContext& eglTestCtx, EGLenum syncType)
1337 : SyncTest (eglTestCtx, syncType, SyncTest::EXTENSION_NONE, syncType != EGL_SYNC_REUSABLE_KHR, "wait_forever_flush", "wait_forever_flush")
1338 {
1339 }
1340
1341 template <typename createSyncFuncType, typename clientWaitSyncFuncType>
test(string funcNames[FUNC_NAME_NUM_NAMES],createSyncFuncType createSyncFunc,clientWaitSyncFuncType clientWaitSyncFunc,EGLint flags,const string & flagsName,EGLTime eglTime,const string & eglTimeName,EGLint condSatisfied)1342 void test(string funcNames[FUNC_NAME_NUM_NAMES],
1343 createSyncFuncType createSyncFunc,
1344 clientWaitSyncFuncType clientWaitSyncFunc,
1345 EGLint flags, const string &flagsName,
1346 EGLTime eglTime, const string &eglTimeName,
1347 EGLint condSatisfied)
1348 {
1349 // Reset before each test
1350 deinit();
1351 init();
1352
1353 const Library& egl = m_eglTestCtx.getLibrary();
1354 TestLog& log = m_testCtx.getLog();
1355 string createSyncMsgChk = funcNames[FUNC_NAME_CREATE_SYNC] + "()";
1356
1357 m_sync = (egl.*createSyncFunc)(m_eglDisplay, m_syncType, NULL);
1358 log << TestLog::Message << m_sync << " = " << funcNames[FUNC_NAME_CREATE_SYNC] <<
1359 "(" << m_eglDisplay << ", " << getSyncTypeName(m_syncType) << ", NULL)" <<
1360 TestLog::EndMessage;
1361 EGLU_CHECK_MSG(egl, createSyncMsgChk.c_str());
1362
1363 if (m_syncType == EGL_SYNC_REUSABLE_KHR)
1364 {
1365 EGLBoolean ret = egl.signalSyncKHR(m_eglDisplay, m_sync, EGL_SIGNALED_KHR);
1366 log << TestLog::Message << ret << " = eglSignalSyncKHR(" <<
1367 m_eglDisplay << ", " << m_sync << ", EGL_SIGNALED_KHR)" <<
1368 TestLog::EndMessage;
1369 EGLU_CHECK_MSG(egl, "eglSignalSyncKHR()");
1370 }
1371
1372 EGLint status = (egl.*clientWaitSyncFunc)(m_eglDisplay, m_sync, flags, eglTime);
1373 log << TestLog::Message << status << " = " << funcNames[FUNC_NAME_CLIENT_WAIT_SYNC] <<
1374 "(" << m_eglDisplay << ", " << m_sync << ", " << flagsName << ", " <<
1375 eglTimeName << ")" << TestLog::EndMessage;
1376
1377 TCU_CHECK(status == condSatisfied);
1378
1379 }
1380
iterate(void)1381 IterateResult iterate (void)
1382 {
1383 m_testCtx.setTestResult(QP_TEST_RESULT_PASS, "Pass");
1384
1385 if (hasRequiredEGLVersion(1, 5))
1386 {
1387 test<createSync, clientWaitSync>(m_funcNames, &Library::createSync,
1388 &Library::clientWaitSync,
1389 EGL_SYNC_FLUSH_COMMANDS_BIT, "EGL_SYNC_FLUSH_COMMANDS_BIT",
1390 EGL_FOREVER, "EGL_FOREVER",
1391 EGL_CONDITION_SATISFIED);
1392 }
1393 if (hasEGLFenceSyncExtension())
1394 {
1395 test<createSyncKHR, clientWaitSyncKHR>(m_funcNamesKHR, &Library::createSyncKHR,
1396 &Library::clientWaitSyncKHR,
1397 EGL_SYNC_FLUSH_COMMANDS_BIT_KHR, "EGL_SYNC_FLUSH_COMMANDS_BIT_KHR",
1398 EGL_FOREVER_KHR, "EGL_FOREVER_KHR",
1399 EGL_CONDITION_SATISFIED_KHR);
1400 }
1401 else if (!hasRequiredEGLVersion(1, 5))
1402 {
1403 TCU_THROW(NotSupportedError, "Required extensions not supported");
1404 }
1405
1406 return STOP;
1407 }
1408 };
1409
1410 class ClientWaitInvalidDisplayTest : public SyncTest
1411 {
1412 public:
ClientWaitInvalidDisplayTest(EglTestContext & eglTestCtx,EGLenum syncType)1413 ClientWaitInvalidDisplayTest (EglTestContext& eglTestCtx, EGLenum syncType)
1414 : SyncTest (eglTestCtx, syncType, SyncTest::EXTENSION_NONE, syncType != EGL_SYNC_REUSABLE_KHR, "wait_invalid_display", "wait_invalid_display")
1415 {
1416 }
1417
1418 template <typename createSyncFuncType, typename clientWaitSyncFuncType>
test(string funcNames[FUNC_NAME_NUM_NAMES],createSyncFuncType createSyncFunc,clientWaitSyncFuncType clientWaitSyncFunc,EGLint flags,const string & flagsName,EGLTime eglTime,const string & eglTimeName)1419 void test(string funcNames[FUNC_NAME_NUM_NAMES],
1420 createSyncFuncType createSyncFunc,
1421 clientWaitSyncFuncType clientWaitSyncFunc,
1422 EGLint flags, const string &flagsName,
1423 EGLTime eglTime, const string &eglTimeName)
1424 {
1425 // Reset before each test
1426 deinit();
1427 init();
1428
1429 const Library& egl = m_eglTestCtx.getLibrary();
1430 TestLog& log = m_testCtx.getLog();
1431 string createSyncMsgChk = funcNames[FUNC_NAME_CREATE_SYNC] + "()";
1432
1433 m_sync = (egl.*createSyncFunc)(m_eglDisplay, m_syncType, NULL);
1434 log << TestLog::Message << m_sync << " = " << funcNames[FUNC_NAME_CREATE_SYNC] << "(" <<
1435 m_eglDisplay << ", " << getSyncTypeName(m_syncType) << ", NULL)" <<
1436 TestLog::EndMessage;
1437 EGLU_CHECK_MSG(egl, createSyncMsgChk.c_str());
1438
1439 EGLint status = (egl.*clientWaitSyncFunc)(EGL_NO_DISPLAY, m_sync, flags, eglTime);
1440 log << TestLog::Message << status << " = " << funcNames[FUNC_NAME_CLIENT_WAIT_SYNC] <<
1441 "(EGL_NO_DISPLAY, " << m_sync << ", " << flagsName << ", " <<
1442 eglTimeName << ")" << TestLog::EndMessage;
1443
1444 EGLint error = egl.getError();
1445 log << TestLog::Message << error << " = eglGetError()" << TestLog::EndMessage;
1446
1447 if (error != EGL_BAD_DISPLAY)
1448 {
1449 log << TestLog::Message << "Unexpected error '" << eglu::getErrorStr(error) <<
1450 "' expected EGL_BAD_DISPLAY" << TestLog::EndMessage;
1451 m_testCtx.setTestResult(QP_TEST_RESULT_FAIL, "Fail");
1452 return;
1453 }
1454
1455 TCU_CHECK(status == EGL_FALSE);
1456 }
1457
iterate(void)1458 IterateResult iterate (void)
1459 {
1460 m_testCtx.setTestResult(QP_TEST_RESULT_PASS, "Pass");
1461
1462 if (hasRequiredEGLVersion(1, 5))
1463 {
1464 test<createSync, clientWaitSync>(m_funcNames, &Library::createSync,
1465 &Library::clientWaitSync,
1466 EGL_SYNC_FLUSH_COMMANDS_BIT, "EGL_SYNC_FLUSH_COMMANDS_BIT",
1467 EGL_FOREVER, "EGL_FOREVER");
1468 }
1469 if (hasEGLFenceSyncExtension())
1470 {
1471 test<createSyncKHR, clientWaitSyncKHR>(m_funcNamesKHR, &Library::createSyncKHR,
1472 &Library::clientWaitSyncKHR,
1473 EGL_SYNC_FLUSH_COMMANDS_BIT_KHR, "EGL_SYNC_FLUSH_COMMANDS_BIT_KHR",
1474 EGL_FOREVER_KHR, "EGL_FOREVER_KHR");
1475 }
1476 else if (!hasRequiredEGLVersion(1, 5))
1477 {
1478 TCU_THROW(NotSupportedError, "Required extensions not supported");
1479 }
1480
1481 return STOP;
1482 }
1483 };
1484
1485 class ClientWaitInvalidSyncTest : public SyncTest
1486 {
1487 public:
ClientWaitInvalidSyncTest(EglTestContext & eglTestCtx,EGLenum syncType)1488 ClientWaitInvalidSyncTest (EglTestContext& eglTestCtx, EGLenum syncType)
1489 : SyncTest (eglTestCtx, syncType, SyncTest::EXTENSION_NONE, syncType != EGL_SYNC_REUSABLE_KHR, "wait_invalid_sync", "wait_invalid_sync")
1490 {
1491 }
1492
1493 template <typename clientWaitSyncFuncType>
test(string funcNames[FUNC_NAME_NUM_NAMES],clientWaitSyncFuncType clientWaitSyncFunc,EGLSync sync,const string & syncName,EGLTime eglTime,const string & eglTimeName)1494 void test(string funcNames[FUNC_NAME_NUM_NAMES],
1495 clientWaitSyncFuncType clientWaitSyncFunc,
1496 EGLSync sync, const string &syncName,
1497 EGLTime eglTime, const string &eglTimeName)
1498 {
1499 // Reset before each test
1500 deinit();
1501 init();
1502
1503 const Library& egl = m_eglTestCtx.getLibrary();
1504 TestLog& log = m_testCtx.getLog();
1505
1506 EGLint status = (egl.*clientWaitSyncFunc)(m_eglDisplay, sync, 0, eglTime);
1507 log << TestLog::Message << status << " = " << funcNames[FUNC_NAME_CLIENT_WAIT_SYNC] <<
1508 "(" << m_eglDisplay << ", " << syncName << ", 0, " << eglTimeName << ")" <<
1509 TestLog::EndMessage;
1510
1511 EGLint error = egl.getError();
1512 log << TestLog::Message << error << " = eglGetError()" << TestLog::EndMessage;
1513
1514 if (error != EGL_BAD_PARAMETER)
1515 {
1516 log << TestLog::Message << "Unexpected error '" << eglu::getErrorStr(error) <<
1517 "' expected EGL_BAD_PARAMETER" << TestLog::EndMessage;
1518 m_testCtx.setTestResult(QP_TEST_RESULT_FAIL, "Fail");
1519 return;
1520 }
1521
1522 TCU_CHECK(status == EGL_FALSE);
1523 }
1524
iterate(void)1525 IterateResult iterate (void)
1526 {
1527 m_testCtx.setTestResult(QP_TEST_RESULT_PASS, "Pass");
1528
1529 if (hasRequiredEGLVersion(1, 5))
1530 {
1531 test<clientWaitSync>(m_funcNames, &Library::clientWaitSync,
1532 EGL_NO_SYNC, "EGL_NO_SYNC",
1533 EGL_FOREVER, "EGL_FOREVER");
1534 }
1535 if (hasEGLFenceSyncExtension())
1536 {
1537 test<clientWaitSyncKHR>(m_funcNamesKHR, &Library::clientWaitSyncKHR,
1538 EGL_NO_SYNC_KHR, "EGL_NO_SYNC_KHR",
1539 EGL_FOREVER_KHR, "EGL_FOREVER_KHR");
1540 }
1541 else if (!hasRequiredEGLVersion(1, 5))
1542 {
1543 TCU_THROW(NotSupportedError, "Required extensions not supported");
1544 }
1545
1546 return STOP;
1547 }
1548 };
1549
1550 class GetSyncTypeTest : public SyncTest
1551 {
1552 public:
GetSyncTypeTest(EglTestContext & eglTestCtx,EGLenum syncType)1553 GetSyncTypeTest (EglTestContext& eglTestCtx, EGLenum syncType)
1554 : SyncTest (eglTestCtx, syncType, SyncTest::EXTENSION_NONE, syncType != EGL_SYNC_REUSABLE_KHR, "get_type", "get_type")
1555 {
1556 }
1557
1558 template <typename createSyncFuncType, typename getSyncAttribFuncType, typename getSyncAttribValueType>
test(string funcNames[FUNC_NAME_NUM_NAMES],createSyncFuncType createSyncFunc,getSyncAttribFuncType getSyncAttribFunc,EGLint attribute,const string & attributeName)1559 void test(string funcNames[FUNC_NAME_NUM_NAMES],
1560 createSyncFuncType createSyncFunc,
1561 getSyncAttribFuncType getSyncAttribFunc,
1562 EGLint attribute, const string &attributeName)
1563 {
1564 // Reset before each test
1565 deinit();
1566 init();
1567
1568 const Library& egl = m_eglTestCtx.getLibrary();
1569 TestLog& log = m_testCtx.getLog();
1570 string createSyncMsgChk = funcNames[FUNC_NAME_CREATE_SYNC] + "()";
1571
1572 m_sync = (egl.*createSyncFunc)(m_eglDisplay, m_syncType, NULL);
1573 log << TestLog::Message << m_sync << " = " << funcNames[FUNC_NAME_CREATE_SYNC] <<
1574 "(" << m_eglDisplay << ", " << getSyncTypeName(m_syncType) << ", NULL)" <<
1575 TestLog::EndMessage;
1576 EGLU_CHECK_MSG(egl, createSyncMsgChk.c_str());
1577
1578 getSyncAttribValueType type = 0;
1579 EGLU_CHECK_CALL_FPTR(egl, (egl.*getSyncAttribFunc)(m_eglDisplay, m_sync,
1580 attribute, &type));
1581 log << TestLog::Message << funcNames[FUNC_NAME_GET_SYNC_ATTRIB] << "(" << m_eglDisplay <<
1582 ", " << m_sync << ", " << attributeName << ", {" << type << "})" <<
1583 TestLog::EndMessage;
1584
1585 TCU_CHECK(type == ((getSyncAttribValueType)m_syncType));
1586 }
1587
iterate(void)1588 IterateResult iterate (void)
1589 {
1590 m_testCtx.setTestResult(QP_TEST_RESULT_PASS, "Pass");
1591
1592 if (hasRequiredEGLVersion(1, 5))
1593 {
1594 test<createSync, getSyncAttrib, EGLAttrib>(m_funcNames, &Library::createSync,
1595 &Library::getSyncAttrib,
1596 EGL_SYNC_TYPE, "EGL_SYNC_TYPE");
1597 }
1598 if (hasEGLFenceSyncExtension())
1599 {
1600 test<createSyncKHR, getSyncAttribKHR, EGLint>(m_funcNamesKHR, &Library::createSyncKHR,
1601 &Library::getSyncAttribKHR,
1602 EGL_SYNC_TYPE_KHR, "EGL_SYNC_TYPE_KHR");
1603 }
1604 else if (!hasRequiredEGLVersion(1, 5))
1605 {
1606 TCU_THROW(NotSupportedError, "Required extensions not supported");
1607 }
1608
1609 return STOP;
1610 }
1611 };
1612
1613 class GetSyncStatusTest : public SyncTest
1614 {
1615 public:
GetSyncStatusTest(EglTestContext & eglTestCtx,EGLenum syncType)1616 GetSyncStatusTest (EglTestContext& eglTestCtx, EGLenum syncType)
1617 : SyncTest (eglTestCtx, syncType, SyncTest::EXTENSION_NONE, syncType != EGL_SYNC_REUSABLE_KHR, "get_status", "get_status")
1618 {
1619 }
1620
1621 template <typename createSyncFuncType, typename getSyncAttribFuncType, typename getSyncAttribValueType>
test(string funcNames[FUNC_NAME_NUM_NAMES],createSyncFuncType createSyncFunc,getSyncAttribFuncType getSyncAttribFunc,EGLint attribute,const string & attributeName)1622 void test(string funcNames[FUNC_NAME_NUM_NAMES],
1623 createSyncFuncType createSyncFunc,
1624 getSyncAttribFuncType getSyncAttribFunc,
1625 EGLint attribute, const string &attributeName)
1626 {
1627 // Reset before each test
1628 deinit();
1629 init();
1630
1631 const Library& egl = m_eglTestCtx.getLibrary();
1632 TestLog& log = m_testCtx.getLog();
1633 string createSyncMsgChk = funcNames[FUNC_NAME_CREATE_SYNC] + "()";
1634
1635 m_sync = (egl.*createSyncFunc)(m_eglDisplay, m_syncType, NULL);
1636 log << TestLog::Message << m_sync << " = " << funcNames[FUNC_NAME_CREATE_SYNC] <<
1637 "(" << m_eglDisplay << ", " << getSyncTypeName(m_syncType) << ", NULL)" <<
1638 TestLog::EndMessage;
1639 EGLU_CHECK_MSG(egl, createSyncMsgChk.c_str());
1640
1641 getSyncAttribValueType status = 0;
1642 EGLU_CHECK_CALL_FPTR(egl, (egl.*getSyncAttribFunc)(m_eglDisplay, m_sync, attribute, &status));
1643 log << TestLog::Message << funcNames[FUNC_NAME_GET_SYNC_ATTRIB] << "(" <<
1644 m_eglDisplay << ", " << m_sync << ", " << attributeName << ", {" <<
1645 status << "})" << TestLog::EndMessage;
1646
1647 if (m_syncType == EGL_SYNC_FENCE_KHR)
1648 TCU_CHECK(status == EGL_SIGNALED_KHR || status == EGL_UNSIGNALED_KHR);
1649 else if (m_syncType == EGL_SYNC_REUSABLE_KHR)
1650 TCU_CHECK(status == EGL_UNSIGNALED_KHR);
1651 }
1652
iterate(void)1653 IterateResult iterate (void)
1654 {
1655 m_testCtx.setTestResult(QP_TEST_RESULT_PASS, "Pass");
1656
1657 if (hasRequiredEGLVersion(1, 5))
1658 {
1659 test<createSync, getSyncAttrib, EGLAttrib>(m_funcNames, &Library::createSync,
1660 &Library::getSyncAttrib,
1661 EGL_SYNC_STATUS, "EGL_SYNC_STATUS");
1662 }
1663 if (hasEGLFenceSyncExtension())
1664 {
1665 test<createSyncKHR, getSyncAttribKHR, EGLint>(m_funcNamesKHR, &Library::createSyncKHR,
1666 &Library::getSyncAttribKHR,
1667 EGL_SYNC_STATUS_KHR, "EGL_SYNC_STATUS_KHR");
1668 }
1669 else if (!hasRequiredEGLVersion(1, 5))
1670 {
1671 TCU_THROW(NotSupportedError, "Required extensions not supported");
1672 }
1673
1674 return STOP;
1675 }
1676 };
1677
1678 class GetSyncStatusSignaledTest : public SyncTest
1679 {
1680 public:
GetSyncStatusSignaledTest(EglTestContext & eglTestCtx,EGLenum syncType)1681 GetSyncStatusSignaledTest (EglTestContext& eglTestCtx, EGLenum syncType)
1682 : SyncTest (eglTestCtx, syncType, SyncTest::EXTENSION_NONE, syncType != EGL_SYNC_REUSABLE_KHR, "get_status_signaled", "get_status_signaled")
1683 {
1684 }
1685
1686 template <typename createSyncFuncType,
1687 typename clientWaitSyncFuncType,
1688 typename getSyncAttribFuncType,
1689 typename getSyncAttribValueType>
test(string funcNames[FUNC_NAME_NUM_NAMES],createSyncFuncType createSyncFunc,clientWaitSyncFuncType clientWaitSyncFunc,EGLint flags,const string & flagsName,EGLTime eglTime,const string & eglTimeName,EGLint condSatisfied,getSyncAttribFuncType getSyncAttribFunc,EGLint attribute,const string & attributeName,getSyncAttribValueType statusVal)1690 void test(string funcNames[FUNC_NAME_NUM_NAMES],
1691 createSyncFuncType createSyncFunc,
1692 clientWaitSyncFuncType clientWaitSyncFunc,
1693 EGLint flags, const string &flagsName,
1694 EGLTime eglTime, const string &eglTimeName,
1695 EGLint condSatisfied,
1696 getSyncAttribFuncType getSyncAttribFunc,
1697 EGLint attribute, const string &attributeName,
1698 getSyncAttribValueType statusVal)
1699 {
1700 // Reset before each test
1701 deinit();
1702 init();
1703
1704 const Library& egl = m_eglTestCtx.getLibrary();
1705 TestLog& log = m_testCtx.getLog();
1706 string createSyncMsgChk = funcNames[FUNC_NAME_CREATE_SYNC] + "()";
1707
1708 m_sync = (egl.*createSyncFunc)(m_eglDisplay, m_syncType, NULL);
1709 log << TestLog::Message << m_sync << " = " << funcNames[FUNC_NAME_CREATE_SYNC] <<
1710 "(" << m_eglDisplay << ", " << getSyncTypeName(m_syncType) << ", NULL)" <<
1711 TestLog::EndMessage;
1712 EGLU_CHECK_MSG(egl, createSyncMsgChk.c_str());
1713
1714 if (m_syncType == EGL_SYNC_REUSABLE_KHR)
1715 {
1716 EGLBoolean ret = egl.signalSyncKHR(m_eglDisplay, m_sync, EGL_SIGNALED_KHR);
1717 log << TestLog::Message << ret << " = eglSignalSyncKHR(" <<
1718 m_eglDisplay << ", " << m_sync << ", EGL_SIGNALED_KHR)" <<
1719 TestLog::EndMessage;
1720 EGLU_CHECK_MSG(egl, "eglSignalSyncKHR()");
1721 }
1722 else if (m_syncType == EGL_SYNC_FENCE_KHR)
1723 {
1724 GLU_CHECK_GLW_CALL(m_gl, finish());
1725 log << TestLog::Message << "glFinish()" << TestLog::EndMessage;
1726 }
1727 else
1728 DE_ASSERT(DE_FALSE);
1729
1730 {
1731 EGLint status = (egl.*clientWaitSyncFunc)(m_eglDisplay, m_sync, flags, eglTime);
1732 log << TestLog::Message << status << " = " << funcNames[FUNC_NAME_CLIENT_WAIT_SYNC] << "(" <<
1733 m_eglDisplay << ", " << m_sync << ", " << flagsName << ", " <<
1734 eglTimeName << ")" << TestLog::EndMessage;
1735 TCU_CHECK(status == condSatisfied);
1736 }
1737
1738 getSyncAttribValueType status = 0;
1739 EGLU_CHECK_CALL_FPTR(egl, (egl.*getSyncAttribFunc)(m_eglDisplay, m_sync, attribute, &status));
1740 log << TestLog::Message << funcNames[FUNC_NAME_GET_SYNC_ATTRIB] << "(" <<
1741 m_eglDisplay << ", " << m_sync << ", " << attributeName << ", {" <<
1742 status << "})" << TestLog::EndMessage;
1743
1744 TCU_CHECK(status == statusVal);
1745 }
1746
iterate(void)1747 IterateResult iterate (void)
1748 {
1749 m_testCtx.setTestResult(QP_TEST_RESULT_PASS, "Pass");
1750
1751 if (hasRequiredEGLVersion(1, 5))
1752 {
1753 test<createSync, clientWaitSync, getSyncAttrib, EGLAttrib>(m_funcNames,
1754 &Library::createSync,
1755 &Library::clientWaitSync,
1756 EGL_SYNC_FLUSH_COMMANDS_BIT, "EGL_SYNC_FLUSH_COMMANDS_BIT",
1757 EGL_FOREVER, "EGL_FOREVER",
1758 EGL_CONDITION_SATISFIED,
1759 &Library::getSyncAttrib,
1760 EGL_SYNC_STATUS, "EGL_SYNC_STATUS",
1761 EGL_SIGNALED);
1762 }
1763 if (hasEGLFenceSyncExtension())
1764 {
1765 test<createSyncKHR, clientWaitSyncKHR, getSyncAttribKHR, EGLint>(m_funcNamesKHR,
1766 &Library::createSyncKHR,
1767 &Library::clientWaitSyncKHR,
1768 EGL_SYNC_FLUSH_COMMANDS_BIT_KHR, "EGL_SYNC_FLUSH_COMMANDS_BIT_KHR",
1769 EGL_FOREVER_KHR, "EGL_FOREVER_KHR",
1770 EGL_CONDITION_SATISFIED_KHR,
1771 &Library::getSyncAttribKHR,
1772 EGL_SYNC_STATUS_KHR, "EGL_SYNC_STATUS_KHR",
1773 EGL_SIGNALED_KHR);
1774 }
1775 else if (!hasRequiredEGLVersion(1, 5))
1776 {
1777 TCU_THROW(NotSupportedError, "Required extensions not supported");
1778 }
1779
1780 return STOP;
1781 }
1782 };
1783
1784 class GetSyncConditionTest : public SyncTest
1785 {
1786 public:
GetSyncConditionTest(EglTestContext & eglTestCtx,EGLenum syncType)1787 GetSyncConditionTest (EglTestContext& eglTestCtx, EGLenum syncType)
1788 : SyncTest (eglTestCtx, syncType, SyncTest::EXTENSION_NONE, syncType != EGL_SYNC_REUSABLE_KHR, "get_condition", "get_condition")
1789 {
1790 }
1791
1792 template <typename createSyncFuncType,
1793 typename getSyncAttribFuncType,
1794 typename getSyncAttribValueType>
test(string funcNames[FUNC_NAME_NUM_NAMES],createSyncFuncType createSyncFunc,getSyncAttribFuncType getSyncAttribFunc,EGLint attribute,const string & attributeName,getSyncAttribValueType statusVal)1795 void test(string funcNames[FUNC_NAME_NUM_NAMES],
1796 createSyncFuncType createSyncFunc,
1797 getSyncAttribFuncType getSyncAttribFunc,
1798 EGLint attribute, const string &attributeName,
1799 getSyncAttribValueType statusVal)
1800 {
1801 // Reset before each test
1802 deinit();
1803 init();
1804
1805 const Library& egl = m_eglTestCtx.getLibrary();
1806 TestLog& log = m_testCtx.getLog();
1807 string createSyncMsgChk = funcNames[FUNC_NAME_CREATE_SYNC] + "()";
1808
1809 m_sync = (egl.*createSyncFunc)(m_eglDisplay, m_syncType, NULL);
1810 log << TestLog::Message << m_sync << " = " << funcNames[FUNC_NAME_CREATE_SYNC] <<
1811 "(" << m_eglDisplay << ", " << getSyncTypeName(m_syncType) << ", NULL)" <<
1812 TestLog::EndMessage;
1813 EGLU_CHECK_MSG(egl, createSyncMsgChk.c_str());
1814
1815 getSyncAttribValueType condition = 0;
1816 EGLU_CHECK_CALL_FPTR(egl, (egl.*getSyncAttribFunc)(m_eglDisplay, m_sync,
1817 attribute, &condition));
1818 log << TestLog::Message << funcNames[FUNC_NAME_GET_SYNC_ATTRIB] << "(" <<
1819 m_eglDisplay << ", " << m_sync << ", " << attributeName << ", {" <<
1820 condition << "})" << TestLog::EndMessage;
1821
1822 TCU_CHECK(condition == statusVal);
1823 }
1824
iterate(void)1825 IterateResult iterate (void)
1826 {
1827 m_testCtx.setTestResult(QP_TEST_RESULT_PASS, "Pass");
1828
1829 if (hasRequiredEGLVersion(1, 5))
1830 {
1831 test<createSync, getSyncAttrib, EGLAttrib>(m_funcNames, &Library::createSync,
1832 &Library::getSyncAttrib,
1833 EGL_SYNC_CONDITION, "EGL_SYNC_CONDITION",
1834 EGL_SYNC_PRIOR_COMMANDS_COMPLETE);
1835 }
1836 if (hasEGLFenceSyncExtension())
1837 {
1838 test<createSyncKHR, getSyncAttribKHR, EGLint>(m_funcNamesKHR, &Library::createSyncKHR,
1839 &Library::getSyncAttribKHR,
1840 EGL_SYNC_CONDITION_KHR, "EGL_SYNC_CONDITION_KHR",
1841 EGL_SYNC_PRIOR_COMMANDS_COMPLETE_KHR);
1842 }
1843 else if (!hasRequiredEGLVersion(1, 5))
1844 {
1845 TCU_THROW(NotSupportedError, "Required extensions not supported");
1846 }
1847
1848 return STOP;
1849 }
1850 };
1851
1852 class GetSyncInvalidDisplayTest : public SyncTest
1853 {
1854 public:
GetSyncInvalidDisplayTest(EglTestContext & eglTestCtx,EGLenum syncType)1855 GetSyncInvalidDisplayTest (EglTestContext& eglTestCtx, EGLenum syncType)
1856 : SyncTest (eglTestCtx, syncType, SyncTest::EXTENSION_NONE, syncType != EGL_SYNC_REUSABLE_KHR,"get_invalid_display", "get_invalid_display")
1857 {
1858 }
1859
1860 template <typename createSyncFuncType,
1861 typename getSyncAttribFuncType,
1862 typename getSyncAttribValueType>
test(string funcNames[FUNC_NAME_NUM_NAMES],createSyncFuncType createSyncFunc,getSyncAttribFuncType getSyncAttribFunc,EGLint attribute,const string & attributeName)1863 void test(string funcNames[FUNC_NAME_NUM_NAMES],
1864 createSyncFuncType createSyncFunc,
1865 getSyncAttribFuncType getSyncAttribFunc,
1866 EGLint attribute, const string &attributeName)
1867 {
1868 // Reset before each test
1869 deinit();
1870 init();
1871
1872 const Library& egl = m_eglTestCtx.getLibrary();
1873 TestLog& log = m_testCtx.getLog();
1874 string createSyncMsgChk = funcNames[FUNC_NAME_CREATE_SYNC] + "()";
1875
1876 m_sync = (egl.*createSyncFunc)(m_eglDisplay, m_syncType, NULL);
1877 log << TestLog::Message << m_sync << " = " << funcNames[FUNC_NAME_CREATE_SYNC] <<
1878 "(" << m_eglDisplay << ", " << getSyncTypeName(m_syncType) << ", NULL)" <<
1879 TestLog::EndMessage;
1880 EGLU_CHECK_MSG(egl, createSyncMsgChk.c_str());
1881
1882 getSyncAttribValueType condition = 0xF0F0F;
1883 EGLBoolean result = (egl.*getSyncAttribFunc)(EGL_NO_DISPLAY, m_sync, attribute, &condition);
1884 log << TestLog::Message << result << " = " << funcNames[FUNC_NAME_GET_SYNC_ATTRIB] <<
1885 "(EGL_NO_DISPLAY, " << m_sync << ", " << attributeName << ", {" <<
1886 condition << "})" << TestLog::EndMessage;
1887
1888 EGLint error = egl.getError();
1889 log << TestLog::Message << error << " = eglGetError()" << TestLog::EndMessage;
1890
1891 if (error != EGL_BAD_DISPLAY)
1892 {
1893 log << TestLog::Message << "Unexpected error '" << eglu::getErrorStr(error) <<
1894 "' expected EGL_BAD_DISPLAY" << TestLog::EndMessage;
1895 m_testCtx.setTestResult(QP_TEST_RESULT_FAIL, "Fail");
1896 return;
1897 }
1898
1899 TCU_CHECK(result == EGL_FALSE);
1900 TCU_CHECK(condition == 0xF0F0F);
1901 }
1902
iterate(void)1903 IterateResult iterate (void)
1904 {
1905 m_testCtx.setTestResult(QP_TEST_RESULT_PASS, "Pass");
1906
1907 if (hasRequiredEGLVersion(1, 5))
1908 {
1909 test<createSync, getSyncAttrib, EGLAttrib>(m_funcNames, &Library::createSync,
1910 &Library::getSyncAttrib,
1911 EGL_SYNC_CONDITION, "EGL_SYNC_CONDITION");
1912 }
1913 if (hasEGLFenceSyncExtension())
1914 {
1915 test<createSyncKHR, getSyncAttribKHR, EGLint>(m_funcNamesKHR, &Library::createSyncKHR,
1916 &Library::getSyncAttribKHR,
1917 EGL_SYNC_CONDITION_KHR, "EGL_SYNC_CONDITION_KHR");
1918 }
1919 else if (!hasRequiredEGLVersion(1, 5))
1920 {
1921 TCU_THROW(NotSupportedError, "Required extensions not supported");
1922 }
1923
1924 return STOP;
1925 }
1926 };
1927
1928 class GetSyncInvalidSyncTest : public SyncTest
1929 {
1930 public:
GetSyncInvalidSyncTest(EglTestContext & eglTestCtx,EGLenum syncType)1931 GetSyncInvalidSyncTest (EglTestContext& eglTestCtx, EGLenum syncType)\
1932 : SyncTest (eglTestCtx, syncType, SyncTest::EXTENSION_NONE, syncType != EGL_SYNC_REUSABLE_KHR, "get_invalid_sync", "get_invalid_sync")
1933 {
1934 }
1935
1936 template <typename getSyncAttribFuncType,
1937 typename getSyncSyncValueType,
1938 typename getSyncAttribValueType>
test(string funcNames[FUNC_NAME_NUM_NAMES],getSyncAttribFuncType getSyncAttribFunc,getSyncSyncValueType syncValue,const string & syncName,EGLint attribute,const string & attributeName)1939 void test(string funcNames[FUNC_NAME_NUM_NAMES],
1940 getSyncAttribFuncType getSyncAttribFunc,
1941 getSyncSyncValueType syncValue, const string &syncName,
1942 EGLint attribute, const string &attributeName)
1943 {
1944 // Reset before each test
1945 deinit();
1946 init();
1947
1948 const Library& egl = m_eglTestCtx.getLibrary();
1949 TestLog& log = m_testCtx.getLog();
1950
1951 getSyncAttribValueType condition = 0xF0F0F;
1952 EGLBoolean result = (egl.*getSyncAttribFunc)(m_eglDisplay, syncValue,
1953 attribute, &condition);
1954 log << TestLog::Message << result << " = " << funcNames[FUNC_NAME_GET_SYNC_ATTRIB] <<
1955 "(" << m_eglDisplay << ", " << syncName << ", " << attributeName << ", {" <<
1956 condition << "})" << TestLog::EndMessage;
1957
1958 EGLint error = egl.getError();
1959 log << TestLog::Message << error << " = eglGetError()" << TestLog::EndMessage;
1960
1961 if (error != EGL_BAD_PARAMETER)
1962 {
1963 log << TestLog::Message << "Unexpected error '" << eglu::getErrorStr(error) <<
1964 "' expected EGL_BAD_PARAMETER" << TestLog::EndMessage;
1965 m_testCtx.setTestResult(QP_TEST_RESULT_FAIL, "Fail");
1966 return;
1967 }
1968
1969 TCU_CHECK(result == EGL_FALSE);
1970 TCU_CHECK(condition == 0xF0F0F);
1971 }
1972
iterate(void)1973 IterateResult iterate (void)
1974 {
1975 m_testCtx.setTestResult(QP_TEST_RESULT_PASS, "Pass");
1976
1977 if (hasRequiredEGLVersion(1, 5))
1978 {
1979 test<getSyncAttrib, EGLSync, EGLAttrib>(m_funcNames, &Library::getSyncAttrib,
1980 EGL_NO_SYNC, "EGL_NO_SYNC",
1981 EGL_SYNC_CONDITION, "EGL_SYNC_CONDITION");
1982 }
1983 if (hasEGLFenceSyncExtension())
1984 {
1985 test<getSyncAttribKHR, EGLSyncKHR, EGLint>(m_funcNamesKHR, &Library::getSyncAttribKHR,
1986 EGL_NO_SYNC_KHR, "EGL_NO_SYNC_KHR",
1987 EGL_SYNC_CONDITION_KHR, "EGL_SYNC_CONDITION_KHR");
1988 }
1989 else if (!hasRequiredEGLVersion(1, 5))
1990 {
1991 TCU_THROW(NotSupportedError, "Required extensions not supported");
1992 }
1993
1994 return STOP;
1995 }
1996 };
1997
1998 class GetSyncInvalidAttributeTest : public SyncTest
1999 {
2000 public:
GetSyncInvalidAttributeTest(EglTestContext & eglTestCtx,EGLenum syncType)2001 GetSyncInvalidAttributeTest (EglTestContext& eglTestCtx, EGLenum syncType)
2002 : SyncTest (eglTestCtx, syncType, SyncTest::EXTENSION_NONE, syncType != EGL_SYNC_REUSABLE_KHR,"get_invalid_attribute", "get_invalid_attribute")
2003 {
2004 }
2005
2006 template <typename createSyncFuncType,
2007 typename getSyncAttribFuncType,
2008 typename getSyncAttribValueType>
test(string funcNames[FUNC_NAME_NUM_NAMES],createSyncFuncType createSyncFunc,getSyncAttribFuncType getSyncAttribFunc)2009 void test(string funcNames[FUNC_NAME_NUM_NAMES],
2010 createSyncFuncType createSyncFunc,
2011 getSyncAttribFuncType getSyncAttribFunc)
2012 {
2013 // Reset before each test
2014 deinit();
2015 init();
2016
2017 const Library& egl = m_eglTestCtx.getLibrary();
2018 TestLog& log = m_testCtx.getLog();
2019 string createSyncMsgChk = funcNames[FUNC_NAME_CREATE_SYNC] + "()";
2020
2021 m_sync = (egl.*createSyncFunc)(m_eglDisplay, m_syncType, NULL);
2022 log << TestLog::Message << m_sync << " = " << funcNames[FUNC_NAME_CREATE_SYNC] <<
2023 "(" << m_eglDisplay << ", " << getSyncTypeName(m_syncType) << ", NULL)" <<
2024 TestLog::EndMessage;
2025 EGLU_CHECK_MSG(egl, createSyncMsgChk.c_str());
2026
2027 getSyncAttribValueType condition = 0xF0F0F;
2028 EGLBoolean result = (egl.*getSyncAttribFunc)(m_eglDisplay, m_sync, EGL_NONE, &condition);
2029 log << TestLog::Message << result << " = " << funcNames[FUNC_NAME_GET_SYNC_ATTRIB] <<
2030 "(" << m_eglDisplay << ", " << m_sync << ", EGL_NONE, {" << condition << "})" <<
2031 TestLog::EndMessage;
2032
2033 EGLint error = egl.getError();
2034 log << TestLog::Message << error << " = eglGetError()" << TestLog::EndMessage;
2035
2036 if (error != EGL_BAD_ATTRIBUTE)
2037 {
2038 log << TestLog::Message << "Unexpected error '" << eglu::getErrorStr(error) <<
2039 "' expected EGL_BAD_ATTRIBUTE" << TestLog::EndMessage;
2040 m_testCtx.setTestResult(QP_TEST_RESULT_FAIL, "Fail");
2041 return;
2042 }
2043
2044 TCU_CHECK(result == EGL_FALSE);
2045 TCU_CHECK(condition == 0xF0F0F);
2046 }
2047
iterate(void)2048 IterateResult iterate (void)
2049 {
2050 m_testCtx.setTestResult(QP_TEST_RESULT_PASS, "Pass");
2051
2052 if (hasRequiredEGLVersion(1, 5))
2053 {
2054 test<createSync, getSyncAttrib, EGLAttrib>(m_funcNames,
2055 &Library::createSync,
2056 &Library::getSyncAttrib);
2057 }
2058 if (hasEGLFenceSyncExtension())
2059 {
2060 test<createSyncKHR, getSyncAttribKHR, EGLint>(m_funcNamesKHR,
2061 &Library::createSyncKHR,
2062 &Library::getSyncAttribKHR);
2063 }
2064 else if (!hasRequiredEGLVersion(1, 5))
2065 {
2066 TCU_THROW(NotSupportedError, "Required extensions not supported");
2067 }
2068
2069 return STOP;
2070 }
2071 };
2072
2073 class GetSyncInvalidValueTest : public SyncTest
2074 {
2075 public:
GetSyncInvalidValueTest(EglTestContext & eglTestCtx,EGLenum syncType)2076 GetSyncInvalidValueTest (EglTestContext& eglTestCtx, EGLenum syncType)
2077 : SyncTest (eglTestCtx, syncType, SyncTest::EXTENSION_NONE, syncType != EGL_SYNC_REUSABLE_KHR,"get_invalid_value", "get_invalid_value")
2078 {
2079 }
2080
2081 template <typename createSyncFuncType,
2082 typename getSyncAttribFuncType, typename valueType>
test(string funcNames[FUNC_NAME_NUM_NAMES],createSyncFuncType createSyncFunc,getSyncAttribFuncType getSyncAttribFunc,EGLint attribute,const string & attributeName,valueType value)2083 void test(string funcNames[FUNC_NAME_NUM_NAMES],
2084 createSyncFuncType createSyncFunc,
2085 getSyncAttribFuncType getSyncAttribFunc,
2086 EGLint attribute, const string &attributeName,
2087 valueType value)
2088 {
2089 // Reset before each test
2090 deinit();
2091 init();
2092
2093 const Library& egl = m_eglTestCtx.getLibrary();
2094 TestLog& log = m_testCtx.getLog();
2095 string createSyncMsgChk = funcNames[FUNC_NAME_CREATE_SYNC] + "()";
2096
2097 m_sync = (egl.*createSyncFunc)(m_eglDisplay, m_syncType, NULL);
2098 log << TestLog::Message << m_sync << " = " << funcNames[FUNC_NAME_CREATE_SYNC] <<
2099 "(" << m_eglDisplay << ", " << getSyncTypeName(m_syncType) << ", NULL)" <<
2100 TestLog::EndMessage;
2101 EGLU_CHECK_MSG(egl, createSyncMsgChk.c_str());
2102
2103 EGLBoolean result = (egl.*getSyncAttribFunc)(m_eglDisplay, NULL, attribute, &value);
2104 log << TestLog::Message << result << " = " << funcNames[FUNC_NAME_GET_SYNC_ATTRIB] <<
2105 "(" << m_eglDisplay << ", " << 0x0 << ", " << attributeName << ", " << &value << ")" <<
2106 TestLog::EndMessage;
2107
2108 EGLint error = egl.getError();
2109 log << TestLog::Message << error << " = eglGetError()" << TestLog::EndMessage;
2110
2111 if (error != EGL_BAD_PARAMETER)
2112 {
2113 log << TestLog::Message << "Unexpected error '" << eglu::getErrorStr(error) <<
2114 "' expected EGL_BAD_PARAMETER" << TestLog::EndMessage;
2115 m_testCtx.setTestResult(QP_TEST_RESULT_FAIL, "Fail");
2116 return;
2117 }
2118
2119 TCU_CHECK(result == EGL_FALSE);
2120 }
2121
iterate(void)2122 IterateResult iterate (void)
2123 {
2124 m_testCtx.setTestResult(QP_TEST_RESULT_PASS, "Pass");
2125
2126 if (hasRequiredEGLVersion(1, 5))
2127 {
2128 EGLAttrib value = 0;
2129 test<createSync, getSyncAttrib>(m_funcNames, &Library::createSync,
2130 &Library::getSyncAttrib,
2131 EGL_SYNC_TYPE, "EGL_SYNC_TYPE", value);
2132 }
2133 if (hasEGLFenceSyncExtension())
2134 {
2135 EGLint value = 0;
2136 test<createSyncKHR, getSyncAttribKHR>(m_funcNamesKHR, &Library::createSyncKHR,
2137 &Library::getSyncAttribKHR,
2138 EGL_SYNC_TYPE_KHR, "EGL_SYNC_TYPE_KHR", value);
2139 }
2140 else if (!hasRequiredEGLVersion(1, 5))
2141 {
2142 TCU_THROW(NotSupportedError, "Required extensions not supported");
2143 }
2144
2145 return STOP;
2146 }
2147 };
2148
2149 class DestroySyncTest : public SyncTest
2150 {
2151 public:
DestroySyncTest(EglTestContext & eglTestCtx,EGLenum syncType)2152 DestroySyncTest (EglTestContext& eglTestCtx, EGLenum syncType)
2153 : SyncTest (eglTestCtx, syncType, SyncTest::EXTENSION_NONE, syncType != EGL_SYNC_REUSABLE_KHR,"destroy", "destroy")
2154 {
2155 }
2156
2157 template <typename createSyncFuncType,
2158 typename destroySyncFuncType,
2159 typename getSyncSyncValueType>
test(string funcNames[FUNC_NAME_NUM_NAMES],createSyncFuncType createSyncFunc,destroySyncFuncType destroySyncFunc,getSyncSyncValueType syncValue)2160 void test(string funcNames[FUNC_NAME_NUM_NAMES],
2161 createSyncFuncType createSyncFunc,
2162 destroySyncFuncType destroySyncFunc,
2163 getSyncSyncValueType syncValue)
2164 {
2165 // Reset before each test
2166 deinit();
2167 init();
2168
2169 const Library& egl = m_eglTestCtx.getLibrary();
2170 TestLog& log = m_testCtx.getLog();
2171 string createSyncMsgChk = funcNames[FUNC_NAME_CREATE_SYNC] + "()";
2172
2173 m_sync = (egl.*createSyncFunc)(m_eglDisplay, m_syncType, NULL);
2174 log << TestLog::Message << funcNames[FUNC_NAME_CREATE_SYNC] << "(" <<
2175 m_eglDisplay << ", " << getSyncTypeName(m_syncType) << ", NULL)" <<
2176 TestLog::EndMessage;
2177 EGLU_CHECK_MSG(egl, createSyncMsgChk.c_str());
2178
2179 log << TestLog::Message << funcNames[FUNC_NAME_DESTROY_SYNC] << "(" <<
2180 m_eglDisplay << ", " << m_sync << ")" << TestLog::EndMessage;
2181 EGLU_CHECK_CALL_FPTR(egl, (egl.*destroySyncFunc)(m_eglDisplay, m_sync));
2182 m_sync = syncValue;
2183 }
2184
iterate(void)2185 IterateResult iterate (void)
2186 {
2187 m_testCtx.setTestResult(QP_TEST_RESULT_PASS, "Pass");
2188
2189 if (hasRequiredEGLVersion(1, 5))
2190 {
2191 test<createSync, destroySync, EGLSync>(m_funcNames,
2192 &Library::createSync,
2193 &Library::destroySync,
2194 EGL_NO_SYNC);
2195 }
2196 if (hasEGLFenceSyncExtension())
2197 {
2198 test<createSyncKHR, destroySyncKHR, EGLSyncKHR>(m_funcNamesKHR,
2199 &Library::createSyncKHR,
2200 &Library::destroySyncKHR,
2201 EGL_NO_SYNC_KHR);
2202 }
2203 else if (!hasRequiredEGLVersion(1, 5))
2204 {
2205 TCU_THROW(NotSupportedError, "Required extensions not supported");
2206 }
2207
2208 return STOP;
2209 }
2210 };
2211
2212 class DestroySyncInvalidDislayTest : public SyncTest
2213 {
2214 public:
DestroySyncInvalidDislayTest(EglTestContext & eglTestCtx,EGLenum syncType)2215 DestroySyncInvalidDislayTest (EglTestContext& eglTestCtx, EGLenum syncType)
2216 : SyncTest(eglTestCtx, syncType, SyncTest::EXTENSION_NONE, syncType != EGL_SYNC_REUSABLE_KHR,"destroy_invalid_display", "destroy_invalid_display")
2217 {
2218 }
2219
2220 template <typename createSyncFuncType, typename destroySyncFuncType>
test(string funcNames[FUNC_NAME_NUM_NAMES],createSyncFuncType createSyncFunc,destroySyncFuncType destroySyncFunc)2221 void test(string funcNames[FUNC_NAME_NUM_NAMES],
2222 createSyncFuncType createSyncFunc,
2223 destroySyncFuncType destroySyncFunc)
2224 {
2225 // Reset before each test
2226 deinit();
2227 init();
2228
2229 const Library& egl = m_eglTestCtx.getLibrary();
2230 TestLog& log = m_testCtx.getLog();
2231 string createSyncMsgChk = funcNames[FUNC_NAME_CREATE_SYNC] + "()";
2232
2233 m_sync = (egl.*createSyncFunc)(m_eglDisplay, m_syncType, NULL);
2234 log << TestLog::Message << funcNames[FUNC_NAME_CREATE_SYNC] << "(" <<
2235 m_eglDisplay << ", " << getSyncTypeName(m_syncType) << ", NULL)" <<
2236 TestLog::EndMessage;
2237 EGLU_CHECK_MSG(egl, createSyncMsgChk.c_str());
2238
2239 EGLBoolean result = (egl.*destroySyncFunc)(EGL_NO_DISPLAY, m_sync);
2240 log << TestLog::Message << result << " = " << funcNames[FUNC_NAME_DESTROY_SYNC] <<
2241 "(EGL_NO_DISPLAY, " << m_sync << ")" << TestLog::EndMessage;
2242
2243 EGLint error = egl.getError();
2244 log << TestLog::Message << error << " = eglGetError()" << TestLog::EndMessage;
2245
2246 if (error != EGL_BAD_DISPLAY)
2247 {
2248 log << TestLog::Message << "Unexpected error '" << eglu::getErrorStr(error) <<
2249 "' expected EGL_BAD_DISPLAY" << TestLog::EndMessage;
2250 m_testCtx.setTestResult(QP_TEST_RESULT_FAIL, "Fail");
2251 return;
2252 }
2253
2254 TCU_CHECK(result == EGL_FALSE);
2255 }
2256
iterate(void)2257 IterateResult iterate (void)
2258 {
2259 m_testCtx.setTestResult(QP_TEST_RESULT_PASS, "Pass");
2260
2261 if (hasRequiredEGLVersion(1, 5))
2262 {
2263 test<createSync, destroySync>(m_funcNames,
2264 &Library::createSync,
2265 &Library::destroySync);
2266 }
2267 if (hasEGLFenceSyncExtension())
2268 {
2269 test<createSyncKHR, destroySyncKHR>(m_funcNamesKHR,
2270 &Library::createSyncKHR,
2271 &Library::destroySyncKHR);
2272 }
2273 else if (!hasRequiredEGLVersion(1, 5))
2274 {
2275 TCU_THROW(NotSupportedError, "Required extensions not supported");
2276 }
2277
2278 return STOP;
2279 }
2280 };
2281
2282 class DestroySyncInvalidSyncTest : public SyncTest
2283 {
2284 public:
DestroySyncInvalidSyncTest(EglTestContext & eglTestCtx,EGLenum syncType)2285 DestroySyncInvalidSyncTest (EglTestContext& eglTestCtx, EGLenum syncType)
2286 : SyncTest (eglTestCtx, syncType, SyncTest::EXTENSION_NONE, syncType != EGL_SYNC_REUSABLE_KHR,"destroy_invalid_sync", "destroy_invalid_sync")
2287 {
2288 }
2289
2290 template <typename destroySyncFuncType, typename getSyncSyncValueType>
test(string funcNames[FUNC_NAME_NUM_NAMES],destroySyncFuncType destroySyncFunc,getSyncSyncValueType syncValue)2291 void test(string funcNames[FUNC_NAME_NUM_NAMES],
2292 destroySyncFuncType destroySyncFunc,
2293 getSyncSyncValueType syncValue)
2294 {
2295 // Reset before each test
2296 deinit();
2297 init();
2298
2299 const Library& egl = m_eglTestCtx.getLibrary();
2300 TestLog& log = m_testCtx.getLog();
2301
2302 EGLBoolean result = (egl.*destroySyncFunc)(m_eglDisplay, syncValue);
2303 log << TestLog::Message << result << " = " << funcNames[FUNC_NAME_DESTROY_SYNC] <<
2304 "(" << m_eglDisplay << ", " << syncValue << ")" << TestLog::EndMessage;
2305
2306 EGLint error = egl.getError();
2307 log << TestLog::Message << error << " = eglGetError()" << TestLog::EndMessage;
2308
2309 if (error != EGL_BAD_PARAMETER)
2310 {
2311 log << TestLog::Message << "Unexpected error '" << eglu::getErrorStr(error) <<
2312 "' expected EGL_BAD_PARAMETER" << TestLog::EndMessage;
2313 m_testCtx.setTestResult(QP_TEST_RESULT_FAIL, "Fail");
2314 return;
2315 }
2316
2317 TCU_CHECK(result == EGL_FALSE);
2318 }
2319
iterate(void)2320 IterateResult iterate (void)
2321 {
2322 m_testCtx.setTestResult(QP_TEST_RESULT_PASS, "Pass");
2323
2324 if (hasRequiredEGLVersion(1, 5))
2325 {
2326 test<destroySync, EGLSync>(m_funcNames,
2327 &Library::destroySync,
2328 EGL_NO_SYNC);
2329 }
2330 if (hasEGLFenceSyncExtension())
2331 {
2332 test<destroySyncKHR, EGLSyncKHR>(m_funcNamesKHR,
2333 &Library::destroySyncKHR,
2334 EGL_NO_SYNC_KHR);
2335 }
2336 else if (!hasRequiredEGLVersion(1, 5))
2337 {
2338 TCU_THROW(NotSupportedError, "Required extensions not supported");
2339 }
2340
2341 return STOP;
2342 }
2343 };
2344
2345 class WaitSyncTest : public SyncTest
2346 {
2347 public:
WaitSyncTest(EglTestContext & eglTestCtx,EGLenum syncType)2348 WaitSyncTest (EglTestContext& eglTestCtx, EGLenum syncType)
2349 : SyncTest (eglTestCtx, syncType, SyncTest::EXTENSION_WAIT_SYNC, true, "wait_server", "wait_server")
2350 {
2351 }
2352
2353 template <typename createSyncFuncType,
2354 typename waitSyncFuncType,
2355 typename waitSyncStatusType>
test(string funcNames[FUNC_NAME_NUM_NAMES],createSyncFuncType createSyncFunc,waitSyncFuncType waitSyncFunc)2356 void test(string funcNames[FUNC_NAME_NUM_NAMES],
2357 createSyncFuncType createSyncFunc,
2358 waitSyncFuncType waitSyncFunc)
2359 {
2360 // Reset before each test
2361 deinit();
2362 init();
2363
2364 const Library& egl = m_eglTestCtx.getLibrary();
2365 TestLog& log = m_testCtx.getLog();
2366 string msgChk = funcNames[FUNC_NAME_CREATE_SYNC] + "()";
2367
2368 m_sync = (egl.*createSyncFunc)(m_eglDisplay, m_syncType, NULL);
2369 log << TestLog::Message << m_sync << " = " << funcNames[FUNC_NAME_CREATE_SYNC] <<
2370 "(" << m_eglDisplay << ", " << getSyncTypeName(m_syncType) << ", NULL)" <<
2371 TestLog::EndMessage;
2372 EGLU_CHECK_MSG(egl, msgChk.c_str());
2373
2374 waitSyncStatusType status = (egl.*waitSyncFunc)(m_eglDisplay, m_sync, 0);
2375 log << TestLog::Message << status << " = " << funcNames[FUNC_NAME_WAIT_SYNC] << "(" <<
2376 m_eglDisplay << ", " << m_sync << ", 0, 0)" << TestLog::EndMessage;
2377
2378 TCU_CHECK(status == EGL_TRUE);
2379
2380 GLU_CHECK_GLW_CALL(m_gl, finish());
2381 }
2382
2383
iterate(void)2384 IterateResult iterate (void)
2385 {
2386 m_testCtx.setTestResult(QP_TEST_RESULT_PASS, "Pass");
2387
2388 if (hasRequiredEGLVersion(1, 5))
2389 {
2390 test<createSync, waitSync, EGLBoolean>(m_funcNames,
2391 &Library::createSync,
2392 &Library::waitSync);
2393 }
2394 if (hasEGLWaitSyncExtension())
2395 {
2396 test<createSyncKHR, waitSyncKHR, EGLint>(m_funcNamesKHR,
2397 &Library::createSyncKHR,
2398 &Library::waitSyncKHR);
2399 }
2400 else if (!hasRequiredEGLVersion(1, 5))
2401 {
2402 TCU_THROW(NotSupportedError, "Required extensions not supported");
2403 }
2404
2405 return STOP;
2406 }
2407
2408 };
2409
2410 class WaitSyncInvalidDisplayTest : public SyncTest
2411 {
2412 public:
WaitSyncInvalidDisplayTest(EglTestContext & eglTestCtx,EGLenum syncType)2413 WaitSyncInvalidDisplayTest (EglTestContext& eglTestCtx, EGLenum syncType)
2414 : SyncTest (eglTestCtx, syncType, SyncTest::EXTENSION_WAIT_SYNC, true, "wait_server_invalid_display", "wait_server_invalid_display")
2415 {
2416 }
2417
2418 template <typename createSyncFuncType,
2419 typename waitSyncFuncType,
2420 typename waitSyncStatusType>
test(string funcNames[FUNC_NAME_NUM_NAMES],createSyncFuncType createSyncFunc,waitSyncFuncType waitSyncFunc)2421 void test(string funcNames[FUNC_NAME_NUM_NAMES],
2422 createSyncFuncType createSyncFunc,
2423 waitSyncFuncType waitSyncFunc)
2424 {
2425 // Reset before each test
2426 deinit();
2427 init();
2428
2429 const Library& egl = m_eglTestCtx.getLibrary();
2430 TestLog& log = m_testCtx.getLog();
2431 string msgChk = funcNames[FUNC_NAME_CREATE_SYNC] + "()";
2432
2433 m_sync = (egl.*createSyncFunc)(m_eglDisplay, m_syncType, NULL);
2434 log << TestLog::Message << m_sync << " = " << funcNames[FUNC_NAME_CREATE_SYNC] <<
2435 "(" << m_eglDisplay << ", " << getSyncTypeName(m_syncType) << ", NULL)" <<
2436 TestLog::EndMessage;
2437 EGLU_CHECK_MSG(egl, msgChk.c_str());
2438
2439 waitSyncStatusType status = (egl.*waitSyncFunc)(EGL_NO_DISPLAY, m_sync, 0);
2440 log << TestLog::Message << status << " = " << funcNames[FUNC_NAME_WAIT_SYNC] <<
2441 "(EGL_NO_DISPLAY, " << m_sync << ", 0)" << TestLog::EndMessage;
2442
2443 EGLint error = egl.getError();
2444 log << TestLog::Message << error << " = eglGetError()" << TestLog::EndMessage;
2445
2446 if (error != EGL_BAD_DISPLAY)
2447 {
2448 log << TestLog::Message << "Unexpected error '" << eglu::getErrorStr(error) <<
2449 "' expected EGL_BAD_DISPLAY" << TestLog::EndMessage;
2450 m_testCtx.setTestResult(QP_TEST_RESULT_FAIL, "Fail");
2451 return;
2452 }
2453
2454 TCU_CHECK(status == EGL_FALSE);
2455 }
2456
iterate(void)2457 IterateResult iterate (void)
2458 {
2459 m_testCtx.setTestResult(QP_TEST_RESULT_PASS, "Pass");
2460
2461 if (hasRequiredEGLVersion(1, 5))
2462 {
2463 test<createSync, waitSync, EGLBoolean>(m_funcNames,
2464 &Library::createSync,
2465 &Library::waitSync);
2466 }
2467 if (hasEGLWaitSyncExtension())
2468 {
2469 test<createSyncKHR, waitSyncKHR, EGLint>(m_funcNamesKHR,
2470 &Library::createSyncKHR,
2471 &Library::waitSyncKHR);
2472 }
2473 else if (!hasRequiredEGLVersion(1, 5))
2474 {
2475 TCU_THROW(NotSupportedError, "Required extensions not supported");
2476 }
2477
2478 return STOP;
2479 }
2480 };
2481
2482 class WaitSyncInvalidSyncTest : public SyncTest
2483 {
2484 public:
WaitSyncInvalidSyncTest(EglTestContext & eglTestCtx,EGLenum syncType)2485 WaitSyncInvalidSyncTest (EglTestContext& eglTestCtx, EGLenum syncType)
2486 : SyncTest (eglTestCtx, syncType, SyncTest::EXTENSION_WAIT_SYNC, true, "wait_server_invalid_sync", "wait_server_invalid_sync")
2487 {
2488 }
2489
2490 template <typename waitSyncFuncType, typename waitSyncSyncType>
test(string funcNames[FUNC_NAME_NUM_NAMES],waitSyncFuncType waitSyncFunc,waitSyncSyncType syncValue)2491 void test(string funcNames[FUNC_NAME_NUM_NAMES],
2492 waitSyncFuncType waitSyncFunc,
2493 waitSyncSyncType syncValue)
2494 {
2495 // Reset before each test
2496 deinit();
2497 init();
2498
2499 const Library& egl = m_eglTestCtx.getLibrary();
2500 TestLog& log = m_testCtx.getLog();
2501
2502 EGLint status = (egl.*waitSyncFunc)(m_eglDisplay, syncValue, 0);
2503 log << TestLog::Message << status << " = " << funcNames[FUNC_NAME_WAIT_SYNC] <<
2504 "(" << m_eglDisplay << ", " << syncValue << ", 0)" << TestLog::EndMessage;
2505
2506 EGLint error = egl.getError();
2507 log << TestLog::Message << error << " = eglGetError()" << TestLog::EndMessage;
2508
2509 if (error != EGL_BAD_PARAMETER)
2510 {
2511 log << TestLog::Message << "Unexpected error '" << eglu::getErrorStr(error) <<
2512 "' expected EGL_BAD_PARAMETER" << TestLog::EndMessage;
2513 m_testCtx.setTestResult(QP_TEST_RESULT_FAIL, "Fail");
2514 return;
2515 }
2516
2517 TCU_CHECK(status == EGL_FALSE);
2518 }
2519
iterate(void)2520 IterateResult iterate (void)
2521 {
2522 m_testCtx.setTestResult(QP_TEST_RESULT_PASS, "Pass");
2523
2524 if (hasRequiredEGLVersion(1, 5))
2525 {
2526 test<waitSync, EGLSync>(m_funcNames,
2527 &Library::waitSync,
2528 EGL_NO_SYNC);
2529 }
2530 if (hasEGLWaitSyncExtension())
2531 {
2532 test<waitSyncKHR, EGLSyncKHR>(m_funcNamesKHR,
2533 &Library::waitSyncKHR,
2534 EGL_NO_SYNC_KHR);
2535 }
2536 else if (!hasRequiredEGLVersion(1, 5))
2537 {
2538 TCU_THROW(NotSupportedError, "Required extensions not supported");
2539 }
2540
2541 return STOP;
2542 }
2543 };
2544
2545 class WaitSyncInvalidFlagTest : public SyncTest
2546 {
2547 public:
WaitSyncInvalidFlagTest(EglTestContext & eglTestCtx,EGLenum syncType)2548 WaitSyncInvalidFlagTest (EglTestContext& eglTestCtx, EGLenum syncType)
2549 : SyncTest (eglTestCtx, syncType, SyncTest::EXTENSION_WAIT_SYNC, true, "wait_server_invalid_flag", "wait_server_invalid_flag")
2550 {
2551 }
2552
2553 template <typename createSyncFuncType, typename waitSyncFuncType>
test(string funcNames[FUNC_NAME_NUM_NAMES],createSyncFuncType createSyncFunc,waitSyncFuncType waitSyncFunc)2554 void test(string funcNames[FUNC_NAME_NUM_NAMES],
2555 createSyncFuncType createSyncFunc,
2556 waitSyncFuncType waitSyncFunc)
2557 {
2558 // Reset before each test
2559 deinit();
2560 init();
2561
2562 const Library& egl = m_eglTestCtx.getLibrary();
2563 TestLog& log = m_testCtx.getLog();
2564 string createSyncMsgChk = funcNames[FUNC_NAME_CREATE_SYNC] + "()";
2565
2566 m_sync = (egl.*createSyncFunc)(m_eglDisplay, m_syncType, NULL);
2567 log << TestLog::Message << m_sync << " = " << funcNames[FUNC_NAME_CREATE_SYNC] <<
2568 "(" << m_eglDisplay << ", " << getSyncTypeName(m_syncType) << ", NULL)" <<
2569 TestLog::EndMessage;
2570 EGLU_CHECK_MSG(egl, createSyncMsgChk.c_str());
2571
2572 EGLint status = (egl.*waitSyncFunc)(m_eglDisplay, m_sync, 0xFFFFFFFF);
2573 log << TestLog::Message << status << " = " << funcNames[FUNC_NAME_WAIT_SYNC] <<
2574 "(" << m_eglDisplay << ", " << m_sync << ", 0xFFFFFFFF)" << TestLog::EndMessage;
2575
2576 EGLint error = egl.getError();
2577 log << TestLog::Message << error << " = eglGetError()" << TestLog::EndMessage;
2578
2579 if (error != EGL_BAD_PARAMETER)
2580 {
2581 log << TestLog::Message << "Unexpected error '" << eglu::getErrorStr(error) <<
2582 "' expected EGL_BAD_PARAMETER" << TestLog::EndMessage;
2583 m_testCtx.setTestResult(QP_TEST_RESULT_FAIL, "Fail");
2584 return;
2585 }
2586
2587 TCU_CHECK(status == EGL_FALSE);
2588 }
2589
iterate(void)2590 IterateResult iterate (void)
2591 {
2592 m_testCtx.setTestResult(QP_TEST_RESULT_PASS, "Pass");
2593
2594 if (hasRequiredEGLVersion(1, 5))
2595 {
2596 test<createSync, waitSync>(m_funcNames,
2597 &Library::createSync,
2598 &Library::waitSync);
2599 }
2600 if (hasEGLWaitSyncExtension())
2601 {
2602 test<createSyncKHR, waitSyncKHR>(m_funcNamesKHR,
2603 &Library::createSyncKHR,
2604 &Library::waitSyncKHR);
2605 }
2606 else if (!hasRequiredEGLVersion(1, 5))
2607 {
2608 TCU_THROW(NotSupportedError, "Required extensions not supported");
2609 }
2610
2611 return STOP;
2612 }
2613 };
2614
FenceSyncTests(EglTestContext & eglTestCtx)2615 FenceSyncTests::FenceSyncTests (EglTestContext& eglTestCtx)
2616 : TestCaseGroup (eglTestCtx, "fence_sync", "EGL_KHR_fence_sync extension tests")
2617 {
2618 }
2619
init(void)2620 void FenceSyncTests::init (void)
2621 {
2622 // Add valid API test
2623 {
2624 TestCaseGroup* const valid = new TestCaseGroup(m_eglTestCtx, "valid", "Valid function calls");
2625
2626 // eglCreateSyncKHR tests
2627 valid->addChild(new CreateNullAttribsTest(m_eglTestCtx, EGL_SYNC_FENCE_KHR));
2628 valid->addChild(new CreateEmptyAttribsTest(m_eglTestCtx, EGL_SYNC_FENCE_KHR));
2629
2630 // eglClientWaitSyncKHR tests
2631 valid->addChild(new ClientWaitNoTimeoutTest(m_eglTestCtx, EGL_SYNC_FENCE_KHR));
2632 valid->addChild(new ClientWaitForeverTest(m_eglTestCtx, EGL_SYNC_FENCE_KHR));
2633 valid->addChild(new ClientWaitNoContextTest(m_eglTestCtx, EGL_SYNC_FENCE_KHR));
2634 valid->addChild(new ClientWaitForeverFlushTest(m_eglTestCtx, EGL_SYNC_FENCE_KHR));
2635
2636 // eglGetSyncAttribKHR tests
2637 valid->addChild(new GetSyncTypeTest(m_eglTestCtx, EGL_SYNC_FENCE_KHR));
2638 valid->addChild(new GetSyncStatusTest(m_eglTestCtx, EGL_SYNC_FENCE_KHR));
2639 valid->addChild(new GetSyncStatusSignaledTest(m_eglTestCtx, EGL_SYNC_FENCE_KHR));
2640 valid->addChild(new GetSyncConditionTest(m_eglTestCtx, EGL_SYNC_FENCE_KHR));
2641
2642 // eglDestroySyncKHR tests
2643 valid->addChild(new DestroySyncTest(m_eglTestCtx, EGL_SYNC_FENCE_KHR));
2644
2645 // eglWaitSyncKHR tests
2646 valid->addChild(new WaitSyncTest(m_eglTestCtx, EGL_SYNC_FENCE_KHR));
2647
2648 // eglClientWaitSyncKHR tests
2649 valid->addChild(new CreateLongRunningSyncTest(m_eglTestCtx, EGL_SYNC_FENCE_KHR));
2650
2651 addChild(valid);
2652 }
2653
2654 // Add negative API tests
2655 {
2656 TestCaseGroup* const invalid = new TestCaseGroup(
2657 m_eglTestCtx, "invalid", "Invalid function calls");
2658
2659 // eglCreateSyncKHR tests
2660 invalid->addChild(new CreateInvalidDisplayTest(m_eglTestCtx, EGL_SYNC_FENCE_KHR));
2661 invalid->addChild(new CreateInvalidTypeTest(m_eglTestCtx, EGL_SYNC_FENCE_KHR));
2662 invalid->addChild(new CreateInvalidAttribsTest(m_eglTestCtx, EGL_SYNC_FENCE_KHR));
2663 invalid->addChild(new CreateInvalidContextTest(m_eglTestCtx, EGL_SYNC_FENCE_KHR));
2664
2665 // eglClientWaitSyncKHR tests
2666 invalid->addChild(new ClientWaitInvalidDisplayTest(m_eglTestCtx, EGL_SYNC_FENCE_KHR));
2667 invalid->addChild(new ClientWaitInvalidSyncTest(m_eglTestCtx, EGL_SYNC_FENCE_KHR));
2668
2669 // eglGetSyncAttribKHR tests
2670 invalid->addChild(new GetSyncInvalidDisplayTest(m_eglTestCtx, EGL_SYNC_FENCE_KHR));
2671 invalid->addChild(new GetSyncInvalidSyncTest(m_eglTestCtx, EGL_SYNC_FENCE_KHR));
2672 invalid->addChild(new GetSyncInvalidAttributeTest(m_eglTestCtx, EGL_SYNC_FENCE_KHR));
2673 invalid->addChild(new GetSyncInvalidValueTest(m_eglTestCtx, EGL_SYNC_FENCE_KHR));
2674
2675 // eglDestroySyncKHR tests
2676 invalid->addChild(new DestroySyncInvalidDislayTest(m_eglTestCtx, EGL_SYNC_FENCE_KHR));
2677 invalid->addChild(new DestroySyncInvalidSyncTest(m_eglTestCtx, EGL_SYNC_FENCE_KHR));
2678
2679 // eglWaitSyncKHR tests
2680 invalid->addChild(new WaitSyncInvalidDisplayTest(m_eglTestCtx, EGL_SYNC_FENCE_KHR));
2681 invalid->addChild(new WaitSyncInvalidSyncTest(m_eglTestCtx, EGL_SYNC_FENCE_KHR));
2682 invalid->addChild(new WaitSyncInvalidFlagTest(m_eglTestCtx, EGL_SYNC_FENCE_KHR));
2683
2684 addChild(invalid);
2685 }
2686 }
2687
ReusableSyncTests(EglTestContext & eglTestCtx)2688 ReusableSyncTests::ReusableSyncTests (EglTestContext& eglTestCtx)
2689 : TestCaseGroup (eglTestCtx, "reusable_sync", "EGL_KHR_reusable_sync extension tests")
2690 {
2691 }
2692
init(void)2693 void ReusableSyncTests::init (void)
2694 {
2695 // Add valid API test
2696 {
2697 TestCaseGroup* const valid = new TestCaseGroup(m_eglTestCtx, "valid", "Valid function calls");
2698
2699 // eglCreateSyncKHR tests
2700 valid->addChild(new CreateNullAttribsTest(m_eglTestCtx, EGL_SYNC_REUSABLE_KHR));
2701 valid->addChild(new CreateEmptyAttribsTest(m_eglTestCtx, EGL_SYNC_REUSABLE_KHR));
2702
2703 // eglClientWaitSyncKHR tests
2704 valid->addChild(new ClientWaitNoTimeoutTest(m_eglTestCtx, EGL_SYNC_REUSABLE_KHR));
2705 valid->addChild(new ClientWaitForeverTest(m_eglTestCtx, EGL_SYNC_REUSABLE_KHR));
2706 valid->addChild(new ClientWaitNoContextTest(m_eglTestCtx, EGL_SYNC_REUSABLE_KHR));
2707 valid->addChild(new ClientWaitForeverFlushTest(m_eglTestCtx, EGL_SYNC_REUSABLE_KHR));
2708
2709 // eglGetSyncAttribKHR tests
2710 valid->addChild(new GetSyncTypeTest(m_eglTestCtx, EGL_SYNC_REUSABLE_KHR));
2711 valid->addChild(new GetSyncStatusTest(m_eglTestCtx, EGL_SYNC_REUSABLE_KHR));
2712 valid->addChild(new GetSyncStatusSignaledTest(m_eglTestCtx, EGL_SYNC_REUSABLE_KHR));
2713
2714 // eglDestroySyncKHR tests
2715 valid->addChild(new DestroySyncTest(m_eglTestCtx, EGL_SYNC_REUSABLE_KHR));
2716
2717 addChild(valid);
2718 }
2719
2720 // Add negative API tests
2721 {
2722 TestCaseGroup* const invalid = new TestCaseGroup(m_eglTestCtx, "invalid", "Invalid function calls");
2723
2724 // eglCreateSyncKHR tests
2725 invalid->addChild(new CreateInvalidDisplayTest(m_eglTestCtx, EGL_SYNC_REUSABLE_KHR));
2726 invalid->addChild(new CreateInvalidTypeTest(m_eglTestCtx, EGL_SYNC_REUSABLE_KHR));
2727 invalid->addChild(new CreateInvalidAttribsTest(m_eglTestCtx, EGL_SYNC_REUSABLE_KHR));
2728
2729 // eglClientWaitSyncKHR tests
2730 invalid->addChild(new ClientWaitInvalidDisplayTest(m_eglTestCtx, EGL_SYNC_REUSABLE_KHR));
2731 invalid->addChild(new ClientWaitInvalidSyncTest(m_eglTestCtx, EGL_SYNC_REUSABLE_KHR));
2732
2733 // eglGetSyncAttribKHR tests
2734 invalid->addChild(new GetSyncInvalidDisplayTest(m_eglTestCtx, EGL_SYNC_REUSABLE_KHR));
2735 invalid->addChild(new GetSyncInvalidSyncTest(m_eglTestCtx, EGL_SYNC_REUSABLE_KHR));
2736 invalid->addChild(new GetSyncInvalidAttributeTest(m_eglTestCtx, EGL_SYNC_REUSABLE_KHR));
2737 invalid->addChild(new GetSyncInvalidValueTest(m_eglTestCtx, EGL_SYNC_REUSABLE_KHR));
2738
2739 // eglDestroySyncKHR tests
2740 invalid->addChild(new DestroySyncInvalidDislayTest(m_eglTestCtx, EGL_SYNC_REUSABLE_KHR));
2741 invalid->addChild(new DestroySyncInvalidSyncTest(m_eglTestCtx, EGL_SYNC_REUSABLE_KHR));
2742
2743 // eglWaitSyncKHR tests
2744 invalid->addChild(new WaitSyncInvalidDisplayTest(m_eglTestCtx, EGL_SYNC_REUSABLE_KHR));
2745 invalid->addChild(new WaitSyncInvalidSyncTest(m_eglTestCtx, EGL_SYNC_REUSABLE_KHR));
2746
2747 addChild(invalid);
2748 }
2749 }
2750
2751 } // egl
2752 } // deqp
2753
2754