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