Merge "Add tests for GL_EXT_copy_image."
diff --git a/Android.mk b/Android.mk
index 5b9865c..94329ff 100644
--- a/Android.mk
+++ b/Android.mk
@@ -49,6 +49,7 @@
 	framework/common/tcuRenderTarget.cpp \
 	framework/common/tcuResource.cpp \
 	framework/common/tcuRGBA.cpp \
+	framework/common/tcuEither.cpp \
 	framework/common/tcuStringTemplate.cpp \
 	framework/common/tcuSurface.cpp \
 	framework/common/tcuTestCase.cpp \
@@ -64,6 +65,7 @@
 	framework/common/tcuTexVerifierUtil.cpp \
 	framework/common/tcuThreadUtil.cpp \
 	framework/common/tcuSeedBuilder.cpp \
+	framework/common/tcuMaybe.cpp \
 	framework/delibs/debase/deDefs.c \
 	framework/delibs/debase/deFloat16.c \
 	framework/delibs/debase/deInt32.c \
@@ -131,11 +133,9 @@
 	framework/egl/egluConfigFilter.cpp \
 	framework/egl/egluConfigInfo.cpp \
 	framework/egl/egluDefs.cpp \
-	framework/egl/egluExtensions.cpp \
 	framework/egl/egluGLContextFactory.cpp \
 	framework/egl/egluGLFunctionLoader.cpp \
 	framework/egl/egluGLUtil.cpp \
-	framework/egl/egluHeaderWrapper.cpp \
 	framework/egl/egluNativeDisplay.cpp \
 	framework/egl/egluNativePixmap.cpp \
 	framework/egl/egluNativeWindow.cpp \
@@ -144,7 +144,9 @@
 	framework/egl/egluStrUtil.cpp \
 	framework/egl/egluUnique.cpp \
 	framework/egl/egluUtil.cpp \
-	framework/egl/tcuEgl.cpp \
+	framework/egl/wrapper/eglwDefs.cpp \
+	framework/egl/wrapper/eglwFunctions.cpp \
+	framework/egl/wrapper/eglwLibrary.cpp \
 	framework/opengl/gluCallLogWrapper.cpp \
 	framework/opengl/gluContextFactory.cpp \
 	framework/opengl/gluContextInfo.cpp \
@@ -186,6 +188,7 @@
 	framework/platform/android/tcuAndroidMain.cpp \
 	framework/platform/android/tcuAndroidNativeActivity.cpp \
 	framework/platform/android/tcuAndroidPlatform.cpp \
+	framework/platform/android/tcuAndroidPlatformCapabilityQueryJNI.cpp \
 	framework/platform/android/tcuAndroidRenderActivity.cpp \
 	framework/platform/android/tcuAndroidTestActivity.cpp \
 	framework/platform/android/tcuAndroidUtil.cpp \
@@ -505,6 +508,7 @@
 	$(deqp_dir)/framework/qphelper \
 	$(deqp_dir)/framework/platform/android \
 	$(deqp_dir)/framework/egl \
+	$(deqp_dir)/framework/egl/wrapper \
 	$(deqp_dir)/framework/opengl \
 	$(deqp_dir)/framework/opengl/wrapper \
 	$(deqp_dir)/framework/referencerenderer \
diff --git a/CMakeLists.txt b/CMakeLists.txt
index 5265aed..4df4f6a 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -2,16 +2,13 @@
 
 cmake_minimum_required(VERSION 2.6)
 
-# Paths to dependencies
-set(DELIBS_DIR "framework/delibs" CACHE STRING "Path to delibs (../delibs).")
-
 # dEQP Target.
 set(DEQP_TARGET "default" CACHE STRING "dEQP Target (default, android...)")
 
 project(dEQP-Core-${DEQP_TARGET})
 
-include(${DELIBS_DIR}/cmake/Defs.cmake NO_POLICY_SCOPE)
-include(${DELIBS_DIR}/cmake/CFlags.cmake)
+include(framework/delibs/cmake/Defs.cmake NO_POLICY_SCOPE)
+include(framework/delibs/cmake/CFlags.cmake)
 
 add_definitions(-DDE_ASSERT_FAILURE_CALLBACK)
 
@@ -33,9 +30,6 @@
 set(DEQP_SUPPORT_EGL		OFF)			# Is EGL supported
 set(DEQP_EGL_LIBRARIES		)				# EGL libraries
 
-set(DEQP_SUPPORT_OPENCL		OFF)			# Is OpenCL supported
-set(DEQP_OPENCL_LIBRARIES	)				# OpenCL libraries
-
 set(DEQP_PLATFORM_LIBRARIES	)				# Other platform libraries
 
 set(DEQP_SUPPORT_OPENGL		OFF)			# Is OpenGL supported on platform
@@ -45,12 +39,12 @@
 
 # Delibs include directories
 include_directories(
-	${DELIBS_DIR}/debase
-	${DELIBS_DIR}/decpp
-	${DELIBS_DIR}/depool
-	${DELIBS_DIR}/dethread
-	${DELIBS_DIR}/deutil
-	${DELIBS_DIR}/destream
+	framework/delibs/debase
+	framework/delibs/decpp
+	framework/delibs/depool
+	framework/delibs/dethread
+	framework/delibs/deutil
+	framework/delibs/destream
 	)
 
 # Include target-specific definitions
@@ -80,21 +74,6 @@
 
 include_directories(${PNG_INCLUDE_PATH})
 
-# \todo [2013-04-14 pyry] Remove once we've got dynamic loading of GL libraries figured out
-if (DEQP_RUNTIME_LINK)
-	include_directories(wrappers/dynlib/inc)
-
-	if (DEQP_SUPPORT_GLES3)
-		set(DEQP_GLES2_LIBRARIES GLESv3)
-		set(DEQP_GLES3_LIBRARIES GLESv3)
-	else ()
-		set(DEQP_GLES2_LIBRARIES GLESv2)
-	endif ()
-
-	set(DEQP_EGL_LIBRARIES EGL)
-	add_definitions(-DKHRONOS_STATIC_LIB)
-endif ()
-
 message(STATUS "DEQP_TARGET_NAME        = ${DEQP_TARGET_NAME}")
 message(STATUS "DEQP_SUPPORT_GLES1      = ${DEQP_SUPPORT_GLES1}")
 message(STATUS "DEQP_GLES1_LIBRARIES    = ${DEQP_GLES1_LIBRARIES}")
@@ -106,8 +85,6 @@
 message(STATUS "DEQP_VG_LIBRARIES       = ${DEQP_VG_LIBRARIES}")
 message(STATUS "DEQP_SUPPORT_EGL        = ${DEQP_SUPPORT_EGL}")
 message(STATUS "DEQP_EGL_LIBRARIES      = ${DEQP_EGL_LIBRARIES}")
-message(STATUS "DEQP_SUPPORT_OPENCL     = ${DEQP_SUPPORT_OPENCL}")
-message(STATUS "DEQP_OPENCL_LIBRARIES   = ${DEQP_OPENCL_LIBRARIES}")
 message(STATUS "DEQP_SUPPORT_OPENGL     = ${DEQP_SUPPORT_OPENGL}")
 message(STATUS "DEQP_PLATFORM_LIBRARIES = ${DEQP_PLATFORM_LIBRARIES}")
 
@@ -134,10 +111,6 @@
 	add_definitions(-DDEQP_SUPPORT_EGL=1)
 endif ()
 
-if (DEQP_SUPPORT_OPENCL)
-	add_definitions(-DDEQP_SUPPORT_OPENCL=1)
-endif ()
-
 if (DEQP_SUPPORT_OPENGL)
 	add_definitions(-DDEQP_SUPPORT_OPENGL=1)
 endif ()
@@ -168,11 +141,7 @@
 endif ()
 
 if (DEQP_SUPPORT_EGL AND NOT DEFINED DEQP_EGL_LIBRARIES)
-	message(FATAL_ERROR "Run-time loading of EGL is not supported (DEQP_EGL_LIBRARIES is not set)")
-endif ()
-
-if (DEQP_SUPPORT_OPENCL AND NOT DEFINED DEQP_OPENCL_LIBRARIES)
-	message(FATAL_ERROR "Run-time loading of OpenCL is not supported (DEQP_OPENCL_LIBRARIES is not set)")
+	add_definitions(-DDEQP_EGL_RUNTIME_LOAD=1)
 endif ()
 
 # OpenGL is always loaded on run-time
@@ -186,17 +155,12 @@
 endif ()
 
 # delibs projects
-add_subdirectory(${DELIBS_DIR}/debase		debase)
-add_subdirectory(${DELIBS_DIR}/depool		depool)
-add_subdirectory(${DELIBS_DIR}/dethread		dethread)
-add_subdirectory(${DELIBS_DIR}/destream		destream)
-add_subdirectory(${DELIBS_DIR}/deutil		deutil)
-add_subdirectory(${DELIBS_DIR}/decpp		decpp)
-
-# \todo [2013-04-14 pyry] Remove once we've got dynamic loading of GL libraries figured out
-if (DEQP_RUNTIME_LINK)
-	add_subdirectory(wrappers/dynlib)
-endif ()
+add_subdirectory(framework/delibs/debase)
+add_subdirectory(framework/delibs/depool)
+add_subdirectory(framework/delibs/dethread)
+add_subdirectory(framework/delibs/destream)
+add_subdirectory(framework/delibs/deutil)
+add_subdirectory(framework/delibs/decpp)
 
 # ExecServer
 add_subdirectory(execserver)
@@ -206,12 +170,6 @@
 	add_subdirectory(executor)
 endif ()
 
-if (DEQP_SUPPORT_OPENCL)
-	# We need to support all older CL1.x versions
-	add_definitions(-DCL_USE_DEPRECATED_OPENCL_1_0_APIS)
-	add_definitions(-DCL_USE_DEPRECATED_OPENCL_1_1_APIS)
-endif ()
-
 # Test framework include directories
 include_directories(
 	framework/common
@@ -221,12 +179,10 @@
 	framework/referencerenderer
 	framework/opengl/simplereference
 	framework/randomshaders
+	framework/egl
+	framework/egl/wrapper
 	)
 
-if (DEQP_SUPPORT_EGL)
-	include_directories(framework/egl)
-endif ()
-
 if (DE_OS_IS_ANDROID OR DE_OS_IS_IOS)
 	# On Android deqp modules are compiled as libraries and linked into final .so
 	set(DEQP_MODULE_LIBRARIES )
@@ -318,7 +274,7 @@
 if (DE_OS_IS_ANDROID)
 	include_directories(executor)
 
-	add_library(deqp SHARED framework/platform/android/tcuAndroidMain.cpp framework/platform/android/tcuAndroidJNI.cpp framework/platform/android/tcuTestLogParserJNI.cpp ${DEQP_MODULE_ENTRY_POINTS})
+	add_library(deqp SHARED framework/platform/android/tcuAndroidMain.cpp framework/platform/android/tcuAndroidJNI.cpp framework/platform/android/tcuAndroidPlatformCapabilityQueryJNI.cpp framework/platform/android/tcuTestLogParserJNI.cpp ${DEQP_MODULE_ENTRY_POINTS})
 	target_link_libraries(deqp tcutil-platform xecore ${DEQP_MODULE_LIBRARIES})
 
 elseif (DE_OS_IS_IOS)
diff --git a/android/package/AndroidManifest.xml b/android/package/AndroidManifest.xml
index 4da88a1..4bc0d4b 100644
--- a/android/package/AndroidManifest.xml
+++ b/android/package/AndroidManifest.xml
@@ -50,4 +50,7 @@
 	<instrumentation android:label="dEQP-Instrumentation"
 					 android:name="com.drawelements.deqp.testercore.DeqpInstrumentation"
 					 android:targetPackage="com.drawelements.deqp" />
+	<instrumentation android:label="dEQP-PlatformCapabilityQueryInstrumentation"
+					 android:name="com.drawelements.deqp.platformutil.DeqpPlatformCapabilityQueryInstrumentation"
+					 android:targetPackage="com.drawelements.deqp" />
 </manifest>
diff --git a/android/package/src/com/drawelements/deqp/platformutil/DeqpPlatformCapabilityQueryInstrumentation.java b/android/package/src/com/drawelements/deqp/platformutil/DeqpPlatformCapabilityQueryInstrumentation.java
new file mode 100644
index 0000000..04e3c1c
--- /dev/null
+++ b/android/package/src/com/drawelements/deqp/platformutil/DeqpPlatformCapabilityQueryInstrumentation.java
@@ -0,0 +1,108 @@
+/*-------------------------------------------------------------------------
+ * drawElements Quality Program Platform Utilites
+ * ----------------------------------------------
+ *
+ * Copyright 2015 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ *//*!
+ * \file
+ * \brief dEQP platform capability query instrumentation
+ *//*--------------------------------------------------------------------*/
+
+package com.drawelements.deqp.platformutil;
+
+import android.app.Instrumentation;
+
+import android.os.Bundle;
+
+public class DeqpPlatformCapabilityQueryInstrumentation extends Instrumentation
+{
+	static
+	{
+		System.loadLibrary("deqp");
+	}
+
+	private static final String	LOG_TAG							= "dEQP/PlatformCapabilityQueryInstrumentation";
+	private static final int	CONFIGQUERYRESULT_SUPPORTED		= 0;
+	private static final int	CONFIGQUERYRESULT_NOT_SUPPORTED	= 1;
+	private static final int	CONFIGQUERYRESULT_GENERIC_ERROR	= -1;
+
+	private String				m_cmdLine;
+	private String				m_queryType;
+
+	@Override
+	public void onCreate (Bundle arguments) {
+		super.onCreate(arguments);
+		start();
+
+		m_queryType = arguments.getString("deqpQueryType");
+		m_cmdLine = arguments.getString("deqpCmdLine");
+	}
+
+	@Override
+	public void onStart () {
+		super.onStart();
+
+		Bundle resultInfo;
+		int resultCode = 0;
+
+		try
+		{
+			if ("renderConfigSupported".equals(m_queryType))
+				resultInfo = doRenderConfigSupportedQuery();
+			else
+			{
+				resultInfo = new Bundle();
+				resultInfo.putString("Error", "unknown query");
+				resultCode = 2;
+			}
+		}
+		catch (Exception e)
+		{
+			resultInfo = new Bundle();
+			resultInfo.putString("Error", e.getMessage());
+			resultCode = 1;
+		}
+
+		finish(resultCode, resultInfo);
+	}
+
+	private Bundle doRenderConfigSupportedQuery ()
+	{
+		if (m_cmdLine == null)
+			throw new RuntimeException("missing command line");
+
+		final int result = nativeRenderConfigSupportedQuery(m_cmdLine);
+
+		if (result == CONFIGQUERYRESULT_SUPPORTED)
+		{
+			final Bundle resultInfo = new Bundle();
+			resultInfo.putString("Supported", "Yes");
+			return resultInfo;
+		}
+		else if (result == CONFIGQUERYRESULT_NOT_SUPPORTED)
+		{
+			final Bundle resultInfo = new Bundle();
+			resultInfo.putString("Supported", "No");
+			return resultInfo;
+		}
+		else if (result == CONFIGQUERYRESULT_GENERIC_ERROR)
+			throw new RuntimeException("platform query reported failure");
+		else
+			throw new RuntimeException("platform query returned out-of-range result");
+	}
+
+	private static native int nativeRenderConfigSupportedQuery (String cmdLine);
+}
diff --git a/android/package/src/com/drawelements/deqp/testercore/DeqpInstrumentation.java b/android/package/src/com/drawelements/deqp/testercore/DeqpInstrumentation.java
index 3c0afb9..c12d7f6 100644
--- a/android/package/src/com/drawelements/deqp/testercore/DeqpInstrumentation.java
+++ b/android/package/src/com/drawelements/deqp/testercore/DeqpInstrumentation.java
@@ -143,9 +143,8 @@
 			Log.e(LOG_TAG, "Exception", e);
 
 			Bundle info = new Bundle();
-
 			info.putString("Exception", e.getMessage());
-			finish(1, new Bundle());
+			finish(1, info);
 		}
 		finally
 		{
diff --git a/android/scripts/build.py b/android/scripts/build.py
index 1fb54e8..e278a1b 100644
--- a/android/scripts/build.py
+++ b/android/scripts/build.py
@@ -1,5 +1,25 @@
 # -*- coding: utf-8 -*-
 
+#-------------------------------------------------------------------------
+# drawElements Quality Program utilities
+# --------------------------------------
+#
+# Copyright 2015 The Android Open Source Project
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+#      http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+#
+#-------------------------------------------------------------------------
+
 import os
 import re
 import sys
diff --git a/android/scripts/common.py b/android/scripts/common.py
index d8e5b1b..2f3caca 100644
--- a/android/scripts/common.py
+++ b/android/scripts/common.py
@@ -1,5 +1,25 @@
 # -*- coding: utf-8 -*-
 
+#-------------------------------------------------------------------------
+# drawElements Quality Program utilities
+# --------------------------------------
+#
+# Copyright 2015 The Android Open Source Project
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+#      http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+#
+#-------------------------------------------------------------------------
+
 import os
 import re
 import sys
diff --git a/android/scripts/debug.py b/android/scripts/debug.py
index 7989e56..94891d9 100644
--- a/android/scripts/debug.py
+++ b/android/scripts/debug.py
@@ -1,5 +1,25 @@
 # -*- coding: utf-8 -*-
 
+#-------------------------------------------------------------------------
+# drawElements Quality Program utilities
+# --------------------------------------
+#
+# Copyright 2015 The Android Open Source Project
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+#      http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+#
+#-------------------------------------------------------------------------
+
 import sys
 import os
 import time
diff --git a/android/scripts/gen_android_cts_xml.py b/android/scripts/gen_android_cts_xml.py
index 3bf894e..bbd0aa1 100644
--- a/android/scripts/gen_android_cts_xml.py
+++ b/android/scripts/gen_android_cts_xml.py
@@ -1,3 +1,23 @@
+#-------------------------------------------------------------------------
+# drawElements Quality Program utilities
+# --------------------------------------
+#
+# Copyright 2015 The Android Open Source Project
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+#      http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+#
+#-------------------------------------------------------------------------
+
 import argparse
 import string
 
diff --git a/android/scripts/install.py b/android/scripts/install.py
index 317dd84..89e60f5 100644
--- a/android/scripts/install.py
+++ b/android/scripts/install.py
@@ -1,5 +1,25 @@
 # -*- coding: utf-8 -*-
 
+#-------------------------------------------------------------------------
+# drawElements Quality Program utilities
+# --------------------------------------
+#
+# Copyright 2015 The Android Open Source Project
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+#      http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+#
+#-------------------------------------------------------------------------
+
 import sys
 import os
 import time
diff --git a/android/scripts/launch.py b/android/scripts/launch.py
index dca8e1a..48dd6b7 100644
--- a/android/scripts/launch.py
+++ b/android/scripts/launch.py
@@ -1,5 +1,25 @@
 # -*- coding: utf-8 -*-
 
+#-------------------------------------------------------------------------
+# drawElements Quality Program utilities
+# --------------------------------------
+#
+# Copyright 2015 The Android Open Source Project
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+#      http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+#
+#-------------------------------------------------------------------------
+
 import sys
 import os
 import time
diff --git a/data/gles3/shaders/linkage.test b/data/gles3/shaders/linkage.test
index 89d4180..63206a2 100644
--- a/data/gles3/shaders/linkage.test
+++ b/data/gles3/shaders/linkage.test
@@ -464,19 +464,16 @@
 			""
 		end
 
-		# different interpolation
-		case differing_interpolation_1
+		# interpolation_mismatch
+		case interpolation_mismatch_1
 			version 300 es
 			desc "varying interpolation different (flat vs. smooth)"
-			values
-			{
-				input float in0		= [ -1.25 | -25.0 | 1.0 | 2.25 | 3.4 | 16.0 ];
-				output float out0	= [ -1.25 | -25.0 | 1.0 | 2.25 | 3.4 | 16.0 ];
-			}
+			expect link_fail
 
 			vertex ""
 				#version 300 es
 				${VERTEX_DECLARATIONS}
+				in highp float in0;
 				flat out mediump float var;
 				void main()
 				{
@@ -491,8 +488,7 @@
 				in mediump float var;
 				void main()
 				{
-					out0 = var;
-					${FRAGMENT_OUTPUT}
+					${FRAG_COLOR} = vec4(var);
 				}
 			""
 		end
diff --git a/external/.gitignore b/external/.gitignore
new file mode 100644
index 0000000..6838e6a
--- /dev/null
+++ b/external/.gitignore
@@ -0,0 +1,4 @@
+libpng/*
+!libpng/CMakeLists.txt
+zlib/*
+!zlib/CMakeLists.txt
diff --git a/framework/CMakeLists.txt b/framework/CMakeLists.txt
index 433af28..f2ac7d3 100644
--- a/framework/CMakeLists.txt
+++ b/framework/CMakeLists.txt
@@ -9,6 +9,9 @@
 # Common OpenGL utilities
 add_subdirectory(opengl)
 
+# EGL utilities
+add_subdirectory(egl)
+
 if (IS_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/randomshaders)
 	add_subdirectory(randomshaders)
 endif ()
@@ -17,9 +20,5 @@
 	add_subdirectory(referencerenderer)
 endif ()
 
-if (DEQP_SUPPORT_EGL)
-	add_subdirectory(egl)
-endif ()
-
 # Platform library
 add_subdirectory(platform)
diff --git a/framework/common/CMakeLists.txt b/framework/common/CMakeLists.txt
index 48893a7..4396797 100644
--- a/framework/common/CMakeLists.txt
+++ b/framework/common/CMakeLists.txt
@@ -75,6 +75,10 @@
 	tcuFactoryRegistry.cpp
 	tcuSeedBuilder.hpp
 	tcuSeedBuilder.cpp
+	tcuMaybe.hpp
+	tcuMaybe.cpp
+	tcuEither.hpp
+	tcuEither.cpp
 	)
 
 set(TCUTIL_LIBS
diff --git a/framework/common/tcuCommandLine.cpp b/framework/common/tcuCommandLine.cpp
index 9c25f31..405d9bd 100644
--- a/framework/common/tcuCommandLine.cpp
+++ b/framework/common/tcuCommandLine.cpp
@@ -675,6 +675,16 @@
 	m_caseTree = DE_NULL;
 }
 
+const de::cmdline::CommandLine& CommandLine::getCommandLine (void) const
+{
+	return m_cmdLine;
+}
+
+void CommandLine::registerExtendedOptions (de::cmdline::Parser& parser)
+{
+	DE_UNREF(parser);
+}
+
 /*--------------------------------------------------------------------*//*!
  * \brief Parse command line from standard argc, argv pair.
  * \note parse() must be called exactly once.
@@ -689,6 +699,7 @@
 
 	opt::registerOptions(parser);
 	opt::registerLegacyOptions(parser);
+	registerExtendedOptions(parser);
 
 	clear();
 
diff --git a/framework/common/tcuCommandLine.hpp b/framework/common/tcuCommandLine.hpp
index 961b563..1685e90 100644
--- a/framework/common/tcuCommandLine.hpp
+++ b/framework/common/tcuCommandLine.hpp
@@ -181,12 +181,17 @@
 	//! Check if test case is in supplied test case list.
 	bool							checkTestCaseName			(const char* caseName) const;
 
+protected:
+	const de::cmdline::CommandLine&	getCommandLine				(void) const;
+
 private:
 									CommandLine					(const CommandLine&);	// not allowed!
 	CommandLine&					operator=					(const CommandLine&);	// not allowed!
 
 	void							clear						(void);
 
+	virtual void					registerExtendedOptions		(de::cmdline::Parser& parser);
+
 	de::cmdline::CommandLine		m_cmdLine;
 	deUint32						m_logFlags;
 	CaseTreeNode*					m_caseTree;
diff --git a/framework/common/tcuCompressedTexture.cpp b/framework/common/tcuCompressedTexture.cpp
index 9bbf55c..961bd90 100644
--- a/framework/common/tcuCompressedTexture.cpp
+++ b/framework/common/tcuCompressedTexture.cpp
@@ -2577,7 +2577,7 @@
 
 void decompress (const PixelBufferAccess& dst, CompressedTexFormat fmt, const deUint8* src, const TexDecompressionParams& params)
 {
-	const size_t			blockSize			= getBlockSize(fmt);
+	const int				blockSize			= getBlockSize(fmt);
 	const IVec3				blockPixelSize		(getBlockPixelSize(fmt));
 	const IVec3				blockCount			(divRoundUp(dst.getWidth(),		blockPixelSize.x()),
 												 divRoundUp(dst.getHeight(),	blockPixelSize.y()),
diff --git a/framework/common/tcuDefs.cpp b/framework/common/tcuDefs.cpp
index 154aea7..10eb1fa 100644
--- a/framework/common/tcuDefs.cpp
+++ b/framework/common/tcuDefs.cpp
@@ -73,43 +73,55 @@
 {
 }
 
+TestException::TestException (const char* message, const char* expr, const char* file, int line, qpTestResult result)
+	: Exception	(formatError(message, expr, file, line))
+	, m_result	(result)
+{
+}
+
+TestException::TestException (const std::string& message, qpTestResult result)
+	: Exception	(message)
+	, m_result	(result)
+{
+}
+
 TestError::TestError (const char* message, const char* expr, const char* file, int line)
-	: Exception(message, expr, file, line)
+	: TestException(message, expr, file, line, QP_TEST_RESULT_FAIL)
 {
 }
 
 TestError::TestError (const std::string& message)
-	: Exception(message)
+	: TestException(message, QP_TEST_RESULT_FAIL)
 {
 }
 
 InternalError::InternalError (const char* message, const char* expr, const char* file, int line)
-	: Exception(message, expr, file, line)
+	: TestException(message, expr, file, line, QP_TEST_RESULT_INTERNAL_ERROR)
 {
 }
 
 InternalError::InternalError (const std::string& message)
-	: Exception(message)
+	: TestException(message, QP_TEST_RESULT_INTERNAL_ERROR)
 {
 }
 
 ResourceError::ResourceError (const char* message, const char* expr, const char* file, int line)
-	: Exception(message, expr, file, line)
+	: TestException(message, expr, file, line, QP_TEST_RESULT_RESOURCE_ERROR)
 {
 }
 
 ResourceError::ResourceError (const std::string& message)
-	: Exception(message)
+	: TestException(message, QP_TEST_RESULT_RESOURCE_ERROR)
 {
 }
 
 NotSupportedError::NotSupportedError (const char* message, const char* expr, const char* file, int line)
-	: Exception(message, expr, file, line)
+	: TestException(message, expr, file, line, QP_TEST_RESULT_NOT_SUPPORTED)
 {
 }
 
 NotSupportedError::NotSupportedError (const std::string& message)
-	: Exception(message)
+	: TestException(message, QP_TEST_RESULT_NOT_SUPPORTED)
 {
 }
 
diff --git a/framework/common/tcuDefs.hpp b/framework/common/tcuDefs.hpp
index 1ed3af5..047c64f 100644
--- a/framework/common/tcuDefs.hpp
+++ b/framework/common/tcuDefs.hpp
@@ -24,6 +24,7 @@
  *//*--------------------------------------------------------------------*/
 
 #include "deDefs.hpp"
+#include "qpTestLog.h"
 
 #include <string>
 #include <stdexcept>
@@ -47,18 +48,33 @@
 class Exception : public std::runtime_error
 {
 public:
-					Exception			(const char* message, const char* expr, const char* file, int line);
-					Exception			(const std::string& message);
-	virtual			~Exception			(void) throw() {}
+						Exception			(const char* message, const char* expr, const char* file, int line);
+						Exception			(const std::string& message);
+	virtual				~Exception			(void) throw() {}
 
-	const char*		getMessage			(void) const { return m_message.c_str(); }
+	const char*			getMessage			(void) const { return m_message.c_str(); }
 
 private:
-	std::string		m_message;
+	const std::string	m_message;
+};
+
+//! Base exception class for test exceptions that affect test result
+class TestException : public Exception
+{
+public:
+						TestException		(const char* message, const char* expr, const char* file, int line, qpTestResult result);
+						TestException		(const std::string& message, qpTestResult result);
+	virtual				~TestException		(void) throw() {}
+
+	qpTestResult		getTestResult		(void) const { return m_result; }
+	virtual bool		isFatal				(void) const { return false; }
+
+private:
+	const qpTestResult	m_result;
 };
 
 //! Exception for test errors.
-class TestError : public Exception
+class TestError : public TestException
 {
 public:
 					TestError			(const char* message, const char* expr, const char* file, int line);
@@ -67,7 +83,7 @@
 };
 
 //! Exception for internal errors.
-class InternalError : public Exception
+class InternalError : public TestException
 {
 public:
 					InternalError		(const char* message, const char* expr, const char* file, int line);
@@ -76,16 +92,18 @@
 };
 
 //! Resource error. Tester will terminate if thrown out of test case.
-class ResourceError : public Exception
+class ResourceError : public TestException
 {
 public:
 					ResourceError		(const char* message, const char* expr, const char* file, int line);
 					ResourceError		(const std::string& message);
 	virtual			~ResourceError		(void) throw() {}
+
+	virtual bool	isFatal				(void) const { return true; }
 };
 
 //! Not supported error.
-class NotSupportedError : public Exception
+class NotSupportedError : public TestException
 {
 public:
 					NotSupportedError	(const char* message, const char* expr, const char* file, int line);
diff --git a/framework/common/tcuEither.cpp b/framework/common/tcuEither.cpp
new file mode 100644
index 0000000..64b9737
--- /dev/null
+++ b/framework/common/tcuEither.cpp
@@ -0,0 +1,297 @@
+/*-------------------------------------------------------------------------
+ * drawElements Quality Program Tester Core
+ * ----------------------------------------
+ *
+ * Copyright 2015 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ *//*!
+ * \file
+ * \brief Template class that is either type of Left or Right.
+ *//*--------------------------------------------------------------------*/
+
+#include "tcuEither.hpp"
+
+namespace tcu
+{
+namespace
+{
+
+enum
+{
+	COPYCHECK_VALUE = 1637423219
+};
+
+class TestClassWithConstructor
+{
+public:
+	TestClassWithConstructor (int i)
+		: m_i			(i)
+		, m_copyCheck	(COPYCHECK_VALUE)
+	{
+	}
+
+	~TestClassWithConstructor (void)
+	{
+		TCU_CHECK(m_copyCheck == COPYCHECK_VALUE);
+	}
+
+	TestClassWithConstructor (const TestClassWithConstructor& other)
+		: m_i			(other.m_i)
+		, m_copyCheck	(other.m_copyCheck)
+	{
+	}
+
+	TestClassWithConstructor& operator= (const TestClassWithConstructor& other)
+	{
+		TCU_CHECK(m_copyCheck == COPYCHECK_VALUE);
+
+		if (this == &other)
+			return *this;
+
+		m_i = other.m_i;
+		m_copyCheck = other.m_copyCheck;
+
+		TCU_CHECK(m_copyCheck == COPYCHECK_VALUE);
+
+		return *this;
+	}
+
+	int getValue (void) const
+	{
+		TCU_CHECK(m_copyCheck == COPYCHECK_VALUE);
+
+		return m_i;
+	}
+
+private:
+	int m_i;
+	int m_copyCheck;
+};
+
+} // anonymous
+
+void Either_selfTest (void)
+{
+	// Simple test for first
+	{
+		const int					intValue	= 1503457782;
+		const Either<int, float>	either		(intValue);
+
+		TCU_CHECK(either.isFirst());
+		TCU_CHECK(!either.isSecond());
+
+		TCU_CHECK(either.is<int>());
+		TCU_CHECK(!either.is<float>());
+
+		TCU_CHECK(either.getFirst() == intValue);
+		TCU_CHECK(either.get<int>() == intValue);
+	}
+
+	// Simple test for second
+	{
+		const float					floatValue	= 0.43223332995f;
+		const Either<int, float>	either		(floatValue);
+
+		TCU_CHECK(!either.isFirst());
+		TCU_CHECK(either.isSecond());
+
+		TCU_CHECK(!either.is<int>());
+		TCU_CHECK(either.is<float>());
+
+		TCU_CHECK(either.getSecond() == floatValue);
+		TCU_CHECK(either.get<float>() == floatValue);
+	}
+
+	// Assign first value
+	{
+		const int			intValue	= 1942092699;
+		const float			floatValue	= 0.43223332995f;
+		Either<int, float>	either		(floatValue);
+
+		either = intValue;
+
+		TCU_CHECK(either.isFirst());
+		TCU_CHECK(!either.isSecond());
+
+		TCU_CHECK(either.is<int>());
+		TCU_CHECK(!either.is<float>());
+
+		TCU_CHECK(either.getFirst() == intValue);
+		TCU_CHECK(either.get<int>() == intValue);
+	}
+
+	// Assign second value
+	{
+		const int			intValue	= 1942092699;
+		const float			floatValue	= 0.43223332995f;
+		Either<int, float>	either		(intValue);
+
+		either = floatValue;
+
+		TCU_CHECK(!either.isFirst());
+		TCU_CHECK(either.isSecond());
+
+		TCU_CHECK(!either.is<int>());
+		TCU_CHECK(either.is<float>());
+
+		TCU_CHECK(either.getSecond() == floatValue);
+		TCU_CHECK(either.get<float>() == floatValue);
+	}
+
+	// Assign first either value
+	{
+		const int					intValue	= 1942092699;
+		const float					floatValue	= 0.43223332995f;
+		Either<int, float>			either		(floatValue);
+		const Either<int, float>	otherEither	(intValue);
+
+		either = otherEither;
+
+		TCU_CHECK(either.isFirst());
+		TCU_CHECK(!either.isSecond());
+
+		TCU_CHECK(either.is<int>());
+		TCU_CHECK(!either.is<float>());
+
+		TCU_CHECK(either.getFirst() == intValue);
+		TCU_CHECK(either.get<int>() == intValue);
+	}
+
+	// Assign second either value
+	{
+		const int					intValue	= 1942092699;
+		const float					floatValue	= 0.43223332995f;
+		Either<int, float>			either		(intValue);
+		const Either<int, float>	otherEither	(floatValue);
+
+		either = otherEither;
+
+		TCU_CHECK(!either.isFirst());
+		TCU_CHECK(either.isSecond());
+
+		TCU_CHECK(!either.is<int>());
+		TCU_CHECK(either.is<float>());
+
+		TCU_CHECK(either.getSecond() == floatValue);
+		TCU_CHECK(either.get<float>() == floatValue);
+	}
+
+	// Simple test for first with constructor
+	{
+		const TestClassWithConstructor				testObject	(171899615);
+		const Either<TestClassWithConstructor, int>	either		(testObject);
+
+		TCU_CHECK(either.isFirst());
+		TCU_CHECK(!either.isSecond());
+
+		TCU_CHECK(either.is<TestClassWithConstructor>());
+		TCU_CHECK(!either.is<int>());
+
+		TCU_CHECK(either.getFirst().getValue() == testObject.getValue());
+		TCU_CHECK(either.get<TestClassWithConstructor>().getValue() == testObject.getValue());
+	}
+
+	// Simple test for second with constructor
+	{
+		const TestClassWithConstructor				testObject	(171899615);
+		const Either<int, TestClassWithConstructor>	either		(testObject);
+
+		TCU_CHECK(!either.isFirst());
+		TCU_CHECK(either.isSecond());
+
+		TCU_CHECK(either.is<TestClassWithConstructor>());
+		TCU_CHECK(!either.is<int>());
+
+		TCU_CHECK(either.getSecond().getValue() == testObject.getValue());
+		TCU_CHECK(either.get<TestClassWithConstructor>().getValue() == testObject.getValue());
+	}
+
+	// Assign first with constructor
+	{
+		const int								intValue	= 1942092699;
+		const TestClassWithConstructor			testObject	(171899615);
+		Either<TestClassWithConstructor, int>	either		(intValue);
+
+		either = testObject;
+
+		TCU_CHECK(either.isFirst());
+		TCU_CHECK(!either.isSecond());
+
+		TCU_CHECK(either.is<TestClassWithConstructor>());
+		TCU_CHECK(!either.is<int>());
+
+		TCU_CHECK(either.getFirst().getValue() == testObject.getValue());
+		TCU_CHECK(either.get<TestClassWithConstructor>().getValue() == testObject.getValue());
+	}
+
+	// Assign second with constructor
+	{
+		const int								intValue	= 1942092699;
+		const TestClassWithConstructor			testObject	(171899615);
+		Either<int, TestClassWithConstructor>	either		(intValue);
+
+		either = testObject;
+
+		TCU_CHECK(!either.isFirst());
+		TCU_CHECK(either.isSecond());
+
+		TCU_CHECK(either.is<TestClassWithConstructor>());
+		TCU_CHECK(!either.is<int>());
+
+		TCU_CHECK(either.getSecond().getValue() == testObject.getValue());
+		TCU_CHECK(either.get<TestClassWithConstructor>().getValue() == testObject.getValue());
+	}
+
+	// Assign first either with constructor
+	{
+		const int									intValue	= 1942092699;
+		const TestClassWithConstructor				testObject	(171899615);
+		Either<TestClassWithConstructor, int>		either		(intValue);
+		const Either<TestClassWithConstructor, int>	otherEither	(testObject);
+
+		either = otherEither;
+
+		TCU_CHECK(either.isFirst());
+		TCU_CHECK(!either.isSecond());
+
+		TCU_CHECK(either.is<TestClassWithConstructor>());
+		TCU_CHECK(!either.is<int>());
+
+		TCU_CHECK(either.getFirst().getValue() == testObject.getValue());
+		TCU_CHECK(either.get<TestClassWithConstructor>().getValue() == testObject.getValue());
+	}
+
+	// Assign second either with constructor
+	{
+		const int									intValue	= 1942092699;
+		const TestClassWithConstructor				testObject	(171899615);
+		Either<int, TestClassWithConstructor>		either		(intValue);
+		const Either<int, TestClassWithConstructor>	otherEither	(testObject);
+
+
+		either = testObject;
+
+		TCU_CHECK(!either.isFirst());
+		TCU_CHECK(either.isSecond());
+
+		TCU_CHECK(either.is<TestClassWithConstructor>());
+		TCU_CHECK(!either.is<int>());
+
+		TCU_CHECK(either.getSecond().getValue() == testObject.getValue());
+		TCU_CHECK(either.get<TestClassWithConstructor>().getValue() == testObject.getValue());
+	}
+}
+
+} // tcu
diff --git a/framework/common/tcuEither.hpp b/framework/common/tcuEither.hpp
new file mode 100644
index 0000000..47a3c49
--- /dev/null
+++ b/framework/common/tcuEither.hpp
@@ -0,0 +1,268 @@
+#ifndef _TCUEITHER_HPP
+#define _TCUEITHER_HPP
+/*-------------------------------------------------------------------------
+ * drawElements Quality Program Tester Core
+ * ----------------------------------------
+ *
+ * Copyright 2015 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ *//*!
+ * \file
+ * \brief Template class that is either type of First or Second.
+ *//*--------------------------------------------------------------------*/
+
+#include "tcuDefs.hpp"
+
+namespace tcu
+{
+
+/*--------------------------------------------------------------------*//*!
+ * \brief Object containing Either First or Second type of object
+ *
+ * \note Type First and Second are always aligned to same alignment as
+ * 		 deUint64.
+ * \note This type always uses at least sizeof(bool) + max(sizeof(First*),
+ * 		 sizeof(Second*)) + sizeof(deUint64) of memory.
+ *//*--------------------------------------------------------------------*/
+template<typename First, typename Second>
+class Either
+{
+public:
+					Either		(const First& first);
+					Either		(const Second& second);
+					~Either		(void);
+
+					Either		(const Either<First, Second>& other);
+	Either&			operator=	(const Either<First, Second>& other);
+
+	Either&			operator=	(const First& first);
+	Either&			operator=	(const Second& second);
+
+	bool			isFirst		(void) const;
+	bool			isSecond	(void) const;
+
+	const First&	getFirst	(void) const;
+	const Second&	getSecond	(void) const;
+
+	template<typename Type>
+	const Type&		get			(void) const;
+
+	template<typename Type>
+	bool			is			(void) const;
+
+private:
+	void			release		(void);
+
+	bool			m_isFirst;
+
+	union
+	{
+		First*		m_first;
+		Second*		m_second;
+	};
+
+	union
+	{
+		deUint8		m_data[sizeof(First) > sizeof(Second) ? sizeof(First) : sizeof(Second)];
+		deUint64	m_align;
+	};
+};
+
+namespace EitherDetail
+{
+
+template<typename Type, typename First, typename Second>
+struct Get;
+
+template<typename First, typename Second>
+struct Get<First, First, Second>
+{
+	static const First& get (const Either<First, Second>& either)
+	{
+		return either.getFirst();
+	}
+};
+
+template<typename First, typename Second>
+struct Get<Second, First, Second>
+{
+	static const Second& get (const Either<First, Second>& either)
+	{
+		return either.getSecond();
+	}
+};
+
+template<typename Type, typename First, typename Second>
+const Type& get (const Either<First, Second>& either)
+{
+	return Get<Type, First, Second>::get(either);
+}
+
+template<typename Type, typename First, typename Second>
+struct Is;
+
+template<typename First, typename Second>
+struct Is<First, First, Second>
+{
+	static bool is (const Either<First, Second>& either)
+	{
+		return either.isFirst();
+	}
+};
+
+template<typename First, typename Second>
+struct Is<Second, First, Second>
+{
+	static bool is (const Either<First, Second>& either)
+	{
+		return either.isSecond();
+	}
+};
+
+template<typename Type, typename First, typename Second>
+bool is (const Either<First, Second>& either)
+{
+	return Is<Type, First, Second>::is(either);
+}
+
+} // EitherDetail
+
+template<typename First, typename Second>
+void Either<First, Second>::release (void)
+{
+	if (m_isFirst)
+		m_first->~First();
+	else
+		m_second->~Second();
+
+	m_isFirst	= true;
+	m_first		= DE_NULL;
+}
+
+template<typename First, typename Second>
+Either<First, Second>::Either (const First& first)
+	: m_isFirst	(true)
+{
+	m_first = new(m_data)First(first);
+}
+
+template<typename First, typename Second>
+Either<First, Second>::Either (const Second& second)
+	: m_isFirst (false)
+{
+	m_second = new(m_data)Second(second);
+}
+
+template<typename First, typename Second>
+Either<First, Second>::~Either (void)
+{
+	release();
+}
+
+template<typename First, typename Second>
+Either<First, Second>::Either (const Either<First, Second>& other)
+	: m_isFirst	(other.m_isFirst)
+{
+	if (m_isFirst)
+		m_first = new(m_data)First(*other.m_first);
+	else
+		m_second = new(m_data)Second(*other.m_second);
+}
+
+template<typename First, typename Second>
+Either<First, Second>& Either<First, Second>::operator= (const Either<First, Second>& other)
+{
+	if (this == &other)
+		return *this;
+
+	release();
+
+	m_isFirst = other.m_isFirst;
+
+	if (m_isFirst)
+		m_first = new(m_data)First(*other.m_first);
+	else
+		m_second = new(m_data)Second(*other.m_second);
+
+	return *this;
+}
+
+template<typename First, typename Second>
+Either<First, Second>& Either<First, Second>::operator= (const First& first)
+{
+	release();
+
+	m_isFirst = true;
+	m_first = new(m_data)First(first);
+
+	return *this;
+}
+
+template<typename First, typename Second>
+Either<First, Second>& Either<First, Second>::operator= (const Second& second)
+{
+	release();
+
+	m_isFirst = false;
+	m_second = new(m_data)Second(second);
+
+	return *this;
+}
+
+template<typename First, typename Second>
+bool Either<First, Second>::isFirst (void) const
+{
+	return m_isFirst;
+}
+
+template<typename First, typename Second>
+bool Either<First, Second>::isSecond (void) const
+{
+	return !m_isFirst;
+}
+
+template<typename First, typename Second>
+const First& Either<First, Second>::getFirst (void) const
+{
+	DE_ASSERT(isFirst());
+	return *m_first;
+}
+
+template<typename First, typename Second>
+const Second& Either<First, Second>::getSecond (void) const
+{
+	DE_ASSERT(isSecond());
+	return *m_second;
+}
+
+template<typename First, typename Second>
+template<typename Type>
+const Type& Either<First, Second>::get (void) const
+{
+	return EitherDetail::get<Type, First, Second>(*this);
+}
+
+template<typename First, typename Second>
+template<typename Type>
+bool Either<First, Second>::is (void) const
+{
+	return EitherDetail::is<Type, First, Second>(*this);
+}
+
+void Either_selfTest (void);
+
+} // tcu
+
+#endif // _TCUEITHER_HPP
diff --git a/framework/common/tcuImageCompare.cpp b/framework/common/tcuImageCompare.cpp
index 3bae0ef..ced0145 100644
--- a/framework/common/tcuImageCompare.cpp
+++ b/framework/common/tcuImageCompare.cpp
@@ -89,18 +89,30 @@
 
 static int findNumPositionDeviationFailingPixels (const PixelBufferAccess& errorMask, const ConstPixelBufferAccess& reference, const ConstPixelBufferAccess& result, const UVec4& threshold, const tcu::IVec3& maxPositionDeviation, bool acceptOutOfBoundsAsAnyValue)
 {
-	const int	width				= reference.getWidth();
-	const int	height				= reference.getHeight();
-	const int	depth				= reference.getDepth();
-	int			numFailingPixels	= 0;
+	const tcu::IVec4	okColor				(0, 255, 0, 255);
+	const tcu::IVec4	errorColor			(255, 0, 0, 255);
+	const int			width				= reference.getWidth();
+	const int			height				= reference.getHeight();
+	const int			depth				= reference.getDepth();
+	int					numFailingPixels	= 0;
+
+	// Accept pixels "sampling" over the image bounds pixels since "taps" could be anything
+	const int			beginX				= (acceptOutOfBoundsAsAnyValue) ? (maxPositionDeviation.x()) : (0);
+	const int			beginY				= (acceptOutOfBoundsAsAnyValue) ? (maxPositionDeviation.y()) : (0);
+	const int			beginZ				= (acceptOutOfBoundsAsAnyValue) ? (maxPositionDeviation.z()) : (0);
+	const int			endX				= (acceptOutOfBoundsAsAnyValue) ? (width  - maxPositionDeviation.x()) : (0);
+	const int			endY				= (acceptOutOfBoundsAsAnyValue) ? (height - maxPositionDeviation.y()) : (0);
+	const int			endZ				= (acceptOutOfBoundsAsAnyValue) ? (depth  - maxPositionDeviation.z()) : (0);
 
 	TCU_CHECK_INTERNAL(result.getWidth() == width && result.getHeight() == height && result.getDepth() == depth);
 
-	for (int z = 0; z < depth; z++)
+	tcu::clear(errorMask, okColor);
+
+	for (int z = beginZ; z < endZ; z++)
 	{
-		for (int y = 0; y < height; y++)
+		for (int y = beginY; y < endY; y++)
 		{
-			for (int x = 0; x < width; x++)
+			for (int x = beginX; x < endX; x++)
 			{
 				const IVec4	refPix = reference.getPixelInt(x, y, z);
 				const IVec4	cmpPix = result.getPixelInt(x, y, z);
@@ -111,28 +123,13 @@
 					const bool	isOk = boolAll(lessThanEqual(diff, threshold));
 
 					if (isOk)
-					{
-						errorMask.setPixel(IVec4(0, 0xff, 0, 0xff), x, y, z);
 						continue;
-					}
-				}
-
-				// Accept over the image bounds pixels since they could be anything
-
-				if (acceptOutOfBoundsAsAnyValue &&
-					(x < maxPositionDeviation.x() || x + maxPositionDeviation.x() >= width  ||
-					 y < maxPositionDeviation.y() || y + maxPositionDeviation.y() >= height ||
-					 z < maxPositionDeviation.z() || z + maxPositionDeviation.z() >= depth))
-				{
-					errorMask.setPixel(IVec4(0, 0xff, 0, 0xff), x, y, z);
-					continue;
 				}
 
 				// Find matching pixels for both result and reference pixel
 
 				{
 					bool pixelFoundForReference = false;
-					bool pixelFoundForResult	= false;
 
 					// Find deviated result pixel for reference
 
@@ -144,9 +141,19 @@
 						const UVec4	diff			= abs(refPix - deviatedCmpPix).cast<deUint32>();
 						const bool	isOk			= boolAll(lessThanEqual(diff, threshold));
 
-						pixelFoundForReference		|= isOk;
+						pixelFoundForReference		= isOk;
 					}
 
+					if (!pixelFoundForReference)
+					{
+						errorMask.setPixel(errorColor, x, y, z);
+						++numFailingPixels;
+						continue;
+					}
+				}
+				{
+					bool pixelFoundForResult = false;
+
 					// Find deviated reference pixel for result
 
 					for (int sz = de::max(0, z - maxPositionDeviation.z()); sz <= de::min(depth  - 1, z + maxPositionDeviation.z()) && !pixelFoundForResult; ++sz)
@@ -157,15 +164,14 @@
 						const UVec4	diff			= abs(cmpPix - deviatedRefPix).cast<deUint32>();
 						const bool	isOk			= boolAll(lessThanEqual(diff, threshold));
 
-						pixelFoundForResult			|= isOk;
+						pixelFoundForResult			= isOk;
 					}
 
-					if (pixelFoundForReference && pixelFoundForResult)
-						errorMask.setPixel(IVec4(0, 0xff, 0, 0xff), x, y, z);
-					else
+					if (!pixelFoundForResult)
 					{
-						errorMask.setPixel(IVec4(0xff, 0, 0, 0xff), x, y, z);
+						errorMask.setPixel(errorColor, x, y, z);
 						++numFailingPixels;
+						continue;
 					}
 				}
 			}
diff --git a/framework/egl/egluHeaderWrapper.cpp b/framework/common/tcuMaybe.cpp
similarity index 86%
rename from framework/egl/egluHeaderWrapper.cpp
rename to framework/common/tcuMaybe.cpp
index 5966c54..d275d53 100644
--- a/framework/egl/egluHeaderWrapper.cpp
+++ b/framework/common/tcuMaybe.cpp
@@ -2,7 +2,7 @@
  * drawElements Quality Program Tester Core
  * ----------------------------------------
  *
- * Copyright 2014 The Android Open Source Project
+ * Copyright 2015 The Android Open Source Project
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -18,9 +18,9 @@
  *
  *//*!
  * \file
- * \brief EGL header file wrapper
+ * \brief Template for values that may not exist.
  *//*--------------------------------------------------------------------*/
 
-#include "egluHeaderWrapper.hpp"
+#include "tcuMaybe.hpp"
 
 DE_EMPTY_CPP_FILE
diff --git a/framework/common/tcuMaybe.hpp b/framework/common/tcuMaybe.hpp
new file mode 100644
index 0000000..62110a9
--- /dev/null
+++ b/framework/common/tcuMaybe.hpp
@@ -0,0 +1,140 @@
+#ifndef _TCUMAYBE_HPP
+#define _TCUMAYBE_HPP
+/*-------------------------------------------------------------------------
+ * drawElements Quality Program Tester Core
+ * ----------------------------------------
+ *
+ * Copyright 2015 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ *//*!
+ * \file
+ * \brief Template for values that may not exist.
+ *//*--------------------------------------------------------------------*/
+
+#include "tcuDefs.hpp"
+
+namespace tcu
+{
+
+// \note Type T is always aligned to same alignment as deUint64.
+// \note This type always uses at least sizeof(T*) + sizeof(deUint64) of memory.
+template<typename T>
+class Maybe
+{
+public:
+				Maybe			(void);
+				~Maybe			(void);
+
+				Maybe			(const T& val);
+	Maybe<T>&	operator=		(const T& val);
+
+				Maybe			(const Maybe<T>& other);
+	Maybe<T>&	operator=		(const Maybe<T>& other);
+
+	const T&	get				(void) const;
+	const T&	operator*		(void) const { return get(); }
+
+	const T*	operator->		(void) const;
+				operator bool	(void) const { return m_ptr; }
+
+private:
+	T*				m_ptr;
+
+	union
+	{
+		deUint8		m_data[sizeof(T)];
+		deUint64	m_align;
+	};
+};
+
+template<typename T>
+Maybe<T> nothing (void)
+{
+	return Maybe<T>();
+}
+
+template<typename T>
+Maybe<T>::Maybe (void)
+	: m_ptr (DE_NULL)
+{
+}
+
+template<typename T>
+Maybe<T>::~Maybe (void)
+{
+	if (m_ptr)
+		m_ptr->~T();
+}
+
+template<typename T>
+Maybe<T>::Maybe (const T& val)
+	: m_ptr (DE_NULL)
+{
+	m_ptr = new(m_data)T(val);
+}
+
+template<typename T>
+Maybe<T>& Maybe<T>::operator= (const T& val)
+{
+	if (m_ptr)
+		m_ptr->~T();
+
+	m_ptr = new(m_data)T(val);
+
+	return *this;
+}
+
+template<typename T>
+Maybe<T>::Maybe (const Maybe<T>& other)
+	: m_ptr (DE_NULL)
+{
+	if (other.m_ptr)
+		m_ptr = new(m_data)T(*other.m_ptr);
+}
+
+template<typename T>
+Maybe<T>& Maybe<T>::operator= (const Maybe<T>& other)
+{
+	if (this == &other)
+		return *this;
+
+	if (m_ptr)
+		m_ptr->~T();
+
+	if (other.m_ptr)
+		m_ptr = new(m_data)T(*other.m_ptr);
+	else
+		m_ptr = DE_NULL;
+
+	return *this;
+}
+
+template<typename T>
+const T* Maybe<T>::operator-> (void) const
+{
+	DE_ASSERT(m_ptr);
+	return m_ptr;
+}
+
+template<typename T>
+const T& Maybe<T>::get (void) const
+{
+	DE_ASSERT(m_ptr);
+	return *m_ptr;
+}
+
+} // tcu
+
+#endif // _TCUMAYBE_HPP
diff --git a/framework/common/tcuTestCase.cpp b/framework/common/tcuTestCase.cpp
index a8aeeb7..fb7a73f 100644
--- a/framework/common/tcuTestCase.cpp
+++ b/framework/common/tcuTestCase.cpp
@@ -45,18 +45,18 @@
 
 TestNode::TestNode (TestContext& testCtx, TestNodeType nodeType, const char* name, const char* description)
 	: m_testCtx		(testCtx)
-	, m_nodeType	(nodeType)
 	, m_name		(name)
 	, m_description	(description)
+	, m_nodeType	(nodeType)
 {
 	DE_ASSERT(isValidCaseName(name));
 }
 
 TestNode::TestNode (TestContext& testCtx, TestNodeType nodeType, const char* name, const char* description, const vector<TestNode*>& children)
 	: m_testCtx		(testCtx)
-	, m_nodeType	(nodeType)
 	, m_name		(name)
 	, m_description	(description)
+	, m_nodeType	(nodeType)
 {
 	DE_ASSERT(isValidCaseName(name));
 	for (int i = 0; i < (int)children.size(); i++)
@@ -68,7 +68,7 @@
 	TestNode::deinit();
 }
 
-void TestNode::getChildren (vector<TestNode*>& res) const
+void TestNode::getChildren (vector<TestNode*>& res)
 {
 	res.clear();
 	for (int i = 0; i < (int)m_children.size(); i++)
@@ -87,6 +87,13 @@
 	}
 #endif
 
+	// children only in group nodes
+	DE_ASSERT(getTestNodeTypeClass(m_nodeType) == NODECLASS_GROUP);
+
+	// children must have the same class
+	if (!m_children.empty())
+		DE_ASSERT(getTestNodeTypeClass(m_children.front()->getNodeType()) == getTestNodeTypeClass(node->getNodeType()));
+
 	m_children.push_back(node);
 }
 
diff --git a/framework/common/tcuTestCase.hpp b/framework/common/tcuTestCase.hpp
index 431f7d1..9ce5271 100644
--- a/framework/common/tcuTestCase.hpp
+++ b/framework/common/tcuTestCase.hpp
@@ -43,12 +43,34 @@
 	NODETYPE_ACCURACY		//!< Accuracy test case -- can be executed
 };
 
+enum TestNodeClass
+{
+	NODECLASS_GROUP = 0,	//!< Root or non-leaf in the test hierarchy tree
+	NODECLASS_EXECUTABLE,	//!< Non-root leaf in the test hierarchy tree
+
+	NODECLASS_LAST
+};
+
+inline TestNodeClass getTestNodeTypeClass (TestNodeType type)
+{
+	switch (type)
+	{
+		case NODETYPE_ROOT:				return NODECLASS_GROUP;
+		case NODETYPE_PACKAGE:			return NODECLASS_GROUP;
+		case NODETYPE_GROUP:			return NODECLASS_GROUP;
+		case NODETYPE_SELF_VALIDATE:	return NODECLASS_EXECUTABLE;
+		case NODETYPE_PERFORMANCE:		return NODECLASS_EXECUTABLE;
+		case NODETYPE_CAPABILITY:		return NODECLASS_EXECUTABLE;
+		case NODETYPE_ACCURACY:			return NODECLASS_EXECUTABLE;
+		default:
+			DE_ASSERT(false);
+			return NODECLASS_LAST;
+	}
+}
+
 inline bool isTestNodeTypeExecutable (TestNodeType type)
 {
-	return type == NODETYPE_SELF_VALIDATE	||
-		   type == NODETYPE_PERFORMANCE		||
-		   type == NODETYPE_CAPABILITY		||
-		   type == NODETYPE_ACCURACY;
+	return getTestNodeTypeClass(type) == NODECLASS_EXECUTABLE;
 }
 
 inline bool isValidTestCaseNameChar (char c)
@@ -90,7 +112,7 @@
 	TestContext&			getTestContext	(void) const	{ return m_testCtx;				}
 	const char*				getName			(void) const	{ return m_name.c_str();		}
 	const char*				getDescription	(void) const	{ return m_description.c_str(); }
-	void					getChildren		(std::vector<TestNode*>& children) const;
+	void					getChildren		(std::vector<TestNode*>& children);
 	void					addChild		(TestNode* node);
 
 	virtual void			init			(void);
@@ -99,11 +121,11 @@
 
 protected:
 	TestContext&			m_testCtx;
-	TestNodeType			m_nodeType;
 	std::string				m_name;
 	std::string				m_description;
 
 private:
+	const TestNodeType		m_nodeType;
 	std::vector<TestNode*>	m_children;
 };
 
diff --git a/framework/common/tcuTestCaseWrapper.cpp b/framework/common/tcuTestCaseWrapper.cpp
index 2639bb7..b8e2eb5 100644
--- a/framework/common/tcuTestCaseWrapper.cpp
+++ b/framework/common/tcuTestCaseWrapper.cpp
@@ -56,23 +56,13 @@
 	{
 		DE_ASSERT(!success);
 		m_testCtx.setTestResult(QP_TEST_RESULT_RESOURCE_ERROR, "Failed to allocate memory in test case init");
+		m_testCtx.setTerminateAfter(true);
 	}
-	catch (const tcu::ResourceError& e)
+	catch (const tcu::TestException& e)
 	{
 		DE_ASSERT(!success);
-		m_testCtx.setTestResult(QP_TEST_RESULT_RESOURCE_ERROR, e.getMessage());
-		log << e;
-	}
-	catch (const tcu::NotSupportedError& e)
-	{
-		DE_ASSERT(!success);
-		m_testCtx.setTestResult(QP_TEST_RESULT_NOT_SUPPORTED, e.getMessage());
-		log << e;
-	}
-	catch (const tcu::InternalError& e)
-	{
-		DE_ASSERT(!success);
-		m_testCtx.setTestResult(QP_TEST_RESULT_INTERNAL_ERROR, e.getMessage());
+		m_testCtx.setTestResult(e.getTestResult(), e.getMessage());
+		m_testCtx.setTerminateAfter(e.isFatal());
 		log << e;
 	}
 	catch (const tcu::Exception& e)
@@ -125,21 +115,13 @@
 	catch (const std::bad_alloc&)
 	{
 		m_testCtx.setTestResult(QP_TEST_RESULT_RESOURCE_ERROR, "Failed to allocate memory during test execution");
+		m_testCtx.setTerminateAfter(true);
 	}
-	catch (const tcu::ResourceError& e)
+	catch (const tcu::TestException& e)
 	{
 		log << e;
-		m_testCtx.setTestResult(QP_TEST_RESULT_RESOURCE_ERROR, e.getMessage());
-	}
-	catch (const tcu::NotSupportedError& e)
-	{
-		log << e;
-		m_testCtx.setTestResult(QP_TEST_RESULT_NOT_SUPPORTED, e.getMessage());
-	}
-	catch (const tcu::InternalError& e)
-	{
-		log << e;
-		m_testCtx.setTestResult(QP_TEST_RESULT_INTERNAL_ERROR, e.getMessage());
+		m_testCtx.setTestResult(e.getTestResult(), e.getMessage());
+		m_testCtx.setTerminateAfter(e.isFatal());
 	}
 	catch (const tcu::Exception& e)
 	{
diff --git a/framework/common/tcuTestContext.cpp b/framework/common/tcuTestContext.cpp
index a3317b2..bfa6d88 100644
--- a/framework/common/tcuTestContext.cpp
+++ b/framework/common/tcuTestContext.cpp
@@ -41,6 +41,7 @@
 	, m_watchDog		(watchDog)
 	, m_curArchive		(DE_NULL)
 	, m_testResult		(QP_TEST_RESULT_LAST)
+	, m_terminateAfter	(false)
 {
 	setCurrentArchive(m_rootArchive);
 }
diff --git a/framework/common/tcuTestContext.hpp b/framework/common/tcuTestContext.hpp
index 35e5577..3196154 100644
--- a/framework/common/tcuTestContext.hpp
+++ b/framework/common/tcuTestContext.hpp
@@ -67,6 +67,8 @@
 	Archive&				getRootArchive		(void) const		{ return m_rootArchive;		}
 	void					setCurrentArchive	(Archive& archive)	{ m_curArchive = &archive;	}
 
+	void					setTerminateAfter	(bool terminate)	{ m_terminateAfter = terminate;	}
+	bool					getTerminateAfter	(void) const		{ return m_terminateAfter; 		}
 protected:
 	Platform&				m_platform;			//!< Platform port implementation.
 	Archive&				m_rootArchive;		//!< Root archive.
@@ -77,6 +79,7 @@
 	Archive*				m_curArchive;		//!< Current archive for test cases.
 	qpTestResult			m_testResult;		//!< Latest test result.
 	std::string				m_testResultDesc;	//!< Latest test result description.
+	bool					m_terminateAfter;	//!< Should tester terminate after execution of the current test
 };
 
 /*--------------------------------------------------------------------*//*!
diff --git a/framework/common/tcuTestExecutor.cpp b/framework/common/tcuTestExecutor.cpp
index 21c1b0a..69500a2 100644
--- a/framework/common/tcuTestExecutor.cpp
+++ b/framework/common/tcuTestExecutor.cpp
@@ -194,11 +194,18 @@
 	const RunMode runMode = m_cmdLine.getRunMode();
 	if (runMode == RUNMODE_EXECUTE)
 	{
-		// Update statistics.
-		qpTestResult testResult = m_testCtx.getTestResult();
+		// De-init case.
+		const bool			deinitOk		= m_testCaseWrapper->deinitTestCase(testCase);
+		const qpTestResult	testResult		= m_testCtx.getTestResult();
+		const char* const	testResultDesc	= m_testCtx.getTestResultDesc();
+		const bool			terminateAfter	= m_testCtx.getTerminateAfter();
 		DE_ASSERT(testResult != QP_TEST_RESULT_LAST);
 
-		print("  %s (%s)\n", qpGetTestResultName(testResult), m_testCtx.getTestResultDesc());
+		m_isInTestCase = false;
+		m_testCtx.getLog().endCase(testResult, testResultDesc);
+
+		// Update statistics.
+		print("  %s (%s)\n", qpGetTestResultName(testResult), testResultDesc);
 
 		m_result.numExecuted += 1;
 		switch (testResult)
@@ -210,14 +217,8 @@
 			default:									m_result.numFailed			+= 1;	break;
 		}
 
-		// De-init case.
-		bool deinitOk = m_testCaseWrapper->deinitTestCase(testCase);
-
-		m_isInTestCase = false;
-		m_testCtx.getLog().endCase(m_testCtx.getTestResult(), m_testCtx.getTestResultDesc());
-
-		// Resource error or any error in deinit means that execution should end
-		if (!deinitOk || testResult == QP_TEST_RESULT_RESOURCE_ERROR)
+		// terminateAfter, Resource error or any error in deinit means that execution should end
+		if (terminateAfter || !deinitOk || testResult == QP_TEST_RESULT_RESOURCE_ERROR)
 			m_abortSession = true;
 
 		// \todo [2011-02-09 pyry] Disable watchdog temporarily?
diff --git a/framework/common/tcuTexture.cpp b/framework/common/tcuTexture.cpp
index efc6f84..735ffc5 100644
--- a/framework/common/tcuTexture.cpp
+++ b/framework/common/tcuTexture.cpp
@@ -403,6 +403,15 @@
 
 } // anonymous
 
+IVec3 calculatePackedPitch (const TextureFormat& format, const IVec3& size)
+{
+	const int pixelSize		= format.getPixelSize();
+	const int rowPitch		= pixelSize * size.x();
+	const int slicePitch	= rowPitch * size.y();
+
+	return IVec3(pixelSize, rowPitch, slicePitch);
+}
+
 /** Get pixel size in bytes. */
 int TextureFormat::getPixelSize (void) const
 {
@@ -492,44 +501,49 @@
 }
 
 ConstPixelBufferAccess::ConstPixelBufferAccess (void)
-	: m_width		(0)
-	, m_height		(0)
-	, m_depth		(0)
-	, m_rowPitch	(0)
-	, m_slicePitch	(0)
+	: m_size		(0)
+	, m_pitch		(0)
 	, m_data		(DE_NULL)
 {
 }
 
 ConstPixelBufferAccess::ConstPixelBufferAccess (const TextureFormat& format, int width, int height, int depth, const void* data)
 	: m_format		(format)
-	, m_width		(width)
-	, m_height		(height)
-	, m_depth		(depth)
-	, m_rowPitch	(width*format.getPixelSize())
-	, m_slicePitch	(m_rowPitch*height)
+	, m_size		(width, height, depth)
+	, m_pitch		(calculatePackedPitch(m_format, m_size))
+	, m_data		((void*)data)
+{
+}
+
+ConstPixelBufferAccess::ConstPixelBufferAccess (const TextureFormat& format, const IVec3& size, const void* data)
+	: m_format		(format)
+	, m_size		(size)
+	, m_pitch		(calculatePackedPitch(m_format, m_size))
 	, m_data		((void*)data)
 {
 }
 
 ConstPixelBufferAccess::ConstPixelBufferAccess (const TextureFormat& format, int width, int height, int depth, int rowPitch, int slicePitch, const void* data)
 	: m_format		(format)
-	, m_width		(width)
-	, m_height		(height)
-	, m_depth		(depth)
-	, m_rowPitch	(rowPitch)
-	, m_slicePitch	(slicePitch)
+	, m_size		(width, height, depth)
+	, m_pitch		(format.getPixelSize(), rowPitch, slicePitch)
 	, m_data		((void*)data)
 {
 }
 
+ConstPixelBufferAccess::ConstPixelBufferAccess (const TextureFormat& format, const IVec3& size, const IVec3& pitch, const void* data)
+	: m_format		(format)
+	, m_size		(size)
+	, m_pitch		(pitch)
+	, m_data		((void*)data)
+{
+	DE_ASSERT(m_format.getPixelSize() <= m_pitch.x());
+}
+
 ConstPixelBufferAccess::ConstPixelBufferAccess (const TextureLevel& level)
 	: m_format		(level.getFormat())
-	, m_width		(level.getWidth())
-	, m_height		(level.getHeight())
-	, m_depth		(level.getDepth())
-	, m_rowPitch	(m_width*m_format.getPixelSize())
-	, m_slicePitch	(m_rowPitch*m_height)
+	, m_size		(level.getSize())
+	, m_pitch		(calculatePackedPitch(m_format, m_size))
 	, m_data		((void*)level.getPtr())
 {
 }
@@ -539,11 +553,21 @@
 {
 }
 
+PixelBufferAccess::PixelBufferAccess (const TextureFormat& format, const IVec3& size, void* data)
+	: ConstPixelBufferAccess(format, size, data)
+{
+}
+
 PixelBufferAccess::PixelBufferAccess (const TextureFormat& format, int width, int height, int depth, int rowPitch, int slicePitch, void* data)
 	: ConstPixelBufferAccess(format, width, height, depth, rowPitch, slicePitch, data)
 {
 }
 
+PixelBufferAccess::PixelBufferAccess (const TextureFormat& format, const IVec3& size, const IVec3& pitch, void* data)
+	: ConstPixelBufferAccess(format, size, pitch, data)
+{
+}
+
 PixelBufferAccess::PixelBufferAccess (TextureLevel& level)
 	: ConstPixelBufferAccess(level)
 {
@@ -557,22 +581,21 @@
 
 Vec4 ConstPixelBufferAccess::getPixel (int x, int y, int z) const
 {
-	DE_ASSERT(de::inBounds(x, 0, m_width));
-	DE_ASSERT(de::inBounds(y, 0, m_height));
-	DE_ASSERT(de::inBounds(z, 0, m_depth));
+	DE_ASSERT(de::inBounds(x, 0, m_size.x()));
+	DE_ASSERT(de::inBounds(y, 0, m_size.y()));
+	DE_ASSERT(de::inBounds(z, 0, m_size.z()));
+
+	const deUint8* pixelPtr = (const deUint8*)getDataPtr() + z*m_pitch.z() + y*m_pitch.y() + x*m_pitch.x();
 
 	// Optimized fomats.
 	if (m_format.type == TextureFormat::UNORM_INT8)
 	{
 		if (m_format.order == TextureFormat::RGBA)
-			return readRGBA8888Float((const deUint8*)getDataPtr() + z*m_slicePitch + y*m_rowPitch + x*4);
+			return readRGBA8888Float(pixelPtr);
 		else if (m_format.order == TextureFormat::RGB)
-			return readRGB888Float((const deUint8*)getDataPtr() + z*m_slicePitch + y*m_rowPitch + x*3);
+			return readRGB888Float(pixelPtr);
 	}
 
-	int				pixelSize		= m_format.getPixelSize();
-	const deUint8*	pixelPtr		= (const deUint8*)getDataPtr() + z*m_slicePitch + y*m_rowPitch + x*pixelSize;
-
 #define UB16(OFFS, COUNT)		((*((const deUint16*)pixelPtr) >> (OFFS)) & ((1<<(COUNT))-1))
 #define UB32(OFFS, COUNT)		((*((const deUint32*)pixelPtr) >> (OFFS)) & ((1<<(COUNT))-1))
 #define NB16(OFFS, COUNT)		channelToNormFloat(UB16(OFFS, COUNT), (COUNT))
@@ -642,12 +665,11 @@
 
 IVec4 ConstPixelBufferAccess::getPixelInt (int x, int y, int z) const
 {
-	DE_ASSERT(de::inBounds(x, 0, m_width));
-	DE_ASSERT(de::inBounds(y, 0, m_height));
-	DE_ASSERT(de::inBounds(z, 0, m_depth));
+	DE_ASSERT(de::inBounds(x, 0, m_size.x()));
+	DE_ASSERT(de::inBounds(y, 0, m_size.y()));
+	DE_ASSERT(de::inBounds(z, 0, m_size.z()));
 
-	int				pixelSize		= m_format.getPixelSize();
-	const deUint8*	pixelPtr		= (const deUint8*)getDataPtr() + z*m_slicePitch + y*m_rowPitch + x*pixelSize;
+	const deUint8*	pixelPtr = (const deUint8*)getDataPtr() + z*m_pitch.z() + y*m_pitch.y() + x*m_pitch.x();
 	IVec4			result;
 
 	// Optimized fomats.
@@ -738,8 +760,7 @@
 	DE_ASSERT(de::inBounds(y, 0, getHeight()));
 	DE_ASSERT(de::inBounds(z, 0, getDepth()));
 
-	int			pixelSize	= m_format.getPixelSize();
-	deUint8*	pixelPtr	= (deUint8*)getDataPtr() + z*m_slicePitch + y*m_rowPitch + x*pixelSize;
+	deUint8* pixelPtr = (deUint8*)getDataPtr() + z*m_pitch.z() + y*m_pitch.y() + x*m_pitch.x();
 
 #define UB32(OFFS, COUNT) ((*((const deUint32*)pixelPtr) >> (OFFS)) & ((1<<(COUNT))-1))
 #define NB32(OFFS, COUNT) channelToNormFloat(UB32(OFFS, COUNT), (COUNT))
@@ -778,8 +799,7 @@
 	DE_ASSERT(de::inBounds(y, 0, getHeight()));
 	DE_ASSERT(de::inBounds(z, 0, getDepth()));
 
-	int			pixelSize	= m_format.getPixelSize();
-	deUint8*	pixelPtr	= (deUint8*)getDataPtr() + z*m_slicePitch + y*m_rowPitch + x*pixelSize;
+	deUint8* pixelPtr = (deUint8*)getDataPtr() + z*m_pitch.z() + y*m_pitch.y() + x*m_pitch.x();
 
 	switch (m_format.type)
 	{
@@ -818,26 +838,23 @@
 	DE_ASSERT(de::inBounds(y, 0, getHeight()));
 	DE_ASSERT(de::inBounds(z, 0, getDepth()));
 
+	deUint8* const pixelPtr = (deUint8*)getDataPtr() + z*m_pitch.z() + y*m_pitch.y() + x*m_pitch.x();
+
 	// Optimized fomats.
 	if (m_format.type == TextureFormat::UNORM_INT8)
 	{
 		if (m_format.order == TextureFormat::RGBA)
 		{
-			deUint8* const ptr = (deUint8*)getDataPtr() + z*m_slicePitch + y*m_rowPitch + x*4;
-			writeRGBA8888Float(ptr, color);
+			writeRGBA8888Float(pixelPtr, color);
 			return;
 		}
 		else if (m_format.order == TextureFormat::RGB)
 		{
-			deUint8* const ptr = (deUint8*)getDataPtr() + z*m_slicePitch + y*m_rowPitch + x*3;
-			writeRGB888Float(ptr, color);
+			writeRGB888Float(pixelPtr, color);
 			return;
 		}
 	}
 
-	const int		pixelSize	= m_format.getPixelSize();
-	deUint8* const	pixelPtr	= (deUint8*)getDataPtr() + z*m_slicePitch + y*m_rowPitch + x*pixelSize;
-
 #define PN(VAL, OFFS, BITS)		(normFloatToChannel((VAL), (BITS)) << (OFFS))
 #define PU(VAL, OFFS, BITS)		(uintToChannel((VAL), (BITS)) << (OFFS))
 
@@ -914,8 +931,7 @@
 	DE_ASSERT(de::inBounds(y, 0, getHeight()));
 	DE_ASSERT(de::inBounds(z, 0, getDepth()));
 
-	int			pixelSize	= m_format.getPixelSize();
-	deUint8*	pixelPtr	= (deUint8*)getDataPtr() + z*m_slicePitch + y*m_rowPitch + x*pixelSize;
+	deUint8* pixelPtr = (deUint8*)getDataPtr() + z*m_pitch.z() + y*m_pitch.y() + x*m_pitch.x();
 
 	// Optimized fomats.
 	if (m_format.type == TextureFormat::UNORM_INT8)
@@ -976,8 +992,7 @@
 	DE_ASSERT(de::inBounds(y, 0, getHeight()));
 	DE_ASSERT(de::inBounds(z, 0, getDepth()));
 
-	int			pixelSize	= m_format.getPixelSize();
-	deUint8*	pixelPtr	= (deUint8*)getDataPtr() + z*m_slicePitch + y*m_rowPitch + x*pixelSize;
+	deUint8* pixelPtr = (deUint8*)getDataPtr() + z*m_pitch.z() + y*m_pitch.y() + x*m_pitch.x();
 
 #define PN(VAL, OFFS, BITS) (normFloatToChannel((VAL), (BITS)) << (OFFS))
 
@@ -1013,8 +1028,7 @@
 	DE_ASSERT(de::inBounds(y, 0, getHeight()));
 	DE_ASSERT(de::inBounds(z, 0, getDepth()));
 
-	int			pixelSize	= m_format.getPixelSize();
-	deUint8*	pixelPtr	= (deUint8*)getDataPtr() + z*m_slicePitch + y*m_rowPitch + x*pixelSize;
+	deUint8* pixelPtr = (deUint8*)getDataPtr() + z*m_pitch.z() + y*m_pitch.y() + x*m_pitch.x();
 
 #define PU(VAL, OFFS, BITS) (uintToChannel((deUint32)(VAL), (BITS)) << (OFFS))
 
@@ -1600,13 +1614,13 @@
 
 Vec4 ConstPixelBufferAccess::sample1D (const Sampler& sampler, Sampler::FilterMode filter, float s, int level) const
 {
-	DE_ASSERT(de::inBounds(level, 0, m_height));
+	DE_ASSERT(de::inBounds(level, 0, m_size.y()));
 
 	// Non-normalized coordinates.
 	float u = s;
 
 	if (sampler.normalizedCoords)
-		u = unnormalize(sampler.wrapS, s, m_width);
+		u = unnormalize(sampler.wrapS, s, m_size.x());
 
 	switch (filter)
 	{
@@ -1620,7 +1634,7 @@
 
 Vec4 ConstPixelBufferAccess::sample2D (const Sampler& sampler, Sampler::FilterMode filter, float s, float t, int depth) const
 {
-	DE_ASSERT(de::inBounds(depth, 0, m_depth));
+	DE_ASSERT(de::inBounds(depth, 0, m_size.z()));
 
 	// Non-normalized coordinates.
 	float u = s;
@@ -1628,8 +1642,8 @@
 
 	if (sampler.normalizedCoords)
 	{
-		u = unnormalize(sampler.wrapS, s, m_width);
-		v = unnormalize(sampler.wrapT, t, m_height);
+		u = unnormalize(sampler.wrapS, s, m_size.x());
+		v = unnormalize(sampler.wrapT, t, m_size.y());
 	}
 
 	switch (filter)
@@ -1644,13 +1658,13 @@
 
 Vec4 ConstPixelBufferAccess::sample1DOffset (const Sampler& sampler, Sampler::FilterMode filter, float s, const IVec2& offset) const
 {
-	DE_ASSERT(de::inBounds(offset.y(), 0, m_width));
+	DE_ASSERT(de::inBounds(offset.y(), 0, m_size.x()));
 
 	// Non-normalized coordinates.
 	float u = s;
 
 	if (sampler.normalizedCoords)
-		u = unnormalize(sampler.wrapS, s, m_width);
+		u = unnormalize(sampler.wrapS, s, m_size.x());
 
 	switch (filter)
 	{
@@ -1664,7 +1678,7 @@
 
 Vec4 ConstPixelBufferAccess::sample2DOffset (const Sampler& sampler, Sampler::FilterMode filter, float s, float t, const IVec3& offset) const
 {
-	DE_ASSERT(de::inBounds(offset.z(), 0, m_depth));
+	DE_ASSERT(de::inBounds(offset.z(), 0, m_size.z()));
 
 	// Non-normalized coordinates.
 	float u = s;
@@ -1672,8 +1686,8 @@
 
 	if (sampler.normalizedCoords)
 	{
-		u = unnormalize(sampler.wrapS, s, m_width);
-		v = unnormalize(sampler.wrapT, t, m_height);
+		u = unnormalize(sampler.wrapS, s, m_size.x());
+		v = unnormalize(sampler.wrapT, t, m_size.y());
 	}
 
 	switch (filter)
@@ -1688,7 +1702,7 @@
 
 float ConstPixelBufferAccess::sample1DCompare (const Sampler& sampler, Sampler::FilterMode filter, float ref, float s, const IVec2& offset) const
 {
-	DE_ASSERT(de::inBounds(offset.y(), 0, m_height));
+	DE_ASSERT(de::inBounds(offset.y(), 0, m_size.y()));
 
 	// Format information for comparison function
 	const bool isFixedPointDepth = isFixedPointDepthTextureFormat(m_format);
@@ -1697,7 +1711,7 @@
 	float u = s;
 
 	if (sampler.normalizedCoords)
-		u = unnormalize(sampler.wrapS, s, m_width);
+		u = unnormalize(sampler.wrapS, s, m_size.x());
 
 	switch (filter)
 	{
@@ -1711,7 +1725,7 @@
 
 float ConstPixelBufferAccess::sample2DCompare (const Sampler& sampler, Sampler::FilterMode filter, float ref, float s, float t, const IVec3& offset) const
 {
-	DE_ASSERT(de::inBounds(offset.z(), 0, m_depth));
+	DE_ASSERT(de::inBounds(offset.z(), 0, m_size.z()));
 
 	// Format information for comparison function
 	const bool isFixedPointDepth = isFixedPointDepthTextureFormat(m_format);
@@ -1722,8 +1736,8 @@
 
 	if (sampler.normalizedCoords)
 	{
-		u = unnormalize(sampler.wrapS, s, m_width);
-		v = unnormalize(sampler.wrapT, t, m_height);
+		u = unnormalize(sampler.wrapS, s, m_size.x());
+		v = unnormalize(sampler.wrapT, t, m_size.y());
 	}
 
 	switch (filter)
@@ -1745,9 +1759,9 @@
 
 	if (sampler.normalizedCoords)
 	{
-		u = unnormalize(sampler.wrapS, s, m_width);
-		v = unnormalize(sampler.wrapT, t, m_height);
-		w = unnormalize(sampler.wrapR, r, m_depth);
+		u = unnormalize(sampler.wrapS, s, m_size.x());
+		v = unnormalize(sampler.wrapT, t, m_size.y());
+		w = unnormalize(sampler.wrapR, r, m_size.z());
 	}
 
 	switch (filter)
@@ -1769,9 +1783,9 @@
 
 	if (sampler.normalizedCoords)
 	{
-		u = unnormalize(sampler.wrapS, s, m_width);
-		v = unnormalize(sampler.wrapT, t, m_height);
-		w = unnormalize(sampler.wrapR, r, m_depth);
+		u = unnormalize(sampler.wrapS, s, m_size.x());
+		v = unnormalize(sampler.wrapT, t, m_size.y());
+		w = unnormalize(sampler.wrapR, r, m_size.z());
 	}
 
 	switch (filter)
@@ -1786,25 +1800,19 @@
 
 TextureLevel::TextureLevel (void)
 	: m_format	()
-	, m_width	(0)
-	, m_height	(0)
-	, m_depth	(0)
+	, m_size	(0)
 {
 }
 
 TextureLevel::TextureLevel (const TextureFormat& format)
 	: m_format	(format)
-	, m_width	(0)
-	, m_height	(0)
-	, m_depth	(0)
+	, m_size	(0)
 {
 }
 
 TextureLevel::TextureLevel (const TextureFormat& format, int width, int height, int depth)
 	: m_format	(format)
-	, m_width	(0)
-	, m_height	(0)
-	, m_depth	(0)
+	, m_size	(0)
 {
 	setSize(width, height, depth);
 }
@@ -1823,11 +1831,9 @@
 {
 	int pixelSize = m_format.getPixelSize();
 
-	m_width		= width;
-	m_height	= height;
-	m_depth		= depth;
+	m_size = IVec3(width, height, depth);
 
-	m_data.setStorage(m_width*m_height*m_depth*pixelSize);
+	m_data.setStorage(m_size.x() * m_size.y() * m_size.z() * pixelSize);
 }
 
 Vec4 sampleLevelArray1D (const ConstPixelBufferAccess* levels, int numLevels, const Sampler& sampler, float s, int depth, float lod)
diff --git a/framework/common/tcuTexture.hpp b/framework/common/tcuTexture.hpp
index c4b6e85..fd69111 100644
--- a/framework/common/tcuTexture.hpp
+++ b/framework/common/tcuTexture.hpp
@@ -228,6 +228,9 @@
 	}
 };
 
+// Calculate pitches for pixel data with no padding.
+IVec3 calculatePackedPitch (const TextureFormat& format, const IVec3& size);
+
 class TextureLevel;
 
 /*--------------------------------------------------------------------*//*!
@@ -246,17 +249,20 @@
 							ConstPixelBufferAccess		(void);
 							ConstPixelBufferAccess		(const TextureLevel& level);
 							ConstPixelBufferAccess		(const TextureFormat& format, int width, int height, int depth, const void* data);
+							ConstPixelBufferAccess		(const TextureFormat& format, const IVec3& size, const void* data);
 							ConstPixelBufferAccess		(const TextureFormat& format, int width, int height, int depth, int rowPitch, int slicePitch, const void* data);
+							ConstPixelBufferAccess		(const TextureFormat& format, const IVec3& size, const IVec3& pitch, const void* data);
 
-	const TextureFormat&	getFormat					(void) const	{ return m_format;		}
-	int						getWidth					(void) const	{ return m_width;		}
-	int						getHeight					(void) const	{ return m_height;		}
-	int						getDepth					(void) const	{ return m_depth;		}
-	int						getRowPitch					(void) const	{ return m_rowPitch;	}
-	int						getSlicePitch				(void) const	{ return m_slicePitch;	}
+	const TextureFormat&	getFormat					(void) const	{ return m_format;					}
+	const IVec3&			getSize						(void) const	{ return m_size;					}
+	int						getWidth					(void) const	{ return m_size.x();				}
+	int						getHeight					(void) const	{ return m_size.y();				}
+	int						getDepth					(void) const	{ return m_size.z();				}
+	int						getRowPitch					(void) const	{ return m_pitch.y();				}
+	int						getSlicePitch				(void) const	{ return m_pitch.z();				}
 
-	const void*				getDataPtr					(void) const	{ return m_data;		}
-	int						getDataSize					(void) const	{ return m_depth*m_slicePitch;	}
+	const void*				getDataPtr					(void) const	{ return m_data;					}
+	int						getDataSize					(void) const	{ return m_size.z()*m_pitch.z();	}
 
 	Vec4					getPixel					(int x, int y, int z = 0) const;
 	IVec4					getPixelInt					(int x, int y, int z = 0) const;
@@ -281,11 +287,8 @@
 
 protected:
 	TextureFormat			m_format;
-	int						m_width;
-	int						m_height;
-	int						m_depth;
-	int						m_rowPitch;
-	int						m_slicePitch;
+	IVec3					m_size;
+	IVec3					m_pitch;	//!< (pixelPitch, rowPitch, slicePitch)
 	mutable void*			m_data;
 };
 
@@ -304,7 +307,9 @@
 						PixelBufferAccess	(void) {}
 						PixelBufferAccess	(TextureLevel& level);
 						PixelBufferAccess	(const TextureFormat& format, int width, int height, int depth, void* data);
+						PixelBufferAccess	(const TextureFormat& format, const IVec3& size, void* data);
 						PixelBufferAccess	(const TextureFormat& format, int width, int height, int depth, int rowPitch, int slicePitch, void* data);
+						PixelBufferAccess	(const TextureFormat& format, const IVec3& size, const IVec3& pitch, void* data);
 
 	void*				getDataPtr			(void) const { return m_data; }
 
@@ -332,26 +337,25 @@
 								TextureLevel		(const TextureFormat& format, int width, int height, int depth = 1);
 								~TextureLevel		(void);
 
-	int							getWidth			(void) const	{ return m_width;	}
-	int							getHeight			(void) const	{ return m_height;	}
-	int							getDepth			(void) const	{ return m_depth;	}
-	bool						isEmpty				(void) const	{ return m_width == 0 || m_height == 0 || m_depth == 0; }
+	const IVec3&				getSize				(void) const	{ return m_size;		}
+	int							getWidth			(void) const	{ return m_size.x();	}
+	int							getHeight			(void) const	{ return m_size.y();	}
+	int							getDepth			(void) const	{ return m_size.z();	}
+	bool						isEmpty				(void) const	{ return m_size.x() * m_size.y() * m_size.z() == 0; }
 	const TextureFormat			getFormat			(void) const	{ return m_format;	}
 
 	void						setStorage			(const TextureFormat& format, int width, int heigth, int depth = 1);
 	void						setSize				(int width, int height, int depth = 1);
 
-	PixelBufferAccess			getAccess			(void)			{ return PixelBufferAccess(m_format, m_width, m_height, m_depth, getPtr());			}
-	ConstPixelBufferAccess		getAccess			(void) const	{ return ConstPixelBufferAccess(m_format, m_width, m_height, m_depth, getPtr());	}
+	PixelBufferAccess			getAccess			(void)			{ return PixelBufferAccess(m_format, m_size, calculatePackedPitch(m_format, m_size), getPtr());			}
+	ConstPixelBufferAccess		getAccess			(void) const	{ return ConstPixelBufferAccess(m_format, m_size, calculatePackedPitch(m_format, m_size), getPtr());	}
 
 private:
 	void*						getPtr				(void)			{ return m_data.getPtr(); }
 	const void*					getPtr				(void) const	{ return m_data.getPtr(); }
 
 	TextureFormat				m_format;
-	int							m_width;
-	int							m_height;
-	int							m_depth;
+	IVec3						m_size;
 	de::ArrayBuffer<deUint8>	m_data;
 
 	friend class ConstPixelBufferAccess;
diff --git a/framework/delibs/deutil/deSocket.c b/framework/delibs/deutil/deSocket.c
index c5cfb50..fa8eced 100644
--- a/framework/delibs/deutil/deSocket.c
+++ b/framework/delibs/deutil/deSocket.c
@@ -159,6 +159,7 @@
 
 	/* WinSock spesific. */
 #	include <WinSock2.h>
+#	include <WS2tcpip.h>
 #	include <WinDef.h>
 
 static deBool initWinsock (void)
@@ -214,12 +215,12 @@
 
 /* Common socket functions. */
 
-static int deSocketFamilyToBsdProtocolFamily (deSocketFamily family)
+static int deSocketFamilyToBsdFamily (deSocketFamily family)
 {
 	switch (family)
 	{
-		case DE_SOCKETFAMILY_INET4:	return PF_INET;
-		case DE_SOCKETFAMILY_INET6:	return PF_INET6;
+		case DE_SOCKETFAMILY_INET4:	return AF_INET;
+		case DE_SOCKETFAMILY_INET6:	return AF_INET6;
 		default:
 			DE_ASSERT(DE_FALSE);
 			return 0;
@@ -250,59 +251,94 @@
 	}
 }
 
-static deBool deSocketAddressToBsdAddress (const deSocketAddress* address, struct sockaddr* bsdAddr, int* bsdAddrSize, deSocketFamily* family)
+static deBool deSocketAddressToBsdAddress (const deSocketAddress* address, int bsdAddrBufSize, struct sockaddr* bsdAddr, int* bsdAddrLen)
 {
-	deBool			hasHost		= address->host != DE_NULL;
-	deUint8			hostAddr[16];	/*!< Binary representation. */
+	deMemset(bsdAddr, 0, bsdAddrBufSize);
 
-	deMemset(bsdAddr, 0, sizeof(struct sockaddr));
-
-	*family = address->family;
-
-	/* If host is supplied, use gethostbyname() to determine actual family. */
-	if (hasHost)
+	/* Resolve host. */
+	if (address->host != DE_NULL)
 	{
-		struct hostent* host = gethostbyname(address->host);
+		struct addrinfo*	result	= DE_NULL;
+		struct addrinfo		hints;
 
-		if (!host)
+		deMemset(&hints, 0, sizeof(hints));
+		hints.ai_family		= deSocketFamilyToBsdFamily(address->family);
+		hints.ai_socktype	= deSocketTypeToBsdType(address->type);
+		hints.ai_protocol	= deSocketProtocolToBsdProtocol(address->protocol);
+
+		if (getaddrinfo(address->host, DE_NULL, &hints, &result) != 0 || !result)
+		{
+			if (result)
+				freeaddrinfo(result);
 			return DE_FALSE;
+		}
 
-		if (host->h_addrtype == AF_INET)
-			*family = DE_SOCKETFAMILY_INET4;
-		else if (host->h_addrtype == AF_INET6)
-			*family = DE_SOCKETFAMILY_INET6;
+		/* \note Always uses first address. */
+
+		if (bsdAddrBufSize < (int)result->ai_addrlen)
+		{
+			DE_ASSERT(!"Too small bsdAddr buffer");
+			freeaddrinfo(result);
+			return DE_FALSE;
+		}
+
+		*bsdAddrLen	= (int)result->ai_addrlen;
+
+		deMemcpy(bsdAddr, result->ai_addr, (int)result->ai_addrlen);
+		freeaddrinfo(result);
+
+		/* Add port. */
+		if (bsdAddr->sa_family == AF_INET)
+		{
+			if (*bsdAddrLen < (int)sizeof(struct sockaddr_in))
+				return DE_FALSE;
+			((struct sockaddr_in*)bsdAddr)->sin_port = htons((deUint16)address->port);
+		}
+		else if (bsdAddr->sa_family == AF_INET6)
+		{
+			if (*bsdAddrLen < (int)sizeof(struct sockaddr_in6))
+				return DE_FALSE;
+			((struct sockaddr_in6*)bsdAddr)->sin6_port = htons((deUint16)address->port);
+		}
 		else
 			return DE_FALSE;
 
-		DE_ASSERT((host->h_addrtype == AF_INET && host->h_length == 4) ||
-				  (host->h_addrtype == AF_INET6 && host->h_length == 16));
-
-		/* Use first address. */
-		if (host->h_addr_list[0] != 0)
-			deMemcpy(hostAddr, host->h_addr_list[0], host->h_length);
-		else
-			return DE_FALSE;
+		return DE_TRUE;
 	}
-
-	if (*family == DE_SOCKETFAMILY_INET4)
+	else if (address->family == DE_SOCKETFAMILY_INET4)
 	{
 		struct sockaddr_in* addr4 = (struct sockaddr_in*)bsdAddr;
 
-		addr4->sin_port		= htons((deUint16)address->port);
-		addr4->sin_family	= AF_INET;
+		if (bsdAddrBufSize < (int)sizeof(struct sockaddr_in))
+		{
+			DE_ASSERT(!"Too small bsdAddr buffer");
+			return DE_FALSE;
+		}
 
-		if (hasHost)
-			deMemcpy(&addr4->sin_addr, hostAddr, 4);
-		else
-			addr4->sin_addr.s_addr = INADDR_ANY;
+		addr4->sin_port			= htons((deUint16)address->port);
+		addr4->sin_family		= AF_INET;
+		addr4->sin_addr.s_addr	= INADDR_ANY;
 
-		*bsdAddrSize = sizeof(struct sockaddr_in);
+		*bsdAddrLen	= sizeof(struct sockaddr_in);
+
 		return DE_TRUE;
 	}
-	else if (*family == DE_SOCKETFAMILY_INET6)
+	else if (address->family == DE_SOCKETFAMILY_INET6)
 	{
-		DE_ASSERT(!"TODO");
-		return DE_FALSE;
+		struct sockaddr_in6* addr6 = (struct sockaddr_in6*)bsdAddr;
+
+		if (bsdAddrBufSize < (int)sizeof(struct sockaddr_in6))
+		{
+			DE_ASSERT(!"Too small bsdAddr buffer");
+			return DE_FALSE;
+		}
+
+		addr6->sin6_port	= htons((deUint16)address->port);
+		addr6->sin6_family	= AF_INET6;
+
+		*bsdAddrLen	= sizeof(struct sockaddr_in6);
+
+		return DE_TRUE;
 	}
 	else
 		return DE_FALSE;
@@ -320,15 +356,26 @@
 		deSocketAddress_setFamily(address, DE_SOCKETFAMILY_INET4);
 		deSocketAddress_setPort(address, ntohs(addr4->sin_port));
 
-#if defined(DE_USE_WINSOCK)
-		deSocketAddress_setHost(address, inet_ntoa(addr4->sin_addr));
-#else
 		{
-			char buf[16];
-			inet_ntop(AF_INET, &addr4->sin_addr, buf, sizeof(buf));
+			char buf[16]; /* Max valid address takes 3*4 + 3 = 15 chars */
+			inet_ntop(AF_INET, (void*)&addr4->sin_addr, buf, sizeof(buf));
 			deSocketAddress_setHost(address, buf);
 		}
-#endif
+	}
+	else if (bsdAddr->sa_family == AF_INET6)
+	{
+		const struct sockaddr_in6* addr6 = (const struct sockaddr_in6*)bsdAddr;
+		DE_ASSERT(addrLen >= (int)sizeof(struct sockaddr_in6));
+		DE_UNREF(addrLen);
+
+		deSocketAddress_setFamily(address, DE_SOCKETFAMILY_INET6);
+		deSocketAddress_setPort(address, ntohs(addr6->sin6_port));
+
+		{
+			char buf[40]; /* Max valid address takes 8*4 + 7 = 39 chars */
+			inet_ntop(AF_INET6, (void*)&addr6->sin6_addr, buf, sizeof(buf));
+			deSocketAddress_setHost(address, buf);
+		}
 	}
 	else
 		DE_ASSERT(DE_FALSE);
@@ -343,7 +390,7 @@
 #if defined(DE_USE_WINSOCK)
 	/* Make sure WSA is up. */
 	if (!initWinsock())
-		return 0;
+		return DE_NULL;
 #endif
 
 	sock->stateLock	= deMutex_create(0);
@@ -423,19 +470,19 @@
 deBool deSocket_listen (deSocket* sock, const deSocketAddress* address)
 {
 	const int			backlogSize	= 4;
-	struct sockaddr		bsdAddr;
+	deUint8				bsdAddrBuf[sizeof(struct sockaddr_in6)];
+	struct sockaddr*	bsdAddr		= (struct sockaddr*)&bsdAddrBuf[0];
 	int					bsdAddrLen;
-	deSocketFamily		family;
 
 	if (sock->state != DE_SOCKETSTATE_CLOSED)
 		return DE_FALSE;
 
 	/* Resolve address. */
-	if (!deSocketAddressToBsdAddress(address, &bsdAddr, &bsdAddrLen, &family))
+	if (!deSocketAddressToBsdAddress(address, (int)sizeof(bsdAddrBuf), bsdAddr, &bsdAddrLen))
 		return DE_FALSE;
 
 	/* Create socket. */
-	sock->handle = socket(deSocketFamilyToBsdProtocolFamily(family), deSocketTypeToBsdType(address->type), deSocketProtocolToBsdProtocol(address->protocol));
+	sock->handle = socket(bsdAddr->sa_family, deSocketTypeToBsdType(address->type), deSocketProtocolToBsdProtocol(address->protocol));
 	if (!deSocketHandleIsValid(sock->handle))
 		return DE_FALSE;
 
@@ -448,7 +495,7 @@
 	}
 
 	/* Bind to address. */
-	if (bind(sock->handle, &bsdAddr, bsdAddrLen) != 0)
+	if (bind(sock->handle, bsdAddr, bsdAddrLen) != 0)
 	{
 		deSocket_close(sock);
 		return DE_FALSE;
@@ -468,17 +515,22 @@
 
 deSocket* deSocket_accept (deSocket* sock, deSocketAddress* clientAddress)
 {
-	deSocketHandle		newFd	= DE_INVALID_SOCKET_HANDLE;
-	deSocket*			newSock	= DE_NULL;
-	struct sockaddr		addr;
-	int					addrLen	= (int)sizeof(addr);
+	deSocketHandle		newFd		= DE_INVALID_SOCKET_HANDLE;
+	deSocket*			newSock		= DE_NULL;
+	deUint8				bsdAddrBuf[sizeof(struct sockaddr_in6)];
+	struct sockaddr*	bsdAddr		= (struct sockaddr*)&bsdAddrBuf[0];
+#if defined(DE_USE_WINSOCK)
+	int					bsdAddrLen	= (int)sizeof(bsdAddrBuf);
+#else
+	socklen_t			bsdAddrLen	= (socklen_t)sizeof(bsdAddrBuf);
+#endif
 
-	deMemset(&addr, 0, sizeof(addr));
+	deMemset(bsdAddr, 0, (int)bsdAddrLen);
 
 #if defined(DE_USE_WINSOCK)
-	newFd = accept(sock->handle, (struct sockaddr*)&addr, &addrLen);
+	newFd = accept(sock->handle, bsdAddr, &bsdAddrLen);
 #else
-	newFd = accept(sock->handle, (struct sockaddr*)&addr, (socklen_t*)&addrLen);
+	newFd = accept(sock->handle, bsdAddr, (socklen_t*)&bsdAddrLen);
 #endif
 	if (!deSocketHandleIsValid(newFd))
 		return DE_NULL;
@@ -500,29 +552,37 @@
 	newSock->openChannels	= DE_SOCKETCHANNEL_BOTH;
 
 	if (clientAddress)
-		deBsdAddressToSocketAddress(clientAddress, &addr, addrLen);
+		deBsdAddressToSocketAddress(clientAddress, bsdAddr, (int)bsdAddrLen);
 
 	return newSock;
 }
 
 deBool deSocket_connect (deSocket* sock, const deSocketAddress* address)
 {
-	struct sockaddr		bsdAddr;
+	deUint8				bsdAddrBuf[sizeof(struct sockaddr_in6)];
+	struct sockaddr*	bsdAddr		= (struct sockaddr*)&bsdAddrBuf[0];
 	int					bsdAddrLen;
-	deSocketFamily		family;
 
 	/* Resolve address. */
-	if (!deSocketAddressToBsdAddress(address, &bsdAddr, &bsdAddrLen, &family))
+	if (!deSocketAddressToBsdAddress(address, (int)sizeof(bsdAddrBuf), bsdAddr, &bsdAddrLen))
 		return DE_FALSE;
 
 	/* Create socket. */
-	sock->handle = socket(deSocketFamilyToBsdProtocolFamily(family), deSocketTypeToBsdType(address->type), deSocketProtocolToBsdProtocol(address->protocol));
+	sock->handle = socket(bsdAddr->sa_family, deSocketTypeToBsdType(address->type), deSocketProtocolToBsdProtocol(address->protocol));
 	if (!deSocketHandleIsValid(sock->handle))
 		return DE_FALSE;
 
 	/* Connect. */
-	if (connect(sock->handle, &bsdAddr, bsdAddrLen) != 0)
+	if (connect(sock->handle, bsdAddr, bsdAddrLen) != 0)
+	{
+#if defined(DE_USE_WINSOCK)
+		closesocket(sock->handle);
+#else
+		close(sock->handle);
+#endif
+		sock->handle = DE_INVALID_SOCKET_HANDLE;
 		return DE_FALSE;
+	}
 
 	sock->state			= DE_SOCKETSTATE_CONNECTED;
 	sock->openChannels	= DE_SOCKETCHANNEL_BOTH;
diff --git a/framework/delibs/deutil/deTimer.c b/framework/delibs/deutil/deTimer.c
index 36f8190..bf8ceae 100644
--- a/framework/delibs/deutil/deTimer.c
+++ b/framework/delibs/deutil/deTimer.c
@@ -131,7 +131,9 @@
 			if (success)
 			{
 				/* Wait for all callbacks to complete. */
-				DE_VERIFY(WaitForSingleObject(waitEvent, INFINITE) == WAIT_OBJECT_0);
+				DWORD res = WaitForSingleObject(waitEvent, INFINITE);
+				DE_ASSERT(res == WAIT_OBJECT_0);
+				DE_UNREF(res);
 				break;
 			}
 			else
diff --git a/framework/egl/CMakeLists.txt b/framework/egl/CMakeLists.txt
index 5346e74..41080c9 100644
--- a/framework/egl/CMakeLists.txt
+++ b/framework/egl/CMakeLists.txt
@@ -1,5 +1,7 @@
 # EGL utilities
 
+add_subdirectory(wrapper)
+
 # GLContextFactory uses glu
 include_directories(../opengl)
 
@@ -12,16 +14,12 @@
 	egluConfigInfo.hpp
 	egluDefs.cpp
 	egluDefs.hpp
-	egluExtensions.cpp
-	egluExtensions.hpp
 	egluGLContextFactory.cpp
 	egluGLContextFactory.hpp
 	egluGLFunctionLoader.cpp
 	egluGLFunctionLoader.hpp
 	egluGLUtil.cpp
 	egluGLUtil.hpp
-	egluHeaderWrapper.cpp
-	egluHeaderWrapper.hpp
 	egluNativeDisplay.cpp
 	egluNativeDisplay.hpp
 	egluNativePixmap.cpp
@@ -38,9 +36,7 @@
 	egluUtil.hpp
 	egluUnique.hpp
 	egluUnique.cpp
-	tcuEgl.cpp
-	tcuEgl.hpp
 	)
 
 add_library(eglutil STATIC ${EGLUTIL_SRCS})
-target_link_libraries(eglutil tcutil glutil glwrapper ${DEQP_EGL_LIBRARIES})
+target_link_libraries(eglutil tcutil eglwrapper glutil glwrapper ${DEQP_EGL_LIBRARIES})
diff --git a/framework/egl/egluCallLogWrapper.cpp b/framework/egl/egluCallLogWrapper.cpp
index 75e54ca..dc87585 100644
--- a/framework/egl/egluCallLogWrapper.cpp
+++ b/framework/egl/egluCallLogWrapper.cpp
@@ -23,6 +23,8 @@
 
 #include "egluCallLogWrapper.hpp"
 #include "egluStrUtil.hpp"
+#include "eglwLibrary.hpp"
+#include "eglwEnums.hpp"
 #include "deStringUtil.hpp"
 #include "deInt32.h"
 
@@ -32,8 +34,9 @@
 using tcu::toHex;
 using tcu::TestLog;
 
-CallLogWrapper::CallLogWrapper (TestLog& log)
-	: m_log			(log)
+CallLogWrapper::CallLogWrapper (const eglw::Library& egl, TestLog& log)
+	: m_egl			(egl)
+	, m_log			(log)
 	, m_enableLog	(false)
 {
 }
@@ -186,11 +189,11 @@
 class EGLDisplayFmt
 {
 public:
-	EGLDisplay display;
-	EGLDisplayFmt (EGLDisplay display_) : display(display_) {}
+	eglw::EGLDisplay display;
+	EGLDisplayFmt (eglw::EGLDisplay display_) : display(display_) {}
 };
 
-inline EGLDisplayFmt getEGLDisplayStr (EGLDisplay display) { return EGLDisplayFmt(display); }
+inline EGLDisplayFmt getEGLDisplayStr (eglw::EGLDisplay display) { return EGLDisplayFmt(display); }
 
 inline std::ostream& operator<< (std::ostream& str, const EGLDisplayFmt& fmt)
 {
@@ -205,18 +208,18 @@
 class EGLSurfaceFmt
 {
 public:
-	EGLSurface display;
-	EGLSurfaceFmt (EGLSurface display_) : display(display_) {}
+	eglw::EGLSurface surface;
+	EGLSurfaceFmt (eglw::EGLSurface surface_) : surface(surface_) {}
 };
 
-inline EGLSurfaceFmt getEGLSurfaceStr (EGLSurface display) { return EGLSurfaceFmt(display); }
+inline EGLSurfaceFmt getEGLSurfaceStr (eglw::EGLSurface surface) { return EGLSurfaceFmt(surface); }
 
 inline std::ostream& operator<< (std::ostream& str, const EGLSurfaceFmt& fmt)
 {
-	if (fmt.display == EGL_NO_SURFACE)
+	if (fmt.surface == EGL_NO_SURFACE)
 		return str << "EGL_NO_SURFACE";
 	else
-		return str << toHex(fmt.display);
+		return str << toHex(fmt.surface);
 }
 
 // EGLContext formatter
@@ -224,18 +227,18 @@
 class EGLContextFmt
 {
 public:
-	EGLContext display;
-	EGLContextFmt (EGLContext display_) : display(display_) {}
+	eglw::EGLContext context;
+	EGLContextFmt (eglw::EGLContext context_) : context(context_) {}
 };
 
-inline EGLContextFmt getEGLContextStr (EGLContext display) { return EGLContextFmt(display); }
+inline EGLContextFmt getEGLContextStr (eglw::EGLContext context) { return EGLContextFmt(context); }
 
 inline std::ostream& operator<< (std::ostream& str, const EGLContextFmt& fmt)
 {
-	if (fmt.display == EGL_NO_CONTEXT)
+	if (fmt.context == EGL_NO_CONTEXT)
 		return str << "EGL_NO_CONTEXT";
 	else
-		return str << toHex(fmt.display);
+		return str << toHex(fmt.context);
 }
 
 // API entry-point implementations are auto-generated
diff --git a/framework/egl/egluCallLogWrapper.hpp b/framework/egl/egluCallLogWrapper.hpp
index 825ae38..43e0994 100644
--- a/framework/egl/egluCallLogWrapper.hpp
+++ b/framework/egl/egluCallLogWrapper.hpp
@@ -25,7 +25,12 @@
 
 #include "tcuDefs.hpp"
 #include "tcuTestLog.hpp"
-#include "egluHeaderWrapper.hpp"
+#include "eglwDefs.hpp"
+
+namespace eglw
+{
+class Library;
+}
 
 namespace eglu
 {
@@ -33,17 +38,18 @@
 class CallLogWrapper
 {
 public:
-						CallLogWrapper			(tcu::TestLog& log);
-						~CallLogWrapper			(void);
+							CallLogWrapper			(const eglw::Library& egl, tcu::TestLog& log);
+							~CallLogWrapper			(void);
 
 // EGL API is exposed as member functions
 #include "egluCallLogWrapperApi.inl"
 
-	void				enableLogging			(bool enable)	{ m_enableLog = enable; }
+	void					enableLogging			(bool enable)	{ m_enableLog = enable; }
 
 private:
-	tcu::TestLog&		m_log;
-	bool				m_enableLog;
+	const eglw::Library&	m_egl;
+	tcu::TestLog&			m_log;
+	bool					m_enableLog;
 };
 
 } // eglu
diff --git a/framework/egl/egluCallLogWrapper.inl b/framework/egl/egluCallLogWrapper.inl
index ee613a8..0d220a6 100644
--- a/framework/egl/egluCallLogWrapper.inl
+++ b/framework/egl/egluCallLogWrapper.inl
@@ -4,31 +4,31 @@
  * Generated from Khronos EGL API description (egl.xml) revision 28861.
  */
 
-EGLBoolean CallLogWrapper::eglBindAPI (EGLenum api)
+eglw::EGLBoolean CallLogWrapper::eglBindAPI (eglw::EGLenum api)
 {
 	if (m_enableLog)
 		m_log << TestLog::Message << "eglBindAPI(" << getAPIStr(api) << ");" << TestLog::EndMessage;
-	EGLBoolean returnValue = ::eglBindAPI(api);
+	eglw::EGLBoolean returnValue = m_egl.bindAPI(api);
 	if (m_enableLog)
 		m_log << TestLog::Message << "// " << getBooleanStr(returnValue) << " returned" << TestLog::EndMessage;
 	return returnValue;
 }
 
-EGLBoolean CallLogWrapper::eglBindTexImage (EGLDisplay dpy, EGLSurface surface, EGLint buffer)
+eglw::EGLBoolean CallLogWrapper::eglBindTexImage (eglw::EGLDisplay dpy, eglw::EGLSurface surface, eglw::EGLint buffer)
 {
 	if (m_enableLog)
 		m_log << TestLog::Message << "eglBindTexImage(" << dpy << ", " << toHex(surface) << ", " << buffer << ");" << TestLog::EndMessage;
-	EGLBoolean returnValue = ::eglBindTexImage(dpy, surface, buffer);
+	eglw::EGLBoolean returnValue = m_egl.bindTexImage(dpy, surface, buffer);
 	if (m_enableLog)
 		m_log << TestLog::Message << "// " << getBooleanStr(returnValue) << " returned" << TestLog::EndMessage;
 	return returnValue;
 }
 
-EGLBoolean CallLogWrapper::eglChooseConfig (EGLDisplay dpy, const EGLint *attrib_list, EGLConfig *configs, EGLint config_size, EGLint *num_config)
+eglw::EGLBoolean CallLogWrapper::eglChooseConfig (eglw::EGLDisplay dpy, const eglw::EGLint *attrib_list, eglw::EGLConfig *configs, eglw::EGLint config_size, eglw::EGLint *num_config)
 {
 	if (m_enableLog)
 		m_log << TestLog::Message << "eglChooseConfig(" << dpy << ", " << getConfigAttribListStr(attrib_list) << ", " << configs << ", " << config_size << ", " << num_config << ");" << TestLog::EndMessage;
-	EGLBoolean returnValue = ::eglChooseConfig(dpy, attrib_list, configs, config_size, num_config);
+	eglw::EGLBoolean returnValue = m_egl.chooseConfig(dpy, attrib_list, configs, config_size, num_config);
 	if (m_enableLog)
 	{
 		m_log << TestLog::Message << "// configs = " << getPointerStr(configs, (num_config && returnValue) ? deMin32(config_size, *num_config) : 0) << TestLog::EndMessage;
@@ -39,91 +39,161 @@
 	return returnValue;
 }
 
-EGLBoolean CallLogWrapper::eglCopyBuffers (EGLDisplay dpy, EGLSurface surface, EGLNativePixmapType target)
+eglw::EGLint CallLogWrapper::eglClientWaitSync (eglw::EGLDisplay dpy, eglw::EGLSync sync, eglw::EGLint flags, eglw::EGLTime timeout)
 {
 	if (m_enableLog)
-		m_log << TestLog::Message << "eglCopyBuffers(" << dpy << ", " << toHex(surface) << ", " << toHex(target) << ");" << TestLog::EndMessage;
-	EGLBoolean returnValue = ::eglCopyBuffers(dpy, surface, target);
-	if (m_enableLog)
-		m_log << TestLog::Message << "// " << getBooleanStr(returnValue) << " returned" << TestLog::EndMessage;
-	return returnValue;
-}
-
-EGLContext CallLogWrapper::eglCreateContext (EGLDisplay dpy, EGLConfig config, EGLContext share_context, const EGLint *attrib_list)
-{
-	if (m_enableLog)
-		m_log << TestLog::Message << "eglCreateContext(" << dpy << ", " << toHex(config) << ", " << share_context << ", " << getContextAttribListStr(attrib_list) << ");" << TestLog::EndMessage;
-	EGLContext returnValue = ::eglCreateContext(dpy, config, share_context, attrib_list);
+		m_log << TestLog::Message << "eglClientWaitSync(" << dpy << ", " << sync << ", " << flags << ", " << timeout << ");" << TestLog::EndMessage;
+	eglw::EGLint returnValue = m_egl.clientWaitSync(dpy, sync, flags, timeout);
 	if (m_enableLog)
 		m_log << TestLog::Message << "// " << returnValue << " returned" << TestLog::EndMessage;
 	return returnValue;
 }
 
-EGLSurface CallLogWrapper::eglCreatePbufferFromClientBuffer (EGLDisplay dpy, EGLenum buftype, EGLClientBuffer buffer, EGLConfig config, const EGLint *attrib_list)
+eglw::EGLBoolean CallLogWrapper::eglCopyBuffers (eglw::EGLDisplay dpy, eglw::EGLSurface surface, eglw::EGLNativePixmapType target)
+{
+	if (m_enableLog)
+		m_log << TestLog::Message << "eglCopyBuffers(" << dpy << ", " << toHex(surface) << ", " << toHex(target) << ");" << TestLog::EndMessage;
+	eglw::EGLBoolean returnValue = m_egl.copyBuffers(dpy, surface, target);
+	if (m_enableLog)
+		m_log << TestLog::Message << "// " << getBooleanStr(returnValue) << " returned" << TestLog::EndMessage;
+	return returnValue;
+}
+
+eglw::EGLContext CallLogWrapper::eglCreateContext (eglw::EGLDisplay dpy, eglw::EGLConfig config, eglw::EGLContext share_context, const eglw::EGLint *attrib_list)
+{
+	if (m_enableLog)
+		m_log << TestLog::Message << "eglCreateContext(" << dpy << ", " << toHex(config) << ", " << share_context << ", " << getContextAttribListStr(attrib_list) << ");" << TestLog::EndMessage;
+	eglw::EGLContext returnValue = m_egl.createContext(dpy, config, share_context, attrib_list);
+	if (m_enableLog)
+		m_log << TestLog::Message << "// " << returnValue << " returned" << TestLog::EndMessage;
+	return returnValue;
+}
+
+eglw::EGLImage CallLogWrapper::eglCreateImage (eglw::EGLDisplay dpy, eglw::EGLContext ctx, eglw::EGLenum target, eglw::EGLClientBuffer buffer, const eglw::EGLint *attrib_list)
+{
+	if (m_enableLog)
+		m_log << TestLog::Message << "eglCreateImage(" << dpy << ", " << ctx << ", " << toHex(target) << ", " << toHex(buffer) << ", " << attrib_list << ");" << TestLog::EndMessage;
+	eglw::EGLImage returnValue = m_egl.createImage(dpy, ctx, target, buffer, attrib_list);
+	if (m_enableLog)
+		m_log << TestLog::Message << "// " << returnValue << " returned" << TestLog::EndMessage;
+	return returnValue;
+}
+
+eglw::EGLSurface CallLogWrapper::eglCreatePbufferFromClientBuffer (eglw::EGLDisplay dpy, eglw::EGLenum buftype, eglw::EGLClientBuffer buffer, eglw::EGLConfig config, const eglw::EGLint *attrib_list)
 {
 	if (m_enableLog)
 		m_log << TestLog::Message << "eglCreatePbufferFromClientBuffer(" << dpy << ", " << toHex(buftype) << ", " << toHex(buffer) << ", " << toHex(config) << ", " << attrib_list << ");" << TestLog::EndMessage;
-	EGLSurface returnValue = ::eglCreatePbufferFromClientBuffer(dpy, buftype, buffer, config, attrib_list);
+	eglw::EGLSurface returnValue = m_egl.createPbufferFromClientBuffer(dpy, buftype, buffer, config, attrib_list);
 	if (m_enableLog)
 		m_log << TestLog::Message << "// " << toHex(returnValue) << " returned" << TestLog::EndMessage;
 	return returnValue;
 }
 
-EGLSurface CallLogWrapper::eglCreatePbufferSurface (EGLDisplay dpy, EGLConfig config, const EGLint *attrib_list)
+eglw::EGLSurface CallLogWrapper::eglCreatePbufferSurface (eglw::EGLDisplay dpy, eglw::EGLConfig config, const eglw::EGLint *attrib_list)
 {
 	if (m_enableLog)
 		m_log << TestLog::Message << "eglCreatePbufferSurface(" << dpy << ", " << toHex(config) << ", " << getSurfaceAttribListStr(attrib_list) << ");" << TestLog::EndMessage;
-	EGLSurface returnValue = ::eglCreatePbufferSurface(dpy, config, attrib_list);
+	eglw::EGLSurface returnValue = m_egl.createPbufferSurface(dpy, config, attrib_list);
 	if (m_enableLog)
 		m_log << TestLog::Message << "// " << toHex(returnValue) << " returned" << TestLog::EndMessage;
 	return returnValue;
 }
 
-EGLSurface CallLogWrapper::eglCreatePixmapSurface (EGLDisplay dpy, EGLConfig config, EGLNativePixmapType pixmap, const EGLint *attrib_list)
+eglw::EGLSurface CallLogWrapper::eglCreatePixmapSurface (eglw::EGLDisplay dpy, eglw::EGLConfig config, eglw::EGLNativePixmapType pixmap, const eglw::EGLint *attrib_list)
 {
 	if (m_enableLog)
 		m_log << TestLog::Message << "eglCreatePixmapSurface(" << dpy << ", " << toHex(config) << ", " << toHex(pixmap) << ", " << getSurfaceAttribListStr(attrib_list) << ");" << TestLog::EndMessage;
-	EGLSurface returnValue = ::eglCreatePixmapSurface(dpy, config, pixmap, attrib_list);
+	eglw::EGLSurface returnValue = m_egl.createPixmapSurface(dpy, config, pixmap, attrib_list);
 	if (m_enableLog)
 		m_log << TestLog::Message << "// " << toHex(returnValue) << " returned" << TestLog::EndMessage;
 	return returnValue;
 }
 
-EGLSurface CallLogWrapper::eglCreateWindowSurface (EGLDisplay dpy, EGLConfig config, EGLNativeWindowType win, const EGLint *attrib_list)
+eglw::EGLSurface CallLogWrapper::eglCreatePlatformPixmapSurface (eglw::EGLDisplay dpy, eglw::EGLConfig config, void *native_pixmap, const eglw::EGLAttrib *attrib_list)
+{
+	if (m_enableLog)
+		m_log << TestLog::Message << "eglCreatePlatformPixmapSurface(" << dpy << ", " << toHex(config) << ", " << native_pixmap << ", " << attrib_list << ");" << TestLog::EndMessage;
+	eglw::EGLSurface returnValue = m_egl.createPlatformPixmapSurface(dpy, config, native_pixmap, attrib_list);
+	if (m_enableLog)
+		m_log << TestLog::Message << "// " << toHex(returnValue) << " returned" << TestLog::EndMessage;
+	return returnValue;
+}
+
+eglw::EGLSurface CallLogWrapper::eglCreatePlatformWindowSurface (eglw::EGLDisplay dpy, eglw::EGLConfig config, void *native_window, const eglw::EGLAttrib *attrib_list)
+{
+	if (m_enableLog)
+		m_log << TestLog::Message << "eglCreatePlatformWindowSurface(" << dpy << ", " << toHex(config) << ", " << native_window << ", " << attrib_list << ");" << TestLog::EndMessage;
+	eglw::EGLSurface returnValue = m_egl.createPlatformWindowSurface(dpy, config, native_window, attrib_list);
+	if (m_enableLog)
+		m_log << TestLog::Message << "// " << toHex(returnValue) << " returned" << TestLog::EndMessage;
+	return returnValue;
+}
+
+eglw::EGLSync CallLogWrapper::eglCreateSync (eglw::EGLDisplay dpy, eglw::EGLenum type, const eglw::EGLAttrib *attrib_list)
+{
+	if (m_enableLog)
+		m_log << TestLog::Message << "eglCreateSync(" << dpy << ", " << toHex(type) << ", " << attrib_list << ");" << TestLog::EndMessage;
+	eglw::EGLSync returnValue = m_egl.createSync(dpy, type, attrib_list);
+	if (m_enableLog)
+		m_log << TestLog::Message << "// " << returnValue << " returned" << TestLog::EndMessage;
+	return returnValue;
+}
+
+eglw::EGLSurface CallLogWrapper::eglCreateWindowSurface (eglw::EGLDisplay dpy, eglw::EGLConfig config, eglw::EGLNativeWindowType win, const eglw::EGLint *attrib_list)
 {
 	if (m_enableLog)
 		m_log << TestLog::Message << "eglCreateWindowSurface(" << dpy << ", " << toHex(config) << ", " << toHex(win) << ", " << getSurfaceAttribListStr(attrib_list) << ");" << TestLog::EndMessage;
-	EGLSurface returnValue = ::eglCreateWindowSurface(dpy, config, win, attrib_list);
+	eglw::EGLSurface returnValue = m_egl.createWindowSurface(dpy, config, win, attrib_list);
 	if (m_enableLog)
 		m_log << TestLog::Message << "// " << toHex(returnValue) << " returned" << TestLog::EndMessage;
 	return returnValue;
 }
 
-EGLBoolean CallLogWrapper::eglDestroyContext (EGLDisplay dpy, EGLContext ctx)
+eglw::EGLBoolean CallLogWrapper::eglDestroyContext (eglw::EGLDisplay dpy, eglw::EGLContext ctx)
 {
 	if (m_enableLog)
 		m_log << TestLog::Message << "eglDestroyContext(" << dpy << ", " << ctx << ");" << TestLog::EndMessage;
-	EGLBoolean returnValue = ::eglDestroyContext(dpy, ctx);
+	eglw::EGLBoolean returnValue = m_egl.destroyContext(dpy, ctx);
 	if (m_enableLog)
 		m_log << TestLog::Message << "// " << getBooleanStr(returnValue) << " returned" << TestLog::EndMessage;
 	return returnValue;
 }
 
-EGLBoolean CallLogWrapper::eglDestroySurface (EGLDisplay dpy, EGLSurface surface)
+eglw::EGLBoolean CallLogWrapper::eglDestroyImage (eglw::EGLDisplay dpy, eglw::EGLImage image)
+{
+	if (m_enableLog)
+		m_log << TestLog::Message << "eglDestroyImage(" << dpy << ", " << image << ");" << TestLog::EndMessage;
+	eglw::EGLBoolean returnValue = m_egl.destroyImage(dpy, image);
+	if (m_enableLog)
+		m_log << TestLog::Message << "// " << getBooleanStr(returnValue) << " returned" << TestLog::EndMessage;
+	return returnValue;
+}
+
+eglw::EGLBoolean CallLogWrapper::eglDestroySurface (eglw::EGLDisplay dpy, eglw::EGLSurface surface)
 {
 	if (m_enableLog)
 		m_log << TestLog::Message << "eglDestroySurface(" << dpy << ", " << toHex(surface) << ");" << TestLog::EndMessage;
-	EGLBoolean returnValue = ::eglDestroySurface(dpy, surface);
+	eglw::EGLBoolean returnValue = m_egl.destroySurface(dpy, surface);
 	if (m_enableLog)
 		m_log << TestLog::Message << "// " << getBooleanStr(returnValue) << " returned" << TestLog::EndMessage;
 	return returnValue;
 }
 
-EGLBoolean CallLogWrapper::eglGetConfigAttrib (EGLDisplay dpy, EGLConfig config, EGLint attribute, EGLint *value)
+eglw::EGLBoolean CallLogWrapper::eglDestroySync (eglw::EGLDisplay dpy, eglw::EGLSync sync)
+{
+	if (m_enableLog)
+		m_log << TestLog::Message << "eglDestroySync(" << dpy << ", " << sync << ");" << TestLog::EndMessage;
+	eglw::EGLBoolean returnValue = m_egl.destroySync(dpy, sync);
+	if (m_enableLog)
+		m_log << TestLog::Message << "// " << getBooleanStr(returnValue) << " returned" << TestLog::EndMessage;
+	return returnValue;
+}
+
+eglw::EGLBoolean CallLogWrapper::eglGetConfigAttrib (eglw::EGLDisplay dpy, eglw::EGLConfig config, eglw::EGLint attribute, eglw::EGLint *value)
 {
 	if (m_enableLog)
 		m_log << TestLog::Message << "eglGetConfigAttrib(" << dpy << ", " << toHex(config) << ", " << getConfigAttribStr(attribute) << ", " << value << ");" << TestLog::EndMessage;
-	EGLBoolean returnValue = ::eglGetConfigAttrib(dpy, config, attribute, value);
+	eglw::EGLBoolean returnValue = m_egl.getConfigAttrib(dpy, config, attribute, value);
 	if (m_enableLog)
 	{
 		m_log << TestLog::Message << "// value = " << getConfigAttribValuePointerStr(attribute, value) << TestLog::EndMessage;
@@ -133,111 +203,131 @@
 	return returnValue;
 }
 
-EGLBoolean CallLogWrapper::eglGetConfigs (EGLDisplay dpy, EGLConfig *configs, EGLint config_size, EGLint *num_config)
+eglw::EGLBoolean CallLogWrapper::eglGetConfigs (eglw::EGLDisplay dpy, eglw::EGLConfig *configs, eglw::EGLint config_size, eglw::EGLint *num_config)
 {
 	if (m_enableLog)
 		m_log << TestLog::Message << "eglGetConfigs(" << dpy << ", " << configs << ", " << config_size << ", " << num_config << ");" << TestLog::EndMessage;
-	EGLBoolean returnValue = ::eglGetConfigs(dpy, configs, config_size, num_config);
+	eglw::EGLBoolean returnValue = m_egl.getConfigs(dpy, configs, config_size, num_config);
 	if (m_enableLog)
 		m_log << TestLog::Message << "// " << getBooleanStr(returnValue) << " returned" << TestLog::EndMessage;
 	return returnValue;
 }
 
-EGLContext CallLogWrapper::eglGetCurrentContext ()
+eglw::EGLContext CallLogWrapper::eglGetCurrentContext ()
 {
 	if (m_enableLog)
 		m_log << TestLog::Message << "eglGetCurrentContext(" << ");" << TestLog::EndMessage;
-	EGLContext returnValue = ::eglGetCurrentContext();
+	eglw::EGLContext returnValue = m_egl.getCurrentContext();
 	if (m_enableLog)
 		m_log << TestLog::Message << "// " << returnValue << " returned" << TestLog::EndMessage;
 	return returnValue;
 }
 
-EGLDisplay CallLogWrapper::eglGetCurrentDisplay ()
+eglw::EGLDisplay CallLogWrapper::eglGetCurrentDisplay ()
 {
 	if (m_enableLog)
 		m_log << TestLog::Message << "eglGetCurrentDisplay(" << ");" << TestLog::EndMessage;
-	EGLDisplay returnValue = ::eglGetCurrentDisplay();
+	eglw::EGLDisplay returnValue = m_egl.getCurrentDisplay();
 	if (m_enableLog)
 		m_log << TestLog::Message << "// " << returnValue << " returned" << TestLog::EndMessage;
 	return returnValue;
 }
 
-EGLSurface CallLogWrapper::eglGetCurrentSurface (EGLint readdraw)
+eglw::EGLSurface CallLogWrapper::eglGetCurrentSurface (eglw::EGLint readdraw)
 {
 	if (m_enableLog)
 		m_log << TestLog::Message << "eglGetCurrentSurface(" << getSurfaceTargetStr(readdraw) << ");" << TestLog::EndMessage;
-	EGLSurface returnValue = ::eglGetCurrentSurface(readdraw);
+	eglw::EGLSurface returnValue = m_egl.getCurrentSurface(readdraw);
 	if (m_enableLog)
 		m_log << TestLog::Message << "// " << toHex(returnValue) << " returned" << TestLog::EndMessage;
 	return returnValue;
 }
 
-EGLDisplay CallLogWrapper::eglGetDisplay (EGLNativeDisplayType display_id)
+eglw::EGLDisplay CallLogWrapper::eglGetDisplay (eglw::EGLNativeDisplayType display_id)
 {
 	if (m_enableLog)
 		m_log << TestLog::Message << "eglGetDisplay(" << toHex(display_id) << ");" << TestLog::EndMessage;
-	EGLDisplay returnValue = ::eglGetDisplay(display_id);
+	eglw::EGLDisplay returnValue = m_egl.getDisplay(display_id);
 	if (m_enableLog)
 		m_log << TestLog::Message << "// " << returnValue << " returned" << TestLog::EndMessage;
 	return returnValue;
 }
 
-EGLint CallLogWrapper::eglGetError ()
+eglw::EGLint CallLogWrapper::eglGetError ()
 {
 	if (m_enableLog)
 		m_log << TestLog::Message << "eglGetError(" << ");" << TestLog::EndMessage;
-	EGLint returnValue = ::eglGetError();
+	eglw::EGLint returnValue = m_egl.getError();
 	if (m_enableLog)
 		m_log << TestLog::Message << "// " << getErrorStr(returnValue) << " returned" << TestLog::EndMessage;
 	return returnValue;
 }
 
-__eglMustCastToProperFunctionPointerType CallLogWrapper::eglGetProcAddress (const char *procname)
+eglw::EGLDisplay CallLogWrapper::eglGetPlatformDisplay (eglw::EGLenum platform, void *native_display, const eglw::EGLAttrib *attrib_list)
+{
+	if (m_enableLog)
+		m_log << TestLog::Message << "eglGetPlatformDisplay(" << toHex(platform) << ", " << native_display << ", " << attrib_list << ");" << TestLog::EndMessage;
+	eglw::EGLDisplay returnValue = m_egl.getPlatformDisplay(platform, native_display, attrib_list);
+	if (m_enableLog)
+		m_log << TestLog::Message << "// " << returnValue << " returned" << TestLog::EndMessage;
+	return returnValue;
+}
+
+eglw::__eglMustCastToProperFunctionPointerType CallLogWrapper::eglGetProcAddress (const char *procname)
 {
 	if (m_enableLog)
 		m_log << TestLog::Message << "eglGetProcAddress(" << getStringStr(procname) << ");" << TestLog::EndMessage;
-	__eglMustCastToProperFunctionPointerType returnValue = ::eglGetProcAddress(procname);
+	eglw::__eglMustCastToProperFunctionPointerType returnValue = m_egl.getProcAddress(procname);
 	if (m_enableLog)
 		m_log << TestLog::Message << "// " << tcu::toHex(returnValue) << " returned" << TestLog::EndMessage;
 	return returnValue;
 }
 
-EGLBoolean CallLogWrapper::eglInitialize (EGLDisplay dpy, EGLint *major, EGLint *minor)
+eglw::EGLBoolean CallLogWrapper::eglGetSyncAttrib (eglw::EGLDisplay dpy, eglw::EGLSync sync, eglw::EGLint attribute, eglw::EGLAttrib *value)
+{
+	if (m_enableLog)
+		m_log << TestLog::Message << "eglGetSyncAttrib(" << dpy << ", " << sync << ", " << attribute << ", " << value << ");" << TestLog::EndMessage;
+	eglw::EGLBoolean returnValue = m_egl.getSyncAttrib(dpy, sync, attribute, value);
+	if (m_enableLog)
+		m_log << TestLog::Message << "// " << getBooleanStr(returnValue) << " returned" << TestLog::EndMessage;
+	return returnValue;
+}
+
+eglw::EGLBoolean CallLogWrapper::eglInitialize (eglw::EGLDisplay dpy, eglw::EGLint *major, eglw::EGLint *minor)
 {
 	if (m_enableLog)
 		m_log << TestLog::Message << "eglInitialize(" << dpy << ", " << major << ", " << minor << ");" << TestLog::EndMessage;
-	EGLBoolean returnValue = ::eglInitialize(dpy, major, minor);
+	eglw::EGLBoolean returnValue = m_egl.initialize(dpy, major, minor);
 	if (m_enableLog)
 		m_log << TestLog::Message << "// " << getBooleanStr(returnValue) << " returned" << TestLog::EndMessage;
 	return returnValue;
 }
 
-EGLBoolean CallLogWrapper::eglMakeCurrent (EGLDisplay dpy, EGLSurface draw, EGLSurface read, EGLContext ctx)
+eglw::EGLBoolean CallLogWrapper::eglMakeCurrent (eglw::EGLDisplay dpy, eglw::EGLSurface draw, eglw::EGLSurface read, eglw::EGLContext ctx)
 {
 	if (m_enableLog)
 		m_log << TestLog::Message << "eglMakeCurrent(" << dpy << ", " << toHex(draw) << ", " << toHex(read) << ", " << ctx << ");" << TestLog::EndMessage;
-	EGLBoolean returnValue = ::eglMakeCurrent(dpy, draw, read, ctx);
+	eglw::EGLBoolean returnValue = m_egl.makeCurrent(dpy, draw, read, ctx);
 	if (m_enableLog)
 		m_log << TestLog::Message << "// " << getBooleanStr(returnValue) << " returned" << TestLog::EndMessage;
 	return returnValue;
 }
 
-EGLenum CallLogWrapper::eglQueryAPI ()
+eglw::EGLenum CallLogWrapper::eglQueryAPI ()
 {
 	if (m_enableLog)
 		m_log << TestLog::Message << "eglQueryAPI(" << ");" << TestLog::EndMessage;
-	EGLenum returnValue = ::eglQueryAPI();
+	eglw::EGLenum returnValue = m_egl.queryAPI();
 	if (m_enableLog)
 		m_log << TestLog::Message << "// " << getAPIStr(returnValue) << " returned" << TestLog::EndMessage;
 	return returnValue;
 }
 
-EGLBoolean CallLogWrapper::eglQueryContext (EGLDisplay dpy, EGLContext ctx, EGLint attribute, EGLint *value)
+eglw::EGLBoolean CallLogWrapper::eglQueryContext (eglw::EGLDisplay dpy, eglw::EGLContext ctx, eglw::EGLint attribute, eglw::EGLint *value)
 {
 	if (m_enableLog)
 		m_log << TestLog::Message << "eglQueryContext(" << dpy << ", " << ctx << ", " << getContextAttribStr(attribute) << ", " << value << ");" << TestLog::EndMessage;
-	EGLBoolean returnValue = ::eglQueryContext(dpy, ctx, attribute, value);
+	eglw::EGLBoolean returnValue = m_egl.queryContext(dpy, ctx, attribute, value);
 	if (m_enableLog)
 	{
 		m_log << TestLog::Message << "// value = " << getContextAttribValuePointerStr(attribute, value) << TestLog::EndMessage;
@@ -247,21 +337,21 @@
 	return returnValue;
 }
 
-const char * CallLogWrapper::eglQueryString (EGLDisplay dpy, EGLint name)
+const char * CallLogWrapper::eglQueryString (eglw::EGLDisplay dpy, eglw::EGLint name)
 {
 	if (m_enableLog)
 		m_log << TestLog::Message << "eglQueryString(" << dpy << ", " << name << ");" << TestLog::EndMessage;
-	const char * returnValue = ::eglQueryString(dpy, name);
+	const char * returnValue = m_egl.queryString(dpy, name);
 	if (m_enableLog)
 		m_log << TestLog::Message << "// " << getStringStr(returnValue) << " returned" << TestLog::EndMessage;
 	return returnValue;
 }
 
-EGLBoolean CallLogWrapper::eglQuerySurface (EGLDisplay dpy, EGLSurface surface, EGLint attribute, EGLint *value)
+eglw::EGLBoolean CallLogWrapper::eglQuerySurface (eglw::EGLDisplay dpy, eglw::EGLSurface surface, eglw::EGLint attribute, eglw::EGLint *value)
 {
 	if (m_enableLog)
 		m_log << TestLog::Message << "eglQuerySurface(" << dpy << ", " << toHex(surface) << ", " << getSurfaceAttribStr(attribute) << ", " << value << ");" << TestLog::EndMessage;
-	EGLBoolean returnValue = ::eglQuerySurface(dpy, surface, attribute, value);
+	eglw::EGLBoolean returnValue = m_egl.querySurface(dpy, surface, attribute, value);
 	if (m_enableLog)
 	{
 		m_log << TestLog::Message << "// value = " << getSurfaceAttribValuePointerStr(attribute, value) << TestLog::EndMessage;
@@ -271,91 +361,101 @@
 	return returnValue;
 }
 
-EGLBoolean CallLogWrapper::eglReleaseTexImage (EGLDisplay dpy, EGLSurface surface, EGLint buffer)
+eglw::EGLBoolean CallLogWrapper::eglReleaseTexImage (eglw::EGLDisplay dpy, eglw::EGLSurface surface, eglw::EGLint buffer)
 {
 	if (m_enableLog)
 		m_log << TestLog::Message << "eglReleaseTexImage(" << dpy << ", " << toHex(surface) << ", " << buffer << ");" << TestLog::EndMessage;
-	EGLBoolean returnValue = ::eglReleaseTexImage(dpy, surface, buffer);
+	eglw::EGLBoolean returnValue = m_egl.releaseTexImage(dpy, surface, buffer);
 	if (m_enableLog)
 		m_log << TestLog::Message << "// " << getBooleanStr(returnValue) << " returned" << TestLog::EndMessage;
 	return returnValue;
 }
 
-EGLBoolean CallLogWrapper::eglReleaseThread ()
+eglw::EGLBoolean CallLogWrapper::eglReleaseThread ()
 {
 	if (m_enableLog)
 		m_log << TestLog::Message << "eglReleaseThread(" << ");" << TestLog::EndMessage;
-	EGLBoolean returnValue = ::eglReleaseThread();
+	eglw::EGLBoolean returnValue = m_egl.releaseThread();
 	if (m_enableLog)
 		m_log << TestLog::Message << "// " << getBooleanStr(returnValue) << " returned" << TestLog::EndMessage;
 	return returnValue;
 }
 
-EGLBoolean CallLogWrapper::eglSurfaceAttrib (EGLDisplay dpy, EGLSurface surface, EGLint attribute, EGLint value)
+eglw::EGLBoolean CallLogWrapper::eglSurfaceAttrib (eglw::EGLDisplay dpy, eglw::EGLSurface surface, eglw::EGLint attribute, eglw::EGLint value)
 {
 	if (m_enableLog)
 		m_log << TestLog::Message << "eglSurfaceAttrib(" << dpy << ", " << toHex(surface) << ", " << getSurfaceAttribStr(attribute) << ", " << getSurfaceAttribValueStr(attribute, value) << ");" << TestLog::EndMessage;
-	EGLBoolean returnValue = ::eglSurfaceAttrib(dpy, surface, attribute, value);
+	eglw::EGLBoolean returnValue = m_egl.surfaceAttrib(dpy, surface, attribute, value);
 	if (m_enableLog)
 		m_log << TestLog::Message << "// " << getBooleanStr(returnValue) << " returned" << TestLog::EndMessage;
 	return returnValue;
 }
 
-EGLBoolean CallLogWrapper::eglSwapBuffers (EGLDisplay dpy, EGLSurface surface)
+eglw::EGLBoolean CallLogWrapper::eglSwapBuffers (eglw::EGLDisplay dpy, eglw::EGLSurface surface)
 {
 	if (m_enableLog)
 		m_log << TestLog::Message << "eglSwapBuffers(" << dpy << ", " << toHex(surface) << ");" << TestLog::EndMessage;
-	EGLBoolean returnValue = ::eglSwapBuffers(dpy, surface);
+	eglw::EGLBoolean returnValue = m_egl.swapBuffers(dpy, surface);
 	if (m_enableLog)
 		m_log << TestLog::Message << "// " << getBooleanStr(returnValue) << " returned" << TestLog::EndMessage;
 	return returnValue;
 }
 
-EGLBoolean CallLogWrapper::eglSwapInterval (EGLDisplay dpy, EGLint interval)
+eglw::EGLBoolean CallLogWrapper::eglSwapInterval (eglw::EGLDisplay dpy, eglw::EGLint interval)
 {
 	if (m_enableLog)
 		m_log << TestLog::Message << "eglSwapInterval(" << dpy << ", " << interval << ");" << TestLog::EndMessage;
-	EGLBoolean returnValue = ::eglSwapInterval(dpy, interval);
+	eglw::EGLBoolean returnValue = m_egl.swapInterval(dpy, interval);
 	if (m_enableLog)
 		m_log << TestLog::Message << "// " << getBooleanStr(returnValue) << " returned" << TestLog::EndMessage;
 	return returnValue;
 }
 
-EGLBoolean CallLogWrapper::eglTerminate (EGLDisplay dpy)
+eglw::EGLBoolean CallLogWrapper::eglTerminate (eglw::EGLDisplay dpy)
 {
 	if (m_enableLog)
 		m_log << TestLog::Message << "eglTerminate(" << dpy << ");" << TestLog::EndMessage;
-	EGLBoolean returnValue = ::eglTerminate(dpy);
+	eglw::EGLBoolean returnValue = m_egl.terminate(dpy);
 	if (m_enableLog)
 		m_log << TestLog::Message << "// " << getBooleanStr(returnValue) << " returned" << TestLog::EndMessage;
 	return returnValue;
 }
 
-EGLBoolean CallLogWrapper::eglWaitClient ()
+eglw::EGLBoolean CallLogWrapper::eglWaitClient ()
 {
 	if (m_enableLog)
 		m_log << TestLog::Message << "eglWaitClient(" << ");" << TestLog::EndMessage;
-	EGLBoolean returnValue = ::eglWaitClient();
+	eglw::EGLBoolean returnValue = m_egl.waitClient();
 	if (m_enableLog)
 		m_log << TestLog::Message << "// " << getBooleanStr(returnValue) << " returned" << TestLog::EndMessage;
 	return returnValue;
 }
 
-EGLBoolean CallLogWrapper::eglWaitGL ()
+eglw::EGLBoolean CallLogWrapper::eglWaitGL ()
 {
 	if (m_enableLog)
 		m_log << TestLog::Message << "eglWaitGL(" << ");" << TestLog::EndMessage;
-	EGLBoolean returnValue = ::eglWaitGL();
+	eglw::EGLBoolean returnValue = m_egl.waitGL();
 	if (m_enableLog)
 		m_log << TestLog::Message << "// " << getBooleanStr(returnValue) << " returned" << TestLog::EndMessage;
 	return returnValue;
 }
 
-EGLBoolean CallLogWrapper::eglWaitNative (EGLint engine)
+eglw::EGLBoolean CallLogWrapper::eglWaitNative (eglw::EGLint engine)
 {
 	if (m_enableLog)
 		m_log << TestLog::Message << "eglWaitNative(" << engine << ");" << TestLog::EndMessage;
-	EGLBoolean returnValue = ::eglWaitNative(engine);
+	eglw::EGLBoolean returnValue = m_egl.waitNative(engine);
+	if (m_enableLog)
+		m_log << TestLog::Message << "// " << getBooleanStr(returnValue) << " returned" << TestLog::EndMessage;
+	return returnValue;
+}
+
+eglw::EGLBoolean CallLogWrapper::eglWaitSync (eglw::EGLDisplay dpy, eglw::EGLSync sync, eglw::EGLint flags)
+{
+	if (m_enableLog)
+		m_log << TestLog::Message << "eglWaitSync(" << dpy << ", " << sync << ", " << flags << ");" << TestLog::EndMessage;
+	eglw::EGLBoolean returnValue = m_egl.waitSync(dpy, sync, flags);
 	if (m_enableLog)
 		m_log << TestLog::Message << "// " << getBooleanStr(returnValue) << " returned" << TestLog::EndMessage;
 	return returnValue;
diff --git a/framework/egl/egluCallLogWrapperApi.inl b/framework/egl/egluCallLogWrapperApi.inl
index 605c907..fe8c1b9 100644
--- a/framework/egl/egluCallLogWrapperApi.inl
+++ b/framework/egl/egluCallLogWrapperApi.inl
@@ -3,37 +3,47 @@
  *
  * Generated from Khronos EGL API description (egl.xml) revision 28861.
  */
-EGLBoolean									eglBindAPI							(EGLenum api);
-EGLBoolean									eglBindTexImage						(EGLDisplay dpy, EGLSurface surface, EGLint buffer);
-EGLBoolean									eglChooseConfig						(EGLDisplay dpy, const EGLint *attrib_list, EGLConfig *configs, EGLint config_size, EGLint *num_config);
-EGLBoolean									eglCopyBuffers						(EGLDisplay dpy, EGLSurface surface, EGLNativePixmapType target);
-EGLContext									eglCreateContext					(EGLDisplay dpy, EGLConfig config, EGLContext share_context, const EGLint *attrib_list);
-EGLSurface									eglCreatePbufferFromClientBuffer	(EGLDisplay dpy, EGLenum buftype, EGLClientBuffer buffer, EGLConfig config, const EGLint *attrib_list);
-EGLSurface									eglCreatePbufferSurface				(EGLDisplay dpy, EGLConfig config, const EGLint *attrib_list);
-EGLSurface									eglCreatePixmapSurface				(EGLDisplay dpy, EGLConfig config, EGLNativePixmapType pixmap, const EGLint *attrib_list);
-EGLSurface									eglCreateWindowSurface				(EGLDisplay dpy, EGLConfig config, EGLNativeWindowType win, const EGLint *attrib_list);
-EGLBoolean									eglDestroyContext					(EGLDisplay dpy, EGLContext ctx);
-EGLBoolean									eglDestroySurface					(EGLDisplay dpy, EGLSurface surface);
-EGLBoolean									eglGetConfigAttrib					(EGLDisplay dpy, EGLConfig config, EGLint attribute, EGLint *value);
-EGLBoolean									eglGetConfigs						(EGLDisplay dpy, EGLConfig *configs, EGLint config_size, EGLint *num_config);
-EGLContext									eglGetCurrentContext				(void);
-EGLDisplay									eglGetCurrentDisplay				(void);
-EGLSurface									eglGetCurrentSurface				(EGLint readdraw);
-EGLDisplay									eglGetDisplay						(EGLNativeDisplayType display_id);
-EGLint										eglGetError							(void);
-__eglMustCastToProperFunctionPointerType	eglGetProcAddress					(const char *procname);
-EGLBoolean									eglInitialize						(EGLDisplay dpy, EGLint *major, EGLint *minor);
-EGLBoolean									eglMakeCurrent						(EGLDisplay dpy, EGLSurface draw, EGLSurface read, EGLContext ctx);
-EGLenum										eglQueryAPI							(void);
-EGLBoolean									eglQueryContext						(EGLDisplay dpy, EGLContext ctx, EGLint attribute, EGLint *value);
-const char *								eglQueryString						(EGLDisplay dpy, EGLint name);
-EGLBoolean									eglQuerySurface						(EGLDisplay dpy, EGLSurface surface, EGLint attribute, EGLint *value);
-EGLBoolean									eglReleaseTexImage					(EGLDisplay dpy, EGLSurface surface, EGLint buffer);
-EGLBoolean									eglReleaseThread					(void);
-EGLBoolean									eglSurfaceAttrib					(EGLDisplay dpy, EGLSurface surface, EGLint attribute, EGLint value);
-EGLBoolean									eglSwapBuffers						(EGLDisplay dpy, EGLSurface surface);
-EGLBoolean									eglSwapInterval						(EGLDisplay dpy, EGLint interval);
-EGLBoolean									eglTerminate						(EGLDisplay dpy);
-EGLBoolean									eglWaitClient						(void);
-EGLBoolean									eglWaitGL							(void);
-EGLBoolean									eglWaitNative						(EGLint engine);
+eglw::EGLBoolean								eglBindAPI							(eglw::EGLenum api);
+eglw::EGLBoolean								eglBindTexImage						(eglw::EGLDisplay dpy, eglw::EGLSurface surface, eglw::EGLint buffer);
+eglw::EGLBoolean								eglChooseConfig						(eglw::EGLDisplay dpy, const eglw::EGLint *attrib_list, eglw::EGLConfig *configs, eglw::EGLint config_size, eglw::EGLint *num_config);
+eglw::EGLint									eglClientWaitSync					(eglw::EGLDisplay dpy, eglw::EGLSync sync, eglw::EGLint flags, eglw::EGLTime timeout);
+eglw::EGLBoolean								eglCopyBuffers						(eglw::EGLDisplay dpy, eglw::EGLSurface surface, eglw::EGLNativePixmapType target);
+eglw::EGLContext								eglCreateContext					(eglw::EGLDisplay dpy, eglw::EGLConfig config, eglw::EGLContext share_context, const eglw::EGLint *attrib_list);
+eglw::EGLImage									eglCreateImage						(eglw::EGLDisplay dpy, eglw::EGLContext ctx, eglw::EGLenum target, eglw::EGLClientBuffer buffer, const eglw::EGLint *attrib_list);
+eglw::EGLSurface								eglCreatePbufferFromClientBuffer	(eglw::EGLDisplay dpy, eglw::EGLenum buftype, eglw::EGLClientBuffer buffer, eglw::EGLConfig config, const eglw::EGLint *attrib_list);
+eglw::EGLSurface								eglCreatePbufferSurface				(eglw::EGLDisplay dpy, eglw::EGLConfig config, const eglw::EGLint *attrib_list);
+eglw::EGLSurface								eglCreatePixmapSurface				(eglw::EGLDisplay dpy, eglw::EGLConfig config, eglw::EGLNativePixmapType pixmap, const eglw::EGLint *attrib_list);
+eglw::EGLSurface								eglCreatePlatformPixmapSurface		(eglw::EGLDisplay dpy, eglw::EGLConfig config, void *native_pixmap, const eglw::EGLAttrib *attrib_list);
+eglw::EGLSurface								eglCreatePlatformWindowSurface		(eglw::EGLDisplay dpy, eglw::EGLConfig config, void *native_window, const eglw::EGLAttrib *attrib_list);
+eglw::EGLSync									eglCreateSync						(eglw::EGLDisplay dpy, eglw::EGLenum type, const eglw::EGLAttrib *attrib_list);
+eglw::EGLSurface								eglCreateWindowSurface				(eglw::EGLDisplay dpy, eglw::EGLConfig config, eglw::EGLNativeWindowType win, const eglw::EGLint *attrib_list);
+eglw::EGLBoolean								eglDestroyContext					(eglw::EGLDisplay dpy, eglw::EGLContext ctx);
+eglw::EGLBoolean								eglDestroyImage						(eglw::EGLDisplay dpy, eglw::EGLImage image);
+eglw::EGLBoolean								eglDestroySurface					(eglw::EGLDisplay dpy, eglw::EGLSurface surface);
+eglw::EGLBoolean								eglDestroySync						(eglw::EGLDisplay dpy, eglw::EGLSync sync);
+eglw::EGLBoolean								eglGetConfigAttrib					(eglw::EGLDisplay dpy, eglw::EGLConfig config, eglw::EGLint attribute, eglw::EGLint *value);
+eglw::EGLBoolean								eglGetConfigs						(eglw::EGLDisplay dpy, eglw::EGLConfig *configs, eglw::EGLint config_size, eglw::EGLint *num_config);
+eglw::EGLContext								eglGetCurrentContext				(void);
+eglw::EGLDisplay								eglGetCurrentDisplay				(void);
+eglw::EGLSurface								eglGetCurrentSurface				(eglw::EGLint readdraw);
+eglw::EGLDisplay								eglGetDisplay						(eglw::EGLNativeDisplayType display_id);
+eglw::EGLint									eglGetError							(void);
+eglw::EGLDisplay								eglGetPlatformDisplay				(eglw::EGLenum platform, void *native_display, const eglw::EGLAttrib *attrib_list);
+eglw::__eglMustCastToProperFunctionPointerType	eglGetProcAddress					(const char *procname);
+eglw::EGLBoolean								eglGetSyncAttrib					(eglw::EGLDisplay dpy, eglw::EGLSync sync, eglw::EGLint attribute, eglw::EGLAttrib *value);
+eglw::EGLBoolean								eglInitialize						(eglw::EGLDisplay dpy, eglw::EGLint *major, eglw::EGLint *minor);
+eglw::EGLBoolean								eglMakeCurrent						(eglw::EGLDisplay dpy, eglw::EGLSurface draw, eglw::EGLSurface read, eglw::EGLContext ctx);
+eglw::EGLenum									eglQueryAPI							(void);
+eglw::EGLBoolean								eglQueryContext						(eglw::EGLDisplay dpy, eglw::EGLContext ctx, eglw::EGLint attribute, eglw::EGLint *value);
+const char *									eglQueryString						(eglw::EGLDisplay dpy, eglw::EGLint name);
+eglw::EGLBoolean								eglQuerySurface						(eglw::EGLDisplay dpy, eglw::EGLSurface surface, eglw::EGLint attribute, eglw::EGLint *value);
+eglw::EGLBoolean								eglReleaseTexImage					(eglw::EGLDisplay dpy, eglw::EGLSurface surface, eglw::EGLint buffer);
+eglw::EGLBoolean								eglReleaseThread					(void);
+eglw::EGLBoolean								eglSurfaceAttrib					(eglw::EGLDisplay dpy, eglw::EGLSurface surface, eglw::EGLint attribute, eglw::EGLint value);
+eglw::EGLBoolean								eglSwapBuffers						(eglw::EGLDisplay dpy, eglw::EGLSurface surface);
+eglw::EGLBoolean								eglSwapInterval						(eglw::EGLDisplay dpy, eglw::EGLint interval);
+eglw::EGLBoolean								eglTerminate						(eglw::EGLDisplay dpy);
+eglw::EGLBoolean								eglWaitClient						(void);
+eglw::EGLBoolean								eglWaitGL							(void);
+eglw::EGLBoolean								eglWaitNative						(eglw::EGLint engine);
+eglw::EGLBoolean								eglWaitSync							(eglw::EGLDisplay dpy, eglw::EGLSync sync, eglw::EGLint flags);
diff --git a/framework/egl/egluConfigFilter.cpp b/framework/egl/egluConfigFilter.cpp
index f36887f..c6d06ad 100644
--- a/framework/egl/egluConfigFilter.cpp
+++ b/framework/egl/egluConfigFilter.cpp
@@ -24,6 +24,7 @@
 #include "egluConfigFilter.hpp"
 #include "egluUtil.hpp"
 #include "egluConfigInfo.hpp"
+#include "eglwEnums.hpp"
 
 #include <algorithm>
 
@@ -32,63 +33,45 @@
 namespace eglu
 {
 
-bool ConfigFilter::match (EGLDisplay display, EGLConfig config) const
+using namespace eglw;
+
+
+CandidateConfig::CandidateConfig (const eglw::Library& egl, eglw::EGLDisplay display, eglw::EGLConfig config)
+	: m_type(TYPE_EGL_OBJECT)
 {
-	EGLint	cmpValue	= getConfigAttribInt(display, config, m_attribute);
-	bool	isMatch		= false;
-
-	switch (m_rule)
-	{
-		case FILTER_EQUAL:				isMatch = (cmpValue == m_value);			break;
-		case FILTER_GREATER_OR_EQUAL:	isMatch = (cmpValue >= m_value);			break;
-		case FILTER_AND:				isMatch = (cmpValue & m_value) == m_value;	break;
-		case FILTER_NOT_SET:			isMatch = (cmpValue & m_value) == 0;		break;
-		default:						DE_ASSERT(false);							break;
-	}
-
-	return isMatch;
+	m_cfg.object.egl		= &egl;
+	m_cfg.object.display	= display;
+	m_cfg.object.config		= config;
 }
 
-bool ConfigFilter::match (const ConfigInfo& configInfo) const
+CandidateConfig::CandidateConfig (const ConfigInfo& configInfo)
+	: m_type(TYPE_CONFIG_INFO)
 {
-	EGLint	cmpValue	= configInfo.getAttribute(m_attribute);
-	bool	isMatch		= false;
-
-	switch (m_rule)
-	{
-		case FILTER_EQUAL:				isMatch = (cmpValue == m_value);			break;
-		case FILTER_GREATER_OR_EQUAL:	isMatch = (cmpValue >= m_value);			break;
-		case FILTER_AND:				isMatch = (cmpValue & m_value) == m_value;	break;
-		case FILTER_NOT_SET:			isMatch = (cmpValue & m_value) == 0;		break;
-		default:						DE_ASSERT(false);							break;
-	}
-
-	return isMatch;
+	m_cfg.configInfo = &configInfo;
 }
 
-FilterList ConfigColorBits::operator== (tcu::RGBA bits) const
+int CandidateConfig::get (deUint32 attrib) const
 {
-	FilterList list;
-	list << (ConfigRedSize()	== bits.getRed())
-		 << (ConfigGreenSize()	== bits.getGreen())
-		 << (ConfigBlueSize()	== bits.getBlue())
-		 << (ConfigAlphaSize()	== bits.getAlpha());
-	return list;
+	if (m_type == TYPE_CONFIG_INFO)
+		return m_cfg.configInfo->getAttribute(attrib);
+	else
+		return getConfigAttribInt(*m_cfg.object.egl, m_cfg.object.display, m_cfg.object.config, attrib);
 }
 
-FilterList ConfigColorBits::operator>= (tcu::RGBA bits) const
-{
-	FilterList list;
-	list << (ConfigRedSize()	>= bits.getRed())
-		 << (ConfigGreenSize()	>= bits.getGreen())
-		 << (ConfigBlueSize()	>= bits.getBlue())
-		 << (ConfigAlphaSize()	>= bits.getAlpha());
-	return list;
-}
+int			CandidateConfig::id				(void) const { return get(EGL_CONFIG_ID);					}
+int			CandidateConfig::redSize		(void) const { return get(EGL_RED_SIZE);					}
+int			CandidateConfig::greenSize		(void) const { return get(EGL_GREEN_SIZE);					}
+int			CandidateConfig::blueSize		(void) const { return get(EGL_BLUE_SIZE);					}
+int			CandidateConfig::alphaSize		(void) const { return get(EGL_ALPHA_SIZE);					}
+int			CandidateConfig::depthSize		(void) const { return get(EGL_DEPTH_SIZE);					}
+int			CandidateConfig::stencilSize	(void) const { return get(EGL_STENCIL_SIZE);				}
+int			CandidateConfig::samples		(void) const { return get(EGL_SAMPLES);						}
+deUint32	CandidateConfig::renderableType	(void) const { return (deUint32)get(EGL_RENDERABLE_TYPE);	}
+deUint32	CandidateConfig::surfaceType	(void) const { return (deUint32)get(EGL_SURFACE_TYPE);		}
 
-FilterList& FilterList::operator<< (const ConfigFilter& rule)
+FilterList& FilterList::operator<< (ConfigFilter filter)
 {
-	m_rules.push_back(rule);
+	m_rules.push_back(filter);
 	return *this;
 }
 
@@ -100,24 +83,28 @@
 	return *this;
 }
 
-bool FilterList::match (const EGLDisplay display, EGLConfig config) const
+bool FilterList::match (const Library& egl, EGLDisplay display, EGLConfig config) const
 {
-	for (vector<ConfigFilter>::const_iterator ruleIter = m_rules.begin(); ruleIter != m_rules.end(); ruleIter++)
-	{
-		if (!ruleIter->match(display, config))
-			return false;
-	}
-	return true;
+	return match(CandidateConfig(egl, display, config));
 }
 
 bool FilterList::match (const ConfigInfo& configInfo) const
 {
-	for (vector<ConfigFilter>::const_iterator ruleIter = m_rules.begin(); ruleIter != m_rules.end(); ruleIter++)
+	return match(CandidateConfig(configInfo));
+}
+
+bool FilterList::match (const CandidateConfig& candidate) const
+{
+	for (vector<ConfigFilter>::const_iterator filterIter = m_rules.begin(); filterIter != m_rules.end(); filterIter++)
 	{
-		if (!ruleIter->match(configInfo))
+		ConfigFilter filter = *filterIter;
+
+		if (!filter(candidate))
 			return false;
 	}
+
 	return true;
 }
 
+
 } // eglu
diff --git a/framework/egl/egluConfigFilter.hpp b/framework/egl/egluConfigFilter.hpp
index faa75e4..2f316fe 100644
--- a/framework/egl/egluConfigFilter.hpp
+++ b/framework/egl/egluConfigFilter.hpp
@@ -24,77 +24,67 @@
  *//*--------------------------------------------------------------------*/
 
 #include "tcuDefs.hpp"
-#include "egluHeaderWrapper.hpp"
 #include "tcuRGBA.hpp"
 
+#include "eglwDefs.hpp"
+
 #include <vector>
 
+namespace eglw
+{
+class Library;
+}
+
 namespace eglu
 {
 
 class ConfigInfo;
 
-class ConfigFilter
+class CandidateConfig
 {
 public:
-	enum Filter
-	{
-		FILTER_EQUAL = 0,
-		FILTER_GREATER_OR_EQUAL,
-		FILTER_AND,
-		FILTER_NOT_SET,
+					CandidateConfig		(const eglw::Library& egl, eglw::EGLDisplay display, eglw::EGLConfig config);
+					CandidateConfig		(const ConfigInfo& configInfo);
 
-		FILTER_LAST
-	};
+	int				get					(deUint32 attrib) const;
 
-	ConfigFilter (EGLint attribute, EGLint value, Filter rule)
-		: m_attribute	(attribute)
-		, m_value		(value)
-		, m_rule		(rule)
-	{
-	}
+	int				id					(void) const;
+	int				redSize				(void) const;
+	int				greenSize			(void) const;
+	int				blueSize			(void) const;
+	int				alphaSize			(void) const;
+	int				depthSize			(void) const;
+	int				stencilSize			(void) const;
+	int				samples				(void) const;
 
-	ConfigFilter (void)
-		: m_attribute	(0)
-		, m_value		(0)
-		, m_rule		(FILTER_LAST)
-	{
-	}
+	deUint32		renderableType		(void) const;
+	deUint32		surfaceType			(void) const;
 
-	bool match (EGLDisplay display, EGLConfig config) const;
-
-	bool match (const ConfigInfo& configInfo) const;
+	tcu::RGBA		colorBits			(void) const { return tcu::RGBA(redSize(), greenSize(), blueSize(), alphaSize());	}
 
 private:
-	EGLint		m_attribute;
-	EGLint		m_value;
-	Filter		m_rule;
+	enum Type
+	{
+		TYPE_EGL_OBJECT = 0,
+		TYPE_CONFIG_INFO,
+
+		TYPE_LAST
+	};
+
+	const Type		m_type;
+	union
+	{
+		struct
+		{
+			const eglw::Library*	egl;
+			eglw::EGLDisplay		display;
+			eglw::EGLConfig			config;
+		} object;
+		const ConfigInfo*			configInfo;
+	} m_cfg;
 };
 
-template <EGLint Attribute>
-class FilterTemplate
-{
-public:
-					FilterTemplate			(void) {}
-					~FilterTemplate			(void) {}
-
-	ConfigFilter	operator==				(EGLint value) const	{ return ConfigFilter(Attribute, value, ConfigFilter::FILTER_EQUAL);			}
-	ConfigFilter	operator>=				(EGLint value) const	{ return ConfigFilter(Attribute, value, ConfigFilter::FILTER_GREATER_OR_EQUAL);	}
-	ConfigFilter	operator&				(EGLint value) const	{ return ConfigFilter(Attribute, value, ConfigFilter::FILTER_AND);				}
-	ConfigFilter	operator^				(EGLint value) const	{ return ConfigFilter(Attribute, value, ConfigFilter::FILTER_NOT_SET);			}
-};
-
-// Helpers for filters
-typedef FilterTemplate<EGL_CONFIG_ID>		ConfigId;
-typedef FilterTemplate<EGL_RED_SIZE>		ConfigRedSize;
-typedef FilterTemplate<EGL_GREEN_SIZE>		ConfigGreenSize;
-typedef FilterTemplate<EGL_BLUE_SIZE>		ConfigBlueSize;
-typedef FilterTemplate<EGL_ALPHA_SIZE>		ConfigAlphaSize;
-typedef FilterTemplate<EGL_DEPTH_SIZE>		ConfigDepthSize;
-typedef FilterTemplate<EGL_STENCIL_SIZE>	ConfigStencilSize;
-typedef FilterTemplate<EGL_RENDERABLE_TYPE>	ConfigRenderableType;
-typedef FilterTemplate<EGL_SURFACE_TYPE>	ConfigSurfaceType;
-typedef FilterTemplate<EGL_SAMPLES>			ConfigSamples;
+typedef bool (*ConfigFilter) (const CandidateConfig& candidate);
 
 class FilterList
 {
@@ -102,25 +92,17 @@
 								FilterList		(void) {}
 								~FilterList		(void) {}
 
-	FilterList&					operator<<		(const ConfigFilter& rule);
+	FilterList&					operator<<		(ConfigFilter filter);
 	FilterList&					operator<<		(const FilterList& other);
 
-	bool						match			(const EGLDisplay display, EGLConfig config) const;
+	bool						match			(const eglw::Library& egl, eglw::EGLDisplay display, eglw::EGLConfig config) const;
 	bool						match			(const ConfigInfo& configInfo) const;
+	bool						match			(const CandidateConfig& candidate) const;
 
 private:
 	std::vector<ConfigFilter>	m_rules;
 };
 
-class ConfigColorBits
-{
-public:
-					ConfigColorBits			(void) {};
-
-	FilterList		operator==				(tcu::RGBA bits) const;
-	FilterList		operator>=				(tcu::RGBA bits) const;
-};
-
 } // eglu
 
 #endif // _EGLUCONFIGFILTER_HPP
diff --git a/framework/egl/egluConfigInfo.cpp b/framework/egl/egluConfigInfo.cpp
index 2806315..b1eefc0 100644
--- a/framework/egl/egluConfigInfo.cpp
+++ b/framework/egl/egluConfigInfo.cpp
@@ -23,10 +23,14 @@
 
 #include "egluConfigInfo.hpp"
 #include "egluDefs.hpp"
+#include "eglwLibrary.hpp"
+#include "eglwEnums.hpp"
 
 namespace eglu
 {
 
+using namespace eglw;
+
 deInt32 ConfigInfo::getAttribute (deUint32 attribute) const
 {
 	switch (attribute)
@@ -66,40 +70,40 @@
 	}
 }
 
-void queryConfigInfo (EGLDisplay display, EGLConfig config, ConfigInfo* dst)
+void queryConfigInfo (const Library& egl, EGLDisplay display, EGLConfig config, ConfigInfo* dst)
 {
-	eglGetConfigAttrib(display, config, EGL_BUFFER_SIZE,				&dst->bufferSize);
-	eglGetConfigAttrib(display, config, EGL_RED_SIZE,					&dst->redSize);
-	eglGetConfigAttrib(display, config, EGL_GREEN_SIZE,					&dst->greenSize);
-	eglGetConfigAttrib(display, config, EGL_BLUE_SIZE,					&dst->blueSize);
-	eglGetConfigAttrib(display, config, EGL_LUMINANCE_SIZE,				&dst->luminanceSize);
-	eglGetConfigAttrib(display, config, EGL_ALPHA_SIZE,					&dst->alphaSize);
-	eglGetConfigAttrib(display, config, EGL_ALPHA_MASK_SIZE,			&dst->alphaMaskSize);
-	eglGetConfigAttrib(display, config, EGL_BIND_TO_TEXTURE_RGB,		(EGLint*)&dst->bindToTextureRGB);
-	eglGetConfigAttrib(display, config, EGL_BIND_TO_TEXTURE_RGBA,		(EGLint*)&dst->bindToTextureRGBA);
-	eglGetConfigAttrib(display, config, EGL_COLOR_BUFFER_TYPE,			(EGLint*)&dst->colorBufferType);
-	eglGetConfigAttrib(display, config, EGL_CONFIG_CAVEAT,				(EGLint*)&dst->configCaveat);
-	eglGetConfigAttrib(display, config, EGL_CONFIG_ID,					&dst->configId);
-	eglGetConfigAttrib(display, config, EGL_CONFORMANT,					&dst->conformant);
-	eglGetConfigAttrib(display, config, EGL_DEPTH_SIZE,					&dst->depthSize);
-	eglGetConfigAttrib(display, config, EGL_LEVEL,						&dst->level);
-	eglGetConfigAttrib(display, config, EGL_MAX_PBUFFER_WIDTH,			&dst->maxPbufferWidth);
-	eglGetConfigAttrib(display, config, EGL_MAX_PBUFFER_HEIGHT,			&dst->maxPbufferHeight);
-	eglGetConfigAttrib(display, config, EGL_MAX_SWAP_INTERVAL,			&dst->maxSwapInterval);
-	eglGetConfigAttrib(display, config, EGL_MIN_SWAP_INTERVAL,			&dst->minSwapInterval);
-	eglGetConfigAttrib(display, config, EGL_NATIVE_RENDERABLE,			(EGLint*)&dst->nativeRenderable);
-	eglGetConfigAttrib(display, config, EGL_NATIVE_VISUAL_ID,			&dst->nativeVisualId);
-	eglGetConfigAttrib(display, config, EGL_NATIVE_VISUAL_TYPE,			&dst->nativeVisualType);
-	eglGetConfigAttrib(display, config, EGL_RENDERABLE_TYPE,			&dst->renderableType);
-	eglGetConfigAttrib(display, config, EGL_SAMPLE_BUFFERS,				&dst->sampleBuffers);
-	eglGetConfigAttrib(display, config, EGL_SAMPLES,					&dst->samples);
-	eglGetConfigAttrib(display, config, EGL_STENCIL_SIZE,				&dst->stencilSize);
-	eglGetConfigAttrib(display, config, EGL_SURFACE_TYPE,				&dst->surfaceType);
-	eglGetConfigAttrib(display, config, EGL_TRANSPARENT_TYPE,			(EGLint*)&dst->transparentType);
-	eglGetConfigAttrib(display, config, EGL_TRANSPARENT_RED_VALUE,		&dst->transparentRedValue);
-	eglGetConfigAttrib(display, config, EGL_TRANSPARENT_GREEN_VALUE,	&dst->transparentGreenValue);
-	eglGetConfigAttrib(display, config, EGL_TRANSPARENT_BLUE_VALUE,		&dst->transparentBlueValue);
-	EGLU_CHECK_MSG("Failed to query config info");
+	egl.getConfigAttrib(display, config, EGL_BUFFER_SIZE,				&dst->bufferSize);
+	egl.getConfigAttrib(display, config, EGL_RED_SIZE,					&dst->redSize);
+	egl.getConfigAttrib(display, config, EGL_GREEN_SIZE,				&dst->greenSize);
+	egl.getConfigAttrib(display, config, EGL_BLUE_SIZE,					&dst->blueSize);
+	egl.getConfigAttrib(display, config, EGL_LUMINANCE_SIZE,			&dst->luminanceSize);
+	egl.getConfigAttrib(display, config, EGL_ALPHA_SIZE,				&dst->alphaSize);
+	egl.getConfigAttrib(display, config, EGL_ALPHA_MASK_SIZE,			&dst->alphaMaskSize);
+	egl.getConfigAttrib(display, config, EGL_BIND_TO_TEXTURE_RGB,		(EGLint*)&dst->bindToTextureRGB);
+	egl.getConfigAttrib(display, config, EGL_BIND_TO_TEXTURE_RGBA,		(EGLint*)&dst->bindToTextureRGBA);
+	egl.getConfigAttrib(display, config, EGL_COLOR_BUFFER_TYPE,			(EGLint*)&dst->colorBufferType);
+	egl.getConfigAttrib(display, config, EGL_CONFIG_CAVEAT,				(EGLint*)&dst->configCaveat);
+	egl.getConfigAttrib(display, config, EGL_CONFIG_ID,					&dst->configId);
+	egl.getConfigAttrib(display, config, EGL_CONFORMANT,				&dst->conformant);
+	egl.getConfigAttrib(display, config, EGL_DEPTH_SIZE,				&dst->depthSize);
+	egl.getConfigAttrib(display, config, EGL_LEVEL,						&dst->level);
+	egl.getConfigAttrib(display, config, EGL_MAX_PBUFFER_WIDTH,			&dst->maxPbufferWidth);
+	egl.getConfigAttrib(display, config, EGL_MAX_PBUFFER_HEIGHT,		&dst->maxPbufferHeight);
+	egl.getConfigAttrib(display, config, EGL_MAX_SWAP_INTERVAL,			&dst->maxSwapInterval);
+	egl.getConfigAttrib(display, config, EGL_MIN_SWAP_INTERVAL,			&dst->minSwapInterval);
+	egl.getConfigAttrib(display, config, EGL_NATIVE_RENDERABLE,			(EGLint*)&dst->nativeRenderable);
+	egl.getConfigAttrib(display, config, EGL_NATIVE_VISUAL_ID,			&dst->nativeVisualId);
+	egl.getConfigAttrib(display, config, EGL_NATIVE_VISUAL_TYPE,		&dst->nativeVisualType);
+	egl.getConfigAttrib(display, config, EGL_RENDERABLE_TYPE,			&dst->renderableType);
+	egl.getConfigAttrib(display, config, EGL_SAMPLE_BUFFERS,			&dst->sampleBuffers);
+	egl.getConfigAttrib(display, config, EGL_SAMPLES,					&dst->samples);
+	egl.getConfigAttrib(display, config, EGL_STENCIL_SIZE,				&dst->stencilSize);
+	egl.getConfigAttrib(display, config, EGL_SURFACE_TYPE,				&dst->surfaceType);
+	egl.getConfigAttrib(display, config, EGL_TRANSPARENT_TYPE,			(EGLint*)&dst->transparentType);
+	egl.getConfigAttrib(display, config, EGL_TRANSPARENT_RED_VALUE,		&dst->transparentRedValue);
+	egl.getConfigAttrib(display, config, EGL_TRANSPARENT_GREEN_VALUE,	&dst->transparentGreenValue);
+	egl.getConfigAttrib(display, config, EGL_TRANSPARENT_BLUE_VALUE,	&dst->transparentBlueValue);
+	EGLU_CHECK_MSG(egl, "Failed to query config info");
 }
 
 } // eglu
diff --git a/framework/egl/egluConfigInfo.hpp b/framework/egl/egluConfigInfo.hpp
index 7de18f9..42fcaa3 100644
--- a/framework/egl/egluConfigInfo.hpp
+++ b/framework/egl/egluConfigInfo.hpp
@@ -24,7 +24,12 @@
  *//*--------------------------------------------------------------------*/
 
 #include "tcuDefs.hpp"
-#include "egluHeaderWrapper.hpp"
+#include "eglwDefs.hpp"
+
+namespace eglw
+{
+class Library;
+}
 
 namespace eglu
 {
@@ -102,7 +107,7 @@
 	deInt32 getAttribute (deUint32 attribute) const;
 };
 
-void	queryConfigInfo		(EGLDisplay display, EGLConfig config, ConfigInfo* dst);
+void	queryConfigInfo		(const eglw::Library& egl, eglw::EGLDisplay display, eglw::EGLConfig config, ConfigInfo* dst);
 
 } // eglu
 
diff --git a/framework/egl/egluDefs.cpp b/framework/egl/egluDefs.cpp
index 7513ef2..25c20a1 100644
--- a/framework/egl/egluDefs.cpp
+++ b/framework/egl/egluDefs.cpp
@@ -24,20 +24,20 @@
 #include "egluDefs.hpp"
 #include "egluStrUtil.hpp"
 #include "egluConfigInfo.hpp"
+#include "eglwLibrary.hpp"
+#include "eglwEnums.hpp"
 #include "deString.h"
 
+#include <string>
 #include <sstream>
 
 namespace eglu
 {
 
-using std::vector;
-using std::string;
+using namespace eglw;
 
-void checkError (const char* message, const char* file, int line)
+void checkError (deUint32 err, const char* message, const char* file, int line)
 {
-	const EGLenum err = eglGetError();
-
 	if (err != EGL_SUCCESS)
 	{
 		std::ostringstream desc;
@@ -52,13 +52,13 @@
 	}
 }
 
-Error::Error (deInt32 errCode, const char* errStr)
+Error::Error (deUint32 errCode, const char* errStr)
 	: tcu::TestError	((std::string("EGL returned ") + getErrorName(errCode)).c_str(), errStr ? errStr : "", __FILE__, __LINE__)
 	, m_error			(errCode)
 {
 }
 
-Error::Error (deInt32 errCode, const char* message, const char* expr, const char* file, int line)
+Error::Error (deUint32 errCode, const char* message, const char* expr, const char* file, int line)
 	: tcu::TestError	(message, expr, file, line)
 	, m_error			(errCode)
 {
diff --git a/framework/egl/egluDefs.hpp b/framework/egl/egluDefs.hpp
index 424c46d..3d6c7ce 100644
--- a/framework/egl/egluDefs.hpp
+++ b/framework/egl/egluDefs.hpp
@@ -25,12 +25,9 @@
 
 #include "tcuDefs.hpp"
 
-#include <vector>
-#include <string>
-
-#define EGLU_CHECK()			eglu::checkError(DE_NULL, __FILE__, __LINE__)
-#define EGLU_CHECK_MSG(MSG)		eglu::checkError(MSG, __FILE__, __LINE__)
-#define EGLU_CHECK_CALL(CALL)	do { CALL; eglu::checkError(#CALL, __FILE__, __LINE__); } while (deGetFalse())
+#define EGLU_CHECK(EGLW)			eglu::checkError((EGLW).getError(), DE_NULL, __FILE__, __LINE__)
+#define EGLU_CHECK_MSG(EGLW, MSG)	eglu::checkError((EGLW).getError(), MSG, __FILE__, __LINE__)
+#define EGLU_CHECK_CALL(EGLW, CALL)	do { (EGLW).CALL; eglu::checkError((EGLW).getError(), #CALL, __FILE__, __LINE__); } while (deGetFalse())
 
 /*--------------------------------------------------------------------*//*!
  * \brief EGL utilities
@@ -41,14 +38,14 @@
 class Error : public tcu::TestError
 {
 public:
-						Error			(deInt32 errCode, const char* errStr);
-						Error			(deInt32 errCode, const char* message, const char* expr, const char* file, int line);
+						Error			(deUint32 errCode, const char* errStr);
+						Error			(deUint32 errCode, const char* message, const char* expr, const char* file, int line);
 						~Error			(void) throw() {}
 
-	deInt32				getError		(void) const { return m_error; }
+	deUint32			getError		(void) const { return m_error; }
 
 private:
-	deInt32				m_error;
+	deUint32			m_error;
 };
 
 class BadAllocError : public tcu::ResourceError
@@ -59,7 +56,7 @@
 						~BadAllocError	(void) throw() {}
 };
 
-void checkError (const char* msg, const char* file, int line);
+void	checkError		(deUint32 err, const char* msg, const char* file, int line);
 
 class Version
 {
diff --git a/framework/egl/egluExtensions.cpp b/framework/egl/egluExtensions.cpp
deleted file mode 100644
index efd7fb9..0000000
--- a/framework/egl/egluExtensions.cpp
+++ /dev/null
@@ -1,62 +0,0 @@
-/*-------------------------------------------------------------------------
- * drawElements Quality Program Tester Core
- * ----------------------------------------
- *
- * Copyright 2014 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- *      http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- *
- *//*!
- * \file
- * \brief EGL extension resolving.
- *//*--------------------------------------------------------------------*/
-
-#include "egluExtensions.hpp"
-
-#include "egluUtil.hpp"
-#include "tcuDefs.hpp"
-
-
-namespace eglu
-{
-
-deFunctionPtr getProcAddressChecked (const char* procName)
-{
-	const deFunctionPtr func = eglGetProcAddress(procName);
-
-	TCU_CHECK_AND_THROW(NotSupportedError, func, procName);
-
-	return func;
-}
-
-ImageFunctions getImageFunctions (EGLDisplay dpy)
-{
-	ImageFunctions ret;
-
-	if (getVersion(dpy) >= Version(1, 5))
-	{
-		ret.createImage = getFunction<PFNEGLCREATEIMAGEKHRPROC>("eglCreateImage");
-		ret.destroyImage = getFunction<PFNEGLDESTROYIMAGEKHRPROC>("eglDestroyImage");
-	}
-	else if (hasExtension(dpy, "EGL_KHR_image_base"))
-	{
-		ret.createImage = getFunction<PFNEGLCREATEIMAGEKHRPROC>("eglCreateImageKHR");
-		ret.destroyImage = getFunction<PFNEGLDESTROYIMAGEKHRPROC>("eglDestroyImageKHR");
-	}
-	else
-		TCU_THROW(NotSupportedError, "EGLImages are not supported");
-
-	return ret;
-}
-
-}
diff --git a/framework/egl/egluExtensions.hpp b/framework/egl/egluExtensions.hpp
deleted file mode 100644
index 1d28348..0000000
--- a/framework/egl/egluExtensions.hpp
+++ /dev/null
@@ -1,50 +0,0 @@
-#ifndef _EGLUEXTENSIONS_HPP
-#define _EGLUEXTENSIONS_HPP
-/*-------------------------------------------------------------------------
- * drawElements Quality Program Tester Core
- * ----------------------------------------
- *
- * Copyright 2014 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- *      http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- *
- *//*!
- * \file
- * \brief EGL extension resolving.
- *//*--------------------------------------------------------------------*/
-
-#include "deDefs.hpp"
-#include "egluHeaderWrapper.hpp"
-
-namespace eglu
-{
-
-deFunctionPtr getProcAddressChecked (const char* procName);
-
-template <typename FUNC>
-inline FUNC getFunction (const char* procName)
-{
-	return reinterpret_cast<FUNC>(getProcAddressChecked(procName));
-}
-
-struct ImageFunctions
-{
-	PFNEGLCREATEIMAGEKHRPROC	createImage;
-	PFNEGLDESTROYIMAGEKHRPROC	destroyImage;
-};
-
-ImageFunctions getImageFunctions (EGLDisplay dpy);
-
-} // eglu
-
-#endif // _EGLUEXTENSIONS_HPP
diff --git a/framework/egl/egluGLContextFactory.cpp b/framework/egl/egluGLContextFactory.cpp
index 9f3a0af..5885381 100644
--- a/framework/egl/egluGLContextFactory.cpp
+++ b/framework/egl/egluGLContextFactory.cpp
@@ -30,13 +30,15 @@
 #include "gluDefs.hpp"
 
 #include "egluDefs.hpp"
-#include "egluHeaderWrapper.hpp"
 #include "egluUtil.hpp"
 #include "egluGLUtil.hpp"
 #include "egluNativeWindow.hpp"
 #include "egluNativePixmap.hpp"
 #include "egluStrUtil.hpp"
 
+#include "eglwLibrary.hpp"
+#include "eglwEnums.hpp"
+
 #include "glwInitFunctions.hpp"
 #include "glwInitES20Direct.hpp"
 #include "glwInitES30Direct.hpp"
@@ -77,6 +79,8 @@
 namespace eglu
 {
 
+using namespace eglw;
+
 namespace
 {
 
@@ -89,10 +93,18 @@
 class GetProcFuncLoader : public glw::FunctionLoader
 {
 public:
+	GetProcFuncLoader (const Library& egl)
+		: m_egl(egl)
+	{
+	}
+
 	glw::GenericFuncType get (const char* name) const
 	{
-		return (glw::GenericFuncType)eglGetProcAddress(name);
+		return (glw::GenericFuncType)m_egl.getProcAddress(name);
 	}
+
+protected:
+	const Library& m_egl;
 };
 
 class DynamicFuncLoader : public glw::FunctionLoader
@@ -190,85 +202,6 @@
 	delete m_dynamicGLLibrary;
 }
 
-bool configMatches (EGLDisplay display, EGLConfig eglConfig, const glu::RenderConfig& renderConfig)
-{
-	// \todo [2014-03-12 pyry] Check other attributes like double-buffer bit.
-
-	{
-		EGLint		renderableType		= 0;
-		EGLint		requiredRenderable	= apiRenderableType(renderConfig.type.getAPI());
-
-		EGLU_CHECK_CALL(eglGetConfigAttrib(display, eglConfig, EGL_RENDERABLE_TYPE, &renderableType));
-
-		if ((renderableType & requiredRenderable) == 0)
-			return false;
-	}
-
-	if (renderConfig.surfaceType != (glu::RenderConfig::SurfaceType)glu::RenderConfig::DONT_CARE)
-	{
-		EGLint		surfaceType		= 0;
-		EGLint		requiredSurface	= 0;
-
-		switch (renderConfig.surfaceType)
-		{
-			case glu::RenderConfig::SURFACETYPE_WINDOW:				requiredSurface = EGL_WINDOW_BIT;	break;
-			case glu::RenderConfig::SURFACETYPE_OFFSCREEN_NATIVE:	requiredSurface = EGL_PIXMAP_BIT;	break;
-			case glu::RenderConfig::SURFACETYPE_OFFSCREEN_GENERIC:	requiredSurface = EGL_PBUFFER_BIT;	break;
-			default:
-				DE_ASSERT(false);
-		}
-
-		EGLU_CHECK_CALL(eglGetConfigAttrib(display, eglConfig, EGL_SURFACE_TYPE, &surfaceType));
-
-		if ((surfaceType & requiredSurface) == 0)
-			return false;
-	}
-
-	{
-		static const struct
-		{
-			int	glu::RenderConfig::*field;
-			EGLint attrib;
-		} s_attribs[] =
-		{
-			{ &glu::RenderConfig::id,			EGL_CONFIG_ID		},
-			{ &glu::RenderConfig::redBits,		EGL_RED_SIZE		},
-			{ &glu::RenderConfig::greenBits,	EGL_GREEN_SIZE		},
-			{ &glu::RenderConfig::blueBits,		EGL_BLUE_SIZE		},
-			{ &glu::RenderConfig::alphaBits,	EGL_ALPHA_SIZE		},
-			{ &glu::RenderConfig::depthBits,	EGL_DEPTH_SIZE		},
-			{ &glu::RenderConfig::stencilBits,	EGL_STENCIL_SIZE	},
-			{ &glu::RenderConfig::numSamples,	EGL_SAMPLES			},
-		};
-
-		for (int attribNdx = 0; attribNdx < DE_LENGTH_OF_ARRAY(s_attribs); attribNdx++)
-		{
-			if (renderConfig.*s_attribs[attribNdx].field != glu::RenderConfig::DONT_CARE)
-			{
-				EGLint value = 0;
-				EGLU_CHECK_CALL(eglGetConfigAttrib(display, eglConfig, s_attribs[attribNdx].attrib, &value));
-				if (value != renderConfig.*s_attribs[attribNdx].field)
-					return false;
-			}
-		}
-	}
-
-	return true;
-}
-
-EGLConfig chooseConfig (EGLDisplay display, const glu::RenderConfig& config)
-{
-	const std::vector<EGLConfig> configs = eglu::getConfigs(display);
-
-	for (vector<EGLConfig>::const_iterator iter = configs.begin(); iter != configs.end(); ++iter)
-	{
-		if (configMatches(display, *iter, config))
-			return *iter;
-	}
-
-	throw tcu::NotSupportedError("Matching EGL config not found", DE_NULL, __FILE__, __LINE__);
-}
-
 static WindowParams::Visibility getNativeWindowVisibility (glu::RenderConfig::Visibility visibility)
 {
 	using glu::RenderConfig;
@@ -334,7 +267,7 @@
 	return PixmapSurfacePair(nativePixmap, surface);
 }
 
-EGLSurface createPBuffer (EGLDisplay display, EGLConfig eglConfig, const glu::RenderConfig& config)
+EGLSurface createPBuffer (const Library& egl, EGLDisplay display, EGLConfig eglConfig, const glu::RenderConfig& config)
 {
 	const int		width			= (config.width		== glu::RenderConfig::DONT_CARE ? DEFAULT_OFFSCREEN_WIDTH	: config.width);
 	const int		height			= (config.height	== glu::RenderConfig::DONT_CARE ? DEFAULT_OFFSCREEN_HEIGHT	: config.height);
@@ -346,8 +279,8 @@
 		EGL_NONE
 	};
 
-	surface = eglCreatePbufferSurface(display, eglConfig, &(attribList[0]));
-	EGLU_CHECK_MSG("eglCreatePbufferSurface()");
+	surface = egl.createPbufferSurface(display, eglConfig, &(attribList[0]));
+	EGLU_CHECK_MSG(egl, "eglCreatePbufferSurface()");
 
 	return surface;
 }
@@ -361,18 +294,20 @@
 	m_display		= displayFactory->createDisplay();
 	m_eglDisplay	= eglu::getDisplay(*m_display);
 
+	const Library& egl = m_display->getLibrary();
+
 	{
 		EGLint major = 0;
 		EGLint minor = 0;
-		EGLU_CHECK_CALL(eglInitialize(m_eglDisplay, &major, &minor));
+		EGLU_CHECK_CALL(egl, initialize(m_eglDisplay, &major, &minor));
 	}
 
-	m_eglConfig	= chooseConfig(m_eglDisplay, config);
+	m_eglConfig	= chooseConfig(egl, m_eglDisplay, config);
 
 	if (surfaceType == glu::RenderConfig::SURFACETYPE_DONT_CARE)
 	{
 		// Choose based on what selected configuration supports
-		const EGLint supportedTypes = eglu::getConfigAttribInt(m_eglDisplay, m_eglConfig, EGL_SURFACE_TYPE);
+		const EGLint supportedTypes = eglu::getConfigAttribInt(egl, m_eglDisplay, m_eglConfig, EGL_SURFACE_TYPE);
 
 		if ((supportedTypes & EGL_WINDOW_BIT) != 0)
 			surfaceType = glu::RenderConfig::SURFACETYPE_WINDOW;
@@ -413,23 +348,23 @@
 		}
 
 		case glu::RenderConfig::SURFACETYPE_OFFSCREEN_GENERIC:
-			m_eglSurface = createPBuffer(m_eglDisplay, m_eglConfig, config);
+			m_eglSurface = createPBuffer(egl, m_eglDisplay, m_eglConfig, config);
 			break;
 
 		default:
 			throw tcu::InternalError("Invalid surface type");
 	}
 
-	m_eglContext = createGLContext(m_eglDisplay, m_eglConfig, config.type);
+	m_eglContext = createGLContext(egl, m_eglDisplay, m_eglConfig, config.type);
 
-	EGLU_CHECK_CALL(eglMakeCurrent(m_eglDisplay, m_eglSurface, m_eglSurface, m_eglContext));
+	EGLU_CHECK_CALL(egl, makeCurrent(m_eglDisplay, m_eglSurface, m_eglSurface, m_eglContext));
 
 	// Init core functions
 
-	if (hasExtension(m_eglDisplay, "EGL_KHR_get_all_proc_addresses"))
+	if (hasExtension(egl, m_eglDisplay, "EGL_KHR_get_all_proc_addresses"))
 	{
 		// Use eglGetProcAddress() for core functions
-		GetProcFuncLoader funcLoader;
+		GetProcFuncLoader funcLoader(egl);
 		glu::initCoreFunctions(&m_glFunctions, &funcLoader, config.type.getAPI());
 	}
 #if !defined(DEQP_GLES2_RUNTIME_LOAD)
@@ -466,7 +401,7 @@
 
 	// Init extension functions
 	{
-		GetProcFuncLoader extLoader;
+		GetProcFuncLoader extLoader(egl);
 		glu::initExtensionFunctions(&m_glFunctions, &extLoader, config.type.getAPI());
 	}
 
@@ -474,19 +409,19 @@
 		EGLint				width, height, depthBits, stencilBits, numSamples;
 		tcu::PixelFormat	pixelFmt;
 
-		eglQuerySurface(m_eglDisplay, m_eglSurface, EGL_WIDTH, &width);
-		eglQuerySurface(m_eglDisplay, m_eglSurface, EGL_HEIGHT, &height);
+		egl.querySurface(m_eglDisplay, m_eglSurface, EGL_WIDTH,		&width);
+		egl.querySurface(m_eglDisplay, m_eglSurface, EGL_HEIGHT,	&height);
 
-		eglGetConfigAttrib(m_eglDisplay, m_eglConfig, EGL_RED_SIZE,		&pixelFmt.redBits);
-		eglGetConfigAttrib(m_eglDisplay, m_eglConfig, EGL_GREEN_SIZE,	&pixelFmt.greenBits);
-		eglGetConfigAttrib(m_eglDisplay, m_eglConfig, EGL_BLUE_SIZE,	&pixelFmt.blueBits);
-		eglGetConfigAttrib(m_eglDisplay, m_eglConfig, EGL_ALPHA_SIZE,	&pixelFmt.alphaBits);
+		egl.getConfigAttrib(m_eglDisplay, m_eglConfig, EGL_RED_SIZE,		&pixelFmt.redBits);
+		egl.getConfigAttrib(m_eglDisplay, m_eglConfig, EGL_GREEN_SIZE,		&pixelFmt.greenBits);
+		egl.getConfigAttrib(m_eglDisplay, m_eglConfig, EGL_BLUE_SIZE,		&pixelFmt.blueBits);
+		egl.getConfigAttrib(m_eglDisplay, m_eglConfig, EGL_ALPHA_SIZE,		&pixelFmt.alphaBits);
 
-		eglGetConfigAttrib(m_eglDisplay, m_eglConfig, EGL_DEPTH_SIZE,	&depthBits);
-		eglGetConfigAttrib(m_eglDisplay, m_eglConfig, EGL_STENCIL_SIZE,	&stencilBits);
-		eglGetConfigAttrib(m_eglDisplay, m_eglConfig, EGL_SAMPLES,		&numSamples);
+		egl.getConfigAttrib(m_eglDisplay, m_eglConfig, EGL_DEPTH_SIZE,		&depthBits);
+		egl.getConfigAttrib(m_eglDisplay, m_eglConfig, EGL_STENCIL_SIZE,	&stencilBits);
+		egl.getConfigAttrib(m_eglDisplay, m_eglConfig, EGL_SAMPLES,			&numSamples);
 
-		EGLU_CHECK_MSG("Failed to query config attributes");
+		EGLU_CHECK_MSG(egl, "Failed to query config attributes");
 
 		m_glRenderTarget = tcu::RenderTarget(width, height, pixelFmt, depthBits, stencilBits, numSamples);
 	}
@@ -494,17 +429,19 @@
 
 void RenderContext::destroy (void)
 {
+	const Library& egl = m_display->getLibrary();
+
 	if (m_eglDisplay != EGL_NO_DISPLAY)
 	{
-		EGLU_CHECK_CALL(eglMakeCurrent(m_eglDisplay, EGL_NO_SURFACE, EGL_NO_SURFACE, EGL_NO_CONTEXT));
+		EGLU_CHECK_CALL(egl, makeCurrent(m_eglDisplay, EGL_NO_SURFACE, EGL_NO_SURFACE, EGL_NO_CONTEXT));
 
 		if (m_eglSurface != EGL_NO_SURFACE)
-			EGLU_CHECK_CALL(eglDestroySurface(m_eglDisplay, m_eglSurface));
+			EGLU_CHECK_CALL(egl, destroySurface(m_eglDisplay, m_eglSurface));
 
 		if (m_eglContext != EGL_NO_CONTEXT)
-			EGLU_CHECK_CALL(eglDestroyContext(m_eglDisplay, m_eglContext));
+			EGLU_CHECK_CALL(egl, destroyContext(m_eglDisplay, m_eglContext));
 
-		EGLU_CHECK_CALL(eglTerminate(m_eglDisplay));
+		EGLU_CHECK_CALL(egl, terminate(m_eglDisplay));
 
 		m_eglDisplay	= EGL_NO_DISPLAY;
 		m_eglSurface	= EGL_NO_SURFACE;
@@ -524,10 +461,12 @@
 
 void RenderContext::postIterate (void)
 {
+	const Library& egl = m_display->getLibrary();
+
 	if (m_window)
 	{
-		EGLBoolean	swapOk		= eglSwapBuffers(m_eglDisplay, m_eglSurface);
-		EGLint		error		= eglGetError();
+		EGLBoolean	swapOk		= egl.swapBuffers(m_eglDisplay, m_eglSurface);
+		EGLint		error		= egl.getError();
 		const bool	badWindow	= error == EGL_BAD_SURFACE || error == EGL_BAD_NATIVE_WINDOW;
 
 		if (!swapOk && !badWindow)
@@ -541,8 +480,8 @@
 		{
 			tcu::print("Warning: Window destroyed, recreating...\n");
 
-			EGLU_CHECK_CALL(eglMakeCurrent(m_eglDisplay, EGL_NO_SURFACE, EGL_NO_SURFACE, EGL_NO_CONTEXT));
-			EGLU_CHECK_CALL(eglDestroySurface(m_eglDisplay, m_eglSurface));
+			EGLU_CHECK_CALL(egl, makeCurrent(m_eglDisplay, EGL_NO_SURFACE, EGL_NO_SURFACE, EGL_NO_CONTEXT));
+			EGLU_CHECK_CALL(egl, destroySurface(m_eglDisplay, m_eglSurface));
 			m_eglSurface = EGL_NO_SURFACE;
 
 			delete m_window;
@@ -554,7 +493,7 @@
 				m_window		= windowSurface.first;
 				m_eglSurface	= windowSurface.second;
 
-				EGLU_CHECK_CALL(eglMakeCurrent(m_eglDisplay, m_eglSurface, m_eglSurface, m_eglContext));
+				EGLU_CHECK_CALL(egl, makeCurrent(m_eglDisplay, m_eglSurface, m_eglSurface, m_eglContext));
 
 				swapOk	= EGL_TRUE;
 				error	= EGL_SUCCESS;
@@ -563,8 +502,8 @@
 			{
 				if (m_eglSurface)
 				{
-					eglMakeCurrent(m_eglDisplay, EGL_NO_SURFACE, EGL_NO_SURFACE, EGL_NO_CONTEXT);
-					eglDestroySurface(m_eglDisplay, m_eglSurface);
+					egl.makeCurrent(m_eglDisplay, EGL_NO_SURFACE, EGL_NO_SURFACE, EGL_NO_CONTEXT);
+					egl.destroySurface(m_eglDisplay, m_eglSurface);
 					m_eglSurface = EGL_NO_SURFACE;
 				}
 
@@ -586,9 +525,9 @@
 			int	newWidth	= 0;
 			int	newHeight	= 0;
 
-			eglQuerySurface(m_eglDisplay, m_eglSurface, EGL_WIDTH,	&newWidth);
-			eglQuerySurface(m_eglDisplay, m_eglSurface, EGL_HEIGHT,	&newHeight);
-			EGLU_CHECK_MSG("Failed to query window size");
+			egl.querySurface(m_eglDisplay, m_eglSurface, EGL_WIDTH,		&newWidth);
+			egl.querySurface(m_eglDisplay, m_eglSurface, EGL_HEIGHT,	&newHeight);
+			EGLU_CHECK_MSG(egl, "Failed to query window size");
 
 			if (newWidth	!= m_glRenderTarget.getWidth() ||
 				newHeight	!= m_glRenderTarget.getHeight())
@@ -616,50 +555,20 @@
 {
 }
 
-namespace
-{
-
-template<typename Factory>
-const Factory* selectFactory (const tcu::FactoryRegistry<Factory>& registry, const char* objectTypeName, const char* cmdLineArg)
-{
-	if (cmdLineArg)
-	{
-		const Factory* factory = registry.getFactoryByName(cmdLineArg);
-
-		if (factory)
-			return factory;
-		else
-		{
-			tcu::print("ERROR: Unknown or unsupported EGL %s type '%s'", objectTypeName, cmdLineArg);
-			tcu::print("Available EGL %s types:\n", objectTypeName);
-			for (size_t ndx = 0; ndx < registry.getFactoryCount(); ndx++)
-				tcu::print("  %s: %s\n", registry.getFactoryByIndex(ndx)->getName(), registry.getFactoryByIndex(ndx)->getDescription());
-
-			throw tcu::NotSupportedError((string("Unsupported or unknown EGL ") + objectTypeName + " type '" + cmdLineArg + "'").c_str(), DE_NULL, __FILE__, __LINE__);
-		}
-	}
-	else if (!registry.empty())
-		return registry.getDefaultFactory();
-	else
-		return DE_NULL;
-}
-
-} // anonymous
-
 glu::RenderContext* GLContextFactory::createContext (const glu::RenderConfig& config, const tcu::CommandLine& cmdLine) const
 {
-	const NativeDisplayFactory* displayFactory = selectFactory(m_displayFactoryRegistry, "display", cmdLine.getEGLDisplayType());
+	const NativeDisplayFactory* displayFactory = selectNativeDisplayFactory(m_displayFactoryRegistry, cmdLine);
 
 	if (displayFactory)
 	{
 		// \note windowFactory & pixmapFactory are not mandatory
-		const NativeWindowFactory*	windowFactory	= selectFactory(displayFactory->getNativeWindowRegistry(), "window", cmdLine.getEGLWindowType());
-		const NativePixmapFactory*	pixmapFactory	= selectFactory(displayFactory->getNativePixmapRegistry(), "pixmap", cmdLine.getEGLPixmapType());
+		const NativeWindowFactory*	windowFactory	= selectNativeWindowFactory(*displayFactory, cmdLine);
+		const NativePixmapFactory*	pixmapFactory	= selectNativePixmapFactory(*displayFactory, cmdLine);
 
 		return new RenderContext(displayFactory, windowFactory, pixmapFactory, config);
 	}
 	else
-		throw tcu::NotSupportedError("No EGL displays available", DE_NULL, __FILE__, __LINE__);
+		TCU_THROW(NotSupportedError, "No EGL displays available");
 }
 
 } // eglu
diff --git a/framework/egl/egluGLContextFactory.hpp b/framework/egl/egluGLContextFactory.hpp
index 1917baf..31b26a5 100644
--- a/framework/egl/egluGLContextFactory.hpp
+++ b/framework/egl/egluGLContextFactory.hpp
@@ -39,8 +39,8 @@
 class GLRenderContext : public glu::RenderContext
 {
 public:
-	virtual EGLDisplay						getEGLDisplay		(void) const = 0;
-	virtual EGLContext						getEGLContext		(void) const = 0;
+	virtual eglw::EGLDisplay				getEGLDisplay		(void) const = 0;
+	virtual eglw::EGLContext				getEGLContext		(void) const = 0;
 };
 
 class GLContextFactory : public glu::ContextFactory
diff --git a/framework/egl/egluGLFunctionLoader.cpp b/framework/egl/egluGLFunctionLoader.cpp
index 9b9713d..d821704 100644
--- a/framework/egl/egluGLFunctionLoader.cpp
+++ b/framework/egl/egluGLFunctionLoader.cpp
@@ -22,13 +22,16 @@
  *//*--------------------------------------------------------------------*/
 
 #include "egluGLFunctionLoader.hpp"
-#include "egluHeaderWrapper.hpp"
+#include "egluPlatform.hpp"
+#include "eglwLibrary.hpp"
+#include "tcuFunctionLibrary.hpp"
 
 namespace eglu
 {
 
-GLFunctionLoader::GLFunctionLoader (const tcu::FunctionLibrary* library)
-	: m_library(library)
+GLFunctionLoader::GLFunctionLoader (const eglw::Library& egl, const tcu::FunctionLibrary* library)
+	: m_egl		(egl)
+	, m_library	(library)
 {
 }
 
@@ -37,9 +40,46 @@
 	glw::GenericFuncType func = (glw::GenericFuncType)m_library->getFunction(name);
 
 	if (!func)
-		return (glw::GenericFuncType)eglGetProcAddress(name);
+		return (glw::GenericFuncType)m_egl.getProcAddress(name);
 	else
 		return func;
 }
 
+GLLibraryCache::GLLibraryCache (const Platform& platform, const tcu::CommandLine& cmdLine)
+	: m_platform	(platform)
+	, m_cmdLine		(cmdLine)
+{
+}
+
+GLLibraryCache::~GLLibraryCache (void)
+{
+	for (LibraryMap::iterator i = m_libraries.begin(); i != m_libraries.end(); ++i)
+		delete i->second;
+}
+
+const tcu::FunctionLibrary* GLLibraryCache::getLibrary (glu::ApiType apiType)
+{
+	tcu::FunctionLibrary*	library	= DE_NULL;
+	const deUint32			key		= apiType.getPacked();
+	LibraryMap::iterator	iter	= m_libraries.find(key);
+
+	if (iter == m_libraries.end())
+	{
+		library = m_platform.createDefaultGLFunctionLibrary(apiType, m_cmdLine);
+		try
+		{
+			m_libraries.insert(std::make_pair(key, library));
+		}
+		catch (...)
+		{
+			delete library;
+			throw;
+		}
+	}
+	else
+		library = iter->second;
+
+	return library;
+}
+
 } // eglu
diff --git a/framework/egl/egluGLFunctionLoader.hpp b/framework/egl/egluGLFunctionLoader.hpp
index 9bab05b..f77b58d 100644
--- a/framework/egl/egluGLFunctionLoader.hpp
+++ b/framework/egl/egluGLFunctionLoader.hpp
@@ -26,23 +26,57 @@
 #include "tcuDefs.hpp"
 #include "tcuFunctionLibrary.hpp"
 #include "glwFunctionLoader.hpp"
+#include "gluRenderContext.hpp"
+
+namespace tcu
+{
+class CommandLine;
+}
+
+namespace eglw
+{
+class Library;
+}
 
 namespace eglu
 {
 
+class Platform;
+
 class GLFunctionLoader : public glw::FunctionLoader
 {
 public:
-										GLFunctionLoader	(const tcu::FunctionLibrary* platformLibrary);
+										GLFunctionLoader	(const eglw::Library& egl, const tcu::FunctionLibrary* platformLibrary);
 	glw::GenericFuncType				get					(const char* name) const;
 
 private:
 										GLFunctionLoader	(const GLFunctionLoader&);
 	GLFunctionLoader&					operator=			(const GLFunctionLoader&);
 
+	const eglw::Library&				m_egl;
 	const tcu::FunctionLibrary* const	m_library;			//!< Base platform library for functions. Used if eglGetProcAddress() fails.
 };
 
+class GLLibraryCache
+{
+public:
+								GLLibraryCache		(const Platform& platform, const tcu::CommandLine& cmdLine);
+								~GLLibraryCache		(void);
+
+	const tcu::FunctionLibrary*	getLibrary			(glu::ApiType apiType);
+
+private:
+	GLLibraryCache&				operator=			(const GLLibraryCache& other);
+								GLLibraryCache		(const GLLibraryCache& other);
+
+	typedef std::map<deUint32, tcu::FunctionLibrary*> LibraryMap;
+
+	const Platform&				m_platform;
+	const tcu::CommandLine&		m_cmdLine;
+
+	LibraryMap					m_libraries;
+};
+
 } // eglu
 
 #endif // _EGLUGLFUNCTIONLOADER_HPP
diff --git a/framework/egl/egluGLUtil.cpp b/framework/egl/egluGLUtil.cpp
index ecd0cef..0f65b6d 100644
--- a/framework/egl/egluGLUtil.cpp
+++ b/framework/egl/egluGLUtil.cpp
@@ -24,6 +24,8 @@
 #include "egluGLUtil.hpp"
 
 #include "egluUtil.hpp"
+#include "eglwLibrary.hpp"
+#include "eglwEnums.hpp"
 #include "glwEnums.hpp"
 
 #include <vector>
@@ -33,6 +35,8 @@
 namespace eglu
 {
 
+using namespace eglw;
+
 glw::GLenum getImageGLTarget (EGLenum source)
 {
 	switch (source)
@@ -72,9 +76,9 @@
 	return 0;
 }
 
-EGLContext createGLContext (EGLDisplay display, EGLContext eglConfig, const glu::ContextType& contextType)
+EGLContext createGLContext (const Library& egl, EGLDisplay display, EGLContext eglConfig, const glu::ContextType& contextType)
 {
-	const bool			khrCreateContextSupported	= hasExtension(display, "EGL_KHR_create_context");
+	const bool			khrCreateContextSupported	= hasExtension(egl, display, "EGL_KHR_create_context");
 	EGLContext			context						= EGL_NO_CONTEXT;
 	EGLenum				api							= EGL_NONE;
 	vector<EGLint>		attribList;
@@ -144,11 +148,90 @@
 
 	attribList.push_back(EGL_NONE);
 
-	EGLU_CHECK_CALL(eglBindAPI(api));
-	context = eglCreateContext(display, eglConfig, EGL_NO_CONTEXT, &(attribList[0]));
-	EGLU_CHECK_MSG("eglCreateContext()");
+	EGLU_CHECK_CALL(egl, bindAPI(api));
+	context = egl.createContext(display, eglConfig, EGL_NO_CONTEXT, &(attribList[0]));
+	EGLU_CHECK_MSG(egl, "eglCreateContext()");
 
 	return context;
 }
 
+static bool configMatches (const eglw::Library& egl, eglw::EGLDisplay display, eglw::EGLConfig eglConfig, const glu::RenderConfig& renderConfig)
+{
+	// \todo [2014-03-12 pyry] Check other attributes like double-buffer bit.
+
+	{
+		EGLint		renderableType		= 0;
+		EGLint		requiredRenderable	= apiRenderableType(renderConfig.type.getAPI());
+
+		EGLU_CHECK_CALL(egl, getConfigAttrib(display, eglConfig, EGL_RENDERABLE_TYPE, &renderableType));
+
+		if ((renderableType & requiredRenderable) == 0)
+			return false;
+	}
+
+	if (renderConfig.surfaceType != (glu::RenderConfig::SurfaceType)glu::RenderConfig::DONT_CARE)
+	{
+		EGLint		surfaceType		= 0;
+		EGLint		requiredSurface	= 0;
+
+		switch (renderConfig.surfaceType)
+		{
+			case glu::RenderConfig::SURFACETYPE_WINDOW:				requiredSurface = EGL_WINDOW_BIT;	break;
+			case glu::RenderConfig::SURFACETYPE_OFFSCREEN_NATIVE:	requiredSurface = EGL_PIXMAP_BIT;	break;
+			case glu::RenderConfig::SURFACETYPE_OFFSCREEN_GENERIC:	requiredSurface = EGL_PBUFFER_BIT;	break;
+			default:
+				DE_ASSERT(false);
+		}
+
+		EGLU_CHECK_CALL(egl, getConfigAttrib(display, eglConfig, EGL_SURFACE_TYPE, &surfaceType));
+
+		if ((surfaceType & requiredSurface) == 0)
+			return false;
+	}
+
+	{
+		static const struct
+		{
+			int	glu::RenderConfig::*field;
+			EGLint attrib;
+		} s_attribs[] =
+		{
+			{ &glu::RenderConfig::id,			EGL_CONFIG_ID		},
+			{ &glu::RenderConfig::redBits,		EGL_RED_SIZE		},
+			{ &glu::RenderConfig::greenBits,	EGL_GREEN_SIZE		},
+			{ &glu::RenderConfig::blueBits,		EGL_BLUE_SIZE		},
+			{ &glu::RenderConfig::alphaBits,	EGL_ALPHA_SIZE		},
+			{ &glu::RenderConfig::depthBits,	EGL_DEPTH_SIZE		},
+			{ &glu::RenderConfig::stencilBits,	EGL_STENCIL_SIZE	},
+			{ &glu::RenderConfig::numSamples,	EGL_SAMPLES			},
+		};
+
+		for (int attribNdx = 0; attribNdx < DE_LENGTH_OF_ARRAY(s_attribs); attribNdx++)
+		{
+			if (renderConfig.*s_attribs[attribNdx].field != glu::RenderConfig::DONT_CARE)
+			{
+				EGLint value = 0;
+				EGLU_CHECK_CALL(egl, getConfigAttrib(display, eglConfig, s_attribs[attribNdx].attrib, &value));
+				if (value != renderConfig.*s_attribs[attribNdx].field)
+					return false;
+			}
+		}
+	}
+
+	return true;
+}
+
+EGLConfig chooseConfig (const Library& egl, EGLDisplay display, const glu::RenderConfig& config)
+{
+	const std::vector<EGLConfig> configs = eglu::getConfigs(egl, display);
+
+	for (vector<EGLConfig>::const_iterator iter = configs.begin(); iter != configs.end(); ++iter)
+	{
+		if (configMatches(egl, display, *iter, config))
+			return *iter;
+	}
+
+	throw tcu::NotSupportedError("Matching EGL config not found", DE_NULL, __FILE__, __LINE__);
+}
+
 }
diff --git a/framework/egl/egluGLUtil.hpp b/framework/egl/egluGLUtil.hpp
index 0f2feed..e0db6ba 100644
--- a/framework/egl/egluGLUtil.hpp
+++ b/framework/egl/egluGLUtil.hpp
@@ -24,17 +24,23 @@
  *//*--------------------------------------------------------------------*/
 
 #include "egluDefs.hpp"
-#include "egluHeaderWrapper.hpp"
+#include "eglwDefs.hpp"
 
 #include "gluRenderConfig.hpp"
 #include "glwDefs.hpp"
 
+namespace eglw
+{
+class Library;
+}
+
 namespace eglu
 {
 
-glw::GLenum		getImageGLTarget		(EGLenum source);
-EGLint			apiRenderableType 		(glu::ApiType apiType);
-EGLContext		createGLContext			(EGLDisplay display, EGLConfig config, const glu::ContextType& contextType);
+glw::GLenum			getImageGLTarget		(eglw::EGLenum source);
+eglw::EGLint		apiRenderableType 		(glu::ApiType apiType);
+eglw::EGLContext	createGLContext			(const eglw::Library& egl, eglw::EGLDisplay display, eglw::EGLConfig config, const glu::ContextType& contextType);
+eglw::EGLConfig		chooseConfig			(const eglw::Library& egl, eglw::EGLDisplay display, const glu::RenderConfig& config);
 
 }
 
diff --git a/framework/egl/egluHeaderWrapper.hpp b/framework/egl/egluHeaderWrapper.hpp
deleted file mode 100644
index c5cea9d..0000000
--- a/framework/egl/egluHeaderWrapper.hpp
+++ /dev/null
@@ -1,71 +0,0 @@
-#ifndef _EGLUHEADERWRAPPER_HPP
-#define _EGLUHEADERWRAPPER_HPP
-/*-------------------------------------------------------------------------
- * drawElements Quality Program Tester Core
- * ----------------------------------------
- *
- * Copyright 2014 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- *      http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- *
- *//*!
- * \file
- * \brief EGL header file wrapper
- *//*--------------------------------------------------------------------*/
-
-#include "tcuDefs.hpp"
-
-// egl.h includes windows.h on Windows
-#if (DE_OS == DE_OS_WIN32)
-#	if !defined(VC_EXTRALEAN)
-#		define VC_EXTRALEAN 1
-#	endif
-#	if !defined(WIN32_LEAN_AND_MEAN)
-#		define WIN32_LEAN_AND_MEAN 1
-#	endif
-#	if !defined(NOMINMAX)
-#		define NOMINMAX 1
-#	endif
-#endif
-
-#include <EGL/egl.h>
-#include <EGL/eglext.h>
-
-#if !defined(EGL_VERSION_1_5)
-	typedef deIntptr EGLAttrib;
-#endif
-
-#if !defined(EGL_KHR_create_context)
-	#define EGL_KHR_create_context 1
-	#define EGL_CONTEXT_MAJOR_VERSION_KHR						0x3098
-	#define EGL_CONTEXT_MINOR_VERSION_KHR						0x30FB
-	#define EGL_CONTEXT_FLAGS_KHR								0x30FC
-	#define EGL_CONTEXT_OPENGL_PROFILE_MASK_KHR					0x30FD
-	#define EGL_CONTEXT_OPENGL_RESET_NOTIFICATION_STRATEGY_KHR	0x31BD
-	#define EGL_NO_RESET_NOTIFICATION_KHR						0x31BE
-	#define EGL_LOSE_CONTEXT_ON_RESET_KHR						0x31BF
-	#define EGL_CONTEXT_OPENGL_DEBUG_BIT_KHR					0x00000001
-	#define EGL_CONTEXT_OPENGL_FORWARD_COMPATIBLE_BIT_KHR		0x00000002
-	#define EGL_CONTEXT_OPENGL_ROBUST_ACCESS_BIT_KHR			0x00000004
-	#define EGL_CONTEXT_OPENGL_CORE_PROFILE_BIT_KHR				0x00000001
-	#define EGL_CONTEXT_OPENGL_COMPATIBILITY_PROFILE_BIT_KHR	0x00000002
-	#define EGL_OPENGL_ES3_BIT_KHR								0x00000040
-#endif // EGL_KHR_create_context
-
-#if !defined(EGL_ANDROID_image_native_buffer)
-#define EGL_ANDROID_image_native_buffer 1
-struct ANativeWindowBuffer;
-#define EGL_NATIVE_BUFFER_ANDROID								0x3140
-#endif
-
-#endif // _EGLUHEADERWRAPPER_HPP
diff --git a/framework/egl/egluNativeDisplay.cpp b/framework/egl/egluNativeDisplay.cpp
index c29e423..8f7af55 100644
--- a/framework/egl/egluNativeDisplay.cpp
+++ b/framework/egl/egluNativeDisplay.cpp
@@ -22,10 +22,13 @@
  *//*--------------------------------------------------------------------*/
 
 #include "egluNativeDisplay.hpp"
+#include "eglwEnums.hpp"
 
 namespace eglu
 {
 
+using namespace eglw;
+
 // NativeDisplay
 
 NativeDisplay::NativeDisplay (Capability capabilities, EGLenum platformType, const char* platformExtension)
@@ -62,6 +65,12 @@
 	throw tcu::NotSupportedError("eglu::NativeDisplay can't be used with eglGetPlatformDisplay()", DE_NULL, __FILE__, __LINE__);
 }
 
+const EGLAttrib* NativeDisplay::getPlatformAttributes (void) const
+{
+	TCU_CHECK_INTERNAL((m_capabilities & CAPABILITY_GET_DISPLAY_PLATFORM) == 0);
+	return DE_NULL;
+}
+
 // NativeDisplayFactory
 
 NativeDisplayFactory::NativeDisplayFactory (const std::string& name, const std::string& description, NativeDisplay::Capability capabilities, EGLenum platformType, const char* platformExtension)
diff --git a/framework/egl/egluNativeDisplay.hpp b/framework/egl/egluNativeDisplay.hpp
index 932f4ed..bd142cc 100644
--- a/framework/egl/egluNativeDisplay.hpp
+++ b/framework/egl/egluNativeDisplay.hpp
@@ -27,10 +27,15 @@
 #include "tcuFactoryRegistry.hpp"
 #include "egluNativeWindow.hpp"
 #include "egluNativePixmap.hpp"
-#include "egluHeaderWrapper.hpp"
+#include "eglwDefs.hpp"
 
 #include <string>
 
+namespace eglw
+{
+class Library;
+}
+
 namespace eglu
 {
 
@@ -45,18 +50,23 @@
 
 	virtual								~NativeDisplay				(void);
 
+	virtual const eglw::Library&		getLibrary					(void) const = 0;
+
 	Capability							getCapabilities				(void) const { return m_capabilities; }
-	EGLenum								getPlatformType				(void) const { return m_platformType; }
+	eglw::EGLenum						getPlatformType				(void) const { return m_platformType; }
 	const char*							getPlatformExtensionName	(void) const { return (m_platformExtension.empty() ? DE_NULL : m_platformExtension.c_str()); }
 
 	//! Get EGLNativeDisplayType that can be used with eglGetDisplay(). Default implementation throws tcu::NotSupportedError().
-	virtual EGLNativeDisplayType		getLegacyNative				(void);
+	virtual eglw::EGLNativeDisplayType	getLegacyNative				(void);
 
 	//! Return display pointer that can be used with eglGetPlatformDisplay(). Default implementations throw tcu::NotSupportedError()
 	virtual void*						getPlatformNative			(void);
 
+	//! Attributes to pass to eglGetPlatformDisplay(EXT)
+	virtual const eglw::EGLAttrib*		getPlatformAttributes		(void) const;
+
 protected:
-										NativeDisplay				(Capability capabilities, EGLenum platformType, const char* platformExtension);
+										NativeDisplay				(Capability capabilities, eglw::EGLenum platformType, const char* platformExtension);
 										NativeDisplay				(Capability capabilities);
 
 private:
@@ -64,7 +74,7 @@
 	NativeDisplay&						operator=					(const NativeDisplay&);
 
 	const Capability					m_capabilities;
-	const EGLenum						m_platformType;				//!< EGL platform type, or EGL_NONE if not supported.
+	const eglw::EGLenum					m_platformType;				//!< EGL platform type, or EGL_NONE if not supported.
 	const std::string					m_platformExtension;
 };
 
@@ -73,10 +83,10 @@
 public:
 	virtual								~NativeDisplayFactory		(void);
 
-	virtual NativeDisplay*				createDisplay				(const EGLAttrib* attribList = DE_NULL) const = 0;
+	virtual NativeDisplay*				createDisplay				(const eglw::EGLAttrib* attribList = DE_NULL) const = 0;
 
 	NativeDisplay::Capability			getCapabilities				(void) const { return m_capabilities; }
-	EGLenum								getPlatformType				(void) const { return m_platformType; }
+	eglw::EGLenum						getPlatformType				(void) const { return m_platformType; }
 	const char*							getPlatformExtensionName	(void) const { return (m_platformExtension.empty() ? DE_NULL : m_platformExtension.c_str()); }
 
 	const NativeWindowFactoryRegistry&	getNativeWindowRegistry		(void) const { return m_nativeWindowRegistry; }
@@ -84,7 +94,7 @@
 
 protected:
 										NativeDisplayFactory		(const std::string& name, const std::string& description, NativeDisplay::Capability capabilities);
-										NativeDisplayFactory		(const std::string& name, const std::string& description, NativeDisplay::Capability capabilities, EGLenum platformType, const char* platformExtension);
+										NativeDisplayFactory		(const std::string& name, const std::string& description, NativeDisplay::Capability capabilities, eglw::EGLenum platformType, const char* platformExtension);
 
 	NativeWindowFactoryRegistry			m_nativeWindowRegistry;
 	NativePixmapFactoryRegistry			m_nativePixmapRegistry;
@@ -94,7 +104,7 @@
 	NativeDisplayFactory&				operator=					(const NativeDisplayFactory&);
 
 	const NativeDisplay::Capability		m_capabilities;
-	const EGLenum						m_platformType;
+	const eglw::EGLenum					m_platformType;
 	const std::string					m_platformExtension;
 };
 
diff --git a/framework/egl/egluNativePixmap.cpp b/framework/egl/egluNativePixmap.cpp
index 2300404..64b1195 100644
--- a/framework/egl/egluNativePixmap.cpp
+++ b/framework/egl/egluNativePixmap.cpp
@@ -26,6 +26,8 @@
 namespace eglu
 {
 
+using namespace eglw;
+
 // NativePixmap
 
 NativePixmap::NativePixmap (Capability capabilities)
diff --git a/framework/egl/egluNativePixmap.hpp b/framework/egl/egluNativePixmap.hpp
index 41d26df..8c8ac79 100644
--- a/framework/egl/egluNativePixmap.hpp
+++ b/framework/egl/egluNativePixmap.hpp
@@ -25,7 +25,7 @@
 
 #include "tcuDefs.hpp"
 #include "tcuFactoryRegistry.hpp"
-#include "egluHeaderWrapper.hpp"
+#include "eglwDefs.hpp"
 #include "tcuVector.hpp"
 
 namespace tcu
@@ -48,51 +48,51 @@
 		CAPABILITY_READ_PIXELS				= (1<<2)
 	};
 
-	virtual						~NativePixmap					(void) {}
+	virtual								~NativePixmap			(void) {}
 
 	//! Return EGLNativePixmapType that can be used with eglCreatePixmapSurface(). Default implementation throws tcu::NotSupportedError().
-	virtual EGLNativePixmapType	getLegacyNative					(void);
+	virtual eglw::EGLNativePixmapType	getLegacyNative			(void);
 
 	//! Return native pointer that can be used with eglCreatePlatformPixmapSurfaceEXT(). Default implementation throws tcu::NotSupportedError().
-	virtual void*				getPlatformNative				(void);
+	virtual void*						getPlatformNative		(void);
 
 	// Read pixels from pixmap. Default implementation throws tcu::NotSupportedError()
-	virtual void				readPixels						(tcu::TextureLevel* dst);
+	virtual void						readPixels				(tcu::TextureLevel* dst);
 
 	// These values are initialized in constructor.
-	Capability					getCapabilities					(void) const { return m_capabilities; }
+	Capability							getCapabilities			(void) const { return m_capabilities; }
 
 protected:
-								NativePixmap					(Capability capabilities);
+										NativePixmap			(Capability capabilities);
 
 private:
-								NativePixmap					(const NativePixmap&);
-	NativePixmap&				operator=						(const NativePixmap&);
+										NativePixmap			(const NativePixmap&);
+	NativePixmap&						operator=				(const NativePixmap&);
 
-	const Capability			m_capabilities;
+	const Capability					m_capabilities;
 };
 
 class NativePixmapFactory : public tcu::FactoryBase
 {
 public:
-	virtual							~NativePixmapFactory	(void);
+	virtual								~NativePixmapFactory	(void);
 
 	//! Create generic pixmap.
-	virtual NativePixmap*			createPixmap			(NativeDisplay* nativeDisplay, int width, int height) const = 0;
+	virtual NativePixmap*				createPixmap			(NativeDisplay* nativeDisplay, int width, int height) const = 0;
 
 	//! Create pixmap that matches given EGL config. Defaults to generic createPixmap().
-	virtual NativePixmap*			createPixmap			(NativeDisplay* nativeDisplay, EGLDisplay display, EGLConfig config, const EGLAttrib* attribList, int width, int height) const;
+	virtual NativePixmap*				createPixmap			(NativeDisplay* nativeDisplay, eglw::EGLDisplay display, eglw::EGLConfig config, const eglw::EGLAttrib* attribList, int width, int height) const;
 
-	NativePixmap::Capability		getCapabilities			(void) const { return m_capabilities; }
+	NativePixmap::Capability			getCapabilities			(void) const { return m_capabilities; }
 
 protected:
-									NativePixmapFactory		(const std::string& name, const std::string& description, NativePixmap::Capability capabilities);
+										NativePixmapFactory		(const std::string& name, const std::string& description, NativePixmap::Capability capabilities);
 
 private:
-									NativePixmapFactory		(const NativePixmapFactory&);
-	NativePixmapFactory&			operator=				(const NativePixmapFactory&);
+										NativePixmapFactory		(const NativePixmapFactory&);
+	NativePixmapFactory&				operator=				(const NativePixmapFactory&);
 
-	const NativePixmap::Capability	m_capabilities;
+	const NativePixmap::Capability		m_capabilities;
 };
 
 typedef tcu::FactoryRegistry<NativePixmapFactory> NativePixmapFactoryRegistry;
diff --git a/framework/egl/egluNativeWindow.cpp b/framework/egl/egluNativeWindow.cpp
index 9a15f23..c564d9f 100644
--- a/framework/egl/egluNativeWindow.cpp
+++ b/framework/egl/egluNativeWindow.cpp
@@ -26,6 +26,8 @@
 namespace eglu
 {
 
+using namespace eglw;
+
 // NativeWindow
 
 NativeWindow::NativeWindow (Capability capabilities)
diff --git a/framework/egl/egluNativeWindow.hpp b/framework/egl/egluNativeWindow.hpp
index f404013..e468a23 100644
--- a/framework/egl/egluNativeWindow.hpp
+++ b/framework/egl/egluNativeWindow.hpp
@@ -25,7 +25,7 @@
 
 #include "tcuDefs.hpp"
 #include "tcuFactoryRegistry.hpp"
-#include "egluHeaderWrapper.hpp"
+#include "eglwDefs.hpp"
 #include "tcuVector.hpp"
 
 namespace tcu
@@ -84,65 +84,65 @@
 		CAPABILITY_CHANGE_VISIBILITY		= (1<<6)
 	};
 
-	virtual						~NativeWindow					(void) {}
+	virtual								~NativeWindow					(void) {}
 
 	//! Return EGLNativeWindowType that can be used with eglCreateWindowSurface(). Default implementation throws tcu::NotSupportedError().
-	virtual EGLNativeWindowType	getLegacyNative					(void);
+	virtual eglw::EGLNativeWindowType	getLegacyNative					(void);
 
 	//! Return native pointer that can be used with eglCreatePlatformWindowSurface(). Default implementation throws tcu::NotSupportedError().
-	virtual void*				getPlatformNative				(void);
+	virtual void*						getPlatformNative				(void);
 
 	// Process window events. Defaults to dummy implementation, that does nothing.
-	virtual void				processEvents					(void) {}
+	virtual void						processEvents					(void) {}
 
 	// Get current size of window's logical surface. Default implementation throws tcu::NotSupportedError()
-	virtual tcu::IVec2			getSurfaceSize					(void) const;
+	virtual tcu::IVec2					getSurfaceSize					(void) const;
 
 	// Set the size of the window's logical surface. Default implementation throws tcu::NotSupportedError()
-	virtual void				setSurfaceSize					(tcu::IVec2 size);
+	virtual void						setSurfaceSize					(tcu::IVec2 size);
 
 	// Get the size of the window in screen pixels. Default implementation throws tcu::NotSupportedError()
-	virtual tcu::IVec2			getScreenSize					(void) const;
+	virtual tcu::IVec2					getScreenSize					(void) const;
 
 	// Read screen (visible) pixels from window. Default implementation throws tcu::NotSupportedError()
-	virtual void				readScreenPixels				(tcu::TextureLevel* dst) const;
+	virtual void						readScreenPixels				(tcu::TextureLevel* dst) const;
 
 	// Change window visibility. Default throws tcu::NotSupportedError().
-	virtual void				setVisibility					(WindowParams::Visibility visibility);
+	virtual void						setVisibility					(WindowParams::Visibility visibility);
 
-	Capability					getCapabilities					(void) const { return m_capabilities; }
+	Capability							getCapabilities					(void) const { return m_capabilities; }
 
 protected:
-								NativeWindow					(Capability capabilities);
+										NativeWindow					(Capability capabilities);
 
 private:
-								NativeWindow					(const NativeWindow&);
-	NativeWindow&				operator=						(const NativeWindow&);
+										NativeWindow					(const NativeWindow&);
+	NativeWindow&						operator=						(const NativeWindow&);
 
-	const Capability			m_capabilities;
+	const Capability					m_capabilities;
 };
 
 class NativeWindowFactory : public tcu::FactoryBase
 {
 public:
-	virtual							~NativeWindowFactory			(void);
+	virtual								~NativeWindowFactory			(void);
 
 	//! Create generic NativeWindow
-	virtual NativeWindow*			createWindow					(NativeDisplay* nativeDisplay, const WindowParams& params) const = 0;
+	virtual NativeWindow*				createWindow					(NativeDisplay* nativeDisplay, const WindowParams& params) const = 0;
 
 	//! Create NativeWindow that matches given config. Defaults to generic createWindow().
-	virtual NativeWindow*			createWindow					(NativeDisplay* nativeDisplay, EGLDisplay display, EGLConfig config, const EGLAttrib* attribList, const WindowParams& params) const;
+	virtual NativeWindow*				createWindow					(NativeDisplay* nativeDisplay, eglw::EGLDisplay display, eglw::EGLConfig config, const eglw::EGLAttrib* attribList, const WindowParams& params) const;
 
-	NativeWindow::Capability		getCapabilities					(void) const { return m_capabilities; }
+	NativeWindow::Capability			getCapabilities					(void) const { return m_capabilities; }
 
 protected:
-									NativeWindowFactory				(const std::string& name, const std::string& description, NativeWindow::Capability capabilities);
+										NativeWindowFactory				(const std::string& name, const std::string& description, NativeWindow::Capability capabilities);
 
 private:
-									NativeWindowFactory				(const NativeWindowFactory&);
-	NativeWindowFactory&			operator=						(const NativeWindowFactory&);
+										NativeWindowFactory				(const NativeWindowFactory&);
+	NativeWindowFactory&				operator=						(const NativeWindowFactory&);
 
-	const NativeWindow::Capability	m_capabilities;
+	const NativeWindow::Capability		m_capabilities;
 };
 
 typedef tcu::FactoryRegistry<NativeWindowFactory> NativeWindowFactoryRegistry;
diff --git a/framework/egl/egluStaticES20Library.inl b/framework/egl/egluStaticES20Library.inl
index 3f01b68..1259dc6 100644
--- a/framework/egl/egluStaticES20Library.inl
+++ b/framework/egl/egluStaticES20Library.inl
@@ -1,7 +1,7 @@
 /* WARNING: This is auto-generated file. Do not modify, since changes will
  * be lost! Modify the generating script instead.
  *
- * Generated from Khronos GL API description (gl.xml) revision 28861.
+ * Generated from Khronos GL API description (gl.xml) revision 29570.
  */
 	{ "glActiveTexture",						(deFunctionPtr)glActiveTexture },
 	{ "glAttachShader",							(deFunctionPtr)glAttachShader },
diff --git a/framework/egl/egluStaticES30Library.inl b/framework/egl/egluStaticES30Library.inl
index 85bc8b0..0c33ffd 100644
--- a/framework/egl/egluStaticES30Library.inl
+++ b/framework/egl/egluStaticES30Library.inl
@@ -1,7 +1,7 @@
 /* WARNING: This is auto-generated file. Do not modify, since changes will
  * be lost! Modify the generating script instead.
  *
- * Generated from Khronos GL API description (gl.xml) revision 28861.
+ * Generated from Khronos GL API description (gl.xml) revision 29570.
  */
 	{ "glActiveTexture",						(deFunctionPtr)glActiveTexture },
 	{ "glAttachShader",							(deFunctionPtr)glAttachShader },
diff --git a/framework/egl/egluStrUtil.cpp b/framework/egl/egluStrUtil.cpp
index 660b9ea..3055731 100644
--- a/framework/egl/egluStrUtil.cpp
+++ b/framework/egl/egluStrUtil.cpp
@@ -22,13 +22,7 @@
  *//*--------------------------------------------------------------------*/
 
 #include "egluStrUtil.hpp"
-#include "egluHeaderWrapper.hpp"
-
-#include <EGL/eglext.h>
-
-#if !defined(EGL_OPENGL_ES3_BIT_KHR)
-#	define EGL_OPENGL_ES3_BIT_KHR	0x0040
-#endif
+#include "eglwEnums.hpp"
 
 namespace eglu
 {
@@ -139,11 +133,11 @@
 		case EGL_TEXTURE_TARGET:
 			return str << getTextureTargetStr(attribFmt.value);
 
-		case EGL_VG_ALPHA_FORMAT:
-			return str << getVGAlphaFormatStr(attribFmt.value);
+		case EGL_ALPHA_FORMAT:
+			return str << getAlphaFormatStr(attribFmt.value);
 
-		case EGL_VG_COLORSPACE:
-			return str << getVGColorspaceStr(attribFmt.value);
+		case EGL_COLORSPACE:
+			return str << getColorspaceStr(attribFmt.value);
 
 		default:
 			return str << tcu::toHex(attribFmt.value);
diff --git a/framework/egl/egluStrUtil.inl b/framework/egl/egluStrUtil.inl
index 693e147..4c1896a 100644
--- a/framework/egl/egluStrUtil.inl
+++ b/framework/egl/egluStrUtil.inl
@@ -126,8 +126,8 @@
 		case EGL_SWAP_BEHAVIOR:			return "EGL_SWAP_BEHAVIOR";
 		case EGL_TEXTURE_FORMAT:		return "EGL_TEXTURE_FORMAT";
 		case EGL_TEXTURE_TARGET:		return "EGL_TEXTURE_TARGET";
-		case EGL_VG_ALPHA_FORMAT:		return "EGL_VG_ALPHA_FORMAT";
-		case EGL_VG_COLORSPACE:			return "EGL_VG_COLORSPACE";
+		case EGL_ALPHA_FORMAT:			return "EGL_ALPHA_FORMAT";
+		case EGL_COLORSPACE:			return "EGL_COLORSPACE";
 		default:						return DE_NULL;
 	}
 }
@@ -224,23 +224,23 @@
 	}
 }
 
-const char* getVGAlphaFormatName (int value)
+const char* getAlphaFormatName (int value)
 {
 	switch (value)
 	{
-		case EGL_VG_ALPHA_FORMAT_NONPRE:	return "EGL_VG_ALPHA_FORMAT_NONPRE";
-		case EGL_VG_ALPHA_FORMAT_PRE:		return "EGL_VG_ALPHA_FORMAT_PRE";
-		default:							return DE_NULL;
+		case EGL_ALPHA_FORMAT_NONPRE:	return "EGL_ALPHA_FORMAT_NONPRE";
+		case EGL_ALPHA_FORMAT_PRE:		return "EGL_ALPHA_FORMAT_PRE";
+		default:						return DE_NULL;
 	}
 }
 
-const char* getVGColorspaceName (int value)
+const char* getColorspaceName (int value)
 {
 	switch (value)
 	{
-		case EGL_VG_COLORSPACE_sRGB:	return "EGL_VG_COLORSPACE_sRGB";
-		case EGL_VG_COLORSPACE_LINEAR:	return "EGL_VG_COLORSPACE_LINEAR";
-		default:						return DE_NULL;
+		case EGL_COLORSPACE_sRGB:	return "EGL_COLORSPACE_sRGB";
+		case EGL_COLORSPACE_LINEAR:	return "EGL_COLORSPACE_LINEAR";
+		default:					return DE_NULL;
 	}
 }
 
diff --git a/framework/egl/egluStrUtilPrototypes.inl b/framework/egl/egluStrUtilPrototypes.inl
index a0746e5..5abcef5 100644
--- a/framework/egl/egluStrUtilPrototypes.inl
+++ b/framework/egl/egluStrUtilPrototypes.inl
@@ -19,8 +19,8 @@
 const char*							getSwapBehaviorName			(int value);
 const char*							getTextureFormatName		(int value);
 const char*							getTextureTargetName		(int value);
-const char*							getVGAlphaFormatName		(int value);
-const char*							getVGColorspaceName			(int value);
+const char*							getAlphaFormatName			(int value);
+const char*							getColorspaceName			(int value);
 tcu::Format::Bitfield<16>			getAPIBitsStr				(int value);
 tcu::Format::Bitfield<16>			getSurfaceBitsStr			(int value);
 inline tcu::Format::Enum<int, 2>	getBooleanStr				(int value)		{ return tcu::Format::Enum<int, 2>(getBooleanName, value); }
@@ -39,5 +39,5 @@
 inline tcu::Format::Enum<int, 2>	getSwapBehaviorStr			(int value)		{ return tcu::Format::Enum<int, 2>(getSwapBehaviorName, value); }
 inline tcu::Format::Enum<int, 2>	getTextureFormatStr			(int value)		{ return tcu::Format::Enum<int, 2>(getTextureFormatName, value); }
 inline tcu::Format::Enum<int, 2>	getTextureTargetStr			(int value)		{ return tcu::Format::Enum<int, 2>(getTextureTargetName, value); }
-inline tcu::Format::Enum<int, 2>	getVGAlphaFormatStr			(int value)		{ return tcu::Format::Enum<int, 2>(getVGAlphaFormatName, value); }
-inline tcu::Format::Enum<int, 2>	getVGColorspaceStr			(int value)		{ return tcu::Format::Enum<int, 2>(getVGColorspaceName, value); }
+inline tcu::Format::Enum<int, 2>	getAlphaFormatStr			(int value)		{ return tcu::Format::Enum<int, 2>(getAlphaFormatName, value); }
+inline tcu::Format::Enum<int, 2>	getColorspaceStr			(int value)		{ return tcu::Format::Enum<int, 2>(getColorspaceName, value); }
diff --git a/framework/egl/egluUnique.cpp b/framework/egl/egluUnique.cpp
index 8b15fdf..da04c1d 100644
--- a/framework/egl/egluUnique.cpp
+++ b/framework/egl/egluUnique.cpp
@@ -22,14 +22,34 @@
  *//*--------------------------------------------------------------------*/
 
 #include "egluUnique.hpp"
-
-#include "tcuEgl.hpp"
+#include "eglwLibrary.hpp"
+#include "eglwEnums.hpp"
 
 namespace eglu
 {
 
-UniqueSurface::UniqueSurface (EGLDisplay display, EGLSurface surface)
-	: m_display	(display)
+using namespace eglw;
+
+UniqueDisplay::UniqueDisplay (const Library& egl, EGLDisplay display)
+	: m_egl		(egl)
+	, m_display	(display)
+{
+}
+
+UniqueDisplay::~UniqueDisplay (void)
+{
+	if (m_display != EGL_NO_DISPLAY)
+		m_egl.terminate(m_display);
+}
+
+UniqueDisplay::operator bool (void) const
+{
+	return m_display != EGL_NO_DISPLAY;
+}
+
+UniqueSurface::UniqueSurface (const Library& egl, EGLDisplay display, EGLSurface surface)
+	: m_egl		(egl)
+	, m_display	(display)
 	, m_surface	(surface)
 {
 }
@@ -37,11 +57,17 @@
 UniqueSurface::~UniqueSurface (void)
 {
 	if (m_surface != EGL_NO_SURFACE)
-		TCU_CHECK_EGL_CALL(eglDestroySurface(m_display, m_surface));
+		m_egl.destroySurface(m_display, m_surface);
 }
 
-UniqueContext::UniqueContext (EGLDisplay display, EGLContext context)
-	: m_display	(display)
+UniqueSurface::operator bool (void) const
+{
+	return m_surface != EGL_NO_SURFACE;
+}
+
+UniqueContext::UniqueContext (const Library& egl, EGLDisplay display, EGLContext context)
+	: m_egl		(egl)
+	, m_display	(display)
 	, m_context	(context)
 {
 }
@@ -49,31 +75,42 @@
 UniqueContext::~UniqueContext (void)
 {
 	if (m_context != EGL_NO_CONTEXT)
-		TCU_CHECK_EGL_CALL(eglDestroyContext(m_display, m_context));
+		m_egl.destroyContext(m_display, m_context);
 }
 
-ScopedCurrentContext::ScopedCurrentContext (EGLDisplay display, EGLSurface draw, EGLSurface read, EGLContext context)
-	: m_display (display)
+UniqueContext::operator bool (void) const
 {
-	EGLU_CHECK_CALL(eglMakeCurrent(display, draw, read, context));
+	return m_context != EGL_NO_CONTEXT;
+}
+
+ScopedCurrentContext::ScopedCurrentContext (const Library& egl, EGLDisplay display, EGLSurface draw, EGLSurface read, EGLContext context)
+	: m_egl		(egl)
+	, m_display (display)
+{
+	EGLU_CHECK_CALL(m_egl, makeCurrent(display, draw, read, context));
 }
 
 ScopedCurrentContext::~ScopedCurrentContext (void)
 {
-	EGLU_CHECK_CALL(eglMakeCurrent(m_display, EGL_NO_SURFACE, EGL_NO_SURFACE, EGL_NO_CONTEXT));
+	m_egl.makeCurrent(m_display, EGL_NO_SURFACE, EGL_NO_SURFACE, EGL_NO_CONTEXT);
 }
 
-UniqueImage::UniqueImage (EGLDisplay display, EGLImageKHR image, const ImageFunctions& funcs)
-	: m_display	(display)
+UniqueImage::UniqueImage (const Library& egl, EGLDisplay display, EGLImage image)
+	: m_egl		(egl)
+	, m_display	(display)
 	, m_image	(image)
-	, m_funcs	(funcs)
 {
 }
 
 UniqueImage::~UniqueImage (void)
 {
-	if (m_image != EGL_NO_IMAGE_KHR)
-		EGLU_CHECK_CALL(m_funcs.destroyImage(m_display, m_image));
+	if (m_image != EGL_NO_IMAGE)
+		m_egl.destroyImageKHR(m_display, m_image);
+}
+
+UniqueImage::operator bool (void) const
+{
+	return m_image != EGL_NO_IMAGE;
 }
 
 } // eglu
diff --git a/framework/egl/egluUnique.hpp b/framework/egl/egluUnique.hpp
index 7db218a..aa24f5a 100644
--- a/framework/egl/egluUnique.hpp
+++ b/framework/egl/egluUnique.hpp
@@ -24,75 +24,100 @@
  *//*--------------------------------------------------------------------*/
 
 #include "egluDefs.hpp"
-#include "egluHeaderWrapper.hpp"
-#include "egluExtensions.hpp"
+#include "eglwDefs.hpp"
+
+namespace eglw
+{
+class Library;
+}
 
 namespace eglu
 {
 
+class UniqueDisplay
+{
+public:
+							UniqueDisplay	(const eglw::Library& egl, eglw::EGLDisplay display);
+							~UniqueDisplay	(void);
+
+	eglw::EGLDisplay		operator*		(void) const { return m_display; }
+	operator				bool			(void) const;
+
+private:
+	const eglw::Library&	m_egl;
+	eglw::EGLDisplay		m_display;
+
+	// Disabled
+	UniqueDisplay&			operator=		(const UniqueDisplay&);
+							UniqueDisplay	(const UniqueDisplay&);
+};
+
 class UniqueSurface
 {
 public:
-					UniqueSurface	(EGLDisplay display, EGLSurface surface);
-					~UniqueSurface	(void);
+							UniqueSurface	(const eglw::Library& egl, eglw::EGLDisplay display, eglw::EGLSurface surface);
+							~UniqueSurface	(void);
 
-	EGLSurface		operator*		(void) { return m_surface; }
-	operator		bool			(void) const { return m_surface != EGL_NO_SURFACE; }
+	eglw::EGLSurface		operator*		(void) const { return m_surface; }
+	operator				bool			(void) const;
 
 private:
-	EGLDisplay		m_display;
-	EGLSurface		m_surface;
+	const eglw::Library&	m_egl;
+	eglw::EGLDisplay		m_display;
+	eglw::EGLSurface		m_surface;
 
 	// Disabled
-	UniqueSurface&	operator=		(const UniqueSurface&);
-					UniqueSurface	(const UniqueSurface&);
+	UniqueSurface&			operator=		(const UniqueSurface&);
+							UniqueSurface	(const UniqueSurface&);
 };
 
 class UniqueContext
 {
 public:
-					UniqueContext	(EGLDisplay display, EGLContext context);
-					~UniqueContext	(void);
+							UniqueContext	(const eglw::Library& egl, eglw::EGLDisplay display, eglw::EGLContext context);
+							~UniqueContext	(void);
 
-	EGLContext		operator*		(void) { return m_context; }
-	operator		bool			(void) const { return m_context != EGL_NO_CONTEXT; }
+	eglw::EGLContext		operator*		(void) const { return m_context; }
+	operator				bool			(void) const;
 
 private:
-	EGLDisplay		m_display;
-	EGLContext		m_context;
+	const eglw::Library&	m_egl;
+	eglw::EGLDisplay		m_display;
+	eglw::EGLContext		m_context;
 
 	// Disabled
-	UniqueContext	operator=		(const UniqueContext&);
-					UniqueContext	(const UniqueContext&);
+	UniqueContext			operator=		(const UniqueContext&);
+							UniqueContext	(const UniqueContext&);
 };
 
 class ScopedCurrentContext
 {
 public:
-	ScopedCurrentContext	(EGLDisplay display, EGLSurface draw, EGLSurface read, EGLContext context);
+	ScopedCurrentContext	(const eglw::Library& egl, eglw::EGLDisplay display, eglw::EGLSurface draw, eglw::EGLSurface read, eglw::EGLContext context);
 	~ScopedCurrentContext	(void);
 
 private:
-	EGLDisplay		m_display;
+	const eglw::Library&	m_egl;
+	eglw::EGLDisplay		m_display;
 };
 
 class UniqueImage
 {
 public:
-							UniqueImage		(EGLDisplay display, EGLImageKHR image, const ImageFunctions& funcs);
+							UniqueImage		(const eglw::Library& egl, eglw::EGLDisplay display, eglw::EGLImage image);
 							~UniqueImage	(void);
 
-	EGLImageKHR				operator*		(void) { return m_image; }
-	operator				bool			(void) const { return m_image != EGL_NO_IMAGE_KHR; }
+	eglw::EGLImage			operator*		(void) const { return m_image; }
+	operator				bool			(void) const;
 
 private:
-	EGLDisplay				m_display;
-	EGLImageKHR				m_image;
-	const ImageFunctions&	m_funcs;
+	const eglw::Library&	m_egl;
+	eglw::EGLDisplay		m_display;
+	eglw::EGLImage			m_image;
 
 	// Disabled
-	UniqueImage		operator=		(const UniqueImage&);
-					UniqueImage		(const UniqueImage&);
+	UniqueImage				operator=		(const UniqueImage&);
+							UniqueImage		(const UniqueImage&);
 };
 
 } // eglu
diff --git a/framework/egl/egluUtil.cpp b/framework/egl/egluUtil.cpp
index 28d66fe..d1cb1be 100644
--- a/framework/egl/egluUtil.cpp
+++ b/framework/egl/egluUtil.cpp
@@ -24,30 +24,26 @@
 #include "egluUtil.hpp"
 #include "egluDefs.hpp"
 #include "egluNativeDisplay.hpp"
+#include "egluConfigFilter.hpp"
+#include "eglwLibrary.hpp"
+#include "eglwEnums.hpp"
 #include "tcuCommandLine.hpp"
 #include "deSTLUtil.hpp"
 #include "deStringUtil.hpp"
 #include "glwEnums.hpp"
 
-#include <EGL/eglext.h>
-
 #include <algorithm>
 #include <sstream>
 
 using std::string;
 using std::vector;
 
-#if !defined(EGL_EXT_platform_base)
-#	define EGL_EXT_platform_base 1
-	typedef EGLDisplay (EGLAPIENTRYP PFNEGLGETPLATFORMDISPLAYEXTPROC) (EGLenum platform, void *native_display, const EGLint *attrib_list);
-	typedef EGLSurface (EGLAPIENTRYP PFNEGLCREATEPLATFORMWINDOWSURFACEEXTPROC) (EGLDisplay dpy, EGLConfig config, void *native_window, const EGLint *attrib_list);
-	typedef EGLSurface (EGLAPIENTRYP PFNEGLCREATEPLATFORMPIXMAPSURFACEEXTPROC) (EGLDisplay dpy, EGLConfig config, void *native_pixmap, const EGLint *attrib_list);
-#endif // EGL_EXT_platform_base
-
 namespace eglu
 {
 
-vector<EGLint> attribMapToVector (const AttribMap& attribs)
+using namespace eglw;
+
+vector<EGLint> attribMapToList (const AttribMap& attribs)
 {
 	vector<EGLint> attribList;
 
@@ -62,124 +58,165 @@
 	return attribList;
 }
 
-Version getVersion (EGLDisplay display)
+Version getVersion (const Library& egl, EGLDisplay display)
 {
 	EGLint major, minor;
 
 	// eglInitialize on already initialized displays just returns the version.
-	EGLU_CHECK_CALL(eglInitialize(display, &major, &minor));
+	EGLU_CHECK_CALL(egl, initialize(display, &major, &minor));
 
 	return Version(major, minor);
 }
 
-vector<string> getExtensions (EGLDisplay display)
+vector<string> getExtensions (const Library& egl, EGLDisplay display)
 {
-	const char*	const extensionStr = eglQueryString(display, EGL_EXTENSIONS);
+	const char*	const extensionStr = egl.queryString(display, EGL_EXTENSIONS);
 
-	EGLU_CHECK_MSG("Querying extensions failed");
+	EGLU_CHECK_MSG(egl, "Querying extensions failed");
 
 	return de::splitString(extensionStr, ' ');
 }
 
-bool hasExtension (EGLDisplay display, const string& str)
+bool hasExtension (const Library& egl, EGLDisplay display, const string& str)
 {
-	const vector<string> extensions = getExtensions(display);
+	const vector<string> extensions = getExtensions(egl, display);
 	return de::contains(extensions.begin(), extensions.end(), str);
 }
 
-vector<string> getPlatformExtensions (void)
+vector<string> getPlatformExtensions (const Library& egl)
 {
-	return getExtensions(EGL_NO_DISPLAY);
+	return getExtensions(egl, EGL_NO_DISPLAY);
 }
 
-vector<string> getClientExtensions (EGLDisplay display)
+vector<string> getClientExtensions (const Library& egl, EGLDisplay display)
 {
 	DE_ASSERT(display != EGL_NO_DISPLAY);
 
-	return getExtensions(display);
+	return getExtensions(egl, display);
 }
 
-vector<EGLConfig> getConfigs (EGLDisplay display)
+vector<EGLConfig> getConfigs (const Library& egl, EGLDisplay display)
 {
 	vector<EGLConfig>	configs;
 	EGLint				configCount	= 0;
-	EGLU_CHECK_CALL(eglGetConfigs(display, DE_NULL, 0, &configCount));
+	EGLU_CHECK_CALL(egl, getConfigs(display, DE_NULL, 0, &configCount));
 
 	if (configCount > 0)
 	{
 		configs.resize(configCount);
-		EGLU_CHECK_CALL(eglGetConfigs(display, &(configs[0]), (EGLint)configs.size(), &configCount));
+		EGLU_CHECK_CALL(egl, getConfigs(display, &(configs[0]), (EGLint)configs.size(), &configCount));
 	}
 
 	return configs;
 }
 
-vector<EGLConfig> chooseConfig (EGLDisplay display, const AttribMap& attribs)
+vector<EGLConfig> chooseConfigs (const Library& egl, EGLDisplay display, const EGLint* attribList)
 {
-	vector<EGLint> attribList;
+	EGLint	numConfigs	= 0;
 
-	for (AttribMap::const_iterator it = attribs.begin(); it != attribs.end(); ++it)
-	{
-		attribList.push_back(it->first);
-		attribList.push_back(it->second);
-	}
-
-	attribList.push_back(EGL_NONE);
+	EGLU_CHECK_CALL(egl, chooseConfig(display, attribList, DE_NULL, 0, &numConfigs));
 
 	{
-		EGLint numConfigs = 0;
-		EGLU_CHECK_CALL(eglChooseConfig(display, &attribList.front(), DE_NULL, 0, &numConfigs));
+		vector<EGLConfig> configs(numConfigs);
 
-		{
-			vector<EGLConfig> configs(numConfigs);
+		if (numConfigs > 0)
+			EGLU_CHECK_CALL(egl, chooseConfig(display, attribList, &configs.front(), numConfigs, &numConfigs));
 
-			if (numConfigs > 0)
-				EGLU_CHECK_CALL(eglChooseConfig(display, &attribList.front(), &configs.front(), numConfigs, &numConfigs));
-
-			return configs;
-		}
+		return configs;
 	}
 }
 
-EGLConfig chooseSingleConfig (EGLDisplay display, const AttribMap& attribs)
+vector<EGLConfig> chooseConfigs (const Library& egl, EGLDisplay display, const FilterList& filters)
 {
-	vector<EGLConfig> configs (chooseConfig(display, attribs));
+	const vector<EGLConfig>	allConfigs		(getConfigs(egl, display));
+	vector<EGLConfig>		matchingConfigs;
+
+	for (vector<EGLConfig>::const_iterator cfg = allConfigs.begin(); cfg != allConfigs.end(); ++cfg)
+	{
+		if (filters.match(egl, display, *cfg))
+			matchingConfigs.push_back(*cfg);
+	}
+
+	return matchingConfigs;
+}
+
+EGLConfig chooseSingleConfig (const Library& egl, EGLDisplay display, const FilterList& filters)
+{
+	const vector<EGLConfig>	allConfigs	(getConfigs(egl, display));
+
+	for (vector<EGLConfig>::const_iterator cfg = allConfigs.begin(); cfg != allConfigs.end(); ++cfg)
+	{
+		if (filters.match(egl, display, *cfg))
+			return *cfg;
+	}
+
+	TCU_THROW(NotSupportedError, "No matching EGL config found");
+}
+
+EGLConfig chooseSingleConfig (const Library& egl, EGLDisplay display, const EGLint* attribList)
+{
+	const vector<EGLConfig> configs (chooseConfigs(egl, display, attribList));
 	if (configs.empty())
-		TCU_THROW(NotSupportedError, "No suitable EGL configuration found");
+		TCU_THROW(NotSupportedError, "No matching EGL config found");
 
 	return configs.front();
 }
 
-EGLint getConfigAttribInt (EGLDisplay display, EGLConfig config, EGLint attrib)
+vector<EGLConfig> chooseConfigs (const Library& egl, EGLDisplay display, const AttribMap& attribs)
+{
+	const vector<EGLint>	attribList	= attribMapToList(attribs);
+	return chooseConfigs(egl, display, &attribList.front());
+}
+
+EGLConfig chooseSingleConfig (const Library& egl, EGLDisplay display, const AttribMap& attribs)
+{
+	const vector<EGLint>	attribList	= attribMapToList(attribs);
+	return chooseSingleConfig(egl, display, &attribList.front());
+}
+
+EGLConfig chooseConfigByID (const Library& egl, EGLDisplay display, EGLint id)
+{
+	AttribMap attribs;
+
+	attribs[EGL_CONFIG_ID]			= id;
+	attribs[EGL_TRANSPARENT_TYPE]	= EGL_DONT_CARE;
+	attribs[EGL_COLOR_BUFFER_TYPE]	= EGL_DONT_CARE;
+	attribs[EGL_RENDERABLE_TYPE]	= EGL_DONT_CARE;
+	attribs[EGL_SURFACE_TYPE]		= EGL_DONT_CARE;
+
+	return chooseSingleConfig(egl, display, attribs);
+}
+
+EGLint getConfigAttribInt (const Library& egl, EGLDisplay display, EGLConfig config, EGLint attrib)
 {
 	EGLint value = 0;
-	EGLU_CHECK_CALL(eglGetConfigAttrib(display, config, attrib, &value));
+	EGLU_CHECK_CALL(egl, getConfigAttrib(display, config, attrib, &value));
 	return value;
 }
 
-EGLint getConfigID (EGLDisplay display, EGLConfig config)
+EGLint getConfigID (const Library& egl, EGLDisplay display, EGLConfig config)
 {
-	return getConfigAttribInt (display, config, EGL_CONFIG_ID);
+	return getConfigAttribInt(egl, display, config, EGL_CONFIG_ID);
 }
 
-EGLint querySurfaceInt (EGLDisplay display, EGLSurface surface, EGLint attrib)
+EGLint querySurfaceInt (const Library& egl, EGLDisplay display, EGLSurface surface, EGLint attrib)
 {
 	EGLint value = 0;
-	EGLU_CHECK_CALL(eglQuerySurface(display, surface, attrib, &value));
+	EGLU_CHECK_CALL(egl, querySurface(display, surface, attrib, &value));
 	return value;
 }
 
-tcu::IVec2 getSurfaceSize (EGLDisplay display, EGLSurface surface)
+tcu::IVec2 getSurfaceSize (const Library& egl, EGLDisplay display, EGLSurface surface)
 {
-	const EGLint width	= querySurfaceInt(display, surface, EGL_WIDTH);
-	const EGLint height	= querySurfaceInt(display, surface, EGL_HEIGHT);
+	const EGLint width	= querySurfaceInt(egl, display, surface, EGL_WIDTH);
+	const EGLint height	= querySurfaceInt(egl, display, surface, EGL_HEIGHT);
 	return tcu::IVec2(width, height);
 }
 
-tcu::IVec2 getSurfaceResolution (EGLDisplay display, EGLSurface surface)
+tcu::IVec2 getSurfaceResolution (const Library& egl, EGLDisplay display, EGLSurface surface)
 {
-	const EGLint hRes	= querySurfaceInt(display, surface, EGL_HORIZONTAL_RESOLUTION);
-	const EGLint vRes	= querySurfaceInt(display, surface, EGL_VERTICAL_RESOLUTION);
+	const EGLint hRes	= querySurfaceInt(egl, display, surface, EGL_HORIZONTAL_RESOLUTION);
+	const EGLint vRes	= querySurfaceInt(egl, display, surface, EGL_VERTICAL_RESOLUTION);
 
 	if (hRes == EGL_UNKNOWN || vRes == EGL_UNKNOWN)
 		TCU_THROW(NotSupportedError, "Surface doesn't support pixel density queries");
@@ -189,35 +226,33 @@
 //! Get EGLdisplay using eglGetDisplay() or eglGetPlatformDisplayEXT()
 EGLDisplay getDisplay (NativeDisplay& nativeDisplay)
 {
-	const bool	supportsLegacyGetDisplay		= (nativeDisplay.getCapabilities() & NativeDisplay::CAPABILITY_GET_DISPLAY_LEGACY) != 0;
-	const bool	supportsPlatformGetDisplay		= (nativeDisplay.getCapabilities() & NativeDisplay::CAPABILITY_GET_DISPLAY_PLATFORM) != 0;
-	bool		usePlatformExt					= false;
-	EGLDisplay	display							= EGL_NO_DISPLAY;
+	const Library&	egl								= nativeDisplay.getLibrary();
+	const bool		supportsLegacyGetDisplay		= (nativeDisplay.getCapabilities() & NativeDisplay::CAPABILITY_GET_DISPLAY_LEGACY) != 0;
+	const bool		supportsPlatformGetDisplay		= (nativeDisplay.getCapabilities() & NativeDisplay::CAPABILITY_GET_DISPLAY_PLATFORM) != 0;
+	bool			usePlatformExt					= false;
+	EGLDisplay		display							= EGL_NO_DISPLAY;
 
 	TCU_CHECK_INTERNAL(supportsLegacyGetDisplay || supportsPlatformGetDisplay);
 
 	if (supportsPlatformGetDisplay)
 	{
-		const vector<string> platformExts = getPlatformExtensions();
+		const vector<string> platformExts = getPlatformExtensions(egl);
 		usePlatformExt = de::contains(platformExts.begin(), platformExts.end(), string("EGL_EXT_platform_base")) &&
 						 de::contains(platformExts.begin(), platformExts.end(), string(nativeDisplay.getPlatformExtensionName()));
 	}
 
 	if (usePlatformExt)
 	{
-		const PFNEGLGETPLATFORMDISPLAYEXTPROC	getPlatformDisplay	= (PFNEGLGETPLATFORMDISPLAYEXTPROC)eglGetProcAddress("eglGetPlatformDisplayEXT");
+		const vector<EGLint>	legacyAttribs	= toLegacyAttribList(nativeDisplay.getPlatformAttributes());
 
-		EGLU_CHECK_MSG("eglGetProcAddress()");
-		TCU_CHECK(getPlatformDisplay);
-
-		display = getPlatformDisplay(nativeDisplay.getPlatformType(), nativeDisplay.getPlatformNative(), DE_NULL);
-		EGLU_CHECK_MSG("eglGetPlatformDisplayEXT()");
+		display = egl.getPlatformDisplayEXT(nativeDisplay.getPlatformType(), nativeDisplay.getPlatformNative(), &legacyAttribs[0]);
+		EGLU_CHECK_MSG(egl, "eglGetPlatformDisplayEXT()");
 		TCU_CHECK(display != EGL_NO_DISPLAY);
 	}
 	else if (supportsLegacyGetDisplay)
 	{
-		display = eglGetDisplay(nativeDisplay.getLegacyNative());
-		EGLU_CHECK_MSG("eglGetDisplay()");
+		display = egl.getDisplay(nativeDisplay.getLegacyNative());
+		EGLU_CHECK_MSG(egl, "eglGetDisplay()");
 		TCU_CHECK(display != EGL_NO_DISPLAY);
 	}
 	else
@@ -227,19 +262,34 @@
 	return display;
 }
 
+EGLDisplay getAndInitDisplay (NativeDisplay& nativeDisplay, Version* version)
+{
+	const Library&	egl		= nativeDisplay.getLibrary();
+	EGLDisplay		display	= getDisplay(nativeDisplay);
+	int				major, minor;
+
+	EGLU_CHECK_CALL(egl, initialize(display, &major, &minor));
+
+	if (version)
+		*version = Version(major, minor);
+
+	return display;
+}
+
 //! Create EGL window surface using eglCreateWindowSurface() or eglCreatePlatformWindowSurfaceEXT()
 EGLSurface createWindowSurface (NativeDisplay& nativeDisplay, NativeWindow& window, EGLDisplay display, EGLConfig config, const EGLAttrib* attribList)
 {
-	const bool	supportsLegacyCreate			= (window.getCapabilities() & NativeWindow::CAPABILITY_CREATE_SURFACE_LEGACY) != 0;
-	const bool	supportsPlatformCreate			= (window.getCapabilities() & NativeWindow::CAPABILITY_CREATE_SURFACE_PLATFORM) != 0;
-	bool		usePlatformExt					= false;
-	EGLSurface	surface							= EGL_NO_SURFACE;
+	const Library&	egl							= nativeDisplay.getLibrary();
+	const bool		supportsLegacyCreate		= (window.getCapabilities() & NativeWindow::CAPABILITY_CREATE_SURFACE_LEGACY) != 0;
+	const bool		supportsPlatformCreate		= (window.getCapabilities() & NativeWindow::CAPABILITY_CREATE_SURFACE_PLATFORM) != 0;
+	bool			usePlatformExt				= false;
+	EGLSurface		surface						= EGL_NO_SURFACE;
 
 	TCU_CHECK_INTERNAL(supportsLegacyCreate || supportsPlatformCreate);
 
 	if (supportsPlatformCreate)
 	{
-		const vector<string> platformExts = getPlatformExtensions();
+		const vector<string> platformExts = getPlatformExtensions(egl);
 		usePlatformExt = de::contains(platformExts.begin(), platformExts.end(), string("EGL_EXT_platform_base")) &&
 						 de::contains(platformExts.begin(), platformExts.end(), string(nativeDisplay.getPlatformExtensionName()));
 	}
@@ -247,21 +297,17 @@
 	// \todo [2014-03-13 pyry] EGL 1.5 core support
 	if (usePlatformExt)
 	{
-		const PFNEGLCREATEPLATFORMWINDOWSURFACEEXTPROC	createPlatformWindowSurface	= (PFNEGLCREATEPLATFORMWINDOWSURFACEEXTPROC)eglGetProcAddress("eglCreatePlatformWindowSurfaceEXT");
-		const vector<EGLint>							legacyAttribs				= toLegacyAttribList(attribList);
+		const vector<EGLint>	legacyAttribs	= toLegacyAttribList(attribList);
 
-		EGLU_CHECK_MSG("eglGetProcAddress()");
-		TCU_CHECK(createPlatformWindowSurface);
-
-		surface = createPlatformWindowSurface(display, config, window.getPlatformNative(), &legacyAttribs[0]);
-		EGLU_CHECK_MSG("eglCreatePlatformWindowSurfaceEXT()");
+		surface = egl.createPlatformWindowSurfaceEXT(display, config, window.getPlatformNative(), &legacyAttribs[0]);
+		EGLU_CHECK_MSG(egl, "eglCreatePlatformWindowSurfaceEXT()");
 		TCU_CHECK(surface != EGL_NO_SURFACE);
 	}
 	else if (supportsLegacyCreate)
 	{
 		const vector<EGLint> legacyAttribs = toLegacyAttribList(attribList);
-		surface = eglCreateWindowSurface(display, config, window.getLegacyNative(), &legacyAttribs[0]);
-		EGLU_CHECK_MSG("eglCreateWindowSurface()");
+		surface = egl.createWindowSurface(display, config, window.getLegacyNative(), &legacyAttribs[0]);
+		EGLU_CHECK_MSG(egl, "eglCreateWindowSurface()");
 		TCU_CHECK(surface != EGL_NO_SURFACE);
 	}
 	else
@@ -274,37 +320,34 @@
 //! Create EGL pixmap surface using eglCreatePixmapSurface() or eglCreatePlatformPixmapSurfaceEXT()
 EGLSurface createPixmapSurface (NativeDisplay& nativeDisplay, NativePixmap& pixmap, EGLDisplay display, EGLConfig config, const EGLAttrib* attribList)
 {
-	const bool	supportsLegacyCreate			= (pixmap.getCapabilities() & NativePixmap::CAPABILITY_CREATE_SURFACE_LEGACY) != 0;
-	const bool	supportsPlatformCreate			= (pixmap.getCapabilities() & NativePixmap::CAPABILITY_CREATE_SURFACE_PLATFORM) != 0;
-	bool		usePlatformExt					= false;
-	EGLSurface	surface							= EGL_NO_SURFACE;
+	const Library&	egl							= nativeDisplay.getLibrary();
+	const bool		supportsLegacyCreate		= (pixmap.getCapabilities() & NativePixmap::CAPABILITY_CREATE_SURFACE_LEGACY) != 0;
+	const bool		supportsPlatformCreate		= (pixmap.getCapabilities() & NativePixmap::CAPABILITY_CREATE_SURFACE_PLATFORM) != 0;
+	bool			usePlatformExt				= false;
+	EGLSurface		surface						= EGL_NO_SURFACE;
 
 	TCU_CHECK_INTERNAL(supportsLegacyCreate || supportsPlatformCreate);
 
 	if (supportsPlatformCreate)
 	{
-		const vector<string> platformExts = getPlatformExtensions();
+		const vector<string> platformExts = getPlatformExtensions(egl);
 		usePlatformExt = de::contains(platformExts.begin(), platformExts.end(), string("EGL_EXT_platform_base")) &&
 						 de::contains(platformExts.begin(), platformExts.end(), string(nativeDisplay.getPlatformExtensionName()));
 	}
 
 	if (usePlatformExt)
 	{
-		const PFNEGLCREATEPLATFORMPIXMAPSURFACEEXTPROC	createPlatformPixmapSurface	= (PFNEGLCREATEPLATFORMPIXMAPSURFACEEXTPROC)eglGetProcAddress("eglCreatePlatformPixmapSurfaceEXT");
-		const vector<EGLint>							legacyAttribs				= toLegacyAttribList(attribList);
+		const vector<EGLint>	legacyAttribs	= toLegacyAttribList(attribList);
 
-		EGLU_CHECK_MSG("eglGetProcAddress()");
-		TCU_CHECK(createPlatformPixmapSurface);
-
-		surface = createPlatformPixmapSurface(display, config, pixmap.getPlatformNative(), &legacyAttribs[0]);
-		EGLU_CHECK_MSG("eglCreatePlatformPixmapSurfaceEXT()");
+		surface = egl.createPlatformPixmapSurfaceEXT(display, config, pixmap.getPlatformNative(), &legacyAttribs[0]);
+		EGLU_CHECK_MSG(egl, "eglCreatePlatformPixmapSurfaceEXT()");
 		TCU_CHECK(surface != EGL_NO_SURFACE);
 	}
 	else if (supportsLegacyCreate)
 	{
 		const vector<EGLint> legacyAttribs = toLegacyAttribList(attribList);
-		surface = eglCreatePixmapSurface(display, config, pixmap.getLegacyNative(), &legacyAttribs[0]);
-		EGLU_CHECK_MSG("eglCreatePixmapSurface()");
+		surface = egl.createPixmapSurface(display, config, pixmap.getLegacyNative(), &legacyAttribs[0]);
+		EGLU_CHECK_MSG(egl, "eglCreatePixmapSurface()");
 		TCU_CHECK(surface != EGL_NO_SURFACE);
 	}
 	else
@@ -333,6 +376,45 @@
 	return getWindowVisibility(commandLine.getVisibility());
 }
 
+EGLenum parseClientAPI (const std::string& api)
+{
+	if (api == "OpenGL")
+		return EGL_OPENGL_API;
+	else if (api == "OpenGL_ES")
+		return EGL_OPENGL_ES_API;
+	else if (api == "OpenVG")
+		return EGL_OPENVG_API;
+	else
+		throw tcu::InternalError("Unknown EGL client API '" + api + "'");
+}
+
+vector<EGLenum> parseClientAPIs (const std::string& apiList)
+{
+	const vector<string>	apiStrs	= de::splitString(apiList, ' ');
+	vector<EGLenum>			apis;
+
+	for (vector<string>::const_iterator api = apiStrs.begin(); api != apiStrs.end(); ++api)
+		apis.push_back(parseClientAPI(*api));
+
+	return apis;
+}
+
+vector<EGLenum> getClientAPIs (const eglw::Library& egl, eglw::EGLDisplay display)
+{
+	return parseClientAPIs(egl.queryString(display, EGL_CLIENT_APIS));
+}
+
+EGLint getRenderableAPIsMask (const eglw::Library& egl, eglw::EGLDisplay display)
+{
+	const vector<EGLConfig>	configs	= getConfigs(egl, display);
+	EGLint					allAPIs	= 0;
+
+	for (vector<EGLConfig>::const_iterator i = configs.begin(); i != configs.end(); ++i)
+		allAPIs |= getConfigAttribInt(egl, display, *i, EGL_RENDERABLE_TYPE);
+
+	return allAPIs;
+}
+
 vector<EGLint> toLegacyAttribList (const EGLAttrib* attribs)
 {
 	const deUint64	attribMask		= 0xffffffffull;	//!< Max bits that can be used
@@ -355,4 +437,44 @@
 	return legacyAttribs;
 }
 
+template<typename Factory>
+static const Factory* selectFactory (const tcu::FactoryRegistry<Factory>& registry, const char* objectTypeName, const char* cmdLineArg)
+{
+	if (cmdLineArg)
+	{
+		const Factory* factory = registry.getFactoryByName(cmdLineArg);
+
+		if (factory)
+			return factory;
+		else
+		{
+			tcu::print("ERROR: Unknown or unsupported EGL %s type '%s'", objectTypeName, cmdLineArg);
+			tcu::print("Available EGL %s types:\n", objectTypeName);
+			for (size_t ndx = 0; ndx < registry.getFactoryCount(); ndx++)
+				tcu::print("  %s: %s\n", registry.getFactoryByIndex(ndx)->getName(), registry.getFactoryByIndex(ndx)->getDescription());
+
+			TCU_THROW(NotSupportedError, (string("Unsupported or unknown EGL ") + objectTypeName + " type '" + cmdLineArg + "'").c_str());
+		}
+	}
+	else if (!registry.empty())
+		return registry.getDefaultFactory();
+	else
+		return DE_NULL;
+}
+
+const NativeDisplayFactory* selectNativeDisplayFactory (const NativeDisplayFactoryRegistry& registry, const tcu::CommandLine& cmdLine)
+{
+	return selectFactory(registry, "display", cmdLine.getEGLDisplayType());
+}
+
+const NativeWindowFactory* selectNativeWindowFactory (const NativeDisplayFactory& factory, const tcu::CommandLine& cmdLine)
+{
+	return selectFactory(factory.getNativeWindowRegistry(), "window", cmdLine.getEGLWindowType());
+}
+
+const NativePixmapFactory* selectNativePixmapFactory (const NativeDisplayFactory& factory, const tcu::CommandLine& cmdLine)
+{
+	return selectFactory(factory.getNativePixmapRegistry(), "pixmap", cmdLine.getEGLPixmapType());
+}
+
 } // eglu
diff --git a/framework/egl/egluUtil.hpp b/framework/egl/egluUtil.hpp
index 9bd77bc..3d56c77 100644
--- a/framework/egl/egluUtil.hpp
+++ b/framework/egl/egluUtil.hpp
@@ -25,8 +25,9 @@
 
 #include "tcuDefs.hpp"
 #include "egluDefs.hpp"
-#include "egluHeaderWrapper.hpp"
 #include "egluNativeWindow.hpp"
+#include "egluNativeDisplay.hpp"
+#include "eglwDefs.hpp"
 
 #include <vector>
 #include <map>
@@ -37,35 +38,60 @@
 class CommandLine;
 }
 
+namespace eglw
+{
+class Library;
+}
+
 namespace eglu
 {
 
-class NativeDisplay;
+class NativePixmapFactory;
 class NativePixmap;
+class FilterList;
 
-typedef std::map<EGLint, EGLint> AttribMap;
+typedef std::map<eglw::EGLint, eglw::EGLint> AttribMap;
 
-std::vector<EGLint>			attribMapToVector			(const AttribMap& map);
+std::vector<eglw::EGLint>		attribMapToList				(const AttribMap& map);
 
-Version						getVersion					(EGLDisplay display);
-bool						hasExtension				(EGLDisplay display, const std::string& extName);
-std::vector<std::string>	getPlatformExtensions		(void);
-std::vector<std::string>	getClientExtensions			(EGLDisplay display);
-std::vector<EGLConfig>		getConfigs					(EGLDisplay display);
-std::vector<EGLConfig>		chooseConfig				(EGLDisplay display, const AttribMap& attribs);
-EGLConfig					chooseSingleConfig			(EGLDisplay display, const AttribMap& attribs);
-EGLint						getConfigAttribInt			(EGLDisplay display, EGLConfig config, EGLint attrib);
-EGLint						getConfigID					(EGLDisplay display, EGLConfig config);
-EGLint						querySurfaceInt				(EGLDisplay display, EGLSurface surface, EGLint attrib);
-tcu::IVec2					getSurfaceSize				(EGLDisplay display, EGLSurface surface);
-tcu::IVec2					getSurfaceResolution		(EGLDisplay display, EGLSurface surface);
-EGLDisplay					getDisplay					(NativeDisplay& nativeDisplay);
-EGLSurface					createWindowSurface			(NativeDisplay& nativeDisplay, NativeWindow& window, EGLDisplay display, EGLConfig config, const EGLAttrib* attribList);
-EGLSurface					createPixmapSurface			(NativeDisplay& nativeDisplay, NativePixmap& pixmap, EGLDisplay display, EGLConfig config, const EGLAttrib* attribList);
+Version							getVersion					(const eglw::Library& egl, eglw::EGLDisplay display);
 
-WindowParams::Visibility	parseWindowVisibility		(const tcu::CommandLine& commandLine);
+std::vector<std::string>		getPlatformExtensions		(const eglw::Library& egl);
+std::vector<std::string>		getClientExtensions			(const eglw::Library& egl, eglw::EGLDisplay display);
+bool							hasExtension				(const eglw::Library& egl, eglw::EGLDisplay display, const std::string& extName);
 
-std::vector<EGLint>			toLegacyAttribList			(const EGLAttrib* attribs);
+std::vector<eglw::EGLConfig>	getConfigs					(const eglw::Library& egl, eglw::EGLDisplay display);
+std::vector<eglw::EGLConfig>	chooseConfigs				(const eglw::Library& egl, eglw::EGLDisplay display, const AttribMap& attribs);
+std::vector<eglw::EGLConfig>	chooseConfigs				(const eglw::Library& egl, eglw::EGLDisplay display, const FilterList& filters);
+std::vector<eglw::EGLConfig>	chooseConfigs				(const eglw::Library& egl, eglw::EGLDisplay display, const eglw::EGLint* attribs);
+eglw::EGLConfig					chooseSingleConfig			(const eglw::Library& egl, eglw::EGLDisplay display, const AttribMap& attribs);
+eglw::EGLConfig					chooseSingleConfig			(const eglw::Library& egl, eglw::EGLDisplay display, const eglw::EGLint* attribs);
+eglw::EGLConfig					chooseSingleConfig			(const eglw::Library& egl, eglw::EGLDisplay display, const FilterList& filters);
+eglw::EGLConfig					chooseConfigByID			(const eglw::Library& egl, eglw::EGLDisplay display, eglw::EGLint id);
+eglw::EGLint					getConfigAttribInt			(const eglw::Library& egl, eglw::EGLDisplay display, eglw::EGLConfig config, eglw::EGLint attrib);
+eglw::EGLint					getConfigID					(const eglw::Library& egl, eglw::EGLDisplay display, eglw::EGLConfig config);
+
+eglw::EGLint					querySurfaceInt				(const eglw::Library& egl, eglw::EGLDisplay display, eglw::EGLSurface surface, eglw::EGLint attrib);
+tcu::IVec2						getSurfaceSize				(const eglw::Library& egl, eglw::EGLDisplay display, eglw::EGLSurface surface);
+tcu::IVec2						getSurfaceResolution		(const eglw::Library& egl, eglw::EGLDisplay display, eglw::EGLSurface surface);
+
+eglw::EGLDisplay				getDisplay					(NativeDisplay& nativeDisplay);
+eglw::EGLDisplay				getAndInitDisplay			(NativeDisplay& nativeDisplay, Version* version = DE_NULL);
+eglw::EGLSurface				createWindowSurface			(NativeDisplay& nativeDisplay, NativeWindow& window, eglw::EGLDisplay display, eglw::EGLConfig config, const eglw::EGLAttrib* attribList);
+eglw::EGLSurface				createPixmapSurface			(NativeDisplay& nativeDisplay, NativePixmap& pixmap, eglw::EGLDisplay display, eglw::EGLConfig config, const eglw::EGLAttrib* attribList);
+
+const NativeDisplayFactory*		selectNativeDisplayFactory	(const NativeDisplayFactoryRegistry& registry, const tcu::CommandLine& cmdLine);
+const NativeWindowFactory*		selectNativeWindowFactory	(const NativeDisplayFactory& factory, const tcu::CommandLine& cmdLine);
+const NativePixmapFactory*		selectNativePixmapFactory	(const NativeDisplayFactory& factory, const tcu::CommandLine& cmdLine);
+
+WindowParams::Visibility		parseWindowVisibility		(const tcu::CommandLine& commandLine);
+eglw::EGLenum					parseClientAPI				(const std::string& api);
+std::vector<eglw::EGLenum>		parseClientAPIs				(const std::string& apiList);
+std::vector<eglw::EGLenum>		getClientAPIs				(const eglw::Library& egl, eglw::EGLDisplay display);
+
+eglw::EGLint					getRenderableAPIsMask		(const eglw::Library& egl, eglw::EGLDisplay display);
+
+std::vector<eglw::EGLint>		toLegacyAttribList			(const eglw::EGLAttrib* attribs);
 
 } // eglu
 
diff --git a/framework/egl/tcuEgl.cpp b/framework/egl/tcuEgl.cpp
deleted file mode 100644
index 00ac0fd..0000000
--- a/framework/egl/tcuEgl.cpp
+++ /dev/null
@@ -1,259 +0,0 @@
-/*-------------------------------------------------------------------------
- * drawElements Quality Program Tester Core
- * ----------------------------------------
- *
- * Copyright 2014 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- *      http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- *
- *//*!
- * \file
- * \brief Legacy EGL utilities
- *//*--------------------------------------------------------------------*/
-
-#include "tcuEgl.hpp"
-#include "egluStrUtil.hpp"
-#include "egluConfigInfo.hpp"
-#include "deString.h"
-
-#include <sstream>
-
-using std::vector;
-using std::string;
-
-namespace tcu
-{
-namespace egl
-{
-
-Display::Display (EGLDisplay display, EGLint majorVersion, EGLint minorVersion)
-	: m_display(display)
-{
-	m_version[0] = majorVersion;
-	m_version[1] = minorVersion;
-}
-
-Display::Display (EGLNativeDisplayType nativeDisplay)
-	: m_display			(EGL_NO_DISPLAY)
-{
-	m_display = eglGetDisplay(nativeDisplay);
-	TCU_CHECK_EGL();
-	TCU_CHECK(m_display != EGL_NO_DISPLAY);
-
-	TCU_CHECK_EGL_CALL(eglInitialize(m_display, &m_version[0], &m_version[1]));
-}
-
-Display::~Display ()
-{
-	if (m_display)
-		eglTerminate(m_display);
-}
-
-void Display::getConfigs (std::vector<EGLConfig>& configs) const
-{
-	EGLint numConfigs = 0;
-	TCU_CHECK_EGL_CALL(eglGetConfigs(m_display, DE_NULL, 0, &numConfigs));
-	configs.resize(numConfigs);
-	if (numConfigs > 0)
-		TCU_CHECK_EGL_CALL(eglGetConfigs(m_display, &configs[0], (EGLint)configs.size(), &numConfigs));
-}
-
-void Display::chooseConfig (const EGLint* attribList, std::vector<EGLConfig>& configs) const
-{
-	EGLint numConfigs = 0;
-	TCU_CHECK_EGL_CALL(eglChooseConfig(m_display, attribList, DE_NULL, 0, &numConfigs));
-	configs.resize(numConfigs);
-	if (numConfigs > 0)
-		TCU_CHECK_EGL_CALL(eglChooseConfig(m_display, attribList, &configs[0], (EGLint)configs.size(), &numConfigs));
-}
-
-EGLint Display::getConfigAttrib (EGLConfig config, EGLint attribute) const
-{
-	EGLint value = 0;
-	TCU_CHECK_EGL_CALL(eglGetConfigAttrib(m_display, config, attribute, &value));
-	return value;
-}
-
-void Display::describeConfig (EGLConfig config, tcu::PixelFormat& pf) const
-{
-	eglGetConfigAttrib(m_display, config, EGL_RED_SIZE,		&pf.redBits);
-	eglGetConfigAttrib(m_display, config, EGL_GREEN_SIZE,	&pf.greenBits);
-	eglGetConfigAttrib(m_display, config, EGL_BLUE_SIZE,	&pf.blueBits);
-	eglGetConfigAttrib(m_display, config, EGL_ALPHA_SIZE,	&pf.alphaBits);
-	TCU_CHECK_EGL();
-}
-
-void Display::describeConfig (EGLConfig config, eglu::ConfigInfo& info) const
-{
-	eglu::queryConfigInfo(m_display, config, &info);
-}
-
-static void split (vector<string>& dst, const string& src)
-{
-	size_t start = 0;
-	size_t end	 = string::npos;
-
-	while ((end = src.find(' ', start)) != string::npos)
-	{
-		dst.push_back(src.substr(start, end-start));
-		start = end+1;
-	}
-
-	if (start < end)
-		dst.push_back(src.substr(start, end-start));
-}
-
-void Display::getExtensions (vector<string>& dst) const
-{
-	const char* extStr = eglQueryString(m_display, EGL_EXTENSIONS);
-	TCU_CHECK_EGL_MSG("eglQueryString(EGL_EXTENSIONS");
-	TCU_CHECK(extStr);
-	split(dst, extStr);
-}
-
-void Display::getString (EGLint name, std::string& dst) const
-{
-	const char* retStr = eglQueryString(m_display, name);
-	TCU_CHECK_EGL_MSG("eglQueryString()");
-	TCU_CHECK(retStr);
-	dst = retStr;
-}
-
-EGLint Surface::getAttribute (EGLint attribute) const
-{
-	EGLint value;
-	TCU_CHECK_EGL_CALL(eglQuerySurface(m_display.getEGLDisplay(), m_surface, attribute, &value));
-	return value;
-}
-
-void Surface::setAttribute (EGLint attribute, EGLint value)
-{
-	TCU_CHECK_EGL_CALL(eglSurfaceAttrib(m_display.getEGLDisplay(), m_surface, attribute, value));
-}
-
-int Surface::getWidth (void) const
-{
-	return getAttribute(EGL_WIDTH);
-}
-
-int Surface::getHeight (void) const
-{
-	return getAttribute(EGL_HEIGHT);
-}
-
-void Surface::getSize (int& x, int& y) const
-{
-	x = getWidth();
-	y = getHeight();
-}
-
-WindowSurface::WindowSurface (Display& display, EGLSurface windowSurface)
-	: Surface	(display)
-{
-	m_surface = windowSurface;
-}
-
-WindowSurface::WindowSurface (Display& display, EGLConfig config, EGLNativeWindowType nativeWindow, const EGLint* attribList)
-	: Surface			(display)
-{
-	m_surface = eglCreateWindowSurface(display.getEGLDisplay(), config, nativeWindow, attribList);
-	TCU_CHECK_EGL();
-	TCU_CHECK(m_surface != EGL_NO_SURFACE);
-}
-
-WindowSurface::~WindowSurface (void)
-{
-	eglDestroySurface(m_display.getEGLDisplay(), m_surface);
-	m_surface = EGL_NO_SURFACE;
-}
-
-void WindowSurface::swapBuffers (void)
-{
-	TCU_CHECK_EGL_CALL(eglSwapBuffers(m_display.getEGLDisplay(), m_surface));
-}
-
-PixmapSurface::PixmapSurface (Display& display, EGLSurface surface)
-	: Surface	(display)
-{
-	m_surface = surface;
-}
-
-PixmapSurface::PixmapSurface (Display& display, EGLConfig config, EGLNativePixmapType nativePixmap, const EGLint* attribList)
-	: Surface			(display)
-{
-	m_surface = eglCreatePixmapSurface(m_display.getEGLDisplay(), config, nativePixmap, attribList);
-	TCU_CHECK_EGL();
-	TCU_CHECK(m_surface != EGL_NO_SURFACE);
-}
-
-PixmapSurface::~PixmapSurface (void)
-{
-	eglDestroySurface(m_display.getEGLDisplay(), m_surface);
-	m_surface = EGL_NO_SURFACE;
-}
-
-#if 0 // \todo [mika] Fix borken
-void PixmapSurface::copyBuffers (void)
-{
-	TCU_CHECK_EGL_CALL(eglCopyBuffers(m_display.getEGLDisplay(), m_surface, m_nativePixmap));
-}
-#endif
-
-PbufferSurface::PbufferSurface (Display& display, EGLConfig config, const EGLint* attribList)
-	: Surface(display)
-{
-	m_surface = eglCreatePbufferSurface(m_display.getEGLDisplay(), config, attribList);
-	TCU_CHECK_EGL();
-	TCU_CHECK(m_surface != EGL_NO_SURFACE);
-}
-
-PbufferSurface::~PbufferSurface (void)
-{
-	eglDestroySurface(m_display.getEGLDisplay(), m_surface);
-	m_surface = EGL_NO_SURFACE;
-}
-
-Context::Context (const Display& display, EGLConfig config, const EGLint* attribList, EGLenum api)
-	: m_display(display)
-	, m_config(config)
-	, m_api(api)
-	, m_context(EGL_NO_CONTEXT)
-{
-	TCU_CHECK_EGL_CALL(eglBindAPI(m_api));
-	m_context = eglCreateContext(m_display.getEGLDisplay(), config, EGL_NO_CONTEXT, attribList);
-	TCU_CHECK_EGL();
-	TCU_CHECK(m_context);
-}
-
-Context::~Context (void)
-{
-	if (m_context)
-	{
-		/* If this is current surface, remove binding. */
-		EGLContext curContext = EGL_NO_CONTEXT;
-		eglBindAPI(m_api);
-		curContext = eglGetCurrentContext();
-		if (curContext == m_context)
-			eglMakeCurrent(m_display.getEGLDisplay(), EGL_NO_SURFACE, EGL_NO_SURFACE, EGL_NO_CONTEXT);
-
-		eglDestroyContext(m_display.getEGLDisplay(), m_context);
-	}
-}
-
-void Context::makeCurrent (const Surface& draw, const Surface& read)
-{
-	TCU_CHECK_EGL_CALL(eglMakeCurrent(m_display.getEGLDisplay(), draw.getEGLSurface(), read.getEGLSurface(), m_context));
-}
-
-} // egl
-} // tcu
diff --git a/framework/egl/tcuEgl.hpp b/framework/egl/tcuEgl.hpp
deleted file mode 100644
index 3b15344..0000000
--- a/framework/egl/tcuEgl.hpp
+++ /dev/null
@@ -1,161 +0,0 @@
-#ifndef _TCUEGL_HPP
-#define _TCUEGL_HPP
-/*-------------------------------------------------------------------------
- * drawElements Quality Program Tester Core
- * ----------------------------------------
- *
- * Copyright 2014 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- *      http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- *
- *//*!
- * \file
- * \brief Legacy EGL utilities
- *//*--------------------------------------------------------------------*/
-
-#include "egluDefs.hpp"
-#include "tcuPixelFormat.hpp"
-#include "egluHeaderWrapper.hpp"
-
-#include <vector>
-#include <string>
-
-#define TCU_CHECK_EGL()				EGLU_CHECK()
-#define TCU_CHECK_EGL_MSG(MSG)		EGLU_CHECK_MSG(MSG)
-#define TCU_CHECK_EGL_CALL(CALL)	EGLU_CHECK_CALL(CALL)
-
-namespace eglu
-{
-class ConfigInfo;
-}
-
-namespace tcu
-{
-
-/*--------------------------------------------------------------------*//*!
- * \brief EGL utilities
- *//*--------------------------------------------------------------------*/
-namespace egl
-{
-
-class Surface;
-
-class Display
-{
-public:
-							Display				(EGLDisplay display, EGLint majorVersion, EGLint minorVersion);
-							Display				(EGLNativeDisplayType nativeDisplay);
-	virtual					~Display			(void);
-
-	void					getConfigs			(std::vector<EGLConfig>& configs) const;
-	void					chooseConfig		(const EGLint* attributeList, std::vector<EGLConfig>& configs) const;
-
-	EGLint					getConfigAttrib		(EGLConfig config, EGLint attribute) const;
-	void					describeConfig		(EGLConfig config, tcu::PixelFormat& pixelFormat) const;
-	void					describeConfig		(EGLConfig config, eglu::ConfigInfo& info) const;
-
-	EGLDisplay				getEGLDisplay		(void) const { return m_display; }
-	EGLint					getEGLMajorVersion	(void) const { return m_version[0]; }
-	EGLint					getEGLMinorVersion	(void) const { return m_version[1]; }
-
-	eglu::Version			getVersion			(void) const { return eglu::Version(m_version[0], m_version[1]); }
-
-	void					getString			(EGLint name, std::string& dst) const;
-	void					getExtensions		(std::vector<std::string>& dst) const;
-
-	std::string				getString			(EGLint name) const { std::string str; getString(name, str); return str; }
-
-protected:
-							Display				(const Display&); // not allowed
-	Display&				operator=			(const Display&); // not allowed
-
-	EGLDisplay				m_display;
-	EGLint					m_version[2];
-};
-
-class Surface
-{
-public:
-	virtual					~Surface			(void) {}
-
-	EGLSurface				getEGLSurface		(void) const { return m_surface; }
-	Display&				getDisplay			(void) const { return m_display; }
-
-	EGLint					getAttribute		(EGLint attribute) const;
-	void					setAttribute		(EGLint attribute, EGLint value);
-
-	int						getWidth			(void) const;
-	int						getHeight			(void) const;
-	void					getSize				(int& width, int& height) const;
-
-protected:
-							Surface				(Display& display) : m_display(display), m_surface(EGL_NO_SURFACE) {}
-
-							Surface				(const Surface&); // not allowed
-	Surface&				operator=			(const Surface&); // not allowed
-
-	Display&				m_display;
-	EGLSurface				m_surface;
-};
-
-class WindowSurface : public Surface
-{
-public:
-							WindowSurface		(Display& display, EGLSurface windowSurface);
-							WindowSurface		(Display& display, EGLConfig config, EGLNativeWindowType nativeWindow, const EGLint* attribList);
-	virtual					~WindowSurface		(void);
-
-	void					swapBuffers			(void);
-};
-
-class PixmapSurface : public Surface
-{
-public:
-							PixmapSurface		(Display& display, EGLSurface surface);
-							PixmapSurface		(Display& display, EGLConfig config, EGLNativePixmapType nativePixmap, const EGLint* attribList);
-	virtual					~PixmapSurface		(void);
-};
-
-class PbufferSurface : public Surface
-{
-public:
-							PbufferSurface		(Display& display, EGLConfig config, const EGLint* attribList);
-	virtual					~PbufferSurface		(void);
-};
-
-class Context
-{
-public:
-							Context				(const Display& display, EGLConfig config, const EGLint* attribList, EGLenum api);
-							~Context			(void);
-
-	EGLenum					getAPI				(void) const { return m_api;		}
-	EGLContext				getEGLContext		(void) const { return m_context;	}
-	EGLConfig				getConfig			(void) const { return m_config;		}
-
-	void					makeCurrent			(const Surface& draw, const Surface& read);
-
-protected:
-							Context				(const Context&); // not allowed
-	Context&				operator=			(const Context&); // not allowed
-
-	const Display&			m_display;
-	EGLConfig				m_config;
-	EGLenum					m_api;
-	EGLContext				m_context;
-};
-
-} // egl
-} // tcu
-
-#endif // _TCUEGL_HPP
diff --git a/framework/egl/wrapper/CMakeLists.txt b/framework/egl/wrapper/CMakeLists.txt
new file mode 100644
index 0000000..b0c97d2
--- /dev/null
+++ b/framework/egl/wrapper/CMakeLists.txt
@@ -0,0 +1,21 @@
+# EGL Wrapper
+
+set(EGLWRAPPER_SRCS
+	eglwDefs.cpp
+	eglwDefs.hpp
+	eglwEnums.hpp
+	eglwFunctions.hpp
+	eglwFunctions.cpp
+	eglwLibrary.hpp
+	eglwLibrary.cpp
+	)
+
+set(EGLWRAPPER_LIBS
+	debase
+	deutil
+	decpp
+	${DEQP_EGL_LIBRARIES}
+	)
+
+add_library(eglwrapper STATIC ${EGLWRAPPER_SRCS})
+target_link_libraries(eglwrapper ${EGLWRAPPER_LIBS})
diff --git a/framework/egl/wrapper/eglwApi.inl b/framework/egl/wrapper/eglwApi.inl
new file mode 100644
index 0000000..fadb2a9
--- /dev/null
+++ b/framework/egl/wrapper/eglwApi.inl
@@ -0,0 +1,119 @@
+/* WARNING: This is auto-generated file. Do not modify, since changes will
+ * be lost! Modify the generating script instead.
+ *
+ * Generated from Khronos EGL API description (egl.xml) revision 28861.
+ */
+#define										eglBindAPI							eglwBindAPI
+#define										eglBindTexImage						eglwBindTexImage
+#define										eglChooseConfig						eglwChooseConfig
+#define										eglClientWaitSync					eglwClientWaitSync
+#define										eglClientWaitSyncKHR				eglwClientWaitSyncKHR
+#define										eglCopyBuffers						eglwCopyBuffers
+#define										eglCreateContext					eglwCreateContext
+#define										eglCreateImage						eglwCreateImage
+#define										eglCreateImageKHR					eglwCreateImageKHR
+#define										eglCreatePbufferFromClientBuffer	eglwCreatePbufferFromClientBuffer
+#define										eglCreatePbufferSurface				eglwCreatePbufferSurface
+#define										eglCreatePixmapSurface				eglwCreatePixmapSurface
+#define										eglCreatePlatformPixmapSurface		eglwCreatePlatformPixmapSurface
+#define										eglCreatePlatformPixmapSurfaceEXT	eglwCreatePlatformPixmapSurfaceEXT
+#define										eglCreatePlatformWindowSurface		eglwCreatePlatformWindowSurface
+#define										eglCreatePlatformWindowSurfaceEXT	eglwCreatePlatformWindowSurfaceEXT
+#define										eglCreateSync						eglwCreateSync
+#define										eglCreateSyncKHR					eglwCreateSyncKHR
+#define										eglCreateWindowSurface				eglwCreateWindowSurface
+#define										eglDestroyContext					eglwDestroyContext
+#define										eglDestroyImage						eglwDestroyImage
+#define										eglDestroyImageKHR					eglwDestroyImageKHR
+#define										eglDestroySurface					eglwDestroySurface
+#define										eglDestroySync						eglwDestroySync
+#define										eglDestroySyncKHR					eglwDestroySyncKHR
+#define										eglGetConfigAttrib					eglwGetConfigAttrib
+#define										eglGetConfigs						eglwGetConfigs
+#define										eglGetCurrentContext				eglwGetCurrentContext
+#define										eglGetCurrentDisplay				eglwGetCurrentDisplay
+#define										eglGetCurrentSurface				eglwGetCurrentSurface
+#define										eglGetDisplay						eglwGetDisplay
+#define										eglGetError							eglwGetError
+#define										eglGetPlatformDisplay				eglwGetPlatformDisplay
+#define										eglGetPlatformDisplayEXT			eglwGetPlatformDisplayEXT
+#define										eglGetProcAddress					eglwGetProcAddress
+#define										eglGetSyncAttrib					eglwGetSyncAttrib
+#define										eglGetSyncAttribKHR					eglwGetSyncAttribKHR
+#define										eglInitialize						eglwInitialize
+#define										eglLockSurfaceKHR					eglwLockSurfaceKHR
+#define										eglMakeCurrent						eglwMakeCurrent
+#define										eglQueryAPI							eglwQueryAPI
+#define										eglQueryContext						eglwQueryContext
+#define										eglQueryString						eglwQueryString
+#define										eglQuerySurface						eglwQuerySurface
+#define										eglReleaseTexImage					eglwReleaseTexImage
+#define										eglReleaseThread					eglwReleaseThread
+#define										eglSignalSyncKHR					eglwSignalSyncKHR
+#define										eglSurfaceAttrib					eglwSurfaceAttrib
+#define										eglSwapBuffers						eglwSwapBuffers
+#define										eglSwapInterval						eglwSwapInterval
+#define										eglTerminate						eglwTerminate
+#define										eglUnlockSurfaceKHR					eglwUnlockSurfaceKHR
+#define										eglWaitClient						eglwWaitClient
+#define										eglWaitGL							eglwWaitGL
+#define										eglWaitNative						eglwWaitNative
+#define										eglWaitSync							eglwWaitSync
+#define										eglWaitSyncKHR						eglwWaitSyncKHR
+EGLBoolean									eglwBindAPI							(EGLenum api);
+EGLBoolean									eglwBindTexImage					(EGLDisplay dpy, EGLSurface surface, EGLint buffer);
+EGLBoolean									eglwChooseConfig					(EGLDisplay dpy, const EGLint *attrib_list, EGLConfig *configs, EGLint config_size, EGLint *num_config);
+EGLint										eglwClientWaitSync					(EGLDisplay dpy, EGLSync sync, EGLint flags, EGLTime timeout);
+EGLint										eglwClientWaitSyncKHR				(EGLDisplay dpy, EGLSyncKHR sync, EGLint flags, EGLTimeKHR timeout);
+EGLBoolean									eglwCopyBuffers						(EGLDisplay dpy, EGLSurface surface, EGLNativePixmapType target);
+EGLContext									eglwCreateContext					(EGLDisplay dpy, EGLConfig config, EGLContext share_context, const EGLint *attrib_list);
+EGLImage									eglwCreateImage						(EGLDisplay dpy, EGLContext ctx, EGLenum target, EGLClientBuffer buffer, const EGLint *attrib_list);
+EGLImageKHR									eglwCreateImageKHR					(EGLDisplay dpy, EGLContext ctx, EGLenum target, EGLClientBuffer buffer, const EGLint *attrib_list);
+EGLSurface									eglwCreatePbufferFromClientBuffer	(EGLDisplay dpy, EGLenum buftype, EGLClientBuffer buffer, EGLConfig config, const EGLint *attrib_list);
+EGLSurface									eglwCreatePbufferSurface			(EGLDisplay dpy, EGLConfig config, const EGLint *attrib_list);
+EGLSurface									eglwCreatePixmapSurface				(EGLDisplay dpy, EGLConfig config, EGLNativePixmapType pixmap, const EGLint *attrib_list);
+EGLSurface									eglwCreatePlatformPixmapSurface		(EGLDisplay dpy, EGLConfig config, void *native_pixmap, const EGLAttrib *attrib_list);
+EGLSurface									eglwCreatePlatformPixmapSurfaceEXT	(EGLDisplay dpy, EGLConfig config, void *native_pixmap, const EGLint *attrib_list);
+EGLSurface									eglwCreatePlatformWindowSurface		(EGLDisplay dpy, EGLConfig config, void *native_window, const EGLAttrib *attrib_list);
+EGLSurface									eglwCreatePlatformWindowSurfaceEXT	(EGLDisplay dpy, EGLConfig config, void *native_window, const EGLint *attrib_list);
+EGLSync										eglwCreateSync						(EGLDisplay dpy, EGLenum type, const EGLAttrib *attrib_list);
+EGLSyncKHR									eglwCreateSyncKHR					(EGLDisplay dpy, EGLenum type, const EGLint *attrib_list);
+EGLSurface									eglwCreateWindowSurface				(EGLDisplay dpy, EGLConfig config, EGLNativeWindowType win, const EGLint *attrib_list);
+EGLBoolean									eglwDestroyContext					(EGLDisplay dpy, EGLContext ctx);
+EGLBoolean									eglwDestroyImage					(EGLDisplay dpy, EGLImage image);
+EGLBoolean									eglwDestroyImageKHR					(EGLDisplay dpy, EGLImageKHR image);
+EGLBoolean									eglwDestroySurface					(EGLDisplay dpy, EGLSurface surface);
+EGLBoolean									eglwDestroySync						(EGLDisplay dpy, EGLSync sync);
+EGLBoolean									eglwDestroySyncKHR					(EGLDisplay dpy, EGLSyncKHR sync);
+EGLBoolean									eglwGetConfigAttrib					(EGLDisplay dpy, EGLConfig config, EGLint attribute, EGLint *value);
+EGLBoolean									eglwGetConfigs						(EGLDisplay dpy, EGLConfig *configs, EGLint config_size, EGLint *num_config);
+EGLContext									eglwGetCurrentContext				();
+EGLDisplay									eglwGetCurrentDisplay				();
+EGLSurface									eglwGetCurrentSurface				(EGLint readdraw);
+EGLDisplay									eglwGetDisplay						(EGLNativeDisplayType display_id);
+EGLint										eglwGetError						();
+EGLDisplay									eglwGetPlatformDisplay				(EGLenum platform, void *native_display, const EGLAttrib *attrib_list);
+EGLDisplay									eglwGetPlatformDisplayEXT			(EGLenum platform, void *native_display, const EGLint *attrib_list);
+__eglMustCastToProperFunctionPointerType	eglwGetProcAddress					(const char *procname);
+EGLBoolean									eglwGetSyncAttrib					(EGLDisplay dpy, EGLSync sync, EGLint attribute, EGLAttrib *value);
+EGLBoolean									eglwGetSyncAttribKHR				(EGLDisplay dpy, EGLSyncKHR sync, EGLint attribute, EGLint *value);
+EGLBoolean									eglwInitialize						(EGLDisplay dpy, EGLint *major, EGLint *minor);
+EGLBoolean									eglwLockSurfaceKHR					(EGLDisplay dpy, EGLSurface surface, const EGLint *attrib_list);
+EGLBoolean									eglwMakeCurrent						(EGLDisplay dpy, EGLSurface draw, EGLSurface read, EGLContext ctx);
+EGLenum										eglwQueryAPI						();
+EGLBoolean									eglwQueryContext					(EGLDisplay dpy, EGLContext ctx, EGLint attribute, EGLint *value);
+const char *								eglwQueryString						(EGLDisplay dpy, EGLint name);
+EGLBoolean									eglwQuerySurface					(EGLDisplay dpy, EGLSurface surface, EGLint attribute, EGLint *value);
+EGLBoolean									eglwReleaseTexImage					(EGLDisplay dpy, EGLSurface surface, EGLint buffer);
+EGLBoolean									eglwReleaseThread					();
+EGLBoolean									eglwSignalSyncKHR					(EGLDisplay dpy, EGLSyncKHR sync, EGLenum mode);
+EGLBoolean									eglwSurfaceAttrib					(EGLDisplay dpy, EGLSurface surface, EGLint attribute, EGLint value);
+EGLBoolean									eglwSwapBuffers						(EGLDisplay dpy, EGLSurface surface);
+EGLBoolean									eglwSwapInterval					(EGLDisplay dpy, EGLint interval);
+EGLBoolean									eglwTerminate						(EGLDisplay dpy);
+EGLBoolean									eglwUnlockSurfaceKHR				(EGLDisplay dpy, EGLSurface surface);
+EGLBoolean									eglwWaitClient						();
+EGLBoolean									eglwWaitGL							();
+EGLBoolean									eglwWaitNative						(EGLint engine);
+EGLBoolean									eglwWaitSync						(EGLDisplay dpy, EGLSync sync, EGLint flags);
+EGLint										eglwWaitSyncKHR						(EGLDisplay dpy, EGLSyncKHR sync, EGLint flags);
diff --git a/framework/egl/wrapper/eglwDefs.cpp b/framework/egl/wrapper/eglwDefs.cpp
new file mode 100644
index 0000000..54be84d
--- /dev/null
+++ b/framework/egl/wrapper/eglwDefs.cpp
@@ -0,0 +1,39 @@
+/*-------------------------------------------------------------------------
+ * drawElements Quality Program OpenGL Utilities
+ * ---------------------------------------------
+ *
+ * Copyright 2014 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ *//*!
+ * \file
+ * \brief OpenGL wrapper base types and definitions.
+ *
+ * This header defines all standard OpenGL types using drawElements Base
+ * Portability Library (delibs) types.
+ *//*--------------------------------------------------------------------*/
+
+#include "eglwDefs.hpp"
+
+namespace eglw
+{
+
+// Verify typedefs
+
+DE_STATIC_ASSERT(sizeof(EGLint)		== 4);
+DE_STATIC_ASSERT(sizeof(EGLBoolean)	== 4);
+DE_STATIC_ASSERT(sizeof(EGLAttrib)	== sizeof(void*));
+DE_STATIC_ASSERT(sizeof(EGLTime)	== 8);
+
+} // eglw
diff --git a/framework/egl/wrapper/eglwDefs.hpp b/framework/egl/wrapper/eglwDefs.hpp
new file mode 100644
index 0000000..2c10fee
--- /dev/null
+++ b/framework/egl/wrapper/eglwDefs.hpp
@@ -0,0 +1,47 @@
+#ifndef _EGLWDEFS_HPP
+#define _EGLWDEFS_HPP
+/*-------------------------------------------------------------------------
+ * drawElements Quality Program EGL Utilities
+ * ------------------------------------------
+ *
+ * Copyright 2014 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ *//*!
+ * \file
+ * \brief EGL wrapper base types and definitions.
+ *
+ * This header defines all standard EGL types using drawElements Base
+ * Portability Library (delibs) types.
+ *//*--------------------------------------------------------------------*/
+
+#include "deDefs.hpp"
+
+/*--------------------------------------------------------------------*//*!
+ * \brief EGL API
+ *//*--------------------------------------------------------------------*/
+namespace eglw
+{
+
+// extern "C" since eglwTypes.inl may contain function pointer types.
+extern "C"
+{
+
+#include "eglwTypes.inl"
+
+}
+
+} // eglw
+
+#endif // _EGLWDEFS_HPP
diff --git a/framework/egl/wrapper/eglwEnums.hpp b/framework/egl/wrapper/eglwEnums.hpp
new file mode 100644
index 0000000..82526e8
--- /dev/null
+++ b/framework/egl/wrapper/eglwEnums.hpp
@@ -0,0 +1,40 @@
+#ifndef _EGLWENUMS_HPP
+#define _EGLWENUMS_HPP
+/*-------------------------------------------------------------------------
+ * drawElements Quality Program EGL Utilities
+ * ------------------------------------------
+ *
+ * Copyright 2014 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ *//*!
+ * \file
+ * \brief EGL Enumeration Values
+ * \note Do not include this anywhere where you'd like to include native
+ *		 EGL headers or otherwise preprocessor will be rather unhappy about
+ *		 duplicate declarations.
+ *//*--------------------------------------------------------------------*/
+
+#include "deDefs.hpp"
+#include "eglwDefs.hpp"
+
+// \note Some defines reference types inside eglw::
+namespace eglw
+{
+
+#include "eglwEnums.inl"
+
+} // eglw
+
+#endif // _EGLWENUMS_HPP
diff --git a/framework/egl/wrapper/eglwEnums.inl b/framework/egl/wrapper/eglwEnums.inl
new file mode 100644
index 0000000..bbda388
--- /dev/null
+++ b/framework/egl/wrapper/eglwEnums.inl
@@ -0,0 +1,237 @@
+/* WARNING: This is auto-generated file. Do not modify, since changes will
+ * be lost! Modify the generating script instead.
+ *
+ * Generated from Khronos EGL API description (egl.xml) revision 28861.
+ */
+#define EGL_PBUFFER_BIT										0x0001
+#define EGL_PIXMAP_BIT										0x0002
+#define EGL_WINDOW_BIT										0x0004
+#define EGL_VG_COLORSPACE_LINEAR_BIT						0x0020
+#define EGL_VG_ALPHA_FORMAT_PRE_BIT							0x0040
+#define EGL_LOCK_SURFACE_BIT_KHR							0x0080
+#define EGL_OPTIMAL_FORMAT_BIT_KHR							0x0100
+#define EGL_MULTISAMPLE_RESOLVE_BOX_BIT						0x0200
+#define EGL_SWAP_BEHAVIOR_PRESERVED_BIT						0x0400
+#define EGL_OPENGL_ES_BIT									0x0001
+#define EGL_OPENVG_BIT										0x0002
+#define EGL_OPENGL_ES2_BIT									0x0004
+#define EGL_OPENGL_BIT										0x0008
+#define EGL_OPENGL_ES3_BIT									0x00000040
+#define EGL_OPENGL_ES3_BIT_KHR								0x00000040
+#define EGL_READ_SURFACE_BIT_KHR							0x0001
+#define EGL_WRITE_SURFACE_BIT_KHR							0x0002
+#define EGL_SYNC_FLUSH_COMMANDS_BIT							0x0001
+#define EGL_SYNC_FLUSH_COMMANDS_BIT_KHR						0x0001
+#define EGL_CONTEXT_OPENGL_DEBUG_BIT_KHR					0x00000001
+#define EGL_CONTEXT_OPENGL_FORWARD_COMPATIBLE_BIT_KHR		0x00000002
+#define EGL_CONTEXT_OPENGL_ROBUST_ACCESS_BIT_KHR			0x00000004
+#define EGL_CONTEXT_OPENGL_CORE_PROFILE_BIT					0x00000001
+#define EGL_CONTEXT_OPENGL_CORE_PROFILE_BIT_KHR				0x00000001
+#define EGL_CONTEXT_OPENGL_COMPATIBILITY_PROFILE_BIT		0x00000002
+#define EGL_CONTEXT_OPENGL_COMPATIBILITY_PROFILE_BIT_KHR	0x00000002
+#define EGL_FALSE											0
+#define EGL_TRUE											1
+#define EGL_DONT_CARE										((eglw::EGLint)-1)
+#define EGL_UNKNOWN											((eglw::EGLint)-1)
+#define EGL_NO_CONTEXT										((eglw::EGLContext)0)
+#define EGL_NO_DISPLAY										((eglw::EGLDisplay)0)
+#define EGL_NO_IMAGE										((eglw::EGLImage)0)
+#define EGL_NO_IMAGE_KHR									((eglw::EGLImageKHR)0)
+#define EGL_DEFAULT_DISPLAY									((eglw::EGLNativeDisplayType)0)
+#define EGL_NO_SURFACE										((eglw::EGLSurface)0)
+#define EGL_NO_SYNC											((eglw::EGLSync)0)
+#define EGL_NO_SYNC_KHR										((eglw::EGLSyncKHR)0)
+#define EGL_DISPLAY_SCALING									10000
+#define EGL_FOREVER											0xFFFFFFFFFFFFFFFFull
+#define EGL_FOREVER_KHR										0xFFFFFFFFFFFFFFFFull
+#define EGL_SUCCESS											0x3000
+#define EGL_NOT_INITIALIZED									0x3001
+#define EGL_BAD_ACCESS										0x3002
+#define EGL_BAD_ALLOC										0x3003
+#define EGL_BAD_ATTRIBUTE									0x3004
+#define EGL_BAD_CONFIG										0x3005
+#define EGL_BAD_CONTEXT										0x3006
+#define EGL_BAD_CURRENT_SURFACE								0x3007
+#define EGL_BAD_DISPLAY										0x3008
+#define EGL_BAD_MATCH										0x3009
+#define EGL_BAD_NATIVE_PIXMAP								0x300A
+#define EGL_BAD_NATIVE_WINDOW								0x300B
+#define EGL_BAD_PARAMETER									0x300C
+#define EGL_BAD_SURFACE										0x300D
+#define EGL_CONTEXT_LOST									0x300E
+#define EGL_BUFFER_SIZE										0x3020
+#define EGL_ALPHA_SIZE										0x3021
+#define EGL_BLUE_SIZE										0x3022
+#define EGL_GREEN_SIZE										0x3023
+#define EGL_RED_SIZE										0x3024
+#define EGL_DEPTH_SIZE										0x3025
+#define EGL_STENCIL_SIZE									0x3026
+#define EGL_CONFIG_CAVEAT									0x3027
+#define EGL_CONFIG_ID										0x3028
+#define EGL_LEVEL											0x3029
+#define EGL_MAX_PBUFFER_HEIGHT								0x302A
+#define EGL_MAX_PBUFFER_PIXELS								0x302B
+#define EGL_MAX_PBUFFER_WIDTH								0x302C
+#define EGL_NATIVE_RENDERABLE								0x302D
+#define EGL_NATIVE_VISUAL_ID								0x302E
+#define EGL_NATIVE_VISUAL_TYPE								0x302F
+#define EGL_SAMPLES											0x3031
+#define EGL_SAMPLE_BUFFERS									0x3032
+#define EGL_SURFACE_TYPE									0x3033
+#define EGL_TRANSPARENT_TYPE								0x3034
+#define EGL_TRANSPARENT_BLUE_VALUE							0x3035
+#define EGL_TRANSPARENT_GREEN_VALUE							0x3036
+#define EGL_TRANSPARENT_RED_VALUE							0x3037
+#define EGL_NONE											0x3038
+#define EGL_BIND_TO_TEXTURE_RGB								0x3039
+#define EGL_BIND_TO_TEXTURE_RGBA							0x303A
+#define EGL_MIN_SWAP_INTERVAL								0x303B
+#define EGL_MAX_SWAP_INTERVAL								0x303C
+#define EGL_LUMINANCE_SIZE									0x303D
+#define EGL_ALPHA_MASK_SIZE									0x303E
+#define EGL_COLOR_BUFFER_TYPE								0x303F
+#define EGL_RENDERABLE_TYPE									0x3040
+#define EGL_MATCH_NATIVE_PIXMAP								0x3041
+#define EGL_CONFORMANT										0x3042
+#define EGL_MATCH_FORMAT_KHR								0x3043
+#define EGL_SLOW_CONFIG										0x3050
+#define EGL_NON_CONFORMANT_CONFIG							0x3051
+#define EGL_TRANSPARENT_RGB									0x3052
+#define EGL_VENDOR											0x3053
+#define EGL_VERSION											0x3054
+#define EGL_EXTENSIONS										0x3055
+#define EGL_HEIGHT											0x3056
+#define EGL_WIDTH											0x3057
+#define EGL_LARGEST_PBUFFER									0x3058
+#define EGL_DRAW											0x3059
+#define EGL_READ											0x305A
+#define EGL_CORE_NATIVE_ENGINE								0x305B
+#define EGL_NO_TEXTURE										0x305C
+#define EGL_TEXTURE_RGB										0x305D
+#define EGL_TEXTURE_RGBA									0x305E
+#define EGL_TEXTURE_2D										0x305F
+#define EGL_TEXTURE_FORMAT									0x3080
+#define EGL_TEXTURE_TARGET									0x3081
+#define EGL_MIPMAP_TEXTURE									0x3082
+#define EGL_MIPMAP_LEVEL									0x3083
+#define EGL_BACK_BUFFER										0x3084
+#define EGL_SINGLE_BUFFER									0x3085
+#define EGL_RENDER_BUFFER									0x3086
+#define EGL_COLORSPACE										0x3087
+#define EGL_COLORSPACE										0x3087
+#define EGL_ALPHA_FORMAT									0x3088
+#define EGL_ALPHA_FORMAT									0x3088
+#define EGL_COLORSPACE_sRGB									0x3089
+#define EGL_GL_COLORSPACE_SRGB								0x3089
+#define EGL_VG_COLORSPACE_sRGB								0x3089
+#define EGL_COLORSPACE_LINEAR								0x308A
+#define EGL_GL_COLORSPACE_LINEAR							0x308A
+#define EGL_VG_COLORSPACE_LINEAR							0x308A
+#define EGL_ALPHA_FORMAT_NONPRE								0x308B
+#define EGL_ALPHA_FORMAT_NONPRE								0x308B
+#define EGL_ALPHA_FORMAT_PRE								0x308C
+#define EGL_ALPHA_FORMAT_PRE								0x308C
+#define EGL_CLIENT_APIS										0x308D
+#define EGL_RGB_BUFFER										0x308E
+#define EGL_LUMINANCE_BUFFER								0x308F
+#define EGL_HORIZONTAL_RESOLUTION							0x3090
+#define EGL_VERTICAL_RESOLUTION								0x3091
+#define EGL_PIXEL_ASPECT_RATIO								0x3092
+#define EGL_SWAP_BEHAVIOR									0x3093
+#define EGL_BUFFER_PRESERVED								0x3094
+#define EGL_BUFFER_DESTROYED								0x3095
+#define EGL_OPENVG_IMAGE									0x3096
+#define EGL_CONTEXT_CLIENT_TYPE								0x3097
+#define EGL_CONTEXT_CLIENT_VERSION							0x3098
+#define EGL_CONTEXT_MAJOR_VERSION							0x3098
+#define EGL_CONTEXT_MAJOR_VERSION_KHR						0x3098
+#define EGL_MULTISAMPLE_RESOLVE								0x3099
+#define EGL_MULTISAMPLE_RESOLVE_DEFAULT						0x309A
+#define EGL_MULTISAMPLE_RESOLVE_BOX							0x309B
+#define EGL_CL_EVENT_HANDLE									0x309C
+#define EGL_GL_COLORSPACE									0x309D
+#define EGL_OPENGL_ES_API									0x30A0
+#define EGL_OPENVG_API										0x30A1
+#define EGL_OPENGL_API										0x30A2
+#define EGL_GL_TEXTURE_2D									0x30B1
+#define EGL_GL_TEXTURE_2D_KHR								0x30B1
+#define EGL_GL_TEXTURE_3D									0x30B2
+#define EGL_GL_TEXTURE_3D_KHR								0x30B2
+#define EGL_GL_TEXTURE_CUBE_MAP_POSITIVE_X					0x30B3
+#define EGL_GL_TEXTURE_CUBE_MAP_POSITIVE_X_KHR				0x30B3
+#define EGL_GL_TEXTURE_CUBE_MAP_NEGATIVE_X					0x30B4
+#define EGL_GL_TEXTURE_CUBE_MAP_NEGATIVE_X_KHR				0x30B4
+#define EGL_GL_TEXTURE_CUBE_MAP_POSITIVE_Y					0x30B5
+#define EGL_GL_TEXTURE_CUBE_MAP_POSITIVE_Y_KHR				0x30B5
+#define EGL_GL_TEXTURE_CUBE_MAP_NEGATIVE_Y					0x30B6
+#define EGL_GL_TEXTURE_CUBE_MAP_NEGATIVE_Y_KHR				0x30B6
+#define EGL_GL_TEXTURE_CUBE_MAP_POSITIVE_Z					0x30B7
+#define EGL_GL_TEXTURE_CUBE_MAP_POSITIVE_Z_KHR				0x30B7
+#define EGL_GL_TEXTURE_CUBE_MAP_NEGATIVE_Z					0x30B8
+#define EGL_GL_TEXTURE_CUBE_MAP_NEGATIVE_Z_KHR				0x30B8
+#define EGL_GL_RENDERBUFFER									0x30B9
+#define EGL_GL_RENDERBUFFER_KHR								0x30B9
+#define EGL_GL_TEXTURE_LEVEL								0x30BC
+#define EGL_GL_TEXTURE_LEVEL_KHR							0x30BC
+#define EGL_GL_TEXTURE_ZOFFSET								0x30BD
+#define EGL_GL_TEXTURE_ZOFFSET_KHR							0x30BD
+#define EGL_CONTEXT_OPENGL_ROBUST_ACCESS_EXT				0x30BF
+#define EGL_CONTEXT_OPENGL_ROBUST_ACCESS_EXT				0x30BF
+#define EGL_FORMAT_RGB_565_EXACT_KHR						0x30C0
+#define EGL_FORMAT_RGB_565_KHR								0x30C1
+#define EGL_FORMAT_RGBA_8888_EXACT_KHR						0x30C2
+#define EGL_FORMAT_RGBA_8888_KHR							0x30C3
+#define EGL_MAP_PRESERVE_PIXELS_KHR							0x30C4
+#define EGL_LOCK_USAGE_HINT_KHR								0x30C5
+#define EGL_BITMAP_POINTER_KHR								0x30C6
+#define EGL_BITMAP_PITCH_KHR								0x30C7
+#define EGL_BITMAP_ORIGIN_KHR								0x30C8
+#define EGL_BITMAP_PIXEL_RED_OFFSET_KHR						0x30C9
+#define EGL_BITMAP_PIXEL_GREEN_OFFSET_KHR					0x30CA
+#define EGL_BITMAP_PIXEL_BLUE_OFFSET_KHR					0x30CB
+#define EGL_BITMAP_PIXEL_ALPHA_OFFSET_KHR					0x30CC
+#define EGL_BITMAP_PIXEL_LUMINANCE_OFFSET_KHR				0x30CD
+#define EGL_LOWER_LEFT_KHR									0x30CE
+#define EGL_UPPER_LEFT_KHR									0x30CF
+#define EGL_IMAGE_PRESERVED									0x30D2
+#define EGL_IMAGE_PRESERVED_KHR								0x30D2
+#define EGL_SYNC_PRIOR_COMMANDS_COMPLETE					0x30F0
+#define EGL_SYNC_PRIOR_COMMANDS_COMPLETE_KHR				0x30F0
+#define EGL_SYNC_STATUS										0x30F1
+#define EGL_SYNC_STATUS_KHR									0x30F1
+#define EGL_SIGNALED										0x30F2
+#define EGL_SIGNALED_KHR									0x30F2
+#define EGL_UNSIGNALED										0x30F3
+#define EGL_UNSIGNALED_KHR									0x30F3
+#define EGL_TIMEOUT_EXPIRED									0x30F5
+#define EGL_TIMEOUT_EXPIRED_KHR								0x30F5
+#define EGL_CONDITION_SATISFIED								0x30F6
+#define EGL_CONDITION_SATISFIED_KHR							0x30F6
+#define EGL_SYNC_TYPE										0x30F7
+#define EGL_SYNC_TYPE_KHR									0x30F7
+#define EGL_SYNC_CONDITION									0x30F8
+#define EGL_SYNC_CONDITION_KHR								0x30F8
+#define EGL_SYNC_FENCE										0x30F9
+#define EGL_SYNC_FENCE_KHR									0x30F9
+#define EGL_SYNC_REUSABLE_KHR								0x30FA
+#define EGL_CONTEXT_MINOR_VERSION							0x30FB
+#define EGL_CONTEXT_MINOR_VERSION_KHR						0x30FB
+#define EGL_CONTEXT_FLAGS_KHR								0x30FC
+#define EGL_CONTEXT_OPENGL_PROFILE_MASK						0x30FD
+#define EGL_CONTEXT_OPENGL_PROFILE_MASK_KHR					0x30FD
+#define EGL_SYNC_CL_EVENT									0x30FE
+#define EGL_SYNC_CL_EVENT_COMPLETE							0x30FF
+#define EGL_CONTEXT_OPENGL_RESET_NOTIFICATION_STRATEGY_EXT	0x3138
+#define EGL_NATIVE_BUFFER_ANDROID							0x3140
+#define EGL_CONTEXT_OPENGL_DEBUG							0x31B0
+#define EGL_CONTEXT_OPENGL_FORWARD_COMPATIBLE				0x31B1
+#define EGL_CONTEXT_OPENGL_RESET_NOTIFICATION_STRATEGY_KHR	0x31BD
+#define EGL_CONTEXT_OPENGL_RESET_NOTIFICATION_STRATEGY_KHR	0x31BD
+#define EGL_NO_RESET_NOTIFICATION							0x31BE
+#define EGL_NO_RESET_NOTIFICATION_KHR						0x31BE
+#define EGL_NO_RESET_NOTIFICATION_EXT						0x31BE
+#define EGL_LOSE_CONTEXT_ON_RESET							0x31BF
+#define EGL_LOSE_CONTEXT_ON_RESET_KHR						0x31BF
+#define EGL_LOSE_CONTEXT_ON_RESET_EXT						0x31BF
+#define EGL_PLATFORM_X11_EXT								0x31D5
+#define EGL_PLATFORM_X11_SCREEN_EXT							0x31D6
diff --git a/framework/egl/wrapper/eglwFuncPtrLibraryDecl.inl b/framework/egl/wrapper/eglwFuncPtrLibraryDecl.inl
new file mode 100644
index 0000000..51b0a43
--- /dev/null
+++ b/framework/egl/wrapper/eglwFuncPtrLibraryDecl.inl
@@ -0,0 +1,62 @@
+/* WARNING: This is auto-generated file. Do not modify, since changes will
+ * be lost! Modify the generating script instead.
+ *
+ * Generated from Khronos EGL API description (egl.xml) revision 28861.
+ */
+EGLBoolean									bindAPI							(EGLenum api) const;
+EGLBoolean									bindTexImage					(EGLDisplay dpy, EGLSurface surface, EGLint buffer) const;
+EGLBoolean									chooseConfig					(EGLDisplay dpy, const EGLint *attrib_list, EGLConfig *configs, EGLint config_size, EGLint *num_config) const;
+EGLint										clientWaitSync					(EGLDisplay dpy, EGLSync sync, EGLint flags, EGLTime timeout) const;
+EGLint										clientWaitSyncKHR				(EGLDisplay dpy, EGLSyncKHR sync, EGLint flags, EGLTimeKHR timeout) const;
+EGLBoolean									copyBuffers						(EGLDisplay dpy, EGLSurface surface, EGLNativePixmapType target) const;
+EGLContext									createContext					(EGLDisplay dpy, EGLConfig config, EGLContext share_context, const EGLint *attrib_list) const;
+EGLImage									createImage						(EGLDisplay dpy, EGLContext ctx, EGLenum target, EGLClientBuffer buffer, const EGLint *attrib_list) const;
+EGLImageKHR									createImageKHR					(EGLDisplay dpy, EGLContext ctx, EGLenum target, EGLClientBuffer buffer, const EGLint *attrib_list) const;
+EGLSurface									createPbufferFromClientBuffer	(EGLDisplay dpy, EGLenum buftype, EGLClientBuffer buffer, EGLConfig config, const EGLint *attrib_list) const;
+EGLSurface									createPbufferSurface			(EGLDisplay dpy, EGLConfig config, const EGLint *attrib_list) const;
+EGLSurface									createPixmapSurface				(EGLDisplay dpy, EGLConfig config, EGLNativePixmapType pixmap, const EGLint *attrib_list) const;
+EGLSurface									createPlatformPixmapSurface		(EGLDisplay dpy, EGLConfig config, void *native_pixmap, const EGLAttrib *attrib_list) const;
+EGLSurface									createPlatformPixmapSurfaceEXT	(EGLDisplay dpy, EGLConfig config, void *native_pixmap, const EGLint *attrib_list) const;
+EGLSurface									createPlatformWindowSurface		(EGLDisplay dpy, EGLConfig config, void *native_window, const EGLAttrib *attrib_list) const;
+EGLSurface									createPlatformWindowSurfaceEXT	(EGLDisplay dpy, EGLConfig config, void *native_window, const EGLint *attrib_list) const;
+EGLSync										createSync						(EGLDisplay dpy, EGLenum type, const EGLAttrib *attrib_list) const;
+EGLSyncKHR									createSyncKHR					(EGLDisplay dpy, EGLenum type, const EGLint *attrib_list) const;
+EGLSurface									createWindowSurface				(EGLDisplay dpy, EGLConfig config, EGLNativeWindowType win, const EGLint *attrib_list) const;
+EGLBoolean									destroyContext					(EGLDisplay dpy, EGLContext ctx) const;
+EGLBoolean									destroyImage					(EGLDisplay dpy, EGLImage image) const;
+EGLBoolean									destroyImageKHR					(EGLDisplay dpy, EGLImageKHR image) const;
+EGLBoolean									destroySurface					(EGLDisplay dpy, EGLSurface surface) const;
+EGLBoolean									destroySync						(EGLDisplay dpy, EGLSync sync) const;
+EGLBoolean									destroySyncKHR					(EGLDisplay dpy, EGLSyncKHR sync) const;
+EGLBoolean									getConfigAttrib					(EGLDisplay dpy, EGLConfig config, EGLint attribute, EGLint *value) const;
+EGLBoolean									getConfigs						(EGLDisplay dpy, EGLConfig *configs, EGLint config_size, EGLint *num_config) const;
+EGLContext									getCurrentContext				(void) const;
+EGLDisplay									getCurrentDisplay				(void) const;
+EGLSurface									getCurrentSurface				(EGLint readdraw) const;
+EGLDisplay									getDisplay						(EGLNativeDisplayType display_id) const;
+EGLint										getError						(void) const;
+EGLDisplay									getPlatformDisplay				(EGLenum platform, void *native_display, const EGLAttrib *attrib_list) const;
+EGLDisplay									getPlatformDisplayEXT			(EGLenum platform, void *native_display, const EGLint *attrib_list) const;
+__eglMustCastToProperFunctionPointerType	getProcAddress					(const char *procname) const;
+EGLBoolean									getSyncAttrib					(EGLDisplay dpy, EGLSync sync, EGLint attribute, EGLAttrib *value) const;
+EGLBoolean									getSyncAttribKHR				(EGLDisplay dpy, EGLSyncKHR sync, EGLint attribute, EGLint *value) const;
+EGLBoolean									initialize						(EGLDisplay dpy, EGLint *major, EGLint *minor) const;
+EGLBoolean									lockSurfaceKHR					(EGLDisplay dpy, EGLSurface surface, const EGLint *attrib_list) const;
+EGLBoolean									makeCurrent						(EGLDisplay dpy, EGLSurface draw, EGLSurface read, EGLContext ctx) const;
+EGLenum										queryAPI						(void) const;
+EGLBoolean									queryContext					(EGLDisplay dpy, EGLContext ctx, EGLint attribute, EGLint *value) const;
+const char *								queryString						(EGLDisplay dpy, EGLint name) const;
+EGLBoolean									querySurface					(EGLDisplay dpy, EGLSurface surface, EGLint attribute, EGLint *value) const;
+EGLBoolean									releaseTexImage					(EGLDisplay dpy, EGLSurface surface, EGLint buffer) const;
+EGLBoolean									releaseThread					(void) const;
+EGLBoolean									signalSyncKHR					(EGLDisplay dpy, EGLSyncKHR sync, EGLenum mode) const;
+EGLBoolean									surfaceAttrib					(EGLDisplay dpy, EGLSurface surface, EGLint attribute, EGLint value) const;
+EGLBoolean									swapBuffers						(EGLDisplay dpy, EGLSurface surface) const;
+EGLBoolean									swapInterval					(EGLDisplay dpy, EGLint interval) const;
+EGLBoolean									terminate						(EGLDisplay dpy) const;
+EGLBoolean									unlockSurfaceKHR				(EGLDisplay dpy, EGLSurface surface) const;
+EGLBoolean									waitClient						(void) const;
+EGLBoolean									waitGL							(void) const;
+EGLBoolean									waitNative						(EGLint engine) const;
+EGLBoolean									waitSync						(EGLDisplay dpy, EGLSync sync, EGLint flags) const;
+EGLint										waitSyncKHR						(EGLDisplay dpy, EGLSyncKHR sync, EGLint flags) const;
diff --git a/framework/egl/wrapper/eglwFuncPtrLibraryImpl.inl b/framework/egl/wrapper/eglwFuncPtrLibraryImpl.inl
new file mode 100644
index 0000000..bf1e280
--- /dev/null
+++ b/framework/egl/wrapper/eglwFuncPtrLibraryImpl.inl
@@ -0,0 +1,290 @@
+/* WARNING: This is auto-generated file. Do not modify, since changes will
+ * be lost! Modify the generating script instead.
+ *
+ * Generated from Khronos EGL API description (egl.xml) revision 28861.
+ */
+
+EGLBoolean FuncPtrLibrary::bindAPI (EGLenum api) const
+{
+	return m_egl.bindAPI(api);
+}
+
+EGLBoolean FuncPtrLibrary::bindTexImage (EGLDisplay dpy, EGLSurface surface, EGLint buffer) const
+{
+	return m_egl.bindTexImage(dpy, surface, buffer);
+}
+
+EGLBoolean FuncPtrLibrary::chooseConfig (EGLDisplay dpy, const EGLint *attrib_list, EGLConfig *configs, EGLint config_size, EGLint *num_config) const
+{
+	return m_egl.chooseConfig(dpy, attrib_list, configs, config_size, num_config);
+}
+
+EGLint FuncPtrLibrary::clientWaitSync (EGLDisplay dpy, EGLSync sync, EGLint flags, EGLTime timeout) const
+{
+	return m_egl.clientWaitSync(dpy, sync, flags, timeout);
+}
+
+EGLint FuncPtrLibrary::clientWaitSyncKHR (EGLDisplay dpy, EGLSyncKHR sync, EGLint flags, EGLTimeKHR timeout) const
+{
+	return m_egl.clientWaitSyncKHR(dpy, sync, flags, timeout);
+}
+
+EGLBoolean FuncPtrLibrary::copyBuffers (EGLDisplay dpy, EGLSurface surface, EGLNativePixmapType target) const
+{
+	return m_egl.copyBuffers(dpy, surface, target);
+}
+
+EGLContext FuncPtrLibrary::createContext (EGLDisplay dpy, EGLConfig config, EGLContext share_context, const EGLint *attrib_list) const
+{
+	return m_egl.createContext(dpy, config, share_context, attrib_list);
+}
+
+EGLImage FuncPtrLibrary::createImage (EGLDisplay dpy, EGLContext ctx, EGLenum target, EGLClientBuffer buffer, const EGLint *attrib_list) const
+{
+	return m_egl.createImage(dpy, ctx, target, buffer, attrib_list);
+}
+
+EGLImageKHR FuncPtrLibrary::createImageKHR (EGLDisplay dpy, EGLContext ctx, EGLenum target, EGLClientBuffer buffer, const EGLint *attrib_list) const
+{
+	return m_egl.createImageKHR(dpy, ctx, target, buffer, attrib_list);
+}
+
+EGLSurface FuncPtrLibrary::createPbufferFromClientBuffer (EGLDisplay dpy, EGLenum buftype, EGLClientBuffer buffer, EGLConfig config, const EGLint *attrib_list) const
+{
+	return m_egl.createPbufferFromClientBuffer(dpy, buftype, buffer, config, attrib_list);
+}
+
+EGLSurface FuncPtrLibrary::createPbufferSurface (EGLDisplay dpy, EGLConfig config, const EGLint *attrib_list) const
+{
+	return m_egl.createPbufferSurface(dpy, config, attrib_list);
+}
+
+EGLSurface FuncPtrLibrary::createPixmapSurface (EGLDisplay dpy, EGLConfig config, EGLNativePixmapType pixmap, const EGLint *attrib_list) const
+{
+	return m_egl.createPixmapSurface(dpy, config, pixmap, attrib_list);
+}
+
+EGLSurface FuncPtrLibrary::createPlatformPixmapSurface (EGLDisplay dpy, EGLConfig config, void *native_pixmap, const EGLAttrib *attrib_list) const
+{
+	return m_egl.createPlatformPixmapSurface(dpy, config, native_pixmap, attrib_list);
+}
+
+EGLSurface FuncPtrLibrary::createPlatformPixmapSurfaceEXT (EGLDisplay dpy, EGLConfig config, void *native_pixmap, const EGLint *attrib_list) const
+{
+	return m_egl.createPlatformPixmapSurfaceEXT(dpy, config, native_pixmap, attrib_list);
+}
+
+EGLSurface FuncPtrLibrary::createPlatformWindowSurface (EGLDisplay dpy, EGLConfig config, void *native_window, const EGLAttrib *attrib_list) const
+{
+	return m_egl.createPlatformWindowSurface(dpy, config, native_window, attrib_list);
+}
+
+EGLSurface FuncPtrLibrary::createPlatformWindowSurfaceEXT (EGLDisplay dpy, EGLConfig config, void *native_window, const EGLint *attrib_list) const
+{
+	return m_egl.createPlatformWindowSurfaceEXT(dpy, config, native_window, attrib_list);
+}
+
+EGLSync FuncPtrLibrary::createSync (EGLDisplay dpy, EGLenum type, const EGLAttrib *attrib_list) const
+{
+	return m_egl.createSync(dpy, type, attrib_list);
+}
+
+EGLSyncKHR FuncPtrLibrary::createSyncKHR (EGLDisplay dpy, EGLenum type, const EGLint *attrib_list) const
+{
+	return m_egl.createSyncKHR(dpy, type, attrib_list);
+}
+
+EGLSurface FuncPtrLibrary::createWindowSurface (EGLDisplay dpy, EGLConfig config, EGLNativeWindowType win, const EGLint *attrib_list) const
+{
+	return m_egl.createWindowSurface(dpy, config, win, attrib_list);
+}
+
+EGLBoolean FuncPtrLibrary::destroyContext (EGLDisplay dpy, EGLContext ctx) const
+{
+	return m_egl.destroyContext(dpy, ctx);
+}
+
+EGLBoolean FuncPtrLibrary::destroyImage (EGLDisplay dpy, EGLImage image) const
+{
+	return m_egl.destroyImage(dpy, image);
+}
+
+EGLBoolean FuncPtrLibrary::destroyImageKHR (EGLDisplay dpy, EGLImageKHR image) const
+{
+	return m_egl.destroyImageKHR(dpy, image);
+}
+
+EGLBoolean FuncPtrLibrary::destroySurface (EGLDisplay dpy, EGLSurface surface) const
+{
+	return m_egl.destroySurface(dpy, surface);
+}
+
+EGLBoolean FuncPtrLibrary::destroySync (EGLDisplay dpy, EGLSync sync) const
+{
+	return m_egl.destroySync(dpy, sync);
+}
+
+EGLBoolean FuncPtrLibrary::destroySyncKHR (EGLDisplay dpy, EGLSyncKHR sync) const
+{
+	return m_egl.destroySyncKHR(dpy, sync);
+}
+
+EGLBoolean FuncPtrLibrary::getConfigAttrib (EGLDisplay dpy, EGLConfig config, EGLint attribute, EGLint *value) const
+{
+	return m_egl.getConfigAttrib(dpy, config, attribute, value);
+}
+
+EGLBoolean FuncPtrLibrary::getConfigs (EGLDisplay dpy, EGLConfig *configs, EGLint config_size, EGLint *num_config) const
+{
+	return m_egl.getConfigs(dpy, configs, config_size, num_config);
+}
+
+EGLContext FuncPtrLibrary::getCurrentContext (void) const
+{
+	return m_egl.getCurrentContext();
+}
+
+EGLDisplay FuncPtrLibrary::getCurrentDisplay (void) const
+{
+	return m_egl.getCurrentDisplay();
+}
+
+EGLSurface FuncPtrLibrary::getCurrentSurface (EGLint readdraw) const
+{
+	return m_egl.getCurrentSurface(readdraw);
+}
+
+EGLDisplay FuncPtrLibrary::getDisplay (EGLNativeDisplayType display_id) const
+{
+	return m_egl.getDisplay(display_id);
+}
+
+EGLint FuncPtrLibrary::getError (void) const
+{
+	return m_egl.getError();
+}
+
+EGLDisplay FuncPtrLibrary::getPlatformDisplay (EGLenum platform, void *native_display, const EGLAttrib *attrib_list) const
+{
+	return m_egl.getPlatformDisplay(platform, native_display, attrib_list);
+}
+
+EGLDisplay FuncPtrLibrary::getPlatformDisplayEXT (EGLenum platform, void *native_display, const EGLint *attrib_list) const
+{
+	return m_egl.getPlatformDisplayEXT(platform, native_display, attrib_list);
+}
+
+__eglMustCastToProperFunctionPointerType FuncPtrLibrary::getProcAddress (const char *procname) const
+{
+	return m_egl.getProcAddress(procname);
+}
+
+EGLBoolean FuncPtrLibrary::getSyncAttrib (EGLDisplay dpy, EGLSync sync, EGLint attribute, EGLAttrib *value) const
+{
+	return m_egl.getSyncAttrib(dpy, sync, attribute, value);
+}
+
+EGLBoolean FuncPtrLibrary::getSyncAttribKHR (EGLDisplay dpy, EGLSyncKHR sync, EGLint attribute, EGLint *value) const
+{
+	return m_egl.getSyncAttribKHR(dpy, sync, attribute, value);
+}
+
+EGLBoolean FuncPtrLibrary::initialize (EGLDisplay dpy, EGLint *major, EGLint *minor) const
+{
+	return m_egl.initialize(dpy, major, minor);
+}
+
+EGLBoolean FuncPtrLibrary::lockSurfaceKHR (EGLDisplay dpy, EGLSurface surface, const EGLint *attrib_list) const
+{
+	return m_egl.lockSurfaceKHR(dpy, surface, attrib_list);
+}
+
+EGLBoolean FuncPtrLibrary::makeCurrent (EGLDisplay dpy, EGLSurface draw, EGLSurface read, EGLContext ctx) const
+{
+	return m_egl.makeCurrent(dpy, draw, read, ctx);
+}
+
+EGLenum FuncPtrLibrary::queryAPI (void) const
+{
+	return m_egl.queryAPI();
+}
+
+EGLBoolean FuncPtrLibrary::queryContext (EGLDisplay dpy, EGLContext ctx, EGLint attribute, EGLint *value) const
+{
+	return m_egl.queryContext(dpy, ctx, attribute, value);
+}
+
+const char * FuncPtrLibrary::queryString (EGLDisplay dpy, EGLint name) const
+{
+	return m_egl.queryString(dpy, name);
+}
+
+EGLBoolean FuncPtrLibrary::querySurface (EGLDisplay dpy, EGLSurface surface, EGLint attribute, EGLint *value) const
+{
+	return m_egl.querySurface(dpy, surface, attribute, value);
+}
+
+EGLBoolean FuncPtrLibrary::releaseTexImage (EGLDisplay dpy, EGLSurface surface, EGLint buffer) const
+{
+	return m_egl.releaseTexImage(dpy, surface, buffer);
+}
+
+EGLBoolean FuncPtrLibrary::releaseThread (void) const
+{
+	return m_egl.releaseThread();
+}
+
+EGLBoolean FuncPtrLibrary::signalSyncKHR (EGLDisplay dpy, EGLSyncKHR sync, EGLenum mode) const
+{
+	return m_egl.signalSyncKHR(dpy, sync, mode);
+}
+
+EGLBoolean FuncPtrLibrary::surfaceAttrib (EGLDisplay dpy, EGLSurface surface, EGLint attribute, EGLint value) const
+{
+	return m_egl.surfaceAttrib(dpy, surface, attribute, value);
+}
+
+EGLBoolean FuncPtrLibrary::swapBuffers (EGLDisplay dpy, EGLSurface surface) const
+{
+	return m_egl.swapBuffers(dpy, surface);
+}
+
+EGLBoolean FuncPtrLibrary::swapInterval (EGLDisplay dpy, EGLint interval) const
+{
+	return m_egl.swapInterval(dpy, interval);
+}
+
+EGLBoolean FuncPtrLibrary::terminate (EGLDisplay dpy) const
+{
+	return m_egl.terminate(dpy);
+}
+
+EGLBoolean FuncPtrLibrary::unlockSurfaceKHR (EGLDisplay dpy, EGLSurface surface) const
+{
+	return m_egl.unlockSurfaceKHR(dpy, surface);
+}
+
+EGLBoolean FuncPtrLibrary::waitClient (void) const
+{
+	return m_egl.waitClient();
+}
+
+EGLBoolean FuncPtrLibrary::waitGL (void) const
+{
+	return m_egl.waitGL();
+}
+
+EGLBoolean FuncPtrLibrary::waitNative (EGLint engine) const
+{
+	return m_egl.waitNative(engine);
+}
+
+EGLBoolean FuncPtrLibrary::waitSync (EGLDisplay dpy, EGLSync sync, EGLint flags) const
+{
+	return m_egl.waitSync(dpy, sync, flags);
+}
+
+EGLint FuncPtrLibrary::waitSyncKHR (EGLDisplay dpy, EGLSyncKHR sync, EGLint flags) const
+{
+	return m_egl.waitSyncKHR(dpy, sync, flags);
+}
diff --git a/framework/egl/wrapper/eglwFunctionTypes.inl b/framework/egl/wrapper/eglwFunctionTypes.inl
new file mode 100644
index 0000000..3616b03
--- /dev/null
+++ b/framework/egl/wrapper/eglwFunctionTypes.inl
@@ -0,0 +1,62 @@
+/* WARNING: This is auto-generated file. Do not modify, since changes will
+ * be lost! Modify the generating script instead.
+ *
+ * Generated from Khronos EGL API description (egl.xml) revision 28861.
+ */
+typedef EGLW_APICALL EGLBoolean									(EGLW_APIENTRY* eglBindAPIFunc)							(EGLenum api);
+typedef EGLW_APICALL EGLBoolean									(EGLW_APIENTRY* eglBindTexImageFunc)					(EGLDisplay dpy, EGLSurface surface, EGLint buffer);
+typedef EGLW_APICALL EGLBoolean									(EGLW_APIENTRY* eglChooseConfigFunc)					(EGLDisplay dpy, const EGLint *attrib_list, EGLConfig *configs, EGLint config_size, EGLint *num_config);
+typedef EGLW_APICALL EGLint										(EGLW_APIENTRY* eglClientWaitSyncFunc)					(EGLDisplay dpy, EGLSync sync, EGLint flags, EGLTime timeout);
+typedef EGLW_APICALL EGLint										(EGLW_APIENTRY* eglClientWaitSyncKHRFunc)				(EGLDisplay dpy, EGLSyncKHR sync, EGLint flags, EGLTimeKHR timeout);
+typedef EGLW_APICALL EGLBoolean									(EGLW_APIENTRY* eglCopyBuffersFunc)						(EGLDisplay dpy, EGLSurface surface, EGLNativePixmapType target);
+typedef EGLW_APICALL EGLContext									(EGLW_APIENTRY* eglCreateContextFunc)					(EGLDisplay dpy, EGLConfig config, EGLContext share_context, const EGLint *attrib_list);
+typedef EGLW_APICALL EGLImage									(EGLW_APIENTRY* eglCreateImageFunc)						(EGLDisplay dpy, EGLContext ctx, EGLenum target, EGLClientBuffer buffer, const EGLint *attrib_list);
+typedef EGLW_APICALL EGLImageKHR								(EGLW_APIENTRY* eglCreateImageKHRFunc)					(EGLDisplay dpy, EGLContext ctx, EGLenum target, EGLClientBuffer buffer, const EGLint *attrib_list);
+typedef EGLW_APICALL EGLSurface									(EGLW_APIENTRY* eglCreatePbufferFromClientBufferFunc)	(EGLDisplay dpy, EGLenum buftype, EGLClientBuffer buffer, EGLConfig config, const EGLint *attrib_list);
+typedef EGLW_APICALL EGLSurface									(EGLW_APIENTRY* eglCreatePbufferSurfaceFunc)			(EGLDisplay dpy, EGLConfig config, const EGLint *attrib_list);
+typedef EGLW_APICALL EGLSurface									(EGLW_APIENTRY* eglCreatePixmapSurfaceFunc)				(EGLDisplay dpy, EGLConfig config, EGLNativePixmapType pixmap, const EGLint *attrib_list);
+typedef EGLW_APICALL EGLSurface									(EGLW_APIENTRY* eglCreatePlatformPixmapSurfaceFunc)		(EGLDisplay dpy, EGLConfig config, void *native_pixmap, const EGLAttrib *attrib_list);
+typedef EGLW_APICALL EGLSurface									(EGLW_APIENTRY* eglCreatePlatformPixmapSurfaceEXTFunc)	(EGLDisplay dpy, EGLConfig config, void *native_pixmap, const EGLint *attrib_list);
+typedef EGLW_APICALL EGLSurface									(EGLW_APIENTRY* eglCreatePlatformWindowSurfaceFunc)		(EGLDisplay dpy, EGLConfig config, void *native_window, const EGLAttrib *attrib_list);
+typedef EGLW_APICALL EGLSurface									(EGLW_APIENTRY* eglCreatePlatformWindowSurfaceEXTFunc)	(EGLDisplay dpy, EGLConfig config, void *native_window, const EGLint *attrib_list);
+typedef EGLW_APICALL EGLSync									(EGLW_APIENTRY* eglCreateSyncFunc)						(EGLDisplay dpy, EGLenum type, const EGLAttrib *attrib_list);
+typedef EGLW_APICALL EGLSyncKHR									(EGLW_APIENTRY* eglCreateSyncKHRFunc)					(EGLDisplay dpy, EGLenum type, const EGLint *attrib_list);
+typedef EGLW_APICALL EGLSurface									(EGLW_APIENTRY* eglCreateWindowSurfaceFunc)				(EGLDisplay dpy, EGLConfig config, EGLNativeWindowType win, const EGLint *attrib_list);
+typedef EGLW_APICALL EGLBoolean									(EGLW_APIENTRY* eglDestroyContextFunc)					(EGLDisplay dpy, EGLContext ctx);
+typedef EGLW_APICALL EGLBoolean									(EGLW_APIENTRY* eglDestroyImageFunc)					(EGLDisplay dpy, EGLImage image);
+typedef EGLW_APICALL EGLBoolean									(EGLW_APIENTRY* eglDestroyImageKHRFunc)					(EGLDisplay dpy, EGLImageKHR image);
+typedef EGLW_APICALL EGLBoolean									(EGLW_APIENTRY* eglDestroySurfaceFunc)					(EGLDisplay dpy, EGLSurface surface);
+typedef EGLW_APICALL EGLBoolean									(EGLW_APIENTRY* eglDestroySyncFunc)						(EGLDisplay dpy, EGLSync sync);
+typedef EGLW_APICALL EGLBoolean									(EGLW_APIENTRY* eglDestroySyncKHRFunc)					(EGLDisplay dpy, EGLSyncKHR sync);
+typedef EGLW_APICALL EGLBoolean									(EGLW_APIENTRY* eglGetConfigAttribFunc)					(EGLDisplay dpy, EGLConfig config, EGLint attribute, EGLint *value);
+typedef EGLW_APICALL EGLBoolean									(EGLW_APIENTRY* eglGetConfigsFunc)						(EGLDisplay dpy, EGLConfig *configs, EGLint config_size, EGLint *num_config);
+typedef EGLW_APICALL EGLContext									(EGLW_APIENTRY* eglGetCurrentContextFunc)				(void);
+typedef EGLW_APICALL EGLDisplay									(EGLW_APIENTRY* eglGetCurrentDisplayFunc)				(void);
+typedef EGLW_APICALL EGLSurface									(EGLW_APIENTRY* eglGetCurrentSurfaceFunc)				(EGLint readdraw);
+typedef EGLW_APICALL EGLDisplay									(EGLW_APIENTRY* eglGetDisplayFunc)						(EGLNativeDisplayType display_id);
+typedef EGLW_APICALL EGLint										(EGLW_APIENTRY* eglGetErrorFunc)						(void);
+typedef EGLW_APICALL EGLDisplay									(EGLW_APIENTRY* eglGetPlatformDisplayFunc)				(EGLenum platform, void *native_display, const EGLAttrib *attrib_list);
+typedef EGLW_APICALL EGLDisplay									(EGLW_APIENTRY* eglGetPlatformDisplayEXTFunc)			(EGLenum platform, void *native_display, const EGLint *attrib_list);
+typedef EGLW_APICALL __eglMustCastToProperFunctionPointerType	(EGLW_APIENTRY* eglGetProcAddressFunc)					(const char *procname);
+typedef EGLW_APICALL EGLBoolean									(EGLW_APIENTRY* eglGetSyncAttribFunc)					(EGLDisplay dpy, EGLSync sync, EGLint attribute, EGLAttrib *value);
+typedef EGLW_APICALL EGLBoolean									(EGLW_APIENTRY* eglGetSyncAttribKHRFunc)				(EGLDisplay dpy, EGLSyncKHR sync, EGLint attribute, EGLint *value);
+typedef EGLW_APICALL EGLBoolean									(EGLW_APIENTRY* eglInitializeFunc)						(EGLDisplay dpy, EGLint *major, EGLint *minor);
+typedef EGLW_APICALL EGLBoolean									(EGLW_APIENTRY* eglLockSurfaceKHRFunc)					(EGLDisplay dpy, EGLSurface surface, const EGLint *attrib_list);
+typedef EGLW_APICALL EGLBoolean									(EGLW_APIENTRY* eglMakeCurrentFunc)						(EGLDisplay dpy, EGLSurface draw, EGLSurface read, EGLContext ctx);
+typedef EGLW_APICALL EGLenum									(EGLW_APIENTRY* eglQueryAPIFunc)						(void);
+typedef EGLW_APICALL EGLBoolean									(EGLW_APIENTRY* eglQueryContextFunc)					(EGLDisplay dpy, EGLContext ctx, EGLint attribute, EGLint *value);
+typedef EGLW_APICALL const char *								(EGLW_APIENTRY* eglQueryStringFunc)						(EGLDisplay dpy, EGLint name);
+typedef EGLW_APICALL EGLBoolean									(EGLW_APIENTRY* eglQuerySurfaceFunc)					(EGLDisplay dpy, EGLSurface surface, EGLint attribute, EGLint *value);
+typedef EGLW_APICALL EGLBoolean									(EGLW_APIENTRY* eglReleaseTexImageFunc)					(EGLDisplay dpy, EGLSurface surface, EGLint buffer);
+typedef EGLW_APICALL EGLBoolean									(EGLW_APIENTRY* eglReleaseThreadFunc)					(void);
+typedef EGLW_APICALL EGLBoolean									(EGLW_APIENTRY* eglSignalSyncKHRFunc)					(EGLDisplay dpy, EGLSyncKHR sync, EGLenum mode);
+typedef EGLW_APICALL EGLBoolean									(EGLW_APIENTRY* eglSurfaceAttribFunc)					(EGLDisplay dpy, EGLSurface surface, EGLint attribute, EGLint value);
+typedef EGLW_APICALL EGLBoolean									(EGLW_APIENTRY* eglSwapBuffersFunc)						(EGLDisplay dpy, EGLSurface surface);
+typedef EGLW_APICALL EGLBoolean									(EGLW_APIENTRY* eglSwapIntervalFunc)					(EGLDisplay dpy, EGLint interval);
+typedef EGLW_APICALL EGLBoolean									(EGLW_APIENTRY* eglTerminateFunc)						(EGLDisplay dpy);
+typedef EGLW_APICALL EGLBoolean									(EGLW_APIENTRY* eglUnlockSurfaceKHRFunc)				(EGLDisplay dpy, EGLSurface surface);
+typedef EGLW_APICALL EGLBoolean									(EGLW_APIENTRY* eglWaitClientFunc)						(void);
+typedef EGLW_APICALL EGLBoolean									(EGLW_APIENTRY* eglWaitGLFunc)							(void);
+typedef EGLW_APICALL EGLBoolean									(EGLW_APIENTRY* eglWaitNativeFunc)						(EGLint engine);
+typedef EGLW_APICALL EGLBoolean									(EGLW_APIENTRY* eglWaitSyncFunc)						(EGLDisplay dpy, EGLSync sync, EGLint flags);
+typedef EGLW_APICALL EGLint										(EGLW_APIENTRY* eglWaitSyncKHRFunc)						(EGLDisplay dpy, EGLSyncKHR sync, EGLint flags);
diff --git a/framework/egl/egluHeaderWrapper.cpp b/framework/egl/wrapper/eglwFunctions.cpp
similarity index 62%
copy from framework/egl/egluHeaderWrapper.cpp
copy to framework/egl/wrapper/eglwFunctions.cpp
index 5966c54..d6d553b 100644
--- a/framework/egl/egluHeaderWrapper.cpp
+++ b/framework/egl/wrapper/eglwFunctions.cpp
@@ -1,6 +1,6 @@
 /*-------------------------------------------------------------------------
- * drawElements Quality Program Tester Core
- * ----------------------------------------
+ * drawElements Quality Program EGL Utilities
+ * ------------------------------------------
  *
  * Copyright 2014 The Android Open Source Project
  *
@@ -18,9 +18,28 @@
  *
  *//*!
  * \file
- * \brief EGL header file wrapper
+ * \brief EGL API Functions.
  *//*--------------------------------------------------------------------*/
 
-#include "egluHeaderWrapper.hpp"
+#include "eglwFunctions.hpp"
+#include "deMemory.h"
 
-DE_EMPTY_CPP_FILE
+namespace eglw
+{
+
+Functions::Functions (void)
+{
+	deMemset(this, 0, sizeof(*this));
+}
+
+void initCore (Functions* dst, const FunctionLoader* loader)
+{
+#include "eglwInitCore.inl"
+}
+
+void initExtensions (Functions* dst, const FunctionLoader* loader)
+{
+#include "eglwInitExtensions.inl"
+}
+
+} // eglw
diff --git a/framework/egl/wrapper/eglwFunctions.hpp b/framework/egl/wrapper/eglwFunctions.hpp
new file mode 100644
index 0000000..341b317
--- /dev/null
+++ b/framework/egl/wrapper/eglwFunctions.hpp
@@ -0,0 +1,60 @@
+#ifndef _EGLWFUNCTIONS_HPP
+#define _EGLWFUNCTIONS_HPP
+/*-------------------------------------------------------------------------
+ * drawElements Quality Program EGL Utilities
+ * ------------------------------------------
+ *
+ * Copyright 2014 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ *//*!
+ * \file
+ * \brief EGL API Functions.
+ *//*--------------------------------------------------------------------*/
+
+#include "eglwDefs.hpp"
+
+namespace eglw
+{
+
+// Function typedefs.
+extern "C"
+{
+#include "eglwFunctionTypes.inl"
+}
+
+class Functions
+{
+public:
+	// Function definitions:
+	// eglInitializeFunc	initialize;
+#include "eglwFunctions.inl"
+
+	Functions (void);
+};
+
+typedef EGLW_APICALL void (EGLW_APIENTRY* GenericFuncType) (void);
+
+class FunctionLoader
+{
+public:
+	virtual GenericFuncType		get		(const char* name) const = 0;
+};
+
+void	initCore		(Functions* dst, const FunctionLoader* loader);
+void	initExtensions	(Functions* dst, const FunctionLoader* loader);
+
+} // eglw
+
+#endif // _EGLWFUNCTIONS_HPP
diff --git a/framework/egl/wrapper/eglwFunctions.inl b/framework/egl/wrapper/eglwFunctions.inl
new file mode 100644
index 0000000..9f7ec46
--- /dev/null
+++ b/framework/egl/wrapper/eglwFunctions.inl
@@ -0,0 +1,62 @@
+/* WARNING: This is auto-generated file. Do not modify, since changes will
+ * be lost! Modify the generating script instead.
+ *
+ * Generated from Khronos EGL API description (egl.xml) revision 28861.
+ */
+eglBindAPIFunc							bindAPI;
+eglBindTexImageFunc						bindTexImage;
+eglChooseConfigFunc						chooseConfig;
+eglClientWaitSyncFunc					clientWaitSync;
+eglClientWaitSyncKHRFunc				clientWaitSyncKHR;
+eglCopyBuffersFunc						copyBuffers;
+eglCreateContextFunc					createContext;
+eglCreateImageFunc						createImage;
+eglCreateImageKHRFunc					createImageKHR;
+eglCreatePbufferFromClientBufferFunc	createPbufferFromClientBuffer;
+eglCreatePbufferSurfaceFunc				createPbufferSurface;
+eglCreatePixmapSurfaceFunc				createPixmapSurface;
+eglCreatePlatformPixmapSurfaceFunc		createPlatformPixmapSurface;
+eglCreatePlatformPixmapSurfaceEXTFunc	createPlatformPixmapSurfaceEXT;
+eglCreatePlatformWindowSurfaceFunc		createPlatformWindowSurface;
+eglCreatePlatformWindowSurfaceEXTFunc	createPlatformWindowSurfaceEXT;
+eglCreateSyncFunc						createSync;
+eglCreateSyncKHRFunc					createSyncKHR;
+eglCreateWindowSurfaceFunc				createWindowSurface;
+eglDestroyContextFunc					destroyContext;
+eglDestroyImageFunc						destroyImage;
+eglDestroyImageKHRFunc					destroyImageKHR;
+eglDestroySurfaceFunc					destroySurface;
+eglDestroySyncFunc						destroySync;
+eglDestroySyncKHRFunc					destroySyncKHR;
+eglGetConfigAttribFunc					getConfigAttrib;
+eglGetConfigsFunc						getConfigs;
+eglGetCurrentContextFunc				getCurrentContext;
+eglGetCurrentDisplayFunc				getCurrentDisplay;
+eglGetCurrentSurfaceFunc				getCurrentSurface;
+eglGetDisplayFunc						getDisplay;
+eglGetErrorFunc							getError;
+eglGetPlatformDisplayFunc				getPlatformDisplay;
+eglGetPlatformDisplayEXTFunc			getPlatformDisplayEXT;
+eglGetProcAddressFunc					getProcAddress;
+eglGetSyncAttribFunc					getSyncAttrib;
+eglGetSyncAttribKHRFunc					getSyncAttribKHR;
+eglInitializeFunc						initialize;
+eglLockSurfaceKHRFunc					lockSurfaceKHR;
+eglMakeCurrentFunc						makeCurrent;
+eglQueryAPIFunc							queryAPI;
+eglQueryContextFunc						queryContext;
+eglQueryStringFunc						queryString;
+eglQuerySurfaceFunc						querySurface;
+eglReleaseTexImageFunc					releaseTexImage;
+eglReleaseThreadFunc					releaseThread;
+eglSignalSyncKHRFunc					signalSyncKHR;
+eglSurfaceAttribFunc					surfaceAttrib;
+eglSwapBuffersFunc						swapBuffers;
+eglSwapIntervalFunc						swapInterval;
+eglTerminateFunc						terminate;
+eglUnlockSurfaceKHRFunc					unlockSurfaceKHR;
+eglWaitClientFunc						waitClient;
+eglWaitGLFunc							waitGL;
+eglWaitNativeFunc						waitNative;
+eglWaitSyncFunc							waitSync;
+eglWaitSyncKHRFunc						waitSyncKHR;
diff --git a/framework/egl/wrapper/eglwInitCore.inl b/framework/egl/wrapper/eglwInitCore.inl
new file mode 100644
index 0000000..244b6a7
--- /dev/null
+++ b/framework/egl/wrapper/eglwInitCore.inl
@@ -0,0 +1,49 @@
+/* WARNING: This is auto-generated file. Do not modify, since changes will
+ * be lost! Modify the generating script instead.
+ *
+ * Generated from Khronos EGL API description (egl.xml) revision 28861.
+ */
+dst->bindAPI						= (eglBindAPIFunc)							loader->get("eglBindAPI");
+dst->bindTexImage					= (eglBindTexImageFunc)						loader->get("eglBindTexImage");
+dst->chooseConfig					= (eglChooseConfigFunc)						loader->get("eglChooseConfig");
+dst->clientWaitSync					= (eglClientWaitSyncFunc)					loader->get("eglClientWaitSync");
+dst->copyBuffers					= (eglCopyBuffersFunc)						loader->get("eglCopyBuffers");
+dst->createContext					= (eglCreateContextFunc)					loader->get("eglCreateContext");
+dst->createImage					= (eglCreateImageFunc)						loader->get("eglCreateImage");
+dst->createPbufferFromClientBuffer	= (eglCreatePbufferFromClientBufferFunc)	loader->get("eglCreatePbufferFromClientBuffer");
+dst->createPbufferSurface			= (eglCreatePbufferSurfaceFunc)				loader->get("eglCreatePbufferSurface");
+dst->createPixmapSurface			= (eglCreatePixmapSurfaceFunc)				loader->get("eglCreatePixmapSurface");
+dst->createPlatformPixmapSurface	= (eglCreatePlatformPixmapSurfaceFunc)		loader->get("eglCreatePlatformPixmapSurface");
+dst->createPlatformWindowSurface	= (eglCreatePlatformWindowSurfaceFunc)		loader->get("eglCreatePlatformWindowSurface");
+dst->createSync						= (eglCreateSyncFunc)						loader->get("eglCreateSync");
+dst->createWindowSurface			= (eglCreateWindowSurfaceFunc)				loader->get("eglCreateWindowSurface");
+dst->destroyContext					= (eglDestroyContextFunc)					loader->get("eglDestroyContext");
+dst->destroyImage					= (eglDestroyImageFunc)						loader->get("eglDestroyImage");
+dst->destroySurface					= (eglDestroySurfaceFunc)					loader->get("eglDestroySurface");
+dst->destroySync					= (eglDestroySyncFunc)						loader->get("eglDestroySync");
+dst->getConfigAttrib				= (eglGetConfigAttribFunc)					loader->get("eglGetConfigAttrib");
+dst->getConfigs						= (eglGetConfigsFunc)						loader->get("eglGetConfigs");
+dst->getCurrentContext				= (eglGetCurrentContextFunc)				loader->get("eglGetCurrentContext");
+dst->getCurrentDisplay				= (eglGetCurrentDisplayFunc)				loader->get("eglGetCurrentDisplay");
+dst->getCurrentSurface				= (eglGetCurrentSurfaceFunc)				loader->get("eglGetCurrentSurface");
+dst->getDisplay						= (eglGetDisplayFunc)						loader->get("eglGetDisplay");
+dst->getError						= (eglGetErrorFunc)							loader->get("eglGetError");
+dst->getPlatformDisplay				= (eglGetPlatformDisplayFunc)				loader->get("eglGetPlatformDisplay");
+dst->getProcAddress					= (eglGetProcAddressFunc)					loader->get("eglGetProcAddress");
+dst->getSyncAttrib					= (eglGetSyncAttribFunc)					loader->get("eglGetSyncAttrib");
+dst->initialize						= (eglInitializeFunc)						loader->get("eglInitialize");
+dst->makeCurrent					= (eglMakeCurrentFunc)						loader->get("eglMakeCurrent");
+dst->queryAPI						= (eglQueryAPIFunc)							loader->get("eglQueryAPI");
+dst->queryContext					= (eglQueryContextFunc)						loader->get("eglQueryContext");
+dst->queryString					= (eglQueryStringFunc)						loader->get("eglQueryString");
+dst->querySurface					= (eglQuerySurfaceFunc)						loader->get("eglQuerySurface");
+dst->releaseTexImage				= (eglReleaseTexImageFunc)					loader->get("eglReleaseTexImage");
+dst->releaseThread					= (eglReleaseThreadFunc)					loader->get("eglReleaseThread");
+dst->surfaceAttrib					= (eglSurfaceAttribFunc)					loader->get("eglSurfaceAttrib");
+dst->swapBuffers					= (eglSwapBuffersFunc)						loader->get("eglSwapBuffers");
+dst->swapInterval					= (eglSwapIntervalFunc)						loader->get("eglSwapInterval");
+dst->terminate						= (eglTerminateFunc)						loader->get("eglTerminate");
+dst->waitClient						= (eglWaitClientFunc)						loader->get("eglWaitClient");
+dst->waitGL							= (eglWaitGLFunc)							loader->get("eglWaitGL");
+dst->waitNative						= (eglWaitNativeFunc)						loader->get("eglWaitNative");
+dst->waitSync						= (eglWaitSyncFunc)							loader->get("eglWaitSync");
diff --git a/framework/egl/wrapper/eglwInitExtensions.inl b/framework/egl/wrapper/eglwInitExtensions.inl
new file mode 100644
index 0000000..eba506d
--- /dev/null
+++ b/framework/egl/wrapper/eglwInitExtensions.inl
@@ -0,0 +1,18 @@
+/* WARNING: This is auto-generated file. Do not modify, since changes will
+ * be lost! Modify the generating script instead.
+ *
+ * Generated from Khronos EGL API description (egl.xml) revision 28861.
+ */
+dst->clientWaitSyncKHR				= (eglClientWaitSyncKHRFunc)				loader->get("eglClientWaitSyncKHR");
+dst->createImageKHR					= (eglCreateImageKHRFunc)					loader->get("eglCreateImageKHR");
+dst->createPlatformPixmapSurfaceEXT	= (eglCreatePlatformPixmapSurfaceEXTFunc)	loader->get("eglCreatePlatformPixmapSurfaceEXT");
+dst->createPlatformWindowSurfaceEXT	= (eglCreatePlatformWindowSurfaceEXTFunc)	loader->get("eglCreatePlatformWindowSurfaceEXT");
+dst->createSyncKHR					= (eglCreateSyncKHRFunc)					loader->get("eglCreateSyncKHR");
+dst->destroyImageKHR				= (eglDestroyImageKHRFunc)					loader->get("eglDestroyImageKHR");
+dst->destroySyncKHR					= (eglDestroySyncKHRFunc)					loader->get("eglDestroySyncKHR");
+dst->getPlatformDisplayEXT			= (eglGetPlatformDisplayEXTFunc)			loader->get("eglGetPlatformDisplayEXT");
+dst->getSyncAttribKHR				= (eglGetSyncAttribKHRFunc)					loader->get("eglGetSyncAttribKHR");
+dst->lockSurfaceKHR					= (eglLockSurfaceKHRFunc)					loader->get("eglLockSurfaceKHR");
+dst->signalSyncKHR					= (eglSignalSyncKHRFunc)					loader->get("eglSignalSyncKHR");
+dst->unlockSurfaceKHR				= (eglUnlockSurfaceKHRFunc)					loader->get("eglUnlockSurfaceKHR");
+dst->waitSyncKHR					= (eglWaitSyncKHRFunc)						loader->get("eglWaitSyncKHR");
diff --git a/framework/egl/wrapper/eglwLibrary.cpp b/framework/egl/wrapper/eglwLibrary.cpp
new file mode 100644
index 0000000..fba4402
--- /dev/null
+++ b/framework/egl/wrapper/eglwLibrary.cpp
@@ -0,0 +1,159 @@
+/*-------------------------------------------------------------------------
+ * drawElements Quality Program EGL Utilities
+ * ------------------------------------------
+ *
+ * Copyright 2014 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ *//*!
+ * \file
+ * \brief EGL API Library.
+ *//*--------------------------------------------------------------------*/
+
+#include "eglwLibrary.hpp"
+#include "tcuFunctionLibrary.hpp"
+#include "deDynamicLibrary.hpp"
+
+#if defined(DEQP_SUPPORT_EGL) && !defined(DEQP_EGL_RUNTIME_LOAD)
+#	include <EGL/egl.h>
+#endif
+
+namespace eglw
+{
+
+FuncPtrLibrary::FuncPtrLibrary (void)
+{
+}
+
+FuncPtrLibrary::~FuncPtrLibrary (void)
+{
+}
+
+#include "eglwFuncPtrLibraryImpl.inl"
+
+namespace
+{
+
+tcu::FunctionLibrary* createStaticLibrary (void)
+{
+#if defined(DEQP_SUPPORT_EGL) && !defined(DEQP_EGL_RUNTIME_LOAD)
+	static tcu::StaticFunctionLibrary::Entry s_staticEntries[] =
+	{
+#	if defined(EGL_VERSION_1_5)
+#		include "eglwStaticLibrary15.inl"
+#	elif defined(EGL_VERSION_1_4)
+#		include "eglwStaticLibrary14.inl"
+#	endif
+	};
+	return new tcu::StaticFunctionLibrary(s_staticEntries, DE_LENGTH_OF_ARRAY(s_staticEntries));
+#else
+	return new tcu::StaticFunctionLibrary(DE_NULL, 0);
+#endif
+}
+
+class CoreLoader : public FunctionLoader
+{
+public:
+	CoreLoader (const de::DynamicLibrary* dynLib)
+		: m_staticLib		(createStaticLibrary())
+		, m_dynLib			(dynLib)
+		, m_getProcAddress	(DE_NULL)
+	{
+		// Try to obtain eglGetProcAddress
+		m_getProcAddress = (eglGetProcAddressFunc)m_staticLib->getFunction("eglGetProcAddress");
+
+		if (!m_getProcAddress && m_dynLib)
+			m_getProcAddress = (eglGetProcAddressFunc)m_dynLib->getFunction("eglGetProcAddress");
+	}
+
+	~CoreLoader (void)
+	{
+		delete m_staticLib;
+	}
+
+	GenericFuncType get (const char* name) const
+	{
+		GenericFuncType res = (GenericFuncType)DE_NULL;
+
+		res = (GenericFuncType)m_staticLib->getFunction(name);
+
+		if (!res && m_dynLib)
+			res = (GenericFuncType)m_dynLib->getFunction(name);
+
+		if (!res && m_getProcAddress)
+			res = (GenericFuncType)m_getProcAddress(name);
+
+		return res;
+	}
+
+protected:
+	tcu::FunctionLibrary* const		m_staticLib;
+	const de::DynamicLibrary*		m_dynLib;
+	eglGetProcAddressFunc			m_getProcAddress;
+};
+
+class ExtLoader : public FunctionLoader
+{
+public:
+	ExtLoader (const eglGetProcAddressFunc getProcAddress)
+		: m_getProcAddress(getProcAddress)
+	{
+	}
+
+	GenericFuncType get (const char* name) const
+	{
+		return (GenericFuncType)m_getProcAddress(name);
+	}
+
+protected:
+	const eglGetProcAddressFunc			m_getProcAddress;
+};
+
+} // anonymous
+
+DefaultLibrary::DefaultLibrary (const char* dynamicLibraryName)
+	: m_dynLib(DE_NULL)
+{
+	if (dynamicLibraryName)
+		m_dynLib = new de::DynamicLibrary(dynamicLibraryName);
+
+	{
+		const CoreLoader loader(m_dynLib);
+		initCore(&m_egl, &loader);
+	}
+
+	if (m_egl.getProcAddress)
+	{
+		const ExtLoader loader(m_egl.getProcAddress);
+		initExtensions(&m_egl, &loader);
+	}
+}
+
+DefaultLibrary::~DefaultLibrary (void)
+{
+	delete m_dynLib;
+}
+
+const char* DefaultLibrary::getLibraryFileName (void)
+{
+#if (DE_OS == DE_OS_ANDROID) || (DE_OS == DE_OS_UNIX)
+	return "libEGL.so";
+#elif (DE_OS == DE_OS_WIN32)
+	return "libEGL.dll";
+#else
+	return DE_NULL;
+#endif
+}
+
+} // eglw
diff --git a/framework/egl/wrapper/eglwLibrary.hpp b/framework/egl/wrapper/eglwLibrary.hpp
new file mode 100644
index 0000000..d3d8fef
--- /dev/null
+++ b/framework/egl/wrapper/eglwLibrary.hpp
@@ -0,0 +1,71 @@
+#ifndef _EGLWLIBRARY_HPP
+#define _EGLWLIBRARY_HPP
+/*-------------------------------------------------------------------------
+ * drawElements Quality Program EGL Utilities
+ * ------------------------------------------
+ *
+ * Copyright 2014 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ *//*!
+ * \file
+ * \brief EGL API Library.
+ *//*--------------------------------------------------------------------*/
+
+#include "eglwDefs.hpp"
+#include "eglwFunctions.hpp"
+
+namespace de
+{
+class DynamicLibrary;
+}
+
+namespace eglw
+{
+
+class Library
+{
+public:
+	// Entry points:
+	// virtual EGLBoolean		initialize	(EGLDisplay ...) const = 0;
+#include "eglwLibrary.inl"
+};
+
+class FuncPtrLibrary : public Library
+{
+public:
+				FuncPtrLibrary		(void);
+				~FuncPtrLibrary		(void);
+
+#include "eglwFuncPtrLibraryDecl.inl"
+
+protected:
+	Functions	m_egl;
+};
+
+class DefaultLibrary : public FuncPtrLibrary
+{
+public:
+						DefaultLibrary		(const char* dynamicLibraryName = getLibraryFileName());
+						~DefaultLibrary		(void);
+
+	static const char*	getLibraryFileName	(void);
+
+protected:
+	de::DynamicLibrary*	m_dynLib;
+};
+
+} // eglw
+
+#endif // _EGLWLIBRARY_HPP
diff --git a/framework/egl/wrapper/eglwLibrary.inl b/framework/egl/wrapper/eglwLibrary.inl
new file mode 100644
index 0000000..5f50513
--- /dev/null
+++ b/framework/egl/wrapper/eglwLibrary.inl
@@ -0,0 +1,62 @@
+/* WARNING: This is auto-generated file. Do not modify, since changes will
+ * be lost! Modify the generating script instead.
+ *
+ * Generated from Khronos EGL API description (egl.xml) revision 28861.
+ */
+virtual EGLBoolean									bindAPI							(EGLenum api) const																								= 0;
+virtual EGLBoolean									bindTexImage					(EGLDisplay dpy, EGLSurface surface, EGLint buffer) const														= 0;
+virtual EGLBoolean									chooseConfig					(EGLDisplay dpy, const EGLint *attrib_list, EGLConfig *configs, EGLint config_size, EGLint *num_config) const	= 0;
+virtual EGLint										clientWaitSync					(EGLDisplay dpy, EGLSync sync, EGLint flags, EGLTime timeout) const												= 0;
+virtual EGLint										clientWaitSyncKHR				(EGLDisplay dpy, EGLSyncKHR sync, EGLint flags, EGLTimeKHR timeout) const										= 0;
+virtual EGLBoolean									copyBuffers						(EGLDisplay dpy, EGLSurface surface, EGLNativePixmapType target) const											= 0;
+virtual EGLContext									createContext					(EGLDisplay dpy, EGLConfig config, EGLContext share_context, const EGLint *attrib_list) const					= 0;
+virtual EGLImage									createImage						(EGLDisplay dpy, EGLContext ctx, EGLenum target, EGLClientBuffer buffer, const EGLint *attrib_list) const		= 0;
+virtual EGLImageKHR									createImageKHR					(EGLDisplay dpy, EGLContext ctx, EGLenum target, EGLClientBuffer buffer, const EGLint *attrib_list) const		= 0;
+virtual EGLSurface									createPbufferFromClientBuffer	(EGLDisplay dpy, EGLenum buftype, EGLClientBuffer buffer, EGLConfig config, const EGLint *attrib_list) const	= 0;
+virtual EGLSurface									createPbufferSurface			(EGLDisplay dpy, EGLConfig config, const EGLint *attrib_list) const												= 0;
+virtual EGLSurface									createPixmapSurface				(EGLDisplay dpy, EGLConfig config, EGLNativePixmapType pixmap, const EGLint *attrib_list) const					= 0;
+virtual EGLSurface									createPlatformPixmapSurface		(EGLDisplay dpy, EGLConfig config, void *native_pixmap, const EGLAttrib *attrib_list) const						= 0;
+virtual EGLSurface									createPlatformPixmapSurfaceEXT	(EGLDisplay dpy, EGLConfig config, void *native_pixmap, const EGLint *attrib_list) const						= 0;
+virtual EGLSurface									createPlatformWindowSurface		(EGLDisplay dpy, EGLConfig config, void *native_window, const EGLAttrib *attrib_list) const						= 0;
+virtual EGLSurface									createPlatformWindowSurfaceEXT	(EGLDisplay dpy, EGLConfig config, void *native_window, const EGLint *attrib_list) const						= 0;
+virtual EGLSync										createSync						(EGLDisplay dpy, EGLenum type, const EGLAttrib *attrib_list) const												= 0;
+virtual EGLSyncKHR									createSyncKHR					(EGLDisplay dpy, EGLenum type, const EGLint *attrib_list) const													= 0;
+virtual EGLSurface									createWindowSurface				(EGLDisplay dpy, EGLConfig config, EGLNativeWindowType win, const EGLint *attrib_list) const					= 0;
+virtual EGLBoolean									destroyContext					(EGLDisplay dpy, EGLContext ctx) const																			= 0;
+virtual EGLBoolean									destroyImage					(EGLDisplay dpy, EGLImage image) const																			= 0;
+virtual EGLBoolean									destroyImageKHR					(EGLDisplay dpy, EGLImageKHR image) const																		= 0;
+virtual EGLBoolean									destroySurface					(EGLDisplay dpy, EGLSurface surface) const																		= 0;
+virtual EGLBoolean									destroySync						(EGLDisplay dpy, EGLSync sync) const																			= 0;
+virtual EGLBoolean									destroySyncKHR					(EGLDisplay dpy, EGLSyncKHR sync) const																			= 0;
+virtual EGLBoolean									getConfigAttrib					(EGLDisplay dpy, EGLConfig config, EGLint attribute, EGLint *value) const										= 0;
+virtual EGLBoolean									getConfigs						(EGLDisplay dpy, EGLConfig *configs, EGLint config_size, EGLint *num_config) const								= 0;
+virtual EGLContext									getCurrentContext				(void) const																									= 0;
+virtual EGLDisplay									getCurrentDisplay				(void) const																									= 0;
+virtual EGLSurface									getCurrentSurface				(EGLint readdraw) const																							= 0;
+virtual EGLDisplay									getDisplay						(EGLNativeDisplayType display_id) const																			= 0;
+virtual EGLint										getError						(void) const																									= 0;
+virtual EGLDisplay									getPlatformDisplay				(EGLenum platform, void *native_display, const EGLAttrib *attrib_list) const									= 0;
+virtual EGLDisplay									getPlatformDisplayEXT			(EGLenum platform, void *native_display, const EGLint *attrib_list) const										= 0;
+virtual __eglMustCastToProperFunctionPointerType	getProcAddress					(const char *procname) const																					= 0;
+virtual EGLBoolean									getSyncAttrib					(EGLDisplay dpy, EGLSync sync, EGLint attribute, EGLAttrib *value) const										= 0;
+virtual EGLBoolean									getSyncAttribKHR				(EGLDisplay dpy, EGLSyncKHR sync, EGLint attribute, EGLint *value) const										= 0;
+virtual EGLBoolean									initialize						(EGLDisplay dpy, EGLint *major, EGLint *minor) const															= 0;
+virtual EGLBoolean									lockSurfaceKHR					(EGLDisplay dpy, EGLSurface surface, const EGLint *attrib_list) const											= 0;
+virtual EGLBoolean									makeCurrent						(EGLDisplay dpy, EGLSurface draw, EGLSurface read, EGLContext ctx) const										= 0;
+virtual EGLenum										queryAPI						(void) const																									= 0;
+virtual EGLBoolean									queryContext					(EGLDisplay dpy, EGLContext ctx, EGLint attribute, EGLint *value) const											= 0;
+virtual const char *								queryString						(EGLDisplay dpy, EGLint name) const																				= 0;
+virtual EGLBoolean									querySurface					(EGLDisplay dpy, EGLSurface surface, EGLint attribute, EGLint *value) const										= 0;
+virtual EGLBoolean									releaseTexImage					(EGLDisplay dpy, EGLSurface surface, EGLint buffer) const														= 0;
+virtual EGLBoolean									releaseThread					(void) const																									= 0;
+virtual EGLBoolean									signalSyncKHR					(EGLDisplay dpy, EGLSyncKHR sync, EGLenum mode) const															= 0;
+virtual EGLBoolean									surfaceAttrib					(EGLDisplay dpy, EGLSurface surface, EGLint attribute, EGLint value) const										= 0;
+virtual EGLBoolean									swapBuffers						(EGLDisplay dpy, EGLSurface surface) const																		= 0;
+virtual EGLBoolean									swapInterval					(EGLDisplay dpy, EGLint interval) const																			= 0;
+virtual EGLBoolean									terminate						(EGLDisplay dpy) const																							= 0;
+virtual EGLBoolean									unlockSurfaceKHR				(EGLDisplay dpy, EGLSurface surface) const																		= 0;
+virtual EGLBoolean									waitClient						(void) const																									= 0;
+virtual EGLBoolean									waitGL							(void) const																									= 0;
+virtual EGLBoolean									waitNative						(EGLint engine) const																							= 0;
+virtual EGLBoolean									waitSync						(EGLDisplay dpy, EGLSync sync, EGLint flags) const																= 0;
+virtual EGLint										waitSyncKHR						(EGLDisplay dpy, EGLSyncKHR sync, EGLint flags) const															= 0;
diff --git a/framework/egl/wrapper/eglwStaticLibrary14.inl b/framework/egl/wrapper/eglwStaticLibrary14.inl
new file mode 100644
index 0000000..8dbce58
--- /dev/null
+++ b/framework/egl/wrapper/eglwStaticLibrary14.inl
@@ -0,0 +1,39 @@
+/* WARNING: This is auto-generated file. Do not modify, since changes will
+ * be lost! Modify the generating script instead.
+ *
+ * Generated from Khronos EGL API description (egl.xml) revision 28861.
+ */
+	{ "eglBindAPI",							(deFunctionPtr)eglBindAPI },
+	{ "eglBindTexImage",					(deFunctionPtr)eglBindTexImage },
+	{ "eglChooseConfig",					(deFunctionPtr)eglChooseConfig },
+	{ "eglCopyBuffers",						(deFunctionPtr)eglCopyBuffers },
+	{ "eglCreateContext",					(deFunctionPtr)eglCreateContext },
+	{ "eglCreatePbufferFromClientBuffer",	(deFunctionPtr)eglCreatePbufferFromClientBuffer },
+	{ "eglCreatePbufferSurface",			(deFunctionPtr)eglCreatePbufferSurface },
+	{ "eglCreatePixmapSurface",				(deFunctionPtr)eglCreatePixmapSurface },
+	{ "eglCreateWindowSurface",				(deFunctionPtr)eglCreateWindowSurface },
+	{ "eglDestroyContext",					(deFunctionPtr)eglDestroyContext },
+	{ "eglDestroySurface",					(deFunctionPtr)eglDestroySurface },
+	{ "eglGetConfigAttrib",					(deFunctionPtr)eglGetConfigAttrib },
+	{ "eglGetConfigs",						(deFunctionPtr)eglGetConfigs },
+	{ "eglGetCurrentContext",				(deFunctionPtr)eglGetCurrentContext },
+	{ "eglGetCurrentDisplay",				(deFunctionPtr)eglGetCurrentDisplay },
+	{ "eglGetCurrentSurface",				(deFunctionPtr)eglGetCurrentSurface },
+	{ "eglGetDisplay",						(deFunctionPtr)eglGetDisplay },
+	{ "eglGetError",						(deFunctionPtr)eglGetError },
+	{ "eglGetProcAddress",					(deFunctionPtr)eglGetProcAddress },
+	{ "eglInitialize",						(deFunctionPtr)eglInitialize },
+	{ "eglMakeCurrent",						(deFunctionPtr)eglMakeCurrent },
+	{ "eglQueryAPI",						(deFunctionPtr)eglQueryAPI },
+	{ "eglQueryContext",					(deFunctionPtr)eglQueryContext },
+	{ "eglQueryString",						(deFunctionPtr)eglQueryString },
+	{ "eglQuerySurface",					(deFunctionPtr)eglQuerySurface },
+	{ "eglReleaseTexImage",					(deFunctionPtr)eglReleaseTexImage },
+	{ "eglReleaseThread",					(deFunctionPtr)eglReleaseThread },
+	{ "eglSurfaceAttrib",					(deFunctionPtr)eglSurfaceAttrib },
+	{ "eglSwapBuffers",						(deFunctionPtr)eglSwapBuffers },
+	{ "eglSwapInterval",					(deFunctionPtr)eglSwapInterval },
+	{ "eglTerminate",						(deFunctionPtr)eglTerminate },
+	{ "eglWaitClient",						(deFunctionPtr)eglWaitClient },
+	{ "eglWaitGL",							(deFunctionPtr)eglWaitGL },
+	{ "eglWaitNative",						(deFunctionPtr)eglWaitNative },
diff --git a/framework/egl/wrapper/eglwStaticLibrary15.inl b/framework/egl/wrapper/eglwStaticLibrary15.inl
new file mode 100644
index 0000000..0701ad1
--- /dev/null
+++ b/framework/egl/wrapper/eglwStaticLibrary15.inl
@@ -0,0 +1,49 @@
+/* WARNING: This is auto-generated file. Do not modify, since changes will
+ * be lost! Modify the generating script instead.
+ *
+ * Generated from Khronos EGL API description (egl.xml) revision 28861.
+ */
+	{ "eglBindAPI",							(deFunctionPtr)eglBindAPI },
+	{ "eglBindTexImage",					(deFunctionPtr)eglBindTexImage },
+	{ "eglChooseConfig",					(deFunctionPtr)eglChooseConfig },
+	{ "eglClientWaitSync",					(deFunctionPtr)eglClientWaitSync },
+	{ "eglCopyBuffers",						(deFunctionPtr)eglCopyBuffers },
+	{ "eglCreateContext",					(deFunctionPtr)eglCreateContext },
+	{ "eglCreateImage",						(deFunctionPtr)eglCreateImage },
+	{ "eglCreatePbufferFromClientBuffer",	(deFunctionPtr)eglCreatePbufferFromClientBuffer },
+	{ "eglCreatePbufferSurface",			(deFunctionPtr)eglCreatePbufferSurface },
+	{ "eglCreatePixmapSurface",				(deFunctionPtr)eglCreatePixmapSurface },
+	{ "eglCreatePlatformPixmapSurface",		(deFunctionPtr)eglCreatePlatformPixmapSurface },
+	{ "eglCreatePlatformWindowSurface",		(deFunctionPtr)eglCreatePlatformWindowSurface },
+	{ "eglCreateSync",						(deFunctionPtr)eglCreateSync },
+	{ "eglCreateWindowSurface",				(deFunctionPtr)eglCreateWindowSurface },
+	{ "eglDestroyContext",					(deFunctionPtr)eglDestroyContext },
+	{ "eglDestroyImage",					(deFunctionPtr)eglDestroyImage },
+	{ "eglDestroySurface",					(deFunctionPtr)eglDestroySurface },
+	{ "eglDestroySync",						(deFunctionPtr)eglDestroySync },
+	{ "eglGetConfigAttrib",					(deFunctionPtr)eglGetConfigAttrib },
+	{ "eglGetConfigs",						(deFunctionPtr)eglGetConfigs },
+	{ "eglGetCurrentContext",				(deFunctionPtr)eglGetCurrentContext },
+	{ "eglGetCurrentDisplay",				(deFunctionPtr)eglGetCurrentDisplay },
+	{ "eglGetCurrentSurface",				(deFunctionPtr)eglGetCurrentSurface },
+	{ "eglGetDisplay",						(deFunctionPtr)eglGetDisplay },
+	{ "eglGetError",						(deFunctionPtr)eglGetError },
+	{ "eglGetPlatformDisplay",				(deFunctionPtr)eglGetPlatformDisplay },
+	{ "eglGetProcAddress",					(deFunctionPtr)eglGetProcAddress },
+	{ "eglGetSyncAttrib",					(deFunctionPtr)eglGetSyncAttrib },
+	{ "eglInitialize",						(deFunctionPtr)eglInitialize },
+	{ "eglMakeCurrent",						(deFunctionPtr)eglMakeCurrent },
+	{ "eglQueryAPI",						(deFunctionPtr)eglQueryAPI },
+	{ "eglQueryContext",					(deFunctionPtr)eglQueryContext },
+	{ "eglQueryString",						(deFunctionPtr)eglQueryString },
+	{ "eglQuerySurface",					(deFunctionPtr)eglQuerySurface },
+	{ "eglReleaseTexImage",					(deFunctionPtr)eglReleaseTexImage },
+	{ "eglReleaseThread",					(deFunctionPtr)eglReleaseThread },
+	{ "eglSurfaceAttrib",					(deFunctionPtr)eglSurfaceAttrib },
+	{ "eglSwapBuffers",						(deFunctionPtr)eglSwapBuffers },
+	{ "eglSwapInterval",					(deFunctionPtr)eglSwapInterval },
+	{ "eglTerminate",						(deFunctionPtr)eglTerminate },
+	{ "eglWaitClient",						(deFunctionPtr)eglWaitClient },
+	{ "eglWaitGL",							(deFunctionPtr)eglWaitGL },
+	{ "eglWaitNative",						(deFunctionPtr)eglWaitNative },
+	{ "eglWaitSync",						(deFunctionPtr)eglWaitSync },
diff --git a/framework/egl/wrapper/eglwTypes.inl b/framework/egl/wrapper/eglwTypes.inl
new file mode 100644
index 0000000..bc1015b
--- /dev/null
+++ b/framework/egl/wrapper/eglwTypes.inl
@@ -0,0 +1,67 @@
+/*-------------------------------------------------------------------------
+ * drawElements Quality Program EGL Utilities
+ * ------------------------------------------
+ *
+ * Copyright 2014 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ *//*!
+ * \file
+ * \brief EGL wrapper base types.
+ *
+ * \note Unlike most .inl files this one is NOT auto-generated. This is .inl
+ *		 because it is included from both glwDefs.hpp (inside glw namespace)
+ *		 and glw.h (in root namespace, as C source).
+ *//*--------------------------------------------------------------------*/
+
+/* Calling convention. */
+#if (DE_OS == DE_OS_ANDROID)
+#	include <sys/cdefs.h>
+#	if !defined(__NDK_FPABI__)
+#		define __NDK_FPABI__
+#	endif
+#	define EGLW_APICALL __NDK_FPABI__
+#else
+#	define EGLW_APICALL
+#endif
+
+#if (DE_OS == DE_OS_WIN32)
+#	define EGLW_APIENTRY __stdcall
+#else
+#	define EGLW_APIENTRY
+#endif
+
+typedef deInt32		EGLint;
+typedef deUint32	EGLenum;
+typedef deUint32	EGLBoolean;
+typedef deIntptr	EGLAttrib;
+typedef deUint64	EGLTime;
+
+typedef void*		EGLDisplay;
+typedef void*		EGLConfig;
+typedef void*		EGLSurface;
+typedef void*		EGLContext;
+typedef void*		EGLImage;
+typedef void*		EGLClientBuffer;
+typedef void*		EGLSync;
+
+typedef void*		EGLNativeDisplayType;
+typedef void*		EGLNativeWindowType;
+typedef void*		EGLNativePixmapType;
+
+typedef void (*__eglMustCastToProperFunctionPointerType) (void);
+
+typedef EGLImage	EGLImageKHR;
+typedef EGLSync		EGLSyncKHR;
+typedef EGLTime		EGLTimeKHR;
diff --git a/framework/opengl/gluCallLogWrapper.inl b/framework/opengl/gluCallLogWrapper.inl
index dc26637..9f46b49 100644
--- a/framework/opengl/gluCallLogWrapper.inl
+++ b/framework/opengl/gluCallLogWrapper.inl
@@ -1,7 +1,7 @@
 /* WARNING: This is auto-generated file. Do not modify, since changes will
  * be lost! Modify the generating script instead.
  *
- * Generated from Khronos GL API description (gl.xml) revision 28861.
+ * Generated from Khronos GL API description (gl.xml) revision 29570.
  */
 
 void CallLogWrapper::glActiveShaderProgram (glw::GLuint pipeline, glw::GLuint program)
@@ -416,7 +416,7 @@
 	m_gl.clearNamedBufferData(buffer, internalformat, format, type, data);
 }
 
-void CallLogWrapper::glClearNamedBufferSubData (glw::GLuint buffer, glw::GLenum internalformat, glw::GLintptr offset, glw::GLsizei size, glw::GLenum format, glw::GLenum type, const void *data)
+void CallLogWrapper::glClearNamedBufferSubData (glw::GLuint buffer, glw::GLenum internalformat, glw::GLintptr offset, glw::GLsizeiptr size, glw::GLenum format, glw::GLenum type, const void *data)
 {
 	if (m_enableLog)
 		m_log << TestLog::Message << "glClearNamedBufferSubData(" << buffer << ", " << toHex(internalformat) << ", " << offset << ", " << size << ", " << toHex(format) << ", " << toHex(type) << ", " << data << ");" << TestLog::EndMessage;
@@ -587,7 +587,7 @@
 	m_gl.copyImageSubData(srcName, srcTarget, srcLevel, srcX, srcY, srcZ, dstName, dstTarget, dstLevel, dstX, dstY, dstZ, srcWidth, srcHeight, srcDepth);
 }
 
-void CallLogWrapper::glCopyNamedBufferSubData (glw::GLuint readBuffer, glw::GLuint writeBuffer, glw::GLintptr readOffset, glw::GLintptr writeOffset, glw::GLsizei size)
+void CallLogWrapper::glCopyNamedBufferSubData (glw::GLuint readBuffer, glw::GLuint writeBuffer, glw::GLintptr readOffset, glw::GLintptr writeOffset, glw::GLsizeiptr size)
 {
 	if (m_enableLog)
 		m_log << TestLog::Message << "glCopyNamedBufferSubData(" << readBuffer << ", " << writeBuffer << ", " << readOffset << ", " << writeOffset << ", " << size << ");" << TestLog::EndMessage;
@@ -1180,7 +1180,7 @@
 	m_gl.flushMappedBufferRange(target, offset, length);
 }
 
-void CallLogWrapper::glFlushMappedNamedBufferRange (glw::GLuint buffer, glw::GLintptr offset, glw::GLsizei length)
+void CallLogWrapper::glFlushMappedNamedBufferRange (glw::GLuint buffer, glw::GLintptr offset, glw::GLsizeiptr length)
 {
 	if (m_enableLog)
 		m_log << TestLog::Message << "glFlushMappedNamedBufferRange(" << buffer << ", " << offset << ", " << length << ");" << TestLog::EndMessage;
@@ -1699,7 +1699,7 @@
 	m_gl.getNamedBufferPointerv(buffer, pname, params);
 }
 
-void CallLogWrapper::glGetNamedBufferSubData (glw::GLuint buffer, glw::GLintptr offset, glw::GLsizei size, void *data)
+void CallLogWrapper::glGetNamedBufferSubData (glw::GLuint buffer, glw::GLintptr offset, glw::GLsizeiptr size, void *data)
 {
 	if (m_enableLog)
 		m_log << TestLog::Message << "glGetNamedBufferSubData(" << buffer << ", " << offset << ", " << size << ", " << data << ");" << TestLog::EndMessage;
@@ -2634,7 +2634,7 @@
 	return returnValue;
 }
 
-void * CallLogWrapper::glMapNamedBufferRange (glw::GLuint buffer, glw::GLintptr offset, glw::GLsizei length, glw::GLbitfield access)
+void * CallLogWrapper::glMapNamedBufferRange (glw::GLuint buffer, glw::GLintptr offset, glw::GLsizeiptr length, glw::GLbitfield access)
 {
 	if (m_enableLog)
 		m_log << TestLog::Message << "glMapNamedBufferRange(" << buffer << ", " << offset << ", " << length << ", " << toHex(access) << ");" << TestLog::EndMessage;
@@ -2700,21 +2700,21 @@
 	m_gl.multiDrawElementsIndirect(mode, type, indirect, drawcount, stride);
 }
 
-void CallLogWrapper::glNamedBufferData (glw::GLuint buffer, glw::GLsizei size, const void *data, glw::GLenum usage)
+void CallLogWrapper::glNamedBufferData (glw::GLuint buffer, glw::GLsizeiptr size, const void *data, glw::GLenum usage)
 {
 	if (m_enableLog)
 		m_log << TestLog::Message << "glNamedBufferData(" << buffer << ", " << size << ", " << data << ", " << toHex(usage) << ");" << TestLog::EndMessage;
 	m_gl.namedBufferData(buffer, size, data, usage);
 }
 
-void CallLogWrapper::glNamedBufferStorage (glw::GLuint buffer, glw::GLsizei size, const void *data, glw::GLbitfield flags)
+void CallLogWrapper::glNamedBufferStorage (glw::GLuint buffer, glw::GLsizeiptr size, const void *data, glw::GLbitfield flags)
 {
 	if (m_enableLog)
 		m_log << TestLog::Message << "glNamedBufferStorage(" << buffer << ", " << size << ", " << data << ", " << toHex(flags) << ");" << TestLog::EndMessage;
 	m_gl.namedBufferStorage(buffer, size, data, flags);
 }
 
-void CallLogWrapper::glNamedBufferSubData (glw::GLuint buffer, glw::GLintptr offset, glw::GLsizei size, const void *data)
+void CallLogWrapper::glNamedBufferSubData (glw::GLuint buffer, glw::GLintptr offset, glw::GLsizeiptr size, const void *data)
 {
 	if (m_enableLog)
 		m_log << TestLog::Message << "glNamedBufferSubData(" << buffer << ", " << offset << ", " << size << ", " << data << ");" << TestLog::EndMessage;
@@ -3645,7 +3645,7 @@
 	m_gl.textureBuffer(texture, internalformat, buffer);
 }
 
-void CallLogWrapper::glTextureBufferRange (glw::GLuint texture, glw::GLenum internalformat, glw::GLuint buffer, glw::GLintptr offset, glw::GLsizei size)
+void CallLogWrapper::glTextureBufferRange (glw::GLuint texture, glw::GLenum internalformat, glw::GLuint buffer, glw::GLintptr offset, glw::GLsizeiptr size)
 {
 	if (m_enableLog)
 		m_log << TestLog::Message << "glTextureBufferRange(" << texture << ", " << toHex(internalformat) << ", " << buffer << ", " << offset << ", " << size << ");" << TestLog::EndMessage;
@@ -3764,7 +3764,7 @@
 	m_gl.transformFeedbackBufferBase(xfb, index, buffer);
 }
 
-void CallLogWrapper::glTransformFeedbackBufferRange (glw::GLuint xfb, glw::GLuint index, glw::GLuint buffer, glw::GLintptr offset, glw::GLsizei size)
+void CallLogWrapper::glTransformFeedbackBufferRange (glw::GLuint xfb, glw::GLuint index, glw::GLuint buffer, glw::GLintptr offset, glw::GLsizeiptr size)
 {
 	if (m_enableLog)
 		m_log << TestLog::Message << "glTransformFeedbackBufferRange(" << xfb << ", " << index << ", " << buffer << ", " << offset << ", " << size << ");" << TestLog::EndMessage;
diff --git a/framework/opengl/gluCallLogWrapperApi.inl b/framework/opengl/gluCallLogWrapperApi.inl
index 66b2114..3d13744 100644
--- a/framework/opengl/gluCallLogWrapperApi.inl
+++ b/framework/opengl/gluCallLogWrapperApi.inl
@@ -1,7 +1,7 @@
 /* WARNING: This is auto-generated file. Do not modify, since changes will
  * be lost! Modify the generating script instead.
  *
- * Generated from Khronos GL API description (gl.xml) revision 28861.
+ * Generated from Khronos GL API description (gl.xml) revision 29570.
  */
 void					glActiveShaderProgram							(glw::GLuint pipeline, glw::GLuint program);
 void					glActiveTexture									(glw::GLenum texture);
@@ -61,7 +61,7 @@
 void					glClearDepth									(glw::GLdouble depth);
 void					glClearDepthf									(glw::GLfloat d);
 void					glClearNamedBufferData							(glw::GLuint buffer, glw::GLenum internalformat, glw::GLenum format, glw::GLenum type, const void *data);
-void					glClearNamedBufferSubData						(glw::GLuint buffer, glw::GLenum internalformat, glw::GLintptr offset, glw::GLsizei size, glw::GLenum format, glw::GLenum type, const void *data);
+void					glClearNamedBufferSubData						(glw::GLuint buffer, glw::GLenum internalformat, glw::GLintptr offset, glw::GLsizeiptr size, glw::GLenum format, glw::GLenum type, const void *data);
 void					glClearNamedFramebufferfi						(glw::GLuint framebuffer, glw::GLenum buffer, const glw::GLfloat depth, glw::GLint stencil);
 void					glClearNamedFramebufferfv						(glw::GLuint framebuffer, glw::GLenum buffer, glw::GLint drawbuffer, const glw::GLfloat *value);
 void					glClearNamedFramebufferiv						(glw::GLuint framebuffer, glw::GLenum buffer, glw::GLint drawbuffer, const glw::GLint *value);
@@ -85,7 +85,7 @@
 void					glCompressedTextureSubImage3D					(glw::GLuint texture, glw::GLint level, glw::GLint xoffset, glw::GLint yoffset, glw::GLint zoffset, glw::GLsizei width, glw::GLsizei height, glw::GLsizei depth, glw::GLenum format, glw::GLsizei imageSize, const void *data);
 void					glCopyBufferSubData								(glw::GLenum readTarget, glw::GLenum writeTarget, glw::GLintptr readOffset, glw::GLintptr writeOffset, glw::GLsizeiptr size);
 void					glCopyImageSubData								(glw::GLuint srcName, glw::GLenum srcTarget, glw::GLint srcLevel, glw::GLint srcX, glw::GLint srcY, glw::GLint srcZ, glw::GLuint dstName, glw::GLenum dstTarget, glw::GLint dstLevel, glw::GLint dstX, glw::GLint dstY, glw::GLint dstZ, glw::GLsizei srcWidth, glw::GLsizei srcHeight, glw::GLsizei srcDepth);
-void					glCopyNamedBufferSubData						(glw::GLuint readBuffer, glw::GLuint writeBuffer, glw::GLintptr readOffset, glw::GLintptr writeOffset, glw::GLsizei size);
+void					glCopyNamedBufferSubData						(glw::GLuint readBuffer, glw::GLuint writeBuffer, glw::GLintptr readOffset, glw::GLintptr writeOffset, glw::GLsizeiptr size);
 void					glCopyTexImage1D								(glw::GLenum target, glw::GLint level, glw::GLenum internalformat, glw::GLint x, glw::GLint y, glw::GLsizei width, glw::GLint border);
 void					glCopyTexImage2D								(glw::GLenum target, glw::GLint level, glw::GLenum internalformat, glw::GLint x, glw::GLint y, glw::GLsizei width, glw::GLsizei height, glw::GLint border);
 void					glCopyTexSubImage1D								(glw::GLenum target, glw::GLint level, glw::GLint xoffset, glw::GLint x, glw::GLint y, glw::GLsizei width);
@@ -168,7 +168,7 @@
 void					glFinish										(void);
 void					glFlush											(void);
 void					glFlushMappedBufferRange						(glw::GLenum target, glw::GLintptr offset, glw::GLsizeiptr length);
-void					glFlushMappedNamedBufferRange					(glw::GLuint buffer, glw::GLintptr offset, glw::GLsizei length);
+void					glFlushMappedNamedBufferRange					(glw::GLuint buffer, glw::GLintptr offset, glw::GLsizeiptr length);
 void					glFramebufferParameteri							(glw::GLenum target, glw::GLenum pname, glw::GLint param);
 void					glFramebufferRenderbuffer						(glw::GLenum target, glw::GLenum attachment, glw::GLenum renderbuffertarget, glw::GLuint renderbuffer);
 void					glFramebufferTexture							(glw::GLenum target, glw::GLenum attachment, glw::GLuint texture, glw::GLint level);
@@ -230,7 +230,7 @@
 void					glGetNamedBufferParameteri64v					(glw::GLuint buffer, glw::GLenum pname, glw::GLint64 *params);
 void					glGetNamedBufferParameteriv						(glw::GLuint buffer, glw::GLenum pname, glw::GLint *params);
 void					glGetNamedBufferPointerv						(glw::GLuint buffer, glw::GLenum pname, void **params);
-void					glGetNamedBufferSubData							(glw::GLuint buffer, glw::GLintptr offset, glw::GLsizei size, void *data);
+void					glGetNamedBufferSubData							(glw::GLuint buffer, glw::GLintptr offset, glw::GLsizeiptr size, void *data);
 void					glGetNamedFramebufferAttachmentParameteriv		(glw::GLuint framebuffer, glw::GLenum attachment, glw::GLenum pname, glw::GLint *params);
 void					glGetNamedFramebufferParameteriv				(glw::GLuint framebuffer, glw::GLenum pname, glw::GLint *param);
 void					glGetNamedRenderbufferParameteriv				(glw::GLuint renderbuffer, glw::GLenum pname, glw::GLint *params);
@@ -345,7 +345,7 @@
 void *					glMapBuffer										(glw::GLenum target, glw::GLenum access);
 void *					glMapBufferRange								(glw::GLenum target, glw::GLintptr offset, glw::GLsizeiptr length, glw::GLbitfield access);
 void *					glMapNamedBuffer								(glw::GLuint buffer, glw::GLenum access);
-void *					glMapNamedBufferRange							(glw::GLuint buffer, glw::GLintptr offset, glw::GLsizei length, glw::GLbitfield access);
+void *					glMapNamedBufferRange							(glw::GLuint buffer, glw::GLintptr offset, glw::GLsizeiptr length, glw::GLbitfield access);
 void					glMemoryBarrier									(glw::GLbitfield barriers);
 void					glMemoryBarrierByRegion							(glw::GLbitfield barriers);
 void					glMinSampleShading								(glw::GLfloat value);
@@ -354,9 +354,9 @@
 void					glMultiDrawElements								(glw::GLenum mode, const glw::GLsizei *count, glw::GLenum type, const void *const*indices, glw::GLsizei drawcount);
 void					glMultiDrawElementsBaseVertex					(glw::GLenum mode, const glw::GLsizei *count, glw::GLenum type, const void *const*indices, glw::GLsizei drawcount, const glw::GLint *basevertex);
 void					glMultiDrawElementsIndirect						(glw::GLenum mode, glw::GLenum type, const void *indirect, glw::GLsizei drawcount, glw::GLsizei stride);
-void					glNamedBufferData								(glw::GLuint buffer, glw::GLsizei size, const void *data, glw::GLenum usage);
-void					glNamedBufferStorage							(glw::GLuint buffer, glw::GLsizei size, const void *data, glw::GLbitfield flags);
-void					glNamedBufferSubData							(glw::GLuint buffer, glw::GLintptr offset, glw::GLsizei size, const void *data);
+void					glNamedBufferData								(glw::GLuint buffer, glw::GLsizeiptr size, const void *data, glw::GLenum usage);
+void					glNamedBufferStorage							(glw::GLuint buffer, glw::GLsizeiptr size, const void *data, glw::GLbitfield flags);
+void					glNamedBufferSubData							(glw::GLuint buffer, glw::GLintptr offset, glw::GLsizeiptr size, const void *data);
 void					glNamedFramebufferDrawBuffer					(glw::GLuint framebuffer, glw::GLenum buf);
 void					glNamedFramebufferDrawBuffers					(glw::GLuint framebuffer, glw::GLsizei n, const glw::GLenum *bufs);
 void					glNamedFramebufferParameteri					(glw::GLuint framebuffer, glw::GLenum pname, glw::GLint param);
@@ -489,7 +489,7 @@
 void					glTexSubImage3D									(glw::GLenum target, glw::GLint level, glw::GLint xoffset, glw::GLint yoffset, glw::GLint zoffset, glw::GLsizei width, glw::GLsizei height, glw::GLsizei depth, glw::GLenum format, glw::GLenum type, const void *pixels);
 void					glTextureBarrier								(void);
 void					glTextureBuffer									(glw::GLuint texture, glw::GLenum internalformat, glw::GLuint buffer);
-void					glTextureBufferRange							(glw::GLuint texture, glw::GLenum internalformat, glw::GLuint buffer, glw::GLintptr offset, glw::GLsizei size);
+void					glTextureBufferRange							(glw::GLuint texture, glw::GLenum internalformat, glw::GLuint buffer, glw::GLintptr offset, glw::GLsizeiptr size);
 void					glTextureParameterIiv							(glw::GLuint texture, glw::GLenum pname, const glw::GLint *params);
 void					glTextureParameterIuiv							(glw::GLuint texture, glw::GLenum pname, const glw::GLuint *params);
 void					glTextureParameterf								(glw::GLuint texture, glw::GLenum pname, glw::GLfloat param);
@@ -506,7 +506,7 @@
 void					glTextureSubImage3D								(glw::GLuint texture, glw::GLint level, glw::GLint xoffset, glw::GLint yoffset, glw::GLint zoffset, glw::GLsizei width, glw::GLsizei height, glw::GLsizei depth, glw::GLenum format, glw::GLenum type, const void *pixels);
 void					glTextureView									(glw::GLuint texture, glw::GLenum target, glw::GLuint origtexture, glw::GLenum internalformat, glw::GLuint minlevel, glw::GLuint numlevels, glw::GLuint minlayer, glw::GLuint numlayers);
 void					glTransformFeedbackBufferBase					(glw::GLuint xfb, glw::GLuint index, glw::GLuint buffer);
-void					glTransformFeedbackBufferRange					(glw::GLuint xfb, glw::GLuint index, glw::GLuint buffer, glw::GLintptr offset, glw::GLsizei size);
+void					glTransformFeedbackBufferRange					(glw::GLuint xfb, glw::GLuint index, glw::GLuint buffer, glw::GLintptr offset, glw::GLsizeiptr size);
 void					glTransformFeedbackVaryings						(glw::GLuint program, glw::GLsizei count, const glw::GLchar *const*varyings, glw::GLenum bufferMode);
 void					glUniform1d										(glw::GLint location, glw::GLdouble x);
 void					glUniform1dv									(glw::GLint location, glw::GLsizei count, const glw::GLdouble *value);
diff --git a/framework/opengl/gluES3PlusWrapperFuncs.inl b/framework/opengl/gluES3PlusWrapperFuncs.inl
index f7de93b..853071a 100644
--- a/framework/opengl/gluES3PlusWrapperFuncs.inl
+++ b/framework/opengl/gluES3PlusWrapperFuncs.inl
@@ -1,7 +1,7 @@
 /* WARNING: This is auto-generated file. Do not modify, since changes will
  * be lost! Modify the generating script instead.
  *
- * Generated from Khronos GL API description (gl.xml) revision 28861.
+ * Generated from Khronos GL API description (gl.xml) revision 29570.
  */
 dst->activeShaderProgram					= src.activeShaderProgram;
 dst->activeTexture							= src.activeTexture;
diff --git a/framework/opengl/gluQueryUtil.inl b/framework/opengl/gluQueryUtil.inl
index 655d1d5..9b9ec17 100644
--- a/framework/opengl/gluQueryUtil.inl
+++ b/framework/opengl/gluQueryUtil.inl
@@ -1,7 +1,7 @@
 /* WARNING: This is auto-generated file. Do not modify, since changes will
  * be lost! Modify the generating script instead.
  *
- * Generated from Khronos GL API description (gl.xml) revision 28861.
+ * Generated from Khronos GL API description (gl.xml) revision 29570.
  */
 
 int getBasicQueryNumArgsOut (int pname)
diff --git a/framework/opengl/gluRenderContext.hpp b/framework/opengl/gluRenderContext.hpp
index 7e73172..fd69ffb 100644
--- a/framework/opengl/gluRenderContext.hpp
+++ b/framework/opengl/gluRenderContext.hpp
@@ -80,6 +80,8 @@
 	bool				operator==		(ApiType other) const	{ return m_bits == other.m_bits;						}
 	bool				operator!=		(ApiType other) const	{ return m_bits != other.m_bits;						}
 
+	deUint32			getPacked		(void) const	{ return m_bits;												}
+
 	// Shorthands
 	static ApiType		es				(int major, int minor)	{ return ApiType(major, minor, PROFILE_ES);				}
 	static ApiType		core			(int major, int minor)	{ return ApiType(major, minor, PROFILE_CORE);			}
diff --git a/framework/opengl/gluShaderProgram.cpp b/framework/opengl/gluShaderProgram.cpp
index 1b47046..3070bc8 100644
--- a/framework/opengl/gluShaderProgram.cpp
+++ b/framework/opengl/gluShaderProgram.cpp
@@ -123,17 +123,29 @@
 
 static std::string getProgramInfoLog (const glw::Functions& gl, deUint32 program)
 {
-	int	infoLogLen	= 0;
-	int	unusedLen;
+	int infoLogLen = 0;
+	int unusedLen;
 
-	gl.getProgramiv(program, GL_INFO_LOG_LENGTH,	&infoLogLen);
+	gl.getProgramiv(program, GL_INFO_LOG_LENGTH, &infoLogLen);
 	GLU_EXPECT_NO_ERROR(gl.getError(), "glGetProgramiv()");
 
 	if (infoLogLen > 0)
 	{
-		std::vector<char> infoLog(infoLogLen);
-		gl.getProgramInfoLog(program, (int)infoLog.size(), &unusedLen, &infoLog[0]);
-		return std::string(&infoLog[0], infoLogLen);
+		// The INFO_LOG_LENGTH query and the buffer query implementations have
+		// very commonly off-by-one errors. Try to work around these issues.
+
+		// add tolerance for off-by-one in log length, buffer write, and for terminator
+		std::vector<char> infoLog(infoLogLen + 3, '\0');
+
+		// claim buf size is one smaller to protect from off-by-one writing over buffer bounds
+		gl.getProgramInfoLog(program, (int)infoLog.size() - 1, &unusedLen, &infoLog[0]);
+
+		// return whole buffer if null terminator was overwritten
+		if (infoLog[(int)(infoLog.size()) - 1] != '\0')
+			return std::string(&infoLog[0], infoLog.size());
+
+		// read as C string. infoLog is guaranteed to be 0-terminated
+		return std::string(&infoLog[0]);
 	}
 	return std::string();
 }
diff --git a/framework/opengl/gluStrUtil.inl b/framework/opengl/gluStrUtil.inl
index 771e88d..c220932 100644
--- a/framework/opengl/gluStrUtil.inl
+++ b/framework/opengl/gluStrUtil.inl
@@ -1,7 +1,7 @@
 /* WARNING: This is auto-generated file. Do not modify, since changes will
  * be lost! Modify the generating script instead.
  *
- * Generated from Khronos GL API description (gl.xml) revision 28861.
+ * Generated from Khronos GL API description (gl.xml) revision 29570.
  */
 
 const char* getErrorName (int value)
diff --git a/framework/opengl/gluStrUtilPrototypes.inl b/framework/opengl/gluStrUtilPrototypes.inl
index 009efac..fed402e 100644
--- a/framework/opengl/gluStrUtilPrototypes.inl
+++ b/framework/opengl/gluStrUtilPrototypes.inl
@@ -1,7 +1,7 @@
 /* WARNING: This is auto-generated file. Do not modify, since changes will
  * be lost! Modify the generating script instead.
  *
- * Generated from Khronos GL API description (gl.xml) revision 28861.
+ * Generated from Khronos GL API description (gl.xml) revision 29570.
  */
 const char*							getErrorName							(int value);
 const char*							getTypeName								(int value);
diff --git a/framework/opengl/wrapper/glwApi.inl b/framework/opengl/wrapper/glwApi.inl
index f3bd4e9..d10906d 100644
--- a/framework/opengl/wrapper/glwApi.inl
+++ b/framework/opengl/wrapper/glwApi.inl
@@ -1,7 +1,7 @@
 /* WARNING: This is auto-generated file. Do not modify, since changes will
  * be lost! Modify the generating script instead.
  *
- * Generated from Khronos GL API description (gl.xml) revision 28861.
+ * Generated from Khronos GL API description (gl.xml) revision 29570.
  */
 #define			glActiveShaderProgram							glwActiveShaderProgram
 #define			glActiveTexture									glwActiveTexture
@@ -718,7 +718,7 @@
 void			glwClearDepth									(GLdouble depth);
 void			glwClearDepthf									(GLfloat d);
 void			glwClearNamedBufferData							(GLuint buffer, GLenum internalformat, GLenum format, GLenum type, const void *data);
-void			glwClearNamedBufferSubData						(GLuint buffer, GLenum internalformat, GLintptr offset, GLsizei size, GLenum format, GLenum type, const void *data);
+void			glwClearNamedBufferSubData						(GLuint buffer, GLenum internalformat, GLintptr offset, GLsizeiptr size, GLenum format, GLenum type, const void *data);
 void			glwClearNamedFramebufferfi						(GLuint framebuffer, GLenum buffer, const GLfloat depth, GLint stencil);
 void			glwClearNamedFramebufferfv						(GLuint framebuffer, GLenum buffer, GLint drawbuffer, const GLfloat *value);
 void			glwClearNamedFramebufferiv						(GLuint framebuffer, GLenum buffer, GLint drawbuffer, const GLint *value);
@@ -742,7 +742,7 @@
 void			glwCompressedTextureSubImage3D					(GLuint texture, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLsizei width, GLsizei height, GLsizei depth, GLenum format, GLsizei imageSize, const void *data);
 void			glwCopyBufferSubData							(GLenum readTarget, GLenum writeTarget, GLintptr readOffset, GLintptr writeOffset, GLsizeiptr size);
 void			glwCopyImageSubData								(GLuint srcName, GLenum srcTarget, GLint srcLevel, GLint srcX, GLint srcY, GLint srcZ, GLuint dstName, GLenum dstTarget, GLint dstLevel, GLint dstX, GLint dstY, GLint dstZ, GLsizei srcWidth, GLsizei srcHeight, GLsizei srcDepth);
-void			glwCopyNamedBufferSubData						(GLuint readBuffer, GLuint writeBuffer, GLintptr readOffset, GLintptr writeOffset, GLsizei size);
+void			glwCopyNamedBufferSubData						(GLuint readBuffer, GLuint writeBuffer, GLintptr readOffset, GLintptr writeOffset, GLsizeiptr size);
 void			glwCopyTexImage1D								(GLenum target, GLint level, GLenum internalformat, GLint x, GLint y, GLsizei width, GLint border);
 void			glwCopyTexImage2D								(GLenum target, GLint level, GLenum internalformat, GLint x, GLint y, GLsizei width, GLsizei height, GLint border);
 void			glwCopyTexSubImage1D							(GLenum target, GLint level, GLint xoffset, GLint x, GLint y, GLsizei width);
@@ -825,7 +825,7 @@
 void			glwFinish										();
 void			glwFlush										();
 void			glwFlushMappedBufferRange						(GLenum target, GLintptr offset, GLsizeiptr length);
-void			glwFlushMappedNamedBufferRange					(GLuint buffer, GLintptr offset, GLsizei length);
+void			glwFlushMappedNamedBufferRange					(GLuint buffer, GLintptr offset, GLsizeiptr length);
 void			glwFramebufferParameteri						(GLenum target, GLenum pname, GLint param);
 void			glwFramebufferRenderbuffer						(GLenum target, GLenum attachment, GLenum renderbuffertarget, GLuint renderbuffer);
 void			glwFramebufferTexture							(GLenum target, GLenum attachment, GLuint texture, GLint level);
@@ -887,7 +887,7 @@
 void			glwGetNamedBufferParameteri64v					(GLuint buffer, GLenum pname, GLint64 *params);
 void			glwGetNamedBufferParameteriv					(GLuint buffer, GLenum pname, GLint *params);
 void			glwGetNamedBufferPointerv						(GLuint buffer, GLenum pname, void **params);
-void			glwGetNamedBufferSubData						(GLuint buffer, GLintptr offset, GLsizei size, void *data);
+void			glwGetNamedBufferSubData						(GLuint buffer, GLintptr offset, GLsizeiptr size, void *data);
 void			glwGetNamedFramebufferAttachmentParameteriv		(GLuint framebuffer, GLenum attachment, GLenum pname, GLint *params);
 void			glwGetNamedFramebufferParameteriv				(GLuint framebuffer, GLenum pname, GLint *param);
 void			glwGetNamedRenderbufferParameteriv				(GLuint renderbuffer, GLenum pname, GLint *params);
@@ -1002,7 +1002,7 @@
 void *			glwMapBuffer									(GLenum target, GLenum access);
 void *			glwMapBufferRange								(GLenum target, GLintptr offset, GLsizeiptr length, GLbitfield access);
 void *			glwMapNamedBuffer								(GLuint buffer, GLenum access);
-void *			glwMapNamedBufferRange							(GLuint buffer, GLintptr offset, GLsizei length, GLbitfield access);
+void *			glwMapNamedBufferRange							(GLuint buffer, GLintptr offset, GLsizeiptr length, GLbitfield access);
 void			glwMemoryBarrier								(GLbitfield barriers);
 void			glwMemoryBarrierByRegion						(GLbitfield barriers);
 void			glwMinSampleShading								(GLfloat value);
@@ -1011,9 +1011,9 @@
 void			glwMultiDrawElements							(GLenum mode, const GLsizei *count, GLenum type, const void *const*indices, GLsizei drawcount);
 void			glwMultiDrawElementsBaseVertex					(GLenum mode, const GLsizei *count, GLenum type, const void *const*indices, GLsizei drawcount, const GLint *basevertex);
 void			glwMultiDrawElementsIndirect					(GLenum mode, GLenum type, const void *indirect, GLsizei drawcount, GLsizei stride);
-void			glwNamedBufferData								(GLuint buffer, GLsizei size, const void *data, GLenum usage);
-void			glwNamedBufferStorage							(GLuint buffer, GLsizei size, const void *data, GLbitfield flags);
-void			glwNamedBufferSubData							(GLuint buffer, GLintptr offset, GLsizei size, const void *data);
+void			glwNamedBufferData								(GLuint buffer, GLsizeiptr size, const void *data, GLenum usage);
+void			glwNamedBufferStorage							(GLuint buffer, GLsizeiptr size, const void *data, GLbitfield flags);
+void			glwNamedBufferSubData							(GLuint buffer, GLintptr offset, GLsizeiptr size, const void *data);
 void			glwNamedFramebufferDrawBuffer					(GLuint framebuffer, GLenum buf);
 void			glwNamedFramebufferDrawBuffers					(GLuint framebuffer, GLsizei n, const GLenum *bufs);
 void			glwNamedFramebufferParameteri					(GLuint framebuffer, GLenum pname, GLint param);
@@ -1146,7 +1146,7 @@
 void			glwTexSubImage3D								(GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLsizei width, GLsizei height, GLsizei depth, GLenum format, GLenum type, const void *pixels);
 void			glwTextureBarrier								();
 void			glwTextureBuffer								(GLuint texture, GLenum internalformat, GLuint buffer);
-void			glwTextureBufferRange							(GLuint texture, GLenum internalformat, GLuint buffer, GLintptr offset, GLsizei size);
+void			glwTextureBufferRange							(GLuint texture, GLenum internalformat, GLuint buffer, GLintptr offset, GLsizeiptr size);
 void			glwTextureParameterIiv							(GLuint texture, GLenum pname, const GLint *params);
 void			glwTextureParameterIuiv							(GLuint texture, GLenum pname, const GLuint *params);
 void			glwTextureParameterf							(GLuint texture, GLenum pname, GLfloat param);
@@ -1163,7 +1163,7 @@
 void			glwTextureSubImage3D							(GLuint texture, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLsizei width, GLsizei height, GLsizei depth, GLenum format, GLenum type, const void *pixels);
 void			glwTextureView									(GLuint texture, GLenum target, GLuint origtexture, GLenum internalformat, GLuint minlevel, GLuint numlevels, GLuint minlayer, GLuint numlayers);
 void			glwTransformFeedbackBufferBase					(GLuint xfb, GLuint index, GLuint buffer);
-void			glwTransformFeedbackBufferRange					(GLuint xfb, GLuint index, GLuint buffer, GLintptr offset, GLsizei size);
+void			glwTransformFeedbackBufferRange					(GLuint xfb, GLuint index, GLuint buffer, GLintptr offset, GLsizeiptr size);
 void			glwTransformFeedbackVaryings					(GLuint program, GLsizei count, const GLchar *const*varyings, GLenum bufferMode);
 void			glwUniform1d									(GLint location, GLdouble x);
 void			glwUniform1dv									(GLint location, GLsizei count, const GLdouble *value);
diff --git a/framework/opengl/wrapper/glwEnums.inl b/framework/opengl/wrapper/glwEnums.inl
index c743f34..66dbcc6 100644
--- a/framework/opengl/wrapper/glwEnums.inl
+++ b/framework/opengl/wrapper/glwEnums.inl
@@ -1,7 +1,7 @@
 /* WARNING: This is auto-generated file. Do not modify, since changes will
  * be lost! Modify the generating script instead.
  *
- * Generated from Khronos GL API description (gl.xml) revision 28861.
+ * Generated from Khronos GL API description (gl.xml) revision 29570.
  */
 #define GL_DEPTH_BUFFER_BIT												0x00000100
 #define GL_STENCIL_BUFFER_BIT											0x00000400
diff --git a/framework/opengl/wrapper/glwFunctionTypes.inl b/framework/opengl/wrapper/glwFunctionTypes.inl
index ee34b35..24c90f2 100644
--- a/framework/opengl/wrapper/glwFunctionTypes.inl
+++ b/framework/opengl/wrapper/glwFunctionTypes.inl
@@ -1,7 +1,7 @@
 /* WARNING: This is auto-generated file. Do not modify, since changes will
  * be lost! Modify the generating script instead.
  *
- * Generated from Khronos GL API description (gl.xml) revision 28861.
+ * Generated from Khronos GL API description (gl.xml) revision 29570.
  */
 typedef GLW_APICALL void			(GLW_APIENTRY* glActiveShaderProgramFunc)							(GLuint pipeline, GLuint program);
 typedef GLW_APICALL void			(GLW_APIENTRY* glActiveTextureFunc)									(GLenum texture);
@@ -61,7 +61,7 @@
 typedef GLW_APICALL void			(GLW_APIENTRY* glClearDepthFunc)									(GLdouble depth);
 typedef GLW_APICALL void			(GLW_APIENTRY* glClearDepthfFunc)									(GLfloat d);
 typedef GLW_APICALL void			(GLW_APIENTRY* glClearNamedBufferDataFunc)							(GLuint buffer, GLenum internalformat, GLenum format, GLenum type, const void *data);
-typedef GLW_APICALL void			(GLW_APIENTRY* glClearNamedBufferSubDataFunc)						(GLuint buffer, GLenum internalformat, GLintptr offset, GLsizei size, GLenum format, GLenum type, const void *data);
+typedef GLW_APICALL void			(GLW_APIENTRY* glClearNamedBufferSubDataFunc)						(GLuint buffer, GLenum internalformat, GLintptr offset, GLsizeiptr size, GLenum format, GLenum type, const void *data);
 typedef GLW_APICALL void			(GLW_APIENTRY* glClearNamedFramebufferfiFunc)						(GLuint framebuffer, GLenum buffer, const GLfloat depth, GLint stencil);
 typedef GLW_APICALL void			(GLW_APIENTRY* glClearNamedFramebufferfvFunc)						(GLuint framebuffer, GLenum buffer, GLint drawbuffer, const GLfloat *value);
 typedef GLW_APICALL void			(GLW_APIENTRY* glClearNamedFramebufferivFunc)						(GLuint framebuffer, GLenum buffer, GLint drawbuffer, const GLint *value);
@@ -85,7 +85,7 @@
 typedef GLW_APICALL void			(GLW_APIENTRY* glCompressedTextureSubImage3DFunc)					(GLuint texture, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLsizei width, GLsizei height, GLsizei depth, GLenum format, GLsizei imageSize, const void *data);
 typedef GLW_APICALL void			(GLW_APIENTRY* glCopyBufferSubDataFunc)								(GLenum readTarget, GLenum writeTarget, GLintptr readOffset, GLintptr writeOffset, GLsizeiptr size);
 typedef GLW_APICALL void			(GLW_APIENTRY* glCopyImageSubDataFunc)								(GLuint srcName, GLenum srcTarget, GLint srcLevel, GLint srcX, GLint srcY, GLint srcZ, GLuint dstName, GLenum dstTarget, GLint dstLevel, GLint dstX, GLint dstY, GLint dstZ, GLsizei srcWidth, GLsizei srcHeight, GLsizei srcDepth);
-typedef GLW_APICALL void			(GLW_APIENTRY* glCopyNamedBufferSubDataFunc)						(GLuint readBuffer, GLuint writeBuffer, GLintptr readOffset, GLintptr writeOffset, GLsizei size);
+typedef GLW_APICALL void			(GLW_APIENTRY* glCopyNamedBufferSubDataFunc)						(GLuint readBuffer, GLuint writeBuffer, GLintptr readOffset, GLintptr writeOffset, GLsizeiptr size);
 typedef GLW_APICALL void			(GLW_APIENTRY* glCopyTexImage1DFunc)								(GLenum target, GLint level, GLenum internalformat, GLint x, GLint y, GLsizei width, GLint border);
 typedef GLW_APICALL void			(GLW_APIENTRY* glCopyTexImage2DFunc)								(GLenum target, GLint level, GLenum internalformat, GLint x, GLint y, GLsizei width, GLsizei height, GLint border);
 typedef GLW_APICALL void			(GLW_APIENTRY* glCopyTexSubImage1DFunc)								(GLenum target, GLint level, GLint xoffset, GLint x, GLint y, GLsizei width);
@@ -168,7 +168,7 @@
 typedef GLW_APICALL void			(GLW_APIENTRY* glFinishFunc)										(void);
 typedef GLW_APICALL void			(GLW_APIENTRY* glFlushFunc)											(void);
 typedef GLW_APICALL void			(GLW_APIENTRY* glFlushMappedBufferRangeFunc)						(GLenum target, GLintptr offset, GLsizeiptr length);
-typedef GLW_APICALL void			(GLW_APIENTRY* glFlushMappedNamedBufferRangeFunc)					(GLuint buffer, GLintptr offset, GLsizei length);
+typedef GLW_APICALL void			(GLW_APIENTRY* glFlushMappedNamedBufferRangeFunc)					(GLuint buffer, GLintptr offset, GLsizeiptr length);
 typedef GLW_APICALL void			(GLW_APIENTRY* glFramebufferParameteriFunc)							(GLenum target, GLenum pname, GLint param);
 typedef GLW_APICALL void			(GLW_APIENTRY* glFramebufferRenderbufferFunc)						(GLenum target, GLenum attachment, GLenum renderbuffertarget, GLuint renderbuffer);
 typedef GLW_APICALL void			(GLW_APIENTRY* glFramebufferTextureFunc)							(GLenum target, GLenum attachment, GLuint texture, GLint level);
@@ -230,7 +230,7 @@
 typedef GLW_APICALL void			(GLW_APIENTRY* glGetNamedBufferParameteri64vFunc)					(GLuint buffer, GLenum pname, GLint64 *params);
 typedef GLW_APICALL void			(GLW_APIENTRY* glGetNamedBufferParameterivFunc)						(GLuint buffer, GLenum pname, GLint *params);
 typedef GLW_APICALL void			(GLW_APIENTRY* glGetNamedBufferPointervFunc)						(GLuint buffer, GLenum pname, void **params);
-typedef GLW_APICALL void			(GLW_APIENTRY* glGetNamedBufferSubDataFunc)							(GLuint buffer, GLintptr offset, GLsizei size, void *data);
+typedef GLW_APICALL void			(GLW_APIENTRY* glGetNamedBufferSubDataFunc)							(GLuint buffer, GLintptr offset, GLsizeiptr size, void *data);
 typedef GLW_APICALL void			(GLW_APIENTRY* glGetNamedFramebufferAttachmentParameterivFunc)		(GLuint framebuffer, GLenum attachment, GLenum pname, GLint *params);
 typedef GLW_APICALL void			(GLW_APIENTRY* glGetNamedFramebufferParameterivFunc)				(GLuint framebuffer, GLenum pname, GLint *param);
 typedef GLW_APICALL void			(GLW_APIENTRY* glGetNamedRenderbufferParameterivFunc)				(GLuint renderbuffer, GLenum pname, GLint *params);
@@ -345,7 +345,7 @@
 typedef GLW_APICALL void *			(GLW_APIENTRY* glMapBufferFunc)										(GLenum target, GLenum access);
 typedef GLW_APICALL void *			(GLW_APIENTRY* glMapBufferRangeFunc)								(GLenum target, GLintptr offset, GLsizeiptr length, GLbitfield access);
 typedef GLW_APICALL void *			(GLW_APIENTRY* glMapNamedBufferFunc)								(GLuint buffer, GLenum access);
-typedef GLW_APICALL void *			(GLW_APIENTRY* glMapNamedBufferRangeFunc)							(GLuint buffer, GLintptr offset, GLsizei length, GLbitfield access);
+typedef GLW_APICALL void *			(GLW_APIENTRY* glMapNamedBufferRangeFunc)							(GLuint buffer, GLintptr offset, GLsizeiptr length, GLbitfield access);
 typedef GLW_APICALL void			(GLW_APIENTRY* glMemoryBarrierFunc)									(GLbitfield barriers);
 typedef GLW_APICALL void			(GLW_APIENTRY* glMemoryBarrierByRegionFunc)							(GLbitfield barriers);
 typedef GLW_APICALL void			(GLW_APIENTRY* glMinSampleShadingFunc)								(GLfloat value);
@@ -354,9 +354,9 @@
 typedef GLW_APICALL void			(GLW_APIENTRY* glMultiDrawElementsFunc)								(GLenum mode, const GLsizei *count, GLenum type, const void *const*indices, GLsizei drawcount);
 typedef GLW_APICALL void			(GLW_APIENTRY* glMultiDrawElementsBaseVertexFunc)					(GLenum mode, const GLsizei *count, GLenum type, const void *const*indices, GLsizei drawcount, const GLint *basevertex);
 typedef GLW_APICALL void			(GLW_APIENTRY* glMultiDrawElementsIndirectFunc)						(GLenum mode, GLenum type, const void *indirect, GLsizei drawcount, GLsizei stride);
-typedef GLW_APICALL void			(GLW_APIENTRY* glNamedBufferDataFunc)								(GLuint buffer, GLsizei size, const void *data, GLenum usage);
-typedef GLW_APICALL void			(GLW_APIENTRY* glNamedBufferStorageFunc)							(GLuint buffer, GLsizei size, const void *data, GLbitfield flags);
-typedef GLW_APICALL void			(GLW_APIENTRY* glNamedBufferSubDataFunc)							(GLuint buffer, GLintptr offset, GLsizei size, const void *data);
+typedef GLW_APICALL void			(GLW_APIENTRY* glNamedBufferDataFunc)								(GLuint buffer, GLsizeiptr size, const void *data, GLenum usage);
+typedef GLW_APICALL void			(GLW_APIENTRY* glNamedBufferStorageFunc)							(GLuint buffer, GLsizeiptr size, const void *data, GLbitfield flags);
+typedef GLW_APICALL void			(GLW_APIENTRY* glNamedBufferSubDataFunc)							(GLuint buffer, GLintptr offset, GLsizeiptr size, const void *data);
 typedef GLW_APICALL void			(GLW_APIENTRY* glNamedFramebufferDrawBufferFunc)					(GLuint framebuffer, GLenum buf);
 typedef GLW_APICALL void			(GLW_APIENTRY* glNamedFramebufferDrawBuffersFunc)					(GLuint framebuffer, GLsizei n, const GLenum *bufs);
 typedef GLW_APICALL void			(GLW_APIENTRY* glNamedFramebufferParameteriFunc)					(GLuint framebuffer, GLenum pname, GLint param);
@@ -489,7 +489,7 @@
 typedef GLW_APICALL void			(GLW_APIENTRY* glTexSubImage3DFunc)									(GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLsizei width, GLsizei height, GLsizei depth, GLenum format, GLenum type, const void *pixels);
 typedef GLW_APICALL void			(GLW_APIENTRY* glTextureBarrierFunc)								(void);
 typedef GLW_APICALL void			(GLW_APIENTRY* glTextureBufferFunc)									(GLuint texture, GLenum internalformat, GLuint buffer);
-typedef GLW_APICALL void			(GLW_APIENTRY* glTextureBufferRangeFunc)							(GLuint texture, GLenum internalformat, GLuint buffer, GLintptr offset, GLsizei size);
+typedef GLW_APICALL void			(GLW_APIENTRY* glTextureBufferRangeFunc)							(GLuint texture, GLenum internalformat, GLuint buffer, GLintptr offset, GLsizeiptr size);
 typedef GLW_APICALL void			(GLW_APIENTRY* glTextureParameterIivFunc)							(GLuint texture, GLenum pname, const GLint *params);
 typedef GLW_APICALL void			(GLW_APIENTRY* glTextureParameterIuivFunc)							(GLuint texture, GLenum pname, const GLuint *params);
 typedef GLW_APICALL void			(GLW_APIENTRY* glTextureParameterfFunc)								(GLuint texture, GLenum pname, GLfloat param);
@@ -506,7 +506,7 @@
 typedef GLW_APICALL void			(GLW_APIENTRY* glTextureSubImage3DFunc)								(GLuint texture, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLsizei width, GLsizei height, GLsizei depth, GLenum format, GLenum type, const void *pixels);
 typedef GLW_APICALL void			(GLW_APIENTRY* glTextureViewFunc)									(GLuint texture, GLenum target, GLuint origtexture, GLenum internalformat, GLuint minlevel, GLuint numlevels, GLuint minlayer, GLuint numlayers);
 typedef GLW_APICALL void			(GLW_APIENTRY* glTransformFeedbackBufferBaseFunc)					(GLuint xfb, GLuint index, GLuint buffer);
-typedef GLW_APICALL void			(GLW_APIENTRY* glTransformFeedbackBufferRangeFunc)					(GLuint xfb, GLuint index, GLuint buffer, GLintptr offset, GLsizei size);
+typedef GLW_APICALL void			(GLW_APIENTRY* glTransformFeedbackBufferRangeFunc)					(GLuint xfb, GLuint index, GLuint buffer, GLintptr offset, GLsizeiptr size);
 typedef GLW_APICALL void			(GLW_APIENTRY* glTransformFeedbackVaryingsFunc)						(GLuint program, GLsizei count, const GLchar *const*varyings, GLenum bufferMode);
 typedef GLW_APICALL void			(GLW_APIENTRY* glUniform1dFunc)										(GLint location, GLdouble x);
 typedef GLW_APICALL void			(GLW_APIENTRY* glUniform1dvFunc)									(GLint location, GLsizei count, const GLdouble *value);
diff --git a/framework/opengl/wrapper/glwFunctions.inl b/framework/opengl/wrapper/glwFunctions.inl
index 61f5dc2..074bea2 100644
--- a/framework/opengl/wrapper/glwFunctions.inl
+++ b/framework/opengl/wrapper/glwFunctions.inl
@@ -1,7 +1,7 @@
 /* WARNING: This is auto-generated file. Do not modify, since changes will
  * be lost! Modify the generating script instead.
  *
- * Generated from Khronos GL API description (gl.xml) revision 28861.
+ * Generated from Khronos GL API description (gl.xml) revision 29570.
  */
 glActiveShaderProgramFunc							activeShaderProgram;
 glActiveTextureFunc									activeTexture;
diff --git a/framework/opengl/wrapper/glwImpl.inl b/framework/opengl/wrapper/glwImpl.inl
index 3b9e862..b701a3f 100644
--- a/framework/opengl/wrapper/glwImpl.inl
+++ b/framework/opengl/wrapper/glwImpl.inl
@@ -1,7 +1,7 @@
 /* WARNING: This is auto-generated file. Do not modify, since changes will
  * be lost! Modify the generating script instead.
  *
- * Generated from Khronos GL API description (gl.xml) revision 28861.
+ * Generated from Khronos GL API description (gl.xml) revision 29570.
  */
 
 void glwActiveShaderProgram (GLuint pipeline, GLuint program)
@@ -468,7 +468,7 @@
 	gl->clearNamedBufferData(buffer, internalformat, format, type, data);
 }
 
-void glwClearNamedBufferSubData (GLuint buffer, GLenum internalformat, GLintptr offset, GLsizei size, GLenum format, GLenum type, const void *data)
+void glwClearNamedBufferSubData (GLuint buffer, GLenum internalformat, GLintptr offset, GLsizeiptr size, GLenum format, GLenum type, const void *data)
 {
 	const glw::Functions* gl = glw::getCurrentThreadFunctions();
 	if (!gl)
@@ -660,7 +660,7 @@
 	gl->copyImageSubData(srcName, srcTarget, srcLevel, srcX, srcY, srcZ, dstName, dstTarget, dstLevel, dstX, dstY, dstZ, srcWidth, srcHeight, srcDepth);
 }
 
-void glwCopyNamedBufferSubData (GLuint readBuffer, GLuint writeBuffer, GLintptr readOffset, GLintptr writeOffset, GLsizei size)
+void glwCopyNamedBufferSubData (GLuint readBuffer, GLuint writeBuffer, GLintptr readOffset, GLintptr writeOffset, GLsizeiptr size)
 {
 	const glw::Functions* gl = glw::getCurrentThreadFunctions();
 	if (!gl)
@@ -1324,7 +1324,7 @@
 	gl->flushMappedBufferRange(target, offset, length);
 }
 
-void glwFlushMappedNamedBufferRange (GLuint buffer, GLintptr offset, GLsizei length)
+void glwFlushMappedNamedBufferRange (GLuint buffer, GLintptr offset, GLsizeiptr length)
 {
 	const glw::Functions* gl = glw::getCurrentThreadFunctions();
 	if (!gl)
@@ -1820,7 +1820,7 @@
 	gl->getNamedBufferPointerv(buffer, pname, params);
 }
 
-void glwGetNamedBufferSubData (GLuint buffer, GLintptr offset, GLsizei size, void *data)
+void glwGetNamedBufferSubData (GLuint buffer, GLintptr offset, GLsizeiptr size, void *data)
 {
 	const glw::Functions* gl = glw::getCurrentThreadFunctions();
 	if (!gl)
@@ -2740,7 +2740,7 @@
 	return gl->mapNamedBuffer(buffer, access);
 }
 
-void * glwMapNamedBufferRange (GLuint buffer, GLintptr offset, GLsizei length, GLbitfield access)
+void * glwMapNamedBufferRange (GLuint buffer, GLintptr offset, GLsizeiptr length, GLbitfield access)
 {
 	const glw::Functions* gl = glw::getCurrentThreadFunctions();
 	if (!gl)
@@ -2812,7 +2812,7 @@
 	gl->multiDrawElementsIndirect(mode, type, indirect, drawcount, stride);
 }
 
-void glwNamedBufferData (GLuint buffer, GLsizei size, const void *data, GLenum usage)
+void glwNamedBufferData (GLuint buffer, GLsizeiptr size, const void *data, GLenum usage)
 {
 	const glw::Functions* gl = glw::getCurrentThreadFunctions();
 	if (!gl)
@@ -2820,7 +2820,7 @@
 	gl->namedBufferData(buffer, size, data, usage);
 }
 
-void glwNamedBufferStorage (GLuint buffer, GLsizei size, const void *data, GLbitfield flags)
+void glwNamedBufferStorage (GLuint buffer, GLsizeiptr size, const void *data, GLbitfield flags)
 {
 	const glw::Functions* gl = glw::getCurrentThreadFunctions();
 	if (!gl)
@@ -2828,7 +2828,7 @@
 	gl->namedBufferStorage(buffer, size, data, flags);
 }
 
-void glwNamedBufferSubData (GLuint buffer, GLintptr offset, GLsizei size, const void *data)
+void glwNamedBufferSubData (GLuint buffer, GLintptr offset, GLsizeiptr size, const void *data)
 {
 	const glw::Functions* gl = glw::getCurrentThreadFunctions();
 	if (!gl)
@@ -3892,7 +3892,7 @@
 	gl->textureBuffer(texture, internalformat, buffer);
 }
 
-void glwTextureBufferRange (GLuint texture, GLenum internalformat, GLuint buffer, GLintptr offset, GLsizei size)
+void glwTextureBufferRange (GLuint texture, GLenum internalformat, GLuint buffer, GLintptr offset, GLsizeiptr size)
 {
 	const glw::Functions* gl = glw::getCurrentThreadFunctions();
 	if (!gl)
@@ -4028,7 +4028,7 @@
 	gl->transformFeedbackBufferBase(xfb, index, buffer);
 }
 
-void glwTransformFeedbackBufferRange (GLuint xfb, GLuint index, GLuint buffer, GLintptr offset, GLsizei size)
+void glwTransformFeedbackBufferRange (GLuint xfb, GLuint index, GLuint buffer, GLintptr offset, GLsizeiptr size)
 {
 	const glw::Functions* gl = glw::getCurrentThreadFunctions();
 	if (!gl)
diff --git a/framework/opengl/wrapper/glwInitES20.inl b/framework/opengl/wrapper/glwInitES20.inl
index d76b75e..d775cc9 100644
--- a/framework/opengl/wrapper/glwInitES20.inl
+++ b/framework/opengl/wrapper/glwInitES20.inl
@@ -1,7 +1,7 @@
 /* WARNING: This is auto-generated file. Do not modify, since changes will
  * be lost! Modify the generating script instead.
  *
- * Generated from Khronos GL API description (gl.xml) revision 28861.
+ * Generated from Khronos GL API description (gl.xml) revision 29570.
  */
 gl->activeTexture						= (glActiveTextureFunc)							loader->get("glActiveTexture");
 gl->attachShader						= (glAttachShaderFunc)							loader->get("glAttachShader");
diff --git a/framework/opengl/wrapper/glwInitES20Direct.inl b/framework/opengl/wrapper/glwInitES20Direct.inl
index 8c8bc19..4cf5cb2 100644
--- a/framework/opengl/wrapper/glwInitES20Direct.inl
+++ b/framework/opengl/wrapper/glwInitES20Direct.inl
@@ -1,7 +1,7 @@
 /* WARNING: This is auto-generated file. Do not modify, since changes will
  * be lost! Modify the generating script instead.
  *
- * Generated from Khronos GL API description (gl.xml) revision 28861.
+ * Generated from Khronos GL API description (gl.xml) revision 29570.
  */
 gl->activeTexture						= &glActiveTexture;
 gl->attachShader						= &glAttachShader;
diff --git a/framework/opengl/wrapper/glwInitES30.inl b/framework/opengl/wrapper/glwInitES30.inl
index 8f684ee..cefaf87 100644
--- a/framework/opengl/wrapper/glwInitES30.inl
+++ b/framework/opengl/wrapper/glwInitES30.inl
@@ -1,7 +1,7 @@
 /* WARNING: This is auto-generated file. Do not modify, since changes will
  * be lost! Modify the generating script instead.
  *
- * Generated from Khronos GL API description (gl.xml) revision 28861.
+ * Generated from Khronos GL API description (gl.xml) revision 29570.
  */
 gl->activeTexture						= (glActiveTextureFunc)							loader->get("glActiveTexture");
 gl->attachShader						= (glAttachShaderFunc)							loader->get("glAttachShader");
diff --git a/framework/opengl/wrapper/glwInitES30Direct.inl b/framework/opengl/wrapper/glwInitES30Direct.inl
index 7dc81e1..a4c5398 100644
--- a/framework/opengl/wrapper/glwInitES30Direct.inl
+++ b/framework/opengl/wrapper/glwInitES30Direct.inl
@@ -1,7 +1,7 @@
 /* WARNING: This is auto-generated file. Do not modify, since changes will
  * be lost! Modify the generating script instead.
  *
- * Generated from Khronos GL API description (gl.xml) revision 28861.
+ * Generated from Khronos GL API description (gl.xml) revision 29570.
  */
 gl->activeTexture						= &glActiveTexture;
 gl->attachShader						= &glAttachShader;
diff --git a/framework/opengl/wrapper/glwInitES31.inl b/framework/opengl/wrapper/glwInitES31.inl
index bf06ff7..66e7ed5 100644
--- a/framework/opengl/wrapper/glwInitES31.inl
+++ b/framework/opengl/wrapper/glwInitES31.inl
@@ -1,7 +1,7 @@
 /* WARNING: This is auto-generated file. Do not modify, since changes will
  * be lost! Modify the generating script instead.
  *
- * Generated from Khronos GL API description (gl.xml) revision 28861.
+ * Generated from Khronos GL API description (gl.xml) revision 29570.
  */
 gl->activeShaderProgram					= (glActiveShaderProgramFunc)					loader->get("glActiveShaderProgram");
 gl->activeTexture						= (glActiveTextureFunc)							loader->get("glActiveTexture");
diff --git a/framework/opengl/wrapper/glwInitES31Direct.inl b/framework/opengl/wrapper/glwInitES31Direct.inl
index c7ac01d..1bcb67b 100644
--- a/framework/opengl/wrapper/glwInitES31Direct.inl
+++ b/framework/opengl/wrapper/glwInitES31Direct.inl
@@ -1,7 +1,7 @@
 /* WARNING: This is auto-generated file. Do not modify, since changes will
  * be lost! Modify the generating script instead.
  *
- * Generated from Khronos GL API description (gl.xml) revision 28861.
+ * Generated from Khronos GL API description (gl.xml) revision 29570.
  */
 gl->activeShaderProgram					= &glActiveShaderProgram;
 gl->activeTexture						= &glActiveTexture;
diff --git a/framework/opengl/wrapper/glwInitExtES.inl b/framework/opengl/wrapper/glwInitExtES.inl
index 14b7cad..0b1daf8 100644
--- a/framework/opengl/wrapper/glwInitExtES.inl
+++ b/framework/opengl/wrapper/glwInitExtES.inl
@@ -1,7 +1,7 @@
 /* WARNING: This is auto-generated file. Do not modify, since changes will
  * be lost! Modify the generating script instead.
  *
- * Generated from Khronos GL API description (gl.xml) revision 28861.
+ * Generated from Khronos GL API description (gl.xml) revision 29570.
  */
 
 if (de::contains(extSet, "GL_KHR_blend_equation_advanced"))
@@ -65,3 +65,15 @@
 {
 	gl->copyImageSubData	= (glCopyImageSubDataFunc)	loader->get("glCopyImageSubDataEXT");
 }
+
+if (de::contains(extSet, "GL_EXT_draw_buffers_indexed"))
+{
+	gl->blendEquationSeparatei	= (glBlendEquationSeparateiFunc)	loader->get("glBlendEquationSeparateiEXT");
+	gl->blendEquationi			= (glBlendEquationiFunc)			loader->get("glBlendEquationiEXT");
+	gl->blendFuncSeparatei		= (glBlendFuncSeparateiFunc)		loader->get("glBlendFuncSeparateiEXT");
+	gl->blendFunci				= (glBlendFunciFunc)				loader->get("glBlendFunciEXT");
+	gl->colorMaski				= (glColorMaskiFunc)				loader->get("glColorMaskiEXT");
+	gl->disablei				= (glDisableiFunc)					loader->get("glDisableiEXT");
+	gl->enablei					= (glEnableiFunc)					loader->get("glEnableiEXT");
+	gl->isEnabledi				= (glIsEnablediFunc)				loader->get("glIsEnablediEXT");
+}
diff --git a/framework/opengl/wrapper/glwInitExtGL.inl b/framework/opengl/wrapper/glwInitExtGL.inl
index d5a0cf4..7bee310 100644
--- a/framework/opengl/wrapper/glwInitExtGL.inl
+++ b/framework/opengl/wrapper/glwInitExtGL.inl
@@ -1,7 +1,7 @@
 /* WARNING: This is auto-generated file. Do not modify, since changes will
  * be lost! Modify the generating script instead.
  *
- * Generated from Khronos GL API description (gl.xml) revision 28861.
+ * Generated from Khronos GL API description (gl.xml) revision 29570.
  */
 
 if (de::contains(extSet, "GL_KHR_debug"))
diff --git a/framework/opengl/wrapper/glwInitGL30.inl b/framework/opengl/wrapper/glwInitGL30.inl
index 7471e00..84bd9ab 100644
--- a/framework/opengl/wrapper/glwInitGL30.inl
+++ b/framework/opengl/wrapper/glwInitGL30.inl
@@ -1,7 +1,7 @@
 /* WARNING: This is auto-generated file. Do not modify, since changes will
  * be lost! Modify the generating script instead.
  *
- * Generated from Khronos GL API description (gl.xml) revision 28861.
+ * Generated from Khronos GL API description (gl.xml) revision 29570.
  */
 gl->activeTexture						= (glActiveTextureFunc)							loader->get("glActiveTexture");
 gl->attachShader						= (glAttachShaderFunc)							loader->get("glAttachShader");
diff --git a/framework/opengl/wrapper/glwInitGL31.inl b/framework/opengl/wrapper/glwInitGL31.inl
index 43cf575..90b1c36 100644
--- a/framework/opengl/wrapper/glwInitGL31.inl
+++ b/framework/opengl/wrapper/glwInitGL31.inl
@@ -1,7 +1,7 @@
 /* WARNING: This is auto-generated file. Do not modify, since changes will
  * be lost! Modify the generating script instead.
  *
- * Generated from Khronos GL API description (gl.xml) revision 28861.
+ * Generated from Khronos GL API description (gl.xml) revision 29570.
  */
 gl->activeTexture						= (glActiveTextureFunc)							loader->get("glActiveTexture");
 gl->attachShader						= (glAttachShaderFunc)							loader->get("glAttachShader");
diff --git a/framework/opengl/wrapper/glwInitGL32.inl b/framework/opengl/wrapper/glwInitGL32.inl
index 2d766be..3012862 100644
--- a/framework/opengl/wrapper/glwInitGL32.inl
+++ b/framework/opengl/wrapper/glwInitGL32.inl
@@ -1,7 +1,7 @@
 /* WARNING: This is auto-generated file. Do not modify, since changes will
  * be lost! Modify the generating script instead.
  *
- * Generated from Khronos GL API description (gl.xml) revision 28861.
+ * Generated from Khronos GL API description (gl.xml) revision 29570.
  */
 gl->activeTexture						= (glActiveTextureFunc)							loader->get("glActiveTexture");
 gl->attachShader						= (glAttachShaderFunc)							loader->get("glAttachShader");
diff --git a/framework/opengl/wrapper/glwInitGL33.inl b/framework/opengl/wrapper/glwInitGL33.inl
index c1ac86d..bbb27cd 100644
--- a/framework/opengl/wrapper/glwInitGL33.inl
+++ b/framework/opengl/wrapper/glwInitGL33.inl
@@ -1,7 +1,7 @@
 /* WARNING: This is auto-generated file. Do not modify, since changes will
  * be lost! Modify the generating script instead.
  *
- * Generated from Khronos GL API description (gl.xml) revision 28861.
+ * Generated from Khronos GL API description (gl.xml) revision 29570.
  */
 gl->activeTexture						= (glActiveTextureFunc)							loader->get("glActiveTexture");
 gl->attachShader						= (glAttachShaderFunc)							loader->get("glAttachShader");
diff --git a/framework/opengl/wrapper/glwInitGL40.inl b/framework/opengl/wrapper/glwInitGL40.inl
index fcdbac0..ede9dae 100644
--- a/framework/opengl/wrapper/glwInitGL40.inl
+++ b/framework/opengl/wrapper/glwInitGL40.inl
@@ -1,7 +1,7 @@
 /* WARNING: This is auto-generated file. Do not modify, since changes will
  * be lost! Modify the generating script instead.
  *
- * Generated from Khronos GL API description (gl.xml) revision 28861.
+ * Generated from Khronos GL API description (gl.xml) revision 29570.
  */
 gl->activeTexture						= (glActiveTextureFunc)							loader->get("glActiveTexture");
 gl->attachShader						= (glAttachShaderFunc)							loader->get("glAttachShader");
diff --git a/framework/opengl/wrapper/glwInitGL41.inl b/framework/opengl/wrapper/glwInitGL41.inl
index 335954d..9763f39 100644
--- a/framework/opengl/wrapper/glwInitGL41.inl
+++ b/framework/opengl/wrapper/glwInitGL41.inl
@@ -1,7 +1,7 @@
 /* WARNING: This is auto-generated file. Do not modify, since changes will
  * be lost! Modify the generating script instead.
  *
- * Generated from Khronos GL API description (gl.xml) revision 28861.
+ * Generated from Khronos GL API description (gl.xml) revision 29570.
  */
 gl->activeShaderProgram					= (glActiveShaderProgramFunc)					loader->get("glActiveShaderProgram");
 gl->activeTexture						= (glActiveTextureFunc)							loader->get("glActiveTexture");
diff --git a/framework/opengl/wrapper/glwInitGL42.inl b/framework/opengl/wrapper/glwInitGL42.inl
index c6b0d86..4bb80c3 100644
--- a/framework/opengl/wrapper/glwInitGL42.inl
+++ b/framework/opengl/wrapper/glwInitGL42.inl
@@ -1,7 +1,7 @@
 /* WARNING: This is auto-generated file. Do not modify, since changes will
  * be lost! Modify the generating script instead.
  *
- * Generated from Khronos GL API description (gl.xml) revision 28861.
+ * Generated from Khronos GL API description (gl.xml) revision 29570.
  */
 gl->activeShaderProgram							= (glActiveShaderProgramFunc)							loader->get("glActiveShaderProgram");
 gl->activeTexture								= (glActiveTextureFunc)									loader->get("glActiveTexture");
diff --git a/framework/opengl/wrapper/glwInitGL43.inl b/framework/opengl/wrapper/glwInitGL43.inl
index 953db98..7c4b488 100644
--- a/framework/opengl/wrapper/glwInitGL43.inl
+++ b/framework/opengl/wrapper/glwInitGL43.inl
@@ -1,7 +1,7 @@
 /* WARNING: This is auto-generated file. Do not modify, since changes will
  * be lost! Modify the generating script instead.
  *
- * Generated from Khronos GL API description (gl.xml) revision 28861.
+ * Generated from Khronos GL API description (gl.xml) revision 29570.
  */
 gl->activeShaderProgram							= (glActiveShaderProgramFunc)							loader->get("glActiveShaderProgram");
 gl->activeTexture								= (glActiveTextureFunc)									loader->get("glActiveTexture");
diff --git a/framework/opengl/wrapper/glwInitGL44.inl b/framework/opengl/wrapper/glwInitGL44.inl
index dd1299c..3de7735 100644
--- a/framework/opengl/wrapper/glwInitGL44.inl
+++ b/framework/opengl/wrapper/glwInitGL44.inl
@@ -1,7 +1,7 @@
 /* WARNING: This is auto-generated file. Do not modify, since changes will
  * be lost! Modify the generating script instead.
  *
- * Generated from Khronos GL API description (gl.xml) revision 28861.
+ * Generated from Khronos GL API description (gl.xml) revision 29570.
  */
 gl->activeShaderProgram							= (glActiveShaderProgramFunc)							loader->get("glActiveShaderProgram");
 gl->activeTexture								= (glActiveTextureFunc)									loader->get("glActiveTexture");
diff --git a/framework/opengl/wrapper/glwInitGL45.inl b/framework/opengl/wrapper/glwInitGL45.inl
index d262b7a..de1dbbf 100644
--- a/framework/opengl/wrapper/glwInitGL45.inl
+++ b/framework/opengl/wrapper/glwInitGL45.inl
@@ -1,7 +1,7 @@
 /* WARNING: This is auto-generated file. Do not modify, since changes will
  * be lost! Modify the generating script instead.
  *
- * Generated from Khronos GL API description (gl.xml) revision 28861.
+ * Generated from Khronos GL API description (gl.xml) revision 29570.
  */
 gl->activeShaderProgram							= (glActiveShaderProgramFunc)							loader->get("glActiveShaderProgram");
 gl->activeTexture								= (glActiveTextureFunc)									loader->get("glActiveTexture");
diff --git a/framework/platform/CMakeLists.txt b/framework/platform/CMakeLists.txt
index 36275db..f1ff95b 100644
--- a/framework/platform/CMakeLists.txt
+++ b/framework/platform/CMakeLists.txt
@@ -105,7 +105,7 @@
 
 # Link to eglutil if platform supports EGL
 if (DEQP_SUPPORT_EGL)
-	target_link_libraries(tcutil-platform eglutil)
+	target_link_libraries(tcutil-platform eglutil eglwrapper)
 endif ()
 
 # X11 libraries
diff --git a/framework/platform/X11/tcuX11EglPlatform.cpp b/framework/platform/X11/tcuX11EglPlatform.cpp
index b84e555..b116659 100644
--- a/framework/platform/X11/tcuX11EglPlatform.cpp
+++ b/framework/platform/X11/tcuX11EglPlatform.cpp
@@ -22,8 +22,10 @@
  *//*--------------------------------------------------------------------*/
 
 #include "tcuX11EglPlatform.hpp"
-
 #include "egluGLContextFactory.hpp"
+#include "eglwLibrary.hpp"
+#include "eglwFunctions.hpp"
+#include "eglwEnums.hpp"
 
 namespace tcu
 {
@@ -32,6 +34,24 @@
 namespace egl
 {
 
+typedef ::Display*	EGLNativeDisplayType;
+typedef ::Pixmap	EGLNativePixmapType;
+typedef ::Window	EGLNativeWindowType;
+
+DE_STATIC_ASSERT(sizeof(EGLNativeDisplayType)	<= sizeof(eglw::EGLNativeDisplayType));
+DE_STATIC_ASSERT(sizeof(EGLNativePixmapType)	<= sizeof(eglw::EGLNativePixmapType));
+DE_STATIC_ASSERT(sizeof(EGLNativeWindowType)	<= sizeof(eglw::EGLNativeWindowType));
+
+extern "C"
+{
+
+typedef EGLW_APICALL	eglw::EGLDisplay	(EGLW_APIENTRY* eglX11GetDisplayFunc)			(EGLNativeDisplayType display_id);
+typedef EGLW_APICALL	eglw::EGLBoolean	(EGLW_APIENTRY* eglX11CopyBuffersFunc)			(eglw::EGLDisplay dpy, eglw::EGLSurface surface, EGLNativePixmapType target);
+typedef EGLW_APICALL	eglw::EGLSurface	(EGLW_APIENTRY* eglX11CreatePixmapSurfaceFunc)	(eglw::EGLDisplay dpy, eglw::EGLConfig config, EGLNativePixmapType pixmap, const eglw::EGLint* attrib_list);
+typedef EGLW_APICALL	eglw::EGLSurface	(EGLW_APIENTRY* eglX11CreateWindowSurfaceFunc)	(eglw::EGLDisplay dpy, eglw::EGLConfig config, EGLNativeWindowType win, const eglw::EGLint* attrib_list);
+
+}
+
 using std::string;
 
 using de::MovePtr;
@@ -47,12 +67,34 @@
 using eglu::WindowParams;
 using tcu::TextureLevel;
 
-#ifndef EGL_PLATFORM_X11_EXT
-#	define EGL_PLATFORM_X11_EXT			0x31D5
-#endif
-#ifndef EGL_PLATFORM_X11_SCREEN_EXT
-#	define EGL_PLATFORM_X11_SCREEN_EXT	0x31D6
-#endif
+class Library : public eglw::DefaultLibrary
+{
+public:
+	Library (void)
+		: eglw::DefaultLibrary("libEGL.so")
+	{
+	}
+
+	eglw::EGLBoolean copyBuffers (eglw::EGLDisplay dpy, eglw::EGLSurface surface, eglw::EGLNativePixmapType target) const
+	{
+		return ((eglX11CopyBuffersFunc)m_egl.copyBuffers)(dpy, surface, reinterpret_cast<EGLNativePixmapType>(target));
+	}
+
+	eglw::EGLSurface createPixmapSurface (eglw::EGLDisplay dpy, eglw::EGLConfig config, eglw::EGLNativePixmapType pixmap, const eglw::EGLint *attrib_list) const
+	{
+		return ((eglX11CreatePixmapSurfaceFunc)m_egl.createPixmapSurface)(dpy, config, reinterpret_cast<EGLNativePixmapType>(pixmap), attrib_list);
+	}
+
+	eglw::EGLSurface createWindowSurface (eglw::EGLDisplay dpy, eglw::EGLConfig config, eglw::EGLNativeWindowType win, const eglw::EGLint *attrib_list) const
+	{
+		return ((eglX11CreateWindowSurfaceFunc)m_egl.createWindowSurface)(dpy, config, reinterpret_cast<EGLNativeWindowType>(win), attrib_list);
+	}
+
+	eglw::EGLDisplay getDisplay (eglw::EGLNativeDisplayType display_id) const
+	{
+		return ((eglX11GetDisplayFunc)m_egl.getDisplay)(reinterpret_cast<EGLNativeDisplayType>(display_id));
+	}
+};
 
 class Display : public NativeDisplay
 {
@@ -60,22 +102,23 @@
 	static const Capability CAPABILITIES 		= Capability(CAPABILITY_GET_DISPLAY_LEGACY |
 															 CAPABILITY_GET_DISPLAY_PLATFORM);
 
-							Display				(MovePtr<x11::Display> x11Display)
-								: NativeDisplay	(CAPABILITIES,
-												 EGL_PLATFORM_X11_EXT,
-												 "EGL_EXT_platform_x11")
-								, m_display		(x11Display) {}
+								Display				(MovePtr<x11::Display> x11Display)
+									: NativeDisplay	(CAPABILITIES,
+													 EGL_PLATFORM_X11_EXT,
+													 "EGL_EXT_platform_x11")
+									, m_display		(x11Display) {}
 
-	void*					getPlatformNative	(void) 	{ return m_display->getXDisplay(); }
-	EGLNativeDisplayType	getLegacyNative		(void)	{ return m_display->getXDisplay(); }
+	void*						getPlatformNative	(void) 	{ return m_display->getXDisplay(); }
+	eglw::EGLNativeDisplayType	getLegacyNative		(void)	{ return reinterpret_cast<eglw::EGLNativeDisplayType>(m_display->getXDisplay()); }
 
-	x11::Display&			getX11Display		(void)	{ return *m_display; }
+	x11::Display&				getX11Display		(void)			{ return *m_display;	}
+	const eglw::Library&		getLibrary			(void) const	{ return m_library;		}
 
 private:
-	UniquePtr<x11::Display>	m_display;
+	UniquePtr<x11::Display>		m_display;
+	Library						m_library;
 };
 
-
 class Window : public NativeWindow
 {
 public:
@@ -85,21 +128,22 @@
 															 CAPABILITY_SET_SURFACE_SIZE |
 															 CAPABILITY_GET_SCREEN_SIZE);
 
-							Window				(Display&				display,
-												 const WindowParams&	params,
-												 Visual*				visual);
+								Window				(Display&				display,
+													 const WindowParams&	params,
+													 Visual*				visual);
 
-	EGLNativeWindowType		getLegacyNative		(void) { return m_window.getXID(); }
-	void*					getPlatformNative	(void) { return &m_window.getXID(); }
-	IVec2					getSurfaceSize		(void) const;
-	void					setSurfaceSize		(IVec2 size);
-	IVec2					getScreenSize		(void) const { return getSurfaceSize(); }
+	eglw::EGLNativeWindowType	getLegacyNative		(void) { return reinterpret_cast<eglw::EGLNativeWindowType>(m_window.getXID()); }
+	void*						getPlatformNative	(void) { return &m_window.getXID();	}
+
+	IVec2						getSurfaceSize		(void) const;
+	void						setSurfaceSize		(IVec2 size);
+	IVec2						getScreenSize		(void) const { return getSurfaceSize(); }
 
 private:
-	x11::Window				m_window;
+	x11::Window					m_window;
 };
 
-Window::Window(Display& display, const WindowParams& params, Visual* visual)
+Window::Window (Display& display, const WindowParams& params, Visual* visual)
 	: NativeWindow	(CAPABILITIES)
 	, m_window		(display.getX11Display(), params.width, params.height, visual)
 {
@@ -127,9 +171,9 @@
 											 const WindowParams&	params) const;
 
 	NativeWindow*		createWindow		(NativeDisplay*			nativeDisplay,
-											 EGLDisplay				display,
-											 EGLConfig				config,
-											 const EGLAttrib*		attribList,
+											 eglw::EGLDisplay		display,
+											 eglw::EGLConfig		config,
+											 const eglw::EGLAttrib*	attribList,
 											 const WindowParams&	params) const;
 };
 
@@ -147,17 +191,17 @@
 }
 
 NativeWindow* WindowFactory::createWindow (NativeDisplay*			nativeDisplay,
-										   EGLDisplay				eglDisplay,
-										   EGLConfig				config,
-										   const EGLAttrib*			attribList,
+										   eglw::EGLDisplay			eglDisplay,
+										   eglw::EGLConfig			config,
+										   const eglw::EGLAttrib*	attribList,
 										   const WindowParams&		params) const
 {
 	DE_UNREF(attribList);
 
-	Display&	display		= *dynamic_cast<Display*>(nativeDisplay);
-	EGLint		visualID	= 0;
-	::Visual*	visual		= DE_NULL;
-	eglGetConfigAttrib(eglDisplay, config, EGL_NATIVE_VISUAL_ID, &visualID);
+	Display&		display		= *dynamic_cast<Display*>(nativeDisplay);
+	eglw::EGLint	visualID	= 0;
+	::Visual*		visual		= DE_NULL;
+	nativeDisplay->getLibrary().getConfigAttrib(eglDisplay, config, EGL_NATIVE_VISUAL_ID, &visualID);
 
 	if (visualID != 0)
 		visual = display.getX11Display().getVisual(visualID);
@@ -214,7 +258,7 @@
 public:
 						DisplayFactory		(EventState& eventState);
 
-	NativeDisplay*		createDisplay		(const EGLAttrib* attribList) const;
+	NativeDisplay*		createDisplay		(const eglw::EGLAttrib* attribList) const;
 
 private:
 	EventState&			m_eventState;
@@ -231,7 +275,7 @@
 	// m_nativePixmapRegistry.registerFactory(new PixmapFactory());
 }
 
-NativeDisplay* DisplayFactory::createDisplay (const EGLAttrib* attribList) const
+NativeDisplay* DisplayFactory::createDisplay (const eglw::EGLAttrib* attribList) const
 {
 	DE_UNREF(attribList);
 
diff --git a/framework/platform/X11/tcuX11GlxPlatform.cpp b/framework/platform/X11/tcuX11GlxPlatform.cpp
index 0c3101c..1f9e9bc 100644
--- a/framework/platform/X11/tcuX11GlxPlatform.cpp
+++ b/framework/platform/X11/tcuX11GlxPlatform.cpp
@@ -177,7 +177,6 @@
 	GlxDisplay							m_glxDisplay;
 	GlxVisual							m_glxVisual;
 	ContextType							m_type;
-	GLXFBConfig							m_fbConfig;
 	GLXContext							m_GLXContext;
 	UniquePtr<GlxDrawable>				m_glxDrawable;
 	RenderTarget						m_renderTarget;
diff --git a/framework/platform/android/tcuAndroidPlatform.cpp b/framework/platform/android/tcuAndroidPlatform.cpp
index d2cf29e..eca3fe0 100644
--- a/framework/platform/android/tcuAndroidPlatform.cpp
+++ b/framework/platform/android/tcuAndroidPlatform.cpp
@@ -27,12 +27,23 @@
 #include "egluNativeWindow.hpp"
 #include "egluGLContextFactory.hpp"
 #include "egluUtil.hpp"
+#include "eglwLibrary.hpp"
+#include "eglwEnums.hpp"
+
+// Assume no call translation is needed
+#include <android/native_window.h>
+struct egl_native_pixmap_t;
+DE_STATIC_ASSERT(sizeof(eglw::EGLNativeDisplayType) == sizeof(void*));
+DE_STATIC_ASSERT(sizeof(eglw::EGLNativePixmapType) == sizeof(struct egl_native_pixmap_t*));
+DE_STATIC_ASSERT(sizeof(eglw::EGLNativeWindowType) == sizeof(ANativeWindow*));
 
 namespace tcu
 {
 namespace Android
 {
 
+using namespace eglw;
+
 static const eglu::NativeDisplay::Capability	DISPLAY_CAPABILITIES	= eglu::NativeDisplay::CAPABILITY_GET_DISPLAY_LEGACY;
 static const eglu::NativeWindow::Capability		WINDOW_CAPABILITIES		= (eglu::NativeWindow::Capability)(eglu::NativeWindow::CAPABILITY_CREATE_SURFACE_LEGACY |
 																										   eglu::NativeWindow::CAPABILITY_SET_SURFACE_SIZE |
@@ -41,10 +52,14 @@
 class NativeDisplay : public eglu::NativeDisplay
 {
 public:
-									NativeDisplay			(void) : eglu::NativeDisplay(DISPLAY_CAPABILITIES) {}
+									NativeDisplay			(void) : eglu::NativeDisplay(DISPLAY_CAPABILITIES), m_library("libEGL.so") {}
 	virtual							~NativeDisplay			(void) {}
 
-	virtual EGLNativeDisplayType	getLegacyNative			(void) { return EGL_DEFAULT_DISPLAY; }
+	virtual EGLNativeDisplayType	getLegacyNative			(void)			{ return EGL_DEFAULT_DISPLAY;	}
+	virtual const eglw::Library&	getLibrary				(void) const	{ return m_library;				}
+
+private:
+	eglw::DefaultLibrary			m_library;
 };
 
 class NativeDisplayFactory : public eglu::NativeDisplayFactory
@@ -138,7 +153,7 @@
 
 eglu::NativeWindow* NativeWindowFactory::createWindow (eglu::NativeDisplay* nativeDisplay, EGLDisplay display, EGLConfig config, const EGLAttrib* attribList, const eglu::WindowParams& params) const
 {
-	const int32_t format = (int32_t)eglu::getConfigAttribInt(display, config, EGL_NATIVE_VISUAL_ID);
+	const int32_t format = (int32_t)eglu::getConfigAttribInt(nativeDisplay->getLibrary(), display, config, EGL_NATIVE_VISUAL_ID);
 	DE_UNREF(nativeDisplay && attribList);
 	return createWindow(params, format);
 }
diff --git a/framework/platform/android/tcuAndroidPlatformCapabilityQueryJNI.cpp b/framework/platform/android/tcuAndroidPlatformCapabilityQueryJNI.cpp
new file mode 100644
index 0000000..83e047d
--- /dev/null
+++ b/framework/platform/android/tcuAndroidPlatformCapabilityQueryJNI.cpp
@@ -0,0 +1,217 @@
+/*-------------------------------------------------------------------------
+ * drawElements Quality Program Platform Utilites
+ * ----------------------------------------------
+ *
+ * Copyright 2015 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ *//*!
+ * \file
+ * \brief Android platform capability query JNI component
+ *//*--------------------------------------------------------------------*/
+
+#include "tcuDefs.hpp"
+
+#include "tcuCommandLine.hpp"
+#include "gluRenderConfig.hpp"
+#include "gluRenderContext.hpp"
+#include "eglwLibrary.hpp"
+#include "eglwEnums.hpp"
+#include "egluUtil.hpp"
+#include "egluGLUtil.hpp"
+
+#include <jni.h>
+
+namespace
+{
+namespace opt
+{
+
+DE_DECLARE_COMMAND_LINE_OPT(GLMajorVersion, int);
+DE_DECLARE_COMMAND_LINE_OPT(GLMinorVersion, int);
+
+} // opt
+
+class GLConfigParser : public tcu::CommandLine
+{
+public:
+					GLConfigParser			(const std::string& argString);
+
+	bool			hasGLMajorVersion		(void) const;
+	bool			hasGLMinorVersion		(void) const;
+	int				getGLMajorVersion		(void) const;
+	int				getGLMinorVersion		(void) const;
+
+private:
+	virtual void	registerExtendedOptions	(de::cmdline::Parser& parser);
+};
+
+GLConfigParser::GLConfigParser (const std::string& argString)
+{
+	const std::string execString = "fakebinaryname " + argString; // convert argument list to full command line
+
+	if (!parse(execString))
+	{
+		tcu::print("failed to parse command line");
+		TCU_THROW(Exception, "failed to parse command line");
+	}
+}
+
+bool GLConfigParser::hasGLMajorVersion (void) const
+{
+	return getCommandLine().hasOption<opt::GLMajorVersion>();
+}
+
+bool GLConfigParser::hasGLMinorVersion (void) const
+{
+	return getCommandLine().hasOption<opt::GLMinorVersion>();
+}
+
+int GLConfigParser::getGLMajorVersion (void) const
+{
+	DE_ASSERT(hasGLMajorVersion());
+	return getCommandLine().getOption<opt::GLMajorVersion>();
+}
+
+int GLConfigParser::getGLMinorVersion (void) const
+{
+	DE_ASSERT(hasGLMinorVersion());
+	return getCommandLine().getOption<opt::GLMinorVersion>();
+}
+
+void GLConfigParser::registerExtendedOptions (de::cmdline::Parser& parser)
+{
+	using de::cmdline::Option;
+
+	parser
+		<< Option<opt::GLMajorVersion>	(DE_NULL, "deqp-gl-major-version", "OpenGL ES Major version")
+		<< Option<opt::GLMinorVersion>	(DE_NULL, "deqp-gl-minor-version", "OpenGL ES Minor version");
+}
+
+glu::RenderConfig parseRenderConfig (const std::string& argsStr)
+{
+	const GLConfigParser parsedCommandLine (argsStr);
+
+	if (!parsedCommandLine.hasGLMajorVersion() ||
+		!parsedCommandLine.hasGLMinorVersion())
+	{
+		tcu::print("minor and major version must be supplied");
+		TCU_THROW(Exception, "minor and major version must be supplied");
+	}
+	else
+	{
+		const glu::ContextType	testContextType	(glu::ApiType::es(parsedCommandLine.getGLMajorVersion(), parsedCommandLine.getGLMinorVersion()));
+		glu::RenderConfig		renderConfig	(testContextType);
+
+		glu::parseRenderConfig(&renderConfig, parsedCommandLine);
+
+		return renderConfig;
+	}
+}
+
+bool isRenderConfigSupported (const std::string& cmdLineStr)
+{
+	const glu::RenderConfig		renderConfig	= parseRenderConfig(cmdLineStr);
+	const eglw::DefaultLibrary	egl;
+	const eglw::EGLDisplay		display			= egl.getDisplay(EGL_DEFAULT_DISPLAY);
+	eglw::EGLint				eglMajor		= -1;
+	eglw::EGLint				eglMinor		= -1;
+
+	if (display == EGL_NO_DISPLAY)
+	{
+		tcu::print("could not get default display");
+		TCU_THROW(Exception, "could not get default display");
+	}
+
+	if (egl.initialize(display, &eglMajor, &eglMinor) != EGL_TRUE)
+	{
+		tcu::print("failed to initialize egl");
+		TCU_THROW(Exception, "failed to initialize egl");
+	}
+	tcu::print("EGL initialized, major=%d, minor=%d", eglMajor, eglMinor);
+
+	try
+	{
+		// ignoring return value
+		(void)eglu::chooseConfig(egl, display, renderConfig);
+	}
+	catch (const tcu::NotSupportedError&)
+	{
+		tcu::print("No matching config");
+		egl.terminate(display);
+		return false;
+	}
+	catch (...)
+	{
+		egl.terminate(display);
+		throw;
+	}
+	egl.terminate(display);
+
+	return true;
+}
+
+} // anonymous
+
+
+DE_BEGIN_EXTERN_C
+
+JNIEXPORT jint JNICALL Java_com_drawelements_deqp_platformutil_DeqpPlatformCapabilityQueryInstrumentation_nativeRenderConfigSupportedQuery (JNIEnv* env, jclass, jstring jCmdLine)
+{
+	enum
+	{
+		CONFIGQUERYRESULT_SUPPORTED = 0,
+		CONFIGQUERYRESULT_NOT_SUPPORTED = 1,
+		CONFIGQUERYRESULT_GENERIC_ERROR = -1,
+	};
+
+	std::string			cmdLine;
+	const char* const	cmdLineBytes = env->GetStringUTFChars(jCmdLine, DE_NULL);
+
+	if (cmdLineBytes == DE_NULL)
+	{
+		// no command line is not executable
+		tcu::print("no command line supplied");
+		return CONFIGQUERYRESULT_GENERIC_ERROR;
+	}
+
+	try
+	{
+		// try to copy to local buffer
+		cmdLine = std::string(cmdLineBytes);
+	}
+	catch (const std::bad_alloc&)
+	{
+		env->ReleaseStringUTFChars(jCmdLine, cmdLineBytes);
+		tcu::print("failed to copy cmdLine");
+		return CONFIGQUERYRESULT_GENERIC_ERROR;
+	}
+	env->ReleaseStringUTFChars(jCmdLine, cmdLineBytes);
+
+	try
+	{
+		const bool isSupported = isRenderConfigSupported(cmdLine);
+
+		return (isSupported) ? (CONFIGQUERYRESULT_SUPPORTED)
+		                     : (CONFIGQUERYRESULT_NOT_SUPPORTED);
+	}
+	catch (const std::exception& ex)
+	{
+		// don't bother forwarding the exception to the caller. They cannot do anything with the exception anyway.
+		tcu::print("Error: %s", ex.what());
+		return CONFIGQUERYRESULT_GENERIC_ERROR;
+	}
+}
+
+DE_END_EXTERN_C
diff --git a/framework/platform/null/tcuNullRenderContextFuncs.inl b/framework/platform/null/tcuNullRenderContextFuncs.inl
index 9f3f6b6..7580966 100644
--- a/framework/platform/null/tcuNullRenderContextFuncs.inl
+++ b/framework/platform/null/tcuNullRenderContextFuncs.inl
@@ -1,7 +1,7 @@
 /* WARNING: This is auto-generated file. Do not modify, since changes will
  * be lost! Modify the generating script instead.
  *
- * Generated from Khronos GL API description (gl.xml) revision 28861.
+ * Generated from Khronos GL API description (gl.xml) revision 29570.
  */
 
 GLW_APICALL void GLW_APIENTRY glActiveShaderProgram (GLuint pipeline, GLuint program)
@@ -466,7 +466,7 @@
 
 }
 
-GLW_APICALL void GLW_APIENTRY glClearNamedBufferSubData (GLuint buffer, GLenum internalformat, GLintptr offset, GLsizei size, GLenum format, GLenum type, const void *data)
+GLW_APICALL void GLW_APIENTRY glClearNamedBufferSubData (GLuint buffer, GLenum internalformat, GLintptr offset, GLsizeiptr size, GLenum format, GLenum type, const void *data)
 {
 	DE_UNREF(buffer);
 	DE_UNREF(internalformat);
@@ -740,7 +740,7 @@
 
 }
 
-GLW_APICALL void GLW_APIENTRY glCopyNamedBufferSubData (GLuint readBuffer, GLuint writeBuffer, GLintptr readOffset, GLintptr writeOffset, GLsizei size)
+GLW_APICALL void GLW_APIENTRY glCopyNamedBufferSubData (GLuint readBuffer, GLuint writeBuffer, GLintptr readOffset, GLintptr writeOffset, GLsizeiptr size)
 {
 	DE_UNREF(readBuffer);
 	DE_UNREF(writeBuffer);
@@ -1385,7 +1385,7 @@
 
 }
 
-GLW_APICALL void GLW_APIENTRY glFlushMappedNamedBufferRange (GLuint buffer, GLintptr offset, GLsizei length)
+GLW_APICALL void GLW_APIENTRY glFlushMappedNamedBufferRange (GLuint buffer, GLintptr offset, GLsizeiptr length)
 {
 	DE_UNREF(buffer);
 	DE_UNREF(offset);
@@ -1823,7 +1823,7 @@
 
 }
 
-GLW_APICALL void GLW_APIENTRY glGetNamedBufferSubData (GLuint buffer, GLintptr offset, GLsizei size, void *data)
+GLW_APICALL void GLW_APIENTRY glGetNamedBufferSubData (GLuint buffer, GLintptr offset, GLsizeiptr size, void *data)
 {
 	DE_UNREF(buffer);
 	DE_UNREF(offset);
@@ -2761,7 +2761,7 @@
 	return (void *)0;
 }
 
-GLW_APICALL void * GLW_APIENTRY glMapNamedBufferRange (GLuint buffer, GLintptr offset, GLsizei length, GLbitfield access)
+GLW_APICALL void * GLW_APIENTRY glMapNamedBufferRange (GLuint buffer, GLintptr offset, GLsizeiptr length, GLbitfield access)
 {
 	DE_UNREF(buffer);
 	DE_UNREF(offset);
@@ -2838,7 +2838,7 @@
 
 }
 
-GLW_APICALL void GLW_APIENTRY glNamedBufferData (GLuint buffer, GLsizei size, const void *data, GLenum usage)
+GLW_APICALL void GLW_APIENTRY glNamedBufferData (GLuint buffer, GLsizeiptr size, const void *data, GLenum usage)
 {
 	DE_UNREF(buffer);
 	DE_UNREF(size);
@@ -2847,7 +2847,7 @@
 
 }
 
-GLW_APICALL void GLW_APIENTRY glNamedBufferStorage (GLuint buffer, GLsizei size, const void *data, GLbitfield flags)
+GLW_APICALL void GLW_APIENTRY glNamedBufferStorage (GLuint buffer, GLsizeiptr size, const void *data, GLbitfield flags)
 {
 	DE_UNREF(buffer);
 	DE_UNREF(size);
@@ -2856,7 +2856,7 @@
 
 }
 
-GLW_APICALL void GLW_APIENTRY glNamedBufferSubData (GLuint buffer, GLintptr offset, GLsizei size, const void *data)
+GLW_APICALL void GLW_APIENTRY glNamedBufferSubData (GLuint buffer, GLintptr offset, GLsizeiptr size, const void *data)
 {
 	DE_UNREF(buffer);
 	DE_UNREF(offset);
@@ -4036,7 +4036,7 @@
 
 }
 
-GLW_APICALL void GLW_APIENTRY glTextureBufferRange (GLuint texture, GLenum internalformat, GLuint buffer, GLintptr offset, GLsizei size)
+GLW_APICALL void GLW_APIENTRY glTextureBufferRange (GLuint texture, GLenum internalformat, GLuint buffer, GLintptr offset, GLsizeiptr size)
 {
 	DE_UNREF(texture);
 	DE_UNREF(internalformat);
@@ -4210,7 +4210,7 @@
 
 }
 
-GLW_APICALL void GLW_APIENTRY glTransformFeedbackBufferRange (GLuint xfb, GLuint index, GLuint buffer, GLintptr offset, GLsizei size)
+GLW_APICALL void GLW_APIENTRY glTransformFeedbackBufferRange (GLuint xfb, GLuint index, GLuint buffer, GLintptr offset, GLsizeiptr size)
 {
 	DE_UNREF(xfb);
 	DE_UNREF(index);
diff --git a/framework/platform/null/tcuNullRenderContextInitFuncs.inl b/framework/platform/null/tcuNullRenderContextInitFuncs.inl
index c31bfa4..b5cf05b 100644
--- a/framework/platform/null/tcuNullRenderContextInitFuncs.inl
+++ b/framework/platform/null/tcuNullRenderContextInitFuncs.inl
@@ -1,7 +1,7 @@
 /* WARNING: This is auto-generated file. Do not modify, since changes will
  * be lost! Modify the generating script instead.
  *
- * Generated from Khronos GL API description (gl.xml) revision 28861.
+ * Generated from Khronos GL API description (gl.xml) revision 29570.
  */
 gl->activeShaderProgram							= glActiveShaderProgram;
 gl->activeTexture								= glActiveTexture;
diff --git a/framework/platform/win32/tcuWin32EGLNativeDisplayFactory.cpp b/framework/platform/win32/tcuWin32EGLNativeDisplayFactory.cpp
index 1c44a25..5cd61e8 100644
--- a/framework/platform/win32/tcuWin32EGLNativeDisplayFactory.cpp
+++ b/framework/platform/win32/tcuWin32EGLNativeDisplayFactory.cpp
@@ -30,12 +30,21 @@
 #include "deMemory.h"
 #include "deThread.h"
 #include "deClock.h"
+#include "eglwLibrary.hpp"
+#include "eglwEnums.hpp"
+
+// Assume no call translation is needed
+DE_STATIC_ASSERT(sizeof(eglw::EGLNativeDisplayType) == sizeof(HDC));
+DE_STATIC_ASSERT(sizeof(eglw::EGLNativePixmapType) == sizeof(HBITMAP));
+DE_STATIC_ASSERT(sizeof(eglw::EGLNativeWindowType) == sizeof(HWND));
 
 namespace tcu
 {
 namespace
 {
 
+using namespace eglw;
+
 enum
 {
 	DEFAULT_SURFACE_WIDTH		= 400,
@@ -59,12 +68,14 @@
 									NativeDisplay			(void);
 	virtual							~NativeDisplay			(void) {}
 
-	virtual EGLNativeDisplayType	getLegacyNative			(void) { return m_deviceContext; }
+	virtual EGLNativeDisplayType	getLegacyNative			(void)			{ return m_deviceContext;	}
+	const eglw::Library&			getLibrary				(void) const	{ return m_library;			}
 
-	HDC								getDeviceContext		(void) { return m_deviceContext; }
+	HDC								getDeviceContext		(void)			{ return m_deviceContext;	}
 
 private:
 	HDC								m_deviceContext;
+	eglw::DefaultLibrary			m_library;
 };
 
 class NativePixmapFactory : public eglu::NativePixmapFactory
@@ -125,7 +136,8 @@
 
 NativeDisplay::NativeDisplay (void)
 	: eglu::NativeDisplay	(DISPLAY_CAPABILITIES)
-	, m_deviceContext		(EGL_DEFAULT_DISPLAY)
+	, m_deviceContext		((HDC)EGL_DEFAULT_DISPLAY)
+	, m_library				("libEGL.dll")
 {
 }
 
@@ -176,18 +188,21 @@
 
 eglu::NativePixmap* NativePixmapFactory::createPixmap (eglu::NativeDisplay* nativeDisplay, EGLDisplay display, EGLConfig config, const EGLAttrib* attribList, int width, int height) const
 {
-	int	redBits		= 0;
-	int	greenBits	= 0;
-	int	blueBits	= 0;
-	int	alphaBits	= 0;
-	int	bitSum		= 0;
+	const Library&	egl			= nativeDisplay->getLibrary();
+	int				redBits		= 0;
+	int				greenBits	= 0;
+	int				blueBits	= 0;
+	int				alphaBits	= 0;
+	int				bitSum		= 0;
 
 	DE_ASSERT(display != EGL_NO_DISPLAY);
 
-	EGLU_CHECK_CALL(eglGetConfigAttrib(display, config, EGL_RED_SIZE,	&redBits));
-	EGLU_CHECK_CALL(eglGetConfigAttrib(display, config, EGL_GREEN_SIZE,	&greenBits));
-	EGLU_CHECK_CALL(eglGetConfigAttrib(display, config, EGL_BLUE_SIZE,	&blueBits));
-	EGLU_CHECK_CALL(eglGetConfigAttrib(display, config, EGL_ALPHA_SIZE,	&alphaBits));
+	egl.getConfigAttrib(display, config, EGL_RED_SIZE,		&redBits);
+	egl.getConfigAttrib(display, config, EGL_GREEN_SIZE,	&greenBits);
+	egl.getConfigAttrib(display, config, EGL_BLUE_SIZE,		&blueBits);
+	egl.getConfigAttrib(display, config, EGL_ALPHA_SIZE,	&alphaBits);
+	EGLU_CHECK_MSG(egl, "eglGetConfigAttrib()");
+
 	bitSum = redBits+greenBits+blueBits+alphaBits;
 
 	return new NativePixmap(dynamic_cast<NativeDisplay*>(nativeDisplay), width, height, bitSum);
diff --git a/framework/platform/win32/tcuWin32EGLNativeDisplayFactory.hpp b/framework/platform/win32/tcuWin32EGLNativeDisplayFactory.hpp
index 6b2db7c..78e1000 100644
--- a/framework/platform/win32/tcuWin32EGLNativeDisplayFactory.hpp
+++ b/framework/platform/win32/tcuWin32EGLNativeDisplayFactory.hpp
@@ -25,6 +25,7 @@
 
 #include "tcuDefs.hpp"
 #include "egluNativeDisplay.hpp"
+#include "eglwDefs.hpp"
 #include "tcuWin32API.h"
 
 namespace tcu
@@ -36,7 +37,7 @@
 									Win32EGLNativeDisplayFactory	(HINSTANCE instance);
 	virtual							~Win32EGLNativeDisplayFactory	(void);
 
-	virtual eglu::NativeDisplay*	createDisplay					(const EGLAttrib* attribList) const;
+	virtual eglu::NativeDisplay*	createDisplay					(const eglw::EGLAttrib* attribList) const;
 
 private:
 	const HINSTANCE					m_instance;
diff --git a/framework/platform/win32/tcuWin32Window.cpp b/framework/platform/win32/tcuWin32Window.cpp
index e691694..4e674e8 100644
--- a/framework/platform/win32/tcuWin32Window.cpp
+++ b/framework/platform/win32/tcuWin32Window.cpp
@@ -40,8 +40,8 @@
 {
 	try
 	{
-		static const char	s_className[]	= "dEQP Tester Core Class";
-		static const char	s_windowName[]	= "dEQP Tester Core";
+		static const char	s_className[]	= "dEQP Test Process Class";
+		static const char	s_windowName[]	= "dEQP Test Process";
 
 		{
 			WNDCLASS wndClass;
@@ -67,7 +67,7 @@
 								NULL, NULL, instance, NULL);
 
 		if (!m_window)
-			throw ResourceError("Failed to create Win32 window", "", __FILE__, __LINE__);
+			TCU_THROW(ResourceError, "Failed to create Win32 window");
 
 		// Store this as userdata
 		SetWindowLongPtr(m_window, GWLP_USERDATA, (LONG_PTR)this);
@@ -109,19 +109,19 @@
 	rc.bottom	= height;
 
 	if (!AdjustWindowRect(&rc, GetWindowLong(m_window, GWL_STYLE), GetMenu(m_window) != NULL))
-		throw tcu::TestError("AdjustWindowRect() failed", DE_NULL, __FILE__, __LINE__);
+		TCU_THROW(TestError, "AdjustWindowRect() failed");
 
 	if (!SetWindowPos(m_window, NULL, 0, 0,
 					  rc.right - rc.left, rc.bottom - rc.top,
 					  SWP_NOACTIVATE | SWP_NOCOPYBITS | SWP_NOMOVE | SWP_NOZORDER))
-		throw tcu::TestError("SetWindowPos() failed", DE_NULL, __FILE__, __LINE__);
+		TCU_THROW(TestError, "SetWindowPos() failed");
 }
 
 IVec2 Win32Window::getSize (void) const
 {
 	RECT rc;
 	if (!GetClientRect(m_window, &rc))
-		throw tcu::TestError("GetClientRect() failed", DE_NULL, __FILE__, __LINE__);
+		TCU_THROW(TestError, "GetClientRect() failed");
 
 	return IVec2(rc.right - rc.left,
 				 rc.bottom - rc.top);
diff --git a/framework/referencerenderer/rrMultisamplePixelBufferAccess.cpp b/framework/referencerenderer/rrMultisamplePixelBufferAccess.cpp
index 65e0b6a..f7effbd 100644
--- a/framework/referencerenderer/rrMultisamplePixelBufferAccess.cpp
+++ b/framework/referencerenderer/rrMultisamplePixelBufferAccess.cpp
@@ -129,10 +129,16 @@
 	DE_ASSERT(dst.getWidth() == src.raw().getHeight());
 	DE_ASSERT(dst.getHeight() == src.raw().getDepth());
 
-	float numSamplesInv = 1.0f / (float)src.getNumSamples();
-
-	for (int y = 0; y < dst.getHeight(); y++)
+	if (src.getNumSamples() == 1)
 	{
+		// fast-path for non-multisampled cases
+		tcu::copy(dst, src.toSinglesampleAccess());
+	}
+	else
+	{
+		const float numSamplesInv = 1.0f / (float)src.getNumSamples();
+
+		for (int y = 0; y < dst.getHeight(); y++)
 		for (int x = 0; x < dst.getWidth(); x++)
 		{
 			tcu::Vec4 sum;
diff --git a/framework/referencerenderer/rrRasterizer.cpp b/framework/referencerenderer/rrRasterizer.cpp
index 855763d..9a8bff1 100644
--- a/framework/referencerenderer/rrRasterizer.cpp
+++ b/framework/referencerenderer/rrRasterizer.cpp
@@ -239,6 +239,43 @@
 
 	const deInt64 halfPixel = 1ll << (RASTERIZER_SUBPIXEL_BITS-1);
 
+	// Reject distant diamonds early
+	{
+		const tcu::Vector<deInt64,2>	u				= line.direction();
+		const tcu::Vector<deInt64,2>	v				= (diamondCenter - line.m_v0);
+		const deInt64					crossProduct	= (u.x() * v.y() - u.y() * v.x());
+
+		// crossProduct = |p| |l| sin(theta)
+		// distanceFromLine = |p| sin(theta)
+		// => distanceFromLine = crossProduct / |l|
+		//
+		// |distanceFromLine| > C
+		// => distanceFromLine^2 > C^2
+		// => crossProduct^2 / |l|^2 > C^2
+		// => crossProduct^2 > |l|^2 * C^2
+
+		const deInt64	floorSqrtMaxInt64			= 3037000499LL; //!< floor(sqrt(MAX_INT64))
+
+		const deInt64	broadRejectDistance			= 2 * halfPixel;
+		const deInt64	broadRejectDistanceSquared	= broadRejectDistance * broadRejectDistance;
+		const bool		crossProductOverflows		= (crossProduct > floorSqrtMaxInt64 || crossProduct < -floorSqrtMaxInt64);
+		const deInt64	crossProductSquared			= (crossProductOverflows) ? (0) : (crossProduct * crossProduct); // avoid overflow
+		const deInt64	lineLengthSquared			= tcu::lengthSquared(u);
+		const bool		limitValueCouldOverflow		= ((64 - deClz64(lineLengthSquared)) + (64 - deClz64(broadRejectDistanceSquared))) > 63;
+		const deInt64	limitValue					= (limitValueCouldOverflow) ? (0) : (lineLengthSquared * broadRejectDistanceSquared); // avoid overflow
+
+		// only cross overflows
+		if (crossProductOverflows && !limitValueCouldOverflow)
+			return false;
+
+		// both representable
+		if (!crossProductOverflows && !limitValueCouldOverflow)
+		{
+			if (crossProductSquared > limitValue)
+				return false;
+		}
+	}
+
 	const struct DiamondBound
 	{
 		tcu::Vector<deInt64,2>	p0;
@@ -281,7 +318,6 @@
 		CORNER_EDGE_CASE_BEHAVIOR	lineBehavior;			// would a line segment going through this corner intersect with the region
 		CORNER_START_CASE_BEHAVIOR	startBehavior;			// how the corner behaves if the start point at the corner
 		CORNER_END_CASE_BEHAVIOR	endBehavior;			// how the corner behaves if the end point at the corner
-
 	} corners[] =
 	{
 		{ tcu::Vector<deInt64,2>(0,				-halfPixel),	false,	DiamondCorners::CORNER_EDGE_CASE_HIT_SECOND_QUARTER,	DiamondCorners::CORNER_START_CASE_POSITIVE_Y_45,	DiamondCorners::CORNER_END_CASE_DIRECTION_AND_SECOND_QUARTER},
diff --git a/modules/egl/teglAndroidUtil.cpp b/modules/egl/teglAndroidUtil.cpp
index 0518bfc..e79b58e 100644
--- a/modules/egl/teglAndroidUtil.cpp
+++ b/modules/egl/teglAndroidUtil.cpp
@@ -27,6 +27,8 @@
 #include "tcuTextureUtil.hpp"
 #include "gluTextureUtil.hpp"
 #include "glwEnums.hpp"
+#include "eglwLibrary.hpp"
+#include "eglwEnums.hpp"
 
 #if (DE_OS == DE_OS_ANDROID)
 #	include "tcuAndroidInternals.hpp"
@@ -45,12 +47,13 @@
 using tcu::Texture2D;
 using eglu::AttribMap;
 using namespace glw;
+using namespace eglw;
 
 #if (DE_OS != DE_OS_ANDROID)
 
 MovePtr<ImageSource> createAndroidNativeImageSource	(GLenum)
 {
-	return createUnsupportedImageSource("Not an android platform");
+	return createUnsupportedImageSource("Not Android platform");
 }
 
 #else // DE_OS == DE_OS_ANDROID
@@ -101,7 +104,7 @@
 							AndroidNativeImageSource	(GLenum format) : m_format(format) {}
 	MovePtr<ClientBuffer>	createBuffer 				(const glw::Functions&, Texture2D*) const;
 	string					getRequiredExtension		(void) const { return "EGL_ANDROID_image_native_buffer"; }
-	EGLImageKHR				createImage					(const eglu::ImageFunctions& imgExt, EGLDisplay dpy, EGLContext ctx, EGLClientBuffer clientBuffer) const;
+	EGLImageKHR				createImage					(const Library& egl, EGLDisplay dpy, EGLContext ctx, EGLClientBuffer clientBuffer) const;
 
 protected:
 	GLenum					m_format;
@@ -138,12 +141,12 @@
 	return MovePtr<ClientBuffer>(buffer);
 }
 
-EGLImageKHR AndroidNativeImageSource::createImage (const eglu::ImageFunctions& imgExt, EGLDisplay dpy, EGLContext, EGLClientBuffer clientBuffer) const
+EGLImageKHR AndroidNativeImageSource::createImage (const Library& egl, EGLDisplay dpy, EGLContext, EGLClientBuffer clientBuffer) const
 {
 	static const EGLint attribs[] = { EGL_IMAGE_PRESERVED_KHR, EGL_TRUE, EGL_NONE };
-	const EGLImageKHR	image 		= imgExt.createImage(dpy, EGL_NO_CONTEXT, EGL_NATIVE_BUFFER_ANDROID, clientBuffer, attribs);
+	const EGLImageKHR	image 		= egl.createImageKHR(dpy, EGL_NO_CONTEXT, EGL_NATIVE_BUFFER_ANDROID, clientBuffer, attribs);
 
-	EGLU_CHECK_MSG("eglCreateImageKHR()");
+	EGLU_CHECK_MSG(egl, "eglCreateImageKHR()");
 	return image;
 }
 
diff --git a/modules/egl/teglApiCase.cpp b/modules/egl/teglApiCase.cpp
index 02ec975..3e34e56 100644
--- a/modules/egl/teglApiCase.cpp
+++ b/modules/egl/teglApiCase.cpp
@@ -22,18 +22,25 @@
  *//*--------------------------------------------------------------------*/
 
 #include "teglApiCase.hpp"
+#include "egluUtil.hpp"
 #include "egluStrUtil.hpp"
-
-using tcu::TestLog;
+#include "eglwLibrary.hpp"
+#include "eglwEnums.hpp"
+#include "deSTLUtil.hpp"
 
 namespace deqp
 {
 namespace egl
 {
 
+using tcu::TestLog;
+using std::vector;
+using namespace eglw;
+
 ApiCase::ApiCase (EglTestContext& eglTestCtx, const char* name, const char* description)
 	: TestCase		(eglTestCtx, name, description)
-	, CallLogWrapper(eglTestCtx.getTestContext().getLog())
+	, CallLogWrapper(eglTestCtx.getLibrary(), eglTestCtx.getTestContext().getLog())
+	, m_display		(EGL_NO_DISPLAY)
 {
 }
 
@@ -41,6 +48,21 @@
 {
 }
 
+void ApiCase::init (void)
+{
+	m_display				= eglu::getAndInitDisplay(m_eglTestCtx.getNativeDisplay());
+	m_supportedClientAPIs	= eglu::getClientAPIs(m_eglTestCtx.getLibrary(), m_display);
+}
+
+void ApiCase::deinit (void)
+{
+	const Library&	egl	= m_eglTestCtx.getLibrary();
+	egl.terminate(m_display);
+
+	m_display = EGL_NO_DISPLAY;
+	m_supportedClientAPIs.clear();
+}
+
 ApiCase::IterateResult ApiCase::iterate (void)
 {
 	// Initialize result to pass.
@@ -55,9 +77,14 @@
 	return STOP;
 }
 
+bool ApiCase::isAPISupported (eglw::EGLenum api) const
+{
+	return de::contains(m_supportedClientAPIs.begin(), m_supportedClientAPIs.end(), api);
+}
+
 void ApiCase::expectError (EGLenum expected)
 {
-	EGLenum err = eglGetError();
+	EGLenum err = m_eglTestCtx.getLibrary().getError();
 	if (err != expected)
 	{
 		m_testCtx.getLog() << TestLog::Message << "// ERROR: expected " << eglu::getErrorStr(expected) << TestLog::EndMessage;
@@ -118,40 +145,17 @@
 	}
 }
 
-bool ApiCase::getConfig (EGLConfig* config,const eglu::FilterList& filters)
+bool ApiCase::getConfig (EGLConfig* config, const eglu::FilterList& filters)
 {
-	for (std::vector<eglu::ConfigInfo>::const_iterator cfgIter = m_eglTestCtx.getConfigs().begin(); cfgIter != m_eglTestCtx.getConfigs().end(); ++cfgIter)
+	try
 	{
-		if (filters.match(*cfgIter))
-		{
-			EGLint		numCfgs;
-			EGLBoolean	ok;
-			EGLint		attribs[] =
-			{
-				EGL_CONFIG_ID,			cfgIter->configId,
-				EGL_TRANSPARENT_TYPE,	EGL_DONT_CARE,
-				EGL_COLOR_BUFFER_TYPE,	EGL_DONT_CARE,
-				EGL_RENDERABLE_TYPE,	EGL_DONT_CARE,
-				EGL_SURFACE_TYPE,		EGL_DONT_CARE,
-				EGL_NONE
-			};
-
-			ok = eglChooseConfig(getDisplay(), &attribs[0], config, 1, &numCfgs);
-			expectTrue(ok);
-
-			if (ok && numCfgs >= 1)
-				return true;
-			else
-			{
-				m_testCtx.getLog() << TestLog::Message << "// ERROR: expected at least one config with id " << cfgIter->configId << TestLog::EndMessage;
-				if (m_testCtx.getTestResult() == QP_TEST_RESULT_PASS)
-					m_testCtx.setTestResult(QP_TEST_RESULT_FAIL, "Got invalid value");
-				return 0;
-			}
-		}
+		*config = eglu::chooseSingleConfig(m_eglTestCtx.getLibrary(), m_display, filters);
+		return true;
 	}
-
-	return DE_NULL;
+	catch (const tcu::NotSupportedError&)
+	{
+		return false;
+	}
 }
 
 } // egl
diff --git a/modules/egl/teglApiCase.hpp b/modules/egl/teglApiCase.hpp
index e80fc65..445a0c0 100644
--- a/modules/egl/teglApiCase.hpp
+++ b/modules/egl/teglApiCase.hpp
@@ -26,8 +26,10 @@
 #include "tcuDefs.hpp"
 #include "teglTestCase.hpp"
 #include "egluCallLogWrapper.hpp"
-#include "tcuTestLog.hpp"
 #include "egluConfigFilter.hpp"
+#include "eglwEnums.hpp"
+
+#include <vector>
 
 namespace deqp
 {
@@ -40,25 +42,32 @@
 						ApiCase					(EglTestContext& eglTestCtx, const char* name, const char* description);
 	virtual				~ApiCase				(void);
 
+	void				init					(void);
+	void				deinit					(void);
+
 	IterateResult		iterate					(void);
 
 protected:
 	virtual void		test					(void) = DE_NULL;
 
-	void				expectError				(EGLenum error);
-	void				expectBoolean			(EGLBoolean expected, EGLBoolean got);
+	void				expectError				(eglw::EGLenum error);
+	void				expectBoolean			(eglw::EGLBoolean expected, eglw::EGLBoolean got);
 
-	void				expectNoContext			(EGLContext got);
-	void				expectNoSurface			(EGLSurface got);
-	void				expectNoDisplay			(EGLDisplay got);
+	void				expectNoContext			(eglw::EGLContext got);
+	void				expectNoSurface			(eglw::EGLSurface got);
+	void				expectNoDisplay			(eglw::EGLDisplay got);
 	void				expectNull				(const void* got);
 
-	inline void			expectTrue				(EGLBoolean got) { expectBoolean(EGL_TRUE, got); }
-	inline void			expectFalse				(EGLBoolean got) { expectBoolean(EGL_FALSE, got); }
+	inline void			expectTrue				(eglw::EGLBoolean got) { expectBoolean(EGL_TRUE, got); }
+	inline void			expectFalse				(eglw::EGLBoolean got) { expectBoolean(EGL_FALSE, got); }
 
-	bool				isAPISupported			(EGLenum api) const	{ return m_eglTestCtx.isAPISupported(api);			}
-	EGLDisplay			getDisplay				(void)				{ return m_eglTestCtx.getDisplay().getEGLDisplay(); }
-	bool				getConfig				(EGLConfig* cfg, const eglu::FilterList& filters);
+	eglw::EGLDisplay	getDisplay				(void)						{ return m_display;							}
+	bool				isAPISupported			(eglw::EGLenum api) const;
+	bool				getConfig				(eglw::EGLConfig* cfg, const eglu::FilterList& filters);
+
+private:
+	eglw::EGLDisplay							m_display;
+	std::vector<eglw::EGLenum>					m_supportedClientAPIs;
 };
 
 } // egl
diff --git a/modules/egl/teglChooseConfigReference.cpp b/modules/egl/teglChooseConfigReference.cpp
index 10f2530..acc0914 100644
--- a/modules/egl/teglChooseConfigReference.cpp
+++ b/modules/egl/teglChooseConfigReference.cpp
@@ -23,6 +23,12 @@
 
 #include "teglChooseConfigReference.hpp"
 
+#include "egluUtil.hpp"
+#include "egluConfigInfo.hpp"
+#include "egluStrUtil.hpp"
+#include "eglwLibrary.hpp"
+#include "eglwEnums.hpp"
+
 #include <algorithm>
 #include <vector>
 #include <map>
@@ -32,6 +38,7 @@
 namespace egl
 {
 
+using namespace eglw;
 using eglu::ConfigInfo;
 
 enum Criteria
@@ -87,7 +94,8 @@
 			case EGL_NONE:					return 0;
 			case EGL_SLOW_CONFIG:			return 1;
 			case EGL_NON_CONFORMANT_CONFIG:	return 2;
-			default: DE_ASSERT(DE_FALSE);	return 3;
+			default:
+				TCU_THROW(TestError, (std::string("Unknown config caveat: ") + eglu::getConfigCaveatStr(caveat).toString()).c_str());
 		}
 	}
 
@@ -97,7 +105,8 @@
 		{
 			case EGL_RGB_BUFFER:			return 0;
 			case EGL_LUMINANCE_BUFFER:		return 1;
-			default: DE_ASSERT(DE_FALSE);	return 2;
+			default:
+				TCU_THROW(TestError, (std::string("Unknown color buffer type: ") + eglu::getColorBufferTypeStr(type).toString()).c_str());
 		}
 	}
 
@@ -354,19 +363,16 @@
 	}
 };
 
-void chooseConfigReference (const tcu::egl::Display& display, std::vector<EGLConfig>& dst, const std::vector<std::pair<EGLenum, EGLint> >& attributes)
+void chooseConfigReference (const Library& egl, EGLDisplay display, std::vector<EGLConfig>& dst, const std::vector<std::pair<EGLenum, EGLint> >& attributes)
 {
 	// Get all configs
-	std::vector<EGLConfig> eglConfigs;
-	display.getConfigs(eglConfigs);
+	std::vector<EGLConfig> eglConfigs = eglu::getConfigs(egl, display);
 
 	// Config infos
 	std::vector<ConfigInfo> configInfos;
 	configInfos.resize(eglConfigs.size());
 	for (size_t ndx = 0; ndx < eglConfigs.size(); ndx++)
-		display.describeConfig(eglConfigs[ndx], configInfos[ndx]);
-
-	TCU_CHECK_EGL_MSG("Config query failed");
+		eglu::queryConfigInfo(egl, display, eglConfigs[ndx], &configInfos[ndx]);
 
 	// Pair configs with info
 	std::vector<SurfaceConfig> configs;
diff --git a/modules/egl/teglChooseConfigReference.hpp b/modules/egl/teglChooseConfigReference.hpp
index bb93df4..5effc0d 100644
--- a/modules/egl/teglChooseConfigReference.hpp
+++ b/modules/egl/teglChooseConfigReference.hpp
@@ -26,12 +26,17 @@
 #include "tcuDefs.hpp"
 #include "teglTestCase.hpp"
 
+namespace eglw
+{
+class Library;
+}
+
 namespace deqp
 {
 namespace egl
 {
 
-void chooseConfigReference (const tcu::egl::Display& display, std::vector<EGLConfig>& dst, const std::vector<std::pair<EGLenum, EGLint> >& attributes);
+void chooseConfigReference (const eglw::Library& egl, eglw::EGLDisplay display, std::vector<eglw::EGLConfig>& dst, const std::vector<std::pair<eglw::EGLenum, eglw::EGLint> >& attributes);
 
 } // egl
 } // deqp
diff --git a/modules/egl/teglChooseConfigTests.cpp b/modules/egl/teglChooseConfigTests.cpp
index cfa8899..b8154ba 100644
--- a/modules/egl/teglChooseConfigTests.cpp
+++ b/modules/egl/teglChooseConfigTests.cpp
@@ -25,6 +25,9 @@
 #include "teglChooseConfigReference.hpp"
 #include "tcuTestLog.hpp"
 #include "egluStrUtil.hpp"
+#include "egluUtil.hpp"
+#include "eglwLibrary.hpp"
+#include "eglwEnums.hpp"
 #include "deRandom.hpp"
 #include "deStringUtil.hpp"
 
@@ -34,29 +37,29 @@
 #include <set>
 #include <map>
 
-using std::set;
-using std::vector;
-using std::pair;
-using std::string;
-using tcu::TestLog;
-
 namespace deqp
 {
 namespace egl
 {
 
+using std::set;
+using std::vector;
+using std::pair;
+using std::string;
+using tcu::TestLog;
 using eglu::ConfigInfo;
+using namespace eglw;
 
 namespace
 {
 
-string configListToString (const tcu::egl::Display& display, const vector<EGLConfig>& configs)
+string configListToString (const Library& egl, const EGLDisplay& display, const vector<EGLConfig>& configs)
 {
 	string str = "";
 	for (vector<EGLConfig>::const_iterator cfgIter = configs.begin(); cfgIter != configs.end(); cfgIter++)
 	{
 		EGLConfig	config		= *cfgIter;
-		EGLint		configId	= display.getConfigAttrib(config, EGL_CONFIG_ID);
+		EGLint		configId	= eglu::getConfigID(egl, display, config);
 
 		if (str.length() != 0)
 			str += " ";
@@ -87,6 +90,7 @@
 	ChooseConfigCase (EglTestContext& eglTestCtx, const char* name, const char* description, bool checkOrder, const EGLint* attributes)
 		: TestCase		(eglTestCtx, name, description)
 		, m_checkOrder	(checkOrder)
+		, m_display		(EGL_NO_DISPLAY)
 	{
 		// Parse attributes
 		while (attributes[0] != EGL_NONE)
@@ -100,27 +104,41 @@
 		: TestCase		(eglTestCtx, name, description)
 		, m_checkOrder	(checkOrder)
 		, m_attributes	(attributes)
+		, m_display		(EGL_NO_DISPLAY)
 	{
 	}
 
+	void init (void)
+	{
+		DE_ASSERT(m_display == EGL_NO_DISPLAY);
+		m_display	= eglu::getAndInitDisplay(m_eglTestCtx.getNativeDisplay());
+	}
+
+	void deinit (void)
+	{
+		m_eglTestCtx.getLibrary().terminate(m_display);
+		m_display = EGL_NO_DISPLAY;
+	}
+
 	IterateResult iterate (void)
 	{
 		m_testCtx.setTestResult(QP_TEST_RESULT_PASS, "Pass");
-
 		executeTest(m_attributes, m_checkOrder);
 		return STOP;
 	}
+
 protected:
 	ChooseConfigCase (EglTestContext& eglTestCtx, const char* name, const char* description, bool checkOrder)
 		: TestCase		(eglTestCtx, name, description)
 		, m_checkOrder	(checkOrder)
+		, m_display		(EGL_NO_DISPLAY)
 	{
 	}
 
 	void executeTest (const std::vector<std::pair<EGLenum, EGLint> >& attributes, bool checkOrder)
 	{
-		TestLog&					log		= m_testCtx.getLog();
-		const tcu::egl::Display&	display	= m_eglTestCtx.getDisplay();
+		const Library&	egl	= m_eglTestCtx.getLibrary();
+		TestLog&		log	= m_testCtx.getLog();
 
 		// Build attributes for EGL
 		vector<EGLint> attribList;
@@ -142,18 +160,18 @@
 		// Query from EGL implementation
 		{
 			EGLint numConfigs = 0;
-			TCU_CHECK_EGL_CALL(eglChooseConfig(display.getEGLDisplay(), &attribList[0], DE_NULL, 0, &numConfigs));
+			EGLU_CHECK_CALL(egl, chooseConfig(m_display, &attribList[0], DE_NULL, 0, &numConfigs));
 			resultConfigs.resize(numConfigs);
 
 			if (numConfigs > 0)
-				TCU_CHECK_EGL_CALL(eglChooseConfig(display.getEGLDisplay(), &attribList[0], &resultConfigs[0], (EGLint)resultConfigs.size(), &numConfigs));
+				EGLU_CHECK_CALL(egl, chooseConfig(m_display, &attribList[0], &resultConfigs[0], (EGLint)resultConfigs.size(), &numConfigs));
 		}
 
 		// Build reference
-		chooseConfigReference(display, referenceConfigs, attributes);
+		chooseConfigReference(egl, m_display, referenceConfigs, attributes);
 
-		log << TestLog::Message << "Expected:\n  " << configListToString(display, referenceConfigs) << TestLog::EndMessage;
-		log << TestLog::Message << "Got:\n  " << configListToString(display, resultConfigs) << TestLog::EndMessage;
+		log << TestLog::Message << "Expected:\n  " << configListToString(egl, m_display, referenceConfigs) << TestLog::EndMessage;
+		log << TestLog::Message << "Got:\n  " << configListToString(egl, m_display, resultConfigs) << TestLog::EndMessage;
 
 		bool isSetMatch		= (set<EGLConfig>(resultConfigs.begin(), resultConfigs.end()) == set<EGLConfig>(referenceConfigs.begin(), referenceConfigs.end()));
 		bool isExactMatch	= (resultConfigs == referenceConfigs);
@@ -191,8 +209,10 @@
 		}
 	}
 
-	bool							m_checkOrder;
+	const bool						m_checkOrder;
 	vector<pair<EGLenum, EGLint> >	m_attributes;
+
+	EGLDisplay						m_display;
 };
 
 class ChooseConfigSimpleCase : public ChooseConfigCase
@@ -204,7 +224,8 @@
 		{
 			EGLenum		name;
 			EGLint		value;
-		} attributes[] = {
+		} attributes[] =
+		{
 			{ EGL_BUFFER_SIZE,				0					},
 			{ EGL_RED_SIZE,					0					},
 			{ EGL_GREEN_SIZE,				0					},
@@ -248,13 +269,15 @@
 		if (name == EGL_CONFIG_ID)
 		{
 			de::Random rnd(0);
-			return m_eglTestCtx.getConfigs()[rnd.getInt(0, (int)(m_eglTestCtx.getConfigs().size()-1))].configId;
+			vector<EGLConfig> configs = eglu::getConfigs(m_eglTestCtx.getLibrary(), m_display);
+			return eglu::getConfigID(m_eglTestCtx.getLibrary(), m_display, configs[rnd.getInt(0, (int)configs.size()-1)]);
 		}
 		else
 		{
 			for (int ndx = 0; ndx < DE_LENGTH_OF_ARRAY(attributes); ndx++)
 			{
-				if (attributes[ndx].name == name) return attributes[ndx].value;
+				if (attributes[ndx].name == name)
+					return attributes[ndx].value;
 			}
 		}
 
@@ -268,10 +291,6 @@
 	{
 	}
 
-	void init (void)
-	{
-	}
-
 	TestCase::IterateResult iterate (void)
 	{
 		m_testCtx.setTestResult(QP_TEST_RESULT_PASS, "Pass");
@@ -301,6 +320,7 @@
 
 	void init (void)
 	{
+		ChooseConfigCase::init();
 		m_iterNdx = 0;
 		m_testCtx.setTestResult(QP_TEST_RESULT_PASS, "Pass");
 	}
diff --git a/modules/egl/teglClientExtensionTests.cpp b/modules/egl/teglClientExtensionTests.cpp
index e089cac..75ae58e 100644
--- a/modules/egl/teglClientExtensionTests.cpp
+++ b/modules/egl/teglClientExtensionTests.cpp
@@ -25,7 +25,13 @@
 
 #include "tcuTestLog.hpp"
 
-#include <EGL/egl.h>
+#include "egluUtil.hpp"
+
+#include "eglwLibrary.hpp"
+#include "eglwEnums.hpp"
+
+#include "deStringUtil.hpp"
+#include "deSTLUtil.hpp"
 
 #include <vector>
 #include <set>
@@ -38,6 +44,8 @@
 
 using tcu::TestLog;
 
+using namespace eglw;
+
 namespace deqp
 {
 namespace egl
@@ -111,17 +119,6 @@
 	"EGL_EXT_platform_wayland"
 };
 
-void splitExtensions (vector<string>& extensions, const char* str)
-{
-	std::istringstream	stream(str);
-	string				extension;
-
-	extensions.clear();
-
-	while (std::getline(stream, extension, ' '))
-		extensions.push_back(extension);
-}
-
 class BaseTest : public TestCase
 {
 public:
@@ -136,19 +133,20 @@
 
 TestCase::IterateResult BaseTest::iterate (void)
 {
-	const char* const	clientExtesionsStr	= eglQueryString(EGL_NO_DISPLAY, EGL_EXTENSIONS);
-	const EGLint		eglError			= eglGetError();
+	const Library&		egl					= m_eglTestCtx.getLibrary();
+	const char* const	clientExtesionsStr	= egl.queryString(EGL_NO_DISPLAY, EGL_EXTENSIONS);
+	const EGLint		eglError			= egl.getError();
 
 	if (eglError == EGL_BAD_DISPLAY)
-		throw tcu::NotSupportedError("EGL_EXT_client_extensions not supported", "", __FILE__, __LINE__);
+		TCU_THROW(NotSupportedError, "EGL_EXT_client_extensions not supported");
 	else if (eglError != EGL_SUCCESS)
-		throw eglu::Error(eglError, "eglQueryString()", "", __FILE__, __LINE__);
+		throw eglu::Error(eglError, "eglQueryString()", DE_NULL, __FILE__, __LINE__);
 
 	TCU_CHECK(clientExtesionsStr);
 
 	{
-		bool				found = false;
-		std::istringstream	stream(clientExtesionsStr);
+		bool				found		= false;
+		std::istringstream	stream		(clientExtesionsStr);
 		string				extension;
 
 		while (std::getline(stream, extension, ' '))
@@ -186,25 +184,33 @@
 
 TestCase::IterateResult CheckExtensionsTest::iterate (void)
 {
-	bool				isOk				= true;
-	const char* const	clientExtesionsStr	= eglQueryString(EGL_NO_DISPLAY, EGL_EXTENSIONS);
-	const EGLint		eglQueryError		= eglGetError();
+	const Library&		egl						= m_eglTestCtx.getLibrary();
+	bool				isOk					= true;
+	const char* const	clientExtensionsStr		= egl.queryString(EGL_NO_DISPLAY, EGL_EXTENSIONS);
+	const EGLint		eglQueryError			= egl.getError();
 
-	set<string>		knownClientExtensions(s_clientExtensionList, s_clientExtensionList + DE_LENGTH_OF_ARRAY(s_clientExtensionList));
-	set<string>		knownDisplayExtensions(s_displayExtensionList, s_displayExtensionList + DE_LENGTH_OF_ARRAY(s_displayExtensionList));
+	set<string>			knownClientExtensions	(s_clientExtensionList, s_clientExtensionList + DE_LENGTH_OF_ARRAY(s_clientExtensionList));
+	set<string>			knownDisplayExtensions	(s_displayExtensionList, s_displayExtensionList + DE_LENGTH_OF_ARRAY(s_displayExtensionList));
 
-	vector<string>	displayExtensions;
-	vector<string>	clientExtensions;
+	vector<string>		displayExtensions;
+	vector<string>		clientExtensions;
 
 	if (eglQueryError == EGL_BAD_DISPLAY)
-		throw tcu::NotSupportedError("EGL_EXT_client_extensions not supported", "", __FILE__, __LINE__);
+		TCU_THROW(NotSupportedError, "EGL_EXT_client_extensions not supported");
 	else if (eglQueryError != EGL_SUCCESS)
-		throw eglu::Error(eglQueryError, "eglQueryString()", "", __FILE__, __LINE__);
+		throw eglu::Error(eglQueryError, "eglQueryString()", DE_NULL, __FILE__, __LINE__);
 
-	TCU_CHECK(clientExtesionsStr);
+	TCU_CHECK(clientExtensionsStr);
 
-	splitExtensions(clientExtensions, clientExtesionsStr);
-	m_eglTestCtx.getDisplay().getExtensions(displayExtensions);
+	clientExtensions = de::splitString(clientExtensionsStr, ' ');
+
+	{
+		EGLDisplay	display	= eglu::getAndInitDisplay(m_eglTestCtx.getNativeDisplay());
+
+		displayExtensions = de::splitString(egl.queryString(display, EGL_EXTENSIONS), ' ');
+
+		egl.terminate(display);
+	}
 
 	for (int extNdx = 0; extNdx < (int)clientExtensions.size(); extNdx++)
 	{
@@ -246,19 +252,27 @@
 
 TestCase::IterateResult DisjointTest::iterate (void)
 {
-	const char*	const	clientExtesionsStr	= eglQueryString(EGL_NO_DISPLAY, EGL_EXTENSIONS);
-	const EGLint		eglQueryError		= eglGetError();
+	const Library&		egl					= m_eglTestCtx.getLibrary();
+	const char*	const	clientExtensionsStr	= egl.queryString(EGL_NO_DISPLAY, EGL_EXTENSIONS);
+	const EGLint		eglQueryError		= egl.getError();
 
 	if (eglQueryError == EGL_BAD_DISPLAY)
-		throw tcu::NotSupportedError("EGL_EXT_client_extensions not supported", "", __FILE__, __LINE__);
+		TCU_THROW(NotSupportedError, "EGL_EXT_client_extensions not supported");
 	else if (eglQueryError != EGL_SUCCESS)
-		throw eglu::Error(eglQueryError, "eglQueryString()", "", __FILE__, __LINE__);
+		throw eglu::Error(eglQueryError, "eglQueryString()", DE_NULL, __FILE__, __LINE__);
 
-	vector<string> displayExtensions;
-	vector<string> clientExtensions;
+	vector<string>		displayExtensions;
+	vector<string>		clientExtensions;
 
-	splitExtensions(clientExtensions, clientExtesionsStr);
-	m_eglTestCtx.getDisplay().getExtensions(displayExtensions);
+	clientExtensions = de::splitString(clientExtensionsStr, ' ');
+
+	{
+		EGLDisplay	display	= eglu::getAndInitDisplay(m_eglTestCtx.getNativeDisplay());
+
+		displayExtensions = de::splitString(egl.queryString(display, EGL_EXTENSIONS), ' ');
+
+		egl.terminate(display);
+	}
 
 	// Log client extensions
 	{
diff --git a/modules/egl/teglColorClearCase.cpp b/modules/egl/teglColorClearCase.cpp
index e280997..9f6bce1 100644
--- a/modules/egl/teglColorClearCase.cpp
+++ b/modules/egl/teglColorClearCase.cpp
@@ -23,11 +23,16 @@
 
 #include "teglColorClearCase.hpp"
 #include "tcuTestLog.hpp"
+#include "eglwLibrary.hpp"
+#include "eglwEnums.hpp"
+#include "egluUtil.hpp"
 #include "deRandom.hpp"
 #include "deString.h"
 #include "tcuImageCompare.hpp"
 #include "tcuVector.hpp"
 #include "tcuTextureUtil.hpp"
+#include "tcuPixelFormat.hpp"
+#include "glwFunctions.hpp"
 #include "deThread.hpp"
 #include "deSemaphore.hpp"
 #include "deSharedPtr.hpp"
@@ -38,25 +43,16 @@
 #include <memory>
 #include <iterator>
 
-#include <EGL/eglext.h>
-
-#if !defined(EGL_OPENGL_ES3_BIT_KHR)
-#	define EGL_OPENGL_ES3_BIT_KHR	0x0040
-#endif
-#if !defined(EGL_CONTEXT_MAJOR_VERSION_KHR)
-#	define EGL_CONTEXT_MAJOR_VERSION_KHR EGL_CONTEXT_CLIENT_VERSION
-#endif
-
-using tcu::TestLog;
-using tcu::RGBA;
-
-using std::vector;
-
 namespace deqp
 {
 namespace egl
 {
 
+using tcu::TestLog;
+using tcu::RGBA;
+using std::vector;
+using namespace eglw;
+
 // Utilities.
 
 struct ClearOp
@@ -86,6 +82,11 @@
 	tcu::RGBA	color;
 };
 
+struct ApiFunctions
+{
+	glw::Functions	gl;
+};
+
 static ClearOp computeRandomClear (de::Random& rnd, int width, int height)
 {
 	int			w		= rnd.getInt(1, width);
@@ -106,87 +107,103 @@
 	}
 }
 
-static void renderClear (EGLint api, const ClearOp& clear)
+static void renderClear (EGLint api, const ApiFunctions& func, const ClearOp& clear)
 {
 	switch (api)
 	{
-		case EGL_OPENGL_ES_BIT:			gles1::clear(clear.x, clear.y, clear.width, clear.height, clear.color.toVec());	break;
-		case EGL_OPENGL_ES2_BIT:		gles2::clear(clear.x, clear.y, clear.width, clear.height, clear.color.toVec());	break;
-		case EGL_OPENGL_ES3_BIT_KHR:	gles2::clear(clear.x, clear.y, clear.width, clear.height, clear.color.toVec());	break;
-		case EGL_OPENVG_BIT:			vg::clear	(clear.x, clear.y, clear.width, clear.height, clear.color.toVec());	break;
+		case EGL_OPENGL_ES_BIT:			gles1::clear(clear.x, clear.y, clear.width, clear.height, clear.color.toVec());				break;
+		case EGL_OPENGL_ES2_BIT:		gles2::clear(func.gl, clear.x, clear.y, clear.width, clear.height, clear.color.toVec());	break;
+		case EGL_OPENGL_ES3_BIT_KHR:	gles2::clear(func.gl, clear.x, clear.y, clear.width, clear.height, clear.color.toVec());	break;
+		case EGL_OPENVG_BIT:			vg::clear	(clear.x, clear.y, clear.width, clear.height, clear.color.toVec());				break;
 		default:
 			DE_ASSERT(DE_FALSE);
 	}
 }
 
-static void readPixels (EGLint api, tcu::Surface& dst)
+static void readPixels (EGLint api, const ApiFunctions& func, tcu::Surface& dst)
 {
 	switch (api)
 	{
-		case EGL_OPENGL_ES_BIT:			gles1::readPixels	(dst, 0, 0, dst.getWidth(), dst.getHeight());	break;
-		case EGL_OPENGL_ES2_BIT:		gles2::readPixels	(dst, 0, 0, dst.getWidth(), dst.getHeight());	break;
-		case EGL_OPENGL_ES3_BIT_KHR:	gles2::readPixels	(dst, 0, 0, dst.getWidth(), dst.getHeight());	break;
-		case EGL_OPENVG_BIT:			vg::readPixels		(dst, 0, 0, dst.getWidth(), dst.getHeight());	break;
+		case EGL_OPENGL_ES_BIT:			gles1::readPixels	(dst, 0, 0, dst.getWidth(), dst.getHeight());			break;
+		case EGL_OPENGL_ES2_BIT:		gles2::readPixels	(func.gl, dst, 0, 0, dst.getWidth(), dst.getHeight());	break;
+		case EGL_OPENGL_ES3_BIT_KHR:	gles2::readPixels	(func.gl, dst, 0, 0, dst.getWidth(), dst.getHeight());	break;
+		case EGL_OPENVG_BIT:			vg::readPixels		(dst, 0, 0, dst.getWidth(), dst.getHeight());			break;
 		default:
 			DE_ASSERT(DE_FALSE);
 	}
 }
 
+static tcu::PixelFormat getPixelFormat (const Library& egl, EGLDisplay display, EGLConfig config)
+{
+	tcu::PixelFormat pixelFmt;
+
+	egl.getConfigAttrib(display, config, EGL_RED_SIZE,		&pixelFmt.redBits);
+	egl.getConfigAttrib(display, config, EGL_GREEN_SIZE,	&pixelFmt.greenBits);
+	egl.getConfigAttrib(display, config, EGL_BLUE_SIZE,		&pixelFmt.blueBits);
+	egl.getConfigAttrib(display, config, EGL_ALPHA_SIZE,	&pixelFmt.alphaBits);
+
+	return pixelFmt;
+}
+
 // SingleThreadColorClearCase
 
-SingleThreadColorClearCase::SingleThreadColorClearCase (EglTestContext& eglTestCtx, const char* name, const char* description, EGLint api, EGLint surfaceType, const std::vector<EGLint>& configIds, int numContextsPerApi)
-	: MultiContextRenderCase(eglTestCtx, name, description, api, surfaceType, configIds, numContextsPerApi)
+SingleThreadColorClearCase::SingleThreadColorClearCase (EglTestContext& eglTestCtx, const char* name, const char* description, EGLint api, EGLint surfaceType, const eglu::FilterList& filters, int numContextsPerApi)
+	: MultiContextRenderCase(eglTestCtx, name, description, api, surfaceType, filters, numContextsPerApi)
 {
 }
 
-void SingleThreadColorClearCase::executeForContexts (tcu::egl::Display& display, tcu::egl::Surface& surface, EGLConfig config, const std::vector<std::pair<EGLint, tcu::egl::Context*> >& contexts)
+void SingleThreadColorClearCase::executeForContexts (EGLDisplay display, EGLSurface surface, const Config& config, const std::vector<std::pair<EGLint, EGLContext> >& contexts)
 {
-	int					width		= surface.getWidth();
-	int					height		= surface.getHeight();
+	const Library&		egl			= m_eglTestCtx.getLibrary();
+
+	const tcu::IVec2	surfaceSize	= eglu::getSurfaceSize(egl, display, surface);
+	const int			width		= surfaceSize.x();
+	const int			height		= surfaceSize.y();
 
 	TestLog&			log			= m_testCtx.getLog();
 
 	tcu::Surface		refFrame	(width, height);
 	tcu::Surface		frame		(width, height);
-	tcu::PixelFormat	pixelFmt;
+	tcu::PixelFormat	pixelFmt	= getPixelFormat(egl, display, config.config);
 
 	de::Random			rnd			(deStringHash(getName()));
 	vector<ClearOp>		clears;
 	const int			ctxClears	= 2;
 	const int			numIters	= 3;
 
-	// Query pixel format.
-	display.describeConfig(config, pixelFmt);
+	ApiFunctions		funcs;
+
+	m_eglTestCtx.initGLFunctions(&funcs.gl, glu::ApiType::es(2,0));
 
 	// Clear to black using first context.
 	{
-		EGLint				api			= contexts[0].first;
-		tcu::egl::Context*	context		= contexts[0].second;
-		ClearOp				clear		(0, 0, width, height, RGBA::black);
+		EGLint		api			= contexts[0].first;
+		EGLContext	context		= contexts[0].second;
+		ClearOp		clear		(0, 0, width, height, RGBA::black);
 
-		eglMakeCurrent(display.getEGLDisplay(), surface.getEGLSurface(), surface.getEGLSurface(), context->getEGLContext());
-		TCU_CHECK_EGL();
+		egl.makeCurrent(display, surface, surface, context);
+		EGLU_CHECK_MSG(egl, "eglMakeCurrent");
 
-		renderClear(api, clear);
+		renderClear(api, funcs, clear);
 		clears.push_back(clear);
 	}
 
 	// Render.
 	for (int iterNdx = 0; iterNdx < numIters; iterNdx++)
 	{
-		for (vector<std::pair<EGLint, tcu::egl::Context*> >::const_iterator ctxIter = contexts.begin(); ctxIter != contexts.end(); ctxIter++)
+		for (vector<std::pair<EGLint, EGLContext> >::const_iterator ctxIter = contexts.begin(); ctxIter != contexts.end(); ctxIter++)
 		{
-			EGLint				api			= ctxIter->first;
-			tcu::egl::Context*	context		= ctxIter->second;
+			EGLint		api			= ctxIter->first;
+			EGLContext	context		= ctxIter->second;
 
-			eglMakeCurrent(display.getEGLDisplay(), surface.getEGLSurface(), surface.getEGLSurface(), context->getEGLContext());
-			TCU_CHECK_EGL();
+			egl.makeCurrent(display, surface, surface, context);
+			EGLU_CHECK_MSG(egl, "eglMakeCurrent");
 
 			for (int clearNdx = 0; clearNdx < ctxClears; clearNdx++)
 			{
 				ClearOp clear = computeRandomClear(rnd, width, height);
 
-				renderClear(api, clear);
+				renderClear(api, funcs, clear);
 				clears.push_back(clear);
 			}
 		}
@@ -194,13 +211,13 @@
 
 	// Read pixels using first context. \todo [pyry] Randomize?
 	{
-		EGLint				api		= contexts[0].first;
-		tcu::egl::Context*	context	= contexts[0].second;
+		EGLint		api		= contexts[0].first;
+		EGLContext	context	= contexts[0].second;
 
-		eglMakeCurrent(display.getEGLDisplay(), surface.getEGLSurface(), surface.getEGLSurface(), context->getEGLContext());
-		TCU_CHECK_EGL();
+		egl.makeCurrent(display, surface, surface, context);
+		EGLU_CHECK_MSG(egl, "eglMakeCurrent");
 
-		readPixels(api, frame);
+		readPixels(api, funcs, frame);
 	}
 
 	// Render reference.
@@ -241,11 +258,13 @@
 class ColorClearThread : public de::Thread
 {
 public:
-	ColorClearThread (tcu::egl::Display& display, tcu::egl::Surface& surface, tcu::egl::Context& context, EGLint api, const std::vector<ClearPacket>& packets)
-		: m_display	(display)
+	ColorClearThread (const Library& egl, EGLDisplay display, EGLSurface surface, EGLContext context, EGLint api, const ApiFunctions& funcs, const std::vector<ClearPacket>& packets)
+		: m_egl		(egl)
+		, m_display	(display)
 		, m_surface	(surface)
 		, m_context	(context)
 		, m_api		(api)
+		, m_funcs	(funcs)
 		, m_packets	(packets)
 	{
 	}
@@ -258,14 +277,14 @@
 			packetIter->wait->decrement();
 
 			// Acquire context.
-			eglMakeCurrent(m_display.getEGLDisplay(), m_surface.getEGLSurface(), m_surface.getEGLSurface(), m_context.getEGLContext());
+			m_egl.makeCurrent(m_display, m_surface, m_surface, m_context);
 
 			// Execute clears.
 			for (int ndx = 0; ndx < DE_LENGTH_OF_ARRAY(packetIter->clears); ndx++)
-				renderClear(m_api, packetIter->clears[ndx]);
+				renderClear(m_api, m_funcs, packetIter->clears[ndx]);
 
 			// Release context.
-			eglMakeCurrent(m_display.getEGLDisplay(), EGL_NO_SURFACE, EGL_NO_SURFACE, EGL_NO_CONTEXT);
+			m_egl.makeCurrent(m_display, EGL_NO_SURFACE, EGL_NO_SURFACE, EGL_NO_CONTEXT);
 
 			// Signal completion.
 			packetIter->signal->increment();
@@ -273,33 +292,39 @@
 	}
 
 private:
-	tcu::egl::Display&				m_display;
-	tcu::egl::Surface&				m_surface;
-	tcu::egl::Context&				m_context;
+	const Library&					m_egl;
+	EGLDisplay						m_display;
+	EGLSurface						m_surface;
+	EGLContext						m_context;
 	EGLint							m_api;
+	const ApiFunctions&				m_funcs;
 	const std::vector<ClearPacket>&	m_packets;
 };
 
-MultiThreadColorClearCase::MultiThreadColorClearCase (EglTestContext& eglTestCtx, const char* name, const char* description, EGLint api, EGLint surfaceType, const std::vector<EGLint>& configIds, int numContextsPerApi)
-	: MultiContextRenderCase(eglTestCtx, name, description, api, surfaceType, configIds, numContextsPerApi)
+MultiThreadColorClearCase::MultiThreadColorClearCase (EglTestContext& eglTestCtx, const char* name, const char* description, EGLint api, EGLint surfaceType, const eglu::FilterList& filters, int numContextsPerApi)
+	: MultiContextRenderCase(eglTestCtx, name, description, api, surfaceType, filters, numContextsPerApi)
 {
 }
 
-void MultiThreadColorClearCase::executeForContexts (tcu::egl::Display& display, tcu::egl::Surface& surface, EGLConfig config, const std::vector<std::pair<EGLint, tcu::egl::Context*> >& contexts)
+void MultiThreadColorClearCase::executeForContexts (EGLDisplay display, EGLSurface surface, const Config& config, const std::vector<std::pair<EGLint, EGLContext> >& contexts)
 {
-	int					width		= surface.getWidth();
-	int					height		= surface.getHeight();
+	const Library&		egl			= m_eglTestCtx.getLibrary();
+
+	const tcu::IVec2	surfaceSize	= eglu::getSurfaceSize(egl, display, surface);
+	const int			width		= surfaceSize.x();
+	const int			height		= surfaceSize.y();
 
 	TestLog&			log			= m_testCtx.getLog();
 
 	tcu::Surface		refFrame	(width, height);
 	tcu::Surface		frame		(width, height);
-	tcu::PixelFormat	pixelFmt;
+	tcu::PixelFormat	pixelFmt	= getPixelFormat(egl, display, config.config);
 
 	de::Random			rnd			(deStringHash(getName()));
 
-	// Query pixel format.
-	display.describeConfig(config, pixelFmt);
+	ApiFunctions		funcs;
+
+	m_eglTestCtx.initGLFunctions(&funcs.gl, glu::ApiType::es(2,0));
 
 	// Create clear packets.
 	const int						numPacketsPerThread		= 2;
@@ -341,7 +366,7 @@
 	// Create and launch threads (actual rendering starts once first semaphore is signaled).
 	for (int threadNdx = 0; threadNdx < numThreads; threadNdx++)
 	{
-		threads[threadNdx] = ColorClearThreadSp(new ColorClearThread(display, surface, *contexts[threadNdx].second, contexts[threadNdx].first, packets[threadNdx]));
+		threads[threadNdx] = ColorClearThreadSp(new ColorClearThread(egl, display, surface, contexts[threadNdx].second, contexts[threadNdx].first, funcs, packets[threadNdx]));
 		threads[threadNdx]->start();
 	}
 
@@ -351,13 +376,13 @@
 
 	// Read pixels using first context. \todo [pyry] Randomize?
 	{
-		EGLint				api		= contexts[0].first;
-		tcu::egl::Context*	context	= contexts[0].second;
+		EGLint		api		= contexts[0].first;
+		EGLContext	context	= contexts[0].second;
 
-		eglMakeCurrent(display.getEGLDisplay(), surface.getEGLSurface(), surface.getEGLSurface(), context->getEGLContext());
-		TCU_CHECK_EGL();
+		egl.makeCurrent(display, surface, surface, context);
+		EGLU_CHECK_MSG(egl, "eglMakeCurrent");
 
-		readPixels(api, frame);
+		readPixels(api, funcs, frame);
 	}
 
 	// Join threads.
diff --git a/modules/egl/teglColorClearCase.hpp b/modules/egl/teglColorClearCase.hpp
index 08b7bf4..abb2931 100644
--- a/modules/egl/teglColorClearCase.hpp
+++ b/modules/egl/teglColorClearCase.hpp
@@ -37,19 +37,37 @@
 class SingleThreadColorClearCase : public MultiContextRenderCase
 {
 public:
-						SingleThreadColorClearCase		(EglTestContext& eglTestCtx, const char* name, const char* description, EGLint api, EGLint surfaceType, const std::vector<EGLint>& configIds, int numContextsPerApi);
+					SingleThreadColorClearCase	(EglTestContext&					eglTestCtx,
+												 const char*						name,
+												 const char*						description,
+												 eglw::EGLint						api,
+												 eglw::EGLint						surfaceType,
+												 const eglu::FilterList&			filters,
+												 int								numContextsPerApi);
 
 private:
-	virtual void		executeForContexts				(tcu::egl::Display& display, tcu::egl::Surface& surface, EGLConfig config, const std::vector<std::pair<EGLint, tcu::egl::Context*> >& contexts);
+	virtual void	executeForContexts			(eglw::EGLDisplay												display,
+												 eglw::EGLSurface												surface,
+												 const Config&													config,
+												 const std::vector<std::pair<eglw::EGLint, eglw::EGLContext> >&	contexts);
 };
 
 class MultiThreadColorClearCase : public MultiContextRenderCase
 {
 public:
-						MultiThreadColorClearCase		(EglTestContext& eglTestCtx, const char* name, const char* description, EGLint api, EGLint surfaceType, const std::vector<EGLint>& configIds, int numContextsPerApi);
+					MultiThreadColorClearCase	(EglTestContext&					eglTestCtx,
+												 const char*						name,
+												 const char*						description,
+												 eglw::EGLint						api,
+												 eglw::EGLint						surfaceType,
+												 const eglu::FilterList&			filters,
+												 int								numContextsPerApi);
 
 private:
-	virtual void		executeForContexts				(tcu::egl::Display& display, tcu::egl::Surface& surface, EGLConfig config, const std::vector<std::pair<EGLint, tcu::egl::Context*> >& contexts);
+	virtual void	executeForContexts			(eglw::EGLDisplay												display,
+												 eglw::EGLSurface												surface,
+												 const Config&													config,
+												 const std::vector<std::pair<eglw::EGLint, eglw::EGLContext> >&	contexts);
 };
 
 } // egl
diff --git a/modules/egl/teglColorClearTests.cpp b/modules/egl/teglColorClearTests.cpp
index e8c424f..c79063c 100644
--- a/modules/egl/teglColorClearTests.cpp
+++ b/modules/egl/teglColorClearTests.cpp
@@ -23,15 +23,7 @@
 
 #include "teglColorClearTests.hpp"
 #include "teglColorClearCase.hpp"
-
-#include <EGL/eglext.h>
-
-#if !defined(EGL_OPENGL_ES3_BIT_KHR)
-#	define EGL_OPENGL_ES3_BIT_KHR	0x0040
-#endif
-#if !defined(EGL_CONTEXT_MAJOR_VERSION_KHR)
-#	define EGL_CONTEXT_MAJOR_VERSION_KHR EGL_CONTEXT_CLIENT_VERSION
-#endif
+#include "eglwEnums.hpp"
 
 using std::string;
 using std::vector;
@@ -41,6 +33,8 @@
 namespace egl
 {
 
+using namespace eglw;
+
 ColorClearTests::ColorClearTests (EglTestContext& eglTestCtx)
 	: TestCaseGroup(eglTestCtx, "color_clears", "Color clears with different client APIs")
 {
@@ -52,10 +46,11 @@
 
 struct ColorClearGroupSpec
 {
-	const char*		name;
-	const char*		desc;
-	EGLint			apiBits;
-	int				numContextsPerApi;
+	const char*			name;
+	const char*			desc;
+	EGLint				apiBits;
+	eglu::ConfigFilter	baseFilter;
+	int					numContextsPerApi;
 };
 
 template <class ClearClass>
@@ -66,40 +61,50 @@
 		tcu::TestCaseGroup* configGroup = new tcu::TestCaseGroup(eglTestCtx.getTestContext(), groupIter->name, groupIter->desc);
 		group->addChild(configGroup);
 
-		vector<RenderConfigIdSet>	configSets;
-		eglu::FilterList			filters;
-		filters << (eglu::ConfigRenderableType() & groupIter->apiBits);
-		getDefaultRenderConfigIdSets(configSets, eglTestCtx.getConfigs(), filters);
+		vector<RenderFilterList>	filterLists;
+		eglu::FilterList			baseFilters;
+		baseFilters << groupIter->baseFilter;
+		getDefaultRenderFilterLists(filterLists, baseFilters);
 
-		for (vector<RenderConfigIdSet>::const_iterator setIter = configSets.begin(); setIter != configSets.end(); setIter++)
-			configGroup->addChild(new ClearClass(eglTestCtx, setIter->getName(), "", groupIter->apiBits, setIter->getSurfaceTypeMask(), setIter->getConfigIds(), groupIter->numContextsPerApi));
+		for (vector<RenderFilterList>::const_iterator listIter = filterLists.begin(); listIter != filterLists.end(); listIter++)
+			configGroup->addChild(new ClearClass(eglTestCtx, listIter->getName(), "", groupIter->apiBits, listIter->getSurfaceTypeMask(), *listIter, groupIter->numContextsPerApi));
 	}
 }
 
+template <deUint32 Bits>
+static bool renderable (const eglu::CandidateConfig& c)
+{
+	return (c.renderableType() & Bits) == Bits;
+}
+
 void ColorClearTests::init (void)
 {
+#define CASE(NAME, DESC, BITS, NUMCFG) { NAME, DESC, BITS, renderable<BITS>, NUMCFG }
+
 	static const ColorClearGroupSpec singleContextCases[] =
 	{
-		{ "gles1",			"Color clears using GLES1",											EGL_OPENGL_ES_BIT,										1 },
-		{ "gles2",			"Color clears using GLES2",											EGL_OPENGL_ES2_BIT,										1 },
-		{ "gles3",			"Color clears using GLES3",											EGL_OPENGL_ES3_BIT_KHR,									1 },
-		{ "vg",				"Color clears using OpenVG",										EGL_OPENVG_BIT,											1 }
+		CASE("gles1",			"Color clears using GLES1",											EGL_OPENGL_ES_BIT,										1),
+		CASE("gles2",			"Color clears using GLES2",											EGL_OPENGL_ES2_BIT,										1),
+		CASE("gles3",			"Color clears using GLES3",											EGL_OPENGL_ES3_BIT,										1),
+		CASE("vg",				"Color clears using OpenVG",										EGL_OPENVG_BIT,											1)
 	};
 
 	static const ColorClearGroupSpec multiContextCases[] =
 	{
-		{ "gles1",				"Color clears using multiple GLES1 contexts to shared surface",		EGL_OPENGL_ES_BIT,												3 },
-		{ "gles2",				"Color clears using multiple GLES2 contexts to shared surface",		EGL_OPENGL_ES2_BIT,												3 },
-		{ "gles3",				"Color clears using multiple GLES3 contexts to shared surface",		EGL_OPENGL_ES3_BIT_KHR,											3 },
-		{ "vg",					"Color clears using multiple OpenVG contexts to shared surface",	EGL_OPENVG_BIT,													3 },
-		{ "gles1_gles2",		"Color clears using multiple APIs to shared surface",				EGL_OPENGL_ES_BIT|EGL_OPENGL_ES2_BIT,							1 },
-		{ "gles1_gles2_gles3",	"Color clears using multiple APIs to shared surface",				EGL_OPENGL_ES_BIT|EGL_OPENGL_ES2_BIT|EGL_OPENGL_ES3_BIT_KHR,	1 },
-		{ "gles1_vg",			"Color clears using multiple APIs to shared surface",				EGL_OPENGL_ES_BIT|EGL_OPENVG_BIT,								1 },
-		{ "gles2_vg",			"Color clears using multiple APIs to shared surface",				EGL_OPENGL_ES2_BIT|EGL_OPENVG_BIT,								1 },
-		{ "gles3_vg",			"Color clears using multiple APIs to shared surface",				EGL_OPENGL_ES3_BIT_KHR|EGL_OPENVG_BIT,							1 },
-		{ "gles1_gles2_vg",		"Color clears using multiple APIs to shared surface",				EGL_OPENGL_ES_BIT|EGL_OPENGL_ES2_BIT|EGL_OPENVG_BIT,			1 }
+		CASE("gles1",				"Color clears using multiple GLES1 contexts to shared surface",		EGL_OPENGL_ES_BIT,											3),
+		CASE("gles2",				"Color clears using multiple GLES2 contexts to shared surface",		EGL_OPENGL_ES2_BIT,											3),
+		CASE("gles3",				"Color clears using multiple GLES3 contexts to shared surface",		EGL_OPENGL_ES3_BIT,											3),
+		CASE("vg",					"Color clears using multiple OpenVG contexts to shared surface",	EGL_OPENVG_BIT,												3),
+		CASE("gles1_gles2",			"Color clears using multiple APIs to shared surface",				EGL_OPENGL_ES_BIT|EGL_OPENGL_ES2_BIT,						1),
+		CASE("gles1_gles2_gles3",	"Color clears using multiple APIs to shared surface",				EGL_OPENGL_ES_BIT|EGL_OPENGL_ES2_BIT|EGL_OPENGL_ES3_BIT,	1),
+		CASE("gles1_vg",			"Color clears using multiple APIs to shared surface",				EGL_OPENGL_ES_BIT|EGL_OPENVG_BIT,							1),
+		CASE("gles2_vg",			"Color clears using multiple APIs to shared surface",				EGL_OPENGL_ES2_BIT|EGL_OPENVG_BIT,							1),
+		CASE("gles3_vg",			"Color clears using multiple APIs to shared surface",				EGL_OPENGL_ES3_BIT|EGL_OPENVG_BIT,							1),
+		CASE("gles1_gles2_vg",		"Color clears using multiple APIs to shared surface",				EGL_OPENGL_ES_BIT|EGL_OPENGL_ES2_BIT|EGL_OPENVG_BIT,		1)
 	};
 
+#undef CASE
+
 	tcu::TestCaseGroup* singleContextGroup = new tcu::TestCaseGroup(m_testCtx, "single_context", "Single-context color clears");
 	addChild(singleContextGroup);
 	createColorClearGroups<SingleThreadColorClearCase>(m_eglTestCtx, singleContextGroup, &singleContextCases[0], &singleContextCases[DE_LENGTH_OF_ARRAY(singleContextCases)]);
diff --git a/modules/egl/teglConfigList.cpp b/modules/egl/teglConfigList.cpp
index 2308234..d8ac999 100644
--- a/modules/egl/teglConfigList.cpp
+++ b/modules/egl/teglConfigList.cpp
@@ -22,20 +22,23 @@
  *//*--------------------------------------------------------------------*/
 
 #include "teglConfigList.hpp"
-#include "tcuEgl.hpp"
 #include "tcuTestLog.hpp"
 #include "egluStrUtil.hpp"
+#include "egluUtil.hpp"
+#include "eglwLibrary.hpp"
+#include "eglwEnums.hpp"
 #include "deStringUtil.hpp"
 
 #include <vector>
 
-using std::vector;
-
 namespace deqp
 {
 namespace egl
 {
 
+using std::vector;
+using namespace eglw;
+
 ConfigList::ConfigList (EglTestContext& eglTestCtx)
 	: TestCase(eglTestCtx, "configs", "Output the list of configs from EGL")
 
@@ -56,16 +59,15 @@
 
 tcu::TestNode::IterateResult ConfigList::iterate (void)
 {
+	const Library&		egl			= m_eglTestCtx.getLibrary();
 	tcu::TestLog&		log			= m_testCtx.getLog();
-	EGLDisplay			display		= m_eglTestCtx.getDisplay().getEGLDisplay();
-	vector<EGLConfig>	configs;
+	EGLDisplay			display		= eglu::getAndInitDisplay(m_eglTestCtx.getNativeDisplay());
+	vector<EGLConfig>	configs		= eglu::getConfigs(egl, display);
 
 	// \todo [2011-03-23 pyry] Check error codes!
 
 	// \todo [kalle 10/08/2010] Get EGL version.
 
-	m_eglTestCtx.getDisplay().getConfigs(configs);
-
 	log.startEglConfigSet("EGL-configs", "List of all EGL configs");
 
 	// \todo [kalle 10/08/2010] Add validity checks for the values?
@@ -76,106 +78,108 @@
 		qpEglConfigInfo info;
 		EGLint val = 0;
 
-		eglGetConfigAttrib(display, configs[i], EGL_BUFFER_SIZE, &val);
+		egl.getConfigAttrib(display, configs[i], EGL_BUFFER_SIZE, &val);
 		info.bufferSize = val;
 
-		eglGetConfigAttrib(display, configs[i], EGL_RED_SIZE, &val);
+		egl.getConfigAttrib(display, configs[i], EGL_RED_SIZE, &val);
 		info.redSize = val;
 
-		eglGetConfigAttrib(display, configs[i], EGL_GREEN_SIZE, &val);
+		egl.getConfigAttrib(display, configs[i], EGL_GREEN_SIZE, &val);
 		info.greenSize = val;
 
-		eglGetConfigAttrib(display, configs[i], EGL_BLUE_SIZE, &val);
+		egl.getConfigAttrib(display, configs[i], EGL_BLUE_SIZE, &val);
 		info.blueSize = val;
 
-		eglGetConfigAttrib(display, configs[i], EGL_LUMINANCE_SIZE, &val);
+		egl.getConfigAttrib(display, configs[i], EGL_LUMINANCE_SIZE, &val);
 		info.luminanceSize = val;
 
-		eglGetConfigAttrib(display, configs[i], EGL_ALPHA_SIZE, &val);
+		egl.getConfigAttrib(display, configs[i], EGL_ALPHA_SIZE, &val);
 		info.alphaSize = val;
 
-		eglGetConfigAttrib(display, configs[i], EGL_ALPHA_MASK_SIZE, &val);
+		egl.getConfigAttrib(display, configs[i], EGL_ALPHA_MASK_SIZE, &val);
 		info.alphaMaskSize = val;
 
-		eglGetConfigAttrib(display, configs[i], EGL_BIND_TO_TEXTURE_RGB, &val);
+		egl.getConfigAttrib(display, configs[i], EGL_BIND_TO_TEXTURE_RGB, &val);
 		info.bindToTextureRGB = val == EGL_TRUE ? DE_TRUE : DE_FALSE;
 
-		eglGetConfigAttrib(display, configs[i], EGL_BIND_TO_TEXTURE_RGBA, &val);
+		egl.getConfigAttrib(display, configs[i], EGL_BIND_TO_TEXTURE_RGBA, &val);
 		info.bindToTextureRGBA = val == EGL_TRUE ? DE_TRUE : DE_FALSE;
 
-		eglGetConfigAttrib(display, configs[i], EGL_COLOR_BUFFER_TYPE, &val);
+		egl.getConfigAttrib(display, configs[i], EGL_COLOR_BUFFER_TYPE, &val);
 		std::string colorBufferType = de::toString(eglu::getColorBufferTypeStr(val));
 		info.colorBufferType = colorBufferType.c_str();
 
-		eglGetConfigAttrib(display, configs[i], EGL_CONFIG_CAVEAT, &val);
+		egl.getConfigAttrib(display, configs[i], EGL_CONFIG_CAVEAT, &val);
 		std::string caveat = de::toString(eglu::getConfigCaveatStr(val));
 		info.configCaveat = caveat.c_str();
 
-		eglGetConfigAttrib(display, configs[i], EGL_CONFIG_ID, &val);
+		egl.getConfigAttrib(display, configs[i], EGL_CONFIG_ID, &val);
 		info.configID = val;
 
-		eglGetConfigAttrib(display, configs[i], EGL_CONFORMANT, &val);
+		egl.getConfigAttrib(display, configs[i], EGL_CONFORMANT, &val);
 		std::string conformant = de::toString(eglu::getAPIBitsStr(val));
 		info.conformant = conformant.c_str();
 
-		eglGetConfigAttrib(display, configs[i], EGL_DEPTH_SIZE, &val);
+		egl.getConfigAttrib(display, configs[i], EGL_DEPTH_SIZE, &val);
 		info.depthSize = val;
 
-		eglGetConfigAttrib(display, configs[i], EGL_LEVEL, &val);
+		egl.getConfigAttrib(display, configs[i], EGL_LEVEL, &val);
 		info.level = val;
 
-		eglGetConfigAttrib(display, configs[i], EGL_MAX_PBUFFER_WIDTH, &val);
+		egl.getConfigAttrib(display, configs[i], EGL_MAX_PBUFFER_WIDTH, &val);
 		info.maxPBufferWidth = val;
 
-		eglGetConfigAttrib(display, configs[i], EGL_MAX_PBUFFER_HEIGHT, &val);
+		egl.getConfigAttrib(display, configs[i], EGL_MAX_PBUFFER_HEIGHT, &val);
 		info.maxPBufferHeight = val;
 
-		eglGetConfigAttrib(display, configs[i], EGL_MAX_PBUFFER_PIXELS, &val);
+		egl.getConfigAttrib(display, configs[i], EGL_MAX_PBUFFER_PIXELS, &val);
 		info.maxPBufferPixels = val;
 
-		eglGetConfigAttrib(display, configs[i], EGL_MAX_SWAP_INTERVAL, &val);
+		egl.getConfigAttrib(display, configs[i], EGL_MAX_SWAP_INTERVAL, &val);
 		info.maxSwapInterval = val;
 
-		eglGetConfigAttrib(display, configs[i], EGL_MIN_SWAP_INTERVAL, &val);
+		egl.getConfigAttrib(display, configs[i], EGL_MIN_SWAP_INTERVAL, &val);
 		info.minSwapInterval = val;
 
-		eglGetConfigAttrib(display, configs[i], EGL_NATIVE_RENDERABLE, &val);
+		egl.getConfigAttrib(display, configs[i], EGL_NATIVE_RENDERABLE, &val);
 		info.nativeRenderable = val == EGL_TRUE ? DE_TRUE : DE_FALSE;
 
-		eglGetConfigAttrib(display, configs[i], EGL_RENDERABLE_TYPE, &val);
+		egl.getConfigAttrib(display, configs[i], EGL_RENDERABLE_TYPE, &val);
 		std::string renderableTypes = de::toString(eglu::getAPIBitsStr(val));
 		info.renderableType = renderableTypes.c_str();
 
-		eglGetConfigAttrib(display, configs[i], EGL_SAMPLE_BUFFERS, &val);
+		egl.getConfigAttrib(display, configs[i], EGL_SAMPLE_BUFFERS, &val);
 		info.sampleBuffers = val;
 
-		eglGetConfigAttrib(display, configs[i], EGL_SAMPLES, &val);
+		egl.getConfigAttrib(display, configs[i], EGL_SAMPLES, &val);
 		info.samples = val;
 
-		eglGetConfigAttrib(display, configs[i], EGL_STENCIL_SIZE, &val);
+		egl.getConfigAttrib(display, configs[i], EGL_STENCIL_SIZE, &val);
 		info.stencilSize = val;
 
-		eglGetConfigAttrib(display, configs[i], EGL_SURFACE_TYPE, &val);
+		egl.getConfigAttrib(display, configs[i], EGL_SURFACE_TYPE, &val);
 		std::string surfaceTypes = de::toString(eglu::getSurfaceBitsStr(val));
 		info.surfaceTypes = surfaceTypes.c_str();
 
-		eglGetConfigAttrib(display, configs[i], EGL_TRANSPARENT_TYPE, &val);
+		egl.getConfigAttrib(display, configs[i], EGL_TRANSPARENT_TYPE, &val);
 		std::string transparentType = de::toString(eglu::getTransparentTypeStr(val));
 		info.transparentType = transparentType.c_str();
 
-		eglGetConfigAttrib(display, configs[i], EGL_TRANSPARENT_RED_VALUE, &val);
+		egl.getConfigAttrib(display, configs[i], EGL_TRANSPARENT_RED_VALUE, &val);
 		info.transparentRedValue = val;
 
-		eglGetConfigAttrib(display, configs[i], EGL_TRANSPARENT_GREEN_VALUE, &val);
+		egl.getConfigAttrib(display, configs[i], EGL_TRANSPARENT_GREEN_VALUE, &val);
 		info.transparentGreenValue = val;
 
-		eglGetConfigAttrib(display, configs[i], EGL_TRANSPARENT_BLUE_VALUE, &val);
+		egl.getConfigAttrib(display, configs[i], EGL_TRANSPARENT_BLUE_VALUE, &val);
 		info.transparentBlueValue = val;
 
 		log.writeEglConfig(&info);
 	}
 	log.endEglConfigSet();
 
+	egl.terminate(display);
+
 	getTestContext().setTestResult(QP_TEST_RESULT_PASS, "");
 
 	return TestNode::STOP;
diff --git a/modules/egl/teglCreateContextExtTests.cpp b/modules/egl/teglCreateContextExtTests.cpp
index 542890e..04214de 100644
--- a/modules/egl/teglCreateContextExtTests.cpp
+++ b/modules/egl/teglCreateContextExtTests.cpp
@@ -31,6 +31,10 @@
 #include "egluConfigFilter.hpp"
 #include "egluStrUtil.hpp"
 #include "egluUtil.hpp"
+#include "egluUnique.hpp"
+
+#include "eglwLibrary.hpp"
+#include "eglwEnums.hpp"
 
 #include "gluDefs.hpp"
 #include "gluRenderConfig.hpp"
@@ -40,8 +44,7 @@
 
 #include "deStringUtil.hpp"
 #include "deUniquePtr.hpp"
-
-#include <EGL/eglext.h>
+#include "deSTLUtil.hpp"
 
 #include <string>
 #include <vector>
@@ -50,60 +53,22 @@
 
 #include <cstring>
 
-// \note Taken from official EGL/eglext.h. EGL_EGLEXT_VERSION 20131028
-#ifndef EGL_KHR_create_context
-#define EGL_KHR_create_context 1
-#define EGL_CONTEXT_MAJOR_VERSION_KHR     0x3098
-#define EGL_CONTEXT_MINOR_VERSION_KHR     0x30FB
-#define EGL_CONTEXT_FLAGS_KHR             0x30FC
-#define EGL_CONTEXT_OPENGL_PROFILE_MASK_KHR 0x30FD
-#define EGL_CONTEXT_OPENGL_RESET_NOTIFICATION_STRATEGY_KHR 0x31BD
-#define EGL_NO_RESET_NOTIFICATION_KHR     0x31BE
-#define EGL_LOSE_CONTEXT_ON_RESET_KHR     0x31BF
-#define EGL_CONTEXT_OPENGL_DEBUG_BIT_KHR  0x00000001
-#define EGL_CONTEXT_OPENGL_FORWARD_COMPATIBLE_BIT_KHR 0x00000002
-#define EGL_CONTEXT_OPENGL_ROBUST_ACCESS_BIT_KHR 0x00000004
-#define EGL_CONTEXT_OPENGL_CORE_PROFILE_BIT_KHR 0x00000001
-#define EGL_CONTEXT_OPENGL_COMPATIBILITY_PROFILE_BIT_KHR 0x00000002
-#define EGL_OPENGL_ES3_BIT_KHR            0x00000040
-#endif /* EGL_KHR_create_context */
-
-#ifndef EGL_EXT_create_context_robustness
-#define EGL_EXT_create_context_robustness 1
-#define EGL_CONTEXT_OPENGL_ROBUST_ACCESS_EXT 0x30BF
-#define EGL_CONTEXT_OPENGL_RESET_NOTIFICATION_STRATEGY_EXT 0x3138
-#define EGL_NO_RESET_NOTIFICATION_EXT     0x31BE
-#define EGL_LOSE_CONTEXT_ON_RESET_EXT     0x31BF
-#endif /* EGL_EXT_create_context_robustness */
-
-// \note Taken from official GLES2/gl2ext.h. Generated on date 20131202.
-#ifndef GL_EXT_robustness
-#define GL_EXT_robustness 1
-#define GL_GUILTY_CONTEXT_RESET_EXT       0x8253
-#define GL_INNOCENT_CONTEXT_RESET_EXT     0x8254
-#define GL_UNKNOWN_CONTEXT_RESET_EXT      0x8255
-#define GL_CONTEXT_ROBUST_ACCESS_EXT      0x90F3
-#define GL_RESET_NOTIFICATION_STRATEGY_EXT 0x8256
-#define GL_LOSE_CONTEXT_ON_RESET_EXT      0x8252
-#define GL_NO_RESET_NOTIFICATION_EXT      0x8261
-#endif /* GL_EXT_robustness */
-
-#ifndef GL_ARB_robustness
-/* reuse GL_NO_ERROR */
-#define GL_CONTEXT_FLAG_ROBUST_ACCESS_BIT_ARB 0x00000004
-#define GL_LOSE_CONTEXT_ON_RESET_ARB      0x8252
-#define GL_GUILTY_CONTEXT_RESET_ARB       0x8253
-#define GL_INNOCENT_CONTEXT_RESET_ARB     0x8254
-#define GL_UNKNOWN_CONTEXT_RESET_ARB      0x8255
-#define GL_RESET_NOTIFICATION_STRATEGY_ARB 0x8256
-#define GL_NO_RESET_NOTIFICATION_ARB      0x8261
-#endif
-
 using std::set;
 using std::string;
 using std::vector;
 using tcu::TestLog;
 
+using namespace eglw;
+
+// Make sure KHR / core values match to those in GL_ARB_robustness and GL_EXT_robustness
+DE_STATIC_ASSERT(GL_RESET_NOTIFICATION_STRATEGY	== 0x8256);
+DE_STATIC_ASSERT(GL_LOSE_CONTEXT_ON_RESET		== 0x8252);
+DE_STATIC_ASSERT(GL_NO_RESET_NOTIFICATION		== 0x8261);
+
+#if !defined(GL_CONTEXT_ROBUST_ACCESS)
+#	define GL_CONTEXT_ROBUST_ACCESS		0x90F3
+#endif
+
 namespace deqp
 {
 namespace egl
@@ -213,7 +178,7 @@
 								CreateContextExtCase	(EglTestContext& eglTestCtx, EGLenum api, const EGLint* attribList, const eglu::FilterList& filter, const char* name, const char* description);
 								~CreateContextExtCase	(void);
 
-	void						executeForConfig		(tcu::egl::Display& display, EGLConfig config, tcu::egl::Surface& surface);
+	void						executeForSurface		(EGLConfig config, EGLSurface surface);
 
 	void						init					(void);
 	void						deinit					(void);
@@ -231,6 +196,7 @@
 	vector<EGLint>				m_attribList;
 	const EGLenum				m_api;
 
+	EGLDisplay					m_display;
 	vector<EGLConfig>			m_configs;
 	glu::ContextType			m_glContextType;
 };
@@ -243,7 +209,7 @@
 	glu::Profile		profile			= api == EGL_OPENGL_ES_API ? glu::PROFILE_ES : glu::PROFILE_CORE;
 	const EGLint*		iter			= attribList;
 
-	while((*iter) != EGL_NONE)
+	while ((*iter) != EGL_NONE)
 	{
 		switch (*iter)
 		{
@@ -312,6 +278,7 @@
 	, m_filter			(filter)
 	, m_attribList		(attribList, attribList + getAttribListLength(attribList))
 	, m_api				(api)
+	, m_display			(EGL_NO_DISPLAY)
 	, m_glContextType	(attribListToContextType(api, attribList))
 {
 }
@@ -323,20 +290,20 @@
 
 void CreateContextExtCase::init (void)
 {
-	vector<EGLConfig> configs;
-	m_eglTestCtx.getDisplay().getConfigs(configs);
-
-	for (int configNdx = 0; configNdx < (int)configs.size(); configNdx++)
-	{
-		if (m_filter.match(m_eglTestCtx.getDisplay().getEGLDisplay(), configs[configNdx]))
-			m_configs.push_back(configs[configNdx]);
-	}
+	m_display	= eglu::getAndInitDisplay(m_eglTestCtx.getNativeDisplay());
+	m_configs	= eglu::chooseConfigs(m_eglTestCtx.getLibrary(), m_display, m_filter);
 }
 
 void CreateContextExtCase::deinit (void)
 {
-	m_attribList	= vector<EGLint>();
-	m_configs		= vector<EGLConfig>();
+	m_attribList.clear();
+	m_configs.clear();
+
+	if (m_display != EGL_NO_DISPLAY)
+	{
+		m_eglTestCtx.getLibrary().terminate(m_display);
+		m_display = EGL_NO_DISPLAY;
+	}
 }
 
 void CreateContextExtCase::logAttribList (void)
@@ -402,9 +369,7 @@
 {
 	bool			isOk = true;
 	set<string>		requiredExtensions;
-	vector<string>	extensions;
-
-	m_eglTestCtx.getDisplay().getExtensions(extensions);
+	vector<string>	extensions			= eglu::getClientExtensions(m_eglTestCtx.getLibrary(), m_display);
 
 	{
 		const EGLint* iter = &(m_attribList[0]);
@@ -462,15 +427,7 @@
 
 	for (std::set<string>::const_iterator reqExt = requiredExtensions.begin(); reqExt != requiredExtensions.end(); ++reqExt)
 	{
-		bool found = false;
-
-		for (int extNdx = 0; extNdx < (int)extensions.size(); extNdx++)
-		{
-			if (*reqExt == extensions[extNdx])
-				found = true;
-		}
-
-		if (!found)
+		if (!de::contains(extensions.begin(), extensions.end(), *reqExt))
 		{
 			m_testCtx.getLog() << TestLog::Message << "Required extension '" << (*reqExt) << "' not supported" << TestLog::EndMessage;
 			isOk = false;
@@ -478,7 +435,7 @@
 	}
 
 	if (!isOk)
-		throw tcu::NotSupportedError("Required extensions not supported", "", __FILE__, __LINE__);
+		TCU_THROW(NotSupportedError, "Required extensions not supported");
 }
 
 bool hasExtension (const glw::Functions& gl, const char* extension)
@@ -858,87 +815,28 @@
 		}
 	}
 
-	if (notificationStrategy != -1)
+	DE_ASSERT(notificationStrategy == -1 || notificationStrategyExt == -1);
+
+	if (notificationStrategy != -1 || notificationStrategyExt != -1)
 	{
-		if (m_api == EGL_OPENGL_API)
+		const deInt32	expected	= notificationStrategy != -1 ? notificationStrategy : notificationStrategyExt;
+		deInt32			strategy	= 0;
+
+		gl.getIntegerv(GL_RESET_NOTIFICATION_STRATEGY, &strategy);
+		GLU_EXPECT_NO_ERROR(gl.getError(), "glGetIntegerv()");
+
+		if (expected == EGL_NO_RESET_NOTIFICATION && strategy != GL_NO_RESET_NOTIFICATION)
 		{
-			deInt32 strategy;
-
-			gl.getIntegerv(GL_RESET_NOTIFICATION_STRATEGY_ARB, &strategy);
-			GLU_EXPECT_NO_ERROR(gl.getError(), "glGetIntegerv()");
-
-			if (notificationStrategy == EGL_NO_RESET_NOTIFICATION_KHR && strategy != GL_NO_RESET_NOTIFICATION_ARB)
-			{
-				log << TestLog::Message << "glGetIntegerv(GL_RESET_NOTIFICATION_STRATEGY_ARB) returned '" << strategy << "', expected 'GL_NO_RESET_NOTIFICATION_ARB'" << TestLog::EndMessage;
-				isOk = false;
-			}
-			else if (notificationStrategy == EGL_LOSE_CONTEXT_ON_RESET_KHR && strategy != GL_LOSE_CONTEXT_ON_RESET_ARB)
-			{
-				log << TestLog::Message << "glGetIntegerv(GL_RESET_NOTIFICATION_STRATEGY_ARB) returned '" << strategy << "', expected 'GL_LOSE_CONTEXT_ON_RESET_ARB'" << TestLog::EndMessage;
-				isOk = false;
-			}
+			log << TestLog::Message << "glGetIntegerv(GL_RESET_NOTIFICATION_STRATEGY) returned '" << strategy << "', expected 'GL_NO_RESET_NOTIFICATION'" << TestLog::EndMessage;
+			isOk = false;
 		}
-		else if (m_api == EGL_OPENGL_ES_API)
+		else if (expected == EGL_LOSE_CONTEXT_ON_RESET && strategy != GL_LOSE_CONTEXT_ON_RESET)
 		{
-			deInt32 strategy;
-
-			gl.getIntegerv(GL_RESET_NOTIFICATION_STRATEGY_EXT, &strategy);
-			GLU_EXPECT_NO_ERROR(gl.getError(), "glGetIntegerv()");
-
-			if (notificationStrategy == EGL_NO_RESET_NOTIFICATION_KHR && strategy != GL_NO_RESET_NOTIFICATION_EXT)
-			{
-				log << TestLog::Message << "glGetIntegerv(GL_RESET_NOTIFICATION_STRATEGY_EXT) returned '" << strategy << "', expected 'GL_NO_RESET_NOTIFICATION_EXT'" << TestLog::EndMessage;
-				isOk = false;
-			}
-			else if (notificationStrategy == EGL_LOSE_CONTEXT_ON_RESET_KHR && strategy != GL_LOSE_CONTEXT_ON_RESET_EXT)
-			{
-				log << TestLog::Message << "glGetIntegerv(GL_RESET_NOTIFICATION_STRATEGY_EXT) returned '" << strategy << "', expected 'GL_LOSE_CONTEXT_ON_RESET_EXT'" << TestLog::EndMessage;
-				isOk = false;
-			}
-		}
-	}
-
-	if (notificationStrategyExt != -1)
-	{
-		if (m_api == EGL_OPENGL_API)
-		{
-			deInt32 strategy;
-
-			gl.getIntegerv(GL_RESET_NOTIFICATION_STRATEGY_ARB, &strategy);
-			GLU_EXPECT_NO_ERROR(gl.getError(), "glGetIntegerv()");
-
-			if (notificationStrategyExt == EGL_NO_RESET_NOTIFICATION_KHR && strategy != GL_NO_RESET_NOTIFICATION_ARB)
-			{
-				log << TestLog::Message << "glGetIntegerv(GL_RESET_NOTIFICATION_STRATEGY_ARB) returned '" << strategy << "', expected 'GL_NO_RESET_NOTIFICATION_ARB'" << TestLog::EndMessage;
-				isOk = false;
-			}
-			else if (notificationStrategyExt == EGL_LOSE_CONTEXT_ON_RESET_KHR && strategy != GL_LOSE_CONTEXT_ON_RESET_ARB)
-			{
-				log << TestLog::Message << "glGetIntegerv(GL_RESET_NOTIFICATION_STRATEGY_ARB) returned '" << strategy << "', expected 'GL_LOSE_CONTEXT_ON_RESET_ARB'" << TestLog::EndMessage;
-				isOk = false;
-			}
-		}
-		else if (m_api == EGL_OPENGL_ES_API)
-		{
-			deInt32 strategy;
-
-			gl.getIntegerv(GL_RESET_NOTIFICATION_STRATEGY_EXT, &strategy);
-			GLU_EXPECT_NO_ERROR(gl.getError(), "glGetIntegerv()");
-
-			if (notificationStrategyExt == EGL_NO_RESET_NOTIFICATION_KHR && strategy != GL_NO_RESET_NOTIFICATION_EXT)
-			{
-				log << TestLog::Message << "glGetIntegerv(GL_RESET_NOTIFICATION_STRATEGY_EXT) returned '" << strategy << "', expected 'GL_NO_RESET_NOTIFICATION_EXT'" << TestLog::EndMessage;
-				isOk = false;
-			}
-			else if (notificationStrategyExt == EGL_LOSE_CONTEXT_ON_RESET_KHR && strategy != GL_LOSE_CONTEXT_ON_RESET_EXT)
-			{
-				log << TestLog::Message << "glGetIntegerv(GL_RESET_NOTIFICATION_STRATEGY_EXT) returned '" << strategy << "', expected 'GL_LOSE_CONTEXT_ON_RESET_EXT'" << TestLog::EndMessage;
-				isOk = false;
-			}
+			log << TestLog::Message << "glGetIntegerv(GL_RESET_NOTIFICATION_STRATEGY) returned '" << strategy << "', expected 'GL_LOSE_CONTEXT_ON_RESET'" << TestLog::EndMessage;
+			isOk = false;
 		}
 	}
 	
-
 	if (robustAccessExt == EGL_TRUE)
 	{
 		if (m_api == EGL_OPENGL_API)
@@ -966,9 +864,9 @@
 
 			gl.getIntegerv(GL_CONTEXT_FLAGS, &contextFlagsGL);
 
-			if ((contextFlagsGL & GL_CONTEXT_FLAG_ROBUST_ACCESS_BIT_ARB) != 0)
+			if ((contextFlagsGL & GL_CONTEXT_FLAG_ROBUST_ACCESS_BIT) != 0)
 			{
-				log << TestLog::Message << "Invalid GL_CONTEXT_FLAGS. GL_CONTEXT_FLAG_ROBUST_ACCESS_BIT_ARB to be set, got '" << eglContextFlagsToString(contextFlagsGL) << "'" << TestLog::EndMessage;
+				log << TestLog::Message << "Invalid GL_CONTEXT_FLAGS. GL_CONTEXT_FLAG_ROBUST_ACCESS_BIT to be set, got '" << eglContextFlagsToString(contextFlagsGL) << "'" << TestLog::EndMessage;
 				isOk = false;
 			}
 		}
@@ -976,12 +874,12 @@
 		{
 			deUint8 robustAccessGL;
 
-			gl.getBooleanv(GL_CONTEXT_ROBUST_ACCESS_EXT, &robustAccessGL);
+			gl.getBooleanv(GL_CONTEXT_ROBUST_ACCESS, &robustAccessGL);
 			GLU_EXPECT_NO_ERROR(gl.getError(), "glGetBooleanv()");
 
 			if (robustAccessGL != GL_TRUE)
 			{
-				log << TestLog::Message << "Invalid GL_CONTEXT_ROBUST_ACCESS_EXT returned by glGetBooleanv(). Got '" << robustAccessGL << "' expected GL_TRUE." << TestLog::EndMessage;
+				log << TestLog::Message << "Invalid GL_CONTEXT_ROBUST_ACCESS returned by glGetBooleanv(). Got '" << robustAccessGL << "' expected GL_TRUE." << TestLog::EndMessage;
 				isOk = false;
 			}
 		}
@@ -1001,40 +899,51 @@
 
 	if (m_iteration < (int)m_configs.size())
 	{
+		const Library&		egl				= m_eglTestCtx.getLibrary();
 		const EGLConfig		config			= m_configs[m_iteration];
-		tcu::egl::Display&	display			= m_eglTestCtx.getDisplay();
-		const EGLint		surfaceTypes	= display.getConfigAttrib(config, EGL_SURFACE_TYPE);
-		const EGLint		configId		= display.getConfigAttrib(config, EGL_CONFIG_ID);
+		const EGLint		surfaceTypes	= eglu::getConfigAttribInt(egl, m_display, config, EGL_SURFACE_TYPE);
+		const EGLint		configId		= eglu::getConfigAttribInt(egl, m_display, config, EGL_CONFIG_ID);
 
 		if ((surfaceTypes & EGL_PBUFFER_BIT) != 0)
 		{
-			tcu::ScopedLogSection section(m_testCtx.getLog(), ("EGLConfig ID: " + de::toString(configId) + " with PBuffer").c_str(), ("EGLConfig ID: " + de::toString(configId)).c_str());
-			const EGLint attribList[] =
+			tcu::ScopedLogSection	section			(m_testCtx.getLog(), ("EGLConfig ID: " + de::toString(configId) + " with PBuffer").c_str(), ("EGLConfig ID: " + de::toString(configId)).c_str());
+			const EGLint			attribList[]	=
 			{
 				EGL_WIDTH,	64,
 				EGL_HEIGHT,	64,
 				EGL_NONE
 			};
+			eglu::UniqueSurface		surface			(egl, m_display, egl.createPbufferSurface(m_display, config, attribList));
+			EGLU_CHECK_MSG(egl, "eglCreatePbufferSurface");
 
-			tcu::egl::PbufferSurface pbuffer(display, config, attribList);
-			executeForConfig(display, config, pbuffer);
+			executeForSurface(config, *surface);
 		}
 		else if ((surfaceTypes & EGL_WINDOW_BIT) != 0)
 		{
-			de::UniquePtr<eglu::NativeWindow>	window	(m_eglTestCtx.createNativeWindow(display.getEGLDisplay(), config, DE_NULL, 256, 256, eglu::parseWindowVisibility(m_testCtx.getCommandLine())));
-			tcu::egl::WindowSurface				surface	(display, eglu::createWindowSurface(m_eglTestCtx.getNativeDisplay(), *window, display.getEGLDisplay(), config, DE_NULL));
+			const eglu::NativeWindowFactory*	factory	= eglu::selectNativeWindowFactory(m_eglTestCtx.getNativeDisplayFactory(), m_testCtx.getCommandLine());
 
-			executeForConfig(display, config, surface);
+			if (!factory)
+				TCU_THROW(NotSupportedError, "Windows not supported");
+
+			de::UniquePtr<eglu::NativeWindow>	window	(factory->createWindow(&m_eglTestCtx.getNativeDisplay(), m_display, config, DE_NULL, eglu::WindowParams(256, 256, eglu::parseWindowVisibility(m_testCtx.getCommandLine()))));
+			eglu::UniqueSurface					surface	(egl, m_display, eglu::createWindowSurface(m_eglTestCtx.getNativeDisplay(), *window, m_display, config, DE_NULL));
+
+			executeForSurface(config, *surface);
 		}
 		else if ((surfaceTypes & EGL_PIXMAP_BIT) != 0)
 		{
-			de::UniquePtr<eglu::NativePixmap>	pixmap	(m_eglTestCtx.createNativePixmap(display.getEGLDisplay(), config, DE_NULL, 256, 256));
-			tcu::egl::PixmapSurface				surface	(display, eglu::createPixmapSurface(m_eglTestCtx.getNativeDisplay(), *pixmap, display.getEGLDisplay(), config, DE_NULL));
+			const eglu::NativePixmapFactory*	factory	= eglu::selectNativePixmapFactory(m_eglTestCtx.getNativeDisplayFactory(), m_testCtx.getCommandLine());
 
-			executeForConfig(display, config, surface);
+			if (!factory)
+				TCU_THROW(NotSupportedError, "Pixmaps not supported");
+
+			de::UniquePtr<eglu::NativePixmap>	pixmap	(factory->createPixmap(&m_eglTestCtx.getNativeDisplay(), m_display, config, DE_NULL, 256, 256));
+			eglu::UniqueSurface					surface	(egl, m_display, eglu::createPixmapSurface(m_eglTestCtx.getNativeDisplay(), *pixmap, m_display, config, DE_NULL));
+
+			executeForSurface(config, *surface);
 		}
 		else // No supported surface type
-			TCU_CHECK(false);
+			TCU_FAIL("Invalid or empty surface type bits");
 
 		m_iteration++;
 		return CONTINUE;
@@ -1055,30 +964,27 @@
 	}
 }
 
-void CreateContextExtCase::executeForConfig (tcu::egl::Display& display, EGLConfig config, tcu::egl::Surface& surface)
+void CreateContextExtCase::executeForSurface (EGLConfig config, EGLSurface surface)
 {
-	tcu::egl::Context*		context		= DE_NULL;
+	const Library&	egl		= m_eglTestCtx.getLibrary();
 
-	TCU_CHECK_EGL_CALL(eglBindAPI(m_api));
+	EGLU_CHECK_CALL(egl, bindAPI(m_api));
 
 	try
 	{
-		glw::Functions	gl;
+		glw::Functions		gl;
+		eglu::UniqueContext	context	(egl, m_display, egl.createContext(m_display, config, EGL_NO_CONTEXT, &m_attribList[0]));
+		EGLU_CHECK_MSG(egl, "eglCreateContext");
 
-		context = new tcu::egl::Context(display, config, &(m_attribList[0]), m_api);
-		context->makeCurrent(surface, surface);
+		EGLU_CHECK_CALL(egl, makeCurrent(m_display, surface, surface, *context));
 
-		m_eglTestCtx.getGLFunctions(gl, m_glContextType.getAPI());
+		m_eglTestCtx.initGLFunctions(&gl, m_glContextType.getAPI());
 
 		if (!validateCurrentContext(gl))
 			m_isOk = false;
-
-		delete context;
 	}
 	catch (const eglu::Error& error)
 	{
-		delete context;
-
 		if (error.getError() == EGL_BAD_MATCH)
 			m_testCtx.getLog() << TestLog::Message << "Context creation failed with error EGL_BAD_CONTEXT. Config doesn't support api version." << TestLog::EndMessage;
 		else if (error.getError() == EGL_BAD_CONFIG)
@@ -1089,11 +995,6 @@
 			m_isOk = false;
 		}
 	}
-	catch (...)
-	{
-		delete context;
-		throw;
-	}
 }
 
 class CreateContextExtGroup : public TestCaseGroup
@@ -1122,6 +1023,40 @@
 {
 }
 
+
+template <int Red, int Green, int Blue, int Alpha>
+static bool colorBits (const eglu::CandidateConfig& c)
+{
+	return c.redSize()		== Red		&&
+		   c.greenSize()	== Green	&&
+		   c.blueSize()		== Blue		&&
+		   c.alphaSize()	== Alpha;
+}
+
+static bool	hasDepth	(const eglu::CandidateConfig& c)	{ return c.depthSize() > 0;		}
+static bool	noDepth		(const eglu::CandidateConfig& c)	{ return c.depthSize() == 0;	}
+static bool	hasStencil	(const eglu::CandidateConfig& c)	{ return c.stencilSize() > 0;	}
+static bool	noStencil	(const eglu::CandidateConfig& c)	{ return c.stencilSize() == 0;	}
+
+template <deUint32 Type>
+static bool renderable (const eglu::CandidateConfig& c)
+{
+	return (c.renderableType() & Type) == Type;
+}
+
+static eglu::ConfigFilter getRenderableFilter (deUint32 bits)
+{
+	switch (bits)
+	{
+		case EGL_OPENGL_ES2_BIT:	return renderable<EGL_OPENGL_ES2_BIT>;
+		case EGL_OPENGL_ES3_BIT:	return renderable<EGL_OPENGL_ES3_BIT>;
+		case EGL_OPENGL_BIT:		return renderable<EGL_OPENGL_BIT>;
+		default:
+			DE_ASSERT(false);
+			return renderable<0>;
+	}
+}
+
 void CreateContextExtGroup::init (void)
 {
 	const struct
@@ -1129,58 +1064,45 @@
 		const char*				name;
 		const char*				description;
 
-		EGLint					redSize;
-		EGLint					greenSize;
-		EGLint					blueSize;
-		EGLint					alphaSize;
-
-		bool					hasDepth;
-		bool					hasStencil;
+		eglu::ConfigFilter		colorFilter;
+		eglu::ConfigFilter		depthFilter;
+		eglu::ConfigFilter		stencilFilter;
 	} groups[] =
 	{
-		{ "rgb565_no_depth_no_stencil",		"RGB565 configs without depth or stencil",		5, 6, 5, 0, false,	false	},
-		{ "rgb565_no_depth_stencil",		"RGB565 configs with stencil and no depth",		5, 6, 5, 0, false,	true	},
-		{ "rgb565_depth_no_stencil",		"RGB565 configs with depth and no stencil",		5, 6, 5, 0, true,	false	},
-		{ "rgb565_depth_stencil",			"RGB565 configs with depth and stencil",		5, 6, 5, 0, true,	true	},
+		{ "rgb565_no_depth_no_stencil",		"RGB565 configs without depth or stencil",		colorBits<5, 6, 5, 0>, noDepth, 	noStencil	},
+		{ "rgb565_no_depth_stencil",		"RGB565 configs with stencil and no depth",		colorBits<5, 6, 5, 0>, noDepth,		hasStencil	},
+		{ "rgb565_depth_no_stencil",		"RGB565 configs with depth and no stencil",		colorBits<5, 6, 5, 0>, hasDepth,	noStencil	},
+		{ "rgb565_depth_stencil",			"RGB565 configs with depth and stencil",		colorBits<5, 6, 5, 0>, hasDepth,	hasStencil	},
 
-		{ "rgb888_no_depth_no_stencil",		"RGB888 configs without depth or stencil",		8, 8, 8, 0, false,	false	},
-		{ "rgb888_no_depth_stencil",		"RGB888 configs with stencil and no depth",		8, 8, 8, 0, false,	true	},
-		{ "rgb888_depth_no_stencil",		"RGB888 configs with depth and no stencil",		8, 8, 8, 0, true,	false	},
-		{ "rgb888_depth_stencil",			"RGB888 configs with depth and stencil",		8, 8, 8, 0, true,	true	},
+		{ "rgb888_no_depth_no_stencil",		"RGB888 configs without depth or stencil",		colorBits<8, 8, 8, 0>, noDepth, 	noStencil	},
+		{ "rgb888_no_depth_stencil",		"RGB888 configs with stencil and no depth",		colorBits<8, 8, 8, 0>, noDepth,		hasStencil	},
+		{ "rgb888_depth_no_stencil",		"RGB888 configs with depth and no stencil",		colorBits<8, 8, 8, 0>, hasDepth,	noStencil	},
+		{ "rgb888_depth_stencil",			"RGB888 configs with depth and stencil",		colorBits<8, 8, 8, 0>, hasDepth,	hasStencil	},
 
-		{ "rgba4444_no_depth_no_stencil",	"RGBA4444 configs without depth or stencil",	4, 4, 4, 4, false,	false	},
-		{ "rgba4444_no_depth_stencil",		"RGBA4444 configs with stencil and no depth",	4, 4, 4, 4, false,	true	},
-		{ "rgba4444_depth_no_stencil",		"RGBA4444 configs with depth and no stencil",	4, 4, 4, 4, false,	false	},
-		{ "rgba4444_depth_stencil",			"RGBA4444 configs with depth and stencil",		4, 4, 4, 4, true,	true	},
+		{ "rgba4444_no_depth_no_stencil",	"RGBA4444 configs without depth or stencil",	colorBits<4, 4, 4, 4>, noDepth, 	noStencil	},
+		{ "rgba4444_no_depth_stencil",		"RGBA4444 configs with stencil and no depth",	colorBits<4, 4, 4, 4>, noDepth,		hasStencil	},
+		{ "rgba4444_depth_no_stencil",		"RGBA4444 configs with depth and no stencil",	colorBits<4, 4, 4, 4>, hasDepth, 	noStencil	},
+		{ "rgba4444_depth_stencil",			"RGBA4444 configs with depth and stencil",		colorBits<4, 4, 4, 4>, hasDepth,	hasStencil	},
 
-		{ "rgba5551_no_depth_no_stencil",	"RGBA5551 configs without depth or stencil",	5, 5, 5, 1, false,	false	},
-		{ "rgba5551_no_depth_stencil",		"RGBA5551 configs with stencil and no depth",	5, 5, 5, 1, false,	true	},
-		{ "rgba5551_depth_no_stencil",		"RGBA5551 configs with depth and no stencil",	5, 5, 5, 1, true,	false	},
-		{ "rgba5551_depth_stencil",			"RGBA5551 configs with depth and stencil",		5, 5, 5, 1, true,	true	},
+		{ "rgba5551_no_depth_no_stencil",	"RGBA5551 configs without depth or stencil",	colorBits<5, 5, 5, 1>, noDepth, 	noStencil	},
+		{ "rgba5551_no_depth_stencil",		"RGBA5551 configs with stencil and no depth",	colorBits<5, 5, 5, 1>, noDepth,		hasStencil	},
+		{ "rgba5551_depth_no_stencil",		"RGBA5551 configs with depth and no stencil",	colorBits<5, 5, 5, 1>, hasDepth,	noStencil	},
+		{ "rgba5551_depth_stencil",			"RGBA5551 configs with depth and stencil",		colorBits<5, 5, 5, 1>, hasDepth,	hasStencil	},
 
-		{ "rgba8888_no_depth_no_stencil",	"RGBA8888 configs without depth or stencil",	8, 8, 8, 8, false,	false	},
-		{ "rgba8888_no_depth_stencil",		"RGBA8888 configs with stencil and no depth",	8, 8, 8, 8, false,	true	},
-		{ "rgba8888_depth_no_stencil",		"RGBA8888 configs with depth and no stencil",	8, 8, 8, 8, true,	false	},
-		{ "rgba8888_depth_stencil",			"RGBA8888 configs with depth and stencil",		8, 8, 8, 8, true,	true	}
+		{ "rgba8888_no_depth_no_stencil",	"RGBA8888 configs without depth or stencil",	colorBits<8, 8, 8, 8>, noDepth, 	noStencil	},
+		{ "rgba8888_no_depth_stencil",		"RGBA8888 configs with stencil and no depth",	colorBits<8, 8, 8, 8>, noDepth,		hasStencil	},
+		{ "rgba8888_depth_no_stencil",		"RGBA8888 configs with depth and no stencil",	colorBits<8, 8, 8, 8>, hasDepth,	noStencil	},
+		{ "rgba8888_depth_stencil",			"RGBA8888 configs with depth and stencil",		colorBits<8, 8, 8, 8>, hasDepth,	hasStencil	}
 	};
 
 	for (int groupNdx = 0; groupNdx < DE_LENGTH_OF_ARRAY(groups); groupNdx++)
 	{
 		eglu::FilterList filter;
 
-		filter
-		<< (eglu::ConfigRedSize()	== groups[groupNdx].redSize)
-		<< (eglu::ConfigGreenSize()	== groups[groupNdx].greenSize)
-		<< (eglu::ConfigBlueSize()	== groups[groupNdx].blueSize)
-		<< (eglu::ConfigAlphaSize()	== groups[groupNdx].alphaSize);
-
-		if (groups[groupNdx].hasDepth)
-			filter << (eglu::ConfigDepthSize() >= 1);
-
-		if (groups[groupNdx].hasStencil)
-			filter << (eglu::ConfigStencilSize() >= 1);
-
-		filter << (eglu::ConfigRenderableType() & m_apiBit);
+		filter << groups[groupNdx].colorFilter
+			   << groups[groupNdx].depthFilter
+			   << groups[groupNdx].stencilFilter
+			   << getRenderableFilter(m_apiBit);
 
 		addChild(new CreateContextExtCase(m_eglTestCtx, m_api, &(m_attribList[0]), filter, groups[groupNdx].name, groups[groupNdx].description));
 	}
diff --git a/modules/egl/teglCreateContextTests.cpp b/modules/egl/teglCreateContextTests.cpp
index 4f48728..81e0c38 100644
--- a/modules/egl/teglCreateContextTests.cpp
+++ b/modules/egl/teglCreateContextTests.cpp
@@ -24,36 +24,31 @@
 #include "teglCreateContextTests.hpp"
 #include "teglSimpleConfigCase.hpp"
 #include "egluStrUtil.hpp"
+#include "egluUtil.hpp"
+#include "eglwLibrary.hpp"
+#include "eglwEnums.hpp"
 #include "tcuTestLog.hpp"
 
-#include <EGL/eglext.h>
-
-#if !defined(EGL_OPENGL_ES3_BIT_KHR)
-#	define EGL_OPENGL_ES3_BIT_KHR	0x0040
-#endif
-#if !defined(EGL_CONTEXT_MAJOR_VERSION_KHR)
-#	define EGL_CONTEXT_MAJOR_VERSION_KHR EGL_CONTEXT_CLIENT_VERSION
-#endif
-
-using std::vector;
-using tcu::TestLog;
-
 namespace deqp
 {
 namespace egl
 {
 
+using std::vector;
+using tcu::TestLog;
+using namespace eglw;
+
 class CreateContextCase : public SimpleConfigCase
 {
 public:
-						CreateContextCase			(EglTestContext& eglTestCtx, const char* name, const char* description, const vector<EGLint>& configIds);
+						CreateContextCase			(EglTestContext& eglTestCtx, const char* name, const char* description, const eglu::FilterList& filters);
 						~CreateContextCase			(void);
 
-	void				executeForConfig			(tcu::egl::Display& display, EGLConfig config);
+	void				executeForConfig			(EGLDisplay display, EGLConfig config);
 };
 
-CreateContextCase::CreateContextCase (EglTestContext& eglTestCtx, const char* name, const char* description, const vector<EGLint>& configIds)
-	: SimpleConfigCase(eglTestCtx, name, description, configIds)
+CreateContextCase::CreateContextCase (EglTestContext& eglTestCtx, const char* name, const char* description, const eglu::FilterList& filters)
+	: SimpleConfigCase(eglTestCtx, name, description, filters)
 {
 }
 
@@ -61,11 +56,12 @@
 {
 }
 
-void CreateContextCase::executeForConfig (tcu::egl::Display& display, EGLConfig config)
+void CreateContextCase::executeForConfig (EGLDisplay display, EGLConfig config)
 {
-	TestLog&	log		= m_testCtx.getLog();
-	EGLint		id		= display.getConfigAttrib(config, EGL_CONFIG_ID);
-	EGLint		apiBits	= display.getConfigAttrib(config, EGL_RENDERABLE_TYPE);
+	const Library&	egl		= m_eglTestCtx.getLibrary();
+	TestLog&		log		= m_testCtx.getLog();
+	EGLint			id		= eglu::getConfigAttribInt(egl, display, config, EGL_CONFIG_ID);
+	EGLint			apiBits	= eglu::getConfigAttribInt(egl, display, config, EGL_RENDERABLE_TYPE);
 
 	static const EGLint es1Attrs[] = { EGL_CONTEXT_CLIENT_VERSION,		1, EGL_NONE };
 	static const EGLint es2Attrs[] = { EGL_CONTEXT_CLIENT_VERSION,		2, EGL_NONE };
@@ -92,12 +88,12 @@
 			continue; // Not supported API
 
 		log << TestLog::Message << "Creating " << apis[apiNdx].name << " context with config ID " << id << TestLog::EndMessage;
-		TCU_CHECK_EGL();
+		EGLU_CHECK_MSG(egl, "init");
 
-		TCU_CHECK_EGL_CALL(eglBindAPI(apis[apiNdx].api));
+		EGLU_CHECK_CALL(egl, bindAPI(apis[apiNdx].api));
 
-		EGLContext	context = eglCreateContext(display.getEGLDisplay(), config, EGL_NO_CONTEXT, apis[apiNdx].ctxAttrs);
-		EGLenum		err		= eglGetError();
+		EGLContext	context = egl.createContext(display, config, EGL_NO_CONTEXT, apis[apiNdx].ctxAttrs);
+		EGLenum		err		= egl.getError();
 
 		if (context == EGL_NO_CONTEXT || err != EGL_SUCCESS)
 		{
@@ -107,7 +103,7 @@
 		else
 		{
 			// Destroy
-			TCU_CHECK_EGL_CALL(eglDestroyContext(display.getEGLDisplay(), context));
+			EGLU_CHECK_CALL(egl, destroyContext(display, context));
 			log << TestLog::Message << "  Pass" << TestLog::EndMessage;
 		}
 	}
@@ -125,12 +121,11 @@
 
 void CreateContextTests::init (void)
 {
-	vector<NamedConfigIdSet>	configIdSets;
-	eglu::FilterList			filters;
-	NamedConfigIdSet::getDefaultSets(configIdSets, m_eglTestCtx.getConfigs(), filters);
+	vector<NamedFilterList>	filterLists;
+	getDefaultFilterLists(filterLists, eglu::FilterList());
 
-	for (vector<NamedConfigIdSet>::iterator i = configIdSets.begin(); i != configIdSets.end(); i++)
-		addChild(new CreateContextCase(m_eglTestCtx, i->getName(), i->getDescription(), i->getConfigIds()));
+	for (vector<NamedFilterList>::iterator i = filterLists.begin(); i != filterLists.end(); i++)
+		addChild(new CreateContextCase(m_eglTestCtx, i->getName(), i->getDescription(), *i));
 }
 
 } // egl
diff --git a/modules/egl/teglCreateSurfaceTests.cpp b/modules/egl/teglCreateSurfaceTests.cpp
index 584c2a9..1cbac4e 100644
--- a/modules/egl/teglCreateSurfaceTests.cpp
+++ b/modules/egl/teglCreateSurfaceTests.cpp
@@ -27,6 +27,10 @@
 #include "egluNativeWindow.hpp"
 #include "egluNativePixmap.hpp"
 #include "egluUtil.hpp"
+#include "egluUnique.hpp"
+
+#include "eglwLibrary.hpp"
+#include "eglwEnums.hpp"
 
 #include "teglSimpleConfigCase.hpp"
 #include "tcuTestContext.hpp"
@@ -38,26 +42,21 @@
 
 #include <memory>
 
-#if !defined(EGL_EXT_platform_base)
-#	define EGL_EXT_platform_base 1
-	typedef EGLDisplay (EGLAPIENTRYP PFNEGLGETPLATFORMDISPLAYEXTPROC) (EGLenum platform, void *native_display, const EGLint *attrib_list);
-	typedef EGLSurface (EGLAPIENTRYP PFNEGLCREATEPLATFORMWINDOWSURFACEEXTPROC) (EGLDisplay dpy, EGLConfig config, void *native_window, const EGLint *attrib_list);
-	typedef EGLSurface (EGLAPIENTRYP PFNEGLCREATEPLATFORMPIXMAPSURFACEEXTPROC) (EGLDisplay dpy, EGLConfig config, void *native_pixmap, const EGLint *attrib_list);
-#endif // EGL_EXT_platform_base
-
-using std::vector;
-using tcu::TestLog;
-
 namespace deqp
 {
 namespace egl
 {
+
+using std::vector;
+using tcu::TestLog;
+using namespace eglw;
+
 namespace
 {
 
-void checkEGLPlatformSupport (const char* platformExt)
+void checkEGLPlatformSupport (const Library& egl, const char* platformExt)
 {
-	std::vector<std::string> extensions = eglu::getPlatformExtensions();
+	std::vector<std::string> extensions = eglu::getPlatformExtensions(egl);
 
 	if (!de::contains(extensions.begin(), extensions.end(), platformExt))
 		throw tcu::NotSupportedError((std::string("Platform extension '") + platformExt + "' not supported").c_str(), "", __FILE__, __LINE__);
@@ -65,22 +64,20 @@
 
 EGLSurface createWindowSurface (EGLDisplay display, EGLConfig config, eglu::NativeDisplay& nativeDisplay, eglu::NativeWindow& window, bool useLegacyCreate)
 {
-	EGLSurface surface = EGL_NO_SURFACE;
+	const Library&	egl		= nativeDisplay.getLibrary();
+	EGLSurface		surface	= EGL_NO_SURFACE;
 
 	if (useLegacyCreate)
 	{
-		surface = eglCreateWindowSurface(display, config, window.getLegacyNative(), DE_NULL);
-		TCU_CHECK_EGL_MSG("eglCreateWindowSurface() failed");
+		surface = egl.createWindowSurface(display, config, window.getLegacyNative(), DE_NULL);
+		EGLU_CHECK_MSG(egl, "eglCreateWindowSurface() failed");
 	}
 	else
 	{
-		checkEGLPlatformSupport(nativeDisplay.getPlatformExtensionName());
+		checkEGLPlatformSupport(egl, nativeDisplay.getPlatformExtensionName());
 
-		PFNEGLCREATEPLATFORMWINDOWSURFACEEXTPROC createPlatformWindowSurfaceEXT = (PFNEGLCREATEPLATFORMWINDOWSURFACEEXTPROC)eglGetProcAddress("eglCreatePlatformWindowSurfaceEXT");
-		TCU_CHECK_EGL_MSG("eglGetProcAddress() failed");
-
-		surface = createPlatformWindowSurfaceEXT(display, config, window.getPlatformNative(), DE_NULL);
-		TCU_CHECK_EGL_MSG("eglCreatePlatformWindowSurfaceEXT() failed");
+		surface = egl.createPlatformWindowSurfaceEXT(display, config, window.getPlatformNative(), DE_NULL);
+		EGLU_CHECK_MSG(egl, "eglCreatePlatformWindowSurfaceEXT() failed");
 	}
 
 	return surface;
@@ -88,22 +85,20 @@
 
 EGLSurface createPixmapSurface (EGLDisplay display, EGLConfig config, eglu::NativeDisplay& nativeDisplay, eglu::NativePixmap& pixmap, bool useLegacyCreate)
 {
-	EGLSurface surface = EGL_NO_SURFACE;
+	const Library&	egl		= nativeDisplay.getLibrary();
+	EGLSurface		surface	= EGL_NO_SURFACE;
 
 	if (useLegacyCreate)
 	{
-		surface = eglCreatePixmapSurface(display, config, pixmap.getLegacyNative(), DE_NULL);
-		TCU_CHECK_EGL_MSG("eglCreatePixmapSurface() failed");
+		surface = egl.createPixmapSurface(display, config, pixmap.getLegacyNative(), DE_NULL);
+		EGLU_CHECK_MSG(egl, "eglCreatePixmapSurface() failed");
 	}
 	else
 	{
-		checkEGLPlatformSupport(nativeDisplay.getPlatformExtensionName());
+		checkEGLPlatformSupport(egl, nativeDisplay.getPlatformExtensionName());
 
-		PFNEGLCREATEPLATFORMPIXMAPSURFACEEXTPROC createPlatformPixmapSurfaceEXT = (PFNEGLCREATEPLATFORMPIXMAPSURFACEEXTPROC)eglGetProcAddress("eglCreatePlatformPixmapSurfaceEXT");
-		TCU_CHECK_EGL_MSG("eglGetProcAddress() failed");
-
-		surface = createPlatformPixmapSurfaceEXT(display, config, pixmap.getPlatformNative(), DE_NULL);
-		TCU_CHECK_EGL_MSG("eglCreatePlatformPixmapSurfaceEXT() failed");
+		surface = egl.createPlatformPixmapSurfaceEXT(display, config, pixmap.getPlatformNative(), DE_NULL);
+		EGLU_CHECK_MSG(egl, "eglCreatePlatformPixmapSurfaceEXT() failed");
 	}
 
 	return surface;
@@ -112,44 +107,49 @@
 class CreateWindowSurfaceCase : public SimpleConfigCase
 {
 public:
-	CreateWindowSurfaceCase (EglTestContext& eglTestCtx, const char* name, const char* description, bool useLegacyCreate, const vector<EGLint>& configIds)
-		: SimpleConfigCase	(eglTestCtx, name, description, configIds)
+	CreateWindowSurfaceCase (EglTestContext& eglTestCtx, const char* name, const char* description, bool useLegacyCreate, const eglu::FilterList& filters)
+		: SimpleConfigCase	(eglTestCtx, name, description, filters)
 		, m_useLegacyCreate	(useLegacyCreate)
 	{
 	}
 
-	void executeForConfig (tcu::egl::Display& display, EGLConfig config)
+	void executeForConfig (EGLDisplay display, EGLConfig config)
 	{
-		TestLog&	log		= m_testCtx.getLog();
-		EGLint		id		= display.getConfigAttrib(config, EGL_CONFIG_ID);
+		const Library&						egl				= m_eglTestCtx.getLibrary();
+		TestLog&							log				= m_testCtx.getLog();
+		EGLint								id				= eglu::getConfigID(egl, display, config);
+		const eglu::NativeWindowFactory*	windowFactory	= eglu::selectNativeWindowFactory(m_eglTestCtx.getNativeDisplayFactory(), m_testCtx.getCommandLine());
+
+		if (!windowFactory)
+			TCU_THROW(NotSupportedError, "Windows not supported");
 
 		// \todo [2011-03-23 pyry] Iterate thru all possible combinations of EGL_RENDER_BUFFER, EGL_VG_COLORSPACE and EGL_VG_ALPHA_FORMAT
 
 		if (m_useLegacyCreate)
 		{
-			if ((m_eglTestCtx.getNativeWindowFactory().getCapabilities() & eglu::NativeWindow::CAPABILITY_CREATE_SURFACE_LEGACY) == 0)
-				throw tcu::NotSupportedError("Native window doesn't support legacy eglCreateWindowSurface()", "", __FILE__, __LINE__);
+			if ((windowFactory->getCapabilities() & eglu::NativeWindow::CAPABILITY_CREATE_SURFACE_LEGACY) == 0)
+				TCU_THROW(NotSupportedError, "Native window doesn't support legacy eglCreateWindowSurface()");
 		}
 		else
 		{
-			if ((m_eglTestCtx.getNativeWindowFactory().getCapabilities() & eglu::NativeWindow::CAPABILITY_CREATE_SURFACE_PLATFORM) == 0)
-				throw tcu::NotSupportedError("Native window doesn't support eglCreatePlatformWindowSurfaceEXT()", "", __FILE__, __LINE__);
+			if ((windowFactory->getCapabilities() & eglu::NativeWindow::CAPABILITY_CREATE_SURFACE_PLATFORM) == 0)
+				TCU_THROW(NotSupportedError, "Native window doesn't support eglCreatePlatformWindowSurfaceEXT()");
 		}
 
 		log << TestLog::Message << "Creating window surface with config ID " << id << TestLog::EndMessage;
-		TCU_CHECK_EGL();
+		EGLU_CHECK_MSG(egl, "init");
 
 		{
 			const int							width			= 64;
 			const int							height			= 64;
-			de::UniquePtr<eglu::NativeWindow>	window			(m_eglTestCtx.createNativeWindow(display.getEGLDisplay(), config, DE_NULL, width, height, eglu::parseWindowVisibility(m_testCtx.getCommandLine())));
-			tcu::egl::WindowSurface				surface			(display, createWindowSurface(display.getEGLDisplay(), config, m_eglTestCtx.getNativeDisplay(), *window, m_useLegacyCreate));
+			de::UniquePtr<eglu::NativeWindow>	window			(windowFactory->createWindow(&m_eglTestCtx.getNativeDisplay(), display, config, DE_NULL, eglu::WindowParams(width, height, eglu::parseWindowVisibility(m_testCtx.getCommandLine()))));
+			eglu::UniqueSurface					surface			(egl, display, createWindowSurface(display, config, m_eglTestCtx.getNativeDisplay(), *window, m_useLegacyCreate));
 
 			EGLint								windowWidth		= 0;
 			EGLint								windowHeight	= 0;
 
-			TCU_CHECK_EGL_CALL(eglQuerySurface(display.getEGLDisplay(), surface.getEGLSurface(), EGL_WIDTH,		&windowWidth));
-			TCU_CHECK_EGL_CALL(eglQuerySurface(display.getEGLDisplay(), surface.getEGLSurface(), EGL_HEIGHT,	&windowHeight));
+			EGLU_CHECK_CALL(egl, querySurface(display, *surface, EGL_WIDTH,		&windowWidth));
+			EGLU_CHECK_CALL(egl, querySurface(display, *surface, EGL_HEIGHT,	&windowHeight));
 
 			if (windowWidth <= 0 || windowHeight <= 0)
 			{
@@ -168,43 +168,48 @@
 class CreatePixmapSurfaceCase : public SimpleConfigCase
 {
 public:
-	CreatePixmapSurfaceCase (EglTestContext& eglTestCtx, const char* name, const char* description, bool useLegacyCreate, const vector<EGLint>& configIds)
-		: SimpleConfigCase(eglTestCtx, name, description, configIds)
+	CreatePixmapSurfaceCase (EglTestContext& eglTestCtx, const char* name, const char* description, bool useLegacyCreate, const eglu::FilterList& filters)
+		: SimpleConfigCase(eglTestCtx, name, description, filters)
 		, m_useLegacyCreate	(useLegacyCreate)
 	{
 	}
 
-	void executeForConfig (tcu::egl::Display& display, EGLConfig config)
+	void executeForConfig (EGLDisplay display, EGLConfig config)
 	{
-		TestLog&	log		= m_testCtx.getLog();
-		EGLint		id		= display.getConfigAttrib(config, EGL_CONFIG_ID);
+		const Library&						egl				= m_eglTestCtx.getLibrary();
+		TestLog&							log				= m_testCtx.getLog();
+		EGLint								id				= eglu::getConfigID(egl, display, config);
+		const eglu::NativePixmapFactory*	pixmapFactory	= eglu::selectNativePixmapFactory(m_eglTestCtx.getNativeDisplayFactory(), m_testCtx.getCommandLine());
+
+		if (!pixmapFactory)
+			TCU_THROW(NotSupportedError, "Pixmaps not supported");
 
 		// \todo [2011-03-23 pyry] Iterate thru all possible combinations of EGL_RENDER_BUFFER, EGL_VG_COLORSPACE and EGL_VG_ALPHA_FORMAT
 
 		if (m_useLegacyCreate)
 		{
-			if ((m_eglTestCtx.getNativePixmapFactory().getCapabilities() & eglu::NativePixmap::CAPABILITY_CREATE_SURFACE_LEGACY) == 0)
-				throw tcu::NotSupportedError("Native pixmap doesn't support legacy eglCreatePixmapSurface()", "", __FILE__, __LINE__);
+			if ((pixmapFactory->getCapabilities() & eglu::NativePixmap::CAPABILITY_CREATE_SURFACE_LEGACY) == 0)
+				TCU_THROW(NotSupportedError, "Native pixmap doesn't support legacy eglCreatePixmapSurface()");
 		}
 		else
 		{
-			if ((m_eglTestCtx.getNativePixmapFactory().getCapabilities() & eglu::NativePixmap::CAPABILITY_CREATE_SURFACE_PLATFORM) == 0)
-				throw tcu::NotSupportedError("Native pixmap doesn't support eglCreatePlatformPixmapSurfaceEXT()", "", __FILE__, __LINE__);
+			if ((pixmapFactory->getCapabilities() & eglu::NativePixmap::CAPABILITY_CREATE_SURFACE_PLATFORM) == 0)
+				TCU_THROW(NotSupportedError, "Native pixmap doesn't support eglCreatePlatformPixmapSurfaceEXT()");
 		}
 
 		log << TestLog::Message << "Creating pixmap surface with config ID " << id << TestLog::EndMessage;
-		TCU_CHECK_EGL();
+		EGLU_CHECK_MSG(egl, "init");
 
 		{
 			const int							width			= 64;
 			const int							height			= 64;
-			de::UniquePtr<eglu::NativePixmap>	pixmap			(m_eglTestCtx.createNativePixmap(display.getEGLDisplay(), config, DE_NULL, width, height));
-			tcu::egl::PixmapSurface				surface			(display, createPixmapSurface(display.getEGLDisplay(), config, m_eglTestCtx.getNativeDisplay(), *pixmap, m_useLegacyCreate));
+			de::UniquePtr<eglu::NativePixmap>	pixmap			(pixmapFactory->createPixmap(&m_eglTestCtx.getNativeDisplay(), display, config, DE_NULL, width, height));
+			eglu::UniqueSurface					surface			(egl, display, createPixmapSurface(display, config, m_eglTestCtx.getNativeDisplay(), *pixmap, m_useLegacyCreate));
 			EGLint								pixmapWidth		= 0;
 			EGLint								pixmapHeight	= 0;
 
-			TCU_CHECK_EGL_CALL(eglQuerySurface(display.getEGLDisplay(), surface.getEGLSurface(), EGL_WIDTH,		&pixmapWidth));
-			TCU_CHECK_EGL_CALL(eglQuerySurface(display.getEGLDisplay(), surface.getEGLSurface(), EGL_HEIGHT,	&pixmapHeight));
+			EGLU_CHECK_CALL(egl, querySurface(display, *surface, EGL_WIDTH,		&pixmapWidth));
+			EGLU_CHECK_CALL(egl, querySurface(display, *surface, EGL_HEIGHT,	&pixmapHeight));
 
 			if (pixmapWidth <= 0 || pixmapHeight <= 0)
 			{
@@ -223,26 +228,27 @@
 class CreatePbufferSurfaceCase : public SimpleConfigCase
 {
 public:
-	CreatePbufferSurfaceCase (EglTestContext& eglTestCtx, const char* name, const char* description, const vector<EGLint>& configIds)
-		: SimpleConfigCase(eglTestCtx, name, description, configIds)
+	CreatePbufferSurfaceCase (EglTestContext& eglTestCtx, const char* name, const char* description, const eglu::FilterList& filters)
+		: SimpleConfigCase(eglTestCtx, name, description, filters)
 	{
 	}
 
-	void executeForConfig (tcu::egl::Display& display, EGLConfig config)
+	void executeForConfig (EGLDisplay display, EGLConfig config)
 	{
-		TestLog&	log		= m_testCtx.getLog();
-		EGLint		id		= display.getConfigAttrib(config, EGL_CONFIG_ID);
-		int			width	= 64;
-		int			height	= 64;
+		const Library&	egl		= m_eglTestCtx.getLibrary();
+		TestLog&		log		= m_testCtx.getLog();
+		EGLint			id		= eglu::getConfigID(egl, display, config);
+		int				width	= 64;
+		int				height	= 64;
 
 		// \todo [2011-03-23 pyry] Iterate thru all possible combinations of EGL_RENDER_BUFFER, EGL_VG_COLORSPACE and EGL_VG_ALPHA_FORMAT
 
 		log << TestLog::Message << "Creating pbuffer surface with config ID " << id << TestLog::EndMessage;
-		TCU_CHECK_EGL();
+		EGLU_CHECK_MSG(egl, "init");
 
 		// Clamp to maximums reported by implementation
-		width	= deMin32(width, display.getConfigAttrib(config, EGL_MAX_PBUFFER_WIDTH));
-		height	= deMin32(height, display.getConfigAttrib(config, EGL_MAX_PBUFFER_HEIGHT));
+		width	= deMin32(width, eglu::getConfigAttribInt(egl, display, config, EGL_MAX_PBUFFER_WIDTH));
+		height	= deMin32(height, eglu::getConfigAttribInt(egl, display, config, EGL_MAX_PBUFFER_HEIGHT));
 
 		if (width == 0 || height == 0)
 		{
@@ -253,7 +259,7 @@
 
 		// \todo [2011-03-23 pyry] Texture-backed variants!
 
-		EGLint attribs[] =
+		const EGLint attribs[] =
 		{
 			EGL_WIDTH,			width,
 			EGL_HEIGHT,			height,
@@ -261,10 +267,10 @@
 			EGL_NONE
 		};
 
-		EGLSurface surface = eglCreatePbufferSurface(display.getEGLDisplay(), config, attribs);
-		TCU_CHECK_EGL_MSG("Failed to create pbuffer");
+		EGLSurface surface = egl.createPbufferSurface(display, config, attribs);
+		EGLU_CHECK_MSG(egl, "Failed to create pbuffer");
 		TCU_CHECK(surface != EGL_NO_SURFACE);
-		eglDestroySurface(display.getEGLDisplay(), surface);
+		egl.destroySurface(display, surface);
 
 		log << TestLog::Message << "  Pass" << TestLog::EndMessage;
 	}
@@ -281,6 +287,12 @@
 {
 }
 
+template <deUint32 Type>
+static bool surfaceType (const eglu::CandidateConfig& c)
+{
+	return (c.surfaceType() & Type) == Type;
+}
+
 void CreateSurfaceTests::init (void)
 {
 	// Window surfaces
@@ -288,14 +300,14 @@
 		tcu::TestCaseGroup* windowGroup = new tcu::TestCaseGroup(m_testCtx, "window", "Window surfaces");
 		addChild(windowGroup);
 
-		eglu::FilterList filters;
-		filters << (eglu::ConfigSurfaceType() & EGL_WINDOW_BIT);
+		eglu::FilterList baseFilters;
+		baseFilters << surfaceType<EGL_WINDOW_BIT>;
 
-		vector<NamedConfigIdSet> configIdSets;
-		NamedConfigIdSet::getDefaultSets(configIdSets, m_eglTestCtx.getConfigs(), filters);
+		vector<NamedFilterList> filterLists;
+		getDefaultFilterLists(filterLists, baseFilters);
 
-		for (vector<NamedConfigIdSet>::iterator i = configIdSets.begin(); i != configIdSets.end(); i++)
-			windowGroup->addChild(new CreateWindowSurfaceCase(m_eglTestCtx, i->getName(), i->getDescription(), true, i->getConfigIds()));
+		for (vector<NamedFilterList>::iterator i = filterLists.begin(); i != filterLists.end(); i++)
+			windowGroup->addChild(new CreateWindowSurfaceCase(m_eglTestCtx, i->getName(), i->getDescription(), true, *i));
 	}
 
 	// Pixmap surfaces
@@ -303,14 +315,14 @@
 		tcu::TestCaseGroup* pixmapGroup = new tcu::TestCaseGroup(m_testCtx, "pixmap", "Pixmap surfaces");
 		addChild(pixmapGroup);
 
-		eglu::FilterList filters;
-		filters << (eglu::ConfigSurfaceType() & EGL_PIXMAP_BIT);
+		eglu::FilterList baseFilters;
+		baseFilters << surfaceType<EGL_PIXMAP_BIT>;
 
-		vector<NamedConfigIdSet> configIdSets;
-		NamedConfigIdSet::getDefaultSets(configIdSets, m_eglTestCtx.getConfigs(), filters);
+		vector<NamedFilterList> filterLists;
+		getDefaultFilterLists(filterLists, baseFilters);
 
-		for (vector<NamedConfigIdSet>::iterator i = configIdSets.begin(); i != configIdSets.end(); i++)
-			pixmapGroup->addChild(new CreatePixmapSurfaceCase(m_eglTestCtx, i->getName(), i->getDescription(), true, i->getConfigIds()));
+		for (vector<NamedFilterList>::iterator i = filterLists.begin(); i != filterLists.end(); i++)
+			pixmapGroup->addChild(new CreatePixmapSurfaceCase(m_eglTestCtx, i->getName(), i->getDescription(), true, *i));
 	}
 
 	// Pbuffer surfaces
@@ -318,14 +330,14 @@
 		tcu::TestCaseGroup* pbufferGroup = new tcu::TestCaseGroup(m_testCtx, "pbuffer", "Pbuffer surfaces");
 		addChild(pbufferGroup);
 
-		eglu::FilterList filters;
-		filters << (eglu::ConfigSurfaceType() & EGL_PBUFFER_BIT);
+		eglu::FilterList baseFilters;
+		baseFilters << surfaceType<EGL_PBUFFER_BIT>;
 
-		vector<NamedConfigIdSet> configIdSets;
-		NamedConfigIdSet::getDefaultSets(configIdSets, m_eglTestCtx.getConfigs(), filters);
+		vector<NamedFilterList> filterLists;
+		getDefaultFilterLists(filterLists, baseFilters);
 
-		for (vector<NamedConfigIdSet>::iterator i = configIdSets.begin(); i != configIdSets.end(); i++)
-			pbufferGroup->addChild(new CreatePbufferSurfaceCase(m_eglTestCtx, i->getName(), i->getDescription(), i->getConfigIds()));
+		for (vector<NamedFilterList>::iterator i = filterLists.begin(); i != filterLists.end(); i++)
+			pbufferGroup->addChild(new CreatePbufferSurfaceCase(m_eglTestCtx, i->getName(), i->getDescription(), *i));
 	}
 
 	// Window surfaces with new platform extension
@@ -333,14 +345,14 @@
 		tcu::TestCaseGroup* windowGroup = new tcu::TestCaseGroup(m_testCtx, "platform_window", "Window surfaces with platform extension");
 		addChild(windowGroup);
 
-		eglu::FilterList filters;
-		filters << (eglu::ConfigSurfaceType() & EGL_WINDOW_BIT);
+		eglu::FilterList baseFilters;
+		baseFilters << surfaceType<EGL_WINDOW_BIT>;
 
-		vector<NamedConfigIdSet> configIdSets;
-		NamedConfigIdSet::getDefaultSets(configIdSets, m_eglTestCtx.getConfigs(), filters);
+		vector<NamedFilterList> filterLists;
+		getDefaultFilterLists(filterLists, baseFilters);
 
-		for (vector<NamedConfigIdSet>::iterator i = configIdSets.begin(); i != configIdSets.end(); i++)
-			windowGroup->addChild(new CreateWindowSurfaceCase(m_eglTestCtx, i->getName(), i->getDescription(), false, i->getConfigIds()));
+		for (vector<NamedFilterList>::iterator i = filterLists.begin(); i != filterLists.end(); i++)
+			windowGroup->addChild(new CreateWindowSurfaceCase(m_eglTestCtx, i->getName(), i->getDescription(), false, *i));
 	}
 
 	// Pixmap surfaces with new platform extension
@@ -348,14 +360,14 @@
 		tcu::TestCaseGroup* pixmapGroup = new tcu::TestCaseGroup(m_testCtx, "platform_pixmap", "Pixmap surfaces with platform extension");
 		addChild(pixmapGroup);
 
-		eglu::FilterList filters;
-		filters << (eglu::ConfigSurfaceType() & EGL_PIXMAP_BIT);
+		eglu::FilterList baseFilters;
+		baseFilters << surfaceType<EGL_PIXMAP_BIT>;
 
-		vector<NamedConfigIdSet> configIdSets;
-		NamedConfigIdSet::getDefaultSets(configIdSets, m_eglTestCtx.getConfigs(), filters);
+		vector<NamedFilterList> filterLists;
+		getDefaultFilterLists(filterLists, baseFilters);
 
-		for (vector<NamedConfigIdSet>::iterator i = configIdSets.begin(); i != configIdSets.end(); i++)
-			pixmapGroup->addChild(new CreatePixmapSurfaceCase(m_eglTestCtx, i->getName(), i->getDescription(), false, i->getConfigIds()));
+		for (vector<NamedFilterList>::iterator i = filterLists.begin(); i != filterLists.end(); i++)
+			pixmapGroup->addChild(new CreatePixmapSurfaceCase(m_eglTestCtx, i->getName(), i->getDescription(), false, *i));
 	}
 }
 
diff --git a/modules/egl/teglGLES1RenderUtil.cpp b/modules/egl/teglGLES1RenderUtil.cpp
index fe96aa9..5066da2 100644
--- a/modules/egl/teglGLES1RenderUtil.cpp
+++ b/modules/egl/teglGLES1RenderUtil.cpp
@@ -59,14 +59,14 @@
 {
 	DE_UNREF(x && y && width && height);
 	DE_UNREF(color);
-	throw tcu::NotSupportedError("OpenGL ES 1.x is not supported", "", __FILE__, __LINE__);
+	TCU_THROW(NotSupportedError, "OpenGL ES 1.x is not supported");
 }
 
 void readPixels (tcu::Surface& dst, int x, int y, int width, int height)
 {
 	DE_UNREF(x && y && width && height);
 	DE_UNREF(dst);
-	throw tcu::NotSupportedError("OpenGL ES 1.x is not supported", "", __FILE__, __LINE__);
+	TCU_THROW(NotSupportedError, "OpenGL ES 1.x is not supported");
 }
 
 #endif // DEQP_SUPPORT_GLES1
diff --git a/modules/egl/teglGLES2RenderUtil.cpp b/modules/egl/teglGLES2RenderUtil.cpp
index 3cc7de9..9246cad 100644
--- a/modules/egl/teglGLES2RenderUtil.cpp
+++ b/modules/egl/teglGLES2RenderUtil.cpp
@@ -22,16 +22,8 @@
  *//*--------------------------------------------------------------------*/
 
 #include "teglGLES2RenderUtil.hpp"
-
-#if defined(DEQP_SUPPORT_GLES2) || defined(DEQP_SUPPORT_GLES3)
-#	include "gluDefs.hpp"
-#	include "gluPixelTransfer.hpp"
-#	if !defined(DEQP_SUPPORT_GLES2)
-#		include <GLES3/gl3.h>
-#	else
-#		include <GLES2/gl2.h>
-#	endif
-#endif
+#include "glwFunctions.hpp"
+#include "glwEnums.hpp"
 
 namespace deqp
 {
@@ -40,41 +32,21 @@
 namespace gles2
 {
 
-#if defined(DEQP_SUPPORT_GLES2) || defined(DEQP_SUPPORT_GLES3)
-
-void clear (int x, int y, int width, int height, const tcu::Vec4& color)
+void clear (const glw::Functions& gl, int x, int y, int width, int height, const tcu::Vec4& color)
 {
-	glEnable(GL_SCISSOR_TEST);
-	glScissor(x, y, width, height);
-	glClearColor(color.x(), color.y(), color.z(), color.w());
-	glClear(GL_COLOR_BUFFER_BIT);
-	glDisable(GL_SCISSOR_TEST);
+	gl.enable(GL_SCISSOR_TEST);
+	gl.scissor(x, y, width, height);
+	gl.clearColor(color.x(), color.y(), color.z(), color.w());
+	gl.clear(GL_COLOR_BUFFER_BIT);
+	gl.disable(GL_SCISSOR_TEST);
 }
 
-void readPixels (tcu::Surface& dst, int x, int y, int width, int height)
+void readPixels (const glw::Functions& gl, tcu::Surface& dst, int x, int y, int width, int height)
 {
 	dst.setSize(width, height);
-	glReadPixels(x, y, width, height, GL_RGBA, GL_UNSIGNED_BYTE, dst.getAccess().getDataPtr());
+	gl.readPixels(x, y, width, height, GL_RGBA, GL_UNSIGNED_BYTE, dst.getAccess().getDataPtr());
 }
 
-#else // DEQP_SUPPORT_GLES2 || DEQP_SUPPORT_GLES3
-
-void clear (int x, int y, int width, int height, const tcu::Vec4& color)
-{
-	DE_UNREF(x && y && width && height);
-	DE_UNREF(color);
-	throw tcu::NotSupportedError("OpenGL ES 2 is not supported", "", __FILE__, __LINE__);
-}
-
-void readPixels (tcu::Surface& dst, int x, int y, int width, int height)
-{
-	DE_UNREF(x && y && width && height);
-	DE_UNREF(dst);
-	throw tcu::NotSupportedError("OpenGL ES 2 is not supported", "", __FILE__, __LINE__);
-}
-
-#endif // DEQP_SUPPORT_GLES2 || DEQP_SUPPORT_GLES3
-
 } // gles2
 } // egl
 } // deqp
diff --git a/modules/egl/teglGLES2RenderUtil.hpp b/modules/egl/teglGLES2RenderUtil.hpp
index 7425bbe..0ec420c 100644
--- a/modules/egl/teglGLES2RenderUtil.hpp
+++ b/modules/egl/teglGLES2RenderUtil.hpp
@@ -27,6 +27,11 @@
 #include "tcuSurface.hpp"
 #include "tcuVector.hpp"
 
+namespace glw
+{
+class Functions;
+}
+
 namespace deqp
 {
 namespace egl
@@ -34,8 +39,8 @@
 namespace gles2
 {
 
-void	clear		(int x, int y, int width, int height, const tcu::Vec4& color);
-void	readPixels	(tcu::Surface& dst, int x, int y, int width, int height);
+void	clear		(const glw::Functions& gl, int x, int y, int width, int height, const tcu::Vec4& color);
+void	readPixels	(const glw::Functions& gl, tcu::Surface& dst, int x, int y, int width, int height);
 
 } // gles2
 } // egl
diff --git a/modules/egl/teglGLES2SharedRenderingPerfTests.cpp b/modules/egl/teglGLES2SharedRenderingPerfTests.cpp
index 90ac7ad..3732551 100644
--- a/modules/egl/teglGLES2SharedRenderingPerfTests.cpp
+++ b/modules/egl/teglGLES2SharedRenderingPerfTests.cpp
@@ -25,6 +25,10 @@
 
 #include "tcuTestLog.hpp"
 
+#include "egluUtil.hpp"
+#include "eglwLibrary.hpp"
+#include "eglwEnums.hpp"
+
 #include "gluDefs.hpp"
 #include "glwDefs.hpp"
 #include "glwEnums.hpp"
@@ -33,26 +37,24 @@
 #include "deThread.hpp"
 #include "deClock.h"
 #include "deStringUtil.hpp"
+#include "deSTLUtil.hpp"
 
 #include <vector>
 #include <string>
 #include <algorithm>
 #include <cmath>
 
-#include <EGL/egl.h>
-#include <EGL/eglext.h>
-
-#include <GLES2/gl2.h>
-#include <GLES2/gl2ext.h>
+namespace deqp
+{
+namespace egl
+{
 
 using tcu::TestLog;
 using std::vector;
 using std::string;
 
-namespace deqp
-{
-namespace egl
-{
+using namespace glw;
+using namespace eglw;
 
 namespace
 {
@@ -99,7 +101,7 @@
 class TestContext
 {
 public:
-						TestContext		(EglTestContext& eglTestCtx, EGLConfig eglConfig, const TestConfig& config, bool share, TestContext* parent);
+						TestContext		(EglTestContext& eglTestCtx, EGLDisplay display, EGLConfig eglConfig, const TestConfig& config, bool share, TestContext* parent);
 						~TestContext	(void);
 
 	void				render			(void);
@@ -113,59 +115,40 @@
 	EGLImageKHR			getEGLImage		(void) const { return m_eglImage;		}
 
 private:
-	TestContext*				m_parent;
-	EglTestContext&				m_testCtx;
-	TestConfig					m_config;
-	EGLContext					m_eglContext;
-	EGLSurface					m_eglSurface;
+	TestContext*		m_parent;
+	EglTestContext&		m_testCtx;
+	TestConfig			m_config;
 
-	glw::Functions				m_gl;
+	EGLDisplay			m_eglDisplay;
+	EGLContext			m_eglContext;
+	EGLSurface			m_eglSurface;
 
-	PFNEGLCREATEIMAGEKHRPROC	m_eglCreateImageKHR;
-	PFNEGLDESTROYIMAGEKHRPROC	m_eglDestroyImageKHR;
+	glw::Functions		m_gl;
 
-	PFNGLEGLIMAGETARGETTEXTURE2DOESPROC	m_glEGLImageTargetTexture2DOES;
+	GLuint				m_coordBuffer;
+	GLuint				m_indexBuffer;
+	GLuint				m_texture;
+	GLuint				m_program;
 
-	GLuint						m_coordBuffer;
-	GLuint						m_indexBuffer;
-	GLuint						m_texture;
-	GLuint						m_program;
+	EGLImageKHR			m_eglImage;
 
-	EGLImageKHR					m_eglImage;
+	GLuint				m_coordLoc;
+	GLuint				m_textureLoc;
 
-	GLuint						m_coordLoc;
-	GLuint						m_textureLoc;
+	vector<float>		m_coordData;
+	vector<deUint16>	m_indexData;
 
-	vector<float>				m_coordData;
-	vector<deUint16>			m_indexData;
-
-	EGLImageKHR					createEGLImage			(void);
-	GLuint						createTextureFromImage	(EGLImageKHR image);
+	EGLImageKHR			createEGLImage			(void);
+	GLuint				createTextureFromImage	(EGLImageKHR image);
 
 	// Not supported
-	TestContext&	operator=		(const TestContext&);
-					TestContext		(const TestContext&);
+	TestContext&		operator=				(const TestContext&);
+						TestContext				(const TestContext&);
 };
 
 namespace
 {
 
-bool checkExtension (const char* extensions, const char* extension)
-{
-	TCU_CHECK(extensions);
-
-	std::istringstream	stream(extensions);
-	string				ext;
-
-	while (std::getline(stream, ext, ' '))
-	{
-		if (ext == extension)
-			return true;
-	}
-
-	return false;
-}
-
 void createCoordData (vector<float>& data, const TestConfig& config)
 {
 	if (config.useIndices)
@@ -338,9 +321,9 @@
 		"\tgl_FragColor = texture2D(u_sampler, v_texCoord);\n"
 		"}\n";
 
-		gl.shaderSource(vertexShader, 1, &vertexShaderSource, NULL);
+		gl.shaderSource(vertexShader, 1, &vertexShaderSource, DE_NULL);
 		GLU_EXPECT_NO_ERROR(gl.getError(), "glShaderSource()");
-		gl.shaderSource(fragmentShader, 1, &fragmentShaderSource, NULL);
+		gl.shaderSource(fragmentShader, 1, &fragmentShaderSource, DE_NULL);
 		GLU_EXPECT_NO_ERROR(gl.getError(), "glShaderSource()");
 	}
 	else
@@ -361,9 +344,9 @@
 		"\tgl_FragColor = v_color;\n"
 		"}\n";
 
-		gl.shaderSource(vertexShader, 1, &vertexShaderSource, NULL);
+		gl.shaderSource(vertexShader, 1, &vertexShaderSource, DE_NULL);
 		GLU_EXPECT_NO_ERROR(gl.getError(), "glShaderSource()");
-		gl.shaderSource(fragmentShader, 1, &fragmentShaderSource, NULL);
+		gl.shaderSource(fragmentShader, 1, &fragmentShaderSource, DE_NULL);
 		GLU_EXPECT_NO_ERROR(gl.getError(), "glShaderSource()");
 	}
 
@@ -438,7 +421,7 @@
 				string	log;
 				GLsizei	length;
 
-				gl.getProgramInfoLog(program, 0, &length, NULL);
+				gl.getProgramInfoLog(program, 0, &length, DE_NULL);
 				GLU_EXPECT_NO_ERROR(gl.getError(), "glGetProgramInfoLog()");
 				log.resize(length, 0);
 
@@ -458,87 +441,87 @@
 	}
 }
 
-EGLContext createEGLContext (EglTestContext& testCtx, EGLConfig eglConfig, EGLContext share)
+EGLContext createEGLContext (EglTestContext& testCtx, EGLDisplay eglDisplay, EGLConfig eglConfig, EGLContext share)
 {
-	const EGLint attribList[] = {
+	const Library&	egl				= testCtx.getLibrary();
+	const EGLint	attribList[]	=
+	{
 		EGL_CONTEXT_CLIENT_VERSION, 2,
 		EGL_NONE
 	};
 
-	TCU_CHECK_EGL_CALL(eglBindAPI(EGL_OPENGL_ES_API));
+	EGLU_CHECK_CALL(egl, bindAPI(EGL_OPENGL_ES_API));
 
-	EGLContext context = eglCreateContext(testCtx.getDisplay().getEGLDisplay(), eglConfig, share, attribList);
-	TCU_CHECK_EGL_MSG("eglCreateContext()");
+	EGLContext context = egl.createContext(eglDisplay, eglConfig, share, attribList);
+	EGLU_CHECK_MSG(egl, "eglCreateContext()");
 
 	return context;
 }
 
-EGLSurface createEGLSurface (EglTestContext& testCtx, EGLConfig eglConfig, const TestConfig& config)
+EGLSurface createEGLSurface (EglTestContext& testCtx, EGLDisplay display, EGLConfig eglConfig, const TestConfig& config)
 {
-	const EGLint attribList[] = {
+	const Library&	egl				= testCtx.getLibrary();
+	const EGLint	attribList[]	=
+	{
 		EGL_WIDTH,	config.surfaceWidth,
 		EGL_HEIGHT, config.surfaceHeight,
 		EGL_NONE
 	};
 
-	EGLSurface surface = eglCreatePbufferSurface(testCtx.getDisplay().getEGLDisplay(), eglConfig, attribList);
-	TCU_CHECK_EGL_MSG("eglCreatePbufferSurface()");
+	EGLSurface surface = egl.createPbufferSurface(display, eglConfig, attribList);
+	EGLU_CHECK_MSG(egl, "eglCreatePbufferSurface()");
 
 	return surface;
 }
 
 } // anonymous
 
-TestContext::TestContext (EglTestContext& testCtx, EGLConfig eglConfig, const TestConfig& config, bool share, TestContext* parent)
+TestContext::TestContext (EglTestContext& testCtx, EGLDisplay eglDisplay, EGLConfig eglConfig, const TestConfig& config, bool share, TestContext* parent)
 	: m_parent				(parent)
 	, m_testCtx				(testCtx)
 	, m_config				(config)
+	, m_eglDisplay			(eglDisplay)
 	, m_eglContext			(EGL_NO_CONTEXT)
 	, m_eglSurface			(EGL_NO_SURFACE)
-
-	, m_eglCreateImageKHR	(NULL)
-	, m_eglDestroyImageKHR	(NULL)
-
-	, m_glEGLImageTargetTexture2DOES			(NULL)
-
 	, m_coordBuffer			(0)
 	, m_indexBuffer			(0)
 	, m_texture				(0)
 	, m_program				(0)
 	, m_eglImage			(EGL_NO_IMAGE_KHR)
 {
+	const Library&	egl	= m_testCtx.getLibrary();
+
 	if (m_config.textureType == TestConfig::TEXTURETYPE_IMAGE
 		|| m_config.textureType == TestConfig::TEXTURETYPE_SHARED_IMAGE
 		|| m_config.textureType == TestConfig::TEXTURETYPE_SHARED_IMAGE_TEXTURE)
 	{
-		if (	!checkExtension(eglQueryString(m_testCtx.getDisplay().getEGLDisplay(), EGL_EXTENSIONS), "EGL_KHR_image_base")
-			||	!checkExtension(eglQueryString(m_testCtx.getDisplay().getEGLDisplay(), EGL_EXTENSIONS), "EGL_KHR_gl_texture_2D_image"))
-			throw tcu::NotSupportedError("EGL_KHR_image_base extensions not supported", "", __FILE__, __LINE__);
+		const vector<string> extensions = eglu::getClientExtensions(egl, m_eglDisplay);
 
-		m_eglCreateImageKHR		= (PFNEGLCREATEIMAGEKHRPROC)eglGetProcAddress("eglCreateImageKHR");
-		m_eglDestroyImageKHR	= (PFNEGLDESTROYIMAGEKHRPROC)eglGetProcAddress("eglDestroyImageKHR");
-
-		TCU_CHECK(m_eglCreateImageKHR);
-		TCU_CHECK(m_eglDestroyImageKHR);
+		if (!de::contains(extensions.begin(), extensions.end(), "EGL_KHR_image_base") ||
+			!de::contains(extensions.begin(), extensions.end(), "EGL_KHR_gl_texture_2D_image"))
+			TCU_THROW(NotSupportedError, "EGL_KHR_image_base extensions not supported");
 	}
 
-	m_eglContext = createEGLContext(m_testCtx, eglConfig, (share && parent ? parent->getEGLContext() : EGL_NO_CONTEXT));
-	m_eglSurface = createEGLSurface(m_testCtx, eglConfig, config);
+	m_eglContext = createEGLContext(m_testCtx, m_eglDisplay, eglConfig, (share && parent ? parent->getEGLContext() : EGL_NO_CONTEXT));
+	m_eglSurface = createEGLSurface(m_testCtx, m_eglDisplay, eglConfig, config);
 
-	TCU_CHECK_EGL_CALL(eglMakeCurrent(m_testCtx.getDisplay().getEGLDisplay(), m_eglSurface, m_eglSurface, m_eglContext));
+	EGLU_CHECK_CALL(egl, makeCurrent(m_eglDisplay, m_eglSurface, m_eglSurface, m_eglContext));
 
-	m_testCtx.getGLFunctions(m_gl, glu::ApiType::es(2,0));
+	{
+		const char* reqExts[] = { "GL_OES_EGL_image" };
+		m_testCtx.initGLFunctions(&m_gl, glu::ApiType::es(2,0), DE_LENGTH_OF_ARRAY(reqExts), reqExts);
+	}
 
 	if (m_config.textureType == TestConfig::TEXTURETYPE_IMAGE
 		|| m_config.textureType == TestConfig::TEXTURETYPE_SHARED_IMAGE
 		|| m_config.textureType == TestConfig::TEXTURETYPE_SHARED_IMAGE_TEXTURE)
 	{
-		if (!checkExtension((const char*)m_gl.getString(GL_EXTENSIONS), "GL_OES_EGL_image"))
-			throw tcu::NotSupportedError("GL_OES_EGL_image extensions not supported", "", __FILE__, __LINE__);
+		vector<string> glExts = de::splitString((const char*)m_gl.getString(GL_EXTENSIONS), ' ');
 
-		m_glEGLImageTargetTexture2DOES = (PFNGLEGLIMAGETARGETTEXTURE2DOESPROC)eglGetProcAddress("glEGLImageTargetTexture2DOES");
+		if (!de::contains(glExts.begin(), glExts.end(), "GL_OES_EGL_image"))
+			TCU_THROW(NotSupportedError, "GL_OES_EGL_image extensions not supported");
 
-		TCU_CHECK(m_glEGLImageTargetTexture2DOES);
+		TCU_CHECK(m_gl.eglImageTargetTexture2DOES);
 	}
 
 	if (m_config.useCoordBuffer && (!m_config.sharedCoordBuffer || !parent))
@@ -602,7 +585,7 @@
 	if (m_config.useTexture)
 		m_textureLoc = m_gl.getUniformLocation(m_program, "u_sampler");
 
-	TCU_CHECK_EGL_CALL(eglMakeCurrent(m_testCtx.getDisplay().getEGLDisplay(), EGL_NO_SURFACE, EGL_NO_SURFACE, EGL_NO_CONTEXT));
+	EGLU_CHECK_CALL(egl, makeCurrent(m_eglDisplay, EGL_NO_SURFACE, EGL_NO_SURFACE, EGL_NO_CONTEXT));
 }
 
 EGLImageKHR TestContext::createEGLImage (void)
@@ -611,13 +594,15 @@
 
 	try
 	{
-		const EGLint attribList[] = {
+		const Library&	egl				= m_testCtx.getLibrary();
+		const EGLint	attribList[]	=
+		{
 			EGL_GL_TEXTURE_LEVEL_KHR, 0,
 			EGL_NONE
 		};
 
-		EGLImageKHR image = m_eglCreateImageKHR(m_testCtx.getDisplay().getEGLDisplay(), m_eglContext, EGL_GL_TEXTURE_2D_KHR, (EGLClientBuffer)(deUintptr)sourceTexture, attribList);
-		TCU_CHECK_EGL_MSG("eglCreateImageKHR()");
+		EGLImageKHR image = egl.createImageKHR(m_eglDisplay, m_eglContext, EGL_GL_TEXTURE_2D_KHR, (EGLClientBuffer)(deUintptr)sourceTexture, attribList);
+		EGLU_CHECK_MSG(egl, "eglCreateImageKHR()");
 
 		m_gl.deleteTextures(1, &sourceTexture);
 		GLU_EXPECT_NO_ERROR(m_gl.getError(), "eglCreateImageKHR()");
@@ -639,8 +624,9 @@
 	{
 		m_gl.genTextures(1, &texture);
 		m_gl.bindTexture(GL_TEXTURE_2D, texture);
-		m_glEGLImageTargetTexture2DOES(GL_TEXTURE_2D, image);
+		m_gl.eglImageTargetTexture2DOES(GL_TEXTURE_2D, image);
 		m_gl.bindTexture(GL_TEXTURE_2D, 0);
+		GLU_EXPECT_NO_ERROR(m_gl.getError(), "Creating texture from image");
 
 		return texture;
 	}
@@ -654,23 +640,23 @@
 
 TestContext::~TestContext (void)
 {
-	EGLDisplay display = m_testCtx.getDisplay().getEGLDisplay();
+	const Library&	egl	= m_testCtx.getLibrary();
 
-	TCU_CHECK_EGL_CALL(eglMakeCurrent(display, m_eglSurface, m_eglSurface, m_eglContext));
+	EGLU_CHECK_CALL(egl, makeCurrent(m_eglDisplay, m_eglSurface, m_eglSurface, m_eglContext));
 
-	if (m_parent == NULL && m_eglImage)
-		TCU_CHECK_EGL_CALL(m_eglDestroyImageKHR(display, m_eglImage));
+	if (m_parent == DE_NULL && m_eglImage)
+		EGLU_CHECK_CALL(egl, destroyImageKHR(m_eglDisplay, m_eglImage));
 
-	TCU_CHECK_EGL_CALL(eglMakeCurrent(display, EGL_NO_SURFACE, EGL_NO_SURFACE, EGL_NO_CONTEXT));
-	TCU_CHECK_EGL_CALL(eglDestroyContext(display, m_eglContext));
-	TCU_CHECK_EGL_CALL(eglDestroySurface(display, m_eglSurface));
+	EGLU_CHECK_CALL(egl, makeCurrent(m_eglDisplay, EGL_NO_SURFACE, EGL_NO_SURFACE, EGL_NO_CONTEXT));
+	EGLU_CHECK_CALL(egl, destroyContext(m_eglDisplay, m_eglContext));
+	EGLU_CHECK_CALL(egl, destroySurface(m_eglDisplay, m_eglSurface));
 }
 
 void TestContext::render (void)
 {
-	EGLDisplay display = m_testCtx.getDisplay().getEGLDisplay();
+	const Library&	egl	= m_testCtx.getLibrary();
 
-	eglMakeCurrent(display, m_eglSurface, m_eglSurface, m_eglContext);
+	egl.makeCurrent(m_eglDisplay, m_eglSurface, m_eglSurface, m_eglContext);
 
 	for (int frameNdx = 0; frameNdx < m_config.frameCount; frameNdx++)
 	{
@@ -720,12 +706,12 @@
 		}
 
 
-		eglSwapBuffers(display, m_eglSurface);
+		egl.swapBuffers(m_eglDisplay, m_eglSurface);
 	}
 
 	m_gl.finish();
 	GLU_EXPECT_NO_ERROR(m_gl.getError(), "glFinish()");
-	TCU_CHECK_EGL_CALL(eglMakeCurrent(display, EGL_NO_SURFACE, EGL_NO_SURFACE, EGL_NO_CONTEXT));
+	EGLU_CHECK_CALL(egl, makeCurrent(m_eglDisplay, EGL_NO_SURFACE, EGL_NO_SURFACE, EGL_NO_CONTEXT));
 }
 
 class TestThread : de::Thread
@@ -836,6 +822,8 @@
 private:
 	TestConfig					m_config;
 	const int					m_iterationCount;
+
+	EGLDisplay					m_display;
 	vector<TestContext*>		m_contexts;
 	vector<deUint64>			m_results;
 
@@ -847,6 +835,7 @@
 	: TestCase			(eglTestCtx, tcu::NODETYPE_PERFORMANCE, name, description)
 	, m_config			(config)
 	, m_iterationCount	(30)
+	, m_display			(EGL_NO_DISPLAY)
 {
 }
 
@@ -857,26 +846,22 @@
 
 void SharedRenderingPerfCase::init (void)
 {
-	EGLConfig eglConfig;
+	m_display = eglu::getAndInitDisplay(m_eglTestCtx.getNativeDisplay());
 
 	{
-		const EGLint	attribList[] = {
+		const Library&	egl				= m_eglTestCtx.getLibrary();
+		const EGLint	attribList[]	=
+		{
 			EGL_SURFACE_TYPE,		EGL_PBUFFER_BIT,
 			EGL_RENDERABLE_TYPE,	EGL_OPENGL_ES2_BIT,
 			EGL_NONE
 		};
+		EGLConfig		eglConfig		= eglu::chooseSingleConfig(egl, m_display, attribList);
 
-		EGLint		configCount = 0;
-		EGLDisplay	display	= m_eglTestCtx.getDisplay().getEGLDisplay();
-
-		TCU_CHECK_EGL_CALL(eglChooseConfig(display, attribList, &eglConfig, 1, &configCount));
-
-		TCU_CHECK(configCount != 0);
+		// Create contexts and resources
+		for (int threadNdx = 0; threadNdx < m_config.threadCount * m_config.perThreadContextCount; threadNdx++)
+			m_contexts.push_back(new TestContext(m_eglTestCtx, m_display, eglConfig, m_config, m_config.sharedContexts, (threadNdx == 0 ? DE_NULL : m_contexts[threadNdx-1])));
 	}
-
-	// Create contexts and resources
-	for (int threadNdx = 0; threadNdx < m_config.threadCount * m_config.perThreadContextCount; threadNdx++)
-		m_contexts.push_back(new TestContext(m_eglTestCtx, eglConfig, m_config, m_config.sharedContexts, (threadNdx == 0 ? NULL : m_contexts[threadNdx-1])));
 }
 
 void SharedRenderingPerfCase::deinit (void)
@@ -885,11 +870,17 @@
 	for (int threadNdx = 0; threadNdx < (int)m_contexts.size(); threadNdx++)
 	{
 		delete m_contexts[threadNdx];
-		m_contexts[threadNdx] = NULL;
+		m_contexts[threadNdx] = DE_NULL;
 	}
 
 	m_contexts.clear();
 	m_results.clear();
+
+	if (m_display != EGL_NO_DISPLAY)
+	{
+		m_eglTestCtx.getLibrary().terminate(m_display);
+		m_display = EGL_NO_DISPLAY;
+	}
 }
 
 namespace
@@ -918,7 +909,7 @@
 	for (int threadNdx = 0; threadNdx < (int)threads.size(); threadNdx++)
 	{
 		delete threads[threadNdx];
-		threads[threadNdx] = NULL;
+		threads[threadNdx] = DE_NULL;
 	}
 
 	threads.clear();
diff --git a/modules/egl/teglGLES2SharingTests.cpp b/modules/egl/teglGLES2SharingTests.cpp
index 5267c60..e073410 100644
--- a/modules/egl/teglGLES2SharingTests.cpp
+++ b/modules/egl/teglGLES2SharingTests.cpp
@@ -27,6 +27,10 @@
 
 #include "egluNativeWindow.hpp"
 #include "egluUtil.hpp"
+#include "egluUnique.hpp"
+
+#include "eglwLibrary.hpp"
+#include "eglwEnums.hpp"
 
 #include "tcuCommandLine.hpp"
 #include "tcuImageCompare.hpp"
@@ -43,8 +47,10 @@
 #include "deString.h"
 
 #include "gluDefs.hpp"
+#include "gluShaderProgram.hpp"
 
-#include <GLES2/gl2.h>
+#include "glwFunctions.hpp"
+#include "glwEnums.hpp"
 
 #include <memory>
 #include <sstream>
@@ -57,84 +63,8 @@
 namespace egl
 {
 
-namespace
-{
-
-// \todo [2013-04-09 pyry] Use glu::Program
-class Program
-{
-public:
-	Program (const char* vertexSource, const char* fragmentSource)
-		: m_program			(0)
-		, m_vertexShader	(0)
-		, m_fragmentShader	(0)
-		, m_isOk			(false)
-	{
-		m_program			= glCreateProgram();
-		m_vertexShader		= glCreateShader(GL_VERTEX_SHADER);
-		m_fragmentShader	= glCreateShader(GL_FRAGMENT_SHADER);
-
-		try
-		{
-			bool	vertexCompileOk		= false;
-			bool	fragmentCompileOk	= false;
-			bool	linkOk				= false;
-
-			for (int ndx = 0; ndx < 2; ndx++)
-			{
-				const char*		source			= ndx ? fragmentSource		: vertexSource;
-				const deUint32	shader			= ndx ? m_fragmentShader	: m_vertexShader;
-				int				compileStatus	= 0;
-				bool&			compileOk		= ndx ? fragmentCompileOk	: vertexCompileOk;
-
-				glShaderSource(shader, 1, &source, DE_NULL);
-				glCompileShader(shader);
-				glGetShaderiv(shader, GL_COMPILE_STATUS, &compileStatus);
-
-				compileOk = (compileStatus == GL_TRUE);
-			}
-
-			if (vertexCompileOk && fragmentCompileOk)
-			{
-				int linkStatus = 0;
-
-				glAttachShader(m_program, m_vertexShader);
-				glAttachShader(m_program, m_fragmentShader);
-				glLinkProgram(m_program);
-				glGetProgramiv(m_program, GL_LINK_STATUS, &linkStatus);
-
-				linkOk = (linkStatus == GL_TRUE);
-			}
-
-			m_isOk = linkOk;
-		}
-		catch (const std::exception&)
-		{
-			glDeleteShader(m_vertexShader);
-			glDeleteShader(m_fragmentShader);
-			glDeleteProgram(m_program);
-			throw;
-		}
-	}
-
-	~Program (void)
-	{
-		glDeleteShader(m_vertexShader);
-		glDeleteShader(m_fragmentShader);
-		glDeleteProgram(m_program);
-	}
-
-	bool			isOk			(void) const { return m_isOk;	}
-	deUint32		getProgram		(void) const {return m_program;	}
-
-private:
-	deUint32		m_program;
-	deUint32		m_vertexShader;
-	deUint32		m_fragmentShader;
-	bool			m_isOk;
-};
-
-} // anonymous
+using namespace glw;
+using namespace eglw;
 
 class GLES2SharingTest : public TestCase
 {
@@ -161,18 +91,20 @@
 	};
 
 					GLES2SharingTest	(EglTestContext& eglTestCtx, const char* name , const char* desc, const TestSpec& spec);
+
 	IterateResult	iterate				(void);
 
 private:
 	TestSpec		m_spec;
 
 	EGLContext		createContext		(EGLDisplay display, EGLContext share, EGLConfig config);
-	void			destroyContext		(EGLDisplay display, EGLContext context);
-	void			makeCurrent			(EGLDisplay display, EGLContext context, EGLSurface surafec);
+	void			makeCurrent			(EGLDisplay display, EGLContext context, EGLSurface surface);
 
 protected:
 	de::Random		m_random;
 	tcu::TestLog&	m_log;
+	glw::Functions	m_gl;
+
 	virtual void	createResource		(void)  { DE_ASSERT(false); }
 	virtual void 	destroyResource		(void)	{ DE_ASSERT(false); }
 	virtual void	renderResource		(tcu::Surface* screen, tcu::Surface* reference) { DE_UNREF(screen); DE_UNREF(reference); DE_ASSERT(false); }
@@ -184,148 +116,174 @@
 	, m_random	(deStringHash(name))
 	, m_log		(eglTestCtx.getTestContext().getLog())
 {
+	m_eglTestCtx.initGLFunctions(&m_gl, glu::ApiType::es(2,0));
 }
 
 EGLContext GLES2SharingTest::createContext (EGLDisplay display, EGLContext share, EGLConfig config)
 {
+	const Library& egl = m_eglTestCtx.getLibrary();
 	EGLContext context = EGL_NO_CONTEXT;
-	EGLint attriblist[] =
+	const EGLint attriblist[] =
 	{
 		EGL_CONTEXT_CLIENT_VERSION, 2,
 		EGL_NONE
 	};
 
-	EGLint configId = -1;
-	eglGetConfigAttrib(display, config, EGL_CONFIG_ID, &configId);
+	EGLU_CHECK_CALL(egl, bindAPI(EGL_OPENGL_ES_API));
 
-	TCU_CHECK_EGL_CALL(eglBindAPI(EGL_OPENGL_ES_API));
-
-	context = eglCreateContext(display, config, share, attriblist);
-	TCU_CHECK_EGL_MSG("Failed to create GLES2 context");
+	context = egl.createContext(display, config, share, attriblist);
+	EGLU_CHECK_MSG(egl, "Failed to create GLES2 context");
 	TCU_CHECK(context != EGL_NO_CONTEXT);
 
 	return context;
 }
 
-void GLES2SharingTest::destroyContext (EGLDisplay display, EGLContext context)
-{
-	TCU_CHECK_EGL_CALL(eglDestroyContext(display, context));
-}
-
 void GLES2SharingTest::makeCurrent (EGLDisplay display, EGLContext context, EGLSurface surface)
 {
-	TCU_CHECK_EGL_CALL(eglMakeCurrent(display, surface, surface, context));
+	const Library& egl = m_eglTestCtx.getLibrary();
+	EGLU_CHECK_CALL(egl, makeCurrent(display, surface, surface, context));
 }
 
 TestCase::IterateResult GLES2SharingTest::iterate (void)
 {
-	tcu::TestLog&		log		= m_testCtx.getLog();
-	vector<EGLConfig>	configs;
+	const Library&						egl				= m_eglTestCtx.getLibrary();
+	tcu::TestLog&						log				= m_testCtx.getLog();
+	eglu::UniqueDisplay					display			(egl, eglu::getAndInitDisplay(m_eglTestCtx.getNativeDisplay()));
+	const eglu::NativeWindowFactory*	windowFactory	= eglu::selectNativeWindowFactory(m_eglTestCtx.getNativeDisplayFactory(), m_testCtx.getCommandLine());
+	EGLConfig							config;
+	bool								isOk			= true;
+	EGLContext							contextA		= EGL_NO_CONTEXT;
+	EGLContext							contextB		= EGL_NO_CONTEXT;
 
-	EGLint attribList[] =
+	if (!windowFactory)
+		TCU_THROW(NotSupportedError, "Windows not supported");
+
 	{
-		EGL_RENDERABLE_TYPE, 	EGL_OPENGL_ES2_BIT,
-		EGL_SURFACE_TYPE,	 	EGL_WINDOW_BIT,
-		EGL_ALPHA_SIZE,			1,
-		EGL_NONE
-	};
-
-	tcu::egl::Display& display = m_eglTestCtx.getDisplay();
-	display.chooseConfig(attribList, configs);
-	EGLConfig config = configs[0];
-
-	de::UniquePtr<eglu::NativeWindow>	window	(m_eglTestCtx.createNativeWindow(display.getEGLDisplay(), config, DE_NULL, 480, 480, eglu::parseWindowVisibility(m_testCtx.getCommandLine())));
-	tcu::egl::WindowSurface				surface	(display, eglu::createWindowSurface(m_eglTestCtx.getNativeDisplay(), *window, display.getEGLDisplay(), config, DE_NULL));
-
-	m_log << tcu::TestLog::Message << "Create context A" << tcu::TestLog::EndMessage;
-	EGLContext		contextA	= createContext(display.getEGLDisplay(), EGL_NO_CONTEXT, config);
-	m_log << tcu::TestLog::Message << "Create context B" << tcu::TestLog::EndMessage;
-	EGLContext		contextB	= createContext(display.getEGLDisplay(), contextA, config);
-	bool			isOk		= true;
-
-	if (m_spec.useResource)
-	{
-		m_log << tcu::TestLog::Message << "Make current context A" << tcu::TestLog::EndMessage;
-		makeCurrent(display.getEGLDisplay(), contextA, surface.getEGLSurface());
-		m_log << tcu::TestLog::Message << "Creating resource" << tcu::TestLog::EndMessage;
-		createResource();
-
-		int		width	= 240;
-		int		height	= 240;
-
-		if (m_spec.renderOnContexA)
+		const EGLint attribList[] =
 		{
-			m_log << tcu::TestLog::Message << "Render resource" << tcu::TestLog::EndMessage;
-			if (m_spec.verifyOnContexA)
-			{
-				tcu::Surface screen	(width, height);
-				tcu::Surface ref	(width, height);
-				renderResource(&screen, &ref);
+			EGL_RENDERABLE_TYPE, 	EGL_OPENGL_ES2_BIT,
+			EGL_SURFACE_TYPE,	 	EGL_WINDOW_BIT,
+			EGL_ALPHA_SIZE,			1,
+			EGL_NONE
+		};
 
-				if (!fuzzyCompare(log, "Rendered image", "Rendering result comparision", ref, screen, 0.05f, tcu::COMPARE_LOG_RESULT))
-					isOk = false;
+		config = eglu::chooseSingleConfig(egl, *display, attribList);
+	}
+
+	try
+	{
+		de::UniquePtr<eglu::NativeWindow>	window	(windowFactory->createWindow(&m_eglTestCtx.getNativeDisplay(), *display, config, DE_NULL, eglu::WindowParams(480, 480, eglu::parseWindowVisibility(m_testCtx.getCommandLine()))));
+		eglu::UniqueSurface					surface	(egl, *display, eglu::createWindowSurface(m_eglTestCtx.getNativeDisplay(), *window, *display, config, DE_NULL));
+
+		m_log << tcu::TestLog::Message << "Create context A (share_context = EGL_NO_CONTEXT)" << tcu::TestLog::EndMessage;
+		contextA = createContext(*display, EGL_NO_CONTEXT, config);
+
+		m_log << tcu::TestLog::Message << "Create context B (share_context = context A)" << tcu::TestLog::EndMessage;
+		contextB = createContext(*display, contextA, config);
+
+		if (m_spec.useResource)
+		{
+			m_log << tcu::TestLog::Message << "Make current context A" << tcu::TestLog::EndMessage;
+			makeCurrent(*display, contextA, *surface);
+			m_log << tcu::TestLog::Message << "Creating resource" << tcu::TestLog::EndMessage;
+			createResource();
+
+			int		width	= 240;
+			int		height	= 240;
+
+			if (m_spec.renderOnContexA)
+			{
+				m_log << tcu::TestLog::Message << "Render resource" << tcu::TestLog::EndMessage;
+				if (m_spec.verifyOnContexA)
+				{
+					tcu::Surface screen	(width, height);
+					tcu::Surface ref	(width, height);
+					renderResource(&screen, &ref);
+
+					if (!fuzzyCompare(log, "Rendered image", "Rendering result comparision", ref, screen, 0.05f, tcu::COMPARE_LOG_RESULT))
+						isOk = false;
+				}
+				else
+				{
+					renderResource(DE_NULL, DE_NULL);
+				}
+			}
+
+			if (m_spec.renderOnContexB)
+			{
+				m_log << tcu::TestLog::Message << "Make current context B" << tcu::TestLog::EndMessage;
+				makeCurrent(*display, contextB, *surface);
+				m_log << tcu::TestLog::Message << "Render resource" << tcu::TestLog::EndMessage;
+				if (m_spec.verifyOnContexB)
+				{
+					tcu::Surface screen	(width, height);
+					tcu::Surface ref	(width, height);
+					renderResource(&screen, &ref);
+
+					if (!fuzzyCompare(log, "Rendered image", "Rendering result comparision", ref, screen, 0.05f, tcu::COMPARE_LOG_RESULT))
+						isOk = false;
+				}
+				else
+				{
+					renderResource(DE_NULL, DE_NULL);
+				}
+			}
+
+			if (m_spec.destroyOnContexB)
+			{
+				m_log << tcu::TestLog::Message << "Make current context B" << tcu::TestLog::EndMessage;
+				makeCurrent(*display, contextB, *surface);
+				m_log << tcu::TestLog::Message << "Destroy resource" << tcu::TestLog::EndMessage;
+				destroyResource();
 			}
 			else
 			{
-				renderResource(NULL, NULL);
+				m_log << tcu::TestLog::Message << "Make current context A" << tcu::TestLog::EndMessage;
+				makeCurrent(*display, contextA, *surface);
+				m_log << tcu::TestLog::Message << "Destroy resource" << tcu::TestLog::EndMessage;
+				destroyResource();
 			}
 		}
 
-		if (m_spec.renderOnContexB)
-		{
-			m_log << tcu::TestLog::Message << "Make current context B" << tcu::TestLog::EndMessage;
-			makeCurrent(display.getEGLDisplay(), contextB, surface.getEGLSurface());
-			m_log << tcu::TestLog::Message << "Render resource" << tcu::TestLog::EndMessage;
-			if (m_spec.verifyOnContexB)
-			{
-				tcu::Surface screen	(width, height);
-				tcu::Surface ref	(width, height);
-				renderResource(&screen, &ref);
+		makeCurrent(*display, EGL_NO_CONTEXT, EGL_NO_SURFACE);
 
-				if (!fuzzyCompare(log, "Rendered image", "Rendering result comparision", ref, screen, 0.05f, tcu::COMPARE_LOG_RESULT))
-					isOk = false;
-			}
-			else
-			{
-				renderResource(NULL, NULL);
-			}
-		}
-
-		if (m_spec.destroyOnContexB)
+		if (m_spec.destroyContextBFirst)
 		{
-			m_log << tcu::TestLog::Message << "Make current context B" << tcu::TestLog::EndMessage;
-			makeCurrent(display.getEGLDisplay(), contextB, surface.getEGLSurface());
-			m_log << tcu::TestLog::Message << "Destroy resource" << tcu::TestLog::EndMessage;
-			destroyResource();
+			m_log << tcu::TestLog::Message << "Destroy context B" << tcu::TestLog::EndMessage;
+			egl.destroyContext(*display, contextB);
+			contextB = EGL_NO_CONTEXT;
+
+			m_log << tcu::TestLog::Message << "Destroy context A" << tcu::TestLog::EndMessage;
+			egl.destroyContext(*display, contextA);
+			contextA = EGL_NO_CONTEXT;
 		}
 		else
 		{
-			m_log << tcu::TestLog::Message << "Make current context A" << tcu::TestLog::EndMessage;
-			makeCurrent(display.getEGLDisplay(), contextA, surface.getEGLSurface());
-			m_log << tcu::TestLog::Message << "Destroy resource" << tcu::TestLog::EndMessage;
-			destroyResource();
-		}
-	}
+			m_log << tcu::TestLog::Message << "Destroy context A" << tcu::TestLog::EndMessage;
+			egl.destroyContext(*display, contextA);
+			contextA = EGL_NO_CONTEXT;
 
-	if (m_spec.destroyContextBFirst)
-	{
-		m_log << tcu::TestLog::Message << "Destroy context B" << tcu::TestLog::EndMessage;
-		destroyContext(display.getEGLDisplay(), contextB);
-		m_log << tcu::TestLog::Message << "Destroy context A" << tcu::TestLog::EndMessage;
-		destroyContext(display.getEGLDisplay(), contextA);
+			m_log << tcu::TestLog::Message << "Destroy context B" << tcu::TestLog::EndMessage;
+			egl.destroyContext(*display, contextB);
+			contextB = EGL_NO_CONTEXT;
+		}
+
+		EGLU_CHECK(egl);
 	}
-	else
+	catch (...)
 	{
-		m_log << tcu::TestLog::Message << "Destroy context A" << tcu::TestLog::EndMessage;
-		destroyContext(display.getEGLDisplay(), contextA);
-		m_log << tcu::TestLog::Message << "Destroy context B" << tcu::TestLog::EndMessage;
-		destroyContext(display.getEGLDisplay(), contextB);
+		egl.makeCurrent(*display, EGL_NO_SURFACE, EGL_NO_SURFACE, EGL_NO_CONTEXT);
+		if (contextA != EGL_NO_CONTEXT)
+			egl.destroyContext(*display, contextA);
+		if (contextB != EGL_NO_CONTEXT)
+			egl.destroyContext(*display, contextB);
+		throw;
 	}
 
 	if (isOk)
 		m_testCtx.setTestResult(QP_TEST_RESULT_PASS, "Pass");
 	else
-		m_testCtx.setTestResult(QP_TEST_RESULT_FAIL, "Fail");
+		m_testCtx.setTestResult(QP_TEST_RESULT_FAIL, "Image comparison failed");
 
 	return STOP;
 }
@@ -360,15 +318,15 @@
 	for (int i = 0; i < size; i++)
 		m_buffer.push_back((GLubyte)m_random.getInt(0, 255));
 
-	GLU_CHECK_CALL(glGenBuffers(1, &m_glBuffer));
-	GLU_CHECK_CALL(glBindBuffer(GL_ARRAY_BUFFER, m_glBuffer));
-	GLU_CHECK_CALL(glBufferData(GL_ARRAY_BUFFER, (GLsizei)(m_buffer.size() * sizeof(GLubyte)), &(m_buffer[0]), GL_DYNAMIC_DRAW));
-	GLU_CHECK_CALL(glBindBuffer(GL_ARRAY_BUFFER, 0));
+	GLU_CHECK_GLW_CALL(m_gl, genBuffers(1, &m_glBuffer));
+	GLU_CHECK_GLW_CALL(m_gl, bindBuffer(GL_ARRAY_BUFFER, m_glBuffer));
+	GLU_CHECK_GLW_CALL(m_gl, bufferData(GL_ARRAY_BUFFER, (GLsizei)(m_buffer.size() * sizeof(GLubyte)), &(m_buffer[0]), GL_DYNAMIC_DRAW));
+	GLU_CHECK_GLW_CALL(m_gl, bindBuffer(GL_ARRAY_BUFFER, 0));
 }
 
 void GLES2BufferSharingTest::destroyResource (void)
 {
-	GLU_CHECK_CALL(glDeleteBuffers(1, &m_glBuffer));
+	GLU_CHECK_GLW_CALL(m_gl, deleteBuffers(1, &m_glBuffer));
 	m_buffer.clear();
 }
 
@@ -393,7 +351,7 @@
 	"\tgl_FragColor = vec4(v_color, v_color, v_color, 1.0);\n"
 	"}\n";
 
-	Program program(vertexShader, fragmentShader);
+	glu::ShaderProgram program(m_gl, glu::makeVtxFragSources(vertexShader, fragmentShader));
 
 	if (!program.isOk())
 		TCU_FAIL("Failed to compile shader program");
@@ -434,40 +392,40 @@
 		height = screen->getHeight();
 	}
 
-	GLU_CHECK_CALL(glViewport(0, 0, width, height));
+	GLU_CHECK_GLW_CALL(m_gl, viewport(0, 0, width, height));
 
-	GLU_CHECK_CALL(glClearColor(1.0f, 0.0f, 0.0f, 1.0f));
-	GLU_CHECK_CALL(glClear(GL_COLOR_BUFFER_BIT));
+	GLU_CHECK_GLW_CALL(m_gl, clearColor(1.0f, 0.0f, 0.0f, 1.0f));
+	GLU_CHECK_GLW_CALL(m_gl, clear(GL_COLOR_BUFFER_BIT));
 
-	GLU_CHECK_CALL(glUseProgram(program.getProgram()));
+	GLU_CHECK_GLW_CALL(m_gl, useProgram(program.getProgram()));
 
-	GLuint gridLocation = glGetAttribLocation(program.getProgram(), "a_pos");
-	GLU_CHECK_MSG("glGetAttribLocation()");
+	GLuint gridLocation = m_gl.getAttribLocation(program.getProgram(), "a_pos");
+	GLU_CHECK_GLW_MSG(m_gl, "glGetAttribLocation()");
 	TCU_CHECK(gridLocation != (GLuint)-1);
 
-	GLuint colorLocation = glGetAttribLocation(program.getProgram(), "a_color");
-	GLU_CHECK_MSG("glGetAttribLocation()");
+	GLuint colorLocation = m_gl.getAttribLocation(program.getProgram(), "a_color");
+	GLU_CHECK_GLW_MSG(m_gl, "glGetAttribLocation()");
 	TCU_CHECK(colorLocation != (GLuint)-1);
 
-	GLU_CHECK_CALL(glEnableVertexAttribArray(colorLocation));
-	GLU_CHECK_CALL(glEnableVertexAttribArray(gridLocation));
+	GLU_CHECK_GLW_CALL(m_gl, enableVertexAttribArray(colorLocation));
+	GLU_CHECK_GLW_CALL(m_gl, enableVertexAttribArray(gridLocation));
 
-	GLU_CHECK_CALL(glBindBuffer(GL_ARRAY_BUFFER, m_glBuffer));
-	GLU_CHECK_CALL(glVertexAttribPointer(colorLocation, 1, GL_UNSIGNED_BYTE, GL_TRUE, 0, NULL));
-	GLU_CHECK_CALL(glBindBuffer(GL_ARRAY_BUFFER, 0));
+	GLU_CHECK_GLW_CALL(m_gl, bindBuffer(GL_ARRAY_BUFFER, m_glBuffer));
+	GLU_CHECK_GLW_CALL(m_gl, vertexAttribPointer(colorLocation, 1, GL_UNSIGNED_BYTE, GL_TRUE, 0, DE_NULL));
+	GLU_CHECK_GLW_CALL(m_gl, bindBuffer(GL_ARRAY_BUFFER, 0));
 
-	GLU_CHECK_CALL(glVertexAttribPointer(gridLocation, 2, GL_FLOAT, GL_FALSE, 0, &(coords[0])));
+	GLU_CHECK_GLW_CALL(m_gl, vertexAttribPointer(gridLocation, 2, GL_FLOAT, GL_FALSE, 0, &(coords[0])));
 
-	GLU_CHECK_CALL(glDrawElements(GL_TRIANGLES, (GLsizei)indices.size(), GL_UNSIGNED_SHORT, &(indices[0])));
-	GLU_CHECK_CALL(glDisableVertexAttribArray(colorLocation));
-	GLU_CHECK_CALL(glDisableVertexAttribArray(gridLocation));
+	GLU_CHECK_GLW_CALL(m_gl, drawElements(GL_TRIANGLES, (GLsizei)indices.size(), GL_UNSIGNED_SHORT, &(indices[0])));
+	GLU_CHECK_GLW_CALL(m_gl, disableVertexAttribArray(colorLocation));
+	GLU_CHECK_GLW_CALL(m_gl, disableVertexAttribArray(gridLocation));
 
-	GLU_CHECK_CALL(glUseProgram(0));
+	GLU_CHECK_GLW_CALL(m_gl, useProgram(0));
 
 	if (screen)
 	{
 		tcu::clear(reference->getAccess(), tcu::IVec4(0xff, 0, 0, 0xff));
-		glReadPixels(0, 0, screen->getWidth(), screen->getHeight(), GL_RGBA, GL_UNSIGNED_BYTE, screen->getAccess().getDataPtr());
+		m_gl.readPixels(0, 0, screen->getWidth(), screen->getHeight(), GL_RGBA, GL_UNSIGNED_BYTE, screen->getAccess().getDataPtr());
 		for (int i = 0; i < (int)m_buffer.size() / 4; i++)
 		{
 			float fx1 = 0.125f * (i % 16) - 1.0f;
@@ -533,19 +491,19 @@
 	m_texture.allocLevel(0);
 
 	tcu::fillWithComponentGradients(m_texture.getLevel(0), tcu::Vec4(0.0f, 0.0f, 0.0f, 1.0f), tcu::Vec4(1.0f, 1.0f, 1.0f, 1.0f));
-	GLU_CHECK_CALL(glGenTextures(1, &m_glTexture));
-	GLU_CHECK_CALL(glBindTexture(GL_TEXTURE_2D, m_glTexture));
-	GLU_CHECK_CALL(glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_REPEAT));
-	GLU_CHECK_CALL(glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_REPEAT));
-	GLU_CHECK_CALL(glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR));
-	GLU_CHECK_CALL(glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR));
-	GLU_CHECK_CALL(glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, width, height, 0, GL_RGBA, GL_UNSIGNED_BYTE, m_texture.getLevel(0).getDataPtr()));
-	GLU_CHECK_CALL(glBindTexture(GL_TEXTURE_2D, 0));
+	GLU_CHECK_GLW_CALL(m_gl, genTextures(1, &m_glTexture));
+	GLU_CHECK_GLW_CALL(m_gl, bindTexture(GL_TEXTURE_2D, m_glTexture));
+	GLU_CHECK_GLW_CALL(m_gl, texParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_REPEAT));
+	GLU_CHECK_GLW_CALL(m_gl, texParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_REPEAT));
+	GLU_CHECK_GLW_CALL(m_gl, texParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR));
+	GLU_CHECK_GLW_CALL(m_gl, texParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR));
+	GLU_CHECK_GLW_CALL(m_gl, texImage2D(GL_TEXTURE_2D, 0, GL_RGBA, width, height, 0, GL_RGBA, GL_UNSIGNED_BYTE, m_texture.getLevel(0).getDataPtr()));
+	GLU_CHECK_GLW_CALL(m_gl, bindTexture(GL_TEXTURE_2D, 0));
 }
 
 void GLES2TextureSharingTest::destroyResource (void)
 {
-	GLU_CHECK_CALL(glDeleteTextures(1, &m_glTexture));
+	GLU_CHECK_GLW_CALL(m_gl, deleteTextures(1, &m_glTexture));
 }
 
 void GLES2TextureSharingTest::renderResource (tcu::Surface* screen, tcu::Surface* reference)
@@ -570,7 +528,7 @@
 	"\tgl_FragColor = texture2D(u_sampler, v_texCoord);\n"
 	"}\n";
 
-	Program program(vertexShader, fragmentShader);
+	glu::ShaderProgram program(m_gl, glu::makeVtxFragSources(vertexShader, fragmentShader));
 
 	if (!program.isOk())
 		TCU_FAIL("Failed to compile shader program");
@@ -603,47 +561,47 @@
 		2, 3, 0
 	};
 
-	GLU_CHECK_CALL(glViewport(0, 0, width, height));
+	GLU_CHECK_GLW_CALL(m_gl, viewport(0, 0, width, height));
 
-	GLU_CHECK_CALL(glClearColor(1.0f, 0.0f, 0.0f, 1.0f));
-	GLU_CHECK_CALL(glClear(GL_COLOR_BUFFER_BIT));
+	GLU_CHECK_GLW_CALL(m_gl, clearColor(1.0f, 0.0f, 0.0f, 1.0f));
+	GLU_CHECK_GLW_CALL(m_gl, clear(GL_COLOR_BUFFER_BIT));
 
-	GLU_CHECK_CALL(glUseProgram(program.getProgram()));
+	GLU_CHECK_GLW_CALL(m_gl, useProgram(program.getProgram()));
 
-	GLuint coordLocation = glGetAttribLocation(program.getProgram(), "a_pos");
-	GLU_CHECK_MSG("glGetAttribLocation()");
+	GLuint coordLocation = m_gl.getAttribLocation(program.getProgram(), "a_pos");
+	GLU_CHECK_GLW_MSG(m_gl, "glGetAttribLocation()");
 	TCU_CHECK(coordLocation != (GLuint)-1);
 
-	GLuint texCoordLocation = glGetAttribLocation(program.getProgram(), "a_texCorod");
-	GLU_CHECK_MSG("glGetAttribLocation()");
+	GLuint texCoordLocation = m_gl.getAttribLocation(program.getProgram(), "a_texCorod");
+	GLU_CHECK_GLW_MSG(m_gl, "glGetAttribLocation()");
 	TCU_CHECK(texCoordLocation != (GLuint)-1);
 
 
-	GLuint samplerLocation = glGetUniformLocation(program.getProgram(), "u_sampler");
-	GLU_CHECK_MSG("glGetUniformLocation()");
+	GLuint samplerLocation = m_gl.getUniformLocation(program.getProgram(), "u_sampler");
+	GLU_CHECK_GLW_MSG(m_gl, "glGetUniformLocation()");
 	TCU_CHECK(samplerLocation != (GLuint)-1);
 
-	GLU_CHECK_CALL(glActiveTexture(GL_TEXTURE0));
-	GLU_CHECK_CALL(glBindTexture(GL_TEXTURE_2D, m_glTexture));
+	GLU_CHECK_GLW_CALL(m_gl, activeTexture(GL_TEXTURE0));
+	GLU_CHECK_GLW_CALL(m_gl, bindTexture(GL_TEXTURE_2D, m_glTexture));
 
-	GLU_CHECK_CALL(glUniform1i(samplerLocation, 0));
+	GLU_CHECK_GLW_CALL(m_gl, uniform1i(samplerLocation, 0));
 
-	GLU_CHECK_CALL(glEnableVertexAttribArray(texCoordLocation));
-	GLU_CHECK_CALL(glEnableVertexAttribArray(coordLocation));
+	GLU_CHECK_GLW_CALL(m_gl, enableVertexAttribArray(texCoordLocation));
+	GLU_CHECK_GLW_CALL(m_gl, enableVertexAttribArray(coordLocation));
 
-	GLU_CHECK_CALL(glVertexAttribPointer(texCoordLocation, 2, GL_FLOAT, GL_FALSE, 0, texCoords));
-	GLU_CHECK_CALL(glVertexAttribPointer(coordLocation, 2, GL_FLOAT, GL_FALSE, 0, coords));
+	GLU_CHECK_GLW_CALL(m_gl, vertexAttribPointer(texCoordLocation, 2, GL_FLOAT, GL_FALSE, 0, texCoords));
+	GLU_CHECK_GLW_CALL(m_gl, vertexAttribPointer(coordLocation, 2, GL_FLOAT, GL_FALSE, 0, coords));
 
-	GLU_CHECK_CALL(glDrawElements(GL_TRIANGLES, 6, GL_UNSIGNED_SHORT, indices));
-	GLU_CHECK_CALL(glDisableVertexAttribArray(coordLocation));
-	GLU_CHECK_CALL(glDisableVertexAttribArray(texCoordLocation));
+	GLU_CHECK_GLW_CALL(m_gl, drawElements(GL_TRIANGLES, 6, GL_UNSIGNED_SHORT, indices));
+	GLU_CHECK_GLW_CALL(m_gl, disableVertexAttribArray(coordLocation));
+	GLU_CHECK_GLW_CALL(m_gl, disableVertexAttribArray(texCoordLocation));
 
-	GLU_CHECK_CALL(glBindTexture(GL_TEXTURE_2D, 0));
-	GLU_CHECK_CALL(glUseProgram(0));
+	GLU_CHECK_GLW_CALL(m_gl, bindTexture(GL_TEXTURE_2D, 0));
+	GLU_CHECK_GLW_CALL(m_gl, useProgram(0));
 
 	if (screen)
 	{
-		glReadPixels(0, 0, screen->getWidth(), screen->getHeight(), GL_RGBA, GL_UNSIGNED_BYTE, screen->getAccess().getDataPtr());
+		m_gl.readPixels(0, 0, screen->getWidth(), screen->getHeight(), GL_RGBA, GL_UNSIGNED_BYTE, screen->getAccess().getDataPtr());
 
 		for (int x = 0; x < width; x++)
 		{
@@ -669,20 +627,20 @@
 class GLES2ProgramSharingTest : public GLES2SharingTest
 {
 public:
-					GLES2ProgramSharingTest	(EglTestContext& eglTestCtx, const char* name, const char* desc, const GLES2SharingTest::TestSpec& spec);
+						GLES2ProgramSharingTest	(EglTestContext& eglTestCtx, const char* name, const char* desc, const GLES2SharingTest::TestSpec& spec);
 
 private:
-	Program*		m_program;
+	glu::ShaderProgram*	m_program;
 
-	virtual void	createResource		(void);
-	virtual void 	destroyResource		(void);
-	virtual void	renderResource		(tcu::Surface* screen, tcu::Surface* reference);
+	virtual void		createResource			(void);
+	virtual void 		destroyResource			(void);
+	virtual void		renderResource			(tcu::Surface* screen, tcu::Surface* reference);
 
 };
 
 GLES2ProgramSharingTest::GLES2ProgramSharingTest (EglTestContext& eglTestCtx, const char* name, const char* desc, const GLES2SharingTest::TestSpec& spec)
 	: GLES2SharingTest	(eglTestCtx, name, desc, spec)
-	, m_program			(NULL)
+	, m_program			(DE_NULL)
 {
 }
 
@@ -705,7 +663,7 @@
 	"\tgl_FragColor = v_color;\n"
 	"}\n";
 
-	m_program = new Program(vertexShader, fragmentShader);
+	m_program = new glu::ShaderProgram(m_gl, glu::makeVtxFragSources(vertexShader, fragmentShader));
 
 	if (!m_program->isOk())
 		TCU_FAIL("Failed to compile shader program");
@@ -748,35 +706,35 @@
 		2, 3, 0
 	};
 
-	GLU_CHECK_CALL(glViewport(0, 0, width, height));
+	GLU_CHECK_GLW_CALL(m_gl, viewport(0, 0, width, height));
 
-	GLU_CHECK_CALL(glClearColor(1.0f, 0.0f, 0.0f, 1.0f));
-	GLU_CHECK_CALL(glClear(GL_COLOR_BUFFER_BIT));
+	GLU_CHECK_GLW_CALL(m_gl, clearColor(1.0f, 0.0f, 0.0f, 1.0f));
+	GLU_CHECK_GLW_CALL(m_gl, clear(GL_COLOR_BUFFER_BIT));
 
-	GLU_CHECK_CALL(glUseProgram(m_program->getProgram()));
+	GLU_CHECK_GLW_CALL(m_gl, useProgram(m_program->getProgram()));
 
-	GLuint coordLocation = glGetAttribLocation(m_program->getProgram(), "a_pos");
-	GLU_CHECK_MSG("glGetAttribLocation()");
+	GLuint coordLocation = m_gl.getAttribLocation(m_program->getProgram(), "a_pos");
+	GLU_CHECK_GLW_MSG(m_gl, "glGetAttribLocation()");
 	TCU_CHECK(coordLocation != (GLuint)-1);
 
-	GLuint colorLocation = glGetAttribLocation(m_program->getProgram(), "a_color");
-	GLU_CHECK_MSG("glGetAttribLocation()");
+	GLuint colorLocation = m_gl.getAttribLocation(m_program->getProgram(), "a_color");
+	GLU_CHECK_GLW_MSG(m_gl, "glGetAttribLocation()");
 	TCU_CHECK(colorLocation != (GLuint)-1);
 
-	GLU_CHECK_CALL(glEnableVertexAttribArray(colorLocation));
-	GLU_CHECK_CALL(glEnableVertexAttribArray(coordLocation));
+	GLU_CHECK_GLW_CALL(m_gl, enableVertexAttribArray(colorLocation));
+	GLU_CHECK_GLW_CALL(m_gl, enableVertexAttribArray(coordLocation));
 
-	GLU_CHECK_CALL(glVertexAttribPointer(colorLocation, 4, GL_FLOAT, GL_FALSE, 0, colors));
-	GLU_CHECK_CALL(glVertexAttribPointer(coordLocation, 2, GL_FLOAT, GL_FALSE, 0, coords));
+	GLU_CHECK_GLW_CALL(m_gl, vertexAttribPointer(colorLocation, 4, GL_FLOAT, GL_FALSE, 0, colors));
+	GLU_CHECK_GLW_CALL(m_gl, vertexAttribPointer(coordLocation, 2, GL_FLOAT, GL_FALSE, 0, coords));
 
-	GLU_CHECK_CALL(glDrawElements(GL_TRIANGLES, 6, GL_UNSIGNED_SHORT, indices));
-	GLU_CHECK_CALL(glDisableVertexAttribArray(coordLocation));
-	GLU_CHECK_CALL(glDisableVertexAttribArray(colorLocation));
-	GLU_CHECK_CALL(glUseProgram(0));
+	GLU_CHECK_GLW_CALL(m_gl, drawElements(GL_TRIANGLES, 6, GL_UNSIGNED_SHORT, indices));
+	GLU_CHECK_GLW_CALL(m_gl, disableVertexAttribArray(coordLocation));
+	GLU_CHECK_GLW_CALL(m_gl, disableVertexAttribArray(colorLocation));
+	GLU_CHECK_GLW_CALL(m_gl, useProgram(0));
 
 	if (screen)
 	{
-		glReadPixels(0, 0, screen->getWidth(), screen->getHeight(), GL_RGBA, GL_UNSIGNED_BYTE, screen->getAccess().getDataPtr());
+		m_gl.readPixels(0, 0, screen->getWidth(), screen->getHeight(), GL_RGBA, GL_UNSIGNED_BYTE, screen->getAccess().getDataPtr());
 
 		tcu::clear(reference->getAccess(), tcu::IVec4(0xff, 0, 0, 0xff));
 
@@ -859,32 +817,32 @@
 	"}\n";
 
 
-	m_shader = glCreateShader(m_shaderType);
-	GLU_CHECK_MSG("glCreateShader()");
+	m_shader = m_gl.createShader(m_shaderType);
+	GLU_CHECK_GLW_MSG(m_gl, "glCreateShader()");
 
 	switch (m_shaderType)
 	{
 		case GL_VERTEX_SHADER:
-			GLU_CHECK_CALL(glShaderSource(m_shader, 1, &vertexShader, NULL));
+			GLU_CHECK_GLW_CALL(m_gl, shaderSource(m_shader, 1, &vertexShader, DE_NULL));
 			break;
 
 		case GL_FRAGMENT_SHADER:
-			GLU_CHECK_CALL(glShaderSource(m_shader, 1, &fragmentShader, NULL));
+			GLU_CHECK_GLW_CALL(m_gl, shaderSource(m_shader, 1, &fragmentShader, DE_NULL));
 			break;
 
 		default:
 			DE_ASSERT(false);
 	}
 
-	GLU_CHECK_CALL(glCompileShader(m_shader));
+	GLU_CHECK_GLW_CALL(m_gl, compileShader(m_shader));
 
 	GLint status = 0;
-	GLU_CHECK_CALL(glGetShaderiv(m_shader, GL_COMPILE_STATUS, &status));
+	GLU_CHECK_GLW_CALL(m_gl, getShaderiv(m_shader, GL_COMPILE_STATUS, &status));
 
 	if (!status)
 	{
 		char buffer[256];
-		GLU_CHECK_CALL(glGetShaderInfoLog(m_shader, 256, NULL, buffer));
+		GLU_CHECK_GLW_CALL(m_gl, getShaderInfoLog(m_shader, 256, DE_NULL, buffer));
 
 		m_log << tcu::TestLog::Message << "Failed to compile shader" << tcu::TestLog::EndMessage;
 
@@ -909,7 +867,7 @@
 
 void GLES2ShaderSharingTest::destroyResource (void)
 {
-	GLU_CHECK_CALL(glDeleteShader(m_shader));
+	GLU_CHECK_GLW_CALL(m_gl, deleteShader(m_shader));
 }
 
 void GLES2ShaderSharingTest::renderResource (tcu::Surface* screen, tcu::Surface* reference)
@@ -942,30 +900,30 @@
 	switch (m_shaderType)
 	{
 		case GL_VERTEX_SHADER:
-			otherShader = glCreateShader(GL_FRAGMENT_SHADER);
-			GLU_CHECK_MSG("glCreateShader()");
-			GLU_CHECK_CALL(glShaderSource(otherShader, 1, &fragmentShader, NULL));
+			otherShader = m_gl.createShader(GL_FRAGMENT_SHADER);
+			GLU_CHECK_GLW_MSG(m_gl, "glCreateShader()");
+			GLU_CHECK_GLW_CALL(m_gl, shaderSource(otherShader, 1, &fragmentShader, DE_NULL));
 			break;
 
 		case GL_FRAGMENT_SHADER:
-			otherShader = glCreateShader(GL_VERTEX_SHADER);
-			GLU_CHECK_MSG("glCreateShader()");
-			GLU_CHECK_CALL(glShaderSource(otherShader, 1, &vertexShader, NULL));
+			otherShader = m_gl.createShader(GL_VERTEX_SHADER);
+			GLU_CHECK_GLW_MSG(m_gl, "glCreateShader()");
+			GLU_CHECK_GLW_CALL(m_gl, shaderSource(otherShader, 1, &vertexShader, DE_NULL));
 			break;
 
 		default:
 			DE_ASSERT(false);
 	}
 
-	GLU_CHECK_CALL(glCompileShader(otherShader));
+	GLU_CHECK_GLW_CALL(m_gl, compileShader(otherShader));
 
 	GLint status = 0;
-	GLU_CHECK_CALL(glGetShaderiv(otherShader, GL_COMPILE_STATUS, &status));
+	GLU_CHECK_GLW_CALL(m_gl, getShaderiv(otherShader, GL_COMPILE_STATUS, &status));
 
 	if (!status)
 	{
 		char buffer[256];
-		GLU_CHECK_CALL(glGetShaderInfoLog(otherShader, 256, NULL, buffer));
+		GLU_CHECK_GLW_CALL(m_gl, getShaderInfoLog(otherShader, 256, DE_NULL, buffer));
 
 		m_log << tcu::TestLog::Message << "Failed to compile shader" << tcu::TestLog::EndMessage;
 
@@ -987,22 +945,22 @@
 		TCU_FAIL("Failed to compile shader");
 	}
 
-	GLuint program = glCreateProgram();
-	GLU_CHECK_MSG("glCreateProgram()");
+	GLuint program = m_gl.createProgram();
+	GLU_CHECK_GLW_MSG(m_gl, "glCreateProgram()");
 
-	GLU_CHECK_CALL(glAttachShader(program, m_shader));
-	GLU_CHECK_CALL(glAttachShader(program, otherShader));
+	GLU_CHECK_GLW_CALL(m_gl, attachShader(program, m_shader));
+	GLU_CHECK_GLW_CALL(m_gl, attachShader(program, otherShader));
 
-	GLU_CHECK_CALL(glLinkProgram(program));
-	GLU_CHECK_CALL(glDeleteShader(otherShader));
+	GLU_CHECK_GLW_CALL(m_gl, linkProgram(program));
+	GLU_CHECK_GLW_CALL(m_gl, deleteShader(otherShader));
 
 	status = 0;
-	GLU_CHECK_CALL(glGetProgramiv(program, GL_LINK_STATUS, &status));
+	GLU_CHECK_GLW_CALL(m_gl, getProgramiv(program, GL_LINK_STATUS, &status));
 
 	if (!status)
 	{
 		char buffer[256];
-		GLU_CHECK_CALL(glGetProgramInfoLog(program, 256, NULL, buffer));
+		GLU_CHECK_GLW_CALL(m_gl, getProgramInfoLog(program, 256, DE_NULL, buffer));
 
 		m_log << tcu::TestLog::Message << "Failed to link program" << tcu::TestLog::EndMessage;
 
@@ -1037,35 +995,35 @@
 		2, 3, 0
 	};
 
-	GLU_CHECK_CALL(glViewport(0, 0, width, height));
+	GLU_CHECK_GLW_CALL(m_gl, viewport(0, 0, width, height));
 
-	GLU_CHECK_CALL(glClearColor(1.0f, 0.0f, 0.0f, 1.0f));
-	GLU_CHECK_CALL(glClear(GL_COLOR_BUFFER_BIT));
+	GLU_CHECK_GLW_CALL(m_gl, clearColor(1.0f, 0.0f, 0.0f, 1.0f));
+	GLU_CHECK_GLW_CALL(m_gl, clear(GL_COLOR_BUFFER_BIT));
 
-	GLU_CHECK_CALL(glUseProgram(program));
+	GLU_CHECK_GLW_CALL(m_gl, useProgram(program));
 
-	GLuint coordLocation = glGetAttribLocation(program, "a_pos");
-	GLU_CHECK_MSG("glGetAttribLocation()");
+	GLuint coordLocation = m_gl.getAttribLocation(program, "a_pos");
+	GLU_CHECK_GLW_MSG(m_gl, "glGetAttribLocation()");
 	TCU_CHECK(coordLocation != (GLuint)-1);
 
-	GLuint colorLocation = glGetAttribLocation(program, "a_color");
-	GLU_CHECK_MSG("glGetAttribLocation()");
+	GLuint colorLocation = m_gl.getAttribLocation(program, "a_color");
+	GLU_CHECK_GLW_MSG(m_gl, "glGetAttribLocation()");
 	TCU_CHECK(colorLocation != (GLuint)-1);
 
-	GLU_CHECK_CALL(glEnableVertexAttribArray(colorLocation));
-	GLU_CHECK_CALL(glEnableVertexAttribArray(coordLocation));
+	GLU_CHECK_GLW_CALL(m_gl, enableVertexAttribArray(colorLocation));
+	GLU_CHECK_GLW_CALL(m_gl, enableVertexAttribArray(coordLocation));
 
-	GLU_CHECK_CALL(glVertexAttribPointer(colorLocation, 4, GL_FLOAT, GL_FALSE, 0, colors));
-	GLU_CHECK_CALL(glVertexAttribPointer(coordLocation, 2, GL_FLOAT, GL_FALSE, 0, coords));
+	GLU_CHECK_GLW_CALL(m_gl, vertexAttribPointer(colorLocation, 4, GL_FLOAT, GL_FALSE, 0, colors));
+	GLU_CHECK_GLW_CALL(m_gl, vertexAttribPointer(coordLocation, 2, GL_FLOAT, GL_FALSE, 0, coords));
 
-	GLU_CHECK_CALL(glDrawElements(GL_TRIANGLES, 6, GL_UNSIGNED_SHORT, indices));
-	GLU_CHECK_CALL(glDisableVertexAttribArray(coordLocation));
-	GLU_CHECK_CALL(glDisableVertexAttribArray(colorLocation));
-	GLU_CHECK_CALL(glUseProgram(0));
+	GLU_CHECK_GLW_CALL(m_gl, drawElements(GL_TRIANGLES, 6, GL_UNSIGNED_SHORT, indices));
+	GLU_CHECK_GLW_CALL(m_gl, disableVertexAttribArray(coordLocation));
+	GLU_CHECK_GLW_CALL(m_gl, disableVertexAttribArray(colorLocation));
+	GLU_CHECK_GLW_CALL(m_gl, useProgram(0));
 
 	if (screen)
 	{
-		glReadPixels(0, 0, screen->getWidth(), screen->getHeight(), GL_RGBA, GL_UNSIGNED_BYTE, screen->getAccess().getDataPtr());
+		m_gl.readPixels(0, 0, screen->getWidth(), screen->getHeight(), GL_RGBA, GL_UNSIGNED_BYTE, screen->getAccess().getDataPtr());
 
 		tcu::clear(reference->getAccess(), tcu::IVec4(0xff, 0, 0, 0xff));
 
diff --git a/modules/egl/teglGLES2SharingThreadedTests.cpp b/modules/egl/teglGLES2SharingThreadedTests.cpp
index 9ec510f..56a59b7 100644
--- a/modules/egl/teglGLES2SharingThreadedTests.cpp
+++ b/modules/egl/teglGLES2SharingThreadedTests.cpp
@@ -24,6 +24,7 @@
 #include "teglGLES2SharingThreadedTests.hpp"
 
 #include "tcuTestLog.hpp"
+#include "tcuThreadUtil.hpp"
 
 #include "deRandom.hpp"
 #include "deThread.hpp"
@@ -39,20 +40,13 @@
 
 #include "gluDefs.hpp"
 
-#include "tcuThreadUtil.hpp"
+#include "glwEnums.hpp"
+#include "glwFunctions.hpp"
 
-#include <GLES2/gl2.h>
-#include <GLES2/gl2ext.h>
-#include <EGL/egl.h>
-#include <EGL/eglext.h>
+#include "egluUtil.hpp"
 
-#ifndef EGL_KHR_wait_sync
-#define EGL_KHR_wait_sync 1
-typedef EGLint (EGLAPIENTRYP PFNEGLWAITSYNCKHRPROC) (EGLDisplay dpy, EGLSyncKHR sync, EGLint flags);
-#ifdef EGL_EGLEXT_PROTOTYPES
-EGLAPI EGLint EGLAPIENTRY eglWaitSyncKHR (EGLDisplay dpy, EGLSyncKHR sync, EGLint flags);
-#endif
-#endif /* EGL_KHR_wait_sync */
+#include "eglwLibrary.hpp"
+#include "eglwEnums.hpp"
 
 #include <vector>
 #include <string>
@@ -63,6 +57,9 @@
 using std::string;
 using de::SharedPtr;
 
+using namespace glw;
+using namespace eglw;
+
 namespace deqp
 {
 namespace egl
@@ -157,7 +154,7 @@
 
 	struct
 	{
-		PFNGLEGLIMAGETARGETTEXTURE2DOESPROC	imageTargetTexture2D;
+		glEGLImageTargetTexture2DOESFunc	imageTargetTexture2D;
 	} glExtensions;
 private:
 					GLES2Context		(const GLES2Context&);
@@ -170,7 +167,7 @@
 	, display					(EGL_NO_DISPLAY)
 	, context					(EGL_NO_CONTEXT)
 {
-	glExtensions.imageTargetTexture2D = NULL;
+	glExtensions.imageTargetTexture2D = DE_NULL;
 }
 
 GLES2Context::~GLES2Context (void)
@@ -205,10 +202,13 @@
 class EGLThread : public tcu::ThreadUtil::Thread
 {
 public:
-								EGLThread	(int seed);
+								EGLThread	(const Library& egl_, const glw::Functions& gl_, int seed);
 								~EGLThread	(void);
 	virtual void				deinit		(void);
 
+	const Library&				egl;
+	const glw::Functions&		gl;
+
 	// Generation time attributes
 	SharedPtr<GLES2Context>		context;
 	SharedPtr<Surface>			surface;
@@ -217,41 +217,15 @@
 
 	SharedPtr<GLES2Context>		runtimeContext;
 	EGLSurface					eglSurface;
-
-	struct
-	{
-		PFNEGLCREATESYNCKHRPROC		createSync;
-		PFNEGLDESTROYSYNCKHRPROC	destroySync;
-		PFNEGLCLIENTWAITSYNCKHRPROC	clientWaitSync;
-
-		PFNEGLWAITSYNCKHRPROC		waitSync;
-
-		PFNEGLCREATEIMAGEKHRPROC	createImage;
-		PFNEGLDESTROYIMAGEKHRPROC	destroyImage;
-	} eglExtensions;
-
 private:
 };
 
-EGLThread::EGLThread (int seed)
+EGLThread::EGLThread (const Library& egl_, const glw::Functions& gl_, int seed)
 	: tcu::ThreadUtil::Thread	(seed)
+	, egl						(egl_)
+	, gl						(gl_)
 	, eglSurface				(EGL_NO_SURFACE)
 {
-	eglExtensions.createSync		= NULL;
-	eglExtensions.destroySync		= NULL;
-	eglExtensions.clientWaitSync	= NULL;
-
-	eglExtensions.createImage		= NULL;
-	eglExtensions.destroyImage		= NULL;
-
-	eglExtensions.createSync		= (PFNEGLCREATESYNCKHRPROC)eglGetProcAddress("eglCreateSyncKHR");
-	eglExtensions.destroySync		= (PFNEGLDESTROYSYNCKHRPROC)eglGetProcAddress("eglDestroySyncKHR");
-	eglExtensions.clientWaitSync	= (PFNEGLCLIENTWAITSYNCKHRPROC)eglGetProcAddress("eglClientWaitSyncKHR");
-
-	eglExtensions.waitSync			= (PFNEGLWAITSYNCKHRPROC)eglGetProcAddress("eglWaitSyncKHR");
-
-	eglExtensions.createImage		= (PFNEGLCREATEIMAGEKHRPROC)eglGetProcAddress("eglCreateImageKHR");
-	eglExtensions.destroyImage		= (PFNEGLDESTROYIMAGEKHRPROC)eglGetProcAddress("eglDestroyImageKHR");
 }
 
 void EGLThread::deinit (void)
@@ -259,16 +233,16 @@
 	if (runtimeContext)
 	{
 		if (runtimeContext->context != EGL_NO_CONTEXT)
-			eglMakeCurrent(runtimeContext->display, EGL_NO_SURFACE, EGL_NO_SURFACE, EGL_NO_CONTEXT);
+			egl.makeCurrent(runtimeContext->display, EGL_NO_SURFACE, EGL_NO_SURFACE, EGL_NO_CONTEXT);
 
-		eglDestroyContext(runtimeContext->display, runtimeContext->context);
-		eglDestroySurface(runtimeContext->display, eglSurface);
+		egl.destroyContext(runtimeContext->display, runtimeContext->context);
+		egl.destroySurface(runtimeContext->display, eglSurface);
 
 		runtimeContext->context	= EGL_NO_CONTEXT;
 		eglSurface	= EGL_NO_SURFACE;
 	}
 
-	eglReleaseThread();
+	egl.releaseThread();
 }
 
 EGLThread::~EGLThread (void)
@@ -322,8 +296,8 @@
 	m_lock.lock();
 	if (m_waiterCount > 0)
 	{
-		thread.newMessage() << "Begin -- eglCreateSyncKHR(" << ((size_t)m_display) << ", EGL_SYNC_FENCE_KHR, NULL)" << tcu::ThreadUtil::Message::End;
-		m_sync = thread.eglExtensions.createSync(m_display, EGL_SYNC_FENCE_KHR, NULL);
+		thread.newMessage() << "Begin -- eglCreateSyncKHR(" << ((size_t)m_display) << ", EGL_SYNC_FENCE_KHR, DE_NULL)" << tcu::ThreadUtil::Message::End;
+		m_sync = thread.egl.createSyncKHR(m_display, EGL_SYNC_FENCE_KHR, DE_NULL);
 		thread.newMessage() << "End -- " << ((size_t)m_sync) << " = eglCreateSyncKHR()" << tcu::ThreadUtil::Message::End;
 		TCU_CHECK(m_sync);
 	}
@@ -336,14 +310,14 @@
 	if (m_serverSync)
 	{
 		thread.newMessage() << "Begin -- eglWaitSyncKHR(" << ((size_t)m_display) << ", " << ((size_t)m_sync) << ", 0)" << tcu::ThreadUtil::Message::End;
-		EGLint result = thread.eglExtensions.waitSync(m_display, m_sync, 0);
+		EGLint result = thread.egl.waitSyncKHR(m_display, m_sync, 0);
 		thread.newMessage() << "End -- " << result << " = eglWaitSyncKHR()" << tcu::ThreadUtil::Message::End;
 		ok = result == EGL_TRUE;
 	}
 	else
 	{
 		thread.newMessage() << "Begin -- eglClientWaitSyncKHR(" << ((size_t)m_display) << ", " << ((size_t)m_sync) << ", EGL_SYNC_FLUSH_COMMANDS_BIT_KHR, 1000 000 000)" << tcu::ThreadUtil::Message::End;
-		EGLint result = thread.eglExtensions.clientWaitSync(m_display, m_sync, EGL_SYNC_FLUSH_COMMANDS_BIT_KHR, 1000000000);
+		EGLint result = thread.egl.clientWaitSyncKHR(m_display, m_sync, EGL_SYNC_FLUSH_COMMANDS_BIT_KHR, 1000000000);
 		thread.newMessage() << "End -- " << result << " = eglClientWaitSyncKHR()" << tcu::ThreadUtil::Message::End;
 		ok = result == EGL_CONDITION_SATISFIED_KHR;
 	}
@@ -356,9 +330,9 @@
 	{
 		// \note [mika] This is no longer deterministic and eglDestroySyncKHR might happen in different places and in different threads
 		thread.newMessage() << "Begin -- eglDestroySyncKHR(" << ((size_t)m_display) << ", " << ((size_t)m_sync) << ")" << tcu::ThreadUtil::Message::End;
-		EGLint destroyResult = thread.eglExtensions.destroySync(m_display, m_sync);
+		EGLint destroyResult = thread.egl.destroySyncKHR(m_display, m_sync);
 		thread.newMessage() << "End -- " << destroyResult << " = eglDestroySyncKHR()" << tcu::ThreadUtil::Message::End;
-		m_sync = NULL;
+		m_sync = DE_NULL;
 	}
 
 	m_lock.unlock();
@@ -468,8 +442,10 @@
 	object->modifyGL(m_sync, m_syncDeps);
 }
 
-void Operation::execute (tcu::ThreadUtil::Thread& thread)
+void Operation::execute (tcu::ThreadUtil::Thread& t)
 {
+	EGLThread& thread = dynamic_cast<EGLThread&>(t);
+
 	bool success = true;
 
 	// Wait for dependencies and check that they succeeded
@@ -507,13 +483,13 @@
 					DE_ASSERT(eglThread);
 					m_sync->init(*eglThread, m_serverSync);
 					thread.newMessage() << "Begin -- glFlush()" << tcu::ThreadUtil::Message::End;
-					GLU_CHECK_CALL(glFlush());
+					GLU_CHECK_GLW_CALL(thread.gl, flush());
 					thread.newMessage() << "End -- glFlush()" << tcu::ThreadUtil::Message::End;
 				}
 				else
 				{
 					thread.newMessage() << "Begin -- glFinish()" << tcu::ThreadUtil::Message::End;
-					GLU_CHECK_CALL(glFinish());
+					GLU_CHECK_GLW_CALL(thread.gl, finish());
 					thread.newMessage() << "End -- glFinish()" << tcu::ThreadUtil::Message::End;
 				}
 			}
@@ -617,19 +593,19 @@
 	m_context = context;
 }
 
-void CreateContext::exec (tcu::ThreadUtil::Thread& thread)
+void CreateContext::exec (tcu::ThreadUtil::Thread& t)
 {
-	DE_UNREF(thread);
+	EGLThread& thread = dynamic_cast<EGLThread&>(t);
 	m_context->display = m_display;
 
-	EGLint attriblist[] =
+	const EGLint attriblist[] =
 	{
 		EGL_CONTEXT_CLIENT_VERSION, 2,
 		EGL_NONE
 	};
 
 	thread.newMessage() << "Begin -- eglBindAPI(EGL_OPENGL_ES_API)" << tcu::ThreadUtil::Message::End;
-	TCU_CHECK_EGL_CALL(eglBindAPI(EGL_OPENGL_ES_API));
+	EGLU_CHECK_CALL(thread.egl, bindAPI(EGL_OPENGL_ES_API));
 	thread.newMessage() << "End -- eglBindAPI()" << tcu::ThreadUtil::Message::End;
 
 	if (m_shared)
@@ -639,17 +615,17 @@
 		DE_ASSERT(m_shared->display == m_display);
 
 		thread.newMessage() << "Begin -- eglCreateContext(" << m_display << ", " << m_config << ", " << m_shared->context << ", { EGL_CONTEXT_CLIENT_VERSION, 2, EGL_NONE })" << tcu::ThreadUtil::Message::End;
-		m_context->context = eglCreateContext(m_display, m_config, m_shared->context, attriblist);
+		m_context->context = thread.egl.createContext(m_display, m_config, m_shared->context, attriblist);
 		thread.newMessage() << "End -- " << m_context->context << " = eglCreateContext()" << tcu::ThreadUtil::Message::End;
 	}
 	else
 	{
 		thread.newMessage() << "Begin -- eglCreateContext(" << m_display << ", " << m_config << ", EGL_NO_CONTEXT, { EGL_CONTEXT_CLIENT_VERSION, 2, EGL_NONE })" << tcu::ThreadUtil::Message::End;
-		m_context->context = eglCreateContext(m_display, m_config, EGL_NO_CONTEXT, attriblist);
+		m_context->context = thread.egl.createContext(m_display, m_config, EGL_NO_CONTEXT, attriblist);
 		thread.newMessage() << "End -- " << m_context->context << " = eglCreateContext()" << tcu::ThreadUtil::Message::End;
 	}
 
-	TCU_CHECK_EGL_MSG("Failed to create GLES2 context");
+	EGLU_CHECK_MSG(thread.egl, "Failed to create GLES2 context");
 	TCU_CHECK(m_context->context != EGL_NO_CONTEXT);
 }
 
@@ -670,11 +646,12 @@
 	modifyObject(SharedPtr<tcu::ThreadUtil::Object>(m_context));
 }
 
-void DestroyContext::exec (tcu::ThreadUtil::Thread& thread)
+void DestroyContext::exec (tcu::ThreadUtil::Thread& t)
 {
-	DE_UNREF(thread);
+	EGLThread& thread = dynamic_cast<EGLThread&>(t);
+
 	thread.newMessage() << "Begin -- eglDestroyContext(" << m_context->display << ", " << m_context->context << ")" << tcu::ThreadUtil::Message::End;
-	TCU_CHECK_EGL_CALL(eglDestroyContext(m_context->display, m_context->context));
+	EGLU_CHECK_CALL(thread.egl, destroyContext(m_context->display, m_context->context));
 	thread.newMessage() << "End -- eglDestroyContext()" << tcu::ThreadUtil::Message::End;
 	m_context->display	= EGL_NO_DISPLAY;
 	m_context->context	= EGL_NO_CONTEXT;
@@ -723,8 +700,7 @@
 
 void MakeCurrent::exec (tcu::ThreadUtil::Thread& t)
 {
-	EGLThread& thread = *(dynamic_cast<EGLThread*>(&t));
-	DE_ASSERT(&thread);
+	EGLThread& thread = dynamic_cast<EGLThread&>(t);
 
 	if (m_context)
 	{
@@ -733,7 +709,7 @@
 
 		DE_ASSERT(m_surface);
 		thread.newMessage() << "Begin -- eglMakeCurrent(" << m_display << ", " << m_surface->surface << ", " << m_surface->surface << ", " << m_context->context << ")" << tcu::ThreadUtil::Message::End;
-		TCU_CHECK_EGL_CALL(eglMakeCurrent(m_display, m_surface->surface, m_surface->surface, m_context->context));
+		EGLU_CHECK_CALL(thread.egl, makeCurrent(m_display, m_surface->surface, m_surface->surface, m_context->context));
 		thread.newMessage() << "End -- eglMakeCurrent()" << tcu::ThreadUtil::Message::End;
 	}
 	else
@@ -741,7 +717,7 @@
 		thread.runtimeContext = m_context;
 
 		thread.newMessage() << "Begin -- eglMakeCurrent(" << m_display << ", EGL_NO_SURFACE, EGL_NO_SURFACE, EGL_NO_CONTEXT)" << tcu::ThreadUtil::Message::End;
-		TCU_CHECK_EGL_CALL(eglMakeCurrent(m_display, EGL_NO_SURFACE, EGL_NO_SURFACE, EGL_NO_CONTEXT));
+		EGLU_CHECK_CALL(thread.egl, makeCurrent(m_display, EGL_NO_SURFACE, EGL_NO_SURFACE, EGL_NO_CONTEXT));
 		thread.newMessage() << "End -- eglMakeCurrent()" << tcu::ThreadUtil::Message::End;
 	}
 }
@@ -765,13 +741,13 @@
 
 void InitGLExtension::exec (tcu::ThreadUtil::Thread& t)
 {
-	EGLThread& thread = *(dynamic_cast<EGLThread*>(&t));
+	EGLThread& thread = dynamic_cast<EGLThread&>(t);
 
 	// Check extensions
 	bool found = false;
 
 	thread.newMessage() << "Begin -- glGetString(GL_EXTENSIONS)" << tcu::ThreadUtil::Message::End;
-	std::string extensions = (const char*)glGetString(GL_EXTENSIONS);
+	std::string extensions = (const char*)thread.gl.getString(GL_EXTENSIONS);
 	thread.newMessage() << "End -- glGetString()" << tcu::ThreadUtil::Message::End;
 
 	std::string::size_type pos = extensions.find(" ");
@@ -806,7 +782,7 @@
 	if (m_extension == "GL_OES_EGL_image")
 	{
 		thread.newMessage() << "Begin -- eglGetProcAddress(\"glEGLImageTargetTexture2DOES\")" << tcu::ThreadUtil::Message::End;
-		thread.runtimeContext->glExtensions.imageTargetTexture2D = (PFNGLEGLIMAGETARGETTEXTURE2DOESPROC)eglGetProcAddress("glEGLImageTargetTexture2DOES");
+		thread.runtimeContext->glExtensions.imageTargetTexture2D = (glEGLImageTargetTexture2DOESFunc)thread.egl.getProcAddress("glEGLImageTargetTexture2DOES");
 		thread.newMessage() << "End --  " << ((void*)thread.runtimeContext->glExtensions.imageTargetTexture2D) << " = eglGetProcAddress()"<< tcu::ThreadUtil::Message::End;
 	}
 }
@@ -836,18 +812,20 @@
 	m_surface = surface;
 }
 
-void CreatePBufferSurface::exec (tcu::ThreadUtil::Thread& thread)
+void CreatePBufferSurface::exec (tcu::ThreadUtil::Thread& t)
 {
-	EGLint attriblist[] = {
+	EGLThread& thread = dynamic_cast<EGLThread&>(t);
+
+	const EGLint attriblist[] = {
 		EGL_WIDTH, m_width,
 		EGL_HEIGHT, m_height,
 		EGL_NONE
 	};
 
 	thread.newMessage() << "Begin -- eglCreatePbufferSurface(" << m_display << ", " << m_config << ", { EGL_WIDTH, " << m_width << ", EGL_HEIGHT, " << m_height << ", EGL_NONE })" << tcu::ThreadUtil::Message::End;
-	m_surface->surface = eglCreatePbufferSurface(m_display, m_config, attriblist);
+	m_surface->surface = thread.egl.createPbufferSurface(m_display, m_config, attriblist);
 	thread.newMessage() << "End -- " << m_surface->surface << "= eglCreatePbufferSurface()" << tcu::ThreadUtil::Message::End;
-	TCU_CHECK_EGL_MSG("eglCreatePbufferSurface()");
+	EGLU_CHECK_MSG(thread.egl, "eglCreatePbufferSurface()");
 }
 
 class DestroySurface : public tcu::ThreadUtil::Operation
@@ -869,10 +847,12 @@
 	modifyObject(SharedPtr<tcu::ThreadUtil::Object>(m_surface));
 }
 
-void DestroySurface::exec (tcu::ThreadUtil::Thread& thread)
+void DestroySurface::exec (tcu::ThreadUtil::Thread& t)
 {
+	EGLThread& thread = dynamic_cast<EGLThread&>(t);
+
 	thread.newMessage() << "Begin -- eglDestroySurface(" << m_display << ",  " << m_surface->surface << ")" << tcu::ThreadUtil::Message::End;
-	TCU_CHECK_EGL_CALL(eglDestroySurface(m_display, m_surface->surface));
+	EGLU_CHECK_CALL(thread.egl, destroySurface(m_display, m_surface->surface));
 	thread.newMessage() << "End -- eglDestroySurface()" << tcu::ThreadUtil::Message::End;
 }
 
@@ -920,12 +900,13 @@
 	m_texture = texture;
 }
 
-void CreateTexture::exec (tcu::ThreadUtil::Thread& thread)
+void CreateTexture::exec (tcu::ThreadUtil::Thread& t)
 {
+	EGLThread& thread = dynamic_cast<EGLThread&>(t);
 	GLuint tex = 0;
 
 	thread.newMessage() << "Begin -- glGenTextures(1, { 0 })" << tcu::ThreadUtil::Message::End;
-	GLU_CHECK_CALL(glGenTextures(1, &tex));
+	GLU_CHECK_GLW_CALL(thread.gl, genTextures(1, &tex));
 	thread.newMessage() << "End -- glGenTextures(1, { " << tex << " })" << tcu::ThreadUtil::Message::End;
 
 	m_texture->texture = tex;
@@ -948,12 +929,13 @@
 	modifyGLObject(SharedPtr<Object>(m_texture));
 }
 
-void DeleteTexture::exec (tcu::ThreadUtil::Thread& thread)
+void DeleteTexture::exec (tcu::ThreadUtil::Thread& t)
 {
+	EGLThread& thread = dynamic_cast<EGLThread&>(t);
 	GLuint tex = m_texture->texture;
 
 	thread.newMessage() << "Begin -- glDeleteTextures(1, { " << tex << " })" << tcu::ThreadUtil::Message::End;
-	GLU_CHECK_CALL(glDeleteTextures(1, &tex));
+	GLU_CHECK_GLW_CALL(thread.gl, deleteTextures(1, &tex));
 	thread.newMessage() << "End -- glDeleteTextures()" << tcu::ThreadUtil::Message::End;
 
 	m_texture->texture = 0;
@@ -992,20 +974,21 @@
 	texture->sourceImage = SharedPtr<EGLImage>();
 }
 
-void TexImage2D::exec (tcu::ThreadUtil::Thread& thread)
+void TexImage2D::exec (tcu::ThreadUtil::Thread& t)
 {
+	EGLThread& thread = dynamic_cast<EGLThread&>(t);
 	void* dummyData = thread.getDummyData(m_width*m_height*4);
 
 	thread.newMessage() << "Begin -- glBindTexture(GL_TEXTURE_2D, " << m_texture->texture << ")" << tcu::ThreadUtil::Message::End;
-	GLU_CHECK_CALL(glBindTexture(GL_TEXTURE_2D, m_texture->texture));
+	GLU_CHECK_GLW_CALL(thread.gl, bindTexture(GL_TEXTURE_2D, m_texture->texture));
 	thread.newMessage() << "End -- glBindTexture()" << tcu::ThreadUtil::Message::End;
 
 	thread.newMessage() << "Begin -- glTexImage2D(GL_TEXTURE_2D, " << m_level << ", " << m_internalFormat << ", " << m_width << ", " << m_height << ", 0, " << m_format << ", " << m_type << ", data)" << tcu::ThreadUtil::Message::End;
-	GLU_CHECK_CALL(glTexImage2D(GL_TEXTURE_2D, m_level, m_internalFormat, m_width, m_height, 0, m_format, m_type, dummyData));
+	GLU_CHECK_GLW_CALL(thread.gl, texImage2D(GL_TEXTURE_2D, m_level, m_internalFormat, m_width, m_height, 0, m_format, m_type, dummyData));
 	thread.newMessage() << "End -- glTexImage2D()" << tcu::ThreadUtil::Message::End;
 
 	thread.newMessage() << "Begin -- glBindTexture(GL_TEXTURE_2D, 0)" << tcu::ThreadUtil::Message::End;
-	GLU_CHECK_CALL(glBindTexture(GL_TEXTURE_2D, 0));
+	GLU_CHECK_GLW_CALL(thread.gl, bindTexture(GL_TEXTURE_2D, 0));
 	thread.newMessage() << "End -- glBindTexture()" << tcu::ThreadUtil::Message::End;
 }
 
@@ -1043,20 +1026,21 @@
 		modifyGLObject(SharedPtr<Object>(m_texture->sourceImage));
 }
 
-void TexSubImage2D::exec (tcu::ThreadUtil::Thread& thread)
+void TexSubImage2D::exec (tcu::ThreadUtil::Thread& t)
 {
+	EGLThread& thread = dynamic_cast<EGLThread&>(t);
 	void* dummyData = thread.getDummyData(m_width*m_height*4);
 
 	thread.newMessage() << "Begin -- glBindTexture(GL_TEXTURE_2D, " << m_texture->texture << ")" << tcu::ThreadUtil::Message::End;
-	GLU_CHECK_CALL(glBindTexture(GL_TEXTURE_2D, m_texture->texture));
+	GLU_CHECK_GLW_CALL(thread.gl, bindTexture(GL_TEXTURE_2D, m_texture->texture));
 	thread.newMessage() << "End -- glBindTexture()" << tcu::ThreadUtil::Message::End;
 
 	thread.newMessage() << "Begin -- glTexSubImage2D(GL_TEXTURE_2D, " << m_level << ", " << m_xoffset << ", " << m_yoffset << ", " << m_width << ", " << m_height << ", 0, " << m_format << ", " << m_type << ", <data>)" << tcu::ThreadUtil::Message::End;
-	GLU_CHECK_CALL(glTexSubImage2D(GL_TEXTURE_2D, m_level, m_xoffset, m_yoffset, m_width, m_height, m_format, m_type, dummyData));
+	GLU_CHECK_GLW_CALL(thread.gl, texSubImage2D(GL_TEXTURE_2D, m_level, m_xoffset, m_yoffset, m_width, m_height, m_format, m_type, dummyData));
 	thread.newMessage() << "End -- glSubTexImage2D()" << tcu::ThreadUtil::Message::End;
 
 	thread.newMessage() << "Begin -- glBindTexture(GL_TEXTURE_2D, 0)" << tcu::ThreadUtil::Message::End;
-	GLU_CHECK_CALL(glBindTexture(GL_TEXTURE_2D, 0));
+	GLU_CHECK_GLW_CALL(thread.gl, bindTexture(GL_TEXTURE_2D, 0));
 	thread.newMessage() << "End -- glBindTexture()" << tcu::ThreadUtil::Message::End;
 }
 
@@ -1095,18 +1079,20 @@
 	texture->sourceImage = SharedPtr<EGLImage>();
 }
 
-void CopyTexImage2D::exec (tcu::ThreadUtil::Thread& thread)
+void CopyTexImage2D::exec (tcu::ThreadUtil::Thread& t)
 {
+	EGLThread& thread = dynamic_cast<EGLThread&>(t);
+
 	thread.newMessage() << "Begin -- glBindTexture(GL_TEXTURE_2D, " << m_texture->texture << ")" << tcu::ThreadUtil::Message::End;
-	GLU_CHECK_CALL(glBindTexture(GL_TEXTURE_2D, m_texture->texture));
+	GLU_CHECK_GLW_CALL(thread.gl, bindTexture(GL_TEXTURE_2D, m_texture->texture));
 	thread.newMessage() << "End -- glBindTexture()" << tcu::ThreadUtil::Message::End;
 
 	thread.newMessage() << "Begin -- glCopyTexImage2D(GL_TEXTURE_2D, " << m_level << ", " << m_internalFormat << ", " << m_x << ", " << m_y << ", " << m_width << ", " << m_height << ", " << m_border << ")" << tcu::ThreadUtil::Message::End;
-	GLU_CHECK_CALL(glCopyTexImage2D(GL_TEXTURE_2D, m_level, m_internalFormat, m_x, m_y, m_width, m_height, m_border));
+	GLU_CHECK_GLW_CALL(thread.gl, copyTexImage2D(GL_TEXTURE_2D, m_level, m_internalFormat, m_x, m_y, m_width, m_height, m_border));
 	thread.newMessage() << "End -- glCopyTexImage2D()" << tcu::ThreadUtil::Message::End;
 
 	thread.newMessage() << "Begin -- glBindTexture(GL_TEXTURE_2D, 0)" << tcu::ThreadUtil::Message::End;
-	GLU_CHECK_CALL(glBindTexture(GL_TEXTURE_2D, 0));
+	GLU_CHECK_GLW_CALL(thread.gl, bindTexture(GL_TEXTURE_2D, 0));
 	thread.newMessage() << "End -- glBindTexture()" << tcu::ThreadUtil::Message::End;
 }
 
@@ -1144,18 +1130,20 @@
 		modifyGLObject(SharedPtr<Object>(m_texture->sourceImage));
 }
 
-void CopyTexSubImage2D::exec (tcu::ThreadUtil::Thread& thread)
+void CopyTexSubImage2D::exec (tcu::ThreadUtil::Thread& t)
 {
+	EGLThread& thread = dynamic_cast<EGLThread&>(t);
+
 	thread.newMessage() << "Begin -- glBindTexture(GL_TEXTURE_2D, " << m_texture->texture << ")" << tcu::ThreadUtil::Message::End;
-	GLU_CHECK_CALL(glBindTexture(GL_TEXTURE_2D, m_texture->texture));
+	GLU_CHECK_GLW_CALL(thread.gl, bindTexture(GL_TEXTURE_2D, m_texture->texture));
 	thread.newMessage() << "End -- glBindTexture()" << tcu::ThreadUtil::Message::End;
 
 	thread.newMessage() << "Begin -- glCopyTexSubImage2D(GL_TEXTURE_2D, " << m_level << ", " << m_xoffset << ", " << m_yoffset << ", " << m_x << ", " << m_y << ", " << m_width << ", " << m_height << ")" << tcu::ThreadUtil::Message::End;
-	GLU_CHECK_CALL(glCopyTexSubImage2D(GL_TEXTURE_2D, m_level, m_xoffset, m_yoffset, m_x, m_y, m_width, m_height));
+	GLU_CHECK_GLW_CALL(thread.gl, copyTexSubImage2D(GL_TEXTURE_2D, m_level, m_xoffset, m_yoffset, m_x, m_y, m_width, m_height));
 	thread.newMessage() << "End -- glCopyTexSubImage2D()" << tcu::ThreadUtil::Message::End;
 
 	thread.newMessage() << "Begin -- glBindTexture(GL_TEXTURE_2D, 0)" << tcu::ThreadUtil::Message::End;
-	GLU_CHECK_CALL(glBindTexture(GL_TEXTURE_2D, 0));
+	GLU_CHECK_GLW_CALL(thread.gl, bindTexture(GL_TEXTURE_2D, 0));
 	thread.newMessage() << "End -- glBindTexture()" << tcu::ThreadUtil::Message::End;
 }
 
@@ -1197,12 +1185,13 @@
 	m_buffer = buffer;
 }
 
-void CreateBuffer::exec (tcu::ThreadUtil::Thread& thread)
+void CreateBuffer::exec (tcu::ThreadUtil::Thread& t)
 {
+	EGLThread& thread = dynamic_cast<EGLThread&>(t);
 	GLuint buffer = 0;
 
 	thread.newMessage() << "Begin -- glGenBuffers(1, { 0 })" << tcu::ThreadUtil::Message::End;
-	GLU_CHECK_CALL(glGenBuffers(1, &buffer));
+	GLU_CHECK_GLW_CALL(thread.gl, genBuffers(1, &buffer));
 	thread.newMessage() << "End -- glGenBuffers(1, { " << buffer << " })" << tcu::ThreadUtil::Message::End;
 
 	m_buffer->buffer = buffer;
@@ -1225,12 +1214,13 @@
 	modifyGLObject(SharedPtr<Object>(m_buffer));
 }
 
-void DeleteBuffer::exec (tcu::ThreadUtil::Thread& thread)
+void DeleteBuffer::exec (tcu::ThreadUtil::Thread& t)
 {
+	EGLThread& thread = dynamic_cast<EGLThread&>(t);
 	GLuint buffer = m_buffer->buffer;
 
 	thread.newMessage() << "Begin -- glDeleteBuffers(1, { " << buffer << " })" << tcu::ThreadUtil::Message::End;
-	GLU_CHECK_CALL(glDeleteBuffers(1, &buffer));
+	GLU_CHECK_GLW_CALL(thread.gl, deleteBuffers(1, &buffer));
 	thread.newMessage() << "End -- glDeleteBuffers()" << tcu::ThreadUtil::Message::End;
 
 	m_buffer->buffer = 0;
@@ -1261,20 +1251,21 @@
 	buffer->size		= size;
 }
 
-void BufferData::exec (tcu::ThreadUtil::Thread& thread)
+void BufferData::exec (tcu::ThreadUtil::Thread& t)
 {
+	EGLThread& thread = dynamic_cast<EGLThread&>(t);
 	void* dummyData = thread.getDummyData(m_size);
 
 	thread.newMessage() << "Begin -- glBindBuffer(" << m_target << ", " << m_buffer->buffer << ")" << tcu::ThreadUtil::Message::End;
-	GLU_CHECK_CALL(glBindBuffer(m_target, m_buffer->buffer));
+	GLU_CHECK_GLW_CALL(thread.gl, bindBuffer(m_target, m_buffer->buffer));
 	thread.newMessage() << "End -- glBindBuffer()" << tcu::ThreadUtil::Message::End;
 
 	thread.newMessage() << "Begin -- glBufferData(" << m_target << ", " << m_size << ", <DATA>, " << m_usage << ")" << tcu::ThreadUtil::Message::End;
-	GLU_CHECK_CALL(glBufferData(m_target, m_size, dummyData, m_usage));
+	GLU_CHECK_GLW_CALL(thread.gl, bufferData(m_target, m_size, dummyData, m_usage));
 	thread.newMessage() << "End -- glBufferData()" << tcu::ThreadUtil::Message::End;
 
 	thread.newMessage() << "Begin -- glBindBuffer(" << m_target << ", 0)" << tcu::ThreadUtil::Message::End;
-	GLU_CHECK_CALL(glBindBuffer(m_target, 0));
+	GLU_CHECK_GLW_CALL(thread.gl, bindBuffer(m_target, 0));
 	thread.newMessage() << "End -- glBindBuffer()" << tcu::ThreadUtil::Message::End;
 }
 
@@ -1301,20 +1292,21 @@
 	modifyGLObject(SharedPtr<Object>(m_buffer));
 }
 
-void BufferSubData::exec (tcu::ThreadUtil::Thread& thread)
+void BufferSubData::exec (tcu::ThreadUtil::Thread& t)
 {
+	EGLThread& thread = dynamic_cast<EGLThread&>(t);
 	void* dummyData = thread.getDummyData(m_size);
 
 	thread.newMessage() << "Begin -- glBindBuffer(" << m_target << ", " << m_buffer->buffer << ")" << tcu::ThreadUtil::Message::End;
-	GLU_CHECK_CALL(glBindBuffer(m_target, m_buffer->buffer));
+	GLU_CHECK_GLW_CALL(thread.gl, bindBuffer(m_target, m_buffer->buffer));
 	thread.newMessage() << "End -- glBindBuffer()" << tcu::ThreadUtil::Message::End;
 
 	thread.newMessage() << "Begin -- glBufferSubData(" << m_target << ", " << m_offset << ", " << m_size << ", <DATA>)" << tcu::ThreadUtil::Message::End;
-	GLU_CHECK_CALL(glBufferSubData(m_target, m_offset, m_size, dummyData));
+	GLU_CHECK_GLW_CALL(thread.gl, bufferSubData(m_target, m_offset, m_size, dummyData));
 	thread.newMessage() << "End -- glBufferSubData()" << tcu::ThreadUtil::Message::End;
 
 	thread.newMessage() << "Begin -- glBindBuffer(" << m_target << ", 0)" << tcu::ThreadUtil::Message::End;
-	GLU_CHECK_CALL(glBindBuffer(m_target, 0));
+	GLU_CHECK_GLW_CALL(thread.gl, bindBuffer(m_target, 0));
 	thread.newMessage() << "End -- glBindBuffer()" << tcu::ThreadUtil::Message::End;
 }
 
@@ -1359,13 +1351,14 @@
 	m_shader = shader;
 }
 
-void CreateShader::exec (tcu::ThreadUtil::Thread& thread)
+void CreateShader::exec (tcu::ThreadUtil::Thread& t)
 {
+	EGLThread& thread = dynamic_cast<EGLThread&>(t);
 	GLuint shader = 0;
 
 	thread.newMessage() << "Begin -- glCreateShader(" << m_type << ")" << tcu::ThreadUtil::Message::End;
-	shader = glCreateShader(m_type);
-	GLU_CHECK_MSG("glCreateShader()");
+	shader = thread.gl.createShader(m_type);
+	GLU_CHECK_GLW_MSG(thread.gl, "glCreateShader()");
 	thread.newMessage() << "End -- " << shader  << " = glCreateShader(" << m_type << ")" << tcu::ThreadUtil::Message::End;
 
 	m_shader->shader	= shader;
@@ -1388,12 +1381,13 @@
 	modifyGLObject(SharedPtr<Object>(m_shader));
 }
 
-void DeleteShader::exec (tcu::ThreadUtil::Thread& thread)
+void DeleteShader::exec (tcu::ThreadUtil::Thread& t)
 {
+	EGLThread& thread = dynamic_cast<EGLThread&>(t);
 	GLuint shader = m_shader->shader;
 
 	thread.newMessage() << "Begin -- glDeleteShader(" << shader << ")" << tcu::ThreadUtil::Message::End;
-	GLU_CHECK_CALL(glDeleteShader(shader));
+	GLU_CHECK_GLW_CALL(thread.gl, deleteShader(shader));
 	thread.newMessage() << "End -- glDeleteShader()" << tcu::ThreadUtil::Message::End;
 
 	m_shader->shader = 0;
@@ -1419,12 +1413,13 @@
 	m_shader->isDefined = true;
 }
 
-void ShaderSource::exec (tcu::ThreadUtil::Thread& thread)
+void ShaderSource::exec (tcu::ThreadUtil::Thread& t)
 {
+	EGLThread& thread = dynamic_cast<EGLThread&>(t);
 	const char* shaderSource = m_source.c_str();
 
-	thread.newMessage() << "Begin -- glShaderSource(" << m_shader->shader << ", 1, \"" << shaderSource << "\", NULL)" << tcu::ThreadUtil::Message::End;
-	GLU_CHECK_CALL(glShaderSource(m_shader->shader, 1, &shaderSource, NULL));
+	thread.newMessage() << "Begin -- glShaderSource(" << m_shader->shader << ", 1, \"" << shaderSource << "\", DE_NULL)" << tcu::ThreadUtil::Message::End;
+	GLU_CHECK_GLW_CALL(thread.gl, shaderSource(m_shader->shader, 1, &shaderSource, DE_NULL));
 	thread.newMessage() << "End -- glShaderSource()" << tcu::ThreadUtil::Message::End;
 }
 
@@ -1446,10 +1441,12 @@
 	modifyGLObject(SharedPtr<Object>(m_shader));
 }
 
-void ShaderCompile::exec (tcu::ThreadUtil::Thread& thread)
+void ShaderCompile::exec (tcu::ThreadUtil::Thread& t)
 {
+	EGLThread& thread = dynamic_cast<EGLThread&>(t);
+
 	thread.newMessage() << "Begin -- glCompileShader(" << m_shader->shader << ")" << tcu::ThreadUtil::Message::End;
-	GLU_CHECK_CALL(glCompileShader(m_shader->shader));
+	GLU_CHECK_GLW_CALL(thread.gl, compileShader(m_shader->shader));
 	thread.newMessage() << "End -- glCompileShader()" << tcu::ThreadUtil::Message::End;
 }
 
@@ -1495,13 +1492,14 @@
 	m_program = program;
 }
 
-void CreateProgram::exec (tcu::ThreadUtil::Thread& thread)
+void CreateProgram::exec (tcu::ThreadUtil::Thread& t)
 {
+	EGLThread& thread = dynamic_cast<EGLThread&>(t);
 	GLuint program = 0;
 
 	thread.newMessage() << "Begin -- glCreateProgram()" << tcu::ThreadUtil::Message::End;
-	program = glCreateProgram();
-	GLU_CHECK_MSG("glCreateProgram()");
+	program = thread.gl.createProgram();
+	GLU_CHECK_GLW_MSG(thread.gl, "glCreateProgram()");
 	thread.newMessage() << "End -- " << program  << " = glCreateProgram()" << tcu::ThreadUtil::Message::End;
 
 	m_program->program	= program;
@@ -1524,12 +1522,13 @@
 	modifyGLObject(SharedPtr<Object>(m_program));
 }
 
-void DeleteProgram::exec (tcu::ThreadUtil::Thread& thread)
+void DeleteProgram::exec (tcu::ThreadUtil::Thread& t)
 {
+	EGLThread& thread = dynamic_cast<EGLThread&>(t);
 	GLuint program = m_program->program;
 
 	thread.newMessage() << "Begin -- glDeleteProgram(" << program << ")" << tcu::ThreadUtil::Message::End;
-	GLU_CHECK_CALL(glDeleteProgram(program));
+	GLU_CHECK_GLW_CALL(thread.gl, deleteProgram(program));
 	thread.newMessage() << "End -- glDeleteProgram()" << tcu::ThreadUtil::Message::End;
 
 	m_program->program = 0;
@@ -1562,10 +1561,12 @@
 		DE_ASSERT(false);
 }
 
-void AttachShader::exec (tcu::ThreadUtil::Thread& thread)
+void AttachShader::exec (tcu::ThreadUtil::Thread& t)
 {
+	EGLThread& thread = dynamic_cast<EGLThread&>(t);
+
 	thread.newMessage() << "Begin -- glAttachShader(" << m_program->program << ", " << m_shader->shader << ")" << tcu::ThreadUtil::Message::End;
-	GLU_CHECK_CALL(glAttachShader(m_program->program, m_shader->shader));
+	GLU_CHECK_GLW_CALL(thread.gl, attachShader(m_program->program, m_shader->shader));
 	thread.newMessage() << "End -- glAttachShader()" << tcu::ThreadUtil::Message::End;
 
 	if (m_shader->type == GL_VERTEX_SHADER)
@@ -1608,19 +1609,21 @@
 		DE_ASSERT(false);
 }
 
-void DetachShader::exec (tcu::ThreadUtil::Thread& thread)
+void DetachShader::exec (tcu::ThreadUtil::Thread& t)
 {
+	EGLThread& thread = dynamic_cast<EGLThread&>(t);
+
 	if (m_type == GL_VERTEX_SHADER)
 	{
 		thread.newMessage() << "Begin -- glDetachShader(" << m_program->program << ", " << m_program->runtimeVertexShader << ")" << tcu::ThreadUtil::Message::End;
-		GLU_CHECK_CALL(glDetachShader(m_program->program, m_program->runtimeVertexShader));
+		GLU_CHECK_GLW_CALL(thread.gl, detachShader(m_program->program, m_program->runtimeVertexShader));
 		thread.newMessage() << "End -- glDetachShader()" << tcu::ThreadUtil::Message::End;
 		m_program->runtimeVertexShader = 0;
 	}
 	else if (m_type == GL_FRAGMENT_SHADER)
 	{
 		thread.newMessage() << "Begin -- glDetachShader(" << m_program->program << ", " << m_program->runtimeFragmentShader << ")" << tcu::ThreadUtil::Message::End;
-		GLU_CHECK_CALL(glDetachShader(m_program->program, m_program->runtimeFragmentShader));
+		GLU_CHECK_GLW_CALL(thread.gl, detachShader(m_program->program, m_program->runtimeFragmentShader));
 		thread.newMessage() << "End -- glDetachShader()" << tcu::ThreadUtil::Message::End;
 		m_program->runtimeFragmentShader = 0;
 	}
@@ -1646,12 +1649,13 @@
 	program->linked = true;
 }
 
-void LinkProgram::exec (tcu::ThreadUtil::Thread& thread)
+void LinkProgram::exec (tcu::ThreadUtil::Thread& t)
 {
+	EGLThread& thread = dynamic_cast<EGLThread&>(t);
 	GLuint program = m_program->program;
 
 	thread.newMessage() << "Begin -- glLinkProgram(" << program << ")" << tcu::ThreadUtil::Message::End;
-	GLU_CHECK_CALL(glLinkProgram(program));
+	GLU_CHECK_GLW_CALL(thread.gl, linkProgram(program));
 	thread.newMessage() << "End -- glLinkProgram()" << tcu::ThreadUtil::Message::End;
 }
 
@@ -1675,51 +1679,53 @@
 	readGLObject(SharedPtr<Object>(buffer));
 }
 
-void RenderBuffer::exec (tcu::ThreadUtil::Thread& thread)
+void RenderBuffer::exec (tcu::ThreadUtil::Thread& t)
 {
+	EGLThread& thread = dynamic_cast<EGLThread&>(t);
+
 	thread.newMessage() << "Begin -- glClearColor(0.5f, 0.5f, 0.5f, 1.0f)" << tcu::ThreadUtil::Message::End;
-	GLU_CHECK_CALL(glClearColor(0.5f, 0.5f, 0.5f, 1.0f));
+	GLU_CHECK_GLW_CALL(thread.gl, clearColor(0.5f, 0.5f, 0.5f, 1.0f));
 	thread.newMessage() << "End -- glClearColor()" << tcu::ThreadUtil::Message::End;
 
 	thread.newMessage() << "Begin -- glClear(GL_COLOR_BUFFER_BIT)" << tcu::ThreadUtil::Message::End;
-	GLU_CHECK_CALL(glClear(GL_COLOR_BUFFER_BIT));
+	GLU_CHECK_GLW_CALL(thread.gl, clear(GL_COLOR_BUFFER_BIT));
 	thread.newMessage() << "End -- glClear()" << tcu::ThreadUtil::Message::End;
 
 	thread.newMessage() << "Begin -- glUseProgram(" << m_program->program << ")" << tcu::ThreadUtil::Message::End;
-	GLU_CHECK_CALL(glUseProgram(m_program->program));
+	GLU_CHECK_GLW_CALL(thread.gl, useProgram(m_program->program));
 	thread.newMessage() << "End -- glUseProgram()" << tcu::ThreadUtil::Message::End;
 
 	thread.newMessage() << "Begin -- glGetAttribLocation(" << m_program->program << ", \"a_pos\")" << tcu::ThreadUtil::Message::End;
-	GLint posLoc = glGetAttribLocation(m_program->program, "a_pos");
-	GLU_CHECK_MSG("glGetAttribLocation()");
+	GLint posLoc = thread.gl.getAttribLocation(m_program->program, "a_pos");
+	GLU_CHECK_GLW_MSG(thread.gl, "glGetAttribLocation()");
 	thread.newMessage() << "End -- " << posLoc << " = glGetAttribLocation()" << tcu::ThreadUtil::Message::End;
 
 	thread.newMessage() << "Begin -- glEnableVertexAttribArray(" << posLoc << ")" << tcu::ThreadUtil::Message::End;
-	GLU_CHECK_CALL(glEnableVertexAttribArray(posLoc));
+	GLU_CHECK_GLW_CALL(thread.gl, enableVertexAttribArray(posLoc));
 	thread.newMessage() << "End -- glEnableVertexAttribArray()" << tcu::ThreadUtil::Message::End;
 
 	thread.newMessage() << "Begin -- glBindBuffer(GL_ARRAY_BUFFER, " << m_buffer->buffer << ")" << tcu::ThreadUtil::Message::End;
-	GLU_CHECK_CALL(glBindBuffer(GL_ARRAY_BUFFER, m_buffer->buffer));
+	GLU_CHECK_GLW_CALL(thread.gl, bindBuffer(GL_ARRAY_BUFFER, m_buffer->buffer));
 	thread.newMessage() << "End -- glBindBuffer()" << tcu::ThreadUtil::Message::End;
 
 	thread.newMessage() << "Begin -- glVertexAttribPointer(" << posLoc << ", GL_BYTE, GL_TRUE, 0, 0)" << tcu::ThreadUtil::Message::End;
-	GLU_CHECK_CALL(glVertexAttribPointer(posLoc, 2, GL_BYTE, GL_TRUE, 0, 0));
+	GLU_CHECK_GLW_CALL(thread.gl, vertexAttribPointer(posLoc, 2, GL_BYTE, GL_TRUE, 0, 0));
 	thread.newMessage() << "End -- glVertexAttribPointer()" << tcu::ThreadUtil::Message::End;
 
 	thread.newMessage() << "Begin -- glDrawArrays(GL_TRIANGLES, 0, " << (m_buffer->size / 2) << ")" << tcu::ThreadUtil::Message::End;
-	GLU_CHECK_CALL(glDrawArrays(GL_TRIANGLES, 0, (GLsizei)m_buffer->size / 2));
+	GLU_CHECK_GLW_CALL(thread.gl, drawArrays(GL_TRIANGLES, 0, (GLsizei)m_buffer->size / 2));
 	thread.newMessage() << "End -- glDrawArrays()" << tcu::ThreadUtil::Message::End;
 
 	thread.newMessage() << "Begin -- glBindBuffer(GL_ARRAY_BUFFER, 0)" << tcu::ThreadUtil::Message::End;
-	GLU_CHECK_CALL(glBindBuffer(GL_ARRAY_BUFFER, 0));
+	GLU_CHECK_GLW_CALL(thread.gl, bindBuffer(GL_ARRAY_BUFFER, 0));
 	thread.newMessage() << "End -- glBindBuffer()" << tcu::ThreadUtil::Message::End;
 
 	thread.newMessage() << "Begin -- glDisableVertexAttribArray(" << posLoc << ")" << tcu::ThreadUtil::Message::End;
-	GLU_CHECK_CALL(glDisableVertexAttribArray(posLoc));
+	GLU_CHECK_GLW_CALL(thread.gl, disableVertexAttribArray(posLoc));
 	thread.newMessage() << "End -- glDisableVertexAttribArray()" << tcu::ThreadUtil::Message::End;
 
 	thread.newMessage() << "Begin -- glUseProgram(0)" << tcu::ThreadUtil::Message::End;
-	GLU_CHECK_CALL(glUseProgram(0));
+	GLU_CHECK_GLW_CALL(thread.gl, useProgram(0));
 	thread.newMessage() << "End -- glUseProgram()" << tcu::ThreadUtil::Message::End;
 }
 
@@ -1743,45 +1749,47 @@
 	readGLObject(SharedPtr<Object>(texture));
 }
 
-void RenderTexture::exec (tcu::ThreadUtil::Thread& thread)
+void RenderTexture::exec (tcu::ThreadUtil::Thread& t)
 {
+	EGLThread& thread = dynamic_cast<EGLThread&>(t);
+
 	thread.newMessage() << "Begin -- glClearColor(0.5f, 0.5f, 0.5f, 1.0f)" << tcu::ThreadUtil::Message::End;
-	GLU_CHECK_CALL(glClearColor(0.5f, 0.5f, 0.5f, 1.0f));
+	GLU_CHECK_GLW_CALL(thread.gl, clearColor(0.5f, 0.5f, 0.5f, 1.0f));
 	thread.newMessage() << "End -- glClearColor()" << tcu::ThreadUtil::Message::End;
 
 	thread.newMessage() << "Begin -- glClear(GL_COLOR_BUFFER_BIT)" << tcu::ThreadUtil::Message::End;
-	GLU_CHECK_CALL(glClear(GL_COLOR_BUFFER_BIT));
+	GLU_CHECK_GLW_CALL(thread.gl, clear(GL_COLOR_BUFFER_BIT));
 	thread.newMessage() << "End -- glClear()" << tcu::ThreadUtil::Message::End;
 
 	thread.newMessage() << "Begin -- glUseProgram(" << m_program->program << ")" << tcu::ThreadUtil::Message::End;
-	GLU_CHECK_CALL(glUseProgram(m_program->program));
+	GLU_CHECK_GLW_CALL(thread.gl, useProgram(m_program->program));
 	thread.newMessage() << "End -- glUseProgram()" << tcu::ThreadUtil::Message::End;
 
 	thread.newMessage() << "Begin -- glBindTexture(GL_TEXTURE_2D, " << m_texture->texture << ")" << tcu::ThreadUtil::Message::End;
-	GLU_CHECK_CALL(glBindTexture(GL_TEXTURE_2D, m_texture->texture));
+	GLU_CHECK_GLW_CALL(thread.gl, bindTexture(GL_TEXTURE_2D, m_texture->texture));
 	thread.newMessage() << "End -- glBindTexture()" << tcu::ThreadUtil::Message::End;
 
 	thread.newMessage() << "Begin -- glGetUniformLocation(" << m_program->program << ", \"u_sampler\")" << tcu::ThreadUtil::Message::End;
-	GLint samplerPos = glGetUniformLocation(m_program->program, "u_sampler");
-	GLU_CHECK_MSG("glGetUniformLocation()");
+	GLint samplerPos = thread.gl.getUniformLocation(m_program->program, "u_sampler");
+	GLU_CHECK_GLW_MSG(thread.gl, "glGetUniformLocation()");
 	thread.newMessage() << "End -- glGetUniformLocation()" << tcu::ThreadUtil::Message::End;
 
 	thread.newMessage() << "Begin -- glUniform1i(" << samplerPos << ", 0)" << tcu::ThreadUtil::Message::End;
-	GLU_CHECK_CALL(glUniform1i(samplerPos, 0));
+	GLU_CHECK_GLW_CALL(thread.gl, uniform1i(samplerPos, 0));
 	thread.newMessage() << "End -- glUniform1i()" << tcu::ThreadUtil::Message::End;
 
 
 	thread.newMessage() << "Begin -- glGetAttribLocation(" << m_program->program << ", \"a_pos\")" << tcu::ThreadUtil::Message::End;
-	GLint posLoc = glGetAttribLocation(m_program->program, "a_pos");
-	GLU_CHECK_MSG("glGetAttribLocation()");
+	GLint posLoc = thread.gl.getAttribLocation(m_program->program, "a_pos");
+	GLU_CHECK_GLW_MSG(thread.gl, "glGetAttribLocation()");
 	thread.newMessage() << "End -- " << posLoc << " = glGetAttribLocation()" << tcu::ThreadUtil::Message::End;
 
 	thread.newMessage() << "Begin -- glEnableVertexAttribArray(" << posLoc << ")" << tcu::ThreadUtil::Message::End;
-	GLU_CHECK_CALL(glEnableVertexAttribArray(posLoc));
+	GLU_CHECK_GLW_CALL(thread.gl, enableVertexAttribArray(posLoc));
 	thread.newMessage() << "End -- glEnableVertexAttribArray()" << tcu::ThreadUtil::Message::End;
 
 	thread.newMessage() << "Begin -- glBindBuffer(GL_ARRAY_BUFFER, 0)" << tcu::ThreadUtil::Message::End;
-	GLU_CHECK_CALL(glBindBuffer(GL_ARRAY_BUFFER, 0));
+	GLU_CHECK_GLW_CALL(thread.gl, bindBuffer(GL_ARRAY_BUFFER, 0));
 	thread.newMessage() << "End -- glBindBuffer()" << tcu::ThreadUtil::Message::End;
 
 
@@ -1796,27 +1804,27 @@
 	};
 
 	thread.newMessage() << "Begin -- glVertexAttribPointer(" << posLoc << ", GL_FLOAT, GL_FALSE, 0, <data>)" << tcu::ThreadUtil::Message::End;
-	GLU_CHECK_CALL(glVertexAttribPointer(posLoc, 2, GL_FLOAT, GL_FALSE, 0, coords));
+	GLU_CHECK_GLW_CALL(thread.gl, vertexAttribPointer(posLoc, 2, GL_FLOAT, GL_FALSE, 0, coords));
 	thread.newMessage() << "End -- glVertexAttribPointer()" << tcu::ThreadUtil::Message::End;
 
 	thread.newMessage() << "Begin -- glDrawArrays(GL_TRIANGLES, 0, 6)" << tcu::ThreadUtil::Message::End;
-	GLU_CHECK_CALL(glDrawArrays(GL_TRIANGLES, 0, 6));
+	GLU_CHECK_GLW_CALL(thread.gl, drawArrays(GL_TRIANGLES, 0, 6));
 	thread.newMessage() << "End -- glDrawArrays()" << tcu::ThreadUtil::Message::End;
 
 	thread.newMessage() << "Begin -- glBindBuffer(GL_ARRAY_BUFFER, 0)" << tcu::ThreadUtil::Message::End;
-	GLU_CHECK_CALL(glBindBuffer(GL_ARRAY_BUFFER, 0));
+	GLU_CHECK_GLW_CALL(thread.gl, bindBuffer(GL_ARRAY_BUFFER, 0));
 	thread.newMessage() << "End -- glBindBuffer()" << tcu::ThreadUtil::Message::End;
 
 	thread.newMessage() << "Begin -- glBindTexture(GL_TEXTURE_2D, 0)" << tcu::ThreadUtil::Message::End;
-	GLU_CHECK_CALL(glBindTexture(GL_TEXTURE_2D, 0));
+	GLU_CHECK_GLW_CALL(thread.gl, bindTexture(GL_TEXTURE_2D, 0));
 	thread.newMessage() << "End -- glBindTexture()" << tcu::ThreadUtil::Message::End;
 
 	thread.newMessage() << "Begin -- glDisableVertexAttribArray(" << posLoc << ")" << tcu::ThreadUtil::Message::End;
-	GLU_CHECK_CALL(glDisableVertexAttribArray(posLoc));
+	GLU_CHECK_GLW_CALL(thread.gl, disableVertexAttribArray(posLoc));
 	thread.newMessage() << "End -- glDisableVertexAttribArray()" << tcu::ThreadUtil::Message::End;
 
 	thread.newMessage() << "Begin -- glUseProgram(0)" << tcu::ThreadUtil::Message::End;
-	GLU_CHECK_CALL(glUseProgram(0));
+	GLU_CHECK_GLW_CALL(thread.gl, useProgram(0));
 	thread.newMessage() << "End -- glUseProgram()" << tcu::ThreadUtil::Message::End;
 }
 
@@ -1849,15 +1857,17 @@
 	m_data = data;
 }
 
-void ReadPixels::exec (tcu::ThreadUtil::Thread& thread)
+void ReadPixels::exec (tcu::ThreadUtil::Thread& t)
 {
+	EGLThread& thread = dynamic_cast<EGLThread&>(t);
+
 	DE_ASSERT(m_type == GL_UNSIGNED_BYTE);
 	DE_ASSERT(m_format == GL_RGBA);
 
 	std::vector<deUint8> data((m_width-m_x)*(m_height-m_y)*4);
 
 	thread.newMessage() << "Begin -- glReadPixels(" << m_x << ", " << m_y << ", " << m_width << ", " << m_height << ", " << m_format << ", " << m_type << ", <data>)" << tcu::ThreadUtil::Message::End;
-	GLU_CHECK_CALL(glReadPixels(m_x, m_y, m_width, m_height, m_format, m_type, &(data[0])));
+	GLU_CHECK_GLW_CALL(thread.gl, readPixels(m_x, m_y, m_width, m_height, m_format, m_type, &(data[0])));
 	thread.newMessage() << "End -- glReadPixels()" << tcu::ThreadUtil::Message::End;
 
 	m_data->setData(data.size(), &(data[0]));
@@ -1889,43 +1899,41 @@
 
 void CreateImageFromTexture::exec (tcu::ThreadUtil::Thread& t)
 {
-	EGLThread& thread = *(dynamic_cast<EGLThread*>(&t));
+	EGLThread& thread = dynamic_cast<EGLThread&>(t);
 
 	EGLint attribList[] = {
 		EGL_GL_TEXTURE_LEVEL_KHR, 0,
 		EGL_NONE
 	};
 
-	TCU_CHECK(thread.eglExtensions.createImage);
-
 	thread.newMessage() << "Begin -- glBindTexture(GL_TEXTURE_2D, " << m_texture->texture << ")" << tcu::ThreadUtil::Message::End;
-	GLU_CHECK_CALL(glBindTexture(GL_TEXTURE_2D, m_texture->texture));
+	GLU_CHECK_GLW_CALL(thread.gl, bindTexture(GL_TEXTURE_2D, m_texture->texture));
 	thread.newMessage() << "End -- glBindTexture()" << tcu::ThreadUtil::Message::End;
 
 	// Make texture image complete...
 	thread.newMessage() << "Begin -- glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR)" << tcu::ThreadUtil::Message::End;
-	GLU_CHECK_CALL(glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR));
+	GLU_CHECK_GLW_CALL(thread.gl, texParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR));
 	thread.newMessage() << "End -- glTexParameteri()" << tcu::ThreadUtil::Message::End;
 
 	thread.newMessage() << "Begin -- glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR)" << tcu::ThreadUtil::Message::End;
-	GLU_CHECK_CALL(glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR));
+	GLU_CHECK_GLW_CALL(thread.gl, texParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR));
 	thread.newMessage() << "End -- glTexParameteri()" << tcu::ThreadUtil::Message::End;
 
 	thread.newMessage() << "Begin -- glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE)" << tcu::ThreadUtil::Message::End;
-	GLU_CHECK_CALL(glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE));
+	GLU_CHECK_GLW_CALL(thread.gl, texParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE));
 	thread.newMessage() << "End -- glTexParameteri()" << tcu::ThreadUtil::Message::End;
 
 	thread.newMessage() << "Begin -- glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE)" << tcu::ThreadUtil::Message::End;
-	GLU_CHECK_CALL(glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE));
+	GLU_CHECK_GLW_CALL(thread.gl, texParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE));
 	thread.newMessage() << "End -- glTexParameteri()" << tcu::ThreadUtil::Message::End;
 
 	thread.newMessage() << "Begin -- eglCreateImageKHR(" << thread.runtimeContext->display << ", " << thread.runtimeContext->context << ", EGL_GL_TEXTURE_2D_KHR, " << m_texture->texture << ", { EGL_GL_TEXTURE_LEVEL_KHR, 0, EGL_NONE })" << tcu::ThreadUtil::Message::End;
-	m_image->image = thread.eglExtensions.createImage(thread.runtimeContext->display, thread.runtimeContext->context, EGL_GL_TEXTURE_2D_KHR, (EGLClientBuffer)(deUintptr)m_texture->texture, attribList);
-	TCU_CHECK_EGL_MSG("eglCreateImageKHR()");
+	m_image->image = thread.egl.createImageKHR(thread.runtimeContext->display, thread.runtimeContext->context, EGL_GL_TEXTURE_2D_KHR, (EGLClientBuffer)(deUintptr)m_texture->texture, attribList);
+	EGLU_CHECK_MSG(thread.egl, "eglCreateImageKHR()");
 	thread.newMessage() << "End -- " << m_image->image << " = eglCreateImageKHR()" << tcu::ThreadUtil::Message::End;
 
 	thread.newMessage() << "Begin -- glBindTexture(GL_TEXTURE_2D, 0)" << tcu::ThreadUtil::Message::End;
-	GLU_CHECK_CALL(glBindTexture(GL_TEXTURE_2D, 0));
+	GLU_CHECK_GLW_CALL(thread.gl, bindTexture(GL_TEXTURE_2D, 0));
 	thread.newMessage() << "End -- glBindTexture()" << tcu::ThreadUtil::Message::End;
 }
 
@@ -1950,14 +1958,12 @@
 
 void DestroyImage::exec (tcu::ThreadUtil::Thread& t)
 {
-	EGLThread& thread = *(dynamic_cast<EGLThread*>(&t));
-
-	TCU_CHECK(thread.eglExtensions.destroyImage);
+	EGLThread& thread = dynamic_cast<EGLThread&>(t);
 
 	thread.newMessage() << "Begin -- eglDestroyImageKHR(" << thread.runtimeContext->display << ", " << m_image->image << ")" << tcu::ThreadUtil::Message::End;
-	thread.eglExtensions.destroyImage(thread.runtimeContext->display, m_image->image);
+	thread.egl.destroyImageKHR(thread.runtimeContext->display, m_image->image);
 	m_image->image = EGL_NO_IMAGE_KHR;
-	TCU_CHECK_EGL_MSG("eglDestroyImageKHR()");
+	EGLU_CHECK_MSG(thread.egl, "eglDestroyImageKHR()");
 	thread.newMessage() << "End -- eglDestroyImageKHR()" << tcu::ThreadUtil::Message::End;
 }
 
@@ -1987,56 +1993,28 @@
 
 void DefineTextureFromImage::exec (tcu::ThreadUtil::Thread& t)
 {
-	EGLThread& thread = *(dynamic_cast<EGLThread*>(&t));
+	EGLThread& thread = dynamic_cast<EGLThread&>(t);
 
 	thread.newMessage() << "Begin -- glBindTexture(GL_TEXTURE_2D, " << m_texture->texture << ")" << tcu::ThreadUtil::Message::End;
-	GLU_CHECK_CALL(glBindTexture(GL_TEXTURE_2D, m_texture->texture));
+	GLU_CHECK_GLW_CALL(thread.gl, bindTexture(GL_TEXTURE_2D, m_texture->texture));
 	thread.newMessage() << "End -- glBindTexture()" << tcu::ThreadUtil::Message::End;
 
 	thread.newMessage() << "Begin -- glEGLImageTargetTexture2DOES(GL_TEXTURE_2D, " << m_image->image << ")" << tcu::ThreadUtil::Message::End;
 	thread.runtimeContext->glExtensions.imageTargetTexture2D(GL_TEXTURE_2D, m_image->image);
-	GLU_CHECK_MSG("glEGLImageTargetTexture2DOES()");
+	GLU_CHECK_GLW_MSG(thread.gl, "glEGLImageTargetTexture2DOES()");
 	thread.newMessage() << "End -- glEGLImageTargetTexture2DOES()" << tcu::ThreadUtil::Message::End;
 
 	thread.newMessage() << "Begin -- glBindTexture(GL_TEXTURE_2D, 0)" << tcu::ThreadUtil::Message::End;
-	GLU_CHECK_CALL(glBindTexture(GL_TEXTURE_2D, 0));
+	GLU_CHECK_GLW_CALL(thread.gl, bindTexture(GL_TEXTURE_2D, 0));
 	thread.newMessage() << "End -- glBindTexture()" << tcu::ThreadUtil::Message::End;
 }
 
 } // GLES2ThreadTest
 
-static void requireEGLExtension (EGLDisplay eglDisplay, const char* requiredExtension)
+static void requireEGLExtension (const Library& egl, EGLDisplay eglDisplay, const char* requiredExtension)
 {
-	// Check extensions
-	bool found = false;
-
-	std::string extensions = eglQueryString(eglDisplay, EGL_EXTENSIONS);
-
-	std::string::size_type pos = extensions.find(" ");
-	do
-	{
-		std::string extension;
-		if (pos != std::string::npos)
-		{
-			extension = extensions.substr(0, pos);
-			extensions = extensions.substr(pos+1);
-		}
-		else
-		{
-			extension = extensions;
-			extensions = "";
-		}
-
-		if (extension == requiredExtension)
-		{
-			found = true;
-			break;
-		}
-		pos = extensions.find(" ");
-	} while (pos != std::string::npos);
-
-	if (!found)
-		throw tcu::NotSupportedError((string(requiredExtension) + " not supported").c_str(), "", __FILE__, __LINE__);
+	if (!eglu::hasExtension(egl, eglDisplay, requiredExtension))
+		TCU_THROW(NotSupportedError, (string(requiredExtension) + " not supported").c_str());
 }
 
 enum OperationId
@@ -2117,6 +2095,8 @@
 	EGLDisplay				m_eglDisplay;
 	EGLConfig				m_eglConfig;
 	OperationId				m_lastOperation;
+
+	glw::Functions			m_gl;
 };
 
 GLES2SharingRandomTest::TestConfig::TestConfig (void)
@@ -2147,6 +2127,7 @@
 	, m_eglConfig		(0)
 	, m_lastOperation	(THREADOPERATIONID_NONE)
 {
+	m_eglTestCtx.initGLFunctions(&m_gl, glu::ApiType::es(2,0));
 }
 
 GLES2SharingRandomTest::~GLES2SharingRandomTest (void)
@@ -2156,11 +2137,9 @@
 
 void GLES2SharingRandomTest::init (void)
 {
-	tcu::egl::Display& display = m_eglTestCtx.getDisplay();
+	const Library& egl = m_eglTestCtx.getLibrary();
 
-	vector<EGLConfig>	configs;
-
-	EGLint attribList[] =
+	const EGLint attribList[] =
 	{
 		EGL_RENDERABLE_TYPE,	EGL_OPENGL_ES2_BIT,
 		EGL_SURFACE_TYPE,		EGL_WINDOW_BIT,
@@ -2168,28 +2147,27 @@
 		EGL_NONE
 	};
 
-	display.chooseConfig(attribList, configs);
-	m_eglDisplay	= display.getEGLDisplay();
-	m_eglConfig 	= configs[0];
+	m_eglDisplay	= eglu::getAndInitDisplay(m_eglTestCtx.getNativeDisplay());
+	m_eglConfig 	= eglu::chooseSingleConfig(egl, m_eglDisplay, attribList);
 
 	// Check extensions
 	if (m_config.useFenceSync)
-		requireEGLExtension(m_eglDisplay, "EGL_KHR_fence_sync");
+		requireEGLExtension(egl, m_eglDisplay, "EGL_KHR_fence_sync");
 
 	if (m_config.serverSync)
-		requireEGLExtension(m_eglDisplay, "EGL_KHR_wait_sync");
+		requireEGLExtension(egl, m_eglDisplay, "EGL_KHR_wait_sync");
 
 	if (m_config.useImages)
 	{
-		requireEGLExtension(m_eglDisplay, "EGL_KHR_image_base");
-		requireEGLExtension(m_eglDisplay, "EGL_KHR_gl_texture_2D_image");
+		requireEGLExtension(egl, m_eglDisplay, "EGL_KHR_image_base");
+		requireEGLExtension(egl, m_eglDisplay, "EGL_KHR_gl_texture_2D_image");
 	}
 
 	GLES2ThreadTest::EGLResourceManager resourceManager;
 	// Create contexts
 	for (int threadNdx = 0; threadNdx < m_config.threadCount; threadNdx++)
 	{
-		m_threads.push_back(new GLES2ThreadTest::EGLThread(deInt32Hash(m_seed+threadNdx)));
+		m_threads.push_back(new GLES2ThreadTest::EGLThread(egl, m_gl, deInt32Hash(m_seed+threadNdx)));
 		SharedPtr<GLES2ThreadTest::GLES2Context> context;
 		SharedPtr<GLES2ThreadTest::GLES2Context> shared = (threadNdx > 0 ? resourceManager.popContext(0) : SharedPtr<GLES2ThreadTest::GLES2Context>());
 		m_threads[threadNdx]->addOperation(new GLES2ThreadTest::CreateContext(m_eglDisplay, m_eglConfig, shared, context));
@@ -2264,6 +2242,8 @@
 
 	m_threads.clear();
 
+	m_eglTestCtx.getLibrary().terminate(m_eglDisplay);
+
 	TCU_CHECK(!m_requiresRestart);
 }
 
@@ -2981,6 +2961,7 @@
 
 	EGLDisplay				m_eglDisplay;
 	EGLConfig				m_eglConfig;
+	glw::Functions			m_gl;
 };
 
 GLES2ThreadedSharingTest::GLES2ThreadedSharingTest (EglTestContext& context, const TestConfig& config, const char* name, const char* description)
@@ -2999,6 +2980,7 @@
 	, m_eglDisplay		(EGL_NO_DISPLAY)
 	, m_eglConfig		(0)
 {
+	m_eglTestCtx.initGLFunctions(&m_gl, glu::ApiType::es(2,0));
 }
 
 GLES2ThreadedSharingTest::~GLES2ThreadedSharingTest (void)
@@ -3008,11 +2990,9 @@
 
 void GLES2ThreadedSharingTest::init (void)
 {
-	tcu::egl::Display& display = m_eglTestCtx.getDisplay();
+	const Library& egl = m_eglTestCtx.getLibrary();
 
-	vector<EGLConfig>	configs;
-
-	EGLint attribList[] =
+	const EGLint attribList[] =
 	{
 		EGL_RENDERABLE_TYPE,	EGL_OPENGL_ES2_BIT,
 		EGL_SURFACE_TYPE,		EGL_WINDOW_BIT,
@@ -3020,26 +3000,25 @@
 		EGL_NONE
 	};
 
-	display.chooseConfig(attribList, configs);
-	m_eglDisplay	= display.getEGLDisplay();
-	m_eglConfig 	= configs[0];
+	m_eglDisplay	= eglu::getAndInitDisplay(m_eglTestCtx.getNativeDisplay());
+	m_eglConfig 	= eglu::chooseSingleConfig(egl, m_eglDisplay, attribList);
 
 	// Check extensions
 	if (m_config.useFenceSync)
-		requireEGLExtension(m_eglDisplay, "EGL_KHR_fence_sync");
+		requireEGLExtension(egl, m_eglDisplay, "EGL_KHR_fence_sync");
 
 	if (m_config.serverSync)
-		requireEGLExtension(m_eglDisplay, "EGL_KHR_wait_sync");
+		requireEGLExtension(egl, m_eglDisplay, "EGL_KHR_wait_sync");
 
 	if (m_config.resourceType == TestConfig::RESOURCETYPE_IMAGE)
 	{
-		requireEGLExtension(m_eglDisplay, "EGL_KHR_image_base");
-		requireEGLExtension(m_eglDisplay, "EGL_KHR_gl_texture_2D_image");
+		requireEGLExtension(egl, m_eglDisplay, "EGL_KHR_image_base");
+		requireEGLExtension(egl, m_eglDisplay, "EGL_KHR_gl_texture_2D_image");
 	}
 
 	// Create threads
-	m_threads.push_back(new GLES2ThreadTest::EGLThread(deInt32Hash(m_seed)));
-	m_threads.push_back(new GLES2ThreadTest::EGLThread(deInt32Hash(m_seed*200)));
+	m_threads.push_back(new GLES2ThreadTest::EGLThread(egl, m_gl, deInt32Hash(m_seed)));
+	m_threads.push_back(new GLES2ThreadTest::EGLThread(egl, m_gl, deInt32Hash(m_seed*200)));
 
 	SharedPtr<GLES2ThreadTest::GLES2Context> contex1;
 	SharedPtr<GLES2ThreadTest::GLES2Context> contex2;
@@ -3591,6 +3570,7 @@
 		delete m_threads[threadNdx];
 
 	m_threads.clear();
+	m_eglTestCtx.getLibrary().terminate(m_eglDisplay);
 
 	TCU_CHECK(!m_requiresRestart);
 }
diff --git a/modules/egl/teglGetProcAddressTests.cpp b/modules/egl/teglGetProcAddressTests.cpp
index 565a1a9..7fd18c9 100644
--- a/modules/egl/teglGetProcAddressTests.cpp
+++ b/modules/egl/teglGetProcAddressTests.cpp
@@ -25,11 +25,12 @@
 #include "teglTestCase.hpp"
 #include "egluCallLogWrapper.hpp"
 #include "egluStrUtil.hpp"
+#include "egluUtil.hpp"
+#include "eglwLibrary.hpp"
+#include "eglwEnums.hpp"
 #include "tcuTestLog.hpp"
-
-#if !defined(EGL_OPENGL_ES3_BIT_KHR)
-#	define EGL_OPENGL_ES3_BIT_KHR	0x0040
-#endif
+#include "deSTLUtil.hpp"
+#include "deStringUtil.hpp"
 
 namespace deqp
 {
@@ -40,6 +41,7 @@
 {
 
 using tcu::TestLog;
+using namespace eglw;
 
 // Function name strings generated from API headers
 
@@ -95,19 +97,24 @@
 	virtual						~GetProcAddressCase		(void);
 
 	void						init					(void);
+	void						deinit					(void);
 	IterateResult				iterate					(void);
 
 	bool						isSupported				(const std::string& extName);
 
 	virtual void				executeTest				(void) = 0;
 
+protected:
+	EGLDisplay					m_display;
+
 private:
 	std::vector<std::string>	m_supported;
 };
 
 GetProcAddressCase::GetProcAddressCase (EglTestContext& eglTestCtx, const char* name, const char* description)
 	: TestCase			(eglTestCtx, name, description)
-	, CallLogWrapper	(eglTestCtx.getTestContext().getLog())
+	, CallLogWrapper	(eglTestCtx.getLibrary(), eglTestCtx.getTestContext().getLog())
+	, m_display			(EGL_NO_DISPLAY)
 {
 }
 
@@ -117,12 +124,20 @@
 
 void GetProcAddressCase::init (void)
 {
-	const tcu::egl::Display&	display		= m_eglTestCtx.getDisplay();
-	display.getExtensions(m_supported);
+	DE_ASSERT(m_display == EGL_NO_DISPLAY);
+
+	m_display	= eglu::getAndInitDisplay(m_eglTestCtx.getNativeDisplay());
+	m_supported	= eglu::getClientExtensions(m_eglTestCtx.getLibrary(), m_display);
 
 	m_testCtx.setTestResult(QP_TEST_RESULT_PASS, "Pass");
 }
 
+void GetProcAddressCase::deinit (void)
+{
+	m_eglTestCtx.getLibrary().terminate(m_display);
+	m_display = EGL_NO_DISPLAY;
+}
+
 tcu::TestNode::IterateResult GetProcAddressCase::iterate (void)
 {
 	enableLogging(true);
@@ -136,7 +151,7 @@
 
 bool GetProcAddressCase::isSupported (const std::string& extName)
 {
-	return std::find(m_supported.begin(), m_supported.end(), extName) != m_supported.end();
+	return de::contains(m_supported.begin(), m_supported.end(), extName);
 }
 
 // Test by extension
@@ -171,7 +186,7 @@
 			void		(*funcPtr)(void);
 
 			funcPtr = eglGetProcAddress(funcName);
-			TCU_CHECK_EGL();
+			eglu::checkError(eglGetError(), "eglGetProcAddress()", __FILE__, __LINE__);
 
 			if (supported && funcPtr == 0)
 			{
@@ -200,29 +215,11 @@
 	{
 	}
 
-	bool isApiSupported (void)
-	{
-		const std::vector<eglu::ConfigInfo>	configs	= m_eglTestCtx.getConfigs();
-
-		if (m_apiBit == 0)
-			return true;
-
-		for (std::vector<eglu::ConfigInfo>::const_iterator configIter = configs.begin(); configIter != configs.end(); configIter++)
-		{
-			const eglu::ConfigInfo&	config	= *configIter;
-
-			if ((config.renderableType & m_apiBit) != 0)
-				return true;
-		}
-
-		return false;
-	}
-
 	void executeTest (void)
 	{
 		TestLog&				log					= m_testCtx.getLog();
 		const bool				funcPtrSupported	= isSupported("EGL_KHR_get_all_proc_addresses");
-		const bool				apiSupported		= isApiSupported();
+		const bool				apiSupported		= (eglu::getRenderableAPIsMask(m_eglTestCtx.getLibrary(), m_display) & m_apiBit) == m_apiBit;
 		const FunctionNames		funcNames			= getCoreFunctionNames(m_apiBit);
 
 		log << TestLog::Message << "EGL_KHR_get_all_proc_addresses: " << (funcPtrSupported ? "supported" : "not supported") << TestLog::EndMessage;
@@ -240,7 +237,7 @@
 			void		(*funcPtr)(void);
 
 			funcPtr = eglGetProcAddress(funcName);
-			TCU_CHECK_EGL();
+			eglu::checkError(eglGetError(), "eglGetProcAddress()", __FILE__, __LINE__);
 
 			if (apiSupported && funcPtrSupported && (funcPtr == 0))
 			{
@@ -281,7 +278,7 @@
 			std::string				testName	(extName);
 
 			for (size_t ndx = 0; ndx < extName.length(); ndx++)
-				testName[ndx] = std::tolower(extName[ndx]);
+				testName[ndx] = de::toLower(extName[ndx]);
 
 			extensionsGroup->addChild(new GetProcAddressExtensionCase(m_eglTestCtx, testName.c_str(), ("Test " + extName).c_str(), extName));
 		}
diff --git a/modules/egl/teglImageFormatTests.cpp b/modules/egl/teglImageFormatTests.cpp
index 0f027d5..abd65f6 100644
--- a/modules/egl/teglImageFormatTests.cpp
+++ b/modules/egl/teglImageFormatTests.cpp
@@ -20,9 +20,11 @@
  * \file
  * \brief EGL image tests.
  *//*--------------------------------------------------------------------*/
+
 #include "teglImageFormatTests.hpp"
 
 #include "deStringUtil.hpp"
+#include "deSTLUtil.hpp"
 
 #include "tcuTestLog.hpp"
 #include "tcuSurface.hpp"
@@ -38,6 +40,9 @@
 #include "egluUnique.hpp"
 #include "egluUtil.hpp"
 
+#include "eglwLibrary.hpp"
+#include "eglwEnums.hpp"
+
 #include "gluCallLogWrapper.hpp"
 #include "gluShaderProgram.hpp"
 #include "gluStrUtil.hpp"
@@ -72,6 +77,7 @@
 using tcu::ConstPixelBufferAccess;
 
 using namespace glw;
+using namespace eglw;
 
 namespace deqp
 {
@@ -141,17 +147,19 @@
 class ImageApi
 {
 public:
-							ImageApi				(int contextId, tcu::egl::Display& display, tcu::egl::Surface* surface);
-	virtual 				~ImageApi				(void) {}
+					ImageApi		(const Library& egl, int contextId, EGLDisplay display, EGLSurface surface);
+	virtual 		~ImageApi		(void) {}
 
 protected:
-	int						m_contextId;
-	tcu::egl::Display&		m_display;
-	tcu::egl::Surface*		m_surface;
+	const Library&	m_egl;
+	int				m_contextId;
+	EGLDisplay		m_display;
+	EGLSurface		m_surface;
 };
 
-ImageApi::ImageApi (int contextId, tcu::egl::Display& display, tcu::egl::Surface* surface)
-	: m_contextId		(contextId)
+ImageApi::ImageApi (const Library& egl, int contextId, EGLDisplay display, EGLSurface surface)
+	: m_egl				(egl)
+	, m_contextId		(contextId)
 	, m_display			(display)
 	, m_surface			(surface)
 {
@@ -249,50 +257,50 @@
 		GLint		m_stencil;
 	};
 
-					GLES2ImageApi					(const glw::Functions& gl, int contextId, tcu::TestLog& log, tcu::egl::Display& display, tcu::egl::Surface* surface, EGLConfig config);
+					GLES2ImageApi					(const Library& egl, const glw::Functions& gl, int contextId, tcu::TestLog& log, EGLDisplay display, EGLSurface surface, EGLConfig config);
 					~GLES2ImageApi					(void);
 
 private:
-	tcu::egl::Context*			m_context;
+	EGLContext					m_context;
 	const glw::Functions&		m_gl;
-	const eglu::ImageFunctions	m_imgExt;
 
 	MovePtr<UniqueImage>		createImage			(const ImageSource& source, const ClientBuffer& buffer) const;
 };
 
-GLES2ImageApi::GLES2ImageApi (const glw::Functions& gl, int contextId, tcu::TestLog& log, tcu::egl::Display& display, tcu::egl::Surface* surface, EGLConfig config)
-	: ImageApi				(contextId, display, surface)
+GLES2ImageApi::GLES2ImageApi (const Library& egl, const glw::Functions& gl, int contextId, tcu::TestLog& log, EGLDisplay display, EGLSurface surface, EGLConfig config)
+	: ImageApi				(egl, contextId, display, surface)
 	, glu::CallLogWrapper	(gl, log)
 	, m_context				(DE_NULL)
 	, m_gl					(gl)
-	, m_imgExt				(eglu::getImageFunctions(display.getEGLDisplay()))
 {
-	EGLint attriblist[] =
+	const EGLint attriblist[] =
 	{
 		EGL_CONTEXT_CLIENT_VERSION, 2,
 		EGL_NONE
 	};
 
 	EGLint configId = -1;
-	TCU_CHECK_EGL_CALL(eglGetConfigAttrib(m_display.getEGLDisplay(), config, EGL_CONFIG_ID, &configId));
+	EGLU_CHECK_CALL(m_egl, getConfigAttrib(m_display, config, EGL_CONFIG_ID, &configId));
 	getLog() << tcu::TestLog::Message << "Creating gles2 context with config id: " << configId << " context: " << m_contextId << tcu::TestLog::EndMessage;
-	m_context = new tcu::egl::Context(m_display, config, attriblist, EGL_OPENGL_ES_API);
-	TCU_CHECK_EGL_MSG("Failed to create GLES2 context");
+	egl.bindAPI(EGL_OPENGL_ES_API);
+	m_context = m_egl.createContext(m_display, config, EGL_NO_CONTEXT, attriblist);
+	EGLU_CHECK_MSG(m_egl, "Failed to create GLES2 context");
 
-	m_context->makeCurrent(*m_surface, *m_surface);
-	TCU_CHECK_EGL_MSG("Failed to make context current");
+	egl.makeCurrent(display, m_surface, m_surface, m_context);
+	EGLU_CHECK_MSG(m_egl, "Failed to make context current");
 }
 
 GLES2ImageApi::~GLES2ImageApi (void)
 {
-	delete m_context;
+	m_egl.makeCurrent(m_display, EGL_NO_SURFACE, EGL_NO_SURFACE, EGL_NO_CONTEXT);
+	m_egl.destroyContext(m_display, m_context);
 }
 
 bool GLES2ImageApi::GLES2Action::invoke (ImageApi& api, MovePtr<UniqueImage>& image, tcu::Texture2D& ref) const
 {
 	GLES2ImageApi& gles2Api = dynamic_cast<GLES2ImageApi&>(api);
 
-	gles2Api.m_context->makeCurrent(*gles2Api.m_surface, *gles2Api.m_surface);
+	gles2Api.m_egl.makeCurrent(gles2Api.m_display, gles2Api.m_surface, gles2Api.m_surface, gles2Api.m_context);
 	return invokeGLES2(gles2Api, image, ref);
 }
 
@@ -306,11 +314,11 @@
 
 MovePtr<UniqueImage> GLES2ImageApi::createImage (const ImageSource& source, const ClientBuffer& buffer) const
 {
-	const EGLImageKHR image = source.createImage(m_imgExt, m_display.getEGLDisplay(), m_context->getEGLContext(), buffer.get());
-	return MovePtr<UniqueImage>(new UniqueImage(m_display.getEGLDisplay(), image, m_imgExt));
+	const EGLImageKHR image = source.createImage(m_egl, m_display, m_context, buffer.get());
+	return MovePtr<UniqueImage>(new UniqueImage(m_egl, m_display, image));
 }
 
-static void imageTargetTexture2D (const glw::Functions& gl, GLeglImageOES img)
+static void imageTargetTexture2D (const Library& egl, const glw::Functions& gl, GLeglImageOES img)
 {
 	gl.eglImageTargetTexture2DOES(GL_TEXTURE_2D, img);
 	{
@@ -320,11 +328,11 @@
 			TCU_THROW(NotSupportedError, "Creating texture2D from EGLImage type not supported");
 
 		GLU_EXPECT_NO_ERROR(error, "glEGLImageTargetTexture2DOES()");
-		EGLU_CHECK_MSG("glEGLImageTargetTexture2DOES()");
+		EGLU_CHECK_MSG(egl, "glEGLImageTargetTexture2DOES()");
 	}
 }
 
-static void imageTargetRenderbuffer (const glw::Functions& gl, GLeglImageOES img)
+static void imageTargetRenderbuffer (const Library& egl, const glw::Functions& gl, GLeglImageOES img)
 {
 	gl.eglImageTargetRenderbufferStorageOES(GL_RENDERBUFFER, img);
 	{
@@ -334,7 +342,7 @@
 			TCU_THROW(NotSupportedError, "Creating renderbuffer from EGLImage type not supported");
 
 		GLU_EXPECT_NO_ERROR(error, "glEGLImageTargetRenderbufferStorageOES()");
-		EGLU_CHECK_MSG("glEGLImageTargetRenderbufferStorageOES()");
+		EGLU_CHECK_MSG(egl, "glEGLImageTargetRenderbufferStorageOES()");
 	}
 }
 
@@ -372,7 +380,7 @@
 	TCU_CHECK(**img != EGL_NO_IMAGE_KHR);
 
 	GLU_CHECK_GLW_CALL(gl, bindTexture(GL_TEXTURE_2D, *srcTex));
-	imageTargetTexture2D(gl, **img);
+	imageTargetTexture2D(api.m_egl, gl, **img);
 
 	GLU_CHECK_GLW_CALL(gl, texParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST));
 	GLU_CHECK_GLW_CALL(gl, texParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST));
@@ -444,7 +452,7 @@
 	framebufferRenderbuffer(gl, GL_COLOR_ATTACHMENT0, *renderbufferColor);
 
 	GLU_CHECK_GLW_CALL(gl, bindRenderbuffer(GL_RENDERBUFFER, *renderbufferDepth));
-	imageTargetRenderbuffer(gl, **img);
+	imageTargetRenderbuffer(api.m_egl, gl, **img);
 	framebufferRenderbuffer(gl, GL_DEPTH_ATTACHMENT, *renderbufferDepth);
 	GLU_CHECK_GLW_CALL(gl, bindRenderbuffer(GL_RENDERBUFFER, 0));
 
@@ -551,7 +559,7 @@
 
 	GLU_CHECK_GLW_CALL(gl, bindFramebuffer(GL_FRAMEBUFFER, *framebuffer));
 	GLU_CHECK_GLW_CALL(gl, bindRenderbuffer(GL_RENDERBUFFER, *renderbuffer));
-	imageTargetRenderbuffer(gl, **img);
+	imageTargetRenderbuffer(api.m_egl, gl, **img);
 	framebufferRenderbuffer(gl, GL_COLOR_ATTACHMENT0, *renderbuffer);
 
 	GLU_CHECK_GLW_CALL(gl, viewport(0, 0, reference.getWidth(), reference.getHeight()));
@@ -615,7 +623,7 @@
 	tcu::fillWithComponentGradients(src.getLevel(0), tcu::Vec4(0.0f, 0.0f, 0.0f, 0.0f), tcu::Vec4(1.0f, 1.0f, 1.0f, 1.0f));
 
 	GLU_CHECK_GLW_CALL(gl, bindTexture(GL_TEXTURE_2D, *srcTex));
-	imageTargetTexture2D(gl, **img);
+	imageTargetTexture2D(api.m_egl, gl, **img);
 	GLU_CHECK_GLW_CALL(gl, texSubImage2D(GL_TEXTURE_2D, 0, xOffset, yOffset, src.getWidth(), src.getHeight(), m_format, m_type, src.getLevel(0).getDataPtr()));
 	GLU_CHECK_GLW_CALL(gl, bindTexture(GL_TEXTURE_2D, 0));
 	GLU_CHECK_GLW_CALL(gl, finish());
@@ -637,7 +645,7 @@
 	GLU_CHECK_GLW_CALL(gl, bindFramebuffer(GL_FRAMEBUFFER, *framebuffer));
 	GLU_CHECK_GLW_CALL(gl, bindRenderbuffer(GL_RENDERBUFFER, *renderbuffer));
 
-	imageTargetRenderbuffer(gl, **img);
+	imageTargetRenderbuffer(api.m_egl, gl, **img);
 
 	initializeRbo(api, *renderbuffer, reference);
 
@@ -709,9 +717,9 @@
 
 	vector<ImageApi*>	m_apiContexts;
 
-	tcu::egl::Display*	m_display;
+	EGLDisplay			m_display;
 	eglu::NativeWindow*	m_window;
-	tcu::egl::Surface*	m_surface;
+	EGLSurface			m_surface;
 	EGLConfig			m_config;
 	int					m_curIter;
 	MovePtr<UniqueImage>m_img;
@@ -721,10 +729,7 @@
 
 EGLConfig ImageFormatCase::getConfig (void)
 {
-	vector<EGLConfig>	configs;
-	eglu::FilterList	filter;
-
-	EGLint attribList[] =
+	const EGLint attribList[] =
 	{
 		EGL_RENDERABLE_TYPE, 	EGL_OPENGL_ES2_BIT,
 		EGL_SURFACE_TYPE,	 	EGL_WINDOW_BIT,
@@ -732,18 +737,17 @@
 		EGL_DEPTH_SIZE,			8,
 		EGL_NONE
 	};
-	m_display->chooseConfig(attribList, configs);
 
-	return configs[0];
+	return eglu::chooseSingleConfig(m_eglTestCtx.getLibrary(), m_display, attribList);
 }
 
 ImageFormatCase::ImageFormatCase (EglTestContext& eglTestCtx, const TestSpec& spec)
 	: TestCase				(eglTestCtx, spec.name.c_str(), spec.desc.c_str())
 	, glu::CallLogWrapper	(m_gl, eglTestCtx.getTestContext().getLog())
 	, m_spec				(spec)
-	, m_display				(DE_NULL)
+	, m_display				(EGL_NO_DISPLAY)
 	, m_window				(DE_NULL)
-	, m_surface				(DE_NULL)
+	, m_surface				(EGL_NO_SURFACE)
 	, m_config				(0)
 	, m_curIter				(0)
 	, m_refImg				(tcu::TextureFormat(tcu::TextureFormat::RGBA, tcu::TextureFormat::UNORM_INT8), 1, 1)
@@ -757,15 +761,16 @@
 
 void ImageFormatCase::checkExtensions (void)
 {
-	const EGLDisplay		dpy		= m_display->getEGLDisplay();
+	const Library&			egl		= m_eglTestCtx.getLibrary();
+	const EGLDisplay		dpy		= m_display;
 	set<string>				exts;
 	const vector<string>	glExts	= de::splitString((const char*) m_gl.getString(GL_EXTENSIONS));
-	const vector<string>	eglExts	= eglu::getClientExtensions(dpy);
+	const vector<string>	eglExts	= eglu::getClientExtensions(egl, dpy);
 
 	exts.insert(glExts.begin(), glExts.end());
 	exts.insert(eglExts.begin(), eglExts.end());
 
-	if (eglu::getVersion(dpy) >= eglu::Version(1, 5))
+	if (eglu::getVersion(egl, dpy) >= eglu::Version(1, 5))
 	{
 		// EGL 1.5 has built-in support for EGLImage and GL sources
 		exts.insert("EGL_KHR_image_base");
@@ -795,43 +800,73 @@
 
 void ImageFormatCase::init (void)
 {
-	m_display	= &m_eglTestCtx.getDisplay();
-	m_config	= getConfig();
-	m_window	= m_eglTestCtx.createNativeWindow(m_display->getEGLDisplay(), m_config, DE_NULL, 480, 480, eglu::parseWindowVisibility(m_testCtx.getCommandLine()));
-	m_surface	= new tcu::egl::WindowSurface(*m_display, eglu::createWindowSurface(m_eglTestCtx.getNativeDisplay(), *m_window, m_display->getEGLDisplay(), m_config, DE_NULL));
+	const Library&						egl				= m_eglTestCtx.getLibrary();
+	const eglu::NativeWindowFactory*	windowFactory	= eglu::selectNativeWindowFactory(m_eglTestCtx.getNativeDisplayFactory(), m_testCtx.getCommandLine());
 
-	m_eglTestCtx.getGLFunctions(m_gl, glu::ApiType::es(2, 0), vector<const char*>(1, "GL_OES_EGL_image"));
+	if (!windowFactory)
+		TCU_THROW(NotSupportedError, "Windows not supported");
 
-	for (int contextNdx = 0; contextNdx < (int)m_spec.contexts.size(); contextNdx++)
+	try
 	{
-		ImageApi* api = DE_NULL;
-		switch (m_spec.contexts[contextNdx])
-		{
-			case TestSpec::API_GLES2:
-			{
-				api = new GLES2ImageApi(m_gl, contextNdx, getLog(), *m_display, m_surface, m_config);
-				break;
-			}
+		m_display	= eglu::getAndInitDisplay(m_eglTestCtx.getNativeDisplay());
+		m_config	= getConfig();
+		m_window	= windowFactory->createWindow(&m_eglTestCtx.getNativeDisplay(), m_display, m_config, DE_NULL, eglu::WindowParams(480, 480, eglu::parseWindowVisibility(m_testCtx.getCommandLine())));
+		m_surface	= eglu::createWindowSurface(m_eglTestCtx.getNativeDisplay(), *m_window, m_display, m_config, DE_NULL);
 
-			default:
-				DE_ASSERT(false);
-				break;
+		{
+			const char* extensions[] = { "GL_OES_EGL_image" };
+			m_eglTestCtx.initGLFunctions(&m_gl, glu::ApiType::es(2, 0), DE_LENGTH_OF_ARRAY(extensions), &extensions[0]);
 		}
-		m_apiContexts.push_back(api);
+
+		for (int contextNdx = 0; contextNdx < (int)m_spec.contexts.size(); contextNdx++)
+		{
+			ImageApi* api = DE_NULL;
+			switch (m_spec.contexts[contextNdx])
+			{
+				case TestSpec::API_GLES2:
+				{
+					api = new GLES2ImageApi(egl, m_gl, contextNdx, getLog(), m_display, m_surface, m_config);
+					break;
+				}
+
+				default:
+					DE_ASSERT(false);
+					break;
+			}
+			m_apiContexts.push_back(api);
+		}
+		checkExtensions();
 	}
-	checkExtensions();
+	catch (...)
+	{
+		deinit();
+		throw;
+	}
 }
 
 void ImageFormatCase::deinit (void)
 {
+	const Library& egl = m_eglTestCtx.getLibrary();
+
 	for (int contexNdx = 0 ; contexNdx < (int)m_apiContexts.size(); contexNdx++)
 		delete m_apiContexts[contexNdx];
 
 	m_apiContexts.clear();
-	delete m_surface;
-	m_surface = DE_NULL;
+
+	if (m_surface != EGL_NO_SURFACE)
+	{
+		egl.destroySurface(m_display, m_surface);
+		m_surface = EGL_NO_SURFACE;
+	}
+
 	delete m_window;
 	m_window = DE_NULL;
+
+	if (m_display != EGL_NO_DISPLAY)
+	{
+		egl.terminate(m_display);
+		m_display = EGL_NO_DISPLAY;
+	}
 }
 
 TestCase::IterateResult ImageFormatCase::iterate (void)
diff --git a/modules/egl/teglImageTests.cpp b/modules/egl/teglImageTests.cpp
index 4c38d1f..4cabdd3 100644
--- a/modules/egl/teglImageTests.cpp
+++ b/modules/egl/teglImageTests.cpp
@@ -27,7 +27,6 @@
 #include "teglAndroidUtil.hpp"
 #include "teglImageFormatTests.hpp"
 
-#include "egluExtensions.hpp"
 #include "egluNativeDisplay.hpp"
 #include "egluNativeWindow.hpp"
 #include "egluNativePixmap.hpp"
@@ -36,6 +35,9 @@
 #include "egluUtil.hpp"
 #include "egluGLUtil.hpp"
 
+#include "eglwLibrary.hpp"
+#include "eglwEnums.hpp"
+
 #include "gluDefs.hpp"
 #include "gluCallLogWrapper.hpp"
 #include "gluObjectWrapper.hpp"
@@ -75,6 +77,7 @@
 using eglu::ScopedCurrentContext;
 
 using namespace glw;
+using namespace eglw;
 
 namespace deqp
 {
@@ -85,15 +88,18 @@
 {
 
 #define CHECK_EXTENSION(DPY, EXTNAME) \
-	TCU_CHECK_AND_THROW(NotSupportedError, eglu::hasExtension(DPY, EXTNAME), (string("Unsupported extension: ") + EXTNAME).c_str())
+	TCU_CHECK_AND_THROW(NotSupportedError, eglu::hasExtension(m_eglTestCtx.getLibrary(), DPY, EXTNAME), (string("Unsupported extension: ") + EXTNAME).c_str())
 
 template <typename RetVal>
-RetVal checkCallError (tcu::TestContext& testCtx, const char* call, RetVal returnValue, EGLint expectError)
+RetVal checkCallError (EglTestContext& eglTestCtx, const char* call, RetVal returnValue, EGLint expectError)
 {
-	TestLog& log = testCtx.getLog();
+	tcu::TestContext&	testCtx		= eglTestCtx.getTestContext();
+	TestLog&			log			= testCtx.getLog();
+	EGLint				error;
+
 	log << TestLog::Message << call << TestLog::EndMessage;
 
-	EGLint error = eglGetError();
+	error = eglTestCtx.getLibrary().getError();
 
 	if (error != expectError)
 	{
@@ -108,12 +114,15 @@
 }
 
 template <typename RetVal>
-void checkCallReturn (tcu::TestContext& testCtx, const char* call, RetVal returnValue, RetVal expectReturnValue, EGLint expectError)
+void checkCallReturn (EglTestContext& eglTestCtx, const char* call, RetVal returnValue, RetVal expectReturnValue, EGLint expectError)
 {
-	TestLog& log = testCtx.getLog();
+	tcu::TestContext&	testCtx		= eglTestCtx.getTestContext();
+	TestLog&			log			= testCtx.getLog();
+	EGLint				error;
+
 	log << TestLog::Message << call << TestLog::EndMessage;
 
-	EGLint error = eglGetError();
+	error = eglTestCtx.getLibrary().getError();
 
 	if (returnValue != expectReturnValue)
 	{
@@ -132,9 +141,9 @@
 	}
 }
 
-// \note These macros expect "TestContext m_testCtx" to be defined.
-#define CHECK_EXT_CALL_RET(CALL, EXPECT_RETURN_VALUE, EXPECT_ERROR)	checkCallReturn(m_testCtx, #CALL, CALL, (EXPECT_RETURN_VALUE), (EXPECT_ERROR))
-#define CHECK_EXT_CALL_ERR(CALL, EXPECT_ERROR)						checkCallError(m_testCtx, #CALL, CALL, (EXPECT_ERROR))
+// \note These macros expect "EglTestContext m_eglTestCtx" to be defined.
+#define CHECK_EXT_CALL_RET(CALL, EXPECT_RETURN_VALUE, EXPECT_ERROR)	checkCallReturn(m_eglTestCtx, #CALL, CALL, (EXPECT_RETURN_VALUE), (EXPECT_ERROR))
+#define CHECK_EXT_CALL_ERR(CALL, EXPECT_ERROR)						checkCallError(m_eglTestCtx, #CALL, CALL, (EXPECT_ERROR))
 
 class ImageTestCase : public TestCase, public glu::CallLogWrapper
 {
@@ -142,28 +151,30 @@
 				ImageTestCase		(EglTestContext& eglTestCtx, ApiType api, const string& name, const string& desc)
 					: TestCase				(eglTestCtx, name.c_str(), desc.c_str())
 					, glu::CallLogWrapper	(m_gl, m_testCtx.getLog())
-					, m_api					(api) {}
+					, m_api					(api)
+					, m_display				(EGL_NO_DISPLAY)
+	{
+	}
 
 	void		init				(void)
 	{
-		m_eglTestCtx.getGLFunctions(m_gl, m_api, vector<const char*>(1, "GL_OES_EGL_image"));
-		m_imageExt = de::newMovePtr<eglu::ImageFunctions>(eglu::getImageFunctions(m_eglTestCtx.getEGLDisplay()));
+		DE_ASSERT(m_display == EGL_NO_DISPLAY);
+		m_display = eglu::getAndInitDisplay(m_eglTestCtx.getNativeDisplay());
+
+		const char* extensions[] = { "GL_OES_EGL_image" };
+		m_eglTestCtx.initGLFunctions(&m_gl, m_api, DE_LENGTH_OF_ARRAY(extensions), &extensions[0]);
+	}
+
+	void		deinit				(void)
+	{
+		m_eglTestCtx.getLibrary().terminate(m_display);
+		m_display = EGL_NO_DISPLAY;
 	}
 
 protected:
-	EGLImageKHR	eglCreateImageKHR	(EGLDisplay dpy, EGLContext ctx, EGLenum target, EGLClientBuffer buffer, const EGLint *attribList)
-	{
-		return m_imageExt->createImage(dpy, ctx, target, buffer, attribList);
-	}
-
-	EGLBoolean	eglDestroyImageKHR	(EGLDisplay dpy, EGLImageKHR image)
-	{
-		return m_imageExt->destroyImage(dpy, image);
-	}
-
-	glw::Functions					m_gl;
-	MovePtr<eglu::ImageFunctions>	m_imageExt;
-	ApiType							m_api;
+	glw::Functions	m_gl;
+	ApiType			m_api;
+	EGLDisplay		m_display;
 };
 
 class InvalidCreateImage : public ImageTestCase
@@ -178,12 +189,10 @@
 
 	IterateResult iterate (void)
 	{
-		const EGLDisplay			dpy 		= m_eglTestCtx.getEGLDisplay();
-
 #define CHECK_CREATE(MSG, DPY, CONTEXT, SOURCE, ERR) checkCreate(MSG, DPY, #DPY, CONTEXT, #CONTEXT, SOURCE, #SOURCE, ERR)
 		CHECK_CREATE("Testing bad display (-1)...", (EGLDisplay)-1, EGL_NO_CONTEXT, EGL_NONE, EGL_BAD_DISPLAY);
-		CHECK_CREATE("Testing bad context (-1)...", dpy, (EGLContext)-1, EGL_NONE, EGL_BAD_CONTEXT);
-		CHECK_CREATE("Testing bad source (-1)...", dpy, EGL_NO_CONTEXT, (EGLenum)-1, EGL_BAD_PARAMETER);
+		CHECK_CREATE("Testing bad context (-1)...", m_display, (EGLContext)-1, EGL_NONE, EGL_BAD_CONTEXT);
+		CHECK_CREATE("Testing bad source (-1)...", m_display, EGL_NO_CONTEXT, (EGLenum)-1, EGL_BAD_PARAMETER);
 #undef CHECK_CREATE
 
 		m_testCtx.setTestResult(QP_TEST_RESULT_PASS, "Pass");
@@ -196,17 +205,16 @@
 {
 	m_testCtx.getLog() << TestLog::Message << msg << TestLog::EndMessage;
 	{
-		const EGLImageKHR	image = m_imageExt->createImage(dpy, context, source, 0, DE_NULL);
+		const Library&		egl		= m_eglTestCtx.getLibrary();
+		const EGLImageKHR	image	= egl.createImageKHR(dpy, context, source, 0, DE_NULL);
 		ostringstream		call;
 
 		call << "eglCreateImage(" << dpyStr << ", " << ctxStr << ", " << srcStr << ", 0, DE_NULL)";
-		checkCallReturn(m_testCtx, call.str().c_str(), image, EGL_NO_IMAGE_KHR, expectError);
+		checkCallReturn(m_eglTestCtx, call.str().c_str(), image, EGL_NO_IMAGE_KHR, expectError);
 	}
 }
 
-
-
-EGLConfig chooseConfig (EGLDisplay display, ApiType apiType)
+EGLConfig chooseConfig (const Library& egl, EGLDisplay display, ApiType apiType)
 {
 	AttribMap				attribs;
 	vector<EGLConfig>		configs;
@@ -218,7 +226,7 @@
 	for (int ndx = 0; ndx < DE_LENGTH_OF_ARRAY(s_surfaceTypes); ++ndx)
 	{
 		attribs[EGL_SURFACE_TYPE] = s_surfaceTypes[ndx];
-		configs = eglu::chooseConfig(display, attribs);
+		configs = eglu::chooseConfigs(egl, display, attribs);
 
 		if (!configs.empty())
 			return configs.front();
@@ -231,25 +239,27 @@
 class Context
 {
 public:
-								Context (EglTestContext& eglTestCtx, ContextType ctxType, int width, int height)
+								Context			(EglTestContext& eglTestCtx, EGLDisplay display, ContextType ctxType, int width, int height)
 									: m_eglTestCtx	(eglTestCtx)
-									, m_config		(chooseConfig(eglTestCtx.getEGLDisplay(), ctxType.getAPI()))
-									, m_context		(eglu::createGLContext(eglTestCtx.getEGLDisplay(), m_config, ctxType))
-									, m_surface		(createSurface(eglTestCtx, m_config, width, height))
-									, m_current		(eglTestCtx.getEGLDisplay(), m_surface->get(), m_surface->get(), m_context)
+									, m_display		(display)
+									, m_config		(chooseConfig(eglTestCtx.getLibrary(), display, ctxType.getAPI()))
+									, m_context		(m_eglTestCtx.getLibrary(), m_display, eglu::createGLContext(eglTestCtx.getLibrary(), m_display, m_config, ctxType))
+									, m_surface		(createSurface(eglTestCtx, m_display, m_config, width, height))
+									, m_current		(eglTestCtx.getLibrary(), m_display, m_surface->get(), m_surface->get(), *m_context)
 	{
-		m_eglTestCtx.getGLFunctions(m_gl, ctxType.getAPI());
+		m_eglTestCtx.initGLFunctions(&m_gl, ctxType.getAPI());
 	}
 
 	EGLConfig					getConfig		(void) const { return m_config; }
-	EGLDisplay 					getEglDisplay	(void) const { return m_eglTestCtx.getEGLDisplay(); }
-	EGLContext 					getEglContext	(void) const { return m_context; }
+	EGLDisplay 					getEglDisplay	(void) const { return m_display; }
+	EGLContext 					getEglContext	(void) const { return *m_context; }
 	const glw::Functions&		gl				(void) const { return m_gl; }
 
 private:
 	EglTestContext&				m_eglTestCtx;
+	EGLDisplay					m_display;
 	EGLConfig					m_config;
-	EGLContext					m_context;
+	eglu::UniqueContext			m_context;
 	UniquePtr<ManagedSurface>	m_surface;
 	ScopedCurrentContext		m_current;
 	glw::Functions				m_gl;
@@ -297,7 +307,7 @@
 		}
 	}
 
-	MovePtr<ImageSource> getImageSource (EGLint target, GLenum format)
+	MovePtr<ImageSource> getImageSource (EGLint target, GLenum format, bool useTexLevel0)
 	{
 		switch (target)
 		{
@@ -308,7 +318,7 @@
 			case EGL_GL_TEXTURE_CUBE_MAP_NEGATIVE_Y_KHR:
 			case EGL_GL_TEXTURE_CUBE_MAP_POSITIVE_Z_KHR:
 			case EGL_GL_TEXTURE_CUBE_MAP_NEGATIVE_Z_KHR:
-				return createTextureImageSource(target, format, GL_UNSIGNED_BYTE);
+				return createTextureImageSource(target, format, GL_UNSIGNED_BYTE, useTexLevel0);
 			case EGL_GL_RENDERBUFFER_KHR:
 				return createRenderbufferImageSource(format);
 			case EGL_NATIVE_BUFFER_ANDROID:
@@ -321,15 +331,16 @@
 
 	CreateImageGLES2 (EglTestContext& eglTestCtx, EGLint target, GLenum storage, bool useTexLevel0 = false)
 		: ImageTestCase		(eglTestCtx, ApiType::es(2, 0), string("create_image_gles2_") + getTargetName(target) + "_" + getStorageName(storage) + (useTexLevel0 ? "_level0_only" : ""), "Create EGLImage from GLES2 object")
-		, m_source			(getImageSource(target, storage))
+		, m_source			(getImageSource(target, storage, useTexLevel0))
 	{
 	}
 
 	IterateResult iterate (void)
 	{
-		const EGLDisplay	dpy			= m_eglTestCtx.getEGLDisplay();
+		const Library&			egl				= m_eglTestCtx.getLibrary();
+		const EGLDisplay		dpy				= m_display;
 
-		if (eglu::getVersion(dpy) < eglu::Version(1, 5))
+		if (eglu::getVersion(egl, dpy) < eglu::Version(1, 5))
 			CHECK_EXTENSION(dpy, m_source->getRequiredExtension());
 
 		// Initialize result.
@@ -338,13 +349,13 @@
 		// Create GLES2 context
 		TestLog&				log				= m_testCtx.getLog();
 		const ContextType		contextType		(ApiType::es(2, 0));
-		Context					context			(m_eglTestCtx, contextType, 64, 64);
+		Context					context			(m_eglTestCtx, dpy, contextType, 64, 64);
 		const EGLContext		eglContext		= context.getEglContext();
 
-		log << TestLog::Message << "Using EGL config " << eglu::getConfigID(dpy, context.getConfig()) << TestLog::EndMessage;
+		log << TestLog::Message << "Using EGL config " << eglu::getConfigID(egl, dpy, context.getConfig()) << TestLog::EndMessage;
 
 		UniquePtr<ClientBuffer>	clientBuffer	(m_source->createBuffer(context.gl()));
-		const EGLImageKHR		image			= m_source->createImage(*m_imageExt, dpy, eglContext, clientBuffer->get());
+		const EGLImageKHR		image			= m_source->createImage(egl, dpy, eglContext, clientBuffer->get());
 
 		if (image == EGL_NO_IMAGE_KHR)
 		{
@@ -355,13 +366,14 @@
 		}
 
 		// Destroy image
-		CHECK_EXT_CALL_RET(eglDestroyImageKHR(context.getEglDisplay(), image), (EGLBoolean)EGL_TRUE, EGL_SUCCESS);
+		CHECK_EXT_CALL_RET(egl.destroyImageKHR(context.getEglDisplay(), image), (EGLBoolean)EGL_TRUE, EGL_SUCCESS);
 
 		return STOP;
 	}
 
 private:
 	UniquePtr<ImageSource>	m_source;
+	EGLint					m_target;
 };
 
 class ImageTargetGLES2 : public ImageTestCase
@@ -387,18 +399,19 @@
 
 	IterateResult iterate (void)
 	{
+		const Library&	egl	= m_eglTestCtx.getLibrary();
 		TestLog&		log	= m_testCtx.getLog();
 
 		// \todo [2011-07-21 pyry] Try all possible EGLImage sources
-		CHECK_EXTENSION(m_eglTestCtx.getEGLDisplay(), "EGL_KHR_gl_texture_2D_image");
+		CHECK_EXTENSION(m_display, "EGL_KHR_gl_texture_2D_image");
 
 		// Initialize result.
 		m_testCtx.setTestResult(QP_TEST_RESULT_PASS, "Pass");
 
 		// Create GLES2 context
 
-		Context context(m_eglTestCtx, ContextType(ApiType::es(2, 0)), 64, 64);
-		log << TestLog::Message << "Using EGL config " << eglu::getConfigID(context.getEglDisplay(), context.getConfig()) << TestLog::EndMessage;
+		Context context(m_eglTestCtx, m_display, ContextType(ApiType::es(2, 0)), 64, 64);
+		log << TestLog::Message << "Using EGL config " << eglu::getConfigID(m_eglTestCtx.getLibrary(), context.getEglDisplay(), context.getConfig()) << TestLog::EndMessage;
 
 		// Check for OES_EGL_image
 		{
@@ -421,7 +434,7 @@
 
 		// Create EGL image
 		EGLint		attribs[]	= { EGL_GL_TEXTURE_LEVEL_KHR, 0, EGL_NONE };
-		EGLImageKHR	image		= CHECK_EXT_CALL_ERR(eglCreateImageKHR(context.getEglDisplay(), context.getEglContext(), EGL_GL_TEXTURE_2D_KHR, (EGLClientBuffer)(deUintptr)srcTex, attribs), EGL_SUCCESS);
+		EGLImageKHR	image		= CHECK_EXT_CALL_ERR(egl.createImageKHR(context.getEglDisplay(), context.getEglContext(), EGL_GL_TEXTURE_2D_KHR, (EGLClientBuffer)(deUintptr)srcTex, attribs), EGL_SUCCESS);
 		if (image == EGL_NO_IMAGE_KHR)
 		{
 			log << TestLog::Message << "  Fail: Got EGL_NO_IMAGE_KHR!" << TestLog::EndMessage;
@@ -453,7 +466,7 @@
 		}
 
 		// Destroy image
-		CHECK_EXT_CALL_RET(eglDestroyImageKHR(context.getEglDisplay(), image), (EGLBoolean)EGL_TRUE, EGL_SUCCESS);
+		CHECK_EXT_CALL_RET(egl.destroyImageKHR(context.getEglDisplay(), image), (EGLBoolean)EGL_TRUE, EGL_SUCCESS);
 
 		// Destroy source texture object
 		GLU_CHECK_CALL(glDeleteTextures(1, &srcTex));
diff --git a/modules/egl/teglImageUtil.cpp b/modules/egl/teglImageUtil.cpp
index a44b294..1efadc4 100644
--- a/modules/egl/teglImageUtil.cpp
+++ b/modules/egl/teglImageUtil.cpp
@@ -31,6 +31,9 @@
 #include "egluNativeWindow.hpp"
 #include "egluNativePixmap.hpp"
 
+#include "eglwLibrary.hpp"
+#include "eglwEnums.hpp"
+
 #include "glwEnums.hpp"
 
 #include "gluObjectWrapper.hpp"
@@ -58,10 +61,16 @@
 
 using eglu::AttribMap;
 using eglu::UniqueSurface;
+using eglu::NativeDisplay;
 using eglu::NativeWindow;
 using eglu::NativePixmap;
+using eglu::NativeDisplayFactory;
+using eglu::NativeWindowFactory;
+using eglu::NativePixmapFactory;
+using eglu::WindowParams;
 
 using namespace glw;
+using namespace eglw;
 
 enum {
 	IMAGE_WIDTH		= 64,
@@ -85,33 +94,49 @@
 typedef NativeSurface<NativeWindow> NativeWindowSurface;
 typedef NativeSurface<NativePixmap> NativePixmapSurface;
 
-MovePtr<ManagedSurface> createSurface (EglTestContext& eglTestCtx, EGLConfig config, int width, int height)
+MovePtr<ManagedSurface> createSurface (EglTestContext& eglTestCtx, EGLDisplay dpy, EGLConfig config, int width, int height)
 {
-	EGLDisplay	dpy				= eglTestCtx.getEGLDisplay();
-	EGLint		surfaceTypeBits	= eglu::getConfigAttribInt(dpy, config, EGL_SURFACE_TYPE);
+	const Library&				egl				= eglTestCtx.getLibrary();
+	EGLint						surfaceTypeBits	= eglu::getConfigAttribInt(egl, dpy, config, EGL_SURFACE_TYPE);
+	const NativeDisplayFactory&	displayFactory	= eglTestCtx.getNativeDisplayFactory();
+	NativeDisplay&				nativeDisplay	= eglTestCtx.getNativeDisplay();
 
 	if (surfaceTypeBits & EGL_PBUFFER_BIT)
 	{
 		static const EGLint attribs[]	= { EGL_WIDTH, width, EGL_HEIGHT, height, EGL_NONE };
-		const EGLSurface	surface		= eglCreatePbufferSurface(dpy, config, attribs);
+		const EGLSurface	surface		= egl.createPbufferSurface(dpy, config, attribs);
 
-		EGLU_CHECK();
+		EGLU_CHECK_MSG(egl, "eglCreatePbufferSurface()");
 
-		return de::newMovePtr<ManagedSurface>(de::newMovePtr<UniqueSurface>(dpy, surface));
+		return de::newMovePtr<ManagedSurface>(MovePtr<UniqueSurface>(new UniqueSurface(egl, dpy, surface)));
 	}
 	else if (surfaceTypeBits & EGL_WINDOW_BIT)
 	{
-		MovePtr<NativeWindow>	window	(eglTestCtx.createNativeWindow(dpy, config, DE_NULL, width, height));
-		const EGLSurface		surface	= eglu::createWindowSurface(eglTestCtx.getNativeDisplay(), *window, dpy, config, DE_NULL);
+		const NativeWindowFactory*	windowFactory	= selectNativeWindowFactory(displayFactory, eglTestCtx.getTestContext().getCommandLine());
 
-		return MovePtr<ManagedSurface>(new NativeWindowSurface(de::newMovePtr<UniqueSurface>(dpy, surface), window));
+		if (windowFactory)
+		{
+			MovePtr<NativeWindow>	window	(windowFactory->createWindow(&nativeDisplay, dpy, config, DE_NULL, WindowParams(width, height, WindowParams::VISIBILITY_DONT_CARE)));
+			const EGLSurface		surface	= eglu::createWindowSurface(nativeDisplay, *window, dpy, config, DE_NULL);
+
+			return MovePtr<ManagedSurface>(new NativeWindowSurface(MovePtr<UniqueSurface>(new UniqueSurface(egl, dpy, surface)), window));
+		}
+		else
+			TCU_THROW(NotSupportedError, "Windows not supported");
 	}
 	else if (surfaceTypeBits & EGL_PIXMAP_BIT)
 	{
-		MovePtr<NativePixmap>	pixmap	(eglTestCtx.createNativePixmap(dpy, config, DE_NULL, width, height));
-		const EGLSurface		surface	= eglu::createPixmapSurface(eglTestCtx.getNativeDisplay(), *pixmap, dpy, config, DE_NULL);
+		const NativePixmapFactory*	pixmapFactory	= selectNativePixmapFactory(displayFactory, eglTestCtx.getTestContext().getCommandLine());
 
-		return MovePtr<ManagedSurface>(new NativePixmapSurface(de::newMovePtr<UniqueSurface>(dpy, surface), pixmap));
+		if (pixmapFactory)
+		{
+			MovePtr<NativePixmap>	pixmap	(pixmapFactory->createPixmap(&nativeDisplay, dpy, config, DE_NULL, width, height));
+			const EGLSurface		surface	= eglu::createPixmapSurface(eglTestCtx.getNativeDisplay(), *pixmap, dpy, config, DE_NULL);
+
+			return MovePtr<ManagedSurface>(new NativePixmapSurface(MovePtr<UniqueSurface>(new UniqueSurface(egl, dpy, surface)), pixmap));
+		}
+		else
+			TCU_THROW(NotSupportedError, "Pixmaps not supported");
 	}
 	else
 		TCU_FAIL("No valid surface types supported in config");
@@ -138,24 +163,24 @@
 class GLImageSource : public ImageSource
 {
 public:
-	EGLImageKHR			createImage			(const eglu::ImageFunctions& imgExt, EGLDisplay dpy, EGLContext ctx, EGLClientBuffer clientBuffer) const;
+	EGLImageKHR			createImage			(const Library& egl, EGLDisplay dpy, EGLContext ctx, EGLClientBuffer clientBuffer) const;
 
 protected:
 	virtual AttribMap	getCreateAttribs	(void) const = 0;
 	virtual EGLenum		getSource			(void) const = 0;
 };
 
-EGLImageKHR GLImageSource::createImage	 (const eglu::ImageFunctions& imgExt, EGLDisplay dpy, EGLContext ctx, EGLClientBuffer clientBuffer) const
+EGLImageKHR GLImageSource::createImage (const Library& egl, EGLDisplay dpy, EGLContext ctx, EGLClientBuffer clientBuffer) const
 {
 	AttribMap				attribMap	= getCreateAttribs();
 
 	attribMap[EGL_IMAGE_PRESERVED_KHR] = EGL_TRUE;
 
 	{
-		const vector<EGLint> 	attribs	= eglu::attribMapToVector(attribMap);
-		const EGLImageKHR		image 	= imgExt.createImage(dpy, ctx, getSource(),
+		const vector<EGLint> 	attribs	= eglu::attribMapToList(attribMap);
+		const EGLImageKHR		image 	= egl.createImageKHR(dpy, ctx, getSource(),
 															 clientBuffer, &attribs.front());
-		EGLU_CHECK_MSG("eglCreateImageKHR()");
+		EGLU_CHECK_MSG(egl, "eglCreateImageKHR()");
 		return image;
 	}
 }
@@ -386,7 +411,7 @@
 							UnsupportedImageSource	(const string& message) : m_message(message) {}
 	string					getRequiredExtension	(void) const { fail(); return ""; }
 	MovePtr<ClientBuffer>	createBuffer			(const glw::Functions&, tcu::Texture2D*) const { fail(); return de::MovePtr<ClientBuffer>(); }
-	EGLImageKHR				createImage				(const eglu::ImageFunctions& imgExt, EGLDisplay dpy, EGLContext ctx, EGLClientBuffer clientBuffer) const;
+	EGLImageKHR				createImage				(const Library& egl, EGLDisplay dpy, EGLContext ctx, EGLClientBuffer clientBuffer) const;
 
 private:
 	const string			m_message;
@@ -394,7 +419,7 @@
 	void					fail					(void) const { TCU_THROW(NotSupportedError, m_message.c_str()); }
 };
 
-EGLImageKHR	UnsupportedImageSource::createImage (const eglu::ImageFunctions&, EGLDisplay, EGLContext, EGLClientBuffer) const
+EGLImageKHR	UnsupportedImageSource::createImage (const Library&, EGLDisplay, EGLContext, EGLClientBuffer) const
 {
 	fail();
 	return EGL_NO_IMAGE_KHR;
diff --git a/modules/egl/teglImageUtil.hpp b/modules/egl/teglImageUtil.hpp
index 9d13c3e..7a2723c 100644
--- a/modules/egl/teglImageUtil.hpp
+++ b/modules/egl/teglImageUtil.hpp
@@ -32,10 +32,14 @@
 
 #include "egluUtil.hpp"
 #include "egluUnique.hpp"
-#include "egluHeaderWrapper.hpp"
 
 #include "glwDefs.hpp"
 
+namespace eglw
+{
+class Library;
+}
+
 namespace deqp
 {
 namespace egl
@@ -48,19 +52,19 @@
 public:
 										ManagedSurface	(de::MovePtr<eglu::UniqueSurface> surface) : m_surface(surface) {}
 	virtual								~ManagedSurface	(void) {}
-	EGLSurface							get				(void) const { return **m_surface; }
+	eglw::EGLSurface					get				(void) const { return **m_surface; }
 
 private:
 	de::UniquePtr<eglu::UniqueSurface>	m_surface;
 };
 
-de::MovePtr<ManagedSurface> createSurface (EglTestContext& eglTestCtx, EGLConfig config, int width, int height);
+de::MovePtr<ManagedSurface> createSurface (EglTestContext& eglTestCtx, eglw::EGLDisplay display, eglw::EGLConfig config, int width, int height);
 
 class ClientBuffer
 {
 public:
-	virtual					~ClientBuffer	(void) {}
-	virtual EGLClientBuffer	get				(void) const = 0;
+	virtual							~ClientBuffer	(void) {}
+	virtual eglw::EGLClientBuffer	get				(void) const = 0;
 };
 
 class ImageSource
@@ -69,10 +73,10 @@
 	virtual								~ImageSource		(void) {}
 	virtual std::string					getRequiredExtension(void) const = 0;
 	virtual de::MovePtr<ClientBuffer>	createBuffer		(const glw::Functions& gl, tcu::Texture2D* reference = DE_NULL) const = 0;
-	virtual EGLImageKHR					createImage			(const eglu::ImageFunctions& imgExt, EGLDisplay dpy, EGLContext ctx, EGLClientBuffer clientBuffer) const = 0;
+	virtual eglw::EGLImageKHR			createImage			(const eglw::Library& egl, eglw::EGLDisplay dpy, eglw::EGLContext ctx, eglw::EGLClientBuffer clientBuffer) const = 0;
 };
 
-de::MovePtr<ImageSource> createTextureImageSource			(EGLenum source, glw::GLenum format, glw::GLenum type, bool useTexLevel0 = false);
+de::MovePtr<ImageSource> createTextureImageSource			(eglw::EGLenum source, glw::GLenum format, glw::GLenum type, bool useTexLevel0 = false);
 de::MovePtr<ImageSource> createRenderbufferImageSource		(glw::GLenum format);
 de::MovePtr<ImageSource> createUnsupportedImageSource		(const std::string& message);
 
diff --git a/modules/egl/teglInfoTests.cpp b/modules/egl/teglInfoTests.cpp
index 7cd71f6..8ed6daf 100644
--- a/modules/egl/teglInfoTests.cpp
+++ b/modules/egl/teglInfoTests.cpp
@@ -24,44 +24,26 @@
 #include "teglInfoTests.hpp"
 #include "teglConfigList.hpp"
 #include "tcuTestLog.hpp"
+#include "deStringUtil.hpp"
+#include "egluUtil.hpp"
+#include "eglwLibrary.hpp"
+#include "eglwEnums.hpp"
 
 #include <vector>
 #include <string>
 #include <sstream>
 
-#include <EGL/egl.h>
-
-using std::vector;
-using std::string;
-
-using tcu::TestLog;
-
 namespace deqp
 {
 namespace egl
 {
 
-static std::vector<std::string> split(const std::string& str, const std::string& delim = " ")
-{
-	std::vector<std::string>	out;
-	if (str.length() == 0) return out;
+using std::vector;
+using std::string;
+using tcu::TestLog;
+using namespace eglw;
 
-	size_t	start	= 0;
-	size_t	end		= string::npos;
-
-	while ((end = str.find(delim, start)) != string::npos)
-	{
-		out.push_back(str.substr(start, end-start));
-		start = end + delim.length();
-	}
-
-	if (start < end)
-		out.push_back(str.substr(start, end-start));
-
-	return out;
-}
-
-static int toInt(std::string str)
+static int toInt (std::string str)
 {
 	std::istringstream strStream(str);
 
@@ -70,11 +52,38 @@
 	return out;
 }
 
-class QueryStringCase : public TestCase
+class InfoCase : public TestCase
+{
+public:
+	InfoCase (EglTestContext& eglTestCtx, const char* name, const char* description)
+		: TestCase	(eglTestCtx, name, description)
+		, m_display	(EGL_NO_DISPLAY)
+		, m_version	(0, 0)
+	{
+	}
+
+	void init (void)
+	{
+		DE_ASSERT(m_display == EGL_NO_DISPLAY);
+		m_display = eglu::getAndInitDisplay(m_eglTestCtx.getNativeDisplay(), &m_version);
+	}
+
+	void deinit (void)
+	{
+		m_eglTestCtx.getLibrary().terminate(m_display);
+		m_display = EGL_NO_DISPLAY;
+	}
+
+protected:
+	EGLDisplay		m_display;
+	eglu::Version	m_version;
+};
+
+class QueryStringCase : public InfoCase
 {
 public:
 	QueryStringCase (EglTestContext& eglTestCtx, const char* name, const char* description, EGLint query)
-		: TestCase	(eglTestCtx, name, description)
+		: InfoCase	(eglTestCtx, name, description)
 		, m_query	(query)
 	{
 	}
@@ -82,15 +91,14 @@
 	void validateString (const std::string& result)
 	{
 		tcu::TestLog&				log		= m_testCtx.getLog();
-		std::vector<std::string>	tokens	= split(result);
+		std::vector<std::string>	tokens	= de::splitString(result, ' ');
 
 		if (m_query == EGL_VERSION)
 		{
-			const tcu::egl::Display&		display			= m_eglTestCtx.getDisplay();
-			const int						dispMajor		= display.getEGLMajorVersion();
-			const int						dispMinor		= display.getEGLMinorVersion();
+			const int	dispMajor	= m_version.getMajor();
+			const int	dispMinor	= m_version.getMinor();
 
-			const std::vector<std::string>	versionTokens	= split(tokens[0], ".");
+			const std::vector<std::string>	versionTokens	= de::splitString(tokens[0], '.');
 
 			if (versionTokens.size() < 2)
 			{
@@ -114,8 +122,9 @@
 
 	IterateResult iterate (void)
 	{
-		const char* result = eglQueryString(m_eglTestCtx.getDisplay().getEGLDisplay(), m_query);
-		TCU_CHECK_EGL_MSG("eglQueryString() failed");
+		const Library&	egl		= m_eglTestCtx.getLibrary();
+		const char*		result	= egl.queryString(m_display, m_query);
+		EGLU_CHECK_MSG(egl, "eglQueryString() failed");
 
 		m_testCtx.getLog() << tcu::TestLog::Message << result << tcu::TestLog::EndMessage;
 		m_testCtx.setTestResult(QP_TEST_RESULT_PASS, "Pass");
@@ -129,18 +138,18 @@
 	EGLint m_query;
 };
 
-class QueryExtensionsCase : public TestCase
+class QueryExtensionsCase : public InfoCase
 {
 public:
 	QueryExtensionsCase (EglTestContext& eglTestCtx)
-		: TestCase	(eglTestCtx, "extensions", "Supported Extensions")
+		: InfoCase	(eglTestCtx, "extensions", "Supported Extensions")
 	{
 	}
 
 	IterateResult iterate (void)
 	{
-		vector<string> extensions;
-		m_eglTestCtx.getDisplay().getExtensions(extensions);
+		const Library&	egl			= m_eglTestCtx.getLibrary();
+		vector<string>	extensions	= eglu::getClientExtensions(egl, m_display);
 
 		for (vector<string>::const_iterator i = extensions.begin(); i != extensions.end(); i++)
 			m_testCtx.getLog() << tcu::TestLog::Message << *i << tcu::TestLog::EndMessage;
diff --git a/modules/egl/teglMakeCurrentPerfTests.cpp b/modules/egl/teglMakeCurrentPerfTests.cpp
index d7d5ff0..161069e 100644
--- a/modules/egl/teglMakeCurrentPerfTests.cpp
+++ b/modules/egl/teglMakeCurrentPerfTests.cpp
@@ -27,6 +27,9 @@
 #include "egluNativePixmap.hpp"
 #include "egluUtil.hpp"
 
+#include "eglwLibrary.hpp"
+#include "eglwEnums.hpp"
+
 #include "tcuTestLog.hpp"
 
 #include "deRandom.hpp"
@@ -48,6 +51,8 @@
 
 using tcu::TestLog;
 
+using namespace eglw;
+
 namespace deqp
 {
 namespace egl
@@ -88,6 +93,7 @@
 	Spec						m_spec;
 	de::Random					m_rnd;
 
+	EGLDisplay					m_display;
 	EGLConfig					m_config;
 	vector<EGLContext>			m_contexts;
 	vector<EGLSurface>			m_surfaces;
@@ -152,6 +158,7 @@
 	: TestCase		(eglTestCtx, tcu::NODETYPE_PERFORMANCE, name, description)
 	, m_spec		(spec)
 	, m_rnd			(deStringHash(name))
+	, m_display		(EGL_NO_DISPLAY)
 	, m_config		(DE_NULL)
 {
 }
@@ -163,6 +170,8 @@
 
 void MakeCurrentPerfCase::init (void)
 {
+	m_display = eglu::getAndInitDisplay(m_eglTestCtx.getNativeDisplay());
+
 	chooseConfig();
 	createContexts();
 	createSurfaces();
@@ -172,6 +181,9 @@
 {
 	destroyContexts();
 	destroySurfaces();
+
+	m_eglTestCtx.getLibrary().terminate(m_display);
+	m_display = EGL_NO_DISPLAY;
 }
 
 void MakeCurrentPerfCase::chooseConfig (void)
@@ -186,10 +198,10 @@
 		EGL_NONE
 	};
 
-	EGLint		configCount = 0;
-	EGLDisplay	display	= m_eglTestCtx.getDisplay().getEGLDisplay();
+	const Library&	egl			= m_eglTestCtx.getLibrary();
+	EGLint			configCount = 0;
 
-	TCU_CHECK_EGL_CALL(eglChooseConfig(display, attribList, &m_config, 1, &configCount));
+	EGLU_CHECK_CALL(egl, chooseConfig(m_display, attribList, &m_config, 1, &configCount));
 
 	if (configCount <= 0)
 		throw tcu::NotSupportedError("No compatible configs found");
@@ -237,6 +249,7 @@
 
 void MakeCurrentPerfCase::createPBuffer (void)
 {
+	const Library&	egl		= m_eglTestCtx.getLibrary();
 	const EGLint	width	= 256;
 	const EGLint	height	= 256;
 
@@ -246,31 +259,36 @@
 		EGL_NONE
 	};
 
-	EGLDisplay	display	= m_eglTestCtx.getDisplay().getEGLDisplay();
-	EGLSurface	surface = eglCreatePbufferSurface(display, m_config, attribList);
+	EGLSurface	surface = egl.createPbufferSurface(m_display, m_config, attribList);
 
-	TCU_CHECK_EGL_MSG("eglCreatePbufferSurface()");
+	EGLU_CHECK_MSG(egl, "eglCreatePbufferSurface()");
 
 	m_surfaces.push_back(surface);
 }
 
 void MakeCurrentPerfCase::createWindow (void)
 {
-	const EGLint	width	= 256;
-	const EGLint	height	= 256;
+	const Library&						egl				= m_eglTestCtx.getLibrary();
+	const EGLint						width			= 256;
+	const EGLint						height			= 256;
 
-	eglu::NativeWindow* window	= DE_NULL;
-	EGLSurface			surface	= EGL_NO_SURFACE;
+	const eglu::NativeWindowFactory*	windowFactory	= eglu::selectNativeWindowFactory(m_eglTestCtx.getNativeDisplayFactory(), m_testCtx.getCommandLine());
+
+	eglu::NativeWindow* 				window			= DE_NULL;
+	EGLSurface							surface			= EGL_NO_SURFACE;
+
+	if (!windowFactory)
+		TCU_THROW(NotSupportedError, "Windows not supported");
 
 	try
 	{
-		window	= m_eglTestCtx.createNativeWindow(m_eglTestCtx.getDisplay().getEGLDisplay(), m_config, DE_NULL, width, height, eglu::parseWindowVisibility(m_eglTestCtx.getTestContext().getCommandLine()));
-		surface	= eglu::createWindowSurface(m_eglTestCtx.getNativeDisplay(), *window, m_eglTestCtx.getDisplay().getEGLDisplay(), m_config, DE_NULL);
+		window	= windowFactory->createWindow(&m_eglTestCtx.getNativeDisplay(), m_display, m_config, DE_NULL, eglu::WindowParams(width, height, eglu::parseWindowVisibility(m_eglTestCtx.getTestContext().getCommandLine())));
+		surface	= eglu::createWindowSurface(m_eglTestCtx.getNativeDisplay(), *window, m_display, m_config, DE_NULL);
 	}
-	catch (const std::exception&)
+	catch (...)
 	{
 		if (surface != EGL_NO_SURFACE)
-			TCU_CHECK_EGL_CALL(eglDestroySurface(m_eglTestCtx.getDisplay().getEGLDisplay(), surface));
+			egl.destroySurface(m_display, surface);
 
 		delete window;
 		throw;
@@ -282,21 +300,27 @@
 
 void MakeCurrentPerfCase::createPixmap (void)
 {
-	const EGLint	width	= 256;
-	const EGLint	height	= 256;
+	const Library&						egl				= m_eglTestCtx.getLibrary();
+	const EGLint						width			= 256;
+	const EGLint						height			= 256;
 
-	eglu::NativePixmap*	pixmap	= DE_NULL;
-	EGLSurface			surface	= EGL_NO_SURFACE;
+	const eglu::NativePixmapFactory*	pixmapFactory	= eglu::selectNativePixmapFactory(m_eglTestCtx.getNativeDisplayFactory(), m_testCtx.getCommandLine());
+
+	eglu::NativePixmap* 				pixmap			= DE_NULL;
+	EGLSurface							surface			= EGL_NO_SURFACE;
+
+	if (!pixmapFactory)
+		TCU_THROW(NotSupportedError, "Pixmaps not supported");
 
 	try
 	{
-		pixmap	= m_eglTestCtx.createNativePixmap(m_eglTestCtx.getDisplay().getEGLDisplay(), m_config, DE_NULL, width, height);
-		surface	= eglu::createPixmapSurface(m_eglTestCtx.getNativeDisplay(), *pixmap, m_eglTestCtx.getDisplay().getEGLDisplay(), m_config, DE_NULL);
+		pixmap	= pixmapFactory->createPixmap(&m_eglTestCtx.getNativeDisplay(), m_display, m_config, DE_NULL, width, height);
+		surface	= eglu::createPixmapSurface(m_eglTestCtx.getNativeDisplay(), *pixmap, m_display, m_config, DE_NULL);
 	}
-	catch (const std::exception&)
+	catch (...)
 	{
 		if (surface != EGL_NO_SURFACE)
-			TCU_CHECK_EGL_CALL(eglDestroySurface(m_eglTestCtx.getDisplay().getEGLDisplay(), surface));
+			egl.destroySurface(m_display, surface);
 
 		delete pixmap;
 		throw;
@@ -308,15 +332,17 @@
 
 void MakeCurrentPerfCase::destroySurfaces (void)
 {
+	const Library&	egl	= m_eglTestCtx.getLibrary();
+
 	if (m_surfaces.size() > 0)
 	{
-		EGLDisplay display = m_eglTestCtx.getDisplay().getEGLDisplay();
+		EGLDisplay display = m_display;
 
 		// Destroy surfaces
 		for (vector<EGLSurface>::iterator iter = m_surfaces.begin(); iter != m_surfaces.end(); ++iter)
 		{
 			if (*iter != EGL_NO_SURFACE)
-				TCU_CHECK_EGL_CALL(eglDestroySurface(display, *iter));
+				EGLU_CHECK_CALL(egl, destroySurface(display, *iter));
 			*iter = EGL_NO_SURFACE;
 		}
 
@@ -347,7 +373,7 @@
 
 void MakeCurrentPerfCase::createContexts (void)
 {
-	EGLDisplay display = m_eglTestCtx.getDisplay().getEGLDisplay();
+	const Library&	egl	= m_eglTestCtx.getLibrary();
 
 	for (int contextNdx = 0; contextNdx < m_spec.contextCount; contextNdx++)
 	{
@@ -356,9 +382,9 @@
 			EGL_NONE
 		};
 
-		TCU_CHECK_EGL_CALL(eglBindAPI(EGL_OPENGL_ES_API));
-		EGLContext context = eglCreateContext(display, m_config, EGL_NO_CONTEXT, attribList);
-		TCU_CHECK_EGL_MSG("eglCreateContext()");
+		EGLU_CHECK_CALL(egl, bindAPI(EGL_OPENGL_ES_API));
+		EGLContext context = egl.createContext(m_display, m_config, EGL_NO_CONTEXT, attribList);
+		EGLU_CHECK_MSG(egl, "eglCreateContext()");
 
 		m_contexts.push_back(context);
 	}
@@ -366,14 +392,15 @@
 
 void MakeCurrentPerfCase::destroyContexts (void)
 {
+	const Library&	egl	= m_eglTestCtx.getLibrary();
 	if (m_contexts.size() > 0)
 	{
-		EGLDisplay display = m_eglTestCtx.getDisplay().getEGLDisplay();
+		EGLDisplay display = m_display;
 
 		for (vector<EGLContext>::iterator iter = m_contexts.begin(); iter != m_contexts.end(); ++iter)
 		{
 			if (*iter != EGL_NO_CONTEXT)
-				TCU_CHECK_EGL_CALL(eglDestroyContext(display, *iter));
+				EGLU_CHECK_CALL(egl, destroyContext(display, *iter));
 			*iter = EGL_NO_CONTEXT;
 		}
 
@@ -483,11 +510,12 @@
 
 TestCase::IterateResult MakeCurrentPerfCase::iterate (void)
 {
+	const Library&	egl	= m_eglTestCtx.getLibrary();
 	if (m_samples.size() == 0)
 		logTestInfo();
 
 	{
-		EGLDisplay	display		= m_eglTestCtx.getDisplay().getEGLDisplay();
+		EGLDisplay	display		= m_display;
 		deUint64	beginTimeUs	= deGetMicroseconds();
 
 		for (int iteration = 0; iteration < m_spec.iterationCount; iteration++)
@@ -495,13 +523,15 @@
 			EGLContext	context = m_contexts[m_rnd.getUint32() % m_contexts.size()];
 			EGLSurface	surface	= m_surfaces[m_rnd.getUint32() % m_surfaces.size()];
 
-			TCU_CHECK_EGL_CALL(eglMakeCurrent(display, surface, surface, context));
+			egl.makeCurrent(display, surface, surface, context);
 
 			if (m_spec.release)
-				TCU_CHECK_EGL_CALL(eglMakeCurrent(display, EGL_NO_SURFACE, EGL_NO_SURFACE, EGL_NO_CONTEXT));
+				egl.makeCurrent(display, EGL_NO_SURFACE, EGL_NO_SURFACE, EGL_NO_CONTEXT);
 		}
 
 		m_samples.push_back(deGetMicroseconds() - beginTimeUs);
+
+		EGLU_CHECK_MSG(egl, "eglMakeCurrent()");
 	}
 
 	if ((int)m_samples.size() == m_spec.sampleCount)
diff --git a/modules/egl/teglMemoryStressTests.cpp b/modules/egl/teglMemoryStressTests.cpp
index e9ba817..269dcfe 100644
--- a/modules/egl/teglMemoryStressTests.cpp
+++ b/modules/egl/teglMemoryStressTests.cpp
@@ -23,19 +23,23 @@
 
 #include "teglMemoryStressTests.hpp"
 
-#include "gluDefs.hpp"
 #include "tcuTestLog.hpp"
 #include "tcuCommandLine.hpp"
 
 #include "deRandom.hpp"
-
 #include "deClock.h"
 #include "deString.h"
 
+#include "gluDefs.hpp"
 #include "glwFunctions.hpp"
 #include "glwDefs.hpp"
 #include "glwEnums.hpp"
 
+#include "egluUtil.hpp"
+
+#include "eglwLibrary.hpp"
+#include "eglwEnums.hpp"
+
 #include <vector>
 #include <string>
 
@@ -43,6 +47,8 @@
 using std::string;
 using tcu::TestLog;
 
+using namespace eglw;
+
 namespace deqp
 {
 namespace egl
@@ -111,20 +117,20 @@
 	, m_maxHeight	(maxHeight)
 	, m_use			(use)
 {
-	m_eglTestCtx.getGLFunctions(m_gl, glu::ApiType::es(2,0));
+	m_eglTestCtx.initGLFunctions(&m_gl, glu::ApiType::es(2,0));
 }
 
 MemoryAllocator::~MemoryAllocator (void)
 {
+	const Library& egl = m_eglTestCtx.getLibrary();
+
 	for (vector<EGLSurface>::const_iterator iter = m_pbuffers.begin(); iter != m_pbuffers.end(); ++iter)
-		TCU_CHECK_EGL_CALL(eglDestroySurface(m_display, *iter));
+		egl.destroySurface(m_display, *iter);
 
 	m_pbuffers.clear();
 
 	for (vector<EGLContext>::const_iterator iter = m_contexts.begin(); iter != m_contexts.end(); ++iter)
-	{
-		TCU_CHECK_EGL_CALL(eglDestroyContext(m_display, *iter));
-	}
+		egl.destroyContext(m_display, *iter);
 
 	m_contexts.clear();
 }
@@ -190,17 +196,18 @@
 	// Allocate pbuffer
 	try
 	{
-		const EGLint	width	= m_rnd.getInt(m_minWidth, m_maxWidth);
-		const EGLint	height	= m_rnd.getInt(m_minHeight, m_maxHeight);
-
-		const EGLint attribList[] = {
+		const Library&	egl				= m_eglTestCtx.getLibrary();
+		const EGLint	width			= m_rnd.getInt(m_minWidth, m_maxWidth);
+		const EGLint	height			= m_rnd.getInt(m_minHeight, m_maxHeight);
+		const EGLint	attribList[]	=
+		{
 			EGL_WIDTH,	width,
 			EGL_HEIGHT, height,
 			EGL_NONE
 		};
 
-		EGLSurface surface = eglCreatePbufferSurface(m_display, m_config, attribList);
-		TCU_CHECK_EGL_MSG("eglCreatePbufferSurface");
+		EGLSurface		surface			= egl.createPbufferSurface(m_display, m_config, attribList);
+		EGLU_CHECK_MSG(egl, "eglCreatePbufferSurface");
 
 		DE_ASSERT(surface != EGL_NO_SURFACE);
 
@@ -214,7 +221,7 @@
 			const float				blue		= m_rnd.getFloat();
 			const float				alpha		= m_rnd.getFloat();
 
-			TCU_CHECK_EGL_CALL(eglMakeCurrent(m_display, surface, surface, context));
+			EGLU_CHECK_CALL(egl, makeCurrent(m_display, surface, surface, context));
 
 			m_gl.clearColor(red, green, blue, alpha);
 			GLU_EXPECT_NO_ERROR(m_gl.getError(), "glClearColor()");
@@ -222,7 +229,7 @@
 			m_gl.clear(GL_COLOR_BUFFER_BIT);
 			GLU_EXPECT_NO_ERROR(m_gl.getError(), "glClear()");
 
-			TCU_CHECK_EGL_CALL(eglMakeCurrent(m_display, EGL_NO_SURFACE, EGL_NO_SURFACE, EGL_NO_CONTEXT));
+			EGLU_CHECK_CALL(egl, makeCurrent(m_display, EGL_NO_SURFACE, EGL_NO_SURFACE, EGL_NO_CONTEXT));
 		}
 	}
 	catch (const eglu::Error& error)
@@ -255,14 +262,16 @@
 	// Allocate context
 	try
 	{
-		const EGLint attribList[] = {
+		const Library&	egl				= m_eglTestCtx.getLibrary();
+		const EGLint	attribList[]	=
+		{
 			EGL_CONTEXT_CLIENT_VERSION, 2,
 			EGL_NONE
 		};
 
-		TCU_CHECK_EGL_CALL(eglBindAPI(EGL_OPENGL_ES_API));
-		EGLContext context = eglCreateContext(m_display, m_config, EGL_NO_CONTEXT, attribList);
-		TCU_CHECK_EGL_MSG("eglCreateContext");
+		EGLU_CHECK_CALL(egl, bindAPI(EGL_OPENGL_ES_API));
+		EGLContext context = egl.createContext(m_display, m_config, EGL_NO_CONTEXT, attribList);
+		EGLU_CHECK_MSG(egl, "eglCreateContext");
 
 		DE_ASSERT(context != EGL_NO_CONTEXT);
 
@@ -276,7 +285,7 @@
 			const float				blue		= m_rnd.getFloat();
 			const float				alpha		= m_rnd.getFloat();
 
-			TCU_CHECK_EGL_CALL(eglMakeCurrent(m_display, surface, surface, context));
+			EGLU_CHECK_CALL(egl, makeCurrent(m_display, surface, surface, context));
 
 			m_gl.clearColor(red, green, blue, alpha);
 			GLU_EXPECT_NO_ERROR(m_gl.getError(), "glClearColor()");
@@ -284,7 +293,7 @@
 			m_gl.clear(GL_COLOR_BUFFER_BIT);
 			GLU_EXPECT_NO_ERROR(m_gl.getError(), "glClear()");
 
-			TCU_CHECK_EGL_CALL(eglMakeCurrent(m_display, EGL_NO_SURFACE, EGL_NO_SURFACE, EGL_NO_CONTEXT));
+			EGLU_CHECK_CALL(egl, makeCurrent(m_display, EGL_NO_SURFACE, EGL_NO_SURFACE, EGL_NO_CONTEXT));
 		}
 	}
 	catch (const eglu::Error& error)
@@ -346,8 +355,10 @@
 
 void MemoryStressCase::init (void)
 {
-	EGLint			configCount = 0;
-	const EGLint	attribList[] = {
+	const Library&	egl				= m_eglTestCtx.getLibrary();
+	EGLint			configCount		= 0;
+	const EGLint	attribList[]	=
+	{
 		EGL_SURFACE_TYPE,		EGL_PBUFFER_BIT,
 		EGL_RENDERABLE_TYPE,	EGL_OPENGL_ES2_BIT,
 		EGL_NONE
@@ -359,9 +370,9 @@
 		throw tcu::NotSupportedError("OOM tests disabled");
 	}
 
-	m_display = m_eglTestCtx.getDisplay().getEGLDisplay();
+	m_display = eglu::getAndInitDisplay(m_eglTestCtx.getNativeDisplay());
 
-	TCU_CHECK_EGL_CALL(eglChooseConfig(m_display, attribList, &m_config, 1, &configCount));
+	EGLU_CHECK_CALL(egl, chooseConfig(m_display, attribList, &m_config, 1, &configCount));
 
 	TCU_CHECK(configCount != 0);
 }
@@ -370,6 +381,12 @@
 {
 	delete m_allocator;
 	m_allocator = DE_NULL;
+
+	if (m_display != EGL_NO_DISPLAY)
+	{
+		m_eglTestCtx.getLibrary().terminate(m_display);
+		m_display = EGL_NO_DISPLAY;
+	}
 }
 
 TestCase::IterateResult MemoryStressCase::iterate (void)
diff --git a/modules/egl/teglMultiThreadTests.cpp b/modules/egl/teglMultiThreadTests.cpp
index 8ccffbc..4a0b44b 100644
--- a/modules/egl/teglMultiThreadTests.cpp
+++ b/modules/egl/teglMultiThreadTests.cpp
@@ -38,6 +38,9 @@
 #include "deAtomic.h"
 #include "deClock.h"
 
+#include "eglwLibrary.hpp"
+#include "eglwEnums.hpp"
+
 #include <vector>
 #include <string>
 #include <sstream>
@@ -47,6 +50,8 @@
 using std::pair;
 using std::ostringstream;
 
+using namespace eglw;
+
 namespace deqp
 {
 namespace egl
@@ -118,6 +123,7 @@
 
 	void			setStatus	(ThreadStatus status)	{ m_status = status; }
 
+	const Library&	getLibrary	(void) const;
 
 	// Test has stopped
 	class TestStop {};
@@ -135,12 +141,16 @@
 public:
 							MultiThreadedTest	(EglTestContext& eglTestCtx, const char* name, const char* description, int threadCount, deUint64 timeoutUs);
 	virtual					~MultiThreadedTest	(void);
-	virtual void			deinit				(void) {}
+
+	void					init				(void);
+	void					deinit				(void);
 
 	virtual bool			runThread			(TestThread& thread) = 0;
 	virtual IterateResult	iterate				(void);
 	bool					execTest			(TestThread& thread);
 
+	const Library&			getLibrary			(void) const { return m_eglTestCtx.getLibrary(); }
+
 protected:
 	void					barrier				(TestThread& thread);
 
@@ -154,8 +164,16 @@
 	volatile deInt32		m_barrierWaiters;
 	de::Semaphore			m_barrierSemaphore1;
 	de::Semaphore			m_barrierSemaphore2;
+
+protected:
+	EGLDisplay				m_display;
 };
 
+inline const Library& TestThread::getLibrary (void) const
+{
+	return m_test.getLibrary();
+}
+
 TestThread::TestThread (MultiThreadedTest& test, int id)
 	: m_test	(test)
 	, m_id		(id)
@@ -249,6 +267,8 @@
 	, m_barrierWaiters		(0)
 	, m_barrierSemaphore1	(0, 0)
 	, m_barrierSemaphore2	(1, 0)
+
+	, m_display				(EGL_NO_DISPLAY)
 {
 }
 
@@ -259,6 +279,17 @@
 	m_threads.clear();
 }
 
+void MultiThreadedTest::init (void)
+{
+	m_display = eglu::getAndInitDisplay(m_eglTestCtx.getNativeDisplay());
+}
+
+void MultiThreadedTest::deinit (void)
+{
+	m_eglTestCtx.getLibrary().terminate(m_display);
+	m_display = EGL_NO_DISPLAY;
+}
+
 void MultiThreadedTest::barrier (TestThread& thread)
 {
 	{
@@ -498,7 +529,6 @@
 	bool		runThread					(TestThread& thread);
 
 private:
-	EGLDisplay	m_display;
 	const int	m_getConfigs;
 	const int	m_chooseConfigs;
 	const int	m_query;
@@ -506,7 +536,6 @@
 
 MultiThreadedConfigTest::MultiThreadedConfigTest (EglTestContext& context, const char* name, const char* description, int getConfigs, int chooseConfigs, int query)
 	: MultiThreadedTest (context, name, description, 2, 20000000/*us = 20s*/) // \todo [mika] Set timeout to something relevant to frameworks timeout?
-	, m_display			(EGL_NO_DISPLAY)
 	, m_getConfigs		(getConfigs)
 	, m_chooseConfigs	(chooseConfigs)
 	, m_query			(query)
@@ -515,12 +544,10 @@
 
 bool MultiThreadedConfigTest::runThread (TestThread& thread)
 {
-	de::Random			rnd(deInt32Hash(thread.getId() + 10435));
+	const Library&		egl		= getLibrary();
+	de::Random			rnd		(deInt32Hash(thread.getId() + 10435));
 	vector<EGLConfig>	configs;
 
-	if (thread.getId() == 0)
-		m_display = m_eglTestCtx.getDisplay().getEGLDisplay();
-
 	barrier(thread);
 
 	for (int getConfigsNdx = 0; getConfigsNdx < m_getConfigs; getConfigsNdx++)
@@ -531,9 +558,9 @@
 		{
 			EGLBoolean result;
 
-			result = eglGetConfigs(m_display, NULL, 0, &configCount);
+			result = egl.getConfigs(m_display, NULL, 0, &configCount);
 			thread.getLog() << ThreadLog::BeginMessage << result << " = eglGetConfigs(" << m_display << ", NULL, 0, " << configCount << ")" <<  ThreadLog::EndMessage;
-			TCU_CHECK_EGL_MSG("eglGetConfigs()");
+			EGLU_CHECK_MSG(egl, "eglGetConfigs()");
 
 			if (!result)
 				return false;
@@ -546,9 +573,9 @@
 		{
 			EGLBoolean result;
 
-			result = eglGetConfigs(m_display, &(configs[configs.size() - configCount]), configCount, &configCount);
+			result = egl.getConfigs(m_display, &(configs[configs.size() - configCount]), configCount, &configCount);
 			thread.getLog() << ThreadLog::BeginMessage << result << " = eglGetConfigs(" << m_display << ", &configs' " << configCount << ", " << configCount << ")" <<  ThreadLog::EndMessage;
-			TCU_CHECK_EGL_MSG("eglGetConfigs()");
+			EGLU_CHECK_MSG(egl, "eglGetConfigs()");
 
 			if (!result)
 				return false;
@@ -579,9 +606,9 @@
 		{
 			EGLBoolean result;
 
-			result = eglChooseConfig(m_display, attribList, NULL, 0, &configCount);
+			result = egl.chooseConfig(m_display, attribList, NULL, 0, &configCount);
 			thread.getLog() << ThreadLog::BeginMessage << result << " = eglChooseConfig(" << m_display << ", { EGL_NONE }, NULL, 0, " << configCount << ")" <<  ThreadLog::EndMessage;
-			TCU_CHECK_EGL_MSG("eglChooseConfig()");
+			EGLU_CHECK_MSG(egl, "eglChooseConfig()");
 
 			if (!result)
 				return false;
@@ -594,9 +621,9 @@
 		{
 			EGLBoolean result;
 
-			result = eglChooseConfig(m_display, attribList, &(configs[configs.size() - configCount]), configCount, &configCount);
+			result = egl.chooseConfig(m_display, attribList, &(configs[configs.size() - configCount]), configCount, &configCount);
 			thread.getLog() << ThreadLog::BeginMessage << result << " = eglChooseConfig(" << m_display << ", { EGL_NONE }, &configs, " << configCount << ", " << configCount << ")" <<  ThreadLog::EndMessage;
-			TCU_CHECK_EGL_MSG("eglChooseConfig()");
+			EGLU_CHECK_MSG(egl, "eglChooseConfig()");
 
 			if (!result)
 				return false;
@@ -660,9 +687,9 @@
 			EGLint			value;
 			EGLBoolean		result;
 
-			result = eglGetConfigAttrib(m_display, config, attribute, &value);
+			result = egl.getConfigAttrib(m_display, config, attribute, &value);
 			thread.getLog() << ThreadLog::BeginMessage << result << " = eglGetConfigAttrib(" << m_display << ", " << config << ", " << configAttributeToString(attribute) << ", " << value << ")" <<  ThreadLog::EndMessage;
-			TCU_CHECK_EGL_MSG("eglGetConfigAttrib()");
+			EGLU_CHECK_MSG(egl, "eglGetConfigAttrib()");
 
 			if (!result)
 				return false;
@@ -698,7 +725,6 @@
 	void			destroyObjects					(TestThread& thread);
 
 private:
-	EGLDisplay			m_display;
 	EGLConfig			m_config;
 	de::Random			m_rnd0;
 	de::Random			m_rnd1;
@@ -725,7 +751,6 @@
 
 MultiThreadedObjectTest::MultiThreadedObjectTest (EglTestContext& context, const char* name, const char* description, deUint32 type)
 	: MultiThreadedTest (context, name, description, 2, 20000000/*us = 20s*/) // \todo [mika] Set timeout to something relevant to frameworks timeout?
-	, m_display			(EGL_NO_DISPLAY)
 	, m_config			(DE_NULL)
 	, m_rnd0			(58204327)
 	, m_rnd1			(230983)
@@ -741,13 +766,15 @@
 
 void MultiThreadedObjectTest::deinit (void)
 {
+	const Library&		egl		= getLibrary();
+
 	// Clear pbuffers
 	for (int pbufferNdx = 0; pbufferNdx < (int)m_pbuffers0.size(); pbufferNdx++)
 	{
 		if (m_pbuffers0[pbufferNdx] != EGL_NO_SURFACE)
 		{
-			eglDestroySurface(m_display, m_pbuffers0[pbufferNdx]);
-			TCU_CHECK_EGL_MSG("eglDestroySurface()");
+			egl.destroySurface(m_display, m_pbuffers0[pbufferNdx]);
+			EGLU_CHECK_MSG(egl, "eglDestroySurface()");
 			m_pbuffers0[pbufferNdx] = EGL_NO_SURFACE;
 		}
 	}
@@ -757,8 +784,8 @@
 	{
 		if (m_pbuffers1[pbufferNdx] != EGL_NO_SURFACE)
 		{
-			eglDestroySurface(m_display, m_pbuffers1[pbufferNdx]);
-			TCU_CHECK_EGL_MSG("eglDestroySurface()");
+			egl.destroySurface(m_display, m_pbuffers1[pbufferNdx]);
+			EGLU_CHECK_MSG(egl, "eglDestroySurface()");
 			m_pbuffers1[pbufferNdx] = EGL_NO_SURFACE;
 		}
 	}
@@ -768,8 +795,8 @@
 	{
 		if (m_sharedPbuffers[pbufferNdx] != EGL_NO_SURFACE)
 		{
-			eglDestroySurface(m_display, m_sharedPbuffers[pbufferNdx]);
-			TCU_CHECK_EGL_MSG("eglDestroySurface()");
+			egl.destroySurface(m_display, m_sharedPbuffers[pbufferNdx]);
+			EGLU_CHECK_MSG(egl, "eglDestroySurface()");
 			m_sharedPbuffers[pbufferNdx] = EGL_NO_SURFACE;
 		}
 	}
@@ -779,8 +806,8 @@
 	{
 		if (m_sharedContexts[contextNdx] != EGL_NO_CONTEXT)
 		{
-			eglDestroyContext(m_display, m_sharedContexts[contextNdx]);
-			TCU_CHECK_EGL_MSG("eglDestroyContext()");
+			egl.destroyContext(m_display, m_sharedContexts[contextNdx]);
+			EGLU_CHECK_MSG(egl, "eglDestroyContext()");
 			m_sharedContexts[contextNdx] =  EGL_NO_CONTEXT;
 		}
 	}
@@ -790,8 +817,8 @@
 	{
 		if (m_contexts0[contextNdx] != EGL_NO_CONTEXT)
 		{
-			eglDestroyContext(m_display, m_contexts0[contextNdx]);
-			TCU_CHECK_EGL_MSG("eglDestroyContext()");
+			egl.destroyContext(m_display, m_contexts0[contextNdx]);
+			EGLU_CHECK_MSG(egl, "eglDestroyContext()");
 			m_contexts0[contextNdx] =  EGL_NO_CONTEXT;
 		}
 	}
@@ -801,8 +828,8 @@
 	{
 		if (m_contexts1[contextNdx] != EGL_NO_CONTEXT)
 		{
-			eglDestroyContext(m_display, m_contexts1[contextNdx]);
-			TCU_CHECK_EGL_MSG("eglDestroyContext()");
+			egl.destroyContext(m_display, m_contexts1[contextNdx]);
+			EGLU_CHECK_MSG(egl, "eglDestroyContext()");
 			m_contexts1[contextNdx] =  EGL_NO_CONTEXT;
 		}
 	}
@@ -812,7 +839,7 @@
 	for (int pixmapNdx = 0; pixmapNdx < (int)m_nativePixmaps0.size(); pixmapNdx++)	
 	{
 		if (m_nativePixmaps0[pixmapNdx].second != EGL_NO_SURFACE)
-			TCU_CHECK_EGL_CALL(eglDestroySurface(m_display, m_nativePixmaps0[pixmapNdx].second));
+			EGLU_CHECK_CALL(egl, destroySurface(m_display, m_nativePixmaps0[pixmapNdx].second));
 
 		m_nativePixmaps0[pixmapNdx].second = EGL_NO_SURFACE;
 		delete m_nativePixmaps0[pixmapNdx].first;
@@ -823,7 +850,7 @@
 	for (int pixmapNdx = 0; pixmapNdx < (int)m_nativePixmaps1.size(); pixmapNdx++)
 	{
 		if (m_nativePixmaps1[pixmapNdx].second != EGL_NO_SURFACE)
-			TCU_CHECK_EGL_CALL(eglDestroySurface(m_display, m_nativePixmaps1[pixmapNdx].second));
+			EGLU_CHECK_CALL(egl, destroySurface(m_display, m_nativePixmaps1[pixmapNdx].second));
 
 		m_nativePixmaps1[pixmapNdx].second = EGL_NO_SURFACE;
 		delete m_nativePixmaps1[pixmapNdx].first;
@@ -834,7 +861,7 @@
 	for (int pixmapNdx = 0; pixmapNdx < (int)m_sharedNativePixmaps.size(); pixmapNdx++)
 	{
 		if (m_sharedNativePixmaps[pixmapNdx].second != EGL_NO_SURFACE)
-			TCU_CHECK_EGL_CALL(eglDestroySurface(m_display, m_sharedNativePixmaps[pixmapNdx].second));
+			EGLU_CHECK_CALL(egl, destroySurface(m_display, m_sharedNativePixmaps[pixmapNdx].second));
 
 		m_sharedNativePixmaps[pixmapNdx].second = EGL_NO_SURFACE;
 		delete m_sharedNativePixmaps[pixmapNdx].first;
@@ -846,7 +873,7 @@
 	for (int windowNdx = 0; windowNdx < (int)m_nativeWindows1.size(); windowNdx++)
 	{
 		if (m_nativeWindows1[windowNdx].second != EGL_NO_SURFACE)
-			TCU_CHECK_EGL_CALL(eglDestroySurface(m_display, m_nativeWindows1[windowNdx].second));
+			EGLU_CHECK_CALL(egl, destroySurface(m_display, m_nativeWindows1[windowNdx].second));
 
 		m_nativeWindows1[windowNdx].second = EGL_NO_SURFACE;
 		delete m_nativeWindows1[windowNdx].first;
@@ -857,7 +884,7 @@
 	for (int windowNdx = 0; windowNdx < (int)m_nativeWindows0.size(); windowNdx++)
 	{
 		if (m_nativeWindows0[windowNdx].second != EGL_NO_SURFACE)
-			TCU_CHECK_EGL_CALL(eglDestroySurface(m_display, m_nativeWindows0[windowNdx].second));
+			EGLU_CHECK_CALL(egl, destroySurface(m_display, m_nativeWindows0[windowNdx].second));
 
 		m_nativeWindows0[windowNdx].second = EGL_NO_SURFACE;
 		delete m_nativeWindows0[windowNdx].first;
@@ -868,21 +895,23 @@
 	for (int windowNdx = 0; windowNdx < (int)m_sharedNativeWindows.size(); windowNdx++)
 	{
 		if (m_sharedNativeWindows[windowNdx].second != EGL_NO_SURFACE)
-			TCU_CHECK_EGL_CALL(eglDestroySurface(m_display, m_sharedNativeWindows[windowNdx].second));
+			EGLU_CHECK_CALL(egl, destroySurface(m_display, m_sharedNativeWindows[windowNdx].second));
 
 		m_sharedNativeWindows[windowNdx].second = EGL_NO_SURFACE;
 		delete m_sharedNativeWindows[windowNdx].first;
 		m_sharedNativeWindows[windowNdx].first = NULL;
 	}
 	m_sharedNativeWindows.clear();
+
+	MultiThreadedTest::deinit();
 }
 
 bool MultiThreadedObjectTest::runThread (TestThread& thread)
 {
+	const Library&		egl		= getLibrary();
+
 	if (thread.getId() == 0)
 	{
-		m_display = m_eglTestCtx.getDisplay().getEGLDisplay();
-
 		EGLint surfaceTypes = 0;
 
 		if ((m_types & TYPE_WINDOW) != 0)
@@ -902,10 +931,10 @@
 			EGL_NONE
 		};
 
-		TCU_CHECK_EGL_CALL(eglChooseConfig(m_display, attribList, &m_config, 1, &configCount));
+		EGLU_CHECK_CALL(egl, chooseConfig(m_display, attribList, &m_config, 1, &configCount));
 
 		if (configCount == 0)
-			throw tcu::NotSupportedError("No usable config found", "", __FILE__, __LINE__);
+			TCU_THROW(NotSupportedError, "No usable config found");
 	}
 
 	barrier(thread);
@@ -960,6 +989,7 @@
 
 void MultiThreadedObjectTest::createDestroyObjects (TestThread& thread, int count)
 {
+	const Library&									egl			= getLibrary();
 	de::Random&										rnd			= (thread.getId() == 0 ? m_rnd0 : m_rnd1);
 	vector<EGLSurface>&								pbuffers	= (thread.getId() == 0 ? m_pbuffers0 : m_pbuffers1);
 	vector<pair<eglu::NativeWindow*, EGLSurface> >&	windows		= (thread.getId() == 0 ? m_nativeWindows0 : m_nativeWindows1);
@@ -1052,9 +1082,9 @@
 						EGL_NONE
 					};
 
-					surface = eglCreatePbufferSurface(m_display, m_config, attributes);
+					surface = egl.createPbufferSurface(m_display, m_config, attributes);
 					thread.getLog() << ThreadLog::BeginMessage << surface << " = eglCreatePbufferSurface(" << m_display << ", " << m_config << ", { EGL_WIDTH, 64, EGL_HEIGHT, 64, EGL_NONE })" << ThreadLog::EndMessage;
-					TCU_CHECK_EGL_MSG("eglCreatePbufferSurface()");
+					EGLU_CHECK_MSG(egl, "eglCreatePbufferSurface()");
 
 					pbuffers.push_back(surface);
 
@@ -1063,6 +1093,11 @@
 
 				case TYPE_WINDOW:
 				{
+					const eglu::NativeWindowFactory*	windowFactory	= eglu::selectNativeWindowFactory(m_eglTestCtx.getNativeDisplayFactory(), m_testCtx.getCommandLine());
+
+					if (!windowFactory)
+						TCU_THROW(NotSupportedError, "Windows nos supported");
+
 					if ((m_types & TYPE_SINGLE_WINDOW) != 0)
 					{
 						if (deAtomicCompareExchange32(&m_hasWindow, 0, 1) == 0)
@@ -1072,8 +1107,8 @@
 
 							try
 							{
-								window = m_eglTestCtx.createNativeWindow(m_eglTestCtx.getDisplay().getEGLDisplay(), m_config, DE_NULL, 64, 64, eglu::parseWindowVisibility(m_testCtx.getCommandLine()));
-								surface = eglu::createWindowSurface(m_eglTestCtx.getNativeDisplay(), *window, m_eglTestCtx.getDisplay().getEGLDisplay(), m_config, DE_NULL);
+								window = windowFactory->createWindow(&m_eglTestCtx.getNativeDisplay(), m_display, m_config, DE_NULL, eglu::WindowParams(64, 64, eglu::parseWindowVisibility(m_testCtx.getCommandLine())));
+								surface = eglu::createWindowSurface(m_eglTestCtx.getNativeDisplay(), *window, m_display, m_config, DE_NULL);
 
 								thread.getLog() << ThreadLog::BeginMessage << surface << " = eglCreateWindowSurface()" << ThreadLog::EndMessage;
 								windows.push_back(std::make_pair(window, surface));
@@ -1081,7 +1116,7 @@
 							catch (const std::exception&)
 							{
 								if (surface != EGL_NO_SURFACE)
-									TCU_CHECK_EGL_CALL(eglDestroySurface(m_display, surface));
+									EGLU_CHECK_CALL(egl, destroySurface(m_display, surface));
 								delete window;
 								throw;
 							}
@@ -1098,8 +1133,8 @@
 
 						try
 						{
-							window	= m_eglTestCtx.createNativeWindow(m_eglTestCtx.getDisplay().getEGLDisplay(), m_config, DE_NULL, 64, 64, eglu::parseWindowVisibility(m_testCtx.getCommandLine()));
-							surface	= eglu::createWindowSurface(m_eglTestCtx.getNativeDisplay(), *window, m_eglTestCtx.getDisplay().getEGLDisplay(), m_config, DE_NULL);
+							window	= windowFactory->createWindow(&m_eglTestCtx.getNativeDisplay(), m_display, m_config, DE_NULL, eglu::WindowParams(64, 64, eglu::parseWindowVisibility(m_testCtx.getCommandLine())));
+							surface	= eglu::createWindowSurface(m_eglTestCtx.getNativeDisplay(), *window, m_display, m_config, DE_NULL);
 
 							thread.getLog() << ThreadLog::BeginMessage << surface << " = eglCreateWindowSurface()" << ThreadLog::EndMessage;
 							windows.push_back(std::make_pair(window, surface));
@@ -1107,7 +1142,7 @@
 						catch (const std::exception&)
 						{
 							if (surface != EGL_NO_SURFACE)
-								TCU_CHECK_EGL_CALL(eglDestroySurface(m_display, surface));
+								EGLU_CHECK_CALL(egl, destroySurface(m_display, surface));
 							delete window;
 							throw;
 						}
@@ -1117,13 +1152,14 @@
 
 				case TYPE_PIXMAP:
 				{
-					eglu::NativePixmap* pixmap	= DE_NULL;
-					EGLSurface			surface	= EGL_NO_SURFACE;
+					const eglu::NativePixmapFactory*	pixmapFactory	= eglu::selectNativePixmapFactory(m_eglTestCtx.getNativeDisplayFactory(), m_testCtx.getCommandLine());
+					eglu::NativePixmap* 				pixmap			= DE_NULL;
+					EGLSurface							surface			= EGL_NO_SURFACE;
 
 					try
 					{
-						pixmap	= m_eglTestCtx.createNativePixmap(m_eglTestCtx.getDisplay().getEGLDisplay(), m_config, DE_NULL, 64, 64);
-						surface	= eglu::createPixmapSurface(m_eglTestCtx.getNativeDisplay(), *pixmap, m_eglTestCtx.getDisplay().getEGLDisplay(), m_config, DE_NULL);
+						pixmap	= pixmapFactory->createPixmap(&m_eglTestCtx.getNativeDisplay(), m_display, m_config, DE_NULL, 64, 64);
+						surface	= eglu::createPixmapSurface(m_eglTestCtx.getNativeDisplay(), *pixmap, m_display, m_config, DE_NULL);
 
 						thread.getLog() << ThreadLog::BeginMessage << surface << " = eglCreatePixmapSurface()" << ThreadLog::EndMessage;
 						pixmaps.push_back(std::make_pair(pixmap, surface));
@@ -1131,7 +1167,7 @@
 					catch (const std::exception&)
 					{
 						if (surface != EGL_NO_SURFACE)
-							TCU_CHECK_EGL_CALL(eglDestroySurface(m_display, surface));
+							EGLU_CHECK_CALL(egl, destroySurface(m_display, surface));
 						delete pixmap;
 						throw;
 					}
@@ -1142,7 +1178,7 @@
 				{
 					EGLContext context;
 
-					TCU_CHECK_EGL_CALL(eglBindAPI(EGL_OPENGL_ES_API));
+					EGLU_CHECK_CALL(egl, bindAPI(EGL_OPENGL_ES_API));
 					thread.getLog() << ThreadLog::BeginMessage << "eglBindAPI(EGL_OPENGL_ES_API)" << ThreadLog::EndMessage;
 
 					const EGLint attributes[] =
@@ -1151,9 +1187,9 @@
 						EGL_NONE
 					};
 
-					context = eglCreateContext(m_display, m_config, EGL_NO_CONTEXT, attributes);
+					context = egl.createContext(m_display, m_config, EGL_NO_CONTEXT, attributes);
 					thread.getLog() << ThreadLog::BeginMessage << context << " = eglCreateContext(" << m_display << ", " << m_config << ", EGL_NO_CONTEXT, { EGL_CONTEXT_CLIENT_VERSION, 2, EGL_NONE })" << ThreadLog::EndMessage;
-					TCU_CHECK_EGL_MSG("eglCreateContext()");
+					EGLU_CHECK_MSG(egl, "eglCreateContext()");
 					contexts.push_back(context);
 					break;
 				}
@@ -1171,9 +1207,9 @@
 					const int pbufferNdx = rnd.getInt(0, (int)(pbuffers.size()-1));
 					EGLBoolean result;
 
-					result = eglDestroySurface(m_display, pbuffers[pbufferNdx]);
+					result = egl.destroySurface(m_display, pbuffers[pbufferNdx]);
 					thread.getLog() << ThreadLog::BeginMessage << result << " = eglDestroySurface(" << m_display << ", " << pbuffers[pbufferNdx] << ")" << ThreadLog::EndMessage;
-					TCU_CHECK_EGL_MSG("eglDestroySurface()");
+					EGLU_CHECK_MSG(egl, "eglDestroySurface()");
 
 					pbuffers.erase(pbuffers.begin() + pbufferNdx);
 
@@ -1186,7 +1222,7 @@
 
 					thread.getLog() << ThreadLog::BeginMessage << "eglDestroySurface(" << m_display << ", " << windows[windowNdx].second << ")" << ThreadLog::EndMessage;
 
-					TCU_CHECK_EGL_CALL(eglDestroySurface(m_display, windows[windowNdx].second));
+					EGLU_CHECK_CALL(egl, destroySurface(m_display, windows[windowNdx].second));
 					windows[windowNdx].second = EGL_NO_SURFACE;
 					delete windows[windowNdx].first;
 					windows[windowNdx].first = DE_NULL;
@@ -1203,7 +1239,7 @@
 					const int pixmapNdx = rnd.getInt(0, (int)(pixmaps.size()-1));
 
 					thread.getLog() << ThreadLog::BeginMessage << "eglDestroySurface(" << m_display << ", " << pixmaps[pixmapNdx].second << ")" << ThreadLog::EndMessage;
-					TCU_CHECK_EGL_CALL(eglDestroySurface(m_display, pixmaps[pixmapNdx].second));
+					EGLU_CHECK_CALL(egl, destroySurface(m_display, pixmaps[pixmapNdx].second));
 					pixmaps[pixmapNdx].second = EGL_NO_SURFACE;
 					delete pixmaps[pixmapNdx].first;
 					pixmaps[pixmapNdx].first = DE_NULL;
@@ -1216,7 +1252,7 @@
 				{
 					const int contextNdx = rnd.getInt(0, (int)(contexts.size()-1));
 
-					TCU_CHECK_EGL_CALL(eglDestroyContext(m_display, contexts[contextNdx]));
+					EGLU_CHECK_CALL(egl, destroyContext(m_display, contexts[contextNdx]));
 					thread.getLog() << ThreadLog::BeginMessage << "eglDestroyContext(" << m_display << ", " << contexts[contextNdx]  << ")" << ThreadLog::EndMessage;
 					contexts.erase(contexts.begin() + contextNdx);
 
@@ -1302,8 +1338,9 @@
 
 void MultiThreadedObjectTest::querySetSharedObjects (TestThread& thread, int count)
 {
-	de::Random& rnd = (thread.getId() == 0 ? m_rnd0 : m_rnd1);
-	vector<Type> objectTypes;
+	const Library&		egl		= getLibrary();
+	de::Random&			rnd		= (thread.getId() == 0 ? m_rnd0 : m_rnd1);
+	vector<Type>		objectTypes;
 
 	if ((m_types & TYPE_PBUFFER) != 0)
 		objectTypes.push_back(TYPE_PBUFFER);
@@ -1358,9 +1395,9 @@
 			EGLBoolean		result;
 			EGLint			value;
 
-			result = eglQuerySurface(m_display, surface, attribute, &value);
+			result = egl.querySurface(m_display, surface, attribute, &value);
 			thread.getLog() << ThreadLog::BeginMessage << result << " = eglQuerySurface(" << m_display << ", " << surface << ", " << attribute << ", " << value << ")" << ThreadLog::EndMessage;
-			TCU_CHECK_EGL_MSG("eglQuerySurface()");
+			EGLU_CHECK_MSG(egl, "eglQuerySurface()");
 
 		}
 		else if (context != EGL_NO_CONTEXT)
@@ -1377,9 +1414,9 @@
 			EGLint			value;
 			EGLBoolean		result;
 
-			result = eglQueryContext(m_display, context, attribute, &value);
+			result = egl.queryContext(m_display, context, attribute, &value);
 			thread.getLog() << ThreadLog::BeginMessage << result << " = eglQueryContext(" << m_display << ", " << context << ", " << attribute << ", " << value << ")" << ThreadLog::EndMessage;
-			TCU_CHECK_EGL_MSG("eglQueryContext()");
+			EGLU_CHECK_MSG(egl, "eglQueryContext()");
 
 		}
 		else
@@ -1389,6 +1426,7 @@
 
 void MultiThreadedObjectTest::destroyObjects (TestThread& thread)
 {
+	const Library&										egl			= getLibrary();
 	vector<EGLSurface>&									pbuffers	= (thread.getId() == 0 ? m_pbuffers0 : m_pbuffers1);
 	vector<pair<eglu::NativeWindow*, EGLSurface> >&		windows		= (thread.getId() == 0 ? m_nativeWindows0 : m_nativeWindows1);
 	vector<pair<eglu::NativePixmap*, EGLSurface> >&		pixmaps		= (thread.getId() == 0 ? m_nativePixmaps0 : m_nativePixmaps1);
@@ -1401,9 +1439,9 @@
 			// Destroy EGLSurface
 			EGLBoolean result;
 
-			result = eglDestroySurface(m_display, pbuffers[pbufferNdx]);
+			result = egl.destroySurface(m_display, pbuffers[pbufferNdx]);
 			thread.getLog() << ThreadLog::BeginMessage << result << " = eglDestroySurface(" << m_display << ", " << pbuffers[pbufferNdx] << ")" << ThreadLog::EndMessage;
-			TCU_CHECK_EGL_MSG("eglDestroySurface()");
+			EGLU_CHECK_MSG(egl, "eglDestroySurface()");
 			pbuffers[pbufferNdx] = EGL_NO_SURFACE;
 		}
 	}
@@ -1414,7 +1452,7 @@
 		if (windows[windowNdx].second != EGL_NO_SURFACE)
 		{
 			thread.getLog() << ThreadLog::BeginMessage << "eglDestroySurface(" << m_display << ", " << windows[windowNdx].second << ")" << ThreadLog::EndMessage;
-			TCU_CHECK_EGL_CALL(eglDestroySurface(m_display, windows[windowNdx].second));
+			EGLU_CHECK_CALL(egl, destroySurface(m_display, windows[windowNdx].second));
 			windows[windowNdx].second = EGL_NO_SURFACE;
 		}
 
@@ -1431,7 +1469,7 @@
 		if (pixmaps[pixmapNdx].first != EGL_NO_SURFACE)
 		{
 			thread.getLog() << ThreadLog::BeginMessage << "eglDestroySurface(" << m_display << ", " << pixmaps[pixmapNdx].second << ")" << ThreadLog::EndMessage;
-			TCU_CHECK_EGL_CALL(eglDestroySurface(m_display, pixmaps[pixmapNdx].second));
+			EGLU_CHECK_CALL(egl, destroySurface(m_display, pixmaps[pixmapNdx].second));
 			pixmaps[pixmapNdx].second = EGL_NO_SURFACE;
 		}
 
@@ -1447,7 +1485,7 @@
 	{
 		if (contexts[contextNdx] != EGL_NO_CONTEXT)
 		{
-			TCU_CHECK_EGL_CALL(eglDestroyContext(m_display, contexts[contextNdx]));
+			EGLU_CHECK_CALL(egl, destroyContext(m_display, contexts[contextNdx]));
 			thread.getLog() << ThreadLog::BeginMessage << "eglDestroyContext(" << m_display << ", " << contexts[contextNdx]  << ")" << ThreadLog::EndMessage;
 			contexts[contextNdx] = EGL_NO_CONTEXT;
 		}
diff --git a/modules/egl/teglNativeColorMappingTests.cpp b/modules/egl/teglNativeColorMappingTests.cpp
index 1ea7f76..8d625a0 100644
--- a/modules/egl/teglNativeColorMappingTests.cpp
+++ b/modules/egl/teglNativeColorMappingTests.cpp
@@ -33,6 +33,9 @@
 #include "egluUnique.hpp"
 #include "egluUtil.hpp"
 
+#include "eglwLibrary.hpp"
+#include "eglwEnums.hpp"
+
 #include "gluDefs.hpp"
 #include "glwFunctions.hpp"
 #include "glwEnums.hpp"
@@ -55,6 +58,8 @@
 using std::vector;
 using std::string;
 
+using namespace eglw;
+
 namespace deqp
 {
 namespace egl
@@ -62,19 +67,19 @@
 namespace
 {
 
-EGLContext createGLES2Context (EGLDisplay display, EGLConfig config)
+EGLContext createGLES2Context (const Library& egl, EGLDisplay display, EGLConfig config)
 {
-	EGLContext		context = EGL_NO_CONTEXT;
-	const EGLint	attribList[] =
+	EGLContext		context			= EGL_NO_CONTEXT;
+	const EGLint	attribList[]	=
 	{
 		EGL_CONTEXT_CLIENT_VERSION, 2,
 		EGL_NONE
 	};
 
-	TCU_CHECK_EGL_CALL(eglBindAPI(EGL_OPENGL_ES_API));
+	EGLU_CHECK_CALL(egl, bindAPI(EGL_OPENGL_ES_API));
 
-	context = eglCreateContext(display, config, EGL_NO_CONTEXT, attribList);
-	TCU_CHECK_EGL_MSG("eglCreateContext() failed");
+	context = egl.createContext(display, config, EGL_NO_CONTEXT, attribList);
+	EGLU_CHECK_MSG(egl, "eglCreateContext() failed");
 	TCU_CHECK(context);
 
 	return context;
@@ -240,12 +245,12 @@
 	GLU_EXPECT_NO_ERROR(gl.getError(), "Failed to render");
 }
 
-bool validate (TestLog& log, EGLDisplay display, EGLConfig config, const tcu::TextureLevel& result, const tcu::Vec4& color)
+bool validate (TestLog& log, const Library& egl, EGLDisplay display, EGLConfig config, const tcu::TextureLevel& result, const tcu::Vec4& color)
 {
-	const tcu::UVec4 eglBitDepth((deUint32)eglu::getConfigAttribInt(display, config, EGL_RED_SIZE),
-								 (deUint32)eglu::getConfigAttribInt(display, config, EGL_GREEN_SIZE),
-								 (deUint32)eglu::getConfigAttribInt(display, config, EGL_BLUE_SIZE),
-								 (deUint32)eglu::getConfigAttribInt(display, config, EGL_ALPHA_SIZE));
+	const tcu::UVec4 eglBitDepth((deUint32)eglu::getConfigAttribInt(egl, display, config, EGL_RED_SIZE),
+								 (deUint32)eglu::getConfigAttribInt(egl, display, config, EGL_GREEN_SIZE),
+								 (deUint32)eglu::getConfigAttribInt(egl, display, config, EGL_BLUE_SIZE),
+								 (deUint32)eglu::getConfigAttribInt(egl, display, config, EGL_ALPHA_SIZE));
 
 	const tcu::UVec4 nativeBitDepth(tcu::getTextureFormatBitDepth(result.getFormat()).asUint());
 	const tcu::UVec4 bitDepth(deMinu32(nativeBitDepth.x(), eglBitDepth.x()),
@@ -279,18 +284,18 @@
 		NATIVETYPE_PBUFFER_COPY_TO_PIXMAP
 	};
 
-				NativeColorMappingCase	(EglTestContext& eglTestCtx, const char* name, const char* description, bool render, NativeType nativeType, const vector<EGLint>& configIds);
+				NativeColorMappingCase	(EglTestContext& eglTestCtx, const char* name, const char* description, bool render, NativeType nativeType, const eglu::FilterList& filters);
 				~NativeColorMappingCase	(void);
 
 private:
-	void		executeForConfig		(tcu::egl::Display& display, EGLConfig config);
+	void		executeForConfig		(EGLDisplay display, EGLConfig config);
 
 	NativeType	m_nativeType;
 	bool		m_render;
 };
 
-NativeColorMappingCase::NativeColorMappingCase (EglTestContext& eglTestCtx, const char* name, const char* description, bool render, NativeType nativeType, const vector<EGLint>& configIds)
-	: SimpleConfigCase	(eglTestCtx, name, description, configIds)
+NativeColorMappingCase::NativeColorMappingCase (EglTestContext& eglTestCtx, const char* name, const char* description, bool render, NativeType nativeType, const eglu::FilterList& filters)
+	: SimpleConfigCase	(eglTestCtx, name, description, filters)
 	, m_nativeType		(nativeType)
 	, m_render			(render)
 {
@@ -301,15 +306,15 @@
 	deinit();
 }
 
-void logConfigInfo (TestLog& log, EGLDisplay display, EGLConfig config, NativeColorMappingCase::NativeType nativeType, int waitFrames)
+void logConfigInfo (TestLog& log, const Library& egl, EGLDisplay display, EGLConfig config, NativeColorMappingCase::NativeType nativeType, int waitFrames)
 {
-	log << TestLog::Message << "EGL_RED_SIZE: "		<< eglu::getConfigAttribInt(display, config, EGL_RED_SIZE)		<< TestLog::EndMessage;
-	log << TestLog::Message << "EGL_GREEN_SIZE: "	<< eglu::getConfigAttribInt(display, config, EGL_GREEN_SIZE)	<< TestLog::EndMessage;
-	log << TestLog::Message << "EGL_BLUE_SIZE: "	<< eglu::getConfigAttribInt(display, config, EGL_BLUE_SIZE)		<< TestLog::EndMessage;
-	log << TestLog::Message << "EGL_ALPHA_SIZE: "	<< eglu::getConfigAttribInt(display, config, EGL_ALPHA_SIZE)	<< TestLog::EndMessage;
-	log << TestLog::Message << "EGL_DEPTH_SIZE: "	<< eglu::getConfigAttribInt(display, config, EGL_DEPTH_SIZE)	<< TestLog::EndMessage;
-	log << TestLog::Message << "EGL_STENCIL_SIZE: "	<< eglu::getConfigAttribInt(display, config, EGL_STENCIL_SIZE)	<< TestLog::EndMessage;
-	log << TestLog::Message << "EGL_SAMPLES: "		<< eglu::getConfigAttribInt(display, config, EGL_SAMPLES)		<< TestLog::EndMessage;
+	log << TestLog::Message << "EGL_RED_SIZE: "		<< eglu::getConfigAttribInt(egl, display, config, EGL_RED_SIZE)		<< TestLog::EndMessage;
+	log << TestLog::Message << "EGL_GREEN_SIZE: "	<< eglu::getConfigAttribInt(egl, display, config, EGL_GREEN_SIZE)	<< TestLog::EndMessage;
+	log << TestLog::Message << "EGL_BLUE_SIZE: "	<< eglu::getConfigAttribInt(egl, display, config, EGL_BLUE_SIZE)	<< TestLog::EndMessage;
+	log << TestLog::Message << "EGL_ALPHA_SIZE: "	<< eglu::getConfigAttribInt(egl, display, config, EGL_ALPHA_SIZE)	<< TestLog::EndMessage;
+	log << TestLog::Message << "EGL_DEPTH_SIZE: "	<< eglu::getConfigAttribInt(egl, display, config, EGL_DEPTH_SIZE)	<< TestLog::EndMessage;
+	log << TestLog::Message << "EGL_STENCIL_SIZE: "	<< eglu::getConfigAttribInt(egl, display, config, EGL_STENCIL_SIZE)	<< TestLog::EndMessage;
+	log << TestLog::Message << "EGL_SAMPLES: "		<< eglu::getConfigAttribInt(egl, display, config, EGL_SAMPLES)		<< TestLog::EndMessage;
 
 	if (nativeType == NativeColorMappingCase::NATIVETYPE_WINDOW)
 		log << TestLog::Message << "Waiting " << waitFrames * 16 << "ms after eglSwapBuffers() and glFinish() for frame to become visible" << TestLog::EndMessage;
@@ -317,14 +322,15 @@
 
 bool testNativeWindow (TestLog& log, eglu::NativeDisplay& nativeDisplay, eglu::NativeWindow& nativeWindow, EGLDisplay display, EGLContext context, EGLConfig config, const glw::Functions& gl, bool renderColor, int waitFrames, size_t colorCount, const tcu::Vec4* colors)
 {
-	eglu::UniqueSurface	surface(display, eglu::createWindowSurface(nativeDisplay, nativeWindow, display, config, DE_NULL));
+	const Library&		egl			= nativeDisplay.getLibrary();
+	eglu::UniqueSurface	surface		(egl, display, eglu::createWindowSurface(nativeDisplay, nativeWindow, display, config, DE_NULL));
 	tcu::TextureLevel	result;
-	deUint32			program	= 0;
-	bool				isOk	= true;
+	deUint32			program		= 0;
+	bool				isOk		= true;
 
 	try
 	{
-		TCU_CHECK_EGL_CALL(eglMakeCurrent(display, *surface, *surface, context));
+		EGLU_CHECK_CALL(egl, makeCurrent(display, *surface, *surface, context));
 
 		if (renderColor)
 			program = createGLES2Program(gl, log);
@@ -336,16 +342,16 @@
 			else
 				clear(gl, colors[colorNdx]);
 
-			TCU_CHECK_EGL_CALL(eglSwapBuffers(display, *surface));
-			TCU_CHECK_EGL_CALL(eglWaitClient());
+			EGLU_CHECK_CALL(egl, swapBuffers(display, *surface));
+			EGLU_CHECK_CALL(egl, waitClient());
 			deSleep(waitFrames*16);
 			nativeWindow.readScreenPixels(&result);
 
-			if (!validate(log, display, config, result, colors[colorNdx]))
+			if (!validate(log, egl, display, config, result, colors[colorNdx]))
 				isOk = false;
 		}
 
-		TCU_CHECK_EGL_CALL(eglMakeCurrent(display, EGL_NO_SURFACE, EGL_NO_SURFACE, EGL_NO_CONTEXT));
+		EGLU_CHECK_CALL(egl, makeCurrent(display, EGL_NO_SURFACE, EGL_NO_SURFACE, EGL_NO_CONTEXT));
 	}
 	catch (...)
 	{
@@ -359,14 +365,15 @@
 
 bool testNativePixmap (TestLog& log, eglu::NativeDisplay& nativeDisplay, eglu::NativePixmap& nativePixmap, EGLDisplay display, EGLContext context, EGLConfig config, const glw::Functions& gl, bool renderColor, size_t colorCount, const tcu::Vec4* colors)
 {
-	eglu::UniqueSurface	surface(display, eglu::createPixmapSurface(nativeDisplay, nativePixmap, display, config, DE_NULL));
+	const Library&		egl			= nativeDisplay.getLibrary();
+	eglu::UniqueSurface	surface		(egl, display, eglu::createPixmapSurface(nativeDisplay, nativePixmap, display, config, DE_NULL));
 	tcu::TextureLevel	result;
-	deUint32			program	= 0;
-	bool				isOk	= true;
+	deUint32			program		= 0;
+	bool				isOk		= true;
 
 	try
 	{
-		TCU_CHECK_EGL_CALL(eglMakeCurrent(display, *surface, *surface, context));
+		EGLU_CHECK_CALL(egl, makeCurrent(display, *surface, *surface, context));
 
 		if (renderColor)
 			program = createGLES2Program(gl, log);
@@ -378,14 +385,14 @@
 			else
 				clear(gl, colors[colorNdx]);
 
-			TCU_CHECK_EGL_CALL(eglWaitClient());
+			EGLU_CHECK_CALL(egl, waitClient());
 			nativePixmap.readPixels(&result);
 
-			if (!validate(log, display, config, result, colors[colorNdx]))
+			if (!validate(log, egl, display, config, result, colors[colorNdx]))
 				isOk = false;
 		}
 
-		TCU_CHECK_EGL_CALL(eglMakeCurrent(display, EGL_NO_SURFACE, EGL_NO_SURFACE, EGL_NO_CONTEXT));
+		EGLU_CHECK_CALL(egl, makeCurrent(display, EGL_NO_SURFACE, EGL_NO_SURFACE, EGL_NO_CONTEXT));
 	}
 	catch (...)
 	{
@@ -397,16 +404,16 @@
 	return isOk;
 }
 
-bool testNativePixmapCopy (TestLog& log, eglu::NativePixmap& nativePixmap, EGLDisplay display, EGLContext context, EGLConfig config, const glw::Functions& gl, bool renderColor, size_t colorCount, const tcu::Vec4* colors)
+bool testNativePixmapCopy (TestLog& log, const Library& egl, eglu::NativePixmap& nativePixmap, EGLDisplay display, EGLContext context, EGLConfig config, const glw::Functions& gl, bool renderColor, size_t colorCount, const tcu::Vec4* colors)
 {
-	eglu::UniqueSurface	surface(display, eglCreatePbufferSurface(display, config, DE_NULL));
+	eglu::UniqueSurface	surface		(egl, display, egl.createPbufferSurface(display, config, DE_NULL));
 	tcu::TextureLevel	result;
-	deUint32			program	= 0;
-	bool				isOk	= true;
+	deUint32			program		= 0;
+	bool				isOk		= true;
 
 	try
 	{
-		TCU_CHECK_EGL_CALL(eglMakeCurrent(display, *surface, *surface, context));
+		EGLU_CHECK_CALL(egl, makeCurrent(display, *surface, *surface, context));
 
 		if (renderColor)
 			program = createGLES2Program(gl, log);
@@ -418,15 +425,15 @@
 			else
 				clear(gl, colors[colorNdx]);
 
-			TCU_CHECK_EGL_CALL(eglCopyBuffers(display, *surface, nativePixmap.getLegacyNative()));
-			TCU_CHECK_EGL_CALL(eglWaitClient());
+			EGLU_CHECK_CALL(egl, copyBuffers(display, *surface, nativePixmap.getLegacyNative()));
+			EGLU_CHECK_CALL(egl, waitClient());
 			nativePixmap.readPixels(&result);
 
-			if (!validate(log, display, config, result, colors[colorNdx]))
+			if (!validate(log, egl, display, config, result, colors[colorNdx]))
 				isOk = false;
 		}
 
-		TCU_CHECK_EGL_CALL(eglMakeCurrent(display, EGL_NO_SURFACE, EGL_NO_SURFACE, EGL_NO_CONTEXT));
+		EGLU_CHECK_CALL(egl, makeCurrent(display, EGL_NO_SURFACE, EGL_NO_SURFACE, EGL_NO_CONTEXT));
 	}
 	catch (...)
 	{
@@ -438,32 +445,50 @@
 	return isOk;
 }
 
-void checkSupport (EglTestContext& eglTestCtx, NativeColorMappingCase::NativeType nativeType)
+void checkSupport (NativeColorMappingCase::NativeType nativeType, const eglu::NativeWindowFactory* windowFactory, const eglu::NativePixmapFactory* pixmapFactory)
 {
 	switch (nativeType)
 	{
 		case NativeColorMappingCase::NATIVETYPE_WINDOW:
-			if ((eglTestCtx.getNativeWindowFactory().getCapabilities() & eglu::NativeWindow::CAPABILITY_READ_SCREEN_PIXELS) == 0)
-				throw tcu::NotSupportedError("Native window doesn't support readPixels()", "", __FILE__, __LINE__);
+		{
+			if (!windowFactory)
+				TCU_THROW(NotSupportedError, "Windows not supported");
+
+			if ((windowFactory->getCapabilities() & eglu::NativeWindow::CAPABILITY_READ_SCREEN_PIXELS) == 0)
+				TCU_THROW(NotSupportedError, "Native window doesn't support readPixels()");
+
 			break;
+		}
 
 		case NativeColorMappingCase::NATIVETYPE_PIXMAP:
-			if ((eglTestCtx.getNativePixmapFactory().getCapabilities() & eglu::NativePixmap::CAPABILITY_READ_PIXELS) == 0)
-				throw tcu::NotSupportedError("Native pixmap doesn't support readPixels()", "", __FILE__, __LINE__);
+		{
+			if (!pixmapFactory)
+				TCU_THROW(NotSupportedError, "Pixmaps not supported");
+
+			if ((pixmapFactory->getCapabilities() & eglu::NativePixmap::CAPABILITY_READ_PIXELS) == 0)
+				TCU_THROW(NotSupportedError, "Native pixmap doesn't support readPixels()");
+
 			break;
+		}
 
 		case NativeColorMappingCase::NATIVETYPE_PBUFFER_COPY_TO_PIXMAP:
-			if ((eglTestCtx.getNativePixmapFactory().getCapabilities() & eglu::NativePixmap::CAPABILITY_READ_PIXELS) == 0 ||
-				(eglTestCtx.getNativePixmapFactory().getCapabilities() & eglu::NativePixmap::CAPABILITY_CREATE_SURFACE_LEGACY) == 0)
-				throw tcu::NotSupportedError("Native pixmap doesn't support readPixels() or legacy create surface", "", __FILE__, __LINE__);
+		{
+			if (!pixmapFactory)
+				TCU_THROW(NotSupportedError, "Pixmaps not supported");
+
+			if ((pixmapFactory->getCapabilities() & eglu::NativePixmap::CAPABILITY_READ_PIXELS) == 0 ||
+				(pixmapFactory->getCapabilities() & eglu::NativePixmap::CAPABILITY_CREATE_SURFACE_LEGACY) == 0)
+				TCU_THROW(NotSupportedError, "Native pixmap doesn't support readPixels() or legacy create surface");
+
 			break;
+		}
 
 		default:
 			DE_ASSERT(DE_FALSE);
 	}
 }
 
-void NativeColorMappingCase::executeForConfig (tcu::egl::Display& display, EGLConfig config)
+void NativeColorMappingCase::executeForConfig (EGLDisplay display, EGLConfig config)
 {
 	const int width		= 128;
 	const int height	= 128;
@@ -489,44 +514,47 @@
 		tcu::Vec4(0.5f, 0.5f, 0.5f, 1.0f)
 	};
 
-	const string			configIdStr	(de::toString(eglu::getConfigAttribInt(display.getEGLDisplay(), config, EGL_CONFIG_ID)));
-	tcu::ScopedLogSection	logSection	(m_testCtx.getLog(), ("Config ID " + configIdStr).c_str(), ("Config ID " + configIdStr).c_str());
-	const int				waitFrames	= 5;
+	const Library&						egl				= m_eglTestCtx.getLibrary();
+	const string						configIdStr		(de::toString(eglu::getConfigAttribInt(egl, display, config, EGL_CONFIG_ID)));
+	tcu::ScopedLogSection				logSection		(m_testCtx.getLog(), ("Config ID " + configIdStr).c_str(), ("Config ID " + configIdStr).c_str());
+	const int							waitFrames		= 5;
+	const eglu::NativeWindowFactory*	windowFactory	= eglu::selectNativeWindowFactory(m_eglTestCtx.getNativeDisplayFactory(), m_testCtx.getCommandLine());
+	const eglu::NativePixmapFactory*	pixmapFactory	= eglu::selectNativePixmapFactory(m_eglTestCtx.getNativeDisplayFactory(), m_testCtx.getCommandLine());
 
-	logConfigInfo(m_testCtx.getLog(), display.getEGLDisplay(), config, m_nativeType, waitFrames);
+	logConfigInfo(m_testCtx.getLog(), egl, display, config, m_nativeType, waitFrames);
 
-	checkSupport(m_eglTestCtx, m_nativeType);
+	checkSupport(m_nativeType, windowFactory, pixmapFactory);
 
-	eglu::UniqueContext context(display.getEGLDisplay(), createGLES2Context(display.getEGLDisplay(), config));
-	glw::Functions		gl;
+	eglu::UniqueContext 	context		(egl, display, createGLES2Context(egl, display, config));
+	glw::Functions			gl;
 
-	m_eglTestCtx.getGLFunctions(gl, glu::ApiType::es(2,0));
+	m_eglTestCtx.initGLFunctions(&gl, glu::ApiType::es(2,0));
 
 	switch (m_nativeType)
 	{
 		case NATIVETYPE_WINDOW:
 		{
-			de::UniquePtr<eglu::NativeWindow> nativeWindow(m_eglTestCtx.createNativeWindow(display.getEGLDisplay(), config, DE_NULL, width, height, eglu::WindowParams::VISIBILITY_VISIBLE));
+			de::UniquePtr<eglu::NativeWindow>	nativeWindow	(windowFactory->createWindow(&m_eglTestCtx.getNativeDisplay(), display, config, DE_NULL, eglu::WindowParams(width, height, eglu::WindowParams::VISIBILITY_VISIBLE)));
 
-			if (!testNativeWindow(m_testCtx.getLog(), m_eglTestCtx.getNativeDisplay(), *nativeWindow, display.getEGLDisplay(), *context, config, gl, m_render, waitFrames, DE_LENGTH_OF_ARRAY(colors), colors))
+			if (!testNativeWindow(m_testCtx.getLog(), m_eglTestCtx.getNativeDisplay(), *nativeWindow, display, *context, config, gl, m_render, waitFrames, DE_LENGTH_OF_ARRAY(colors), colors))
 				m_testCtx.setTestResult(QP_TEST_RESULT_FAIL, "Invalid color rendered");
 			break;
 		}
 
 		case NATIVETYPE_PIXMAP:
 		{
-			de::UniquePtr<eglu::NativePixmap> nativePixmap(m_eglTestCtx.createNativePixmap(display.getEGLDisplay(), config, DE_NULL, width, height));
+			de::UniquePtr<eglu::NativePixmap> nativePixmap		(pixmapFactory->createPixmap(&m_eglTestCtx.getNativeDisplay(), display, config, DE_NULL, width, height));
 
-			if (!testNativePixmap(m_testCtx.getLog(), m_eglTestCtx.getNativeDisplay(), *nativePixmap, display.getEGLDisplay(), *context, config, gl, m_render, DE_LENGTH_OF_ARRAY(colors), colors))
+			if (!testNativePixmap(m_testCtx.getLog(), m_eglTestCtx.getNativeDisplay(), *nativePixmap, display, *context, config, gl, m_render, DE_LENGTH_OF_ARRAY(colors), colors))
 				m_testCtx.setTestResult(QP_TEST_RESULT_FAIL, "Invalid color rendered");
 			break;
 		}
 
 		case NATIVETYPE_PBUFFER_COPY_TO_PIXMAP:
 		{
-			de::UniquePtr<eglu::NativePixmap> nativePixmap(m_eglTestCtx.createNativePixmap(display.getEGLDisplay(), config, DE_NULL, width, height));
+			de::UniquePtr<eglu::NativePixmap> nativePixmap		(pixmapFactory->createPixmap(&m_eglTestCtx.getNativeDisplay(), display, config, DE_NULL, width, height));
 
-			if (!testNativePixmapCopy(m_testCtx.getLog(), *nativePixmap, display.getEGLDisplay(), *context, config, gl, m_render, DE_LENGTH_OF_ARRAY(colors), colors))
+			if (!testNativePixmapCopy(m_testCtx.getLog(), egl, *nativePixmap, display, *context, config, gl, m_render, DE_LENGTH_OF_ARRAY(colors), colors))
 				m_testCtx.setTestResult(QP_TEST_RESULT_FAIL, "Invalid color rendered");
 			break;
 		}
@@ -536,35 +564,41 @@
 	}
 }
 
+template<deUint32 Type>
+static bool surfaceType (const eglu::CandidateConfig& c)
+{
+	return (c.surfaceType() & Type) == Type;
+}
+
 void addTestGroups (EglTestContext& eglTestCtx, TestCaseGroup* group, NativeColorMappingCase::NativeType type)
 {
-	eglu::FilterList filters;
+	eglu::FilterList baseFilters;
 
 	switch (type)
 	{
 		case NativeColorMappingCase::NATIVETYPE_WINDOW:
-			filters << (eglu::ConfigSurfaceType() & EGL_WINDOW_BIT);
+			baseFilters << surfaceType<EGL_WINDOW_BIT>;
 			break;
 
 		case NativeColorMappingCase::NATIVETYPE_PIXMAP:
-			filters << (eglu::ConfigSurfaceType() & EGL_PIXMAP_BIT);
+			baseFilters << surfaceType<EGL_PIXMAP_BIT>;
 			break;
 
 		case NativeColorMappingCase::NATIVETYPE_PBUFFER_COPY_TO_PIXMAP:
-			filters << (eglu::ConfigSurfaceType() & EGL_PBUFFER_BIT);
+			baseFilters << surfaceType<EGL_PBUFFER_BIT>;
 			break;
 
 		default:
 			DE_ASSERT(DE_FALSE);
 	}
 
-	vector<NamedConfigIdSet> configIdSets;
-	NamedConfigIdSet::getDefaultSets(configIdSets, eglTestCtx.getConfigs(), filters);
+	vector<NamedFilterList> filterLists;
+	getDefaultFilterLists(filterLists, baseFilters);
 
-	for (vector<NamedConfigIdSet>::iterator i = configIdSets.begin(); i != configIdSets.end(); i++)
+	for (vector<NamedFilterList>::iterator i = filterLists.begin(); i != filterLists.end(); i++)
 	{
-		group->addChild(new NativeColorMappingCase(eglTestCtx, (string(i->getName()) + "_clear").c_str(), i->getDescription(), false, type, i->getConfigIds()));
-		group->addChild(new NativeColorMappingCase(eglTestCtx, (string(i->getName()) + "_render").c_str(), i->getDescription(), true, type, i->getConfigIds()));
+		group->addChild(new NativeColorMappingCase(eglTestCtx, (string(i->getName()) + "_clear").c_str(), i->getDescription(), false, type, *i));
+		group->addChild(new NativeColorMappingCase(eglTestCtx, (string(i->getName()) + "_render").c_str(), i->getDescription(), true, type, *i));
 	}
 }
 
diff --git a/modules/egl/teglNativeCoordMappingTests.cpp b/modules/egl/teglNativeCoordMappingTests.cpp
index a79aebb..90b38d4 100644
--- a/modules/egl/teglNativeCoordMappingTests.cpp
+++ b/modules/egl/teglNativeCoordMappingTests.cpp
@@ -34,6 +34,9 @@
 #include "egluUnique.hpp"
 #include "egluUtil.hpp"
 
+#include "eglwLibrary.hpp"
+#include "eglwEnums.hpp"
+
 #include "gluDefs.hpp"
 #include "glwFunctions.hpp"
 #include "glwEnums.hpp"
@@ -56,6 +59,8 @@
 using std::vector;
 using std::string;
 
+using namespace eglw;
+
 namespace deqp
 {
 namespace egl
@@ -63,19 +68,19 @@
 namespace
 {
 
-EGLContext createGLES2Context (EGLDisplay display, EGLConfig config)
+EGLContext createGLES2Context (const Library& egl, EGLDisplay display, EGLConfig config)
 {
-	EGLContext		context = EGL_NO_CONTEXT;
-	const EGLint	attribList[] =
+	EGLContext		context			= EGL_NO_CONTEXT;
+	const EGLint	attribList[]	=
 	{
 		EGL_CONTEXT_CLIENT_VERSION, 2,
 		EGL_NONE
 	};
 
-	TCU_CHECK_EGL_CALL(eglBindAPI(EGL_OPENGL_ES_API));
+	EGLU_CHECK_CALL(egl, bindAPI(EGL_OPENGL_ES_API));
 
-	context = eglCreateContext(display, config, EGL_NO_CONTEXT, attribList);
-	TCU_CHECK_EGL_MSG("eglCreateContext() failed");
+	context = egl.createContext(display, config, EGL_NO_CONTEXT, attribList);
+	EGLU_CHECK_MSG(egl, "eglCreateContext() failed");
 	TCU_CHECK(context);
 
 	return context;
@@ -320,18 +325,18 @@
 		NATIVETYPE_PBUFFER_COPY_TO_PIXMAP
 	};
 
-				NativeCoordMappingCase	(EglTestContext& eglTestCtx, const char* name, const char* description, bool render, NativeType nativeType, const vector<EGLint>& configIds);
+				NativeCoordMappingCase	(EglTestContext& eglTestCtx, const char* name, const char* description, bool render, NativeType nativeType, const eglu::FilterList& filters);
 				~NativeCoordMappingCase	(void);
 
 private:
-	void		executeForConfig		(tcu::egl::Display& display, EGLConfig config);
+	void		executeForConfig		(EGLDisplay display, EGLConfig config);
 
 	NativeType	m_nativeType;
 	bool		m_render;
 };
 
-NativeCoordMappingCase::NativeCoordMappingCase (EglTestContext& eglTestCtx, const char* name, const char* description, bool render, NativeType nativeType, const vector<EGLint>& configIds)
-	: SimpleConfigCase	(eglTestCtx, name, description, configIds)
+NativeCoordMappingCase::NativeCoordMappingCase (EglTestContext& eglTestCtx, const char* name, const char* description, bool render, NativeType nativeType, const eglu::FilterList& filters)
+	: SimpleConfigCase	(eglTestCtx, name, description, filters)
 	, m_nativeType		(nativeType)
 	, m_render			(render)
 {
@@ -342,15 +347,15 @@
 	deinit();
 }
 
-void logConfigInfo (TestLog& log, EGLDisplay display, EGLConfig config, NativeCoordMappingCase::NativeType nativeType, int waitFrames)
+void logConfigInfo (TestLog& log, const Library& egl, EGLDisplay display, EGLConfig config, NativeCoordMappingCase::NativeType nativeType, int waitFrames)
 {
-	log << TestLog::Message << "EGL_RED_SIZE: "		<< eglu::getConfigAttribInt(display, config, EGL_RED_SIZE)		<< TestLog::EndMessage;
-	log << TestLog::Message << "EGL_GREEN_SIZE: "	<< eglu::getConfigAttribInt(display, config, EGL_GREEN_SIZE)	<< TestLog::EndMessage;
-	log << TestLog::Message << "EGL_BLUE_SIZE: "	<< eglu::getConfigAttribInt(display, config, EGL_BLUE_SIZE)		<< TestLog::EndMessage;
-	log << TestLog::Message << "EGL_ALPHA_SIZE: "	<< eglu::getConfigAttribInt(display, config, EGL_ALPHA_SIZE)	<< TestLog::EndMessage;
-	log << TestLog::Message << "EGL_DEPTH_SIZE: "	<< eglu::getConfigAttribInt(display, config, EGL_DEPTH_SIZE)	<< TestLog::EndMessage;
-	log << TestLog::Message << "EGL_STENCIL_SIZE: "	<< eglu::getConfigAttribInt(display, config, EGL_STENCIL_SIZE)	<< TestLog::EndMessage;
-	log << TestLog::Message << "EGL_SAMPLES: "		<< eglu::getConfigAttribInt(display, config, EGL_SAMPLES)		<< TestLog::EndMessage;
+	log << TestLog::Message << "EGL_RED_SIZE: "		<< eglu::getConfigAttribInt(egl, display, config, EGL_RED_SIZE)		<< TestLog::EndMessage;
+	log << TestLog::Message << "EGL_GREEN_SIZE: "	<< eglu::getConfigAttribInt(egl, display, config, EGL_GREEN_SIZE)	<< TestLog::EndMessage;
+	log << TestLog::Message << "EGL_BLUE_SIZE: "	<< eglu::getConfigAttribInt(egl, display, config, EGL_BLUE_SIZE)	<< TestLog::EndMessage;
+	log << TestLog::Message << "EGL_ALPHA_SIZE: "	<< eglu::getConfigAttribInt(egl, display, config, EGL_ALPHA_SIZE)	<< TestLog::EndMessage;
+	log << TestLog::Message << "EGL_DEPTH_SIZE: "	<< eglu::getConfigAttribInt(egl, display, config, EGL_DEPTH_SIZE)	<< TestLog::EndMessage;
+	log << TestLog::Message << "EGL_STENCIL_SIZE: "	<< eglu::getConfigAttribInt(egl, display, config, EGL_STENCIL_SIZE)	<< TestLog::EndMessage;
+	log << TestLog::Message << "EGL_SAMPLES: "		<< eglu::getConfigAttribInt(egl, display, config, EGL_SAMPLES)		<< TestLog::EndMessage;
 
 	if (nativeType == NativeCoordMappingCase::NATIVETYPE_WINDOW)
 		log << TestLog::Message << "Waiting " << waitFrames * 16 << "ms after eglSwapBuffers() and glFinish() for frame to become visible" << TestLog::EndMessage;
@@ -363,16 +368,17 @@
 	const int			rectW		= 64;
 	const int			rectH		= 72;
 
+	const Library&		egl			= nativeDisplay.getLibrary();
 	const tcu::IVec2	screenSize	= nativeWindow.getScreenSize();
-	eglu::UniqueSurface	surface		(display, eglu::createWindowSurface(nativeDisplay, nativeWindow, display, config, DE_NULL));
-	const tcu::IVec2	surfaceSize = eglu::getSurfaceSize(display, *surface);
+	eglu::UniqueSurface	surface		(egl, display, eglu::createWindowSurface(nativeDisplay, nativeWindow, display, config, DE_NULL));
+	const tcu::IVec2	surfaceSize = eglu::getSurfaceSize(egl, display, *surface);
 	deUint32			program		= 0;
 	bool				isOk		= true;
 	tcu::TextureLevel	result;
 
 	try
 	{
-		TCU_CHECK_EGL_CALL(eglMakeCurrent(display, *surface, *surface, context));
+		EGLU_CHECK_CALL(egl, makeCurrent(display, *surface, *surface, context));
 
 		if (renderColor)
 			program = createGLES2Program(gl, log);
@@ -384,15 +390,15 @@
 		else
 			clear(gl, tcu::Vec4(1.0f, 1.0f, 1.0f, 1.0f), rectX, rectY, rectW, rectH);
 
-		TCU_CHECK_EGL_CALL(eglSwapBuffers(display, *surface));
-		TCU_CHECK_EGL_CALL(eglWaitClient());
+		EGLU_CHECK_CALL(egl, swapBuffers(display, *surface));
+		EGLU_CHECK_CALL(egl, waitClient());
 		deSleep(waitFrames*16);
 		nativeWindow.readScreenPixels(&result);
 
 		if (!validate(log, result, rectX, screenSize.y() - rectY - rectH, rectW, rectH))
 			isOk = false;
 
-		TCU_CHECK_EGL_CALL(eglMakeCurrent(display, EGL_NO_SURFACE, EGL_NO_SURFACE, EGL_NO_CONTEXT));
+		EGLU_CHECK_CALL(egl, makeCurrent(display, EGL_NO_SURFACE, EGL_NO_SURFACE, EGL_NO_CONTEXT));
 	}
 	catch (...)
 	{
@@ -411,14 +417,15 @@
 	const int			rectW		= 64;
 	const int			rectH		= 72;
 
-	eglu::UniqueSurface	surface(display, eglu::createPixmapSurface(nativeDisplay, nativePixmap, display, config, DE_NULL));
-	deUint32			program	= 0;
-	bool				isOk	= true;
+	const Library&		egl			= nativeDisplay.getLibrary();
+	eglu::UniqueSurface	surface		(egl, display, eglu::createPixmapSurface(nativeDisplay, nativePixmap, display, config, DE_NULL));
+	deUint32			program		= 0;
+	bool				isOk		= true;
 	tcu::TextureLevel	result;
 
 	try
 	{
-		TCU_CHECK_EGL_CALL(eglMakeCurrent(display, *surface, *surface, context));
+		EGLU_CHECK_CALL(egl, makeCurrent(display, *surface, *surface, context));
 
 		if (renderColor)
 			program = createGLES2Program(gl, log);
@@ -430,13 +437,13 @@
 		else
 			clear(gl, tcu::Vec4(1.0f, 1.0f, 1.0f, 1.0f), rectX, rectY, rectW, rectH);
 
-		TCU_CHECK_EGL_CALL(eglWaitClient());
+		EGLU_CHECK_CALL(egl, waitClient());
 		nativePixmap.readPixels(&result);
 
 		if (!validate(log, result, rectX, height - 1 - rectY - rectH, rectW, rectH))
 			isOk = false;
 
-		TCU_CHECK_EGL_CALL(eglMakeCurrent(display, EGL_NO_SURFACE, EGL_NO_SURFACE, EGL_NO_CONTEXT));
+		EGLU_CHECK_CALL(egl, makeCurrent(display, EGL_NO_SURFACE, EGL_NO_SURFACE, EGL_NO_CONTEXT));
 	}
 	catch (...)
 	{
@@ -448,21 +455,21 @@
 	return isOk;
 }
 
-bool testNativePixmapCopy (TestLog& log, eglu::NativePixmap& nativePixmap, int width, int height, EGLDisplay display, EGLContext context, EGLConfig config, const glw::Functions& gl, bool renderColor)
+bool testNativePixmapCopy (TestLog& log, const Library& egl, eglu::NativePixmap& nativePixmap, int width, int height, EGLDisplay display, EGLContext context, EGLConfig config, const glw::Functions& gl, bool renderColor)
 {
 	const int			rectX		= 8;
 	const int			rectY		= 16;
 	const int			rectW		= 64;
 	const int			rectH		= 72;
 
-	eglu::UniqueSurface	surface(display, eglCreatePbufferSurface(display, config, DE_NULL));
-	deUint32			program	= 0;
-	bool				isOk	= true;
+	eglu::UniqueSurface	surface		(egl, display, egl.createPbufferSurface(display, config, DE_NULL));
+	deUint32			program		= 0;
+	bool				isOk		= true;
 	tcu::TextureLevel	result;
 
 	try
 	{
-		TCU_CHECK_EGL_CALL(eglMakeCurrent(display, *surface, *surface, context));
+		EGLU_CHECK_CALL(egl, makeCurrent(display, *surface, *surface, context));
 
 		if (renderColor)
 			program = createGLES2Program(gl, log);
@@ -474,14 +481,14 @@
 		else
 			clear(gl, tcu::Vec4(1.0f, 1.0f, 1.0f, 1.0f), rectX, rectY, rectW, rectH);
 
-		TCU_CHECK_EGL_CALL(eglCopyBuffers(display, *surface, nativePixmap.getLegacyNative()));
-		TCU_CHECK_EGL_CALL(eglWaitClient());
+		EGLU_CHECK_CALL(egl, copyBuffers(display, *surface, nativePixmap.getLegacyNative()));
+		EGLU_CHECK_CALL(egl, waitClient());
 		nativePixmap.readPixels(&result);
 
 		if (!validate(log, result, rectX, height - 1 - rectY, rectW, rectH))
 			isOk = false;
 
-		TCU_CHECK_EGL_CALL(eglMakeCurrent(display, EGL_NO_SURFACE, EGL_NO_SURFACE, EGL_NO_CONTEXT));
+		EGLU_CHECK_CALL(egl, makeCurrent(display, EGL_NO_SURFACE, EGL_NO_SURFACE, EGL_NO_CONTEXT));
 	}
 	catch (...)
 	{
@@ -493,55 +500,76 @@
 	return isOk;
 }
 
-void checkSupport (EglTestContext& eglTestCtx, NativeCoordMappingCase::NativeType nativeType)
+void checkSupport (NativeCoordMappingCase::NativeType nativeType, const eglu::NativeWindowFactory* windowFactory, const eglu::NativePixmapFactory* pixmapFactory)
 {
 	switch (nativeType)
 	{
 		case NativeCoordMappingCase::NATIVETYPE_WINDOW:
-			if ((eglTestCtx.getNativeWindowFactory().getCapabilities() & eglu::NativeWindow::CAPABILITY_READ_SCREEN_PIXELS) == 0)
-				throw tcu::NotSupportedError("Native window doesn't support readPixels()", "", __FILE__, __LINE__);
+		{
+			if (!windowFactory)
+				TCU_THROW(NotSupportedError, "Windows not supported");
+
+			if ((windowFactory->getCapabilities() & eglu::NativeWindow::CAPABILITY_READ_SCREEN_PIXELS) == 0)
+				TCU_THROW(NotSupportedError, "Native window doesn't support readPixels()");
+
 			break;
+		}
 
 		case NativeCoordMappingCase::NATIVETYPE_PIXMAP:
-			if ((eglTestCtx.getNativePixmapFactory().getCapabilities() & eglu::NativePixmap::CAPABILITY_READ_PIXELS) == 0)
-				throw tcu::NotSupportedError("Native pixmap doesn't support readPixels()", "", __FILE__, __LINE__);
+		{
+			if (!pixmapFactory)
+				TCU_THROW(NotSupportedError, "Pixmaps not supported");
+
+			if ((pixmapFactory->getCapabilities() & eglu::NativePixmap::CAPABILITY_READ_PIXELS) == 0)
+				TCU_THROW(NotSupportedError, "Native pixmap doesn't support readPixels()");
+
 			break;
+		}
 
 		case NativeCoordMappingCase::NATIVETYPE_PBUFFER_COPY_TO_PIXMAP:
-			if ((eglTestCtx.getNativePixmapFactory().getCapabilities() & eglu::NativePixmap::CAPABILITY_READ_PIXELS) == 0 ||
-				(eglTestCtx.getNativePixmapFactory().getCapabilities() & eglu::NativePixmap::CAPABILITY_CREATE_SURFACE_LEGACY) == 0)
-				throw tcu::NotSupportedError("Native pixmap doesn't support readPixels() or legacy create surface", "", __FILE__, __LINE__);
+		{
+			if (!pixmapFactory)
+				TCU_THROW(NotSupportedError, "Pixmaps not supported");
+
+			if ((pixmapFactory->getCapabilities() & eglu::NativePixmap::CAPABILITY_READ_PIXELS) == 0 ||
+				(pixmapFactory->getCapabilities() & eglu::NativePixmap::CAPABILITY_CREATE_SURFACE_LEGACY) == 0)
+				TCU_THROW(NotSupportedError, "Native pixmap doesn't support readPixels() or legacy create surface");
+
 			break;
+		}
 
 		default:
 			DE_ASSERT(DE_FALSE);
 	}
 }
 
-void NativeCoordMappingCase::executeForConfig (tcu::egl::Display& display, EGLConfig config)
+void NativeCoordMappingCase::executeForConfig (EGLDisplay display, EGLConfig config)
 {
-	const int				width		= 128;
-	const int				height		= 128;
-	const string			configIdStr	(de::toString(eglu::getConfigAttribInt(display.getEGLDisplay(), config, EGL_CONFIG_ID)));
-	tcu::ScopedLogSection	logSection	(m_testCtx.getLog(), ("Config ID " + configIdStr).c_str(), ("Config ID " + configIdStr).c_str());
-	const int				waitFrames	= 5;
+	const Library&						egl				= m_eglTestCtx.getLibrary();
+	const string						configIdStr		(de::toString(eglu::getConfigAttribInt(egl, display, config, EGL_CONFIG_ID)));
+	tcu::ScopedLogSection				logSection		(m_testCtx.getLog(), ("Config ID " + configIdStr).c_str(), ("Config ID " + configIdStr).c_str());
+	const int							waitFrames		= 5;
+	const int							width			= 128;
+	const int							height			= 128;
+	const eglu::NativeWindowFactory*	windowFactory	= eglu::selectNativeWindowFactory(m_eglTestCtx.getNativeDisplayFactory(), m_testCtx.getCommandLine());
+	const eglu::NativePixmapFactory*	pixmapFactory	= eglu::selectNativePixmapFactory(m_eglTestCtx.getNativeDisplayFactory(), m_testCtx.getCommandLine());
 
-	logConfigInfo(m_testCtx.getLog(), display.getEGLDisplay(), config, m_nativeType, waitFrames);
+	logConfigInfo(m_testCtx.getLog(), egl, display, config, m_nativeType, waitFrames);
 
-	checkSupport(m_eglTestCtx, m_nativeType);
+	checkSupport(m_nativeType, windowFactory, pixmapFactory);
 
-	eglu::UniqueContext	context(display.getEGLDisplay(), createGLES2Context(display.getEGLDisplay(), config));
-	glw::Functions		gl;
+	eglu::UniqueContext 	context		(egl, display, createGLES2Context(egl, display, config));
+	glw::Functions			gl;
 
-	m_eglTestCtx.getGLFunctions(gl, glu::ApiType::es(2,0));
+	m_eglTestCtx.initGLFunctions(&gl, glu::ApiType::es(2,0));
 
 	switch (m_nativeType)
 	{
 		case NATIVETYPE_WINDOW:
 		{
-			de::UniquePtr<eglu::NativeWindow> nativeWindow(m_eglTestCtx.createNativeWindow(display.getEGLDisplay(), config, DE_NULL, width, height, eglu::WindowParams::VISIBILITY_VISIBLE));
+			de::UniquePtr<eglu::NativeWindow>	nativeWindow	(windowFactory->createWindow(&m_eglTestCtx.getNativeDisplay(), display, config, DE_NULL, eglu::WindowParams(width, height, eglu::WindowParams::VISIBILITY_VISIBLE)));
 
-			if (!testNativeWindow(m_testCtx.getLog(), m_eglTestCtx.getNativeDisplay(), *nativeWindow, display.getEGLDisplay(), *context, config, gl, m_render, waitFrames))
+			if (!testNativeWindow(m_testCtx.getLog(), m_eglTestCtx.getNativeDisplay(), *nativeWindow, display, *context, config, gl, m_render, waitFrames))
 				m_testCtx.setTestResult(QP_TEST_RESULT_FAIL, "Invalid color rendered");
 
 			break;
@@ -549,9 +577,9 @@
 
 		case NATIVETYPE_PIXMAP:
 		{
-			de::UniquePtr<eglu::NativePixmap> nativePixmap(m_eglTestCtx.createNativePixmap(display.getEGLDisplay(), config, DE_NULL, width, height));
+			de::UniquePtr<eglu::NativePixmap> nativePixmap		(pixmapFactory->createPixmap(&m_eglTestCtx.getNativeDisplay(), display, config, DE_NULL, width, height));
 
-			if (!testNativePixmap(m_testCtx.getLog(), m_eglTestCtx.getNativeDisplay(), *nativePixmap, width, height, display.getEGLDisplay(), *context, config, gl, m_render))
+			if (!testNativePixmap(m_testCtx.getLog(), m_eglTestCtx.getNativeDisplay(), *nativePixmap, width, height, display, *context, config, gl, m_render))
 				m_testCtx.setTestResult(QP_TEST_RESULT_FAIL, "Invalid color rendered");
 
 			break;
@@ -559,9 +587,9 @@
 
 		case NATIVETYPE_PBUFFER_COPY_TO_PIXMAP:
 		{
-			de::UniquePtr<eglu::NativePixmap> nativePixmap(m_eglTestCtx.createNativePixmap(display.getEGLDisplay(), config, DE_NULL, width, height));
+			de::UniquePtr<eglu::NativePixmap> nativePixmap		(pixmapFactory->createPixmap(&m_eglTestCtx.getNativeDisplay(), display, config, DE_NULL, width, height));
 
-			if (!testNativePixmapCopy(m_testCtx.getLog(), *nativePixmap, width, height, display.getEGLDisplay(), *context, config, gl, m_render))
+			if (!testNativePixmapCopy(m_testCtx.getLog(), egl, *nativePixmap, width, height, display, *context, config, gl, m_render))
 				m_testCtx.setTestResult(QP_TEST_RESULT_FAIL, "Invalid color rendered");
 
 			break;
@@ -572,35 +600,41 @@
 	}
 }
 
+template <deUint32 Type>
+static bool surfaceType (const eglu::CandidateConfig& c)
+{
+	return (c.surfaceType() & Type) == Type;
+}
+
 void addTestGroups (EglTestContext& eglTestCtx, TestCaseGroup* group, NativeCoordMappingCase::NativeType type)
 {
-	eglu::FilterList filters;
+	eglu::FilterList baseFilters;
 
 	switch (type)
 	{
 		case NativeCoordMappingCase::NATIVETYPE_WINDOW:
-			filters << (eglu::ConfigSurfaceType() & EGL_WINDOW_BIT);
+			baseFilters << surfaceType<EGL_WINDOW_BIT>;
 			break;
 
 		case NativeCoordMappingCase::NATIVETYPE_PIXMAP:
-			filters << (eglu::ConfigSurfaceType() & EGL_PIXMAP_BIT);
+			baseFilters << surfaceType<EGL_PIXMAP_BIT>;
 			break;
 
 		case NativeCoordMappingCase::NATIVETYPE_PBUFFER_COPY_TO_PIXMAP:
-			filters << (eglu::ConfigSurfaceType() & EGL_PBUFFER_BIT);
+			baseFilters << surfaceType<EGL_PBUFFER_BIT>;
 			break;
 
 		default:
 			DE_ASSERT(DE_FALSE);
 	}
 
-	vector<NamedConfigIdSet> configIdSets;
-	NamedConfigIdSet::getDefaultSets(configIdSets, eglTestCtx.getConfigs(), filters);
+	vector<NamedFilterList> filterLists;
+	getDefaultFilterLists(filterLists, baseFilters);
 
-	for (vector<NamedConfigIdSet>::iterator i = configIdSets.begin(); i != configIdSets.end(); i++)
+	for (vector<NamedFilterList>::iterator i = filterLists.begin(); i != filterLists.end(); i++)
 	{
-		group->addChild(new NativeCoordMappingCase(eglTestCtx, (string(i->getName()) + "_clear").c_str(), i->getDescription(), false, type, i->getConfigIds()));
-		group->addChild(new NativeCoordMappingCase(eglTestCtx, (string(i->getName()) + "_render").c_str(), i->getDescription(), true, type, i->getConfigIds()));
+		group->addChild(new NativeCoordMappingCase(eglTestCtx, (string(i->getName()) + "_clear").c_str(), i->getDescription(), false, type, *i));
+		group->addChild(new NativeCoordMappingCase(eglTestCtx, (string(i->getName()) + "_render").c_str(), i->getDescription(), true, type, *i));
 	}
 }
 
diff --git a/modules/egl/teglNegativeApiTests.cpp b/modules/egl/teglNegativeApiTests.cpp
index 920abe5..3961eaa 100755
--- a/modules/egl/teglNegativeApiTests.cpp
+++ b/modules/egl/teglNegativeApiTests.cpp
@@ -33,6 +33,32 @@
 namespace egl
 {
 
+using namespace eglw;
+
+template <deUint32 Type>
+static bool renderable (const eglu::CandidateConfig& c)
+{
+	return (c.renderableType() & Type) == Type;
+}
+
+template <deUint32 Type>
+static bool notRenderable (const eglu::CandidateConfig& c)
+{
+	return (c.renderableType() & Type) == 0;
+}
+
+template <deUint32 Bits>
+static bool surfaceBits (const eglu::CandidateConfig& c)
+{
+	return (c.surfaceType() & Bits) == Bits;
+}
+
+template <deUint32 Bits>
+static bool notSurfaceBits (const eglu::CandidateConfig& c)
+{
+	return (c.surfaceType() & Bits) == 0;
+}
+
 NegativeApiTests::NegativeApiTests (EglTestContext& eglTestCtx)
 	: TestCaseGroup(eglTestCtx, "negative_api", "Negative API Tests")
 {
@@ -85,7 +111,7 @@
 	//  * eglWaitNative()
 	//    - EGL_BAD_CURRENT_SURFACE is generated if the surface associated with the current context has a native window or pixmap, and that window or pixmap is no longer valid
 
-	using namespace tcu::egl;
+	using namespace eglw;
 	using namespace eglu;
 
 	static const EGLint s_emptyAttribList[]			= { EGL_NONE };
@@ -157,20 +183,20 @@
 
 			log << TestLog::Section("Test1", "EGL_BAD_DISPLAY is generated if display is not an EGL display connection");
 
-			expectFalse(eglCopyBuffers(EGL_NO_DISPLAY, EGL_NO_SURFACE, (NativePixmapType)0));
+			expectFalse(eglCopyBuffers(EGL_NO_DISPLAY, EGL_NO_SURFACE, (EGLNativePixmapType)0));
 			expectError(EGL_BAD_DISPLAY);
 
-			expectFalse(eglCopyBuffers((EGLDisplay)-1, EGL_NO_SURFACE, (NativePixmapType)0));
+			expectFalse(eglCopyBuffers((EGLDisplay)-1, EGL_NO_SURFACE, (EGLNativePixmapType)0));
 			expectError(EGL_BAD_DISPLAY);
 
 			log << TestLog::EndSection;
 
 			log << TestLog::Section("Test2", "EGL_BAD_SURFACE is generated if surface is not an EGL surface");
 
-			expectFalse(eglCopyBuffers(display, EGL_NO_SURFACE, (NativePixmapType)0));
+			expectFalse(eglCopyBuffers(display, EGL_NO_SURFACE, (EGLNativePixmapType)0));
 			expectError(EGL_BAD_SURFACE);
 
-			expectFalse(eglCopyBuffers(display, (EGLSurface)-1, (NativePixmapType)0));
+			expectFalse(eglCopyBuffers(display, (EGLSurface)-1, (EGLNativePixmapType)0));
 			expectError(EGL_BAD_SURFACE);
 
 			log << TestLog::EndSection;
@@ -261,7 +287,7 @@
 			if (isAPISupported(EGL_OPENGL_API))
 			{
 				EGLConfig es1OnlyConfig;
-				if (getConfig(&es1OnlyConfig, FilterList() << (ConfigRenderableType() & EGL_OPENGL_ES_BIT) << (ConfigRenderableType() ^ EGL_OPENGL_BIT)))
+				if (getConfig(&es1OnlyConfig, FilterList() << renderable<EGL_OPENGL_ES_BIT> << notRenderable<EGL_OPENGL_BIT>))
 				{
 					expectTrue(eglBindAPI(EGL_OPENGL_API));
 					expectNoContext(eglCreateContext(display, es1OnlyConfig, EGL_NO_CONTEXT, s_es1ContextAttribList));
@@ -269,7 +295,7 @@
 				}
 
 				EGLConfig es2OnlyConfig;
-				if (getConfig(&es2OnlyConfig, FilterList() << (ConfigRenderableType() & EGL_OPENGL_ES2_BIT) << (ConfigRenderableType() ^ EGL_OPENGL_BIT)))
+				if (getConfig(&es2OnlyConfig, FilterList() << renderable<EGL_OPENGL_ES2_BIT> << notRenderable<EGL_OPENGL_BIT>))
 				{
 					expectTrue(eglBindAPI(EGL_OPENGL_API));
 					expectNoContext(eglCreateContext(display, es2OnlyConfig, EGL_NO_CONTEXT, s_es2ContextAttribList));
@@ -277,7 +303,7 @@
 				}
 
 				EGLConfig vgOnlyConfig;
-				if (getConfig(&vgOnlyConfig, FilterList() << (ConfigRenderableType() & EGL_OPENVG_BIT) << (ConfigRenderableType() ^ EGL_OPENGL_BIT)))
+				if (getConfig(&vgOnlyConfig, FilterList() << renderable<EGL_OPENVG_BIT> << notRenderable<EGL_OPENGL_BIT>))
 				{
 					expectTrue(eglBindAPI(EGL_OPENGL_API));
 					expectNoContext(eglCreateContext(display, vgOnlyConfig, EGL_NO_CONTEXT, s_emptyAttribList));
@@ -288,7 +314,7 @@
 			if (isAPISupported(EGL_OPENGL_ES_API))
 			{
 				EGLConfig glOnlyConfig;
-				if (getConfig(&glOnlyConfig, FilterList() << (ConfigRenderableType() & EGL_OPENGL_BIT) << (ConfigRenderableType() ^ (EGL_OPENGL_ES_BIT|EGL_OPENGL_ES2_BIT))))
+				if (getConfig(&glOnlyConfig, FilterList() << renderable<EGL_OPENGL_BIT> << notRenderable<EGL_OPENGL_ES_BIT|EGL_OPENGL_ES2_BIT>))
 				{
 					expectTrue(eglBindAPI(EGL_OPENGL_ES_API));
 					expectNoContext(eglCreateContext(display, glOnlyConfig, EGL_NO_CONTEXT, s_emptyAttribList));
@@ -296,7 +322,7 @@
 				}
 
 				EGLConfig vgOnlyConfig;
-				if (getConfig(&vgOnlyConfig, FilterList() << (ConfigRenderableType() & EGL_OPENVG_BIT) << (ConfigRenderableType() ^ (EGL_OPENGL_ES_BIT|EGL_OPENGL_ES2_BIT))))
+				if (getConfig(&vgOnlyConfig, FilterList() << renderable<EGL_OPENVG_BIT> << notRenderable<EGL_OPENGL_ES_BIT|EGL_OPENGL_ES2_BIT>))
 				{
 					expectTrue(eglBindAPI(EGL_OPENGL_ES_API));
 					expectNoContext(eglCreateContext(display, vgOnlyConfig, EGL_NO_CONTEXT, s_emptyAttribList));
@@ -307,7 +333,7 @@
 			if (isAPISupported(EGL_OPENVG_API))
 			{
 				EGLConfig glOnlyConfig;
-				if (getConfig(&glOnlyConfig, FilterList() << (ConfigRenderableType() & EGL_OPENGL_BIT) << (ConfigRenderableType() ^ EGL_OPENVG_BIT)))
+				if (getConfig(&glOnlyConfig, FilterList() << renderable<EGL_OPENGL_BIT> << notRenderable<EGL_OPENVG_BIT>))
 				{
 					expectTrue(eglBindAPI(EGL_OPENVG_API));
 					expectNoContext(eglCreateContext(display, glOnlyConfig, EGL_NO_CONTEXT, s_emptyAttribList));
@@ -315,7 +341,7 @@
 				}
 
 				EGLConfig es1OnlyConfig;
-				if (getConfig(&es1OnlyConfig, FilterList() << (ConfigRenderableType() & EGL_OPENGL_ES_BIT) << (ConfigRenderableType() ^ EGL_OPENVG_BIT)))
+				if (getConfig(&es1OnlyConfig, FilterList() << renderable<EGL_OPENGL_ES_BIT> << notRenderable<EGL_OPENVG_BIT>))
 				{
 					expectTrue(eglBindAPI(EGL_OPENVG_API));
 					expectNoContext(eglCreateContext(display, es1OnlyConfig, EGL_NO_CONTEXT, s_es1ContextAttribList));
@@ -323,7 +349,7 @@
 				}
 
 				EGLConfig es2OnlyConfig;
-				if (getConfig(&es2OnlyConfig, FilterList() << (ConfigRenderableType() & EGL_OPENGL_ES2_BIT) << (ConfigRenderableType() ^ EGL_OPENVG_BIT)))
+				if (getConfig(&es2OnlyConfig, FilterList() << renderable<EGL_OPENGL_ES2_BIT> << notRenderable<EGL_OPENVG_BIT>))
 				{
 					expectTrue(eglBindAPI(EGL_OPENVG_API));
 					expectNoContext(eglCreateContext(display, es2OnlyConfig, EGL_NO_CONTEXT, s_es2ContextAttribList));
@@ -338,7 +364,7 @@
 			if (isAPISupported(EGL_OPENGL_ES_API))
 			{
 				EGLConfig notES1Config;
-				if (getConfig(&notES1Config, FilterList() << (ConfigRenderableType() ^ EGL_OPENGL_ES_BIT)))
+				if (getConfig(&notES1Config, FilterList() << notRenderable<EGL_OPENGL_ES_BIT>))
 				{
 					expectTrue(eglBindAPI(EGL_OPENGL_ES_API));
 					expectNoContext(eglCreateContext(display, notES1Config, EGL_NO_CONTEXT, s_es1ContextAttribList));
@@ -353,7 +379,7 @@
 			if (isAPISupported(EGL_OPENGL_ES_API))
 			{
 				EGLConfig notES2Config;
-				if (getConfig(&notES2Config, FilterList() << (ConfigRenderableType() ^ EGL_OPENGL_ES2_BIT)))
+				if (getConfig(&notES2Config, FilterList() << notRenderable<EGL_OPENGL_ES2_BIT>))
 				{
 					expectTrue(eglBindAPI(EGL_OPENGL_ES_API));
 					expectNoContext(eglCreateContext(display, notES2Config, EGL_NO_CONTEXT, s_es2ContextAttribList));
@@ -368,7 +394,7 @@
 			if (isAPISupported(EGL_OPENGL_API))
 			{
 				EGLConfig glConfig;
-				if (getConfig(&glConfig, FilterList() << (ConfigRenderableType() & EGL_OPENGL_BIT)))
+				if (getConfig(&glConfig, FilterList() << renderable<EGL_OPENGL_BIT>))
 				{
 					expectTrue(eglBindAPI(EGL_OPENGL_API));
 					expectNoContext(eglCreateContext(display, glConfig, EGL_NO_CONTEXT, s_es1ContextAttribList));
@@ -379,7 +405,7 @@
 			if (isAPISupported(EGL_OPENVG_API))
 			{
 				EGLConfig vgConfig;
-				if (getConfig(&vgConfig, FilterList() << (ConfigRenderableType() & EGL_OPENVG_BIT)))
+				if (getConfig(&vgConfig, FilterList() << renderable<EGL_OPENVG_BIT>))
 				{
 					expectTrue(eglBindAPI(EGL_OPENVG_API));
 					expectNoContext(eglCreateContext(display, vgConfig, EGL_NO_CONTEXT, s_es1ContextAttribList));
@@ -392,8 +418,8 @@
 				bool		gotConfig	= false;
 				EGLConfig	esConfig;
 
-				gotConfig = getConfig(&esConfig, FilterList() << (ConfigRenderableType() & EGL_OPENGL_ES_BIT)) ||
-							getConfig(&esConfig, FilterList() << (ConfigRenderableType() & EGL_OPENGL_ES2_BIT));
+				gotConfig = getConfig(&esConfig, FilterList() << renderable<EGL_OPENGL_ES_BIT>) ||
+							getConfig(&esConfig, FilterList() << renderable<EGL_OPENGL_ES2_BIT>);
 
 				if (gotConfig)
 				{
@@ -477,8 +503,8 @@
 		s_invalidEsPbufferAttrib1
 	};
 
-	static const EGLint s_vgPreMultAlphaPbufferAttrib[] = { EGL_VG_ALPHA_FORMAT, EGL_VG_ALPHA_FORMAT_PRE, EGL_WIDTH, 64, EGL_HEIGHT, 64, EGL_NONE };
-	static const EGLint s_vgLinearColorspacePbufferAttrib[] = { EGL_VG_COLORSPACE, EGL_VG_COLORSPACE_LINEAR, EGL_WIDTH, 64, EGL_HEIGHT, 64, EGL_NONE };
+	static const EGLint s_vgPreMultAlphaPbufferAttrib[] = { EGL_ALPHA_FORMAT, EGL_ALPHA_FORMAT_PRE, EGL_WIDTH, 64, EGL_HEIGHT, 64, EGL_NONE };
+	static const EGLint s_vgLinearColorspacePbufferAttrib[] = { EGL_COLORSPACE, EGL_VG_COLORSPACE_LINEAR, EGL_WIDTH, 64, EGL_HEIGHT, 64, EGL_NONE };
 
 	TEGL_ADD_API_CASE(create_pbuffer_surface, "eglCreatePbufferSurface() negative tests",
 		{
@@ -506,7 +532,7 @@
 
 			// Generic pbuffer-capable config
 			EGLConfig genericConfig;
-			if (getConfig(&genericConfig, FilterList() << (ConfigSurfaceType() & EGL_PBUFFER_BIT)))
+			if (getConfig(&genericConfig, FilterList() << surfaceBits<EGL_PBUFFER_BIT>))
 			{
 				for (int ndx = 0; ndx < DE_LENGTH_OF_ARRAY(s_invalidGenericPbufferAttribs); ndx++)
 				{
@@ -520,7 +546,7 @@
 			log << TestLog::Section("Test4", "EGL_BAD_MATCH is generated if config does not support rendering to pixel buffers");
 
 			EGLConfig noPbufferConfig;
-			if (getConfig(&noPbufferConfig, FilterList() << (ConfigSurfaceType() ^ EGL_PBUFFER_BIT)))
+			if (getConfig(&noPbufferConfig, FilterList() << notSurfaceBits<EGL_PBUFFER_BIT>))
 			{
 				expectNoSurface(eglCreatePbufferSurface(display, noPbufferConfig, s_validGenericPbufferAttrib));
 				expectError(EGL_BAD_MATCH);
@@ -531,7 +557,7 @@
 			log << TestLog::Section("Test5", "EGL_BAD_ATTRIBUTE is generated if attrib_list contains any of the attributes EGL_MIPMAP_TEXTURE, EGL_TEXTURE_FORMAT, or EGL_TEXTURE_TARGET, and config does not support OpenGL ES rendering");
 
 			EGLConfig noEsConfig;
-			if (getConfig(&noEsConfig, FilterList() << (ConfigRenderableType() ^ (EGL_OPENGL_ES_BIT|EGL_OPENGL_ES2_BIT))))
+			if (getConfig(&noEsConfig, FilterList() << notRenderable<EGL_OPENGL_ES_BIT|EGL_OPENGL_ES2_BIT>))
 			{
 				for (int ndx = 0; ndx < DE_LENGTH_OF_ARRAY(s_invalidNoEsPbufferAttribs); ndx++)
 				{
@@ -546,8 +572,8 @@
 
 			// ES1 or ES2 config.
 			EGLConfig	esConfig;
-			bool		gotEsConfig	= getConfig(&esConfig, FilterList() << (ConfigRenderableType() & EGL_OPENGL_ES_BIT)) ||
-									  getConfig(&esConfig, FilterList() << (ConfigRenderableType() & EGL_OPENGL_ES2_BIT));
+			bool		gotEsConfig	= getConfig(&esConfig, FilterList() << renderable<EGL_OPENGL_ES_BIT>) ||
+									  getConfig(&esConfig, FilterList() << renderable<EGL_OPENGL_ES2_BIT>);
 			if (gotEsConfig)
 			{
 				for (int ndx = 0; ndx < DE_LENGTH_OF_ARRAY(s_invalidEsPbufferAttribs); ndx++)
@@ -562,14 +588,14 @@
 			log << TestLog::Section("Test7", "EGL_BAD_MATCH is generated if config does not support the specified OpenVG alpha format attribute or colorspace attribute");
 
 			EGLConfig vgNoPreConfig;
-			if (getConfig(&vgNoPreConfig, FilterList() << (ConfigRenderableType() & EGL_OPENVG_BIT) << (ConfigSurfaceType() ^ EGL_VG_ALPHA_FORMAT_PRE)))
+			if (getConfig(&vgNoPreConfig, FilterList() << renderable<EGL_OPENVG_BIT> << notSurfaceBits<EGL_VG_ALPHA_FORMAT_PRE_BIT>))
 			{
 				expectNoSurface(eglCreatePbufferSurface(display, vgNoPreConfig, s_vgPreMultAlphaPbufferAttrib));
 				expectError(EGL_BAD_MATCH);
 			}
 
 			EGLConfig vgNoLinearConfig;
-			if (getConfig(&vgNoLinearConfig, FilterList() << (ConfigRenderableType() & EGL_OPENVG_BIT) << (ConfigSurfaceType() ^ EGL_VG_COLORSPACE_LINEAR_BIT)))
+			if (getConfig(&vgNoLinearConfig, FilterList() << renderable<EGL_OPENVG_BIT> << notSurfaceBits<EGL_VG_COLORSPACE_LINEAR_BIT>))
 			{
 				expectNoSurface(eglCreatePbufferSurface(display, vgNoLinearConfig, s_vgLinearColorspacePbufferAttrib));
 				expectError(EGL_BAD_MATCH);
@@ -604,7 +630,7 @@
 
 			// Any pixmap-capable config.
 			EGLConfig pixmapConfig;
-			if (getConfig(&pixmapConfig, FilterList() << (ConfigSurfaceType() & EGL_PIXMAP_BIT)))
+			if (getConfig(&pixmapConfig, FilterList() << surfaceBits<EGL_PIXMAP_BIT>))
 			{
 				expectNoSurface(eglCreatePixmapSurface(display, pixmapConfig, DE_NULL, s_emptyAttribList));
 				expectError(EGL_BAD_NATIVE_PIXMAP);
@@ -642,7 +668,7 @@
 
 			// Any window-capable config.
 			EGLConfig windowConfig;
-			if (getConfig(&windowConfig, FilterList() << (ConfigSurfaceType() & EGL_WINDOW_BIT)))
+			if (getConfig(&windowConfig, FilterList() << surfaceBits<EGL_WINDOW_BIT>))
 			{
 				expectNoSurface(eglCreateWindowSurface(display, windowConfig, DE_NULL, s_emptyAttribList));
 				expectError(EGL_BAD_NATIVE_WINDOW);
@@ -814,7 +840,7 @@
 			EGLSurface surface = EGL_NO_SURFACE;
 			{
 				EGLConfig config;
-				if (getConfig(&config, FilterList() << (ConfigSurfaceType() & EGL_PBUFFER_BIT)))
+				if (getConfig(&config, FilterList() << surfaceBits<EGL_PBUFFER_BIT>))
 				{
 					surface = eglCreatePbufferSurface(display, config, s_validGenericPbufferAttrib);
 					expectError(EGL_SUCCESS);
@@ -915,7 +941,7 @@
 			// Create ES2 context.
 			EGLConfig	config		= DE_NULL;
 			EGLContext	context		= DE_NULL;
-			bool		gotConfig	= getConfig(&config, FilterList() << (ConfigRenderableType() & EGL_OPENGL_ES2_BIT));
+			bool		gotConfig	= getConfig(&config, FilterList() << renderable<EGL_OPENGL_ES2_BIT>);
 
 			if (gotConfig)
 			{
@@ -1002,7 +1028,7 @@
 			EGLSurface surface = EGL_NO_SURFACE;
 			{
 				EGLConfig config;
-				if (getConfig(&config, FilterList() << (ConfigSurfaceType() & EGL_PBUFFER_BIT)))
+				if (getConfig(&config, FilterList() << surfaceBits<EGL_PBUFFER_BIT>))
 				{
 					surface = eglCreatePbufferSurface(display, config, s_validGenericPbufferAttrib);
 					expectError(EGL_SUCCESS);
@@ -1087,7 +1113,7 @@
 				EGLSurface surface = EGL_NO_SURFACE;
 				{
 					EGLConfig config;
-					if (getConfig(&config, FilterList() << (ConfigSurfaceType() & EGL_PBUFFER_BIT)))
+					if (getConfig(&config, FilterList() << surfaceBits<EGL_PBUFFER_BIT>))
 					{
 						surface = eglCreatePbufferSurface(display, config, s_validGenericPbufferAttrib);
 						expectError(EGL_SUCCESS);
@@ -1121,7 +1147,7 @@
 				EGLSurface surface = EGL_NO_SURFACE;
 				{
 					EGLConfig config;
-					if (getConfig(&config, FilterList() << (ConfigSurfaceType() & EGL_PBUFFER_BIT) << (ConfigSurfaceType() ^ EGL_MULTISAMPLE_RESOLVE_BOX_BIT)))
+					if (getConfig(&config, FilterList() << surfaceBits<EGL_PBUFFER_BIT> << notSurfaceBits<EGL_MULTISAMPLE_RESOLVE_BOX_BIT>))
 					{
 						surface = eglCreatePbufferSurface(display, config, s_validGenericPbufferAttrib);
 						expectError(EGL_SUCCESS);
@@ -1152,7 +1178,7 @@
 				EGLSurface surface = EGL_NO_SURFACE;
 				{
 					EGLConfig config;
-					if (getConfig(&config, FilterList() << (ConfigSurfaceType() & EGL_PBUFFER_BIT) << (ConfigSurfaceType() ^ EGL_SWAP_BEHAVIOR_PRESERVED_BIT)))
+					if (getConfig(&config, FilterList() << surfaceBits<EGL_PBUFFER_BIT> << notSurfaceBits<EGL_SWAP_BEHAVIOR_PRESERVED_BIT>))
 					{
 						surface = eglCreatePbufferSurface(display, config, s_validGenericPbufferAttrib);
 						expectError(EGL_SUCCESS);
diff --git a/modules/egl/teglPreservingSwapTests.cpp b/modules/egl/teglPreservingSwapTests.cpp
index e94fb44..11a377b 100644
--- a/modules/egl/teglPreservingSwapTests.cpp
+++ b/modules/egl/teglPreservingSwapTests.cpp
@@ -27,13 +27,16 @@
 #include "tcuTestLog.hpp"
 #include "tcuSurface.hpp"
 #include "tcuTextureUtil.hpp"
-#include "tcuEgl.hpp"
 
 #include "egluNativeWindow.hpp"
 #include "egluUtil.hpp"
 
+#include "eglwLibrary.hpp"
+#include "eglwEnums.hpp"
+
 #include "gluDefs.hpp"
 #include "gluRenderContext.hpp"
+#include "gluShaderProgram.hpp"
 
 #include "glwDefs.hpp"
 #include "glwEnums.hpp"
@@ -49,6 +52,8 @@
 using std::vector;
 using std::string;
 
+using namespace eglw;
+
 namespace deqp
 {
 namespace egl
@@ -83,10 +88,11 @@
 	const DrawType				m_preSwapDrawType;
 	const DrawType				m_postSwapDrawType;
 
+	EGLDisplay					m_eglDisplay;
 	eglu::NativeWindow*			m_window;
-	tcu::egl::WindowSurface*	m_eglSurface;
+	EGLSurface					m_eglSurface;
 	EGLConfig					m_eglConfig;
-	tcu::egl::Context*			m_eglContext;
+	EGLContext					m_eglContext;
 	glw::Functions				m_gl;
 
 	GLES2Program*				m_gles2Program;
@@ -106,7 +112,7 @@
 
 private:
 	const glw::Functions&	m_gl;
-	glw::GLuint				m_glProgram;
+	glu::ShaderProgram		m_glProgram;
 	glw::GLuint				m_coordLoc;
 	glw::GLuint				m_colorLoc;
 
@@ -114,91 +120,41 @@
 							GLES2Program	(const GLES2Program&);
 };
 
+static glu::ProgramSources getSources (void)
+{
+	const char* const vertexShaderSource =
+		"attribute mediump vec4 a_pos;\n"
+		"attribute mediump vec4 a_color;\n"
+		"varying mediump vec4 v_color;\n"
+		"void main(void)\n"
+		"{\n"
+		"\tv_color = a_color;\n"
+		"\tgl_Position = a_pos;\n"
+		"}";
+
+	const char* const fragmentShaderSource =
+		"varying mediump vec4 v_color;\n"
+		"void main(void)\n"
+		"{\n"
+		"\tgl_FragColor = v_color;\n"
+		"}";
+
+	return glu::makeVtxFragSources(vertexShaderSource, fragmentShaderSource);
+}
+
 GLES2Program::GLES2Program (const glw::Functions& gl)
 	: m_gl			(gl)
-	, m_glProgram	(0)
+	, m_glProgram	(gl, getSources())
 	, m_coordLoc	((glw::GLuint)-1)
 	, m_colorLoc	((glw::GLuint)-1)
 {
-	const char* const vertexShaderSource =
-	"attribute mediump vec4 a_pos;\n"
-	"attribute mediump vec4 a_color;\n"
-	"varying mediump vec4 v_color;\n"
-	"void main(void)\n"
-	"{\n"
-	"\tv_color = a_color;\n"
-	"\tgl_Position = a_pos;\n"
-	"}";
-
-	const char* const fragmentShaderSource =
-	"varying mediump vec4 v_color;\n"
-	"void main(void)\n"
-	"{\n"
-	"\tgl_FragColor = v_color;\n"
-	"}";
-
-	glw::GLuint	vtxShader	= (glw::GLuint)-1;
-	glw::GLuint	fragShader	= (glw::GLuint)-1;
-
-	try
-	{
-		vtxShader = m_gl.createShader(GL_VERTEX_SHADER);
-		fragShader = m_gl.createShader(GL_FRAGMENT_SHADER);
-
-		m_glProgram	= m_gl.createProgram();
-
-		GLU_EXPECT_NO_ERROR(m_gl.getError(), "Failed to create resources for shader program");
-
-		m_gl.shaderSource(vtxShader, 1, &vertexShaderSource, DE_NULL);
-		m_gl.shaderSource(fragShader, 1, &fragmentShaderSource, DE_NULL);
-		GLU_EXPECT_NO_ERROR(m_gl.getError(), "Failed to set shader sources");
-
-		m_gl.compileShader(vtxShader);
-		m_gl.compileShader(fragShader);
-		GLU_EXPECT_NO_ERROR(m_gl.getError(), "Shader compilation failed");
-
-		m_gl.attachShader(m_glProgram, vtxShader);
-		m_gl.attachShader(m_glProgram, fragShader);
-		GLU_EXPECT_NO_ERROR(m_gl.getError(), "Failed to attach shaders to program");
-
-		m_gl.linkProgram(m_glProgram);
-		GLU_EXPECT_NO_ERROR(m_gl.getError(), "Failed to link program");
-
-		m_gl.deleteShader(fragShader);
-		fragShader = (glw::GLuint)-1;
-		m_gl.deleteShader(vtxShader);
-		vtxShader = (glw::GLuint)-1;
-		GLU_EXPECT_NO_ERROR(m_gl.getError(), "Failed to delete shaders");
-
-		m_colorLoc = m_gl.getAttribLocation(m_glProgram, "a_color");
-		m_coordLoc = m_gl.getAttribLocation(m_glProgram, "a_pos");
-		GLU_EXPECT_NO_ERROR(m_gl.getError(), "Failed to get attribute locations");
-
-		TCU_CHECK(m_colorLoc != (glw::GLuint)-1);
-		TCU_CHECK(m_coordLoc != (glw::GLuint)-1);
-
-	}
-	catch (...)
-	{
-		if (vtxShader != (glw::GLuint)-1)
-			m_gl.deleteShader(vtxShader);
-
-		if (fragShader != (glw::GLuint)-1)
-			m_gl.deleteShader(fragShader);
-
-		if (m_glProgram != (glw::GLuint)-1)
-			m_gl.deleteProgram(m_glProgram);
-
-		m_glProgram = (glw::GLuint)-1;
-
-		throw;
-	}
+	m_colorLoc = m_gl.getAttribLocation(m_glProgram.getProgram(), "a_color");
+	m_coordLoc = m_gl.getAttribLocation(m_glProgram.getProgram(), "a_pos");
+	GLU_EXPECT_NO_ERROR(m_gl.getError(), "Failed to get attribute locations");
 }
 
 GLES2Program::~GLES2Program (void)
 {
-	if (m_glProgram != (glw::GLuint)-1)
-		m_gl.deleteProgram(m_glProgram);
 }
 
 void GLES2Program::render (int width, int height, float x1, float y1, float x2, float y2, PreservingSwapTest::DrawType drawType)
@@ -227,7 +183,7 @@
 			127,	127,	127,	255
 		};
 
-		m_gl.useProgram(m_glProgram);
+		m_gl.useProgram(m_glProgram.getProgram());
 		GLU_EXPECT_NO_ERROR(m_gl.getError(), "glUseProgram() failed");
 
 		m_gl.enableVertexAttribArray(m_coordLoc);
@@ -328,9 +284,10 @@
 	, m_readPixelsBeforeSwap	(readPixelsBeforeSwap)
 	, m_preSwapDrawType			(preSwapDrawType)
 	, m_postSwapDrawType		(postSwapDrawType)
+	, m_eglDisplay				(EGL_NO_DISPLAY)
 	, m_window					(DE_NULL)
-	, m_eglSurface				(DE_NULL)
-	, m_eglContext				(DE_NULL)
+	, m_eglSurface				(EGL_NO_SURFACE)
+	, m_eglContext				(EGL_NO_CONTEXT)
 	, m_gles2Program			(DE_NULL)
 	, m_refProgram				(DE_NULL)
 {
@@ -341,31 +298,25 @@
 	deinit();
 }
 
-EGLConfig getEGLConfig (tcu::egl::Display& eglDisplay, bool preserveColorbuffer)
+EGLConfig getEGLConfig (const Library& egl, EGLDisplay eglDisplay, bool preserveColorbuffer)
 {
-	vector<EGLConfig>	configs;
-	const EGLint		attribList[] =
+	const EGLint attribList[] =
 	{
 		EGL_SURFACE_TYPE,		EGL_WINDOW_BIT | (preserveColorbuffer ? EGL_SWAP_BEHAVIOR_PRESERVED_BIT : 0),
 		EGL_RENDERABLE_TYPE,	EGL_OPENGL_ES2_BIT,
 		EGL_NONE
 	};
 
-	eglDisplay.chooseConfig(attribList, configs);
-
-	if (configs.size() == 0)
-		return DE_NULL;
-	else
-		return configs[0];
+	return eglu::chooseSingleConfig(egl, eglDisplay, &attribList[0]);
 }
 
-void clearColorScreen(const glw::Functions& gl, float red, float green, float blue, float alpha)
+void clearColorScreen (const glw::Functions& gl, float red, float green, float blue, float alpha)
 {
 	gl.clearColor(red, green, blue, alpha);
 	gl.clear(GL_COLOR_BUFFER_BIT);
 }
 
-void clearColorReference(tcu::Surface* ref, float red, float green, float blue, float alpha)
+void clearColorReference (tcu::Surface* ref, float red, float green, float blue, float alpha)
 {
 	tcu::clear(ref->getAccess(), tcu::Vec4(red, green, blue, alpha));
 }
@@ -377,34 +328,45 @@
 
 void PreservingSwapTest::initEGLSurface (EGLConfig config)
 {
-	m_window		= m_eglTestCtx.createNativeWindow(m_eglTestCtx.getDisplay().getEGLDisplay(), config, DE_NULL, 480, 480, eglu::parseWindowVisibility(m_testCtx.getCommandLine()));
-	m_eglSurface	= new tcu::egl::WindowSurface(m_eglTestCtx.getDisplay(), eglu::createWindowSurface(m_eglTestCtx.getNativeDisplay(), *m_window, m_eglTestCtx.getDisplay().getEGLDisplay(), config, DE_NULL));
+	const eglu::NativeWindowFactory*	factory	= eglu::selectNativeWindowFactory(m_eglTestCtx.getNativeDisplayFactory(), m_testCtx.getCommandLine());
+
+	if (!factory)
+		TCU_THROW(NotSupportedError, "Windows not supported");
+
+	m_window		= factory->createWindow(&m_eglTestCtx.getNativeDisplay(), m_eglDisplay, config, DE_NULL, eglu::WindowParams(480, 480, eglu::parseWindowVisibility(m_testCtx.getCommandLine())));
+	m_eglSurface	= eglu::createWindowSurface(m_eglTestCtx.getNativeDisplay(), *m_window, m_eglDisplay, config, DE_NULL);
 }
 
 void PreservingSwapTest::initEGLContext (EGLConfig config)
 {
-	const EGLint attribList[] =
+	const Library&	egl				= m_eglTestCtx.getLibrary();
+	const EGLint	attribList[]	=
 	{
 		EGL_CONTEXT_CLIENT_VERSION, 2,
 		EGL_NONE
 	};
 
-	m_eglContext = new tcu::egl::Context(m_eglTestCtx.getDisplay(), config, attribList, EGL_OPENGL_ES_API);
+	egl.bindAPI(EGL_OPENGL_ES_API);
+	m_eglContext = egl.createContext(m_eglDisplay, config, EGL_NO_CONTEXT, attribList);
+	EGLU_CHECK_MSG(egl, "eglCreateContext");
+
+	DE_ASSERT(m_eglSurface != EGL_NO_SURFACE);
+	egl.makeCurrent(m_eglDisplay, m_eglSurface, m_eglSurface, m_eglContext);
+	EGLU_CHECK_MSG(egl, "eglMakeCurrent");
 }
 
 void PreservingSwapTest::init (void)
 {
-	m_eglConfig = getEGLConfig(m_eglTestCtx.getDisplay(), m_preserveColorbuffer);
+	m_eglDisplay	= eglu::getAndInitDisplay(m_eglTestCtx.getNativeDisplay());
+	m_eglConfig		= getEGLConfig(m_eglTestCtx.getLibrary(), m_eglDisplay, m_preserveColorbuffer);
 
 	if (m_eglConfig == DE_NULL)
-		throw tcu::NotSupportedError("No supported config found", "", __FILE__, __LINE__);
+		TCU_THROW(NotSupportedError, "No supported config found");
 
 	initEGLSurface(m_eglConfig);
 	initEGLContext(m_eglConfig);
 
-	m_eglContext->makeCurrent(*m_eglSurface, *m_eglSurface);
-
-	m_eglTestCtx.getGLFunctions(m_gl, glu::ApiType::es(2,0));
+	m_eglTestCtx.initGLFunctions(&m_gl, glu::ApiType::es(2,0));
 
 	m_gles2Program	= new GLES2Program(m_gl);
 	m_refProgram	= new ReferenceProgram();
@@ -412,17 +374,32 @@
 
 void PreservingSwapTest::deinit (void)
 {
+	const Library& egl = m_eglTestCtx.getLibrary();
+
 	delete m_refProgram;
 	m_refProgram = DE_NULL;
 
 	delete m_gles2Program;
 	m_gles2Program = DE_NULL;
 
-	delete m_eglContext;
-	m_eglContext = DE_NULL;
+	if (m_eglContext != EGL_NO_CONTEXT)
+	{
+		egl.makeCurrent(m_eglDisplay, EGL_NO_SURFACE, EGL_NO_SURFACE, EGL_NO_CONTEXT);
+		egl.destroyContext(m_eglDisplay, m_eglContext);
+		m_eglContext = EGL_NO_CONTEXT;
+	}
 
-	delete m_eglSurface;
-	m_eglSurface = DE_NULL;
+	if (m_eglSurface != EGL_NO_SURFACE)
+	{
+		egl.destroySurface(m_eglDisplay, m_eglSurface);
+		m_eglSurface = EGL_NO_SURFACE;
+	}
+
+	if (m_eglDisplay != EGL_NO_DISPLAY)
+	{
+		egl.terminate(m_eglDisplay);
+		m_eglDisplay = EGL_NO_DISPLAY;
+	}
 
 	delete m_window;
 	m_window = DE_NULL;
@@ -443,11 +420,12 @@
 
 TestCase::IterateResult PreservingSwapTest::iterate (void)
 {
+	const Library&	egl				= m_eglTestCtx.getLibrary();
 	tcu::TestLog&	log				= m_testCtx.getLog();
 	de::Random		rnd(m_seed);
 
-	const int		width			= m_eglSurface->getWidth();
-	const int		height			= m_eglSurface->getHeight();
+	const int		width			= eglu::querySurfaceInt(egl, m_eglDisplay, m_eglSurface, EGL_WIDTH);
+	const int		height			= eglu::querySurfaceInt(egl, m_eglDisplay, m_eglSurface, EGL_HEIGHT);
 
 	const float		clearRed		= rnd.getFloat();
 	const float		clearGreen		= rnd.getFloat();
@@ -471,9 +449,9 @@
 	tcu::Surface	preSwapFramebuffer(width, height);
 
 	if (m_preserveColorbuffer)
-		m_eglSurface->setAttribute(EGL_SWAP_BEHAVIOR, EGL_BUFFER_PRESERVED);
+		EGLU_CHECK_CALL(egl, surfaceAttrib(m_eglDisplay, m_eglSurface, EGL_SWAP_BEHAVIOR, EGL_BUFFER_PRESERVED));
 
-	m_eglContext->makeCurrent(*m_eglSurface, *m_eglSurface);
+	EGLU_CHECK_CALL(egl, makeCurrent(m_eglDisplay, m_eglSurface, m_eglSurface, m_eglContext));
 
 	clearColorScreen(m_gl, clearRed, clearGreen, clearBlue, clearAlpha);
 
@@ -496,7 +474,7 @@
 		readPixels(m_gl, &preSwapFramebuffer);
 	}
 
-	m_eglSurface->swapBuffers();
+	EGLU_CHECK_CALL(egl, swapBuffers(m_eglDisplay, m_eglSurface));
 
 	if (m_postSwapDrawType != DRAWTYPE_NONE)
 	{
diff --git a/modules/egl/teglQueryConfigTests.cpp b/modules/egl/teglQueryConfigTests.cpp
index aa08c22..2e820a9 100644
--- a/modules/egl/teglQueryConfigTests.cpp
+++ b/modules/egl/teglQueryConfigTests.cpp
@@ -28,15 +28,14 @@
 #include "tcuCommandLine.hpp"
 #include "egluCallLogWrapper.hpp"
 #include "egluStrUtil.hpp"
+#include "egluUtil.hpp"
+#include "eglwLibrary.hpp"
+#include "eglwEnums.hpp"
 #include "deRandom.hpp"
 
 #include <string>
 #include <vector>
 
-#if !defined(EGL_OPENGL_ES3_BIT_KHR)
-#	define EGL_OPENGL_ES3_BIT_KHR	0x0040
-#endif
-
 namespace deqp
 {
 namespace egl
@@ -44,6 +43,7 @@
 
 using eglu::ConfigInfo;
 using tcu::TestLog;
+using namespace eglw;
 
 static void logConfigAttribute (TestLog& log, EGLenum attrib, EGLint value)
 {
@@ -81,17 +81,26 @@
 {
 public:
 	GetConfigsBoundsCase (EglTestContext& eglTestCtx, const char* name, const char* description)
-		: TestCase	(eglTestCtx, name, description)
-		, CallLogWrapper(eglTestCtx.getTestContext().getLog())
+		: TestCase		(eglTestCtx, name, description)
+		, CallLogWrapper(eglTestCtx.getLibrary(), eglTestCtx.getTestContext().getLog())
+		, m_display		(EGL_NO_DISPLAY)
 	{
 	}
 
 	void init (void)
 	{
+		DE_ASSERT(m_display == EGL_NO_DISPLAY);
+		m_display = eglu::getAndInitDisplay(m_eglTestCtx.getNativeDisplay());
 		m_testCtx.setTestResult(QP_TEST_RESULT_PASS, "Pass");
 	}
 
-	void checkGetConfigsBounds(const tcu::egl::Display& display, de::Random& rnd, const int numConfigAll, const int numConfigRequested)
+	void deinit (void)
+	{
+		m_eglTestCtx.getLibrary().terminate(m_display);
+		m_display = EGL_NO_DISPLAY;
+	}
+
+	void checkGetConfigsBounds (de::Random& rnd, const int numConfigAll, const int numConfigRequested)
 	{
 		tcu::TestLog&			log				= m_testCtx.getLog();
 		std::vector<EGLConfig>	buffer			(numConfigAll + 10);
@@ -105,8 +114,8 @@
 		for (size_t ndx = 0; ndx < magicBuffer.size(); ndx++)	magicBuffer[ndx]	= rnd.getUint32();
 		for (size_t ndx = 0; ndx < buffer.size(); ndx++)		buffer[ndx]			= magicConfigs[ndx];
 
-		eglGetConfigs(display.getEGLDisplay(), &buffer[0], numConfigRequested, &numConfigReturned);
-		TCU_CHECK_EGL();
+		eglGetConfigs(m_display, &buffer[0], numConfigRequested, &numConfigReturned);
+		eglu::checkError(eglGetError(), DE_NULL, __FILE__, __LINE__);
 
 		log << TestLog::Message << numConfigReturned << " configs returned" << TestLog::EndMessage;
 
@@ -146,13 +155,12 @@
 
 	IterateResult iterate (void)
 	{
-		tcu::TestLog&		log			= m_testCtx.getLog();
-		tcu::egl::Display&	display		= m_eglTestCtx.getDisplay();
-		EGLint				numConfigAll;
+		tcu::TestLog&	log		= m_testCtx.getLog();
+		EGLint			numConfigAll;
 
 		enableLogging(true);
 
-		eglGetConfigs(display.getEGLDisplay(), 0, 0, &numConfigAll);
+		eglGetConfigs(m_display, 0, 0, &numConfigAll);
 
 		log << TestLog::Message << numConfigAll << " configs available" << TestLog::EndMessage;
 		log << TestLog::Message << TestLog::EndMessage;
@@ -163,11 +171,11 @@
 
 			for (int i = 0; i < 5; i++)
 			{
-				checkGetConfigsBounds(display, rnd, numConfigAll, rnd.getInt(0, numConfigAll));
+				checkGetConfigsBounds(rnd, numConfigAll, rnd.getInt(0, numConfigAll));
 				log << TestLog::Message << TestLog::EndMessage;
 			}
 
-			checkGetConfigsBounds(display, rnd, numConfigAll, -1);
+			checkGetConfigsBounds(rnd, numConfigAll, -1);
 		}
 		else
 		{
@@ -178,6 +186,9 @@
 
 		return STOP;
 	}
+
+protected:
+	EGLDisplay	m_display;
 };
 
 class GetConfigAttribCase : public TestCase, protected eglu::CallLogWrapper
@@ -185,37 +196,48 @@
 public:
 	GetConfigAttribCase (EglTestContext& eglTestCtx, const char* name, const char* description);
 
-	void			init		();
+	void			init		(void);
+	void			deinit		(void);
 	IterateResult	iterate		(void);
 
 	EGLint			getValue	(EGLConfig config, EGLenum attrib, bool logValue=true);
 
 	virtual void	executeTest	(EGLConfig config) = 0;
+
+protected:
+	EGLDisplay								m_display;
+
 private:
 	std::vector<EGLConfig>					m_configs;
 	std::vector<EGLConfig>::const_iterator	m_configsIter;
 };
 
 GetConfigAttribCase::GetConfigAttribCase (EglTestContext& eglTestCtx, const char* name, const char* description)
-	: TestCase(eglTestCtx, name, description)
-	, CallLogWrapper(eglTestCtx.getTestContext().getLog())
+	: TestCase			(eglTestCtx, name, description)
+	, CallLogWrapper	(eglTestCtx.getLibrary(), eglTestCtx.getTestContext().getLog())
+	, m_display			(EGL_NO_DISPLAY)
 {
 }
 
 void GetConfigAttribCase::init (void)
 {
-	const tcu::egl::Display&	display	= m_eglTestCtx.getDisplay();
-
-	display.getConfigs(m_configs);
-	m_configsIter = m_configs.begin();
+	DE_ASSERT(m_display == EGL_NO_DISPLAY);
+	m_display		= eglu::getAndInitDisplay(m_eglTestCtx.getNativeDisplay());
+	m_configs		= eglu::getConfigs(m_eglTestCtx.getLibrary(), m_display);
+	m_configsIter	= m_configs.begin();
 
 	m_testCtx.setTestResult(QP_TEST_RESULT_PASS, "Pass");
 }
 
+void GetConfigAttribCase::deinit (void)
+{
+	m_eglTestCtx.getLibrary().terminate(m_display);
+	m_display = EGL_NO_DISPLAY;
+}
+
 tcu::TestNode::IterateResult GetConfigAttribCase::iterate (void)
 {
-	tcu::TestLog&		log			= m_testCtx.getLog();
-	tcu::egl::Display&	display		= m_eglTestCtx.getDisplay();
+	tcu::TestLog&	log		= m_testCtx.getLog();
 
 	if (m_configsIter == m_configs.end())
 	{
@@ -227,7 +249,8 @@
 		const EGLConfig	config	= *m_configsIter;
 		EGLint			id;
 
-		TCU_CHECK_EGL_CALL(eglGetConfigAttrib(display.getEGLDisplay(), config, EGL_CONFIG_ID, &id));
+		eglGetConfigAttrib(m_display, config, EGL_CONFIG_ID, &id);
+		eglu::checkError(eglGetError(), DE_NULL, __FILE__, __LINE__);
 		log << TestLog::Message << "Config ID " << id << TestLog::EndMessage;
 
 		executeTest(config);
@@ -245,14 +268,14 @@
 
 EGLint GetConfigAttribCase::getValue (EGLConfig config, EGLenum attrib, bool logValue)
 {
-	TestLog&					log		= m_testCtx.getLog();
-	const tcu::egl::Display&	display	= m_eglTestCtx.getDisplay();
-	EGLint			value;
+	TestLog&	log		= m_testCtx.getLog();
+	EGLint		value;
 
-	eglGetConfigAttrib(display.getEGLDisplay(), config, attrib, &value);
-	TCU_CHECK_EGL();
+	eglGetConfigAttrib(m_display, config, attrib, &value);
+	eglu::checkError(eglGetError(), DE_NULL, __FILE__, __LINE__);
 
-	if (logValue) logConfigAttribute(log, attrib, value);
+	if (logValue)
+		logConfigAttribute(log, attrib, value);
 
 	return value;
 }
@@ -369,10 +392,10 @@
 
 	void executeTest (EGLConfig config)
 	{
-		TestLog&					log		= m_testCtx.getLog();
-		const tcu::egl::Display&	display	= m_eglTestCtx.getDisplay();
+		TestLog&			log		= m_testCtx.getLog();
+		eglu::Version		version	= eglu::getVersion(m_eglTestCtx.getLibrary(), m_display);
 
-		if (!isAttributePresent(display.getVersion(), m_attrib))
+		if (!isAttributePresent(version, m_attrib))
 		{
 			log << TestLog::Message << eglu::getConfigAttribStr(m_attrib) << " not supported by this EGL version";
 		}
@@ -382,8 +405,8 @@
 
 			enableLogging(true);
 
-			eglGetConfigAttrib(display.getEGLDisplay(), config, m_attrib, &value);
-			TCU_CHECK_EGL();
+			eglGetConfigAttrib(m_display, config, m_attrib, &value);
+			eglu::checkError(eglGetError(), DE_NULL, __FILE__, __LINE__);
 
 			logConfigAttribute(log, m_attrib, value);
 			checkAttribute(m_attrib, value);
diff --git a/modules/egl/teglQueryContextTests.cpp b/modules/egl/teglQueryContextTests.cpp
index 3f3fe2b..e9d9b3d 100644
--- a/modules/egl/teglQueryContextTests.cpp
+++ b/modules/egl/teglQueryContextTests.cpp
@@ -22,7 +22,7 @@
  *//*--------------------------------------------------------------------*/
 
 #include "teglQueryContextTests.hpp"
-#include "teglSimpleConfigCase.hpp"
+#include "teglRenderCase.hpp"
 #include "teglRenderCase.hpp"
 #include "egluCallLogWrapper.hpp"
 #include "egluStrUtil.hpp"
@@ -35,223 +35,76 @@
 #include "egluNativeWindow.hpp"
 #include "egluNativePixmap.hpp"
 
+#include "eglwLibrary.hpp"
+#include "eglwEnums.hpp"
+
 #include "deUniquePtr.hpp"
+#include "deSTLUtil.hpp"
 
 #include <vector>
 
-#include <EGL/eglext.h>
-
-#if !defined(EGL_OPENGL_ES3_BIT_KHR)
-#	define EGL_OPENGL_ES3_BIT_KHR	0x0040
-#endif
-#if !defined(EGL_CONTEXT_MAJOR_VERSION_KHR)
-#	define EGL_CONTEXT_MAJOR_VERSION_KHR EGL_CONTEXT_CLIENT_VERSION
-#endif
-
 namespace deqp
 {
 namespace egl
 {
 
+using std::vector;
 using eglu::ConfigInfo;
 using tcu::TestLog;
+using namespace eglw;
 
-struct ContextCaseInfo
+static EGLint getClientTypeFromAPIBit (EGLint apiBit)
 {
-	EGLint	surfaceType;
-	EGLint	clientType;
-	EGLint	clientVersion;
-};
+	switch (apiBit)
+	{
+		case EGL_OPENGL_BIT:		return EGL_OPENGL_API;
+		case EGL_OPENGL_ES_BIT:		return EGL_OPENGL_ES_API;
+		case EGL_OPENGL_ES2_BIT:	return EGL_OPENGL_ES_API;
+		case EGL_OPENGL_ES3_BIT:	return EGL_OPENGL_ES_API;
+		case EGL_OPENVG_BIT:		return EGL_OPENVG_API;
+		default:
+			DE_ASSERT(false);
+			return 0;
+	}
+}
 
-class ContextCase : public SimpleConfigCase, protected eglu::CallLogWrapper
+static EGLint getMinClientMajorVersion (EGLint apiBit)
+{
+	switch (apiBit)
+	{
+		case EGL_OPENGL_BIT:		return 1;
+		case EGL_OPENGL_ES_BIT:		return 1;
+		case EGL_OPENGL_ES2_BIT:	return 2;
+		case EGL_OPENGL_ES3_BIT:	return 3;
+		case EGL_OPENVG_BIT:		return 1;
+		default:
+			DE_ASSERT(false);
+			return 0;
+	}
+}
+
+class GetCurrentContextCase : public SingleContextRenderCase, private eglu::CallLogWrapper
 {
 public:
-						ContextCase			(EglTestContext& eglTestCtx, const char* name, const char* description, const std::vector<EGLint>& configIds, EGLint surfaceTypeMask);
-	virtual				~ContextCase		(void);
-
-	void				executeForConfig	(tcu::egl::Display& display, EGLConfig config);
-	void				executeForSurface	(tcu::egl::Display& display, EGLConfig config, EGLSurface surface, ContextCaseInfo& info);
-
-	virtual void		executeForContext	(tcu::egl::Display& display, EGLConfig config, EGLSurface surface, EGLContext context, ContextCaseInfo& info) = 0;
-
-private:
-	EGLint				m_surfaceTypeMask;
-};
-
-ContextCase::ContextCase (EglTestContext& eglTestCtx, const char* name, const char* description, const std::vector<EGLint>& configIds, EGLint surfaceTypeMask)
-	: SimpleConfigCase	(eglTestCtx, name, description, configIds)
-	, CallLogWrapper	(eglTestCtx.getTestContext().getLog())
-	, m_surfaceTypeMask	(surfaceTypeMask)
-{
-}
-
-ContextCase::~ContextCase (void)
-{
-}
-
-void ContextCase::executeForConfig (tcu::egl::Display& display, EGLConfig config)
-{
-	tcu::TestLog&			log				= m_testCtx.getLog();
-	const int				width			= 64;
-	const int				height			= 64;
-	const EGLint			configId		= display.getConfigAttrib(config, EGL_CONFIG_ID);
-	eglu::NativeDisplay&	nativeDisplay	= m_eglTestCtx.getNativeDisplay();
-	bool					isOk			= true;
-	std::string				failReason		= "";
-
-	if (m_surfaceTypeMask & EGL_WINDOW_BIT)
-	{
-		log << TestLog::Message << "Creating window surface with config ID " << configId << TestLog::EndMessage;
-
-		try
-		{
-			de::UniquePtr<eglu::NativeWindow>	window		(m_eglTestCtx.createNativeWindow(display.getEGLDisplay(), config, DE_NULL, width, height, eglu::parseWindowVisibility(m_testCtx.getCommandLine())));
-			tcu::egl::WindowSurface				surface		(display, eglu::createWindowSurface(nativeDisplay, *window, display.getEGLDisplay(), config, DE_NULL));
-
-			ContextCaseInfo info;
-			info.surfaceType	= EGL_WINDOW_BIT;
-
-			executeForSurface(m_eglTestCtx.getDisplay(), config, surface.getEGLSurface(), info);
-		}
-		catch (const tcu::TestError& e)
-		{
-			log << e;
-			isOk = false;
-			failReason = e.what();
-		}
-
-		log << TestLog::Message << TestLog::EndMessage;
-	}
-
-	if (m_surfaceTypeMask & EGL_PIXMAP_BIT)
-	{
-		log << TestLog::Message << "Creating pixmap surface with config ID " << configId << TestLog::EndMessage;
-
-		try
-		{
-			de::UniquePtr<eglu::NativePixmap>	pixmap		(m_eglTestCtx.createNativePixmap(display.getEGLDisplay(), config, DE_NULL, width, height));
-			tcu::egl::PixmapSurface				surface		(display, eglu::createPixmapSurface(nativeDisplay, *pixmap, display.getEGLDisplay(), config, DE_NULL));
-
-			ContextCaseInfo info;
-			info.surfaceType	= EGL_PIXMAP_BIT;
-
-			executeForSurface(display, config, surface.getEGLSurface(), info);
-		}
-		catch (const tcu::TestError& e)
-		{
-			log << e;
-			isOk = false;
-			failReason = e.what();
-		}
-
-		log << TestLog::Message << TestLog::EndMessage;
-	}
-
-	if (m_surfaceTypeMask & EGL_PBUFFER_BIT)
-	{
-		log << TestLog::Message << "Creating pbuffer surface with config ID " << configId << TestLog::EndMessage;
-
-		try
-		{
-			const EGLint surfaceAttribs[] =
-			{
-				EGL_WIDTH,	width,
-				EGL_HEIGHT,	height,
-				EGL_NONE
-			};
-
-			tcu::egl::PbufferSurface surface(display, config, surfaceAttribs);
-
-			ContextCaseInfo info;
-			info.surfaceType	= EGL_PBUFFER_BIT;
-
-			executeForSurface(display, config, surface.getEGLSurface(), info);
-		}
-		catch (const tcu::TestError& e)
-		{
-			log << e;
-			isOk = false;
-			failReason = e.what();
-		}
-
-		log << TestLog::Message << TestLog::EndMessage;
-	}
-
-	if (!isOk && m_testCtx.getTestResult() == QP_TEST_RESULT_PASS)
-		m_testCtx.setTestResult(QP_TEST_RESULT_FAIL, failReason.c_str());
-}
-
-void ContextCase::executeForSurface (tcu::egl::Display& display, EGLConfig config, EGLSurface surface, ContextCaseInfo& info)
-{
-	TestLog&	log		= m_testCtx.getLog();
-	EGLint		apiBits	= display.getConfigAttrib(config, EGL_RENDERABLE_TYPE);
-
-	static const EGLint es1Attrs[] = { EGL_CONTEXT_CLIENT_VERSION,		1, EGL_NONE };
-	static const EGLint es2Attrs[] = { EGL_CONTEXT_CLIENT_VERSION,		2, EGL_NONE };
-	static const EGLint es3Attrs[] = { EGL_CONTEXT_MAJOR_VERSION_KHR,	3, EGL_NONE };
-
-	static const struct
-	{
-		const char*		name;
-		EGLenum			api;
-		EGLint			apiBit;
-		const EGLint*	ctxAttrs;
-		EGLint			apiVersion;
-	} apis[] =
-	{
-		{ "OpenGL",			EGL_OPENGL_API,		EGL_OPENGL_BIT,			DE_NULL,	0	},
-		{ "OpenGL ES 1",	EGL_OPENGL_ES_API,	EGL_OPENGL_ES_BIT,		es1Attrs,	1	},
-		{ "OpenGL ES 2",	EGL_OPENGL_ES_API,	EGL_OPENGL_ES2_BIT,		es2Attrs,	2	},
-		{ "OpenGL ES 3",	EGL_OPENGL_ES_API,	EGL_OPENGL_ES3_BIT_KHR,	es3Attrs,	3	},
-		{ "OpenVG",			EGL_OPENVG_API,		EGL_OPENVG_BIT,			DE_NULL,	0	}
-	};
-
-	for (int apiNdx = 0; apiNdx < (int)DE_LENGTH_OF_ARRAY(apis); apiNdx++)
-	{
-		if ((apiBits & apis[apiNdx].apiBit) == 0)
-			continue; // Not supported API
-
-		TCU_CHECK_EGL_CALL(eglBindAPI(apis[apiNdx].api));
-
-		log << TestLog::Message << "Creating " << apis[apiNdx].name << " context" << TestLog::EndMessage;
-
-		const EGLContext	context = eglCreateContext(display.getEGLDisplay(), config, EGL_NO_CONTEXT, apis[apiNdx].ctxAttrs);
-		TCU_CHECK_EGL();
-		TCU_CHECK(context != EGL_NO_CONTEXT);
-
-		TCU_CHECK_EGL_CALL(eglMakeCurrent(display.getEGLDisplay(), surface, surface, context));
-
-		info.clientType		= apis[apiNdx].api;
-		info.clientVersion	= apis[apiNdx].apiVersion;
-
-		executeForContext(display, config, surface, context, info);
-
-		// Destroy
-		TCU_CHECK_EGL_CALL(eglMakeCurrent(display.getEGLDisplay(), EGL_NO_SURFACE, EGL_NO_SURFACE, EGL_NO_CONTEXT));
-		TCU_CHECK_EGL_CALL(eglDestroyContext(display.getEGLDisplay(), context));
-	}
-}
-
-class GetCurrentContextCase : public ContextCase
-{
-public:
-	GetCurrentContextCase (EglTestContext& eglTestCtx, const char* name, const char* description, const std::vector<EGLint>& configIds, EGLint surfaceTypeMask)
-		: ContextCase(eglTestCtx, name, description, configIds, surfaceTypeMask)
+	GetCurrentContextCase (EglTestContext& eglTestCtx, const char* name, const char* description, const eglu::FilterList& filters, EGLint surfaceTypeMask)
+		: SingleContextRenderCase	(eglTestCtx, name, description, getBuildClientAPIMask(), surfaceTypeMask, filters)
+		, eglu::CallLogWrapper		(eglTestCtx.getLibrary(), m_testCtx.getLog())
 	{
 	}
 
-	void executeForContext (tcu::egl::Display& display, EGLConfig config, EGLSurface surface, EGLContext context, ContextCaseInfo& info)
+	void executeForContext (EGLDisplay display, EGLContext context, EGLSurface surface, const Config& config)
 	{
-		TestLog&	log	= m_testCtx.getLog();
+		const Library&	egl	= m_eglTestCtx.getLibrary();
+		TestLog&		log	= m_testCtx.getLog();
 
 		DE_UNREF(display);
-		DE_UNREF(config && surface);
-		DE_UNREF(info);
+		DE_UNREF(surface);
+		DE_UNREF(config);
 
 		enableLogging(true);
 
 		const EGLContext	gotContext	= eglGetCurrentContext();
-		TCU_CHECK_EGL();
+		EGLU_CHECK_MSG(egl, "eglGetCurrentContext");
 
 		if (gotContext == context)
 		{
@@ -272,29 +125,31 @@
 	}
 };
 
-class GetCurrentSurfaceCase : public ContextCase
+class GetCurrentSurfaceCase : public SingleContextRenderCase, private eglu::CallLogWrapper
 {
 public:
-	GetCurrentSurfaceCase (EglTestContext& eglTestCtx, const char* name, const char* description, const std::vector<EGLint>& configIds, EGLint surfaceTypeMask)
-		: ContextCase(eglTestCtx, name, description, configIds, surfaceTypeMask)
+	GetCurrentSurfaceCase (EglTestContext& eglTestCtx, const char* name, const char* description, const eglu::FilterList& filters, EGLint surfaceTypeMask)
+		: SingleContextRenderCase	(eglTestCtx, name, description, getBuildClientAPIMask(), surfaceTypeMask, filters)
+		, eglu::CallLogWrapper		(eglTestCtx.getLibrary(), m_testCtx.getLog())
 	{
 	}
 
-	void executeForContext (tcu::egl::Display& display, EGLConfig config, EGLSurface surface, EGLContext context, ContextCaseInfo& info)
+	void executeForContext (EGLDisplay display, EGLContext context, EGLSurface surface, const Config& config)
 	{
-		TestLog&	log	= m_testCtx.getLog();
+		const Library&	egl	= m_eglTestCtx.getLibrary();
+		TestLog&		log	= m_testCtx.getLog();
 
 		DE_UNREF(display);
-		DE_UNREF(config && context);
-		DE_UNREF(info);
+		DE_UNREF(context);
+		DE_UNREF(config);
 
 		enableLogging(true);
 
 		const EGLContext	gotReadSurface	= eglGetCurrentSurface(EGL_READ);
-		TCU_CHECK_EGL();
+		EGLU_CHECK_MSG(egl, "eglGetCurrentSurface(EGL_READ)");
 
 		const EGLContext	gotDrawSurface	= eglGetCurrentSurface(EGL_DRAW);
-		TCU_CHECK_EGL();
+		EGLU_CHECK_MSG(egl, "eglGetCurrentSurface(EGL_DRAW)");
 
 		if (gotReadSurface == surface && gotDrawSurface == surface)
 		{
@@ -312,27 +167,29 @@
 	}
 };
 
-class GetCurrentDisplayCase : public ContextCase
+class GetCurrentDisplayCase : public SingleContextRenderCase, private eglu::CallLogWrapper
 {
 public:
-	GetCurrentDisplayCase (EglTestContext& eglTestCtx, const char* name, const char* description, const std::vector<EGLint>& configIds, EGLint surfaceTypeMask)
-		: ContextCase(eglTestCtx, name, description, configIds, surfaceTypeMask)
+	GetCurrentDisplayCase (EglTestContext& eglTestCtx, const char* name, const char* description, const eglu::FilterList& filters, EGLint surfaceTypeMask)
+		: SingleContextRenderCase	(eglTestCtx, name, description, getBuildClientAPIMask(), surfaceTypeMask, filters)
+		, eglu::CallLogWrapper		(eglTestCtx.getLibrary(), m_testCtx.getLog())
 	{
 	}
 
-	void executeForContext (tcu::egl::Display& display, EGLConfig config, EGLSurface surface, EGLContext context, ContextCaseInfo& info)
+	void executeForContext (EGLDisplay display, EGLContext context, EGLSurface surface, const Config& config)
 	{
-		TestLog&	log	= m_testCtx.getLog();
+		const Library&	egl	= m_eglTestCtx.getLibrary();
+		TestLog&		log	= m_testCtx.getLog();
 
-		DE_UNREF(config && surface && context);
-		DE_UNREF(info);
+		DE_UNREF(surface && context);
+		DE_UNREF(config);
 
 		enableLogging(true);
 
 		const EGLDisplay	gotDisplay	= eglGetCurrentDisplay();
-		TCU_CHECK_EGL();
+		EGLU_CHECK_MSG(egl, "eglGetCurrentDisplay");
 
-		if (gotDisplay == display.getEGLDisplay())
+		if (gotDisplay == display)
 		{
 			log << TestLog::Message << "  Pass" << TestLog::EndMessage;
 		}
@@ -341,9 +198,9 @@
 			log << TestLog::Message << "  Fail, got EGL_NO_DISPLAY" << TestLog::EndMessage;
 			m_testCtx.setTestResult(QP_TEST_RESULT_FAIL, "Unexpected EGL_NO_DISPLAY");
 		}
-		else if (gotDisplay != display.getEGLDisplay())
+		else if (gotDisplay != display)
 		{
-			log << TestLog::Message << "  Fail, call returned the wrong display. Expected: " << tcu::toHex(display.getEGLDisplay()) << ", got: " << tcu::toHex(gotDisplay) << TestLog::EndMessage;
+			log << TestLog::Message << "  Fail, call returned the wrong display. Expected: " << tcu::toHex(display) << ", got: " << tcu::toHex(gotDisplay) << TestLog::EndMessage;
 			m_testCtx.setTestResult(QP_TEST_RESULT_FAIL, "Invalid display");
 		}
 
@@ -351,26 +208,29 @@
 	}
 };
 
-class QueryContextCase : public ContextCase
+class QueryContextCase : public SingleContextRenderCase, private eglu::CallLogWrapper
 {
 public:
-	QueryContextCase (EglTestContext& eglTestCtx, const char* name, const char* description, const std::vector<EGLint>& configIds, EGLint surfaceTypeMask)
-		: ContextCase(eglTestCtx, name, description, configIds, surfaceTypeMask)
+	QueryContextCase (EglTestContext& eglTestCtx, const char* name, const char* description, const eglu::FilterList& filters, EGLint surfaceTypeMask)
+		: SingleContextRenderCase	(eglTestCtx, name, description, getBuildClientAPIMask(), surfaceTypeMask, filters)
+		, eglu::CallLogWrapper		(eglTestCtx.getLibrary(), m_testCtx.getLog())
 	{
 	}
 
-	EGLint getContextAttrib (tcu::egl::Display& display, EGLContext context, EGLint attrib)
+	EGLint getContextAttrib (EGLDisplay display, EGLContext context, EGLint attrib)
 	{
-		EGLint	value;
-		TCU_CHECK_EGL_CALL(eglQueryContext(display.getEGLDisplay(), context, attrib, &value));
+		const Library&	egl	= m_eglTestCtx.getLibrary();
+		EGLint			value;
+		EGLU_CHECK_CALL(egl, queryContext(display, context, attrib, &value));
 
 		return value;
 	}
 
-	void executeForContext (tcu::egl::Display& display, EGLConfig config, EGLSurface surface, EGLContext context, ContextCaseInfo& info)
+	void executeForContext (EGLDisplay display, EGLContext context, EGLSurface surface, const Config& config)
 	{
+		const Library&		egl		= m_eglTestCtx.getLibrary();
 		TestLog&			log		= m_testCtx.getLog();
-		const eglu::Version	version	(display.getEGLMajorVersion(), display.getEGLMinorVersion());
+		const eglu::Version	version	= eglu::getVersion(egl, display);
 
 		DE_UNREF(surface);
 		enableLogging(true);
@@ -378,7 +238,7 @@
 		// Config ID
 		{
 			const EGLint	configID		= getContextAttrib(display, context, EGL_CONFIG_ID);
-			const EGLint	surfaceConfigID	= display.getConfigAttrib(config, EGL_CONFIG_ID);
+			const EGLint	surfaceConfigID	= eglu::getConfigAttribInt(egl, display, config.config, EGL_CONFIG_ID);
 
 			if (configID != surfaceConfigID)
 			{
@@ -392,7 +252,7 @@
 		{
 			const EGLint	clientType		= getContextAttrib(display, context, EGL_CONTEXT_CLIENT_TYPE);
 
-			if (clientType != info.clientType)
+			if (clientType != getClientTypeFromAPIBit(config.apiBits))
 			{
 				log << TestLog::Message << "  Fail, client API type doesn't match." << TestLog::EndMessage;
 				m_testCtx.setTestResult(QP_TEST_RESULT_FAIL, "Invalid client API type");
@@ -405,7 +265,7 @@
 			const EGLint	clientVersion	= getContextAttrib(display, context, EGL_CONTEXT_CLIENT_VERSION);
 
 			// \todo [2014-10-21 mika] Query actual supported api version from client api to make this check stricter.
-			if (info.clientType == EGL_OPENGL_ES_API && ((info.clientVersion == 1 && clientVersion != 1) || clientVersion < info.clientVersion))
+			if (clientVersion < getMinClientMajorVersion(config.apiBits))
 			{
 				log << TestLog::Message << "  Fail, client API version doesn't match." << TestLog::EndMessage;
 				m_testCtx.setTestResult(QP_TEST_RESULT_FAIL, "Invalid client API version");
@@ -417,17 +277,17 @@
 		{
 			const EGLint	renderBuffer	= getContextAttrib(display, context, EGL_RENDER_BUFFER);
 
-			if (info.surfaceType == EGL_PIXMAP_BIT && renderBuffer != EGL_SINGLE_BUFFER)
+			if (config.surfaceTypeBit == EGL_PIXMAP_BIT && renderBuffer != EGL_SINGLE_BUFFER)
 			{
 				log << TestLog::Message << "  Fail, render buffer should be EGL_SINGLE_BUFFER for a pixmap surface." << TestLog::EndMessage;
 				m_testCtx.setTestResult(QP_TEST_RESULT_FAIL, "Invalid render buffer");
 			}
-			else if (info.surfaceType == EGL_PBUFFER_BIT && renderBuffer != EGL_BACK_BUFFER)
+			else if (config.surfaceTypeBit == EGL_PBUFFER_BIT && renderBuffer != EGL_BACK_BUFFER)
 			{
 				log << TestLog::Message << "  Fail, render buffer should be EGL_BACK_BUFFER for a pbuffer surface." << TestLog::EndMessage;
 				m_testCtx.setTestResult(QP_TEST_RESULT_FAIL, "Invalid render buffer");
 			}
-			else if (info.surfaceType == EGL_WINDOW_BIT && renderBuffer != EGL_SINGLE_BUFFER && renderBuffer != EGL_BACK_BUFFER)
+			else if (config.surfaceTypeBit == EGL_WINDOW_BIT && renderBuffer != EGL_SINGLE_BUFFER && renderBuffer != EGL_BACK_BUFFER)
 			{
 				log << TestLog::Message << "  Fail, render buffer should be either EGL_SINGLE_BUFFER or EGL_BACK_BUFFER for a window surface." << TestLog::EndMessage;
 				m_testCtx.setTestResult(QP_TEST_RESULT_FAIL, "Invalid render buffer");
@@ -440,12 +300,12 @@
 	}
 };
 
-class QueryAPICase : public TestCase, protected eglu::CallLogWrapper
+class QueryAPICase : public TestCase, private eglu::CallLogWrapper
 {
 public:
 	QueryAPICase (EglTestContext& eglTestCtx, const char* name, const char* description)
-		: TestCase(eglTestCtx, name, description)
-		, CallLogWrapper(eglTestCtx.getTestContext().getLog())
+		: TestCase		(eglTestCtx, name, description)
+		, CallLogWrapper(eglTestCtx.getLibrary(), eglTestCtx.getTestContext().getLog())
 	{
 	}
 
@@ -456,20 +316,23 @@
 
 	IterateResult iterate (void)
 	{
-		tcu::TestLog&	log		= m_testCtx.getLog();
-		const EGLenum	apis[]	= { EGL_OPENGL_API, EGL_OPENGL_ES_API, EGL_OPENVG_API };
+		const Library&			egl				= m_eglTestCtx.getLibrary();
+		EGLDisplay				display			= eglu::getAndInitDisplay(m_eglTestCtx.getNativeDisplay());
+		tcu::TestLog&			log				= m_testCtx.getLog();
+		const EGLenum			apis[]			= { EGL_OPENGL_API, EGL_OPENGL_ES_API, EGL_OPENVG_API };
+		const vector<EGLenum>	supportedAPIs	= eglu::getClientAPIs(egl, display);
 
 		enableLogging(true);
 
 		{
 			const EGLenum	api	= eglQueryAPI();
 
-			if (api != EGL_OPENGL_ES_API && m_eglTestCtx.isAPISupported(EGL_OPENGL_ES_API))
+			if (api != EGL_OPENGL_ES_API && (de::contains(supportedAPIs.begin(), supportedAPIs.end(), EGL_OPENGL_ES_API)))
 			{
 				log << TestLog::Message << "  Fail, initial value should be EGL_OPENGL_ES_API if OpenGL ES is supported." << TestLog::EndMessage;
 				m_testCtx.setTestResult(QP_TEST_RESULT_FAIL, "Invalid default value");
 			}
-			else if(api != EGL_NONE && !m_eglTestCtx.isAPISupported(EGL_OPENGL_ES_API))
+			else if (api != EGL_NONE && !(de::contains(supportedAPIs.begin(), supportedAPIs.end(), EGL_OPENGL_ES_API)))
 			{
 				log << TestLog::Message << "  Fail, initial value should be EGL_NONE if OpenGL ES is not supported." << TestLog::EndMessage;
 				m_testCtx.setTestResult(QP_TEST_RESULT_FAIL, "Invalid default value");
@@ -482,11 +345,11 @@
 
 			log << TestLog::Message << TestLog::EndMessage;
 
-			if (m_eglTestCtx.isAPISupported(api))
+			if (de::contains(supportedAPIs.begin(), supportedAPIs.end(), api))
 			{
-				eglBindAPI(api);
+				egl.bindAPI(api);
 
-				if (api != eglQueryAPI())
+				if (api != egl.queryAPI())
 				{
 					log << TestLog::Message << "  Fail, return value does not match previously bound API." << TestLog::EndMessage;
 					m_testCtx.setTestResult(QP_TEST_RESULT_FAIL, "Invalid return value");
@@ -499,6 +362,7 @@
 		}
 
 		enableLogging(false);
+		eglTerminate(display);
 		return STOP;
 	}
 };
@@ -515,13 +379,12 @@
 template<class QueryContextClass>
 void createQueryContextGroups (EglTestContext& eglTestCtx, tcu::TestCaseGroup* group)
 {
-	std::vector<RenderConfigIdSet>	configSets;
-	eglu::FilterList				filters;
+	std::vector<RenderFilterList> filterLists;
 
-	getDefaultRenderConfigIdSets(configSets, eglTestCtx.getConfigs(), filters);
+	getDefaultRenderFilterLists(filterLists, eglu::FilterList());
 
-	for (std::vector<RenderConfigIdSet>::const_iterator setIter = configSets.begin(); setIter != configSets.end(); setIter++)
-		group->addChild(new QueryContextClass(eglTestCtx, setIter->getName(), "", setIter->getConfigIds(), setIter->getSurfaceTypeMask()));
+	for (std::vector<RenderFilterList>::const_iterator listIter = filterLists.begin(); listIter != filterLists.end(); listIter++)
+		group->addChild(new QueryContextClass(eglTestCtx, listIter->getName(), "", *listIter, listIter->getSurfaceTypeMask()));
 }
 
 void QueryContextTests::init (void)
diff --git a/modules/egl/teglQuerySurfaceTests.cpp b/modules/egl/teglQuerySurfaceTests.cpp
index 0817e9e..a31ca05 100644
--- a/modules/egl/teglQuerySurfaceTests.cpp
+++ b/modules/egl/teglQuerySurfaceTests.cpp
@@ -30,6 +30,10 @@
 #include "egluNativePixmap.hpp"
 #include "egluStrUtil.hpp"
 #include "egluUtil.hpp"
+#include "egluUnique.hpp"
+
+#include "eglwLibrary.hpp"
+#include "eglwEnums.hpp"
 
 #include "tcuTestLog.hpp"
 #include "tcuTestContext.hpp"
@@ -48,6 +52,7 @@
 
 using eglu::ConfigInfo;
 using tcu::TestLog;
+using namespace eglw;
 
 static void logSurfaceAttribute (tcu::TestLog& log, EGLint attribute, EGLint value)
 {
@@ -57,17 +62,13 @@
 	log << TestLog::Message << "  " << name << ": " << valueFmt << TestLog::EndMessage;
 }
 
-static void logSurfaceAttributes (tcu::TestLog& log, const tcu::egl::Surface& surface, const EGLint* attributes, int num)
+static void logSurfaceAttributes (tcu::TestLog& log, const Library& egl, EGLDisplay display, EGLSurface surface, const EGLint* attributes, int numAttribs)
 {
-	for (int ndx = 0; ndx < num; ndx++)
-	{
-		const EGLint	attrib	= attributes[ndx];
-
-		logSurfaceAttribute(log, attrib, surface.getAttribute(attrib));
-	}
+	for (int ndx = 0; ndx < numAttribs; ndx++)
+		logSurfaceAttribute(log, attributes[ndx], eglu::querySurfaceInt(egl, display, surface, attributes[ndx]));
 }
 
-static void logCommonSurfaceAttributes (tcu::TestLog& log, const tcu::egl::Surface& surface)
+static void logCommonSurfaceAttributes (tcu::TestLog& log, const Library& egl, EGLDisplay display, EGLSurface surface)
 {
 	static const EGLint	attributes[] =
 	{
@@ -80,16 +81,17 @@
 		EGL_PIXEL_ASPECT_RATIO,
 		EGL_RENDER_BUFFER,
 		EGL_SWAP_BEHAVIOR,
-		EGL_VG_ALPHA_FORMAT,
-		EGL_VG_COLORSPACE
+		EGL_ALPHA_FORMAT,
+		EGL_COLORSPACE
 	};
 
-	logSurfaceAttributes(log, surface, attributes, DE_LENGTH_OF_ARRAY(attributes));
+	logSurfaceAttributes(log, egl, display, surface, attributes, DE_LENGTH_OF_ARRAY(attributes));
 }
 
-static void logPbufferSurfaceAttributes (tcu::TestLog& log, const tcu::egl::Surface& surface)
+static void logPbufferSurfaceAttributes (tcu::TestLog& log, const Library& egl, EGLDisplay display, EGLSurface surface)
 {
-	static const EGLint	attributes[] = {
+	static const EGLint	attributes[] =
+	{
 		EGL_LARGEST_PBUFFER,
 		EGL_TEXTURE_FORMAT,
 		EGL_TEXTURE_TARGET,
@@ -97,32 +99,33 @@
 		EGL_MIPMAP_LEVEL,
 	};
 
-	logSurfaceAttributes(log, surface, attributes, DE_LENGTH_OF_ARRAY(attributes));
+	logSurfaceAttributes(log, egl, display, surface, attributes, DE_LENGTH_OF_ARRAY(attributes));
 }
 
 class QuerySurfaceCase : public SimpleConfigCase
 {
 public:
-	QuerySurfaceCase (EglTestContext& eglTestCtx, const char* name, const char* description, const std::vector<EGLint>& configIds);
+			QuerySurfaceCase			(EglTestContext& eglTestCtx, const char* name, const char* description, const eglu::FilterList& filters);
 
-	void checkCommonAttributes (const tcu::egl::Surface& surface, const ConfigInfo& info);
-	void checkNonPbufferAttributes (EGLDisplay display, const tcu::egl::Surface& surface);
+	void	checkCommonAttributes		(EGLDisplay display, EGLSurface surface, const ConfigInfo& info);
+	void	checkNonPbufferAttributes	(EGLDisplay display, EGLSurface surface);
 };
 
-QuerySurfaceCase::QuerySurfaceCase (EglTestContext& eglTestCtx, const char* name, const char* description, const std::vector<EGLint>& configIds)
-	: SimpleConfigCase(eglTestCtx, name, description, configIds)
+QuerySurfaceCase::QuerySurfaceCase (EglTestContext& eglTestCtx, const char* name, const char* description, const eglu::FilterList& filters)
+	: SimpleConfigCase(eglTestCtx, name, description, filters)
 {
 }
 
-void QuerySurfaceCase::checkCommonAttributes (const tcu::egl::Surface& surface, const ConfigInfo& info)
+void QuerySurfaceCase::checkCommonAttributes (EGLDisplay display, EGLSurface surface, const ConfigInfo& info)
 {
+	const Library&	egl		= m_eglTestCtx.getLibrary();
 	tcu::TestLog&	log		= m_testCtx.getLog();
 
 	// Attributes which are common to all surface types
 
 	// Config ID
 	{
-		const EGLint	id	= surface.getAttribute(EGL_CONFIG_ID);
+		const EGLint	id	= eglu::querySurfaceInt(egl, display, surface, EGL_CONFIG_ID);
 
 		if (id != info.configId)
 		{
@@ -133,8 +136,8 @@
 
 	// Width and height
 	{
-		const EGLint	width	= surface.getWidth();
-		const EGLint	height	= surface.getHeight();
+		const EGLint	width	= eglu::querySurfaceInt(egl, display, surface, EGL_WIDTH);
+		const EGLint	height	= eglu::querySurfaceInt(egl, display, surface, EGL_HEIGHT);
 
 		if (width <= 0 || height <= 0)
 		{
@@ -145,8 +148,8 @@
 
 	// Horizontal and vertical resolution
 	{
-		const EGLint	hRes	= surface.getAttribute(EGL_HORIZONTAL_RESOLUTION);
-		const EGLint	vRes	= surface.getAttribute(EGL_VERTICAL_RESOLUTION);
+		const EGLint	hRes	= eglu::querySurfaceInt(egl, display, surface, EGL_HORIZONTAL_RESOLUTION);
+		const EGLint	vRes	= eglu::querySurfaceInt(egl, display, surface, EGL_VERTICAL_RESOLUTION);
 
 		if ((hRes <= 0 || vRes <= 0) && (hRes != EGL_UNKNOWN && vRes != EGL_UNKNOWN))
 		{
@@ -157,18 +160,18 @@
 
 	// Pixel aspect ratio
 	{
-		const EGLint	pixelRatio	= surface.getAttribute(EGL_PIXEL_ASPECT_RATIO);
+		const EGLint	pixelRatio	= eglu::querySurfaceInt(egl, display, surface, EGL_PIXEL_ASPECT_RATIO);
 
 		if (pixelRatio <= 0 && pixelRatio != EGL_UNKNOWN)
 		{
-			log << TestLog::Message << "    Fail, invalid pixel aspect ratio " << surface.getAttribute(EGL_PIXEL_ASPECT_RATIO) << TestLog::EndMessage;
+			log << TestLog::Message << "    Fail, invalid pixel aspect ratio " << eglu::querySurfaceInt(egl, display, surface, EGL_PIXEL_ASPECT_RATIO) << TestLog::EndMessage;
 			m_testCtx.setTestResult(QP_TEST_RESULT_FAIL, "Invalid pixel aspect ratio");
 		}
 	}
 
 	// Render buffer
 	{
-		const EGLint	renderBuffer	= surface.getAttribute(EGL_RENDER_BUFFER);
+		const EGLint	renderBuffer	= eglu::querySurfaceInt(egl, display, surface, EGL_RENDER_BUFFER);
 
 		if (renderBuffer != EGL_BACK_BUFFER && renderBuffer != EGL_SINGLE_BUFFER)
 		{
@@ -179,7 +182,7 @@
 
 	// Multisample resolve
 	{
-		const EGLint	multisampleResolve	= surface.getAttribute(EGL_MULTISAMPLE_RESOLVE);
+		const EGLint	multisampleResolve	= eglu::querySurfaceInt(egl, display, surface, EGL_MULTISAMPLE_RESOLVE);
 
 		if (multisampleResolve != EGL_MULTISAMPLE_RESOLVE_DEFAULT && multisampleResolve != EGL_MULTISAMPLE_RESOLVE_BOX)
 		{
@@ -196,7 +199,7 @@
 
 	// Swap behavior
 	{
-		const EGLint	swapBehavior	= surface.getAttribute(EGL_SWAP_BEHAVIOR);
+		const EGLint	swapBehavior	= eglu::querySurfaceInt(egl, display, surface, EGL_SWAP_BEHAVIOR);
 
 		if (swapBehavior != EGL_BUFFER_DESTROYED && swapBehavior != EGL_BUFFER_PRESERVED)
 		{
@@ -211,48 +214,50 @@
 		}
 	}
 
-	// OpenVG alpha format
+	// alpha format
 	{
-		const EGLint	vgAlphaFormat	= surface.getAttribute(EGL_VG_ALPHA_FORMAT);
+		const EGLint	alphaFormat	= eglu::querySurfaceInt(egl, display, surface, EGL_ALPHA_FORMAT);
 
-		if (vgAlphaFormat != EGL_VG_ALPHA_FORMAT_NONPRE && vgAlphaFormat != EGL_VG_ALPHA_FORMAT_PRE)
+		if (alphaFormat != EGL_ALPHA_FORMAT_NONPRE && alphaFormat != EGL_ALPHA_FORMAT_PRE)
 		{
-			log << TestLog::Message << "    Fail, invalid OpenVG alpha format value " << vgAlphaFormat << TestLog::EndMessage;
-			m_testCtx.setTestResult(QP_TEST_RESULT_FAIL, "Invalid OpenVG alpha format");
+			log << TestLog::Message << "    Fail, invalid alpha format value " << alphaFormat << TestLog::EndMessage;
+			m_testCtx.setTestResult(QP_TEST_RESULT_FAIL, "Invalid alpha format");
 		}
 
-		if (vgAlphaFormat == EGL_VG_ALPHA_FORMAT_PRE && !(info.surfaceType & EGL_VG_ALPHA_FORMAT_PRE_BIT))
+		if (alphaFormat == EGL_ALPHA_FORMAT_PRE && !(info.surfaceType & EGL_VG_ALPHA_FORMAT_PRE_BIT))
 		{
-			log << TestLog::Message << "    Fail, OpenVG is set to use premultiplied alpha but configuration does not support it." << TestLog::EndMessage;
-			m_testCtx.setTestResult(QP_TEST_RESULT_FAIL, "Invalid OpenVG alpha format");
+			log << TestLog::Message << "    Fail, is set to use premultiplied alpha but configuration does not support it." << TestLog::EndMessage;
+			m_testCtx.setTestResult(QP_TEST_RESULT_FAIL, "Invalid alpha format");
 		}
 	}
 
-	// OpenVG color space
+	// color space
 	{
-		const EGLint	vgColorspace	= surface.getAttribute(EGL_VG_COLORSPACE);
+		const EGLint	colorspace	= eglu::querySurfaceInt(egl, display, surface, EGL_COLORSPACE);
 
-		if (vgColorspace != EGL_VG_COLORSPACE_sRGB && vgColorspace != EGL_VG_COLORSPACE_LINEAR)
+		if (colorspace != EGL_VG_COLORSPACE_sRGB && colorspace != EGL_VG_COLORSPACE_LINEAR)
 		{
-			log << TestLog::Message << "    Fail, invalid OpenVG color space value " << vgColorspace << TestLog::EndMessage;
-			m_testCtx.setTestResult(QP_TEST_RESULT_FAIL, "Invalid OpenVG color space");
+			log << TestLog::Message << "    Fail, invalid color space value " << colorspace << TestLog::EndMessage;
+			m_testCtx.setTestResult(QP_TEST_RESULT_FAIL, "Invalid color space");
 		}
 
-		if (vgColorspace == EGL_VG_COLORSPACE_LINEAR && !(info.surfaceType & EGL_VG_COLORSPACE_LINEAR_BIT))
+		if (colorspace == EGL_VG_COLORSPACE_LINEAR && !(info.surfaceType & EGL_VG_COLORSPACE_LINEAR_BIT))
 		{
-			log << TestLog::Message << "    Fail, OpenVG is set to use a linear color space but configuration does not support it." << TestLog::EndMessage;
-			m_testCtx.setTestResult(QP_TEST_RESULT_FAIL, "Invalid OpenVG color space");
+			log << TestLog::Message << "    Fail, is set to use a linear color space but configuration does not support it." << TestLog::EndMessage;
+			m_testCtx.setTestResult(QP_TEST_RESULT_FAIL, "Invalid color space");
 		}
 	}
 }
 
-void QuerySurfaceCase::checkNonPbufferAttributes (EGLDisplay display, const tcu::egl::Surface& surface)
+void QuerySurfaceCase::checkNonPbufferAttributes (EGLDisplay display, EGLSurface surface)
 {
+	const Library&	egl						= m_eglTestCtx.getLibrary();
 	const EGLint	uninitializedMagicValue	= -42;
 	tcu::TestLog&	log						= m_testCtx.getLog();
 	EGLint			value					= uninitializedMagicValue;
 
-	static const EGLint pbufferAttribs[] = {
+	static const EGLint pbufferAttribs[] =
+	{
 		EGL_LARGEST_PBUFFER,
 		EGL_TEXTURE_FORMAT,
 		EGL_TEXTURE_TARGET,
@@ -265,19 +270,18 @@
 		const EGLint		attribute	= pbufferAttribs[ndx];
 		const std::string	name		= eglu::getSurfaceAttribName(pbufferAttribs[ndx]);
 
-		eglQuerySurface(display, surface.getEGLSurface(), attribute, &value);
+		egl.querySurface(display, surface, attribute, &value);
 
 		{
-			const EGLint	error	= eglGetError();
+			const EGLint	error	= egl.getError();
 
 			if (error != EGL_SUCCESS)
 			{
 				log << TestLog::Message << "    Fail, querying " << name << " from a non-pbuffer surface should not result in an error, received "
 					<< eglu::getErrorStr(error) << TestLog::EndMessage;
 				m_testCtx.setTestResult(QP_TEST_RESULT_FAIL, "Illegal error condition");
+				break;
 			}
-
-			break;
 		}
 
 		// "For a window or pixmap surface, the contents of value are not modified."
@@ -292,86 +296,95 @@
 class QuerySurfaceSimpleWindowCase : public QuerySurfaceCase
 {
 public:
-	QuerySurfaceSimpleWindowCase (EglTestContext& eglTestCtx, const char* name, const char* description, const std::vector<EGLint>& configIds)
-		: QuerySurfaceCase(eglTestCtx, name, description, configIds)
+	QuerySurfaceSimpleWindowCase (EglTestContext& eglTestCtx, const char* name, const char* description, const eglu::FilterList& filters)
+		: QuerySurfaceCase(eglTestCtx, name, description, filters)
 	{
 	}
 
-	void executeForConfig (tcu::egl::Display& display, EGLConfig config)
+	void executeForConfig (EGLDisplay display, EGLConfig config)
 	{
-		tcu::TestLog&	log		= m_testCtx.getLog();
-		const int		width	= 64;
-		const int		height	= 64;
+		const Library&						egl				= m_eglTestCtx.getLibrary();
+		tcu::TestLog&						log				= m_testCtx.getLog();
+		const int							width			= 64;
+		const int							height			= 64;
+		const eglu::NativeWindowFactory*	windowFactory	= eglu::selectNativeWindowFactory(m_eglTestCtx.getNativeDisplayFactory(), m_testCtx.getCommandLine());
+		ConfigInfo							info;
 
-		ConfigInfo		info;
-		display.describeConfig(config, info);
+		if (!windowFactory)
+			TCU_THROW(NotSupportedError, "Windows not supported");
+
+		eglu::queryConfigInfo(egl, display, config, &info);
 
 		log << TestLog::Message << "Creating window surface with config ID " << info.configId << TestLog::EndMessage;
-		TCU_CHECK_EGL();
+		EGLU_CHECK_MSG(egl, "before queries");
 
-		de::UniquePtr<eglu::NativeWindow>	window(m_eglTestCtx.createNativeWindow(display.getEGLDisplay(), config, DE_NULL, width, height, eglu::parseWindowVisibility(m_testCtx.getCommandLine())));
-		tcu::egl::WindowSurface				surface(display, eglu::createWindowSurface(m_eglTestCtx.getNativeDisplay(), *window, display.getEGLDisplay(), config, DE_NULL));
+		de::UniquePtr<eglu::NativeWindow>	window	(windowFactory->createWindow(&m_eglTestCtx.getNativeDisplay(), display, config, DE_NULL, eglu::WindowParams(width, height, eglu::parseWindowVisibility(m_testCtx.getCommandLine()))));
+		eglu::UniqueSurface					surface	(egl, display, eglu::createWindowSurface(m_eglTestCtx.getNativeDisplay(), *window, display, config, DE_NULL));
 
-		logCommonSurfaceAttributes(log, surface);
-
-		checkCommonAttributes(surface, info);
-		checkNonPbufferAttributes(display.getEGLDisplay(), surface);
+		logCommonSurfaceAttributes	(log, egl, display, *surface);
+		checkCommonAttributes		(display, *surface, info);
+		checkNonPbufferAttributes	(display, *surface);
 	}
 };
 
 class QuerySurfaceSimplePixmapCase : public QuerySurfaceCase
 {
 public:
-	QuerySurfaceSimplePixmapCase (EglTestContext& eglTestCtx, const char* name, const char* description, const std::vector<EGLint>& configIds)
-		: QuerySurfaceCase(eglTestCtx, name, description, configIds)
+	QuerySurfaceSimplePixmapCase (EglTestContext& eglTestCtx, const char* name, const char* description, const eglu::FilterList& filters)
+		: QuerySurfaceCase(eglTestCtx, name, description, filters)
 	{
 	}
 
-	void executeForConfig (tcu::egl::Display& display, EGLConfig config)
+	void executeForConfig (EGLDisplay display, EGLConfig config)
 	{
-		tcu::TestLog&	log		= m_testCtx.getLog();
-		const int		width	= 64;
-		const int		height	= 64;
+		const Library&						egl				= m_eglTestCtx.getLibrary();
+		tcu::TestLog&						log				= m_testCtx.getLog();
+		const int							width			= 64;
+		const int							height			= 64;
+		const eglu::NativePixmapFactory*	pixmapFactory	= eglu::selectNativePixmapFactory(m_eglTestCtx.getNativeDisplayFactory(), m_testCtx.getCommandLine());
+		ConfigInfo							info;
 
-		ConfigInfo		info;
-		display.describeConfig(config, info);
+		if (!pixmapFactory)
+			TCU_THROW(NotSupportedError, "Pixmaps not supported");
+
+		eglu::queryConfigInfo(egl, display, config, &info);
 
 		log << TestLog::Message << "Creating pixmap surface with config ID " << info.configId << TestLog::EndMessage;
-		TCU_CHECK_EGL();
+		EGLU_CHECK_MSG(egl, "before queries");
 
-		de::UniquePtr<eglu::NativePixmap>	pixmap	(m_eglTestCtx.createNativePixmap(display.getEGLDisplay(), config, DE_NULL, width, height));
-		tcu::egl::PixmapSurface				surface	(display, eglu::createPixmapSurface(m_eglTestCtx.getNativeDisplay(), *pixmap, display.getEGLDisplay(), config, DE_NULL));
+		de::UniquePtr<eglu::NativePixmap>	pixmap	(pixmapFactory->createPixmap(&m_eglTestCtx.getNativeDisplay(), display, config, DE_NULL, width, height));
+		eglu::UniqueSurface					surface	(egl, display, eglu::createPixmapSurface(m_eglTestCtx.getNativeDisplay(), *pixmap, display, config, DE_NULL));
 
-		logCommonSurfaceAttributes(log, surface);
-
-		checkCommonAttributes(surface, info);
-		checkNonPbufferAttributes(display.getEGLDisplay(), surface);
+		logCommonSurfaceAttributes	(log, egl, display, *surface);
+		checkCommonAttributes		(display, *surface, info);
+		checkNonPbufferAttributes	(display, *surface);
 	}
 };
 
 class QuerySurfaceSimplePbufferCase : public QuerySurfaceCase
 {
 public:
-	QuerySurfaceSimplePbufferCase (EglTestContext& eglTestCtx, const char* name, const char* description, const std::vector<EGLint>& configIds)
-		: QuerySurfaceCase(eglTestCtx, name, description, configIds)
+	QuerySurfaceSimplePbufferCase (EglTestContext& eglTestCtx, const char* name, const char* description, const eglu::FilterList& filters)
+		: QuerySurfaceCase(eglTestCtx, name, description, filters)
 	{
 	}
 
-	void executeForConfig (tcu::egl::Display& display, EGLConfig config)
+	void executeForConfig (EGLDisplay display, EGLConfig config)
 	{
+		const Library&	egl		= m_eglTestCtx.getLibrary();
 		tcu::TestLog&	log		= m_testCtx.getLog();
 		int				width	= 64;
 		int				height	= 64;
-
 		ConfigInfo		info;
-		display.describeConfig(config, info);
+
+		eglu::queryConfigInfo(egl, display, config, &info);
 
 		log << TestLog::Message << "Creating pbuffer surface with config ID " << info.configId << TestLog::EndMessage;
-		TCU_CHECK_EGL();
+		EGLU_CHECK_MSG(egl, "before queries");
 
 		// Clamp to maximums reported by implementation
-		width	= deMin32(width, display.getConfigAttrib(config, EGL_MAX_PBUFFER_WIDTH));
-		height	= deMin32(height, display.getConfigAttrib(config, EGL_MAX_PBUFFER_HEIGHT));
+		width	= deMin32(width, eglu::getConfigAttribInt(egl, display, config, EGL_MAX_PBUFFER_WIDTH));
+		height	= deMin32(height, eglu::getConfigAttribInt(egl, display, config, EGL_MAX_PBUFFER_HEIGHT));
 
 		if (width == 0 || height == 0)
 		{
@@ -389,18 +402,17 @@
 		};
 
 		{
-			tcu::egl::PbufferSurface surface(display, config, attribs);
+			eglu::UniqueSurface surface(egl, display, egl.createPbufferSurface(display, config, attribs));
 
-			logCommonSurfaceAttributes(log, surface);
-			logPbufferSurfaceAttributes(log, surface);
-
-			checkCommonAttributes(surface, info);
+			logCommonSurfaceAttributes	(log, egl, display, *surface);
+			logPbufferSurfaceAttributes	(log, egl, display, *surface);
+			checkCommonAttributes		(display, *surface, info);
 
 			// Pbuffer-specific attributes
 
 			// Largest pbuffer
 			{
-				const EGLint	largestPbuffer	= surface.getAttribute(EGL_LARGEST_PBUFFER);
+				const EGLint	largestPbuffer	= eglu::querySurfaceInt(egl, display, *surface, EGL_LARGEST_PBUFFER);
 
 				if (largestPbuffer != EGL_FALSE && largestPbuffer != EGL_TRUE)
 				{
@@ -411,7 +423,7 @@
 
 			// Texture format
 			{
-				const EGLint	textureFormat	= surface.getAttribute(EGL_TEXTURE_FORMAT);
+				const EGLint	textureFormat	= eglu::querySurfaceInt(egl, display, *surface, EGL_TEXTURE_FORMAT);
 
 				if (textureFormat != EGL_NO_TEXTURE && textureFormat != EGL_TEXTURE_RGB && textureFormat != EGL_TEXTURE_RGBA)
 				{
@@ -422,7 +434,7 @@
 
 			// Texture target
 			{
-				const EGLint	textureTarget	= surface.getAttribute(EGL_TEXTURE_TARGET);
+				const EGLint	textureTarget	= eglu::querySurfaceInt(egl, display, *surface, EGL_TEXTURE_TARGET);
 
 				if (textureTarget != EGL_NO_TEXTURE && textureTarget != EGL_TEXTURE_2D)
 				{
@@ -433,7 +445,7 @@
 
 			// Mipmap texture
 			{
-				const EGLint	mipmapTexture	= surface.getAttribute(EGL_MIPMAP_TEXTURE);
+				const EGLint	mipmapTexture	= eglu::querySurfaceInt(egl, display, *surface, EGL_MIPMAP_TEXTURE);
 
 				if (mipmapTexture != EGL_FALSE && mipmapTexture != EGL_TRUE)
 				{
@@ -448,26 +460,25 @@
 class SurfaceAttribCase : public SimpleConfigCase
 {
 public:
-			SurfaceAttribCase	(EglTestContext& eglTestCtx, const char* name, const char* description, const std::vector<EGLint>& configIds);
+			SurfaceAttribCase	(EglTestContext& eglTestCtx, const char* name, const char* description, const eglu::FilterList& filters);
 	virtual	~SurfaceAttribCase	(void) {}
 
-	void	testAttributes		(tcu::egl::Surface& surface, const ConfigInfo& info);
+	void	testAttributes		(EGLDisplay display, EGLSurface surface, EGLint surfaceType, const ConfigInfo& info);
 };
 
-SurfaceAttribCase::SurfaceAttribCase (EglTestContext& eglTestCtx, const char* name, const char* description, const std::vector<EGLint>& configIds)
-		: SimpleConfigCase(eglTestCtx, name, description, configIds)
+SurfaceAttribCase::SurfaceAttribCase (EglTestContext& eglTestCtx, const char* name, const char* description, const eglu::FilterList& filters)
+		: SimpleConfigCase(eglTestCtx, name, description, filters)
 {
 }
 
-void SurfaceAttribCase::testAttributes (tcu::egl::Surface& surface, const ConfigInfo& info)
+void SurfaceAttribCase::testAttributes (EGLDisplay display, EGLSurface surface, EGLint surfaceType, const ConfigInfo& info)
 {
-	const tcu::egl::Display&	display			= surface.getDisplay();
-	tcu::TestLog&				log				= m_testCtx.getLog();
-	const int					majorVersion	= display.getEGLMajorVersion();
-	const int					minorVersion	= display.getEGLMinorVersion();
-	de::Random					rnd				(deStringHash(m_name.c_str()) ^ 0xf215918f);
+	const Library&		egl		= m_eglTestCtx.getLibrary();
+	tcu::TestLog&		log		= m_testCtx.getLog();
+	const eglu::Version	version	= eglu::getVersion(egl, display);
+	de::Random			rnd		(deStringHash(m_name.c_str()) ^ 0xf215918f);
 
-	if (majorVersion == 1 && minorVersion == 0)
+	if (version.getMajor() == 1 && version.getMinor() == 0)
 	{
 		log << TestLog::Message << "No attributes can be set in EGL 1.0" << TestLog::EndMessage;
 		return;
@@ -479,11 +490,11 @@
 		const EGLint initialValue = 0xDEADBAAD;
 		EGLint value = initialValue;
 
-		TCU_CHECK_EGL_CALL(eglQuerySurface(surface.getDisplay().getEGLDisplay(), surface.getEGLSurface(), EGL_MIPMAP_LEVEL, &value));
+		EGLU_CHECK_CALL(egl, querySurface(display, surface, EGL_MIPMAP_LEVEL, &value));
 
 		logSurfaceAttribute(log, EGL_MIPMAP_LEVEL, value);
 
-		if (dynamic_cast<tcu::egl::PbufferSurface*>(&surface))
+		if (surfaceType == EGL_PBUFFER_BIT)
 		{
 			if (value != 0)
 			{
@@ -497,10 +508,10 @@
 			m_testCtx.setTestResult(QP_TEST_RESULT_FAIL, "EGL_MIPMAP_LEVEL query modified result for non-pbuffer surface.");
 		}
 
-		eglSurfaceAttrib(display.getEGLDisplay(), surface.getEGLSurface(), EGL_MIPMAP_LEVEL, 1);
+		egl.surfaceAttrib(display, surface, EGL_MIPMAP_LEVEL, 1);
 
 		{
-			const EGLint	error	= eglGetError();
+			const EGLint	error	= egl.getError();
 
 			if (error != EGL_SUCCESS)
 			{
@@ -512,11 +523,11 @@
 	}
 
 	// Only mipmap level can be set in EGL 1.3 and lower
-	if (majorVersion == 1 && minorVersion <= 3) return;
+	if (version.getMajor() == 1 && version.getMinor() <= 3) return;
 
 	// Multisample resolve
 	{
-		const EGLint	value	= surface.getAttribute(EGL_MULTISAMPLE_RESOLVE);
+		const EGLint	value	= eglu::querySurfaceInt(egl, display, surface, EGL_MULTISAMPLE_RESOLVE);
 
 		logSurfaceAttribute(log, EGL_MULTISAMPLE_RESOLVE, value);
 
@@ -531,9 +542,9 @@
 		{
 			log << TestLog::Message << "    Box filter is supported by surface, trying to set." << TestLog::EndMessage;
 
-			surface.setAttribute(EGL_MULTISAMPLE_RESOLVE, EGL_MULTISAMPLE_RESOLVE_BOX);
+			egl.surfaceAttrib(display, surface, EGL_MULTISAMPLE_RESOLVE, EGL_MULTISAMPLE_RESOLVE_BOX);
 
-			if (surface.getAttribute(EGL_MULTISAMPLE_RESOLVE) != EGL_MULTISAMPLE_RESOLVE_BOX)
+			if (eglu::querySurfaceInt(egl, display, surface, EGL_MULTISAMPLE_RESOLVE) != EGL_MULTISAMPLE_RESOLVE_BOX)
 			{
 				log << TestLog::Message << "    Fail, tried to enable box filter but value did not change.";
 				m_testCtx.setTestResult(QP_TEST_RESULT_FAIL, "Failed to set multisample resolve");
@@ -543,7 +554,7 @@
 
 	// Swap behavior
 	{
-		const EGLint	value	= surface.getAttribute(EGL_SWAP_BEHAVIOR);
+		const EGLint	value	= eglu::querySurfaceInt(egl, display, surface, EGL_SWAP_BEHAVIOR);
 
 		logSurfaceAttribute(log, EGL_SWAP_BEHAVIOR, value);
 
@@ -551,9 +562,9 @@
 		{
 			const EGLint	nextValue	= (value == EGL_BUFFER_DESTROYED) ? EGL_BUFFER_PRESERVED : EGL_BUFFER_DESTROYED;
 
-			surface.setAttribute(EGL_SWAP_BEHAVIOR, nextValue);
+			egl.surfaceAttrib(display, surface, EGL_SWAP_BEHAVIOR, nextValue);
 
-			if (surface.getAttribute(EGL_SWAP_BEHAVIOR) != nextValue)
+			if (eglu::querySurfaceInt(egl, display, surface, EGL_SWAP_BEHAVIOR) != nextValue)
 			{
 				log << TestLog::Message << "  Fail, tried to set swap behavior to " << eglu::getSurfaceAttribStr(nextValue) << TestLog::EndMessage;
 				m_testCtx.setTestResult(QP_TEST_RESULT_FAIL, "Failed to set swap behavior");
@@ -565,80 +576,91 @@
 class SurfaceAttribWindowCase : public SurfaceAttribCase
 {
 public:
-	SurfaceAttribWindowCase (EglTestContext& eglTestCtx, const char* name, const char* description, const std::vector<EGLint>& configIds)
-		: SurfaceAttribCase(eglTestCtx, name, description, configIds)
+	SurfaceAttribWindowCase (EglTestContext& eglTestCtx, const char* name, const char* description, const eglu::FilterList& filters)
+		: SurfaceAttribCase(eglTestCtx, name, description, filters)
 	{
 	}
 
-	void executeForConfig (tcu::egl::Display& display, EGLConfig config)
+	void executeForConfig (EGLDisplay display, EGLConfig config)
 	{
-		tcu::TestLog&	log		= m_testCtx.getLog();
-		const int		width	= 64;
-		const int		height	= 64;
+		const Library&						egl				= m_eglTestCtx.getLibrary();
+		tcu::TestLog&						log				= m_testCtx.getLog();
+		const int							width			= 64;
+		const int							height			= 64;
+		const eglu::NativeWindowFactory*	windowFactory	= eglu::selectNativeWindowFactory(m_eglTestCtx.getNativeDisplayFactory(), m_testCtx.getCommandLine());
+		ConfigInfo							info;
 
-		ConfigInfo		info;
-		display.describeConfig(config, info);
+		if (!windowFactory)
+			TCU_THROW(NotSupportedError, "Windows not supported");
+
+		eglu::queryConfigInfo(egl, display, config, &info);
 
 		log << TestLog::Message << "Creating window surface with config ID " << info.configId << TestLog::EndMessage;
-		TCU_CHECK_EGL();
+		EGLU_CHECK_MSG(egl, "before queries");
 
-		de::UniquePtr<eglu::NativeWindow>	window(m_eglTestCtx.createNativeWindow(display.getEGLDisplay(), config, DE_NULL, width, height, eglu::parseWindowVisibility(m_testCtx.getCommandLine())));
-		tcu::egl::WindowSurface				surface(display, eglu::createWindowSurface(m_eglTestCtx.getNativeDisplay(), *window, display.getEGLDisplay(), config, DE_NULL));
+		de::UniquePtr<eglu::NativeWindow>	window	(windowFactory->createWindow(&m_eglTestCtx.getNativeDisplay(), display, config, DE_NULL, eglu::WindowParams(width, height, eglu::parseWindowVisibility(m_testCtx.getCommandLine()))));
+		eglu::UniqueSurface					surface	(egl, display, eglu::createWindowSurface(m_eglTestCtx.getNativeDisplay(), *window, display, config, DE_NULL));
 
-		testAttributes(surface, info);
+		testAttributes(display, *surface, EGL_WINDOW_BIT, info);
 	}
 };
 
 class SurfaceAttribPixmapCase : public SurfaceAttribCase
 {
 public:
-	SurfaceAttribPixmapCase (EglTestContext& eglTestCtx, const char* name, const char* description, const std::vector<EGLint>& configIds)
-		: SurfaceAttribCase(eglTestCtx, name, description, configIds)
+	SurfaceAttribPixmapCase (EglTestContext& eglTestCtx, const char* name, const char* description, const eglu::FilterList& filters)
+		: SurfaceAttribCase(eglTestCtx, name, description, filters)
 	{
 	}
 
-	void executeForConfig (tcu::egl::Display& display, EGLConfig config)
+	void executeForConfig (EGLDisplay display, EGLConfig config)
 	{
-		tcu::TestLog&	log		= m_testCtx.getLog();
-		const int		width	= 64;
-		const int		height	= 64;
+		const Library&						egl				= m_eglTestCtx.getLibrary();
+		tcu::TestLog&						log				= m_testCtx.getLog();
+		const int							width			= 64;
+		const int							height			= 64;
+		const eglu::NativePixmapFactory*	pixmapFactory	= eglu::selectNativePixmapFactory(m_eglTestCtx.getNativeDisplayFactory(), m_testCtx.getCommandLine());
+		ConfigInfo							info;
 
-		ConfigInfo		info;
-		display.describeConfig(config, info);
+		if (!pixmapFactory)
+			TCU_THROW(NotSupportedError, "Pixmaps not supported");
+
+		eglu::queryConfigInfo(egl, display, config, &info);
 
 		log << TestLog::Message << "Creating pixmap surface with config ID " << info.configId << TestLog::EndMessage;
-		TCU_CHECK_EGL();
+		EGLU_CHECK_MSG(egl, "before queries");
 
-		de::UniquePtr<eglu::NativePixmap>	pixmap	(m_eglTestCtx.createNativePixmap(display.getEGLDisplay(), config, DE_NULL, width, height));
-		tcu::egl::PixmapSurface				surface	(display, eglu::createPixmapSurface(m_eglTestCtx.getNativeDisplay(), *pixmap, display.getEGLDisplay(), config, DE_NULL));
+		de::UniquePtr<eglu::NativePixmap>	pixmap	(pixmapFactory->createPixmap(&m_eglTestCtx.getNativeDisplay(), display, config, DE_NULL, width, height));
+		eglu::UniqueSurface					surface	(egl, display, eglu::createPixmapSurface(m_eglTestCtx.getNativeDisplay(), *pixmap, display, config, DE_NULL));
 
-		testAttributes(surface, info);
+		testAttributes(display, *surface, EGL_PIXMAP_BIT, info);
 	}
 };
 
 class SurfaceAttribPbufferCase : public SurfaceAttribCase
 {
 public:
-	SurfaceAttribPbufferCase (EglTestContext& eglTestCtx, const char* name, const char* description, const std::vector<EGLint>& configIds)
-		: SurfaceAttribCase(eglTestCtx, name, description, configIds)
+	SurfaceAttribPbufferCase (EglTestContext& eglTestCtx, const char* name, const char* description, const eglu::FilterList& filters)
+		: SurfaceAttribCase(eglTestCtx, name, description, filters)
 	{
 	}
 
-	void executeForConfig (tcu::egl::Display& display, EGLConfig config)
+	void executeForConfig (EGLDisplay display, EGLConfig config)
 	{
+		const Library&	egl		= m_eglTestCtx.getLibrary();
 		tcu::TestLog&	log		= m_testCtx.getLog();
 		int				width	= 64;
 		int				height	= 64;
-
 		ConfigInfo		info;
-		display.describeConfig(config, info);
+
+		eglu::queryConfigInfo(egl, display, config, &info);
 
 		log << TestLog::Message << "Creating pbuffer surface with config ID " << info.configId << TestLog::EndMessage;
-		TCU_CHECK_EGL();
+		EGLU_CHECK_MSG(egl, "before queries");
 
 		// Clamp to maximums reported by implementation
-		width	= deMin32(width, display.getConfigAttrib(config, EGL_MAX_PBUFFER_WIDTH));
-		height	= deMin32(height, display.getConfigAttrib(config, EGL_MAX_PBUFFER_HEIGHT));
+		width	= deMin32(width, eglu::getConfigAttribInt(egl, display, config, EGL_MAX_PBUFFER_WIDTH));
+		height	= deMin32(height, eglu::getConfigAttribInt(egl, display, config, EGL_MAX_PBUFFER_HEIGHT));
 
 		if (width == 0 || height == 0)
 		{
@@ -655,9 +677,9 @@
 			EGL_NONE
 		};
 
-		tcu::egl::PbufferSurface surface(display, config, attribs);
+		eglu::UniqueSurface surface(egl, display, egl.createPbufferSurface(display, config, attribs));
 
-		testAttributes(surface, info);
+		testAttributes(display, *surface, EGL_PBUFFER_BIT, info);
 	}
 };
 
@@ -670,23 +692,10 @@
 {
 }
 
-std::vector<EGLint> getConfigs (const tcu::egl::Display& display, EGLint surfaceType)
+template <deUint32 Type>
+static bool surfaceType (const eglu::CandidateConfig& c)
 {
-	std::vector<EGLint>			out;
-
-	std::vector<EGLConfig> eglConfigs;
-	display.getConfigs(eglConfigs);
-
-	for (size_t ndx = 0; ndx < eglConfigs.size(); ndx++)
-	{
-		ConfigInfo info;
-		display.describeConfig(eglConfigs[ndx], info);
-
-		if (info.surfaceType & surfaceType)
-			out.push_back(info.configId);
-	}
-
-	return out;
+	return (c.surfaceType() & Type) == Type;
 }
 
 void QuerySurfaceTests::init (void)
@@ -701,14 +710,14 @@
 			tcu::TestCaseGroup* windowGroup = new tcu::TestCaseGroup(m_testCtx, "window", "Window surfaces");
 			simpleGroup->addChild(windowGroup);
 
-			eglu::FilterList filters;
-			filters << (eglu::ConfigSurfaceType() & EGL_WINDOW_BIT);
+			eglu::FilterList baseFilters;
+			baseFilters << surfaceType<EGL_WINDOW_BIT>;
 
-			std::vector<NamedConfigIdSet> configIdSets;
-			NamedConfigIdSet::getDefaultSets(configIdSets, m_eglTestCtx.getConfigs(), filters);
+			std::vector<NamedFilterList> filterLists;
+			getDefaultFilterLists(filterLists, baseFilters);
 
-			for (std::vector<NamedConfigIdSet>::iterator i = configIdSets.begin(); i != configIdSets.end(); i++)
-				windowGroup->addChild(new QuerySurfaceSimpleWindowCase(m_eglTestCtx, i->getName(), i->getDescription(), i->getConfigIds()));
+			for (std::vector<NamedFilterList>::iterator i = filterLists.begin(); i != filterLists.end(); i++)
+				windowGroup->addChild(new QuerySurfaceSimpleWindowCase(m_eglTestCtx, i->getName(), i->getDescription(), *i));
 		}
 
 		// Pixmap
@@ -716,14 +725,14 @@
 			tcu::TestCaseGroup* pixmapGroup = new tcu::TestCaseGroup(m_testCtx, "pixmap", "Pixmap surfaces");
 			simpleGroup->addChild(pixmapGroup);
 
-			eglu::FilterList filters;
-			filters << (eglu::ConfigSurfaceType() & EGL_PIXMAP_BIT);
+			eglu::FilterList baseFilters;
+			baseFilters << surfaceType<EGL_PIXMAP_BIT>;
 
-			std::vector<NamedConfigIdSet> configIdSets;
-			NamedConfigIdSet::getDefaultSets(configIdSets, m_eglTestCtx.getConfigs(), filters);
+			std::vector<NamedFilterList> filterLists;
+			getDefaultFilterLists(filterLists, baseFilters);
 
-			for (std::vector<NamedConfigIdSet>::iterator i = configIdSets.begin(); i != configIdSets.end(); i++)
-				pixmapGroup->addChild(new QuerySurfaceSimplePixmapCase(m_eglTestCtx, i->getName(), i->getDescription(), i->getConfigIds()));
+			for (std::vector<NamedFilterList>::iterator i = filterLists.begin(); i != filterLists.end(); i++)
+				pixmapGroup->addChild(new QuerySurfaceSimplePixmapCase(m_eglTestCtx, i->getName(), i->getDescription(), *i));
 		}
 
 		// Pbuffer
@@ -731,14 +740,14 @@
 			tcu::TestCaseGroup* pbufferGroup = new tcu::TestCaseGroup(m_testCtx, "pbuffer", "Pbuffer surfaces");
 			simpleGroup->addChild(pbufferGroup);
 
-			eglu::FilterList filters;
-			filters << (eglu::ConfigSurfaceType() & EGL_PBUFFER_BIT);
+			eglu::FilterList baseFilters;
+			baseFilters << surfaceType<EGL_PBUFFER_BIT>;
 
-			std::vector<NamedConfigIdSet> configIdSets;
-			NamedConfigIdSet::getDefaultSets(configIdSets, m_eglTestCtx.getConfigs(), filters);
+			std::vector<NamedFilterList> filterLists;
+			getDefaultFilterLists(filterLists, baseFilters);
 
-			for (std::vector<NamedConfigIdSet>::iterator i = configIdSets.begin(); i != configIdSets.end(); i++)
-				pbufferGroup->addChild(new QuerySurfaceSimplePbufferCase(m_eglTestCtx, i->getName(), i->getDescription(), i->getConfigIds()));
+			for (std::vector<NamedFilterList>::iterator i = filterLists.begin(); i != filterLists.end(); i++)
+				pbufferGroup->addChild(new QuerySurfaceSimplePbufferCase(m_eglTestCtx, i->getName(), i->getDescription(), *i));
 		}
 	}
 
@@ -752,14 +761,14 @@
 			tcu::TestCaseGroup* windowGroup = new tcu::TestCaseGroup(m_testCtx, "window", "Window surfaces");
 			setAttributeGroup->addChild(windowGroup);
 
-			eglu::FilterList filters;
-			filters << (eglu::ConfigSurfaceType() & EGL_WINDOW_BIT);
+			eglu::FilterList baseFilters;
+			baseFilters << surfaceType<EGL_WINDOW_BIT>;
 
-			std::vector<NamedConfigIdSet> configIdSets;
-			NamedConfigIdSet::getDefaultSets(configIdSets, m_eglTestCtx.getConfigs(), filters);
+			std::vector<NamedFilterList> filterLists;
+			getDefaultFilterLists(filterLists, baseFilters);
 
-			for (std::vector<NamedConfigIdSet>::iterator i = configIdSets.begin(); i != configIdSets.end(); i++)
-				windowGroup->addChild(new SurfaceAttribWindowCase(m_eglTestCtx, i->getName(), i->getDescription(), i->getConfigIds()));
+			for (std::vector<NamedFilterList>::iterator i = filterLists.begin(); i != filterLists.end(); i++)
+				windowGroup->addChild(new SurfaceAttribWindowCase(m_eglTestCtx, i->getName(), i->getDescription(), *i));
 		}
 
 		// Pixmap
@@ -767,14 +776,14 @@
 			tcu::TestCaseGroup* pixmapGroup = new tcu::TestCaseGroup(m_testCtx, "pixmap", "Pixmap surfaces");
 			setAttributeGroup->addChild(pixmapGroup);
 
-			eglu::FilterList filters;
-			filters << (eglu::ConfigSurfaceType() & EGL_PIXMAP_BIT);
+			eglu::FilterList baseFilters;
+			baseFilters << surfaceType<EGL_PIXMAP_BIT>;
 
-			std::vector<NamedConfigIdSet> configIdSets;
-			NamedConfigIdSet::getDefaultSets(configIdSets, m_eglTestCtx.getConfigs(), filters);
+			std::vector<NamedFilterList> filterLists;
+			getDefaultFilterLists(filterLists, baseFilters);
 
-			for (std::vector<NamedConfigIdSet>::iterator i = configIdSets.begin(); i != configIdSets.end(); i++)
-				pixmapGroup->addChild(new SurfaceAttribPixmapCase(m_eglTestCtx, i->getName(), i->getDescription(), i->getConfigIds()));
+			for (std::vector<NamedFilterList>::iterator i = filterLists.begin(); i != filterLists.end(); i++)
+				pixmapGroup->addChild(new SurfaceAttribPixmapCase(m_eglTestCtx, i->getName(), i->getDescription(), *i));
 		}
 
 		// Pbuffer
@@ -782,14 +791,14 @@
 			tcu::TestCaseGroup* pbufferGroup = new tcu::TestCaseGroup(m_testCtx, "pbuffer", "Pbuffer surfaces");
 			setAttributeGroup->addChild(pbufferGroup);
 
-			eglu::FilterList filters;
-			filters << (eglu::ConfigSurfaceType() & EGL_PBUFFER_BIT);
+			eglu::FilterList baseFilters;
+			baseFilters << surfaceType<EGL_PBUFFER_BIT>;
 
-			std::vector<NamedConfigIdSet> configIdSets;
-			NamedConfigIdSet::getDefaultSets(configIdSets, m_eglTestCtx.getConfigs(), filters);
+			std::vector<NamedFilterList> filterLists;
+			getDefaultFilterLists(filterLists, baseFilters);
 
-			for (std::vector<NamedConfigIdSet>::iterator i = configIdSets.begin(); i != configIdSets.end(); i++)
-				pbufferGroup->addChild(new SurfaceAttribPbufferCase(m_eglTestCtx, i->getName(), i->getDescription(), i->getConfigIds()));
+			for (std::vector<NamedFilterList>::iterator i = filterLists.begin(); i != filterLists.end(); i++)
+				pbufferGroup->addChild(new SurfaceAttribPbufferCase(m_eglTestCtx, i->getName(), i->getDescription(), *i));
 		}
 	}
 }
diff --git a/modules/egl/teglRenderCase.cpp b/modules/egl/teglRenderCase.cpp
index d4e2f05..01fd576 100644
--- a/modules/egl/teglRenderCase.cpp
+++ b/modules/egl/teglRenderCase.cpp
@@ -29,6 +29,10 @@
 #include "egluNativeWindow.hpp"
 #include "egluNativePixmap.hpp"
 #include "egluUtil.hpp"
+#include "egluUnique.hpp"
+
+#include "eglwLibrary.hpp"
+#include "eglwEnums.hpp"
 
 #include "tcuRenderTarget.hpp"
 #include "tcuTestLog.hpp"
@@ -42,62 +46,33 @@
 #include <memory>
 #include <set>
 
-#include <EGL/eglext.h>
-
-#if !defined(EGL_OPENGL_ES3_BIT_KHR)
-#	define EGL_OPENGL_ES3_BIT_KHR	0x0040
-#endif
-#if !defined(EGL_CONTEXT_MAJOR_VERSION_KHR)
-#	define EGL_CONTEXT_MAJOR_VERSION_KHR EGL_CONTEXT_CLIENT_VERSION
-#endif
-
-using std::string;
-using std::vector;
-using std::set;
-
-using tcu::TestLog;
-
 namespace deqp
 {
 namespace egl
 {
 
-// \todo [2013-04-24 pyry] Should we instead store surface bit somewhere?
-template<class Derived, class Base>
-inline bool instanceOf (Base& obj)
+using std::string;
+using std::vector;
+using std::set;
+using tcu::TestLog;
+using namespace eglw;
+
+static void postSurface (const Library& egl, EGLDisplay display, EGLSurface surface, EGLint typeBit)
 {
-	return dynamic_cast<Derived*>(&obj) != DE_NULL;
-}
-
-static void postSurface (tcu::egl::Surface& surface)
-{
-	const bool	isWindow	= instanceOf<tcu::egl::WindowSurface>(surface);
-	const bool	isPixmap	= instanceOf<tcu::egl::PixmapSurface>(surface);
-	const bool	isPbuffer	= instanceOf<tcu::egl::PbufferSurface>(surface);
-
-	DE_ASSERT((isWindow?1:0) + (isPixmap?1:0) + (isPbuffer?1:0) == 1);
-
-	if (isWindow)
-	{
-		tcu::egl::WindowSurface& window = static_cast<tcu::egl::WindowSurface&>(surface);
-		window.swapBuffers();
-	}
-	else if (isPixmap)
-	{
-		TCU_CHECK_EGL_CALL(eglWaitClient());
-	}
+	if (typeBit == EGL_WINDOW_BIT)
+		EGLU_CHECK_CALL(egl, swapBuffers(display, surface));
+	else if (typeBit == EGL_PIXMAP_BIT)
+		EGLU_CHECK_CALL(egl, waitClient());
+	else if (typeBit == EGL_PBUFFER_BIT)
+		EGLU_CHECK_CALL(egl, waitClient());
 	else
-	{
-		DE_ASSERT(isPbuffer);
-		DE_UNREF(isPbuffer);
-		TCU_CHECK_EGL_CALL(eglWaitClient());
-	}
+		DE_ASSERT(false);
 }
 
 // RenderCase
 
-RenderCase::RenderCase (EglTestContext& eglTestCtx, const char* name, const char* description, EGLint apiMask, EGLint surfaceTypeMask, const vector<EGLint>& configIds)
-	: SimpleConfigCase	(eglTestCtx, name, description, configIds)
+RenderCase::RenderCase (EglTestContext& eglTestCtx, const char* name, const char* description, EGLint apiMask, EGLint surfaceTypeMask, const eglu::FilterList& filters)
+	: SimpleConfigCase	(eglTestCtx, name, description, filters)
 	, m_apiMask			(apiMask)
 	, m_surfaceTypeMask	(surfaceTypeMask)
 {
@@ -107,17 +82,14 @@
 {
 }
 
-EGLint RenderCase::getSupportedApis (void)
+EGLint getBuildClientAPIMask (void)
 {
 	EGLint apiMask = 0;
 
-#if defined(DEQP_SUPPORT_GLES2)
+	// Always supported regardless of flags - dynamically loaded
 	apiMask |= EGL_OPENGL_ES2_BIT;
-#endif
-
-#if defined(DEQP_SUPPORT_GLES3)
-	apiMask |= EGL_OPENGL_ES3_BIT_KHR;
-#endif
+	apiMask |= EGL_OPENGL_ES3_BIT;
+	apiMask |= EGL_OPENGL_BIT;
 
 #if defined(DEQP_SUPPORT_GLES1)
 	apiMask |= EGL_OPENGL_ES_BIT;
@@ -130,28 +102,47 @@
 	return apiMask;
 }
 
-void RenderCase::executeForConfig (tcu::egl::Display& defaultDisplay, EGLConfig config)
+static void checkBuildClientAPISupport (EGLint requiredAPIs)
 {
-	tcu::TestLog&			log				= m_testCtx.getLog();
-	int						width			= 128;
-	int						height			= 128;
-	EGLint					configId		= defaultDisplay.getConfigAttrib(config, EGL_CONFIG_ID);
-	bool					isOk			= true;
-	string					failReason		= "";
+	const EGLint	builtClientAPIs		= getBuildClientAPIMask();
+
+	if ((requiredAPIs & builtClientAPIs) != requiredAPIs)
+		TCU_THROW(InternalError, "Test case requires client API not supported in current build");
+}
+
+void RenderCase::executeForConfig (EGLDisplay display, EGLConfig config)
+{
+	const Library&						egl				= m_eglTestCtx.getLibrary();
+	tcu::TestLog&						log				= m_testCtx.getLog();
+	const int							width			= 128;
+	const int							height			= 128;
+	const EGLint						configId		= eglu::getConfigID(egl, display, config);
+
+	const eglu::NativeDisplayFactory&	displayFactory	= m_eglTestCtx.getNativeDisplayFactory();
+	eglu::NativeDisplay&				nativeDisplay	= m_eglTestCtx.getNativeDisplay();
+
+	bool								isOk			= true;
+	string								failReason		= "";
 
 	if (m_surfaceTypeMask & EGL_WINDOW_BIT)
 	{
-		tcu::ScopedLogSection(log, (string("Config") + de::toString(configId) + "-Window").c_str(),
-										(string("Config ID ") + de::toString(configId) + ", window surface").c_str());
+		tcu::ScopedLogSection(log,
+							  string("Config") + de::toString(configId) + "-Window",
+							  string("Config ID ") + de::toString(configId) + ", window surface");
+
+		const eglu::NativeWindowFactory*	windowFactory	= eglu::selectNativeWindowFactory(displayFactory, m_testCtx.getCommandLine());
+
+		if (!windowFactory)
+			TCU_THROW(NotSupportedError, "Windows not supported");
 
 		try
 		{
-			tcu::egl::Display&					display		= m_eglTestCtx.getDisplay();
-			de::UniquePtr<eglu::NativeWindow>	window		(m_eglTestCtx.createNativeWindow(display.getEGLDisplay(), config, DE_NULL, width, height, eglu::parseWindowVisibility(m_testCtx.getCommandLine())));
-			EGLSurface							eglSurface	= createWindowSurface(m_eglTestCtx.getNativeDisplay(), *window, display.getEGLDisplay(), config, DE_NULL);
-			tcu::egl::WindowSurface				surface		(display, eglSurface);
+			const eglu::WindowParams			params		(width, height, eglu::parseWindowVisibility(m_testCtx.getCommandLine()));
+			de::UniquePtr<eglu::NativeWindow>	window		(windowFactory->createWindow(&nativeDisplay, display, config, DE_NULL, params));
+			EGLSurface							eglSurface	= createWindowSurface(nativeDisplay, *window, display, config, DE_NULL);
+			eglu::UniqueSurface					surface		(egl, display, eglSurface);
 
-			executeForSurface(display, surface, config);
+			executeForSurface(display, *surface, Config(config, EGL_WINDOW_BIT, 0));
 		}
 		catch (const tcu::TestError& e)
 		{
@@ -163,17 +154,22 @@
 
 	if (m_surfaceTypeMask & EGL_PIXMAP_BIT)
 	{
-		tcu::ScopedLogSection(log, (string("Config") + de::toString(configId) + "-Pixmap").c_str(),
-										(string("Config ID ") + de::toString(configId) + ", pixmap surface").c_str());
+		tcu::ScopedLogSection(log,
+							  string("Config") + de::toString(configId) + "-Pixmap",
+							  string("Config ID ") + de::toString(configId) + ", pixmap surface");
+
+		const eglu::NativePixmapFactory*	pixmapFactory	= eglu::selectNativePixmapFactory(displayFactory, m_testCtx.getCommandLine());
+
+		if (!pixmapFactory)
+			TCU_THROW(NotSupportedError, "Windows not supported");
 
 		try
 		{
-			tcu::egl::Display&					display		= m_eglTestCtx.getDisplay();
-			std::auto_ptr<eglu::NativePixmap>	pixmap		(m_eglTestCtx.createNativePixmap(display.getEGLDisplay(), config, DE_NULL, width, height));
-			EGLSurface							eglSurface	= createPixmapSurface(m_eglTestCtx.getNativeDisplay(), *pixmap, display.getEGLDisplay(), config, DE_NULL);
-			tcu::egl::PixmapSurface				surface		(display, eglSurface);
+			std::auto_ptr<eglu::NativePixmap>	pixmap		(pixmapFactory->createPixmap(&nativeDisplay, display, config, DE_NULL, width, height));
+			EGLSurface							eglSurface	= createPixmapSurface(nativeDisplay, *pixmap, display, config, DE_NULL);
+			eglu::UniqueSurface					surface		(egl, display, eglSurface);
 
-			executeForSurface(display, surface, config);
+			executeForSurface(display, *surface, Config(config, EGL_PIXMAP_BIT, 0));
 		}
 		catch (const tcu::TestError& e)
 		{
@@ -185,20 +181,22 @@
 
 	if (m_surfaceTypeMask & EGL_PBUFFER_BIT)
 	{
-		tcu::ScopedLogSection(log, (string("Config") + de::toString(configId) + "-Pbuffer").c_str(),
-										(string("Config ID ") + de::toString(configId) + ", pbuffer surface").c_str());
+		tcu::ScopedLogSection(log,
+							  string("Config") + de::toString(configId) + "-Pbuffer",
+							  string("Config ID ") + de::toString(configId) + ", pbuffer surface");
 		try
 		{
-			EGLint surfaceAttribs[] =
+			const EGLint surfaceAttribs[] =
 			{
 				EGL_WIDTH,	width,
 				EGL_HEIGHT,	height,
 				EGL_NONE
 			};
 
-			tcu::egl::PbufferSurface surface(defaultDisplay, config, surfaceAttribs);
+			eglu::UniqueSurface surface(egl, display, egl.createPbufferSurface(display, config, surfaceAttribs));
+			EGLU_CHECK_MSG(egl, "eglCreatePbufferSurface()");
 
-			executeForSurface(defaultDisplay, surface, config);
+			executeForSurface(display, *surface, Config(config, EGL_PBUFFER_BIT, 0));
 		}
 		catch (const tcu::TestError& e)
 		{
@@ -214,8 +212,8 @@
 
 // SingleContextRenderCase
 
-SingleContextRenderCase::SingleContextRenderCase (EglTestContext& eglTestCtx, const char* name, const char* description, EGLint apiMask, EGLint surfaceTypeMask, const std::vector<EGLint>& configIds)
-	: RenderCase(eglTestCtx, name, description, apiMask, surfaceTypeMask, configIds)
+SingleContextRenderCase::SingleContextRenderCase (EglTestContext& eglTestCtx, const char* name, const char* description, EGLint apiMask, EGLint surfaceTypeMask, const eglu::FilterList& filters)
+	: RenderCase(eglTestCtx, name, description, apiMask, surfaceTypeMask, filters)
 {
 }
 
@@ -223,15 +221,13 @@
 {
 }
 
-void SingleContextRenderCase::executeForSurface (tcu::egl::Display& display, tcu::egl::Surface& surface, EGLConfig config)
+void SingleContextRenderCase::executeForSurface (EGLDisplay display, EGLSurface surface, const Config& config)
 {
-	EGLint				supportedApis	= getSupportedApis();
-	const EGLint		apis[]			= { EGL_OPENGL_ES2_BIT, EGL_OPENGL_ES3_BIT_KHR, EGL_OPENGL_ES_BIT, EGL_OPENVG_BIT };
-	tcu::TestLog&		log				= m_testCtx.getLog();
+	const Library&		egl		= m_eglTestCtx.getLibrary();
+	const EGLint		apis[]	= { EGL_OPENGL_ES2_BIT, EGL_OPENGL_ES3_BIT_KHR, EGL_OPENGL_ES_BIT, EGL_OPENVG_BIT };
+	tcu::TestLog&		log		= m_testCtx.getLog();
 
-	// Check if case is supported
-	if ((m_apiMask & supportedApis) != m_apiMask)
-		throw tcu::NotSupportedError("Client APIs not supported", "", __FILE__, __LINE__);
+	checkBuildClientAPISupport(m_apiMask);
 
 	for (int apiNdx = 0; apiNdx < DE_LENGTH_OF_ARRAY(apis); apiNdx++)
 	{
@@ -281,20 +277,24 @@
 
 		log << TestLog::Message << apiName << TestLog::EndMessage;
 
-		tcu::egl::Context context(display, config, &contextAttribs[0], api);
+		EGLU_CHECK_CALL(egl, bindAPI(api));
 
-		context.makeCurrent(surface, surface);
-		executeForContext(display, context, surface, apiBit);
+		eglu::UniqueContext	context	(egl, display, egl.createContext(display, config.config, EGL_NO_CONTEXT, &contextAttribs[0]));
+
+		EGLU_CHECK_CALL(egl, makeCurrent(display, surface, surface, *context));
+		executeForContext(display, *context, surface, Config(config.config, config.surfaceTypeBit, apiBit));
 
 		// Call SwapBuffers() / WaitClient() to finish rendering
-		postSurface(surface);
+		postSurface(egl, display, surface, config.surfaceTypeBit);
 	}
+
+	EGLU_CHECK_CALL(egl, makeCurrent(display, EGL_NO_SURFACE, EGL_NO_SURFACE, EGL_NO_CONTEXT));
 }
 
 // MultiContextRenderCase
 
-MultiContextRenderCase::MultiContextRenderCase (EglTestContext& eglTestCtx, const char* name, const char* description, EGLint api, EGLint surfaceType, const vector<EGLint>& configIds, int numContextsPerApi)
-	: RenderCase			(eglTestCtx, name, description, api, surfaceType, configIds)
+MultiContextRenderCase::MultiContextRenderCase (EglTestContext& eglTestCtx, const char* name, const char* description, EGLint api, EGLint surfaceType, const eglu::FilterList& filters, int numContextsPerApi)
+	: RenderCase			(eglTestCtx, name, description, api, surfaceType, filters)
 	, m_numContextsPerApi	(numContextsPerApi)
 {
 }
@@ -303,11 +303,14 @@
 {
 }
 
-void MultiContextRenderCase::executeForSurface (tcu::egl::Display& display, tcu::egl::Surface& surface, EGLConfig config)
+void MultiContextRenderCase::executeForSurface (EGLDisplay display, EGLSurface surface, const Config& config)
 {
-	vector<std::pair<EGLint, tcu::egl::Context*> > contexts;
+	const Library&							egl		= m_eglTestCtx.getLibrary();
+	vector<std::pair<EGLint, EGLContext> >	contexts;
 	contexts.reserve(3*m_numContextsPerApi); // 3 types of contexts at maximum.
 
+	checkBuildClientAPISupport(m_apiMask);
+
 	try
 	{
 		// Create contexts that will participate in rendering.
@@ -316,116 +319,132 @@
 			if (m_apiMask & EGL_OPENGL_ES2_BIT)
 			{
 				static const EGLint attribs[] = { EGL_CONTEXT_CLIENT_VERSION, 2, EGL_NONE };
-				contexts.push_back(std::make_pair(EGL_OPENGL_ES2_BIT, new tcu::egl::Context(display, config, &attribs[0], EGL_OPENGL_ES_API)));
+				EGLU_CHECK_CALL(egl, bindAPI(EGL_OPENGL_ES_API));
+				contexts.push_back(std::make_pair(EGL_OPENGL_ES2_BIT, egl.createContext(display, config.config, EGL_NO_CONTEXT, &attribs[0])));
 			}
 
 			if (m_apiMask & EGL_OPENGL_ES3_BIT_KHR)
 			{
 				static const EGLint attribs[] = { EGL_CONTEXT_MAJOR_VERSION_KHR, 3, EGL_NONE };
-				contexts.push_back(std::make_pair(EGL_OPENGL_ES3_BIT_KHR, new tcu::egl::Context(display, config, &attribs[0], EGL_OPENGL_ES_API)));
+				EGLU_CHECK_CALL(egl, bindAPI(EGL_OPENGL_ES_API));
+				contexts.push_back(std::make_pair(EGL_OPENGL_ES3_BIT_KHR, egl.createContext(display, config.config, EGL_NO_CONTEXT, &attribs[0])));
 			}
 
 			if (m_apiMask & EGL_OPENGL_ES_BIT)
 			{
 				static const EGLint attribs[] = { EGL_CONTEXT_CLIENT_VERSION, 1, EGL_NONE };
-				contexts.push_back(std::make_pair(EGL_OPENGL_ES_BIT, new tcu::egl::Context(display, config, &attribs[0], EGL_OPENGL_ES_API)));
+				EGLU_CHECK_CALL(egl, bindAPI(EGL_OPENGL_ES_API));
+				contexts.push_back(std::make_pair(EGL_OPENGL_ES_BIT, egl.createContext(display, config.config, EGL_NO_CONTEXT, &attribs[0])));
 			}
 
 			if (m_apiMask & EGL_OPENVG_BIT)
 			{
 				static const EGLint attribs[] = { EGL_NONE };
-				contexts.push_back(std::make_pair(EGL_OPENVG_BIT, new tcu::egl::Context(display, config, &attribs[0], EGL_OPENVG_API)));
+				EGLU_CHECK_CALL(egl, bindAPI(EGL_OPENVG_API));
+				contexts.push_back(std::make_pair(EGL_OPENVG_BIT, egl.createContext(display, config.config, EGL_NO_CONTEXT, &attribs[0])));
 			}
 		}
 
+		EGLU_CHECK_MSG(egl, "eglCreateContext()");
+
 		// Execute for contexts.
-		executeForContexts(display, surface, config, contexts);
+		executeForContexts(display, surface, Config(config.config, config.surfaceTypeBit, m_apiMask), contexts);
+
+		EGLU_CHECK_CALL(egl, makeCurrent(display, EGL_NO_SURFACE, EGL_NO_SURFACE, EGL_NO_CONTEXT));
 	}
-	catch (const std::exception&)
+	catch (...)
 	{
 		// Make sure all contexts have been destroyed.
-		for (vector<std::pair<EGLint, tcu::egl::Context*> >::iterator i = contexts.begin(); i != contexts.end(); i++)
-			delete i->second;
+		for (vector<std::pair<EGLint, EGLContext> >::iterator i = contexts.begin(); i != contexts.end(); i++)
+			egl.destroyContext(display, i->second);
 		throw;
 	}
 
 	// Destroy contexts.
-	for (vector<std::pair<EGLint, tcu::egl::Context*> >::iterator i = contexts.begin(); i != contexts.end(); i++)
-		delete i->second;
+	for (vector<std::pair<EGLint, EGLContext> >::iterator i = contexts.begin(); i != contexts.end(); i++)
+		egl.destroyContext(display, i->second);
 }
 
 // Utilities
 
-void addRenderConfigIdSet (
-	vector<RenderConfigIdSet>&			configSets,
-	const vector<eglu::ConfigInfo>&		configInfos,
-	const eglu::FilterList&				baseFilters,
-	const char*							name,
-	tcu::RGBA							colorBits,
-	EGLint								surfaceType)
+template <int Red, int Green, int Blue, int Alpha>
+static bool colorBits (const eglu::CandidateConfig& c)
 {
-	eglu::FilterList filters = baseFilters;
-	filters << (eglu::ConfigColorBits() == colorBits) << (eglu::ConfigSurfaceType() & surfaceType);
+	return c.redSize()		== Red		&&
+		   c.greenSize()	== Green	&&
+		   c.blueSize()		== Blue		&&
+		   c.alphaSize()	== Alpha;
+}
 
-	vector<EGLint> matchingConfigs;
+template <int Red, int Green, int Blue, int Alpha>
+static bool notColorBits (const eglu::CandidateConfig& c)
+{
+	return c.redSize()		!= Red		||
+		   c.greenSize()	!= Green	||
+		   c.blueSize()		!= Blue		||
+		   c.alphaSize()	!= Alpha;
+}
 
-	for (vector<eglu::ConfigInfo>::const_iterator configIter = configInfos.begin(); configIter != configInfos.end(); configIter++)
+template <deUint32 Type>
+static bool surfaceType (const eglu::CandidateConfig& c)
+{
+	return (c.surfaceType() & Type) == Type;
+}
+
+void getDefaultRenderFilterLists (vector<RenderFilterList>& filterLists, const eglu::FilterList& baseFilters)
+{
+	static const struct
 	{
-		if (!filters.match(*configIter))
-			continue;
+		const char*			name;
+		eglu::ConfigFilter	filter;
+	} s_colorRules[] =
+	{
+		{ "rgb565",		colorBits<5, 6, 5, 0>	},
+		{ "rgb888",		colorBits<8, 8, 8, 0>	},
+		{ "rgba4444",	colorBits<4, 4, 4, 4>	},
+		{ "rgba5551",	colorBits<5, 5, 5, 1>	},
+		{ "rgba8888",	colorBits<8, 8, 8, 8>	},
+	};
 
-		matchingConfigs.push_back(configIter->configId);
+	static const struct
+	{
+		const char*			name;
+		EGLint				bits;
+		eglu::ConfigFilter	filter;
+	} s_surfaceRules[] =
+	{
+		{ "window",		EGL_WINDOW_BIT,		surfaceType<EGL_WINDOW_BIT>		},
+		{ "pixmap",		EGL_PIXMAP_BIT,		surfaceType<EGL_PIXMAP_BIT>,	},
+		{ "pbuffer",	EGL_PBUFFER_BIT,	surfaceType<EGL_PBUFFER_BIT>	}
+	};
+
+	for (int colorNdx = 0; colorNdx < DE_LENGTH_OF_ARRAY(s_colorRules); colorNdx++)
+	{
+		for (int surfaceNdx = 0; surfaceNdx < DE_LENGTH_OF_ARRAY(s_surfaceRules); surfaceNdx++)
+		{
+			const string		name	= string(s_colorRules[colorNdx].name) + "_" + s_surfaceRules[surfaceNdx].name;
+			RenderFilterList	filters	(name.c_str(), "", s_surfaceRules[surfaceNdx].bits);
+
+			filters << baseFilters
+					<< s_colorRules[colorNdx].filter
+					<< s_surfaceRules[surfaceNdx].filter;
+
+			filterLists.push_back(filters);
+		}
 	}
 
-	configSets.push_back(RenderConfigIdSet(name, "", matchingConfigs, surfaceType));
-}
-
-void addRenderConfigIdSet (
-	vector<RenderConfigIdSet>&			configSets,
-	const vector<eglu::ConfigInfo>&		configInfos,
-	const eglu::FilterList&				baseFilters,
-	const char*							name,
-	tcu::RGBA							colorBits)
-{
-	addRenderConfigIdSet(configSets, configInfos, baseFilters, (string(name) + "_window").c_str(),	colorBits, EGL_WINDOW_BIT);
-	addRenderConfigIdSet(configSets, configInfos, baseFilters, (string(name) + "_pixmap").c_str(),	colorBits, EGL_PIXMAP_BIT);
-	addRenderConfigIdSet(configSets, configInfos, baseFilters, (string(name) + "_pbuffer").c_str(),	colorBits, EGL_PBUFFER_BIT);
-}
-
-void getDefaultRenderConfigIdSets (vector<RenderConfigIdSet>& configSets, const vector<eglu::ConfigInfo>& configInfos, const eglu::FilterList& baseFilters)
-{
-	using tcu::RGBA;
-
-	addRenderConfigIdSet(configSets, configInfos, baseFilters, "rgb565",	RGBA(5, 6, 5, 0));
-	addRenderConfigIdSet(configSets, configInfos, baseFilters, "rgb888",	RGBA(8, 8, 8, 0));
-	addRenderConfigIdSet(configSets, configInfos, baseFilters, "rgba4444",	RGBA(4, 4, 4, 4));
-	addRenderConfigIdSet(configSets, configInfos, baseFilters, "rgba5551",	RGBA(5, 5, 5, 1));
-	addRenderConfigIdSet(configSets, configInfos, baseFilters, "rgba8888",	RGBA(8, 8, 8, 8));
-
 	// Add other config ids to "other" set
 	{
-		set<EGLint>		usedConfigs;
-		vector<EGLint>	otherCfgSet;
+		RenderFilterList	filters	("other", "", EGL_WINDOW_BIT|EGL_PIXMAP_BIT|EGL_PBUFFER_BIT);
 
-		for (vector<RenderConfigIdSet>::const_iterator setIter = configSets.begin(); setIter != configSets.end(); setIter++)
-		{
-			const vector<EGLint>& setCfgs = setIter->getConfigIds();
-			for (vector<EGLint>::const_iterator i = setCfgs.begin(); i != setCfgs.end(); i++)
-				usedConfigs.insert(*i);
-		}
+		filters << baseFilters
+				<< notColorBits<5, 6, 5, 0>
+				<< notColorBits<8, 8, 8, 0>
+				<< notColorBits<4, 4, 4, 4>
+				<< notColorBits<5, 5, 5, 1>
+				<< notColorBits<8, 8, 8, 8>;
 
-		for (vector<eglu::ConfigInfo>::const_iterator cfgIter = configInfos.begin(); cfgIter != configInfos.end(); cfgIter++)
-		{
-			if (!baseFilters.match(*cfgIter))
-				continue;
-
-			EGLint id = cfgIter->configId;
-
-			if (usedConfigs.find(id) == usedConfigs.end())
-				otherCfgSet.push_back(id);
-		}
-
-		configSets.push_back(RenderConfigIdSet("other", "", otherCfgSet, EGL_WINDOW_BIT|EGL_PIXMAP_BIT|EGL_PBUFFER_BIT));
+		filterLists.push_back(filters);
 	}
 }
 
diff --git a/modules/egl/teglRenderCase.hpp b/modules/egl/teglRenderCase.hpp
index 69a374b..a823750 100644
--- a/modules/egl/teglRenderCase.hpp
+++ b/modules/egl/teglRenderCase.hpp
@@ -21,7 +21,6 @@
  *//*!
  * \file
  * \brief Base class for rendering tests.
- * \todo [2011-07-18 pyry] Uses currently gles2-specific RenderContext.
  *//*--------------------------------------------------------------------*/
 
 #include "tcuDefs.hpp"
@@ -38,65 +37,80 @@
 class RenderCase : public SimpleConfigCase
 {
 public:
-					RenderCase				(EglTestContext& eglTestCtx, const char* name, const char* description, EGLint apiMask, EGLint surfaceTypeMask, const std::vector<EGLint>& configIds);
-	virtual			~RenderCase				(void);
-
-	static EGLint	getSupportedApis		(void);
+						RenderCase				(EglTestContext& eglTestCtx, const char* name, const char* description, eglw::EGLint apiMask, eglw::EGLint surfaceTypeMask, const eglu::FilterList& filters);
+	virtual				~RenderCase				(void);
 
 protected:
-	virtual void	executeForConfig		(tcu::egl::Display& display, EGLConfig config);
+	struct Config
+	{
+		eglw::EGLConfig		config;
+		eglw::EGLint		surfaceTypeBit;
+		eglw::EGLint		apiBits;
 
-	virtual void	executeForSurface		(tcu::egl::Display& display, tcu::egl::Surface& surface, EGLConfig config) = DE_NULL;
+		Config (eglw::EGLConfig config_, eglw::EGLint surfaceTypeBit_, eglw::EGLint apiBits_)
+			: config			(config_)
+			, surfaceTypeBit	(surfaceTypeBit_)
+			, apiBits			(apiBits_)
+		{
+		}
+	};
 
-	EGLint			m_apiMask;
-	EGLint			m_surfaceTypeMask;
+	virtual void		executeForConfig		(eglw::EGLDisplay display, eglw::EGLConfig config);
+
+	virtual void		executeForSurface		(eglw::EGLDisplay display, eglw::EGLSurface surface, const Config& config) = DE_NULL;
+
+	eglw::EGLint		m_apiMask;
+	eglw::EGLint		m_surfaceTypeMask;
 };
 
 class SingleContextRenderCase : public RenderCase
 {
 public:
-					SingleContextRenderCase		(EglTestContext& eglTestCtx, const char* name, const char* description, EGLint apiMask, EGLint surfaceTypeMask, const std::vector<EGLint>& configIds);
+					SingleContextRenderCase		(EglTestContext& eglTestCtx, const char* name, const char* description, eglw::EGLint apiMask, eglw::EGLint surfaceTypeMask, const eglu::FilterList& filters);
 	virtual			~SingleContextRenderCase	(void);
 
 protected:
-	virtual void	executeForSurface			(tcu::egl::Display& display, tcu::egl::Surface& surface, EGLConfig config);
+	virtual void	executeForSurface			(eglw::EGLDisplay display, eglw::EGLSurface surface, const Config& config);
 
-	virtual void	executeForContext			(const tcu::egl::Display& display, tcu::egl::Context& context, tcu::egl::Surface& surface, EGLint api) = DE_NULL;
+	virtual void	executeForContext			(eglw::EGLDisplay display, eglw::EGLContext context, eglw::EGLSurface surface, const Config& config) = DE_NULL;
 };
 
 class MultiContextRenderCase : public RenderCase
 {
 public:
-						MultiContextRenderCase		(EglTestContext& eglTestCtx, const char* name, const char* description, EGLint api, EGLint surfaceType, const std::vector<EGLint>& configIds, int numContextsPerApi);
-	virtual				~MultiContextRenderCase		(void);
+					MultiContextRenderCase		(EglTestContext& eglTestCtx, const char* name, const char* description, eglw::EGLint api, eglw::EGLint surfaceType, const eglu::FilterList& filters, int numContextsPerApi);
+	virtual			~MultiContextRenderCase		(void);
 
 protected:
-	void				executeForSurface			(tcu::egl::Display& display, tcu::egl::Surface& surface, EGLConfig config);
+	void			executeForSurface			(eglw::EGLDisplay display, eglw::EGLSurface surface, const Config& config);
 
-	virtual void		executeForContexts			(tcu::egl::Display& display, tcu::egl::Surface& surface, EGLConfig config, const std::vector<std::pair<EGLint, tcu::egl::Context*> >& contexts) = DE_NULL;
+	virtual void	executeForContexts			(eglw::EGLDisplay display, eglw::EGLSurface surface, const Config& config, const std::vector<std::pair<eglw::EGLint, eglw::EGLContext> >& contexts) = DE_NULL;
 
-	int					m_numContextsPerApi;
+	int				m_numContextsPerApi;
 };
 
-class RenderConfigIdSet : public NamedConfigIdSet
+class RenderFilterList : public NamedFilterList
 {
 public:
-	RenderConfigIdSet (const char* name, const char* description, std::vector<EGLint> configIds, EGLint surfaceTypeMask)
-		: NamedConfigIdSet	(name, description, configIds)
+	RenderFilterList (const char* name, const char* description, eglw::EGLint surfaceTypeMask)
+		: NamedFilterList	(name, description)
 		, m_surfaceTypeMask	(surfaceTypeMask)
 	{
 	}
 
-	EGLint getSurfaceTypeMask (void) const
+	eglw::EGLint getSurfaceTypeMask (void) const
 	{
 		return m_surfaceTypeMask;
 	}
 
 private:
-	EGLint m_surfaceTypeMask;
+	eglw::EGLint	m_surfaceTypeMask;
 };
 
-void getDefaultRenderConfigIdSets (std::vector<RenderConfigIdSet>& configSets, const std::vector<eglu::ConfigInfo>& configInfos, const eglu::FilterList& baseFilters);
+void			getDefaultRenderFilterLists	(std::vector<RenderFilterList>& configSets, const eglu::FilterList& baseFilters);
+
+//! Client APIs supported in current build
+eglw::EGLint	getBuildClientAPIMask		(void);
 
 } // egl
 } // deqp
diff --git a/modules/egl/teglRenderTests.cpp b/modules/egl/teglRenderTests.cpp
index 654004e..1f3ff2c 100644
--- a/modules/egl/teglRenderTests.cpp
+++ b/modules/egl/teglRenderTests.cpp
@@ -24,49 +24,38 @@
 
 #include "teglRenderTests.hpp"
 #include "teglRenderCase.hpp"
+
 #include "tcuRenderTarget.hpp"
 #include "tcuTestLog.hpp"
 #include "tcuImageCompare.hpp"
 #include "tcuTextureUtil.hpp"
 #include "tcuSurface.hpp"
 
+#include "egluDefs.hpp"
+#include "egluUtil.hpp"
+
+#include "eglwLibrary.hpp"
+#include "eglwEnums.hpp"
+
+#include "gluShaderProgram.hpp"
+
+#include "glwFunctions.hpp"
+#include "glwEnums.hpp"
+
 #include "deRandom.hpp"
 #include "deSharedPtr.hpp"
 #include "deSemaphore.hpp"
 #include "deThread.hpp"
 #include "deString.h"
 
+#include "rrRenderer.hpp"
+#include "rrFragmentOperations.hpp"
+
 #include <algorithm>
 #include <iterator>
 #include <memory>
 #include <set>
 
-#include <EGL/eglext.h>
-
-#if !defined(EGL_OPENGL_ES3_BIT_KHR)
-#	define EGL_OPENGL_ES3_BIT_KHR	0x0040
-#endif
-#if !defined(EGL_CONTEXT_MAJOR_VERSION_KHR)
-#	define EGL_CONTEXT_MAJOR_VERSION_KHR EGL_CONTEXT_CLIENT_VERSION
-#endif
-
-#if defined(DEQP_SUPPORT_GLES2)
-#	include <GLES2/gl2.h>
-#elif defined(DEQP_SUPPORT_GLES3)
-#	include <GLES3/gl3.h>
-#endif
-
-#include "rrRenderer.hpp"
-#include "rrFragmentOperations.hpp"
-
-#if defined(DEQP_SUPPORT_GLES2) || defined(DEQP_SUPPORT_GLES3)
-#      include "gluDefs.hpp"
-#else
-       // \todo [pyry] Move renderer to common utils
-       // \note [jarkko] gluDefs is required for GLU_CHECK_MSG
-#      error "Reference renderer requires GLES2 or GLES3 support"
-#endif
-
 namespace deqp
 {
 namespace egl
@@ -80,6 +69,9 @@
 
 using tcu::TestLog;
 
+using namespace glw;
+using namespace eglw;
+
 static const tcu::Vec4	CLEAR_COLOR		= tcu::Vec4(0.0f, 0.0f, 0.0f, 1.0f);
 static const float		CLEAR_DEPTH		= 1.0f;
 static const int		CLEAR_STENCIL	= 0;
@@ -423,92 +415,40 @@
 
 typedef de::SharedPtr<Program> ProgramSp;
 
-#if defined(DEQP_SUPPORT_GLES2) || defined(DEQP_SUPPORT_GLES3)
-
-static const char* s_vertexSrc =
-	"attribute highp vec4 a_position;\n"
-	"attribute mediump vec4 a_color;\n"
-	"varying mediump vec4 v_color;\n"
-	"void main (void)\n"
-	"{\n"
-	"	gl_Position = a_position;\n"
-	"	v_color = a_color;\n"
-	"}\n";
-
-static const char* s_fragmentSrc =
-	"varying mediump vec4 v_color;\n"
-	"void main (void)\n"
-	"{\n"
-	"	gl_FragColor = v_color;\n"
-	"}\n";
-
-static deUint32 createShader (deUint32 shaderType, const char* source)
+static glu::ProgramSources getProgramSourcesES2 (void)
 {
-	deUint32 shader = glCreateShader(shaderType);
-	glShaderSource(shader, 1, &source, DE_NULL);
-	glCompileShader(shader);
+	static const char* s_vertexSrc =
+		"attribute highp vec4 a_position;\n"
+		"attribute mediump vec4 a_color;\n"
+		"varying mediump vec4 v_color;\n"
+		"void main (void)\n"
+		"{\n"
+		"	gl_Position = a_position;\n"
+		"	v_color = a_color;\n"
+		"}\n";
 
-	int compileStatus = 0;
-	glGetShaderiv(shader, GL_COMPILE_STATUS, &compileStatus);
+	static const char* s_fragmentSrc =
+		"varying mediump vec4 v_color;\n"
+		"void main (void)\n"
+		"{\n"
+		"	gl_FragColor = v_color;\n"
+		"}\n";
 
-	if (!compileStatus)
-	{
-		glDeleteShader(shader);
-		return 0;
-	}
-
-	return shader;
-}
-
-static deUint32 createProgram (deUint32 vertexShader, deUint32 fragmentShader)
-{
-	deUint32 program = glCreateProgram();
-	glAttachShader(program, vertexShader);
-	glAttachShader(program, fragmentShader);
-	glLinkProgram(program);
-
-	int linkStatus = 0;
-	glGetProgramiv(program, GL_LINK_STATUS, &linkStatus);
-
-	if (!linkStatus)
-	{
-		glDeleteProgram(program);
-		return 0;
-	}
-
-	return program;
+	return glu::ProgramSources() << glu::VertexSource(s_vertexSrc) << glu::FragmentSource(s_fragmentSrc);
 }
 
 class GLES2Program : public Program
 {
 public:
-	GLES2Program (void)
-		: m_program			(0)
-		, m_vertexShader	(0)
-		, m_fragmentShader	(0)
+	GLES2Program (const glw::Functions& gl)
+		: m_gl				(gl)
+		, m_program			(gl, getProgramSourcesES2())
 		, m_positionLoc		(0)
 		, m_colorLoc		(0)
 	{
-		m_vertexShader		= createShader(GL_VERTEX_SHADER, s_vertexSrc);
-		m_fragmentShader	= createShader(GL_FRAGMENT_SHADER, s_fragmentSrc);
 
-		if (!m_vertexShader || !m_fragmentShader)
-		{
-			glDeleteShader(m_vertexShader);
-			glDeleteShader(m_fragmentShader);
-			throw tcu::TestError("Failed to compile shaders");
-		}
-
-		m_program = createProgram(m_vertexShader, m_fragmentShader);
-		if (!m_program)
-		{
-			glDeleteShader(m_vertexShader);
-			glDeleteShader(m_fragmentShader);
-			throw tcu::TestError("Failed to link program");
-		}
-
-		m_positionLoc	= glGetAttribLocation(m_program, "a_position");
-		m_colorLoc		= glGetAttribLocation(m_program, "a_color");
+		m_positionLoc	= m_gl.getAttribLocation(m_program.getProgram(), "a_position");
+		m_colorLoc		= m_gl.getAttribLocation(m_program.getProgram(), "a_color");
 	}
 
 	~GLES2Program (void)
@@ -517,49 +457,48 @@
 
 	void setup (void) const
 	{
-		glUseProgram(m_program);
-		glEnableVertexAttribArray(m_positionLoc);
-		glEnableVertexAttribArray(m_colorLoc);
-		GLU_CHECK_MSG("Program setup failed");
+		m_gl.useProgram(m_program.getProgram());
+		m_gl.enableVertexAttribArray(m_positionLoc);
+		m_gl.enableVertexAttribArray(m_colorLoc);
+		GLU_CHECK_GLW_MSG(m_gl, "Program setup failed");
 	}
 
-	int			getPositionLoc		(void) const { return m_positionLoc;	}
-	int			getColorLoc			(void) const { return m_colorLoc;		}
+	int						getPositionLoc		(void) const { return m_positionLoc;	}
+	int						getColorLoc			(void) const { return m_colorLoc;		}
 
 private:
-	deUint32	m_program;
-	deUint32	m_vertexShader;
-	deUint32	m_fragmentShader;
-	int			m_positionLoc;
-	int			m_colorLoc;
+	const glw::Functions&	m_gl;
+	glu::ShaderProgram		m_program;
+	int						m_positionLoc;
+	int						m_colorLoc;
 };
 
-void clearGLES2 (const tcu::Vec4& color, const float depth, const int stencil)
+void clearGLES2 (const glw::Functions& gl, const tcu::Vec4& color, const float depth, const int stencil)
 {
-	glClearColor(color.x(), color.y(), color.z(), color.w());
-	glClearDepthf(depth);
-	glClearStencil(stencil);
-	glClear(GL_COLOR_BUFFER_BIT|GL_DEPTH_BUFFER_BIT|GL_STENCIL_BUFFER_BIT);
+	gl.clearColor(color.x(), color.y(), color.z(), color.w());
+	gl.clearDepthf(depth);
+	gl.clearStencil(stencil);
+	gl.clear(GL_COLOR_BUFFER_BIT|GL_DEPTH_BUFFER_BIT|GL_STENCIL_BUFFER_BIT);
 }
 
-void drawGLES2 (const Program& program, const DrawPrimitiveOp& drawOp)
+void drawGLES2 (const glw::Functions& gl, const Program& program, const DrawPrimitiveOp& drawOp)
 {
 	const GLES2Program& gles2Program = dynamic_cast<const GLES2Program&>(program);
 
 	switch (drawOp.blend)
 	{
 		case BLENDMODE_NONE:
-			glDisable(GL_BLEND);
+			gl.disable(GL_BLEND);
 			break;
 
 		case BLENDMODE_ADDITIVE:
-			glEnable(GL_BLEND);
-			glBlendFunc(GL_ONE, GL_ONE);
+			gl.enable(GL_BLEND);
+			gl.blendFunc(GL_ONE, GL_ONE);
 			break;
 
 		case BLENDMODE_SRC_OVER:
-			glEnable(GL_BLEND);
-			glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
+			gl.enable(GL_BLEND);
+			gl.blendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
 			break;
 
 		default:
@@ -569,11 +508,11 @@
 	switch (drawOp.depth)
 	{
 		case DEPTHMODE_NONE:
-			glDisable(GL_DEPTH_TEST);
+			gl.disable(GL_DEPTH_TEST);
 			break;
 
 		case DEPTHMODE_LESS:
-			glEnable(GL_DEPTH_TEST);
+			gl.enable(GL_DEPTH_TEST);
 			break;
 
 		default:
@@ -583,89 +522,82 @@
 	switch (drawOp.stencil)
 	{
 		case STENCILMODE_NONE:
-			glDisable(GL_STENCIL_TEST);
+			gl.disable(GL_STENCIL_TEST);
 			break;
 
 		case STENCILMODE_LEQUAL_INC:
-			glEnable(GL_STENCIL_TEST);
-			glStencilFunc(GL_LEQUAL, drawOp.stencilRef, ~0u);
-			glStencilOp(GL_KEEP, GL_INCR, GL_INCR);
+			gl.enable(GL_STENCIL_TEST);
+			gl.stencilFunc(GL_LEQUAL, drawOp.stencilRef, ~0u);
+			gl.stencilOp(GL_KEEP, GL_INCR, GL_INCR);
 			break;
 
 		default:
 			DE_ASSERT(false);
 	}
 
-	glVertexAttribPointer(gles2Program.getPositionLoc(), 4, GL_FLOAT, GL_FALSE, 0, &drawOp.positions[0]);
-	glVertexAttribPointer(gles2Program.getColorLoc(), 4, GL_FLOAT, GL_FALSE, 0, &drawOp.colors[0]);
+	gl.vertexAttribPointer(gles2Program.getPositionLoc(), 4, GL_FLOAT, GL_FALSE, 0, &drawOp.positions[0]);
+	gl.vertexAttribPointer(gles2Program.getColorLoc(), 4, GL_FLOAT, GL_FALSE, 0, &drawOp.colors[0]);
 
 	DE_ASSERT(drawOp.type == PRIMITIVETYPE_TRIANGLE);
-	glDrawArrays(GL_TRIANGLES, 0, drawOp.count*3);
+	gl.drawArrays(GL_TRIANGLES, 0, drawOp.count*3);
 }
 
-static void readPixelsGLES2 (tcu::Surface& dst)
+static void readPixelsGLES2 (const glw::Functions& gl, tcu::Surface& dst)
 {
-	glReadPixels(0, 0, dst.getWidth(), dst.getHeight(), GL_RGBA, GL_UNSIGNED_BYTE, dst.getAccess().getDataPtr());
+	gl.readPixels(0, 0, dst.getWidth(), dst.getHeight(), GL_RGBA, GL_UNSIGNED_BYTE, dst.getAccess().getDataPtr());
 }
 
-#endif
-
-Program* createProgram (EGLint api)
+Program* createProgram (const glw::Functions& gl, EGLint api)
 {
 	switch (api)
 	{
-#if defined(DEQP_SUPPORT_GLES2) || defined(DEQP_SUPPORT_GLES3)
-		case EGL_OPENGL_ES2_BIT:		return new GLES2Program();
-		case EGL_OPENGL_ES3_BIT_KHR:	return new GLES2Program();
-#endif
+		case EGL_OPENGL_ES2_BIT:		return new GLES2Program(gl);
+		case EGL_OPENGL_ES3_BIT_KHR:	return new GLES2Program(gl);
 		default:
 			throw tcu::NotSupportedError("Unsupported API");
 	}
 }
 
-void draw (EGLint api, const Program& program, const DrawPrimitiveOp& drawOp)
+void draw (const glw::Functions& gl, EGLint api, const Program& program, const DrawPrimitiveOp& drawOp)
 {
 	switch (api)
 	{
-#if defined(DEQP_SUPPORT_GLES2) || defined(DEQP_SUPPORT_GLES3)
-		case EGL_OPENGL_ES2_BIT:		drawGLES2(program, drawOp);		break;
-		case EGL_OPENGL_ES3_BIT_KHR:	drawGLES2(program, drawOp);		break;
-#endif
+		case EGL_OPENGL_ES2_BIT:		drawGLES2(gl, program, drawOp);		break;
+		case EGL_OPENGL_ES3_BIT_KHR:	drawGLES2(gl, program, drawOp);		break;
 		default:
 			throw tcu::NotSupportedError("Unsupported API");
 	}
 }
 
-void clear (EGLint api, const tcu::Vec4& color, const float depth, const int stencil)
+void clear (const glw::Functions& gl, EGLint api, const tcu::Vec4& color, const float depth, const int stencil)
 {
 	switch (api)
 	{
-#if defined(DEQP_SUPPORT_GLES2) || defined(DEQP_SUPPORT_GLES3)
-		case EGL_OPENGL_ES2_BIT:		clearGLES2(color, depth, stencil);		break;
-		case EGL_OPENGL_ES3_BIT_KHR:	clearGLES2(color, depth, stencil);		break;
-#endif
+		case EGL_OPENGL_ES2_BIT:		clearGLES2(gl, color, depth, stencil);		break;
+		case EGL_OPENGL_ES3_BIT_KHR:	clearGLES2(gl, color, depth, stencil);		break;
 		default:
 			throw tcu::NotSupportedError("Unsupported API");
 	}
 }
 
-static void readPixels (EGLint api, tcu::Surface& dst)
+static void readPixels (const glw::Functions& gl, EGLint api, tcu::Surface& dst)
 {
 	switch (api)
 	{
-#if defined(DEQP_SUPPORT_GLES2) || defined(DEQP_SUPPORT_GLES3)
-		case EGL_OPENGL_ES2_BIT:		readPixelsGLES2(dst);		break;
-		case EGL_OPENGL_ES3_BIT_KHR:	readPixelsGLES2(dst);		break;
-#endif
+		case EGL_OPENGL_ES2_BIT:		readPixelsGLES2(gl, dst);		break;
+		case EGL_OPENGL_ES3_BIT_KHR:	readPixelsGLES2(gl, dst);		break;
 		default:
 			throw tcu::NotSupportedError("Unsupported API");
 	}
 }
 
-tcu::PixelFormat getPixelFormat (const tcu::egl::Display& display, EGLConfig config)
+tcu::PixelFormat getPixelFormat (const Library& egl, EGLDisplay display, EGLConfig config)
 {
 	tcu::PixelFormat fmt;
-	display.describeConfig(config, fmt);
+	fmt.redBits		= eglu::getConfigAttribInt(egl, display, config, EGL_RED_SIZE);
+	fmt.greenBits	= eglu::getConfigAttribInt(egl, display, config, EGL_GREEN_SIZE);
+	fmt.blueBits	= eglu::getConfigAttribInt(egl, display, config, EGL_BLUE_SIZE);
+	fmt.alphaBits	= eglu::getConfigAttribInt(egl, display, config, EGL_ALPHA_SIZE);
 	return fmt;
 }
 
@@ -676,32 +608,36 @@
 class SingleThreadRenderCase : public MultiContextRenderCase
 {
 public:
-						SingleThreadRenderCase		(EglTestContext& eglTestCtx, const char* name, const char* description, EGLint api, EGLint surfaceType, const std::vector<EGLint>& configIds, int numContextsPerApi);
+						SingleThreadRenderCase		(EglTestContext& eglTestCtx, const char* name, const char* description, EGLint api, EGLint surfaceType, const eglu::FilterList& filters, int numContextsPerApi);
 
 private:
-	virtual void		executeForContexts			(tcu::egl::Display& display, tcu::egl::Surface& surface, EGLConfig config, const std::vector<std::pair<EGLint, tcu::egl::Context*> >& contexts);
+	virtual void		executeForContexts			(EGLDisplay display, EGLSurface surface, const Config& config, const std::vector<std::pair<EGLint, EGLContext> >& contexts);
+
+	glw::Functions		m_gl;
 };
 
 // SingleThreadColorClearCase
 
-SingleThreadRenderCase::SingleThreadRenderCase (EglTestContext& eglTestCtx, const char* name, const char* description, EGLint api, EGLint surfaceType, const std::vector<EGLint>& configIds, int numContextsPerApi)
-	: MultiContextRenderCase(eglTestCtx, name, description, api, surfaceType, configIds, numContextsPerApi)
+SingleThreadRenderCase::SingleThreadRenderCase (EglTestContext& eglTestCtx, const char* name, const char* description, EGLint api, EGLint surfaceType, const eglu::FilterList& filters, int numContextsPerApi)
+	: MultiContextRenderCase(eglTestCtx, name, description, api, surfaceType, filters, numContextsPerApi)
 {
+	m_eglTestCtx.initGLFunctions(&m_gl, glu::ApiType::es(2,0));
 }
 
-void SingleThreadRenderCase::executeForContexts (tcu::egl::Display& display, tcu::egl::Surface& surface, EGLConfig config, const std::vector<std::pair<EGLint, tcu::egl::Context*> >& contexts)
+void SingleThreadRenderCase::executeForContexts (EGLDisplay display, EGLSurface surface, const Config& config, const std::vector<std::pair<EGLint, EGLContext> >& contexts)
 {
-	const int				width		= surface.getWidth();
-	const int				height		= surface.getHeight();
+	const Library&			egl			= m_eglTestCtx.getLibrary();
+	const int				width		= eglu::querySurfaceInt(egl, display, surface, EGL_WIDTH);
+	const int				height		= eglu::querySurfaceInt(egl, display, surface, EGL_HEIGHT);
 	const int				numContexts	= (int)contexts.size();
 	const int				drawsPerCtx	= 2;
 	const int				numIters	= 2;
 	const float				threshold	= 0.02f;
 
-	const tcu::PixelFormat	pixelFmt	= getPixelFormat(display, config);
-	const int				depthBits	= display.getConfigAttrib(config, EGL_DEPTH_SIZE);
-	const int				stencilBits	= display.getConfigAttrib(config, EGL_STENCIL_SIZE);
-	const int				numSamples	= display.getConfigAttrib(config, EGL_SAMPLES);
+	const tcu::PixelFormat	pixelFmt	= getPixelFormat(egl, display, config.config);
+	const int				depthBits	= eglu::getConfigAttribInt(egl, display, config.config, EGL_DEPTH_SIZE);
+	const int				stencilBits	= eglu::getConfigAttribInt(egl, display, config.config, EGL_STENCIL_SIZE);
+	const int				numSamples	= eglu::getConfigAttribInt(egl, display, config.config, EGL_SAMPLES);
 
 	TestLog&				log			= m_testCtx.getLog();
 
@@ -729,25 +665,23 @@
 	// Create and setup programs per context
 	for (int ctxNdx = 0; ctxNdx < numContexts; ctxNdx++)
 	{
-		EGLint				api			= contexts[ctxNdx].first;
-		tcu::egl::Context*	context		= contexts[ctxNdx].second;
+		EGLint		api			= contexts[ctxNdx].first;
+		EGLContext	context		= contexts[ctxNdx].second;
 
-		eglMakeCurrent(display.getEGLDisplay(), surface.getEGLSurface(), surface.getEGLSurface(), context->getEGLContext());
-		TCU_CHECK_EGL();
+		EGLU_CHECK_CALL(egl, makeCurrent(display, surface, surface, context));
 
-		programs[ctxNdx] = ProgramSp(createProgram(api));
+		programs[ctxNdx] = ProgramSp(createProgram(m_gl, api));
 		programs[ctxNdx]->setup();
 	}
 
 	// Clear to black using first context.
 	{
-		EGLint				api			= contexts[0].first;
-		tcu::egl::Context*	context		= contexts[0].second;
+		EGLint		api			= contexts[0].first;
+		EGLContext	context		= contexts[0].second;
 
-		eglMakeCurrent(display.getEGLDisplay(), surface.getEGLSurface(), surface.getEGLSurface(), context->getEGLContext());
-		TCU_CHECK_EGL();
+		EGLU_CHECK_CALL(egl, makeCurrent(display, surface, surface, context));
 
-		clear(api, CLEAR_COLOR, CLEAR_DEPTH, CLEAR_STENCIL);
+		clear(m_gl, api, CLEAR_COLOR, CLEAR_DEPTH, CLEAR_STENCIL);
 	}
 
 	// Render.
@@ -755,29 +689,27 @@
 	{
 		for (int ctxNdx = 0; ctxNdx < numContexts; ctxNdx++)
 		{
-			EGLint				api			= contexts[ctxNdx].first;
-			tcu::egl::Context*	context		= contexts[ctxNdx].second;
+			EGLint		api			= contexts[ctxNdx].first;
+			EGLContext	context		= contexts[ctxNdx].second;
 
-			eglMakeCurrent(display.getEGLDisplay(), surface.getEGLSurface(), surface.getEGLSurface(), context->getEGLContext());
-			TCU_CHECK_EGL();
+			EGLU_CHECK_CALL(egl, makeCurrent(display, surface, surface, context));
 
 			for (int drawNdx = 0; drawNdx < drawsPerCtx; drawNdx++)
 			{
 				const DrawPrimitiveOp& drawOp = drawOps[iterNdx*numContexts*drawsPerCtx + ctxNdx*drawsPerCtx + drawNdx];
-				draw(api, *programs[ctxNdx], drawOp);
+				draw(m_gl, api, *programs[ctxNdx], drawOp);
 			}
 		}
 	}
 
 	// Read pixels using first context. \todo [pyry] Randomize?
 	{
-		EGLint				api		= contexts[0].first;
-		tcu::egl::Context*	context	= contexts[0].second;
+		EGLint		api		= contexts[0].first;
+		EGLContext	context	= contexts[0].second;
 
-		eglMakeCurrent(display.getEGLDisplay(), surface.getEGLSurface(), surface.getEGLSurface(), context->getEGLContext());
-		TCU_CHECK_EGL();
+		EGLU_CHECK_CALL(egl, makeCurrent(display, surface, surface, context));
 
-		readPixels(api, frame);
+		readPixels(m_gl, api, frame);
 	}
 
 	// Render reference.
@@ -798,10 +730,12 @@
 class MultiThreadRenderCase : public MultiContextRenderCase
 {
 public:
-						MultiThreadRenderCase		(EglTestContext& eglTestCtx, const char* name, const char* description, EGLint api, EGLint surfaceType, const std::vector<EGLint>& configIds, int numContextsPerApi);
+						MultiThreadRenderCase		(EglTestContext& eglTestCtx, const char* name, const char* description, EGLint api, EGLint surfaceType, const eglu::FilterList& filters, int numContextsPerApi);
 
 private:
-	virtual void		executeForContexts			(tcu::egl::Display& display, tcu::egl::Surface& surface, EGLConfig config, const std::vector<std::pair<EGLint, tcu::egl::Context*> >& contexts);
+	virtual void		executeForContexts			(EGLDisplay display, EGLSurface surface, const Config& config, const std::vector<std::pair<EGLint, EGLContext> >& contexts);
+
+	glw::Functions		m_gl;
 };
 
 class RenderTestThread;
@@ -826,11 +760,13 @@
 class RenderTestThread : public de::Thread
 {
 public:
-	RenderTestThread (tcu::egl::Display& display, tcu::egl::Surface& surface, tcu::egl::Context& context, EGLint api, const Program& program, const std::vector<DrawOpPacket>& packets)
-		: m_display	(display)
+	RenderTestThread (const Library& egl, EGLDisplay display, EGLSurface surface, EGLContext context, EGLint api, const glw::Functions& gl, const Program& program, const std::vector<DrawOpPacket>& packets)
+		: m_egl		(egl)
+		, m_display	(display)
 		, m_surface	(surface)
 		, m_context	(context)
 		, m_api		(api)
+		, m_gl		(gl)
 		, m_program	(program)
 		, m_packets	(packets)
 	{
@@ -844,14 +780,14 @@
 			packetIter->wait->decrement();
 
 			// Acquire context.
-			eglMakeCurrent(m_display.getEGLDisplay(), m_surface.getEGLSurface(), m_surface.getEGLSurface(), m_context.getEGLContext());
+			EGLU_CHECK_CALL(m_egl, makeCurrent(m_display, m_surface, m_surface, m_context));
 
 			// Execute rendering.
 			for (int ndx = 0; ndx < packetIter->numOps; ndx++)
-				draw(m_api, m_program, packetIter->drawOps[ndx]);
+				draw(m_gl, m_api, m_program, packetIter->drawOps[ndx]);
 
 			// Release context.
-			eglMakeCurrent(m_display.getEGLDisplay(), EGL_NO_SURFACE, EGL_NO_SURFACE, EGL_NO_CONTEXT);
+			EGLU_CHECK_CALL(m_egl, makeCurrent(m_display, EGL_NO_SURFACE, EGL_NO_SURFACE, EGL_NO_CONTEXT));
 
 			// Signal completion.
 			packetIter->signal->increment();
@@ -859,23 +795,27 @@
 	}
 
 private:
-	tcu::egl::Display&					m_display;
-	tcu::egl::Surface&					m_surface;
-	tcu::egl::Context&					m_context;
+	const Library&						m_egl;
+	EGLDisplay							m_display;
+	EGLSurface							m_surface;
+	EGLContext							m_context;
 	EGLint								m_api;
+	const glw::Functions&				m_gl;
 	const Program&						m_program;
 	const std::vector<DrawOpPacket>&	m_packets;
 };
 
-MultiThreadRenderCase::MultiThreadRenderCase (EglTestContext& eglTestCtx, const char* name, const char* description, EGLint api, EGLint surfaceType, const std::vector<EGLint>& configIds, int numContextsPerApi)
-	: MultiContextRenderCase(eglTestCtx, name, description, api, surfaceType, configIds, numContextsPerApi)
+MultiThreadRenderCase::MultiThreadRenderCase (EglTestContext& eglTestCtx, const char* name, const char* description, EGLint api, EGLint surfaceType, const eglu::FilterList& filters, int numContextsPerApi)
+	: MultiContextRenderCase(eglTestCtx, name, description, api, surfaceType, filters, numContextsPerApi)
 {
+	m_eglTestCtx.initGLFunctions(&m_gl, glu::ApiType::es(2,0));
 }
 
-void MultiThreadRenderCase::executeForContexts (tcu::egl::Display& display, tcu::egl::Surface& surface, EGLConfig config, const std::vector<std::pair<EGLint, tcu::egl::Context*> >& contexts)
+void MultiThreadRenderCase::executeForContexts (EGLDisplay display, EGLSurface surface, const Config& config, const std::vector<std::pair<EGLint, EGLContext> >& contexts)
 {
-	const int				width				= surface.getWidth();
-	const int				height				= surface.getHeight();
+	const Library&			egl					= m_eglTestCtx.getLibrary();
+	const int				width				= eglu::querySurfaceInt(egl, display, surface, EGL_WIDTH);
+	const int				height				= eglu::querySurfaceInt(egl, display, surface, EGL_HEIGHT);
 	const int				numContexts			= (int)contexts.size();
 	const int				opsPerPacket		= 2;
 	const int				packetsPerThread	= 2;
@@ -883,10 +823,10 @@
 	const int				numPackets			= numThreads * packetsPerThread;
 	const float				threshold			= 0.02f;
 
-	const tcu::PixelFormat	pixelFmt			= getPixelFormat(display, config);
-	const int				depthBits			= display.getConfigAttrib(config, EGL_DEPTH_SIZE);
-	const int				stencilBits			= display.getConfigAttrib(config, EGL_STENCIL_SIZE);
-	const int				numSamples			= display.getConfigAttrib(config, EGL_SAMPLES);
+	const tcu::PixelFormat	pixelFmt			= getPixelFormat(egl, display, config.config);
+	const int				depthBits			= eglu::getConfigAttribInt(egl, display, config.config, EGL_DEPTH_SIZE);
+	const int				stencilBits			= eglu::getConfigAttribInt(egl, display, config.config, EGL_STENCIL_SIZE);
+	const int				numSamples			= eglu::getConfigAttribInt(egl, display, config.config, EGL_SAMPLES);
 
 	TestLog&				log					= m_testCtx.getLog();
 
@@ -939,37 +879,35 @@
 	// Create and setup programs per context
 	for (int ctxNdx = 0; ctxNdx < numContexts; ctxNdx++)
 	{
-		EGLint				api			= contexts[ctxNdx].first;
-		tcu::egl::Context*	context		= contexts[ctxNdx].second;
+		EGLint		api			= contexts[ctxNdx].first;
+		EGLContext	context		= contexts[ctxNdx].second;
 
-		eglMakeCurrent(display.getEGLDisplay(), surface.getEGLSurface(), surface.getEGLSurface(), context->getEGLContext());
-		TCU_CHECK_EGL();
+		EGLU_CHECK_CALL(egl, makeCurrent(display, surface, surface, context));
 
-		programs[ctxNdx] = ProgramSp(createProgram(api));
+		programs[ctxNdx] = ProgramSp(createProgram(m_gl, api));
 		programs[ctxNdx]->setup();
 
 		// Release context
-		eglMakeCurrent(display.getEGLDisplay(), EGL_NO_SURFACE, EGL_NO_SURFACE, EGL_NO_CONTEXT);
+		EGLU_CHECK_CALL(egl, makeCurrent(display, EGL_NO_SURFACE, EGL_NO_SURFACE, EGL_NO_CONTEXT));
 	}
 
 	// Clear to black using first context.
 	{
-		EGLint				api			= contexts[0].first;
-		tcu::egl::Context*	context		= contexts[0].second;
+		EGLint		api			= contexts[0].first;
+		EGLContext	context		= contexts[0].second;
 
-		eglMakeCurrent(display.getEGLDisplay(), surface.getEGLSurface(), surface.getEGLSurface(), context->getEGLContext());
-		TCU_CHECK_EGL();
+		EGLU_CHECK_CALL(egl, makeCurrent(display, surface, surface, context));
 
-		clear(api, CLEAR_COLOR, CLEAR_DEPTH, CLEAR_STENCIL);
+		clear(m_gl, api, CLEAR_COLOR, CLEAR_DEPTH, CLEAR_STENCIL);
 
 		// Release context
-		eglMakeCurrent(display.getEGLDisplay(), EGL_NO_SURFACE, EGL_NO_SURFACE, EGL_NO_CONTEXT);
+		EGLU_CHECK_CALL(egl, makeCurrent(display, EGL_NO_SURFACE, EGL_NO_SURFACE, EGL_NO_CONTEXT));
 	}
 
 	// Create and launch threads (actual rendering starts once first semaphore is signaled).
 	for (int threadNdx = 0; threadNdx < numThreads; threadNdx++)
 	{
-		threads[threadNdx] = RenderTestThreadSp(new RenderTestThread(display, surface, *contexts[threadNdx].second, contexts[threadNdx].first, *programs[threadNdx], packets[threadNdx]));
+		threads[threadNdx] = RenderTestThreadSp(new RenderTestThread(egl, display, surface, contexts[threadNdx].second, contexts[threadNdx].first, m_gl, *programs[threadNdx], packets[threadNdx]));
 		threads[threadNdx]->start();
 	}
 
@@ -979,13 +917,12 @@
 
 	// Read pixels using first context. \todo [pyry] Randomize?
 	{
-		EGLint				api		= contexts[0].first;
-		tcu::egl::Context*	context	= contexts[0].second;
+		EGLint		api		= contexts[0].first;
+		EGLContext	context	= contexts[0].second;
 
-		eglMakeCurrent(display.getEGLDisplay(), surface.getEGLSurface(), surface.getEGLSurface(), context->getEGLContext());
-		TCU_CHECK_EGL();
+		EGLU_CHECK_CALL(egl, makeCurrent(display, surface, surface, context));
 
-		readPixels(api, frame);
+		readPixels(m_gl, api, frame);
 	}
 
 	// Join threads.
@@ -1015,12 +952,19 @@
 
 struct RenderGroupSpec
 {
-	const char*		name;
-	const char*		desc;
-	EGLint			apiBits;
-	int				numContextsPerApi;
+	const char*			name;
+	const char*			desc;
+	EGLint				apiBits;
+	eglu::ConfigFilter	baseFilter;
+	int					numContextsPerApi;
 };
 
+template <deUint32 Bits>
+static bool renderable (const eglu::CandidateConfig& c)
+{
+	return (c.renderableType() & Bits) == Bits;
+}
+
 template <class RenderClass>
 static void createRenderGroups (EglTestContext& eglTestCtx, tcu::TestCaseGroup* group, const RenderGroupSpec* first, const RenderGroupSpec* last)
 {
@@ -1029,13 +973,13 @@
 		tcu::TestCaseGroup* configGroup = new tcu::TestCaseGroup(eglTestCtx.getTestContext(), groupIter->name, groupIter->desc);
 		group->addChild(configGroup);
 
-		vector<RenderConfigIdSet>	configSets;
-		eglu::FilterList			filters;
-		filters << (eglu::ConfigRenderableType() & groupIter->apiBits);
-		getDefaultRenderConfigIdSets(configSets, eglTestCtx.getConfigs(), filters);
+		vector<RenderFilterList>	filterLists;
+		eglu::FilterList			baseFilters;
+		baseFilters << groupIter->baseFilter;
+		getDefaultRenderFilterLists(filterLists, baseFilters);
 
-		for (vector<RenderConfigIdSet>::const_iterator setIter = configSets.begin(); setIter != configSets.end(); setIter++)
-			configGroup->addChild(new RenderClass(eglTestCtx, setIter->getName(), "", groupIter->apiBits, setIter->getSurfaceTypeMask(), setIter->getConfigIds(), groupIter->numContextsPerApi));
+		for (vector<RenderFilterList>::const_iterator listIter = filterLists.begin(); listIter != filterLists.end(); listIter++)
+			configGroup->addChild(new RenderClass(eglTestCtx, listIter->getName(), "", groupIter->apiBits, listIter->getSurfaceTypeMask(), *listIter, groupIter->numContextsPerApi));
 	}
 }
 
@@ -1043,25 +987,45 @@
 {
 	static const RenderGroupSpec singleContextCases[] =
 	{
-//		{ "gles1",			"Primitive rendering using GLES1",												EGL_OPENGL_ES_BIT,										1 },
-		{ "gles2",			"Primitive rendering using GLES2",												EGL_OPENGL_ES2_BIT,										1 },
-		{ "gles3",			"Primitive rendering using GLES3",												EGL_OPENGL_ES3_BIT_KHR,									1 },
-//		{ "vg",				"Primitive rendering using OpenVG",												EGL_OPENVG_BIT,											1 }
+		{
+			"gles2",
+			"Primitive rendering using GLES2",
+			EGL_OPENGL_ES2_BIT,
+			renderable<EGL_OPENGL_ES2_BIT>,
+			1
+		},
+		{
+			"gles3",
+			"Primitive rendering using GLES3",
+			EGL_OPENGL_ES3_BIT,
+			renderable<EGL_OPENGL_ES3_BIT>,
+			1
+		},
 	};
 
 	static const RenderGroupSpec multiContextCases[] =
 	{
-//		{ "gles1",				"Primitive rendering using multiple GLES1 contexts to shared surface",		EGL_OPENGL_ES_BIT,												3 },
-		{ "gles2",				"Primitive rendering using multiple GLES2 contexts to shared surface",		EGL_OPENGL_ES2_BIT,												3 },
-		{ "gles3",				"Primitive rendering using multiple GLES3 contexts to shared surface",		EGL_OPENGL_ES3_BIT_KHR,											3 },
-//		{ "vg",					"Primitive rendering using multiple OpenVG contexts to shared surface",		EGL_OPENVG_BIT,													3 },
-//		{ "gles1_gles2",		"Primitive rendering using multiple APIs to shared surface",				EGL_OPENGL_ES_BIT|EGL_OPENGL_ES2_BIT,							1 },
-//		{ "gles1_gles2_gles3",	"Primitive rendering using multiple APIs to shared surface",				EGL_OPENGL_ES_BIT|EGL_OPENGL_ES2_BIT|EGL_OPENGL_ES3_BIT_KHR,	1 },
-		{ "gles2_gles3",		"Primitive rendering using multiple APIs to shared surface",				EGL_OPENGL_ES2_BIT|EGL_OPENGL_ES3_BIT_KHR,						1 },
-//		{ "gles1_vg",			"Primitive rendering using multiple APIs to shared surface",				EGL_OPENGL_ES_BIT|EGL_OPENVG_BIT,								1 },
-//		{ "gles2_vg",			"Primitive rendering using multiple APIs to shared surface",				EGL_OPENGL_ES2_BIT|EGL_OPENVG_BIT,								1 },
-//		{ "gles3_vg",			"Primitive rendering using multiple APIs to shared surface",				EGL_OPENGL_ES3_BIT_KHR|EGL_OPENVG_BIT,							1 },
-//		{ "gles1_gles2_vg",		"Primitive rendering using multiple APIs to shared surface",				EGL_OPENGL_ES_BIT|EGL_OPENGL_ES2_BIT|EGL_OPENVG_BIT,			1 }
+		{
+			"gles2",
+			"Primitive rendering using multiple GLES2 contexts to shared surface",
+			EGL_OPENGL_ES2_BIT,
+			renderable<EGL_OPENGL_ES2_BIT>,
+			3
+		},
+		{
+			"gles3",
+			"Primitive rendering using multiple GLES3 contexts to shared surface",
+			EGL_OPENGL_ES3_BIT,
+			renderable<EGL_OPENGL_ES3_BIT>,
+			3
+		},
+		{
+			"gles2_gles3",
+			"Primitive rendering using multiple APIs to shared surface",
+			EGL_OPENGL_ES2_BIT|EGL_OPENGL_ES3_BIT,
+			renderable<EGL_OPENGL_ES2_BIT|EGL_OPENGL_ES3_BIT>,
+			1
+		},
 	};
 
 	tcu::TestCaseGroup* singleContextGroup = new tcu::TestCaseGroup(m_testCtx, "single_context", "Single-context rendering");
diff --git a/modules/egl/teglResizeTests.cpp b/modules/egl/teglResizeTests.cpp
index 7c7e3c3..b79ba73 100644
--- a/modules/egl/teglResizeTests.cpp
+++ b/modules/egl/teglResizeTests.cpp
@@ -38,6 +38,9 @@
 #include "egluUnique.hpp"
 #include "egluUtil.hpp"
 
+#include "eglwLibrary.hpp"
+#include "eglwEnums.hpp"
+
 #include "gluDefs.hpp"
 #include "glwFunctions.hpp"
 #include "glwEnums.hpp"
@@ -55,27 +58,29 @@
 namespace egl
 {
 
-using	std::vector;
-using	std::string;
-using	std::ostringstream;
-using	de::MovePtr;
-using	tcu::CommandLine;
-using	tcu::ConstPixelBufferAccess;
-using	tcu::Interval;
-using	tcu::IVec2;
-using	tcu::Vec3;
-using	tcu::Vec4;
-using	tcu::UVec4;
-using	tcu::ResultCollector;
-using	tcu::Surface;
-using	tcu::TestLog;
-using	tcu::egl::Display;
-using	eglu::AttribMap;
-using	eglu::NativeDisplay;
-using	eglu::NativeWindow;
-using	eglu::ScopedCurrentContext;
-using	eglu::UniqueSurface;
-using	eglu::UniqueContext;
+using std::vector;
+using std::string;
+using std::ostringstream;
+using de::MovePtr;
+using tcu::CommandLine;
+using tcu::ConstPixelBufferAccess;
+using tcu::Interval;
+using tcu::IVec2;
+using tcu::Vec3;
+using tcu::Vec4;
+using tcu::UVec4;
+using tcu::ResultCollector;
+using tcu::Surface;
+using tcu::TestLog;
+using eglu::AttribMap;
+using eglu::NativeDisplay;
+using eglu::NativeWindow;
+using eglu::ScopedCurrentContext;
+using eglu::UniqueSurface;
+using eglu::UniqueContext;
+using eglu::NativeWindowFactory;
+using eglu::WindowParams;
+using namespace eglw;
 
 typedef	eglu::WindowParams::Visibility	Visibility;
 typedef	TestCase::IterateResult			IterateResult;
@@ -122,68 +127,79 @@
 	glw::Functions				m_gl;
 };
 
-EGLConfig getEGLConfig (const EGLDisplay eglDisplay, EGLenum surfaceType)
+EGLConfig getEGLConfig (const Library& egl, const EGLDisplay eglDisplay, EGLenum surfaceType)
 {
 	AttribMap attribMap;
 
 	attribMap[EGL_SURFACE_TYPE]		= surfaceType;
 	attribMap[EGL_RENDERABLE_TYPE]	= EGL_OPENGL_ES2_BIT;
 
-	return eglu::chooseSingleConfig(eglDisplay, attribMap);
+	return eglu::chooseSingleConfig(egl, eglDisplay, attribMap);
 }
 
 void ResizeTest::init (void)
 {
 	TestCase::init();
 
-	const CommandLine&		cmdLine			= m_testCtx.getCommandLine();
-	const EGLDisplay		eglDisplay		= m_eglTestCtx.getDisplay().getEGLDisplay();
-	const EGLConfig			eglConfig		= getEGLConfig(eglDisplay, surfaceType());
-	const EGLint			ctxAttribs[]	=
+	const Library&				egl				= m_eglTestCtx.getLibrary();
+	const CommandLine&			cmdLine			= m_testCtx.getCommandLine();
+	const EGLDisplay			eglDisplay		= eglu::getAndInitDisplay(m_eglTestCtx.getNativeDisplay());
+	const EGLConfig				eglConfig		= getEGLConfig(egl, eglDisplay, surfaceType());
+	const EGLint				ctxAttribs[]	=
 	{
 		EGL_CONTEXT_CLIENT_VERSION, 2,
 		EGL_NONE
 	};
-	EGLContext				eglContext		= eglCreateContext(eglDisplay,
-															   eglConfig,
-															   EGL_NO_CONTEXT,
-															   ctxAttribs);
-	EGLU_CHECK_MSG("eglCreateContext()");
-	MovePtr<UniqueContext>	context			(new UniqueContext(eglDisplay, eglContext));
-	const EGLint			configId		= eglu::getConfigAttribInt(eglDisplay,
-																	   eglConfig,
-																	   EGL_CONFIG_ID);
-	const Visibility		visibility		= eglu::parseWindowVisibility(cmdLine);
-	NativeDisplay&			nativeDisplay	= m_eglTestCtx.getNativeDisplay();
-	MovePtr<NativeWindow>	nativeWindow	(m_eglTestCtx.createNativeWindow(eglDisplay,
+	EGLContext					eglContext		= egl.createContext(eglDisplay,
+																   eglConfig,
+																   EGL_NO_CONTEXT,
+																   ctxAttribs);
+	EGLU_CHECK_MSG(egl, "eglCreateContext()");
+	MovePtr<UniqueContext>		context			(new UniqueContext(egl, eglDisplay, eglContext));
+	const EGLint				configId		= eglu::getConfigAttribInt(egl,
+																		   eglDisplay,
+																		   eglConfig,
+																		   EGL_CONFIG_ID);
+	const Visibility			visibility		= eglu::parseWindowVisibility(cmdLine);
+	NativeDisplay&				nativeDisplay	= m_eglTestCtx.getNativeDisplay();
+	const NativeWindowFactory*	windowFactory	= eglu::selectNativeWindowFactory(m_eglTestCtx.getNativeDisplayFactory(),
+																				  cmdLine);
+
+	if (!windowFactory)
+		TCU_THROW(NotSupportedError, "Windows not supported");
+
+	const WindowParams			windowParams	(m_oldSize.x(), m_oldSize.y(), visibility);
+	MovePtr<NativeWindow>		nativeWindow	(windowFactory->createWindow(&nativeDisplay,
+																			 eglDisplay,
 																			 eglConfig,
 																			 DE_NULL,
-																			 m_oldSize.x(),
-																			 m_oldSize.y(),
-																			 visibility));
-	const EGLSurface		eglSurface		= eglu::createWindowSurface(nativeDisplay,
-																		*nativeWindow,
-																		eglDisplay,
-																		eglConfig,
-																		DE_NULL);
-	MovePtr<UniqueSurface>	surface			(new UniqueSurface(eglDisplay, eglSurface));
+																			 windowParams));
+	const EGLSurface			eglSurface		= eglu::createWindowSurface(nativeDisplay,
+																			*nativeWindow,
+																			eglDisplay,
+																			eglConfig,
+																			DE_NULL);
+	MovePtr<UniqueSurface>		surface			(new UniqueSurface(egl, eglDisplay, eglSurface));
 
 	m_log << TestLog::Message
 		  << "Chose EGLConfig with id " << configId << ".\n"
 		  << "Created initial surface with size " << m_oldSize
 		  << TestLog::EndMessage;
 
-	m_eglTestCtx.getGLFunctions(m_gl, glu::ApiType::es(2, 0));
+	m_eglTestCtx.initGLFunctions(&m_gl, glu::ApiType::es(2, 0));
 	m_config		= eglConfig;
 	m_surface		= surface;
 	m_context		= context;
 	m_display		= eglDisplay;
 	m_nativeWindow	= nativeWindow;
-	EGLU_CHECK();
+	EGLU_CHECK_MSG(egl, "init");
 }
 
 void ResizeTest::deinit (void)
 {
+	if (m_display != EGL_NO_DISPLAY)
+		m_eglTestCtx.getLibrary().terminate(m_display);
+
 	m_config		= DE_NULL;
 	m_display		= EGL_NO_DISPLAY;
 	m_context.clear();
@@ -311,14 +327,15 @@
 	return reqSize; // assume we got the requested size
 }
 
-IVec2 checkSurfaceSize (EGLDisplay			eglDisplay,
+IVec2 checkSurfaceSize (const Library&		egl,
+						EGLDisplay			eglDisplay,
 						EGLSurface			eglSurface,
 						const NativeWindow&	nativeWindow,
 						IVec2				reqSize,
 						ResultCollector&	status)
 {
 	const IVec2		nativeSize	= getNativeSurfaceSize(nativeWindow, reqSize);
-	IVec2			eglSize		= eglu::getSurfaceSize(eglDisplay, eglSurface);
+	IVec2			eglSize		= eglu::getSurfaceSize(egl, eglDisplay, eglSurface);
 	ostringstream	oss;
 
 	oss << "Size of EGL surface " << eglSize
@@ -330,11 +347,12 @@
 
 IterateResult ChangeSurfaceSizeCase::iterate (void)
 {
-	EGLU_CHECK();
+	const Library&			egl			= m_eglTestCtx.getLibrary();
 	Surface					oldSurface;
 	Surface					newSurface;
-	ScopedCurrentContext	currentCtx	(m_display, **m_surface, **m_surface, **m_context);
-	IVec2					oldEglSize	= checkSurfaceSize(m_display,
+	ScopedCurrentContext	currentCtx	(egl, m_display, **m_surface, **m_surface, **m_context);
+	IVec2					oldEglSize	= checkSurfaceSize(egl,
+														   m_display,
 														   **m_surface,
 														   *m_nativeWindow,
 														   m_oldSize,
@@ -344,8 +362,9 @@
 
 	this->resize(m_newSize);
 
-	eglSwapBuffers(m_display, **m_surface);
-	checkSurfaceSize(m_display, **m_surface, *m_nativeWindow, m_newSize, m_status);
+	egl.swapBuffers(m_display, **m_surface);
+	EGLU_CHECK_MSG(egl, "eglSwapBuffers()");
+	checkSurfaceSize(egl, m_display, **m_surface, *m_nativeWindow, m_newSize, m_status);
 
 	m_status.setTestContextResult(m_testCtx);
 	return STOP;
@@ -369,15 +388,15 @@
 
 IterateResult PreserveBackBufferCase::iterate (void)
 {
-	ScopedCurrentContext	currentCtx	(m_display, **m_surface, **m_surface, **m_context);
+	const Library&			egl			= m_eglTestCtx.getLibrary();
+	ScopedCurrentContext	currentCtx	(egl, m_display, **m_surface, **m_surface, **m_context);
 
-	EGLU_CHECK_CALL(
-		eglSurfaceAttrib(m_display, **m_surface, EGL_SWAP_BEHAVIOR, EGL_BUFFER_PRESERVED));
+	EGLU_CHECK_CALL(egl, surfaceAttrib(m_display, **m_surface, EGL_SWAP_BEHAVIOR, EGL_BUFFER_PRESERVED));
 
 	GLU_EXPECT_NO_ERROR(m_gl.getError(), "GL state erroneous upon initialization!");
 
 	{
-		const IVec2 oldEglSize = eglu::getSurfaceSize(m_display, **m_surface);
+		const IVec2 oldEglSize = eglu::getSurfaceSize(egl, m_display, **m_surface);
 		initSurface(m_gl, oldEglSize);
 
 		m_gl.finish();
@@ -386,12 +405,13 @@
 		{
 			const Surface oldSurface = readSurface(m_gl, oldEglSize);
 
-			eglSwapBuffers(m_display, **m_surface);
+			egl.swapBuffers(m_display, **m_surface);
 			this->resize(m_newSize);
-			eglSwapBuffers(m_display, **m_surface);
+			egl.swapBuffers(m_display, **m_surface);
+			EGLU_CHECK_MSG(egl, "eglSwapBuffers()");
 
 			{
-				const IVec2		newEglSize	= eglu::getSurfaceSize(m_display, **m_surface);
+				const IVec2		newEglSize	= eglu::getSurfaceSize(egl, m_display, **m_surface);
 				const Surface	newSurface	= readSurface(m_gl, newEglSize);
 
 				m_log << TestLog::ImageSet("Corner comparison",
@@ -438,10 +458,11 @@
 
 IvVec2 UpdateResolutionCase::getNativePixelsPerInch	(void)
 {
+	const Library&	egl			= m_eglTestCtx.getLibrary();
 	const int		inchPer10km	= 254 * EGL_DISPLAY_SCALING;
-	const IVec2		bufSize		= eglu::getSurfaceSize(m_display, **m_surface);
+	const IVec2		bufSize		= eglu::getSurfaceSize(egl, m_display, **m_surface);
 	const IVec2		winSize		= m_nativeWindow->getScreenSize();
-	const IVec2		bufPp10km	= eglu::getSurfaceResolution(m_display, **m_surface);
+	const IVec2		bufPp10km	= eglu::getSurfaceResolution(egl, m_display, **m_surface);
 	const Interval	margin		(-1.0, 1.0); // The resolution may be rounded
 	const IvVec2	bufPpiI		= (IvVec2(approximateInt(bufPp10km.x()),
 										  approximateInt(bufPp10km.y()))
@@ -466,20 +487,21 @@
 
 IterateResult UpdateResolutionCase::iterate (void)
 {
-	ScopedCurrentContext	currentCtx	(m_display, **m_surface, **m_surface, **m_context);
+	const Library&			egl			= m_eglTestCtx.getLibrary();
+	ScopedCurrentContext	currentCtx	(egl, m_display, **m_surface, **m_surface, **m_context);
 
 	if (!hasBits(m_nativeWindow->getCapabilities(),
 				 NativeWindow::CAPABILITY_GET_SCREEN_SIZE))
 		TCU_THROW(NotSupportedError, "Unable to determine surface size in screen pixels");
 
 	{
-		const IVec2 oldEglSize = eglu::getSurfaceSize(m_display, **m_surface);
+		const IVec2 oldEglSize = eglu::getSurfaceSize(egl, m_display, **m_surface);
 		initSurface(m_gl, oldEglSize);
 	}
 	{
 		const IvVec2 oldPpi = this->getNativePixelsPerInch();
 		this->resize(m_newSize);
-		eglSwapBuffers(m_display, **m_surface);
+		EGLU_CHECK_CALL(egl, swapBuffers(m_display, **m_surface));
 		{
 			const IvVec2 newPpi = this->getNativePixelsPerInch();
 			m_status.check(oldPpi.x().intersects(newPpi.x()) &&
diff --git a/modules/egl/teglSimpleConfigCase.cpp b/modules/egl/teglSimpleConfigCase.cpp
index d11232f..f8210bf 100644
--- a/modules/egl/teglSimpleConfigCase.cpp
+++ b/modules/egl/teglSimpleConfigCase.cpp
@@ -22,29 +22,29 @@
  *//*--------------------------------------------------------------------*/
 
 #include "teglSimpleConfigCase.hpp"
-#include "deStringUtil.hpp"
 #include "tcuTestLog.hpp"
 #include "tcuFormatUtil.hpp"
-
-#include <map>
-#include <set>
-#include <algorithm>
+#include "egluUtil.hpp"
+#include "eglwLibrary.hpp"
+#include "eglwEnums.hpp"
+#include "deStringUtil.hpp"
 
 namespace deqp
 {
 namespace egl
 {
 
-using std::map;
-using std::set;
 using std::vector;
 using std::string;
 using tcu::TestLog;
 using eglu::ConfigInfo;
+using namespace eglw;
+using namespace eglu;
 
-SimpleConfigCase::SimpleConfigCase (EglTestContext& eglTestCtx, const char* name, const char* description, const vector<EGLint>& configIds)
-	: TestCase		(eglTestCtx, name, description)
-	, m_configIds	(configIds)
+SimpleConfigCase::SimpleConfigCase (EglTestContext& eglTestCtx, const char* name, const char* description, const FilterList& filters)
+	: TestCase	(eglTestCtx, name, description)
+	, m_filters	(filters)
+	, m_display	(EGL_NO_DISPLAY)
 {
 }
 
@@ -54,39 +54,28 @@
 
 void SimpleConfigCase::init (void)
 {
-	const tcu::egl::Display& display = m_eglTestCtx.getDisplay();
+	const Library&		egl		= m_eglTestCtx.getLibrary();
+
+	DE_ASSERT(m_display == EGL_NO_DISPLAY && m_configs.empty());
+
+	m_display	= getAndInitDisplay(m_eglTestCtx.getNativeDisplay());
+	m_configs	= chooseConfigs(egl, m_display, m_filters);
 
 	// Log matching configs.
-	m_testCtx.getLog() << TestLog::Message << "Matching configs: " << tcu::formatArray(m_configIds.begin(), m_configIds.end()) << TestLog::EndMessage;
-
-	// Config id set.
-	set<EGLint> idSet(m_configIds.begin(), m_configIds.end());
-
-	if (idSet.size() != m_configIds.size())
 	{
-		DE_ASSERT(idSet.size() < m_configIds.size());
-		m_testCtx.getLog() << tcu::TestLog::Message << "Warning: Duplicate config IDs in list" << TestLog::EndMessage;
-	}
+		vector<EGLint> configIds(m_configs.size());
 
-	// Get all configs
-	vector<EGLConfig> allConfigs;
-	display.getConfigs(allConfigs);
+		for (size_t ndx = 0; ndx < m_configs.size(); ndx++)
+			configIds[ndx] = getConfigID(egl, m_display, m_configs[ndx]);
 
-	// Collect list of configs with matching IDs
-	m_configs.clear();
-	for (vector<EGLConfig>::const_iterator cfgIter = allConfigs.begin(); cfgIter != allConfigs.end(); ++cfgIter)
-	{
-		const EGLint	configId	= display.getConfigAttrib(*cfgIter, EGL_CONFIG_ID);
-		const bool		isInSet		= idSet.find(configId) != idSet.end();
-
-		if (isInSet)
-			m_configs.push_back(*cfgIter);
+		m_testCtx.getLog() << TestLog::Message << "Compatible configs: " << tcu::formatArray(configIds.begin(), configIds.end()) << TestLog::EndMessage;
 	}
 
 	if (m_configs.empty())
 	{
-		// If no compatible configs are found, it is reported as NotSupported
-		throw tcu::NotSupportedError("No compatible configs found");
+		egl.terminate(m_display);
+		m_display = EGL_NO_DISPLAY;
+		TCU_THROW(NotSupportedError, "No compatible configs found");
 	}
 
 	// Init config iter
@@ -96,16 +85,22 @@
 	m_testCtx.setTestResult(QP_TEST_RESULT_PASS, "Pass");
 }
 
+void SimpleConfigCase::deinit (void)
+{
+	m_eglTestCtx.getLibrary().terminate(m_display);
+	m_display = EGL_NO_DISPLAY;
+	m_configs.clear();
+}
+
 SimpleConfigCase::IterateResult SimpleConfigCase::iterate (void)
 {
 	DE_ASSERT(m_configIter != m_configs.end());
 
-	tcu::egl::Display&	display	= m_eglTestCtx.getDisplay();
-	EGLConfig			config	= *m_configIter++;
+	EGLConfig	config	= *m_configIter++;
 
 	try
 	{
-		executeForConfig(display, config);
+		executeForConfig(m_display, config);
 	}
 	catch (const tcu::TestError& e)
 	{
@@ -117,111 +112,96 @@
 	return (m_configIter != m_configs.end()) ? CONTINUE : STOP;
 }
 
-namespace
+template <int Red, int Green, int Blue, int Alpha>
+static bool colorBits (const eglu::CandidateConfig& c)
 {
-
-void addConfigId (map<string, NamedConfigIdSet*>& setMap, const char* name, const ConfigInfo& info)
-{
-	DE_ASSERT(setMap.find(name) != setMap.end());
-	setMap[name]->getConfigIds().push_back(info.configId);
+	return c.redSize()		== Red		&&
+		   c.greenSize()	== Green	&&
+		   c.blueSize()		== Blue		&&
+		   c.alphaSize()	== Alpha;
 }
 
-bool filterConfigStencil (map<string, NamedConfigIdSet*>& setMap, const char* namePrefix, const ConfigInfo& info)
+template <int Red, int Green, int Blue, int Alpha>
+static bool notColorBits (const eglu::CandidateConfig& c)
 {
-	if (info.stencilSize > 0)
-		addConfigId(setMap, (string(namePrefix) + "stencil").c_str(), info);
-	else
-		addConfigId(setMap, (string(namePrefix) + "no_stencil").c_str(), info);
-	return true;
+	return c.redSize()		!= Red		||
+		   c.greenSize()	!= Green	||
+		   c.blueSize()		!= Blue		||
+		   c.alphaSize()	!= Alpha;
 }
 
-bool filterConfigDepth (map<string, NamedConfigIdSet*>& setMap, const char* namePrefix, const ConfigInfo& info)
-{
-	if (info.depthSize > 0)
-		return filterConfigStencil(setMap, (string(namePrefix) + "depth_").c_str(), info);
-	else
-		return filterConfigStencil(setMap, (string(namePrefix) + "no_depth_").c_str(), info);
-}
+static bool	hasDepth	(const eglu::CandidateConfig& c)	{ return c.depthSize() > 0;		}
+static bool	noDepth		(const eglu::CandidateConfig& c)	{ return c.depthSize() == 0;	}
+static bool	hasStencil	(const eglu::CandidateConfig& c)	{ return c.stencilSize() > 0;	}
+static bool	noStencil	(const eglu::CandidateConfig& c)	{ return c.stencilSize() == 0;	}
 
-bool filterConfigColor (map<string, NamedConfigIdSet*>& setMap, const char* namePrefix, const ConfigInfo& info)
+void getDefaultFilterLists (vector<NamedFilterList>& lists, const FilterList& baseFilters)
 {
 	static const struct
 	{
-		const char*	name;
-		int			red, green, blue, alpha;
-	}
-	colorRules[] =
+		const char*			name;
+		eglu::ConfigFilter	filter;
+	} s_colorRules[] =
 	{
-		{ "rgb565",		5, 6, 5, 0 },
-		{ "rgb888",		8, 8, 8, 0 },
-		{ "rgba4444",	4, 4, 4, 4 },
-		{ "rgba5551",	5, 5, 5, 1 },
-		{ "rgba8888",	8, 8, 8, 8 }
+		{ "rgb565",		colorBits<5, 6, 5, 0> },
+		{ "rgb888",		colorBits<8, 8, 8, 0> },
+		{ "rgba4444",	colorBits<4, 4, 4, 4> },
+		{ "rgba5551",	colorBits<5, 5, 5, 1> },
+		{ "rgba8888",	colorBits<8, 8, 8, 8> }
 	};
-	for (int ndx = 0; ndx < (int)DE_LENGTH_OF_ARRAY(colorRules); ndx++)
+
+	static const struct
 	{
-		if (info.redSize	== colorRules[ndx].red		&&
-			info.greenSize	== colorRules[ndx].green	&&
-			info.blueSize	== colorRules[ndx].blue		&&
-			info.alphaSize	== colorRules[ndx].alpha)
-			return filterConfigDepth(setMap, (string(namePrefix) + colorRules[ndx].name + "_").c_str(), info);
-	}
-
-	return false; // Didn't match any
-}
-
-} // anonymous
-
-void NamedConfigIdSet::getDefaultSets (vector<NamedConfigIdSet>& configSets, const vector<ConfigInfo>& configInfos, const eglu::FilterList& baseFilters)
-{
-	// Set list
-	configSets.push_back(NamedConfigIdSet("rgb565_no_depth_no_stencil",		"RGB565 configs without depth or stencil"));
-	configSets.push_back(NamedConfigIdSet("rgb565_no_depth_stencil",		"RGB565 configs with stencil and no depth"));
-	configSets.push_back(NamedConfigIdSet("rgb565_depth_no_stencil",		"RGB565 configs with depth and no stencil"));
-	configSets.push_back(NamedConfigIdSet("rgb565_depth_stencil",			"RGB565 configs with depth and stencil"));
-	configSets.push_back(NamedConfigIdSet("rgb888_no_depth_no_stencil",		"RGB888 configs without depth or stencil"));
-	configSets.push_back(NamedConfigIdSet("rgb888_no_depth_stencil",		"RGB888 configs with stencil and no depth"));
-	configSets.push_back(NamedConfigIdSet("rgb888_depth_no_stencil",		"RGB888 configs with depth and no stencil"));
-	configSets.push_back(NamedConfigIdSet("rgb888_depth_stencil",			"RGB888 configs with depth and stencil"));
-	configSets.push_back(NamedConfigIdSet("rgba4444_no_depth_no_stencil",	"RGBA4444 configs without depth or stencil"));
-	configSets.push_back(NamedConfigIdSet("rgba4444_no_depth_stencil",		"RGBA4444 configs with stencil and no depth"));
-	configSets.push_back(NamedConfigIdSet("rgba4444_depth_no_stencil",		"RGBA4444 configs with depth and no stencil"));
-	configSets.push_back(NamedConfigIdSet("rgba4444_depth_stencil",			"RGBA4444 configs with depth and stencil"));
-	configSets.push_back(NamedConfigIdSet("rgba5551_no_depth_no_stencil",	"RGBA5551 configs without depth or stencil"));
-	configSets.push_back(NamedConfigIdSet("rgba5551_no_depth_stencil",		"RGBA5551 configs with stencil and no depth"));
-	configSets.push_back(NamedConfigIdSet("rgba5551_depth_no_stencil",		"RGBA5551 configs with depth and no stencil"));
-	configSets.push_back(NamedConfigIdSet("rgba5551_depth_stencil",			"RGBA5551 configs with depth and stencil"));
-	configSets.push_back(NamedConfigIdSet("rgba8888_no_depth_no_stencil",	"RGBA8888 configs without depth or stencil"));
-	configSets.push_back(NamedConfigIdSet("rgba8888_no_depth_stencil",		"RGBA8888 configs with stencil and no depth"));
-	configSets.push_back(NamedConfigIdSet("rgba8888_depth_no_stencil",		"RGBA8888 configs with depth and no stencil"));
-	configSets.push_back(NamedConfigIdSet("rgba8888_depth_stencil",			"RGBA8888 configs with depth and stencil"));
-	configSets.push_back(NamedConfigIdSet("other",							"All other configs"));
-
-	// Build set map
-	map<string, NamedConfigIdSet*> setMap;
-	for (int ndx = 0; ndx < (int)configSets.size(); ndx++)
-		setMap[configSets[ndx].getName()] = &configSets[ndx];
-
-	// Filter configs
-	for (vector<ConfigInfo>::const_iterator cfgIter = configInfos.begin(); cfgIter != configInfos.end(); cfgIter++)
+		const char*			name;
+		eglu::ConfigFilter	filter;
+	} s_depthRules[] =
 	{
-		const ConfigInfo& info = *cfgIter;
+		{ "no_depth",	noDepth		},
+		{ "depth",		hasDepth	},
+	};
 
-		if (!baseFilters.match(info))
-			continue;
+	static const struct
+	{
+		const char*			name;
+		eglu::ConfigFilter	filter;
+	} s_stencilRules[] =
+	{
+		{ "no_stencil",	noStencil	},
+		{ "stencil",	hasStencil	},
+	};
 
-		if (!filterConfigColor(setMap, "", info))
+	for (int colorRuleNdx = 0; colorRuleNdx < DE_LENGTH_OF_ARRAY(s_colorRules); colorRuleNdx++)
+	{
+		for (int depthRuleNdx = 0; depthRuleNdx < DE_LENGTH_OF_ARRAY(s_depthRules); depthRuleNdx++)
 		{
-			// Add to "other" set
-			addConfigId(setMap, "other", info);
+			for (int stencilRuleNdx = 0; stencilRuleNdx < DE_LENGTH_OF_ARRAY(s_stencilRules); stencilRuleNdx++)
+			{
+				const string		name		= string(s_colorRules[colorRuleNdx].name) + "_" + s_depthRules[depthRuleNdx].name + "_" + s_stencilRules[stencilRuleNdx].name;
+				NamedFilterList		filters		(name.c_str(), "");
+
+				filters << baseFilters
+						<< s_colorRules[colorRuleNdx].filter
+						<< s_depthRules[depthRuleNdx].filter
+						<< s_stencilRules[stencilRuleNdx].filter;
+
+				lists.push_back(filters);
+			}
 		}
 	}
 
-	// Sort config ids
-	for (vector<NamedConfigIdSet>::iterator i = configSets.begin(); i != configSets.end(); i++)
+	// Build "other" set - not configs that don't match any of known color rules
 	{
-		vector<EGLint>& ids = i->getConfigIds();
-		std::sort(ids.begin(), ids.end());
+		NamedFilterList		filters		("other", "All other configs");
+
+		// \todo [2014-12-18 pyry] Optimize rules
+		filters << baseFilters
+				<< notColorBits<5, 6, 5, 0>
+				<< notColorBits<8, 8, 8, 0>
+				<< notColorBits<4, 4, 4, 4>
+				<< notColorBits<5, 5, 5, 1>
+				<< notColorBits<8, 8, 8, 8>;
+
+		lists.push_back(filters);
 	}
 }
 
diff --git a/modules/egl/teglSimpleConfigCase.hpp b/modules/egl/teglSimpleConfigCase.hpp
index 5e959d4..03bfa9d 100644
--- a/modules/egl/teglSimpleConfigCase.hpp
+++ b/modules/egl/teglSimpleConfigCase.hpp
@@ -25,7 +25,6 @@
 
 #include "tcuDefs.hpp"
 #include "teglTestCase.hpp"
-#include "tcuEgl.hpp"
 #include "egluConfigFilter.hpp"
 
 #include <vector>
@@ -39,44 +38,44 @@
 class SimpleConfigCase : public TestCase
 {
 public:
-							SimpleConfigCase			(EglTestContext& eglTestCtx, const char* name, const char* description, const std::vector<EGLint>& configIds);
-	virtual					~SimpleConfigCase			(void);
+							SimpleConfigCase	(EglTestContext& eglTestCtx, const char* name, const char* description, const eglu::FilterList& filters);
+	virtual					~SimpleConfigCase	(void);
 
-	void					init						(void);
-	IterateResult			iterate						(void);
+	void					init				(void);
+	void					deinit				(void);
+	IterateResult			iterate				(void);
+
+protected:
+	eglw::EGLDisplay		getDisplay			(void) { return m_display; }
 
 private:
-	virtual void			executeForConfig			(tcu::egl::Display& display, EGLConfig config)	= DE_NULL;
+	virtual void			executeForConfig	(eglw::EGLDisplay display, eglw::EGLConfig config)	= DE_NULL;
 
-							SimpleConfigCase			(const SimpleConfigCase& other);
-	SimpleConfigCase&		operator=					(const SimpleConfigCase& other);
+							SimpleConfigCase	(const SimpleConfigCase& other);
+	SimpleConfigCase&		operator=			(const SimpleConfigCase& other);
 
-	std::vector<EGLint>					m_configIds;
-	std::vector<EGLConfig>				m_configs;
-	std::vector<EGLConfig>::iterator	m_configIter;
+	const eglu::FilterList						m_filters;
+
+	eglw::EGLDisplay							m_display;
+	std::vector<eglw::EGLConfig>				m_configs;
+	std::vector<eglw::EGLConfig>::iterator		m_configIter;
 };
 
-class NamedConfigIdSet
+class NamedFilterList : public eglu::FilterList
 {
 public:
-								NamedConfigIdSet		(void) {}
-								NamedConfigIdSet		(const char* name, const char* description) : m_name(name), m_description(description) {}
-								NamedConfigIdSet		(const char* name, const char* description, const std::vector<EGLint>& configIds) : m_name(name), m_description(description), m_configIds(configIds) {}
+					NamedFilterList		(const char* name, const char* description) : m_name(name), m_description(description) {}
 
-	const char*					getName					(void) const	{ return m_name.c_str();		}
-	const char*					getDescription			(void) const	{ return m_description.c_str();	}
-	const std::vector<EGLint>	getConfigIds			(void) const	{ return m_configIds;			}
-
-	std::vector<EGLint>&		getConfigIds			(void)			{ return m_configIds;			}
-
-	static void					getDefaultSets			(std::vector<NamedConfigIdSet>& configSets, const std::vector<eglu::ConfigInfo>& configInfos, const eglu::FilterList& baseFilters);
+	const char*		getName				(void) const	{ return m_name.c_str();		}
+	const char*		getDescription		(void) const	{ return m_description.c_str();	}
 
 private:
-	std::string					m_name;
-	std::string					m_description;
-	std::vector<EGLint>			m_configIds;
+	std::string		m_name;
+	std::string		m_description;
 };
 
+void getDefaultFilterLists (std::vector<NamedFilterList>& lists, const eglu::FilterList& baseFilters);
+
 } // egl
 } // deqp
 
diff --git a/modules/egl/teglSurfacelessContextTests.cpp b/modules/egl/teglSurfacelessContextTests.cpp
index 650f125..1be9cc7 100644
--- a/modules/egl/teglSurfacelessContextTests.cpp
+++ b/modules/egl/teglSurfacelessContextTests.cpp
@@ -23,26 +23,28 @@
 
 #include "teglSurfacelessContextTests.hpp"
 #include "teglSimpleConfigCase.hpp"
+
 #include "egluStrUtil.hpp"
+#include "egluUtil.hpp"
+#include "egluUnique.hpp"
+
 #include "tcuTestLog.hpp"
 
-#include <EGL/eglext.h>
+#include "eglwLibrary.hpp"
+#include "eglwEnums.hpp"
+
+#include "deSTLUtil.hpp"
 
 #include <string>
 #include <vector>
 #include <algorithm>
 
-#if !defined(EGL_OPENGL_ES3_BIT_KHR)
-#	define EGL_OPENGL_ES3_BIT_KHR	0x0040
-#endif
-#if !defined(EGL_CONTEXT_MAJOR_VERSION_KHR)
-#	define EGL_CONTEXT_MAJOR_VERSION_KHR EGL_CONTEXT_CLIENT_VERSION
-#endif
-
 using std::vector;
 using std::string;
 using tcu::TestLog;
 
+using namespace eglw;
+
 namespace deqp
 {
 namespace egl
@@ -53,14 +55,14 @@
 class SurfacelessContextCase : public SimpleConfigCase
 {
 public:
-						SurfacelessContextCase			(EglTestContext& eglTestCtx, const char* name, const char* description, const vector<EGLint>& configIds);
+						SurfacelessContextCase			(EglTestContext& eglTestCtx, const char* name, const char* description, const eglu::FilterList& filters);
 						~SurfacelessContextCase			(void);
 
-	void				executeForConfig				(tcu::egl::Display& display, EGLConfig config);
+	void				executeForConfig				(EGLDisplay display, EGLConfig config);
 };
 
-SurfacelessContextCase::SurfacelessContextCase (EglTestContext& eglTestCtx, const char* name, const char* description, const vector<EGLint>& configIds)
-	: SimpleConfigCase(eglTestCtx, name, description, configIds)
+SurfacelessContextCase::SurfacelessContextCase (EglTestContext& eglTestCtx, const char* name, const char* description, const eglu::FilterList& filters)
+	: SimpleConfigCase(eglTestCtx, name, description, filters)
 {
 }
 
@@ -68,11 +70,12 @@
 {
 }
 
-void SurfacelessContextCase::executeForConfig (tcu::egl::Display& display, EGLConfig config)
+void SurfacelessContextCase::executeForConfig (EGLDisplay display, EGLConfig config)
 {
+	const Library&	egl		= m_eglTestCtx.getLibrary();
 	TestLog&		log		= m_testCtx.getLog();
-	const EGLint	id		= display.getConfigAttrib(config, EGL_CONFIG_ID);
-	const EGLint	apiBits	= display.getConfigAttrib(config, EGL_RENDERABLE_TYPE);
+	const EGLint	id		= eglu::getConfigAttribInt(egl, display, config, EGL_CONFIG_ID);
+	const EGLint	apiBits	= eglu::getConfigAttribInt(egl, display, config, EGL_RENDERABLE_TYPE);
 
 	static const EGLint es1Attrs[] = { EGL_CONTEXT_CLIENT_VERSION,		1, EGL_NONE };
 	static const EGLint es2Attrs[] = { EGL_CONTEXT_CLIENT_VERSION,		2, EGL_NONE };
@@ -93,13 +96,8 @@
 		{ "OpenVG",			EGL_OPENVG_API,		EGL_OPENVG_BIT,			DE_NULL		}
 	};
 
-	{
-		vector<string> extensions;
-		display.getExtensions(extensions);
-
-		if (std::find(extensions.begin(), extensions.end(), string("EGL_KHR_surfaceless_context")) == extensions.end())
-			throw tcu::NotSupportedError("EGL_KHR_surfaceless_context not supported", "", __FILE__, __LINE__);
-	}
+	if (!eglu::hasExtension(egl, display, "EGL_KHR_surfaceless_context"))
+		TCU_THROW(NotSupportedError, "EGL_KHR_surfaceless_context not supported");
 
 	for (int apiNdx = 0; apiNdx < (int)DE_LENGTH_OF_ARRAY(apis); apiNdx++)
 	{
@@ -107,35 +105,31 @@
 			continue; // Not supported API
 
 		log << TestLog::Message << "Creating " << apis[apiNdx].name << " context with config ID " << id << TestLog::EndMessage;
-		TCU_CHECK_EGL();
 
-		TCU_CHECK_EGL_CALL(eglBindAPI(apis[apiNdx].api));
+		EGLU_CHECK_CALL(egl, bindAPI(apis[apiNdx].api));
 
-		EGLContext context = eglCreateContext(display.getEGLDisplay(), config, EGL_NO_CONTEXT, apis[apiNdx].ctxAttrs);
-		TCU_CHECK_EGL();
+		eglu::UniqueContext context(egl, display, egl.createContext(display, config, EGL_NO_CONTEXT, apis[apiNdx].ctxAttrs));
+		EGLU_CHECK_MSG(egl, "eglCreateContext()");
 
-		if (!eglMakeCurrent(display.getEGLDisplay(), EGL_NO_SURFACE, EGL_NO_SURFACE, context))
+		if (!egl.makeCurrent(display, EGL_NO_SURFACE, EGL_NO_SURFACE, *context))
 		{
-			const EGLenum err = eglGetError();
+			const EGLenum err = egl.getError();
 
 			if (err == EGL_BAD_MATCH)
 			{
 				log << TestLog::Message << "  eglMakeCurrent() failed with EGL_BAD_MATCH. Context doesn't support surfaceless mode." << TestLog::EndMessage;
-				TCU_CHECK_EGL_CALL(eglDestroyContext(display.getEGLDisplay(), context));
 				continue;
 			}
 			else
 			{
-				log << TestLog::Message << "  Fail, context: " << tcu::toHex(context) << ", error: " << eglu::getErrorName(err) << TestLog::EndMessage;
+				log << TestLog::Message << "  Fail, context: " << tcu::toHex(*context) << ", error: " << eglu::getErrorName(err) << TestLog::EndMessage;
 				m_testCtx.setTestResult(QP_TEST_RESULT_FAIL, "Failed to make context current");
 				continue;
 			}
 		}
 
-		TCU_CHECK_EGL_CALL(eglMakeCurrent(display.getEGLDisplay(), EGL_NO_SURFACE, EGL_NO_SURFACE, EGL_NO_CONTEXT));
+		EGLU_CHECK_CALL(egl, makeCurrent(display, EGL_NO_SURFACE, EGL_NO_SURFACE, EGL_NO_CONTEXT));
 
-		// Destroy
-		TCU_CHECK_EGL_CALL(eglDestroyContext(display.getEGLDisplay(), context));
 		log << TestLog::Message << "  Pass" << TestLog::EndMessage;
 	}
 }
@@ -151,12 +145,11 @@
 
 void SurfacelessContextTests::init (void)
 {
-	vector<NamedConfigIdSet>	configIdSets;
-	eglu::FilterList			filters;
-	NamedConfigIdSet::getDefaultSets(configIdSets, m_eglTestCtx.getConfigs(), filters);
+	vector<NamedFilterList>	filterLists;
+	getDefaultFilterLists(filterLists, eglu::FilterList());
 
-	for (vector<NamedConfigIdSet>::const_iterator i = configIdSets.begin(); i != configIdSets.end(); i++)
-		addChild(new SurfacelessContextCase(m_eglTestCtx, i->getName(), i->getDescription(), i->getConfigIds()));
+	for (vector<NamedFilterList>::const_iterator i = filterLists.begin(); i != filterLists.end(); i++)
+		addChild(new SurfacelessContextCase(m_eglTestCtx, i->getName(), i->getDescription(), *i));
 }
 
 } // egl
diff --git a/modules/egl/teglSwapBuffersTests.cpp b/modules/egl/teglSwapBuffersTests.cpp
index 9a353bc..52243f4 100644
--- a/modules/egl/teglSwapBuffersTests.cpp
+++ b/modules/egl/teglSwapBuffersTests.cpp
@@ -28,6 +28,8 @@
 #include "egluNativeWindow.hpp"
 #include "egluUtil.hpp"
 #include "egluUnique.hpp"
+#include "eglwLibrary.hpp"
+#include "eglwEnums.hpp"
 
 #include "gluDefs.hpp"
 #include "glwEnums.hpp"
@@ -48,20 +50,20 @@
 #include <vector>
 #include <sstream>
 
-using tcu::TestLog;
-
-using std::string;
-using std::vector;
-
 namespace deqp
 {
 namespace egl
 {
 
+using tcu::TestLog;
+using std::string;
+using std::vector;
+using namespace eglw;
+
 namespace
 {
 
-EGLContext createGLES2Context (EGLDisplay display, EGLConfig config)
+EGLContext createGLES2Context (const Library& egl, EGLDisplay display, EGLConfig config)
 {
 	EGLContext		context = EGL_NO_CONTEXT;
 	const EGLint	attribList[] =
@@ -71,10 +73,10 @@
 	};
 
 
-	TCU_CHECK_EGL_CALL(eglBindAPI(EGL_OPENGL_ES_API));
+	EGLU_CHECK_CALL(egl, bindAPI(EGL_OPENGL_ES_API));
 
-	context = eglCreateContext(display, config, EGL_NO_CONTEXT, attribList);
-	TCU_CHECK_EGL_MSG("eglCreateContext() failed");
+	context = egl.createContext(display, config, EGL_NO_CONTEXT, attribList);
+	EGLU_CHECK_MSG(egl, "eglCreateContext() failed");
 	TCU_CHECK(context);
 
 	return context;
@@ -83,11 +85,11 @@
 class SwapBuffersTest : public SimpleConfigCase
 {
 public:
-						SwapBuffersTest		(EglTestContext& eglTestCtx, const char* name, const char* description, const vector<EGLint>& configIds);
+						SwapBuffersTest		(EglTestContext& eglTestCtx, const NamedFilterList& filters);
 						~SwapBuffersTest	(void);
 
 private:
-	void				executeForConfig	(tcu::egl::Display& display, EGLConfig config);
+	void				executeForConfig	(EGLDisplay display, EGLConfig config);
 
 	// Not allowed
 						SwapBuffersTest		(const SwapBuffersTest&);
@@ -95,8 +97,8 @@
 };
 
 
-SwapBuffersTest::SwapBuffersTest (EglTestContext& eglTestCtx, const char* name, const char* description, const vector<EGLint>& configIds)
-	: SimpleConfigCase			(eglTestCtx, name, description, configIds)
+SwapBuffersTest::SwapBuffersTest (EglTestContext& eglTestCtx, const NamedFilterList& filters)
+	: SimpleConfigCase(eglTestCtx, filters.getName(), filters.getDescription(), filters)
 {
 }
 
@@ -104,12 +106,12 @@
 {
 }
 
-string getConfigIdString (EGLDisplay display, EGLConfig config)
+string getConfigIdString (const Library& egl, EGLDisplay display, EGLConfig config)
 {
 	std::ostringstream	stream;
 	EGLint				id;
 
-	TCU_CHECK_EGL_CALL(eglGetConfigAttrib(display, config , EGL_CONFIG_ID, &id));
+	EGLU_CHECK_CALL(egl, getConfigAttrib(display, config , EGL_CONFIG_ID, &id));
 
 	stream << id;
 
@@ -262,33 +264,38 @@
 	return true;
 }
 
-void SwapBuffersTest::executeForConfig (tcu::egl::Display& display, EGLConfig config)
+void SwapBuffersTest::executeForConfig (EGLDisplay display, EGLConfig config)
 {
-	const string			configIdStr	(getConfigIdString(display.getEGLDisplay(), config));
-	tcu::ScopedLogSection	logSection	(m_testCtx.getLog(), ("Config ID " + configIdStr).c_str(), ("Config ID " + configIdStr).c_str());
-	const int				waitFrames	= 5;
+	const Library&						egl			= m_eglTestCtx.getLibrary();
+	const string						configIdStr	(getConfigIdString(egl, display, config));
+	tcu::ScopedLogSection				logSection	(m_testCtx.getLog(), ("Config ID " + configIdStr).c_str(), ("Config ID " + configIdStr).c_str());
+	const int							waitFrames	= 5;
+	const eglu::NativeWindowFactory*	factory		= eglu::selectNativeWindowFactory(m_eglTestCtx.getNativeDisplayFactory(), m_testCtx.getCommandLine());
+
+	if (!factory)
+		TCU_THROW(NotSupportedError, "Windows not supported");
+
+	if ((factory->getCapabilities() & eglu::NativeWindow::CAPABILITY_READ_SCREEN_PIXELS) == 0)
+		TCU_THROW(NotSupportedError, "eglu::NativeWindow doesn't support readScreenPixels()");
 
 	{
 		TestLog& log = m_testCtx.getLog();
 
-		log << TestLog::Message << "EGL_RED_SIZE: " << eglu::getConfigAttribInt(display.getEGLDisplay(), config, EGL_RED_SIZE) << TestLog::EndMessage;
-		log << TestLog::Message << "EGL_GREEN_SIZE: " << eglu::getConfigAttribInt(display.getEGLDisplay(), config, EGL_GREEN_SIZE) << TestLog::EndMessage;
-		log << TestLog::Message << "EGL_BLUE_SIZE: " << eglu::getConfigAttribInt(display.getEGLDisplay(), config, EGL_BLUE_SIZE) << TestLog::EndMessage;
-		log << TestLog::Message << "EGL_ALPHA_SIZE: " << eglu::getConfigAttribInt(display.getEGLDisplay(), config, EGL_ALPHA_SIZE) << TestLog::EndMessage;
-		log << TestLog::Message << "EGL_DEPTH_SIZE: " << eglu::getConfigAttribInt(display.getEGLDisplay(), config, EGL_DEPTH_SIZE) << TestLog::EndMessage;
-		log << TestLog::Message << "EGL_STENCIL_SIZE: " << eglu::getConfigAttribInt(display.getEGLDisplay(), config, EGL_STENCIL_SIZE) << TestLog::EndMessage;
-		log << TestLog::Message << "EGL_SAMPLES: " << eglu::getConfigAttribInt(display.getEGLDisplay(), config, EGL_SAMPLES) << TestLog::EndMessage;
+		log << TestLog::Message << "EGL_RED_SIZE: "		<< eglu::getConfigAttribInt(egl, display, config, EGL_RED_SIZE)		<< TestLog::EndMessage;
+		log << TestLog::Message << "EGL_GREEN_SIZE: "	<< eglu::getConfigAttribInt(egl, display, config, EGL_GREEN_SIZE)	<< TestLog::EndMessage;
+		log << TestLog::Message << "EGL_BLUE_SIZE: "	<< eglu::getConfigAttribInt(egl, display, config, EGL_BLUE_SIZE)	<< TestLog::EndMessage;
+		log << TestLog::Message << "EGL_ALPHA_SIZE: "	<< eglu::getConfigAttribInt(egl, display, config, EGL_ALPHA_SIZE)	<< TestLog::EndMessage;
+		log << TestLog::Message << "EGL_DEPTH_SIZE: "	<< eglu::getConfigAttribInt(egl, display, config, EGL_DEPTH_SIZE)	<< TestLog::EndMessage;
+		log << TestLog::Message << "EGL_STENCIL_SIZE: "	<< eglu::getConfigAttribInt(egl, display, config, EGL_STENCIL_SIZE)	<< TestLog::EndMessage;
+		log << TestLog::Message << "EGL_SAMPLES: "		<< eglu::getConfigAttribInt(egl, display, config, EGL_SAMPLES)		<< TestLog::EndMessage;
 
 		log << TestLog::Message << "Waiting " << waitFrames * 16 << "ms after eglSwapBuffers() and glFinish() for frame to become visible" << TestLog::EndMessage;
 	}
 
-	if ((m_eglTestCtx.getNativeWindowFactory().getCapabilities() & eglu::NativeWindow::CAPABILITY_READ_SCREEN_PIXELS) == 0)
-		throw tcu::NotSupportedError("eglu::NativeWindow doesn't support readScreenPixels()", "", __FILE__, __LINE__);
+	de::UniquePtr<eglu::NativeWindow>	window	(factory->createWindow(&m_eglTestCtx.getNativeDisplay(), display, config, DE_NULL, eglu::WindowParams(128, 128, eglu::WindowParams::VISIBILITY_VISIBLE)));
 
-	de::UniquePtr<eglu::NativeWindow>	window	(m_eglTestCtx.createNativeWindow(m_eglTestCtx.getDisplay().getEGLDisplay(), config, DE_NULL, 128, 128, eglu::WindowParams::VISIBILITY_VISIBLE));
-
-	eglu::UniqueSurface					surface	(display.getEGLDisplay(), eglu::createWindowSurface(m_eglTestCtx.getNativeDisplay(), *window, display.getEGLDisplay(), config, DE_NULL));
-	eglu::UniqueContext					context	(display.getEGLDisplay(), createGLES2Context(display.getEGLDisplay(), config));
+	eglu::UniqueSurface					surface	(egl, display, eglu::createWindowSurface(m_eglTestCtx.getNativeDisplay(), *window, display, config, DE_NULL));
+	eglu::UniqueContext					context	(egl, display, createGLES2Context(egl, display, config));
 	glw::Functions						gl;
 	deUint32							program = 0;
 
@@ -297,8 +304,8 @@
 	tcu::TextureLevel					frameBegin;
 	tcu::TextureLevel					frameEnd;
 
-	m_eglTestCtx.getGLFunctions(gl, glu::ApiType::es(2,0));
-	TCU_CHECK_EGL_CALL(eglMakeCurrent(display.getEGLDisplay(), *surface, *surface, *context));
+	m_eglTestCtx.initGLFunctions(&gl, glu::ApiType::es(2,0));
+	EGLU_CHECK_CALL(egl, makeCurrent(display, *surface, *surface, *context));
 
 	try
 	{
@@ -336,7 +343,7 @@
 		gl.clear(GL_COLOR_BUFFER_BIT);
 		GLU_EXPECT_NO_ERROR(gl.getError(), "Failed to clear surface");
 
-		TCU_CHECK_EGL_CALL(eglSwapBuffers(display.getEGLDisplay(), *surface));
+		EGLU_CHECK_CALL(egl, swapBuffers(display, *surface));
 		gl.finish();
 		GLU_EXPECT_NO_ERROR(gl.getError(), "glFinish() failed");
 		deSleep(waitFrames * 16);
@@ -354,7 +361,7 @@
 		gl.clear(GL_COLOR_BUFFER_BIT);
 		GLU_EXPECT_NO_ERROR(gl.getError(), "Failed to clear surface");
 
-		TCU_CHECK_EGL_CALL(eglSwapBuffers(display.getEGLDisplay(), *surface));
+		EGLU_CHECK_CALL(egl, swapBuffers(display, *surface));
 		gl.finish();
 		GLU_EXPECT_NO_ERROR(gl.getError(), "glFinish() failed");
 		deSleep(waitFrames * 16);
@@ -375,7 +382,7 @@
 		gl.drawArrays(GL_TRIANGLES, 0, 6);
 		GLU_EXPECT_NO_ERROR(gl.getError(), "Failed to render");
 
-		TCU_CHECK_EGL_CALL(eglSwapBuffers(display.getEGLDisplay(), *surface));
+		EGLU_CHECK_CALL(egl, swapBuffers(display, *surface));
 		gl.finish();
 		GLU_EXPECT_NO_ERROR(gl.getError(), "glFinish() failed");
 		deSleep(waitFrames * 16);
@@ -395,7 +402,7 @@
 		deSleep(waitFrames * 16);
 		window->readScreenPixels(&frameEnd);
 
-		TCU_CHECK_EGL_CALL(eglSwapBuffers(display.getEGLDisplay(), *surface));
+		EGLU_CHECK_CALL(egl, swapBuffers(display, *surface));
 		gl.finish();
 		GLU_EXPECT_NO_ERROR(gl.getError(), "glFinish() failed");
 		deSleep(waitFrames * 16);
@@ -417,11 +424,11 @@
 		if (program != 0)
 			gl.deleteProgram(program);
 
-		TCU_CHECK_EGL_CALL(eglMakeCurrent(display.getEGLDisplay(), EGL_NO_SURFACE, EGL_NO_SURFACE, EGL_NO_CONTEXT));
+		EGLU_CHECK_CALL(egl, makeCurrent(display, EGL_NO_SURFACE, EGL_NO_SURFACE, EGL_NO_CONTEXT));
 		throw;
 	}
 
-	TCU_CHECK_EGL_CALL(eglMakeCurrent(display.getEGLDisplay(), EGL_NO_SURFACE, EGL_NO_SURFACE, EGL_NO_CONTEXT));
+	EGLU_CHECK_CALL(egl, makeCurrent(display, EGL_NO_SURFACE, EGL_NO_SURFACE, EGL_NO_CONTEXT));
 }
 
 } // anonymous
@@ -431,16 +438,18 @@
 {
 }
 
+static bool isWindow (const eglu::CandidateConfig& c) { return (c.surfaceType() & EGL_WINDOW_BIT) != 0; }
+
 void SwapBuffersTests::init (void)
 {
-	eglu::FilterList filters;
-	filters << (eglu::ConfigSurfaceType() & EGL_WINDOW_BIT);
+	eglu::FilterList baseFilters;
+	baseFilters << isWindow;
 
-	vector<NamedConfigIdSet> configIdSets;
-	NamedConfigIdSet::getDefaultSets(configIdSets, m_eglTestCtx.getConfigs(), filters);
+	vector<NamedFilterList> filterLists;
+	getDefaultFilterLists(filterLists, baseFilters);
 
-	for (vector<NamedConfigIdSet>::iterator i = configIdSets.begin(); i != configIdSets.end(); i++)
-		addChild(new SwapBuffersTest(m_eglTestCtx, i->getName(), i->getDescription(), i->getConfigIds()));
+	for (vector<NamedFilterList>::iterator i = filterLists.begin(); i != filterLists.end(); i++)
+		addChild(new SwapBuffersTest(m_eglTestCtx, *i));
 }
 
 } // egl
diff --git a/modules/egl/teglSyncTests.cpp b/modules/egl/teglSyncTests.cpp
index 3d90403..f3b24fc 100644
--- a/modules/egl/teglSyncTests.cpp
+++ b/modules/egl/teglSyncTests.cpp
@@ -27,21 +27,16 @@
 #include "egluStrUtil.hpp"
 #include "egluUtil.hpp"
 
+#include "eglwLibrary.hpp"
+#include "eglwEnums.hpp"
+
 #include "tcuTestLog.hpp"
 #include "tcuCommandLine.hpp"
 
 #include "gluDefs.hpp"
 
-#include <EGL/eglext.h>
-#include <GLES2/gl2.h>
-
-#ifndef EGL_KHR_wait_sync
-#define EGL_KHR_wait_sync 1
-typedef EGLint (EGLAPIENTRYP PFNEGLWAITSYNCKHRPROC) (EGLDisplay dpy, EGLSyncKHR sync, EGLint flags);
-#ifdef EGL_EGLEXT_PROTOTYPES
-EGLAPI EGLint EGLAPIENTRY eglWaitSyncKHR (EGLDisplay dpy, EGLSyncKHR sync, EGLint flags);
-#endif
-#endif /* EGL_KHR_wait_sync */
+#include "glwFunctions.hpp"
+#include "glwEnums.hpp"
 
 #include <vector>
 #include <string>
@@ -54,6 +49,9 @@
 
 using tcu::TestLog;
 
+using namespace eglw;
+using namespace glw;
+
 namespace deqp
 {
 namespace egl
@@ -93,23 +91,14 @@
 	const EGLenum					m_syncType;
 	const Extension					m_extensions;
 
+	glw::Functions					m_gl;
+
 	EGLDisplay						m_eglDisplay;
 	EGLConfig						m_eglConfig;
 	EGLSurface						m_eglSurface;
 	eglu::NativeWindow*				m_nativeWindow;
 	EGLContext						m_eglContext;
 	EGLSyncKHR						m_sync;
-
-	struct
-	{
-		PFNEGLCREATESYNCKHRPROC		createSync;
-		PFNEGLDESTROYSYNCKHRPROC	destroySync;
-		PFNEGLCLIENTWAITSYNCKHRPROC	clientWaitSync;
-		PFNEGLGETSYNCATTRIBKHRPROC	getSyncAttrib;
-
-		PFNEGLWAITSYNCKHRPROC		waitSync;
-		PFNEGLSIGNALSYNCKHRPROC		signalSync;
-	} m_ext;
 };
 
 SyncTest::SyncTest (EglTestContext& eglTestCtx, EGLenum syncType, Extension extensions, const char* name, const char* description)
@@ -122,11 +111,7 @@
 	, m_eglContext		(EGL_NO_CONTEXT)
 	, m_sync			(EGL_NO_SYNC_KHR)
 {
-	m_ext.createSync		= DE_NULL;
-	m_ext.destroySync		= DE_NULL;
-	m_ext.clientWaitSync	= DE_NULL;
-	m_ext.getSyncAttrib		= DE_NULL;
-	m_ext.waitSync			= DE_NULL;
+	m_eglTestCtx.initGLFunctions(&m_gl, glu::ApiType::es(2,0));
 }
 
 SyncTest::~SyncTest (void)
@@ -134,13 +119,13 @@
 	SyncTest::deinit();
 }
 
-void requiredEGLExtensions (EGLDisplay display, SyncTest::Extension requiredExtensions)
+void requiredEGLExtensions (const Library& egl, EGLDisplay display, SyncTest::Extension requiredExtensions)
 {
 	SyncTest::Extension foundExtensions = SyncTest::EXTENSION_NONE;
-	std::istringstream	extensionStream(eglQueryString(display, EGL_EXTENSIONS));
+	std::istringstream	extensionStream(egl.queryString(display, EGL_EXTENSIONS));
 	string				extension;
 
-	TCU_CHECK_EGL_MSG("eglQueryString(display, EGL_EXTENSIONS)");
+	EGLU_CHECK_MSG(egl, "eglQueryString(display, EGL_EXTENSIONS)");
 
 	while (std::getline(extensionStream, extension, ' '))
 	{
@@ -156,23 +141,23 @@
 		const SyncTest::Extension missingExtensions = (SyncTest::Extension)((foundExtensions & requiredExtensions) ^ requiredExtensions);
 
 		if ((missingExtensions & SyncTest::EXTENSION_FENCE_SYNC) != 0)
-			throw tcu::NotSupportedError("EGL_KHR_fence_sync not supported", "", __FILE__, __LINE__);
+			TCU_THROW(NotSupportedError, "EGL_KHR_fence_sync not supported");
 
 		if ((missingExtensions & SyncTest::EXTENSION_REUSABLE_SYNC) != 0)
-			throw tcu::NotSupportedError("EGL_KHR_reusable_sync not supported", "", __FILE__, __LINE__);
+			TCU_THROW(NotSupportedError, "EGL_KHR_reusable_sync not supported");
 
 		if ((missingExtensions & SyncTest::EXTENSION_WAIT_SYNC) != 0)
-			throw tcu::NotSupportedError("EGL_KHR_wait_sync not supported", "", __FILE__, __LINE__);
+			TCU_THROW(NotSupportedError, "EGL_KHR_wait_sync not supported");
 	}
 }
 
-void requiredGLESExtensions (void)
+void requiredGLESExtensions (const glw::Functions& gl)
 {
 	bool				found = false;
-	std::istringstream	extensionStream((const char*)glGetString(GL_EXTENSIONS));
+	std::istringstream	extensionStream((const char*)gl.getString(GL_EXTENSIONS));
 	string				extension;
 
-	GLU_CHECK_MSG("glGetString(GL_EXTENSIONS)");
+	GLU_CHECK_GLW_MSG(gl, "glGetString(GL_EXTENSIONS)");
 
 	while (std::getline(extensionStream, extension, ' '))
 	{
@@ -181,7 +166,7 @@
 	}
 
 	if (!found)
-		throw tcu::NotSupportedError("GL_OES_EGL_sync not supported", "", __FILE__, __LINE__);
+		TCU_THROW(NotSupportedError, "GL_OES_EGL_sync not supported");
 }
 
 SyncTest::Extension getSyncTypeExtension (EGLenum syncType)
@@ -198,6 +183,9 @@
 
 void SyncTest::init (void)
 {
+	const Library&						egl				= m_eglTestCtx.getLibrary();
+	const eglu::NativeWindowFactory*	windowFactory	= eglu::selectNativeWindowFactory(m_eglTestCtx.getNativeDisplayFactory(), m_testCtx.getCommandLine());
+
 	const EGLint displayAttribList[] =
 	{
 		EGL_RENDERABLE_TYPE,	EGL_OPENGL_ES2_BIT,
@@ -212,66 +200,61 @@
 		EGL_NONE
 	};
 
-	tcu::egl::Display&	display = m_eglTestCtx.getDisplay();
-	vector<EGLConfig>	configs;
+	if (!windowFactory)
+		TCU_THROW(NotSupportedError, "Windows not supported");
 
-	display.chooseConfig(displayAttribList, configs);
-	m_eglDisplay	= display.getEGLDisplay();
-	m_eglConfig 	= configs[0];
+	m_eglDisplay	= eglu::getAndInitDisplay(m_eglTestCtx.getNativeDisplay());
+	m_eglConfig 	= eglu::chooseSingleConfig(egl, m_eglDisplay, displayAttribList);
 
 	{
 		const Extension syncTypeExtension = getSyncTypeExtension(m_syncType);
-		requiredEGLExtensions(m_eglDisplay, (Extension)(m_extensions | syncTypeExtension));
+		requiredEGLExtensions(egl, m_eglDisplay, (Extension)(m_extensions | syncTypeExtension));
 	}
 
-	m_ext.createSync		= (PFNEGLCREATESYNCKHRPROC)eglGetProcAddress("eglCreateSyncKHR");
-	m_ext.destroySync		= (PFNEGLDESTROYSYNCKHRPROC)eglGetProcAddress("eglDestroySyncKHR");
-	m_ext.clientWaitSync	= (PFNEGLCLIENTWAITSYNCKHRPROC)eglGetProcAddress("eglClientWaitSyncKHR");
-	m_ext.getSyncAttrib		= (PFNEGLGETSYNCATTRIBKHRPROC)eglGetProcAddress("eglGetSyncAttribKHR");
-	m_ext.waitSync			= (PFNEGLWAITSYNCKHRPROC)eglGetProcAddress("eglWaitSyncKHR");
-	m_ext.signalSync		= (PFNEGLSIGNALSYNCKHRPROC)eglGetProcAddress("eglSignalSyncKHR");
-
 	// Create context
-	TCU_CHECK_EGL_CALL(eglBindAPI(EGL_OPENGL_ES_API));
-	m_eglContext = eglCreateContext(m_eglDisplay, m_eglConfig, EGL_NO_CONTEXT, contextAttribList);
-	TCU_CHECK_EGL_MSG("Failed to create GLES2 context");
+	EGLU_CHECK_CALL(egl, bindAPI(EGL_OPENGL_ES_API));
+	m_eglContext = egl.createContext(m_eglDisplay, m_eglConfig, EGL_NO_CONTEXT, contextAttribList);
+	EGLU_CHECK_MSG(egl, "Failed to create GLES2 context");
 
 	// Create surface
-	m_nativeWindow = m_eglTestCtx.createNativeWindow(m_eglDisplay, m_eglConfig, DE_NULL, 480, 480, eglu::parseWindowVisibility(m_testCtx.getCommandLine()));
+	m_nativeWindow = windowFactory->createWindow(&m_eglTestCtx.getNativeDisplay(), m_eglDisplay, m_eglConfig, DE_NULL, eglu::WindowParams(480, 480, eglu::parseWindowVisibility(m_testCtx.getCommandLine())));
 	m_eglSurface = eglu::createWindowSurface(m_eglTestCtx.getNativeDisplay(), *m_nativeWindow, m_eglDisplay, m_eglConfig, DE_NULL);
 
-	TCU_CHECK_EGL_CALL(eglMakeCurrent(m_eglDisplay, m_eglSurface, m_eglSurface, m_eglContext));
+	EGLU_CHECK_CALL(egl, makeCurrent(m_eglDisplay, m_eglSurface, m_eglSurface, m_eglContext));
 
-	requiredGLESExtensions();
+	requiredGLESExtensions(m_gl);
 }
 
 void SyncTest::deinit (void)
 {
+	const Library&	egl		= m_eglTestCtx.getLibrary();
+
 	if (m_eglDisplay != EGL_NO_DISPLAY)
 	{
 		if (m_sync != EGL_NO_SYNC_KHR)
 		{
-			TCU_CHECK_EGL_CALL(m_ext.destroySync(m_eglDisplay, m_sync));
+			EGLU_CHECK_CALL(egl, destroySyncKHR(m_eglDisplay, m_sync));
 			m_sync = EGL_NO_SYNC_KHR;
 		}
 
-		TCU_CHECK_EGL_CALL(eglMakeCurrent(m_eglDisplay, EGL_NO_SURFACE, EGL_NO_SURFACE, EGL_NO_CONTEXT));
+		EGLU_CHECK_CALL(egl, makeCurrent(m_eglDisplay, EGL_NO_SURFACE, EGL_NO_SURFACE, EGL_NO_CONTEXT));
 
 		if (m_eglContext != EGL_NO_CONTEXT)
 		{
-			TCU_CHECK_EGL_CALL(eglDestroyContext(m_eglDisplay, m_eglContext));
+			EGLU_CHECK_CALL(egl, destroyContext(m_eglDisplay, m_eglContext));
 			m_eglContext = EGL_NO_CONTEXT;
 		}
 
 		if (m_eglSurface != EGL_NO_SURFACE)
 		{
-			TCU_CHECK_EGL_CALL(eglDestroySurface(m_eglDisplay, m_eglSurface));
+			EGLU_CHECK_CALL(egl, destroySurface(m_eglDisplay, m_eglSurface));
 			m_eglSurface = EGL_NO_SURFACE;
 		}
 
 		delete m_nativeWindow;
 		m_nativeWindow = DE_NULL;
 
+		egl.terminate(m_eglDisplay);
 		m_eglDisplay = EGL_NO_DISPLAY;
 	}
 }
@@ -283,12 +266,12 @@
 
 	IterateResult	iterate					(void)
 	{
-		TestLog& log = m_testCtx.getLog();
-		TCU_CHECK(m_ext.createSync);
+		const Library&	egl		= m_eglTestCtx.getLibrary();
+		TestLog&		log		= m_testCtx.getLog();
 
-		m_sync = m_ext.createSync(m_eglDisplay, m_syncType, NULL);
+		m_sync = egl.createSyncKHR(m_eglDisplay, m_syncType, NULL);
 		log << TestLog::Message << m_sync << " = eglCreateSyncKHR(" << m_eglDisplay << ", " << getSyncTypeName(m_syncType) << ", NULL)" << TestLog::EndMessage;
-		TCU_CHECK_EGL_MSG("eglCreateSyncKHR()");
+		EGLU_CHECK_MSG(egl, "eglCreateSyncKHR()");
 
 		m_testCtx.setTestResult(QP_TEST_RESULT_PASS, "Pass");
 		return STOP;
@@ -303,15 +286,16 @@
 	IterateResult	iterate					(void)
 	{
 
-		const EGLint attribList[] = {
+		const Library&	egl				= m_eglTestCtx.getLibrary();
+		TestLog&		log				= m_testCtx.getLog();
+		const EGLint	attribList[]	=
+		{
 			EGL_NONE
 		};
-		TestLog& log = m_testCtx.getLog();
-		TCU_CHECK(m_ext.createSync);
 
-		m_sync = m_ext.createSync(m_eglDisplay, m_syncType, attribList);
+		m_sync = egl.createSyncKHR(m_eglDisplay, m_syncType, attribList);
 		log << TestLog::Message << m_sync << " = eglCreateSyncKHR(" << m_eglDisplay << ", " << getSyncTypeName(m_syncType) << ", { EGL_NONE })" << TestLog::EndMessage;
-		TCU_CHECK_EGL_MSG("eglCreateSyncKHR()");
+		EGLU_CHECK_MSG(egl, "eglCreateSyncKHR()");
 
 		m_testCtx.setTestResult(QP_TEST_RESULT_PASS, "Pass");
 		return STOP;
@@ -325,13 +309,13 @@
 
 	IterateResult	iterate						(void)
 	{
-		TestLog& log = m_testCtx.getLog();
-		TCU_CHECK(m_ext.createSync);
+		const Library&	egl		= m_eglTestCtx.getLibrary();
+		TestLog&		log		= m_testCtx.getLog();
 
-		m_sync = m_ext.createSync(EGL_NO_DISPLAY, m_syncType, NULL);
+		m_sync = egl.createSyncKHR(EGL_NO_DISPLAY, m_syncType, NULL);
 		log << TestLog::Message << m_sync << " = eglCreateSyncKHR(EGL_NO_DISPLAY, " << getSyncTypeName(m_syncType) << ", NULL)" << TestLog::EndMessage;
 
-		EGLint error = eglGetError();
+		EGLint error = egl.getError();
 		log << TestLog::Message << error << " = eglGetError()" << TestLog::EndMessage;
 
 		if (error != EGL_BAD_DISPLAY)
@@ -355,13 +339,13 @@
 
 	IterateResult	iterate					(void)
 	{
-		TestLog& log = m_testCtx.getLog();
-		TCU_CHECK(m_ext.createSync);
+		const Library&	egl		= m_eglTestCtx.getLibrary();
+		TestLog&		log		= m_testCtx.getLog();
 
-		m_sync = m_ext.createSync(m_eglDisplay, EGL_NONE, NULL);
+		m_sync = egl.createSyncKHR(m_eglDisplay, EGL_NONE, NULL);
 		log << TestLog::Message << m_sync << " = eglCreateSyncKHR(" << m_eglDisplay << ", EGL_NONE, NULL)" << TestLog::EndMessage;
 
-		EGLint error = eglGetError();
+		EGLint error = egl.getError();
 		log << TestLog::Message << error << " = eglGetError()" << TestLog::EndMessage;
 
 		if (error != EGL_BAD_ATTRIBUTE)
@@ -385,18 +369,18 @@
 
 	IterateResult	iterate						(void)
 	{
-		TestLog& log = m_testCtx.getLog();
-		TCU_CHECK(m_ext.createSync);
+		const Library&	egl		= m_eglTestCtx.getLibrary();
+		TestLog&		log		= m_testCtx.getLog();
 
 		EGLint attribs[] = {
 			2, 3, 4, 5,
 			EGL_NONE
 		};
 
-		m_sync = m_ext.createSync(m_eglDisplay, m_syncType, attribs);
+		m_sync = egl.createSyncKHR(m_eglDisplay, m_syncType, attribs);
 		log << TestLog::Message << m_sync << " = eglCreateSyncKHR(" << m_eglDisplay << ", " << getSyncTypeName(m_syncType) << ", { 2, 3, 4, 5, EGL_NONE })" << TestLog::EndMessage;
 
-		EGLint error = eglGetError();
+		EGLint error = egl.getError();
 		log << TestLog::Message << error << " = eglGetError()" << TestLog::EndMessage;
 
 		if (error != EGL_BAD_ATTRIBUTE)
@@ -420,16 +404,16 @@
 
 	IterateResult	iterate						(void)
 	{
-		TestLog& log = m_testCtx.getLog();
-		TCU_CHECK(m_ext.createSync);
+		const Library&	egl		= m_eglTestCtx.getLibrary();
+		TestLog&		log		= m_testCtx.getLog();
 
 		log << TestLog::Message << "eglMakeCurrent(" << m_eglDisplay << ", EGL_NO_SURFACE, EGL_NO_SURFACE, EGL_NO_CONTEXT)" << TestLog::EndMessage;
-		TCU_CHECK_EGL_CALL(eglMakeCurrent(m_eglDisplay, EGL_NO_SURFACE, EGL_NO_SURFACE, EGL_NO_CONTEXT));
+		EGLU_CHECK_CALL(egl, makeCurrent(m_eglDisplay, EGL_NO_SURFACE, EGL_NO_SURFACE, EGL_NO_CONTEXT));
 
-		m_sync = m_ext.createSync(m_eglDisplay, m_syncType, NULL);
+		m_sync = egl.createSyncKHR(m_eglDisplay, m_syncType, NULL);
 		log << TestLog::Message << m_sync << " = eglCreateSyncKHR(" << m_eglDisplay << ", " << getSyncTypeName(m_syncType) << ", NULL)" << TestLog::EndMessage;
 
-		EGLint error = eglGetError();
+		EGLint error = egl.getError();
 		log << TestLog::Message << error << " = eglGetError()" << TestLog::EndMessage;
 
 		if (error != EGL_BAD_MATCH)
@@ -453,15 +437,14 @@
 
 	IterateResult	iterate					(void)
 	{
-		TestLog& log = m_testCtx.getLog();
-		TCU_CHECK(m_ext.createSync);
-		TCU_CHECK(m_ext.clientWaitSync);
+		const Library&	egl		= m_eglTestCtx.getLibrary();
+		TestLog&		log		= m_testCtx.getLog();
 
-		m_sync = m_ext.createSync(m_eglDisplay, m_syncType, NULL);
+		m_sync = egl.createSyncKHR(m_eglDisplay, m_syncType, NULL);
 		log << TestLog::Message << m_sync << " = eglCreateSyncKHR(" << m_eglDisplay << ", " << getSyncTypeName(m_syncType) << ", NULL)" << TestLog::EndMessage;
-		TCU_CHECK_EGL_MSG("eglCreateSyncKHR()");
+		EGLU_CHECK_MSG(egl, "eglCreateSyncKHR()");
 
-		EGLint status = m_ext.clientWaitSync(m_eglDisplay, m_sync, 0, 0);
+		EGLint status = egl.clientWaitSyncKHR(m_eglDisplay, m_sync, 0, 0);
 		log << TestLog::Message << status << " = eglClientWaitSyncKHR(" << m_eglDisplay << ", " << m_sync << ", 0, 0)" << TestLog::EndMessage;
 
 		if (m_syncType == EGL_SYNC_FENCE_KHR)
@@ -484,33 +467,32 @@
 
 	IterateResult	iterate					(void)
 	{
-		TestLog& log = m_testCtx.getLog();
-		TCU_CHECK(m_ext.createSync);
-		TCU_CHECK(m_ext.clientWaitSync);
+		const Library&	egl		= m_eglTestCtx.getLibrary();
+		TestLog&		log		= m_testCtx.getLog();
 
-		m_sync = m_ext.createSync(m_eglDisplay, m_syncType, NULL);
+		m_sync = egl.createSyncKHR(m_eglDisplay, m_syncType, NULL);
 		log << TestLog::Message << m_sync << " = eglCreateSyncKHR(" << m_eglDisplay << ", " << getSyncTypeName(m_syncType) << ", NULL)" << TestLog::EndMessage;
-		TCU_CHECK_EGL_MSG("eglCreateSyncKHR()");
+		EGLU_CHECK_MSG(egl, "eglCreateSyncKHR()");
 
 		if (m_syncType == EGL_SYNC_REUSABLE_KHR)
 		{
-			EGLBoolean ret = m_ext.signalSync(m_eglDisplay, m_sync, EGL_SIGNALED_KHR);
+			EGLBoolean ret = egl.signalSyncKHR(m_eglDisplay, m_sync, EGL_SIGNALED_KHR);
 			log << TestLog::Message << ret << " = eglSignalSyncKHR(" << m_eglDisplay << ", " << m_sync << ", EGL_SIGNALED_KHR)" << TestLog::EndMessage;
-			TCU_CHECK_EGL_MSG("eglSignalSyncKHR()");
+			EGLU_CHECK_MSG(egl, "eglSignalSyncKHR()");
 		}
 		else if (m_syncType == EGL_SYNC_FENCE_KHR)
 		{
-			GLU_CHECK_CALL(glFlush());
+			GLU_CHECK_GLW_CALL(m_gl, flush());
 			log << TestLog::Message << "glFlush()" << TestLog::EndMessage;
 		}
 		else
 			DE_ASSERT(DE_FALSE);
 
-		EGLint status = m_ext.clientWaitSync(m_eglDisplay, m_sync, 0, EGL_FOREVER_KHR);
+		EGLint status = egl.clientWaitSyncKHR(m_eglDisplay, m_sync, 0, EGL_FOREVER_KHR);
 		log << TestLog::Message << status << " = eglClientWaitSyncKHR(" << m_eglDisplay << ", " << m_sync << ", 0, EGL_FOREVER_KHR)" << TestLog::EndMessage;
 
 		TCU_CHECK(status == EGL_CONDITION_SATISFIED_KHR);
-		TCU_CHECK_EGL_MSG("eglClientWaitSyncKHR()");
+		EGLU_CHECK_MSG(egl, "eglClientWaitSyncKHR()");
 
 		m_testCtx.setTestResult(QP_TEST_RESULT_PASS, "Pass");
 		return STOP;
@@ -524,33 +506,32 @@
 
 	IterateResult	iterate					(void)
 	{
-		TestLog& log = m_testCtx.getLog();
-		TCU_CHECK(m_ext.createSync);
-		TCU_CHECK(m_ext.clientWaitSync);
+		const Library&	egl		= m_eglTestCtx.getLibrary();
+		TestLog&		log		= m_testCtx.getLog();
 
-		m_sync = m_ext.createSync(m_eglDisplay, m_syncType, NULL);
+		m_sync = egl.createSyncKHR(m_eglDisplay, m_syncType, NULL);
 		log << TestLog::Message << m_sync << " = eglCreateSyncKHR(" << m_eglDisplay << ", " << getSyncTypeName(m_syncType) << ", NULL)" << TestLog::EndMessage;
-		TCU_CHECK_EGL_MSG("eglCreateSyncKHR()");
+		EGLU_CHECK_MSG(egl, "eglCreateSyncKHR()");
 
 
 		if (m_syncType == EGL_SYNC_REUSABLE_KHR)
 		{
-			EGLBoolean ret = m_ext.signalSync(m_eglDisplay, m_sync, EGL_SIGNALED_KHR);
+			EGLBoolean ret = egl.signalSyncKHR(m_eglDisplay, m_sync, EGL_SIGNALED_KHR);
 			log << TestLog::Message << ret << " = eglSignalSyncKHR(" << m_eglDisplay << ", " << m_sync << ", EGL_SIGNALED_KHR)" << TestLog::EndMessage;
-			TCU_CHECK_EGL_MSG("eglSignalSyncKHR()");
+			EGLU_CHECK_MSG(egl, "eglSignalSyncKHR()");
 		}
 		else if (m_syncType == EGL_SYNC_FENCE_KHR)
 		{
-			GLU_CHECK_CALL(glFlush());
+			GLU_CHECK_GLW_CALL(m_gl, flush());
 			log << TestLog::Message << "glFlush()" << TestLog::EndMessage;
 		}
 		else
 			DE_ASSERT(DE_FALSE);
 
 		log << TestLog::Message << "eglMakeCurrent(" << m_eglDisplay << ", EGL_NO_SURFACE, EGL_NO_SURFACE, EGL_NO_CONTEXT)" << TestLog::EndMessage;
-		TCU_CHECK_EGL_CALL(eglMakeCurrent(m_eglDisplay, EGL_NO_SURFACE, EGL_NO_SURFACE, EGL_NO_CONTEXT));
+		EGLU_CHECK_CALL(egl, makeCurrent(m_eglDisplay, EGL_NO_SURFACE, EGL_NO_SURFACE, EGL_NO_CONTEXT));
 
-		EGLint result = m_ext.clientWaitSync(m_eglDisplay, m_sync, 0, EGL_FOREVER_KHR);
+		EGLint result = egl.clientWaitSyncKHR(m_eglDisplay, m_sync, 0, EGL_FOREVER_KHR);
 		log << TestLog::Message << result << " = eglClientWaitSyncKHR(" << m_eglDisplay << ", " << m_sync << ", 0, EGL_FOREVER_KHR)" << TestLog::EndMessage;
 
 		TCU_CHECK(result == EGL_CONDITION_SATISFIED_KHR);
@@ -567,22 +548,21 @@
 
 	IterateResult	iterate						(void)
 	{
-		TestLog& log = m_testCtx.getLog();
-		TCU_CHECK(m_ext.createSync);
-		TCU_CHECK(m_ext.clientWaitSync);
+		const Library&	egl		= m_eglTestCtx.getLibrary();
+		TestLog&		log		= m_testCtx.getLog();
 
-		m_sync = m_ext.createSync(m_eglDisplay, m_syncType, NULL);
+		m_sync = egl.createSyncKHR(m_eglDisplay, m_syncType, NULL);
 		log << TestLog::Message << m_sync << " = eglCreateSyncKHR(" << m_eglDisplay << ", " << getSyncTypeName(m_syncType) << ", NULL)" << TestLog::EndMessage;
-		TCU_CHECK_EGL_MSG("eglCreateSyncKHR()");
+		EGLU_CHECK_MSG(egl, "eglCreateSyncKHR()");
 
 		if (m_syncType == EGL_SYNC_REUSABLE_KHR)
 		{
-			EGLBoolean ret = m_ext.signalSync(m_eglDisplay, m_sync, EGL_SIGNALED_KHR);
+			EGLBoolean ret = egl.signalSyncKHR(m_eglDisplay, m_sync, EGL_SIGNALED_KHR);
 			log << TestLog::Message << ret << " = eglSignalSyncKHR(" << m_eglDisplay << ", " << m_sync << ", EGL_SIGNALED_KHR)" << TestLog::EndMessage;
-			TCU_CHECK_EGL_MSG("eglSignalSyncKHR()");
+			EGLU_CHECK_MSG(egl, "eglSignalSyncKHR()");
 		}
 
-		EGLint status = m_ext.clientWaitSync(m_eglDisplay, m_sync, EGL_SYNC_FLUSH_COMMANDS_BIT_KHR, EGL_FOREVER_KHR);
+		EGLint status = egl.clientWaitSyncKHR(m_eglDisplay, m_sync, EGL_SYNC_FLUSH_COMMANDS_BIT_KHR, EGL_FOREVER_KHR);
 		log << TestLog::Message << status << " = eglClientWaitSyncKHR(" << m_eglDisplay << ", " << m_sync << ", EGL_SYNC_FLUSH_COMMANDS_BIT_KHR, EGL_FOREVER_KHR)" << TestLog::EndMessage;
 
 		TCU_CHECK(status == EGL_CONDITION_SATISFIED_KHR);
@@ -599,18 +579,17 @@
 
 	IterateResult	iterate							(void)
 	{
-		TestLog& log = m_testCtx.getLog();
-		TCU_CHECK(m_ext.createSync);
-		TCU_CHECK(m_ext.clientWaitSync);
+		const Library&	egl		= m_eglTestCtx.getLibrary();
+		TestLog&		log		= m_testCtx.getLog();
 
-		m_sync = m_ext.createSync(m_eglDisplay, m_syncType, NULL);
+		m_sync = egl.createSyncKHR(m_eglDisplay, m_syncType, NULL);
 		log << TestLog::Message << m_sync << " = eglCreateSyncKHR(" << m_eglDisplay << ", " << getSyncTypeName(m_syncType) << ", NULL)" << TestLog::EndMessage;
-		TCU_CHECK_EGL_MSG("eglCreateSyncKHR()");
+		EGLU_CHECK_MSG(egl, "eglCreateSyncKHR()");
 
-		EGLint status = m_ext.clientWaitSync(EGL_NO_DISPLAY, m_sync, EGL_SYNC_FLUSH_COMMANDS_BIT_KHR, EGL_FOREVER_KHR);
+		EGLint status = egl.clientWaitSyncKHR(EGL_NO_DISPLAY, m_sync, EGL_SYNC_FLUSH_COMMANDS_BIT_KHR, EGL_FOREVER_KHR);
 		log << TestLog::Message << status << " = eglClientWaitSyncKHR(EGL_NO_DISPLAY, " << m_sync << ", EGL_SYNC_FLUSH_COMMANDS_BIT_KHR, EGL_FOREVER_KHR)" << TestLog::EndMessage;
 
-		EGLint error = eglGetError();
+		EGLint error = egl.getError();
 		log << TestLog::Message << error << " = eglGetError()" << TestLog::EndMessage;
 
 		if (error != EGL_BAD_DISPLAY)
@@ -634,13 +613,13 @@
 
 	IterateResult	iterate						(void)
 	{
-		TestLog& log = m_testCtx.getLog();
-		TCU_CHECK(m_ext.clientWaitSync);
+		const Library&	egl		= m_eglTestCtx.getLibrary();
+		TestLog&		log		= m_testCtx.getLog();
 
-		EGLint status = m_ext.clientWaitSync(m_eglDisplay, EGL_NO_SYNC_KHR, 0, EGL_FOREVER_KHR);
+		EGLint status = egl.clientWaitSyncKHR(m_eglDisplay, EGL_NO_SYNC_KHR, 0, EGL_FOREVER_KHR);
 		log << TestLog::Message << status << " = eglClientWaitSyncKHR(" << m_eglDisplay << ", EGL_NO_SYNC_KHR, 0, EGL_FOREVER_KHR)" << TestLog::EndMessage;
 
-		EGLint error = eglGetError();
+		EGLint error = egl.getError();
 		log << TestLog::Message << error << " = eglGetError()" << TestLog::EndMessage;
 
 		if (error != EGL_BAD_PARAMETER)
@@ -664,18 +643,17 @@
 
 	IterateResult	iterate						(void)
 	{
-		TestLog& log = m_testCtx.getLog();
-		TCU_CHECK(m_ext.createSync);
-		TCU_CHECK(m_ext.clientWaitSync);
+		const Library&	egl		= m_eglTestCtx.getLibrary();
+		TestLog&		log		= m_testCtx.getLog();
 
-		m_sync = m_ext.createSync(m_eglDisplay, m_syncType, NULL);
+		m_sync = egl.createSyncKHR(m_eglDisplay, m_syncType, NULL);
 		log << TestLog::Message << m_sync << " = eglCreateSyncKHR(" << m_eglDisplay << ", " << getSyncTypeName(m_syncType) << ", NULL)" << TestLog::EndMessage;
-		TCU_CHECK_EGL_MSG("eglCreateSyncKHR()");
+		EGLU_CHECK_MSG(egl, "eglCreateSyncKHR()");
 
-		EGLint status = m_ext.clientWaitSync(m_eglDisplay, m_sync, 0xFFFFFFFF, EGL_FOREVER_KHR);
+		EGLint status = egl.clientWaitSyncKHR(m_eglDisplay, m_sync, 0xFFFFFFFF, EGL_FOREVER_KHR);
 		log << TestLog::Message << status << " = eglClientWaitSyncKHR(" << m_eglDisplay << ", " << m_sync << ", 0xFFFFFFFF, EGL_FOREVER_KHR)" << TestLog::EndMessage;
 
-		EGLint error = eglGetError();
+		EGLint error = egl.getError();
 		log << TestLog::Message << error << " = eglGetError()" << TestLog::EndMessage;
 
 		if (error != EGL_BAD_PARAMETER)
@@ -699,16 +677,15 @@
 
 	IterateResult	iterate			(void)
 	{
-		TestLog& log = m_testCtx.getLog();
-		TCU_CHECK(m_ext.createSync);
-		TCU_CHECK(m_ext.getSyncAttrib);
+		const Library&	egl		= m_eglTestCtx.getLibrary();
+		TestLog&		log		= m_testCtx.getLog();
 
-		m_sync = m_ext.createSync(m_eglDisplay, m_syncType, NULL);
+		m_sync = egl.createSyncKHR(m_eglDisplay, m_syncType, NULL);
 		log << TestLog::Message << m_sync << " = eglCreateSyncKHR(" << m_eglDisplay << ", " << getSyncTypeName(m_syncType) << ", NULL)" << TestLog::EndMessage;
-		TCU_CHECK_EGL_MSG("eglCreateSyncKHR()");
+		EGLU_CHECK_MSG(egl, "eglCreateSyncKHR()");
 
 		EGLint type = 0;
-		TCU_CHECK_EGL_CALL(m_ext.getSyncAttrib(m_eglDisplay, m_sync, EGL_SYNC_TYPE_KHR, &type));
+		EGLU_CHECK_CALL(egl, getSyncAttribKHR(m_eglDisplay, m_sync, EGL_SYNC_TYPE_KHR, &type));
 		log << TestLog::Message << "eglGetSyncAttribKHR(" << m_eglDisplay << ", " << m_sync << ", EGL_SYNC_TYPE_KHR, {" << type << "})" << TestLog::EndMessage;
 
 		TCU_CHECK(type == ((EGLint)m_syncType));
@@ -725,16 +702,15 @@
 
 	IterateResult	iterate				(void)
 	{
-		TestLog& log = m_testCtx.getLog();
-		TCU_CHECK(m_ext.createSync);
-		TCU_CHECK(m_ext.getSyncAttrib);
+		const Library&	egl		= m_eglTestCtx.getLibrary();
+		TestLog&		log		= m_testCtx.getLog();
 
-		m_sync = m_ext.createSync(m_eglDisplay, m_syncType, NULL);
+		m_sync = egl.createSyncKHR(m_eglDisplay, m_syncType, NULL);
 		log << TestLog::Message << m_sync << " = eglCreateSyncKHR(" << m_eglDisplay << ", " << getSyncTypeName(m_syncType) << ", NULL)" << TestLog::EndMessage;
-		TCU_CHECK_EGL_MSG("eglCreateSyncKHR()");
+		EGLU_CHECK_MSG(egl, "eglCreateSyncKHR()");
 
 		EGLint status = 0;
-		TCU_CHECK_EGL_CALL(m_ext.getSyncAttrib(m_eglDisplay, m_sync, EGL_SYNC_STATUS_KHR, &status));
+		EGLU_CHECK_CALL(egl, getSyncAttribKHR(m_eglDisplay, m_sync, EGL_SYNC_STATUS_KHR, &status));
 		log << TestLog::Message << "eglGetSyncAttribKHR(" << m_eglDisplay << ", " << m_sync << ", EGL_SYNC_STATUS_KHR, {" << status << "})" << TestLog::EndMessage;
 
 		if (m_syncType == EGL_SYNC_FENCE_KHR)
@@ -754,37 +730,35 @@
 
 	IterateResult	iterate						(void)
 	{
-		TestLog& log = m_testCtx.getLog();
-		TCU_CHECK(m_ext.createSync);
-		TCU_CHECK(m_ext.clientWaitSync);
-		TCU_CHECK(m_ext.getSyncAttrib);
+		const Library&	egl		= m_eglTestCtx.getLibrary();
+		TestLog&		log		= m_testCtx.getLog();
 
-		m_sync = m_ext.createSync(m_eglDisplay, m_syncType, NULL);
+		m_sync = egl.createSyncKHR(m_eglDisplay, m_syncType, NULL);
 		log << TestLog::Message << m_sync << " = eglCreateSyncKHR(" << m_eglDisplay << ", " << getSyncTypeName(m_syncType) << ", NULL)" << TestLog::EndMessage;
-		TCU_CHECK_EGL_MSG("eglCreateSyncKHR()");
+		EGLU_CHECK_MSG(egl, "eglCreateSyncKHR()");
 
 		if (m_syncType == EGL_SYNC_REUSABLE_KHR)
 		{
-			EGLBoolean ret = m_ext.signalSync(m_eglDisplay, m_sync, EGL_SIGNALED_KHR);
+			EGLBoolean ret = egl.signalSyncKHR(m_eglDisplay, m_sync, EGL_SIGNALED_KHR);
 			log << TestLog::Message << ret << " = eglSignalSyncKHR(" << m_eglDisplay << ", " << m_sync << ", EGL_SIGNALED_KHR)" << TestLog::EndMessage;
-			TCU_CHECK_EGL_MSG("eglSignalSyncKHR()");
+			EGLU_CHECK_MSG(egl, "eglSignalSyncKHR()");
 		}
 		else if (m_syncType == EGL_SYNC_FENCE_KHR)
 		{
-			GLU_CHECK_CALL(glFinish());
+			GLU_CHECK_GLW_CALL(m_gl, finish());
 			log << TestLog::Message << "glFinish()" << TestLog::EndMessage;
 		}
 		else
 			DE_ASSERT(DE_FALSE);
 
 		{
-			EGLint status = m_ext.clientWaitSync(m_eglDisplay, m_sync, EGL_SYNC_FLUSH_COMMANDS_BIT_KHR, EGL_FOREVER_KHR);
+			EGLint status = egl.clientWaitSyncKHR(m_eglDisplay, m_sync, EGL_SYNC_FLUSH_COMMANDS_BIT_KHR, EGL_FOREVER_KHR);
 			log << TestLog::Message << status << " = eglClientWaitSyncKHR(" << m_eglDisplay << ", " << m_sync << ", EGL_SYNC_FLUSH_COMMANDS_BIT_KHR, EGL_FOREVER_KHR)" << TestLog::EndMessage;
 			TCU_CHECK(status == EGL_CONDITION_SATISFIED_KHR);
 		}
 
 		EGLint status = 0;
-		TCU_CHECK_EGL_CALL(m_ext.getSyncAttrib(m_eglDisplay, m_sync, EGL_SYNC_STATUS_KHR, &status));
+		EGLU_CHECK_CALL(egl, getSyncAttribKHR(m_eglDisplay, m_sync, EGL_SYNC_STATUS_KHR, &status));
 		log << TestLog::Message << "eglGetSyncAttribKHR(" << m_eglDisplay << ", " << m_sync << ", EGL_SYNC_STATUS_KHR, {" << status << "})" << TestLog::EndMessage;
 
 		TCU_CHECK(status == EGL_SIGNALED_KHR);
@@ -801,16 +775,15 @@
 
 	IterateResult	iterate					(void)
 	{
-		TestLog& log = m_testCtx.getLog();
-		TCU_CHECK(m_ext.createSync);
-		TCU_CHECK(m_ext.getSyncAttrib);
+		const Library&	egl		= m_eglTestCtx.getLibrary();
+		TestLog&		log		= m_testCtx.getLog();
 
-		m_sync = m_ext.createSync(m_eglDisplay, m_syncType, NULL);
+		m_sync = egl.createSyncKHR(m_eglDisplay, m_syncType, NULL);
 		log << TestLog::Message << m_sync << " = eglCreateSyncKHR(" << m_eglDisplay << ", " << getSyncTypeName(m_syncType) << ", NULL)" << TestLog::EndMessage;
-		TCU_CHECK_EGL_MSG("eglCreateSyncKHR()");
+		EGLU_CHECK_MSG(egl, "eglCreateSyncKHR()");
 
 		EGLint condition = 0;
-		TCU_CHECK_EGL_CALL(m_ext.getSyncAttrib(m_eglDisplay, m_sync, EGL_SYNC_CONDITION_KHR, &condition));
+		EGLU_CHECK_CALL(egl, getSyncAttribKHR(m_eglDisplay, m_sync, EGL_SYNC_CONDITION_KHR, &condition));
 		log << TestLog::Message << "eglGetSyncAttribKHR(" << m_eglDisplay << ", " << m_sync << ", EGL_SYNC_CONDITION_KHR, {" << condition << "})" << TestLog::EndMessage;
 
 		TCU_CHECK(condition == EGL_SYNC_PRIOR_COMMANDS_COMPLETE_KHR);
@@ -827,19 +800,18 @@
 
 	IterateResult	iterate						(void)
 	{
-		TestLog& log = m_testCtx.getLog();
-		TCU_CHECK(m_ext.createSync);
-		TCU_CHECK(m_ext.getSyncAttrib);
+		const Library&	egl		= m_eglTestCtx.getLibrary();
+		TestLog&		log		= m_testCtx.getLog();
 
-		m_sync = m_ext.createSync(m_eglDisplay, m_syncType, NULL);
+		m_sync = egl.createSyncKHR(m_eglDisplay, m_syncType, NULL);
 		log << TestLog::Message << m_sync << " = eglCreateSyncKHR(" << m_eglDisplay << ", " << getSyncTypeName(m_syncType) << ", NULL)" << TestLog::EndMessage;
-		TCU_CHECK_EGL_MSG("eglCreateSyncKHR()");
+		EGLU_CHECK_MSG(egl, "eglCreateSyncKHR()");
 
 		EGLint condition = 0xF0F0F;
-		EGLBoolean result = m_ext.getSyncAttrib(EGL_NO_DISPLAY, m_sync, EGL_SYNC_CONDITION_KHR, &condition);
+		EGLBoolean result = egl.getSyncAttribKHR(EGL_NO_DISPLAY, m_sync, EGL_SYNC_CONDITION_KHR, &condition);
 		log << TestLog::Message << result << " = eglGetSyncAttribKHR(EGL_NO_DISPLAY, " << m_sync << ", EGL_SYNC_CONDITION_KHR, {" << condition << "})" << TestLog::EndMessage;
 
-		EGLint error = eglGetError();
+		EGLint error = egl.getError();
 		log << TestLog::Message << error << " = eglGetError()" << TestLog::EndMessage;
 
 		if (error != EGL_BAD_DISPLAY)
@@ -864,14 +836,14 @@
 
 	IterateResult	iterate					(void)
 	{
-		TestLog& log = m_testCtx.getLog();
-		TCU_CHECK(m_ext.getSyncAttrib);
+		const Library&	egl		= m_eglTestCtx.getLibrary();
+		TestLog&		log		= m_testCtx.getLog();
 
 		EGLint condition = 0xF0F0F;
-		EGLBoolean result = m_ext.getSyncAttrib(m_eglDisplay, EGL_NO_SYNC_KHR, EGL_SYNC_CONDITION_KHR, &condition);
+		EGLBoolean result = egl.getSyncAttribKHR(m_eglDisplay, EGL_NO_SYNC_KHR, EGL_SYNC_CONDITION_KHR, &condition);
 		log << TestLog::Message << result << " = eglGetSyncAttribKHR(" << m_eglDisplay << ", EGL_NO_SYNC_KHR, EGL_SYNC_CONDITION_KHR, {" << condition << "})" << TestLog::EndMessage;
 
-		EGLint error = eglGetError();
+		EGLint error = egl.getError();
 		log << TestLog::Message << error << " = eglGetError()" << TestLog::EndMessage;
 
 		if (error != EGL_BAD_PARAMETER)
@@ -896,19 +868,18 @@
 
 	IterateResult	iterate						(void)
 	{
-		TestLog& log = m_testCtx.getLog();
-		TCU_CHECK(m_ext.createSync);
-		TCU_CHECK(m_ext.getSyncAttrib);
+		const Library&	egl		= m_eglTestCtx.getLibrary();
+		TestLog&		log		= m_testCtx.getLog();
 
-		m_sync = m_ext.createSync(m_eglDisplay, m_syncType, NULL);
+		m_sync = egl.createSyncKHR(m_eglDisplay, m_syncType, NULL);
 		log << TestLog::Message << m_sync << " = eglCreateSyncKHR(" << m_eglDisplay << ", " << getSyncTypeName(m_syncType) << ", NULL)" << TestLog::EndMessage;
-		TCU_CHECK_EGL_MSG("eglCreateSyncKHR()");
+		EGLU_CHECK_MSG(egl, "eglCreateSyncKHR()");
 
 		EGLint condition = 0xF0F0F;
-		EGLBoolean result = m_ext.getSyncAttrib(m_eglDisplay, m_sync, EGL_NONE, &condition);
+		EGLBoolean result = egl.getSyncAttribKHR(m_eglDisplay, m_sync, EGL_NONE, &condition);
 		log << TestLog::Message << result << " = eglGetSyncAttribKHR(" << m_eglDisplay << ", " << m_sync << ", EGL_NONE, {" << condition << "})" << TestLog::EndMessage;
 
-		EGLint error = eglGetError();
+		EGLint error = egl.getError();
 		log << TestLog::Message << error << " = eglGetError()" << TestLog::EndMessage;
 
 		if (error != EGL_BAD_ATTRIBUTE)
@@ -933,18 +904,17 @@
 
 	IterateResult	iterate					(void)
 	{
-		TestLog& log = m_testCtx.getLog();
-		TCU_CHECK(m_ext.createSync);
-		TCU_CHECK(m_ext.getSyncAttrib);
+		const Library&	egl		= m_eglTestCtx.getLibrary();
+		TestLog&		log		= m_testCtx.getLog();
 
-		m_sync = m_ext.createSync(m_eglDisplay, m_syncType, NULL);
+		m_sync = egl.createSyncKHR(m_eglDisplay, m_syncType, NULL);
 		log << TestLog::Message << m_sync << " = eglCreateSyncKHR(" << m_eglDisplay << ", " << getSyncTypeName(m_syncType) << ", NULL)" << TestLog::EndMessage;
-		TCU_CHECK_EGL_MSG("eglCreateSyncKHR()");
+		EGLU_CHECK_MSG(egl, "eglCreateSyncKHR()");
 
-		EGLBoolean result = m_ext.getSyncAttrib(m_eglDisplay, m_sync, EGL_SYNC_TYPE_KHR, NULL);
+		EGLBoolean result = egl.getSyncAttribKHR(m_eglDisplay, m_sync, EGL_SYNC_TYPE_KHR, NULL);
 		log << TestLog::Message << result << " = eglGetSyncAttribKHR(" << m_eglDisplay << ", " << m_sync << ", EGL_SYNC_CONDITION_KHR, NULL)" << TestLog::EndMessage;
 
-		EGLint error = eglGetError();
+		EGLint error = egl.getError();
 		log << TestLog::Message << error << " = eglGetError()" << TestLog::EndMessage;
 
 		if (error != EGL_BAD_PARAMETER)
@@ -968,16 +938,15 @@
 
 	IterateResult	iterate			(void)
 	{
-		TestLog& log = m_testCtx.getLog();
-		TCU_CHECK(m_ext.createSync);
-		TCU_CHECK(m_ext.destroySync);
+		const Library&	egl		= m_eglTestCtx.getLibrary();
+		TestLog&		log		= m_testCtx.getLog();
 
-		m_sync = m_ext.createSync(m_eglDisplay, m_syncType, NULL);
+		m_sync = egl.createSyncKHR(m_eglDisplay, m_syncType, NULL);
 		log << TestLog::Message << "eglCreateSyncKHR(" << m_eglDisplay << ", " << getSyncTypeName(m_syncType) << ", NULL)" << TestLog::EndMessage;
-		TCU_CHECK_EGL_MSG("eglCreateSyncKHR()");
+		EGLU_CHECK_MSG(egl, "eglCreateSyncKHR()");
 
 		log << TestLog::Message << "eglDestroySyncKHR(" << m_eglDisplay << ", " << m_sync << ")" << TestLog::EndMessage;
-		TCU_CHECK_EGL_CALL(m_ext.destroySync(m_eglDisplay, m_sync));
+		EGLU_CHECK_CALL(egl, destroySyncKHR(m_eglDisplay, m_sync));
 		m_sync = EGL_NO_SYNC_KHR;
 
 		m_testCtx.setTestResult(QP_TEST_RESULT_PASS, "Pass");
@@ -992,18 +961,17 @@
 
 	IterateResult	iterate							(void)
 	{
-		TestLog& log = m_testCtx.getLog();
-		TCU_CHECK(m_ext.createSync);
-		TCU_CHECK(m_ext.destroySync);
+		const Library&	egl		= m_eglTestCtx.getLibrary();
+		TestLog&		log		= m_testCtx.getLog();
 
-		m_sync = m_ext.createSync(m_eglDisplay, m_syncType, NULL);
+		m_sync = egl.createSyncKHR(m_eglDisplay, m_syncType, NULL);
 		log << TestLog::Message << "eglCreateSyncKHR(" << m_eglDisplay << ", " << getSyncTypeName(m_syncType) << ", NULL)" << TestLog::EndMessage;
-		TCU_CHECK_EGL_MSG("eglCreateSyncKHR()");
+		EGLU_CHECK_MSG(egl, "eglCreateSyncKHR()");
 
-		EGLBoolean result = m_ext.destroySync(EGL_NO_DISPLAY, m_sync);
+		EGLBoolean result = egl.destroySyncKHR(EGL_NO_DISPLAY, m_sync);
 		log << TestLog::Message << result << " = eglDestroySyncKHR(EGL_NO_DISPLAY, " << m_sync << ")" << TestLog::EndMessage;
 
-		EGLint error = eglGetError();
+		EGLint error = egl.getError();
 		log << TestLog::Message << error << " = eglGetError()" << TestLog::EndMessage;
 
 		if (error != EGL_BAD_DISPLAY)
@@ -1027,13 +995,13 @@
 
 	IterateResult	iterate						(void)
 	{
-		TestLog& log = m_testCtx.getLog();
-		TCU_CHECK(m_ext.destroySync);
+		const Library&	egl		= m_eglTestCtx.getLibrary();
+		TestLog&		log		= m_testCtx.getLog();
 
-		EGLBoolean result = m_ext.destroySync(m_eglDisplay, EGL_NO_SYNC_KHR);
+		EGLBoolean result = egl.destroySyncKHR(m_eglDisplay, EGL_NO_SYNC_KHR);
 		log << TestLog::Message << result << " = eglDestroySyncKHR(" << m_eglDisplay << ", EGL_NO_SYNC_KHR)" << TestLog::EndMessage;
 
-		EGLint error = eglGetError();
+		EGLint error = egl.getError();
 		log << TestLog::Message << error << " = eglGetError()" << TestLog::EndMessage;
 
 		if (error != EGL_BAD_PARAMETER)
@@ -1057,20 +1025,19 @@
 
 	IterateResult	iterate			(void)
 	{
-		TestLog& log = m_testCtx.getLog();
-		TCU_CHECK(m_ext.createSync);
-		TCU_CHECK(m_ext.waitSync);
+		const Library&	egl		= m_eglTestCtx.getLibrary();
+		TestLog&		log		= m_testCtx.getLog();
 
-		m_sync = m_ext.createSync(m_eglDisplay, m_syncType, NULL);
+		m_sync = egl.createSyncKHR(m_eglDisplay, m_syncType, NULL);
 		log << TestLog::Message << m_sync << " = eglCreateSyncKHR(" << m_eglDisplay << ", " << getSyncTypeName(m_syncType) << ", NULL)" << TestLog::EndMessage;
-		TCU_CHECK_EGL_MSG("eglCreateSyncKHR()");
+		EGLU_CHECK_MSG(egl, "eglCreateSyncKHR()");
 
-		EGLint status = m_ext.waitSync(m_eglDisplay, m_sync, 0);
+		EGLint status = egl.waitSyncKHR(m_eglDisplay, m_sync, 0);
 		log << TestLog::Message << status << " = eglWaitSyncKHR(" << m_eglDisplay << ", " << m_sync << ", 0, 0)" << TestLog::EndMessage;
 
 		TCU_CHECK(status == EGL_TRUE);
 
-		GLU_CHECK_CALL(glFinish());
+		GLU_CHECK_GLW_CALL(m_gl, finish());
 
 		m_testCtx.setTestResult(QP_TEST_RESULT_PASS, "Pass");
 		return STOP;
@@ -1085,18 +1052,17 @@
 
 	IterateResult	iterate						(void)
 	{
-		TestLog& log = m_testCtx.getLog();
-		TCU_CHECK(m_ext.createSync);
-		TCU_CHECK(m_ext.waitSync);
+		const Library&	egl		= m_eglTestCtx.getLibrary();
+		TestLog&		log		= m_testCtx.getLog();
 
-		m_sync = m_ext.createSync(m_eglDisplay, m_syncType, NULL);
+		m_sync = egl.createSyncKHR(m_eglDisplay, m_syncType, NULL);
 		log << TestLog::Message << m_sync << " = eglCreateSyncKHR(" << m_eglDisplay << ", " << getSyncTypeName(m_syncType) << ", NULL)" << TestLog::EndMessage;
-		TCU_CHECK_EGL_MSG("eglCreateSyncKHR()");
+		EGLU_CHECK_MSG(egl, "eglCreateSyncKHR()");
 
-		EGLint status = m_ext.waitSync(EGL_NO_DISPLAY, m_sync, 0);
+		EGLint status = egl.waitSyncKHR(EGL_NO_DISPLAY, m_sync, 0);
 		log << TestLog::Message << status << " = eglWaitSyncKHR(EGL_NO_DISPLAY, " << m_sync << ", 0)" << TestLog::EndMessage;
 
-		EGLint error = eglGetError();
+		EGLint error = egl.getError();
 		log << TestLog::Message << error << " = eglGetError()" << TestLog::EndMessage;
 
 		if (error != EGL_BAD_DISPLAY)
@@ -1120,13 +1086,13 @@
 
 	IterateResult	iterate					(void)
 	{
-		TestLog& log = m_testCtx.getLog();
-		TCU_CHECK(m_ext.waitSync);
+		const Library&	egl		= m_eglTestCtx.getLibrary();
+		TestLog&		log		= m_testCtx.getLog();
 
-		EGLint status = m_ext.waitSync(m_eglDisplay, EGL_NO_SYNC_KHR, 0);
+		EGLint status = egl.waitSyncKHR(m_eglDisplay, EGL_NO_SYNC_KHR, 0);
 		log << TestLog::Message << status << " = eglWaitSyncKHR(" << m_eglDisplay << ", EGL_NO_SYNC_KHR, 0)" << TestLog::EndMessage;
 
-		EGLint error = eglGetError();
+		EGLint error = egl.getError();
 		log << TestLog::Message << error << " = eglGetError()" << TestLog::EndMessage;
 
 		if (error != EGL_BAD_PARAMETER)
@@ -1150,18 +1116,17 @@
 
 	IterateResult	iterate					(void)
 	{
-		TestLog& log = m_testCtx.getLog();
-		TCU_CHECK(m_ext.createSync);
-		TCU_CHECK(m_ext.waitSync);
+		const Library&	egl		= m_eglTestCtx.getLibrary();
+		TestLog&		log		= m_testCtx.getLog();
 
-		m_sync = m_ext.createSync(m_eglDisplay, m_syncType, NULL);
+		m_sync = egl.createSyncKHR(m_eglDisplay, m_syncType, NULL);
 		log << TestLog::Message << m_sync << " = eglCreateSyncKHR(" << m_eglDisplay << ", " << getSyncTypeName(m_syncType) << ", NULL)" << TestLog::EndMessage;
-		TCU_CHECK_EGL_MSG("eglCreateSyncKHR()");
+		EGLU_CHECK_MSG(egl, "eglCreateSyncKHR()");
 
-		EGLint status = m_ext.waitSync(m_eglDisplay, m_sync, 0xFFFFFFFF);
+		EGLint status = egl.waitSyncKHR(m_eglDisplay, m_sync, 0xFFFFFFFF);
 		log << TestLog::Message << status << " = eglWaitSyncKHR(" << m_eglDisplay << ", " << m_sync << ", 0xFFFFFFFF)" << TestLog::EndMessage;
 
-		EGLint error = eglGetError();
+		EGLint error = egl.getError();
 		log << TestLog::Message << error << " = eglGetError()" << TestLog::EndMessage;
 
 		if (error != EGL_BAD_PARAMETER)
diff --git a/modules/egl/teglTestCase.cpp b/modules/egl/teglTestCase.cpp
index 3beeb76..91ebdd5 100644
--- a/modules/egl/teglTestCase.cpp
+++ b/modules/egl/teglTestCase.cpp
@@ -29,249 +29,48 @@
 #include "egluGLFunctionLoader.hpp"
 #include "egluPlatform.hpp"
 
+#include "eglwLibrary.hpp"
+#include "eglwEnums.hpp"
+
 #include "gluRenderContext.hpp"
 #include "glwInitFunctions.hpp"
 
-#include <set>
-
-using std::vector;
-using std::set;
-
 namespace deqp
 {
 namespace egl
 {
 
-namespace
-{
+using namespace eglw;
 
-void split (std::vector<std::string>& dst, const std::string& src)
-{
-	size_t start = 0;
-	size_t end	 = std::string::npos;
-
-	while ((end = src.find(' ', start)) != std::string::npos)
-	{
-		dst.push_back(src.substr(start, end-start));
-		start = end+1;
-	}
-
-	if (start < end)
-		dst.push_back(src.substr(start, end-start));
-}
-
-EGLint parseAPI (const std::string& api)
-{
-	if (api == "OpenGL")
-		return EGL_OPENGL_API;
-	else if (api == "OpenGL_ES")
-		return EGL_OPENGL_ES_API;
-	else if (api == "OpenVG")
-		return EGL_OPENVG_API;
-	else
-	{
-		tcu::print("Warning: Unknown API '%s'", api.c_str());
-		return 0;
-	}
-}
-
-} // anonymous
-
-EglTestContext::EglTestContext (tcu::TestContext& testCtx, const eglu::NativeDisplayFactory& displayFactory, const eglu::NativeWindowFactory* windowFactory, const eglu::NativePixmapFactory* pixmapFactory)
+EglTestContext::EglTestContext (tcu::TestContext& testCtx, const eglu::NativeDisplayFactory& displayFactory)
 	: m_testCtx					(testCtx)
-	, m_displayFactory			(displayFactory)
-	, m_windowFactory			(windowFactory)
-	, m_pixmapFactory			(pixmapFactory)
-	, m_defaultNativeDisplay	(DE_NULL)
-	, m_defaultEGLDisplay		(DE_NULL)
+	, m_nativeDisplayFactory	(displayFactory)
+	, m_nativeDisplay			(m_nativeDisplayFactory.createDisplay())
+	, m_glLibraryCache			(testCtx.getPlatform().getEGLPlatform(), testCtx.getCommandLine())
 {
-	// Temporarily allocate default display for storing config list
-	try
-	{
-		EGLDisplay	eglDisplay	= EGL_NO_DISPLAY;
-		EGLint		majorVersion;
-		EGLint		minorVersion;
-
-		m_defaultNativeDisplay	= m_displayFactory.createDisplay();
-
-		eglDisplay = eglu::getDisplay(*m_defaultNativeDisplay);
-		TCU_CHECK_EGL_CALL(eglInitialize(eglDisplay, &majorVersion, &minorVersion));
-
-		m_defaultEGLDisplay = new tcu::egl::Display(eglDisplay, majorVersion, minorVersion);
-
-		// Create config list
-		{
-			vector<EGLConfig>	configs;
-			set<EGLint>			idSet; // For checking for duplicate config IDs
-
-			m_defaultEGLDisplay->getConfigs(configs);
-
-			m_configs.resize(configs.size());
-			for (int ndx = 0; ndx < (int)configs.size(); ndx++)
-			{
-				m_defaultEGLDisplay->describeConfig(configs[ndx], m_configs[ndx]);
-
-				EGLint id = m_configs[ndx].configId;
-				if (idSet.find(id) != idSet.end())
-					tcu::print("Warning: Duplicate config ID %d\n", id);
-				idSet.insert(id);
-			}
-		}
-
-		// Query supported APIs
-		{
-			const char*					clientAPIs	= eglQueryString(eglDisplay, EGL_CLIENT_APIS);
-			std::vector<std::string>	apis;
-			TCU_CHECK(clientAPIs);
-
-			split(apis, clientAPIs);
-			for (std::vector<std::string>::const_iterator apiIter = apis.begin(); apiIter != apis.end(); apiIter++)
-			{
-				EGLint parsedAPI = parseAPI(*apiIter);
-				if (parsedAPI != 0)
-					m_supportedAPIs.insert(parsedAPI);
-			}
-		}
-
-		delete m_defaultEGLDisplay;
-		m_defaultEGLDisplay = DE_NULL;
-		delete m_defaultNativeDisplay;
-		m_defaultNativeDisplay = DE_NULL;
-	}
-	catch (...)
-	{
-		delete m_defaultEGLDisplay;
-		m_defaultEGLDisplay = DE_NULL;
-		delete m_defaultNativeDisplay;
-		m_defaultNativeDisplay = DE_NULL;
-		throw;
-	}
 }
 
 EglTestContext::~EglTestContext (void)
 {
-	for (GLLibraryMap::iterator iter = m_glLibraries.begin(); iter != m_glLibraries.end(); ++iter)
-		delete iter->second;
-
-	delete m_defaultEGLDisplay;
-	delete m_defaultNativeDisplay;
 }
 
-void EglTestContext::createDefaultDisplay (void)
+const eglw::Library& EglTestContext::getLibrary (void) const
 {
-	EGLDisplay	eglDisplay	= EGL_NO_DISPLAY;
-	EGLint		majorVersion;
-	EGLint		minorVersion;
-
-	DE_ASSERT(!m_defaultEGLDisplay);
-	DE_ASSERT(!m_defaultNativeDisplay);
-
-	try
-	{
-		m_defaultNativeDisplay	= m_displayFactory.createDisplay();
-
-		eglDisplay = eglu::getDisplay(*m_defaultNativeDisplay);
-		TCU_CHECK_EGL_CALL(eglInitialize(eglDisplay, &majorVersion, &minorVersion));
-
-		m_defaultEGLDisplay = new tcu::egl::Display(eglDisplay, majorVersion, minorVersion);
-	}
-	catch (const std::exception&)
-	{
-		delete m_defaultEGLDisplay;
-		m_defaultEGLDisplay = DE_NULL;
-		delete m_defaultNativeDisplay;
-		m_defaultNativeDisplay = DE_NULL;
-		throw;
-	}
+	return m_nativeDisplay->getLibrary();
 }
 
-const eglu::NativeWindowFactory& EglTestContext::getNativeWindowFactory (void) const
+void EglTestContext::initGLFunctions (glw::Functions* dst, glu::ApiType apiType) const
 {
-	if (m_windowFactory)
-		return *m_windowFactory;
-	else
-		throw tcu::NotSupportedError("No default native window factory available", "", __FILE__, __LINE__);
+	initGLFunctions(dst, apiType, 0, DE_NULL);
 }
 
-const eglu::NativePixmapFactory& EglTestContext::getNativePixmapFactory (void) const
+void EglTestContext::initGLFunctions (glw::Functions* dst, glu::ApiType apiType, int numExtensions, const char* const* extensions) const
 {
-	if (m_pixmapFactory)
-		return *m_pixmapFactory;
-	else
-		throw tcu::NotSupportedError("No default native pixmap factory available", "", __FILE__, __LINE__);
-}
+	const tcu::FunctionLibrary*		platformLib		= m_glLibraryCache.getLibrary(apiType);
+	const eglu::GLFunctionLoader	loader			(getLibrary(), platformLib);
 
-void EglTestContext::destroyDefaultDisplay (void)
-{
-	DE_ASSERT(m_defaultEGLDisplay);
-	DE_ASSERT(m_defaultNativeDisplay);
-
-	delete m_defaultEGLDisplay;
-	m_defaultEGLDisplay = DE_NULL;
-
-	delete m_defaultNativeDisplay;
-	m_defaultNativeDisplay = DE_NULL;
-}
-
-eglu::NativeWindow* EglTestContext::createNativeWindow (EGLDisplay display, EGLConfig config, const EGLAttrib* attribList, int width, int height, eglu::WindowParams::Visibility visibility)
-{
-	if (!m_windowFactory)
-		throw tcu::NotSupportedError("Windows not supported", "", __FILE__, __LINE__);
-
-	return m_windowFactory->createWindow(m_defaultNativeDisplay, display, config, attribList, eglu::WindowParams(width, height, visibility));
-}
-
-eglu::NativeWindow* EglTestContext::createNativeWindow (EGLDisplay display, EGLConfig config, const EGLAttrib* attribList, int width, int height)
-{
-	return createNativeWindow(display, config, attribList, width, height, eglu::parseWindowVisibility(getTestContext().getCommandLine()));
-}
-
-eglu::NativePixmap* EglTestContext::createNativePixmap (EGLDisplay display, EGLConfig config, const EGLAttrib* attribList, int width, int height)
-{
-	if (!m_pixmapFactory)
-		throw tcu::NotSupportedError("Pixmaps not supported", "", __FILE__, __LINE__);
-
-	return m_pixmapFactory->createPixmap(m_defaultNativeDisplay, display, config, attribList, width, height);
-}
-
-// \todo [2014-10-06 pyry] Quite hacky, expose ApiType internals?
-static deUint32 makeKey (glu::ApiType apiType)
-{
-	return (apiType.getMajorVersion() << 8) | (apiType.getMinorVersion() << 4) | apiType.getProfile();
-}
-
-const tcu::FunctionLibrary* EglTestContext::getGLLibrary (glu::ApiType apiType) const
-{
-	tcu::FunctionLibrary*		library	= DE_NULL;
-	const deUint32				key		= makeKey(apiType);
-	GLLibraryMap::iterator		iter	= m_glLibraries.find(key);
-
-	if (iter == m_glLibraries.end())
-	{
-		library = m_testCtx.getPlatform().getEGLPlatform().createDefaultGLFunctionLibrary(apiType, m_testCtx.getCommandLine());
-		m_glLibraries.insert(std::make_pair(key, library));
-	}
-	else
-		library = iter->second;
-
-	return library;
-}
-
-deFunctionPtr EglTestContext::getGLFunction (glu::ApiType apiType, const char* name) const
-{
-	// \todo [2014-03-11 pyry] This requires fall-back to eglGetProcAddress(), right?
-	const tcu::FunctionLibrary* const	library	= getGLLibrary(apiType);
-	return library->getFunction(name);
-}
-
-void EglTestContext::getGLFunctions (glw::Functions& gl, glu::ApiType apiType, const std::vector<const char*>& extensions) const
-{
-	const tcu::FunctionLibrary* const	library		= getGLLibrary(apiType);
-	const eglu::GLFunctionLoader		loader		(library);
-
-	// \note There may not be current context, so we can't use initFunctions().
-	glu::initCoreFunctions(&gl, &loader, apiType);
-	glu::initExtensionFunctions(&gl, &loader, apiType, extensions.size(), &extensions.front());
+	glu::initCoreFunctions(dst, &loader, apiType);
+	glu::initExtensionFunctions(dst, &loader, apiType, numExtensions, extensions);
 }
 
 TestCaseGroup::TestCaseGroup (EglTestContext& eglTestCtx, const char* name, const char* description)
diff --git a/modules/egl/teglTestCase.hpp b/modules/egl/teglTestCase.hpp
index cb3b5bb..ae5fc6a 100644
--- a/modules/egl/teglTestCase.hpp
+++ b/modules/egl/teglTestCase.hpp
@@ -25,15 +25,17 @@
 
 #include "tcuDefs.hpp"
 #include "tcuTestCase.hpp"
-#include "tcuEgl.hpp"
-#include "egluNativeWindow.hpp"
-#include "egluConfigInfo.hpp"
 #include "tcuFunctionLibrary.hpp"
-#include "gluRenderContext.hpp"
-#include "deSTLUtil.hpp"
 
-#include <set>
-#include <map>
+#include "egluNativeDisplay.hpp"
+#include "egluGLFunctionLoader.hpp"
+#include "egluConfigInfo.hpp"
+
+#include "eglwDefs.hpp"
+
+#include "gluRenderContext.hpp"
+
+#include "deUniquePtr.hpp"
 
 namespace eglu
 {
@@ -43,7 +45,12 @@
 class NativeDisplayFactory;
 class NativeWindowFactory;
 class NativePixmapFactory;
-} // eglu
+}
+
+namespace eglw
+{
+class Library;
+}
 
 namespace deqp
 {
@@ -53,50 +60,25 @@
 class EglTestContext
 {
 public:
-												EglTestContext			(tcu::TestContext& testCtx, const eglu::NativeDisplayFactory& displayFactory, const eglu::NativeWindowFactory* windowFactory, const eglu::NativePixmapFactory* pixmapFactory);
-												~EglTestContext			(void);
+										EglTestContext			(tcu::TestContext& testCtx, const eglu::NativeDisplayFactory& displayFactory);
+										~EglTestContext			(void);
 
-	tcu::TestContext&							getTestContext			(void) const	{ return m_testCtx;													}
-	eglu::NativeDisplay&						getNativeDisplay		(void) const	{ return *m_defaultNativeDisplay;									}
-	tcu::egl::Display&							getDisplay				(void) const	{ return *m_defaultEGLDisplay;										}
-	EGLDisplay									getEGLDisplay			(void) const	{ return getDisplay().getEGLDisplay();								}
-	const std::vector<eglu::ConfigInfo>&		getConfigs				(void) const	{ return m_configs;													}
+	tcu::TestContext&					getTestContext			(void) const { return m_testCtx;				}
+	const eglu::NativeDisplayFactory&	getNativeDisplayFactory	(void) const { return m_nativeDisplayFactory;	}
+	eglu::NativeDisplay&				getNativeDisplay		(void) const { return *m_nativeDisplay;			}
+	const eglw::Library&				getLibrary				(void) const;
 
-	const eglu::NativeWindowFactory&			getNativeWindowFactory	(void) const;
-	const eglu::NativePixmapFactory&			getNativePixmapFactory	(void) const;
-
-	eglu::NativeWindow*							createNativeWindow		(EGLDisplay display, EGLConfig config, const EGLAttrib* attribList, int width, int height, eglu::WindowParams::Visibility visibility);
-	eglu::NativeWindow*							createNativeWindow		(EGLDisplay display, EGLConfig config, const EGLAttrib* attribList, int width, int height);
-	eglu::NativePixmap*							createNativePixmap		(EGLDisplay display, EGLConfig config, const EGLAttrib* attribList, int width, int height);
-
-	deFunctionPtr								getGLFunction			(glu::ApiType apiType, const char* name) const;
-	void										getGLFunctions			(glw::Functions& gl, glu::ApiType apiType, const std::vector<const char*>& extensions) const;
-	void										getGLFunctions			(glw::Functions& gl, glu::ApiType apiType) const	{ getGLFunctions(gl, apiType, std::vector<const char*>()); }
-
-	bool										isAPISupported			(EGLint api) const { return de::contains(m_supportedAPIs, api);						}
-
-	// Test case wrapper will instruct test context to create display upon case init and destroy it in deinit
-	void										createDefaultDisplay	(void);
-	void										destroyDefaultDisplay	(void);
+	void								initGLFunctions			(glw::Functions* dst, glu::ApiType apiType) const;
+	void								initGLFunctions			(glw::Functions* dst, glu::ApiType apiType, int numExtensions, const char* const* extensions) const;
 
 private:
-												EglTestContext			(const EglTestContext&);
-	EglTestContext&								operator=				(const EglTestContext&);
+										EglTestContext			(const EglTestContext&);
+	EglTestContext&						operator=				(const EglTestContext&);
 
-	const tcu::FunctionLibrary*					getGLLibrary			(glu::ApiType apiType) const;
-
-	tcu::TestContext&							m_testCtx;
-	const eglu::NativeDisplayFactory&			m_displayFactory;
-	const eglu::NativeWindowFactory*			m_windowFactory;
-	const eglu::NativePixmapFactory*			m_pixmapFactory;
-
-	typedef std::map<deUint32, tcu::FunctionLibrary*> GLLibraryMap;
-	mutable GLLibraryMap						m_glLibraries;			//!< GL library cache.
-
-	eglu::NativeDisplay*						m_defaultNativeDisplay;
-	tcu::egl::Display*							m_defaultEGLDisplay;
-	std::vector<eglu::ConfigInfo>				m_configs;
-	std::set<EGLint>							m_supportedAPIs;
+	tcu::TestContext&					m_testCtx;
+	const eglu::NativeDisplayFactory&	m_nativeDisplayFactory;
+	de::UniquePtr<eglu::NativeDisplay>	m_nativeDisplay;
+	mutable eglu::GLLibraryCache		m_glLibraryCache;
 };
 
 class TestCaseGroup : public tcu::TestCaseGroup
diff --git a/modules/egl/teglTestPackage.cpp b/modules/egl/teglTestPackage.cpp
index 06ee088..90fbe08 100644
--- a/modules/egl/teglTestPackage.cpp
+++ b/modules/egl/teglTestPackage.cpp
@@ -28,9 +28,7 @@
 #include "tcuCommandLine.hpp"
 
 #include "egluPlatform.hpp"
-#include "egluNativeDisplay.hpp"
-#include "egluNativeWindow.hpp"
-#include "egluNativePixmap.hpp"
+#include "egluUtil.hpp"
 
 #include "teglInfoTests.hpp"
 #include "teglCreateContextTests.hpp"
@@ -59,10 +57,6 @@
 #include "teglNativeCoordMappingTests.hpp"
 #include "teglResizeTests.hpp"
 
-#include <typeinfo>
-
-using std::vector;
-
 namespace deqp
 {
 namespace egl
@@ -145,43 +139,12 @@
 
 bool TestCaseWrapper::initTestCase (tcu::TestCase* testCase)
 {
-	tcu::TestLog& log = m_eglTestCtx.getTestContext().getLog();
-
-	// Create display
-	try
-	{
-		m_eglTestCtx.createDefaultDisplay();
-	}
-	catch (const std::exception& e)
-	{
-		log << e;
-		m_eglTestCtx.getTestContext().setTestResult(QP_TEST_RESULT_FAIL, "Failed to initialize EGL for default display");
-		return false;
-	}
-
 	return tcu::TestCaseWrapper::initTestCase(testCase);
 }
 
 bool TestCaseWrapper::deinitTestCase (tcu::TestCase* testCase)
 {
-	tcu::TestLog& log = m_eglTestCtx.getTestContext().getLog();
-
-	bool deinitOk = tcu::TestCaseWrapper::deinitTestCase(testCase);
-
-	// Destroy display
-	try
-	{
-		TCU_CHECK_EGL_CALL(eglMakeCurrent(m_eglTestCtx.getDisplay().getEGLDisplay(), EGL_NO_SURFACE, EGL_NO_SURFACE, EGL_NO_CONTEXT));
-		m_eglTestCtx.destroyDefaultDisplay();
-	}
-	catch (const std::exception& e)
-	{
-		log << e;
-		log << tcu::TestLog::Message << "Error in EGL deinit, test program will teminate." << tcu::TestLog::EndMessage;
-		return false;
-	}
-
-	return deinitOk;
+	return tcu::TestCaseWrapper::deinitTestCase(testCase);
 }
 
 tcu::TestNode::IterateResult TestCaseWrapper::iterateTestCase (tcu::TestCase* testCase)
@@ -189,123 +152,24 @@
 	return tcu::TestCaseWrapper::iterateTestCase(testCase);
 }
 
-PackageContext::PackageContext (tcu::TestContext& testCtx)
-	: m_eglTestCtx	(DE_NULL)
-	, m_caseWrapper	(DE_NULL)
+static const eglu::NativeDisplayFactory& getDefaultDisplayFactory (tcu::TestContext& testCtx)
 {
-	const eglu::NativeDisplayFactoryRegistry&	dpyFactoryRegistry	= testCtx.getPlatform().getEGLPlatform().getNativeDisplayFactoryRegistry();
-	const char* const							displayFactoryName	= testCtx.getCommandLine().getEGLDisplayType();
-	const char* const							windowFactoryName	= testCtx.getCommandLine().getEGLWindowType();
-	const char* const							pixmapFactoryName	= testCtx.getCommandLine().getEGLPixmapType();
+	const eglu::NativeDisplayFactory* factory = eglu::selectNativeDisplayFactory(testCtx.getPlatform().getEGLPlatform().getNativeDisplayFactoryRegistry(), testCtx.getCommandLine());
 
-	const eglu::NativeDisplayFactory*			displayFactory		= DE_NULL;
-	const eglu::NativeWindowFactory*			windowFactory		= DE_NULL;
-	const eglu::NativePixmapFactory*			pixmapFactory		= DE_NULL;
+	if (!factory)
+		TCU_THROW(InternalError, "No native display factories available");
 
-	if (dpyFactoryRegistry.empty())
-	{
-		tcu::print("ERROR: Platform doesn't support any EGL native display types!\n");
-		throw tcu::NotSupportedError("Platform doesn't have EGL any native display factories", DE_NULL, __FILE__, __LINE__);
-	}
+	return *factory;
+}
 
-	if (!displayFactoryName)
-		displayFactory = dpyFactoryRegistry.getDefaultFactory();
-	else
-	{
-		displayFactory = dpyFactoryRegistry.getFactoryByName(displayFactoryName);
-
-		if (!displayFactory)
-		{
-			tcu::print("ERROR: Unknown/unsupported EGL native display type '%s'\n", displayFactoryName);
-			tcu::print("Supported EGL native display types:\n");
-
-			for (int factoryNdx = 0; factoryNdx < (int)dpyFactoryRegistry.getFactoryCount(); factoryNdx++)
-			{
-				const char* name = dpyFactoryRegistry.getFactoryByIndex(factoryNdx)->getName();
-				const char* desc = dpyFactoryRegistry.getFactoryByIndex(factoryNdx)->getDescription();
-
-				tcu::print("  %s: %s\n", name, desc);
-			}
-
-			throw tcu::NotSupportedError(("Unknown EGL native display type '" + std::string(displayFactoryName) + "'.").c_str(), DE_NULL, __FILE__, __LINE__);
-		}
-	}
-
-	tcu::print("Using EGL native display type '%s'\n", displayFactory->getName());
-
-	if (!displayFactory->getNativeWindowRegistry().empty())
-	{
-		windowFactory = windowFactoryName ? displayFactory->getNativeWindowRegistry().getFactoryByName(windowFactoryName)
-										  : displayFactory->getNativeWindowRegistry().getDefaultFactory();
-
-		if (!windowFactory)
-		{
-			DE_ASSERT(windowFactoryName);
-			tcu::print("ERROR: Unknown/unsupported EGL native window type '%s'\n", windowFactoryName);
-			tcu::print("Supported EGL native window types for native display '%s':\n", displayFactory->getName());
-
-			for (int factoryNdx = 0; factoryNdx < (int)displayFactory->getNativeWindowRegistry().getFactoryCount(); factoryNdx++)
-			{
-				const char* name = displayFactory->getNativeWindowRegistry().getFactoryByIndex(factoryNdx)->getName();
-				const char* desc = displayFactory->getNativeWindowRegistry().getFactoryByIndex(factoryNdx)->getDescription();
-
-				tcu::print("  %s: %s\n", name, desc);
-			}
-
-			throw tcu::NotSupportedError(("Unknown EGL native window type '" + std::string(windowFactoryName) + "'").c_str(), DE_NULL, __FILE__, __LINE__);
-		}
-	}
-	else
-		tcu::print("Warning: EGL native display doesn't have any native window types.\n");
-
-	if (!displayFactory->getNativePixmapRegistry().empty())
-	{
-		pixmapFactory = pixmapFactoryName ? displayFactory->getNativePixmapRegistry().getFactoryByName(pixmapFactoryName)
-										  : displayFactory->getNativePixmapRegistry().getDefaultFactory();
-
-		if (!pixmapFactory)
-		{
-			DE_ASSERT(pixmapFactoryName);
-			tcu::print("ERROR: Unknown/unsupported EGL native pixmap type '%s'\n", pixmapFactoryName);
-			tcu::print("Supported EGL native pixmap types for native display '%s':\n", displayFactory->getName());
-
-			for (int factoryNdx = 0; factoryNdx < (int)displayFactory->getNativePixmapRegistry().getFactoryCount(); factoryNdx++)
-			{
-				const char* name = displayFactory->getNativePixmapRegistry().getFactoryByIndex(factoryNdx)->getName();
-				const char* desc = displayFactory->getNativePixmapRegistry().getFactoryByIndex(factoryNdx)->getDescription();
-
-				tcu::print("  %s: %s\n", name, desc);
-			}
-
-			throw tcu::NotSupportedError(("Unknown EGL native pixmap type '" + std::string(pixmapFactoryName) + "'").c_str(), DE_NULL, __FILE__, __LINE__);
-		}
-	}
-	else
-		tcu::print("Warning: EGL native display doesn't have any native pixmap types.\n");
-
-	if (windowFactory)
-		tcu::print("Using EGL native window type '%s'\n", windowFactory->getName());
-	if (pixmapFactory)
-		tcu::print("Using EGL native pixmap type '%s'\n", pixmapFactory->getName());
-
-	try
-	{
-		m_eglTestCtx	= new EglTestContext(testCtx, *displayFactory, windowFactory, pixmapFactory);
-		m_caseWrapper	= new TestCaseWrapper(*m_eglTestCtx);
-	}
-	catch (...)
-	{
-		delete m_caseWrapper;
-		delete m_eglTestCtx;
-
-		throw;
-	}
+PackageContext::PackageContext (tcu::TestContext& testCtx)
+	: m_eglTestCtx	(testCtx, getDefaultDisplayFactory(testCtx))
+	, m_caseWrapper	(m_eglTestCtx)
+{
 }
 
 PackageContext::~PackageContext (void)
 {
-	delete m_caseWrapper;
-	delete m_eglTestCtx;
 }
 
 TestPackage::TestPackage (tcu::TestContext& testCtx)
@@ -329,10 +193,10 @@
 
 	try
 	{
-		addChild(new InfoTests				(m_packageCtx->getEglTestContext()));
-		addChild(new FunctionalTests		(m_packageCtx->getEglTestContext()));
-		addChild(new PerformanceTests		(m_packageCtx->getEglTestContext()));
-		addChild(new StressTests			(m_packageCtx->getEglTestContext()));
+		addChild(new InfoTests			(m_packageCtx->getEglTestContext()));
+		addChild(new FunctionalTests	(m_packageCtx->getEglTestContext()));
+		addChild(new PerformanceTests	(m_packageCtx->getEglTestContext()));
+		addChild(new StressTests		(m_packageCtx->getEglTestContext()));
 	}
 	catch (...)
 	{
diff --git a/modules/egl/teglTestPackage.hpp b/modules/egl/teglTestPackage.hpp
index fa5bd5f..8f0fd63 100644
--- a/modules/egl/teglTestPackage.hpp
+++ b/modules/egl/teglTestPackage.hpp
@@ -54,12 +54,12 @@
 									PackageContext			(tcu::TestContext& testCtx);
 									~PackageContext			(void);
 
-	EglTestContext&					getEglTestContext		(void) { return *m_eglTestCtx;	}
-	tcu::TestCaseWrapper&			getTestCaseWrapper		(void) { return *m_caseWrapper;	}
+	EglTestContext&					getEglTestContext		(void) { return m_eglTestCtx;	}
+	tcu::TestCaseWrapper&			getTestCaseWrapper		(void) { return m_caseWrapper;	}
 
 private:
-	EglTestContext*					m_eglTestCtx;
-	TestCaseWrapper*				m_caseWrapper;
+	EglTestContext					m_eglTestCtx;
+	TestCaseWrapper					m_caseWrapper;
 };
 
 class TestPackage : public tcu::TestPackage
diff --git a/modules/egl/teglVGRenderUtil.cpp b/modules/egl/teglVGRenderUtil.cpp
index afb68f6..a171ca7 100644
--- a/modules/egl/teglVGRenderUtil.cpp
+++ b/modules/egl/teglVGRenderUtil.cpp
@@ -57,14 +57,14 @@
 {
 	DE_UNREF(x && y && width && height);
 	DE_UNREF(color);
-	throw tcu::NotSupportedError("OpenVG is not supported", "", __FILE__, __LINE__);
+	TCU_THROW(NotSupportedError, "OpenVG is not supported");
 }
 
 void readPixels (tcu::Surface& dst, int x, int y, int width, int height)
 {
 	DE_UNREF(x && y && width && height);
 	DE_UNREF(dst);
-	throw tcu::NotSupportedError("OpenVG is not supported", "", __FILE__, __LINE__);
+	TCU_THROW(NotSupportedError, "OpenVG is not supported");
 }
 
 #endif // DEQP_SUPPORT_VG
diff --git a/modules/gles2/functional/es2fDrawTests.cpp b/modules/gles2/functional/es2fDrawTests.cpp
index 8219f0c..762b273 100644
--- a/modules/gles2/functional/es2fDrawTests.cpp
+++ b/modules/gles2/functional/es2fDrawTests.cpp
@@ -323,8 +323,6 @@
 
 		{ gls::DrawTestSpec::STORAGE_BUFFER,	gls::DrawTestSpec::INDEXTYPE_BYTE,	true,	{ 0, 1, -1 } },
 		{ gls::DrawTestSpec::STORAGE_BUFFER,	gls::DrawTestSpec::INDEXTYPE_SHORT,	true,	{ 0, 2, -1 } },
-
-		{ gls::DrawTestSpec::STORAGE_BUFFER,	gls::DrawTestSpec::INDEXTYPE_SHORT,	false,	{ 1, 3, -1 } },
 	};
 
 	gls::DrawTestSpec spec;
@@ -332,19 +330,19 @@
 	tcu::TestCaseGroup* userPtrGroup			= new tcu::TestCaseGroup(m_testCtx, "user_ptr", "user pointer");
 	tcu::TestCaseGroup* unalignedUserPtrGroup	= new tcu::TestCaseGroup(m_testCtx, "unaligned_user_ptr", "unaligned user pointer");
 	tcu::TestCaseGroup* bufferGroup				= new tcu::TestCaseGroup(m_testCtx, "buffer", "buffer");
-	tcu::TestCaseGroup* unalignedBufferGroup	= new tcu::TestCaseGroup(m_testCtx, "unaligned_buffer", "unaligned buffer");
 
 	genBasicSpec(spec, m_method);
 
 	this->addChild(userPtrGroup);
 	this->addChild(unalignedUserPtrGroup);
 	this->addChild(bufferGroup);
-	this->addChild(unalignedBufferGroup);
 
 	for (int testNdx = 0; testNdx < DE_LENGTH_OF_ARRAY(tests); ++testNdx)
 	{
 		const IndexTest&				indexTest	= tests[testNdx];
-		tcu::TestCaseGroup*				group		= (indexTest.storage == gls::DrawTestSpec::STORAGE_USER) ? ((indexTest.aligned) ? (userPtrGroup) : (unalignedUserPtrGroup)) : ((indexTest.aligned) ? (bufferGroup) : (unalignedBufferGroup));
+		tcu::TestCaseGroup*				group		= (indexTest.storage == gls::DrawTestSpec::STORAGE_USER)
+													? ((indexTest.aligned) ? (userPtrGroup) : (unalignedUserPtrGroup))
+													: ((indexTest.aligned) ? (bufferGroup) : (DE_NULL));
 
 		const std::string				name		= std::string("index_") + gls::DrawTestSpec::indexTypeToString(indexTest.type);
 		const std::string				desc		= std::string("index ") + gls::DrawTestSpec::indexTypeToString(indexTest.type) + " in " + gls::DrawTestSpec::storageToString(indexTest.storage);
@@ -360,9 +358,9 @@
 			test->addIteration(spec, iterationDesc.c_str());
 		}
 
-		if (spec.isCompatibilityTest() != gls::DrawTestSpec::COMPATIBILITY_UNALIGNED_OFFSET &&
-			spec.isCompatibilityTest() != gls::DrawTestSpec::COMPATIBILITY_UNALIGNED_STRIDE)
-			group->addChild(test.release());
+		DE_ASSERT(spec.isCompatibilityTest() != gls::DrawTestSpec::COMPATIBILITY_UNALIGNED_OFFSET);
+		DE_ASSERT(spec.isCompatibilityTest() != gls::DrawTestSpec::COMPATIBILITY_UNALIGNED_STRIDE);
+		group->addChild(test.release());
 	}
 }
 
diff --git a/modules/gles2/functional/es2fUniformApiTests.cpp b/modules/gles2/functional/es2fUniformApiTests.cpp
index 4e184c2..6e64042 100644
--- a/modules/gles2/functional/es2fUniformApiTests.cpp
+++ b/modules/gles2/functional/es2fUniformApiTests.cpp
@@ -2297,8 +2297,7 @@
 						{
 							const UniformCollectionGroup&	collectionGroup			= defaultUniformCollections[collectionGroupNdx];
 							const string					collectionGroupName		= collectionGroup.name + (referToFirstArrayElemWithoutIndexI == 0 ? "" : "_first_elem_without_brackets");
-							TestCaseGroup* const			collectionTestGroup		= new TestCaseGroup(m_context, collectionGroupName.c_str(), "");
-							checkMethodGroup->addChild(collectionTestGroup);
+							TestCaseGroup*					collectionTestGroup		= DE_NULL;
 
 							for (int collectionNdx = 0; collectionNdx < (int)collectionGroup.cases.size(); collectionNdx++)
 							{
@@ -2328,6 +2327,13 @@
 										const string	name							= nameWithMatrixType + getCaseShaderTypeName((CaseShaderType)shaderType);
 										const deUint32	arrayFirstElemNameNoIndexFeat	= referToFirstArrayElemWithoutIndexI == 0 ? 0 : UniformCase::FEATURE_ARRAY_FIRST_ELEM_NAME_NO_INDEX;
 
+										// skip empty groups by creating groups on demand
+										if (!collectionTestGroup)
+										{
+											collectionTestGroup = new TestCaseGroup(m_context, collectionGroupName.c_str(), "");
+											checkMethodGroup->addChild(collectionTestGroup);
+										}
+
 										collectionTestGroup->addChild(new UniformValueCase(m_context, name.c_str(), "", (CaseShaderType)shaderType, uniformCollection,
 																							UniformValueCase::VALUETOCHECK_ASSIGNED, checkMethod, assignMethod,
 																							booleanTypeFeat | arrayFirstElemNameNoIndexFeat));
diff --git a/modules/gles2/stress/es2sDrawTests.cpp b/modules/gles2/stress/es2sDrawTests.cpp
index b6d8a66..8d027d5 100644
--- a/modules/gles2/stress/es2sDrawTests.cpp
+++ b/modules/gles2/stress/es2sDrawTests.cpp
@@ -114,35 +114,24 @@
 
 	const IndexTest tests[] =
 	{
-		{ gls::DrawTestSpec::STORAGE_USER,		gls::DrawTestSpec::INDEXTYPE_BYTE,	true,	{ 0, 1, -1 } },
-		{ gls::DrawTestSpec::STORAGE_USER,		gls::DrawTestSpec::INDEXTYPE_SHORT,	true,	{ 0, 2, -1 } },
-
-		{ gls::DrawTestSpec::STORAGE_USER,		gls::DrawTestSpec::INDEXTYPE_SHORT,	false,	{ 1, 3, -1 } },
-
-		{ gls::DrawTestSpec::STORAGE_BUFFER,	gls::DrawTestSpec::INDEXTYPE_BYTE,	true,	{ 0, 1, -1 } },
-		{ gls::DrawTestSpec::STORAGE_BUFFER,	gls::DrawTestSpec::INDEXTYPE_SHORT,	true,	{ 0, 2, -1 } },
-
 		{ gls::DrawTestSpec::STORAGE_BUFFER,	gls::DrawTestSpec::INDEXTYPE_SHORT,	false,	{ 1, 3, -1 } },
 	};
 
 	gls::DrawTestSpec spec;
 
-	tcu::TestCaseGroup* userPtrGroup			= new tcu::TestCaseGroup(m_testCtx, "user_ptr", "user pointer");
-	tcu::TestCaseGroup* unalignedUserPtrGroup	= new tcu::TestCaseGroup(m_testCtx, "unaligned_user_ptr", "unaligned user pointer");
-	tcu::TestCaseGroup* bufferGroup				= new tcu::TestCaseGroup(m_testCtx, "buffer", "buffer");
 	tcu::TestCaseGroup* unalignedBufferGroup	= new tcu::TestCaseGroup(m_testCtx, "unaligned_buffer", "unaligned buffer");
 
 	genBasicSpec(spec, m_method);
 
-	this->addChild(userPtrGroup);
-	this->addChild(unalignedUserPtrGroup);
-	this->addChild(bufferGroup);
 	this->addChild(unalignedBufferGroup);
 
 	for (int testNdx = 0; testNdx < DE_LENGTH_OF_ARRAY(tests); ++testNdx)
 	{
 		const IndexTest&				indexTest	= tests[testNdx];
-		tcu::TestCaseGroup*				group		= (indexTest.storage == gls::DrawTestSpec::STORAGE_USER) ? ((indexTest.aligned) ? (userPtrGroup) : (unalignedUserPtrGroup)) : ((indexTest.aligned) ? (bufferGroup) : (unalignedBufferGroup));
+
+		DE_ASSERT(indexTest.storage != gls::DrawTestSpec::STORAGE_USER);
+		DE_ASSERT(!indexTest.aligned);
+		tcu::TestCaseGroup*				group		= unalignedBufferGroup;
 
 		const std::string				name		= std::string("index_") + gls::DrawTestSpec::indexTypeToString(indexTest.type);
 		const std::string				desc		= std::string("index ") + gls::DrawTestSpec::indexTypeToString(indexTest.type) + " in " + gls::DrawTestSpec::storageToString(indexTest.storage);
@@ -158,9 +147,9 @@
 			test->addIteration(spec, iterationDesc.c_str());
 		}
 
-		if (spec.isCompatibilityTest() == gls::DrawTestSpec::COMPATIBILITY_UNALIGNED_OFFSET ||
-			spec.isCompatibilityTest() == gls::DrawTestSpec::COMPATIBILITY_UNALIGNED_STRIDE)
-			group->addChild(test.release());
+		DE_ASSERT(spec.isCompatibilityTest() == gls::DrawTestSpec::COMPATIBILITY_UNALIGNED_OFFSET ||
+				  spec.isCompatibilityTest() == gls::DrawTestSpec::COMPATIBILITY_UNALIGNED_STRIDE);
+		group->addChild(test.release());
 	}
 }
 
diff --git a/modules/gles2/tes2TestCaseWrapper.cpp b/modules/gles2/tes2TestCaseWrapper.cpp
index c7c2eb9..dc3fa2c 100644
--- a/modules/gles2/tes2TestCaseWrapper.cpp
+++ b/modules/gles2/tes2TestCaseWrapper.cpp
@@ -95,6 +95,7 @@
 	{
 		m_testCtx.getLog() << e;
 		m_testCtx.setTestResult(QP_TEST_RESULT_RESOURCE_ERROR, "Resource error in context post-iteration routine");
+		m_testCtx.setTerminateAfter(true);
 		return tcu::TestNode::STOP;
 	}
 	catch (const std::exception& e)
diff --git a/modules/gles3/accuracy/es3aTextureFilteringTests.cpp b/modules/gles3/accuracy/es3aTextureFilteringTests.cpp
index 8fca97f..25fe515 100644
--- a/modules/gles3/accuracy/es3aTextureFilteringTests.cpp
+++ b/modules/gles3/accuracy/es3aTextureFilteringTests.cpp
@@ -541,7 +541,7 @@
 	tcu::TextureFormatInfo		fmtInfo				= tcu::getTextureFormatInfo(texFmt);
 
 	// Accuracy measurements are off unless viewport size is exactly as expected.
-	if (m_nodeType == tcu::NODETYPE_ACCURACY && (viewport.width < defViewportWidth || viewport.height < defViewportHeight))
+	if (getNodeType() == tcu::NODETYPE_ACCURACY && (viewport.width < defViewportWidth || viewport.height < defViewportHeight))
 		throw tcu::NotSupportedError("Too small viewport", "", __FILE__, __LINE__);
 
 	// Viewport is divided into 4 sections.
diff --git a/modules/gles3/functional/es3fDrawTests.cpp b/modules/gles3/functional/es3fDrawTests.cpp
index ff9fbfc..bdf22dd 100644
--- a/modules/gles3/functional/es3fDrawTests.cpp
+++ b/modules/gles3/functional/es3fDrawTests.cpp
@@ -424,9 +424,6 @@
 		{ gls::DrawTestSpec::STORAGE_BUFFER,	gls::DrawTestSpec::INDEXTYPE_BYTE,	true,	{ 0, 1, -1 } },
 		{ gls::DrawTestSpec::STORAGE_BUFFER,	gls::DrawTestSpec::INDEXTYPE_SHORT,	true,	{ 0, 2, -1 } },
 		{ gls::DrawTestSpec::STORAGE_BUFFER,	gls::DrawTestSpec::INDEXTYPE_INT,	true,	{ 0, 4, -1 } },
-
-		{ gls::DrawTestSpec::STORAGE_BUFFER,	gls::DrawTestSpec::INDEXTYPE_SHORT,	false,	{ 1, 3, -1 } },
-		{ gls::DrawTestSpec::STORAGE_BUFFER,	gls::DrawTestSpec::INDEXTYPE_INT,	false,	{ 2, 3, -1 } },
 	};
 
 	gls::DrawTestSpec spec;
@@ -434,19 +431,19 @@
 	tcu::TestCaseGroup* userPtrGroup			= new tcu::TestCaseGroup(m_testCtx, "user_ptr", "user pointer");
 	tcu::TestCaseGroup* unalignedUserPtrGroup	= new tcu::TestCaseGroup(m_testCtx, "unaligned_user_ptr", "unaligned user pointer");
 	tcu::TestCaseGroup* bufferGroup				= new tcu::TestCaseGroup(m_testCtx, "buffer", "buffer");
-	tcu::TestCaseGroup* unalignedBufferGroup	= new tcu::TestCaseGroup(m_testCtx, "unaligned_buffer", "unaligned buffer");
 
 	genBasicSpec(spec, m_method);
 
 	this->addChild(userPtrGroup);
 	this->addChild(unalignedUserPtrGroup);
 	this->addChild(bufferGroup);
-	this->addChild(unalignedBufferGroup);
 
 	for (int testNdx = 0; testNdx < DE_LENGTH_OF_ARRAY(tests); ++testNdx)
 	{
 		const IndexTest&				indexTest	= tests[testNdx];
-		tcu::TestCaseGroup*				group		= (indexTest.storage == gls::DrawTestSpec::STORAGE_USER) ? ((indexTest.aligned) ? (userPtrGroup) : (unalignedUserPtrGroup)) : ((indexTest.aligned) ? (bufferGroup) : (unalignedBufferGroup));
+		tcu::TestCaseGroup*				group		= (indexTest.storage == gls::DrawTestSpec::STORAGE_USER)
+													? ((indexTest.aligned) ? (userPtrGroup) : (unalignedUserPtrGroup))
+													: ((indexTest.aligned) ? (bufferGroup) : (DE_NULL));
 
 		const std::string				name		= std::string("index_") + gls::DrawTestSpec::indexTypeToString(indexTest.type);
 		const std::string				desc		= std::string("index ") + gls::DrawTestSpec::indexTypeToString(indexTest.type) + " in " + gls::DrawTestSpec::storageToString(indexTest.storage);
@@ -462,9 +459,9 @@
 			test->addIteration(spec, iterationDesc.c_str());
 		}
 
-		if (spec.isCompatibilityTest() != gls::DrawTestSpec::COMPATIBILITY_UNALIGNED_OFFSET &&
-			spec.isCompatibilityTest() != gls::DrawTestSpec::COMPATIBILITY_UNALIGNED_STRIDE)
-			group->addChild(test.release());
+		DE_ASSERT(spec.isCompatibilityTest() != gls::DrawTestSpec::COMPATIBILITY_UNALIGNED_OFFSET);
+		DE_ASSERT(spec.isCompatibilityTest() != gls::DrawTestSpec::COMPATIBILITY_UNALIGNED_STRIDE);
+		group->addChild(test.release());
 	}
 }
 
diff --git a/modules/gles3/functional/es3fShaderDerivateTests.cpp b/modules/gles3/functional/es3fShaderDerivateTests.cpp
index 97a948f..a5144f5 100644
--- a/modules/gles3/functional/es3fShaderDerivateTests.cpp
+++ b/modules/gles3/functional/es3fShaderDerivateTests.cpp
@@ -508,12 +508,12 @@
 			const int			nominatorLoBits			= de::max(0, numBits - nominatorLoBitsLost);
 			const int			nominatorHiBits			= de::max(0, numBits - nominatorHiBitsLost);
 
-			const tcu::Interval	nominatorRange			(convertFloorFlushToZero(nominator.lo(), minExponent, nominatorLoBits),
-														 convertCeilFlushToZero(nominator.hi(), minExponent, nominatorHiBits));
+			const tcu::Interval	nominatorRange			(convertFloorFlushToZero((float)nominator.lo(), minExponent, nominatorLoBits),
+														 convertCeilFlushToZero((float)nominator.hi(), minExponent, nominatorHiBits));
 
 			const tcu::Interval	divisionRange			= nominatorRange / 3.0f; // legal sample area is anywhere within this and neighboring pixels (i.e. size = 3)
-			const tcu::Interval	divisionResultRange		(convertFloorFlushToZero(addErrorUlp(divisionRange.lo(), -divisionErrorUlps, numBits), minExponent, numBits),
-														 convertCeilFlushToZero(addErrorUlp(divisionRange.hi(), +divisionErrorUlps, numBits), minExponent, numBits));
+			const tcu::Interval	divisionResultRange		(convertFloorFlushToZero(addErrorUlp((float)divisionRange.lo(), -divisionErrorUlps, numBits), minExponent, numBits),
+														 convertCeilFlushToZero(addErrorUlp((float)divisionRange.hi(), +divisionErrorUlps, numBits), minExponent, numBits));
 			const tcu::Interval	finalResultRange		(divisionResultRange.lo() - surfaceThreshold[c], divisionResultRange.hi() + surfaceThreshold[c]);
 
 			if (resultDerivative[c] >= finalResultRange.lo() && resultDerivative[c] <= finalResultRange.hi())
diff --git a/modules/gles3/functional/es3fTextureMipmapTests.cpp b/modules/gles3/functional/es3fTextureMipmapTests.cpp
index 02aede9..dd78b96 100644
--- a/modules/gles3/functional/es3fTextureMipmapTests.cpp
+++ b/modules/gles3/functional/es3fTextureMipmapTests.cpp
@@ -38,8 +38,6 @@
 #include "glwFunctions.hpp"
 #include "glwEnums.hpp"
 
-#include "tcuImageIO.hpp"
-
 using std::vector;
 using std::string;
 using namespace deqp::gls;
@@ -723,7 +721,7 @@
 		lookupPrec.coordBits			= isProjected ? tcu::IVec3(8) : tcu::IVec3(10);
 		lookupPrec.uvwBits				= tcu::IVec3(5,5,0);
 		lodPrec.derivateBits			= 10;
-		lodPrec.lodBits					= isProjected ? 4 : 6;
+		lodPrec.lodBits					= isProjected ? 3 : 6;
 
 		for (int cellNdx = 0; cellNdx < (int)gridLayout.size(); cellNdx++)
 		{
diff --git a/modules/gles3/functional/es3fUniformApiTests.cpp b/modules/gles3/functional/es3fUniformApiTests.cpp
index 30245f4..3364d22 100644
--- a/modules/gles3/functional/es3fUniformApiTests.cpp
+++ b/modules/gles3/functional/es3fUniformApiTests.cpp
@@ -2823,8 +2823,7 @@
 						{
 							const UniformCollectionGroup&	collectionGroup			= defaultUniformCollections[collectionGroupNdx];
 							const string					collectionGroupName		= collectionGroup.name + (referToFirstArrayElemWithoutIndexI == 0 ? "" : "_first_elem_without_brackets");
-							TestCaseGroup* const			collectionTestGroup		= new TestCaseGroup(m_context, collectionGroupName.c_str(), "");
-							checkMethodGroup->addChild(collectionTestGroup);
+							TestCaseGroup*					collectionTestGroup		= DE_NULL;
 
 							for (int collectionNdx = 0; collectionNdx < (int)collectionGroup.cases.size(); collectionNdx++)
 							{
@@ -2862,6 +2861,13 @@
 											const string	name							= nameWithMatrixType + getCaseShaderTypeName((CaseShaderType)shaderType);
 											const deUint32	arrayFirstElemNameNoIndexFeat	= referToFirstArrayElemWithoutIndexI == 0 ? 0 : UniformCase::FEATURE_ARRAY_FIRST_ELEM_NAME_NO_INDEX;
 
+											// skip empty groups by creating groups on demand
+											if (!collectionTestGroup)
+											{
+												collectionTestGroup = new TestCaseGroup(m_context, collectionGroupName.c_str(), "");
+												checkMethodGroup->addChild(collectionTestGroup);
+											}
+
 											collectionTestGroup->addChild(new UniformValueCase(m_context, name.c_str(), "", (CaseShaderType)shaderType, uniformCollection,
 																							   UniformValueCase::VALUETOCHECK_ASSIGNED, checkMethod, assignMethod,
 																							   booleanTypeFeat | arrayFirstElemNameNoIndexFeat | (matrixTypeI == 1 ? UniformCase::FEATURE_MATRIXMODE_ROWMAJOR : 0)));
diff --git a/modules/gles3/stress/es3sDrawTests.cpp b/modules/gles3/stress/es3sDrawTests.cpp
index 821ba92..f041ed0 100644
--- a/modules/gles3/stress/es3sDrawTests.cpp
+++ b/modules/gles3/stress/es3sDrawTests.cpp
@@ -295,40 +295,26 @@
 
 	const IndexTest tests[] =
 	{
-		{ gls::DrawTestSpec::STORAGE_USER,		gls::DrawTestSpec::INDEXTYPE_BYTE,	true,	{ 0, 1, -1 } },
-		{ gls::DrawTestSpec::STORAGE_USER,		gls::DrawTestSpec::INDEXTYPE_SHORT,	true,	{ 0, 2, -1 } },
-		{ gls::DrawTestSpec::STORAGE_USER,		gls::DrawTestSpec::INDEXTYPE_INT,	true,	{ 0, 4, -1 } },
-
-		{ gls::DrawTestSpec::STORAGE_USER,		gls::DrawTestSpec::INDEXTYPE_SHORT,	false,	{ 1, 3, -1 } },
-		{ gls::DrawTestSpec::STORAGE_USER,		gls::DrawTestSpec::INDEXTYPE_INT,	false,	{ 2, 3, -1 } },
-
-		{ gls::DrawTestSpec::STORAGE_BUFFER,	gls::DrawTestSpec::INDEXTYPE_BYTE,	true,	{ 0, 1, -1 } },
-		{ gls::DrawTestSpec::STORAGE_BUFFER,	gls::DrawTestSpec::INDEXTYPE_SHORT,	true,	{ 0, 2, -1 } },
-		{ gls::DrawTestSpec::STORAGE_BUFFER,	gls::DrawTestSpec::INDEXTYPE_INT,	true,	{ 0, 4, -1 } },
-
 		{ gls::DrawTestSpec::STORAGE_BUFFER,	gls::DrawTestSpec::INDEXTYPE_SHORT,	false,	{ 1, 3, -1 } },
 		{ gls::DrawTestSpec::STORAGE_BUFFER,	gls::DrawTestSpec::INDEXTYPE_INT,	false,	{ 2, 3, -1 } },
 	};
 
 	gls::DrawTestSpec spec;
 
-	tcu::TestCaseGroup* const	userPtrGroup			= new tcu::TestCaseGroup(m_testCtx, "user_ptr", "user pointer");
-	tcu::TestCaseGroup* const	unalignedUserPtrGroup	= new tcu::TestCaseGroup(m_testCtx, "unaligned_user_ptr", "unaligned user pointer");
-	tcu::TestCaseGroup* const	bufferGroup				= new tcu::TestCaseGroup(m_testCtx, "buffer", "buffer");
 	tcu::TestCaseGroup* const	unalignedBufferGroup	= new tcu::TestCaseGroup(m_testCtx, "unaligned_buffer", "unaligned buffer");
 	const bool					isRangedMethod			= (m_method == gls::DrawTestSpec::DRAWMETHOD_DRAWELEMENTS_RANGED || m_method == gls::DrawTestSpec::DRAWMETHOD_DRAWELEMENTS_RANGED_BASEVERTEX);
 
 	genBasicSpec(spec, m_method);
 
-	this->addChild(userPtrGroup);
-	this->addChild(unalignedUserPtrGroup);
-	this->addChild(bufferGroup);
 	this->addChild(unalignedBufferGroup);
 
 	for (int testNdx = 0; testNdx < DE_LENGTH_OF_ARRAY(tests); ++testNdx)
 	{
 		const IndexTest&				indexTest	= tests[testNdx];
-		tcu::TestCaseGroup*				group		= (indexTest.storage == gls::DrawTestSpec::STORAGE_USER) ? ((indexTest.aligned) ? (userPtrGroup) : (unalignedUserPtrGroup)) : ((indexTest.aligned) ? (bufferGroup) : (unalignedBufferGroup));
+
+		DE_ASSERT(indexTest.storage != gls::DrawTestSpec::STORAGE_USER);
+		DE_ASSERT(!indexTest.aligned);
+		tcu::TestCaseGroup*				group		= unalignedBufferGroup;
 
 		const std::string				name		= std::string("index_") + gls::DrawTestSpec::indexTypeToString(indexTest.type);
 		const std::string				desc		= std::string("index ") + gls::DrawTestSpec::indexTypeToString(indexTest.type) + " in " + gls::DrawTestSpec::storageToString(indexTest.storage);
@@ -350,9 +336,9 @@
 			test->addIteration(spec, iterationDesc.c_str());
 		}
 
-		if (spec.isCompatibilityTest() == gls::DrawTestSpec::COMPATIBILITY_UNALIGNED_OFFSET ||
-			spec.isCompatibilityTest() == gls::DrawTestSpec::COMPATIBILITY_UNALIGNED_STRIDE)
-			group->addChild(test.release());
+		DE_ASSERT(spec.isCompatibilityTest() == gls::DrawTestSpec::COMPATIBILITY_UNALIGNED_OFFSET ||
+				  spec.isCompatibilityTest() == gls::DrawTestSpec::COMPATIBILITY_UNALIGNED_STRIDE);
+		group->addChild(test.release());
 	}
 }
 
diff --git a/modules/gles3/tes3TestCaseWrapper.cpp b/modules/gles3/tes3TestCaseWrapper.cpp
index 76cb78d..d2e2446 100644
--- a/modules/gles3/tes3TestCaseWrapper.cpp
+++ b/modules/gles3/tes3TestCaseWrapper.cpp
@@ -95,6 +95,7 @@
 	{
 		m_testCtx.getLog() << e;
 		m_testCtx.setTestResult(QP_TEST_RESULT_RESOURCE_ERROR, "Resource error in context post-iteration routine");
+		m_testCtx.setTerminateAfter(true);
 		return tcu::TestNode::STOP;
 	}
 	catch (const std::exception& e)
diff --git a/modules/gles31/functional/es31fAdvancedBlendTests.cpp b/modules/gles31/functional/es31fAdvancedBlendTests.cpp
index aed9395..f005f61 100644
--- a/modules/gles31/functional/es31fAdvancedBlendTests.cpp
+++ b/modules/gles31/functional/es31fAdvancedBlendTests.cpp
@@ -104,6 +104,8 @@
 	const RenderTargetType	m_rtType;
 	const int				m_numIters;
 
+	bool					m_coherentExtensionSupported;
+
 	deUint32				m_colorRbo;
 	deUint32				m_fbo;
 
@@ -224,6 +226,8 @@
 	DE_ASSERT(!m_referenceRenderer);
 	DE_ASSERT(!m_refColorBuffer);
 
+	m_coherentExtensionSupported = m_context.getContextInfo().isExtensionSupported("GL_KHR_blend_equation_advanced_coherent");
+
 	m_program = new glu::ShaderProgram(m_context.getRenderContext(), getBlendProgramSrc(sglr::rr_util::mapGLBlendEquationAdvanced(m_blendMode)));
 	m_testCtx.getLog() << *m_program;
 
@@ -414,8 +418,12 @@
 		gl.useProgram(program);
 		gl.viewport(viewportX, viewportY, m_viewportWidth, m_viewportHeight);
 		gl.blendEquation(m_blendMode);
+
+		// \note coherent extension enables GL_BLEND_ADVANCED_COHERENT_KHR by default
 		if (m_coherentBlending)
 			gl.enable(GL_BLEND_ADVANCED_COHERENT_KHR);
+		else if (m_coherentExtensionSupported)
+			gl.disable(GL_BLEND_ADVANCED_COHERENT_KHR);
 
 		GLU_EXPECT_NO_ERROR(gl.getError(), "Failed to set render state");
 
diff --git a/modules/gles31/functional/es31fDrawTests.cpp b/modules/gles31/functional/es31fDrawTests.cpp
index 5bd9ccc..89d904a 100644
--- a/modules/gles31/functional/es31fDrawTests.cpp
+++ b/modules/gles31/functional/es31fDrawTests.cpp
@@ -1179,6 +1179,7 @@
 	{
 		m_testCtx.getLog() << tcu::TestLog::Message << "Got GL_OUT_OF_MEMORY." << tcu::TestLog::EndMessage;
 		m_testCtx.setTestResult(QP_TEST_RESULT_NOT_SUPPORTED, "Got GL_OUT_OF_MEMORY");
+		m_testCtx.setTerminateAfter(true); // Do not rely on implementation to be able to recover from OOM
 		return STOP;
 	}
 
@@ -1536,15 +1537,15 @@
 	}
 	gl.useProgram(0);
 
-	glu::checkError(gl.getError(), "", __FILE__, __LINE__);
-
 	// free
 
 	gl.deleteVertexArrays(1, &vaoID);
+	glu::checkError(gl.getError(), "", __FILE__, __LINE__);
 
 	gl.finish();
-	glu::readPixels(m_context.getRenderContext(), 0, 0, dst.getAccess());
+	glu::checkError(gl.getError(), "", __FILE__, __LINE__);
 
+	glu::readPixels(m_context.getRenderContext(), 0, 0, dst.getAccess());
 	glu::checkError(gl.getError(), "", __FILE__, __LINE__);
 }
 
diff --git a/modules/gles31/functional/es31fGeometryShaderTests.cpp b/modules/gles31/functional/es31fGeometryShaderTests.cpp
index 6e374a5..e3b0891 100644
--- a/modules/gles31/functional/es31fGeometryShaderTests.cpp
+++ b/modules/gles31/functional/es31fGeometryShaderTests.cpp
@@ -3878,7 +3878,12 @@
 	// not linked -case (INVALID OP)
 	{
 		const tcu::ScopedLogSection section			(m_testCtx.getLog(), "NotLinkedProgram", "Shader program not linked");
-		const std::string			geometrySource	= "#version 310 es\nlayout (triangles) in;\n" + std::string(s_geometryBody);
+		const std::string			geometrySource	= "#version 310 es\n"
+													  "#extension GL_EXT_geometry_shader : require\n"
+													  "layout (triangles) in;\n"
+													  "layout (points, max_vertices = 3) out;\n"
+													  + std::string(s_geometryBody);
+
 
 		glu::Shader					vertexShader	(m_context.getRenderContext(), glu::SHADERTYPE_VERTEX);
 		glu::Shader					fragmentShader	(m_context.getRenderContext(), glu::SHADERTYPE_FRAGMENT);
diff --git a/modules/gles31/functional/es31fPrimitiveBoundingBoxTests.cpp b/modules/gles31/functional/es31fPrimitiveBoundingBoxTests.cpp
index 6cccfb9..92766c8 100644
--- a/modules/gles31/functional/es31fPrimitiveBoundingBoxTests.cpp
+++ b/modules/gles31/functional/es31fPrimitiveBoundingBoxTests.cpp
@@ -903,7 +903,8 @@
 					"	if (gl_FragCoord.x < float(u_viewportPos.x) + wc.x || gl_FragCoord.x > float(u_viewportPos.x) + wc.z ||\n"
 					"	    gl_FragCoord.y < float(u_viewportPos.y) + wc.y || gl_FragCoord.y > float(u_viewportPos.y) + wc.w)\n"
 					"	    return false;\n"
-					"	if (depth*2.0-1.0 < v_bbox_clipMin.z || depth*2.0-1.0 > v_bbox_clipMax.z)\n"
+					"	const highp float dEpsilon = 0.001;\n"
+					"	if (depth*2.0-1.0 < v_bbox_clipMin.z - dEpsilon || depth*2.0-1.0 > v_bbox_clipMax.z + dEpsilon)\n"
 					"	    return false;\n"
 					"	return true;\n"
 					"}\n";
@@ -1989,7 +1990,7 @@
 bool LineRenderCase::checkLineWidths (const tcu::ConstPixelBufferAccess& access, const tcu::IVec2& begin, const tcu::IVec2& end, int componentNdx, int& messageLimitCounter) const
 {
 	const bool			multisample		= m_context.getRenderTarget().getNumSamples() > 1;
-	const int			lineRenderWidth	= (m_isWideLineCase) ? (m_wideLineLineWidth) : (1.0);
+	const int			lineRenderWidth	= (m_isWideLineCase) ? (m_wideLineLineWidth) : 1;
 	const tcu::IVec2	lineWidthRange	= (multisample)
 											? (tcu::IVec2(lineRenderWidth, lineRenderWidth+1))	// multisampled "smooth" lines may spread to neighboring pixel
 											: (tcu::IVec2(lineRenderWidth, lineRenderWidth));
@@ -2629,7 +2630,7 @@
 	{
 		currentPoints[ndx].center	= m_attribData[ndx*2].swizzle(0, 1);
 		currentPoints[ndx].even		= (m_attribData[ndx*2 + 1].y() == 1.0f); // is green
-		currentPoints[ndx].size		= ((m_isWidePointCase) ? ((currentPoints[ndx].even) ? (5.0f) : (3.0f)) : (1.0));
+		currentPoints[ndx].size		= ((m_isWidePointCase) ? ((currentPoints[ndx].even) ? 5 : 3) : 1);
 	}
 
 	// tessellation
@@ -2717,7 +2718,7 @@
 		else
 		{
 			// transform to viewport coords
-			const tcu::IVec2 pixelCenter(deFloatRound((refPoint.center.x() * 0.5f + 0.5f) * viewport.getWidth()), deFloatRound((refPoint.center.y() * 0.5f + 0.5f) * viewport.getHeight()));
+			const tcu::IVec2 pixelCenter(deRoundFloatToInt32((refPoint.center.x() * 0.5f + 0.5f) * viewport.getWidth()), deRoundFloatToInt32((refPoint.center.y() * 0.5f + 0.5f) * viewport.getHeight()));
 
 			// find rasterized point in the result
 			if (pixelCenter.x() < 1 || pixelCenter.y() < 1 || pixelCenter.x() >= viewport.getWidth()-1 || pixelCenter.y() >= viewport.getHeight()-1)
@@ -2794,13 +2795,13 @@
 	const int			componentNdx		= (refPoint.even) ? (1) : (2);
 	const int			halfPointSizeCeil	= (refPoint.size + 1) / 2;
 	const int			halfPointSizeFloor	= (refPoint.size + 1) / 2;
-	const tcu::IVec4	viewportBBoxArea	= getViewportBoundingBoxArea(bbox, tcu::IVec2(viewport.getWidth(), viewport.getHeight()), refPoint.size);
+	const tcu::IVec4	viewportBBoxArea	= getViewportBoundingBoxArea(bbox, tcu::IVec2(viewport.getWidth(), viewport.getHeight()), (float)refPoint.size);
 	const tcu::IVec4	verificationArea	= tcu::IVec4(de::max(viewportBBoxArea.x(), 0),
 														 de::max(viewportBBoxArea.y(), 0),
 														 de::min(viewportBBoxArea.z(), viewport.getWidth()),
 														 de::min(viewportBBoxArea.w(), viewport.getHeight()));
-	const tcu::IVec2	pointPos			= tcu::IVec2(deFloatRound((refPoint.center.x()*0.5f + 0.5f) * viewport.getWidth()),
-														 deFloatRound((refPoint.center.y()*0.5f + 0.5f) * viewport.getHeight()));
+	const tcu::IVec2	pointPos			= tcu::IVec2(deRoundFloatToInt32((refPoint.center.x()*0.5f + 0.5f) * viewport.getWidth()),
+														 deRoundFloatToInt32((refPoint.center.y()*0.5f + 0.5f) * viewport.getHeight()));
 
 	// find any fragment within the point that is inside the bbox, start search at the center
 
@@ -4170,7 +4171,7 @@
 bool ClearCase::verifyImagesEqual (const tcu::PixelBufferAccess& withoutBBox, const tcu::PixelBufferAccess& withBBox)
 {
 	DE_ASSERT(withoutBBox.getWidth() == withBBox.getWidth());
-	DE_ASSERT(withoutBBox.getHeight() == withBBox.getWidth());
+	DE_ASSERT(withoutBBox.getHeight() == withBBox.getHeight());
 
 	tcu::Surface	errorMask	(withoutBBox.getWidth(), withoutBBox.getHeight());
 	bool			anyError	= false;
diff --git a/modules/gles31/functional/es31fProgramInterfaceQueryTests.cpp b/modules/gles31/functional/es31fProgramInterfaceQueryTests.cpp
index c55237a..0c10beb 100644
--- a/modules/gles31/functional/es31fProgramInterfaceQueryTests.cpp
+++ b/modules/gles31/functional/es31fProgramInterfaceQueryTests.cpp
@@ -5080,7 +5080,7 @@
 	{
 		tcu::TestCaseGroup* const blockGroup = new tcu::TestCaseGroup(m_testCtx, "type", "Type");
 		addChild(blockGroup);
-		generateProgramInputOutputShaderCaseBlocks(m_context, blockGroup, true, true, generateProgramInputTypeBlockContents);
+		generateProgramInputOutputShaderCaseBlocks(m_context, blockGroup, false, true, generateProgramInputTypeBlockContents);
 	}
 }
 
@@ -5137,7 +5137,7 @@
 	{
 		tcu::TestCaseGroup* const blockGroup = new tcu::TestCaseGroup(m_testCtx, "type", "Type");
 		addChild(blockGroup);
-		generateProgramInputOutputShaderCaseBlocks(m_context, blockGroup, true, false, generateProgramOutputTypeBlockContents);
+		generateProgramInputOutputShaderCaseBlocks(m_context, blockGroup, false, false, generateProgramOutputTypeBlockContents);
 	}
 }
 
diff --git a/modules/gles31/functional/es31fProgramUniformTests.cpp b/modules/gles31/functional/es31fProgramUniformTests.cpp
index 02a4db3..c020b34 100644
--- a/modules/gles31/functional/es31fProgramUniformTests.cpp
+++ b/modules/gles31/functional/es31fProgramUniformTests.cpp
@@ -1961,8 +1961,7 @@
 				{
 					const UniformCollectionGroup&	collectionGroup			= defaultUniformCollections[collectionGroupNdx];
 					const string					collectionGroupName		= collectionGroup.name + (referToFirstArrayElemWithoutIndexI == 0 ? "" : "_first_elem_without_brackets");
-					TestCaseGroup* const			collectionTestGroup		= new TestCaseGroup(m_context, collectionGroupName.c_str(), "");
-					checkMethodGroup->addChild(collectionTestGroup);
+					TestCaseGroup*					collectionTestGroup		= DE_NULL;
 
 					for (int collectionNdx = 0; collectionNdx < (int)collectionGroup.cases.size(); collectionNdx++)
 					{
@@ -2000,6 +1999,13 @@
 									const string	name							= nameWithMatrixType + getCaseShaderTypeName((CaseShaderType)shaderType);
 									const deUint32	arrayFirstElemNameNoIndexFeat	= referToFirstArrayElemWithoutIndexI == 0 ? 0 : UniformCase::FEATURE_ARRAY_FIRST_ELEM_NAME_NO_INDEX;
 
+									// skip empty groups by creating groups on demand
+									if (!collectionTestGroup)
+									{
+										collectionTestGroup = new TestCaseGroup(m_context, collectionGroupName.c_str(), "");
+										checkMethodGroup->addChild(collectionTestGroup);
+									}
+
 									collectionTestGroup->addChild(new UniformAssignCase(m_context, name.c_str(), "", (CaseShaderType)shaderType, uniformCollection,
 																						checkMethod, assignMethod,
 																						booleanTypeFeat | arrayFirstElemNameNoIndexFeat | (matrixTypeI == 1 ? UniformCase::FEATURE_MATRIXMODE_ROWMAJOR : 0)));
diff --git a/modules/gles31/functional/es31fShaderCommonFunctionTests.cpp b/modules/gles31/functional/es31fShaderCommonFunctionTests.cpp
index 3aec886..9e40589 100644
--- a/modules/gles31/functional/es31fShaderCommonFunctionTests.cpp
+++ b/modules/gles31/functional/es31fShaderCommonFunctionTests.cpp
@@ -1877,7 +1877,6 @@
 		const glu::DataType		type			= m_spec.inputs[0].varType.getBasicType();
 		const glu::Precision	precision		= m_spec.inputs[0].varType.getPrecision();
 		const int				scalarSize		= glu::getDataTypeScalarSize(type);
-		const bool				signedZero		= supportsSignedZero(precision);
 
 		const int				mantissaBits	= getMinMantissaBits(precision);
 		const deUint32			maxUlpDiff		= getMaxUlpDiffFromBits(mantissaBits);
@@ -1888,7 +1887,7 @@
 			const int		in1			= ((const int*)inputs[1])[compNdx];
 			const float		out0		= ((const float*)outputs[0])[compNdx];
 			const float		refOut0		= ldexp(in0, in1);
-			const deUint32	ulpDiff		= signedZero ? getUlpDiff(out0, refOut0) : getUlpDiffIgnoreZeroSign(out0, refOut0);
+			const deUint32	ulpDiff		= getUlpDiffIgnoreZeroSign(out0, refOut0);
 
 			const int		inExp		= tcu::Float32(in0).exponent();
 
diff --git a/modules/gles31/functional/es31fTextureGatherTests.cpp b/modules/gles31/functional/es31fTextureGatherTests.cpp
index 74e6354..dcdc1b2 100644
--- a/modules/gles31/functional/es31fTextureGatherTests.cpp
+++ b/modules/gles31/functional/es31fTextureGatherTests.cpp
@@ -2126,7 +2126,7 @@
 					TestCaseGroup* const		formatGroup		= new TestCaseGroup(m_context, formats[formatNdx].name, "");
 					textureTypeGroup->addChild(formatGroup);
 
-					for (int noCornersI = 0; noCornersI <= (textureType == TEXTURETYPE_CUBE)?1:0; noCornersI++)
+					for (int noCornersI = 0; noCornersI <= ((textureType == TEXTURETYPE_CUBE)?1:0); noCornersI++)
 					{
 						const bool				noCorners		= noCornersI!= 0;
 						TestCaseGroup* const	cornersGroup	= noCorners
diff --git a/modules/gles31/tes31TestCaseWrapper.cpp b/modules/gles31/tes31TestCaseWrapper.cpp
index 05b89e3..e45ab8e 100644
--- a/modules/gles31/tes31TestCaseWrapper.cpp
+++ b/modules/gles31/tes31TestCaseWrapper.cpp
@@ -86,6 +86,7 @@
 	{
 		m_testCtx.getLog() << e;
 		m_testCtx.setTestResult(QP_TEST_RESULT_RESOURCE_ERROR, "Resource error in context post-iteration routine");
+		m_testCtx.setTerminateAfter(true);
 		return tcu::TestNode::STOP;
 	}
 	catch (const std::exception& e)
diff --git a/modules/glshared/glsDrawTest.cpp b/modules/glshared/glsDrawTest.cpp
index b82f261..05689db 100644
--- a/modules/glshared/glsDrawTest.cpp
+++ b/modules/glshared/glsDrawTest.cpp
@@ -76,21 +76,17 @@
 
 static GLenum targetToGL (DrawTestSpec::Target target)
 {
-	DE_ASSERT(target < DrawTestSpec::TARGET_LAST);
-
 	static const GLenum targets[] =
 	{
 		GL_ELEMENT_ARRAY_BUFFER,	// TARGET_ELEMENT_ARRAY = 0,
 		GL_ARRAY_BUFFER				// TARGET_ARRAY,
 	};
 
-	return targets[(int)target];
+	return de::getSizedArrayElement<DrawTestSpec::TARGET_LAST>(targets, (int)target);
 }
 
 static GLenum usageToGL (DrawTestSpec::Usage usage)
 {
-	DE_ASSERT(usage < DrawTestSpec::USAGE_LAST);
-
 	static const GLenum usages[] =
 	{
 		GL_DYNAMIC_DRAW,	// USAGE_DYNAMIC_DRAW = 0,
@@ -106,15 +102,12 @@
 		GL_DYNAMIC_READ,	// USAGE_DYNAMIC_READ,
 		GL_DYNAMIC_COPY		// USAGE_DYNAMIC_COPY,
 	};
-	DE_STATIC_ASSERT(DE_LENGTH_OF_ARRAY(usages) == DrawTestSpec::USAGE_LAST);
 
-	return usages[(int)usage];
+	return de::getSizedArrayElement<DrawTestSpec::USAGE_LAST>(usages, (int)usage);
 }
 
 static GLenum inputTypeToGL (DrawTestSpec::InputType type)
 {
-	DE_ASSERT(type < DrawTestSpec::INPUTTYPE_LAST);
-
 	static const GLenum types[] =
 	{
 		GL_FLOAT,				// INPUTTYPE_FLOAT = 0,
@@ -131,15 +124,12 @@
 		GL_UNSIGNED_INT_2_10_10_10_REV, // INPUTTYPE_UNSIGNED_INT_2_10_10_10,
 		GL_INT_2_10_10_10_REV			// INPUTTYPE_INT_2_10_10_10,
 	};
-	DE_STATIC_ASSERT(DE_LENGTH_OF_ARRAY(types) == DrawTestSpec::INPUTTYPE_LAST);
 
-	return types[(int)type];
+	return de::getSizedArrayElement<DrawTestSpec::INPUTTYPE_LAST>(types, (int)type);
 }
 
 static std::string outputTypeToGLType (DrawTestSpec::OutputType type)
 {
-	DE_ASSERT(type < DrawTestSpec::OUTPUTTYPE_LAST);
-
 	static const char* types[] =
 	{
 		"float",		// OUTPUTTYPE_FLOAT = 0,
@@ -158,14 +148,13 @@
 		"uvec3",		// OUTPUTTYPE_UVEC3,
 		"uvec4",		// OUTPUTTYPE_UVEC4,
 	};
-	DE_STATIC_ASSERT(DE_LENGTH_OF_ARRAY(types) == DrawTestSpec::OUTPUTTYPE_LAST);
 
-	return types[type];
+	return de::getSizedArrayElement<DrawTestSpec::OUTPUTTYPE_LAST>(types, (int)type);
 }
 
 static GLenum primitiveToGL (DrawTestSpec::Primitive primitive)
 {
-	GLenum primitives[] =
+	static const GLenum primitives[] =
 	{
 		GL_POINTS,						// PRIMITIVE_POINTS = 0,
 		GL_TRIANGLES,					// PRIMITIVE_TRIANGLES,
@@ -179,22 +168,20 @@
 		GL_TRIANGLES_ADJACENCY,			// PRIMITIVE_TRIANGLES_ADJACENCY
 		GL_TRIANGLE_STRIP_ADJACENCY,	// PRIMITIVE_TRIANGLE_STRIP_ADJACENCY
 	};
-	DE_STATIC_ASSERT(DE_LENGTH_OF_ARRAY(primitives) == DrawTestSpec::PRIMITIVE_LAST);
 
-	return primitives[(int)primitive];
+	return de::getSizedArrayElement<DrawTestSpec::PRIMITIVE_LAST>(primitives, (int)primitive);
 }
 
 static deUint32 indexTypeToGL (DrawTestSpec::IndexType indexType)
 {
-	GLenum indexTypes[] =
+	static const GLenum indexTypes[] =
 	{
 		GL_UNSIGNED_BYTE,	// INDEXTYPE_BYTE = 0,
 		GL_UNSIGNED_SHORT,	// INDEXTYPE_SHORT,
 		GL_UNSIGNED_INT,	// INDEXTYPE_INT,
 	};
-	DE_STATIC_ASSERT(DE_LENGTH_OF_ARRAY(indexTypes) == DrawTestSpec::INDEXTYPE_LAST);
 
-	return indexTypes[(int)indexType];
+	return de::getSizedArrayElement<DrawTestSpec::INDEXTYPE_LAST>(indexTypes, (int)indexType);
 }
 
 static bool inputTypeIsFloatType (DrawTestSpec::InputType type)
@@ -291,9 +278,7 @@
 		{	true,		false,		true,		false,		true,		false	}, //!< DRAWMETHOD_DRAWELEMENTS_RANGED_BASEVERTEX,
 	};
 
-	DE_STATIC_ASSERT(DE_LENGTH_OF_ARRAY(infos) == DrawTestSpec::DRAWMETHOD_LAST);
-	DE_ASSERT((int)method < DE_LENGTH_OF_ARRAY(infos));
-	return infos[(int)method];
+	return de::getSizedArrayElement<DrawTestSpec::DRAWMETHOD_LAST>(infos, (int)method);
 }
 
 template<class T>
@@ -2333,22 +2318,17 @@
 
 std::string DrawTestSpec::targetToString(Target target)
 {
-	DE_ASSERT(target < TARGET_LAST);
-
 	static const char* targets[] =
 	{
 		"element_array",	// TARGET_ELEMENT_ARRAY = 0,
 		"array"				// TARGET_ARRAY,
 	};
-	DE_STATIC_ASSERT(DE_LENGTH_OF_ARRAY(targets) == DrawTestSpec::TARGET_LAST);
 
-	return targets[(int)target];
+	return de::getSizedArrayElement<DrawTestSpec::TARGET_LAST>(targets, (int)target);
 }
 
 std::string DrawTestSpec::inputTypeToString(InputType type)
 {
-	DE_ASSERT(type < INPUTTYPE_LAST);
-
 	static const char* types[] =
 	{
 		"float",			// INPUTTYPE_FLOAT = 0,
@@ -2367,15 +2347,12 @@
 		"unsigned_int2_10_10_10",	// INPUTTYPE_UNSIGNED_INT_2_10_10_10,
 		"int2_10_10_10"				// INPUTTYPE_INT_2_10_10_10,
 	};
-	DE_STATIC_ASSERT(DE_LENGTH_OF_ARRAY(types) == DrawTestSpec::INPUTTYPE_LAST);
 
-	return types[(int)type];
+	return de::getSizedArrayElement<DrawTestSpec::INPUTTYPE_LAST>(types, (int)type);
 }
 
 std::string DrawTestSpec::outputTypeToString(OutputType type)
 {
-	DE_ASSERT(type < OUTPUTTYPE_LAST);
-
 	static const char* types[] =
 	{
 		"float",		// OUTPUTTYPE_FLOAT = 0,
@@ -2394,15 +2371,12 @@
 		"uvec3",		// OUTPUTTYPE_UVEC3,
 		"uvec4",		// OUTPUTTYPE_UVEC4,
 	};
-	DE_STATIC_ASSERT(DE_LENGTH_OF_ARRAY(types) == DrawTestSpec::OUTPUTTYPE_LAST);
 
-	return types[(int)type];
+	return de::getSizedArrayElement<DrawTestSpec::OUTPUTTYPE_LAST>(types, (int)type);
 }
 
 std::string DrawTestSpec::usageTypeToString(Usage usage)
 {
-	DE_ASSERT(usage < USAGE_LAST);
-
 	static const char* usages[] =
 	{
 		"dynamic_draw",	// USAGE_DYNAMIC_DRAW = 0,
@@ -2418,29 +2392,23 @@
 		"dynamic_read",	// USAGE_DYNAMIC_READ,
 		"dynamic_copy",	// USAGE_DYNAMIC_COPY,
 	};
-	DE_STATIC_ASSERT(DE_LENGTH_OF_ARRAY(usages) == DrawTestSpec::USAGE_LAST);
 
-	return usages[(int)usage];
+	return de::getSizedArrayElement<DrawTestSpec::USAGE_LAST>(usages, (int)usage);
 }
 
 std::string	DrawTestSpec::storageToString (Storage storage)
 {
-	DE_ASSERT(storage < STORAGE_LAST);
-
 	static const char* storages[] =
 	{
 		"user_ptr",	// STORAGE_USER = 0,
 		"buffer"	// STORAGE_BUFFER,
 	};
-	DE_STATIC_ASSERT(DE_LENGTH_OF_ARRAY(storages) == DrawTestSpec::STORAGE_LAST);
 
-	return storages[(int)storage];
+	return de::getSizedArrayElement<DrawTestSpec::STORAGE_LAST>(storages, (int)storage);
 }
 
 std::string DrawTestSpec::primitiveToString (Primitive primitive)
 {
-	DE_ASSERT(primitive < PRIMITIVE_LAST);
-
 	static const char* primitives[] =
 	{
 		"points",					// PRIMITIVE_POINTS ,
@@ -2455,30 +2423,24 @@
 		"triangles_adjacency",		// PRIMITIVE_TRIANGLES_ADJACENCY
 		"triangle_strip_adjacency",	// PRIMITIVE_TRIANGLE_STRIP_ADJACENCY
 	};
-	DE_STATIC_ASSERT(DE_LENGTH_OF_ARRAY(primitives) == DrawTestSpec::PRIMITIVE_LAST);
 
-	return primitives[(int)primitive];
+	return de::getSizedArrayElement<DrawTestSpec::PRIMITIVE_LAST>(primitives, (int)primitive);
 }
 
 std::string DrawTestSpec::indexTypeToString (IndexType type)
 {
-	DE_ASSERT(type < DrawTestSpec::INDEXTYPE_LAST);
-
 	static const char* indexTypes[] =
 	{
 		"byte",		// INDEXTYPE_BYTE = 0,
 		"short",	// INDEXTYPE_SHORT,
 		"int",		// INDEXTYPE_INT,
 	};
-	DE_STATIC_ASSERT(DE_LENGTH_OF_ARRAY(indexTypes) == DrawTestSpec::INDEXTYPE_LAST);
 
-	return indexTypes[(int)type];
+	return de::getSizedArrayElement<DrawTestSpec::INDEXTYPE_LAST>(indexTypes, (int)type);
 }
 
 std::string DrawTestSpec::drawMethodToString (DrawTestSpec::DrawMethod method)
 {
-	DE_ASSERT(method < DrawTestSpec::DRAWMETHOD_LAST);
-
 	static const char* methods[] =
 	{
 		"draw_arrays",							//!< DRAWMETHOD_DRAWARRAYS
@@ -2492,15 +2454,12 @@
 		"draw_elements_instanced_base_vertex",	//!< DRAWMETHOD_DRAWELEMENTS_INSTANCED_BASEVERTEX,
 		"draw_range_elements_base_vertex",		//!< DRAWMETHOD_DRAWELEMENTS_RANGED_BASEVERTEX,
 	};
-	DE_STATIC_ASSERT(DE_LENGTH_OF_ARRAY(methods) == DrawTestSpec::DRAWMETHOD_LAST);
 
-	return methods[(int)method];
+	return de::getSizedArrayElement<DrawTestSpec::DRAWMETHOD_LAST>(methods, (int)method);
 }
 
 int DrawTestSpec::inputTypeSize (InputType type)
 {
-	DE_ASSERT(type < INPUTTYPE_LAST);
-
 	static const int size[] =
 	{
 		sizeof(float),		// INPUTTYPE_FLOAT = 0,
@@ -2519,24 +2478,20 @@
 		sizeof(deUint32) / 4,		// INPUTTYPE_UNSIGNED_INT_2_10_10_10,
 		sizeof(deUint32) / 4		// INPUTTYPE_INT_2_10_10_10,
 	};
-	DE_STATIC_ASSERT(DE_LENGTH_OF_ARRAY(size) == DrawTestSpec::INPUTTYPE_LAST);
 
-	return size[(int)type];
+	return de::getSizedArrayElement<DrawTestSpec::INPUTTYPE_LAST>(size, (int)type);
 }
 
 int DrawTestSpec::indexTypeSize (IndexType type)
 {
-	DE_ASSERT(type < INDEXTYPE_LAST);
-
 	static const int size[] =
 	{
 		sizeof(deUint8),	// INDEXTYPE_BYTE,
 		sizeof(deUint16),	// INDEXTYPE_SHORT,
 		sizeof(deUint32),	// INDEXTYPE_INT,
 	};
-	DE_STATIC_ASSERT(DE_LENGTH_OF_ARRAY(size) == DrawTestSpec::INDEXTYPE_LAST);
 
-	return size[(int)type];
+	return de::getSizedArrayElement<DrawTestSpec::INDEXTYPE_LAST>(size, (int)type);
 }
 
 std::string DrawTestSpec::getName (void) const
@@ -3546,6 +3501,16 @@
 	return false;
 }
 
+static inline bool colorsEqual (const tcu::RGBA& colorA, const tcu::RGBA& colorB, const tcu::IVec3& compareThreshold)
+{
+	enum
+	{
+		TCU_RGBA_RGB_MASK = tcu::RGBA::RED_MASK | tcu::RGBA::GREEN_MASK | tcu::RGBA::BLUE_MASK
+	};
+
+	return tcu::compareThresholdMasked(colorA, colorB, tcu::RGBA(compareThreshold.x(), compareThreshold.y(), compareThreshold.z(), 0), TCU_RGBA_RGB_MASK);
+}
+
 // search 3x3 are for matching color
 static bool pixelNeighborhoodContainsColor (const tcu::Surface& target, int x, int y, const tcu::RGBA& color, const tcu::IVec3& compareThreshold)
 {
@@ -3556,12 +3521,8 @@
 	for (int dy = -1; dy < 2; dy++)
 	for (int dx = -1; dx < 2; dx++)
 	{
-		const tcu::RGBA	targetCmpPixel	= target.getPixel(x+dx, y+dy);
-		const int		r				= deAbs32(color.getRed()	- targetCmpPixel.getRed());
-		const int		g				= deAbs32(color.getGreen()	- targetCmpPixel.getGreen());
-		const int		b				= deAbs32(color.getBlue()	- targetCmpPixel.getBlue());
-
-		if (r <= compareThreshold.x() && g <= compareThreshold.y() && b <= compareThreshold.z())
+		const tcu::RGBA	targetCmpPixel = target.getPixel(x+dx, y+dy);
+		if (colorsEqual(color, targetCmpPixel, compareThreshold))
 			return true;
 	}
 
@@ -3590,19 +3551,20 @@
 {
 	DE_ASSERT(result.getWidth() == reference.getWidth() && result.getHeight() == reference.getHeight());
 
-	const tcu::IVec4	green						(0, 255, 0, 255);
-	const tcu::IVec4	errorColor					(255, 0, 0, 255);
-	const int			width						= reference.getWidth();
-	const int			height						= reference.getHeight();
-	tcu::TextureLevel	errorMask					(tcu::TextureFormat(tcu::TextureFormat::RGB, tcu::TextureFormat::UNORM_INT8), width, height);
-	int					numFailingPixels			= 0;
+	const tcu::IVec4				green						(0, 255, 0, 255);
+	const tcu::IVec4				red							(255, 0, 0, 255);
+	const int						width						= reference.getWidth();
+	const int						height						= reference.getHeight();
+	tcu::TextureLevel				errorMask					(tcu::TextureFormat(tcu::TextureFormat::RGB, tcu::TextureFormat::UNORM_INT8), width, height);
+	const tcu::PixelBufferAccess	errorAccess					= errorMask.getAccess();
+	int								numFailingPixels			= 0;
 
 	// clear errormask edges which would otherwise be transparent
 
-	tcu::clear(tcu::getSubregion(errorMask.getAccess(), 0,			0,			width,	1),			green);
-	tcu::clear(tcu::getSubregion(errorMask.getAccess(), 0,			height-1,	width,	1),			green);
-	tcu::clear(tcu::getSubregion(errorMask.getAccess(), 0,			0,			1,		height),	green);
-	tcu::clear(tcu::getSubregion(errorMask.getAccess(), width-1,	0,			1,		height),	green);
+	tcu::clear(tcu::getSubregion(errorAccess, 0,			0,			width,	1),			green);
+	tcu::clear(tcu::getSubregion(errorAccess, 0,			height-1,	width,	1),			green);
+	tcu::clear(tcu::getSubregion(errorAccess, 0,			0,			1,		height),	green);
+	tcu::clear(tcu::getSubregion(errorAccess, width-1,		0,			1,		height),	green);
 
 	// skip edge pixels since coverage on edge cannot be verified
 
@@ -3611,19 +3573,20 @@
 	{
 		const tcu::RGBA	refPixel			= reference.getPixel(x, y);
 		const tcu::RGBA	screenPixel			= result.getPixel(x, y);
-		const bool		isOkReferencePixel	= pixelNeighborhoodContainsColor(result, x, y, refPixel, compareThreshold);			// screen image has a matching pixel nearby (~= If something is drawn on reference, it must be drawn to screen too.)
-		const bool		isOkScreenPixel		= pixelNeighborhoodContainsColor(reference, x, y, screenPixel, compareThreshold);	// reference image has a matching pixel nearby (~= If something is drawn on screen, it must be drawn to reference too.)
+		const bool		directMatch			= colorsEqual(refPixel, screenPixel, compareThreshold);
+		const bool		isOkReferencePixel	= directMatch || pixelNeighborhoodContainsColor(result, x, y, refPixel, compareThreshold);			// screen image has a matching pixel nearby (~= If something is drawn on reference, it must be drawn to screen too.)
+		const bool		isOkScreenPixel		= directMatch || pixelNeighborhoodContainsColor(reference, x, y, screenPixel, compareThreshold);	// reference image has a matching pixel nearby (~= If something is drawn on screen, it must be drawn to reference too.)
 
 		if (isOkScreenPixel && isOkReferencePixel)
 		{
 			// pixel valid, write greenish pixels to make the result image easier to read
 			const deUint32 grayscaleValue = getVisualizationGrayscaleColor(screenPixel);
-			errorMask.getAccess().setPixel(tcu::UVec4(grayscaleValue, 255, grayscaleValue, 255), x, y);
+			errorAccess.setPixel(tcu::UVec4(grayscaleValue, 255, grayscaleValue, 255), x, y);
 		}
 		else if (!pixelNearEdge(x, y, reference, renderTargetThreshold))
 		{
 			// non-edge pixel values must be within threshold of the reference values
-			errorMask.getAccess().setPixel(errorColor, x, y);
+			errorAccess.setPixel(red, x, y);
 			++numFailingPixels;
 		}
 		else
@@ -3638,12 +3601,12 @@
 			{
 				// pixel valid, write greenish pixels to make the result image easier to read
 				const deUint32 grayscaleValue = getVisualizationGrayscaleColor(screenPixel);
-				errorMask.getAccess().setPixel(tcu::UVec4(grayscaleValue, 255, grayscaleValue, 255), x, y);
+				errorAccess.setPixel(tcu::UVec4(grayscaleValue, 255, grayscaleValue, 255), x, y);
 			}
 			else
 			{
 				// coverage does not match
-				errorMask.getAccess().setPixel(errorColor, x, y);
+				errorAccess.setPixel(red, x, y);
 				++numFailingPixels;
 			}
 		}
@@ -3683,19 +3646,20 @@
 {
 	DE_ASSERT(result.getWidth() == reference.getWidth() && result.getHeight() == reference.getHeight());
 
-	const tcu::IVec4	green						(0, 255, 0, 255);
-	const tcu::IVec4	errorColor					(255, 0, 0, 255);
-	const int			width						= reference.getWidth();
-	const int			height						= reference.getHeight();
-	tcu::TextureLevel	errorMask					(tcu::TextureFormat(tcu::TextureFormat::RGB, tcu::TextureFormat::UNORM_INT8), width, height);
-	int					numFailingPixels			= 0;
+	const tcu::IVec4				green						(0, 255, 0, 255);
+	const tcu::IVec4				red							(255, 0, 0, 255);
+	const int						width						= reference.getWidth();
+	const int						height						= reference.getHeight();
+	tcu::TextureLevel				errorMask					(tcu::TextureFormat(tcu::TextureFormat::RGB, tcu::TextureFormat::UNORM_INT8), width, height);
+	const tcu::PixelBufferAccess	errorAccess					= errorMask.getAccess();
+	int								numFailingPixels			= 0;
 
 	// clear errormask edges which would otherwise be transparent
 
-	tcu::clear(tcu::getSubregion(errorMask.getAccess(), 0,			0,			width,	1),			green);
-	tcu::clear(tcu::getSubregion(errorMask.getAccess(), 0,			height-1,	width,	1),			green);
-	tcu::clear(tcu::getSubregion(errorMask.getAccess(), 0,			0,			1,		height),	green);
-	tcu::clear(tcu::getSubregion(errorMask.getAccess(), width-1,	0,			1,		height),	green);
+	tcu::clear(tcu::getSubregion(errorAccess, 0,			0,			width,	1),			green);
+	tcu::clear(tcu::getSubregion(errorAccess, 0,			height-1,	width,	1),			green);
+	tcu::clear(tcu::getSubregion(errorAccess, 0,			0,			1,		height),	green);
+	tcu::clear(tcu::getSubregion(errorAccess, width-1,		0,			1,		height),	green);
 
 	// skip edge pixels since coverage on edge cannot be verified
 
@@ -3704,20 +3668,21 @@
 	{
 		const tcu::RGBA	refPixel			= reference.getPixel(x, y);
 		const tcu::RGBA	screenPixel			= result.getPixel(x, y);
-		const bool		isOkScreenPixel		= pixelNeighborhoodContainsColor(reference, x, y, screenPixel, compareThreshold);	// reference image has a matching pixel nearby (~= If something is drawn on screen, it must be drawn to reference too.)
-		const bool		isOkReferencePixel	= pixelNeighborhoodContainsColor(result, x, y, refPixel, compareThreshold);			// screen image has a matching pixel nearby (~= If something is drawn on reference, it must be drawn to screen too.)
+		const bool		directMatch			= colorsEqual(refPixel, screenPixel, compareThreshold);
+		const bool		isOkScreenPixel		= directMatch || pixelNeighborhoodContainsColor(reference, x, y, screenPixel, compareThreshold);	// reference image has a matching pixel nearby (~= If something is drawn on screen, it must be drawn to reference too.)
+		const bool		isOkReferencePixel	= directMatch || pixelNeighborhoodContainsColor(result, x, y, refPixel, compareThreshold);			// screen image has a matching pixel nearby (~= If something is drawn on reference, it must be drawn to screen too.)
 
 		if (isOkScreenPixel && isOkReferencePixel)
 		{
 			// pixel valid, write greenish pixels to make the result image easier to read
 			const deUint32 grayscaleValue = getVisualizationGrayscaleColor(screenPixel);
-			errorMask.getAccess().setPixel(tcu::UVec4(grayscaleValue, 255, grayscaleValue, 255), x, y);
+			errorAccess.setPixel(tcu::UVec4(grayscaleValue, 255, grayscaleValue, 255), x, y);
 		}
 		else if (!pixelNearLineIntersection(x, y, reference) &&
 				 !pixelNearLineIntersection(x, y, result))
 		{
 			// non-intersection pixel values must be within threshold of the reference values
-			errorMask.getAccess().setPixel(errorColor, x, y);
+			errorAccess.setPixel(red, x, y);
 			++numFailingPixels;
 		}
 		else
@@ -3733,12 +3698,12 @@
 			{
 				// pixel valid, write greenish pixels to make the result image easier to read
 				const deUint32 grayscaleValue = getVisualizationGrayscaleColor(screenPixel);
-				errorMask.getAccess().setPixel(tcu::UVec4(grayscaleValue, 255, grayscaleValue, 255), x, y);
+				errorAccess.setPixel(tcu::UVec4(grayscaleValue, 255, grayscaleValue, 255), x, y);
 			}
 			else
 			{
 				// coverage does not match
-				errorMask.getAccess().setPixel(errorColor, x, y);
+				errorAccess.setPixel(red, x, y);
 				++numFailingPixels;
 			}
 		}
diff --git a/modules/glshared/glsTextureTestUtil.cpp b/modules/glshared/glsTextureTestUtil.cpp
index cae9d87..438ba02 100644
--- a/modules/glshared/glsTextureTestUtil.cpp
+++ b/modules/glshared/glsTextureTestUtil.cpp
@@ -50,6 +50,11 @@
 namespace TextureTestUtil
 {
 
+enum
+{
+	MIN_SUBPIXEL_BITS	= 4
+};
+
 SamplerType getSamplerType (tcu::TextureFormat format)
 {
 	using tcu::TextureFormat;
@@ -1985,7 +1990,7 @@
 
 	const tcu::Vec2		lodBias			((sampleParams.flags & ReferenceParams::USE_BIAS) ? sampleParams.bias : 0.0f);
 
-	const float			posEps			= 1.0f / float((1<<4) + 1); // ES3 requires at least 4 subpixel bits.
+	const float			posEps			= 1.0f / float((1<<MIN_SUBPIXEL_BITS) + 1);
 
 	int					numFailed		= 0;
 
@@ -2000,7 +2005,7 @@
 		tcu::Vec2(-1, -1),
 		tcu::Vec2(-1, +1),
 		tcu::Vec2(+1, -1),
-		tcu::Vec2(+1, -1),
+		tcu::Vec2(+1, +1),
 	};
 
 	tcu::clear(errorMask, tcu::RGBA::green.toVec());
@@ -2164,6 +2169,8 @@
 
 	const tcu::Vec2		lodBias			((sampleParams.flags & ReferenceParams::USE_BIAS) ? sampleParams.bias : 0.0f);
 
+	const float			posEps			= 1.0f / float((1<<MIN_SUBPIXEL_BITS) + 1);
+
 	int					numFailed		= 0;
 
 	const tcu::Vec2 lodOffsets[] =
@@ -2195,50 +2202,65 @@
 				const float		nx		= wx / dstW;
 				const float		ny		= wy / dstH;
 
-				const int		triNdx	= nx + ny >= 1.0f ? 1 : 0;
-				const float		triWx	= triNdx ? dstW - wx : wx;
-				const float		triWy	= triNdx ? dstH - wy : wy;
-				const float		triNx	= triNdx ? 1.0f - nx : nx;
-				const float		triNy	= triNdx ? 1.0f - ny : ny;
+				const bool		tri0	= nx + ny - posEps <= 1.0f;
+				const bool		tri1	= nx + ny + posEps >= 1.0f;
 
-				const tcu::Vec3	coord		(projectedTriInterpolate(triS[triNdx], triW[triNdx], triNx, triNy),
-											 projectedTriInterpolate(triT[triNdx], triW[triNdx], triNx, triNy),
-											 projectedTriInterpolate(triR[triNdx], triW[triNdx], triNx, triNy));
-				const tcu::Vec3	coordDx		= tcu::Vec3(triDerivateX(triS[triNdx], triW[triNdx], wx, dstW, triNy),
-														triDerivateX(triT[triNdx], triW[triNdx], wx, dstW, triNy),
-														triDerivateX(triR[triNdx], triW[triNdx], wx, dstW, triNy)) * srcSize.asFloat();
-				const tcu::Vec3	coordDy		= tcu::Vec3(triDerivateY(triS[triNdx], triW[triNdx], wy, dstH, triNx),
-														triDerivateY(triT[triNdx], triW[triNdx], wy, dstH, triNx),
-														triDerivateY(triR[triNdx], triW[triNdx], wy, dstH, triNx)) * srcSize.asFloat();
+				bool			isOk	= false;
 
-				tcu::Vec2		lodBounds	= tcu::computeLodBoundsFromDerivates(coordDx.x(), coordDx.y(), coordDx.z(), coordDy.x(), coordDy.y(), coordDy.z(), lodPrec);
+				DE_ASSERT(tri0 || tri1);
 
-				// Compute lod bounds across lodOffsets range.
-				for (int lodOffsNdx = 0; lodOffsNdx < DE_LENGTH_OF_ARRAY(lodOffsets); lodOffsNdx++)
+				// Pixel can belong to either of the triangles if it lies close enough to the edge.
+				for (int triNdx = (tri0?0:1); triNdx <= (tri1?1:0); triNdx++)
 				{
-					const float		wxo		= triWx + lodOffsets[lodOffsNdx].x();
-					const float		wyo		= triWy + lodOffsets[lodOffsNdx].y();
-					const float		nxo		= wxo/dstW;
-					const float		nyo		= wyo/dstH;
+					const float		triWx	= triNdx ? dstW - wx : wx;
+					const float		triWy	= triNdx ? dstH - wy : wy;
+					const float		triNx	= triNdx ? 1.0f - nx : nx;
+					const float		triNy	= triNdx ? 1.0f - ny : ny;
 
-					const tcu::Vec3	coordO		(projectedTriInterpolate(triS[triNdx], triW[triNdx], nxo, nyo),
-												 projectedTriInterpolate(triT[triNdx], triW[triNdx], nxo, nyo),
-												 projectedTriInterpolate(triR[triNdx], triW[triNdx], nxo, nyo));
-					const tcu::Vec3	coordDxo	= tcu::Vec3(triDerivateX(triS[triNdx], triW[triNdx], wxo, dstW, nyo),
-															triDerivateX(triT[triNdx], triW[triNdx], wxo, dstW, nyo),
-															triDerivateX(triR[triNdx], triW[triNdx], wxo, dstW, nyo)) * srcSize.asFloat();
-					const tcu::Vec3	coordDyo	= tcu::Vec3(triDerivateY(triS[triNdx], triW[triNdx], wyo, dstH, nxo),
-															triDerivateY(triT[triNdx], triW[triNdx], wyo, dstH, nxo),
-															triDerivateY(triR[triNdx], triW[triNdx], wyo, dstH, nxo)) * srcSize.asFloat();
-					const tcu::Vec2	lodO		= tcu::computeLodBoundsFromDerivates(coordDxo.x(), coordDxo.y(), coordDxo.z(), coordDyo.x(), coordDyo.y(), coordDyo.z(), lodPrec);
+					const tcu::Vec3	coord		(projectedTriInterpolate(triS[triNdx], triW[triNdx], triNx, triNy),
+												 projectedTriInterpolate(triT[triNdx], triW[triNdx], triNx, triNy),
+												 projectedTriInterpolate(triR[triNdx], triW[triNdx], triNx, triNy));
+					const tcu::Vec3	coordDx		= tcu::Vec3(triDerivateX(triS[triNdx], triW[triNdx], wx, dstW, triNy),
+															triDerivateX(triT[triNdx], triW[triNdx], wx, dstW, triNy),
+															triDerivateX(triR[triNdx], triW[triNdx], wx, dstW, triNy)) * srcSize.asFloat();
+					const tcu::Vec3	coordDy		= tcu::Vec3(triDerivateY(triS[triNdx], triW[triNdx], wy, dstH, triNx),
+															triDerivateY(triT[triNdx], triW[triNdx], wy, dstH, triNx),
+															triDerivateY(triR[triNdx], triW[triNdx], wy, dstH, triNx)) * srcSize.asFloat();
 
-					lodBounds.x() = de::min(lodBounds.x(), lodO.x());
-					lodBounds.y() = de::max(lodBounds.y(), lodO.y());
+					tcu::Vec2		lodBounds	= tcu::computeLodBoundsFromDerivates(coordDx.x(), coordDx.y(), coordDx.z(), coordDy.x(), coordDy.y(), coordDy.z(), lodPrec);
+
+					// Compute lod bounds across lodOffsets range.
+					for (int lodOffsNdx = 0; lodOffsNdx < DE_LENGTH_OF_ARRAY(lodOffsets); lodOffsNdx++)
+					{
+						const float		wxo		= triWx + lodOffsets[lodOffsNdx].x();
+						const float		wyo		= triWy + lodOffsets[lodOffsNdx].y();
+						const float		nxo		= wxo/dstW;
+						const float		nyo		= wyo/dstH;
+
+						const tcu::Vec3	coordO		(projectedTriInterpolate(triS[triNdx], triW[triNdx], nxo, nyo),
+													 projectedTriInterpolate(triT[triNdx], triW[triNdx], nxo, nyo),
+													 projectedTriInterpolate(triR[triNdx], triW[triNdx], nxo, nyo));
+						const tcu::Vec3	coordDxo	= tcu::Vec3(triDerivateX(triS[triNdx], triW[triNdx], wxo, dstW, nyo),
+																triDerivateX(triT[triNdx], triW[triNdx], wxo, dstW, nyo),
+																triDerivateX(triR[triNdx], triW[triNdx], wxo, dstW, nyo)) * srcSize.asFloat();
+						const tcu::Vec3	coordDyo	= tcu::Vec3(triDerivateY(triS[triNdx], triW[triNdx], wyo, dstH, nxo),
+																triDerivateY(triT[triNdx], triW[triNdx], wyo, dstH, nxo),
+																triDerivateY(triR[triNdx], triW[triNdx], wyo, dstH, nxo)) * srcSize.asFloat();
+						const tcu::Vec2	lodO		= tcu::computeLodBoundsFromDerivates(coordDxo.x(), coordDxo.y(), coordDxo.z(), coordDyo.x(), coordDyo.y(), coordDyo.z(), lodPrec);
+
+						lodBounds.x() = de::min(lodBounds.x(), lodO.x());
+						lodBounds.y() = de::max(lodBounds.y(), lodO.y());
+					}
+
+					const tcu::Vec2	clampedLod	= tcu::clampLodBounds(lodBounds + lodBias, tcu::Vec2(sampleParams.minLod, sampleParams.maxLod), lodPrec);
+
+					if (tcu::isLookupResultValid(src, sampleParams.sampler, lookupPrec, coord, clampedLod, resPix))
+					{
+						isOk = true;
+						break;
+					}
 				}
 
-				const tcu::Vec2	clampedLod	= tcu::clampLodBounds(lodBounds + lodBias, tcu::Vec2(sampleParams.minLod, sampleParams.maxLod), lodPrec);
-				const bool		isOk		= tcu::isLookupResultValid(src, sampleParams.sampler, lookupPrec, coord, clampedLod, resPix);
-
 				if (!isOk)
 				{
 					errorMask.setPixel(tcu::RGBA::red.toVec(), px, py);
@@ -2631,7 +2653,7 @@
 		tcu::Vec2(-1, -1),
 		tcu::Vec2(-1, +1),
 		tcu::Vec2(+1, -1),
-		tcu::Vec2(+1, -1),
+		tcu::Vec2(+1, +1),
 	};
 
 	tcu::clear(errorMask, tcu::RGBA::green.toVec());
diff --git a/modules/glshared/glsVertexArrayTests.cpp b/modules/glshared/glsVertexArrayTests.cpp
index 919e702..8b6fcff 100644
--- a/modules/glshared/glsVertexArrayTests.cpp
+++ b/modules/glshared/glsVertexArrayTests.cpp
@@ -65,22 +65,17 @@
 
 std::string Array::targetToString(Target target)
 {
-	DE_ASSERT(target < TARGET_LAST);
-
 	static const char* targets[] =
 	{
 		"element_array",	// TARGET_ELEMENT_ARRAY = 0,
 		"array"				// TARGET_ARRAY,
 	};
-	DE_STATIC_ASSERT(DE_LENGTH_OF_ARRAY(targets) == Array::TARGET_LAST);
 
-	return targets[(int)target];
+	return de::getSizedArrayElement<Array::TARGET_LAST>(targets, (int)target);
 }
 
 std::string Array::inputTypeToString(InputType type)
 {
-	DE_ASSERT(type < INPUTTYPE_LAST);
-
 	static const char* types[] =
 	{
 		"float",			// INPUTTYPE_FLOAT = 0,
@@ -99,15 +94,12 @@
 		"usigned_int2_10_10_10",	// INPUTTYPE_UNSIGNED_INT_2_10_10_10,
 		"int2_10_10_10"				// INPUTTYPE_INT_2_10_10_10,
 	};
-	DE_STATIC_ASSERT(DE_LENGTH_OF_ARRAY(types) == Array::INPUTTYPE_LAST);
 
-	return types[(int)type];
+	return de::getSizedArrayElement<Array::INPUTTYPE_LAST>(types, (int)type);
 }
 
 std::string Array::outputTypeToString(OutputType type)
 {
-	DE_ASSERT(type < OUTPUTTYPE_LAST);
-
 	static const char* types[] =
 	{
 		"float",		// OUTPUTTYPE_FLOAT = 0,
@@ -126,15 +118,12 @@
 		"uvec3",		// OUTPUTTYPE_UVEC3,
 		"uvec4",		// OUTPUTTYPE_UVEC4,
 	};
-	DE_STATIC_ASSERT(DE_LENGTH_OF_ARRAY(types) == Array::OUTPUTTYPE_LAST);
 
-	return types[(int)type];
+	return de::getSizedArrayElement<Array::OUTPUTTYPE_LAST>(types, (int)type);
 }
 
 std::string Array::usageTypeToString(Usage usage)
 {
-	DE_ASSERT(usage < USAGE_LAST);
-
 	static const char* usages[] =
 	{
 		"dynamic_draw",	// USAGE_DYNAMIC_DRAW = 0,
@@ -150,29 +139,23 @@
 		"dynamic_read",	// USAGE_DYNAMIC_READ,
 		"dynamic_copy",	// USAGE_DYNAMIC_COPY,
 	};
-	DE_STATIC_ASSERT(DE_LENGTH_OF_ARRAY(usages) == Array::USAGE_LAST);
 
-	return usages[(int)usage];
+	return de::getSizedArrayElement<Array::USAGE_LAST>(usages, (int)usage);
 }
 
 std::string	Array::storageToString (Storage storage)
 {
-	DE_ASSERT(storage < STORAGE_LAST);
-
 	static const char* storages[] =
 	{
 		"user_ptr",	// STORAGE_USER = 0,
 		"buffer"	// STORAGE_BUFFER,
 	};
-	DE_STATIC_ASSERT(DE_LENGTH_OF_ARRAY(storages) == Array::STORAGE_LAST);
 
-	return storages[(int)storage];
+	return de::getSizedArrayElement<Array::STORAGE_LAST>(storages, (int)storage);
 }
 
 std::string Array::primitiveToString (Primitive primitive)
 {
-	DE_ASSERT(primitive < PRIMITIVE_LAST);
-
 	static const char* primitives[] =
 	{
 		"points",			// PRIMITIVE_POINTS ,
@@ -180,15 +163,12 @@
 		"triangle_fan",		// PRIMITIVE_TRIANGLE_FAN,
 		"triangle_strip"	// PRIMITIVE_TRIANGLE_STRIP,
 	};
-	DE_STATIC_ASSERT(DE_LENGTH_OF_ARRAY(primitives) == Array::PRIMITIVE_LAST);
 
-	return primitives[(int)primitive];
+	return de::getSizedArrayElement<Array::PRIMITIVE_LAST>(primitives, (int)primitive);
 }
 
 int Array::inputTypeSize (InputType type)
 {
-	DE_ASSERT(type < INPUTTYPE_LAST);
-
 	static const int size[] =
 	{
 		sizeof(float),		// INPUTTYPE_FLOAT = 0,
@@ -207,9 +187,8 @@
 		sizeof(deUint32) / 4,		// INPUTTYPE_UNSIGNED_INT_2_10_10_10,
 		sizeof(deUint32) / 4		// INPUTTYPE_INT_2_10_10_10,
 	};
-	DE_STATIC_ASSERT(DE_LENGTH_OF_ARRAY(size) == Array::INPUTTYPE_LAST);
 
-	return size[(int)type];
+	return de::getSizedArrayElement<Array::INPUTTYPE_LAST>(size, (int)type);
 }
 
 static bool inputTypeIsFloatType (Array::InputType type)
@@ -648,21 +627,17 @@
 
 GLenum ContextArray::targetToGL (Array::Target target)
 {
-	DE_ASSERT(target < TARGET_LAST);
-
 	static const GLenum targets[] =
 	{
 		GL_ELEMENT_ARRAY_BUFFER,	// TARGET_ELEMENT_ARRAY = 0,
 		GL_ARRAY_BUFFER				// TARGET_ARRAY,
 	};
 
-	return targets[(int)target];
+	return de::getSizedArrayElement<Array::TARGET_LAST>(targets, (int)target);
 }
 
 GLenum ContextArray::usageToGL (Array::Usage usage)
 {
-	DE_ASSERT(usage < USAGE_LAST);
-
 	static const GLenum usages[] =
 	{
 		GL_DYNAMIC_DRAW,	// USAGE_DYNAMIC_DRAW = 0,
@@ -678,15 +653,12 @@
 		GL_DYNAMIC_READ,	// USAGE_DYNAMIC_READ,
 		GL_DYNAMIC_COPY		// USAGE_DYNAMIC_COPY,
 	};
-	DE_STATIC_ASSERT(DE_LENGTH_OF_ARRAY(usages) == Array::USAGE_LAST);
 
-	return usages[(int)usage];
+	return de::getSizedArrayElement<Array::USAGE_LAST>(usages, (int)usage);
 }
 
 GLenum ContextArray::inputTypeToGL (Array::InputType type)
 {
-	DE_ASSERT(type < INPUTTYPE_LAST);
-
 	static const GLenum types[] =
 	{
 		GL_FLOAT,				// INPUTTYPE_FLOAT = 0,
@@ -703,15 +675,12 @@
 		GL_UNSIGNED_INT_2_10_10_10_REV, // INPUTTYPE_UNSIGNED_INT_2_10_10_10,
 		GL_INT_2_10_10_10_REV			// INPUTTYPE_INT_2_10_10_10,
 	};
-	DE_STATIC_ASSERT(DE_LENGTH_OF_ARRAY(types) == Array::INPUTTYPE_LAST);
 
-	return types[(int)type];
+	return de::getSizedArrayElement<Array::INPUTTYPE_LAST>(types, (int)type);
 }
 
 std::string ContextArray::outputTypeToGLType (Array::OutputType type)
 {
-	DE_ASSERT(type < OUTPUTTYPE_LAST);
-
 	static const char* types[] =
 	{
 		"float",		// OUTPUTTYPE_FLOAT = 0,
@@ -730,23 +699,21 @@
 		"uvec3",		// OUTPUTTYPE_UVEC3,
 		"uvec4",		// OUTPUTTYPE_UVEC4,
 	};
-	DE_STATIC_ASSERT(DE_LENGTH_OF_ARRAY(types) == Array::OUTPUTTYPE_LAST);
 
-	return types[type];
+	return de::getSizedArrayElement<Array::OUTPUTTYPE_LAST>(types, (int)type);
 }
 
 GLenum ContextArray::primitiveToGL (Array::Primitive primitive)
 {
-	GLenum primitives[] =
+	static const GLenum primitives[] =
 	{
 		GL_POINTS,			// PRIMITIVE_POINTS = 0,
 		GL_TRIANGLES,		// PRIMITIVE_TRIANGLES,
 		GL_TRIANGLE_FAN,	// PRIMITIVE_TRIANGLE_FAN,
 		GL_TRIANGLE_STRIP	// PRIMITIVE_TRIANGLE_STRIP,
 	};
-	DE_STATIC_ASSERT(DE_LENGTH_OF_ARRAY(primitives) == Array::PRIMITIVE_LAST);
 
-	return primitives[(int)primitive];
+	return de::getSizedArrayElement<Array::PRIMITIVE_LAST>(primitives, (int)primitive);
 }
 
 ContextArrayPack::ContextArrayPack (glu::RenderContext& renderCtx, sglr::Context& drawContext)
diff --git a/modules/internal/ditFrameworkTests.cpp b/modules/internal/ditFrameworkTests.cpp
index 0b5b1b5..ec8f241 100644
--- a/modules/internal/ditFrameworkTests.cpp
+++ b/modules/internal/ditFrameworkTests.cpp
@@ -23,6 +23,7 @@
 
 #include "ditFrameworkTests.hpp"
 #include "tcuFloatFormat.hpp"
+#include "tcuEither.hpp"
 #include "tcuTestLog.hpp"
 #include "tcuCommandLine.hpp"
 
@@ -556,7 +557,8 @@
 	{
 		addChild(new SelfCheckCase(m_testCtx, "float_format","tcu::FloatFormat_selfTest()",
 								   tcu::FloatFormat_selfTest));
-		addChild(new CaseListParserTests(m_testCtx));
+		addChild(new SelfCheckCase(m_testCtx, "either","tcu::Either_selfTest()",
+								   tcu::Either_selfTest));
 	}
 };
 
@@ -573,7 +575,8 @@
 
 void FrameworkTests::init (void)
 {
-	addChild(new CommonFrameworkTests(m_testCtx));
+	addChild(new CommonFrameworkTests	(m_testCtx));
+	addChild(new CaseListParserTests	(m_testCtx));
 }
 
 }
diff --git a/scripts/build/__init__.py b/scripts/build/__init__.py
index d7dcb59..fe50833 100644
--- a/scripts/build/__init__.py
+++ b/scripts/build/__init__.py
@@ -1,2 +1,23 @@
 # -*- coding: utf-8 -*-
+
+#-------------------------------------------------------------------------
+# drawElements Quality Program utilities
+# --------------------------------------
+#
+# Copyright 2015 The Android Open Source Project
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+#      http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+#
+#-------------------------------------------------------------------------
+
 __all__ = ['common', 'config', 'build']
diff --git a/scripts/build/build.py b/scripts/build/build.py
index 222c3bb..7732e12 100644
--- a/scripts/build/build.py
+++ b/scripts/build/build.py
@@ -1,5 +1,25 @@
 # -*- coding: utf-8 -*-
 
+#-------------------------------------------------------------------------
+# drawElements Quality Program utilities
+# --------------------------------------
+#
+# Copyright 2015 The Android Open Source Project
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+#      http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+#
+#-------------------------------------------------------------------------
+
 import os
 import sys
 
diff --git a/scripts/build/common.py b/scripts/build/common.py
index 8b39268..f3f327e 100644
--- a/scripts/build/common.py
+++ b/scripts/build/common.py
@@ -1,5 +1,25 @@
 # -*- coding: utf-8 -*-
 
+#-------------------------------------------------------------------------
+# drawElements Quality Program utilities
+# --------------------------------------
+#
+# Copyright 2015 The Android Open Source Project
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+#      http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+#
+#-------------------------------------------------------------------------
+
 import os
 import shlex
 import subprocess
diff --git a/scripts/build/config.py b/scripts/build/config.py
index 733a224..0e68a22 100644
--- a/scripts/build/config.py
+++ b/scripts/build/config.py
@@ -1,5 +1,25 @@
 # -*- coding: utf-8 -*-
 
+#-------------------------------------------------------------------------
+# drawElements Quality Program utilities
+# --------------------------------------
+#
+# Copyright 2015 The Android Open Source Project
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+#      http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+#
+#-------------------------------------------------------------------------
+
 import os
 import sys
 import copy
diff --git a/scripts/caselist_diff.py b/scripts/caselist_diff.py
index e56c192..6427de0 100644
--- a/scripts/caselist_diff.py
+++ b/scripts/caselist_diff.py
@@ -1,5 +1,25 @@
 # -*- coding: utf-8 -*-
 
+#-------------------------------------------------------------------------
+# drawElements Quality Program utilities
+# --------------------------------------
+#
+# Copyright 2015 The Android Open Source Project
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+#      http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+#
+#-------------------------------------------------------------------------
+
 import sys
 
 RENAME_LIST_2011_1_2011_2 = [
diff --git a/scripts/check_include_guards.py b/scripts/check_include_guards.py
index a28c877..085ba0c 100644
--- a/scripts/check_include_guards.py
+++ b/scripts/check_include_guards.py
@@ -1,5 +1,25 @@
 # -*- coding: utf-8 -*-
 
+#-------------------------------------------------------------------------
+# drawElements Quality Program utilities
+# --------------------------------------
+#
+# Copyright 2015 The Android Open Source Project
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+#      http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+#
+#-------------------------------------------------------------------------
+
 import os
 import sys
 from fnmatch import fnmatch
diff --git a/scripts/check_redundant_include_guards.py b/scripts/check_redundant_include_guards.py
index 71f7c8d..fb29487 100644
--- a/scripts/check_redundant_include_guards.py
+++ b/scripts/check_redundant_include_guards.py
@@ -1,5 +1,25 @@
 # -*- coding: utf-8 -*-
 
+#-------------------------------------------------------------------------
+# drawElements Quality Program utilities
+# --------------------------------------
+#
+# Copyright 2015 The Android Open Source Project
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+#      http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+#
+#-------------------------------------------------------------------------
+
 import os
 import sys
 from fnmatch import fnmatch
diff --git a/scripts/check_resolution_list.py b/scripts/check_resolution_list.py
index 5afcca3..4c5f123 100644
--- a/scripts/check_resolution_list.py
+++ b/scripts/check_resolution_list.py
@@ -1,5 +1,25 @@
 # -*- coding: utf-8 -*-
 
+#-------------------------------------------------------------------------
+# drawElements Quality Program utilities
+# --------------------------------------
+#
+# Copyright 2015 The Android Open Source Project
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+#      http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+#
+#-------------------------------------------------------------------------
+
 import re
 import sys
 from fnmatch import fnmatch
diff --git a/scripts/convert_case_list_to_xml.py b/scripts/convert_case_list_to_xml.py
index ebd545b..456e1a0 100644
--- a/scripts/convert_case_list_to_xml.py
+++ b/scripts/convert_case_list_to_xml.py
@@ -1,3 +1,23 @@
+#-------------------------------------------------------------------------
+# drawElements Quality Program utilities
+# --------------------------------------
+#
+# Copyright 2015 The Android Open Source Project
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+#      http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+#
+#-------------------------------------------------------------------------
+
 import re
 import sys
 from xml.dom.minidom import Document
diff --git a/scripts/cppcheck.py b/scripts/cppcheck.py
index e8ab756..8fd5b48 100644
--- a/scripts/cppcheck.py
+++ b/scripts/cppcheck.py
@@ -1,5 +1,25 @@
 # -*- coding: utf-8 -*-
 
+#-------------------------------------------------------------------------
+# drawElements Quality Program utilities
+# --------------------------------------
+#
+# Copyright 2015 The Android Open Source Project
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+#      http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+#
+#-------------------------------------------------------------------------
+
 import os
 import sys
 import shlex
diff --git a/scripts/egl/__init__.py b/scripts/egl/__init__.py
index c0c86d7..f170c8b 100644
--- a/scripts/egl/__init__.py
+++ b/scripts/egl/__init__.py
@@ -1,16 +1,42 @@
 # -*- coding: utf-8 -*-
 
-from common import getEGLRegistry, getInterface, getDefaultInterface
+#-------------------------------------------------------------------------
+# drawElements Quality Program utilities
+# --------------------------------------
+#
+# Copyright 2015 The Android Open Source Project
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+#      http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+#
+#-------------------------------------------------------------------------
+
+from common import getEGLRegistry, getInterface, getDefaultInterface, VERSION
 
 import str_util
 import call_log_wrapper
 import proc_address_tests
+import enums
+import func_ptrs
+import library
 
 def gen ():
 	registry	= getEGLRegistry()
 	iface		= getDefaultInterface()
-	noExtIface	= getInterface(registry, 'egl', '1.4')
+	noExtIface	= getInterface(registry, 'egl', VERSION)
 
 	str_util.gen(iface)
 	call_log_wrapper.gen(noExtIface)
 	proc_address_tests.gen()
+	enums.gen(iface)
+	func_ptrs.gen(iface)
+	library.gen(registry)
diff --git a/scripts/egl/call_log_wrapper.py b/scripts/egl/call_log_wrapper.py
index b7145c3..7841e46 100644
--- a/scripts/egl/call_log_wrapper.py
+++ b/scripts/egl/call_log_wrapper.py
@@ -6,12 +6,6 @@
 from common import *
 from khr_util.format import indentLines
 
-def genCommandList (iface, renderCommand, directory, filename, align=False):
-	lines = map(renderCommand, iface.commands)
-	if align:
-		lines = indentLines(lines)
-	writeInlFile(os.path.join(directory, filename), lines)
-
 class LogSpec:
 	def __init__ (self, argInPrints, argOutPrints = {}, returnPrint = None):
 		self.argInPrints	= argInPrints
@@ -49,8 +43,10 @@
 }
 
 def eglwPrefix (string):
-	# \note Not used for now
-	return string
+	if string[:5] == "__egl":
+		return "eglw::" + string
+	else:
+		return re.sub(r'\bEGL', 'eglw::EGL', string)
 
 def prefixedParams (command):
 	if len(command.params) > 0:
@@ -97,7 +93,7 @@
 	src += "\tif (m_enableLog)\n"
 	src += "\t\tm_log << TestLog::Message << %s;\n" % " << ".join(callPrintItems)
 
-	callStr = "::%s(%s)" % (command.name, ", ".join([p.name for p in command.params]))
+	callStr = "m_egl.%s(%s)" % (getFunctionMemberName(command.name), ", ".join([p.name for p in command.params]))
 
 	isVoid	= command.type == 'void'
 	if isVoid:
diff --git a/scripts/egl/common.py b/scripts/egl/common.py
index fa573cb..7ad2f33 100644
--- a/scripts/egl/common.py
+++ b/scripts/egl/common.py
@@ -1,5 +1,25 @@
 # -*- coding: utf-8 -*-
 
+#-------------------------------------------------------------------------
+# drawElements Quality Program utilities
+# --------------------------------------
+#
+# Copyright 2015 The Android Open Source Project
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+#      http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+#
+#-------------------------------------------------------------------------
+
 import os
 import re
 import sys
@@ -15,15 +35,34 @@
 
 SCRIPTS_DIR			= os.path.dirname(__file__)
 EGL_DIR				= os.path.normpath(os.path.join(SCRIPTS_DIR, "..", "..", "framework", "egl"))
+EGL_WRAPPER_DIR		= os.path.normpath(os.path.join(EGL_DIR, "wrapper"))
 
 EGL_SOURCE			= khr_util.registry_cache.RegistrySource(
 						"egl.xml",
 						28861,
 						"0e7e6381c4e518f915450fe5080c9b1307cbf3548999a74e2b7676de7b5e5a30")
 
+VERSION				= '1.5'
+
 EXTENSIONS			= [
+	# \todo [2014-12-05 pyry] Use 1.5 core functions/enums instead
 	"EGL_KHR_create_context",
-	"EGL_KHR_lock_surface"
+	"EGL_KHR_lock_surface",
+	"EGL_KHR_image_base",
+	"EGL_KHR_fence_sync",
+	"EGL_KHR_reusable_sync",
+	"EGL_KHR_wait_sync",
+	"EGL_KHR_gl_texture_2D_image",
+	"EGL_KHR_gl_texture_cubemap_image",
+	"EGL_KHR_gl_renderbuffer_image",
+	"EGL_KHR_gl_texture_3D_image",
+	"EGL_EXT_create_context_robustness",
+	"EGL_EXT_platform_base",
+	"EGL_EXT_platform_x11",
+	"EGL_ANDROID_image_native_buffer",
+]
+PROTECTS			= [
+	"KHRONOS_SUPPORT_INT64"
 ]
 
 def getEGLRegistry ():
@@ -34,7 +73,36 @@
 	return khr_util.registry.createInterface(registry, spec, api)
 
 def getDefaultInterface ():
-	return getInterface(getEGLRegistry(), 'egl', '1.4', extensionNames = EXTENSIONS)
+	return getInterface(getEGLRegistry(), 'egl', VERSION, extensionNames = EXTENSIONS, protects = PROTECTS)
+
+def getFunctionTypeName (funcName):
+	return "%sFunc" % funcName
+
+def getFunctionMemberName (funcName):
+	assert funcName[:3] == "egl"
+	return "%c%s" % (funcName[3].lower(), funcName[4:])
+
+def genCommandList (iface, renderCommand, directory, filename, align=False):
+	lines = map(renderCommand, iface.commands)
+	if align:
+		lines = khr_util.format.indentLines(lines)
+	writeInlFile(os.path.join(directory, filename), lines)
+
+def getVersionToken (version):
+	return version.replace(".", "")
+
+def genCommandLists (registry, renderCommand, check, directory, filePattern, align=False):
+	for eFeature in registry.features:
+		api			= eFeature.get('api')
+		version		= eFeature.get('number')
+		profile		= check(api, version)
+		if profile is True:
+			profile = None
+		elif profile is False:
+			continue
+		iface		= getInterface(registry, api, version=version, profile=profile)
+		filename	= filePattern % getVersionToken(version)
+		genCommandList(iface, renderCommand, directory, filename, align)
 
 INL_HEADER = khr_util.format.genInlHeader("Khronos EGL API description (egl.xml)", EGL_SOURCE.getRevision())
 
diff --git a/scripts/egl/enums.py b/scripts/egl/enums.py
new file mode 100644
index 0000000..c78e0a7
--- /dev/null
+++ b/scripts/egl/enums.py
@@ -0,0 +1,32 @@
+# -*- coding: utf-8 -*-
+
+import os
+import string
+
+from common import *
+from khr_util.format import indentLines, normalizeConstant
+
+TYPED_VALUES = [
+	"EGL_DONT_CARE",
+	"EGL_UNKNOWN",
+	"EGL_NO_CONTEXT",
+	"EGL_NO_DISPLAY",
+	"EGL_DEFAULT_DISPLAY",
+	"EGL_NO_SURFACE",
+	"EGL_NO_IMAGE",
+	"EGL_NO_SYNC",
+	"EGL_NO_IMAGE_KHR",
+	"EGL_NO_SYNC_KHR"
+]
+
+def enumValue (enum, typePrefix = ""):
+	if enum.name in TYPED_VALUES:
+		return enum.value.replace("(EGL", "(%sEGL" % typePrefix)
+	else:
+		return normalizeConstant(enum.value)
+
+def enumDefinition (enum):
+	return "#define %s\t%s" % (enum.name, enumValue(enum, "eglw::"))
+
+def gen (iface):
+	writeInlFile(os.path.join(EGL_WRAPPER_DIR, "eglwEnums.inl"), indentLines(map(enumDefinition, iface.enums)))
diff --git a/scripts/egl/func_ptrs.py b/scripts/egl/func_ptrs.py
new file mode 100644
index 0000000..024e9b1
--- /dev/null
+++ b/scripts/egl/func_ptrs.py
@@ -0,0 +1,18 @@
+# -*- coding: utf-8 -*-
+
+from common import *
+from khr_util.format import commandParams
+
+def commandTypedefDecl (command):
+	return "typedef EGLW_APICALL %s\t(EGLW_APIENTRY* %s)\t(%s);" % (
+		command.type,
+		getFunctionTypeName(command.name),
+		commandParams(command))
+
+def commandMemberDecl (command):
+	return "%s\t%s;" % (getFunctionTypeName(command.name),
+						getFunctionMemberName(command.name))
+
+def gen (iface):
+	genCommandList(iface, commandTypedefDecl, EGL_WRAPPER_DIR, "eglwFunctionTypes.inl", True)
+	genCommandList(iface, commandMemberDecl, EGL_WRAPPER_DIR, "eglwFunctions.inl", True)
diff --git a/scripts/egl/library.py b/scripts/egl/library.py
new file mode 100644
index 0000000..f0e675b
--- /dev/null
+++ b/scripts/egl/library.py
@@ -0,0 +1,76 @@
+# -*- coding: utf-8 -*-
+
+from common import *
+from khr_util.format import indentLines, commandParams, commandArgs
+import khr_util.registry
+from itertools import imap, chain
+
+def virtualMemberDecl (command):
+	return "virtual %s\t%s\t(%s) const\t= 0;" % (
+		command.type,
+		getFunctionMemberName(command.name),
+		commandParams(command))
+
+def concreteMemberDecl (command):
+	return "%s\t%s\t(%s) const;" % (
+		command.type,
+		getFunctionMemberName(command.name),
+		commandParams(command))
+
+def memberImpl (command):
+	template = """
+{returnType} FuncPtrLibrary::{memberName} ({paramDecls}) const
+{{
+	{maybeReturn}m_egl.{memberName}({arguments});
+}}"""
+	return template.format(
+		returnType		= command.type,
+		mangledName		= getFunctionMemberName(command.name),
+		paramDecls		= commandParams(command),
+		maybeReturn		= "return " if command.type != 'void' else "",
+		memberName		= getFunctionMemberName(command.name),
+		arguments		= commandArgs(command))
+
+def initFunctionEntry (command):
+	return "dst->%s\t= (%sFunc)\tloader->get(\"%s\");" % (
+		getFunctionMemberName(command.name),
+		command.name,
+		command.name)
+
+def getExtOnlyIface (registry, api, extensions):
+	spec = khr_util.registry.InterfaceSpec()
+
+	for extension in registry.extensions:
+		if not khr_util.registry.getExtensionName(extension) in extensions:
+			continue
+
+		if not khr_util.registry.extensionSupports(extension, api):
+			continue
+
+		spec.addExtension(extension, api)
+
+	return khr_util.registry.createInterface(registry, spec, api)
+
+def commandLibraryEntry (command):
+	return "\t{ \"%s\",\t(deFunctionPtr)%s }," % (command.name, command.name)
+
+def genStaticLibrary (registry):
+	genCommandLists(registry, commandLibraryEntry,
+					check		= lambda api, version: api == 'egl' and version in set(["1.4", "1.5"]),
+					directory	= EGL_WRAPPER_DIR,
+					filePattern	= "eglwStaticLibrary%s.inl",
+					align		= True)
+
+def gen (registry):
+	defaultIface	= getDefaultInterface()
+	noExtIface		= getInterface(registry, 'egl', VERSION)
+	extOnlyIface	= getExtOnlyIface(registry, 'egl', EXTENSIONS)
+
+	genCommandList(defaultIface,	virtualMemberDecl,	EGL_WRAPPER_DIR, "eglwLibrary.inl", True)
+	genCommandList(defaultIface,	concreteMemberDecl,	EGL_WRAPPER_DIR, "eglwFuncPtrLibraryDecl.inl", True)
+	genCommandList(defaultIface,	memberImpl,			EGL_WRAPPER_DIR, "eglwFuncPtrLibraryImpl.inl")
+
+	genCommandList(noExtIface,		initFunctionEntry,	EGL_WRAPPER_DIR, "eglwInitCore.inl", True)
+	genCommandList(extOnlyIface,	initFunctionEntry,	EGL_WRAPPER_DIR, "eglwInitExtensions.inl", True)
+
+	genStaticLibrary(registry)
diff --git a/scripts/egl/proc_address_tests.py b/scripts/egl/proc_address_tests.py
index c3fce49..91470e5 100644
--- a/scripts/egl/proc_address_tests.py
+++ b/scripts/egl/proc_address_tests.py
@@ -1,5 +1,25 @@
 # -*- coding: utf-8 -*-
 
+#-------------------------------------------------------------------------
+# drawElements Quality Program utilities
+# --------------------------------------
+#
+# Copyright 2015 The Android Open Source Project
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+#      http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+#
+#-------------------------------------------------------------------------
+
 import os
 import string
 
diff --git a/scripts/egl/str_util.py b/scripts/egl/str_util.py
index 7e5e4f4..d00fe45 100644
--- a/scripts/egl/str_util.py
+++ b/scripts/egl/str_util.py
@@ -1,5 +1,25 @@
 # -*- coding: utf-8 -*-
 
+#-------------------------------------------------------------------------
+# drawElements Quality Program utilities
+# --------------------------------------
+#
+# Copyright 2015 The Android Open Source Project
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+#      http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+#
+#-------------------------------------------------------------------------
+
 import os
 import string
 
@@ -103,8 +123,8 @@
 		"SWAP_BEHAVIOR",
 		"TEXTURE_FORMAT",
 		"TEXTURE_TARGET",
-		"VG_ALPHA_FORMAT",
-		"VG_COLORSPACE"
+		"ALPHA_FORMAT",
+		"COLORSPACE"
 		]),
 	("SurfaceTarget",		["READ", "DRAW"]),
 
@@ -119,8 +139,8 @@
 	("SwapBehavior",		["BUFFER_DESTROYED", "BUFFER_PRESERVED"]),
 	("TextureFormat",		["NO_TEXTURE", "TEXTURE_RGB", "TEXTURE_RGBA"]),
 	("TextureTarget",		["NO_TEXTURE", "TEXTURE_2D"]),
-	("VGAlphaFormat",		["VG_ALPHA_FORMAT_NONPRE", "VG_ALPHA_FORMAT_PRE"]),
-	("VGColorspace",		["VG_COLORSPACE_sRGB", "VG_COLORSPACE_LINEAR"])
+	("AlphaFormat",			["ALPHA_FORMAT_NONPRE", "ALPHA_FORMAT_PRE"]),
+	("Colorspace",			["COLORSPACE_sRGB", "COLORSPACE_LINEAR"])
 ]
 
 def gen (iface):
diff --git a/scripts/gen_egl.py b/scripts/gen_egl.py
index 23aa200..97e1434 100644
--- a/scripts/gen_egl.py
+++ b/scripts/gen_egl.py
@@ -1,5 +1,25 @@
 # -*- coding: utf-8 -*-
 
+#-------------------------------------------------------------------------
+# drawElements Quality Program utilities
+# --------------------------------------
+#
+# Copyright 2015 The Android Open Source Project
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+#      http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+#
+#-------------------------------------------------------------------------
+
 import egl
 
 def gen ():
diff --git a/scripts/khr_util/__init__.py b/scripts/khr_util/__init__.py
index 46ae457..384dec8 100644
--- a/scripts/khr_util/__init__.py
+++ b/scripts/khr_util/__init__.py
@@ -1,3 +1,23 @@
 # -*- coding: utf-8 -*-
 
+#-------------------------------------------------------------------------
+# drawElements Quality Program utilities
+# --------------------------------------
+#
+# Copyright 2015 The Android Open Source Project
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+#      http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+#
+#-------------------------------------------------------------------------
+
 __all__ = ['format', 'registry', 'registry_cache', 'gen_str_util']
diff --git a/scripts/khr_util/format.py b/scripts/khr_util/format.py
index 903aac6..b929a74 100644
--- a/scripts/khr_util/format.py
+++ b/scripts/khr_util/format.py
@@ -1,5 +1,25 @@
 # -*- coding: utf-8 -*-
 
+#-------------------------------------------------------------------------
+# drawElements Quality Program utilities
+# --------------------------------------
+#
+# Copyright 2015 The Android Open Source Project
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+#      http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+#
+#-------------------------------------------------------------------------
+
 from itertools import chain
 
 INL_HEADER_TMPL = """\
@@ -60,3 +80,24 @@
 
 def writeInlFile (filename, header, source):
 	writeLines(filename, chain([header], source))
+
+def normalizeConstant (constant):
+	value = int(constant, base=0)
+	if value >= 1 << 63:
+		suffix = 'ull'
+	elif value >= 1 << 32:
+		suffix = 'll'
+	elif value >= 1 << 31:
+		suffix = 'u'
+	else:
+		suffix = ''
+	return constant + suffix
+
+def commandParams (command):
+	if len(command.params) > 0:
+		return ", ".join(param.declaration for param in command.params)
+	else:
+		return "void"
+
+def commandArgs (command):
+	return ", ".join(param.name for param in command.params)
diff --git a/scripts/khr_util/gen_str_util.py b/scripts/khr_util/gen_str_util.py
index 82ff868..050486f 100644
--- a/scripts/khr_util/gen_str_util.py
+++ b/scripts/khr_util/gen_str_util.py
@@ -1,5 +1,25 @@
 # -*- coding: utf-8 -*-
 
+#-------------------------------------------------------------------------
+# drawElements Quality Program utilities
+# --------------------------------------
+#
+# Copyright 2015 The Android Open Source Project
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+#      http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+#
+#-------------------------------------------------------------------------
+
 from itertools import chain
 from format import indentLines
 
diff --git a/scripts/khr_util/registry.py b/scripts/khr_util/registry.py
index d6eda71..58dab52 100644
--- a/scripts/khr_util/registry.py
+++ b/scripts/khr_util/registry.py
@@ -1,5 +1,25 @@
 # -*- coding: utf-8 -*-
 
+#-------------------------------------------------------------------------
+# drawElements Quality Program utilities
+# --------------------------------------
+#
+# Copyright 2015 The Android Open Source Project
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+#      http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+#
+#-------------------------------------------------------------------------
+
 import sys, logging, re
 from lxml import etree
 from collections import OrderedDict
diff --git a/scripts/khr_util/registry_cache.py b/scripts/khr_util/registry_cache.py
index 45de4f0..47f06e0 100644
--- a/scripts/khr_util/registry_cache.py
+++ b/scripts/khr_util/registry_cache.py
@@ -1,5 +1,25 @@
 # -*- coding: utf-8 -*-
 
+#-------------------------------------------------------------------------
+# drawElements Quality Program utilities
+# --------------------------------------
+#
+# Copyright 2015 The Android Open Source Project
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+#      http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+#
+#-------------------------------------------------------------------------
+
 import os
 import urllib2
 import hashlib
diff --git a/scripts/launchcontrol_build.py b/scripts/launchcontrol_build.py
index b7448c9..06a2d4f 100644
--- a/scripts/launchcontrol_build.py
+++ b/scripts/launchcontrol_build.py
@@ -1,5 +1,25 @@
 # -*- coding: utf-8 -*-
 
+#-------------------------------------------------------------------------
+# drawElements Quality Program utilities
+# --------------------------------------
+#
+# Copyright 2015 The Android Open Source Project
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+#      http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+#
+#-------------------------------------------------------------------------
+
 import os
 from build.common import *
 from build.build import *
diff --git a/scripts/log/log_parser.py b/scripts/log/log_parser.py
index 6fc3e87..8740397 100644
--- a/scripts/log/log_parser.py
+++ b/scripts/log/log_parser.py
@@ -1,5 +1,25 @@
 # -*- coding: utf-8 -*-
 
+#-------------------------------------------------------------------------
+# drawElements Quality Program utilities
+# --------------------------------------
+#
+# Copyright 2015 The Android Open Source Project
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+#      http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+#
+#-------------------------------------------------------------------------
+
 import shlex
 import xml.dom.minidom
 
diff --git a/scripts/log/log_to_csv.py b/scripts/log/log_to_csv.py
index 9d673ab..41ca5c9 100644
--- a/scripts/log/log_to_csv.py
+++ b/scripts/log/log_to_csv.py
@@ -1,5 +1,25 @@
 # -*- coding: utf-8 -*-
 
+#-------------------------------------------------------------------------
+# drawElements Quality Program utilities
+# --------------------------------------
+#
+# Copyright 2015 The Android Open Source Project
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+#      http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+#
+#-------------------------------------------------------------------------
+
 import sys
 from log_parser import BatchResultParser
 
diff --git a/scripts/log/log_to_xml.py b/scripts/log/log_to_xml.py
index 429fdd5..8618566 100644
--- a/scripts/log/log_to_xml.py
+++ b/scripts/log/log_to_xml.py
@@ -1,5 +1,25 @@
 # -*- coding: utf-8 -*-
 
+#-------------------------------------------------------------------------
+# drawElements Quality Program utilities
+# --------------------------------------
+#
+# Copyright 2015 The Android Open Source Project
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+#      http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+#
+#-------------------------------------------------------------------------
+
 import os
 import sys
 import codecs
diff --git a/scripts/make_release.py b/scripts/make_release.py
index f31a189..cf3f489 100644
--- a/scripts/make_release.py
+++ b/scripts/make_release.py
@@ -1,5 +1,25 @@
 # -*- coding: utf-8 -*-
 
+#-------------------------------------------------------------------------
+# drawElements Quality Program utilities
+# --------------------------------------
+#
+# Copyright 2015 The Android Open Source Project
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+#      http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+#
+#-------------------------------------------------------------------------
+
 import os
 import re
 import sys
diff --git a/scripts/no_empty_fail.rule b/scripts/no_empty_fail.rule
index 092f82e..e7846b9 100644
--- a/scripts/no_empty_fail.rule
+++ b/scripts/no_empty_fail.rule
@@ -1,4 +1,24 @@
 <?xml version="2.0"?>
+<!--
+
+  drawElements Quality Program utilities
+  --------------------------------------
+
+  Copyright 2015 The Android Open Source Project
+
+  Licensed under the Apache License, Version 2.0 (the "License");
+  you may not use this file except in compliance with the License.
+  You may obtain a copy of the License at
+
+       http://www.apache.org/licenses/LICENSE-2.0
+
+  Unless required by applicable law or agreed to in writing, software
+  distributed under the License is distributed on an "AS IS" BASIS,
+  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+  See the License for the specific language governing permissions and
+  limitations under the License.
+
+-->
 <rule version="1">
 <pattern>setTestResult \( QP_TEST_RESULT_FAIL , (\"\"|\"Fail\") \)</pattern>
 <message>
diff --git a/scripts/opengl/__init__.py b/scripts/opengl/__init__.py
index e69de29..6e13ef1 100644
--- a/scripts/opengl/__init__.py
+++ b/scripts/opengl/__init__.py
@@ -0,0 +1,19 @@
+#-------------------------------------------------------------------------
+# drawElements Quality Program utilities
+# --------------------------------------
+#
+# Copyright 2015 The Android Open Source Project
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+#      http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+#
+#-------------------------------------------------------------------------
diff --git a/scripts/opengl/gen_all.py b/scripts/opengl/gen_all.py
index ae0a4f5..c012ba0 100644
--- a/scripts/opengl/gen_all.py
+++ b/scripts/opengl/gen_all.py
@@ -1,5 +1,25 @@
 # -*- coding: utf-8 -*-
 
+#-------------------------------------------------------------------------
+# drawElements Quality Program utilities
+# --------------------------------------
+#
+# Copyright 2015 The Android Open Source Project
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+#      http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+#
+#-------------------------------------------------------------------------
+
 from src_util import getGLRegistry, getHybridInterface
 from gen_call_log_wrapper import genCallLogWrapper
 from gen_enums import genEnums
diff --git a/scripts/opengl/gen_call_log_wrapper.py b/scripts/opengl/gen_call_log_wrapper.py
index e085ef0..0f5f47e 100644
--- a/scripts/opengl/gen_call_log_wrapper.py
+++ b/scripts/opengl/gen_call_log_wrapper.py
@@ -1,5 +1,25 @@
 # -*- coding: utf-8 -*-
 
+#-------------------------------------------------------------------------
+# drawElements Quality Program utilities
+# --------------------------------------
+#
+# Copyright 2015 The Android Open Source Project
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+#      http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+#
+#-------------------------------------------------------------------------
+
 from src_util import *
 import re
 
diff --git a/scripts/opengl/gen_enums.py b/scripts/opengl/gen_enums.py
index 7fe0469..5e2c359 100644
--- a/scripts/opengl/gen_enums.py
+++ b/scripts/opengl/gen_enums.py
@@ -1,5 +1,25 @@
 # -*- coding: utf-8 -*-
 
+#-------------------------------------------------------------------------
+# drawElements Quality Program utilities
+# --------------------------------------
+#
+# Copyright 2015 The Android Open Source Project
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+#      http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+#
+#-------------------------------------------------------------------------
+
 import os
 import string
 
diff --git a/scripts/opengl/gen_es31_wrapper.py b/scripts/opengl/gen_es31_wrapper.py
index 4263ce9..874c884 100644
--- a/scripts/opengl/gen_es31_wrapper.py
+++ b/scripts/opengl/gen_es31_wrapper.py
@@ -1,5 +1,25 @@
 # -*- coding: utf-8 -*-
 
+#-------------------------------------------------------------------------
+# drawElements Quality Program utilities
+# --------------------------------------
+#
+# Copyright 2015 The Android Open Source Project
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+#      http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+#
+#-------------------------------------------------------------------------
+
 from src_util import *
 
 def commandES31InitStatement (command):
diff --git a/scripts/opengl/gen_es_direct_init.py b/scripts/opengl/gen_es_direct_init.py
index c895b7e..24370c3 100644
--- a/scripts/opengl/gen_es_direct_init.py
+++ b/scripts/opengl/gen_es_direct_init.py
@@ -1,5 +1,25 @@
 # -*- coding: utf-8 -*-
 
+#-------------------------------------------------------------------------
+# drawElements Quality Program utilities
+# --------------------------------------
+#
+# Copyright 2015 The Android Open Source Project
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+#      http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+#
+#-------------------------------------------------------------------------
+
 from src_util import *
 
 def commandDirectInitStatement (command):
diff --git a/scripts/opengl/gen_es_static_library.py b/scripts/opengl/gen_es_static_library.py
index 130d3b9..cef5b36 100644
--- a/scripts/opengl/gen_es_static_library.py
+++ b/scripts/opengl/gen_es_static_library.py
@@ -1,5 +1,25 @@
 # -*- coding: utf-8 -*-
 
+#-------------------------------------------------------------------------
+# drawElements Quality Program utilities
+# --------------------------------------
+#
+# Copyright 2015 The Android Open Source Project
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+#      http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+#
+#-------------------------------------------------------------------------
+
 from src_util import *
 
 GEN_VERSIONS = set(["2.0", "3.0"])
diff --git a/scripts/opengl/gen_ext_init.py b/scripts/opengl/gen_ext_init.py
index 5591dd7..4ab0eeb 100644
--- a/scripts/opengl/gen_ext_init.py
+++ b/scripts/opengl/gen_ext_init.py
@@ -1,5 +1,25 @@
 # -*- coding: utf-8 -*-
 
+#-------------------------------------------------------------------------
+# drawElements Quality Program utilities
+# --------------------------------------
+#
+# Copyright 2015 The Android Open Source Project
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+#      http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+#
+#-------------------------------------------------------------------------
+
 from src_util import *
 
 def genExtensions (registry, iface, api):
diff --git a/scripts/opengl/gen_func_init.py b/scripts/opengl/gen_func_init.py
index 12066cf..d5dcca9 100644
--- a/scripts/opengl/gen_func_init.py
+++ b/scripts/opengl/gen_func_init.py
@@ -1,5 +1,25 @@
 # -*- coding: utf-8 -*-
 
+#-------------------------------------------------------------------------
+# drawElements Quality Program utilities
+# --------------------------------------
+#
+# Copyright 2015 The Android Open Source Project
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+#      http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+#
+#-------------------------------------------------------------------------
+
 from src_util import *
 
 def commandInitStatement (command):
diff --git a/scripts/opengl/gen_func_ptrs.py b/scripts/opengl/gen_func_ptrs.py
index 65ff622..3172aa2 100644
--- a/scripts/opengl/gen_func_ptrs.py
+++ b/scripts/opengl/gen_func_ptrs.py
@@ -1,5 +1,25 @@
 # -*- coding: utf-8 -*-
 
+#-------------------------------------------------------------------------
+# drawElements Quality Program utilities
+# --------------------------------------
+#
+# Copyright 2015 The Android Open Source Project
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+#      http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+#
+#-------------------------------------------------------------------------
+
 from src_util import *
 
 def commandTypedefDecl (command):
diff --git a/scripts/opengl/gen_null_render_context.py b/scripts/opengl/gen_null_render_context.py
index 5ebf00f..36a2d5e 100644
--- a/scripts/opengl/gen_null_render_context.py
+++ b/scripts/opengl/gen_null_render_context.py
@@ -1,5 +1,25 @@
 # -*- coding: utf-8 -*-
 
+#-------------------------------------------------------------------------
+# drawElements Quality Program utilities
+# --------------------------------------
+#
+# Copyright 2015 The Android Open Source Project
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+#      http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+#
+#-------------------------------------------------------------------------
+
 from src_util import *
 
 # Functions that have special implementation
diff --git a/scripts/opengl/gen_query_util.py b/scripts/opengl/gen_query_util.py
index 79e8684..ea9b280 100644
--- a/scripts/opengl/gen_query_util.py
+++ b/scripts/opengl/gen_query_util.py
@@ -1,5 +1,25 @@
 # -*- coding: utf-8 -*-
 
+#-------------------------------------------------------------------------
+# drawElements Quality Program utilities
+# --------------------------------------
+#
+# Copyright 2015 The Android Open Source Project
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+#      http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+#
+#-------------------------------------------------------------------------
+
 from src_util import *
 from khr_util.gen_str_util import genEnumUtilImpls
 
diff --git a/scripts/opengl/gen_str_util.py b/scripts/opengl/gen_str_util.py
index d2afdc6..91d9ceb 100644
--- a/scripts/opengl/gen_str_util.py
+++ b/scripts/opengl/gen_str_util.py
@@ -1,5 +1,25 @@
 # -*- coding: utf-8 -*-
 
+#-------------------------------------------------------------------------
+# drawElements Quality Program utilities
+# --------------------------------------
+#
+# Copyright 2015 The Android Open Source Project
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+#      http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+#
+#-------------------------------------------------------------------------
+
 import os
 import string
 
diff --git a/scripts/opengl/gen_wrapper.py b/scripts/opengl/gen_wrapper.py
index 7437afa..3a335ec 100644
--- a/scripts/opengl/gen_wrapper.py
+++ b/scripts/opengl/gen_wrapper.py
@@ -1,5 +1,25 @@
 # -*- coding: utf-8 -*-
 
+#-------------------------------------------------------------------------
+# drawElements Quality Program utilities
+# --------------------------------------
+#
+# Copyright 2015 The Android Open Source Project
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+#      http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+#
+#-------------------------------------------------------------------------
+
 import os
 from src_util import *
 from itertools import imap, chain
diff --git a/scripts/opengl/src_util.py b/scripts/opengl/src_util.py
index 8cccefc..66e943e 100644
--- a/scripts/opengl/src_util.py
+++ b/scripts/opengl/src_util.py
@@ -1,5 +1,25 @@
 # -*- coding: utf-8 -*-
 
+#-------------------------------------------------------------------------
+# drawElements Quality Program utilities
+# --------------------------------------
+#
+# Copyright 2015 The Android Open Source Project
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+#      http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+#
+#-------------------------------------------------------------------------
+
 import os
 import re
 import sys
@@ -17,8 +37,8 @@
 
 GL_SOURCE			= khr_util.registry_cache.RegistrySource(
 						"gl.xml",
-						28861,
-						"65564395098c82ec9d18cc19100357cb11d99f7baf1d99133bb543ffca7a0f0e")
+						29570,
+						"cc358ff7b5fd27863518b80fe4578e021ef5a3d4e3397f323b44433a9b31f60f")
 
 EXTENSIONS			= [
 	'GL_KHR_texture_compression_astc_ldr',
@@ -39,6 +59,7 @@
 	'GL_EXT_texture_compression_s3tc',
 	'GL_IMG_texture_compression_pvrtc',
 	'GL_EXT_copy_image',
+	'GL_EXT_draw_buffers_indexed'
 ]
 
 def getGLRegistry ():
@@ -120,31 +141,13 @@
 	else:
 		return "%c%s" % (funcName[2].lower(), funcName[3:])
 
-def normalizeConstant(constant):
-	value = int(constant, base=0)
-	if value >= 1 << 63:
-		suffix = 'ull'
-	elif value >= 1 << 32:
-		suffix = 'll'
-	elif value >= 1 << 31:
-		suffix = 'u'
-	else:
-		suffix = ''
-	return constant + suffix
-
-def commandParams(command):
-	if len(command.params) > 0:
-		return ", ".join(param.declaration for param in command.params)
-	else:
-		return "void"
-
-def commandArgs(command):
-	return ", ".join(param.name for param in command.params)
-
 INL_HEADER = khr_util.format.genInlHeader("Khronos GL API description (gl.xml)", GL_SOURCE.getRevision())
 
 def writeInlFile (filename, source):
 	khr_util.format.writeInlFile(filename, INL_HEADER, source)
 
 # Aliases from khr_util.common
-indentLines		= khr_util.format.indentLines
+indentLines			= khr_util.format.indentLines
+normalizeConstant	= khr_util.format.normalizeConstant
+commandParams		= khr_util.format.commandParams
+commandArgs			= khr_util.format.commandArgs
diff --git a/scripts/run_internal_tests.py b/scripts/run_internal_tests.py
index d112b02..672d50a 100644
--- a/scripts/run_internal_tests.py
+++ b/scripts/run_internal_tests.py
@@ -1,5 +1,25 @@
 # -*- coding: utf-8 -*-
 
+#-------------------------------------------------------------------------
+# drawElements Quality Program utilities
+# --------------------------------------
+#
+# Copyright 2015 The Android Open Source Project
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+#      http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+#
+#-------------------------------------------------------------------------
+
 import os
 import sys
 import shutil
diff --git a/scripts/run_nightly.py b/scripts/run_nightly.py
index f8cb63d..a4f9e18 100644
--- a/scripts/run_nightly.py
+++ b/scripts/run_nightly.py
@@ -1,5 +1,25 @@
 # -*- coding: utf-8 -*-
 
+#-------------------------------------------------------------------------
+# drawElements Quality Program utilities
+# --------------------------------------
+#
+# Copyright 2015 The Android Open Source Project
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+#      http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+#
+#-------------------------------------------------------------------------
+
 from build.common import *
 from build.config import *
 from build.build import *
diff --git a/scripts/testset.py b/scripts/testset.py
index 5227a12..03d8385 100644
--- a/scripts/testset.py
+++ b/scripts/testset.py
@@ -1,5 +1,25 @@
 # -*- coding: utf-8 -*-
 
+#-------------------------------------------------------------------------
+# drawElements Quality Program utilities
+# --------------------------------------
+#
+# Copyright 2015 The Android Open Source Project
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+#      http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+#
+#-------------------------------------------------------------------------
+
 import sys
 import random
 import string
diff --git a/targets/android/android.cmake b/targets/android/android.cmake
index 4b8d81b..59d5e9c 100644
--- a/targets/android/android.cmake
+++ b/targets/android/android.cmake
@@ -3,15 +3,8 @@
 set(DEQP_TARGET_NAME	"Android")
 set(DEQP_SUPPORT_GLES1	ON)
 set(DEQP_SUPPORT_GLES2	ON)
-
-if (DE_ANDROID_API GREATER 8)
-	set(DEQP_SUPPORT_EGL	ON)
-	set(DEQP_SUPPORT_GLES3	ON) # \note GLES3 support requires eglGetProcAddress()
-else ()
-	set(DEQP_SUPPORT_EGL	OFF)
-endif ()
-
-set(DEQP_SUPPORT_OPENCL	OFF)
+set(DEQP_SUPPORT_GLES3	ON)
+set(DEQP_SUPPORT_EGL	ON)
 
 # GLESv2 lib
 find_library(GLES2_LIBRARY GLESv2 PATHS /usr/lib)
@@ -27,14 +20,6 @@
 	set(DEQP_EGL_LIBRARIES ${EGL_LIBRARY})
 endif ()
 
-# OpenCL - dynamic loading
-if (DEQP_SUPPORT_OPENCL)
-	include_directories(framework/opencl/inc)
-
-	add_subdirectory(wrappers/opencl_dynamic)
-	set(DEQP_OPENCL_LIBRARIES OpenCL)
-endif ()
-
 # Platform libs
 find_library(LOG_LIBRARY NAMES log PATHS /usr/lib)
 set(DEQP_PLATFORM_LIBRARIES ${DEQP_PLATFORM_LIBRARIES} ${LOG_LIBRARY})
diff --git a/targets/default/default.cmake b/targets/default/default.cmake
index 02a1475..f08389c 100644
--- a/targets/default/default.cmake
+++ b/targets/default/default.cmake
@@ -3,10 +3,11 @@
 
 set(DEQP_TARGET_NAME 	"Default")
 
-# OpenGL (ES) tests do not require any libraries or headers
+# OpenGL (ES) & EGL tests do not require any libraries or headers
 set(DEQP_SUPPORT_GLES2	ON)
 set(DEQP_SUPPORT_GLES3	ON)
 set(DEQP_SUPPORT_OPENGL	ON)
+set(DEQP_SUPPORT_EGL	ON)
 
 # For static linking
 find_library(GLES2_LIBRARY		NAMES libGLESv2 GLESv2)
@@ -18,6 +19,7 @@
 
 if (GLES2_LIBRARY AND GLES2_INCLUDE_PATH)
 	set(DEQP_GLES2_LIBRARIES ${GLES2_LIBRARY})
+	include_directories(${GLES2_INCLUDE_PATH})
 endif ()
 
 if (GLES2_LIBRARY AND GLES3_INCLUDE_PATH)
@@ -26,24 +28,10 @@
 endif ()
 
 if (EGL_LIBRARY AND EGL_INCLUDE_PATH)
-	set(DEQP_SUPPORT_EGL		ON)
-	set(DEQP_EGL_LIBRARIES		${EGL_LIBRARY})
+	set(DEQP_EGL_LIBRARIES ${EGL_LIBRARY})
 	include_directories(${EGL_INCLUDE_PATH})
 endif ()
 
-# OpenCL support?
-find_library(OPENCL_LIBRARY		NAMES libOpenCL OpenCL)
-find_path(OPENCL_INCLUDE_PATH	CL/cl.h OpenCL/cl.h)
-
-message("OPENCL_LIBRARY = ${OPENCL_LIBRARY}")
-message("OPENCL_INCLUDE_PATH = ${OPENCL_INCLUDE_PATH}")
-
-if (OPENCL_LIBRARY AND OPENCL_INCLUDE_PATH)
-	set(DEQP_SUPPORT_OPENCL		ON)
-	set(DEQP_OPENCL_LIBRARIES	${OPENCL_LIBRARY})
-	include_directories(${OPENCL_INCLUDE_PATH})
-endif ()
-
 # X11 / GLX?
 if (DE_OS_IS_UNIX)
 	find_package(X11)
diff --git a/targets/dynamic_opencl/dynamic_opencl.cmake b/targets/dynamic_opencl/dynamic_opencl.cmake
deleted file mode 100644
index 4a57246..0000000
--- a/targets/dynamic_opencl/dynamic_opencl.cmake
+++ /dev/null
@@ -1,13 +0,0 @@
-# Dynamic OpenCL
-
-set(DEQP_TARGET_NAME "OpenCL (run-time linking)")
-
-set(DEQP_SUPPORT_OPENGL		ON)
-set(DEQP_SUPPORT_OPENCL		ON)
-
-# Headers
-include_directories(framework/opencl/inc)
-
-# Library
-add_subdirectory(wrappers/opencl_dynamic)
-set(DEQP_OPENCL_LIBRARIES OpenCL)
diff --git a/targets/osx/osx.cmake b/targets/osx/osx.cmake
index afadd89..c11650e 100644
--- a/targets/osx/osx.cmake
+++ b/targets/osx/osx.cmake
@@ -3,20 +3,7 @@
 set(DEQP_TARGET_NAME	"OS X")
 
 set(DEQP_SUPPORT_OPENGL	ON)
-set(DEQP_SUPPORT_OPENCL	ON)
 
 find_package(OpenGL REQUIRED)
 set(DEQP_PLATFORM_LIBRARIES ${OPENGL_LIBRARIES})
 include_directories(${OPENGL_INCLUDE_DIRS})
-
-find_path(OPENCL_INC NAMES CL/cl.h OpenCL/cl.h)
-if (NOT OPENCL_INC)
-	message(FATAL_ERROR "Can't find OpenCL headers")
-endif ()
-include_directories(${OPENCL_INC})
-
-find_library(OPENCL_LIB NAMES OpenCL libOpenCL)
-set(DEQP_OPENCL_LIBRARIES ${OPENCL_LIB})
-
-# Apple versions of cl headers do not respect CL_USE_DEPRECATED_OPENCL_1_X_APIs
-set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wno-deprecated-declarations")
diff --git a/targets/system_opencl/system_opencl.cmake b/targets/system_opencl/system_opencl.cmake
deleted file mode 100644
index ee35e30..0000000
--- a/targets/system_opencl/system_opencl.cmake
+++ /dev/null
@@ -1,20 +0,0 @@
-# System OpenCL
-
-set(DEQP_TARGET_NAME "System OpenCL")
-
-set(DEQP_SUPPORT_GLES2		OFF)
-set(DEQP_SUPPORT_GLES1		OFF)
-set(DEQP_SUPPORT_OPENVG		OFF)
-set(DEQP_SUPPORT_EGL		OFF)
-set(DEQP_SUPPORT_OPENCL		ON)
-
-# Headers
-find_path(OPENCL_INC NAMES CL/cl.h OpenCL/cl.h)
-if (NOT OPENCL_INC)
-	message(FATAL_ERROR "Can't find OpenCL headers")
-endif ()
-include_directories(${OPENCL_INC})
-
-# Libraries
-find_library(OPENCL_LIB NAMES OpenCL libOpenCL)
-set(DEQP_OPENCL_LIBRARIES ${OPENCL_LIB})
diff --git a/targets/win32_wgl/win32_wgl.cmake b/targets/win32_wgl/win32_wgl.cmake
index a34f8dd..690fe13 100644
--- a/targets/win32_wgl/win32_wgl.cmake
+++ b/targets/win32_wgl/win32_wgl.cmake
@@ -4,3 +4,4 @@
 set(DEQP_SUPPORT_GLES2	ON)
 set(DEQP_SUPPORT_GLES3	ON)
 set(DEQP_SUPPORT_OPENGL	ON)
+set(DEQP_SUPPORT_EGL	ON)
diff --git a/targets/x11_egl_glx/x11_egl_glx.cmake b/targets/x11_egl_glx/x11_egl_glx.cmake
index 3772922..8c8eee0 100644
--- a/targets/x11_egl_glx/x11_egl_glx.cmake
+++ b/targets/x11_egl_glx/x11_egl_glx.cmake
@@ -1,7 +1,6 @@
 
 message("*** Using X11 EGL/GLX target")
 set(DEQP_TARGET_NAME 	"X11 EGL/GLX")
-set(DEQP_RUNTIME_LINK	OFF)
 set(DEQP_SUPPORT_GLES2	ON)
 set(DEQP_SUPPORT_GLES3	ON)
 set(DEQP_SUPPORT_OPENGL	ON)
@@ -9,19 +8,13 @@
 set(DEQP_SUPPORT_GLX	ON)
 
 # Use X11 target
-set(DEQP_USE_X11	ON)
+set(DEQP_USE_X11		ON)
 
 find_package(X11)
 if (NOT X11_FOUND)
 	message(FATAL_ERROR "X11 development package not found")
 endif ()
 
-find_library(EGL_LIBRARY EGL)
-if (NOT EGL_LIBRARY)
-	message(FATAL_ERROR "EGL library not found")
-endif()
-
-set(DEQP_EGL_LIBRARIES		${EGL_LIBRARY})
-set(DEQP_PLATFORM_LIBRARIES	${X11_LIBRARIES})
+set(DEQP_PLATFORM_LIBRARIES ${X11_LIBRARIES})
 
 include_directories(${X11_INCLUDE_DIR})
diff --git a/targets/x11_glx/x11_glx.cmake b/targets/x11_glx/x11_glx.cmake
index 6759ed6..b6a036e 100644
--- a/targets/x11_glx/x11_glx.cmake
+++ b/targets/x11_glx/x11_glx.cmake
@@ -8,7 +8,7 @@
 set(DEQP_SUPPORT_GLX	ON)
 
 # Use X11 target
-set(DEQP_USE_X11	ON)
+set(DEQP_USE_X11		ON)
 
 find_package(X11)
 if (NOT X11_FOUND)