am 910108c4: Merge "Add negative tests for explicit TCS-TES varying arrays."

* commit '910108c42f58ed92c575e406808290bc71f3b182':
  Add negative tests for explicit TCS-TES varying arrays.
diff --git a/android/cts/master/src/gles31-new-tests.txt b/android/cts/master/src/gles31-new-tests.txt
new file mode 100644
index 0000000..85003ca
--- /dev/null
+++ b/android/cts/master/src/gles31-new-tests.txt
@@ -0,0 +1,5 @@
+# Feature Request 21737242
+dEQP-GLES31.functional.tessellation.user_defined_io.negative.per_vertex_incorrect_control_explicit_output_array_size_1
+dEQP-GLES31.functional.tessellation.user_defined_io.negative.per_vertex_incorrect_control_explicit_output_array_size_2
+dEQP-GLES31.functional.tessellation.user_defined_io.negative.per_vertex_incorrect_control_explicit_output_array_size_3
+dEQP-GLES31.functional.tessellation.user_defined_io.negative.per_vertex_incorrect_eval_explicit_input_array_size
diff --git a/data/gles31/shaders/tessellation_negative_user_defined_io.test b/data/gles31/shaders/tessellation_negative_user_defined_io.test
index 36bd5e7..32ae315 100644
--- a/data/gles31/shaders/tessellation_negative_user_defined_io.test
+++ b/data/gles31/shaders/tessellation_negative_user_defined_io.test
@@ -114,3 +114,187 @@
 		}
 	""
 end
+
+case per_vertex_incorrect_control_explicit_output_array_size_1
+	version 310 es
+	desc "Incorrectly sized tessellation control output array"
+	expect compile_or_link_fail
+	require extension { "GL_OES_tessellation_shader" | "GL_EXT_tessellation_shader" } in { tessellation_control, tessellation_evaluation }
+	vertex ""
+		#version 310 es
+		${VERTEX_DECLARATIONS}
+		void main()
+		{
+			${VERTEX_OUTPUT}
+		}
+	""
+	tessellation_control ""
+		#version 310 es
+		${TESSELLATION_CONTROL_DECLARATIONS}
+		out highp float varyingArray[3]; // size is not equal to gl_MaxPatchVertices
+		void main()
+		{
+			varyingArray[gl_InvocationID] = gl_in[0].gl_Position[gl_InvocationID];
+			${TESSELLATION_CONTROL_OUTPUT}
+		}
+	""
+	tessellation_evaluation ""
+		#version 310 es
+		${TESSELLATION_EVALUATION_DECLARATIONS}
+		in highp float varyingArray[gl_MaxPatchVertices]; // size is correct
+		out mediump float te_out;
+		void main()
+		{
+			te_out = varyingArray[0] * gl_TessCoord.x + varyingArray[1] * gl_TessCoord.y + varyingArray[2];
+			${TESSELLATION_EVALUATION_OUTPUT}
+		}
+	""
+	fragment ""
+		#version 310 es
+		precision mediump float;
+		${FRAGMENT_DECLARATIONS}
+		in mediump float te_out;
+		void main()
+		{
+			${FRAG_COLOR} = vec4(te_out);
+		}
+	""
+end
+
+case per_vertex_incorrect_control_explicit_output_array_size_2
+	version 310 es
+	desc "Incorrectly sized tessellation control output array"
+	expect compile_or_link_fail
+	require extension { "GL_OES_tessellation_shader" | "GL_EXT_tessellation_shader" } in { tessellation_control, tessellation_evaluation }
+	vertex ""
+		#version 310 es
+		${VERTEX_DECLARATIONS}
+		void main()
+		{
+			${VERTEX_OUTPUT}
+		}
+	""
+	tessellation_control ""
+		#version 310 es
+		${TESSELLATION_CONTROL_DECLARATIONS}
+		out highp float varyingArray[gl_MaxPatchVertices]; // size does not match layout declaration
+		void main()
+		{
+			varyingArray[gl_InvocationID] = gl_in[0].gl_Position[gl_InvocationID];
+			${TESSELLATION_CONTROL_OUTPUT}
+		}
+	""
+	tessellation_evaluation ""
+		#version 310 es
+		${TESSELLATION_EVALUATION_DECLARATIONS}
+		in highp float varyingArray[gl_MaxPatchVertices]; // size is correct
+		out mediump float te_out;
+		void main()
+		{
+			te_out = varyingArray[0] * gl_TessCoord.x + varyingArray[1] * gl_TessCoord.y + varyingArray[2];
+			${TESSELLATION_EVALUATION_OUTPUT}
+		}
+	""
+	fragment ""
+		#version 310 es
+		precision mediump float;
+		${FRAGMENT_DECLARATIONS}
+		in mediump float te_out;
+		void main()
+		{
+			${FRAG_COLOR} = vec4(te_out);
+		}
+	""
+end
+
+case per_vertex_incorrect_control_explicit_output_array_size_3
+	version 310 es
+	desc "Incorrectly sized tessellation control output array"
+	expect compile_or_link_fail
+	require extension { "GL_OES_tessellation_shader" | "GL_EXT_tessellation_shader" } in { tessellation_control, tessellation_evaluation }
+	vertex ""
+		#version 310 es
+		${VERTEX_DECLARATIONS}
+		void main()
+		{
+			${VERTEX_OUTPUT}
+		}
+	""
+	tessellation_control ""
+		#version 310 es
+		${TESSELLATION_CONTROL_DECLARATIONS}
+		out highp float varyingArray[${GL_MAX_PATCH_VERTICES}]; // size does not match layout declaration
+		void main()
+		{
+			varyingArray[gl_InvocationID] = gl_in[0].gl_Position[gl_InvocationID];
+			${TESSELLATION_CONTROL_OUTPUT}
+		}
+	""
+	tessellation_evaluation ""
+		#version 310 es
+		${TESSELLATION_EVALUATION_DECLARATIONS}
+		in highp float varyingArray[gl_MaxPatchVertices]; // size is correct
+		out mediump float te_out;
+		void main()
+		{
+			te_out = varyingArray[0] * gl_TessCoord.x + varyingArray[1] * gl_TessCoord.y + varyingArray[2];
+			${TESSELLATION_EVALUATION_OUTPUT}
+		}
+	""
+	fragment ""
+		#version 310 es
+		precision mediump float;
+		${FRAGMENT_DECLARATIONS}
+		in mediump float te_out;
+		void main()
+		{
+			${FRAG_COLOR} = vec4(te_out);
+		}
+	""
+end
+
+case per_vertex_incorrect_eval_explicit_input_array_size
+	version 310 es
+	desc "Incorrectly sized tessellation control output array"
+	expect compile_or_link_fail
+	require extension { "GL_OES_tessellation_shader" | "GL_EXT_tessellation_shader" } in { tessellation_control, tessellation_evaluation }
+	vertex ""
+		#version 310 es
+		${VERTEX_DECLARATIONS}
+		void main()
+		{
+			${VERTEX_OUTPUT}
+		}
+	""
+	tessellation_control ""
+		#version 310 es
+		${TESSELLATION_CONTROL_DECLARATIONS}
+		out highp float varyingArray[];
+		void main()
+		{
+			varyingArray[gl_InvocationID] = gl_in[0].gl_Position[gl_InvocationID];
+			${TESSELLATION_CONTROL_OUTPUT}
+		}
+	""
+	tessellation_evaluation ""
+		#version 310 es
+		${TESSELLATION_EVALUATION_DECLARATIONS}
+		in highp float varyingArray[3]; // size is not equal to gl_MaxPatchVertices
+		out mediump float te_out;
+		void main()
+		{
+			te_out = varyingArray[0] * gl_TessCoord.x + varyingArray[1] * gl_TessCoord.y + varyingArray[2];
+			${TESSELLATION_EVALUATION_OUTPUT}
+		}
+	""
+	fragment ""
+		#version 310 es
+		precision mediump float;
+		${FRAGMENT_DECLARATIONS}
+		in mediump float te_out;
+		void main()
+		{
+			${FRAG_COLOR} = vec4(te_out);
+		}
+	""
+end
diff --git a/modules/glshared/glsShaderLibraryCase.cpp b/modules/glshared/glsShaderLibraryCase.cpp
index 7a4e366..a37bb47 100644
--- a/modules/glshared/glsShaderLibraryCase.cpp
+++ b/modules/glshared/glsShaderLibraryCase.cpp
@@ -85,6 +85,17 @@
 	return version != glu::GLSL_VERSION_100_ES;
 }
 
+static int queryGLInt (const glu::RenderContext& renderCtx, deUint32 pname)
+{
+	const glw::Functions&	gl		= renderCtx.getFunctions();
+	glw::GLint				value	= 0;
+
+	gl.getIntegerv(pname, &value);
+	GLU_EXPECT_NO_ERROR(gl.getError(), ("query " + de::toString(glu::getGettableStateStr(pname))).c_str());
+
+	return value;
+}
+
 ShaderCase::ValueBlock::ValueBlock (void)
 	: arrayLength(0)
 {
@@ -1493,7 +1504,7 @@
 	return withExt;
 }
 
-static map<string, string> generateVertexSpecialization (glu::GLSLVersion targetVersion, const ShaderCase::ValueBlock& valueBlock)
+static map<string, string> generateVertexSpecialization (const glu::RenderContext& renderCtx, glu::GLSLVersion targetVersion, const ShaderCase::ValueBlock& valueBlock)
 {
 	const bool				usesInout	= usesShaderInoutQualifiers(targetVersion);
 	const char*				vtxIn		= usesInout ? "in" : "attribute";
@@ -1501,6 +1512,8 @@
 	ostringstream			setup;
 	map<string, string>		params;
 
+	DE_UNREF(renderCtx);
+
 	decl << vtxIn << " highp vec4 dEQP_Position;\n";
 
 	for (int ndx = 0; ndx < (int)valueBlock.values.size(); ndx++)
@@ -1534,7 +1547,7 @@
 	return params;
 }
 
-static map<string, string> generateFragmentSpecialization (glu::GLSLVersion targetVersion, const ShaderCase::ValueBlock& valueBlock)
+static map<string, string> generateFragmentSpecialization (const glu::RenderContext& renderCtx, glu::GLSLVersion targetVersion, const ShaderCase::ValueBlock& valueBlock)
 {
 	const bool			usesInout		= usesShaderInoutQualifiers(targetVersion);
 	const bool			customColorOut	= usesInout;
@@ -1543,6 +1556,8 @@
 	ostringstream		output;
 	map<string, string>	params;
 
+	DE_UNREF(renderCtx);
+
 	genCompareFunctions(decl, valueBlock, false);
 	genCompareOp(output, fragColor, valueBlock, "", DE_NULL);
 
@@ -1573,11 +1588,12 @@
 	return params;
 }
 
-static map<string, string> generateGeometrySpecialization (glu::GLSLVersion targetVersion, const ShaderCase::ValueBlock& valueBlock)
+static map<string, string> generateGeometrySpecialization (const glu::RenderContext& renderCtx, glu::GLSLVersion targetVersion, const ShaderCase::ValueBlock& valueBlock)
 {
 	ostringstream		decl;
 	map<string, string>	params;
 
+	DE_UNREF(renderCtx);
 	DE_UNREF(targetVersion);
 
 	decl << "layout (triangles) in;\n";
@@ -1601,7 +1617,7 @@
 	return params;
 }
 
-static map<string, string> generateTessControlSpecialization (glu::GLSLVersion targetVersion, const ShaderCase::ValueBlock& valueBlock)
+static map<string, string> generateTessControlSpecialization (const glu::RenderContext& renderCtx, glu::GLSLVersion targetVersion, const ShaderCase::ValueBlock& valueBlock)
 {
 	ostringstream		decl;
 	ostringstream		output;
@@ -1635,10 +1651,11 @@
 
 	params.insert(pair<string, string>("TESSELLATION_CONTROL_DECLARATIONS",	decl.str()));
 	params.insert(pair<string, string>("TESSELLATION_CONTROL_OUTPUT",		output.str()));
+	params.insert(pair<string, string>("GL_MAX_PATCH_VERTICES",				de::toString(queryGLInt(renderCtx, GL_MAX_PATCH_VERTICES))));
 	return params;
 }
 
-static map<string, string> generateTessEvalSpecialization (glu::GLSLVersion targetVersion, const ShaderCase::ValueBlock& valueBlock)
+static map<string, string> generateTessEvalSpecialization (const glu::RenderContext& renderCtx, glu::GLSLVersion targetVersion, const ShaderCase::ValueBlock& valueBlock)
 {
 	ostringstream		decl;
 	ostringstream		output;
@@ -1666,14 +1683,22 @@
 
 	params.insert(pair<string, string>("TESSELLATION_EVALUATION_DECLARATIONS",	decl.str()));
 	params.insert(pair<string, string>("TESSELLATION_EVALUATION_OUTPUT",		output.str()));
+	params.insert(pair<string, string>("GL_MAX_PATCH_VERTICES",					de::toString(queryGLInt(renderCtx, GL_MAX_PATCH_VERTICES))));
 	return params;
 }
 
-static void specializeShaders (glu::ProgramSources& dst, glu::ShaderType shaderType, const std::vector<std::string>& sources, const ShaderCase::ValueBlock& valueBlock, glu::GLSLVersion targetVersion, const std::vector<ShaderCase::CaseRequirement>& requirements, std::map<std::string, std::string> (*specializationGenerator)(glu::GLSLVersion, const ShaderCase::ValueBlock&))
+static void specializeShaders (const glu::RenderContext&						renderCtx,
+							   glu::ProgramSources&								dst,
+							   glu::ShaderType									shaderType,
+							   const std::vector<std::string>&					sources,
+							   const ShaderCase::ValueBlock&					valueBlock,
+							   glu::GLSLVersion									targetVersion,
+							   const std::vector<ShaderCase::CaseRequirement>&	requirements,
+							   std::map<std::string, std::string>				(*specializationGenerator)(const glu::RenderContext&, glu::GLSLVersion, const ShaderCase::ValueBlock&))
 {
 	if (!sources.empty())
 	{
-		const std::map<std::string, std::string> specializationParams = specializationGenerator(targetVersion, valueBlock);
+		const std::map<std::string, std::string> specializationParams = specializationGenerator(renderCtx, targetVersion, valueBlock);
 
 		for (int ndx = 0; ndx < (int)sources.size(); ++ndx)
 		{
@@ -1688,27 +1713,27 @@
 
 void ShaderCase::specializeVertexShaders (glu::ProgramSources& dst, const std::vector<std::string>& sources, const ValueBlock& valueBlock, const std::vector<ShaderCase::CaseRequirement>& requirements) const
 {
-	specializeShaders(dst, glu::SHADERTYPE_VERTEX, sources, valueBlock, m_targetVersion, requirements, generateVertexSpecialization);
+	specializeShaders(m_renderCtx, dst, glu::SHADERTYPE_VERTEX, sources, valueBlock, m_targetVersion, requirements, generateVertexSpecialization);
 }
 
 void ShaderCase::specializeFragmentShaders (glu::ProgramSources& dst, const std::vector<std::string>& sources, const ValueBlock& valueBlock, const std::vector<ShaderCase::CaseRequirement>& requirements) const
 {
-	specializeShaders(dst, glu::SHADERTYPE_FRAGMENT, sources, valueBlock, m_targetVersion, requirements, generateFragmentSpecialization);
+	specializeShaders(m_renderCtx, dst, glu::SHADERTYPE_FRAGMENT, sources, valueBlock, m_targetVersion, requirements, generateFragmentSpecialization);
 }
 
 void ShaderCase::specializeGeometryShaders (glu::ProgramSources& dst, const std::vector<std::string>& sources, const ValueBlock& valueBlock, const std::vector<ShaderCase::CaseRequirement>& requirements) const
 {
-	specializeShaders(dst, glu::SHADERTYPE_GEOMETRY, sources, valueBlock, m_targetVersion, requirements, generateGeometrySpecialization);
+	specializeShaders(m_renderCtx, dst, glu::SHADERTYPE_GEOMETRY, sources, valueBlock, m_targetVersion, requirements, generateGeometrySpecialization);
 }
 
 void ShaderCase::specializeTessControlShaders (glu::ProgramSources& dst, const std::vector<std::string>& sources, const ValueBlock& valueBlock, const std::vector<ShaderCase::CaseRequirement>& requirements) const
 {
-	specializeShaders(dst, glu::SHADERTYPE_TESSELLATION_CONTROL, sources, valueBlock, m_targetVersion, requirements, generateTessControlSpecialization);
+	specializeShaders(m_renderCtx, dst, glu::SHADERTYPE_TESSELLATION_CONTROL, sources, valueBlock, m_targetVersion, requirements, generateTessControlSpecialization);
 }
 
 void ShaderCase::specializeTessEvalShaders (glu::ProgramSources& dst, const std::vector<std::string>& sources, const ValueBlock& valueBlock, const std::vector<ShaderCase::CaseRequirement>& requirements) const
 {
-	specializeShaders(dst, glu::SHADERTYPE_TESSELLATION_EVALUATION, sources, valueBlock, m_targetVersion, requirements, generateTessEvalSpecialization);
+	specializeShaders(m_renderCtx, dst, glu::SHADERTYPE_TESSELLATION_EVALUATION, sources, valueBlock, m_targetVersion, requirements, generateTessEvalSpecialization);
 }
 
 void ShaderCase::dumpValues (const ValueBlock& valueBlock, int arrayNdx)
diff --git a/scripts/build_android_mustpass.py b/scripts/build_android_mustpass.py
index 8f987f7..d81362b 100644
--- a/scripts/build_android_mustpass.py
+++ b/scripts/build_android_mustpass.py
@@ -488,6 +488,7 @@
 		exclude("gles31-hw-issues.txt"),
 		exclude("gles31-test-issues.txt"),
 		exclude("gles31-spec-issues.txt"),
+		exclude("gles31-new-tests.txt"),
 	]
 MASTER_GLES31_PKG				= Package(module = GLES31_MODULE, configurations = [
 		# Master