Check for GLES 3.0 Context Before Using 3.0 Functionality

The additional testFramebufferColorEncoding() testing requires a GLES
3.0 context, but only a 2.0 context is requested.   This change will
continue to execute those tests, but only after verifying a 3.0 context
was returned.

Affects:
dEQP-EGL.functional.wide_color.window_fp16_colorspace_p3_passthrough
dEQP-EGL.functional.wide_color.pbuffer_fp16_colorspace_p3_passthrough
dEQP-EGL.functional.wide_color.window_1010102_colorspace_p3_passthrough
dEQP-EGL.functional.wide_color.pbuffer_1010102_colorspace_p3_passthrough
dEQP-EGL.functional.wide_color.window_8888_colorspace_p3_passthrough
dEQP-EGL.functional.wide_color.pbuffer_8888_colorspace_p3_passthrough
dEQP-EGL.functional.wide_color.window_888_colorspace_p3_passthrough
dEQP-EGL.functional.wide_color.pbuffer_888_colorspace_p3_passthrough

Components: EGL

Bug: 1704
Google Bug: 124910588

Change-Id: Ifc81308c569923d4d777cd5c5329568b579f1ac1
diff --git a/modules/egl/teglWideColorTests.cpp b/modules/egl/teglWideColorTests.cpp
index 16be114..c053789 100644
--- a/modules/egl/teglWideColorTests.cpp
+++ b/modules/egl/teglWideColorTests.cpp
@@ -1194,7 +1194,15 @@
 
 				reference += it->increment;
 
-				testFramebufferColorEncoding();
+				// Detect compatible GLES context by querying GL_MAJOR_VERSION.
+				// This query does not exist on GLES2 so succeeding query implies GLES3+ context.
+				glw::GLint majorVersion = 0;
+				m_gl.getIntegerv(GL_MAJOR_VERSION, &majorVersion);
+				if (m_gl.getError() == GL_NO_ERROR)
+				{
+					// This device is ES3 compatible, so do some additional testing
+					testFramebufferColorEncoding();
+				}
 			}
 
 			EGLU_CHECK_CALL(egl, swapBuffers(m_eglDisplay, surface));