xref: /aosp_15_r20/external/deqp/framework/egl/egluConfigInfo.cpp (revision 35238bce31c2a825756842865a792f8cf7f89930)
1*35238bceSAndroid Build Coastguard Worker /*-------------------------------------------------------------------------
2*35238bceSAndroid Build Coastguard Worker  * drawElements Quality Program Tester Core
3*35238bceSAndroid Build Coastguard Worker  * ----------------------------------------
4*35238bceSAndroid Build Coastguard Worker  *
5*35238bceSAndroid Build Coastguard Worker  * Copyright 2014 The Android Open Source Project
6*35238bceSAndroid Build Coastguard Worker  *
7*35238bceSAndroid Build Coastguard Worker  * Licensed under the Apache License, Version 2.0 (the "License");
8*35238bceSAndroid Build Coastguard Worker  * you may not use this file except in compliance with the License.
9*35238bceSAndroid Build Coastguard Worker  * You may obtain a copy of the License at
10*35238bceSAndroid Build Coastguard Worker  *
11*35238bceSAndroid Build Coastguard Worker  *      http://www.apache.org/licenses/LICENSE-2.0
12*35238bceSAndroid Build Coastguard Worker  *
13*35238bceSAndroid Build Coastguard Worker  * Unless required by applicable law or agreed to in writing, software
14*35238bceSAndroid Build Coastguard Worker  * distributed under the License is distributed on an "AS IS" BASIS,
15*35238bceSAndroid Build Coastguard Worker  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16*35238bceSAndroid Build Coastguard Worker  * See the License for the specific language governing permissions and
17*35238bceSAndroid Build Coastguard Worker  * limitations under the License.
18*35238bceSAndroid Build Coastguard Worker  *
19*35238bceSAndroid Build Coastguard Worker  *//*!
20*35238bceSAndroid Build Coastguard Worker  * \file
21*35238bceSAndroid Build Coastguard Worker  * \brief EGL config dst->
22*35238bceSAndroid Build Coastguard Worker  *//*--------------------------------------------------------------------*/
23*35238bceSAndroid Build Coastguard Worker 
24*35238bceSAndroid Build Coastguard Worker #include "egluConfigInfo.hpp"
25*35238bceSAndroid Build Coastguard Worker #include "egluDefs.hpp"
26*35238bceSAndroid Build Coastguard Worker #include "eglwLibrary.hpp"
27*35238bceSAndroid Build Coastguard Worker #include "eglwEnums.hpp"
28*35238bceSAndroid Build Coastguard Worker #include "egluUtil.hpp"
29*35238bceSAndroid Build Coastguard Worker #include "deSTLUtil.hpp"
30*35238bceSAndroid Build Coastguard Worker 
31*35238bceSAndroid Build Coastguard Worker namespace eglu
32*35238bceSAndroid Build Coastguard Worker {
33*35238bceSAndroid Build Coastguard Worker 
34*35238bceSAndroid Build Coastguard Worker using namespace eglw;
35*35238bceSAndroid Build Coastguard Worker 
getAttribute(uint32_t attribute) const36*35238bceSAndroid Build Coastguard Worker int32_t ConfigInfo::getAttribute(uint32_t attribute) const
37*35238bceSAndroid Build Coastguard Worker {
38*35238bceSAndroid Build Coastguard Worker     switch (attribute)
39*35238bceSAndroid Build Coastguard Worker     {
40*35238bceSAndroid Build Coastguard Worker     case EGL_BUFFER_SIZE:
41*35238bceSAndroid Build Coastguard Worker         return bufferSize;
42*35238bceSAndroid Build Coastguard Worker     case EGL_RED_SIZE:
43*35238bceSAndroid Build Coastguard Worker         return redSize;
44*35238bceSAndroid Build Coastguard Worker     case EGL_GREEN_SIZE:
45*35238bceSAndroid Build Coastguard Worker         return greenSize;
46*35238bceSAndroid Build Coastguard Worker     case EGL_BLUE_SIZE:
47*35238bceSAndroid Build Coastguard Worker         return blueSize;
48*35238bceSAndroid Build Coastguard Worker     case EGL_LUMINANCE_SIZE:
49*35238bceSAndroid Build Coastguard Worker         return luminanceSize;
50*35238bceSAndroid Build Coastguard Worker     case EGL_ALPHA_SIZE:
51*35238bceSAndroid Build Coastguard Worker         return alphaSize;
52*35238bceSAndroid Build Coastguard Worker     case EGL_ALPHA_MASK_SIZE:
53*35238bceSAndroid Build Coastguard Worker         return alphaMaskSize;
54*35238bceSAndroid Build Coastguard Worker     case EGL_BIND_TO_TEXTURE_RGB:
55*35238bceSAndroid Build Coastguard Worker         return bindToTextureRGB;
56*35238bceSAndroid Build Coastguard Worker     case EGL_BIND_TO_TEXTURE_RGBA:
57*35238bceSAndroid Build Coastguard Worker         return bindToTextureRGBA;
58*35238bceSAndroid Build Coastguard Worker     case EGL_COLOR_BUFFER_TYPE:
59*35238bceSAndroid Build Coastguard Worker         return colorBufferType;
60*35238bceSAndroid Build Coastguard Worker     case EGL_CONFIG_CAVEAT:
61*35238bceSAndroid Build Coastguard Worker         return configCaveat;
62*35238bceSAndroid Build Coastguard Worker     case EGL_CONFIG_ID:
63*35238bceSAndroid Build Coastguard Worker         return configId;
64*35238bceSAndroid Build Coastguard Worker     case EGL_CONFORMANT:
65*35238bceSAndroid Build Coastguard Worker         return conformant;
66*35238bceSAndroid Build Coastguard Worker     case EGL_DEPTH_SIZE:
67*35238bceSAndroid Build Coastguard Worker         return depthSize;
68*35238bceSAndroid Build Coastguard Worker     case EGL_LEVEL:
69*35238bceSAndroid Build Coastguard Worker         return level;
70*35238bceSAndroid Build Coastguard Worker     case EGL_MAX_PBUFFER_WIDTH:
71*35238bceSAndroid Build Coastguard Worker         return maxPbufferWidth;
72*35238bceSAndroid Build Coastguard Worker     case EGL_MAX_PBUFFER_HEIGHT:
73*35238bceSAndroid Build Coastguard Worker         return maxPbufferHeight;
74*35238bceSAndroid Build Coastguard Worker     case EGL_MAX_SWAP_INTERVAL:
75*35238bceSAndroid Build Coastguard Worker         return maxSwapInterval;
76*35238bceSAndroid Build Coastguard Worker     case EGL_MIN_SWAP_INTERVAL:
77*35238bceSAndroid Build Coastguard Worker         return minSwapInterval;
78*35238bceSAndroid Build Coastguard Worker     case EGL_NATIVE_RENDERABLE:
79*35238bceSAndroid Build Coastguard Worker         return nativeRenderable;
80*35238bceSAndroid Build Coastguard Worker     case EGL_NATIVE_VISUAL_ID:
81*35238bceSAndroid Build Coastguard Worker         return nativeVisualId;
82*35238bceSAndroid Build Coastguard Worker     case EGL_NATIVE_VISUAL_TYPE:
83*35238bceSAndroid Build Coastguard Worker         return nativeVisualType;
84*35238bceSAndroid Build Coastguard Worker     case EGL_RENDERABLE_TYPE:
85*35238bceSAndroid Build Coastguard Worker         return renderableType;
86*35238bceSAndroid Build Coastguard Worker     case EGL_SAMPLE_BUFFERS:
87*35238bceSAndroid Build Coastguard Worker         return sampleBuffers;
88*35238bceSAndroid Build Coastguard Worker     case EGL_SAMPLES:
89*35238bceSAndroid Build Coastguard Worker         return samples;
90*35238bceSAndroid Build Coastguard Worker     case EGL_STENCIL_SIZE:
91*35238bceSAndroid Build Coastguard Worker         return stencilSize;
92*35238bceSAndroid Build Coastguard Worker     case EGL_SURFACE_TYPE:
93*35238bceSAndroid Build Coastguard Worker         return surfaceType;
94*35238bceSAndroid Build Coastguard Worker     case EGL_TRANSPARENT_TYPE:
95*35238bceSAndroid Build Coastguard Worker         return transparentType;
96*35238bceSAndroid Build Coastguard Worker     case EGL_TRANSPARENT_RED_VALUE:
97*35238bceSAndroid Build Coastguard Worker         return transparentRedValue;
98*35238bceSAndroid Build Coastguard Worker     case EGL_TRANSPARENT_GREEN_VALUE:
99*35238bceSAndroid Build Coastguard Worker         return transparentGreenValue;
100*35238bceSAndroid Build Coastguard Worker     case EGL_TRANSPARENT_BLUE_VALUE:
101*35238bceSAndroid Build Coastguard Worker         return transparentBlueValue;
102*35238bceSAndroid Build Coastguard Worker 
103*35238bceSAndroid Build Coastguard Worker     // EGL_EXT_yuv_surface
104*35238bceSAndroid Build Coastguard Worker     case EGL_YUV_ORDER_EXT:
105*35238bceSAndroid Build Coastguard Worker         return yuvOrder;
106*35238bceSAndroid Build Coastguard Worker     case EGL_YUV_NUMBER_OF_PLANES_EXT:
107*35238bceSAndroid Build Coastguard Worker         return yuvNumberOfPlanes;
108*35238bceSAndroid Build Coastguard Worker     case EGL_YUV_SUBSAMPLE_EXT:
109*35238bceSAndroid Build Coastguard Worker         return yuvSubsample;
110*35238bceSAndroid Build Coastguard Worker     case EGL_YUV_DEPTH_RANGE_EXT:
111*35238bceSAndroid Build Coastguard Worker         return yuvDepthRange;
112*35238bceSAndroid Build Coastguard Worker     case EGL_YUV_CSC_STANDARD_EXT:
113*35238bceSAndroid Build Coastguard Worker         return yuvCscStandard;
114*35238bceSAndroid Build Coastguard Worker     case EGL_YUV_PLANE_BPP_EXT:
115*35238bceSAndroid Build Coastguard Worker         return yuvPlaneBpp;
116*35238bceSAndroid Build Coastguard Worker 
117*35238bceSAndroid Build Coastguard Worker     // EGL_EXT_pixel_format_float
118*35238bceSAndroid Build Coastguard Worker     case EGL_COLOR_COMPONENT_TYPE_EXT:
119*35238bceSAndroid Build Coastguard Worker         return colorComponentType;
120*35238bceSAndroid Build Coastguard Worker 
121*35238bceSAndroid Build Coastguard Worker     // EGL_ANDROID_recordable
122*35238bceSAndroid Build Coastguard Worker     case EGL_RECORDABLE_ANDROID:
123*35238bceSAndroid Build Coastguard Worker         return recordableAndroid;
124*35238bceSAndroid Build Coastguard Worker 
125*35238bceSAndroid Build Coastguard Worker     default:
126*35238bceSAndroid Build Coastguard Worker         TCU_THROW(InternalError, "Unknown attribute");
127*35238bceSAndroid Build Coastguard Worker     }
128*35238bceSAndroid Build Coastguard Worker }
129*35238bceSAndroid Build Coastguard Worker 
queryCoreConfigInfo(const Library & egl,EGLDisplay display,EGLConfig config,ConfigInfo * dst)130*35238bceSAndroid Build Coastguard Worker void queryCoreConfigInfo(const Library &egl, EGLDisplay display, EGLConfig config, ConfigInfo *dst)
131*35238bceSAndroid Build Coastguard Worker {
132*35238bceSAndroid Build Coastguard Worker     egl.getConfigAttrib(display, config, EGL_BUFFER_SIZE, &dst->bufferSize);
133*35238bceSAndroid Build Coastguard Worker     egl.getConfigAttrib(display, config, EGL_RED_SIZE, &dst->redSize);
134*35238bceSAndroid Build Coastguard Worker     egl.getConfigAttrib(display, config, EGL_GREEN_SIZE, &dst->greenSize);
135*35238bceSAndroid Build Coastguard Worker     egl.getConfigAttrib(display, config, EGL_BLUE_SIZE, &dst->blueSize);
136*35238bceSAndroid Build Coastguard Worker     egl.getConfigAttrib(display, config, EGL_LUMINANCE_SIZE, &dst->luminanceSize);
137*35238bceSAndroid Build Coastguard Worker     egl.getConfigAttrib(display, config, EGL_ALPHA_SIZE, &dst->alphaSize);
138*35238bceSAndroid Build Coastguard Worker     egl.getConfigAttrib(display, config, EGL_ALPHA_MASK_SIZE, &dst->alphaMaskSize);
139*35238bceSAndroid Build Coastguard Worker     egl.getConfigAttrib(display, config, EGL_BIND_TO_TEXTURE_RGB, (EGLint *)&dst->bindToTextureRGB);
140*35238bceSAndroid Build Coastguard Worker     egl.getConfigAttrib(display, config, EGL_BIND_TO_TEXTURE_RGBA, (EGLint *)&dst->bindToTextureRGBA);
141*35238bceSAndroid Build Coastguard Worker     egl.getConfigAttrib(display, config, EGL_COLOR_BUFFER_TYPE, (EGLint *)&dst->colorBufferType);
142*35238bceSAndroid Build Coastguard Worker     egl.getConfigAttrib(display, config, EGL_CONFIG_CAVEAT, (EGLint *)&dst->configCaveat);
143*35238bceSAndroid Build Coastguard Worker     egl.getConfigAttrib(display, config, EGL_CONFIG_ID, &dst->configId);
144*35238bceSAndroid Build Coastguard Worker     egl.getConfigAttrib(display, config, EGL_CONFORMANT, &dst->conformant);
145*35238bceSAndroid Build Coastguard Worker     egl.getConfigAttrib(display, config, EGL_DEPTH_SIZE, &dst->depthSize);
146*35238bceSAndroid Build Coastguard Worker     egl.getConfigAttrib(display, config, EGL_LEVEL, &dst->level);
147*35238bceSAndroid Build Coastguard Worker     egl.getConfigAttrib(display, config, EGL_MAX_PBUFFER_WIDTH, &dst->maxPbufferWidth);
148*35238bceSAndroid Build Coastguard Worker     egl.getConfigAttrib(display, config, EGL_MAX_PBUFFER_HEIGHT, &dst->maxPbufferHeight);
149*35238bceSAndroid Build Coastguard Worker     egl.getConfigAttrib(display, config, EGL_MAX_SWAP_INTERVAL, &dst->maxSwapInterval);
150*35238bceSAndroid Build Coastguard Worker     egl.getConfigAttrib(display, config, EGL_MIN_SWAP_INTERVAL, &dst->minSwapInterval);
151*35238bceSAndroid Build Coastguard Worker     egl.getConfigAttrib(display, config, EGL_NATIVE_RENDERABLE, (EGLint *)&dst->nativeRenderable);
152*35238bceSAndroid Build Coastguard Worker     egl.getConfigAttrib(display, config, EGL_NATIVE_VISUAL_ID, &dst->nativeVisualId);
153*35238bceSAndroid Build Coastguard Worker     egl.getConfigAttrib(display, config, EGL_NATIVE_VISUAL_TYPE, &dst->nativeVisualType);
154*35238bceSAndroid Build Coastguard Worker     egl.getConfigAttrib(display, config, EGL_RENDERABLE_TYPE, &dst->renderableType);
155*35238bceSAndroid Build Coastguard Worker     egl.getConfigAttrib(display, config, EGL_SAMPLE_BUFFERS, &dst->sampleBuffers);
156*35238bceSAndroid Build Coastguard Worker     egl.getConfigAttrib(display, config, EGL_SAMPLES, &dst->samples);
157*35238bceSAndroid Build Coastguard Worker     egl.getConfigAttrib(display, config, EGL_STENCIL_SIZE, &dst->stencilSize);
158*35238bceSAndroid Build Coastguard Worker     egl.getConfigAttrib(display, config, EGL_SURFACE_TYPE, &dst->surfaceType);
159*35238bceSAndroid Build Coastguard Worker     egl.getConfigAttrib(display, config, EGL_TRANSPARENT_TYPE, (EGLint *)&dst->transparentType);
160*35238bceSAndroid Build Coastguard Worker     egl.getConfigAttrib(display, config, EGL_TRANSPARENT_RED_VALUE, &dst->transparentRedValue);
161*35238bceSAndroid Build Coastguard Worker     egl.getConfigAttrib(display, config, EGL_TRANSPARENT_GREEN_VALUE, &dst->transparentGreenValue);
162*35238bceSAndroid Build Coastguard Worker     egl.getConfigAttrib(display, config, EGL_TRANSPARENT_BLUE_VALUE, &dst->transparentBlueValue);
163*35238bceSAndroid Build Coastguard Worker     EGLU_CHECK_MSG(egl, "Failed to query config info");
164*35238bceSAndroid Build Coastguard Worker }
165*35238bceSAndroid Build Coastguard Worker 
queryExtConfigInfo(const eglw::Library & egl,eglw::EGLDisplay display,eglw::EGLConfig config,ConfigInfo * dst)166*35238bceSAndroid Build Coastguard Worker void queryExtConfigInfo(const eglw::Library &egl, eglw::EGLDisplay display, eglw::EGLConfig config, ConfigInfo *dst)
167*35238bceSAndroid Build Coastguard Worker {
168*35238bceSAndroid Build Coastguard Worker     const std::vector<std::string> extensions = getDisplayExtensions(egl, display);
169*35238bceSAndroid Build Coastguard Worker 
170*35238bceSAndroid Build Coastguard Worker     if (de::contains(extensions.begin(), extensions.end(), "EGL_EXT_yuv_surface"))
171*35238bceSAndroid Build Coastguard Worker     {
172*35238bceSAndroid Build Coastguard Worker         egl.getConfigAttrib(display, config, EGL_YUV_ORDER_EXT, (EGLint *)&dst->yuvOrder);
173*35238bceSAndroid Build Coastguard Worker         egl.getConfigAttrib(display, config, EGL_YUV_NUMBER_OF_PLANES_EXT, (EGLint *)&dst->yuvNumberOfPlanes);
174*35238bceSAndroid Build Coastguard Worker         egl.getConfigAttrib(display, config, EGL_YUV_SUBSAMPLE_EXT, (EGLint *)&dst->yuvSubsample);
175*35238bceSAndroid Build Coastguard Worker         egl.getConfigAttrib(display, config, EGL_YUV_DEPTH_RANGE_EXT, (EGLint *)&dst->yuvDepthRange);
176*35238bceSAndroid Build Coastguard Worker         egl.getConfigAttrib(display, config, EGL_YUV_CSC_STANDARD_EXT, (EGLint *)&dst->yuvCscStandard);
177*35238bceSAndroid Build Coastguard Worker         egl.getConfigAttrib(display, config, EGL_YUV_PLANE_BPP_EXT, (EGLint *)&dst->yuvPlaneBpp);
178*35238bceSAndroid Build Coastguard Worker 
179*35238bceSAndroid Build Coastguard Worker         EGLU_CHECK_MSG(egl, "Failed to query EGL_EXT_yuv_surface config attribs");
180*35238bceSAndroid Build Coastguard Worker     }
181*35238bceSAndroid Build Coastguard Worker 
182*35238bceSAndroid Build Coastguard Worker     if (de::contains(extensions.begin(), extensions.end(), "EGL_ANDROID_recordable"))
183*35238bceSAndroid Build Coastguard Worker     {
184*35238bceSAndroid Build Coastguard Worker         egl.getConfigAttrib(display, config, EGL_RECORDABLE_ANDROID, (EGLint *)&dst->recordableAndroid);
185*35238bceSAndroid Build Coastguard Worker 
186*35238bceSAndroid Build Coastguard Worker         EGLU_CHECK_MSG(egl, "Failed to query EGL_ANDROID_recordable config attribs");
187*35238bceSAndroid Build Coastguard Worker     }
188*35238bceSAndroid Build Coastguard Worker 
189*35238bceSAndroid Build Coastguard Worker     if (de::contains(extensions.begin(), extensions.end(), "EGL_EXT_pixel_format_float"))
190*35238bceSAndroid Build Coastguard Worker     {
191*35238bceSAndroid Build Coastguard Worker         egl.getConfigAttrib(display, config, EGL_COLOR_COMPONENT_TYPE_EXT, (EGLint *)&dst->colorComponentType);
192*35238bceSAndroid Build Coastguard Worker 
193*35238bceSAndroid Build Coastguard Worker         EGLU_CHECK_MSG(egl, "Failed to query EGL_EXT_pixel_format_float config attribs");
194*35238bceSAndroid Build Coastguard Worker     }
195*35238bceSAndroid Build Coastguard Worker     else
196*35238bceSAndroid Build Coastguard Worker         dst->colorComponentType = EGL_COLOR_COMPONENT_TYPE_FIXED_EXT;
197*35238bceSAndroid Build Coastguard Worker }
198*35238bceSAndroid Build Coastguard Worker 
199*35238bceSAndroid Build Coastguard Worker } // namespace eglu
200