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 Choose config reference implementation.
     22  *//*--------------------------------------------------------------------*/
     23 
     24 #include "teglChooseConfigReference.hpp"
     25 
     26 #include "egluUtil.hpp"
     27 #include "egluConfigInfo.hpp"
     28 #include "egluStrUtil.hpp"
     29 #include "eglwLibrary.hpp"
     30 #include "eglwEnums.hpp"
     31 
     32 #include "deSTLUtil.hpp"
     33 
     34 #include <algorithm>
     35 #include <vector>
     36 #include <map>
     37 
     38 namespace deqp
     39 {
     40 namespace egl
     41 {
     42 
     43 using namespace eglw;
     44 using eglu::ConfigInfo;
     45 
     46 enum Criteria
     47 {
     48 	CRITERIA_AT_LEAST = 0,
     49 	CRITERIA_EXACT,
     50 	CRITERIA_MASK,
     51 	CRITERIA_SPECIAL,
     52 
     53 	CRITERIA_LAST
     54 };
     55 
     56 enum SortOrder
     57 {
     58 	SORTORDER_NONE	= 0,
     59 	SORTORDER_SMALLER,
     60 	SORTORDER_SPECIAL,
     61 
     62 	SORTORDER_LAST
     63 };
     64 
     65 struct AttribRule
     66 {
     67 	EGLenum		name;
     68 	EGLint		value;
     69 	Criteria	criteria;
     70 	SortOrder	sortOrder;
     71 
     72 	AttribRule (void)
     73 		: name			(EGL_NONE)
     74 		, value			(EGL_NONE)
     75 		, criteria		(CRITERIA_LAST)
     76 		, sortOrder		(SORTORDER_LAST)
     77 	{
     78 	}
     79 
     80 	AttribRule (EGLenum name_, EGLint value_, Criteria criteria_, SortOrder sortOrder_)
     81 		: name			(name_)
     82 		, value			(value_)
     83 		, criteria		(criteria_)
     84 		, sortOrder		(sortOrder_)
     85 	{
     86 	}
     87 };
     88 
     89 class SurfaceConfig
     90 {
     91 private:
     92 	static int getCaveatRank (EGLenum caveat)
     93 	{
     94 		switch (caveat)
     95 		{
     96 			case EGL_NONE:					return 0;
     97 			case EGL_SLOW_CONFIG:			return 1;
     98 			case EGL_NON_CONFORMANT_CONFIG:	return 2;
     99 			default:
    100 				TCU_THROW(TestError, (std::string("Unknown config caveat: ") + eglu::getConfigCaveatStr(caveat).toString()).c_str());
    101 		}
    102 	}
    103 
    104 	static int getColorBufferTypeRank (EGLenum type)
    105 	{
    106 		switch (type)
    107 		{
    108 			case EGL_RGB_BUFFER:			return 0;
    109 			case EGL_LUMINANCE_BUFFER:		return 1;
    110 			case EGL_YUV_BUFFER_EXT:		return 2;
    111 			default:
    112 				TCU_THROW(TestError, (std::string("Unknown color buffer type: ") + eglu::getColorBufferTypeStr(type).toString()).c_str());
    113 		}
    114 	}
    115 
    116 	static int getYuvOrderRank (EGLenum order)
    117 	{
    118 		switch (order)
    119 		{
    120 			case EGL_NONE:					return 0;
    121 			case EGL_YUV_ORDER_YUV_EXT:		return 1;
    122 			case EGL_YUV_ORDER_YVU_EXT:		return 2;
    123 			case EGL_YUV_ORDER_YUYV_EXT:	return 3;
    124 			case EGL_YUV_ORDER_YVYU_EXT:	return 4;
    125 			case EGL_YUV_ORDER_UYVY_EXT:	return 5;
    126 			case EGL_YUV_ORDER_VYUY_EXT:	return 6;
    127 			case EGL_YUV_ORDER_AYUV_EXT:	return 7;
    128 			default:
    129 				TCU_THROW(TestError, (std::string("Unknown YUV order: ") + eglu::getYuvOrderStr(order).toString()).c_str());
    130 		}
    131 	}
    132 
    133 	static int getYuvPlaneBppValue (EGLenum bpp)
    134 	{
    135 		switch (bpp)
    136 		{
    137 			case EGL_YUV_PLANE_BPP_0_EXT:	return 0;
    138 			case EGL_YUV_PLANE_BPP_8_EXT:	return 8;
    139 			case EGL_YUV_PLANE_BPP_10_EXT:	return 10;
    140 			default:
    141 				TCU_THROW(TestError, (std::string("Unknown YUV plane BPP: ") + eglu::getYuvPlaneBppStr(bpp).toString()).c_str());
    142 		}
    143 	}
    144 
    145 	typedef bool (*CompareFunc) (const SurfaceConfig& a, const SurfaceConfig& b);
    146 
    147 	static bool compareCaveat (const SurfaceConfig& a, const SurfaceConfig& b)
    148 	{
    149 		return getCaveatRank((EGLenum)a.m_info.configCaveat) < getCaveatRank((EGLenum)b.m_info.configCaveat);
    150 	}
    151 
    152 	static bool compareColorBufferType (const SurfaceConfig& a, const SurfaceConfig& b)
    153 	{
    154 		return getColorBufferTypeRank((EGLenum)a.m_info.colorBufferType) < getColorBufferTypeRank((EGLenum)b.m_info.colorBufferType);
    155 	}
    156 
    157 	static bool compareYuvOrder (const SurfaceConfig& a, const SurfaceConfig& b)
    158 	{
    159 		return getYuvOrderRank((EGLenum)a.m_info.yuvOrder) < getYuvOrderRank((EGLenum)b.m_info.yuvOrder);
    160 	}
    161 
    162 	static bool compareColorBufferBits (const SurfaceConfig& a, const SurfaceConfig& b, const tcu::BVec4& specifiedRGBColors, const tcu::BVec2& specifiedLuminanceColors, bool yuvPlaneBppSpecified)
    163 	{
    164 		DE_ASSERT(a.m_info.colorBufferType == b.m_info.colorBufferType);
    165 		switch (a.m_info.colorBufferType)
    166 		{
    167 			case EGL_RGB_BUFFER:
    168 			{
    169 				const tcu::IVec4	mask	(specifiedRGBColors.cast<deInt32>());
    170 
    171 				return (a.m_info.redSize * mask[0] + a.m_info.greenSize * mask[1] + a.m_info.blueSize * mask[2] + a.m_info.alphaSize * mask[3])
    172 						> (b.m_info.redSize * mask[0] + b.m_info.greenSize * mask[1] + b.m_info.blueSize * mask[2] + b.m_info.alphaSize * mask[3]);
    173 			}
    174 
    175 			case EGL_LUMINANCE_BUFFER:
    176 			{
    177 				const tcu::IVec2	mask	(specifiedLuminanceColors.cast<deInt32>());
    178 
    179 				return (a.m_info.luminanceSize * mask[0] + a.m_info.alphaSize * mask[1]) > (b.m_info.luminanceSize * mask[0] + b.m_info.alphaSize * mask[1]);
    180 			}
    181 
    182 			case EGL_YUV_BUFFER_EXT:
    183 				return yuvPlaneBppSpecified ? (a.m_info.yuvPlaneBpp > b.m_info.yuvPlaneBpp) : false;
    184 
    185 			default:
    186 				DE_ASSERT(DE_FALSE);
    187 				return true;
    188 		}
    189 	}
    190 
    191 	template <EGLenum Attribute>
    192 	static bool compareAttributeSmaller (const SurfaceConfig& a, const SurfaceConfig& b)
    193 	{
    194 		return a.getAttribute(Attribute) < b.getAttribute(Attribute);
    195 	}
    196 public:
    197 	SurfaceConfig (EGLConfig config, ConfigInfo &info)
    198 		: m_config(config)
    199 		, m_info(info)
    200 	{
    201 	}
    202 
    203 	EGLConfig getEglConfig (void) const
    204 	{
    205 		return m_config;
    206 	}
    207 
    208 	EGLint getAttribute (const EGLenum attribute) const
    209 	{
    210 		return m_info.getAttribute(attribute);
    211 	}
    212 
    213 	friend bool operator== (const SurfaceConfig& a, const SurfaceConfig& b)
    214 	{
    215 		const std::map<EGLenum, AttribRule> defaultRules = getDefaultRules();
    216 
    217 		for (std::map<EGLenum, AttribRule>::const_iterator iter = defaultRules.begin(); iter != defaultRules.end(); iter++)
    218 		{
    219 			const EGLenum attribute = iter->first;
    220 
    221 			if (a.getAttribute(attribute) != b.getAttribute(attribute)) return false;
    222 		}
    223 		return true;
    224 	}
    225 
    226 	bool compareTo (const SurfaceConfig& b, const tcu::BVec4& specifiedRGBColors, const tcu::BVec2& specifiedLuminanceColors, bool yuvPlaneBppSpecified) const
    227 	{
    228 		static const SurfaceConfig::CompareFunc compareFuncs[] =
    229 		{
    230 			SurfaceConfig::compareCaveat,
    231 			SurfaceConfig::compareColorBufferType,
    232 			DE_NULL, // SurfaceConfig::compareColorBufferBits,
    233 			SurfaceConfig::compareAttributeSmaller<EGL_BUFFER_SIZE>,
    234 			SurfaceConfig::compareAttributeSmaller<EGL_SAMPLE_BUFFERS>,
    235 			SurfaceConfig::compareAttributeSmaller<EGL_SAMPLES>,
    236 			SurfaceConfig::compareAttributeSmaller<EGL_DEPTH_SIZE>,
    237 			SurfaceConfig::compareAttributeSmaller<EGL_STENCIL_SIZE>,
    238 			SurfaceConfig::compareAttributeSmaller<EGL_ALPHA_MASK_SIZE>,
    239 			SurfaceConfig::compareYuvOrder,
    240 			SurfaceConfig::compareAttributeSmaller<EGL_CONFIG_ID>
    241 		};
    242 
    243 		if (*this == b)
    244 			return false; // std::sort() can compare object to itself.
    245 
    246 		for (int ndx = 0; ndx < (int)DE_LENGTH_OF_ARRAY(compareFuncs); ndx++)
    247 		{
    248 			if (!compareFuncs[ndx])
    249 			{
    250 				if (compareColorBufferBits(*this, b, specifiedRGBColors, specifiedLuminanceColors, yuvPlaneBppSpecified))
    251 					return true;
    252 				else if (compareColorBufferBits(b, *this, specifiedRGBColors, specifiedLuminanceColors, yuvPlaneBppSpecified))
    253 					return false;
    254 
    255 				continue;
    256 			}
    257 
    258 			if (compareFuncs[ndx](*this, b))
    259 				return true;
    260 			else if (compareFuncs[ndx](b, *this))
    261 				return false;
    262 		}
    263 
    264 		TCU_FAIL("Unable to compare configs - duplicate ID?");
    265 	}
    266 
    267 	static std::map<EGLenum, AttribRule> getDefaultRules (void)
    268 	{
    269 		// \todo [2011-03-24 pyry] From EGL 1.4 spec - check that this is valid for other versions as well
    270 		std::map<EGLenum, AttribRule> rules;
    271 
    272 		//									Attribute									Default				Selection Criteria	Sort Order			Sort Priority
    273 		rules[EGL_BUFFER_SIZE]				= AttribRule(EGL_BUFFER_SIZE,				0,					CRITERIA_AT_LEAST,	SORTORDER_SMALLER);	//	4
    274 		rules[EGL_RED_SIZE]					= AttribRule(EGL_RED_SIZE,					0,					CRITERIA_AT_LEAST,	SORTORDER_SPECIAL);	//	3
    275 		rules[EGL_GREEN_SIZE]				= AttribRule(EGL_GREEN_SIZE,				0,					CRITERIA_AT_LEAST,	SORTORDER_SPECIAL);	//	3
    276 		rules[EGL_BLUE_SIZE]				= AttribRule(EGL_BLUE_SIZE,					0,					CRITERIA_AT_LEAST,	SORTORDER_SPECIAL);	//	3
    277 		rules[EGL_LUMINANCE_SIZE]			= AttribRule(EGL_LUMINANCE_SIZE,			0,					CRITERIA_AT_LEAST,	SORTORDER_SPECIAL);	//	3
    278 		rules[EGL_ALPHA_SIZE]				= AttribRule(EGL_ALPHA_SIZE,				0,					CRITERIA_AT_LEAST,	SORTORDER_SPECIAL);	//	3
    279 		rules[EGL_ALPHA_MASK_SIZE]			= AttribRule(EGL_ALPHA_MASK_SIZE,			0,					CRITERIA_AT_LEAST,	SORTORDER_SMALLER);	//	9
    280 		rules[EGL_BIND_TO_TEXTURE_RGB]		= AttribRule(EGL_BIND_TO_TEXTURE_RGB,		EGL_DONT_CARE,		CRITERIA_EXACT,		SORTORDER_NONE);
    281 		rules[EGL_BIND_TO_TEXTURE_RGBA]		= AttribRule(EGL_BIND_TO_TEXTURE_RGBA,		EGL_DONT_CARE,		CRITERIA_EXACT,		SORTORDER_NONE);
    282 		rules[EGL_COLOR_BUFFER_TYPE]		= AttribRule(EGL_COLOR_BUFFER_TYPE,			EGL_RGB_BUFFER,		CRITERIA_EXACT,		SORTORDER_NONE);	//	2
    283 		rules[EGL_CONFIG_CAVEAT]			= AttribRule(EGL_CONFIG_CAVEAT,				EGL_DONT_CARE,		CRITERIA_EXACT,		SORTORDER_SPECIAL);	//	1
    284 		rules[EGL_CONFIG_ID]				= AttribRule(EGL_CONFIG_ID,					EGL_DONT_CARE,		CRITERIA_EXACT,		SORTORDER_SMALLER);	//	11
    285 		rules[EGL_CONFORMANT]				= AttribRule(EGL_CONFORMANT,				0,					CRITERIA_MASK,		SORTORDER_NONE);
    286 		rules[EGL_DEPTH_SIZE]				= AttribRule(EGL_DEPTH_SIZE,				0,					CRITERIA_AT_LEAST,	SORTORDER_SMALLER);	//	7
    287 		rules[EGL_LEVEL]					= AttribRule(EGL_LEVEL,						0,					CRITERIA_EXACT,		SORTORDER_NONE);
    288 		rules[EGL_MAX_SWAP_INTERVAL]		= AttribRule(EGL_MAX_SWAP_INTERVAL,			EGL_DONT_CARE,		CRITERIA_EXACT,		SORTORDER_NONE);
    289 		rules[EGL_MIN_SWAP_INTERVAL]		= AttribRule(EGL_MIN_SWAP_INTERVAL,			EGL_DONT_CARE,		CRITERIA_EXACT,		SORTORDER_NONE);
    290 		rules[EGL_NATIVE_RENDERABLE]		= AttribRule(EGL_NATIVE_RENDERABLE,			EGL_DONT_CARE,		CRITERIA_EXACT,		SORTORDER_NONE);
    291 		rules[EGL_NATIVE_VISUAL_TYPE]		= AttribRule(EGL_NATIVE_VISUAL_TYPE,		EGL_DONT_CARE,		CRITERIA_EXACT,		SORTORDER_SPECIAL);	//	10
    292 		rules[EGL_RENDERABLE_TYPE]			= AttribRule(EGL_RENDERABLE_TYPE,			EGL_OPENGL_ES_BIT,	CRITERIA_MASK,		SORTORDER_NONE);
    293 		rules[EGL_SAMPLE_BUFFERS]			= AttribRule(EGL_SAMPLE_BUFFERS,			0,					CRITERIA_AT_LEAST,	SORTORDER_SMALLER);	//	5
    294 		rules[EGL_SAMPLES]					= AttribRule(EGL_SAMPLES,					0,					CRITERIA_AT_LEAST,	SORTORDER_SMALLER);	//	6
    295 		rules[EGL_STENCIL_SIZE]				= AttribRule(EGL_STENCIL_SIZE,				0,					CRITERIA_AT_LEAST,	SORTORDER_SMALLER);	//	8
    296 		rules[EGL_SURFACE_TYPE]				= AttribRule(EGL_SURFACE_TYPE,				EGL_WINDOW_BIT,		CRITERIA_MASK,		SORTORDER_NONE);
    297 		rules[EGL_TRANSPARENT_TYPE]			= AttribRule(EGL_TRANSPARENT_TYPE,			EGL_NONE,			CRITERIA_EXACT,		SORTORDER_NONE);
    298 		rules[EGL_TRANSPARENT_RED_VALUE]	= AttribRule(EGL_TRANSPARENT_RED_VALUE,		EGL_DONT_CARE,		CRITERIA_EXACT,		SORTORDER_NONE);
    299 		rules[EGL_TRANSPARENT_GREEN_VALUE]	= AttribRule(EGL_TRANSPARENT_GREEN_VALUE,	EGL_DONT_CARE,		CRITERIA_EXACT,		SORTORDER_NONE);
    300 		rules[EGL_TRANSPARENT_BLUE_VALUE]	= AttribRule(EGL_TRANSPARENT_BLUE_VALUE,	EGL_DONT_CARE,		CRITERIA_EXACT,		SORTORDER_NONE);
    301 
    302 		// EGL_EXT_yuv_surface
    303 		rules[EGL_YUV_ORDER_EXT]			= AttribRule(EGL_YUV_ORDER_EXT,				EGL_DONT_CARE,		CRITERIA_EXACT,		SORTORDER_SPECIAL);
    304 		rules[EGL_YUV_NUMBER_OF_PLANES_EXT]	= AttribRule(EGL_YUV_NUMBER_OF_PLANES_EXT,	EGL_DONT_CARE,		CRITERIA_EXACT,		SORTORDER_NONE);
    305 		rules[EGL_YUV_SUBSAMPLE_EXT]		= AttribRule(EGL_YUV_SUBSAMPLE_EXT,			EGL_DONT_CARE,		CRITERIA_EXACT,		SORTORDER_NONE);
    306 		rules[EGL_YUV_DEPTH_RANGE_EXT]		= AttribRule(EGL_YUV_DEPTH_RANGE_EXT,		EGL_DONT_CARE,		CRITERIA_EXACT,		SORTORDER_NONE);
    307 		rules[EGL_YUV_CSC_STANDARD_EXT]		= AttribRule(EGL_YUV_CSC_STANDARD_EXT,		EGL_DONT_CARE,		CRITERIA_EXACT,		SORTORDER_NONE);
    308 		rules[EGL_YUV_PLANE_BPP_EXT]		= AttribRule(EGL_YUV_PLANE_BPP_EXT,			EGL_DONT_CARE,		CRITERIA_AT_LEAST,	SORTORDER_SPECIAL);	//	3
    309 
    310 		return rules;
    311 	}
    312 private:
    313 	EGLConfig m_config;
    314 	ConfigInfo m_info;
    315 };
    316 
    317 class CompareConfigs
    318 {
    319 public:
    320 	CompareConfigs (const tcu::BVec4& specifiedRGBColors, const tcu::BVec2& specifiedLuminanceColors, bool yuvPlaneBppSpecified)
    321 		: m_specifiedRGBColors			(specifiedRGBColors)
    322 		, m_specifiedLuminanceColors	(specifiedLuminanceColors)
    323 		, m_yuvPlaneBppSpecified		(yuvPlaneBppSpecified)
    324 	{
    325 	}
    326 
    327 	bool operator() (const SurfaceConfig& a, const SurfaceConfig& b)
    328 	{
    329 		return a.compareTo(b, m_specifiedRGBColors, m_specifiedLuminanceColors, m_yuvPlaneBppSpecified);
    330 	}
    331 
    332 private:
    333 	const tcu::BVec4	m_specifiedRGBColors;
    334 	const tcu::BVec2	m_specifiedLuminanceColors;
    335 	const bool			m_yuvPlaneBppSpecified;
    336 };
    337 
    338 class ConfigFilter
    339 {
    340 private:
    341 	std::map<EGLenum, AttribRule> m_rules;
    342 public:
    343 	ConfigFilter ()
    344 		: m_rules(SurfaceConfig::getDefaultRules())
    345 	{
    346 	}
    347 
    348 	void setValue (EGLenum name, EGLint value)
    349 	{
    350 		DE_ASSERT(de::contains(m_rules, name));
    351 		m_rules[name].value = value;
    352 	}
    353 
    354 	void setValues (std::vector<std::pair<EGLenum, EGLint> > values)
    355 	{
    356 		for (size_t ndx = 0; ndx < values.size(); ndx++)
    357 		{
    358 			const EGLenum	name	= values[ndx].first;
    359 			const EGLint	value	= values[ndx].second;
    360 
    361 			setValue(name, value);
    362 		}
    363 	}
    364 
    365 	AttribRule getAttribute (EGLenum name) const
    366 	{
    367 		DE_ASSERT(de::contains(m_rules, name));
    368 		return m_rules.find(name)->second;
    369 	}
    370 
    371 	bool isMatch (const SurfaceConfig& config) const
    372 	{
    373 		for (std::map<EGLenum, AttribRule>::const_iterator iter = m_rules.begin(); iter != m_rules.end(); iter++)
    374 		{
    375 			const AttribRule rule = iter->second;
    376 
    377 			if (rule.value == EGL_DONT_CARE)
    378 				continue;
    379 			else if (rule.name == EGL_MATCH_NATIVE_PIXMAP)
    380 				TCU_CHECK(rule.value == EGL_NONE); // Not supported
    381 			else if (rule.name == EGL_TRANSPARENT_RED_VALUE || rule.name == EGL_TRANSPARENT_GREEN_VALUE || rule.name == EGL_TRANSPARENT_BLUE_VALUE)
    382 				continue;
    383 			else
    384 			{
    385 				const EGLint cfgValue = config.getAttribute(rule.name);
    386 
    387 				switch (rule.criteria)
    388 				{
    389 					case CRITERIA_EXACT:
    390 						if (rule.value != cfgValue)
    391 							return false;
    392 						break;
    393 
    394 					case CRITERIA_AT_LEAST:
    395 						if (rule.value > cfgValue)
    396 							return false;
    397 						break;
    398 
    399 					case CRITERIA_MASK:
    400 						if ((rule.value & cfgValue) != rule.value)
    401 							return false;
    402 						break;
    403 
    404 					default:
    405 						TCU_FAIL("Unknown criteria");
    406 				}
    407 			}
    408 		}
    409 
    410 		return true;
    411 	}
    412 
    413 	tcu::BVec4 getSpecifiedRGBColors (void) const
    414 	{
    415 		const EGLenum bitAttribs[] =
    416 		{
    417 			EGL_RED_SIZE,
    418 			EGL_GREEN_SIZE,
    419 			EGL_BLUE_SIZE,
    420 			EGL_ALPHA_SIZE
    421 		};
    422 
    423 		tcu::BVec4 result;
    424 
    425 		for (int ndx = 0; ndx < DE_LENGTH_OF_ARRAY(bitAttribs); ndx++)
    426 		{
    427 			const EGLenum	attrib	= bitAttribs[ndx];
    428 			const EGLint	value	= getAttribute(attrib).value;
    429 
    430 			if (value != 0 && value != EGL_DONT_CARE)
    431 				result[ndx] = true;
    432 			else
    433 				result[ndx] = false;
    434 		}
    435 
    436 		return result;
    437 	}
    438 
    439 	tcu::BVec2 getSpecifiedLuminanceColors (void) const
    440 	{
    441 		const EGLenum bitAttribs[] =
    442 		{
    443 			EGL_LUMINANCE_SIZE,
    444 			EGL_ALPHA_SIZE
    445 		};
    446 
    447 		tcu::BVec2 result;
    448 
    449 		for (int ndx = 0; ndx < DE_LENGTH_OF_ARRAY(bitAttribs); ndx++)
    450 		{
    451 			const EGLenum	attrib	= bitAttribs[ndx];
    452 			const EGLint	value	= getAttribute(attrib).value;
    453 
    454 			if (value != 0 && value != EGL_DONT_CARE)
    455 				result[ndx] = true;
    456 			else
    457 				result[ndx] = false;
    458 		}
    459 
    460 		return result;
    461 	}
    462 
    463 	bool isYuvPlaneBppSpecified (void) const
    464 	{
    465 		const EGLenum	attrib	= EGL_YUV_PLANE_BPP_EXT;
    466 		const EGLint	value	= getAttribute(attrib).value;
    467 
    468 		return (value != 0) && (value != EGL_DONT_CARE);
    469 	}
    470 
    471 	std::vector<SurfaceConfig> filter (const std::vector<SurfaceConfig>& configs) const
    472 	{
    473 		std::vector<SurfaceConfig> out;
    474 
    475 		for (std::vector<SurfaceConfig>::const_iterator iter = configs.begin(); iter != configs.end(); iter++)
    476 		{
    477 			if (isMatch(*iter)) out.push_back(*iter);
    478 		}
    479 
    480 		return out;
    481 	}
    482 };
    483 
    484 void chooseConfigReference (const Library& egl, EGLDisplay display, std::vector<EGLConfig>& dst, const std::vector<std::pair<EGLenum, EGLint> >& attributes)
    485 {
    486 	// Get all configs
    487 	std::vector<EGLConfig> eglConfigs = eglu::getConfigs(egl, display);
    488 
    489 	// Config infos - including extension attributes
    490 	std::vector<ConfigInfo> configInfos;
    491 	configInfos.resize(eglConfigs.size());
    492 
    493 	for (size_t ndx = 0; ndx < eglConfigs.size(); ndx++)
    494 	{
    495 		eglu::queryCoreConfigInfo(egl, display, eglConfigs[ndx], &configInfos[ndx]);
    496 		eglu::queryExtConfigInfo(egl, display, eglConfigs[ndx], &configInfos[ndx]);
    497 	}
    498 
    499 	// Pair configs with info
    500 	std::vector<SurfaceConfig> configs;
    501 	for (size_t ndx = 0; ndx < eglConfigs.size(); ndx++)
    502 		configs.push_back(SurfaceConfig(eglConfigs[ndx], configInfos[ndx]));
    503 
    504 	// Filter configs
    505 	ConfigFilter configFilter;
    506 	configFilter.setValues(attributes);
    507 
    508 	std::vector<SurfaceConfig> filteredConfigs = configFilter.filter(configs);
    509 
    510 	// Sort configs
    511 	std::sort(filteredConfigs.begin(), filteredConfigs.end(), CompareConfigs(configFilter.getSpecifiedRGBColors(), configFilter.getSpecifiedLuminanceColors(), configFilter.isYuvPlaneBppSpecified()));
    512 
    513 	// Write to dst list
    514 	dst.resize(filteredConfigs.size());
    515 	for (size_t ndx = 0; ndx < filteredConfigs.size(); ndx++)
    516 		dst[ndx] = filteredConfigs[ndx].getEglConfig();
    517 }
    518 
    519 } // egl
    520 } // deqp
    521