1 //
2 // Copyright 2019 The ANGLE Project Authors. All rights reserved.
3 // Use of this source code is governed by a BSD-style license that can be
4 // found in the LICENSE file.
5 //
6 // EGLPrintEGLinfoTest.cpp:
7 // This test prints out the extension strings, configs and their attributes
8 //
9
10 #include <gtest/gtest.h>
11
12 #include "common/string_utils.h"
13 #include "test_utils/ANGLETest.h"
14 #include "test_utils/runner/TestSuite.h"
15
16 #if defined(ANGLE_HAS_RAPIDJSON)
17 # include "common/serializer/JsonSerializer.h"
18 #endif // defined(ANGLE_HAS_RAPIDJSON)
19
20 using namespace angle;
21
22 class EGLPrintEGLinfoTest : public ANGLETest
23 {
24 protected:
EGLPrintEGLinfoTest()25 EGLPrintEGLinfoTest() {}
26
testSetUp()27 void testSetUp() override
28 {
29 mDisplay = getEGLWindow()->getDisplay();
30 ASSERT_TRUE(mDisplay != EGL_NO_DISPLAY);
31 }
32
33 EGLDisplay mDisplay = EGL_NO_DISPLAY;
34 };
35
36 namespace
37 {
38 // Parse space separated extension string into a vector of strings
ParseExtensions(const char * extensions)39 std::vector<std::string> ParseExtensions(const char *extensions)
40 {
41 std::string extensionsStr(extensions);
42 std::vector<std::string> extensionsVec;
43 SplitStringAlongWhitespace(extensionsStr, &extensionsVec);
44 return extensionsVec;
45 }
46
47 // Query a EGL attribute
GetAttrib(EGLDisplay display,EGLConfig config,EGLint attrib)48 EGLint GetAttrib(EGLDisplay display, EGLConfig config, EGLint attrib)
49 {
50 EGLint value = 0;
51 EXPECT_EGL_TRUE(eglGetConfigAttrib(display, config, attrib, &value));
52 return value;
53 }
54
55 // Query a egl string
GetEGLString(EGLDisplay display,EGLint name)56 const char *GetEGLString(EGLDisplay display, EGLint name)
57 {
58 const char *value = "";
59 value = eglQueryString(display, name);
60 EXPECT_TRUE(value != nullptr);
61 return value;
62 }
63
64 // Query a GL string
GetGLString(EGLint name)65 const char *GetGLString(EGLint name)
66 {
67 const char *value = "";
68 value = reinterpret_cast<const char *>(glGetString(name));
69 EXPECT_TRUE(value != nullptr);
70 return value;
71 }
72
73 } // namespace
74
75 // Print the EGL strings and extensions
TEST_P(EGLPrintEGLinfoTest,PrintEGLInfo)76 TEST_P(EGLPrintEGLinfoTest, PrintEGLInfo)
77 {
78 std::cout << " EGL Information:" << std::endl;
79 std::cout << "\tVendor: " << GetEGLString(mDisplay, EGL_VENDOR) << std::endl;
80 std::cout << "\tVersion: " << GetEGLString(mDisplay, EGL_VENDOR) << std::endl;
81 std::cout << "\tClient APIs: " << GetEGLString(mDisplay, EGL_CLIENT_APIS) << std::endl;
82
83 std::cout << "\tEGL Client Extensions:" << std::endl;
84 for (auto extension : ParseExtensions(GetEGLString(EGL_NO_DISPLAY, EGL_EXTENSIONS)))
85 {
86 std::cout << "\t\t" << extension << std::endl;
87 }
88
89 std::cout << "\tEGL Display Extensions:" << std::endl;
90 for (auto extension : ParseExtensions(GetEGLString(mDisplay, EGL_EXTENSIONS)))
91 {
92 std::cout << "\t\t" << extension << std::endl;
93 }
94
95 std::cout << std::endl;
96 }
97
98 // Print the GL strings and extensions
TEST_P(EGLPrintEGLinfoTest,PrintGLInfo)99 TEST_P(EGLPrintEGLinfoTest, PrintGLInfo)
100 {
101 std::cout << " GLES Information:" << std::endl;
102 std::cout << "\tVendor: " << GetGLString(GL_VENDOR) << std::endl;
103 std::cout << "\tVersion: " << GetGLString(GL_VERSION) << std::endl;
104 std::cout << "\tRenderer: " << GetGLString(GL_RENDERER) << std::endl;
105 std::cout << "\tShader: " << GetGLString(GL_SHADING_LANGUAGE_VERSION) << std::endl;
106
107 std::cout << "\tExtensions:" << std::endl;
108
109 const std::vector<std::string> extensions = ParseExtensions(GetGLString(GL_EXTENSIONS));
110
111 for (const std::string &extension : extensions)
112 {
113 std::cout << "\t\t" << extension << std::endl;
114 }
115
116 std::cout << std::endl;
117
118 #if defined(ANGLE_HAS_RAPIDJSON)
119 angle::TestSuite *testSuite = angle::TestSuite::GetInstance();
120 if (!testSuite->hasTestArtifactsDirectory())
121 {
122 return;
123 }
124 JsonSerializer json;
125 json.addCString("Vendor", GetGLString(GL_VENDOR));
126 json.addCString("Version", GetGLString(GL_VERSION));
127 json.addCString("Renderer", GetGLString(GL_RENDERER));
128 json.addCString("ShaderLanguageVersion", GetGLString(GL_SHADING_LANGUAGE_VERSION));
129 json.addVectorOfStrings("Extensions", extensions);
130
131 constexpr size_t kBufferSize = 1000;
132 std::array<char, kBufferSize> buffer;
133 std::time_t timeNow = std::time(nullptr);
134 std::strftime(buffer.data(), buffer.size(), "%B %e, %Y", std::localtime(&timeNow));
135 json.addCString("DateRecorded", buffer.data());
136
137 std::stringstream fnameStream;
138 fnameStream << "GLinfo_" << GetParam() << ".json";
139 std::string fname = fnameStream.str();
140
141 const std::string artifactPath = testSuite->reserveTestArtifactPath(fname);
142
143 {
144 std::vector<uint8_t> jsonData = json.getData();
145 SaveFileHelper saveFile(artifactPath);
146 saveFile.write(jsonData.data(), jsonData.size());
147 }
148 #endif // defined(ANGLE_HAS_RAPIDJSON)
149 }
150
151 #define QUERY_HELPER(enumValue, enumString, stream) \
152 { \
153 GLint result; \
154 glGetIntegerv(enumValue, &result); \
155 ASSERT_GL_NO_ERROR(); \
156 stream << enumString + std::string(",") + std::to_string(result) << std::endl; \
157 }
158
159 #define QUERY_ARRAY_HELPER(enumValue, enumString, size, stream) \
160 { \
161 GLint result[size]; \
162 glGetIntegerv(enumValue, result); \
163 ASSERT_GL_NO_ERROR(); \
164 std::stringstream results; \
165 for (int i = 0; i < size; i++) \
166 results << result[i] << " "; \
167 stream << enumString + std::string(",") + results.str() << std::endl; \
168 }
169
170 #define QUERY_INDEXED_HELPER(enumValue, enumString, index, stream) \
171 { \
172 GLint result; \
173 glGetIntegeri_v(enumValue, index, &result); \
174 ASSERT_GL_NO_ERROR(); \
175 stream << enumString + std::string(",") + std::to_string(result) << std::endl; \
176 }
177
178 #define QUERY_AND_LOG_CAPABILITY(enum, stream) QUERY_HELPER(enum, #enum, stream)
179
180 #define QUERY_AND_LOG_CAPABILITY_ARRAY(enum, size, stream) \
181 QUERY_ARRAY_HELPER(enum, #enum, size, stream)
182
183 #define QUERY_AND_LOG_CAPABILITY_INDEXED(enum, index, stream) \
184 QUERY_INDEXED_HELPER(enum, #enum "[" #index "]", index, stream)
185
LogGles2Capabilities(std::ostream & stream)186 static void LogGles2Capabilities(std::ostream &stream)
187 {
188 QUERY_AND_LOG_CAPABILITY(GL_MAX_COMBINED_TEXTURE_IMAGE_UNITS, stream);
189 QUERY_AND_LOG_CAPABILITY(GL_MAX_CUBE_MAP_TEXTURE_SIZE, stream);
190 QUERY_AND_LOG_CAPABILITY(GL_MAX_FRAGMENT_UNIFORM_VECTORS, stream);
191 QUERY_AND_LOG_CAPABILITY(GL_MAX_RENDERBUFFER_SIZE, stream);
192 QUERY_AND_LOG_CAPABILITY(GL_MAX_TEXTURE_IMAGE_UNITS, stream);
193 QUERY_AND_LOG_CAPABILITY(GL_MAX_TEXTURE_SIZE, stream);
194 QUERY_AND_LOG_CAPABILITY(GL_MAX_VARYING_VECTORS, stream);
195 QUERY_AND_LOG_CAPABILITY(GL_MAX_VERTEX_ATTRIBS, stream);
196 QUERY_AND_LOG_CAPABILITY(GL_MAX_VERTEX_TEXTURE_IMAGE_UNITS, stream);
197 QUERY_AND_LOG_CAPABILITY(GL_MAX_VERTEX_UNIFORM_VECTORS, stream);
198 constexpr int kMaxViewPortDimsReturnValuesSize = 2;
199 QUERY_AND_LOG_CAPABILITY_ARRAY(GL_MAX_VIEWPORT_DIMS, kMaxViewPortDimsReturnValuesSize, stream);
200 QUERY_AND_LOG_CAPABILITY(GL_NUM_COMPRESSED_TEXTURE_FORMATS, stream);
201 QUERY_AND_LOG_CAPABILITY(GL_NUM_SHADER_BINARY_FORMATS, stream);
202 }
203
LogGles3Capabilities(std::ostream & stream)204 static void LogGles3Capabilities(std::ostream &stream)
205 {
206 QUERY_AND_LOG_CAPABILITY(GL_MAX_3D_TEXTURE_SIZE, stream);
207 QUERY_AND_LOG_CAPABILITY(GL_MAX_ARRAY_TEXTURE_LAYERS, stream);
208 QUERY_AND_LOG_CAPABILITY(GL_MAX_COLOR_ATTACHMENTS, stream);
209 QUERY_AND_LOG_CAPABILITY(GL_MAX_COMBINED_FRAGMENT_UNIFORM_COMPONENTS, stream);
210 QUERY_AND_LOG_CAPABILITY(GL_MAX_COMBINED_UNIFORM_BLOCKS, stream);
211 QUERY_AND_LOG_CAPABILITY(GL_MAX_COMBINED_VERTEX_UNIFORM_COMPONENTS, stream);
212 QUERY_AND_LOG_CAPABILITY(GL_MAX_DRAW_BUFFERS, stream);
213 QUERY_AND_LOG_CAPABILITY(GL_MAX_ELEMENT_INDEX, stream);
214 QUERY_AND_LOG_CAPABILITY(GL_MAX_ELEMENTS_INDICES, stream);
215 QUERY_AND_LOG_CAPABILITY(GL_MAX_ELEMENTS_VERTICES, stream);
216 QUERY_AND_LOG_CAPABILITY(GL_MAX_FRAGMENT_INPUT_COMPONENTS, stream);
217 QUERY_AND_LOG_CAPABILITY(GL_MAX_FRAGMENT_UNIFORM_BLOCKS, stream);
218 QUERY_AND_LOG_CAPABILITY(GL_MAX_FRAGMENT_UNIFORM_COMPONENTS, stream);
219 QUERY_AND_LOG_CAPABILITY(GL_MAX_PROGRAM_TEXEL_OFFSET, stream);
220 QUERY_AND_LOG_CAPABILITY(GL_MAX_SAMPLES, stream);
221 QUERY_AND_LOG_CAPABILITY(GL_MAX_SERVER_WAIT_TIMEOUT, stream);
222 QUERY_AND_LOG_CAPABILITY(GL_MAX_TEXTURE_LOD_BIAS, stream);
223 QUERY_AND_LOG_CAPABILITY(GL_MAX_TRANSFORM_FEEDBACK_INTERLEAVED_COMPONENTS, stream);
224 QUERY_AND_LOG_CAPABILITY(GL_MAX_TRANSFORM_FEEDBACK_SEPARATE_ATTRIBS, stream);
225 QUERY_AND_LOG_CAPABILITY(GL_MAX_TRANSFORM_FEEDBACK_SEPARATE_COMPONENTS, stream);
226 QUERY_AND_LOG_CAPABILITY(GL_MAX_UNIFORM_BLOCK_SIZE, stream);
227 QUERY_AND_LOG_CAPABILITY(GL_MAX_UNIFORM_BUFFER_BINDINGS, stream);
228 QUERY_AND_LOG_CAPABILITY(GL_MAX_VARYING_COMPONENTS, stream);
229 QUERY_AND_LOG_CAPABILITY(GL_MAX_VERTEX_OUTPUT_COMPONENTS, stream);
230 QUERY_AND_LOG_CAPABILITY(GL_MAX_VERTEX_UNIFORM_BLOCKS, stream);
231 QUERY_AND_LOG_CAPABILITY(GL_MAX_VERTEX_UNIFORM_COMPONENTS, stream);
232 QUERY_AND_LOG_CAPABILITY(GL_MIN_PROGRAM_TEXEL_OFFSET, stream);
233 QUERY_AND_LOG_CAPABILITY(GL_NUM_PROGRAM_BINARY_FORMATS, stream);
234 // GLES3 capabilities are a superset of GLES2
235 LogGles2Capabilities(stream);
236 }
237
LogGles31Capabilities(std::ostream & stream)238 static void LogGles31Capabilities(std::ostream &stream)
239 {
240 QUERY_AND_LOG_CAPABILITY(GL_MAX_ATOMIC_COUNTER_BUFFER_BINDINGS, stream);
241 QUERY_AND_LOG_CAPABILITY(GL_MAX_ATOMIC_COUNTER_BUFFER_SIZE, stream);
242 QUERY_AND_LOG_CAPABILITY(GL_MAX_COLOR_TEXTURE_SAMPLES, stream);
243 QUERY_AND_LOG_CAPABILITY(GL_MAX_COMBINED_ATOMIC_COUNTER_BUFFERS, stream);
244 QUERY_AND_LOG_CAPABILITY(GL_MAX_COMBINED_ATOMIC_COUNTERS, stream);
245 QUERY_AND_LOG_CAPABILITY(GL_MAX_COMBINED_COMPUTE_UNIFORM_COMPONENTS, stream);
246 QUERY_AND_LOG_CAPABILITY(GL_MAX_COMBINED_IMAGE_UNIFORMS, stream);
247 QUERY_AND_LOG_CAPABILITY(GL_MAX_COMBINED_SHADER_OUTPUT_RESOURCES, stream);
248 QUERY_AND_LOG_CAPABILITY(GL_MAX_COMBINED_SHADER_STORAGE_BLOCKS, stream);
249 QUERY_AND_LOG_CAPABILITY(GL_MAX_COMPUTE_ATOMIC_COUNTER_BUFFERS, stream);
250 QUERY_AND_LOG_CAPABILITY(GL_MAX_COMPUTE_ATOMIC_COUNTERS, stream);
251 QUERY_AND_LOG_CAPABILITY(GL_MAX_COMPUTE_IMAGE_UNIFORMS, stream);
252 QUERY_AND_LOG_CAPABILITY(GL_MAX_COMPUTE_SHADER_STORAGE_BLOCKS, stream);
253 QUERY_AND_LOG_CAPABILITY(GL_MAX_COMPUTE_SHARED_MEMORY_SIZE, stream);
254 QUERY_AND_LOG_CAPABILITY(GL_MAX_COMPUTE_TEXTURE_IMAGE_UNITS, stream);
255 QUERY_AND_LOG_CAPABILITY(GL_MAX_COMPUTE_UNIFORM_BLOCKS, stream);
256 QUERY_AND_LOG_CAPABILITY(GL_MAX_COMPUTE_UNIFORM_COMPONENTS, stream);
257 QUERY_AND_LOG_CAPABILITY_INDEXED(GL_MAX_COMPUTE_WORK_GROUP_COUNT, 0, stream);
258 QUERY_AND_LOG_CAPABILITY_INDEXED(GL_MAX_COMPUTE_WORK_GROUP_COUNT, 1, stream);
259 QUERY_AND_LOG_CAPABILITY_INDEXED(GL_MAX_COMPUTE_WORK_GROUP_COUNT, 2, stream);
260 QUERY_AND_LOG_CAPABILITY(GL_MAX_COMPUTE_WORK_GROUP_INVOCATIONS, stream);
261 QUERY_AND_LOG_CAPABILITY_INDEXED(GL_MAX_COMPUTE_WORK_GROUP_SIZE, 0, stream);
262 QUERY_AND_LOG_CAPABILITY_INDEXED(GL_MAX_COMPUTE_WORK_GROUP_SIZE, 1, stream);
263 QUERY_AND_LOG_CAPABILITY_INDEXED(GL_MAX_COMPUTE_WORK_GROUP_SIZE, 2, stream);
264 QUERY_AND_LOG_CAPABILITY(GL_MAX_DEPTH_TEXTURE_SAMPLES, stream);
265 QUERY_AND_LOG_CAPABILITY(GL_MAX_FRAGMENT_ATOMIC_COUNTER_BUFFERS, stream);
266 QUERY_AND_LOG_CAPABILITY(GL_MAX_FRAGMENT_ATOMIC_COUNTERS, stream);
267 QUERY_AND_LOG_CAPABILITY(GL_MAX_FRAGMENT_IMAGE_UNIFORMS, stream);
268 QUERY_AND_LOG_CAPABILITY(GL_MAX_FRAGMENT_SHADER_STORAGE_BLOCKS, stream);
269 QUERY_AND_LOG_CAPABILITY(GL_MAX_FRAMEBUFFER_HEIGHT, stream);
270 QUERY_AND_LOG_CAPABILITY(GL_MAX_FRAMEBUFFER_SAMPLES, stream);
271 QUERY_AND_LOG_CAPABILITY(GL_MAX_FRAMEBUFFER_WIDTH, stream);
272 QUERY_AND_LOG_CAPABILITY(GL_MAX_IMAGE_UNITS, stream);
273 QUERY_AND_LOG_CAPABILITY(GL_MAX_INTEGER_SAMPLES, stream);
274 QUERY_AND_LOG_CAPABILITY(GL_MAX_PROGRAM_TEXTURE_GATHER_OFFSET, stream);
275 QUERY_AND_LOG_CAPABILITY(GL_MAX_SAMPLE_MASK_WORDS, stream);
276 QUERY_AND_LOG_CAPABILITY(GL_MAX_SHADER_STORAGE_BLOCK_SIZE, stream);
277 QUERY_AND_LOG_CAPABILITY(GL_MAX_SHADER_STORAGE_BUFFER_BINDINGS, stream);
278 QUERY_AND_LOG_CAPABILITY(GL_MAX_UNIFORM_LOCATIONS, stream);
279 QUERY_AND_LOG_CAPABILITY(GL_MAX_VERTEX_ATOMIC_COUNTER_BUFFERS, stream);
280 QUERY_AND_LOG_CAPABILITY(GL_MAX_VERTEX_ATOMIC_COUNTERS, stream);
281 QUERY_AND_LOG_CAPABILITY(GL_MAX_VERTEX_ATTRIB_BINDINGS, stream);
282 QUERY_AND_LOG_CAPABILITY(GL_MAX_VERTEX_ATTRIB_RELATIVE_OFFSET, stream);
283 QUERY_AND_LOG_CAPABILITY(GL_MAX_VERTEX_ATTRIB_STRIDE, stream);
284 QUERY_AND_LOG_CAPABILITY(GL_MAX_VERTEX_IMAGE_UNIFORMS, stream);
285 QUERY_AND_LOG_CAPABILITY(GL_MAX_VERTEX_SHADER_STORAGE_BLOCKS, stream);
286 QUERY_AND_LOG_CAPABILITY(GL_MIN_PROGRAM_TEXTURE_GATHER_OFFSET, stream);
287
288 // GLES31 capabilities are a superset of GLES3
289 LogGles3Capabilities(stream);
290 }
291
LogGles32Capabilities(std::ostream & stream)292 static void LogGles32Capabilities(std::ostream &stream)
293 {
294 // Most of these capabilities are not implemented yet.
295 ANGLE_SKIP_TEST_IF(IsVulkan());
296
297 QUERY_AND_LOG_CAPABILITY(GL_MAX_COMBINED_GEOMETRY_UNIFORM_COMPONENTS, stream);
298 QUERY_AND_LOG_CAPABILITY(GL_MAX_COMBINED_TESS_CONTROL_UNIFORM_COMPONENTS, stream);
299 QUERY_AND_LOG_CAPABILITY(GL_MAX_COMBINED_TESS_EVALUATION_UNIFORM_COMPONENTS, stream);
300 QUERY_AND_LOG_CAPABILITY(GL_MAX_DEBUG_GROUP_STACK_DEPTH, stream);
301 QUERY_AND_LOG_CAPABILITY(GL_MAX_DEBUG_LOGGED_MESSAGES, stream);
302 QUERY_AND_LOG_CAPABILITY(GL_MAX_DEBUG_MESSAGE_LENGTH, stream);
303 QUERY_AND_LOG_CAPABILITY(GL_MAX_FRAGMENT_INTERPOLATION_OFFSET, stream);
304 QUERY_AND_LOG_CAPABILITY(GL_MAX_FRAMEBUFFER_LAYERS, stream);
305 QUERY_AND_LOG_CAPABILITY(GL_MAX_GEOMETRY_ATOMIC_COUNTER_BUFFERS, stream);
306 QUERY_AND_LOG_CAPABILITY(GL_MAX_GEOMETRY_ATOMIC_COUNTERS, stream);
307 QUERY_AND_LOG_CAPABILITY(GL_MAX_GEOMETRY_IMAGE_UNIFORMS, stream);
308 QUERY_AND_LOG_CAPABILITY(GL_MAX_GEOMETRY_INPUT_COMPONENTS, stream);
309 QUERY_AND_LOG_CAPABILITY(GL_MAX_GEOMETRY_OUTPUT_COMPONENTS, stream);
310 QUERY_AND_LOG_CAPABILITY(GL_MAX_GEOMETRY_OUTPUT_VERTICES, stream);
311 QUERY_AND_LOG_CAPABILITY(GL_MAX_GEOMETRY_SHADER_INVOCATIONS, stream);
312 QUERY_AND_LOG_CAPABILITY(GL_MAX_GEOMETRY_SHADER_STORAGE_BLOCKS, stream);
313 QUERY_AND_LOG_CAPABILITY(GL_MAX_GEOMETRY_TEXTURE_IMAGE_UNITS, stream);
314 QUERY_AND_LOG_CAPABILITY(GL_MAX_GEOMETRY_TOTAL_OUTPUT_COMPONENTS, stream);
315 QUERY_AND_LOG_CAPABILITY(GL_MAX_GEOMETRY_UNIFORM_BLOCKS, stream);
316 QUERY_AND_LOG_CAPABILITY(GL_MAX_GEOMETRY_UNIFORM_COMPONENTS, stream);
317 QUERY_AND_LOG_CAPABILITY(GL_MAX_LABEL_LENGTH, stream);
318 QUERY_AND_LOG_CAPABILITY(GL_MAX_PATCH_VERTICES, stream);
319 QUERY_AND_LOG_CAPABILITY(GL_MAX_TESS_CONTROL_ATOMIC_COUNTER_BUFFERS, stream);
320 QUERY_AND_LOG_CAPABILITY(GL_MAX_TESS_CONTROL_ATOMIC_COUNTERS, stream);
321 QUERY_AND_LOG_CAPABILITY(GL_MAX_TESS_CONTROL_IMAGE_UNIFORMS, stream);
322 QUERY_AND_LOG_CAPABILITY(GL_MAX_TESS_CONTROL_INPUT_COMPONENTS, stream);
323 QUERY_AND_LOG_CAPABILITY(GL_MAX_TESS_CONTROL_OUTPUT_COMPONENTS, stream);
324 QUERY_AND_LOG_CAPABILITY(GL_MAX_TESS_CONTROL_SHADER_STORAGE_BLOCKS, stream);
325 QUERY_AND_LOG_CAPABILITY(GL_MAX_TESS_CONTROL_TEXTURE_IMAGE_UNITS, stream);
326 QUERY_AND_LOG_CAPABILITY(GL_MAX_TESS_CONTROL_TOTAL_OUTPUT_COMPONENTS, stream);
327 QUERY_AND_LOG_CAPABILITY(GL_MAX_TESS_CONTROL_UNIFORM_BLOCKS, stream);
328 QUERY_AND_LOG_CAPABILITY(GL_MAX_TESS_CONTROL_UNIFORM_COMPONENTS, stream);
329 QUERY_AND_LOG_CAPABILITY(GL_MAX_TESS_EVALUATION_ATOMIC_COUNTER_BUFFERS, stream);
330 QUERY_AND_LOG_CAPABILITY(GL_MAX_TESS_EVALUATION_ATOMIC_COUNTERS, stream);
331 QUERY_AND_LOG_CAPABILITY(GL_MAX_TESS_EVALUATION_IMAGE_UNIFORMS, stream);
332 QUERY_AND_LOG_CAPABILITY(GL_MAX_TESS_EVALUATION_INPUT_COMPONENTS, stream);
333 QUERY_AND_LOG_CAPABILITY(GL_MAX_TESS_EVALUATION_OUTPUT_COMPONENTS, stream);
334 QUERY_AND_LOG_CAPABILITY(GL_MAX_TESS_EVALUATION_SHADER_STORAGE_BLOCKS, stream);
335 QUERY_AND_LOG_CAPABILITY(GL_MAX_TESS_EVALUATION_TEXTURE_IMAGE_UNITS, stream);
336 QUERY_AND_LOG_CAPABILITY(GL_MAX_TESS_EVALUATION_UNIFORM_BLOCKS, stream);
337 QUERY_AND_LOG_CAPABILITY(GL_MAX_TESS_EVALUATION_UNIFORM_COMPONENTS, stream);
338 QUERY_AND_LOG_CAPABILITY(GL_MAX_TESS_GEN_LEVEL, stream);
339 QUERY_AND_LOG_CAPABILITY(GL_MAX_TESS_PATCH_COMPONENTS, stream);
340 QUERY_AND_LOG_CAPABILITY(GL_MAX_TEXTURE_BUFFER_SIZE, stream);
341 QUERY_AND_LOG_CAPABILITY(GL_MIN_FRAGMENT_INTERPOLATION_OFFSET, stream);
342 QUERY_AND_LOG_CAPABILITY(GL_MIN_SAMPLE_SHADING_VALUE, stream);
343
344 // GLES32 capabilities are a superset of GLES31
345 LogGles31Capabilities(stream);
346 }
347
348 // Prints GLES Capabilities listed at
349 // https://opengles.gpuinfo.org/listcapabilities.php
350 // in CSV format
TEST_P(EGLPrintEGLinfoTest,PrintGLESCapabilities)351 TEST_P(EGLPrintEGLinfoTest, PrintGLESCapabilities)
352 {
353 std::cout << std::endl << "Capability name, value" << std::endl << std::endl;
354
355 std::ostream &stream = std::cout;
356
357 switch (getClientMajorVersion())
358 {
359 case 1:
360 break;
361 case 2:
362 LogGles2Capabilities(stream);
363 break;
364 case 3:
365 switch (getClientMinorVersion())
366 {
367 case 2:
368 LogGles32Capabilities(stream);
369 break;
370 case 1:
371 LogGles31Capabilities(stream);
372 break;
373 case 0:
374 LogGles3Capabilities(stream);
375 break;
376 default:
377 FAIL() << "unknown client minor version.";
378 }
379 break;
380 default:
381 FAIL() << "unknown client major version.";
382 }
383
384 stream << std::endl;
385 }
386
387 // Print the EGL configs with attributes
TEST_P(EGLPrintEGLinfoTest,PrintConfigInfo)388 TEST_P(EGLPrintEGLinfoTest, PrintConfigInfo)
389 {
390 // Get all the configs
391 EGLint count;
392 EXPECT_EGL_TRUE(eglGetConfigs(mDisplay, nullptr, 0, &count));
393 EXPECT_TRUE(count > 0);
394 std::vector<EGLConfig> configs(count);
395 EXPECT_EGL_TRUE(eglGetConfigs(mDisplay, configs.data(), count, &count));
396 configs.resize(count);
397 // sort configs by increaing ID
398 std::sort(configs.begin(), configs.end(), [this](EGLConfig a, EGLConfig b) -> bool {
399 return GetAttrib(mDisplay, a, EGL_CONFIG_ID) < GetAttrib(mDisplay, b, EGL_CONFIG_ID);
400 });
401
402 std::cout << "Configs - Count: " << count << std::endl;
403
404 // For each config, print its attributes
405 for (auto config : configs)
406 {
407 // Config ID
408 std::cout << " Config: " << GetAttrib(mDisplay, config, EGL_CONFIG_ID) << std::endl;
409
410 // Color
411 const char *componentType = (GetAttrib(mDisplay, config, EGL_COLOR_COMPONENT_TYPE_EXT) ==
412 EGL_COLOR_COMPONENT_TYPE_FLOAT_EXT)
413 ? "Float "
414 : "Fixed ";
415 const char *colorBuffType =
416 (GetAttrib(mDisplay, config, EGL_COLOR_BUFFER_TYPE) == EGL_LUMINANCE_BUFFER)
417 ? "LUMINANCE"
418 : "RGB";
419 std::cout << "\tColor:" << GetAttrib(mDisplay, config, EGL_BUFFER_SIZE) << "bit "
420 << componentType << colorBuffType
421 << " Red:" << GetAttrib(mDisplay, config, EGL_RED_SIZE)
422 << " Green:" << GetAttrib(mDisplay, config, EGL_GREEN_SIZE)
423 << " Blue:" << GetAttrib(mDisplay, config, EGL_BLUE_SIZE)
424 << " Alpha:" << GetAttrib(mDisplay, config, EGL_ALPHA_SIZE)
425 << " Lum:" << GetAttrib(mDisplay, config, EGL_LUMINANCE_SIZE)
426 << " AlphaMask:" << GetAttrib(mDisplay, config, EGL_ALPHA_MASK_SIZE) << std::endl;
427
428 // Texture Binding
429 std::cout << "\tBinding RGB:" << (bool)GetAttrib(mDisplay, config, EGL_BIND_TO_TEXTURE_RGB)
430 << " RGBA:" << (bool)GetAttrib(mDisplay, config, EGL_BIND_TO_TEXTURE_RGBA)
431 << " MaxWidth:" << GetAttrib(mDisplay, config, EGL_MAX_PBUFFER_WIDTH)
432 << " MaxHeight:" << GetAttrib(mDisplay, config, EGL_MAX_PBUFFER_HEIGHT)
433 << " MaxPixels:" << GetAttrib(mDisplay, config, EGL_MAX_PBUFFER_PIXELS)
434 << std::endl;
435
436 // Conformant
437 EGLint caveatAttrib = GetAttrib(mDisplay, config, EGL_CONFIG_CAVEAT);
438 const char *caveat = nullptr;
439 switch (caveatAttrib)
440 {
441 case EGL_NONE:
442 caveat = "None.";
443 break;
444 case EGL_SLOW_CONFIG:
445 caveat = "Slow.";
446 break;
447 case EGL_NON_CONFORMANT_CONFIG:
448 caveat = "Non-Conformant.";
449 break;
450 default:
451 caveat = ".";
452 }
453 std::cout << "\tCaveate: " << caveat;
454
455 EGLint conformant = GetAttrib(mDisplay, config, EGL_CONFORMANT);
456 std::cout << " Conformant: ";
457 if (conformant & EGL_OPENGL_BIT)
458 std::cout << "OpenGL ";
459 if (conformant & EGL_OPENGL_ES_BIT)
460 std::cout << "ES1 ";
461 if (conformant & EGL_OPENGL_ES2_BIT)
462 std::cout << "ES2 ";
463 if (conformant & EGL_OPENGL_ES3_BIT)
464 std::cout << "ES3";
465 std::cout << std::endl;
466
467 // Ancilary buffers
468 std::cout << "\tAncilary "
469 << "Depth:" << GetAttrib(mDisplay, config, EGL_DEPTH_SIZE)
470 << " Stencil:" << GetAttrib(mDisplay, config, EGL_STENCIL_SIZE)
471 << " SampleBuffs:" << GetAttrib(mDisplay, config, EGL_SAMPLE_BUFFERS)
472 << " Samples:" << GetAttrib(mDisplay, config, EGL_SAMPLES) << std::endl;
473
474 // Swap interval
475 std::cout << "\tSwap Interval"
476 << " Min:" << GetAttrib(mDisplay, config, EGL_MIN_SWAP_INTERVAL)
477 << " Max:" << GetAttrib(mDisplay, config, EGL_MAX_SWAP_INTERVAL) << std::endl;
478
479 // Native
480 std::cout << "\tNative Renderable: " << GetAttrib(mDisplay, config, EGL_NATIVE_RENDERABLE)
481 << ", VisualID: " << GetAttrib(mDisplay, config, EGL_NATIVE_VISUAL_ID)
482 << ", VisualType: " << GetAttrib(mDisplay, config, EGL_NATIVE_VISUAL_TYPE)
483 << std::endl;
484
485 // Surface type
486 EGLint surfaceType = GetAttrib(mDisplay, config, EGL_SURFACE_TYPE);
487 std::cout << "\tSurface Type: ";
488 if (surfaceType & EGL_WINDOW_BIT)
489 std::cout << "WINDOW ";
490 if (surfaceType & EGL_PIXMAP_BIT)
491 std::cout << "PIXMAP ";
492 if (surfaceType & EGL_PBUFFER_BIT)
493 std::cout << "PBUFFER ";
494 if (surfaceType & EGL_MULTISAMPLE_RESOLVE_BOX_BIT)
495 std::cout << "MULTISAMPLE_RESOLVE_BOX ";
496 if (surfaceType & EGL_SWAP_BEHAVIOR_PRESERVED_BIT)
497 std::cout << "SWAP_PRESERVE ";
498 std::cout << std::endl;
499
500 // Renderable
501 EGLint rendType = GetAttrib(mDisplay, config, EGL_RENDERABLE_TYPE);
502 std::cout << "\tRender: ";
503 if (rendType & EGL_OPENGL_BIT)
504 std::cout << "OpenGL ";
505 if (rendType & EGL_OPENGL_ES_BIT)
506 std::cout << "ES1 ";
507 if (rendType & EGL_OPENGL_ES2_BIT)
508 std::cout << "ES2 ";
509 if (rendType & EGL_OPENGL_ES3_BIT)
510 std::cout << "ES3 ";
511 std::cout << std::endl;
512
513 // Extensions
514 if (IsEGLDisplayExtensionEnabled(mDisplay, "EGL_ANDROID_recordable"))
515 {
516 std::cout << "\tAndroid Recordable: "
517 << GetAttrib(mDisplay, config, EGL_RECORDABLE_ANDROID) << std::endl;
518 }
519 if (IsEGLDisplayExtensionEnabled(mDisplay, "EGL_ANDROID_framebuffer_target"))
520 {
521 std::cout << "\tAndroid framebuffer target: "
522 << GetAttrib(mDisplay, config, EGL_FRAMEBUFFER_TARGET_ANDROID) << std::endl;
523 }
524
525 // Separator between configs
526 std::cout << std::endl;
527 }
528 }
529
530 ANGLE_INSTANTIATE_TEST(EGLPrintEGLinfoTest,
531 ES1_VULKAN(),
532 ES1_VULKAN_SWIFTSHADER(),
533 ES2_VULKAN(),
534 ES3_VULKAN(),
535 ES32_VULKAN(),
536 ES31_VULKAN_SWIFTSHADER());
537
538 // This test suite is not instantiated on some OSes.
539 GTEST_ALLOW_UNINSTANTIATED_PARAMETERIZED_TEST(EGLPrintEGLinfoTest);
540