Fixes arrays of arrays tests

Tests were requiring more ssbos in shaders
than what the implementation supports

VK-GL-CTS Public Issue: 324
Components: OpenGL

Affects either:
KHR-GL46.arrays_of_arrays_gl.InteractionInterfaceArrays1
or
KHR-Single-GL46.arrays_of_arrays_gl.InteractionInterfaceArrays1
depending on branch.

Change-Id: I8664e7b85ff78b93aeb52c4e0739a4cc3c14e6aa
diff --git a/external/openglcts/modules/gles31/es31cArrayOfArraysTests.cpp b/external/openglcts/modules/gles31/es31cArrayOfArraysTests.cpp
index 10e19fd..dafd184 100644
--- a/external/openglcts/modules/gles31/es31cArrayOfArraysTests.cpp
+++ b/external/openglcts/modules/gles31/es31cArrayOfArraysTests.cpp
@@ -1001,6 +1001,68 @@
 	return CONTINUE;
 }
 
+/** Check that the shader supports the number of SSBOs used in the test.
+ *  The number of active shader storage blocks referenced by the shaders in a program implementation dependent and cannot exceeds
+ *  implementation-dependent limits. The limits for vertex, tessellation control, tessellation evaluation and geometry can be obtained
+ *  by calling GetIntegerv with pname values of MAX_VERTEX_SHADER_STORAGE_BLOCKS, MAX_TESS_CONTROL_SHADER_STORAGE_BLOCKS,
+ *  MAX_TESS_EVALUATION_SHADER_STORAGE_BLOCKS and MAX_GEOMETRY_SHADER_STORAGE_BLOCKS, respectively.
+ *
+ * @tparam API                  Tested API descriptor
+ *
+ * @param tested_shader_type    The type of shader used.
+ * @param num                   The number of SSBOs used in shader.
+ *
+ *  @return STOP     - test is not supported by the implementation;
+ *          CONTINUE - test is supported by the implementation;
+ **/
+template <class API>
+tcu::TestNode::IterateResult TestCaseBase<API>::limit_active_shader_storage_block_number(
+	typename TestCaseBase<API>::TestShaderType tested_shader_type, size_t num)
+{
+	const glw::Functions& gl = context_id.getRenderContext().getFunctions();
+	glw::GLint res;
+
+	switch (tested_shader_type)
+	{
+	case TestCaseBase<API>::VERTEX_SHADER_TYPE:
+		gl.getIntegerv(GL_MAX_VERTEX_SHADER_STORAGE_BLOCKS, &res);
+		if (static_cast<size_t>(res) < num)
+		{
+			tcu::NotSupportedError(
+				"The number of active vertex shader storage blocks exceeds implementation-dependent limits.");
+			return STOP;
+		}
+		break;
+	case TestCaseBase<API>::TESSELATION_CONTROL_SHADER_TYPE:
+		gl.getIntegerv(GL_MAX_TESS_CONTROL_SHADER_STORAGE_BLOCKS, &res);
+		if (static_cast<size_t>(res) < num)
+		{
+			tcu::NotSupportedError("The number of active TC shader storage blocks exceeds implementation-dependent limits.");
+			return STOP;
+		}
+		break;
+	case TestCaseBase<API>::TESSELATION_EVALUATION_SHADER_TYPE:
+		gl.getIntegerv(GL_MAX_TESS_EVALUATION_SHADER_STORAGE_BLOCKS, &res);
+		if (static_cast<size_t>(res) < num)
+		{
+			tcu::NotSupportedError("The number of active TE shader storage blocks exceeds implementation-dependent limits.");
+			return STOP;
+		}
+		break;
+	case TestCaseBase<API>::GEOMETRY_SHADER_TYPE:
+		gl.getIntegerv(GL_MAX_GEOMETRY_SHADER_STORAGE_BLOCKS, &res);
+		if (static_cast<size_t>(res) < num)
+		{
+			tcu::NotSupportedError("The number of active geometry shader storage blocks exceeds implementation-dependent limits.");
+			return STOP;
+		}
+		break;
+	default:
+		break;
+	}
+	return CONTINUE;
+}
+
 /** Runs the positive test.
  *  The shader sources are considered as valid,
  *  and the compilation and program linking are expected to succeed.
diff --git a/external/openglcts/modules/gles31/es31cArrayOfArraysTests.hpp b/external/openglcts/modules/gles31/es31cArrayOfArraysTests.hpp
index 90bb6b0..1e810b2 100644
--- a/external/openglcts/modules/gles31/es31cArrayOfArraysTests.hpp
+++ b/external/openglcts/modules/gles31/es31cArrayOfArraysTests.hpp
@@ -292,6 +292,9 @@
 															   const std::string& compute_shader_source,
 															   bool delete_generated_objects, bool require_gpu_shader5);
 
+	virtual tcu::TestNode::IterateResult limit_active_shader_storage_block_number(
+		typename TestCaseBase<API>::TestShaderType tested_shader_type, size_t number_of_blocks);
+
 	virtual void test_shader_compilation(typename TestCaseBase<API>::TestShaderType tested_shader_type) = 0;
 
 	/* Protected fields */