Allow not supporting separate depth/stencil with combined formats

Components: OpenGL
Affects: dEQP-GLES3.functional.fbo.*

Change-Id: I2eb2433921b3d8f7da30d5d546c07da46bebb343
diff --git a/external/fetch_sources.py b/external/fetch_sources.py
index f3003de..b4a5cd4 100644
--- a/external/fetch_sources.py
+++ b/external/fetch_sources.py
@@ -299,9 +299,9 @@
 
 PACKAGES = [
 	SourcePackage(
-		"http://zlib.net/zlib-1.2.12.tar.gz",
-		"zlib-1.2.12.tar.gz",
-		"91844808532e5ce316b3c010929493c0244f3d37593afd6de04f71821d5136d9",
+		"http://zlib.net/zlib-1.2.13.tar.gz",
+		"zlib-1.2.13.tar.gz",
+		"b3a24de97a8fdbc835b9833169501030b8977031bcb54b3b3ac13740f846ab30",
 		"zlib"),
 	SourcePackage(
 		"http://prdownloads.sourceforge.net/libpng/libpng-1.6.27.tar.gz",
diff --git a/modules/gles2/functional/es2fFboCompletenessTests.cpp b/modules/gles2/functional/es2fFboCompletenessTests.cpp
index f1333b5..5e8dc7d 100644
--- a/modules/gles2/functional/es2fFboCompletenessTests.cpp
+++ b/modules/gles2/functional/es2fFboCompletenessTests.cpp
@@ -230,7 +230,7 @@
 class ES2Checker : public Checker
 {
 public:
-			ES2Checker				(const glu::RenderContext& ctx);
+			ES2Checker				(const glu::RenderContext& ctx, const FormatDB& formats);
 	void	check					(GLenum attPoint, const Attachment& att,
 									 const Image* image);
 private:
@@ -238,8 +238,8 @@
 	GLsizei	m_height;	//< The common height of images
 };
 
-ES2Checker::ES2Checker (const glu::RenderContext& ctx)\
-	: Checker		(ctx)
+ES2Checker::ES2Checker (const glu::RenderContext& ctx, const FormatDB& formats)\
+	: Checker		(ctx, formats)
 	, m_width		(-1)
 	, m_height		(-1)
 {
@@ -373,7 +373,7 @@
 class ES2CheckerFactory : public CheckerFactory
 {
 public:
-	Checker*			createChecker	(const glu::RenderContext& ctx) { return new ES2Checker(ctx); }
+	Checker*			createChecker	(const glu::RenderContext& ctx, const FormatDB& formats) { return new ES2Checker(ctx, formats); }
 };
 
 class TestGroup : public TestCaseGroup
diff --git a/modules/gles3/functional/es3fFboCompletenessTests.cpp b/modules/gles3/functional/es3fFboCompletenessTests.cpp
index 3a65a00..2e6b351 100644
--- a/modules/gles3/functional/es3fFboCompletenessTests.cpp
+++ b/modules/gles3/functional/es3fFboCompletenessTests.cpp
@@ -24,6 +24,7 @@
 #include "es3fFboCompletenessTests.hpp"
 
 #include "glsFboCompletenessTests.hpp"
+#include "deUniquePtr.hpp"
 #include <sstream>
 
 using namespace glw;
@@ -187,20 +188,24 @@
 class ES3Checker : public Checker
 {
 public:
-				ES3Checker	(const glu::RenderContext& ctx)
-					: Checker				(ctx)
+				ES3Checker	(const glu::RenderContext& ctx, const FormatDB& formats)
+					: Checker				(ctx, formats)
+					, m_ctxInfo				(glu::ContextInfo::create(ctx))
 					, m_numSamples			(-1)
 					, m_depthStencilImage	(0)
 					, m_depthStencilType	(GL_NONE) {}
 	void		check		(GLenum attPoint, const Attachment& att, const Image* image);
 
 private:
+	de::UniquePtr<glu::ContextInfo> m_ctxInfo;
+
 	//! The common number of samples of images.
 	GLsizei		m_numSamples;
 
 	//! The common image for depth and stencil attachments.
 	GLuint		m_depthStencilImage;
 	GLenum		m_depthStencilType;
+	ImageFormat	m_depthStencilFormat;
 };
 
 void ES3Checker::check (GLenum attPoint, const Attachment& att, const Image* image)
@@ -237,18 +242,28 @@
 			addPotentialFBOStatus(GL_FRAMEBUFFER_INCOMPLETE_MULTISAMPLE, "Number of samples differ");
 	}
 
-	// "Depth and stencil attachments, if present, are the same image."
 	if (attPoint == GL_DEPTH_ATTACHMENT || attPoint == GL_STENCIL_ATTACHMENT)
 	{
 		if (m_depthStencilImage == 0)
 		{
 			m_depthStencilImage = att.imageName;
 			m_depthStencilType = attachmentType(att);
+			m_depthStencilFormat = image->internalFormat;
 		}
-		else
+		else if (m_depthStencilImage != att.imageName || m_depthStencilType != attachmentType(att))
 		{
-			if (m_depthStencilImage != att.imageName || m_depthStencilType != attachmentType(att))
+			// "Depth and stencil attachments, if present, are the same image."
+			if (!m_ctxInfo->isExtensionSupported("GL_EXT_separate_depth_stencil"))
 				addFBOStatus(GL_FRAMEBUFFER_UNSUPPORTED, "Depth and stencil attachments are not the same image");
+
+			// "The combination of internal formats of the attached images does not violate
+			//  an implementation-dependent set of restrictions."
+			ImageFormat depthFormat = attPoint == GL_DEPTH_ATTACHMENT ? image->internalFormat : m_depthStencilFormat;
+			ImageFormat stencilFormat = attPoint == GL_STENCIL_ATTACHMENT ? image->internalFormat : m_depthStencilFormat;
+			if (m_formats.getFormatInfo(depthFormat) & STENCIL_RENDERABLE)
+				addPotentialFBOStatus(GL_FRAMEBUFFER_UNSUPPORTED, "Separate depth attachment has combined depth and stencil format");
+			if (m_formats.getFormatInfo(stencilFormat) & DEPTH_RENDERABLE)
+				addPotentialFBOStatus(GL_FRAMEBUFFER_UNSUPPORTED, "Separate stencil attachment has combined depth and stencil format");
 		}
 	}
 }
@@ -448,7 +463,7 @@
 class ES3CheckerFactory : public CheckerFactory
 {
 public:
-	Checker*			createChecker	(const glu::RenderContext& ctx) { return new ES3Checker(ctx); }
+	Checker*			createChecker	(const glu::RenderContext& ctx, const FormatDB& formats) { return new ES3Checker(ctx, formats); }
 };
 
 class TestGroup : public TestCaseGroup
diff --git a/modules/glshared/glsBuiltinPrecisionTests.cpp b/modules/glshared/glsBuiltinPrecisionTests.cpp
index a4d7842..bbb0bd4 100644
--- a/modules/glshared/glsBuiltinPrecisionTests.cpp
+++ b/modules/glshared/glsBuiltinPrecisionTests.cpp
@@ -3560,7 +3560,7 @@
 		// Khronos bug 11180 consensus: if exp2(exponent) cannot be represented,
 		// the result is undefined.
 
-		if (ret.contains(TCU_INFINITY) | ret.contains(-TCU_INFINITY))
+		if (ret.contains(TCU_INFINITY) || ret.contains(-TCU_INFINITY))
 			ret |= TCU_NAN;
 
 		return call<Mul>(ctx, iargs.a, ret);
diff --git a/modules/glshared/glsFboUtil.cpp b/modules/glshared/glsFboUtil.cpp
index 0c27670..e728410 100644
--- a/modules/glshared/glsFboUtil.cpp
+++ b/modules/glshared/glsFboUtil.cpp
@@ -518,8 +518,8 @@
 
 using namespace config;
 
-Checker::Checker (const glu::RenderContext& ctx)
-	: m_renderCtx(ctx)
+Checker::Checker (const glu::RenderContext& ctx, const FormatDB& formats)
+	: m_renderCtx(ctx), m_formats(formats)
 {
 	m_statusCodes.setAllowComplete(true);
 }
@@ -573,7 +573,7 @@
 ValidStatusCodes FboVerifier::validStatusCodes (const Framebuffer& fboConfig) const
 {
 	const AttachmentMap& atts = fboConfig.attachments;
-	const UniquePtr<Checker> cctx(m_factory.createChecker(m_renderCtx));
+	const UniquePtr<Checker> cctx(m_factory.createChecker(m_renderCtx, m_formats));
 
 	for (TextureMap::const_iterator it = fboConfig.textures.begin();
 		 it != fboConfig.textures.end(); it++)
diff --git a/modules/glshared/glsFboUtil.hpp b/modules/glshared/glsFboUtil.hpp
index 6affa68..58ecb29 100644
--- a/modules/glshared/glsFboUtil.hpp
+++ b/modules/glshared/glsFboUtil.hpp
@@ -393,7 +393,7 @@
 class Checker
 {
 public:
-								Checker					(const glu::RenderContext&);
+								Checker					(const glu::RenderContext&, const FormatDB&);
 	virtual						~Checker				(void) {}
 
 	void						addGLError				(glw::GLenum error, const char* description);
@@ -409,6 +409,7 @@
 
 protected:
 	const glu::RenderContext&	m_renderCtx;
+	const FormatDB&			m_formats;
 
 private:
 	ValidStatusCodes			m_statusCodes;	//< Allowed return values for glCheckFramebufferStatus.
@@ -417,7 +418,7 @@
 class CheckerFactory
 {
 public:
-	virtual Checker*	createChecker	(const glu::RenderContext&) = 0;
+	virtual Checker*	createChecker	(const glu::RenderContext&, const FormatDB&) = 0;
 };
 
 typedef std::set<glw::GLenum> AttachmentPoints;