Merge vk-gl-cts/master into vk-gl-cts/vulkan-cts-next-dev

Change-Id: I61a6ffc581f10ec14c27cb06363daf85b00c8983
diff --git a/external/openglcts/README.md b/external/openglcts/README.md
index 27d5b87..07b9a8f 100644
--- a/external/openglcts/README.md
+++ b/external/openglcts/README.md
@@ -218,11 +218,13 @@
 
 	python external/fetch_sources.py
 
-To download Khronos Confidential Conformance Test Suite, run:
+For OpenGL CTS releases, and OpenGL ES CTS releases prior to opengl-es-cts-3.2.4.0
+download Khronos Confidential Conformance Test Suite:
 
 	python external/fetch_kc_cts.py
 
-The results for the tests included in this suite must be included in a
+For OpenGL CTS releases, and OpenGL ES CTS releases prior to opengl-es-cts-3.2.4.0
+the results for the tests included in this suite must be included in a
 conformance submission.
 
 **NOTE**: You need to be a Khronos Adopter and have an active account
@@ -321,14 +323,14 @@
 
 An Android binary (for ES 3.2) can be built using command:
 
-	python scripts/android/build_apk.py --target=openglcts
+	python scripts/android/build_apk.py --target=openglcts --sdk <path to Android SDK> --ndk <path to Android NDK>
 
 If Khronos Confidential CTS is present then the script will set `GLCTS_GTF_TARGET`
 to `gles32` by default.
 It is possible to specify a different `GLCTS_GTF_TARGET` target by invoking the script
 with the `--kc-cts-target` option, e.g.:
 
-	python scripts/android/build_apk.py --target=openglcts --kc-cts-target=gles31
+	python scripts/android/build_apk.py --target=openglcts --kc-cts-target=gles31 --sdk <path to Android SDK> --ndk <path to Android NDK>
 
 Available values for `--kc-cts-target` are `gles32`, `gles31`, `gles3`, `gles2` and `gl`.
 
@@ -344,12 +346,6 @@
 
 	adb install --abi <ABI name> <build root>/Khronos-CTS.apk /data/local/tmp/Khronos-CTS.apk
 
-The script assumes some default install locations, which should be changed based
-on your environment. It is a good idea to check at least variables
-`ANDROID_NDK_PATH`, `ANDROID_SDK_PATH`, and `ANDROID_NDK_HOST_OS`.
-The `ANDROID_NDK_HOST_OS` is used to select the correct compiler binaries from
-in the Android NDK package.
-
 Porting
 ------------------------
 The Conformance Tests have been designed to be relatively platform-, OS-, and
@@ -409,9 +405,8 @@
 ------------------------
 All the following commands need to be run in the CTS build directory. If you
 need to move the binaries from the build directory, remember to copy the
-data directory named `gl_cts` and its subdirectories from the build directory
-to the test target in the same relative locations. For more information on data
-files, see Section [Data Files](#data-files) later in the document.
+data directories named `gl_cts`, `gles2`, `gles3`, and `gles31` and its subdirectories
+from the build directory to the test target in the same relative locations.
 
 If the build instructions have been followed as-is, the correct path is:
 
diff --git a/external/openglcts/data/mustpass/gles/aosp_mustpass/master/gles2-master.txt b/external/openglcts/data/mustpass/gles/aosp_mustpass/master/gles2-master.txt
index bae638e..b593acc 100644
--- a/external/openglcts/data/mustpass/gles/aosp_mustpass/master/gles2-master.txt
+++ b/external/openglcts/data/mustpass/gles/aosp_mustpass/master/gles2-master.txt
@@ -10235,7 +10235,6 @@
 dEQP-GLES2.functional.shaders.random.all_features.fragment.13
 dEQP-GLES2.functional.shaders.random.all_features.fragment.14
 dEQP-GLES2.functional.shaders.random.all_features.fragment.15
-dEQP-GLES2.functional.shaders.random.all_features.fragment.16
 dEQP-GLES2.functional.shaders.random.all_features.fragment.17
 dEQP-GLES2.functional.shaders.random.all_features.fragment.18
 dEQP-GLES2.functional.shaders.random.all_features.fragment.19
@@ -10275,7 +10274,6 @@
 dEQP-GLES2.functional.shaders.random.all_features.fragment.53
 dEQP-GLES2.functional.shaders.random.all_features.fragment.54
 dEQP-GLES2.functional.shaders.random.all_features.fragment.55
-dEQP-GLES2.functional.shaders.random.all_features.fragment.56
 dEQP-GLES2.functional.shaders.random.all_features.fragment.57
 dEQP-GLES2.functional.shaders.random.all_features.fragment.58
 dEQP-GLES2.functional.shaders.random.all_features.fragment.59
diff --git a/external/openglcts/data/mustpass/gles/aosp_mustpass/master/src/gles2-test-issues.txt b/external/openglcts/data/mustpass/gles/aosp_mustpass/master/src/gles2-test-issues.txt
index 8c9ea65..f8f453c 100644
--- a/external/openglcts/data/mustpass/gles/aosp_mustpass/master/src/gles2-test-issues.txt
+++ b/external/openglcts/data/mustpass/gles/aosp_mustpass/master/src/gles2-test-issues.txt
@@ -65,3 +65,9 @@
 dEQP-GLES2.functional.texture.wrap.mirror_clamp_nearest_pot_rgba8888
 dEQP-GLES2.functional.texture.wrap.mirror_repeat_nearest_pot_rgba8888
 dEQP-GLES2.functional.texture.wrap.mirror_mirror_nearest_pot_rgba8888
+
+# Bug 18323060
+dEQP-GLES2.functional.shaders.random.all_features.fragment.16
+
+# Bug 21851700
+dEQP-GLES2.functional.shaders.random.all_features.fragment.56
diff --git a/external/openglcts/modules/glesext/texture_cube_map_array/esextcTextureCubeMapArrayETC2Support.cpp b/external/openglcts/modules/glesext/texture_cube_map_array/esextcTextureCubeMapArrayETC2Support.cpp
index d1200ff..8ebf7d3 100644
--- a/external/openglcts/modules/glesext/texture_cube_map_array/esextcTextureCubeMapArrayETC2Support.cpp
+++ b/external/openglcts/modules/glesext/texture_cube_map_array/esextcTextureCubeMapArrayETC2Support.cpp
@@ -67,6 +67,7 @@
  */
 tcu::TestCase::IterateResult TextureCubeMapArrayETC2Support::iterate(void)
 {
+	prepareFramebuffer();
 	prepareProgram();
 	prepareVertexArrayObject();
 	prepareTexture();
@@ -81,6 +82,34 @@
 	return STOP;
 }
 
+/** @brief Bind default framebuffer object.
+ *
+ *  @note The function may throw if unexpected error has occured.
+ */
+void TextureCubeMapArrayETC2Support::prepareFramebuffer()
+{
+	/* Shortcut for GL functionality */
+	const glw::Functions& gl = m_context.getRenderContext().getFunctions();
+
+	gl.genRenderbuffers(1, &m_rbo);
+	GLU_EXPECT_NO_ERROR(gl.getError(), "glGenRenderbuffers call failed.");
+
+	gl.bindRenderbuffer(GL_RENDERBUFFER, m_rbo);
+	GLU_EXPECT_NO_ERROR(gl.getError(), "glBindRenderbuffer call failed.");
+
+	gl.renderbufferStorage(GL_RENDERBUFFER, GL_RGBA8, RENDER_WIDTH, RENDER_HEIGHT);
+	GLU_EXPECT_NO_ERROR(gl.getError(), "glRenderbufferStorage call failed.");
+
+	gl.genFramebuffers(1, &m_fbo);
+	GLU_EXPECT_NO_ERROR(gl.getError(), "glGenFramebuffers call failed.");
+
+	gl.bindFramebuffer(GL_FRAMEBUFFER, m_fbo);
+	GLU_EXPECT_NO_ERROR(gl.getError(), "glBindFramebuffer call failed.");
+
+	gl.framebufferRenderbuffer(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_RENDERBUFFER, m_rbo);
+	GLU_EXPECT_NO_ERROR(gl.getError(), "glFramebufferRenderbuffer call failed.");
+}
+
 /** @brief Function generate and bind empty vertex array object.
  *
  *  @note The function may throw if unexpected error has occured.
diff --git a/external/openglcts/modules/glesext/texture_cube_map_array/esextcTextureCubeMapArrayETC2Support.hpp b/external/openglcts/modules/glesext/texture_cube_map_array/esextcTextureCubeMapArrayETC2Support.hpp
index a1a899a..f0529d0 100644
--- a/external/openglcts/modules/glesext/texture_cube_map_array/esextcTextureCubeMapArrayETC2Support.hpp
+++ b/external/openglcts/modules/glesext/texture_cube_map_array/esextcTextureCubeMapArrayETC2Support.hpp
@@ -42,6 +42,7 @@
 	virtual IterateResult iterate(void);
 
 protected:
+	void prepareFramebuffer();
 	void prepareVertexArrayObject();
 	void prepareProgram();
 	void prepareTexture();
diff --git a/framework/common/tcuFuzzyImageCompare.cpp b/framework/common/tcuFuzzyImageCompare.cpp
index 4e76476..6aa62ab 100644
--- a/framework/common/tcuFuzzyImageCompare.cpp
+++ b/framework/common/tcuFuzzyImageCompare.cpp
@@ -318,7 +318,7 @@
 
 	for (int y = 1; y < height-1; y++)
 	{
-		for (int x = 1; x < width-1; x += 1 + (int)rnd.getInt(0, params.maxSampleSkip))
+		for (int x = 1; x < width-1; x += params.maxSampleSkip > 0 ? (int)rnd.getInt(1, params.maxSampleSkip) : 1)
 		{
 			const deUint32	minDist2RefToCmp	= distSquaredToNeighbor<4>(rnd, readUnorm8<4>(refAccess, x, y), cmpAccess, x, y);
 			const deUint32	minDist2CmpToRef	= distSquaredToNeighbor<4>(rnd, readUnorm8<4>(cmpAccess, x, y), refAccess, x, y);