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 // EGL_ANDROID_recordable
84 case EGL_RECORDABLE_ANDROID: return recordableAndroid;
85
86 default: TCU_THROW(InternalError, "Unknown attribute");
87 }
88 }
89
queryCoreConfigInfo(const Library & egl,EGLDisplay display,EGLConfig config,ConfigInfo * dst)90 void queryCoreConfigInfo (const Library& egl, EGLDisplay display, EGLConfig config, ConfigInfo* dst)
91 {
92 egl.getConfigAttrib(display, config, EGL_BUFFER_SIZE, &dst->bufferSize);
93 egl.getConfigAttrib(display, config, EGL_RED_SIZE, &dst->redSize);
94 egl.getConfigAttrib(display, config, EGL_GREEN_SIZE, &dst->greenSize);
95 egl.getConfigAttrib(display, config, EGL_BLUE_SIZE, &dst->blueSize);
96 egl.getConfigAttrib(display, config, EGL_LUMINANCE_SIZE, &dst->luminanceSize);
97 egl.getConfigAttrib(display, config, EGL_ALPHA_SIZE, &dst->alphaSize);
98 egl.getConfigAttrib(display, config, EGL_ALPHA_MASK_SIZE, &dst->alphaMaskSize);
99 egl.getConfigAttrib(display, config, EGL_BIND_TO_TEXTURE_RGB, (EGLint*)&dst->bindToTextureRGB);
100 egl.getConfigAttrib(display, config, EGL_BIND_TO_TEXTURE_RGBA, (EGLint*)&dst->bindToTextureRGBA);
101 egl.getConfigAttrib(display, config, EGL_COLOR_BUFFER_TYPE, (EGLint*)&dst->colorBufferType);
102 egl.getConfigAttrib(display, config, EGL_CONFIG_CAVEAT, (EGLint*)&dst->configCaveat);
103 egl.getConfigAttrib(display, config, EGL_CONFIG_ID, &dst->configId);
104 egl.getConfigAttrib(display, config, EGL_CONFORMANT, &dst->conformant);
105 egl.getConfigAttrib(display, config, EGL_DEPTH_SIZE, &dst->depthSize);
106 egl.getConfigAttrib(display, config, EGL_LEVEL, &dst->level);
107 egl.getConfigAttrib(display, config, EGL_MAX_PBUFFER_WIDTH, &dst->maxPbufferWidth);
108 egl.getConfigAttrib(display, config, EGL_MAX_PBUFFER_HEIGHT, &dst->maxPbufferHeight);
109 egl.getConfigAttrib(display, config, EGL_MAX_SWAP_INTERVAL, &dst->maxSwapInterval);
110 egl.getConfigAttrib(display, config, EGL_MIN_SWAP_INTERVAL, &dst->minSwapInterval);
111 egl.getConfigAttrib(display, config, EGL_NATIVE_RENDERABLE, (EGLint*)&dst->nativeRenderable);
112 egl.getConfigAttrib(display, config, EGL_NATIVE_VISUAL_ID, &dst->nativeVisualId);
113 egl.getConfigAttrib(display, config, EGL_NATIVE_VISUAL_TYPE, &dst->nativeVisualType);
114 egl.getConfigAttrib(display, config, EGL_RENDERABLE_TYPE, &dst->renderableType);
115 egl.getConfigAttrib(display, config, EGL_SAMPLE_BUFFERS, &dst->sampleBuffers);
116 egl.getConfigAttrib(display, config, EGL_SAMPLES, &dst->samples);
117 egl.getConfigAttrib(display, config, EGL_STENCIL_SIZE, &dst->stencilSize);
118 egl.getConfigAttrib(display, config, EGL_SURFACE_TYPE, &dst->surfaceType);
119 egl.getConfigAttrib(display, config, EGL_TRANSPARENT_TYPE, (EGLint*)&dst->transparentType);
120 egl.getConfigAttrib(display, config, EGL_TRANSPARENT_RED_VALUE, &dst->transparentRedValue);
121 egl.getConfigAttrib(display, config, EGL_TRANSPARENT_GREEN_VALUE, &dst->transparentGreenValue);
122 egl.getConfigAttrib(display, config, EGL_TRANSPARENT_BLUE_VALUE, &dst->transparentBlueValue);
123 EGLU_CHECK_MSG(egl, "Failed to query config info");
124 }
125
queryExtConfigInfo(const eglw::Library & egl,eglw::EGLDisplay display,eglw::EGLConfig config,ConfigInfo * dst)126 void queryExtConfigInfo (const eglw::Library& egl, eglw::EGLDisplay display, eglw::EGLConfig config, ConfigInfo* dst)
127 {
128 const std::vector<std::string> extensions = getDisplayExtensions(egl, display);
129
130 if (de::contains(extensions.begin(), extensions.end(), "EGL_EXT_yuv_surface"))
131 {
132 egl.getConfigAttrib(display, config, EGL_YUV_ORDER_EXT, (EGLint*)&dst->yuvOrder);
133 egl.getConfigAttrib(display, config, EGL_YUV_NUMBER_OF_PLANES_EXT, (EGLint*)&dst->yuvNumberOfPlanes);
134 egl.getConfigAttrib(display, config, EGL_YUV_SUBSAMPLE_EXT, (EGLint*)&dst->yuvSubsample);
135 egl.getConfigAttrib(display, config, EGL_YUV_DEPTH_RANGE_EXT, (EGLint*)&dst->yuvDepthRange);
136 egl.getConfigAttrib(display, config, EGL_YUV_CSC_STANDARD_EXT, (EGLint*)&dst->yuvCscStandard);
137 egl.getConfigAttrib(display, config, EGL_YUV_PLANE_BPP_EXT, (EGLint*)&dst->yuvPlaneBpp);
138
139 EGLU_CHECK_MSG(egl, "Failed to query EGL_EXT_yuv_surface config attribs");
140 }
141
142 if (de::contains(extensions.begin(), extensions.end(), "EGL_ANDROID_recordable"))
143 {
144 egl.getConfigAttrib(display, config, EGL_RECORDABLE_ANDROID, (EGLint*)&dst->recordableAndroid);
145
146 EGLU_CHECK_MSG(egl, "Failed to query EGL_ANDROID_recordable config attribs");
147 }
148
149 if (de::contains(extensions.begin(), extensions.end(), "EGL_EXT_pixel_format_float"))
150 {
151 egl.getConfigAttrib(display, config, EGL_COLOR_COMPONENT_TYPE_EXT, (EGLint*)&dst->colorComponentType);
152
153 EGLU_CHECK_MSG(egl, "Failed to query EGL_EXT_pixel_format_float config attribs");
154 }
155 else
156 dst->colorComponentType = EGL_COLOR_COMPONENT_TYPE_FIXED_EXT;
157 }
158
159 } // eglu
160