Merge "Remove unnecessary current context from reusable sync tests" into nyc-dev
diff --git a/android/cts/master/com.drawelements.deqp.egl.xml b/android/cts/master/com.drawelements.deqp.egl.xml
index e557301..b931e93 100644
--- a/android/cts/master/com.drawelements.deqp.egl.xml
+++ b/android/cts/master/com.drawelements.deqp.egl.xml
@@ -3149,9 +3149,6 @@
 					<Test name="tex_rgb8_tex_subimage_rgb8">
 						<TestInstance glconfig="rgba8888d24s8ms0" rotation="unspecified" surfacetype="window"/>
 					</Test>
-					<Test name="tex_rgb8_tex_subimage_rgb565">
-						<TestInstance glconfig="rgba8888d24s8ms0" rotation="unspecified" surfacetype="window"/>
-					</Test>
 					<Test name="tex_rgb8_renderbuffer_clear_color">
 						<TestInstance glconfig="rgba8888d24s8ms0" rotation="unspecified" surfacetype="window"/>
 					</Test>
@@ -3167,12 +3164,6 @@
 					<Test name="tex_rgba8_tex_subimage_rgba8">
 						<TestInstance glconfig="rgba8888d24s8ms0" rotation="unspecified" surfacetype="window"/>
 					</Test>
-					<Test name="tex_rgba8_tex_subimage_rgba5_a1">
-						<TestInstance glconfig="rgba8888d24s8ms0" rotation="unspecified" surfacetype="window"/>
-					</Test>
-					<Test name="tex_rgba8_tex_subimage_rgba4">
-						<TestInstance glconfig="rgba8888d24s8ms0" rotation="unspecified" surfacetype="window"/>
-					</Test>
 					<Test name="tex_rgba8_renderbuffer_clear_color">
 						<TestInstance glconfig="rgba8888d24s8ms0" rotation="unspecified" surfacetype="window"/>
 					</Test>
@@ -3182,18 +3173,12 @@
 					<Test name="tex_rgba5_a1_tex_subimage_rgba5_a1">
 						<TestInstance glconfig="rgba8888d24s8ms0" rotation="unspecified" surfacetype="window"/>
 					</Test>
-					<Test name="tex_rgba5_a1_tex_subimage_rgba4">
-						<TestInstance glconfig="rgba8888d24s8ms0" rotation="unspecified" surfacetype="window"/>
-					</Test>
 					<Test name="tex_rgba5_a1_renderbuffer_clear_color">
 						<TestInstance glconfig="rgba8888d24s8ms0" rotation="unspecified" surfacetype="window"/>
 					</Test>
 					<Test name="tex_rgba4_tex_subimage_rgba8">
 						<TestInstance glconfig="rgba8888d24s8ms0" rotation="unspecified" surfacetype="window"/>
 					</Test>
-					<Test name="tex_rgba4_tex_subimage_rgba5_a1">
-						<TestInstance glconfig="rgba8888d24s8ms0" rotation="unspecified" surfacetype="window"/>
-					</Test>
 					<Test name="tex_rgba4_tex_subimage_rgba4">
 						<TestInstance glconfig="rgba8888d24s8ms0" rotation="unspecified" surfacetype="window"/>
 					</Test>
@@ -3203,9 +3188,6 @@
 					<Test name="renderbuffer_rgba4_tex_subimage_rgba8">
 						<TestInstance glconfig="rgba8888d24s8ms0" rotation="unspecified" surfacetype="window"/>
 					</Test>
-					<Test name="renderbuffer_rgba4_tex_subimage_rgba5_a1">
-						<TestInstance glconfig="rgba8888d24s8ms0" rotation="unspecified" surfacetype="window"/>
-					</Test>
 					<Test name="renderbuffer_rgba4_tex_subimage_rgba4">
 						<TestInstance glconfig="rgba8888d24s8ms0" rotation="unspecified" surfacetype="window"/>
 					</Test>
@@ -3218,9 +3200,6 @@
 					<Test name="renderbuffer_rgb5_a1_tex_subimage_rgba5_a1">
 						<TestInstance glconfig="rgba8888d24s8ms0" rotation="unspecified" surfacetype="window"/>
 					</Test>
-					<Test name="renderbuffer_rgb5_a1_tex_subimage_rgba4">
-						<TestInstance glconfig="rgba8888d24s8ms0" rotation="unspecified" surfacetype="window"/>
-					</Test>
 					<Test name="renderbuffer_rgb5_a1_renderbuffer_clear_color">
 						<TestInstance glconfig="rgba8888d24s8ms0" rotation="unspecified" surfacetype="window"/>
 					</Test>
diff --git a/android/cts/master/egl-master.txt b/android/cts/master/egl-master.txt
index 2f76b88..00b7cd1 100644
--- a/android/cts/master/egl-master.txt
+++ b/android/cts/master/egl-master.txt
@@ -991,30 +991,23 @@
 dEQP-EGL.functional.image.create.gles2_renderbuffer_depth16_depth_buffer
 dEQP-EGL.functional.image.create.gles2_renderbuffer_stencil_stencil_buffer
 dEQP-EGL.functional.image.modify.tex_rgb8_tex_subimage_rgb8
-dEQP-EGL.functional.image.modify.tex_rgb8_tex_subimage_rgb565
 dEQP-EGL.functional.image.modify.tex_rgb8_renderbuffer_clear_color
 dEQP-EGL.functional.image.modify.tex_rgb565_tex_subimage_rgb8
 dEQP-EGL.functional.image.modify.tex_rgb565_tex_subimage_rgb565
 dEQP-EGL.functional.image.modify.tex_rgb565_renderbuffer_clear_color
 dEQP-EGL.functional.image.modify.tex_rgba8_tex_subimage_rgba8
-dEQP-EGL.functional.image.modify.tex_rgba8_tex_subimage_rgba5_a1
-dEQP-EGL.functional.image.modify.tex_rgba8_tex_subimage_rgba4
 dEQP-EGL.functional.image.modify.tex_rgba8_renderbuffer_clear_color
 dEQP-EGL.functional.image.modify.tex_rgba5_a1_tex_subimage_rgba8
 dEQP-EGL.functional.image.modify.tex_rgba5_a1_tex_subimage_rgba5_a1
-dEQP-EGL.functional.image.modify.tex_rgba5_a1_tex_subimage_rgba4
 dEQP-EGL.functional.image.modify.tex_rgba5_a1_renderbuffer_clear_color
 dEQP-EGL.functional.image.modify.tex_rgba4_tex_subimage_rgba8
-dEQP-EGL.functional.image.modify.tex_rgba4_tex_subimage_rgba5_a1
 dEQP-EGL.functional.image.modify.tex_rgba4_tex_subimage_rgba4
 dEQP-EGL.functional.image.modify.tex_rgba4_renderbuffer_clear_color
 dEQP-EGL.functional.image.modify.renderbuffer_rgba4_tex_subimage_rgba8
-dEQP-EGL.functional.image.modify.renderbuffer_rgba4_tex_subimage_rgba5_a1
 dEQP-EGL.functional.image.modify.renderbuffer_rgba4_tex_subimage_rgba4
 dEQP-EGL.functional.image.modify.renderbuffer_rgba4_renderbuffer_clear_color
 dEQP-EGL.functional.image.modify.renderbuffer_rgb5_a1_tex_subimage_rgba8
 dEQP-EGL.functional.image.modify.renderbuffer_rgb5_a1_tex_subimage_rgba5_a1
-dEQP-EGL.functional.image.modify.renderbuffer_rgb5_a1_tex_subimage_rgba4
 dEQP-EGL.functional.image.modify.renderbuffer_rgb5_a1_renderbuffer_clear_color
 dEQP-EGL.functional.image.modify.renderbuffer_rgb565_tex_subimage_rgb8
 dEQP-EGL.functional.image.modify.renderbuffer_rgb565_tex_subimage_rgb565
diff --git a/modules/egl/teglAndroidUtil.cpp b/modules/egl/teglAndroidUtil.cpp
index e32c18a..95e3d9e 100644
--- a/modules/egl/teglAndroidUtil.cpp
+++ b/modules/egl/teglAndroidUtil.cpp
@@ -106,7 +106,7 @@
 	MovePtr<ClientBuffer>	createBuffer 				(const glw::Functions&, Texture2D*) const;
 	string					getRequiredExtension		(void) const { return "EGL_ANDROID_image_native_buffer"; }
 	EGLImageKHR				createImage					(const Library& egl, EGLDisplay dpy, EGLContext ctx, EGLClientBuffer clientBuffer) const;
-	GLenum					getFormat					(void) const { return m_format; }
+	GLenum					getEffectiveFormat			(void) const { return m_format; }
 
 protected:
 	GLenum					m_format;
diff --git a/modules/egl/teglImageFormatTests.cpp b/modules/egl/teglImageFormatTests.cpp
index 2d46751..8d6cea0 100644
--- a/modules/egl/teglImageFormatTests.cpp
+++ b/modules/egl/teglImageFormatTests.cpp
@@ -185,7 +185,7 @@
 								Create					(MovePtr<ImageSource> imgSource) : m_imgSource(imgSource) {}
 		string					getRequiredExtension	(void) const { return m_imgSource->getRequiredExtension(); }
 		bool					invokeGLES2				(GLES2ImageApi& api, MovePtr<UniqueImage>& image, tcu::Texture2D& ref) const;
-		glw::GLenum				getFormat				(void) const { return m_imgSource->getFormat(); }
+		glw::GLenum				getEffectiveFormat		(void) const { return m_imgSource->getEffectiveFormat(); }
 
 	private:
 		UniquePtr<ImageSource>	m_imgSource;
@@ -216,6 +216,7 @@
 							ModifyTexSubImage		(GLenum format, GLenum type) : m_format(format), m_type(type) {}
 		bool				invokeGLES2				(GLES2ImageApi& api, MovePtr<UniqueImage>& image, tcu::Texture2D& ref) const;
 		GLenum				getFormat				(void) const { return m_format; }
+		GLenum				getType					(void) const { return m_type; }
 
 	private:
 		GLenum				m_format;
@@ -1214,7 +1215,7 @@
 {
 	if (const GLES2ImageApi::Create* gles2Create = dynamic_cast<const GLES2ImageApi::Create*>(&create))
 	{
-		const GLenum createFormat = gles2Create->getFormat();
+		const GLenum createFormat = gles2Create->getEffectiveFormat();
 
 		if (dynamic_cast<const GLES2ImageApi::RenderTexture2D*>(&render))
 		{
@@ -1291,38 +1292,84 @@
 	return new SimpleCreationTests(eglTestCtx, name, desc);
 }
 
-bool isCompatibleFormats (GLenum createFormat, GLenum modifyFormat)
+bool isCompatibleFormats (GLenum createFormat, GLenum modifyFormat, GLenum modifyType)
 {
-	switch (createFormat)
+	switch (modifyFormat)
 	{
 		case GL_RGB:
-		case GL_RGB8:
-		case GL_RGB565:
-			if (modifyFormat == GL_RGB
-				|| modifyFormat == GL_RGB8
-				|| modifyFormat == GL_RGB565)
-				return true;
-			else
-				return false;
+			switch (modifyType)
+			{
+				case GL_UNSIGNED_BYTE:
+					return createFormat == GL_RGB
+							|| createFormat == GL_RGB8
+							|| createFormat == GL_RGB565
+							|| createFormat == GL_SRGB8;
+
+				case GL_BYTE:
+					return createFormat == GL_RGB8_SNORM;
+
+				case GL_UNSIGNED_SHORT_5_6_5:
+					return createFormat == GL_RGB
+							|| createFormat == GL_RGB565;
+
+				case GL_UNSIGNED_INT_10F_11F_11F_REV:
+					return createFormat == GL_R11F_G11F_B10F;
+
+				case GL_UNSIGNED_INT_5_9_9_9_REV:
+					return createFormat == GL_RGB9_E5;
+
+				case GL_HALF_FLOAT:
+					return createFormat == GL_RGB16F
+							|| createFormat == GL_R11F_G11F_B10F
+							|| createFormat == GL_RGB9_E5;
+
+				case GL_FLOAT:
+					return createFormat == GL_RGB16F
+							|| createFormat == GL_RGB32F
+							|| createFormat == GL_R11F_G11F_B10F
+							|| createFormat == GL_RGB9_E5;
+
+				default:
+					DE_FATAL("Unknown modify type");
+					return false;
+			}
 
 		case GL_RGBA:
-		case GL_RGBA4:
-		case GL_RGBA8:
-		case GL_RGB5_A1:
-			if (modifyFormat == GL_RGBA
-				|| modifyFormat == GL_RGBA8
-				|| modifyFormat == GL_RGBA4
-				|| modifyFormat == GL_RGB5_A1)
-				return true;
-			else
-				return false;
+			switch (modifyType)
+			{
+				case GL_UNSIGNED_BYTE:
+					return createFormat == GL_RGBA8
+						|| createFormat == GL_RGB5_A1
+						|| createFormat == GL_RGBA4
+						|| createFormat == GL_SRGB8_ALPHA8
+						|| createFormat == GL_RGBA;
 
-		case GL_DEPTH_COMPONENT16:
-		case GL_STENCIL_INDEX8:
-			return false;
+				case GL_UNSIGNED_SHORT_4_4_4_4:
+					return createFormat == GL_RGBA4
+						|| createFormat == GL_RGBA;
+
+				case GL_UNSIGNED_SHORT_5_5_5_1:
+					return createFormat == GL_RGB5_A1
+						|| createFormat == GL_RGBA;
+
+				case GL_UNSIGNED_INT_2_10_10_10_REV:
+					return createFormat == GL_RGB10_A2
+						|| createFormat == GL_RGB5_A1;
+
+				case GL_HALF_FLOAT:
+					return createFormat == GL_RGBA16F;
+
+				case GL_FLOAT:
+					return createFormat == GL_RGBA16F
+						|| createFormat == GL_RGBA32F;
+
+				default:
+					DE_FATAL("Unknown modify type");
+					return false;
+			};
 
 		default:
-			DE_ASSERT(false);
+			DE_FATAL("Unknown modify format");
 			return false;
 	}
 }
@@ -1331,13 +1378,14 @@
 {
 	if (const GLES2ImageApi::Create* gles2Create = dynamic_cast<const GLES2ImageApi::Create*>(&create))
 	{
-		const GLenum createFormat = gles2Create->getFormat();
+		const GLenum createFormat = gles2Create->getEffectiveFormat();
 
 		if (const GLES2ImageApi::ModifyTexSubImage* gles2TexSubImageModify = dynamic_cast<const GLES2ImageApi::ModifyTexSubImage*>(&modify))
 		{
-			const GLenum modifyFormat  = gles2TexSubImageModify->getFormat();
+			const GLenum modifyFormat 	= gles2TexSubImageModify->getFormat();
+			const GLenum modifyType		= gles2TexSubImageModify->getType();
 
-			return isCompatibleFormats(createFormat, modifyFormat);
+			return isCompatibleFormats(createFormat, modifyFormat, modifyType);
 		}
 
 		if (dynamic_cast<const GLES2ImageApi::ModifyRenderbufferClearColor*>(&modify))
diff --git a/modules/egl/teglImageUtil.cpp b/modules/egl/teglImageUtil.cpp
index 1228b8c..169e8c2 100644
--- a/modules/egl/teglImageUtil.cpp
+++ b/modules/egl/teglImageUtil.cpp
@@ -180,7 +180,7 @@
 public:
 							TextureImageSource	(GLenum internalFormat, GLenum format, GLenum type, bool useTexLevel0) : m_internalFormat(internalFormat), m_format(format), m_type(type), m_useTexLevel0(useTexLevel0) {}
 	MovePtr<ClientBuffer>	createBuffer		(const glw::Functions& gl, Texture2D* reference) const;
-	GLenum					getFormat			(void) const { return m_format; }
+	GLenum					getEffectiveFormat	(void) const;
 	GLenum					getInternalFormat	(void) const { return m_internalFormat; }
 
 protected:
@@ -194,6 +194,32 @@
 	const bool				m_useTexLevel0;
 };
 
+bool isSizedFormat (GLenum format)
+{
+	try
+	{
+		glu::mapGLInternalFormat(format);
+		return true;
+	}
+	catch (const tcu::InternalError&)
+	{
+		return false;
+	}
+}
+
+GLenum getEffectiveFormat (GLenum format, GLenum type)
+{
+	return glu::getInternalFormat(glu::mapGLTransferFormat(format, type));
+}
+
+GLenum TextureImageSource::getEffectiveFormat (void) const
+{
+	if (isSizedFormat(m_internalFormat))
+		return m_internalFormat;
+	else
+		return deqp::egl::Image::getEffectiveFormat(m_format, m_type);
+}
+
 AttribMap TextureImageSource::getCreateAttribs (void) const
 {
 	AttribMap ret;
@@ -307,7 +333,7 @@
 
 	string					getRequiredExtension	(void) const 	{ return "EGL_KHR_gl_renderbuffer_image"; }
 	MovePtr<ClientBuffer>	createBuffer			(const glw::Functions& gl, Texture2D* reference) const;
-	GLenum					getFormat				(void) const { return m_format; }
+	GLenum					getEffectiveFormat		(void) const { return m_format; }
 
 protected:
 	EGLenum					getSource				(void) const	{ return EGL_GL_RENDERBUFFER_KHR; }
@@ -492,7 +518,7 @@
 	string					getRequiredExtension	(void) const { fail(); return ""; }
 	MovePtr<ClientBuffer>	createBuffer			(const glw::Functions&, tcu::Texture2D*) const { fail(); return de::MovePtr<ClientBuffer>(); }
 	EGLImageKHR				createImage				(const Library& egl, EGLDisplay dpy, EGLContext ctx, EGLClientBuffer clientBuffer) const;
-	GLenum					getFormat				(void) const { return m_format; }
+	GLenum					getEffectiveFormat		(void) const { return m_format; }
 
 private:
 	const string			m_message;
diff --git a/modules/egl/teglImageUtil.hpp b/modules/egl/teglImageUtil.hpp
index d3c3747..beca1be 100644
--- a/modules/egl/teglImageUtil.hpp
+++ b/modules/egl/teglImageUtil.hpp
@@ -74,7 +74,7 @@
 	virtual std::string					getRequiredExtension(void) const = 0;
 	virtual de::MovePtr<ClientBuffer>	createBuffer		(const glw::Functions& gl, tcu::Texture2D* reference = DE_NULL) const = 0;
 	virtual eglw::EGLImageKHR			createImage			(const eglw::Library& egl, eglw::EGLDisplay dpy, eglw::EGLContext ctx, eglw::EGLClientBuffer clientBuffer) const = 0;
-	virtual glw::GLenum					getFormat			(void) const = 0;
+	virtual glw::GLenum					getEffectiveFormat	(void) const = 0;
 };
 
 de::MovePtr<ImageSource> createTextureImageSource			(eglw::EGLenum source, glw::GLenum internalFormat, glw::GLenum format, glw::GLenum type, bool useTexLevel0 = false);
diff --git a/modules/egl/teglResizeTests.cpp b/modules/egl/teglResizeTests.cpp
index fd250e4..60cc66d 100644
--- a/modules/egl/teglResizeTests.cpp
+++ b/modules/egl/teglResizeTests.cpp
@@ -416,9 +416,10 @@
 					  << TestLog::Image("After resizing", "After resizing", newSurface)
 					  << TestLog::EndImageSet;
 
-				m_status.check(compareCorners(oldSurface, newSurface),
-							   "Resizing the native window changed the contents of "
-							   "the EGL surface");
+				m_status.checkResult(compareCorners(oldSurface, newSurface),
+									 QP_TEST_RESULT_QUALITY_WARNING,
+									 "Resizing the native window changed the contents of "
+									 "the EGL surface");
 			}
 		}
 	}