Merge gerrit/vulkan-cts-1.0.1 into gerrit/vulkan-cts-1.0-dev
[platform/upstream/VK-GL-CTS.git] / framework / egl / egluConfigInfo.cpp
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
36 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                 default:                                                        TCU_THROW(InternalError, "Unknown attribute");
81         }
82 }
83
84 void queryCoreConfigInfo (const Library& egl, EGLDisplay display, EGLConfig config, ConfigInfo* dst)
85 {
86         egl.getConfigAttrib(display, config, EGL_BUFFER_SIZE,                           &dst->bufferSize);
87         egl.getConfigAttrib(display, config, EGL_RED_SIZE,                                      &dst->redSize);
88         egl.getConfigAttrib(display, config, EGL_GREEN_SIZE,                            &dst->greenSize);
89         egl.getConfigAttrib(display, config, EGL_BLUE_SIZE,                                     &dst->blueSize);
90         egl.getConfigAttrib(display, config, EGL_LUMINANCE_SIZE,                        &dst->luminanceSize);
91         egl.getConfigAttrib(display, config, EGL_ALPHA_SIZE,                            &dst->alphaSize);
92         egl.getConfigAttrib(display, config, EGL_ALPHA_MASK_SIZE,                       &dst->alphaMaskSize);
93         egl.getConfigAttrib(display, config, EGL_BIND_TO_TEXTURE_RGB,           (EGLint*)&dst->bindToTextureRGB);
94         egl.getConfigAttrib(display, config, EGL_BIND_TO_TEXTURE_RGBA,          (EGLint*)&dst->bindToTextureRGBA);
95         egl.getConfigAttrib(display, config, EGL_COLOR_BUFFER_TYPE,                     (EGLint*)&dst->colorBufferType);
96         egl.getConfigAttrib(display, config, EGL_CONFIG_CAVEAT,                         (EGLint*)&dst->configCaveat);
97         egl.getConfigAttrib(display, config, EGL_CONFIG_ID,                                     &dst->configId);
98         egl.getConfigAttrib(display, config, EGL_CONFORMANT,                            &dst->conformant);
99         egl.getConfigAttrib(display, config, EGL_DEPTH_SIZE,                            &dst->depthSize);
100         egl.getConfigAttrib(display, config, EGL_LEVEL,                                         &dst->level);
101         egl.getConfigAttrib(display, config, EGL_MAX_PBUFFER_WIDTH,                     &dst->maxPbufferWidth);
102         egl.getConfigAttrib(display, config, EGL_MAX_PBUFFER_HEIGHT,            &dst->maxPbufferHeight);
103         egl.getConfigAttrib(display, config, EGL_MAX_SWAP_INTERVAL,                     &dst->maxSwapInterval);
104         egl.getConfigAttrib(display, config, EGL_MIN_SWAP_INTERVAL,                     &dst->minSwapInterval);
105         egl.getConfigAttrib(display, config, EGL_NATIVE_RENDERABLE,                     (EGLint*)&dst->nativeRenderable);
106         egl.getConfigAttrib(display, config, EGL_NATIVE_VISUAL_ID,                      &dst->nativeVisualId);
107         egl.getConfigAttrib(display, config, EGL_NATIVE_VISUAL_TYPE,            &dst->nativeVisualType);
108         egl.getConfigAttrib(display, config, EGL_RENDERABLE_TYPE,                       &dst->renderableType);
109         egl.getConfigAttrib(display, config, EGL_SAMPLE_BUFFERS,                        &dst->sampleBuffers);
110         egl.getConfigAttrib(display, config, EGL_SAMPLES,                                       &dst->samples);
111         egl.getConfigAttrib(display, config, EGL_STENCIL_SIZE,                          &dst->stencilSize);
112         egl.getConfigAttrib(display, config, EGL_SURFACE_TYPE,                          &dst->surfaceType);
113         egl.getConfigAttrib(display, config, EGL_TRANSPARENT_TYPE,                      (EGLint*)&dst->transparentType);
114         egl.getConfigAttrib(display, config, EGL_TRANSPARENT_RED_VALUE,         &dst->transparentRedValue);
115         egl.getConfigAttrib(display, config, EGL_TRANSPARENT_GREEN_VALUE,       &dst->transparentGreenValue);
116         egl.getConfigAttrib(display, config, EGL_TRANSPARENT_BLUE_VALUE,        &dst->transparentBlueValue);
117         EGLU_CHECK_MSG(egl, "Failed to query config info");
118 }
119
120 void queryExtConfigInfo (const eglw::Library& egl, eglw::EGLDisplay display, eglw::EGLConfig config, ConfigInfo* dst)
121 {
122         const std::vector<std::string>  extensions      = getDisplayExtensions(egl, display);
123
124         if (de::contains(extensions.begin(), extensions.end(), "EGL_EXT_yuv_surface"))
125         {
126                 egl.getConfigAttrib(display, config, EGL_YUV_ORDER_EXT,                         (EGLint*)&dst->yuvOrder);
127                 egl.getConfigAttrib(display, config, EGL_YUV_NUMBER_OF_PLANES_EXT,      (EGLint*)&dst->yuvNumberOfPlanes);
128                 egl.getConfigAttrib(display, config, EGL_YUV_SUBSAMPLE_EXT,                     (EGLint*)&dst->yuvSubsample);
129                 egl.getConfigAttrib(display, config, EGL_YUV_DEPTH_RANGE_EXT,           (EGLint*)&dst->yuvDepthRange);
130                 egl.getConfigAttrib(display, config, EGL_YUV_CSC_STANDARD_EXT,          (EGLint*)&dst->yuvCscStandard);
131                 egl.getConfigAttrib(display, config, EGL_YUV_PLANE_BPP_EXT,                     (EGLint*)&dst->yuvPlaneBpp);
132
133                 EGLU_CHECK_MSG(egl, "Failed to query EGL_EXT_yuv_surface config attribs");
134         }
135 }
136
137 } // eglu