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