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