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_CONFORMANT, EGL_OPENGL_BIT | EGL_OPENGL_ES_BIT | EGL_OPENGL_ES2_BIT | EGL_OPENVG_BIT },
281 //{ EGL_RENDERABLE_TYPE, EGL_OPENGL_BIT | EGL_OPENGL_ES_BIT | EGL_OPENGL_ES2_BIT | EGL_OPENVG_BIT },
282 //{ EGL_SURFACE_TYPE, EGL_WINDOW_BIT
283 // | EGL_PIXMAP_BIT
284 // | EGL_PBUFFER_BIT
285 // | EGL_MULTISAMPLE_RESOLVE_BOX_BIT
286 // | EGL_VG_ALPHA_FORMAT_PRE_BIT
287 // | EGL_SWAP_BEHAVIOR_PRESERVED_BIT
288 // | EGL_VG_COLORSPACE_LINEAR_BIT
289 // }
290 };
291
292 if (name == EGL_CONFIG_ID)
293 {
294 de::Random rnd(0);
295 vector<EGLConfig> configs = eglu::getConfigs(m_eglTestCtx.getLibrary(), m_display);
296 return eglu::getConfigID(m_eglTestCtx.getLibrary(), m_display, configs[rnd.getInt(0, (int)configs.size()-1)]);
297 }
298 else
299 {
300 for (int ndx = 0; ndx < DE_LENGTH_OF_ARRAY(attributes); ndx++)
301 {
302 if (attributes[ndx].name == name)
303 return attributes[ndx].value;
304 }
305 }
306
307 DE_ASSERT(DE_FALSE);
308 return EGL_NONE;
309 }
310 public:
ChooseConfigSimpleCase(EglTestContext & eglTestCtx,const char * name,const char * description,EGLenum attribute,bool checkOrder)311 ChooseConfigSimpleCase (EglTestContext& eglTestCtx, const char* name, const char* description, EGLenum attribute, bool checkOrder)
312 : ChooseConfigCase(eglTestCtx, name, description, checkOrder)
313 , m_attribute(attribute)
314 {
315 }
316
iterate(void)317 TestCase::IterateResult iterate (void)
318 {
319 m_testCtx.setTestResult(QP_TEST_RESULT_PASS, "Pass");
320
321 std::vector<std::pair<EGLenum, EGLint> > attributes;
322 attributes.push_back(std::pair<EGLenum, EGLint>(m_attribute, getValue(m_attribute)));
323
324 fillDontCare(attributes);
325 executeTest(attributes, m_checkOrder);
326
327 return STOP;
328 }
329 private:
330 EGLenum m_attribute;
331 };
332
333 class ChooseConfigRandomCase : public ChooseConfigCase
334 {
335 public:
ChooseConfigRandomCase(EglTestContext & eglTestCtx,const char * name,const char * description,const set<EGLenum> & attribSet)336 ChooseConfigRandomCase (EglTestContext& eglTestCtx, const char* name, const char* description, const set<EGLenum>& attribSet)
337 : ChooseConfigCase (eglTestCtx, name, description, true)
338 , m_attribSet (attribSet)
339 , m_numIters (10)
340 , m_iterNdx (0)
341 {
342 }
343
init(void)344 void init (void)
345 {
346 ChooseConfigCase::init();
347 m_iterNdx = 0;
348 m_testCtx.setTestResult(QP_TEST_RESULT_PASS, "Pass");
349 }
350
iterate(void)351 TestCase::IterateResult iterate (void)
352 {
353 m_testCtx.getLog() << TestLog::Message << "Iteration :" << m_iterNdx << TestLog::EndMessage;
354 m_iterNdx += 1;
355
356 // Build random list of attributes
357 de::Random rnd(m_iterNdx);
358 const int numAttribs = rnd.getInt(0, (int)m_attribSet.size()*2);
359
360 std::vector<std::pair<EGLenum, EGLint> > attributes = genRandomAttributes(m_attribSet, numAttribs, rnd);
361
362 fillDontCare(attributes);
363 executeTest(attributes, m_checkOrder);
364
365 return m_iterNdx < m_numIters ? CONTINUE : STOP;
366 }
367
getInt(de::Random & rnd)368 template <int MinVal, int MaxVal> static EGLint getInt (de::Random& rnd)
369 {
370 return rnd.getInt(MinVal, MaxVal);
371 }
372
getBool(de::Random & rnd)373 static EGLint getBool (de::Random& rnd)
374 {
375 return rnd.getBool() ? EGL_TRUE : EGL_FALSE;
376 }
377
getBufferType(de::Random & rnd)378 static EGLint getBufferType (de::Random& rnd)
379 {
380 static const EGLint types[] = { EGL_RGB_BUFFER, EGL_LUMINANCE_BUFFER };
381 return rnd.choose<EGLint>(types, types+DE_LENGTH_OF_ARRAY(types));
382 }
383
getConfigCaveat(de::Random & rnd)384 static EGLint getConfigCaveat (de::Random& rnd)
385 {
386 static const EGLint caveats[] = { EGL_SLOW_CONFIG, EGL_NON_CONFORMANT_CONFIG };
387 return rnd.choose<EGLint>(caveats, caveats+DE_LENGTH_OF_ARRAY(caveats));
388 }
389
getApiBits(de::Random & rnd)390 static EGLint getApiBits (de::Random& rnd)
391 {
392 EGLint api = 0;
393 api |= rnd.getBool() ? EGL_OPENGL_BIT : 0;
394 api |= rnd.getBool() ? EGL_OPENGL_ES_BIT : 0;
395 api |= rnd.getBool() ? EGL_OPENGL_ES2_BIT : 0;
396 api |= rnd.getBool() ? EGL_OPENVG_BIT : 0;
397 return api;
398 }
399
getSurfaceType(de::Random & rnd)400 static EGLint getSurfaceType (de::Random& rnd)
401 {
402 EGLint bits = 0;
403 bits |= rnd.getBool() ? EGL_WINDOW_BIT : 0;
404 bits |= rnd.getBool() ? EGL_PIXMAP_BIT : 0;
405 bits |= rnd.getBool() ? EGL_PBUFFER_BIT : 0;
406 return bits;
407 }
408
409 struct AttribSpec
410 {
411 EGLenum attribute;
412 EGLint (*getValue)(de::Random& rnd);
413 };
414
genRandomAttributes(const std::set<EGLenum> & attribSet,int numAttribs,de::Random & rnd)415 std::vector<std::pair<EGLenum, EGLint> > genRandomAttributes (const std::set<EGLenum>& attribSet, int numAttribs, de::Random& rnd)
416 {
417 static const struct AttribSpec attributes[] =
418 {
419 { EGL_BUFFER_SIZE, ChooseConfigRandomCase::getInt<0, 32>, },
420 { EGL_RED_SIZE, ChooseConfigRandomCase::getInt<0, 8>, },
421 { EGL_GREEN_SIZE, ChooseConfigRandomCase::getInt<0, 8>, },
422 { EGL_BLUE_SIZE, ChooseConfigRandomCase::getInt<0, 8>, },
423 { EGL_LUMINANCE_SIZE, ChooseConfigRandomCase::getInt<0, 1>, },
424 { EGL_ALPHA_SIZE, ChooseConfigRandomCase::getInt<0, 8>, },
425 { EGL_ALPHA_MASK_SIZE, ChooseConfigRandomCase::getInt<0, 1>, },
426 { EGL_BIND_TO_TEXTURE_RGB, ChooseConfigRandomCase::getBool, },
427 { EGL_BIND_TO_TEXTURE_RGBA, ChooseConfigRandomCase::getBool, },
428 { EGL_COLOR_BUFFER_TYPE, ChooseConfigRandomCase::getBufferType, },
429 { EGL_CONFIG_CAVEAT, ChooseConfigRandomCase::getConfigCaveat, },
430 // { EGL_CONFIG_ID, 0/*special*/, },
431 { EGL_CONFORMANT, ChooseConfigRandomCase::getApiBits, },
432 { EGL_DEPTH_SIZE, ChooseConfigRandomCase::getInt<0, 32>, },
433 { EGL_LEVEL, ChooseConfigRandomCase::getInt<0, 1>, },
434 // { EGL_MATCH_NATIVE_PIXMAP, EGL_NONE, },
435 { EGL_MAX_SWAP_INTERVAL, ChooseConfigRandomCase::getInt<0, 2>, },
436 { EGL_MIN_SWAP_INTERVAL, ChooseConfigRandomCase::getInt<0, 1>, },
437 { EGL_NATIVE_RENDERABLE, ChooseConfigRandomCase::getBool, },
438 // { EGL_NATIVE_VISUAL_TYPE, EGL_DONT_CARE, },
439 { EGL_RENDERABLE_TYPE, ChooseConfigRandomCase::getApiBits, },
440 { EGL_SAMPLE_BUFFERS, ChooseConfigRandomCase::getInt<0, 1>, },
441 { EGL_SAMPLES, ChooseConfigRandomCase::getInt<0, 1>, },
442 { EGL_STENCIL_SIZE, ChooseConfigRandomCase::getInt<0, 1>, },
443 { EGL_SURFACE_TYPE, ChooseConfigRandomCase::getSurfaceType, },
444 // { EGL_TRANSPARENT_TYPE, EGL_TRANSPARENT_RGB,},
445 // { EGL_TRANSPARENT_RED_VALUE, ChooseConfigRandomCase::getInt<0, 255>, },
446 // { EGL_TRANSPARENT_GREEN_VALUE, ChooseConfigRandomCase::getInt<0, 255>, },
447 // { EGL_TRANSPARENT_BLUE_VALUE, ChooseConfigRandomCase::getInt<0, 255>, }
448 };
449
450 std::vector<std::pair<EGLenum, EGLint> > out;
451
452 // Build list to select from
453 std::vector<AttribSpec> candidates;
454 for (int ndx = 0; ndx < (int)DE_LENGTH_OF_ARRAY(attributes); ndx++)
455 {
456 if (attribSet.find(attributes[ndx].attribute) != attribSet.end())
457 candidates.push_back(attributes[ndx]);
458 }
459
460 for (int attribNdx = 0; attribNdx < numAttribs; attribNdx++)
461 {
462 AttribSpec spec = rnd.choose<AttribSpec>(candidates.begin(), candidates.end());
463 out.push_back(std::make_pair(spec.attribute, spec.getValue(rnd)));
464 }
465
466 return out;
467 }
468 private:
469 std::set<EGLenum> m_attribSet;
470 int m_numIters;
471 int m_iterNdx;
472 };
473
474 class ColorComponentTypeCase : public ChooseConfigCase
475 {
476
477 public:
ColorComponentTypeCase(EglTestContext & eglTestCtx,const char * name,EGLenum value)478 ColorComponentTypeCase (EglTestContext& eglTestCtx, const char* name, EGLenum value)
479 : ChooseConfigCase (eglTestCtx, name, "", true /* sorting order is validated */)
480 , m_value (value)
481 {
482 }
483
iterate(void)484 TestCase::IterateResult iterate (void)
485 {
486 m_testCtx.setTestResult(QP_TEST_RESULT_PASS, "Pass");
487
488 {
489 const std::vector<std::string> extensions = eglu::getDisplayExtensions(m_eglTestCtx.getLibrary(), m_display);
490
491 if (!de::contains(extensions.begin(), extensions.end(), "EGL_EXT_pixel_format_float"))
492 TCU_THROW(NotSupportedError, "EGL_EXT_pixel_format_float is not supported");
493 }
494
495 {
496 std::vector<std::pair<EGLenum, EGLint> > attributes;
497
498 attributes.push_back(std::pair<EGLenum, EGLint>(EGL_COLOR_COMPONENT_TYPE_EXT, m_value));
499 fillDontCare(attributes);
500
501 executeTest(attributes, m_checkOrder);
502 }
503
504 return STOP;
505 }
506 private:
507 const EGLenum m_value;
508 };
509
ChooseConfigTests(EglTestContext & eglTestCtx)510 ChooseConfigTests::ChooseConfigTests (EglTestContext& eglTestCtx)
511 : TestCaseGroup(eglTestCtx, "choose_config", "eglChooseConfig() tests")
512 {
513 }
514
~ChooseConfigTests(void)515 ChooseConfigTests::~ChooseConfigTests (void)
516 {
517 }
518
519 namespace
520 {
521
522 template <typename T, size_t N>
toSet(const T (& arr)[N])523 std::set<T> toSet (const T (&arr)[N])
524 {
525 std::set<T> set;
526 for (size_t i = 0; i < N; i++)
527 set.insert(arr[i]);
528 return set;
529 }
530
531 } // anonymous
532
init(void)533 void ChooseConfigTests::init (void)
534 {
535 // Single attributes
536 {
537 static const struct
538 {
539 EGLenum attribute;
540 const char* testName;
541 } attributes[] =
542 {
543 { EGL_BUFFER_SIZE, "buffer_size" },
544 { EGL_RED_SIZE, "red_size" },
545 { EGL_GREEN_SIZE, "green_size" },
546 { EGL_BLUE_SIZE, "blue_size" },
547 { EGL_LUMINANCE_SIZE, "luminance_size" },
548 { EGL_ALPHA_SIZE, "alpha_size" },
549 { EGL_ALPHA_MASK_SIZE, "alpha_mask_size" },
550 { EGL_BIND_TO_TEXTURE_RGB, "bind_to_texture_rgb" },
551 { EGL_BIND_TO_TEXTURE_RGBA, "bind_to_texture_rgba" },
552 { EGL_COLOR_BUFFER_TYPE, "color_buffer_type" },
553 { EGL_CONFIG_CAVEAT, "config_caveat" },
554 { EGL_CONFIG_ID, "config_id" },
555 { EGL_CONFORMANT, "conformant" },
556 { EGL_DEPTH_SIZE, "depth_size" },
557 { EGL_LEVEL, "level" },
558 { EGL_MAX_SWAP_INTERVAL, "max_swap_interval" },
559 { EGL_MIN_SWAP_INTERVAL, "min_swap_interval" },
560 { EGL_NATIVE_RENDERABLE, "native_renderable" },
561 { EGL_NATIVE_VISUAL_TYPE, "native_visual_type" },
562 { EGL_RENDERABLE_TYPE, "renderable_type" },
563 { EGL_SAMPLE_BUFFERS, "sample_buffers" },
564 { EGL_SAMPLES, "samples" },
565 { EGL_STENCIL_SIZE, "stencil_size" },
566 { EGL_SURFACE_TYPE, "surface_type" },
567 { EGL_TRANSPARENT_TYPE, "transparent_type" },
568 { EGL_TRANSPARENT_RED_VALUE, "transparent_red_value" },
569 { EGL_TRANSPARENT_GREEN_VALUE, "transparent_green_value" },
570 { EGL_TRANSPARENT_BLUE_VALUE, "transparent_blue_value" }
571 };
572
573 tcu::TestCaseGroup* simpleGroup = new tcu::TestCaseGroup(m_testCtx, "simple", "Simple tests");
574 addChild(simpleGroup);
575
576 tcu::TestCaseGroup* selectionGroup = new tcu::TestCaseGroup(m_testCtx, "selection_only", "Selection tests, order ignored");
577 simpleGroup->addChild(selectionGroup);
578
579 tcu::TestCaseGroup* sortGroup = new tcu::TestCaseGroup(m_testCtx, "selection_and_sort", "Selection and ordering tests");
580 simpleGroup->addChild(sortGroup);
581
582 for (int ndx = 0; ndx < (int)DE_LENGTH_OF_ARRAY(attributes); ndx++)
583 {
584 selectionGroup->addChild(new ChooseConfigSimpleCase(m_eglTestCtx, attributes[ndx].testName, "Simple config selection case", attributes[ndx].attribute, false));
585 sortGroup->addChild(new ChooseConfigSimpleCase(m_eglTestCtx, attributes[ndx].testName, "Simple config selection and sort case", attributes[ndx].attribute, true));
586 }
587 }
588
589 // Random
590 {
591 tcu::TestCaseGroup* randomGroup = new tcu::TestCaseGroup(m_testCtx, "random", "Random eglChooseConfig() usage");
592 addChild(randomGroup);
593
594 static const EGLenum rgbaSizes[] =
595 {
596 EGL_RED_SIZE,
597 EGL_GREEN_SIZE,
598 EGL_BLUE_SIZE,
599 EGL_ALPHA_SIZE
600 };
601 randomGroup->addChild(new ChooseConfigRandomCase(m_eglTestCtx, "color_sizes", "Random color size rules", toSet(rgbaSizes)));
602
603 static const EGLenum colorDepthStencilSizes[] =
604 {
605 EGL_RED_SIZE,
606 EGL_GREEN_SIZE,
607 EGL_BLUE_SIZE,
608 EGL_ALPHA_SIZE,
609 EGL_DEPTH_SIZE,
610 EGL_STENCIL_SIZE
611 };
612 randomGroup->addChild(new ChooseConfigRandomCase(m_eglTestCtx, "color_depth_stencil_sizes", "Random color, depth and stencil size rules", toSet(colorDepthStencilSizes)));
613
614 static const EGLenum bufferSizes[] =
615 {
616 EGL_BUFFER_SIZE,
617 EGL_LUMINANCE_SIZE,
618 EGL_ALPHA_MASK_SIZE,
619 EGL_DEPTH_SIZE,
620 EGL_STENCIL_SIZE
621 };
622 randomGroup->addChild(new ChooseConfigRandomCase(m_eglTestCtx, "buffer_sizes", "Various buffer size rules", toSet(bufferSizes)));
623
624 static const EGLenum surfaceType[] =
625 {
626 EGL_NATIVE_RENDERABLE,
627 EGL_SURFACE_TYPE
628 };
629 randomGroup->addChild(new ChooseConfigRandomCase(m_eglTestCtx, "surface_type", "Surface type rules", toSet(surfaceType)));
630
631 static const EGLenum sampleBuffers[] =
632 {
633 EGL_SAMPLE_BUFFERS,
634 EGL_SAMPLES
635 };
636 randomGroup->addChild(new ChooseConfigRandomCase(m_eglTestCtx, "sample_buffers", "Sample buffer rules", toSet(sampleBuffers)));
637
638 // \note Not every attribute is supported at the moment
639 static const EGLenum allAttribs[] =
640 {
641 EGL_BUFFER_SIZE,
642 EGL_RED_SIZE,
643 EGL_GREEN_SIZE,
644 EGL_BLUE_SIZE,
645 EGL_ALPHA_SIZE,
646 EGL_ALPHA_MASK_SIZE,
647 EGL_BIND_TO_TEXTURE_RGB,
648 EGL_BIND_TO_TEXTURE_RGBA,
649 EGL_COLOR_BUFFER_TYPE,
650 EGL_CONFIG_CAVEAT,
651 EGL_CONFIG_ID,
652 EGL_CONFORMANT,
653 EGL_DEPTH_SIZE,
654 EGL_LEVEL,
655 // EGL_MATCH_NATIVE_PIXMAP,
656 EGL_MAX_SWAP_INTERVAL,
657 EGL_MIN_SWAP_INTERVAL,
658 EGL_NATIVE_RENDERABLE,
659 EGL_NATIVE_VISUAL_TYPE,
660 EGL_RENDERABLE_TYPE,
661 EGL_SAMPLE_BUFFERS,
662 EGL_SAMPLES,
663 EGL_STENCIL_SIZE,
664 EGL_SURFACE_TYPE,
665 EGL_TRANSPARENT_TYPE,
666 // EGL_TRANSPARENT_RED_VALUE,
667 // EGL_TRANSPARENT_GREEN_VALUE,
668 // EGL_TRANSPARENT_BLUE_VALUE
669 };
670 randomGroup->addChild(new ChooseConfigRandomCase(m_eglTestCtx, "all", "All attributes", toSet(allAttribs)));
671 }
672
673 // EGL_EXT_pixel_format_float
674 {
675 de::MovePtr<tcu::TestCaseGroup> colorComponentTypeGroup (new tcu::TestCaseGroup(m_testCtx, "color_component_type_ext", "EGL_EXT_pixel_format_float tests"));
676
677 colorComponentTypeGroup->addChild(new ColorComponentTypeCase(m_eglTestCtx, "dont_care", EGL_DONT_CARE));
678 colorComponentTypeGroup->addChild(new ColorComponentTypeCase(m_eglTestCtx, "fixed", EGL_COLOR_COMPONENT_TYPE_FIXED_EXT));
679 colorComponentTypeGroup->addChild(new ColorComponentTypeCase(m_eglTestCtx, "float", EGL_COLOR_COMPONENT_TYPE_FLOAT_EXT));
680
681 addChild(colorComponentTypeGroup.release());
682 }
683 }
684
685 } // egl
686 } // deqp
687