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 Simple context construction test for EGL_KHR_create_context.
22 *//*--------------------------------------------------------------------*/
23
24 #include "teglCreateContextExtTests.hpp"
25
26 #include "tcuTestLog.hpp"
27
28 #include "egluNativeDisplay.hpp"
29 #include "egluNativeWindow.hpp"
30 #include "egluNativePixmap.hpp"
31 #include "egluConfigFilter.hpp"
32 #include "egluStrUtil.hpp"
33 #include "egluUtil.hpp"
34 #include "egluUnique.hpp"
35
36 #include "eglwLibrary.hpp"
37 #include "eglwEnums.hpp"
38
39 #include "gluDefs.hpp"
40 #include "gluRenderConfig.hpp"
41
42 #include "glwFunctions.hpp"
43 #include "glwEnums.hpp"
44
45 #include "deStringUtil.hpp"
46 #include "deUniquePtr.hpp"
47 #include "deSTLUtil.hpp"
48
49 #include <string>
50 #include <vector>
51 #include <set>
52 #include <sstream>
53
54 #include <cstring>
55
56 using std::set;
57 using std::string;
58 using std::vector;
59 using tcu::TestLog;
60
61 using namespace eglw;
62
63 // Make sure KHR / core values match to those in GL_ARB_robustness and GL_EXT_robustness
64 DE_STATIC_ASSERT(GL_RESET_NOTIFICATION_STRATEGY == 0x8256);
65 DE_STATIC_ASSERT(GL_LOSE_CONTEXT_ON_RESET == 0x8252);
66 DE_STATIC_ASSERT(GL_NO_RESET_NOTIFICATION == 0x8261);
67
68 #if !defined(GL_CONTEXT_ROBUST_ACCESS)
69 #define GL_CONTEXT_ROBUST_ACCESS 0x90F3
70 #endif
71
72 namespace deqp
73 {
74 namespace egl
75 {
76
77 namespace
78 {
79
getAttribListLength(const EGLint * attribList)80 size_t getAttribListLength(const EGLint *attribList)
81 {
82 size_t size = 0;
83
84 while (attribList[size] != EGL_NONE)
85 size++;
86
87 return size + 1;
88 }
89
eglContextFlagsToString(EGLint flags)90 string eglContextFlagsToString(EGLint flags)
91 {
92 std::ostringstream stream;
93
94 if (flags == 0)
95 stream << "<None>";
96 else
97 {
98 bool first = true;
99
100 if ((flags & EGL_CONTEXT_OPENGL_DEBUG_BIT_KHR) != 0)
101 {
102 if (!first)
103 stream << "|";
104
105 first = false;
106
107 stream << "EGL_CONTEXT_OPENGL_DEBUG_BIT_KHR";
108 }
109
110 if ((flags & EGL_CONTEXT_OPENGL_FORWARD_COMPATIBLE_BIT_KHR) != 0)
111 {
112 if (!first)
113 stream << "|";
114
115 first = false;
116
117 stream << "EGL_CONTEXT_OPENGL_FORWARD_COMPATIBLE_BIT_KHR";
118 }
119
120 if ((flags & EGL_CONTEXT_OPENGL_ROBUST_ACCESS_BIT_KHR) != 0)
121 {
122 if (!first)
123 stream << "|";
124
125 stream << "EGL_CONTEXT_OPENGL_ROBUST_ACCESS_BIT_KHR";
126 }
127 }
128
129 return stream.str();
130 }
131
eglProfileMaskToString(EGLint mask)132 string eglProfileMaskToString(EGLint mask)
133 {
134 std::ostringstream stream;
135
136 if (mask == 0)
137 stream << "<None>";
138 else
139 {
140 bool first = true;
141
142 if ((mask & EGL_CONTEXT_OPENGL_CORE_PROFILE_BIT_KHR) != 0)
143 {
144 if (!first)
145 stream << "|";
146
147 first = false;
148
149 stream << "EGL_CONTEXT_OPENGL_CORE_PROFILE_BIT_KHR";
150 }
151
152 if ((mask & EGL_CONTEXT_OPENGL_COMPATIBILITY_PROFILE_BIT_KHR) != 0)
153 {
154 if (!first)
155 stream << "|";
156
157 stream << "EGL_CONTEXT_OPENGL_COMPATIBILITY_PROFILE_BIT_KHR";
158 }
159 }
160
161 return stream.str();
162 }
163
eglResetNotificationStrategyToString(EGLint strategy)164 const char *eglResetNotificationStrategyToString(EGLint strategy)
165 {
166 switch (strategy)
167 {
168 case EGL_NO_RESET_NOTIFICATION_KHR:
169 return "EGL_NO_RESET_NOTIFICATION_KHR";
170 case EGL_LOSE_CONTEXT_ON_RESET_KHR:
171 return "EGL_LOSE_CONTEXT_ON_RESET_KHR";
172 default:
173 return "<Unknown>";
174 }
175 }
176
177 class CreateContextExtCase : public TestCase
178 {
179 public:
180 CreateContextExtCase(EglTestContext &eglTestCtx, EGLenum api, const EGLint *attribList,
181 const eglu::FilterList &filter, const char *name, const char *description);
182 ~CreateContextExtCase(void);
183
184 void executeForSurface(EGLConfig config, EGLSurface surface);
185
186 void init(void);
187 void deinit(void);
188
189 IterateResult iterate(void);
190 void checkRequiredExtensions(void);
191 void logAttribList(void);
192 bool validateCurrentContext(const glw::Functions &gl);
193
194 private:
195 bool m_isOk;
196 int m_iteration;
197
198 const eglu::FilterList m_filter;
199 vector<EGLint> m_attribList;
200 const EGLenum m_api;
201
202 EGLDisplay m_display;
203 vector<EGLConfig> m_configs;
204 glu::ContextType m_glContextType;
205 };
206
attribListToContextType(EGLenum api,const EGLint * attribList)207 glu::ContextType attribListToContextType(EGLenum api, const EGLint *attribList)
208 {
209 EGLint majorVersion = 1;
210 EGLint minorVersion = 0;
211 glu::ContextFlags flags = glu::ContextFlags(0);
212 glu::Profile profile = api == EGL_OPENGL_ES_API ? glu::PROFILE_ES : glu::PROFILE_CORE;
213 const EGLint *iter = attribList;
214
215 while ((*iter) != EGL_NONE)
216 {
217 switch (*iter)
218 {
219 case EGL_CONTEXT_MAJOR_VERSION_KHR:
220 iter++;
221 majorVersion = (*iter);
222 iter++;
223 break;
224
225 case EGL_CONTEXT_MINOR_VERSION_KHR:
226 iter++;
227 minorVersion = (*iter);
228 iter++;
229 break;
230
231 case EGL_CONTEXT_FLAGS_KHR:
232 iter++;
233
234 if ((*iter & EGL_CONTEXT_OPENGL_ROBUST_ACCESS_BIT_KHR) != 0)
235 flags = flags | glu::CONTEXT_ROBUST;
236
237 if ((*iter & EGL_CONTEXT_OPENGL_DEBUG_BIT_KHR) != 0)
238 flags = flags | glu::CONTEXT_DEBUG;
239
240 if ((*iter & EGL_CONTEXT_OPENGL_FORWARD_COMPATIBLE_BIT_KHR) != 0)
241 flags = flags | glu::CONTEXT_FORWARD_COMPATIBLE;
242
243 iter++;
244 break;
245
246 case EGL_CONTEXT_OPENGL_PROFILE_MASK_KHR:
247 iter++;
248
249 if (*iter == EGL_CONTEXT_OPENGL_COMPATIBILITY_PROFILE_BIT_KHR)
250 profile = glu::PROFILE_COMPATIBILITY;
251 else if (*iter != EGL_CONTEXT_OPENGL_CORE_PROFILE_BIT_KHR)
252 throw tcu::InternalError("Indeterminate OpenGL profile");
253
254 iter++;
255 break;
256
257 case EGL_CONTEXT_OPENGL_RESET_NOTIFICATION_STRATEGY_KHR:
258 iter += 2;
259 break;
260
261 case EGL_CONTEXT_OPENGL_RESET_NOTIFICATION_STRATEGY_EXT:
262 iter += 2;
263 break;
264
265 case EGL_CONTEXT_OPENGL_ROBUST_ACCESS_EXT:
266 iter += 2;
267 break;
268
269 default:
270 DE_ASSERT(false);
271 }
272 }
273
274 return glu::ContextType(majorVersion, minorVersion, profile, flags);
275 }
276
CreateContextExtCase(EglTestContext & eglTestCtx,EGLenum api,const EGLint * attribList,const eglu::FilterList & filter,const char * name,const char * description)277 CreateContextExtCase::CreateContextExtCase(EglTestContext &eglTestCtx, EGLenum api, const EGLint *attribList,
278 const eglu::FilterList &filter, const char *name, const char *description)
279 : TestCase(eglTestCtx, name, description)
280 , m_isOk(true)
281 , m_iteration(0)
282 , m_filter(filter)
283 , m_attribList(attribList, attribList + getAttribListLength(attribList))
284 , m_api(api)
285 , m_display(EGL_NO_DISPLAY)
286 , m_glContextType(attribListToContextType(api, attribList))
287 {
288 }
289
~CreateContextExtCase(void)290 CreateContextExtCase::~CreateContextExtCase(void)
291 {
292 deinit();
293 }
294
init(void)295 void CreateContextExtCase::init(void)
296 {
297 m_display = eglu::getAndInitDisplay(m_eglTestCtx.getNativeDisplay());
298 m_configs = eglu::chooseConfigs(m_eglTestCtx.getLibrary(), m_display, m_filter);
299 }
300
deinit(void)301 void CreateContextExtCase::deinit(void)
302 {
303 m_attribList.clear();
304 m_configs.clear();
305
306 if (m_display != EGL_NO_DISPLAY)
307 {
308 m_eglTestCtx.getLibrary().terminate(m_display);
309 m_display = EGL_NO_DISPLAY;
310 }
311 }
312
logAttribList(void)313 void CreateContextExtCase::logAttribList(void)
314 {
315 const EGLint *iter = &(m_attribList[0]);
316 std::ostringstream attribListString;
317
318 while ((*iter) != EGL_NONE)
319 {
320 switch (*iter)
321 {
322 case EGL_CONTEXT_MAJOR_VERSION_KHR:
323 iter++;
324 attribListString << "EGL_CONTEXT_MAJOR_VERSION_KHR(EGL_CONTEXT_CLIENT_VERSION), " << (*iter) << ", ";
325 iter++;
326 break;
327
328 case EGL_CONTEXT_MINOR_VERSION_KHR:
329 iter++;
330 attribListString << "EGL_CONTEXT_MINOR_VERSION_KHR, " << (*iter) << ", ";
331 iter++;
332 break;
333
334 case EGL_CONTEXT_FLAGS_KHR:
335 iter++;
336 attribListString << "EGL_CONTEXT_FLAGS_KHR, " << eglContextFlagsToString(*iter) << ", ";
337 iter++;
338 break;
339
340 case EGL_CONTEXT_OPENGL_PROFILE_MASK_KHR:
341 iter++;
342 attribListString << "EGL_CONTEXT_OPENGL_PROFILE_MASK_KHR, " << eglProfileMaskToString(*iter) << ", ";
343 iter++;
344 break;
345
346 case EGL_CONTEXT_OPENGL_RESET_NOTIFICATION_STRATEGY_KHR:
347 iter++;
348 attribListString << "EGL_CONTEXT_OPENGL_RESET_NOTIFICATION_STRATEGY_KHR, "
349 << eglResetNotificationStrategyToString(*iter) << ", ";
350 iter++;
351 break;
352
353 case EGL_CONTEXT_OPENGL_ROBUST_ACCESS_EXT:
354 iter++;
355 attribListString << "EGL_CONTEXT_OPENGL_ROBUST_ACCESS_EXT, ";
356
357 if (*iter == EGL_FALSE || *iter == EGL_TRUE)
358 attribListString << (*iter ? "EGL_TRUE" : "EGL_FALSE");
359 else
360 attribListString << (*iter);
361 iter++;
362 break;
363
364 default:
365 DE_ASSERT(false);
366 }
367 }
368
369 attribListString << "EGL_NONE";
370 m_testCtx.getLog() << TestLog::Message << "EGL attrib list: { " << attribListString.str() << " }"
371 << TestLog::EndMessage;
372 }
373
checkRequiredExtensions(void)374 void CreateContextExtCase::checkRequiredExtensions(void)
375 {
376 bool isOk = true;
377 set<string> requiredExtensions;
378 vector<string> extensions = eglu::getDisplayExtensions(m_eglTestCtx.getLibrary(), m_display);
379
380 {
381 const EGLint *iter = &(m_attribList[0]);
382
383 while ((*iter) != EGL_NONE)
384 {
385 switch (*iter)
386 {
387 case EGL_CONTEXT_MAJOR_VERSION_KHR:
388 iter++;
389 iter++;
390 break;
391
392 case EGL_CONTEXT_MINOR_VERSION_KHR:
393 iter++;
394 requiredExtensions.insert("EGL_KHR_create_context");
395 iter++;
396 break;
397
398 case EGL_CONTEXT_FLAGS_KHR:
399 iter++;
400 requiredExtensions.insert("EGL_KHR_create_context");
401
402 if (*iter & EGL_CONTEXT_OPENGL_ROBUST_ACCESS_BIT_KHR)
403 requiredExtensions.insert("EGL_EXT_create_context_robustness");
404
405 iter++;
406 break;
407
408 case EGL_CONTEXT_OPENGL_PROFILE_MASK_KHR:
409 iter++;
410 requiredExtensions.insert("EGL_KHR_create_context");
411 iter++;
412 break;
413
414 case EGL_CONTEXT_OPENGL_RESET_NOTIFICATION_STRATEGY_KHR:
415 iter++;
416 requiredExtensions.insert("EGL_KHR_create_context");
417 iter++;
418 break;
419
420 case EGL_CONTEXT_OPENGL_RESET_NOTIFICATION_STRATEGY_EXT:
421 iter++;
422 requiredExtensions.insert("EGL_EXT_create_context_robustness");
423 iter++;
424 break;
425
426 case EGL_CONTEXT_OPENGL_ROBUST_ACCESS_EXT:
427 iter++;
428 requiredExtensions.insert("EGL_EXT_create_context_robustness");
429 iter++;
430 break;
431
432 default:
433 DE_ASSERT(false);
434 }
435 }
436 }
437
438 for (std::set<string>::const_iterator reqExt = requiredExtensions.begin(); reqExt != requiredExtensions.end();
439 ++reqExt)
440 {
441 if (!de::contains(extensions.begin(), extensions.end(), *reqExt))
442 {
443 m_testCtx.getLog() << TestLog::Message << "Required extension '" << (*reqExt) << "' not supported"
444 << TestLog::EndMessage;
445 isOk = false;
446 }
447 }
448
449 if (!isOk)
450 TCU_THROW(NotSupportedError, "Required extensions not supported");
451 }
452
checkVersionString(TestLog & log,const glw::Functions & gl,bool desktop,int major,int minor)453 bool checkVersionString(TestLog &log, const glw::Functions &gl, bool desktop, int major, int minor)
454 {
455 const char *const versionStr = (const char *)gl.getString(GL_VERSION);
456 const char *iter = versionStr;
457
458 int majorVersion = 0;
459 int minorVersion = 0;
460
461 // Check embedded version prefixes
462 if (!desktop)
463 {
464 const char *prefix = NULL;
465 const char *prefixIter = NULL;
466
467 if (major == 1)
468 prefix = "OpenGL ES-CM ";
469 else
470 prefix = "OpenGL ES ";
471
472 prefixIter = prefix;
473
474 while (*prefixIter)
475 {
476 if ((*prefixIter) != (*iter))
477 {
478 log << TestLog::Message << "Invalid version string prefix. Expected '" << prefix << "'."
479 << TestLog::EndMessage;
480 return false;
481 }
482
483 prefixIter++;
484 iter++;
485 }
486 }
487
488 while ((*iter) && (*iter) != '.')
489 {
490 const int val = (*iter) - '0';
491
492 // Not a number
493 if (val < 0 || val > 9)
494 {
495 log << TestLog::Message << "Failed to parse major version number. Not a number." << TestLog::EndMessage;
496 return false;
497 }
498
499 // Leading zero
500 if (majorVersion == 0 && val == 0)
501 {
502 log << TestLog::Message << "Failed to parse major version number. Begins with zero." << TestLog::EndMessage;
503 return false;
504 }
505
506 majorVersion = majorVersion * 10 + val;
507
508 iter++;
509 }
510
511 // Invalid format
512 if ((*iter) != '.')
513 {
514 log << TestLog::Message << "Failed to parse version. Expected '.' after major version number."
515 << TestLog::EndMessage;
516 return false;
517 }
518
519 iter++;
520
521 while ((*iter) && (*iter) != ' ' && (*iter) != '.')
522 {
523 const int val = (*iter) - '0';
524
525 // Not a number
526 if (val < 0 || val > 9)
527 {
528 log << TestLog::Message << "Failed to parse minor version number. Not a number." << TestLog::EndMessage;
529 return false;
530 }
531
532 // Leading zero
533 if (minorVersion == 0 && val == 0)
534 {
535 // Leading zeros in minor version
536 if ((*(iter + 1)) != ' ' && (*(iter + 1)) != '.' && (*(iter + 1)) != '\0')
537 {
538 log << TestLog::Message << "Failed to parse minor version number. Leading zeros."
539 << TestLog::EndMessage;
540 return false;
541 }
542 }
543
544 minorVersion = minorVersion * 10 + val;
545
546 iter++;
547 }
548
549 // Invalid format
550 if ((*iter) != ' ' && (*iter) != '.' && (*iter) != '\0')
551 return false;
552
553 if (desktop)
554 {
555 if (majorVersion < major)
556 {
557 log << TestLog::Message << "Major version is less than required." << TestLog::EndMessage;
558 return false;
559 }
560 else if (majorVersion == major && minorVersion < minor)
561 {
562 log << TestLog::Message << "Minor version is less than required." << TestLog::EndMessage;
563 return false;
564 }
565 else if (majorVersion == major && minorVersion == minor)
566 return true;
567
568 if (major < 3 || (major == 3 && minor == 0))
569 {
570 if (majorVersion == 3 && minorVersion == 1)
571 {
572 if (glu::hasExtension(gl, glu::ApiType::core(3, 1), "GL_ARB_compatibility"))
573 return true;
574 else
575 {
576 log << TestLog::Message
577 << "Required OpenGL 3.0 or earlier. Got OpenGL 3.1 without GL_ARB_compatibility."
578 << TestLog::EndMessage;
579 return false;
580 }
581 }
582 else if (majorVersion > 3 || (majorVersion == 3 && minorVersion >= minor))
583 {
584 int32_t profile = 0;
585
586 gl.getIntegerv(GL_CONTEXT_PROFILE_MASK, &profile);
587 GLU_EXPECT_NO_ERROR(gl.getError(), "glGetIntegerv()");
588
589 if (profile == GL_CONTEXT_COMPATIBILITY_PROFILE_BIT)
590 return true;
591 else
592 {
593 log << TestLog::Message
594 << "Required OpenGL 3.0 or earlier. Got later version without compatibility profile."
595 << TestLog::EndMessage;
596 return false;
597 }
598 }
599 else
600 DE_ASSERT(false);
601
602 return false;
603 }
604 else if (major == 3 && minor == 1)
605 {
606 if (majorVersion > 3 || (majorVersion == 3 && minorVersion >= minor))
607 {
608 int32_t profile = 0;
609
610 gl.getIntegerv(GL_CONTEXT_PROFILE_MASK, &profile);
611 GLU_EXPECT_NO_ERROR(gl.getError(), "glGetIntegerv()");
612
613 if (profile == GL_CONTEXT_CORE_PROFILE_BIT)
614 return true;
615 else
616 {
617 log << TestLog::Message << "Required OpenGL 3.1. Got later version without core profile."
618 << TestLog::EndMessage;
619 return false;
620 }
621 }
622 else
623 DE_ASSERT(false);
624
625 return false;
626 }
627 else
628 {
629 log << TestLog::Message << "Couldn't do any further compatibilyt checks." << TestLog::EndMessage;
630 return true;
631 }
632 }
633 else
634 {
635 if (majorVersion < major)
636 {
637 log << TestLog::Message << "Major version is less than required." << TestLog::EndMessage;
638 return false;
639 }
640 else if (majorVersion == major && minorVersion < minor)
641 {
642 log << TestLog::Message << "Minor version is less than required." << TestLog::EndMessage;
643 return false;
644 }
645 else
646 return true;
647 }
648 }
649
checkVersionQueries(TestLog & log,const glw::Functions & gl,int major,int minor)650 bool checkVersionQueries(TestLog &log, const glw::Functions &gl, int major, int minor)
651 {
652 int32_t majorVersion = 0;
653 int32_t minorVersion = 0;
654
655 gl.getIntegerv(GL_MAJOR_VERSION, &majorVersion);
656 GLU_EXPECT_NO_ERROR(gl.getError(), "glGetIntegerv()");
657
658 gl.getIntegerv(GL_MINOR_VERSION, &minorVersion);
659 GLU_EXPECT_NO_ERROR(gl.getError(), "glGetIntegerv()");
660
661 if (majorVersion < major || (majorVersion == major && minorVersion < minor))
662 {
663 if (majorVersion < major)
664 log << TestLog::Message << "glGetIntegerv(GL_MAJOR_VERSION) returned '" << majorVersion
665 << "' expected at least '" << major << "'" << TestLog::EndMessage;
666 else if (majorVersion == major && minorVersion < minor)
667 log << TestLog::Message << "glGetIntegerv(GL_MINOR_VERSION) returned '" << minorVersion << "' expected '"
668 << minor << "'" << TestLog::EndMessage;
669 else
670 DE_ASSERT(false);
671
672 return false;
673 }
674 else
675 return true;
676 }
677
validateCurrentContext(const glw::Functions & gl)678 bool CreateContextExtCase::validateCurrentContext(const glw::Functions &gl)
679 {
680 bool isOk = true;
681 TestLog &log = m_testCtx.getLog();
682 const EGLint *iter = &(m_attribList[0]);
683
684 EGLint majorVersion = -1;
685 EGLint minorVersion = -1;
686 EGLint contextFlags = -1;
687 EGLint profileMask = -1;
688 EGLint notificationStrategy = -1;
689 EGLint robustAccessExt = -1;
690 EGLint notificationStrategyExt = -1;
691
692 while ((*iter) != EGL_NONE)
693 {
694 switch (*iter)
695 {
696 case EGL_CONTEXT_MAJOR_VERSION_KHR:
697 iter++;
698 majorVersion = (*iter);
699 iter++;
700 break;
701
702 case EGL_CONTEXT_MINOR_VERSION_KHR:
703 iter++;
704 minorVersion = (*iter);
705 iter++;
706 break;
707
708 case EGL_CONTEXT_FLAGS_KHR:
709 iter++;
710 contextFlags = (*iter);
711 iter++;
712 break;
713
714 case EGL_CONTEXT_OPENGL_PROFILE_MASK_KHR:
715 iter++;
716 profileMask = (*iter);
717 iter++;
718 break;
719
720 case EGL_CONTEXT_OPENGL_RESET_NOTIFICATION_STRATEGY_KHR:
721 iter++;
722 notificationStrategy = (*iter);
723 iter++;
724 break;
725
726 case EGL_CONTEXT_OPENGL_ROBUST_ACCESS_EXT:
727 iter++;
728 robustAccessExt = *iter;
729 iter++;
730 break;
731
732 case EGL_CONTEXT_OPENGL_RESET_NOTIFICATION_STRATEGY_EXT:
733 iter++;
734 notificationStrategyExt = *iter;
735 iter++;
736 break;
737
738 default:
739 DE_ASSERT(false);
740 }
741 }
742
743 const string version = (const char *)gl.getString(GL_VERSION);
744
745 log << TestLog::Message << "GL_VERSION: '" << version << "'" << TestLog::EndMessage;
746
747 if (majorVersion == -1)
748 majorVersion = 1;
749
750 if (minorVersion == -1)
751 minorVersion = 0;
752
753 if (m_api == EGL_OPENGL_ES_API)
754 {
755 if (!checkVersionString(log, gl, false, majorVersion, minorVersion))
756 isOk = false;
757
758 if (majorVersion == 3)
759 {
760 if (!checkVersionQueries(log, gl, majorVersion, minorVersion))
761 isOk = false;
762 }
763 }
764 else if (m_api == EGL_OPENGL_API)
765 {
766 if (!checkVersionString(log, gl, true, majorVersion, minorVersion))
767 isOk = false;
768
769 if (majorVersion >= 3)
770 {
771 if (!checkVersionQueries(log, gl, majorVersion, minorVersion))
772 isOk = false;
773 }
774 }
775 else
776 DE_ASSERT(false);
777
778 if (contextFlags != -1)
779 {
780 if (m_api == EGL_OPENGL_API && (majorVersion > 3 || (majorVersion == 3 && minorVersion >= 1)))
781 {
782 int32_t contextFlagsGL;
783
784 DE_ASSERT(m_api == EGL_OPENGL_API);
785
786 if (contextFlags == -1)
787 contextFlags = 0;
788
789 gl.getIntegerv(GL_CONTEXT_FLAGS, &contextFlagsGL);
790
791 if (contextFlags != contextFlagsGL)
792 {
793 log << TestLog::Message << "Invalid GL_CONTEXT_FLAGS. Expected '"
794 << eglContextFlagsToString(contextFlags) << "' got '" << eglContextFlagsToString(contextFlagsGL)
795 << "'" << TestLog::EndMessage;
796 isOk = false;
797 }
798 }
799 }
800
801 if (profileMask != -1 || (m_api == EGL_OPENGL_API && (majorVersion >= 3)))
802 {
803 if (profileMask == -1)
804 profileMask = EGL_CONTEXT_OPENGL_CORE_PROFILE_BIT_KHR;
805
806 DE_ASSERT(m_api == EGL_OPENGL_API);
807
808 if (majorVersion < 3 || (majorVersion == 3 && minorVersion < 2))
809 {
810 // \note Ignore profile masks. This is not an error
811 }
812 else
813 {
814 int32_t profileMaskGL = 0;
815
816 gl.getIntegerv(GL_CONTEXT_PROFILE_MASK, &profileMaskGL);
817 GLU_EXPECT_NO_ERROR(gl.getError(), "glGetIntegerv()");
818
819 if (profileMask != profileMaskGL)
820 {
821 log << TestLog::Message << "Invalid GL_CONTEXT_PROFILE_MASK. Expected '"
822 << eglProfileMaskToString(profileMask) << "' got '" << eglProfileMaskToString(profileMaskGL) << "'"
823 << TestLog::EndMessage;
824 isOk = false;
825 }
826 }
827 }
828
829 DE_ASSERT(notificationStrategy == -1 || notificationStrategyExt == -1);
830
831 if (notificationStrategy != -1 || notificationStrategyExt != -1)
832 {
833 const int32_t expected = notificationStrategy != -1 ? notificationStrategy : notificationStrategyExt;
834 int32_t strategy = 0;
835
836 gl.getIntegerv(GL_RESET_NOTIFICATION_STRATEGY, &strategy);
837 GLU_EXPECT_NO_ERROR(gl.getError(), "glGetIntegerv()");
838
839 if (expected == EGL_NO_RESET_NOTIFICATION && strategy != GL_NO_RESET_NOTIFICATION)
840 {
841 log << TestLog::Message << "glGetIntegerv(GL_RESET_NOTIFICATION_STRATEGY) returned '" << strategy
842 << "', expected 'GL_NO_RESET_NOTIFICATION'" << TestLog::EndMessage;
843 isOk = false;
844 }
845 else if (expected == EGL_LOSE_CONTEXT_ON_RESET && strategy != GL_LOSE_CONTEXT_ON_RESET)
846 {
847 log << TestLog::Message << "glGetIntegerv(GL_RESET_NOTIFICATION_STRATEGY) returned '" << strategy
848 << "', expected 'GL_LOSE_CONTEXT_ON_RESET'" << TestLog::EndMessage;
849 isOk = false;
850 }
851 }
852
853 if (robustAccessExt == EGL_TRUE)
854 {
855 if (m_api == EGL_OPENGL_API)
856 {
857 if (!glu::hasExtension(gl, glu::ApiType::core(majorVersion, minorVersion), "GL_ARB_robustness"))
858 {
859 log << TestLog::Message << "Created robustness context but it doesn't support GL_ARB_robustness."
860 << TestLog::EndMessage;
861 isOk = false;
862 }
863 }
864 else if (m_api == EGL_OPENGL_ES_API)
865 {
866 if (!glu::hasExtension(gl, glu::ApiType::es(majorVersion, minorVersion), "GL_EXT_robustness"))
867 {
868 log << TestLog::Message << "Created robustness context but it doesn't support GL_EXT_robustness."
869 << TestLog::EndMessage;
870 isOk = false;
871 }
872 }
873
874 if (m_api == EGL_OPENGL_API && (majorVersion > 3 || (majorVersion == 3 && minorVersion >= 1)))
875 {
876 int32_t contextFlagsGL;
877
878 DE_ASSERT(m_api == EGL_OPENGL_API);
879
880 gl.getIntegerv(GL_CONTEXT_FLAGS, &contextFlagsGL);
881
882 if ((contextFlagsGL & GL_CONTEXT_FLAG_ROBUST_ACCESS_BIT) != 0)
883 {
884 log << TestLog::Message
885 << "Invalid GL_CONTEXT_FLAGS. GL_CONTEXT_FLAG_ROBUST_ACCESS_BIT to be set, got '"
886 << eglContextFlagsToString(contextFlagsGL) << "'" << TestLog::EndMessage;
887 isOk = false;
888 }
889 }
890 else if (m_api == EGL_OPENGL_ES_API)
891 {
892 uint8_t robustAccessGL;
893
894 gl.getBooleanv(GL_CONTEXT_ROBUST_ACCESS, &robustAccessGL);
895 GLU_EXPECT_NO_ERROR(gl.getError(), "glGetBooleanv()");
896
897 if (robustAccessGL != GL_TRUE)
898 {
899 log << TestLog::Message << "Invalid GL_CONTEXT_ROBUST_ACCESS returned by glGetBooleanv(). Got '"
900 << robustAccessGL << "' expected GL_TRUE." << TestLog::EndMessage;
901 isOk = false;
902 }
903 }
904 }
905
906 return isOk;
907 }
908
iterate(void)909 TestCase::IterateResult CreateContextExtCase::iterate(void)
910 {
911 if (m_iteration == 0)
912 {
913 logAttribList();
914 checkRequiredExtensions();
915 }
916
917 if (m_iteration < (int)m_configs.size())
918 {
919 const Library &egl = m_eglTestCtx.getLibrary();
920 const EGLConfig config = m_configs[m_iteration];
921 const EGLint surfaceTypes = eglu::getConfigAttribInt(egl, m_display, config, EGL_SURFACE_TYPE);
922 const EGLint configId = eglu::getConfigAttribInt(egl, m_display, config, EGL_CONFIG_ID);
923
924 if ((surfaceTypes & EGL_PBUFFER_BIT) != 0)
925 {
926 tcu::ScopedLogSection section(m_testCtx.getLog(),
927 ("EGLConfig ID: " + de::toString(configId) + " with PBuffer").c_str(),
928 ("EGLConfig ID: " + de::toString(configId)).c_str());
929 const EGLint attribList[] = {EGL_WIDTH, 64, EGL_HEIGHT, 64, EGL_NONE};
930 eglu::UniqueSurface surface(egl, m_display, egl.createPbufferSurface(m_display, config, attribList));
931 EGLU_CHECK_MSG(egl, "eglCreatePbufferSurface");
932
933 executeForSurface(config, *surface);
934 }
935 else if ((surfaceTypes & EGL_WINDOW_BIT) != 0)
936 {
937 const eglu::NativeWindowFactory &factory =
938 eglu::selectNativeWindowFactory(m_eglTestCtx.getNativeDisplayFactory(), m_testCtx.getCommandLine());
939
940 de::UniquePtr<eglu::NativeWindow> window(factory.createWindow(
941 &m_eglTestCtx.getNativeDisplay(), m_display, config, DE_NULL,
942 eglu::WindowParams(256, 256, eglu::parseWindowVisibility(m_testCtx.getCommandLine()))));
943 eglu::UniqueSurface surface(
944 egl, m_display,
945 eglu::createWindowSurface(m_eglTestCtx.getNativeDisplay(), *window, m_display, config, DE_NULL));
946
947 executeForSurface(config, *surface);
948 }
949 else if ((surfaceTypes & EGL_PIXMAP_BIT) != 0)
950 {
951 const eglu::NativePixmapFactory &factory =
952 eglu::selectNativePixmapFactory(m_eglTestCtx.getNativeDisplayFactory(), m_testCtx.getCommandLine());
953
954 de::UniquePtr<eglu::NativePixmap> pixmap(
955 factory.createPixmap(&m_eglTestCtx.getNativeDisplay(), m_display, config, DE_NULL, 256, 256));
956 eglu::UniqueSurface surface(
957 egl, m_display,
958 eglu::createPixmapSurface(m_eglTestCtx.getNativeDisplay(), *pixmap, m_display, config, DE_NULL));
959
960 executeForSurface(config, *surface);
961 }
962 else // No supported surface type
963 TCU_FAIL("Invalid or empty surface type bits");
964
965 m_iteration++;
966 return CONTINUE;
967 }
968 else
969 {
970 if (m_configs.size() == 0)
971 {
972 m_testCtx.getLog() << TestLog::Message << "No supported configs found" << TestLog::EndMessage;
973 m_testCtx.setTestResult(QP_TEST_RESULT_NOT_SUPPORTED, "No supported configs found");
974 }
975 else if (m_isOk)
976 m_testCtx.setTestResult(QP_TEST_RESULT_PASS, "Pass");
977 else
978 m_testCtx.setTestResult(QP_TEST_RESULT_FAIL, "Fail");
979
980 return STOP;
981 }
982 }
983
executeForSurface(EGLConfig config,EGLSurface surface)984 void CreateContextExtCase::executeForSurface(EGLConfig config, EGLSurface surface)
985 {
986 const Library &egl = m_eglTestCtx.getLibrary();
987
988 EGLU_CHECK_CALL(egl, bindAPI(m_api));
989
990 try
991 {
992 glw::Functions gl;
993 eglu::UniqueContext context(egl, m_display,
994 egl.createContext(m_display, config, EGL_NO_CONTEXT, &m_attribList[0]));
995 EGLU_CHECK_MSG(egl, "eglCreateContext");
996
997 EGLU_CHECK_CALL(egl, makeCurrent(m_display, surface, surface, *context));
998
999 m_eglTestCtx.initGLFunctions(&gl, m_glContextType.getAPI());
1000
1001 if (!validateCurrentContext(gl))
1002 m_isOk = false;
1003 }
1004 catch (const eglu::Error &error)
1005 {
1006 if (error.getError() == EGL_BAD_MATCH)
1007 m_testCtx.getLog()
1008 << TestLog::Message
1009 << "Context creation failed with error EGL_BAD_CONTEXT. Config doesn't support api version."
1010 << TestLog::EndMessage;
1011 else if (error.getError() == EGL_BAD_CONFIG)
1012 m_testCtx.getLog()
1013 << TestLog::Message
1014 << "Context creation failed with error EGL_BAD_MATCH. Context attribute compination not supported."
1015 << TestLog::EndMessage;
1016 else
1017 {
1018 m_testCtx.getLog() << TestLog::Message << "Context creation failed with error "
1019 << eglu::getErrorStr(error.getError()) << ". Error is not result of unsupported api etc."
1020 << TestLog::EndMessage;
1021 m_isOk = false;
1022 }
1023 }
1024
1025 EGLU_CHECK_CALL(egl, makeCurrent(m_display, EGL_NO_SURFACE, EGL_NO_SURFACE, EGL_NO_CONTEXT));
1026 }
1027
1028 class CreateContextExtGroup : public TestCaseGroup
1029 {
1030 public:
1031 CreateContextExtGroup(EglTestContext &eglTestCtx, EGLenum api, EGLint apiBit, const EGLint *attribList,
1032 const char *name, const char *description);
1033 virtual ~CreateContextExtGroup(void);
1034
1035 void init(void);
1036
1037 private:
1038 const EGLenum m_api;
1039 const EGLint m_apiBit;
1040 vector<EGLint> m_attribList;
1041 };
1042
CreateContextExtGroup(EglTestContext & eglTestCtx,EGLenum api,EGLint apiBit,const EGLint * attribList,const char * name,const char * description)1043 CreateContextExtGroup::CreateContextExtGroup(EglTestContext &eglTestCtx, EGLenum api, EGLint apiBit,
1044 const EGLint *attribList, const char *name, const char *description)
1045 : TestCaseGroup(eglTestCtx, name, description)
1046 , m_api(api)
1047 , m_apiBit(apiBit)
1048 , m_attribList(attribList, attribList + getAttribListLength(attribList))
1049 {
1050 }
1051
~CreateContextExtGroup(void)1052 CreateContextExtGroup::~CreateContextExtGroup(void)
1053 {
1054 }
1055
1056 template <int Red, int Green, int Blue, int Alpha>
colorBits(const eglu::CandidateConfig & c)1057 static bool colorBits(const eglu::CandidateConfig &c)
1058 {
1059 return c.redSize() == Red && c.greenSize() == Green && c.blueSize() == Blue && c.alphaSize() == Alpha;
1060 }
1061
hasDepth(const eglu::CandidateConfig & c)1062 static bool hasDepth(const eglu::CandidateConfig &c)
1063 {
1064 return c.depthSize() > 0;
1065 }
noDepth(const eglu::CandidateConfig & c)1066 static bool noDepth(const eglu::CandidateConfig &c)
1067 {
1068 return c.depthSize() == 0;
1069 }
hasStencil(const eglu::CandidateConfig & c)1070 static bool hasStencil(const eglu::CandidateConfig &c)
1071 {
1072 return c.stencilSize() > 0;
1073 }
noStencil(const eglu::CandidateConfig & c)1074 static bool noStencil(const eglu::CandidateConfig &c)
1075 {
1076 return c.stencilSize() == 0;
1077 }
1078
1079 template <uint32_t Type>
renderable(const eglu::CandidateConfig & c)1080 static bool renderable(const eglu::CandidateConfig &c)
1081 {
1082 return (c.renderableType() & Type) == Type;
1083 }
1084
getRenderableFilter(uint32_t bits)1085 static eglu::ConfigFilter getRenderableFilter(uint32_t bits)
1086 {
1087 switch (bits)
1088 {
1089 case EGL_OPENGL_ES2_BIT:
1090 return renderable<EGL_OPENGL_ES2_BIT>;
1091 case EGL_OPENGL_ES3_BIT:
1092 return renderable<EGL_OPENGL_ES3_BIT>;
1093 case EGL_OPENGL_BIT:
1094 return renderable<EGL_OPENGL_BIT>;
1095 default:
1096 DE_ASSERT(false);
1097 return renderable<0>;
1098 }
1099 }
1100
init(void)1101 void CreateContextExtGroup::init(void)
1102 {
1103 const struct
1104 {
1105 const char *name;
1106 const char *description;
1107
1108 eglu::ConfigFilter colorFilter;
1109 eglu::ConfigFilter depthFilter;
1110 eglu::ConfigFilter stencilFilter;
1111 } groups[] = {
1112 {"rgb565_no_depth_no_stencil", "RGB565 configs without depth or stencil", colorBits<5, 6, 5, 0>, noDepth,
1113 noStencil},
1114 {"rgb565_no_depth_stencil", "RGB565 configs with stencil and no depth", colorBits<5, 6, 5, 0>, noDepth,
1115 hasStencil},
1116 {"rgb565_depth_no_stencil", "RGB565 configs with depth and no stencil", colorBits<5, 6, 5, 0>, hasDepth,
1117 noStencil},
1118 {"rgb565_depth_stencil", "RGB565 configs with depth and stencil", colorBits<5, 6, 5, 0>, hasDepth, hasStencil},
1119
1120 {"rgb888_no_depth_no_stencil", "RGB888 configs without depth or stencil", colorBits<8, 8, 8, 0>, noDepth,
1121 noStencil},
1122 {"rgb888_no_depth_stencil", "RGB888 configs with stencil and no depth", colorBits<8, 8, 8, 0>, noDepth,
1123 hasStencil},
1124 {"rgb888_depth_no_stencil", "RGB888 configs with depth and no stencil", colorBits<8, 8, 8, 0>, hasDepth,
1125 noStencil},
1126 {"rgb888_depth_stencil", "RGB888 configs with depth and stencil", colorBits<8, 8, 8, 0>, hasDepth, hasStencil},
1127
1128 {"rgba4444_no_depth_no_stencil", "RGBA4444 configs without depth or stencil", colorBits<4, 4, 4, 4>, noDepth,
1129 noStencil},
1130 {"rgba4444_no_depth_stencil", "RGBA4444 configs with stencil and no depth", colorBits<4, 4, 4, 4>, noDepth,
1131 hasStencil},
1132 {"rgba4444_depth_no_stencil", "RGBA4444 configs with depth and no stencil", colorBits<4, 4, 4, 4>, hasDepth,
1133 noStencil},
1134 {"rgba4444_depth_stencil", "RGBA4444 configs with depth and stencil", colorBits<4, 4, 4, 4>, hasDepth,
1135 hasStencil},
1136
1137 {"rgba5551_no_depth_no_stencil", "RGBA5551 configs without depth or stencil", colorBits<5, 5, 5, 1>, noDepth,
1138 noStencil},
1139 {"rgba5551_no_depth_stencil", "RGBA5551 configs with stencil and no depth", colorBits<5, 5, 5, 1>, noDepth,
1140 hasStencil},
1141 {"rgba5551_depth_no_stencil", "RGBA5551 configs with depth and no stencil", colorBits<5, 5, 5, 1>, hasDepth,
1142 noStencil},
1143 {"rgba5551_depth_stencil", "RGBA5551 configs with depth and stencil", colorBits<5, 5, 5, 1>, hasDepth,
1144 hasStencil},
1145
1146 {"rgba8888_no_depth_no_stencil", "RGBA8888 configs without depth or stencil", colorBits<8, 8, 8, 8>, noDepth,
1147 noStencil},
1148 {"rgba8888_no_depth_stencil", "RGBA8888 configs with stencil and no depth", colorBits<8, 8, 8, 8>, noDepth,
1149 hasStencil},
1150 {"rgba8888_depth_no_stencil", "RGBA8888 configs with depth and no stencil", colorBits<8, 8, 8, 8>, hasDepth,
1151 noStencil},
1152 {"rgba8888_depth_stencil", "RGBA8888 configs with depth and stencil", colorBits<8, 8, 8, 8>, hasDepth,
1153 hasStencil}};
1154
1155 for (int groupNdx = 0; groupNdx < DE_LENGTH_OF_ARRAY(groups); groupNdx++)
1156 {
1157 eglu::FilterList filter;
1158
1159 filter << groups[groupNdx].colorFilter << groups[groupNdx].depthFilter << groups[groupNdx].stencilFilter
1160 << getRenderableFilter(m_apiBit);
1161
1162 addChild(new CreateContextExtCase(m_eglTestCtx, m_api, &(m_attribList[0]), filter, groups[groupNdx].name,
1163 groups[groupNdx].description));
1164 }
1165 // \todo [mika] Add other group
1166 }
1167
1168 } // namespace
1169
CreateContextExtTests(EglTestContext & eglTestCtx)1170 CreateContextExtTests::CreateContextExtTests(EglTestContext &eglTestCtx)
1171 : TestCaseGroup(eglTestCtx, "create_context_ext", "EGL_KHR_create_context tests.")
1172 {
1173 }
1174
~CreateContextExtTests(void)1175 CreateContextExtTests::~CreateContextExtTests(void)
1176 {
1177 }
1178
init(void)1179 void CreateContextExtTests::init(void)
1180 {
1181 const size_t maxAttributeCount = 10;
1182 const struct
1183 {
1184 const char *name;
1185 const char *description;
1186 EGLenum api;
1187 EGLint apiBit;
1188 EGLint attribList[maxAttributeCount];
1189 } groupList[] = {
1190 #if 0
1191 // \todo [mika] Not supported by glw
1192 // OpenGL ES 1.x
1193 { "gles_10", "Create OpenGL ES 1.0 context", EGL_OPENGL_ES_API, EGL_OPENGL_ES_BIT,
1194 { EGL_CONTEXT_MAJOR_VERSION_KHR, 1, EGL_CONTEXT_MINOR_VERSION_KHR, 0, EGL_NONE} },
1195 { "gles_11", "Create OpenGL ES 1.1 context", EGL_OPENGL_ES_API, EGL_OPENGL_ES_BIT,
1196 { EGL_CONTEXT_MAJOR_VERSION_KHR, 1, EGL_CONTEXT_MINOR_VERSION_KHR, 1, EGL_NONE } },
1197 #endif
1198 // OpenGL ES 2.x
1199 {"gles_20",
1200 "Create OpenGL ES 2.0 context",
1201 EGL_OPENGL_ES_API,
1202 EGL_OPENGL_ES2_BIT,
1203 {EGL_CONTEXT_MAJOR_VERSION_KHR, 2, EGL_CONTEXT_MINOR_VERSION_KHR, 0, EGL_NONE}},
1204 // OpenGL ES 3.x
1205 {"gles_30",
1206 "Create OpenGL ES 3.0 context",
1207 EGL_OPENGL_ES_API,
1208 EGL_OPENGL_ES3_BIT_KHR,
1209 {EGL_CONTEXT_MAJOR_VERSION_KHR, 3, EGL_CONTEXT_MINOR_VERSION_KHR, 0, EGL_NONE}},
1210 #if 0
1211 // \todo [mika] Not supported by glw
1212 // \note [mika] Should we really test 1.x?
1213 { "gl_10", "Create OpenGL 1.0 context", EGL_OPENGL_API, EGL_OPENGL_BIT,
1214 { EGL_CONTEXT_MAJOR_VERSION_KHR, 1, EGL_CONTEXT_MINOR_VERSION_KHR, 0, EGL_NONE} },
1215 { "gl_11", "Create OpenGL 1.1 context", EGL_OPENGL_API, EGL_OPENGL_BIT,
1216 { EGL_CONTEXT_MAJOR_VERSION_KHR, 1, EGL_CONTEXT_MINOR_VERSION_KHR, 1, EGL_NONE } },
1217
1218 // OpenGL 2.x
1219 { "gl_20", "Create OpenGL 2.0 context", EGL_OPENGL_API, EGL_OPENGL_BIT,
1220 { EGL_CONTEXT_MAJOR_VERSION_KHR, 2, EGL_CONTEXT_MINOR_VERSION_KHR, 0, EGL_NONE } },
1221 { "gl_21", "Create OpenGL 2.1 context", EGL_OPENGL_API, EGL_OPENGL_BIT,
1222 { EGL_CONTEXT_MAJOR_VERSION_KHR, 2, EGL_CONTEXT_MINOR_VERSION_KHR, 1, EGL_NONE } },
1223 #endif
1224 // OpenGL 3.x
1225 {"gl_30",
1226 "Create OpenGL 3.0 context",
1227 EGL_OPENGL_API,
1228 EGL_OPENGL_BIT,
1229 {EGL_CONTEXT_MAJOR_VERSION_KHR, 3, EGL_CONTEXT_MINOR_VERSION_KHR, 0, EGL_NONE}},
1230 {"robust_gl_30",
1231 "Create robust OpenGL 3.0 context",
1232 EGL_OPENGL_API,
1233 EGL_OPENGL_BIT,
1234 {EGL_CONTEXT_MAJOR_VERSION_KHR, 3, EGL_CONTEXT_MINOR_VERSION_KHR, 0, EGL_CONTEXT_FLAGS_KHR,
1235 EGL_CONTEXT_OPENGL_ROBUST_ACCESS_BIT_KHR, EGL_NONE}},
1236 {"gl_31",
1237 "Create OpenGL 3.1 context",
1238 EGL_OPENGL_API,
1239 EGL_OPENGL_BIT,
1240 {EGL_CONTEXT_MAJOR_VERSION_KHR, 3, EGL_CONTEXT_MINOR_VERSION_KHR, 1, EGL_NONE}},
1241 {"robust_gl_31",
1242 "Create robust OpenGL 3.1 context",
1243 EGL_OPENGL_API,
1244 EGL_OPENGL_BIT,
1245 {EGL_CONTEXT_MAJOR_VERSION_KHR, 3, EGL_CONTEXT_MINOR_VERSION_KHR, 1, EGL_CONTEXT_FLAGS_KHR,
1246 EGL_CONTEXT_OPENGL_ROBUST_ACCESS_BIT_KHR, EGL_NONE}},
1247 {"gl_32",
1248 "Create OpenGL 3.2 context",
1249 EGL_OPENGL_API,
1250 EGL_OPENGL_BIT,
1251 {EGL_CONTEXT_MAJOR_VERSION_KHR, 3, EGL_CONTEXT_MINOR_VERSION_KHR, 2, EGL_NONE}},
1252 {"robust_gl_32",
1253 "Create robust OpenGL 3.2 context",
1254 EGL_OPENGL_API,
1255 EGL_OPENGL_BIT,
1256 {EGL_CONTEXT_MAJOR_VERSION_KHR, 3, EGL_CONTEXT_MINOR_VERSION_KHR, 2, EGL_CONTEXT_FLAGS_KHR,
1257 EGL_CONTEXT_OPENGL_ROBUST_ACCESS_BIT_KHR, EGL_NONE}},
1258 {"gl_33",
1259 "Create OpenGL 3.3 context",
1260 EGL_OPENGL_API,
1261 EGL_OPENGL_BIT,
1262 {EGL_CONTEXT_MAJOR_VERSION_KHR, 3, EGL_CONTEXT_MINOR_VERSION_KHR, 3, EGL_NONE}},
1263 {"robust_gl_33",
1264 "Create robust OpenGL 3.3 context",
1265 EGL_OPENGL_API,
1266 EGL_OPENGL_BIT,
1267 {EGL_CONTEXT_MAJOR_VERSION_KHR, 3, EGL_CONTEXT_MINOR_VERSION_KHR, 3, EGL_CONTEXT_FLAGS_KHR,
1268 EGL_CONTEXT_OPENGL_ROBUST_ACCESS_BIT_KHR, EGL_NONE}},
1269
1270 // OpenGL 4.x
1271 {"gl_40",
1272 "Create OpenGL 4.0 context",
1273 EGL_OPENGL_API,
1274 EGL_OPENGL_BIT,
1275 {EGL_CONTEXT_MAJOR_VERSION_KHR, 4, EGL_CONTEXT_MINOR_VERSION_KHR, 0, EGL_NONE}},
1276 {"robust_gl_40",
1277 "Create robust OpenGL 4.0 context",
1278 EGL_OPENGL_API,
1279 EGL_OPENGL_BIT,
1280 {EGL_CONTEXT_MAJOR_VERSION_KHR, 4, EGL_CONTEXT_MINOR_VERSION_KHR, 0, EGL_CONTEXT_FLAGS_KHR,
1281 EGL_CONTEXT_OPENGL_ROBUST_ACCESS_BIT_KHR, EGL_NONE}},
1282 {"gl_41",
1283 "Create OpenGL 4.1 context",
1284 EGL_OPENGL_API,
1285 EGL_OPENGL_BIT,
1286 {EGL_CONTEXT_MAJOR_VERSION_KHR, 4, EGL_CONTEXT_MINOR_VERSION_KHR, 1, EGL_NONE}},
1287 {"robust_gl_41",
1288 "Create robust OpenGL 4.1 context",
1289 EGL_OPENGL_API,
1290 EGL_OPENGL_BIT,
1291 {EGL_CONTEXT_MAJOR_VERSION_KHR, 4, EGL_CONTEXT_MINOR_VERSION_KHR, 1, EGL_CONTEXT_FLAGS_KHR,
1292 EGL_CONTEXT_OPENGL_ROBUST_ACCESS_BIT_KHR, EGL_NONE}},
1293 {"gl_42",
1294 "Create OpenGL 4.2 context",
1295 EGL_OPENGL_API,
1296 EGL_OPENGL_BIT,
1297 {EGL_CONTEXT_MAJOR_VERSION_KHR, 4, EGL_CONTEXT_MINOR_VERSION_KHR, 2, EGL_NONE}},
1298 {"robust_gl_42",
1299 "Create robust OpenGL 4.2 context",
1300 EGL_OPENGL_API,
1301 EGL_OPENGL_BIT,
1302 {EGL_CONTEXT_MAJOR_VERSION_KHR, 4, EGL_CONTEXT_MINOR_VERSION_KHR, 2, EGL_CONTEXT_FLAGS_KHR,
1303 EGL_CONTEXT_OPENGL_ROBUST_ACCESS_BIT_KHR, EGL_NONE}},
1304 {"gl_43",
1305 "Create OpenGL 4.3 context",
1306 EGL_OPENGL_API,
1307 EGL_OPENGL_BIT,
1308 {EGL_CONTEXT_MAJOR_VERSION_KHR, 4, EGL_CONTEXT_MINOR_VERSION_KHR, 3, EGL_NONE}},
1309 {"robust_gl_43",
1310 "Create robust OpenGL 4.3 context",
1311 EGL_OPENGL_API,
1312 EGL_OPENGL_BIT,
1313 {EGL_CONTEXT_MAJOR_VERSION_KHR, 4, EGL_CONTEXT_MINOR_VERSION_KHR, 3, EGL_CONTEXT_FLAGS_KHR,
1314 EGL_CONTEXT_OPENGL_ROBUST_ACCESS_BIT_KHR, EGL_NONE}},
1315
1316 // Robust contexts with EGL_EXT_create_context_robustness
1317 {"robust_gles_2_ext",
1318 "Create robust OpenGL ES 2.0 context with EGL_EXT_create_context_robustness.",
1319 EGL_OPENGL_ES_API,
1320 EGL_OPENGL_ES2_BIT,
1321 {EGL_CONTEXT_CLIENT_VERSION, 2, EGL_CONTEXT_OPENGL_ROBUST_ACCESS_EXT, EGL_TRUE, EGL_NONE}},
1322 {"robust_gles_3_ext",
1323 "Create robust OpenGL ES 3.0 context with EGL_EXT_create_context_robustness.",
1324 EGL_OPENGL_ES_API,
1325 EGL_OPENGL_ES3_BIT_KHR,
1326 {EGL_CONTEXT_CLIENT_VERSION, 3, EGL_CONTEXT_OPENGL_ROBUST_ACCESS_EXT, EGL_TRUE, EGL_NONE}},
1327 #if 0
1328 // glu/glw doesn't support any version of OpenGL and EGL doesn't allow use of EGL_CONTEXT_CLIENT_VERSION with OpenGL and doesn't define which OpenGL version should be returned.
1329 { "robust_gl_ext", "Create robust OpenGL context with EGL_EXT_create_context_robustness.", EGL_OPENGL_API, EGL_OPENGL_BIT,
1330 { EGL_CONTEXT_OPENGL_ROBUST_ACCESS_EXT, EGL_TRUE, EGL_NONE } }
1331 #endif
1332 };
1333
1334 for (int groupNdx = 0; groupNdx < DE_LENGTH_OF_ARRAY(groupList); groupNdx++)
1335 addChild(new CreateContextExtGroup(m_eglTestCtx, groupList[groupNdx].api, groupList[groupNdx].apiBit,
1336 groupList[groupNdx].attribList, groupList[groupNdx].name,
1337 groupList[groupNdx].description));
1338 }
1339
1340 } // namespace egl
1341 } // namespace deqp
1342