13c827367444ee418f129b2c238299f49d3264554Jarkko Poyry/*-------------------------------------------------------------------------
23c827367444ee418f129b2c238299f49d3264554Jarkko Poyry * drawElements Quality Program Tester Core
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 EGL config dst->
223c827367444ee418f129b2c238299f49d3264554Jarkko Poyry *//*--------------------------------------------------------------------*/
233c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
243c827367444ee418f129b2c238299f49d3264554Jarkko Poyry#include "egluConfigInfo.hpp"
253c827367444ee418f129b2c238299f49d3264554Jarkko Poyry#include "egluDefs.hpp"
263c67e4f0ec73f9c30c6b2ed2adfbfe7faaf576a4Pyry Haulos#include "eglwLibrary.hpp"
273c67e4f0ec73f9c30c6b2ed2adfbfe7faaf576a4Pyry Haulos#include "eglwEnums.hpp"
28baea2158190b91fcf5d1aa78628dbad01d52a3cePyry Haulos#include "egluUtil.hpp"
29baea2158190b91fcf5d1aa78628dbad01d52a3cePyry Haulos#include "deSTLUtil.hpp"
303c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
313c827367444ee418f129b2c238299f49d3264554Jarkko Poyrynamespace eglu
323c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{
333c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
343c67e4f0ec73f9c30c6b2ed2adfbfe7faaf576a4Pyry Haulosusing namespace eglw;
353c67e4f0ec73f9c30c6b2ed2adfbfe7faaf576a4Pyry Haulos
363c827367444ee418f129b2c238299f49d3264554Jarkko PoyrydeInt32 ConfigInfo::getAttribute (deUint32 attribute) const
373c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{
383c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	switch (attribute)
393c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	{
403c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		case EGL_BUFFER_SIZE:				return bufferSize;
413c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		case EGL_RED_SIZE:					return redSize;
423c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		case EGL_GREEN_SIZE:				return greenSize;
433c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		case EGL_BLUE_SIZE:					return blueSize;
443c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		case EGL_LUMINANCE_SIZE:			return luminanceSize;
453c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		case EGL_ALPHA_SIZE:				return alphaSize;
463c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		case EGL_ALPHA_MASK_SIZE:			return alphaMaskSize;
473c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		case EGL_BIND_TO_TEXTURE_RGB:		return bindToTextureRGB;
483c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		case EGL_BIND_TO_TEXTURE_RGBA:		return bindToTextureRGBA;
493c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		case EGL_COLOR_BUFFER_TYPE:			return colorBufferType;
503c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		case EGL_CONFIG_CAVEAT:				return configCaveat;
513c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		case EGL_CONFIG_ID:					return configId;
523c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		case EGL_CONFORMANT:				return conformant;
533c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		case EGL_DEPTH_SIZE:				return depthSize;
543c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		case EGL_LEVEL:						return level;
553c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		case EGL_MAX_PBUFFER_WIDTH:			return maxPbufferWidth;
563c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		case EGL_MAX_PBUFFER_HEIGHT:		return maxPbufferHeight;
573c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		case EGL_MAX_SWAP_INTERVAL:			return maxSwapInterval;
583c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		case EGL_MIN_SWAP_INTERVAL:			return minSwapInterval;
593c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		case EGL_NATIVE_RENDERABLE:			return nativeRenderable;
603c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		case EGL_NATIVE_VISUAL_ID:			return nativeVisualId;
613c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		case EGL_NATIVE_VISUAL_TYPE:		return nativeVisualType;
623c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		case EGL_RENDERABLE_TYPE:			return renderableType;
633c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		case EGL_SAMPLE_BUFFERS:			return sampleBuffers;
643c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		case EGL_SAMPLES:					return samples;
653c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		case EGL_STENCIL_SIZE:				return stencilSize;
663c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		case EGL_SURFACE_TYPE:				return surfaceType;
673c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		case EGL_TRANSPARENT_TYPE:			return transparentType;
683c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		case EGL_TRANSPARENT_RED_VALUE:		return transparentRedValue;
693c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		case EGL_TRANSPARENT_GREEN_VALUE:	return transparentGreenValue;
703c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		case EGL_TRANSPARENT_BLUE_VALUE:	return transparentBlueValue;
71baea2158190b91fcf5d1aa78628dbad01d52a3cePyry Haulos
72baea2158190b91fcf5d1aa78628dbad01d52a3cePyry Haulos		// EGL_EXT_yuv_surface
73baea2158190b91fcf5d1aa78628dbad01d52a3cePyry Haulos		case EGL_YUV_ORDER_EXT:				return yuvOrder;
74baea2158190b91fcf5d1aa78628dbad01d52a3cePyry Haulos		case EGL_YUV_NUMBER_OF_PLANES_EXT:	return yuvNumberOfPlanes;
75baea2158190b91fcf5d1aa78628dbad01d52a3cePyry Haulos		case EGL_YUV_SUBSAMPLE_EXT:			return yuvSubsample;
76baea2158190b91fcf5d1aa78628dbad01d52a3cePyry Haulos		case EGL_YUV_DEPTH_RANGE_EXT:		return yuvDepthRange;
77baea2158190b91fcf5d1aa78628dbad01d52a3cePyry Haulos		case EGL_YUV_CSC_STANDARD_EXT:		return yuvCscStandard;
78baea2158190b91fcf5d1aa78628dbad01d52a3cePyry Haulos		case EGL_YUV_PLANE_BPP_EXT:			return yuvPlaneBpp;
79baea2158190b91fcf5d1aa78628dbad01d52a3cePyry Haulos
8008d24954e0c75c3e6a1d2ba231bd09915d5c7ecdMark Adams		// EGL_EXT_pixel_format_float
8108d24954e0c75c3e6a1d2ba231bd09915d5c7ecdMark Adams		case EGL_COLOR_COMPONENT_TYPE_EXT:	return colorComponentType;
8208d24954e0c75c3e6a1d2ba231bd09915d5c7ecdMark Adams
83baea2158190b91fcf5d1aa78628dbad01d52a3cePyry Haulos		default:							TCU_THROW(InternalError, "Unknown attribute");
843c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	}
853c827367444ee418f129b2c238299f49d3264554Jarkko Poyry}
863c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
87baea2158190b91fcf5d1aa78628dbad01d52a3cePyry Haulosvoid queryCoreConfigInfo (const Library& egl, EGLDisplay display, EGLConfig config, ConfigInfo* dst)
883c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{
893c67e4f0ec73f9c30c6b2ed2adfbfe7faaf576a4Pyry Haulos	egl.getConfigAttrib(display, config, EGL_BUFFER_SIZE,				&dst->bufferSize);
903c67e4f0ec73f9c30c6b2ed2adfbfe7faaf576a4Pyry Haulos	egl.getConfigAttrib(display, config, EGL_RED_SIZE,					&dst->redSize);
913c67e4f0ec73f9c30c6b2ed2adfbfe7faaf576a4Pyry Haulos	egl.getConfigAttrib(display, config, EGL_GREEN_SIZE,				&dst->greenSize);
923c67e4f0ec73f9c30c6b2ed2adfbfe7faaf576a4Pyry Haulos	egl.getConfigAttrib(display, config, EGL_BLUE_SIZE,					&dst->blueSize);
933c67e4f0ec73f9c30c6b2ed2adfbfe7faaf576a4Pyry Haulos	egl.getConfigAttrib(display, config, EGL_LUMINANCE_SIZE,			&dst->luminanceSize);
943c67e4f0ec73f9c30c6b2ed2adfbfe7faaf576a4Pyry Haulos	egl.getConfigAttrib(display, config, EGL_ALPHA_SIZE,				&dst->alphaSize);
953c67e4f0ec73f9c30c6b2ed2adfbfe7faaf576a4Pyry Haulos	egl.getConfigAttrib(display, config, EGL_ALPHA_MASK_SIZE,			&dst->alphaMaskSize);
963c67e4f0ec73f9c30c6b2ed2adfbfe7faaf576a4Pyry Haulos	egl.getConfigAttrib(display, config, EGL_BIND_TO_TEXTURE_RGB,		(EGLint*)&dst->bindToTextureRGB);
973c67e4f0ec73f9c30c6b2ed2adfbfe7faaf576a4Pyry Haulos	egl.getConfigAttrib(display, config, EGL_BIND_TO_TEXTURE_RGBA,		(EGLint*)&dst->bindToTextureRGBA);
983c67e4f0ec73f9c30c6b2ed2adfbfe7faaf576a4Pyry Haulos	egl.getConfigAttrib(display, config, EGL_COLOR_BUFFER_TYPE,			(EGLint*)&dst->colorBufferType);
993c67e4f0ec73f9c30c6b2ed2adfbfe7faaf576a4Pyry Haulos	egl.getConfigAttrib(display, config, EGL_CONFIG_CAVEAT,				(EGLint*)&dst->configCaveat);
1003c67e4f0ec73f9c30c6b2ed2adfbfe7faaf576a4Pyry Haulos	egl.getConfigAttrib(display, config, EGL_CONFIG_ID,					&dst->configId);
1013c67e4f0ec73f9c30c6b2ed2adfbfe7faaf576a4Pyry Haulos	egl.getConfigAttrib(display, config, EGL_CONFORMANT,				&dst->conformant);
1023c67e4f0ec73f9c30c6b2ed2adfbfe7faaf576a4Pyry Haulos	egl.getConfigAttrib(display, config, EGL_DEPTH_SIZE,				&dst->depthSize);
1033c67e4f0ec73f9c30c6b2ed2adfbfe7faaf576a4Pyry Haulos	egl.getConfigAttrib(display, config, EGL_LEVEL,						&dst->level);
1043c67e4f0ec73f9c30c6b2ed2adfbfe7faaf576a4Pyry Haulos	egl.getConfigAttrib(display, config, EGL_MAX_PBUFFER_WIDTH,			&dst->maxPbufferWidth);
1053c67e4f0ec73f9c30c6b2ed2adfbfe7faaf576a4Pyry Haulos	egl.getConfigAttrib(display, config, EGL_MAX_PBUFFER_HEIGHT,		&dst->maxPbufferHeight);
1063c67e4f0ec73f9c30c6b2ed2adfbfe7faaf576a4Pyry Haulos	egl.getConfigAttrib(display, config, EGL_MAX_SWAP_INTERVAL,			&dst->maxSwapInterval);
1073c67e4f0ec73f9c30c6b2ed2adfbfe7faaf576a4Pyry Haulos	egl.getConfigAttrib(display, config, EGL_MIN_SWAP_INTERVAL,			&dst->minSwapInterval);
1083c67e4f0ec73f9c30c6b2ed2adfbfe7faaf576a4Pyry Haulos	egl.getConfigAttrib(display, config, EGL_NATIVE_RENDERABLE,			(EGLint*)&dst->nativeRenderable);
1093c67e4f0ec73f9c30c6b2ed2adfbfe7faaf576a4Pyry Haulos	egl.getConfigAttrib(display, config, EGL_NATIVE_VISUAL_ID,			&dst->nativeVisualId);
1103c67e4f0ec73f9c30c6b2ed2adfbfe7faaf576a4Pyry Haulos	egl.getConfigAttrib(display, config, EGL_NATIVE_VISUAL_TYPE,		&dst->nativeVisualType);
1113c67e4f0ec73f9c30c6b2ed2adfbfe7faaf576a4Pyry Haulos	egl.getConfigAttrib(display, config, EGL_RENDERABLE_TYPE,			&dst->renderableType);
1123c67e4f0ec73f9c30c6b2ed2adfbfe7faaf576a4Pyry Haulos	egl.getConfigAttrib(display, config, EGL_SAMPLE_BUFFERS,			&dst->sampleBuffers);
1133c67e4f0ec73f9c30c6b2ed2adfbfe7faaf576a4Pyry Haulos	egl.getConfigAttrib(display, config, EGL_SAMPLES,					&dst->samples);
1143c67e4f0ec73f9c30c6b2ed2adfbfe7faaf576a4Pyry Haulos	egl.getConfigAttrib(display, config, EGL_STENCIL_SIZE,				&dst->stencilSize);
1153c67e4f0ec73f9c30c6b2ed2adfbfe7faaf576a4Pyry Haulos	egl.getConfigAttrib(display, config, EGL_SURFACE_TYPE,				&dst->surfaceType);
1163c67e4f0ec73f9c30c6b2ed2adfbfe7faaf576a4Pyry Haulos	egl.getConfigAttrib(display, config, EGL_TRANSPARENT_TYPE,			(EGLint*)&dst->transparentType);
1173c67e4f0ec73f9c30c6b2ed2adfbfe7faaf576a4Pyry Haulos	egl.getConfigAttrib(display, config, EGL_TRANSPARENT_RED_VALUE,		&dst->transparentRedValue);
1183c67e4f0ec73f9c30c6b2ed2adfbfe7faaf576a4Pyry Haulos	egl.getConfigAttrib(display, config, EGL_TRANSPARENT_GREEN_VALUE,	&dst->transparentGreenValue);
1193c67e4f0ec73f9c30c6b2ed2adfbfe7faaf576a4Pyry Haulos	egl.getConfigAttrib(display, config, EGL_TRANSPARENT_BLUE_VALUE,	&dst->transparentBlueValue);
1203c67e4f0ec73f9c30c6b2ed2adfbfe7faaf576a4Pyry Haulos	EGLU_CHECK_MSG(egl, "Failed to query config info");
1213c827367444ee418f129b2c238299f49d3264554Jarkko Poyry}
1223c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
123baea2158190b91fcf5d1aa78628dbad01d52a3cePyry Haulosvoid queryExtConfigInfo (const eglw::Library& egl, eglw::EGLDisplay display, eglw::EGLConfig config, ConfigInfo* dst)
124baea2158190b91fcf5d1aa78628dbad01d52a3cePyry Haulos{
125baea2158190b91fcf5d1aa78628dbad01d52a3cePyry Haulos	const std::vector<std::string>	extensions	= getDisplayExtensions(egl, display);
126baea2158190b91fcf5d1aa78628dbad01d52a3cePyry Haulos
127baea2158190b91fcf5d1aa78628dbad01d52a3cePyry Haulos	if (de::contains(extensions.begin(), extensions.end(), "EGL_EXT_yuv_surface"))
128baea2158190b91fcf5d1aa78628dbad01d52a3cePyry Haulos	{
129baea2158190b91fcf5d1aa78628dbad01d52a3cePyry Haulos		egl.getConfigAttrib(display, config, EGL_YUV_ORDER_EXT,				(EGLint*)&dst->yuvOrder);
130baea2158190b91fcf5d1aa78628dbad01d52a3cePyry Haulos		egl.getConfigAttrib(display, config, EGL_YUV_NUMBER_OF_PLANES_EXT,	(EGLint*)&dst->yuvNumberOfPlanes);
131baea2158190b91fcf5d1aa78628dbad01d52a3cePyry Haulos		egl.getConfigAttrib(display, config, EGL_YUV_SUBSAMPLE_EXT,			(EGLint*)&dst->yuvSubsample);
132baea2158190b91fcf5d1aa78628dbad01d52a3cePyry Haulos		egl.getConfigAttrib(display, config, EGL_YUV_DEPTH_RANGE_EXT,		(EGLint*)&dst->yuvDepthRange);
133baea2158190b91fcf5d1aa78628dbad01d52a3cePyry Haulos		egl.getConfigAttrib(display, config, EGL_YUV_CSC_STANDARD_EXT,		(EGLint*)&dst->yuvCscStandard);
134baea2158190b91fcf5d1aa78628dbad01d52a3cePyry Haulos		egl.getConfigAttrib(display, config, EGL_YUV_PLANE_BPP_EXT,			(EGLint*)&dst->yuvPlaneBpp);
135baea2158190b91fcf5d1aa78628dbad01d52a3cePyry Haulos
136baea2158190b91fcf5d1aa78628dbad01d52a3cePyry Haulos		EGLU_CHECK_MSG(egl, "Failed to query EGL_EXT_yuv_surface config attribs");
137baea2158190b91fcf5d1aa78628dbad01d52a3cePyry Haulos	}
13808d24954e0c75c3e6a1d2ba231bd09915d5c7ecdMark Adams
13908d24954e0c75c3e6a1d2ba231bd09915d5c7ecdMark Adams	if (de::contains(extensions.begin(), extensions.end(), "EGL_EXT_pixel_format_float"))
14008d24954e0c75c3e6a1d2ba231bd09915d5c7ecdMark Adams	{
14108d24954e0c75c3e6a1d2ba231bd09915d5c7ecdMark Adams		egl.getConfigAttrib(display, config, EGL_COLOR_COMPONENT_TYPE_EXT,	(EGLint*)&dst->colorComponentType);
14208d24954e0c75c3e6a1d2ba231bd09915d5c7ecdMark Adams
14308d24954e0c75c3e6a1d2ba231bd09915d5c7ecdMark Adams		EGLU_CHECK_MSG(egl, "Failed to query EGL_EXT_pixel_format_float config attribs");
14408d24954e0c75c3e6a1d2ba231bd09915d5c7ecdMark Adams	}
14508d24954e0c75c3e6a1d2ba231bd09915d5c7ecdMark Adams	else
14608d24954e0c75c3e6a1d2ba231bd09915d5c7ecdMark Adams		dst->colorComponentType = EGL_COLOR_COMPONENT_TYPE_FIXED_EXT;
147baea2158190b91fcf5d1aa78628dbad01d52a3cePyry Haulos}
148baea2158190b91fcf5d1aa78628dbad01d52a3cePyry Haulos
1493c827367444ee418f129b2c238299f49d3264554Jarkko Poyry} // eglu
150