1 /*-------------------------------------------------------------------------
2  * drawElements Quality Program OpenGL ES 2.0 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 Capability Tests.
22  *//*--------------------------------------------------------------------*/
23 
24 #include "tes2CapabilityTests.hpp"
25 #include "gluStrUtil.hpp"
26 #include "tcuTestLog.hpp"
27 #include "deStringUtil.hpp"
28 #include "gluContextInfo.hpp"
29 
30 #include <algorithm>
31 #include <iterator>
32 
33 #include "glw.h"
34 
35 using tcu::TestLog;
36 using std::vector;
37 using std::string;
38 
39 namespace deqp
40 {
41 namespace gles2
42 {
43 
44 class GetIntCase : public tcu::TestCase
45 {
46 public:
GetIntCase(Context & context,const char * name,const char * description,GLenum param)47 	GetIntCase (Context& context, const char* name, const char* description, GLenum param)
48 		: tcu::TestCase	(context.getTestContext(), tcu::NODETYPE_CAPABILITY, name, description)
49 		, m_param		(param)
50 	{
51 	}
52 
iterate(void)53 	IterateResult iterate (void)
54 	{
55 		GLint value = 0;
56 		GLU_CHECK_CALL(glGetIntegerv(m_param, &value));
57 
58 		m_testCtx.getLog() << TestLog::Message << glu::getParamQueryStr(m_param) << " = " << value << TestLog::EndMessage;
59 
60 		m_testCtx.setTestResult(QP_TEST_RESULT_PASS, de::toString(value).c_str());
61 		return STOP;
62 	}
63 
64 private:
65 	GLenum	m_param;
66 };
67 
68 class LimitTests : public TestCaseGroup
69 {
70 public:
LimitTests(Context & context)71 	LimitTests (Context& context)
72 		: TestCaseGroup(context, "limits", "Implementation-defined limits")
73 	{
74 	}
75 
init(void)76 	void init (void)
77 	{
78 		static const struct
79 		{
80 			const char*		name;
81 			const char*		description;
82 			GLenum			param;
83 		} getIntCases[] =
84 		{
85 			{ "vertex_attribs",					"Number of vertex attributes supported",							GL_MAX_VERTEX_ATTRIBS					},
86 			{ "varying_vectors",				"Number of varying vectors supported",								GL_MAX_VARYING_VECTORS					},
87 			{ "vertex_uniform_vectors",			"Number of vertex uniform vectors supported",						GL_MAX_VERTEX_UNIFORM_VECTORS			},
88 			{ "fragment_uniform_vectors",		"Number of fragment uniform vectors supported",						GL_MAX_FRAGMENT_UNIFORM_VECTORS			},
89 			{ "texture_image_units",			"Number of fragment texture units supported",						GL_MAX_TEXTURE_IMAGE_UNITS				},
90 			{ "vertex_texture_image_units",		"Number of vertex texture units supported",							GL_MAX_VERTEX_TEXTURE_IMAGE_UNITS		},
91 			{ "combined_texture_image_units",	"Number of vertex and fragment combined texture units supported",	GL_MAX_COMBINED_TEXTURE_IMAGE_UNITS		},
92 			{ "texture_2d_size",				"Maximum 2D texture size",											GL_MAX_TEXTURE_SIZE						},
93 			{ "texture_cube_size",				"Maximum cubemap texture size",										GL_MAX_CUBE_MAP_TEXTURE_SIZE			},
94 			{ "renderbuffer_size",				"Maximum renderbuffer size",										GL_MAX_RENDERBUFFER_SIZE				},
95 		};
96 
97 		for (int ndx = 0; ndx < DE_LENGTH_OF_ARRAY(getIntCases); ndx++)
98 			addChild(new GetIntCase(m_context, getIntCases[ndx].name, getIntCases[ndx].description, getIntCases[ndx].param));
99 	}
100 };
101 
102 class ExtensionCase : public tcu::TestCase
103 {
104 public:
105 								ExtensionCase				(tcu::TestContext& testCtx, const glu::ContextInfo& ctxInfo, const char* name, const char* desc, const char* extName);
106 
107 	IterateResult				iterate						(void);
108 
109 private:
110 	const glu::ContextInfo&		m_ctxInfo;
111 	std::string					m_extName;
112 };
113 
ExtensionCase(tcu::TestContext & testCtx,const glu::ContextInfo & ctxInfo,const char * name,const char * desc,const char * extName)114 ExtensionCase::ExtensionCase (tcu::TestContext& testCtx, const glu::ContextInfo& ctxInfo, const char* name, const char* desc, const char* extName)
115 	: tcu::TestCase		(testCtx, tcu::NODETYPE_CAPABILITY, name, desc)
116 	, m_ctxInfo			(ctxInfo)
117 	, m_extName			(extName)
118 {
119 }
120 
iterate(void)121 ExtensionCase::IterateResult ExtensionCase::iterate (void)
122 {
123 	bool isSupported = std::find(m_ctxInfo.getExtensions().begin(), m_ctxInfo.getExtensions().end(), m_extName) != m_ctxInfo.getExtensions().end();
124 	m_testCtx.setTestResult(isSupported ? QP_TEST_RESULT_PASS	: QP_TEST_RESULT_NOT_SUPPORTED,
125 							isSupported ? "Supported"			: "Not supported");
126 	return STOP;
127 }
128 
129 class ExtensionTests : public TestCaseGroup
130 {
131 public:
ExtensionTests(Context & context)132 	ExtensionTests (Context& context)
133 		: TestCaseGroup(context, "extensions", "Supported extensions")
134 	{
135 	}
136 
init(void)137 	void init (void)
138 	{
139 		struct ExtGroup
140 		{
141 			tcu::TestCaseGroup*		group;
142 			const glu::ContextInfo&	ctxInfo;
143 
144 			ExtGroup (TestCaseGroup* parent, const char* name, const char* desc)
145 				: group		(DE_NULL)
146 				, ctxInfo	(parent->getContext().getContextInfo())
147 			{
148 				group = new tcu::TestCaseGroup(parent->getTestContext(), name, desc);
149 				parent->addChild(group);
150 			}
151 
152 			ExtGroup& operator<< (const char* extName)
153 			{
154 				group->addChild(new ExtensionCase(group->getTestContext(), ctxInfo, extName, "", extName));
155 				return *this;
156 			}
157 		};
158 
159 		// Uncompressed formats.
160 		ExtGroup(this, "uncompressed_texture_formats", "Uncompressed texture formats")
161 			<< "GL_OES_texture_float_linear"
162 			<< "GL_OES_texture_half_float_linear"
163 			<< "GL_OES_texture_float"
164 			<< "GL_OES_texture_half_float"
165 			<< "GL_OES_texture_npot"
166 			<< "GL_EXT_texture_format_BGRA8888"
167 			<< "GL_EXT_texture_rg"
168 			<< "GL_EXT_texture_type_2_10_10_10_REV"
169 			<< "GL_EXT_sRGB"
170 			<< "GL_APPLE_rgb_422"
171 			<< "GL_APPLE_texture_format_BGRA8888";
172 
173 		// Compressed formats.
174 		ExtGroup(this, "compressed_texture_formats", "Compressed texture formats")
175 			<< "GL_OES_compressed_ETC1_RGB8_texture"
176 			<< "GL_OES_compressed_paletted_texture"
177 			<< "GL_EXT_texture_compression_dxt1"
178 			<< "GL_AMD_compressed_3DC_texture"
179 			<< "GL_AMD_compressed_ATC_texture"
180 			<< "GL_IMG_texture_compression_pvrtc"
181 			<< "GL_NV_texture_compression_s3tc_update";
182 
183 		// Texture features.
184 		ExtGroup(this, "texture", "Texturing features")
185 			<< "GL_OES_texture_3D"
186 			<< "GL_OES_depth_texture"
187 			<< "GL_EXT_texture_filter_anisotropic"
188 			<< "GL_EXT_texture_lod_bias"
189 			<< "GL_EXT_shadow_samplers"
190 			<< "GL_EXT_texture_storage"
191 			<< "GL_NV_texture_npot_2D_mipmap"
192 			<< "GL_APPLE_texture_max_level";
193 
194 		// FBO features
195 		ExtGroup(this, "fbo", "FBO features")
196 			<< "GL_OES_depth24"
197 			<< "GL_OES_depth32"
198 			<< "GL_OES_packed_depth_stencil"
199 			<< "GL_OES_fbo_render_mipmap"
200 			<< "GL_OES_rgb8_rgba8"
201 			<< "GL_OES_stencil1"
202 			<< "GL_OES_stencil4"
203 			<< "GL_OES_stencil8"
204 			<< "GL_EXT_color_buffer_half_float"
205 			<< "GL_EXT_multisampled_render_to_texture"
206 			<< "GL_IMG_multisampled_render_to_texture"
207 			<< "GL_ARM_rgba8"
208 			<< "GL_NV_depth_nonlinear"
209 			<< "GL_NV_draw_buffers"
210 			<< "GL_NV_fbo_color_attachments"
211 			<< "GL_NV_read_buffer"
212 			<< "GL_APPLE_framebuffer_multisample";
213 
214 		// Vertex data formats.
215 		ExtGroup(this, "vertex_data_formats", "Vertex data formats")
216 			<< "GL_OES_element_index_uint"
217 			<< "GL_OES_vertex_half_float"
218 			<< "GL_OES_vertex_type_10_10_10_2";
219 
220 		// Shader functionality.
221 		ExtGroup(this, "shaders", "Shader features")
222 			<< "GL_OES_fragment_precision_high"
223 			<< "GL_OES_standard_derivatives"
224 			<< "GL_EXT_shader_texture_lod"
225 			<< "GL_EXT_frag_depth"
226 			<< "GL_EXT_separate_shader_objects";
227 
228 		// Shader binary formats.
229 		ExtGroup(this, "shader_binary_formats", "Shader binary formats")
230 			<< "GL_OES_get_program_binary"
231 			<< "GL_AMD_program_binary_Z400"
232 			<< "GL_IMG_shader_binary"
233 			<< "GL_IMG_program_binary"
234 			<< "GL_ARM_mali_shader_binary"
235 			<< "GL_VIV_shader_binary"
236 			<< "GL_DMP_shader_binary";
237 
238 		// Development features.
239 		ExtGroup(this, "development", "Development aids")
240 			<< "GL_EXT_debug_label"
241 			<< "GL_EXT_debug_marker"
242 			<< "GL_AMD_performance_monitor"
243 			<< "GL_QCOM_performance_monitor_global_mode"
244 			<< "GL_QCOM_extended_get"
245 			<< "GL_QCOM_extended_get2";
246 
247 		// Other extensions.
248 		ExtGroup(this, "other", "Other extensions")
249 			<< "GL_OES_draw_texture"
250 			<< "GL_OES_mapbuffer"
251 			<< "GL_OES_vertex_array_object"
252 			<< "GL_EXT_occlusion_query_boolean"
253 			<< "GL_EXT_robustness"
254 			<< "GL_EXT_discard_framebuffer"
255 			<< "GL_EXT_read_format_bgra"
256 			<< "GL_EXT_multi_draw_arrays"
257 			<< "GL_EXT_unpack_subimage"
258 			<< "GL_EXT_blend_minmax"
259 			<< "GL_IMG_read_format"
260 			<< "GL_NV_coverage_sample"
261 			<< "GL_NV_read_depth_stencil"
262 			<< "GL_SUN_multi_draw_arrays";
263 	}
264 };
265 
CapabilityTests(Context & context)266 CapabilityTests::CapabilityTests (Context& context)
267 	: TestCaseGroup(context, "capability", "Capability Tests")
268 {
269 }
270 
~CapabilityTests(void)271 CapabilityTests::~CapabilityTests (void)
272 {
273 }
274 
init(void)275 void CapabilityTests::init (void)
276 {
277 	addChild(new LimitTests		(m_context));
278 	addChild(new ExtensionTests	(m_context));
279 }
280 
281 } // gles2
282 } // deqp
283