1 /*-------------------------------------------------------------------------
2 * drawElements Quality Program EGL 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 Choose config tests.
22 *//*--------------------------------------------------------------------*/
23
24 #include "teglChooseConfigTests.hpp"
25 #include "teglChooseConfigReference.hpp"
26 #include "tcuTestLog.hpp"
27 #include "egluStrUtil.hpp"
28 #include "egluUtil.hpp"
29 #include "eglwLibrary.hpp"
30 #include "eglwEnums.hpp"
31 #include "deRandom.hpp"
32 #include "deStringUtil.hpp"
33 #include "deUniquePtr.hpp"
34 #include "deSTLUtil.hpp"
35
36 #include <vector>
37 #include <algorithm>
38 #include <string>
39 #include <set>
40 #include <map>
41
42 namespace deqp
43 {
44 namespace egl
45 {
46
47 using std::set;
48 using std::vector;
49 using std::pair;
50 using std::string;
51 using tcu::TestLog;
52 using eglu::ConfigInfo;
53 using namespace eglw;
54
55 namespace
56 {
57
configListToString(const Library& egl, const EGLDisplay& display, const vector<EGLConfig>& configs)58 string configListToString (const Library& egl, const EGLDisplay& display, const vector<EGLConfig>& configs)
59 {
60 string str = "";
61 for (vector<EGLConfig>::const_iterator cfgIter = configs.begin(); cfgIter != configs.end(); cfgIter++)
62 {
63 EGLConfig config = *cfgIter;
64 EGLint configId = eglu::getConfigID(egl, display, config);
65
66 if (str.length() != 0)
67 str += " ";
68
69 str += de::toString(configId);
70 }
71 return str;
72 }
73
logConfigAttrib(TestLog& log, EGLenum attrib, EGLint value)74 void logConfigAttrib (TestLog& log, EGLenum attrib, EGLint value)
75 {
76 const std::string attribStr = eglu::getConfigAttribName(attrib);
77
78 if (value == EGL_DONT_CARE)
79 {
80 log << TestLog::Message << " " << attribStr << ": EGL_DONT_CARE" << TestLog::EndMessage;
81 return;
82 }
83
84 log << TestLog::Message << " " << attribStr << ": " << eglu::getConfigAttribValueStr(attrib, value) << TestLog::EndMessage;
85 }
86
configListEqual(const Library& egl, const EGLDisplay& display, const vector<EGLConfig>& as, const vector<EGLConfig>& bs)87 bool configListEqual (const Library& egl, const EGLDisplay& display, const vector<EGLConfig>& as, const vector<EGLConfig>& bs)
88 {
89 if (as.size() != bs.size())
90 return false;
91
92 for (int configNdx = 0; configNdx < (int)as.size(); configNdx++)
93 {
94 if (as[configNdx] != bs[configNdx])
95 {
96 // Allow lists to differ if both configs are non-conformant
97 const EGLint aCaveat = eglu::getConfigAttribInt(egl, display, as[configNdx], EGL_CONFIG_CAVEAT);
98 const EGLint bCaveat = eglu::getConfigAttribInt(egl, display, bs[configNdx], EGL_CONFIG_CAVEAT);
99
100 if (aCaveat != EGL_NON_CONFORMANT_CONFIG || bCaveat != EGL_NON_CONFORMANT_CONFIG)
101 return false;
102 }
103 }
104
105 return true;
106 }
107
108 } // anonymous
109
110 class ChooseConfigCase : public TestCase
111 {
112 public:
ChooseConfigCase(EglTestContext& eglTestCtx, const char* name, const char* description, bool checkOrder, const EGLint* attributes)113 ChooseConfigCase (EglTestContext& eglTestCtx, const char* name, const char* description, bool checkOrder, const EGLint* attributes)
114 : TestCase (eglTestCtx, name, description)
115 , m_checkOrder (checkOrder)
116 , m_display (EGL_NO_DISPLAY)
117 {
118 // Parse attributes
119 while (attributes[0] != EGL_NONE)
120 {
121 m_attributes.push_back(std::make_pair((EGLenum)attributes[0], (EGLint)attributes[1]));
122 attributes += 2;
123 }
124 }
125
ChooseConfigCase(EglTestContext& eglTestCtx, const char* name, const char* description, bool checkOrder, const std::vector<std::pair<EGLenum, EGLint> >& attributes)126 ChooseConfigCase (EglTestContext& eglTestCtx, const char* name, const char* description, bool checkOrder, const std::vector<std::pair<EGLenum, EGLint> >& attributes)
127 : TestCase (eglTestCtx, name, description)
128 , m_checkOrder (checkOrder)
129 , m_attributes (attributes)
130 , m_display (EGL_NO_DISPLAY)
131 {
132 }
133
init(void)134 void init (void)
135 {
136 DE_ASSERT(m_display == EGL_NO_DISPLAY);
137 m_display = eglu::getAndInitDisplay(m_eglTestCtx.getNativeDisplay());
138 }
139
deinit(void)140 void deinit (void)
141 {
142 m_eglTestCtx.getLibrary().terminate(m_display);
143 m_display = EGL_NO_DISPLAY;
144 }
145
iterate(void)146 IterateResult iterate (void)
147 {
148 m_testCtx.setTestResult(QP_TEST_RESULT_PASS, "Pass");
149 executeTest(m_attributes, m_checkOrder);
150 return STOP;
151 }
152
153 protected:
ChooseConfigCase(EglTestContext& eglTestCtx, const char* name, const char* description, bool checkOrder)154 ChooseConfigCase (EglTestContext& eglTestCtx, const char* name, const char* description, bool checkOrder)
155 : TestCase (eglTestCtx, name, description)
156 , m_checkOrder (checkOrder)
157 , m_display (EGL_NO_DISPLAY)
158 {
159 }
160
executeTest(const std::vector<std::pair<EGLenum, EGLint> >& attributes, bool checkOrder)161 void executeTest (const std::vector<std::pair<EGLenum, EGLint> >& attributes, bool checkOrder)
162 {
163 const Library& egl = m_eglTestCtx.getLibrary();
164 TestLog& log = m_testCtx.getLog();
165
166 // Build attributes for EGL
167 vector<EGLint> attribList;
168 for (vector<pair<EGLenum, EGLint> >::const_iterator i = attributes.begin(); i != attributes.end(); i++)
169 {
170 attribList.push_back(i->first);
171 attribList.push_back(i->second);
172 }
173 attribList.push_back(EGL_NONE);
174
175 // Print attribList to log
176 log << TestLog::Message << "Attributes:" << TestLog::EndMessage;
177 for (vector<pair<EGLenum, EGLint> >::const_iterator i = attributes.begin(); i != attributes.end(); i++)
178 logConfigAttrib(log, i->first, i->second);
179
180 std::vector<EGLConfig> resultConfigs;
181 std::vector<EGLConfig> referenceConfigs;
182
183 // Query from EGL implementation
184 {
185 EGLint numConfigs = 0;
186 EGLU_CHECK_CALL(egl, chooseConfig(m_display, &attribList[0], DE_NULL, 0, &numConfigs));
187 resultConfigs.resize(numConfigs);
188
189 if (numConfigs > 0)
190 EGLU_CHECK_CALL(egl, chooseConfig(m_display, &attribList[0], &resultConfigs[0], (EGLint)resultConfigs.size(), &numConfigs));
191 }
192
193 // Build reference
194 chooseConfigReference(egl, m_display, referenceConfigs, attributes);
195
196 log << TestLog::Message << "Expected:\n " << configListToString(egl, m_display, referenceConfigs) << TestLog::EndMessage;
197 log << TestLog::Message << "Got:\n " << configListToString(egl, m_display, resultConfigs) << TestLog::EndMessage;
198
199 bool isSetMatch = (set<EGLConfig>(resultConfigs.begin(), resultConfigs.end()) == set<EGLConfig>(referenceConfigs.begin(), referenceConfigs.end()));
200 bool isExactMatch = configListEqual(egl, m_display, resultConfigs, referenceConfigs);
201 bool isMatch = isSetMatch && (checkOrder ? isExactMatch : true);
202
203 if (isMatch)
204 log << TestLog::Message << "Pass" << TestLog::EndMessage;
205 else if (!isSetMatch)
206 log << TestLog::Message << "Fail, configs don't match" << TestLog::EndMessage;
207 else if (!isExactMatch)
208 log << TestLog::Message << "Fail, got correct configs but in invalid order" << TestLog::EndMessage;
209
210 if (!isMatch)
211 m_testCtx.setTestResult(QP_TEST_RESULT_FAIL, "Fail");
212 }
213
fillDontCare(std::vector<std::pair<EGLenum, EGLint> >& attributes)214 void fillDontCare (std::vector<std::pair<EGLenum, EGLint> >& attributes)
215 {
216 static const EGLenum dontCareAttributes[] =
217 {
218 EGL_TRANSPARENT_TYPE,
219 EGL_COLOR_BUFFER_TYPE,
220 EGL_RENDERABLE_TYPE,
221 EGL_SURFACE_TYPE
222 };
223
224 // Fill appropriate unused attributes with EGL_DONT_CARE
225 for (int ndx = 0; ndx < DE_LENGTH_OF_ARRAY(dontCareAttributes); ndx++)
226 {
227 bool found = false;
228 for (size_t findNdx = 0; findNdx < attributes.size(); findNdx++)
229 if (attributes[findNdx].first == dontCareAttributes[ndx]) found = true;
230
231 if (!found) attributes.push_back(std::make_pair(dontCareAttributes[ndx], EGL_DONT_CARE));
232 }
233 }
234
235 const bool m_checkOrder;
236 vector<pair<EGLenum, EGLint> > m_attributes;
237
238 EGLDisplay m_display;
239 };
240
241 class ChooseConfigSimpleCase : public ChooseConfigCase
242 {
243 protected:
getValue(EGLenum name)244 EGLint getValue (EGLenum name)
245 {
246 static const struct
247 {
248 EGLenum name;
249 EGLint value;
250 } attributes[] =
251 {
252 { EGL_BUFFER_SIZE, 0 },
253 { EGL_RED_SIZE, 0 },
254 { EGL_GREEN_SIZE, 0 },
255 { EGL_BLUE_SIZE, 0 },
256 { EGL_LUMINANCE_SIZE, 0 },
257 { EGL_ALPHA_SIZE, 0 },
258 { EGL_ALPHA_MASK_SIZE, 0 },
259 { EGL_BIND_TO_TEXTURE_RGB, EGL_DONT_CARE },
260 { EGL_BIND_TO_TEXTURE_RGBA, EGL_DONT_CARE },
261 { EGL_COLOR_BUFFER_TYPE, EGL_DONT_CARE },
262 { EGL_CONFIG_CAVEAT, EGL_DONT_CARE },
263 //{ EGL_CONFIG_ID, EGL_DONT_CARE },
264 { EGL_DEPTH_SIZE, 0 },
265 { EGL_LEVEL, 0 },
266 { EGL_MAX_SWAP_INTERVAL, EGL_DONT_CARE },
267 { EGL_MIN_SWAP_INTERVAL, EGL_DONT_CARE },
268 { EGL_NATIVE_RENDERABLE, EGL_DONT_CARE },
269 { EGL_NATIVE_VISUAL_TYPE, EGL_DONT_CARE },
270 { EGL_SAMPLE_BUFFERS, 0 },
271 { EGL_SAMPLES, 0 },
272 { EGL_STENCIL_SIZE, 0 },
273 { EGL_TRANSPARENT_TYPE, EGL_TRANSPARENT_RGB },
274 { EGL_TRANSPARENT_RED_VALUE, 0 },
275 { EGL_TRANSPARENT_GREEN_VALUE, 0 },
276 { EGL_TRANSPARENT_BLUE_VALUE, 0 },
277 { EGL_CONFORMANT, EGL_OPENGL_ES_BIT },
278 { EGL_RENDERABLE_TYPE, EGL_OPENGL_ES_BIT },
279 { EGL_SURFACE_TYPE, EGL_WINDOW_BIT },
280 { EGL_RECORDABLE_ANDROID, EGL_DONT_CARE },
281 //{ EGL_CONFORMANT, EGL_OPENGL_BIT | EGL_OPENGL_ES_BIT | EGL_OPENGL_ES2_BIT | EGL_OPENVG_BIT },
282 //{ EGL_RENDERABLE_TYPE, EGL_OPENGL_BIT | EGL_OPENGL_ES_BIT | EGL_OPENGL_ES2_BIT | EGL_OPENVG_BIT },
283 //{ EGL_SURFACE_TYPE, EGL_WINDOW_BIT
284 // | EGL_PIXMAP_BIT
285 // | EGL_PBUFFER_BIT
286 // | EGL_MULTISAMPLE_RESOLVE_BOX_BIT
287 // | EGL_VG_ALPHA_FORMAT_PRE_BIT
288 // | EGL_SWAP_BEHAVIOR_PRESERVED_BIT
289 // | EGL_VG_COLORSPACE_LINEAR_BIT
290 // }
291 };
292
293 if (name == EGL_CONFIG_ID)
294 {
295 de::Random rnd(0);
296 vector<EGLConfig> configs = eglu::getConfigs(m_eglTestCtx.getLibrary(), m_display);
297 return eglu::getConfigID(m_eglTestCtx.getLibrary(), m_display, configs[rnd.getInt(0, (int)configs.size()-1)]);
298 }
299 else
300 {
301 for (int ndx = 0; ndx < DE_LENGTH_OF_ARRAY(attributes); ndx++)
302 {
303 if (attributes[ndx].name == name)
304 return attributes[ndx].value;
305 }
306 }
307
308 DE_ASSERT(DE_FALSE);
309 return EGL_NONE;
310 }
311 public:
ChooseConfigSimpleCase(EglTestContext& eglTestCtx, const char* name, const char* description, EGLenum attribute, bool checkOrder)312 ChooseConfigSimpleCase (EglTestContext& eglTestCtx, const char* name, const char* description, EGLenum attribute, bool checkOrder)
313 : ChooseConfigCase(eglTestCtx, name, description, checkOrder)
314 , m_attribute(attribute)
315 {
316 }
317
iterate(void)318 TestCase::IterateResult iterate (void)
319 {
320 m_testCtx.setTestResult(QP_TEST_RESULT_PASS, "Pass");
321
322 {
323 const Library& egl = m_eglTestCtx.getLibrary();
324 if (m_attribute == EGL_RECORDABLE_ANDROID && !eglu::hasExtension(egl, m_display, "EGL_ANDROID_recordable"))
325 TCU_THROW(NotSupportedError, "EGL_ANDROID_recordable is not supported");
326 }
327
328 std::vector<std::pair<EGLenum, EGLint> > attributes;
329 attributes.push_back(std::pair<EGLenum, EGLint>(m_attribute, getValue(m_attribute)));
330
331 fillDontCare(attributes);
332 executeTest(attributes, m_checkOrder);
333
334 return STOP;
335 }
336 private:
337 EGLenum m_attribute;
338 };
339
340 class ChooseConfigRandomCase : public ChooseConfigCase
341 {
342 public:
ChooseConfigRandomCase(EglTestContext& eglTestCtx, const char* name, const char* description, const set<EGLenum>& attribSet)343 ChooseConfigRandomCase (EglTestContext& eglTestCtx, const char* name, const char* description, const set<EGLenum>& attribSet)
344 : ChooseConfigCase (eglTestCtx, name, description, true)
345 , m_attribSet (attribSet)
346 , m_numIters (10)
347 , m_iterNdx (0)
348 {
349 }
350
init(void)351 void init (void)
352 {
353 ChooseConfigCase::init();
354 m_iterNdx = 0;
355 m_testCtx.setTestResult(QP_TEST_RESULT_PASS, "Pass");
356
357 // Remove unsupported attributes from the set
358 if (!eglu::hasExtension(m_eglTestCtx.getLibrary(), m_display, "EGL_ANDROID_recordable"))
359 m_attribSet.erase(EGL_RECORDABLE_ANDROID);
360 }
361
iterate(void)362 TestCase::IterateResult iterate (void)
363 {
364 m_testCtx.getLog() << TestLog::Message << "Iteration :" << m_iterNdx << TestLog::EndMessage;
365 m_iterNdx += 1;
366
367 // Build random list of attributes
368 de::Random rnd(m_iterNdx);
369 const int numAttribs = rnd.getInt(0, (int)m_attribSet.size()*2);
370
371 std::vector<std::pair<EGLenum, EGLint> > attributes = genRandomAttributes(m_attribSet, numAttribs, rnd);
372
373 fillDontCare(attributes);
374 executeTest(attributes, m_checkOrder);
375
376 return m_iterNdx < m_numIters ? CONTINUE : STOP;
377 }
378
getInt(de::Random& rnd)379 template <int MinVal, int MaxVal> static EGLint getInt (de::Random& rnd)
380 {
381 return rnd.getInt(MinVal, MaxVal);
382 }
383
getBool(de::Random& rnd)384 static EGLint getBool (de::Random& rnd)
385 {
386 return rnd.getBool() ? EGL_TRUE : EGL_FALSE;
387 }
388
getBufferType(de::Random& rnd)389 static EGLint getBufferType (de::Random& rnd)
390 {
391 static const EGLint types[] = { EGL_RGB_BUFFER, EGL_LUMINANCE_BUFFER };
392 return rnd.choose<EGLint>(types, types+DE_LENGTH_OF_ARRAY(types));
393 }
394
getConfigCaveat(de::Random& rnd)395 static EGLint getConfigCaveat (de::Random& rnd)
396 {
397 static const EGLint caveats[] = { EGL_SLOW_CONFIG, EGL_NON_CONFORMANT_CONFIG };
398 return rnd.choose<EGLint>(caveats, caveats+DE_LENGTH_OF_ARRAY(caveats));
399 }
400
getApiBits(de::Random& rnd)401 static EGLint getApiBits (de::Random& rnd)
402 {
403 EGLint api = 0;
404 api |= rnd.getBool() ? EGL_OPENGL_BIT : 0;
405 api |= rnd.getBool() ? EGL_OPENGL_ES_BIT : 0;
406 api |= rnd.getBool() ? EGL_OPENGL_ES2_BIT : 0;
407 api |= rnd.getBool() ? EGL_OPENVG_BIT : 0;
408 return api;
409 }
410
getSurfaceType(de::Random& rnd)411 static EGLint getSurfaceType (de::Random& rnd)
412 {
413 EGLint bits = 0;
414 bits |= rnd.getBool() ? EGL_WINDOW_BIT : 0;
415 bits |= rnd.getBool() ? EGL_PIXMAP_BIT : 0;
416 bits |= rnd.getBool() ? EGL_PBUFFER_BIT : 0;
417 return bits;
418 }
419
420 struct AttribSpec
421 {
422 EGLenum attribute;
423 EGLint (*getValue)(de::Random& rnd);
424 };
425
genRandomAttributes(const std::set<EGLenum>& attribSet, int numAttribs, de::Random& rnd)426 std::vector<std::pair<EGLenum, EGLint> > genRandomAttributes (const std::set<EGLenum>& attribSet, int numAttribs, de::Random& rnd)
427 {
428 static const struct AttribSpec attributes[] =
429 {
430 { EGL_BUFFER_SIZE, ChooseConfigRandomCase::getInt<0, 32>, },
431 { EGL_RED_SIZE, ChooseConfigRandomCase::getInt<0, 8>, },
432 { EGL_GREEN_SIZE, ChooseConfigRandomCase::getInt<0, 8>, },
433 { EGL_BLUE_SIZE, ChooseConfigRandomCase::getInt<0, 8>, },
434 { EGL_LUMINANCE_SIZE, ChooseConfigRandomCase::getInt<0, 1>, },
435 { EGL_ALPHA_SIZE, ChooseConfigRandomCase::getInt<0, 8>, },
436 { EGL_ALPHA_MASK_SIZE, ChooseConfigRandomCase::getInt<0, 1>, },
437 { EGL_BIND_TO_TEXTURE_RGB, ChooseConfigRandomCase::getBool, },
438 { EGL_BIND_TO_TEXTURE_RGBA, ChooseConfigRandomCase::getBool, },
439 { EGL_COLOR_BUFFER_TYPE, ChooseConfigRandomCase::getBufferType, },
440 { EGL_CONFIG_CAVEAT, ChooseConfigRandomCase::getConfigCaveat, },
441 // { EGL_CONFIG_ID, 0/*special*/, },
442 { EGL_CONFORMANT, ChooseConfigRandomCase::getApiBits, },
443 { EGL_DEPTH_SIZE, ChooseConfigRandomCase::getInt<0, 32>, },
444 { EGL_LEVEL, ChooseConfigRandomCase::getInt<0, 1>, },
445 // { EGL_MATCH_NATIVE_PIXMAP, EGL_NONE, },
446 { EGL_MAX_SWAP_INTERVAL, ChooseConfigRandomCase::getInt<0, 2>, },
447 { EGL_MIN_SWAP_INTERVAL, ChooseConfigRandomCase::getInt<0, 1>, },
448 { EGL_NATIVE_RENDERABLE, ChooseConfigRandomCase::getBool, },
449 // { EGL_NATIVE_VISUAL_TYPE, EGL_DONT_CARE, },
450 { EGL_RENDERABLE_TYPE, ChooseConfigRandomCase::getApiBits, },
451 { EGL_SAMPLE_BUFFERS, ChooseConfigRandomCase::getInt<0, 1>, },
452 { EGL_SAMPLES, ChooseConfigRandomCase::getInt<0, 1>, },
453 { EGL_STENCIL_SIZE, ChooseConfigRandomCase::getInt<0, 1>, },
454 { EGL_SURFACE_TYPE, ChooseConfigRandomCase::getSurfaceType, },
455 // { EGL_TRANSPARENT_TYPE, EGL_TRANSPARENT_RGB,},
456 // { EGL_TRANSPARENT_RED_VALUE, ChooseConfigRandomCase::getInt<0, 255>, },
457 // { EGL_TRANSPARENT_GREEN_VALUE, ChooseConfigRandomCase::getInt<0, 255>, },
458 // { EGL_TRANSPARENT_BLUE_VALUE, ChooseConfigRandomCase::getInt<0, 255>, },
459 { EGL_RECORDABLE_ANDROID, ChooseConfigRandomCase::getBool, },
460 };
461
462 std::vector<std::pair<EGLenum, EGLint> > out;
463
464 // Build list to select from
465 std::vector<AttribSpec> candidates;
466 for (int ndx = 0; ndx < (int)DE_LENGTH_OF_ARRAY(attributes); ndx++)
467 {
468 if (attribSet.find(attributes[ndx].attribute) != attribSet.end())
469 candidates.push_back(attributes[ndx]);
470 }
471
472 for (int attribNdx = 0; attribNdx < numAttribs; attribNdx++)
473 {
474 AttribSpec spec = rnd.choose<AttribSpec>(candidates.begin(), candidates.end());
475 out.push_back(std::make_pair(spec.attribute, spec.getValue(rnd)));
476 }
477
478 return out;
479 }
480 private:
481 std::set<EGLenum> m_attribSet;
482 int m_numIters;
483 int m_iterNdx;
484 };
485
486 class ColorComponentTypeCase : public ChooseConfigCase
487 {
488
489 public:
ColorComponentTypeCase(EglTestContext& eglTestCtx, const char* name, EGLenum value)490 ColorComponentTypeCase (EglTestContext& eglTestCtx, const char* name, EGLenum value)
491 : ChooseConfigCase (eglTestCtx, name, "", true /* sorting order is validated */)
492 , m_value (value)
493 {
494 }
495
iterate(void)496 TestCase::IterateResult iterate (void)
497 {
498 m_testCtx.setTestResult(QP_TEST_RESULT_PASS, "Pass");
499
500 {
501 const std::vector<std::string> extensions = eglu::getDisplayExtensions(m_eglTestCtx.getLibrary(), m_display);
502
503 if (!de::contains(extensions.begin(), extensions.end(), "EGL_EXT_pixel_format_float"))
504 TCU_THROW(NotSupportedError, "EGL_EXT_pixel_format_float is not supported");
505 }
506
507 {
508 std::vector<std::pair<EGLenum, EGLint> > attributes;
509
510 attributes.push_back(std::pair<EGLenum, EGLint>(EGL_COLOR_COMPONENT_TYPE_EXT, m_value));
511 fillDontCare(attributes);
512
513 executeTest(attributes, m_checkOrder);
514 }
515
516 return STOP;
517 }
518 private:
519 const EGLenum m_value;
520 };
521
ChooseConfigTests(EglTestContext& eglTestCtx)522 ChooseConfigTests::ChooseConfigTests (EglTestContext& eglTestCtx)
523 : TestCaseGroup(eglTestCtx, "choose_config", "eglChooseConfig() tests")
524 {
525 }
526
~ChooseConfigTests(void)527 ChooseConfigTests::~ChooseConfigTests (void)
528 {
529 }
530
531 namespace
532 {
533
534 template <typename T, size_t N>
535 std::set<T> toSet (const T (&arr)[N])
536 {
537 std::set<T> set;
538 for (size_t i = 0; i < N; i++)
539 set.insert(arr[i]);
540 return set;
541 }
542
543 } // anonymous
544
init(void)545 void ChooseConfigTests::init (void)
546 {
547 // Single attributes
548 {
549 static const struct
550 {
551 EGLenum attribute;
552 const char* testName;
553 } attributes[] =
554 {
555 { EGL_BUFFER_SIZE, "buffer_size" },
556 { EGL_RED_SIZE, "red_size" },
557 { EGL_GREEN_SIZE, "green_size" },
558 { EGL_BLUE_SIZE, "blue_size" },
559 { EGL_LUMINANCE_SIZE, "luminance_size" },
560 { EGL_ALPHA_SIZE, "alpha_size" },
561 { EGL_ALPHA_MASK_SIZE, "alpha_mask_size" },
562 { EGL_BIND_TO_TEXTURE_RGB, "bind_to_texture_rgb" },
563 { EGL_BIND_TO_TEXTURE_RGBA, "bind_to_texture_rgba" },
564 { EGL_COLOR_BUFFER_TYPE, "color_buffer_type" },
565 { EGL_CONFIG_CAVEAT, "config_caveat" },
566 { EGL_CONFIG_ID, "config_id" },
567 { EGL_CONFORMANT, "conformant" },
568 { EGL_DEPTH_SIZE, "depth_size" },
569 { EGL_LEVEL, "level" },
570 { EGL_MAX_SWAP_INTERVAL, "max_swap_interval" },
571 { EGL_MIN_SWAP_INTERVAL, "min_swap_interval" },
572 { EGL_NATIVE_RENDERABLE, "native_renderable" },
573 { EGL_NATIVE_VISUAL_TYPE, "native_visual_type" },
574 { EGL_RENDERABLE_TYPE, "renderable_type" },
575 { EGL_SAMPLE_BUFFERS, "sample_buffers" },
576 { EGL_SAMPLES, "samples" },
577 { EGL_STENCIL_SIZE, "stencil_size" },
578 { EGL_SURFACE_TYPE, "surface_type" },
579 { EGL_TRANSPARENT_TYPE, "transparent_type" },
580 { EGL_TRANSPARENT_RED_VALUE, "transparent_red_value" },
581 { EGL_TRANSPARENT_GREEN_VALUE, "transparent_green_value" },
582 { EGL_TRANSPARENT_BLUE_VALUE, "transparent_blue_value" },
583 { EGL_RECORDABLE_ANDROID, "recordable_android" },
584 };
585
586 tcu::TestCaseGroup* simpleGroup = new tcu::TestCaseGroup(m_testCtx, "simple", "Simple tests");
587 addChild(simpleGroup);
588
589 tcu::TestCaseGroup* selectionGroup = new tcu::TestCaseGroup(m_testCtx, "selection_only", "Selection tests, order ignored");
590 simpleGroup->addChild(selectionGroup);
591
592 tcu::TestCaseGroup* sortGroup = new tcu::TestCaseGroup(m_testCtx, "selection_and_sort", "Selection and ordering tests");
593 simpleGroup->addChild(sortGroup);
594
595 for (int ndx = 0; ndx < (int)DE_LENGTH_OF_ARRAY(attributes); ndx++)
596 {
597 selectionGroup->addChild(new ChooseConfigSimpleCase(m_eglTestCtx, attributes[ndx].testName, "Simple config selection case", attributes[ndx].attribute, false));
598 sortGroup->addChild(new ChooseConfigSimpleCase(m_eglTestCtx, attributes[ndx].testName, "Simple config selection and sort case", attributes[ndx].attribute, true));
599 }
600 }
601
602 // Random
603 {
604 tcu::TestCaseGroup* randomGroup = new tcu::TestCaseGroup(m_testCtx, "random", "Random eglChooseConfig() usage");
605 addChild(randomGroup);
606
607 static const EGLenum rgbaSizes[] =
608 {
609 EGL_RED_SIZE,
610 EGL_GREEN_SIZE,
611 EGL_BLUE_SIZE,
612 EGL_ALPHA_SIZE
613 };
614 randomGroup->addChild(new ChooseConfigRandomCase(m_eglTestCtx, "color_sizes", "Random color size rules", toSet(rgbaSizes)));
615
616 static const EGLenum colorDepthStencilSizes[] =
617 {
618 EGL_RED_SIZE,
619 EGL_GREEN_SIZE,
620 EGL_BLUE_SIZE,
621 EGL_ALPHA_SIZE,
622 EGL_DEPTH_SIZE,
623 EGL_STENCIL_SIZE
624 };
625 randomGroup->addChild(new ChooseConfigRandomCase(m_eglTestCtx, "color_depth_stencil_sizes", "Random color, depth and stencil size rules", toSet(colorDepthStencilSizes)));
626
627 static const EGLenum bufferSizes[] =
628 {
629 EGL_BUFFER_SIZE,
630 EGL_LUMINANCE_SIZE,
631 EGL_ALPHA_MASK_SIZE,
632 EGL_DEPTH_SIZE,
633 EGL_STENCIL_SIZE
634 };
635 randomGroup->addChild(new ChooseConfigRandomCase(m_eglTestCtx, "buffer_sizes", "Various buffer size rules", toSet(bufferSizes)));
636
637 static const EGLenum surfaceType[] =
638 {
639 EGL_NATIVE_RENDERABLE,
640 EGL_SURFACE_TYPE
641 };
642 randomGroup->addChild(new ChooseConfigRandomCase(m_eglTestCtx, "surface_type", "Surface type rules", toSet(surfaceType)));
643
644 static const EGLenum sampleBuffers[] =
645 {
646 EGL_SAMPLE_BUFFERS,
647 EGL_SAMPLES
648 };
649 randomGroup->addChild(new ChooseConfigRandomCase(m_eglTestCtx, "sample_buffers", "Sample buffer rules", toSet(sampleBuffers)));
650
651 // \note Not every attribute is supported at the moment
652 static const EGLenum allAttribs[] =
653 {
654 EGL_BUFFER_SIZE,
655 EGL_RED_SIZE,
656 EGL_GREEN_SIZE,
657 EGL_BLUE_SIZE,
658 EGL_ALPHA_SIZE,
659 EGL_ALPHA_MASK_SIZE,
660 EGL_BIND_TO_TEXTURE_RGB,
661 EGL_BIND_TO_TEXTURE_RGBA,
662 EGL_COLOR_BUFFER_TYPE,
663 EGL_CONFIG_CAVEAT,
664 EGL_CONFIG_ID,
665 EGL_CONFORMANT,
666 EGL_DEPTH_SIZE,
667 EGL_LEVEL,
668 // EGL_MATCH_NATIVE_PIXMAP,
669 EGL_MAX_SWAP_INTERVAL,
670 EGL_MIN_SWAP_INTERVAL,
671 EGL_NATIVE_RENDERABLE,
672 EGL_NATIVE_VISUAL_TYPE,
673 EGL_RENDERABLE_TYPE,
674 EGL_SAMPLE_BUFFERS,
675 EGL_SAMPLES,
676 EGL_STENCIL_SIZE,
677 EGL_SURFACE_TYPE,
678 EGL_TRANSPARENT_TYPE,
679 // EGL_TRANSPARENT_RED_VALUE,
680 // EGL_TRANSPARENT_GREEN_VALUE,
681 // EGL_TRANSPARENT_BLUE_VALUE,
682 EGL_RECORDABLE_ANDROID,
683 };
684 randomGroup->addChild(new ChooseConfigRandomCase(m_eglTestCtx, "all", "All attributes", toSet(allAttribs)));
685 }
686
687 // EGL_EXT_pixel_format_float
688 {
689 de::MovePtr<tcu::TestCaseGroup> colorComponentTypeGroup (new tcu::TestCaseGroup(m_testCtx, "color_component_type_ext", "EGL_EXT_pixel_format_float tests"));
690
691 colorComponentTypeGroup->addChild(new ColorComponentTypeCase(m_eglTestCtx, "dont_care", EGL_DONT_CARE));
692 colorComponentTypeGroup->addChild(new ColorComponentTypeCase(m_eglTestCtx, "fixed", EGL_COLOR_COMPONENT_TYPE_FIXED_EXT));
693 colorComponentTypeGroup->addChild(new ColorComponentTypeCase(m_eglTestCtx, "float", EGL_COLOR_COMPONENT_TYPE_FLOAT_EXT));
694
695 addChild(colorComponentTypeGroup.release());
696 }
697 }
698
699 } // egl
700 } // deqp
701