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