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