Add CTS_KHR_no_error test implementation
[platform/upstream/VK-GL-CTS.git] / framework / egl / egluGLUtil.cpp
index 39ca8a1..cca5681 100644 (file)
@@ -82,9 +82,10 @@ EGLContext createGLContext (const Library&                                   egl,
                                                        const glu::ContextType&                 contextType,
                                                        glu::ResetNotificationStrategy  resetNotificationStrategy)
 {
-       const bool                      khrCreateContextSupported       = hasExtension(egl, display, "EGL_KHR_create_context");
-       EGLContext                      context                                         = EGL_NO_CONTEXT;
-       EGLenum                         api                                                     = EGL_NONE;
+       const bool                      khrCreateContextSupported                       = hasExtension(egl, display, "EGL_KHR_create_context");
+       const bool                      khrCreateContextNoErrorSupported        = hasExtension(egl, display, "EGL_KHR_create_context_no_error");
+       EGLContext                      context                                                         = EGL_NO_CONTEXT;
+       EGLenum                         api                                                                     = EGL_NONE;
        vector<EGLint>          attribList;
 
        if (glu::isContextTypeES(contextType))
@@ -149,6 +150,17 @@ EGLContext createGLContext (const Library&                                 egl,
                                flags |= EGL_CONTEXT_OPENGL_ROBUST_ACCESS_BIT_KHR;
                }
 
+               if ((contextType.getFlags() & glu::CONTEXT_NO_ERROR) != 0)
+               {
+                       if (khrCreateContextNoErrorSupported)
+                       {
+                               attribList.push_back(EGL_CONTEXT_OPENGL_NO_ERROR_KHR);
+                               attribList.push_back(EGL_TRUE);
+                       }
+                       else
+                               throw tcu::NotSupportedError("EGL_KHR_create_context_no_error is required for creating no-error contexts");
+               }
+
                if ((contextType.getFlags() & glu::CONTEXT_FORWARD_COMPATIBLE) != 0)
                {
                        if (!glu::isContextTypeGLCore(contextType))
@@ -162,10 +174,12 @@ EGLContext createGLContext (const Library&                                        egl,
 
                if (resetNotificationStrategy != glu::RESET_NOTIFICATION_STRATEGY_NOT_SPECIFIED)
                {
-                       if (glu::isContextTypeES(contextType))
-                               TCU_THROW(InternalError, "Specifying reset notification strategy is not allowed when creating OpenGL ES contexts");
-
-                       attribList.push_back(EGL_CONTEXT_OPENGL_RESET_NOTIFICATION_STRATEGY_KHR);
+                       if (getVersion(egl, display) >= Version(1, 5) || glu::isContextTypeGLCore(contextType) || glu::isContextTypeGLCompatibility(contextType))
+                               attribList.push_back(EGL_CONTEXT_OPENGL_RESET_NOTIFICATION_STRATEGY_KHR);
+                       else if (hasExtension(egl, display, "EGL_EXT_create_context_robustness"))
+                               attribList.push_back(EGL_CONTEXT_OPENGL_RESET_NOTIFICATION_STRATEGY_EXT);
+                       else
+                               TCU_THROW(NotSupportedError, "EGL 1.5 or EGL_EXT_create_context_robustness is required for creating robust context");
 
                        if (resetNotificationStrategy == glu::RESET_NOTIFICATION_STRATEGY_NO_RESET_NOTIFICATION)
                                attribList.push_back(EGL_NO_RESET_NOTIFICATION_KHR);