• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*-------------------------------------------------------------------------
2  * drawElements Quality Program OpenGL ES 3.1 Module
3  * -------------------------------------------------
4  *
5  * Copyright 2014 The Android Open Source Project
6  *
7  * Licensed under the Apache License, Version 2.0 (the "License");
8  * you may not use this file except in compliance with the License.
9  * You may obtain a copy of the License at
10  *
11  *      http://www.apache.org/licenses/LICENSE-2.0
12  *
13  * Unless required by applicable law or agreed to in writing, software
14  * distributed under the License is distributed on an "AS IS" BASIS,
15  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16  * See the License for the specific language governing permissions and
17  * limitations under the License.
18  *
19  *//*!
20  * \file
21  * \brief ANDROID_extension_pack_es31a tests
22  *//*--------------------------------------------------------------------*/
23 
24 #include "es31fAndroidExtensionPackES31ATests.hpp"
25 #include "glsStateQueryUtil.hpp"
26 #include "glsShaderLibrary.hpp"
27 #include "tcuTestLog.hpp"
28 #include "gluCallLogWrapper.hpp"
29 #include "gluContextInfo.hpp"
30 #include "gluStrUtil.hpp"
31 #include "glwFunctions.hpp"
32 #include "glwEnums.hpp"
33 #include "deStringUtil.hpp"
34 
35 namespace deqp
36 {
37 namespace gles31
38 {
39 namespace Functional
40 {
41 namespace
42 {
43 
genExtensionTestName(const char * extensionName)44 static std::string genExtensionTestName (const char* extensionName)
45 {
46 	DE_ASSERT(deStringBeginsWith(extensionName, "GL_"));
47 	return de::toLower(std::string(extensionName + 3));
48 }
49 
50 class ExtensionPackTestCase : public TestCase
51 {
52 public:
53 			ExtensionPackTestCase	(Context& context, const char* name, const char* description);
54 
55 protected:
56 	void	init					(void);
57 };
58 
ExtensionPackTestCase(Context & context,const char * name,const char * description)59 ExtensionPackTestCase::ExtensionPackTestCase (Context& context, const char* name, const char* description)
60 	: TestCase	(context, name, description)
61 {
62 }
63 
init(void)64 void ExtensionPackTestCase::init (void)
65 {
66 	if (!m_context.getContextInfo().isExtensionSupported("GL_ANDROID_extension_pack_es31a"))
67 		throw tcu::NotSupportedError("Test requires GL_ANDROID_extension_pack_es31a extension");
68 }
69 
70 class ImplementationLimitCase : public ExtensionPackTestCase
71 {
72 public:
73 							ImplementationLimitCase	(Context& context, const char* name, const char* description, glw::GLenum target, int limit);
74 
75 private:
76 	IterateResult			iterate					(void);
77 
78 	const glw::GLenum		m_target;
79 	const int				m_limit;
80 };
81 
ImplementationLimitCase(Context & context,const char * name,const char * description,glw::GLenum target,int limit)82 ImplementationLimitCase::ImplementationLimitCase (Context& context, const char* name, const char* description, glw::GLenum target, int limit)
83 	: ExtensionPackTestCase	(context, name, description)
84 	, m_target				(target)
85 	, m_limit				(limit)
86 {
87 }
88 
iterate(void)89 ImplementationLimitCase::IterateResult ImplementationLimitCase::iterate (void)
90 {
91 	using namespace gls::StateQueryUtil;
92 
93 	glu::CallLogWrapper						gl		(m_context.getRenderContext().getFunctions(), m_testCtx.getLog());
94 	StateQueryMemoryWriteGuard<glw::GLint>	result;
95 
96 	m_testCtx.setTestResult(QP_TEST_RESULT_PASS, "Pass");
97 	m_testCtx.getLog()
98 		<< tcu::TestLog::Message
99 		<< "Querying " << glu::getGettableStateName(m_target) << ", expecting at least " << m_limit
100 		<< tcu::TestLog::EndMessage;
101 
102 	gl.enableLogging(true);
103 	gl.glGetIntegerv(m_target, &result);
104 	GLU_EXPECT_NO_ERROR(gl.glGetError(), "implementation limit query failed");
105 
106 	if (result.verifyValidity(m_testCtx) && result < m_limit)
107 	{
108 		m_testCtx.getLog()
109 			<< tcu::TestLog::Message
110 			<< "// ERROR: Got " << result << ", expected at least " << m_limit
111 			<< tcu::TestLog::EndMessage;
112 
113 		m_testCtx.setTestResult(QP_TEST_RESULT_FAIL, "Too low implementation limit");
114 	}
115 
116 	return STOP;
117 }
118 
119 class SubExtensionCase : public ExtensionPackTestCase
120 {
121 public:
122 						SubExtensionCase	(Context& context, const char* name, const char* description, const char* extension);
123 
124 private:
125 	IterateResult		iterate				(void);
126 
127 	const std::string	m_extension;
128 };
129 
SubExtensionCase(Context & context,const char * name,const char * description,const char * extension)130 SubExtensionCase::SubExtensionCase (Context& context, const char* name, const char* description, const char* extension)
131 	: ExtensionPackTestCase	(context, name, description)
132 	, m_extension			(extension)
133 {
134 }
135 
iterate(void)136 SubExtensionCase::IterateResult SubExtensionCase::iterate (void)
137 {
138 	m_testCtx.getLog()
139 		<< tcu::TestLog::Message
140 		<< "Verifying that extension \"" << m_extension << "\" is supported."
141 		<< tcu::TestLog::EndMessage;
142 
143 	if (m_context.getContextInfo().isExtensionSupported(m_extension.c_str()))
144 	{
145 		m_testCtx.getLog()
146 			<< tcu::TestLog::Message
147 			<< "Extension is supported."
148 			<< tcu::TestLog::EndMessage;
149 
150 		m_testCtx.setTestResult(QP_TEST_RESULT_PASS, "Pass");
151 	}
152 	else
153 	{
154 		m_testCtx.getLog()
155 			<< tcu::TestLog::Message
156 			<< "Error, extension is not supported."
157 			<< tcu::TestLog::EndMessage;
158 
159 		m_testCtx.setTestResult(QP_TEST_RESULT_FAIL, "Required extension not supported");
160 	}
161 
162 	return STOP;
163 }
164 
165 } //anonymous
166 
AndroidExtensionPackES31ATests(Context & context)167 AndroidExtensionPackES31ATests::AndroidExtensionPackES31ATests (Context& context)
168 	: TestCaseGroup(context, "android_extension_pack", "ANDROID_extension_pack_es31a extension tests")
169 {
170 }
171 
~AndroidExtensionPackES31ATests(void)172 AndroidExtensionPackES31ATests::~AndroidExtensionPackES31ATests (void)
173 {
174 }
175 
init(void)176 void AndroidExtensionPackES31ATests::init (void)
177 {
178 	// .limits
179 	{
180 		static const struct
181 		{
182 			const char*	name;
183 			glw::GLenum	target;
184 			int			limit;
185 		} limits[] =
186 		{
187 			{
188 				"max_fragment_atomic_counter_buffers",
189 				GL_MAX_FRAGMENT_ATOMIC_COUNTER_BUFFERS,
190 				1
191 			},
192 			{
193 				"max_fragment_atomic_counters",
194 				GL_MAX_FRAGMENT_ATOMIC_COUNTERS,
195 				8
196 			},
197 			{
198 				"max_fragment_image_uniforms",
199 				GL_MAX_FRAGMENT_IMAGE_UNIFORMS,
200 				4
201 			},
202 			{
203 				"max_fragment_shader_storage_blocks",
204 				GL_MAX_FRAGMENT_SHADER_STORAGE_BLOCKS,
205 				4
206 			},
207 		};
208 
209 		tcu::TestCaseGroup* const group = new tcu::TestCaseGroup(m_testCtx, "limits", "Implementation limits");
210 		addChild(group);
211 
212 		for (int ndx = 0; ndx < DE_LENGTH_OF_ARRAY(limits); ++ndx)
213 			group->addChild(new ImplementationLimitCase(m_context,
214 														limits[ndx].name,
215 														(std::string() + "Check " + limits[ndx].name + " is at least " + de::toString(limits[ndx].limit)).c_str(),
216 														limits[ndx].target,
217 														limits[ndx].limit));
218 	}
219 
220 	// .extensions
221 	{
222 		static const char* const subExtensions[] =
223 		{
224 			"GL_KHR_debug",
225 			"GL_KHR_texture_compression_astc_ldr",
226 			"GL_KHR_blend_equation_advanced",
227 			"GL_OES_sample_shading",
228 			"GL_OES_sample_variables",
229 			"GL_OES_shader_image_atomic",
230 			"GL_OES_shader_multisample_interpolation",
231 			"GL_OES_texture_stencil8",
232 			"GL_OES_texture_storage_multisample_2d_array",
233 			"GL_EXT_copy_image",
234 			"GL_EXT_draw_buffers_indexed",
235 			"GL_EXT_geometry_shader",
236 			"GL_EXT_gpu_shader5",
237 			"GL_EXT_primitive_bounding_box",
238 			"GL_EXT_shader_io_blocks",
239 			"GL_EXT_tessellation_shader",
240 			"GL_EXT_texture_border_clamp",
241 			"GL_EXT_texture_buffer",
242 			"GL_EXT_texture_cube_map_array",
243 			"GL_EXT_texture_sRGB_decode",
244 		};
245 
246 		tcu::TestCaseGroup* const group = new tcu::TestCaseGroup(m_testCtx, "extensions", "Required extensions");
247 		addChild(group);
248 
249 		for (int ndx = 0; ndx < DE_LENGTH_OF_ARRAY(subExtensions); ++ndx)
250 		{
251 			const std::string name			= genExtensionTestName(subExtensions[ndx]);
252 			const std::string description	= "Check that extension " + name + " is supported if extension pack is supported";
253 			group->addChild(new SubExtensionCase(m_context, name.c_str(), description.c_str(), subExtensions[ndx]));
254 		}
255 	}
256 
257 	// .shaders
258 	{
259 		gls::ShaderLibrary					shaderLibrary	(m_testCtx, m_context.getRenderContext(), m_context.getContextInfo());
260 		tcu::TestCaseGroup* const			group			= new tcu::TestCaseGroup(m_testCtx, "shaders", "Shader tests");
261 
262 		{
263 			const std::vector<tcu::TestNode*>&	children		= shaderLibrary.loadShaderFile("shaders/es31/android_extension_pack.test");
264 			tcu::TestCaseGroup* const			groupES31		= new tcu::TestCaseGroup(m_testCtx, "es31", "GLSL ES 3.1 Shader tests", children);
265 
266 			group->addChild(groupES31);
267 		}
268 
269 		{
270 			const std::vector<tcu::TestNode*>&	children		= shaderLibrary.loadShaderFile("shaders/es32/android_extension_pack.test");
271 			tcu::TestCaseGroup* const			groupES32		= new tcu::TestCaseGroup(m_testCtx, "es32", "GLSL ES 3.2 Shader tests", children);
272 
273 			group->addChild(groupES32);
274 		}
275 
276 		addChild(group);
277 	}
278 }
279 
280 } // Functional
281 } // gles31
282 } // deqp
283