xref: /aosp_15_r20/external/deqp/framework/egl/egluConfigInfo.cpp (revision 35238bce31c2a825756842865a792f8cf7f89930)
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(uint32_t attribute) const36 int32_t ConfigInfo::getAttribute(uint32_t attribute) const
37 {
38     switch (attribute)
39     {
40     case EGL_BUFFER_SIZE:
41         return bufferSize;
42     case EGL_RED_SIZE:
43         return redSize;
44     case EGL_GREEN_SIZE:
45         return greenSize;
46     case EGL_BLUE_SIZE:
47         return blueSize;
48     case EGL_LUMINANCE_SIZE:
49         return luminanceSize;
50     case EGL_ALPHA_SIZE:
51         return alphaSize;
52     case EGL_ALPHA_MASK_SIZE:
53         return alphaMaskSize;
54     case EGL_BIND_TO_TEXTURE_RGB:
55         return bindToTextureRGB;
56     case EGL_BIND_TO_TEXTURE_RGBA:
57         return bindToTextureRGBA;
58     case EGL_COLOR_BUFFER_TYPE:
59         return colorBufferType;
60     case EGL_CONFIG_CAVEAT:
61         return configCaveat;
62     case EGL_CONFIG_ID:
63         return configId;
64     case EGL_CONFORMANT:
65         return conformant;
66     case EGL_DEPTH_SIZE:
67         return depthSize;
68     case EGL_LEVEL:
69         return level;
70     case EGL_MAX_PBUFFER_WIDTH:
71         return maxPbufferWidth;
72     case EGL_MAX_PBUFFER_HEIGHT:
73         return maxPbufferHeight;
74     case EGL_MAX_SWAP_INTERVAL:
75         return maxSwapInterval;
76     case EGL_MIN_SWAP_INTERVAL:
77         return minSwapInterval;
78     case EGL_NATIVE_RENDERABLE:
79         return nativeRenderable;
80     case EGL_NATIVE_VISUAL_ID:
81         return nativeVisualId;
82     case EGL_NATIVE_VISUAL_TYPE:
83         return nativeVisualType;
84     case EGL_RENDERABLE_TYPE:
85         return renderableType;
86     case EGL_SAMPLE_BUFFERS:
87         return sampleBuffers;
88     case EGL_SAMPLES:
89         return samples;
90     case EGL_STENCIL_SIZE:
91         return stencilSize;
92     case EGL_SURFACE_TYPE:
93         return surfaceType;
94     case EGL_TRANSPARENT_TYPE:
95         return transparentType;
96     case EGL_TRANSPARENT_RED_VALUE:
97         return transparentRedValue;
98     case EGL_TRANSPARENT_GREEN_VALUE:
99         return transparentGreenValue;
100     case EGL_TRANSPARENT_BLUE_VALUE:
101         return transparentBlueValue;
102 
103     // EGL_EXT_yuv_surface
104     case EGL_YUV_ORDER_EXT:
105         return yuvOrder;
106     case EGL_YUV_NUMBER_OF_PLANES_EXT:
107         return yuvNumberOfPlanes;
108     case EGL_YUV_SUBSAMPLE_EXT:
109         return yuvSubsample;
110     case EGL_YUV_DEPTH_RANGE_EXT:
111         return yuvDepthRange;
112     case EGL_YUV_CSC_STANDARD_EXT:
113         return yuvCscStandard;
114     case EGL_YUV_PLANE_BPP_EXT:
115         return yuvPlaneBpp;
116 
117     // EGL_EXT_pixel_format_float
118     case EGL_COLOR_COMPONENT_TYPE_EXT:
119         return colorComponentType;
120 
121     // EGL_ANDROID_recordable
122     case EGL_RECORDABLE_ANDROID:
123         return recordableAndroid;
124 
125     default:
126         TCU_THROW(InternalError, "Unknown attribute");
127     }
128 }
129 
queryCoreConfigInfo(const Library & egl,EGLDisplay display,EGLConfig config,ConfigInfo * dst)130 void queryCoreConfigInfo(const Library &egl, EGLDisplay display, EGLConfig config, ConfigInfo *dst)
131 {
132     egl.getConfigAttrib(display, config, EGL_BUFFER_SIZE, &dst->bufferSize);
133     egl.getConfigAttrib(display, config, EGL_RED_SIZE, &dst->redSize);
134     egl.getConfigAttrib(display, config, EGL_GREEN_SIZE, &dst->greenSize);
135     egl.getConfigAttrib(display, config, EGL_BLUE_SIZE, &dst->blueSize);
136     egl.getConfigAttrib(display, config, EGL_LUMINANCE_SIZE, &dst->luminanceSize);
137     egl.getConfigAttrib(display, config, EGL_ALPHA_SIZE, &dst->alphaSize);
138     egl.getConfigAttrib(display, config, EGL_ALPHA_MASK_SIZE, &dst->alphaMaskSize);
139     egl.getConfigAttrib(display, config, EGL_BIND_TO_TEXTURE_RGB, (EGLint *)&dst->bindToTextureRGB);
140     egl.getConfigAttrib(display, config, EGL_BIND_TO_TEXTURE_RGBA, (EGLint *)&dst->bindToTextureRGBA);
141     egl.getConfigAttrib(display, config, EGL_COLOR_BUFFER_TYPE, (EGLint *)&dst->colorBufferType);
142     egl.getConfigAttrib(display, config, EGL_CONFIG_CAVEAT, (EGLint *)&dst->configCaveat);
143     egl.getConfigAttrib(display, config, EGL_CONFIG_ID, &dst->configId);
144     egl.getConfigAttrib(display, config, EGL_CONFORMANT, &dst->conformant);
145     egl.getConfigAttrib(display, config, EGL_DEPTH_SIZE, &dst->depthSize);
146     egl.getConfigAttrib(display, config, EGL_LEVEL, &dst->level);
147     egl.getConfigAttrib(display, config, EGL_MAX_PBUFFER_WIDTH, &dst->maxPbufferWidth);
148     egl.getConfigAttrib(display, config, EGL_MAX_PBUFFER_HEIGHT, &dst->maxPbufferHeight);
149     egl.getConfigAttrib(display, config, EGL_MAX_SWAP_INTERVAL, &dst->maxSwapInterval);
150     egl.getConfigAttrib(display, config, EGL_MIN_SWAP_INTERVAL, &dst->minSwapInterval);
151     egl.getConfigAttrib(display, config, EGL_NATIVE_RENDERABLE, (EGLint *)&dst->nativeRenderable);
152     egl.getConfigAttrib(display, config, EGL_NATIVE_VISUAL_ID, &dst->nativeVisualId);
153     egl.getConfigAttrib(display, config, EGL_NATIVE_VISUAL_TYPE, &dst->nativeVisualType);
154     egl.getConfigAttrib(display, config, EGL_RENDERABLE_TYPE, &dst->renderableType);
155     egl.getConfigAttrib(display, config, EGL_SAMPLE_BUFFERS, &dst->sampleBuffers);
156     egl.getConfigAttrib(display, config, EGL_SAMPLES, &dst->samples);
157     egl.getConfigAttrib(display, config, EGL_STENCIL_SIZE, &dst->stencilSize);
158     egl.getConfigAttrib(display, config, EGL_SURFACE_TYPE, &dst->surfaceType);
159     egl.getConfigAttrib(display, config, EGL_TRANSPARENT_TYPE, (EGLint *)&dst->transparentType);
160     egl.getConfigAttrib(display, config, EGL_TRANSPARENT_RED_VALUE, &dst->transparentRedValue);
161     egl.getConfigAttrib(display, config, EGL_TRANSPARENT_GREEN_VALUE, &dst->transparentGreenValue);
162     egl.getConfigAttrib(display, config, EGL_TRANSPARENT_BLUE_VALUE, &dst->transparentBlueValue);
163     EGLU_CHECK_MSG(egl, "Failed to query config info");
164 }
165 
queryExtConfigInfo(const eglw::Library & egl,eglw::EGLDisplay display,eglw::EGLConfig config,ConfigInfo * dst)166 void queryExtConfigInfo(const eglw::Library &egl, eglw::EGLDisplay display, eglw::EGLConfig config, ConfigInfo *dst)
167 {
168     const std::vector<std::string> extensions = getDisplayExtensions(egl, display);
169 
170     if (de::contains(extensions.begin(), extensions.end(), "EGL_EXT_yuv_surface"))
171     {
172         egl.getConfigAttrib(display, config, EGL_YUV_ORDER_EXT, (EGLint *)&dst->yuvOrder);
173         egl.getConfigAttrib(display, config, EGL_YUV_NUMBER_OF_PLANES_EXT, (EGLint *)&dst->yuvNumberOfPlanes);
174         egl.getConfigAttrib(display, config, EGL_YUV_SUBSAMPLE_EXT, (EGLint *)&dst->yuvSubsample);
175         egl.getConfigAttrib(display, config, EGL_YUV_DEPTH_RANGE_EXT, (EGLint *)&dst->yuvDepthRange);
176         egl.getConfigAttrib(display, config, EGL_YUV_CSC_STANDARD_EXT, (EGLint *)&dst->yuvCscStandard);
177         egl.getConfigAttrib(display, config, EGL_YUV_PLANE_BPP_EXT, (EGLint *)&dst->yuvPlaneBpp);
178 
179         EGLU_CHECK_MSG(egl, "Failed to query EGL_EXT_yuv_surface config attribs");
180     }
181 
182     if (de::contains(extensions.begin(), extensions.end(), "EGL_ANDROID_recordable"))
183     {
184         egl.getConfigAttrib(display, config, EGL_RECORDABLE_ANDROID, (EGLint *)&dst->recordableAndroid);
185 
186         EGLU_CHECK_MSG(egl, "Failed to query EGL_ANDROID_recordable config attribs");
187     }
188 
189     if (de::contains(extensions.begin(), extensions.end(), "EGL_EXT_pixel_format_float"))
190     {
191         egl.getConfigAttrib(display, config, EGL_COLOR_COMPONENT_TYPE_EXT, (EGLint *)&dst->colorComponentType);
192 
193         EGLU_CHECK_MSG(egl, "Failed to query EGL_EXT_pixel_format_float config attribs");
194     }
195     else
196         dst->colorComponentType = EGL_COLOR_COMPONENT_TYPE_FIXED_EXT;
197 }
198 
199 } // namespace eglu
200