xref: /aosp_15_r20/external/deqp/modules/egl/teglSimpleConfigCase.cpp (revision 35238bce31c2a825756842865a792f8cf7f89930)
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 Simple Context construction test.
22*35238bceSAndroid Build Coastguard Worker  *//*--------------------------------------------------------------------*/
23*35238bceSAndroid Build Coastguard Worker 
24*35238bceSAndroid Build Coastguard Worker #include "teglSimpleConfigCase.hpp"
25*35238bceSAndroid Build Coastguard Worker #include "tcuTestLog.hpp"
26*35238bceSAndroid Build Coastguard Worker #include "tcuFormatUtil.hpp"
27*35238bceSAndroid Build Coastguard Worker #include "egluUtil.hpp"
28*35238bceSAndroid Build Coastguard Worker #include "eglwLibrary.hpp"
29*35238bceSAndroid Build Coastguard Worker #include "eglwEnums.hpp"
30*35238bceSAndroid Build Coastguard Worker #include "deStringUtil.hpp"
31*35238bceSAndroid Build Coastguard Worker 
32*35238bceSAndroid Build Coastguard Worker namespace deqp
33*35238bceSAndroid Build Coastguard Worker {
34*35238bceSAndroid Build Coastguard Worker namespace egl
35*35238bceSAndroid Build Coastguard Worker {
36*35238bceSAndroid Build Coastguard Worker 
37*35238bceSAndroid Build Coastguard Worker using eglu::ConfigInfo;
38*35238bceSAndroid Build Coastguard Worker using std::string;
39*35238bceSAndroid Build Coastguard Worker using std::vector;
40*35238bceSAndroid Build Coastguard Worker using tcu::TestLog;
41*35238bceSAndroid Build Coastguard Worker using namespace eglw;
42*35238bceSAndroid Build Coastguard Worker using namespace eglu;
43*35238bceSAndroid Build Coastguard Worker 
SimpleConfigCase(EglTestContext & eglTestCtx,const char * name,const char * description,const FilterList & filters)44*35238bceSAndroid Build Coastguard Worker SimpleConfigCase::SimpleConfigCase(EglTestContext &eglTestCtx, const char *name, const char *description,
45*35238bceSAndroid Build Coastguard Worker                                    const FilterList &filters)
46*35238bceSAndroid Build Coastguard Worker     : TestCase(eglTestCtx, name, description)
47*35238bceSAndroid Build Coastguard Worker     , m_filters(filters)
48*35238bceSAndroid Build Coastguard Worker     , m_display(EGL_NO_DISPLAY)
49*35238bceSAndroid Build Coastguard Worker {
50*35238bceSAndroid Build Coastguard Worker }
51*35238bceSAndroid Build Coastguard Worker 
~SimpleConfigCase(void)52*35238bceSAndroid Build Coastguard Worker SimpleConfigCase::~SimpleConfigCase(void)
53*35238bceSAndroid Build Coastguard Worker {
54*35238bceSAndroid Build Coastguard Worker }
55*35238bceSAndroid Build Coastguard Worker 
init(void)56*35238bceSAndroid Build Coastguard Worker void SimpleConfigCase::init(void)
57*35238bceSAndroid Build Coastguard Worker {
58*35238bceSAndroid Build Coastguard Worker     const Library &egl = m_eglTestCtx.getLibrary();
59*35238bceSAndroid Build Coastguard Worker 
60*35238bceSAndroid Build Coastguard Worker     DE_ASSERT(m_display == EGL_NO_DISPLAY && m_configs.empty());
61*35238bceSAndroid Build Coastguard Worker 
62*35238bceSAndroid Build Coastguard Worker     m_display = getAndInitDisplay(m_eglTestCtx.getNativeDisplay());
63*35238bceSAndroid Build Coastguard Worker     m_configs = chooseConfigs(egl, m_display, m_filters);
64*35238bceSAndroid Build Coastguard Worker 
65*35238bceSAndroid Build Coastguard Worker     // Log matching configs.
66*35238bceSAndroid Build Coastguard Worker     {
67*35238bceSAndroid Build Coastguard Worker         vector<EGLint> configIds(m_configs.size());
68*35238bceSAndroid Build Coastguard Worker 
69*35238bceSAndroid Build Coastguard Worker         for (size_t ndx = 0; ndx < m_configs.size(); ndx++)
70*35238bceSAndroid Build Coastguard Worker             configIds[ndx] = getConfigID(egl, m_display, m_configs[ndx]);
71*35238bceSAndroid Build Coastguard Worker 
72*35238bceSAndroid Build Coastguard Worker         m_testCtx.getLog() << TestLog::Message
73*35238bceSAndroid Build Coastguard Worker                            << "Compatible configs: " << tcu::formatArray(configIds.begin(), configIds.end())
74*35238bceSAndroid Build Coastguard Worker                            << TestLog::EndMessage;
75*35238bceSAndroid Build Coastguard Worker     }
76*35238bceSAndroid Build Coastguard Worker 
77*35238bceSAndroid Build Coastguard Worker     if (m_configs.empty())
78*35238bceSAndroid Build Coastguard Worker     {
79*35238bceSAndroid Build Coastguard Worker         egl.terminate(m_display);
80*35238bceSAndroid Build Coastguard Worker         m_display = EGL_NO_DISPLAY;
81*35238bceSAndroid Build Coastguard Worker         TCU_THROW(NotSupportedError, "No compatible configs found");
82*35238bceSAndroid Build Coastguard Worker     }
83*35238bceSAndroid Build Coastguard Worker 
84*35238bceSAndroid Build Coastguard Worker     // Init config iter
85*35238bceSAndroid Build Coastguard Worker     m_configIter = m_configs.begin();
86*35238bceSAndroid Build Coastguard Worker 
87*35238bceSAndroid Build Coastguard Worker     // Init test case result to Pass
88*35238bceSAndroid Build Coastguard Worker     m_testCtx.setTestResult(QP_TEST_RESULT_PASS, "Pass");
89*35238bceSAndroid Build Coastguard Worker }
90*35238bceSAndroid Build Coastguard Worker 
deinit(void)91*35238bceSAndroid Build Coastguard Worker void SimpleConfigCase::deinit(void)
92*35238bceSAndroid Build Coastguard Worker {
93*35238bceSAndroid Build Coastguard Worker     if (m_display != EGL_NO_DISPLAY)
94*35238bceSAndroid Build Coastguard Worker     {
95*35238bceSAndroid Build Coastguard Worker         m_eglTestCtx.getLibrary().terminate(m_display);
96*35238bceSAndroid Build Coastguard Worker         m_display = EGL_NO_DISPLAY;
97*35238bceSAndroid Build Coastguard Worker     }
98*35238bceSAndroid Build Coastguard Worker     m_configs.clear();
99*35238bceSAndroid Build Coastguard Worker }
100*35238bceSAndroid Build Coastguard Worker 
iterate(void)101*35238bceSAndroid Build Coastguard Worker SimpleConfigCase::IterateResult SimpleConfigCase::iterate(void)
102*35238bceSAndroid Build Coastguard Worker {
103*35238bceSAndroid Build Coastguard Worker     DE_ASSERT(m_configIter != m_configs.end());
104*35238bceSAndroid Build Coastguard Worker 
105*35238bceSAndroid Build Coastguard Worker     EGLConfig config = *m_configIter++;
106*35238bceSAndroid Build Coastguard Worker 
107*35238bceSAndroid Build Coastguard Worker     try
108*35238bceSAndroid Build Coastguard Worker     {
109*35238bceSAndroid Build Coastguard Worker         executeForConfig(m_display, config);
110*35238bceSAndroid Build Coastguard Worker     }
111*35238bceSAndroid Build Coastguard Worker     catch (const tcu::TestError &e)
112*35238bceSAndroid Build Coastguard Worker     {
113*35238bceSAndroid Build Coastguard Worker         m_testCtx.getLog() << e;
114*35238bceSAndroid Build Coastguard Worker         m_testCtx.setTestResult(QP_TEST_RESULT_FAIL, "Fail");
115*35238bceSAndroid Build Coastguard Worker     }
116*35238bceSAndroid Build Coastguard Worker     // \note Other errors are handled by framework (resource / internal errors).
117*35238bceSAndroid Build Coastguard Worker 
118*35238bceSAndroid Build Coastguard Worker     return (m_configIter != m_configs.end()) ? CONTINUE : STOP;
119*35238bceSAndroid Build Coastguard Worker }
120*35238bceSAndroid Build Coastguard Worker 
121*35238bceSAndroid Build Coastguard Worker template <int Red, int Green, int Blue, int Alpha>
colorBits(const eglu::CandidateConfig & c)122*35238bceSAndroid Build Coastguard Worker static bool colorBits(const eglu::CandidateConfig &c)
123*35238bceSAndroid Build Coastguard Worker {
124*35238bceSAndroid Build Coastguard Worker     return c.redSize() == Red && c.greenSize() == Green && c.blueSize() == Blue && c.alphaSize() == Alpha;
125*35238bceSAndroid Build Coastguard Worker }
126*35238bceSAndroid Build Coastguard Worker 
127*35238bceSAndroid Build Coastguard Worker template <int Red, int Green, int Blue, int Alpha>
notColorBits(const eglu::CandidateConfig & c)128*35238bceSAndroid Build Coastguard Worker static bool notColorBits(const eglu::CandidateConfig &c)
129*35238bceSAndroid Build Coastguard Worker {
130*35238bceSAndroid Build Coastguard Worker     return c.redSize() != Red || c.greenSize() != Green || c.blueSize() != Blue || c.alphaSize() != Alpha;
131*35238bceSAndroid Build Coastguard Worker }
132*35238bceSAndroid Build Coastguard Worker 
hasDepth(const eglu::CandidateConfig & c)133*35238bceSAndroid Build Coastguard Worker static bool hasDepth(const eglu::CandidateConfig &c)
134*35238bceSAndroid Build Coastguard Worker {
135*35238bceSAndroid Build Coastguard Worker     return c.depthSize() > 0;
136*35238bceSAndroid Build Coastguard Worker }
noDepth(const eglu::CandidateConfig & c)137*35238bceSAndroid Build Coastguard Worker static bool noDepth(const eglu::CandidateConfig &c)
138*35238bceSAndroid Build Coastguard Worker {
139*35238bceSAndroid Build Coastguard Worker     return c.depthSize() == 0;
140*35238bceSAndroid Build Coastguard Worker }
hasStencil(const eglu::CandidateConfig & c)141*35238bceSAndroid Build Coastguard Worker static bool hasStencil(const eglu::CandidateConfig &c)
142*35238bceSAndroid Build Coastguard Worker {
143*35238bceSAndroid Build Coastguard Worker     return c.stencilSize() > 0;
144*35238bceSAndroid Build Coastguard Worker }
noStencil(const eglu::CandidateConfig & c)145*35238bceSAndroid Build Coastguard Worker static bool noStencil(const eglu::CandidateConfig &c)
146*35238bceSAndroid Build Coastguard Worker {
147*35238bceSAndroid Build Coastguard Worker     return c.stencilSize() == 0;
148*35238bceSAndroid Build Coastguard Worker }
149*35238bceSAndroid Build Coastguard Worker 
isConformant(const eglu::CandidateConfig & c)150*35238bceSAndroid Build Coastguard Worker static bool isConformant(const eglu::CandidateConfig &c)
151*35238bceSAndroid Build Coastguard Worker {
152*35238bceSAndroid Build Coastguard Worker     return c.get(EGL_CONFIG_CAVEAT) != EGL_NON_CONFORMANT_CONFIG;
153*35238bceSAndroid Build Coastguard Worker }
154*35238bceSAndroid Build Coastguard Worker 
notFloat(const eglu::CandidateConfig & c)155*35238bceSAndroid Build Coastguard Worker static bool notFloat(const eglu::CandidateConfig &c)
156*35238bceSAndroid Build Coastguard Worker {
157*35238bceSAndroid Build Coastguard Worker     return c.colorComponentType() != EGL_COLOR_COMPONENT_TYPE_FLOAT_EXT;
158*35238bceSAndroid Build Coastguard Worker }
159*35238bceSAndroid Build Coastguard Worker 
notYUV(const eglu::CandidateConfig & c)160*35238bceSAndroid Build Coastguard Worker static bool notYUV(const eglu::CandidateConfig &c)
161*35238bceSAndroid Build Coastguard Worker {
162*35238bceSAndroid Build Coastguard Worker     return c.get(EGL_COLOR_BUFFER_TYPE) != EGL_YUV_BUFFER_EXT;
163*35238bceSAndroid Build Coastguard Worker }
164*35238bceSAndroid Build Coastguard Worker 
getDefaultFilterLists(vector<NamedFilterList> & lists,const FilterList & baseFilters)165*35238bceSAndroid Build Coastguard Worker void getDefaultFilterLists(vector<NamedFilterList> &lists, const FilterList &baseFilters)
166*35238bceSAndroid Build Coastguard Worker {
167*35238bceSAndroid Build Coastguard Worker     static const struct
168*35238bceSAndroid Build Coastguard Worker     {
169*35238bceSAndroid Build Coastguard Worker         const char *name;
170*35238bceSAndroid Build Coastguard Worker         eglu::ConfigFilter filter;
171*35238bceSAndroid Build Coastguard Worker     } s_colorRules[] = {{"rgb565", colorBits<5, 6, 5, 0>},
172*35238bceSAndroid Build Coastguard Worker                         {"rgb888", colorBits<8, 8, 8, 0>},
173*35238bceSAndroid Build Coastguard Worker                         {"rgba4444", colorBits<4, 4, 4, 4>},
174*35238bceSAndroid Build Coastguard Worker                         {"rgba5551", colorBits<5, 5, 5, 1>},
175*35238bceSAndroid Build Coastguard Worker                         {"rgba8888", colorBits<8, 8, 8, 8>}};
176*35238bceSAndroid Build Coastguard Worker 
177*35238bceSAndroid Build Coastguard Worker     static const struct
178*35238bceSAndroid Build Coastguard Worker     {
179*35238bceSAndroid Build Coastguard Worker         const char *name;
180*35238bceSAndroid Build Coastguard Worker         eglu::ConfigFilter filter;
181*35238bceSAndroid Build Coastguard Worker     } s_depthRules[] = {
182*35238bceSAndroid Build Coastguard Worker         {"no_depth", noDepth},
183*35238bceSAndroid Build Coastguard Worker         {"depth", hasDepth},
184*35238bceSAndroid Build Coastguard Worker     };
185*35238bceSAndroid Build Coastguard Worker 
186*35238bceSAndroid Build Coastguard Worker     static const struct
187*35238bceSAndroid Build Coastguard Worker     {
188*35238bceSAndroid Build Coastguard Worker         const char *name;
189*35238bceSAndroid Build Coastguard Worker         eglu::ConfigFilter filter;
190*35238bceSAndroid Build Coastguard Worker     } s_stencilRules[] = {
191*35238bceSAndroid Build Coastguard Worker         {"no_stencil", noStencil},
192*35238bceSAndroid Build Coastguard Worker         {"stencil", hasStencil},
193*35238bceSAndroid Build Coastguard Worker     };
194*35238bceSAndroid Build Coastguard Worker 
195*35238bceSAndroid Build Coastguard Worker     for (int colorRuleNdx = 0; colorRuleNdx < DE_LENGTH_OF_ARRAY(s_colorRules); colorRuleNdx++)
196*35238bceSAndroid Build Coastguard Worker     {
197*35238bceSAndroid Build Coastguard Worker         for (int depthRuleNdx = 0; depthRuleNdx < DE_LENGTH_OF_ARRAY(s_depthRules); depthRuleNdx++)
198*35238bceSAndroid Build Coastguard Worker         {
199*35238bceSAndroid Build Coastguard Worker             for (int stencilRuleNdx = 0; stencilRuleNdx < DE_LENGTH_OF_ARRAY(s_stencilRules); stencilRuleNdx++)
200*35238bceSAndroid Build Coastguard Worker             {
201*35238bceSAndroid Build Coastguard Worker                 const string name = string(s_colorRules[colorRuleNdx].name) + "_" + s_depthRules[depthRuleNdx].name +
202*35238bceSAndroid Build Coastguard Worker                                     "_" + s_stencilRules[stencilRuleNdx].name;
203*35238bceSAndroid Build Coastguard Worker                 NamedFilterList filters(name.c_str(), "");
204*35238bceSAndroid Build Coastguard Worker 
205*35238bceSAndroid Build Coastguard Worker                 filters << baseFilters << s_colorRules[colorRuleNdx].filter << s_depthRules[depthRuleNdx].filter
206*35238bceSAndroid Build Coastguard Worker                         << s_stencilRules[stencilRuleNdx].filter << isConformant;
207*35238bceSAndroid Build Coastguard Worker 
208*35238bceSAndroid Build Coastguard Worker                 lists.push_back(filters);
209*35238bceSAndroid Build Coastguard Worker             }
210*35238bceSAndroid Build Coastguard Worker         }
211*35238bceSAndroid Build Coastguard Worker     }
212*35238bceSAndroid Build Coastguard Worker 
213*35238bceSAndroid Build Coastguard Worker     // Build "other" set - not configs that don't match any of known color rules
214*35238bceSAndroid Build Coastguard Worker     {
215*35238bceSAndroid Build Coastguard Worker         NamedFilterList filters("other", "All other configs");
216*35238bceSAndroid Build Coastguard Worker 
217*35238bceSAndroid Build Coastguard Worker         // \todo [2014-12-18 pyry] Optimize rules
218*35238bceSAndroid Build Coastguard Worker         filters
219*35238bceSAndroid Build Coastguard Worker             << baseFilters
220*35238bceSAndroid Build Coastguard Worker             << notColorBits<
221*35238bceSAndroid Build Coastguard Worker                    5, 6, 5,
222*35238bceSAndroid Build Coastguard Worker                    0> << notColorBits<8, 8, 8, 0> << notColorBits<4, 4, 4, 4> << notColorBits<5, 5, 5, 1> << notColorBits<8, 8, 8, 8> << isConformant
223*35238bceSAndroid Build Coastguard Worker             << notFloat << notYUV;
224*35238bceSAndroid Build Coastguard Worker 
225*35238bceSAndroid Build Coastguard Worker         lists.push_back(filters);
226*35238bceSAndroid Build Coastguard Worker     }
227*35238bceSAndroid Build Coastguard Worker }
228*35238bceSAndroid Build Coastguard Worker 
229*35238bceSAndroid Build Coastguard Worker } // namespace egl
230*35238bceSAndroid Build Coastguard Worker } // namespace deqp
231