13c827367444ee418f129b2c238299f49d3264554Jarkko Poyry/*------------------------------------------------------------------------- 23c827367444ee418f129b2c238299f49d3264554Jarkko Poyry * drawElements Quality Program EGL Module 33c827367444ee418f129b2c238299f49d3264554Jarkko Poyry * --------------------------------------- 43c827367444ee418f129b2c238299f49d3264554Jarkko Poyry * 53c827367444ee418f129b2c238299f49d3264554Jarkko Poyry * Copyright 2014 The Android Open Source Project 63c827367444ee418f129b2c238299f49d3264554Jarkko Poyry * 73c827367444ee418f129b2c238299f49d3264554Jarkko Poyry * Licensed under the Apache License, Version 2.0 (the "License"); 83c827367444ee418f129b2c238299f49d3264554Jarkko Poyry * you may not use this file except in compliance with the License. 93c827367444ee418f129b2c238299f49d3264554Jarkko Poyry * You may obtain a copy of the License at 103c827367444ee418f129b2c238299f49d3264554Jarkko Poyry * 113c827367444ee418f129b2c238299f49d3264554Jarkko Poyry * http://www.apache.org/licenses/LICENSE-2.0 123c827367444ee418f129b2c238299f49d3264554Jarkko Poyry * 133c827367444ee418f129b2c238299f49d3264554Jarkko Poyry * Unless required by applicable law or agreed to in writing, software 143c827367444ee418f129b2c238299f49d3264554Jarkko Poyry * distributed under the License is distributed on an "AS IS" BASIS, 153c827367444ee418f129b2c238299f49d3264554Jarkko Poyry * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 163c827367444ee418f129b2c238299f49d3264554Jarkko Poyry * See the License for the specific language governing permissions and 173c827367444ee418f129b2c238299f49d3264554Jarkko Poyry * limitations under the License. 183c827367444ee418f129b2c238299f49d3264554Jarkko Poyry * 193c827367444ee418f129b2c238299f49d3264554Jarkko Poyry *//*! 203c827367444ee418f129b2c238299f49d3264554Jarkko Poyry * \file 213c827367444ee418f129b2c238299f49d3264554Jarkko Poyry * \brief Config query tests. 223c827367444ee418f129b2c238299f49d3264554Jarkko Poyry *//*--------------------------------------------------------------------*/ 233c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 243c827367444ee418f129b2c238299f49d3264554Jarkko Poyry#include "teglQueryConfigTests.hpp" 253c827367444ee418f129b2c238299f49d3264554Jarkko Poyry#include "teglSimpleConfigCase.hpp" 263c827367444ee418f129b2c238299f49d3264554Jarkko Poyry#include "tcuTestLog.hpp" 273c827367444ee418f129b2c238299f49d3264554Jarkko Poyry#include "tcuTestContext.hpp" 283c827367444ee418f129b2c238299f49d3264554Jarkko Poyry#include "tcuCommandLine.hpp" 293c827367444ee418f129b2c238299f49d3264554Jarkko Poyry#include "egluCallLogWrapper.hpp" 303c827367444ee418f129b2c238299f49d3264554Jarkko Poyry#include "egluStrUtil.hpp" 313c827367444ee418f129b2c238299f49d3264554Jarkko Poyry#include "deRandom.hpp" 323c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 333c827367444ee418f129b2c238299f49d3264554Jarkko Poyry#include <string> 343c827367444ee418f129b2c238299f49d3264554Jarkko Poyry#include <vector> 353c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 363c827367444ee418f129b2c238299f49d3264554Jarkko Poyry#if !defined(EGL_OPENGL_ES3_BIT_KHR) 373c827367444ee418f129b2c238299f49d3264554Jarkko Poyry# define EGL_OPENGL_ES3_BIT_KHR 0x0040 383c827367444ee418f129b2c238299f49d3264554Jarkko Poyry#endif 393c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 403c827367444ee418f129b2c238299f49d3264554Jarkko Poyrynamespace deqp 413c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{ 423c827367444ee418f129b2c238299f49d3264554Jarkko Poyrynamespace egl 433c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{ 443c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 453c827367444ee418f129b2c238299f49d3264554Jarkko Poyryusing eglu::ConfigInfo; 463c827367444ee418f129b2c238299f49d3264554Jarkko Poyryusing tcu::TestLog; 473c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 483c827367444ee418f129b2c238299f49d3264554Jarkko Poyrystatic void logConfigAttribute (TestLog& log, EGLenum attrib, EGLint value) 493c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{ 503c827367444ee418f129b2c238299f49d3264554Jarkko Poyry log << TestLog::Message << " " << eglu::getConfigAttribName(attrib) << ": " << eglu::getConfigAttribValueStr(attrib, value) << TestLog::EndMessage; 513c827367444ee418f129b2c238299f49d3264554Jarkko Poyry} 523c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 533c827367444ee418f129b2c238299f49d3264554Jarkko Poyrystatic bool isAttributePresent (const eglu::Version& version, EGLenum attribute) 543c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{ 553c827367444ee418f129b2c238299f49d3264554Jarkko Poyry switch (attribute) 563c827367444ee418f129b2c238299f49d3264554Jarkko Poyry { 573c827367444ee418f129b2c238299f49d3264554Jarkko Poyry case EGL_CONFORMANT: 583c827367444ee418f129b2c238299f49d3264554Jarkko Poyry if (version < eglu::Version(1, 3)) return false; 593c827367444ee418f129b2c238299f49d3264554Jarkko Poyry break; 603c827367444ee418f129b2c238299f49d3264554Jarkko Poyry case EGL_LUMINANCE_SIZE: 613c827367444ee418f129b2c238299f49d3264554Jarkko Poyry case EGL_ALPHA_MASK_SIZE: 623c827367444ee418f129b2c238299f49d3264554Jarkko Poyry case EGL_COLOR_BUFFER_TYPE: 633c827367444ee418f129b2c238299f49d3264554Jarkko Poyry case EGL_MATCH_NATIVE_PIXMAP: 643c827367444ee418f129b2c238299f49d3264554Jarkko Poyry if (version < eglu::Version(1, 2)) return false; 653c827367444ee418f129b2c238299f49d3264554Jarkko Poyry break; 663c827367444ee418f129b2c238299f49d3264554Jarkko Poyry case EGL_BIND_TO_TEXTURE_RGB: 673c827367444ee418f129b2c238299f49d3264554Jarkko Poyry case EGL_BIND_TO_TEXTURE_RGBA: 683c827367444ee418f129b2c238299f49d3264554Jarkko Poyry case EGL_MAX_SWAP_INTERVAL: 693c827367444ee418f129b2c238299f49d3264554Jarkko Poyry case EGL_MIN_SWAP_INTERVAL: 703c827367444ee418f129b2c238299f49d3264554Jarkko Poyry case EGL_RENDERABLE_TYPE: 713c827367444ee418f129b2c238299f49d3264554Jarkko Poyry if (version < eglu::Version(1, 1)) return false; 723c827367444ee418f129b2c238299f49d3264554Jarkko Poyry break; 733c827367444ee418f129b2c238299f49d3264554Jarkko Poyry default: 743c827367444ee418f129b2c238299f49d3264554Jarkko Poyry break; 753c827367444ee418f129b2c238299f49d3264554Jarkko Poyry } 763c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 773c827367444ee418f129b2c238299f49d3264554Jarkko Poyry return true; 783c827367444ee418f129b2c238299f49d3264554Jarkko Poyry} 793c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 803c827367444ee418f129b2c238299f49d3264554Jarkko Poyryclass GetConfigsBoundsCase : public TestCase, protected eglu::CallLogWrapper 813c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{ 823c827367444ee418f129b2c238299f49d3264554Jarkko Poyrypublic: 833c827367444ee418f129b2c238299f49d3264554Jarkko Poyry GetConfigsBoundsCase (EglTestContext& eglTestCtx, const char* name, const char* description) 843c827367444ee418f129b2c238299f49d3264554Jarkko Poyry : TestCase (eglTestCtx, name, description) 853c827367444ee418f129b2c238299f49d3264554Jarkko Poyry , CallLogWrapper(eglTestCtx.getTestContext().getLog()) 863c827367444ee418f129b2c238299f49d3264554Jarkko Poyry { 873c827367444ee418f129b2c238299f49d3264554Jarkko Poyry } 883c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 893c827367444ee418f129b2c238299f49d3264554Jarkko Poyry void init (void) 903c827367444ee418f129b2c238299f49d3264554Jarkko Poyry { 913c827367444ee418f129b2c238299f49d3264554Jarkko Poyry m_testCtx.setTestResult(QP_TEST_RESULT_PASS, "Pass"); 923c827367444ee418f129b2c238299f49d3264554Jarkko Poyry } 933c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 943c827367444ee418f129b2c238299f49d3264554Jarkko Poyry void checkGetConfigsBounds(const tcu::egl::Display& display, de::Random& rnd, const int numConfigAll, const int numConfigRequested) 953c827367444ee418f129b2c238299f49d3264554Jarkko Poyry { 963c827367444ee418f129b2c238299f49d3264554Jarkko Poyry tcu::TestLog& log = m_testCtx.getLog(); 973c827367444ee418f129b2c238299f49d3264554Jarkko Poyry std::vector<EGLConfig> buffer (numConfigAll + 10); 983c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 993c827367444ee418f129b2c238299f49d3264554Jarkko Poyry std::vector<deUint32> magicBuffer ((buffer.size() * sizeof(EGLConfig)) / sizeof(deUint32) + 1); 1003c827367444ee418f129b2c238299f49d3264554Jarkko Poyry const EGLConfig* magicConfigs = reinterpret_cast<EGLConfig*>(&magicBuffer[0]); 1013c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 1023c827367444ee418f129b2c238299f49d3264554Jarkko Poyry int numConfigReturned; 1033c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 1043c827367444ee418f129b2c238299f49d3264554Jarkko Poyry // Fill buffers with magic 1053c827367444ee418f129b2c238299f49d3264554Jarkko Poyry for (size_t ndx = 0; ndx < magicBuffer.size(); ndx++) magicBuffer[ndx] = rnd.getUint32(); 1063c827367444ee418f129b2c238299f49d3264554Jarkko Poyry for (size_t ndx = 0; ndx < buffer.size(); ndx++) buffer[ndx] = magicConfigs[ndx]; 1073c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 1083c827367444ee418f129b2c238299f49d3264554Jarkko Poyry eglGetConfigs(display.getEGLDisplay(), &buffer[0], numConfigRequested, &numConfigReturned); 1093c827367444ee418f129b2c238299f49d3264554Jarkko Poyry TCU_CHECK_EGL(); 1103c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 1113c827367444ee418f129b2c238299f49d3264554Jarkko Poyry log << TestLog::Message << numConfigReturned << " configs returned" << TestLog::EndMessage; 1123c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 1133c827367444ee418f129b2c238299f49d3264554Jarkko Poyry // Compare results with stored magic 1143c827367444ee418f129b2c238299f49d3264554Jarkko Poyry { 1153c827367444ee418f129b2c238299f49d3264554Jarkko Poyry int numOverwritten = 0; 1163c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 1173c827367444ee418f129b2c238299f49d3264554Jarkko Poyry for (size_t ndx = 0; ndx < buffer.size(); ndx++) 1183c827367444ee418f129b2c238299f49d3264554Jarkko Poyry { 1193c827367444ee418f129b2c238299f49d3264554Jarkko Poyry if (buffer[ndx] == magicConfigs[ndx]) 1203c827367444ee418f129b2c238299f49d3264554Jarkko Poyry { 1213c827367444ee418f129b2c238299f49d3264554Jarkko Poyry numOverwritten = (int)ndx; 1223c827367444ee418f129b2c238299f49d3264554Jarkko Poyry break; 1233c827367444ee418f129b2c238299f49d3264554Jarkko Poyry } 1243c827367444ee418f129b2c238299f49d3264554Jarkko Poyry } 1253c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 1263c827367444ee418f129b2c238299f49d3264554Jarkko Poyry log << TestLog::Message << numOverwritten << " values actually written" << TestLog::EndMessage; 1273c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 1283c827367444ee418f129b2c238299f49d3264554Jarkko Poyry if (numConfigReturned > deMax32(numConfigRequested, 0)) 1293c827367444ee418f129b2c238299f49d3264554Jarkko Poyry { 1303c827367444ee418f129b2c238299f49d3264554Jarkko Poyry log << TestLog::Message << "Fail, more configs returned than requested." << TestLog::EndMessage; 1313c827367444ee418f129b2c238299f49d3264554Jarkko Poyry m_testCtx.setTestResult(QP_TEST_RESULT_FAIL, "Too many configs returned"); 1323c827367444ee418f129b2c238299f49d3264554Jarkko Poyry } 1333c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 1343c827367444ee418f129b2c238299f49d3264554Jarkko Poyry if (numOverwritten > deMax32(numConfigReturned, 0)) 1353c827367444ee418f129b2c238299f49d3264554Jarkko Poyry { 1363c827367444ee418f129b2c238299f49d3264554Jarkko Poyry log << TestLog::Message << "Fail, buffer overflow detected." << TestLog::EndMessage; 1373c827367444ee418f129b2c238299f49d3264554Jarkko Poyry m_testCtx.setTestResult(QP_TEST_RESULT_FAIL, "Buffer overflow"); 1383c827367444ee418f129b2c238299f49d3264554Jarkko Poyry } 1393c827367444ee418f129b2c238299f49d3264554Jarkko Poyry else if (numOverwritten != numConfigReturned) 1403c827367444ee418f129b2c238299f49d3264554Jarkko Poyry { 1413c827367444ee418f129b2c238299f49d3264554Jarkko Poyry log << TestLog::Message << "Fail, reported number of returned configs differs from number of values written." << TestLog::EndMessage; 1423c827367444ee418f129b2c238299f49d3264554Jarkko Poyry m_testCtx.setTestResult(QP_TEST_RESULT_FAIL, "Incorrect size"); 1433c827367444ee418f129b2c238299f49d3264554Jarkko Poyry } 1443c827367444ee418f129b2c238299f49d3264554Jarkko Poyry } 1453c827367444ee418f129b2c238299f49d3264554Jarkko Poyry } 1463c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 1473c827367444ee418f129b2c238299f49d3264554Jarkko Poyry IterateResult iterate (void) 1483c827367444ee418f129b2c238299f49d3264554Jarkko Poyry { 1493c827367444ee418f129b2c238299f49d3264554Jarkko Poyry tcu::TestLog& log = m_testCtx.getLog(); 1503c827367444ee418f129b2c238299f49d3264554Jarkko Poyry tcu::egl::Display& display = m_eglTestCtx.getDisplay(); 1513c827367444ee418f129b2c238299f49d3264554Jarkko Poyry EGLint numConfigAll; 1523c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 1533c827367444ee418f129b2c238299f49d3264554Jarkko Poyry enableLogging(true); 1543c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 1553c827367444ee418f129b2c238299f49d3264554Jarkko Poyry eglGetConfigs(display.getEGLDisplay(), 0, 0, &numConfigAll); 1563c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 1573c827367444ee418f129b2c238299f49d3264554Jarkko Poyry log << TestLog::Message << numConfigAll << " configs available" << TestLog::EndMessage; 1583c827367444ee418f129b2c238299f49d3264554Jarkko Poyry log << TestLog::Message << TestLog::EndMessage; 1593c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 1603c827367444ee418f129b2c238299f49d3264554Jarkko Poyry if (numConfigAll > 0) 1613c827367444ee418f129b2c238299f49d3264554Jarkko Poyry { 1623c827367444ee418f129b2c238299f49d3264554Jarkko Poyry de::Random rnd (123); 1633c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 1643c827367444ee418f129b2c238299f49d3264554Jarkko Poyry for (int i = 0; i < 5; i++) 1653c827367444ee418f129b2c238299f49d3264554Jarkko Poyry { 1663c827367444ee418f129b2c238299f49d3264554Jarkko Poyry checkGetConfigsBounds(display, rnd, numConfigAll, rnd.getInt(0, numConfigAll)); 1673c827367444ee418f129b2c238299f49d3264554Jarkko Poyry log << TestLog::Message << TestLog::EndMessage; 1683c827367444ee418f129b2c238299f49d3264554Jarkko Poyry } 1693c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 1703c827367444ee418f129b2c238299f49d3264554Jarkko Poyry checkGetConfigsBounds(display, rnd, numConfigAll, -1); 1713c827367444ee418f129b2c238299f49d3264554Jarkko Poyry } 1723c827367444ee418f129b2c238299f49d3264554Jarkko Poyry else 1733c827367444ee418f129b2c238299f49d3264554Jarkko Poyry { 1743c827367444ee418f129b2c238299f49d3264554Jarkko Poyry m_testCtx.setTestResult(QP_TEST_RESULT_FAIL, "No configs"); 1753c827367444ee418f129b2c238299f49d3264554Jarkko Poyry } 1763c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 1773c827367444ee418f129b2c238299f49d3264554Jarkko Poyry enableLogging(false); 1783c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 1793c827367444ee418f129b2c238299f49d3264554Jarkko Poyry return STOP; 1803c827367444ee418f129b2c238299f49d3264554Jarkko Poyry } 1813c827367444ee418f129b2c238299f49d3264554Jarkko Poyry}; 1823c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 1833c827367444ee418f129b2c238299f49d3264554Jarkko Poyryclass GetConfigAttribCase : public TestCase, protected eglu::CallLogWrapper 1843c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{ 1853c827367444ee418f129b2c238299f49d3264554Jarkko Poyrypublic: 1863c827367444ee418f129b2c238299f49d3264554Jarkko Poyry GetConfigAttribCase (EglTestContext& eglTestCtx, const char* name, const char* description); 1873c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 1883c827367444ee418f129b2c238299f49d3264554Jarkko Poyry void init (); 1893c827367444ee418f129b2c238299f49d3264554Jarkko Poyry IterateResult iterate (void); 1903c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 1913c827367444ee418f129b2c238299f49d3264554Jarkko Poyry EGLint getValue (EGLConfig config, EGLenum attrib, bool logValue=true); 1923c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 1933c827367444ee418f129b2c238299f49d3264554Jarkko Poyry virtual void executeTest (EGLConfig config) = 0; 1943c827367444ee418f129b2c238299f49d3264554Jarkko Poyryprivate: 1953c827367444ee418f129b2c238299f49d3264554Jarkko Poyry std::vector<EGLConfig> m_configs; 1963c827367444ee418f129b2c238299f49d3264554Jarkko Poyry std::vector<EGLConfig>::const_iterator m_configsIter; 1973c827367444ee418f129b2c238299f49d3264554Jarkko Poyry}; 1983c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 1993c827367444ee418f129b2c238299f49d3264554Jarkko PoyryGetConfigAttribCase::GetConfigAttribCase (EglTestContext& eglTestCtx, const char* name, const char* description) 2003c827367444ee418f129b2c238299f49d3264554Jarkko Poyry : TestCase(eglTestCtx, name, description) 2013c827367444ee418f129b2c238299f49d3264554Jarkko Poyry , CallLogWrapper(eglTestCtx.getTestContext().getLog()) 2023c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{ 2033c827367444ee418f129b2c238299f49d3264554Jarkko Poyry} 2043c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 2053c827367444ee418f129b2c238299f49d3264554Jarkko Poyryvoid GetConfigAttribCase::init (void) 2063c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{ 2073c827367444ee418f129b2c238299f49d3264554Jarkko Poyry const tcu::egl::Display& display = m_eglTestCtx.getDisplay(); 2083c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 2093c827367444ee418f129b2c238299f49d3264554Jarkko Poyry display.getConfigs(m_configs); 2103c827367444ee418f129b2c238299f49d3264554Jarkko Poyry m_configsIter = m_configs.begin(); 2113c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 2123c827367444ee418f129b2c238299f49d3264554Jarkko Poyry m_testCtx.setTestResult(QP_TEST_RESULT_PASS, "Pass"); 2133c827367444ee418f129b2c238299f49d3264554Jarkko Poyry} 2143c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 2153c827367444ee418f129b2c238299f49d3264554Jarkko Poyrytcu::TestNode::IterateResult GetConfigAttribCase::iterate (void) 2163c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{ 2173c827367444ee418f129b2c238299f49d3264554Jarkko Poyry tcu::TestLog& log = m_testCtx.getLog(); 2183c827367444ee418f129b2c238299f49d3264554Jarkko Poyry tcu::egl::Display& display = m_eglTestCtx.getDisplay(); 2193c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 2203c827367444ee418f129b2c238299f49d3264554Jarkko Poyry if (m_configsIter == m_configs.end()) 2213c827367444ee418f129b2c238299f49d3264554Jarkko Poyry { 2223c827367444ee418f129b2c238299f49d3264554Jarkko Poyry log << TestLog::Message << "No configs available." << TestLog::EndMessage; 2233c827367444ee418f129b2c238299f49d3264554Jarkko Poyry return STOP; 2243c827367444ee418f129b2c238299f49d3264554Jarkko Poyry } 2253c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 2263c827367444ee418f129b2c238299f49d3264554Jarkko Poyry { 2273c827367444ee418f129b2c238299f49d3264554Jarkko Poyry const EGLConfig config = *m_configsIter; 2283c827367444ee418f129b2c238299f49d3264554Jarkko Poyry EGLint id; 2293c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 2303c827367444ee418f129b2c238299f49d3264554Jarkko Poyry TCU_CHECK_EGL_CALL(eglGetConfigAttrib(display.getEGLDisplay(), config, EGL_CONFIG_ID, &id)); 2313c827367444ee418f129b2c238299f49d3264554Jarkko Poyry log << TestLog::Message << "Config ID " << id << TestLog::EndMessage; 2323c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 2333c827367444ee418f129b2c238299f49d3264554Jarkko Poyry executeTest(config); 2343c827367444ee418f129b2c238299f49d3264554Jarkko Poyry } 2353c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 2363c827367444ee418f129b2c238299f49d3264554Jarkko Poyry log << TestLog::Message << TestLog::EndMessage; 2373c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 2383c827367444ee418f129b2c238299f49d3264554Jarkko Poyry m_configsIter++; 2393c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 2403c827367444ee418f129b2c238299f49d3264554Jarkko Poyry if (m_configsIter == m_configs.end()) 2413c827367444ee418f129b2c238299f49d3264554Jarkko Poyry return STOP; 2423c827367444ee418f129b2c238299f49d3264554Jarkko Poyry else 2433c827367444ee418f129b2c238299f49d3264554Jarkko Poyry return CONTINUE; 2443c827367444ee418f129b2c238299f49d3264554Jarkko Poyry} 2453c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 2463c827367444ee418f129b2c238299f49d3264554Jarkko PoyryEGLint GetConfigAttribCase::getValue (EGLConfig config, EGLenum attrib, bool logValue) 2473c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{ 2483c827367444ee418f129b2c238299f49d3264554Jarkko Poyry TestLog& log = m_testCtx.getLog(); 2493c827367444ee418f129b2c238299f49d3264554Jarkko Poyry const tcu::egl::Display& display = m_eglTestCtx.getDisplay(); 2503c827367444ee418f129b2c238299f49d3264554Jarkko Poyry EGLint value; 2513c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 2523c827367444ee418f129b2c238299f49d3264554Jarkko Poyry eglGetConfigAttrib(display.getEGLDisplay(), config, attrib, &value); 2533c827367444ee418f129b2c238299f49d3264554Jarkko Poyry TCU_CHECK_EGL(); 2543c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 2553c827367444ee418f129b2c238299f49d3264554Jarkko Poyry if (logValue) logConfigAttribute(log, attrib, value); 2563c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 2573c827367444ee418f129b2c238299f49d3264554Jarkko Poyry return value; 2583c827367444ee418f129b2c238299f49d3264554Jarkko Poyry} 2593c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 2603c827367444ee418f129b2c238299f49d3264554Jarkko Poyryclass GetConfigAttribSimpleCase : public GetConfigAttribCase 2613c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{ 2623c827367444ee418f129b2c238299f49d3264554Jarkko Poyrypublic: 2633c827367444ee418f129b2c238299f49d3264554Jarkko Poyry GetConfigAttribSimpleCase (EglTestContext& eglTestCtx, const char* name, const char* description, EGLenum attribute) 2643c827367444ee418f129b2c238299f49d3264554Jarkko Poyry : GetConfigAttribCase(eglTestCtx, name, description) 2653c827367444ee418f129b2c238299f49d3264554Jarkko Poyry , m_attrib(attribute) 2663c827367444ee418f129b2c238299f49d3264554Jarkko Poyry { 2673c827367444ee418f129b2c238299f49d3264554Jarkko Poyry } 2683c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 2693c827367444ee418f129b2c238299f49d3264554Jarkko Poyry void checkColorBufferType (EGLint value) 2703c827367444ee418f129b2c238299f49d3264554Jarkko Poyry { 2713c827367444ee418f129b2c238299f49d3264554Jarkko Poyry if (!(value == EGL_RGB_BUFFER || value == EGL_LUMINANCE_BUFFER)) 2723c827367444ee418f129b2c238299f49d3264554Jarkko Poyry { 2733c827367444ee418f129b2c238299f49d3264554Jarkko Poyry TestLog& log = m_testCtx.getLog(); 2743c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 2753c827367444ee418f129b2c238299f49d3264554Jarkko Poyry log << TestLog::Message << "Fail, invalid EGL_COLOR_BUFFER_TYPE value" << TestLog::EndMessage; 2763c827367444ee418f129b2c238299f49d3264554Jarkko Poyry m_testCtx.setTestResult(QP_TEST_RESULT_FAIL, "Invalid value"); 2773c827367444ee418f129b2c238299f49d3264554Jarkko Poyry } 2783c827367444ee418f129b2c238299f49d3264554Jarkko Poyry } 2793c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 2803c827367444ee418f129b2c238299f49d3264554Jarkko Poyry void checkCaveat (EGLint value) 2813c827367444ee418f129b2c238299f49d3264554Jarkko Poyry { 2823c827367444ee418f129b2c238299f49d3264554Jarkko Poyry if (!(value == EGL_NONE || value == EGL_SLOW_CONFIG || value == EGL_NON_CONFORMANT_CONFIG)) 2833c827367444ee418f129b2c238299f49d3264554Jarkko Poyry { 2843c827367444ee418f129b2c238299f49d3264554Jarkko Poyry TestLog& log = m_testCtx.getLog(); 2853c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 2863c827367444ee418f129b2c238299f49d3264554Jarkko Poyry log << TestLog::Message << "Fail, invalid EGL_CONFIG_CAVEAT value" << TestLog::EndMessage; 2873c827367444ee418f129b2c238299f49d3264554Jarkko Poyry m_testCtx.setTestResult(QP_TEST_RESULT_FAIL, "Invalid value"); 2883c827367444ee418f129b2c238299f49d3264554Jarkko Poyry } 2893c827367444ee418f129b2c238299f49d3264554Jarkko Poyry } 2903c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 2913c827367444ee418f129b2c238299f49d3264554Jarkko Poyry void checkTransparentType (EGLint value) 2923c827367444ee418f129b2c238299f49d3264554Jarkko Poyry { 2933c827367444ee418f129b2c238299f49d3264554Jarkko Poyry if (!(value == EGL_NONE || value == EGL_TRANSPARENT_RGB)) 2943c827367444ee418f129b2c238299f49d3264554Jarkko Poyry { 2953c827367444ee418f129b2c238299f49d3264554Jarkko Poyry TestLog& log = m_testCtx.getLog(); 2963c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 2973c827367444ee418f129b2c238299f49d3264554Jarkko Poyry log << TestLog::Message << "Fail, invalid EGL_TRANSPARENT_TYPE value" << TestLog::EndMessage; 2983c827367444ee418f129b2c238299f49d3264554Jarkko Poyry m_testCtx.setTestResult(QP_TEST_RESULT_FAIL, "Invalid value"); 2993c827367444ee418f129b2c238299f49d3264554Jarkko Poyry } 3003c827367444ee418f129b2c238299f49d3264554Jarkko Poyry } 3013c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 3023c827367444ee418f129b2c238299f49d3264554Jarkko Poyry void checkBoolean (EGLenum attrib, EGLint value) 3033c827367444ee418f129b2c238299f49d3264554Jarkko Poyry { 3043c827367444ee418f129b2c238299f49d3264554Jarkko Poyry if (!(value == EGL_FALSE || value == EGL_TRUE)) 3053c827367444ee418f129b2c238299f49d3264554Jarkko Poyry { 3063c827367444ee418f129b2c238299f49d3264554Jarkko Poyry TestLog& log = m_testCtx.getLog(); 3073c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 3083c827367444ee418f129b2c238299f49d3264554Jarkko Poyry log << TestLog::Message << "Fail, " << eglu::getConfigAttribStr(attrib) << " should be a boolean value." << TestLog::EndMessage; 3093c827367444ee418f129b2c238299f49d3264554Jarkko Poyry m_testCtx.setTestResult(QP_TEST_RESULT_FAIL, "Invalid value"); 3103c827367444ee418f129b2c238299f49d3264554Jarkko Poyry } 3113c827367444ee418f129b2c238299f49d3264554Jarkko Poyry } 3123c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 3133c827367444ee418f129b2c238299f49d3264554Jarkko Poyry void checkInteger (EGLenum attrib, EGLint value) 3143c827367444ee418f129b2c238299f49d3264554Jarkko Poyry { 3153c827367444ee418f129b2c238299f49d3264554Jarkko Poyry if (attrib == EGL_NATIVE_VISUAL_ID || attrib == EGL_NATIVE_VISUAL_TYPE) // Implementation-defined 3163c827367444ee418f129b2c238299f49d3264554Jarkko Poyry return; 3173c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 3183c827367444ee418f129b2c238299f49d3264554Jarkko Poyry if (attrib == EGL_CONFIG_ID && value < 1) 3193c827367444ee418f129b2c238299f49d3264554Jarkko Poyry { 3203c827367444ee418f129b2c238299f49d3264554Jarkko Poyry TestLog& log = m_testCtx.getLog(); 3213c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 3223c827367444ee418f129b2c238299f49d3264554Jarkko Poyry log << TestLog::Message << "Fail, config IDs should be positive integer values beginning from 1." << TestLog::EndMessage; 3233c827367444ee418f129b2c238299f49d3264554Jarkko Poyry m_testCtx.setTestResult(QP_TEST_RESULT_FAIL, "Invalid value"); 3243c827367444ee418f129b2c238299f49d3264554Jarkko Poyry } 3253c827367444ee418f129b2c238299f49d3264554Jarkko Poyry } 3263c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 3273c827367444ee418f129b2c238299f49d3264554Jarkko Poyry void checkSurfaceTypeMask (EGLint value) 3283c827367444ee418f129b2c238299f49d3264554Jarkko Poyry { 3293c827367444ee418f129b2c238299f49d3264554Jarkko Poyry const EGLint wantedBits = EGL_WINDOW_BIT | EGL_PIXMAP_BIT | EGL_PBUFFER_BIT; 3303c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 3313c827367444ee418f129b2c238299f49d3264554Jarkko Poyry if ((value & wantedBits) == 0) 3323c827367444ee418f129b2c238299f49d3264554Jarkko Poyry { 3333c827367444ee418f129b2c238299f49d3264554Jarkko Poyry TestLog& log = m_testCtx.getLog(); 3343c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 3353c827367444ee418f129b2c238299f49d3264554Jarkko Poyry log << TestLog::Message << "Fail, config does not actually support creation of any surface type?" << TestLog::EndMessage; 3363c827367444ee418f129b2c238299f49d3264554Jarkko Poyry m_testCtx.setTestResult(QP_TEST_RESULT_FAIL, "Invalid value"); 3373c827367444ee418f129b2c238299f49d3264554Jarkko Poyry } 3383c827367444ee418f129b2c238299f49d3264554Jarkko Poyry } 3393c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 3403c827367444ee418f129b2c238299f49d3264554Jarkko Poyry void checkAttribute (EGLenum attrib, EGLint value) 3413c827367444ee418f129b2c238299f49d3264554Jarkko Poyry { 3423c827367444ee418f129b2c238299f49d3264554Jarkko Poyry switch (attrib) 3433c827367444ee418f129b2c238299f49d3264554Jarkko Poyry { 3443c827367444ee418f129b2c238299f49d3264554Jarkko Poyry case EGL_COLOR_BUFFER_TYPE: 3453c827367444ee418f129b2c238299f49d3264554Jarkko Poyry checkColorBufferType(value); 3463c827367444ee418f129b2c238299f49d3264554Jarkko Poyry break; 3473c827367444ee418f129b2c238299f49d3264554Jarkko Poyry case EGL_CONFIG_CAVEAT: 3483c827367444ee418f129b2c238299f49d3264554Jarkko Poyry checkCaveat(value); 3493c827367444ee418f129b2c238299f49d3264554Jarkko Poyry break; 3503c827367444ee418f129b2c238299f49d3264554Jarkko Poyry case EGL_TRANSPARENT_TYPE: 3513c827367444ee418f129b2c238299f49d3264554Jarkko Poyry checkTransparentType(value); 3523c827367444ee418f129b2c238299f49d3264554Jarkko Poyry break; 3533c827367444ee418f129b2c238299f49d3264554Jarkko Poyry case EGL_CONFORMANT: 3543c827367444ee418f129b2c238299f49d3264554Jarkko Poyry case EGL_RENDERABLE_TYPE: 3553c827367444ee418f129b2c238299f49d3264554Jarkko Poyry // Just print what we know 3563c827367444ee418f129b2c238299f49d3264554Jarkko Poyry break; 3573c827367444ee418f129b2c238299f49d3264554Jarkko Poyry case EGL_SURFACE_TYPE: 3583c827367444ee418f129b2c238299f49d3264554Jarkko Poyry checkSurfaceTypeMask(value); 3593c827367444ee418f129b2c238299f49d3264554Jarkko Poyry break; 3603c827367444ee418f129b2c238299f49d3264554Jarkko Poyry case EGL_BIND_TO_TEXTURE_RGB: 3613c827367444ee418f129b2c238299f49d3264554Jarkko Poyry case EGL_BIND_TO_TEXTURE_RGBA: 3623c827367444ee418f129b2c238299f49d3264554Jarkko Poyry case EGL_NATIVE_RENDERABLE: 3633c827367444ee418f129b2c238299f49d3264554Jarkko Poyry checkBoolean(attrib, value); 3643c827367444ee418f129b2c238299f49d3264554Jarkko Poyry break; 3653c827367444ee418f129b2c238299f49d3264554Jarkko Poyry default: 3663c827367444ee418f129b2c238299f49d3264554Jarkko Poyry checkInteger(attrib, value); 3673c827367444ee418f129b2c238299f49d3264554Jarkko Poyry } 3683c827367444ee418f129b2c238299f49d3264554Jarkko Poyry } 3693c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 3703c827367444ee418f129b2c238299f49d3264554Jarkko Poyry void executeTest (EGLConfig config) 3713c827367444ee418f129b2c238299f49d3264554Jarkko Poyry { 3723c827367444ee418f129b2c238299f49d3264554Jarkko Poyry TestLog& log = m_testCtx.getLog(); 3733c827367444ee418f129b2c238299f49d3264554Jarkko Poyry const tcu::egl::Display& display = m_eglTestCtx.getDisplay(); 3743c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 3753c827367444ee418f129b2c238299f49d3264554Jarkko Poyry if (!isAttributePresent(display.getVersion(), m_attrib)) 3763c827367444ee418f129b2c238299f49d3264554Jarkko Poyry { 3773c827367444ee418f129b2c238299f49d3264554Jarkko Poyry log << TestLog::Message << eglu::getConfigAttribStr(m_attrib) << " not supported by this EGL version"; 3783c827367444ee418f129b2c238299f49d3264554Jarkko Poyry } 3793c827367444ee418f129b2c238299f49d3264554Jarkko Poyry else 3803c827367444ee418f129b2c238299f49d3264554Jarkko Poyry { 3813c827367444ee418f129b2c238299f49d3264554Jarkko Poyry EGLint value; 3823c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 3833c827367444ee418f129b2c238299f49d3264554Jarkko Poyry enableLogging(true); 3843c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 3853c827367444ee418f129b2c238299f49d3264554Jarkko Poyry eglGetConfigAttrib(display.getEGLDisplay(), config, m_attrib, &value); 3863c827367444ee418f129b2c238299f49d3264554Jarkko Poyry TCU_CHECK_EGL(); 3873c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 3883c827367444ee418f129b2c238299f49d3264554Jarkko Poyry logConfigAttribute(log, m_attrib, value); 3893c827367444ee418f129b2c238299f49d3264554Jarkko Poyry checkAttribute(m_attrib, value); 3903c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 3913c827367444ee418f129b2c238299f49d3264554Jarkko Poyry enableLogging(false); 3923c827367444ee418f129b2c238299f49d3264554Jarkko Poyry } 3933c827367444ee418f129b2c238299f49d3264554Jarkko Poyry } 3943c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 3953c827367444ee418f129b2c238299f49d3264554Jarkko Poyryprivate: 3963c827367444ee418f129b2c238299f49d3264554Jarkko Poyry EGLenum m_attrib; 3973c827367444ee418f129b2c238299f49d3264554Jarkko Poyry}; 3983c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 3993c827367444ee418f129b2c238299f49d3264554Jarkko Poyryclass GetConfigAttribBufferSizeCase : public GetConfigAttribCase 4003c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{ 4013c827367444ee418f129b2c238299f49d3264554Jarkko Poyrypublic: 4023c827367444ee418f129b2c238299f49d3264554Jarkko Poyry GetConfigAttribBufferSizeCase (EglTestContext& eglTestCtx, const char* name, const char* description) 4033c827367444ee418f129b2c238299f49d3264554Jarkko Poyry : GetConfigAttribCase(eglTestCtx, name, description) 4043c827367444ee418f129b2c238299f49d3264554Jarkko Poyry { 4053c827367444ee418f129b2c238299f49d3264554Jarkko Poyry } 4063c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 4073c827367444ee418f129b2c238299f49d3264554Jarkko Poyry void executeTest (EGLConfig config) 4083c827367444ee418f129b2c238299f49d3264554Jarkko Poyry { 4093c827367444ee418f129b2c238299f49d3264554Jarkko Poyry TestLog& log = m_testCtx.getLog(); 4103c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 4113c827367444ee418f129b2c238299f49d3264554Jarkko Poyry const EGLint colorBufferType = getValue(config, EGL_COLOR_BUFFER_TYPE); 4123c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 4133c827367444ee418f129b2c238299f49d3264554Jarkko Poyry const EGLint bufferSize = getValue(config, EGL_BUFFER_SIZE); 4143c827367444ee418f129b2c238299f49d3264554Jarkko Poyry const EGLint redSize = getValue(config, EGL_RED_SIZE); 4153c827367444ee418f129b2c238299f49d3264554Jarkko Poyry const EGLint greenSize = getValue(config, EGL_GREEN_SIZE); 4163c827367444ee418f129b2c238299f49d3264554Jarkko Poyry const EGLint blueSize = getValue(config, EGL_BLUE_SIZE); 4173c827367444ee418f129b2c238299f49d3264554Jarkko Poyry const EGLint luminanceSize = getValue(config, EGL_LUMINANCE_SIZE); 4183c827367444ee418f129b2c238299f49d3264554Jarkko Poyry const EGLint alphaSize = getValue(config, EGL_ALPHA_SIZE); 4193c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 4203c827367444ee418f129b2c238299f49d3264554Jarkko Poyry if (alphaSize < 0) 4213c827367444ee418f129b2c238299f49d3264554Jarkko Poyry { 4223c827367444ee418f129b2c238299f49d3264554Jarkko Poyry log << TestLog::Message << "Fail, alpha size must be zero or positive." << TestLog::EndMessage; 4233c827367444ee418f129b2c238299f49d3264554Jarkko Poyry m_testCtx.setTestResult(QP_TEST_RESULT_FAIL, "Invalid alpha size"); 4243c827367444ee418f129b2c238299f49d3264554Jarkko Poyry } 4253c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 4263c827367444ee418f129b2c238299f49d3264554Jarkko Poyry if (colorBufferType == EGL_RGB_BUFFER) 4273c827367444ee418f129b2c238299f49d3264554Jarkko Poyry { 4283c827367444ee418f129b2c238299f49d3264554Jarkko Poyry if (luminanceSize != 0) 4293c827367444ee418f129b2c238299f49d3264554Jarkko Poyry { 4303c827367444ee418f129b2c238299f49d3264554Jarkko Poyry log << TestLog::Message << "Fail, luminance size must be zero for an RGB buffer." << TestLog::EndMessage; 4313c827367444ee418f129b2c238299f49d3264554Jarkko Poyry m_testCtx.setTestResult(QP_TEST_RESULT_FAIL, "Invalid luminance size"); 4323c827367444ee418f129b2c238299f49d3264554Jarkko Poyry } 4333c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 4343c827367444ee418f129b2c238299f49d3264554Jarkko Poyry if (redSize <= 0 || greenSize <= 0 || blueSize <= 0) 4353c827367444ee418f129b2c238299f49d3264554Jarkko Poyry { 4363c827367444ee418f129b2c238299f49d3264554Jarkko Poyry log << TestLog::Message << "Fail, RGB component sizes must be positive for an RGB buffer." << TestLog::EndMessage; 4373c827367444ee418f129b2c238299f49d3264554Jarkko Poyry m_testCtx.setTestResult(QP_TEST_RESULT_FAIL, "Invalid color component size"); 4383c827367444ee418f129b2c238299f49d3264554Jarkko Poyry } 4393c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 4403c827367444ee418f129b2c238299f49d3264554Jarkko Poyry if (bufferSize != (redSize + greenSize + blueSize + alphaSize)) 4413c827367444ee418f129b2c238299f49d3264554Jarkko Poyry { 4423c827367444ee418f129b2c238299f49d3264554Jarkko Poyry log << TestLog::Message << "Fail, buffer size must be equal to the sum of RGB component sizes and alpha size." << TestLog::EndMessage; 4433c827367444ee418f129b2c238299f49d3264554Jarkko Poyry m_testCtx.setTestResult(QP_TEST_RESULT_FAIL, "Invalid buffer size"); 4443c827367444ee418f129b2c238299f49d3264554Jarkko Poyry } 4453c827367444ee418f129b2c238299f49d3264554Jarkko Poyry } 4463c827367444ee418f129b2c238299f49d3264554Jarkko Poyry else if (colorBufferType == EGL_LUMINANCE_BUFFER) 4473c827367444ee418f129b2c238299f49d3264554Jarkko Poyry { 4483c827367444ee418f129b2c238299f49d3264554Jarkko Poyry if (luminanceSize <= 0) 4493c827367444ee418f129b2c238299f49d3264554Jarkko Poyry { 4503c827367444ee418f129b2c238299f49d3264554Jarkko Poyry log << TestLog::Message << "Fail, luminance size must be positive for a luminance buffer." << TestLog::EndMessage; 4513c827367444ee418f129b2c238299f49d3264554Jarkko Poyry m_testCtx.setTestResult(QP_TEST_RESULT_FAIL, "Invalid luminance size"); 4523c827367444ee418f129b2c238299f49d3264554Jarkko Poyry } 4533c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 4543c827367444ee418f129b2c238299f49d3264554Jarkko Poyry if (redSize != 0 || greenSize != 0 || blueSize != 0) 4553c827367444ee418f129b2c238299f49d3264554Jarkko Poyry { 4563c827367444ee418f129b2c238299f49d3264554Jarkko Poyry log << TestLog::Message << "Fail, RGB component sizes must be zero for a luminance buffer." << TestLog::EndMessage; 4573c827367444ee418f129b2c238299f49d3264554Jarkko Poyry m_testCtx.setTestResult(QP_TEST_RESULT_FAIL, "Invalid color component size"); 4583c827367444ee418f129b2c238299f49d3264554Jarkko Poyry } 4593c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 4603c827367444ee418f129b2c238299f49d3264554Jarkko Poyry if (bufferSize != (luminanceSize + alphaSize)) 4613c827367444ee418f129b2c238299f49d3264554Jarkko Poyry { 4623c827367444ee418f129b2c238299f49d3264554Jarkko Poyry log << TestLog::Message << "Fail, buffer size must be equal to the sum of luminance size and alpha size." << TestLog::EndMessage; 4633c827367444ee418f129b2c238299f49d3264554Jarkko Poyry m_testCtx.setTestResult(QP_TEST_RESULT_FAIL, "Invalid buffer size"); 4643c827367444ee418f129b2c238299f49d3264554Jarkko Poyry } 4653c827367444ee418f129b2c238299f49d3264554Jarkko Poyry } 4663c827367444ee418f129b2c238299f49d3264554Jarkko Poyry } 4673c827367444ee418f129b2c238299f49d3264554Jarkko Poyry}; 4683c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 4693c827367444ee418f129b2c238299f49d3264554Jarkko Poyryclass GetConfigAttribTransparentValueCase : public GetConfigAttribCase 4703c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{ 4713c827367444ee418f129b2c238299f49d3264554Jarkko Poyrypublic: 4723c827367444ee418f129b2c238299f49d3264554Jarkko Poyry GetConfigAttribTransparentValueCase (EglTestContext& eglTestCtx, const char* name, const char* description) 4733c827367444ee418f129b2c238299f49d3264554Jarkko Poyry : GetConfigAttribCase(eglTestCtx, name, description) 4743c827367444ee418f129b2c238299f49d3264554Jarkko Poyry { 4753c827367444ee418f129b2c238299f49d3264554Jarkko Poyry } 4763c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 4773c827367444ee418f129b2c238299f49d3264554Jarkko Poyry void executeTest (EGLConfig config) 4783c827367444ee418f129b2c238299f49d3264554Jarkko Poyry { 4793c827367444ee418f129b2c238299f49d3264554Jarkko Poyry TestLog& log = m_testCtx.getLog(); 4803c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 4813c827367444ee418f129b2c238299f49d3264554Jarkko Poyry const EGLint transparentType = getValue(config, EGL_TRANSPARENT_TYPE); 4823c827367444ee418f129b2c238299f49d3264554Jarkko Poyry const EGLint redValue = getValue(config, EGL_TRANSPARENT_RED_VALUE); 4833c827367444ee418f129b2c238299f49d3264554Jarkko Poyry const EGLint greenValue = getValue(config, EGL_TRANSPARENT_GREEN_VALUE); 4843c827367444ee418f129b2c238299f49d3264554Jarkko Poyry const EGLint blueValue = getValue(config, EGL_TRANSPARENT_BLUE_VALUE); 4853c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 4863c827367444ee418f129b2c238299f49d3264554Jarkko Poyry const EGLint redSize = getValue(config, EGL_RED_SIZE); 4873c827367444ee418f129b2c238299f49d3264554Jarkko Poyry const EGLint greenSize = getValue(config, EGL_GREEN_SIZE); 4883c827367444ee418f129b2c238299f49d3264554Jarkko Poyry const EGLint blueSize = getValue(config, EGL_BLUE_SIZE); 4893c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 4903c827367444ee418f129b2c238299f49d3264554Jarkko Poyry if (transparentType == EGL_TRANSPARENT_RGB) 4913c827367444ee418f129b2c238299f49d3264554Jarkko Poyry { 4923c827367444ee418f129b2c238299f49d3264554Jarkko Poyry if ( (redValue < 0 || redValue >= (1 << redSize)) 4933c827367444ee418f129b2c238299f49d3264554Jarkko Poyry || (greenValue < 0 || greenValue >= (1 << greenSize)) 4943c827367444ee418f129b2c238299f49d3264554Jarkko Poyry || (blueValue < 0 || blueValue >= (1 << blueSize)) ) 4953c827367444ee418f129b2c238299f49d3264554Jarkko Poyry { 4963c827367444ee418f129b2c238299f49d3264554Jarkko Poyry log << TestLog::Message << "Fail, transparent color values must lie between 0 and the maximum component value." << TestLog::EndMessage; 4973c827367444ee418f129b2c238299f49d3264554Jarkko Poyry m_testCtx.setTestResult(QP_TEST_RESULT_FAIL, "Invalid transparent color value"); 4983c827367444ee418f129b2c238299f49d3264554Jarkko Poyry } 4993c827367444ee418f129b2c238299f49d3264554Jarkko Poyry } 5003c827367444ee418f129b2c238299f49d3264554Jarkko Poyry } 5013c827367444ee418f129b2c238299f49d3264554Jarkko Poyry}; 5023c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 5033c827367444ee418f129b2c238299f49d3264554Jarkko PoyryQueryConfigTests::QueryConfigTests (EglTestContext& eglTestCtx) 5043c827367444ee418f129b2c238299f49d3264554Jarkko Poyry : TestCaseGroup(eglTestCtx, "query_config", "Surface config query tests") 5053c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{ 5063c827367444ee418f129b2c238299f49d3264554Jarkko Poyry} 5073c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 5083c827367444ee418f129b2c238299f49d3264554Jarkko PoyryQueryConfigTests::~QueryConfigTests (void) 5093c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{ 5103c827367444ee418f129b2c238299f49d3264554Jarkko Poyry} 5113c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 5123c827367444ee418f129b2c238299f49d3264554Jarkko Poyryvoid QueryConfigTests::init (void) 5133c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{ 5143c827367444ee418f129b2c238299f49d3264554Jarkko Poyry // eglGetGonfigs 5153c827367444ee418f129b2c238299f49d3264554Jarkko Poyry { 5163c827367444ee418f129b2c238299f49d3264554Jarkko Poyry tcu::TestCaseGroup* getConfigsGroup = new tcu::TestCaseGroup(m_testCtx, "get_configs", "eglGetConfigs tests"); 5173c827367444ee418f129b2c238299f49d3264554Jarkko Poyry addChild(getConfigsGroup); 5183c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 5193c827367444ee418f129b2c238299f49d3264554Jarkko Poyry getConfigsGroup->addChild(new GetConfigsBoundsCase(m_eglTestCtx, "get_configs_bounds", "eglGetConfigs bounds checking test")); 5203c827367444ee418f129b2c238299f49d3264554Jarkko Poyry } 5213c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 5223c827367444ee418f129b2c238299f49d3264554Jarkko Poyry // eglGetConfigAttrib 5233c827367444ee418f129b2c238299f49d3264554Jarkko Poyry { 5243c827367444ee418f129b2c238299f49d3264554Jarkko Poyry static const struct 5253c827367444ee418f129b2c238299f49d3264554Jarkko Poyry { 5263c827367444ee418f129b2c238299f49d3264554Jarkko Poyry EGLenum attribute; 5273c827367444ee418f129b2c238299f49d3264554Jarkko Poyry const char* testName; 5283c827367444ee418f129b2c238299f49d3264554Jarkko Poyry } attributes[] = 5293c827367444ee418f129b2c238299f49d3264554Jarkko Poyry { 5303c827367444ee418f129b2c238299f49d3264554Jarkko Poyry { EGL_BUFFER_SIZE, "buffer_size" }, 5313c827367444ee418f129b2c238299f49d3264554Jarkko Poyry { EGL_RED_SIZE, "red_size" }, 5323c827367444ee418f129b2c238299f49d3264554Jarkko Poyry { EGL_GREEN_SIZE, "green_size" }, 5333c827367444ee418f129b2c238299f49d3264554Jarkko Poyry { EGL_BLUE_SIZE, "blue_size" }, 5343c827367444ee418f129b2c238299f49d3264554Jarkko Poyry { EGL_LUMINANCE_SIZE, "luminance_size" }, 5353c827367444ee418f129b2c238299f49d3264554Jarkko Poyry { EGL_ALPHA_SIZE, "alpha_size" }, 5363c827367444ee418f129b2c238299f49d3264554Jarkko Poyry { EGL_ALPHA_MASK_SIZE, "alpha_mask_size" }, 5373c827367444ee418f129b2c238299f49d3264554Jarkko Poyry { EGL_BIND_TO_TEXTURE_RGB, "bind_to_texture_rgb" }, 5383c827367444ee418f129b2c238299f49d3264554Jarkko Poyry { EGL_BIND_TO_TEXTURE_RGBA, "bind_to_texture_rgba" }, 5393c827367444ee418f129b2c238299f49d3264554Jarkko Poyry { EGL_COLOR_BUFFER_TYPE, "color_buffer_type" }, 5403c827367444ee418f129b2c238299f49d3264554Jarkko Poyry { EGL_CONFIG_CAVEAT, "config_caveat" }, 5413c827367444ee418f129b2c238299f49d3264554Jarkko Poyry { EGL_CONFIG_ID, "config_id" }, 5423c827367444ee418f129b2c238299f49d3264554Jarkko Poyry { EGL_CONFORMANT, "conformant" }, 5433c827367444ee418f129b2c238299f49d3264554Jarkko Poyry { EGL_DEPTH_SIZE, "depth_size" }, 5443c827367444ee418f129b2c238299f49d3264554Jarkko Poyry { EGL_LEVEL, "level" }, 5453c827367444ee418f129b2c238299f49d3264554Jarkko Poyry { EGL_MAX_SWAP_INTERVAL, "max_swap_interval" }, 5463c827367444ee418f129b2c238299f49d3264554Jarkko Poyry { EGL_MIN_SWAP_INTERVAL, "min_swap_interval" }, 5473c827367444ee418f129b2c238299f49d3264554Jarkko Poyry { EGL_NATIVE_RENDERABLE, "native_renderable" }, 5483c827367444ee418f129b2c238299f49d3264554Jarkko Poyry { EGL_NATIVE_VISUAL_TYPE, "native_visual_type" }, 5493c827367444ee418f129b2c238299f49d3264554Jarkko Poyry { EGL_RENDERABLE_TYPE, "renderable_type" }, 5503c827367444ee418f129b2c238299f49d3264554Jarkko Poyry { EGL_SAMPLE_BUFFERS, "sample_buffers" }, 5513c827367444ee418f129b2c238299f49d3264554Jarkko Poyry { EGL_SAMPLES, "samples" }, 5523c827367444ee418f129b2c238299f49d3264554Jarkko Poyry { EGL_STENCIL_SIZE, "stencil_size" }, 5533c827367444ee418f129b2c238299f49d3264554Jarkko Poyry { EGL_SURFACE_TYPE, "surface_type" }, 5543c827367444ee418f129b2c238299f49d3264554Jarkko Poyry { EGL_TRANSPARENT_TYPE, "transparent_type" }, 5553c827367444ee418f129b2c238299f49d3264554Jarkko Poyry { EGL_TRANSPARENT_RED_VALUE, "transparent_red_value" }, 5563c827367444ee418f129b2c238299f49d3264554Jarkko Poyry { EGL_TRANSPARENT_GREEN_VALUE, "transparent_green_value" }, 5573c827367444ee418f129b2c238299f49d3264554Jarkko Poyry { EGL_TRANSPARENT_BLUE_VALUE, "transparent_blue_value" } 5583c827367444ee418f129b2c238299f49d3264554Jarkko Poyry }; 5593c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 5603c827367444ee418f129b2c238299f49d3264554Jarkko Poyry tcu::TestCaseGroup* simpleGroup = new tcu::TestCaseGroup(m_testCtx, "get_config_attrib", "eglGetConfigAttrib() tests"); 5613c827367444ee418f129b2c238299f49d3264554Jarkko Poyry addChild(simpleGroup); 5623c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 5633c827367444ee418f129b2c238299f49d3264554Jarkko Poyry for (int ndx = 0; ndx < (int)DE_LENGTH_OF_ARRAY(attributes); ndx++) 5643c827367444ee418f129b2c238299f49d3264554Jarkko Poyry { 5653c827367444ee418f129b2c238299f49d3264554Jarkko Poyry simpleGroup->addChild(new GetConfigAttribSimpleCase(m_eglTestCtx, attributes[ndx].testName, "Simple attribute query case", attributes[ndx].attribute)); 5663c827367444ee418f129b2c238299f49d3264554Jarkko Poyry } 5673c827367444ee418f129b2c238299f49d3264554Jarkko Poyry } 5683c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 5693c827367444ee418f129b2c238299f49d3264554Jarkko Poyry // Attribute constraints 5703c827367444ee418f129b2c238299f49d3264554Jarkko Poyry { 5713c827367444ee418f129b2c238299f49d3264554Jarkko Poyry tcu::TestCaseGroup* constraintsGroup = new tcu::TestCaseGroup(m_testCtx, "constraints", "Attribute constraint tests"); 5723c827367444ee418f129b2c238299f49d3264554Jarkko Poyry addChild(constraintsGroup); 5733c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 5743c827367444ee418f129b2c238299f49d3264554Jarkko Poyry constraintsGroup->addChild(new GetConfigAttribBufferSizeCase(m_eglTestCtx, "color_buffer_size", "Color buffer component sizes")); 5753c827367444ee418f129b2c238299f49d3264554Jarkko Poyry constraintsGroup->addChild(new GetConfigAttribTransparentValueCase(m_eglTestCtx, "transparent_value", "Transparent color value")); 5763c827367444ee418f129b2c238299f49d3264554Jarkko Poyry } 5773c827367444ee418f129b2c238299f49d3264554Jarkko Poyry} 5783c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 5793c827367444ee418f129b2c238299f49d3264554Jarkko Poyry} // egl 5803c827367444ee418f129b2c238299f49d3264554Jarkko Poyry} // deqp 581