Home | History | Annotate | Download | only in egl
      1 /*-------------------------------------------------------------------------
      2  * drawElements Quality Program EGL Module
      3  * ---------------------------------------
      4  *
      5  * Copyright 2014 The Android Open Source Project
      6  *
      7  * Licensed under the Apache License, Version 2.0 (the "License");
      8  * you may not use this file except in compliance with the License.
      9  * You may obtain a copy of the License at
     10  *
     11  *      http://www.apache.org/licenses/LICENSE-2.0
     12  *
     13  * Unless required by applicable law or agreed to in writing, software
     14  * distributed under the License is distributed on an "AS IS" BASIS,
     15  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
     16  * See the License for the specific language governing permissions and
     17  * limitations under the License.
     18  *
     19  *//*!
     20  * \file
     21  * \brief EGL tests
     22  *//*--------------------------------------------------------------------*/
     23 
     24 #include "teglConfigList.hpp"
     25 #include "tcuTestLog.hpp"
     26 #include "egluStrUtil.hpp"
     27 #include "egluUtil.hpp"
     28 #include "eglwLibrary.hpp"
     29 #include "eglwEnums.hpp"
     30 #include "deStringUtil.hpp"
     31 
     32 #include <vector>
     33 
     34 namespace deqp
     35 {
     36 namespace egl
     37 {
     38 
     39 using std::vector;
     40 using namespace eglw;
     41 
     42 ConfigList::ConfigList (EglTestContext& eglTestCtx)
     43 	: TestCase(eglTestCtx, "configs", "Output the list of configs from EGL")
     44 
     45 {
     46 }
     47 
     48 ConfigList::~ConfigList (void)
     49 {
     50 }
     51 
     52 void ConfigList::init (void)
     53 {
     54 }
     55 
     56 void ConfigList::deinit (void)
     57 {
     58 }
     59 
     60 tcu::TestNode::IterateResult ConfigList::iterate (void)
     61 {
     62 	const Library&		egl			= m_eglTestCtx.getLibrary();
     63 	tcu::TestLog&		log			= m_testCtx.getLog();
     64 	EGLDisplay			display		= eglu::getAndInitDisplay(m_eglTestCtx.getNativeDisplay());
     65 	vector<EGLConfig>	configs		= eglu::getConfigs(egl, display);
     66 
     67 	// \todo [2011-03-23 pyry] Check error codes!
     68 
     69 	// \todo [kalle 10/08/2010] Get EGL version.
     70 
     71 	log.startEglConfigSet("EGL-configs", "List of all EGL configs");
     72 
     73 	// \todo [kalle 10/08/2010] Add validity checks for the values?
     74 	// \todo [kalle 10/08/2010] Adapt for different EGL versions
     75 
     76 	for (int i = 0; i < (int)configs.size(); i++)
     77 	{
     78 		qpEglConfigInfo info;
     79 		EGLint val = 0;
     80 
     81 		egl.getConfigAttrib(display, configs[i], EGL_BUFFER_SIZE, &val);
     82 		info.bufferSize = val;
     83 
     84 		egl.getConfigAttrib(display, configs[i], EGL_RED_SIZE, &val);
     85 		info.redSize = val;
     86 
     87 		egl.getConfigAttrib(display, configs[i], EGL_GREEN_SIZE, &val);
     88 		info.greenSize = val;
     89 
     90 		egl.getConfigAttrib(display, configs[i], EGL_BLUE_SIZE, &val);
     91 		info.blueSize = val;
     92 
     93 		egl.getConfigAttrib(display, configs[i], EGL_LUMINANCE_SIZE, &val);
     94 		info.luminanceSize = val;
     95 
     96 		egl.getConfigAttrib(display, configs[i], EGL_ALPHA_SIZE, &val);
     97 		info.alphaSize = val;
     98 
     99 		egl.getConfigAttrib(display, configs[i], EGL_ALPHA_MASK_SIZE, &val);
    100 		info.alphaMaskSize = val;
    101 
    102 		egl.getConfigAttrib(display, configs[i], EGL_BIND_TO_TEXTURE_RGB, &val);
    103 		info.bindToTextureRGB = val == EGL_TRUE ? DE_TRUE : DE_FALSE;
    104 
    105 		egl.getConfigAttrib(display, configs[i], EGL_BIND_TO_TEXTURE_RGBA, &val);
    106 		info.bindToTextureRGBA = val == EGL_TRUE ? DE_TRUE : DE_FALSE;
    107 
    108 		egl.getConfigAttrib(display, configs[i], EGL_COLOR_BUFFER_TYPE, &val);
    109 		std::string colorBufferType = de::toString(eglu::getColorBufferTypeStr(val));
    110 		info.colorBufferType = colorBufferType.c_str();
    111 
    112 		egl.getConfigAttrib(display, configs[i], EGL_CONFIG_CAVEAT, &val);
    113 		std::string caveat = de::toString(eglu::getConfigCaveatStr(val));
    114 		info.configCaveat = caveat.c_str();
    115 
    116 		egl.getConfigAttrib(display, configs[i], EGL_CONFIG_ID, &val);
    117 		info.configID = val;
    118 
    119 		egl.getConfigAttrib(display, configs[i], EGL_CONFORMANT, &val);
    120 		std::string conformant = de::toString(eglu::getAPIBitsStr(val));
    121 		info.conformant = conformant.c_str();
    122 
    123 		egl.getConfigAttrib(display, configs[i], EGL_DEPTH_SIZE, &val);
    124 		info.depthSize = val;
    125 
    126 		egl.getConfigAttrib(display, configs[i], EGL_LEVEL, &val);
    127 		info.level = val;
    128 
    129 		egl.getConfigAttrib(display, configs[i], EGL_MAX_PBUFFER_WIDTH, &val);
    130 		info.maxPBufferWidth = val;
    131 
    132 		egl.getConfigAttrib(display, configs[i], EGL_MAX_PBUFFER_HEIGHT, &val);
    133 		info.maxPBufferHeight = val;
    134 
    135 		egl.getConfigAttrib(display, configs[i], EGL_MAX_PBUFFER_PIXELS, &val);
    136 		info.maxPBufferPixels = val;
    137 
    138 		egl.getConfigAttrib(display, configs[i], EGL_MAX_SWAP_INTERVAL, &val);
    139 		info.maxSwapInterval = val;
    140 
    141 		egl.getConfigAttrib(display, configs[i], EGL_MIN_SWAP_INTERVAL, &val);
    142 		info.minSwapInterval = val;
    143 
    144 		egl.getConfigAttrib(display, configs[i], EGL_NATIVE_RENDERABLE, &val);
    145 		info.nativeRenderable = val == EGL_TRUE ? DE_TRUE : DE_FALSE;
    146 
    147 		egl.getConfigAttrib(display, configs[i], EGL_RENDERABLE_TYPE, &val);
    148 		std::string renderableTypes = de::toString(eglu::getAPIBitsStr(val));
    149 		info.renderableType = renderableTypes.c_str();
    150 
    151 		egl.getConfigAttrib(display, configs[i], EGL_SAMPLE_BUFFERS, &val);
    152 		info.sampleBuffers = val;
    153 
    154 		egl.getConfigAttrib(display, configs[i], EGL_SAMPLES, &val);
    155 		info.samples = val;
    156 
    157 		egl.getConfigAttrib(display, configs[i], EGL_STENCIL_SIZE, &val);
    158 		info.stencilSize = val;
    159 
    160 		egl.getConfigAttrib(display, configs[i], EGL_SURFACE_TYPE, &val);
    161 		std::string surfaceTypes = de::toString(eglu::getSurfaceBitsStr(val));
    162 		info.surfaceTypes = surfaceTypes.c_str();
    163 
    164 		egl.getConfigAttrib(display, configs[i], EGL_TRANSPARENT_TYPE, &val);
    165 		std::string transparentType = de::toString(eglu::getTransparentTypeStr(val));
    166 		info.transparentType = transparentType.c_str();
    167 
    168 		egl.getConfigAttrib(display, configs[i], EGL_TRANSPARENT_RED_VALUE, &val);
    169 		info.transparentRedValue = val;
    170 
    171 		egl.getConfigAttrib(display, configs[i], EGL_TRANSPARENT_GREEN_VALUE, &val);
    172 		info.transparentGreenValue = val;
    173 
    174 		egl.getConfigAttrib(display, configs[i], EGL_TRANSPARENT_BLUE_VALUE, &val);
    175 		info.transparentBlueValue = val;
    176 
    177 		log.writeEglConfig(&info);
    178 	}
    179 	log.endEglConfigSet();
    180 
    181 	egl.terminate(display);
    182 
    183 	getTestContext().setTestResult(QP_TEST_RESULT_PASS, "");
    184 
    185 	return TestNode::STOP;
    186 }
    187 
    188 } // egl
    189 } // deqp
    190