1 /*-------------------------------------------------------------------------
2 * drawElements Quality Program OpenGL ES Utilities
3 * ------------------------------------------------
5 * Copyright 2014 The Android Open Source Project
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
11 * http://www.apache.org/licenses/LICENSE-2.0
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.
21 * \brief OpenGL rendering configuration.
22 *//*--------------------------------------------------------------------*/
24 #include "gluRenderConfig.hpp"
25 #include "tcuCommandLine.hpp"
31 void parseConfigBitsFromName (RenderConfig* config, const char* renderCfgName)
33 const char* cfgName = renderCfgName;
35 DE_ASSERT(config->redBits == RenderConfig::DONT_CARE &&
36 config->greenBits == RenderConfig::DONT_CARE &&
37 config->blueBits == RenderConfig::DONT_CARE &&
38 config->alphaBits == RenderConfig::DONT_CARE &&
39 config->depthBits == RenderConfig::DONT_CARE &&
40 config->stencilBits == RenderConfig::DONT_CARE &&
41 config->numSamples == RenderConfig::DONT_CARE);
52 { "rgb888", 8, 8, 8, 0 },
53 { "rgba8888", 8, 8, 8, 8 },
54 { "rgb565", 5, 6, 5, 0 },
55 { "rgba4444", 4, 4, 4, 4 },
56 { "rgba5551", 5, 5, 5, 1 }
58 for (int ndx = 0; ndx < DE_LENGTH_OF_ARRAY(colorCfgs); ndx++)
60 if (deStringBeginsWith(cfgName, colorCfgs[ndx].name))
62 config->redBits = colorCfgs[ndx].redBits;
63 config->greenBits = colorCfgs[ndx].greenBits;
64 config->blueBits = colorCfgs[ndx].blueBits;
65 config->alphaBits = colorCfgs[ndx].alphaBits;
67 cfgName += strlen(colorCfgs[ndx].name);
83 for (int ndx = 0; ndx < DE_LENGTH_OF_ARRAY(depthCfgs); ndx++)
85 if (deStringBeginsWith(cfgName, depthCfgs[ndx].name))
87 config->depthBits = depthCfgs[ndx].depthSize;
89 cfgName += strlen(depthCfgs[ndx].name);
104 for (int ndx = 0; ndx < DE_LENGTH_OF_ARRAY(stencilCfgs); ndx++)
106 if (deStringBeginsWith(cfgName, stencilCfgs[ndx].name))
108 config->stencilBits = stencilCfgs[ndx].stencilSize;
110 cfgName += strlen(stencilCfgs[ndx].name);
119 } multiSampleCfgs[] =
128 for (int ndx = 0; ndx < DE_LENGTH_OF_ARRAY(multiSampleCfgs); ndx++)
130 if (deStringBeginsWith(cfgName, multiSampleCfgs[ndx].name))
132 config->numSamples = multiSampleCfgs[ndx].numSamples;
134 cfgName += strlen(multiSampleCfgs[ndx].name);
140 throw tcu::InternalError(std::string("Invalid GL configuration: '") + renderCfgName + "'");
143 void parseRenderConfig (RenderConfig* config, const tcu::CommandLine& cmdLine)
145 switch (cmdLine.getSurfaceType())
147 case tcu::SURFACETYPE_WINDOW: config->surfaceType = RenderConfig::SURFACETYPE_WINDOW; break;
148 case tcu::SURFACETYPE_OFFSCREEN_NATIVE: config->surfaceType = RenderConfig::SURFACETYPE_OFFSCREEN_NATIVE; break;
149 case tcu::SURFACETYPE_OFFSCREEN_GENERIC: config->surfaceType = RenderConfig::SURFACETYPE_OFFSCREEN_GENERIC; break;
150 case tcu::SURFACETYPE_FBO: config->surfaceType = RenderConfig::SURFACETYPE_DONT_CARE; break;
151 case tcu::SURFACETYPE_LAST: config->surfaceType = RenderConfig::SURFACETYPE_DONT_CARE; break;
153 throw tcu::InternalError("Unsupported surface type");
156 config->windowVisibility = parseWindowVisibility(cmdLine);
158 if (cmdLine.getSurfaceWidth() > 0)
159 config->width = cmdLine.getSurfaceWidth();
161 if (cmdLine.getSurfaceHeight() > 0)
162 config->height = cmdLine.getSurfaceHeight();
164 if (cmdLine.getGLConfigName() != DE_NULL)
165 parseConfigBitsFromName(config, cmdLine.getGLConfigName());
167 if (cmdLine.getGLConfigId() >= 0)
168 config->id = cmdLine.getGLConfigId();
171 RenderConfig::Visibility parseWindowVisibility (const tcu::CommandLine& cmdLine)
173 switch (cmdLine.getVisibility())
175 case tcu::WINDOWVISIBILITY_HIDDEN: return RenderConfig::VISIBILITY_HIDDEN;
176 case tcu::WINDOWVISIBILITY_WINDOWED: return RenderConfig::VISIBILITY_VISIBLE;
177 case tcu::WINDOWVISIBILITY_FULLSCREEN: return RenderConfig::VISIBILITY_FULLSCREEN;
179 throw tcu::InternalError("Unsupported window visibility");