1 /*-------------------------------------------------------------------------
2  * drawElements Quality Program Tester Core
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 config dst->
22  *//*--------------------------------------------------------------------*/
23 
24 #include "egluConfigInfo.hpp"
25 #include "egluDefs.hpp"
26 #include "eglwLibrary.hpp"
27 #include "eglwEnums.hpp"
28 #include "egluUtil.hpp"
29 #include "deSTLUtil.hpp"
30 
31 namespace eglu
32 {
33 
34 using namespace eglw;
35 
getAttribute(deUint32 attribute) const36 deInt32 ConfigInfo::getAttribute (deUint32 attribute) const
37 {
38 	switch (attribute)
39 	{
40 		case EGL_BUFFER_SIZE:				return bufferSize;
41 		case EGL_RED_SIZE:					return redSize;
42 		case EGL_GREEN_SIZE:				return greenSize;
43 		case EGL_BLUE_SIZE:					return blueSize;
44 		case EGL_LUMINANCE_SIZE:			return luminanceSize;
45 		case EGL_ALPHA_SIZE:				return alphaSize;
46 		case EGL_ALPHA_MASK_SIZE:			return alphaMaskSize;
47 		case EGL_BIND_TO_TEXTURE_RGB:		return bindToTextureRGB;
48 		case EGL_BIND_TO_TEXTURE_RGBA:		return bindToTextureRGBA;
49 		case EGL_COLOR_BUFFER_TYPE:			return colorBufferType;
50 		case EGL_CONFIG_CAVEAT:				return configCaveat;
51 		case EGL_CONFIG_ID:					return configId;
52 		case EGL_CONFORMANT:				return conformant;
53 		case EGL_DEPTH_SIZE:				return depthSize;
54 		case EGL_LEVEL:						return level;
55 		case EGL_MAX_PBUFFER_WIDTH:			return maxPbufferWidth;
56 		case EGL_MAX_PBUFFER_HEIGHT:		return maxPbufferHeight;
57 		case EGL_MAX_SWAP_INTERVAL:			return maxSwapInterval;
58 		case EGL_MIN_SWAP_INTERVAL:			return minSwapInterval;
59 		case EGL_NATIVE_RENDERABLE:			return nativeRenderable;
60 		case EGL_NATIVE_VISUAL_ID:			return nativeVisualId;
61 		case EGL_NATIVE_VISUAL_TYPE:		return nativeVisualType;
62 		case EGL_RENDERABLE_TYPE:			return renderableType;
63 		case EGL_SAMPLE_BUFFERS:			return sampleBuffers;
64 		case EGL_SAMPLES:					return samples;
65 		case EGL_STENCIL_SIZE:				return stencilSize;
66 		case EGL_SURFACE_TYPE:				return surfaceType;
67 		case EGL_TRANSPARENT_TYPE:			return transparentType;
68 		case EGL_TRANSPARENT_RED_VALUE:		return transparentRedValue;
69 		case EGL_TRANSPARENT_GREEN_VALUE:	return transparentGreenValue;
70 		case EGL_TRANSPARENT_BLUE_VALUE:	return transparentBlueValue;
71 
72 		// EGL_EXT_yuv_surface
73 		case EGL_YUV_ORDER_EXT:				return yuvOrder;
74 		case EGL_YUV_NUMBER_OF_PLANES_EXT:	return yuvNumberOfPlanes;
75 		case EGL_YUV_SUBSAMPLE_EXT:			return yuvSubsample;
76 		case EGL_YUV_DEPTH_RANGE_EXT:		return yuvDepthRange;
77 		case EGL_YUV_CSC_STANDARD_EXT:		return yuvCscStandard;
78 		case EGL_YUV_PLANE_BPP_EXT:			return yuvPlaneBpp;
79 
80 		// EGL_EXT_pixel_format_float
81 		case EGL_COLOR_COMPONENT_TYPE_EXT:	return colorComponentType;
82 
83 		default:							TCU_THROW(InternalError, "Unknown attribute");
84 	}
85 }
86 
queryCoreConfigInfo(const Library & egl,EGLDisplay display,EGLConfig config,ConfigInfo * dst)87 void queryCoreConfigInfo (const Library& egl, EGLDisplay display, EGLConfig config, ConfigInfo* dst)
88 {
89 	egl.getConfigAttrib(display, config, EGL_BUFFER_SIZE,				&dst->bufferSize);
90 	egl.getConfigAttrib(display, config, EGL_RED_SIZE,					&dst->redSize);
91 	egl.getConfigAttrib(display, config, EGL_GREEN_SIZE,				&dst->greenSize);
92 	egl.getConfigAttrib(display, config, EGL_BLUE_SIZE,					&dst->blueSize);
93 	egl.getConfigAttrib(display, config, EGL_LUMINANCE_SIZE,			&dst->luminanceSize);
94 	egl.getConfigAttrib(display, config, EGL_ALPHA_SIZE,				&dst->alphaSize);
95 	egl.getConfigAttrib(display, config, EGL_ALPHA_MASK_SIZE,			&dst->alphaMaskSize);
96 	egl.getConfigAttrib(display, config, EGL_BIND_TO_TEXTURE_RGB,		(EGLint*)&dst->bindToTextureRGB);
97 	egl.getConfigAttrib(display, config, EGL_BIND_TO_TEXTURE_RGBA,		(EGLint*)&dst->bindToTextureRGBA);
98 	egl.getConfigAttrib(display, config, EGL_COLOR_BUFFER_TYPE,			(EGLint*)&dst->colorBufferType);
99 	egl.getConfigAttrib(display, config, EGL_CONFIG_CAVEAT,				(EGLint*)&dst->configCaveat);
100 	egl.getConfigAttrib(display, config, EGL_CONFIG_ID,					&dst->configId);
101 	egl.getConfigAttrib(display, config, EGL_CONFORMANT,				&dst->conformant);
102 	egl.getConfigAttrib(display, config, EGL_DEPTH_SIZE,				&dst->depthSize);
103 	egl.getConfigAttrib(display, config, EGL_LEVEL,						&dst->level);
104 	egl.getConfigAttrib(display, config, EGL_MAX_PBUFFER_WIDTH,			&dst->maxPbufferWidth);
105 	egl.getConfigAttrib(display, config, EGL_MAX_PBUFFER_HEIGHT,		&dst->maxPbufferHeight);
106 	egl.getConfigAttrib(display, config, EGL_MAX_SWAP_INTERVAL,			&dst->maxSwapInterval);
107 	egl.getConfigAttrib(display, config, EGL_MIN_SWAP_INTERVAL,			&dst->minSwapInterval);
108 	egl.getConfigAttrib(display, config, EGL_NATIVE_RENDERABLE,			(EGLint*)&dst->nativeRenderable);
109 	egl.getConfigAttrib(display, config, EGL_NATIVE_VISUAL_ID,			&dst->nativeVisualId);
110 	egl.getConfigAttrib(display, config, EGL_NATIVE_VISUAL_TYPE,		&dst->nativeVisualType);
111 	egl.getConfigAttrib(display, config, EGL_RENDERABLE_TYPE,			&dst->renderableType);
112 	egl.getConfigAttrib(display, config, EGL_SAMPLE_BUFFERS,			&dst->sampleBuffers);
113 	egl.getConfigAttrib(display, config, EGL_SAMPLES,					&dst->samples);
114 	egl.getConfigAttrib(display, config, EGL_STENCIL_SIZE,				&dst->stencilSize);
115 	egl.getConfigAttrib(display, config, EGL_SURFACE_TYPE,				&dst->surfaceType);
116 	egl.getConfigAttrib(display, config, EGL_TRANSPARENT_TYPE,			(EGLint*)&dst->transparentType);
117 	egl.getConfigAttrib(display, config, EGL_TRANSPARENT_RED_VALUE,		&dst->transparentRedValue);
118 	egl.getConfigAttrib(display, config, EGL_TRANSPARENT_GREEN_VALUE,	&dst->transparentGreenValue);
119 	egl.getConfigAttrib(display, config, EGL_TRANSPARENT_BLUE_VALUE,	&dst->transparentBlueValue);
120 	EGLU_CHECK_MSG(egl, "Failed to query config info");
121 }
122 
queryExtConfigInfo(const eglw::Library & egl,eglw::EGLDisplay display,eglw::EGLConfig config,ConfigInfo * dst)123 void queryExtConfigInfo (const eglw::Library& egl, eglw::EGLDisplay display, eglw::EGLConfig config, ConfigInfo* dst)
124 {
125 	const std::vector<std::string>	extensions	= getDisplayExtensions(egl, display);
126 
127 	if (de::contains(extensions.begin(), extensions.end(), "EGL_EXT_yuv_surface"))
128 	{
129 		egl.getConfigAttrib(display, config, EGL_YUV_ORDER_EXT,				(EGLint*)&dst->yuvOrder);
130 		egl.getConfigAttrib(display, config, EGL_YUV_NUMBER_OF_PLANES_EXT,	(EGLint*)&dst->yuvNumberOfPlanes);
131 		egl.getConfigAttrib(display, config, EGL_YUV_SUBSAMPLE_EXT,			(EGLint*)&dst->yuvSubsample);
132 		egl.getConfigAttrib(display, config, EGL_YUV_DEPTH_RANGE_EXT,		(EGLint*)&dst->yuvDepthRange);
133 		egl.getConfigAttrib(display, config, EGL_YUV_CSC_STANDARD_EXT,		(EGLint*)&dst->yuvCscStandard);
134 		egl.getConfigAttrib(display, config, EGL_YUV_PLANE_BPP_EXT,			(EGLint*)&dst->yuvPlaneBpp);
135 
136 		EGLU_CHECK_MSG(egl, "Failed to query EGL_EXT_yuv_surface config attribs");
137 	}
138 
139 	if (de::contains(extensions.begin(), extensions.end(), "EGL_EXT_pixel_format_float"))
140 	{
141 		egl.getConfigAttrib(display, config, EGL_COLOR_COMPONENT_TYPE_EXT,	(EGLint*)&dst->colorComponentType);
142 
143 		EGLU_CHECK_MSG(egl, "Failed to query EGL_EXT_pixel_format_float config attribs");
144 	}
145 	else
146 		dst->colorComponentType = EGL_COLOR_COMPONENT_TYPE_FIXED_EXT;
147 }
148 
149 } // eglu
150