1*35238bceSAndroid Build Coastguard Worker /*-------------------------------------------------------------------------
2*35238bceSAndroid Build Coastguard Worker * drawElements Quality Program OpenGL ES Utilities
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 OpenGL ES rendering context.
22*35238bceSAndroid Build Coastguard Worker *//*--------------------------------------------------------------------*/
23*35238bceSAndroid Build Coastguard Worker
24*35238bceSAndroid Build Coastguard Worker #include "gluRenderContext.hpp"
25*35238bceSAndroid Build Coastguard Worker #include "gluDefs.hpp"
26*35238bceSAndroid Build Coastguard Worker #include "gluRenderConfig.hpp"
27*35238bceSAndroid Build Coastguard Worker #include "gluFboRenderContext.hpp"
28*35238bceSAndroid Build Coastguard Worker #include "gluPlatform.hpp"
29*35238bceSAndroid Build Coastguard Worker #include "gluStrUtil.hpp"
30*35238bceSAndroid Build Coastguard Worker #include "glwInitFunctions.hpp"
31*35238bceSAndroid Build Coastguard Worker #include "glwEnums.hpp"
32*35238bceSAndroid Build Coastguard Worker #include "tcuPlatform.hpp"
33*35238bceSAndroid Build Coastguard Worker #include "tcuCommandLine.hpp"
34*35238bceSAndroid Build Coastguard Worker #include "deStringUtil.hpp"
35*35238bceSAndroid Build Coastguard Worker #include "deSTLUtil.hpp"
36*35238bceSAndroid Build Coastguard Worker
37*35238bceSAndroid Build Coastguard Worker namespace glu
38*35238bceSAndroid Build Coastguard Worker {
39*35238bceSAndroid Build Coastguard Worker
40*35238bceSAndroid Build Coastguard Worker // RenderContext
41*35238bceSAndroid Build Coastguard Worker
getProcAddress(const char *) const42*35238bceSAndroid Build Coastguard Worker glw::GenericFuncType RenderContext::getProcAddress(const char *) const
43*35238bceSAndroid Build Coastguard Worker {
44*35238bceSAndroid Build Coastguard Worker return (glw::GenericFuncType)DE_NULL;
45*35238bceSAndroid Build Coastguard Worker }
46*35238bceSAndroid Build Coastguard Worker
makeCurrent(void)47*35238bceSAndroid Build Coastguard Worker void RenderContext::makeCurrent(void)
48*35238bceSAndroid Build Coastguard Worker {
49*35238bceSAndroid Build Coastguard Worker TCU_THROW(InternalError, "RenderContext::makeCurrent() is not implemented");
50*35238bceSAndroid Build Coastguard Worker }
51*35238bceSAndroid Build Coastguard Worker
52*35238bceSAndroid Build Coastguard Worker // Utilities
53*35238bceSAndroid Build Coastguard Worker
versionGreaterOrEqual(ApiType a,ApiType b)54*35238bceSAndroid Build Coastguard Worker inline bool versionGreaterOrEqual(ApiType a, ApiType b)
55*35238bceSAndroid Build Coastguard Worker {
56*35238bceSAndroid Build Coastguard Worker return a.getMajorVersion() > b.getMajorVersion() ||
57*35238bceSAndroid Build Coastguard Worker (a.getMajorVersion() == b.getMajorVersion() && a.getMinorVersion() >= b.getMinorVersion());
58*35238bceSAndroid Build Coastguard Worker }
59*35238bceSAndroid Build Coastguard Worker
contextSupports(ContextType ctxType,ApiType requiredApiType)60*35238bceSAndroid Build Coastguard Worker bool contextSupports(ContextType ctxType, ApiType requiredApiType)
61*35238bceSAndroid Build Coastguard Worker {
62*35238bceSAndroid Build Coastguard Worker // \todo [2014-10-06 pyry] Check exact forward-compatible restrictions.
63*35238bceSAndroid Build Coastguard Worker const bool forwardCompatible = (ctxType.getFlags() & CONTEXT_FORWARD_COMPATIBLE) != 0;
64*35238bceSAndroid Build Coastguard Worker
65*35238bceSAndroid Build Coastguard Worker if (isContextTypeES(ctxType))
66*35238bceSAndroid Build Coastguard Worker {
67*35238bceSAndroid Build Coastguard Worker DE_ASSERT(!forwardCompatible);
68*35238bceSAndroid Build Coastguard Worker return requiredApiType.getProfile() == PROFILE_ES && versionGreaterOrEqual(ctxType.getAPI(), requiredApiType);
69*35238bceSAndroid Build Coastguard Worker }
70*35238bceSAndroid Build Coastguard Worker else if (isContextTypeGLCore(ctxType))
71*35238bceSAndroid Build Coastguard Worker {
72*35238bceSAndroid Build Coastguard Worker if (forwardCompatible)
73*35238bceSAndroid Build Coastguard Worker return ctxType.getAPI() == requiredApiType;
74*35238bceSAndroid Build Coastguard Worker else
75*35238bceSAndroid Build Coastguard Worker return requiredApiType.getProfile() == PROFILE_CORE &&
76*35238bceSAndroid Build Coastguard Worker versionGreaterOrEqual(ctxType.getAPI(), requiredApiType);
77*35238bceSAndroid Build Coastguard Worker }
78*35238bceSAndroid Build Coastguard Worker else if (isContextTypeGLCompatibility(ctxType))
79*35238bceSAndroid Build Coastguard Worker {
80*35238bceSAndroid Build Coastguard Worker DE_ASSERT(!forwardCompatible);
81*35238bceSAndroid Build Coastguard Worker return (requiredApiType.getProfile() == PROFILE_CORE ||
82*35238bceSAndroid Build Coastguard Worker requiredApiType.getProfile() == PROFILE_COMPATIBILITY) &&
83*35238bceSAndroid Build Coastguard Worker versionGreaterOrEqual(ctxType.getAPI(), requiredApiType);
84*35238bceSAndroid Build Coastguard Worker }
85*35238bceSAndroid Build Coastguard Worker else
86*35238bceSAndroid Build Coastguard Worker {
87*35238bceSAndroid Build Coastguard Worker DE_ASSERT(false);
88*35238bceSAndroid Build Coastguard Worker return false;
89*35238bceSAndroid Build Coastguard Worker }
90*35238bceSAndroid Build Coastguard Worker }
91*35238bceSAndroid Build Coastguard Worker
parseContextFlags(const std::string & flagsStr)92*35238bceSAndroid Build Coastguard Worker static ContextFlags parseContextFlags(const std::string &flagsStr)
93*35238bceSAndroid Build Coastguard Worker {
94*35238bceSAndroid Build Coastguard Worker const std::vector<std::string> flagNames = de::splitString(flagsStr, ',');
95*35238bceSAndroid Build Coastguard Worker ContextFlags flags = ContextFlags(0);
96*35238bceSAndroid Build Coastguard Worker static const struct
97*35238bceSAndroid Build Coastguard Worker {
98*35238bceSAndroid Build Coastguard Worker const char *name;
99*35238bceSAndroid Build Coastguard Worker ContextFlags flag;
100*35238bceSAndroid Build Coastguard Worker } s_flagMap[] = {{"debug", CONTEXT_DEBUG}, {"robust", CONTEXT_ROBUST}};
101*35238bceSAndroid Build Coastguard Worker
102*35238bceSAndroid Build Coastguard Worker for (std::vector<std::string>::const_iterator flagIter = flagNames.begin(); flagIter != flagNames.end(); ++flagIter)
103*35238bceSAndroid Build Coastguard Worker {
104*35238bceSAndroid Build Coastguard Worker int ndx;
105*35238bceSAndroid Build Coastguard Worker for (ndx = 0; ndx < DE_LENGTH_OF_ARRAY(s_flagMap); ndx++)
106*35238bceSAndroid Build Coastguard Worker {
107*35238bceSAndroid Build Coastguard Worker if (*flagIter == s_flagMap[ndx].name)
108*35238bceSAndroid Build Coastguard Worker {
109*35238bceSAndroid Build Coastguard Worker flags = flags | s_flagMap[ndx].flag;
110*35238bceSAndroid Build Coastguard Worker break;
111*35238bceSAndroid Build Coastguard Worker }
112*35238bceSAndroid Build Coastguard Worker }
113*35238bceSAndroid Build Coastguard Worker
114*35238bceSAndroid Build Coastguard Worker if (ndx == DE_LENGTH_OF_ARRAY(s_flagMap))
115*35238bceSAndroid Build Coastguard Worker {
116*35238bceSAndroid Build Coastguard Worker tcu::print("ERROR: Unrecognized GL context flag '%s'\n", flagIter->c_str());
117*35238bceSAndroid Build Coastguard Worker tcu::print("Supported GL context flags:\n");
118*35238bceSAndroid Build Coastguard Worker
119*35238bceSAndroid Build Coastguard Worker for (ndx = 0; ndx < DE_LENGTH_OF_ARRAY(s_flagMap); ndx++)
120*35238bceSAndroid Build Coastguard Worker tcu::print(" %s\n", s_flagMap[ndx].name);
121*35238bceSAndroid Build Coastguard Worker
122*35238bceSAndroid Build Coastguard Worker throw tcu::NotSupportedError((std::string("Unknown GL context flag '") + *flagIter + "'").c_str(), DE_NULL,
123*35238bceSAndroid Build Coastguard Worker __FILE__, __LINE__);
124*35238bceSAndroid Build Coastguard Worker }
125*35238bceSAndroid Build Coastguard Worker }
126*35238bceSAndroid Build Coastguard Worker
127*35238bceSAndroid Build Coastguard Worker return flags;
128*35238bceSAndroid Build Coastguard Worker }
129*35238bceSAndroid Build Coastguard Worker
createRenderContext(tcu::Platform & platform,const tcu::CommandLine & cmdLine,const RenderConfig & config,const RenderContext * sharedContext)130*35238bceSAndroid Build Coastguard Worker RenderContext *createRenderContext(tcu::Platform &platform, const tcu::CommandLine &cmdLine, const RenderConfig &config,
131*35238bceSAndroid Build Coastguard Worker const RenderContext *sharedContext)
132*35238bceSAndroid Build Coastguard Worker {
133*35238bceSAndroid Build Coastguard Worker const ContextFactoryRegistry ®istry = platform.getGLPlatform().getContextFactoryRegistry();
134*35238bceSAndroid Build Coastguard Worker const char *factoryName = cmdLine.getGLContextType();
135*35238bceSAndroid Build Coastguard Worker const ContextFactory *factory = DE_NULL;
136*35238bceSAndroid Build Coastguard Worker
137*35238bceSAndroid Build Coastguard Worker if (registry.empty())
138*35238bceSAndroid Build Coastguard Worker throw tcu::NotSupportedError("OpenGL is not supported", DE_NULL, __FILE__, __LINE__);
139*35238bceSAndroid Build Coastguard Worker
140*35238bceSAndroid Build Coastguard Worker if (factoryName)
141*35238bceSAndroid Build Coastguard Worker {
142*35238bceSAndroid Build Coastguard Worker factory = registry.getFactoryByName(factoryName);
143*35238bceSAndroid Build Coastguard Worker
144*35238bceSAndroid Build Coastguard Worker if (!factory)
145*35238bceSAndroid Build Coastguard Worker {
146*35238bceSAndroid Build Coastguard Worker tcu::print("ERROR: Unknown or unsupported GL context type '%s'\n", factoryName);
147*35238bceSAndroid Build Coastguard Worker tcu::print("Supported GL context types:\n");
148*35238bceSAndroid Build Coastguard Worker
149*35238bceSAndroid Build Coastguard Worker for (int factoryNdx = 0; factoryNdx < (int)registry.getFactoryCount(); factoryNdx++)
150*35238bceSAndroid Build Coastguard Worker {
151*35238bceSAndroid Build Coastguard Worker const ContextFactory *curFactory = registry.getFactoryByIndex(factoryNdx);
152*35238bceSAndroid Build Coastguard Worker tcu::print(" %s: %s\n", curFactory->getName(), curFactory->getDescription());
153*35238bceSAndroid Build Coastguard Worker }
154*35238bceSAndroid Build Coastguard Worker
155*35238bceSAndroid Build Coastguard Worker throw tcu::NotSupportedError((std::string("Unknown GL context type '") + factoryName + "'").c_str(),
156*35238bceSAndroid Build Coastguard Worker DE_NULL, __FILE__, __LINE__);
157*35238bceSAndroid Build Coastguard Worker }
158*35238bceSAndroid Build Coastguard Worker }
159*35238bceSAndroid Build Coastguard Worker else
160*35238bceSAndroid Build Coastguard Worker factory = registry.getDefaultFactory();
161*35238bceSAndroid Build Coastguard Worker
162*35238bceSAndroid Build Coastguard Worker if (cmdLine.getSurfaceType() == tcu::SURFACETYPE_FBO)
163*35238bceSAndroid Build Coastguard Worker {
164*35238bceSAndroid Build Coastguard Worker if (sharedContext)
165*35238bceSAndroid Build Coastguard Worker TCU_FAIL("Shared context not implemented for FBO surface type");
166*35238bceSAndroid Build Coastguard Worker return new FboRenderContext(*factory, config, cmdLine);
167*35238bceSAndroid Build Coastguard Worker }
168*35238bceSAndroid Build Coastguard Worker else
169*35238bceSAndroid Build Coastguard Worker return factory->createContext(config, cmdLine, sharedContext);
170*35238bceSAndroid Build Coastguard Worker }
171*35238bceSAndroid Build Coastguard Worker
createDefaultRenderContext(tcu::Platform & platform,const tcu::CommandLine & cmdLine,ApiType apiType)172*35238bceSAndroid Build Coastguard Worker RenderContext *createDefaultRenderContext(tcu::Platform &platform, const tcu::CommandLine &cmdLine, ApiType apiType)
173*35238bceSAndroid Build Coastguard Worker {
174*35238bceSAndroid Build Coastguard Worker RenderConfig config;
175*35238bceSAndroid Build Coastguard Worker ContextFlags ctxFlags = ContextFlags(0);
176*35238bceSAndroid Build Coastguard Worker
177*35238bceSAndroid Build Coastguard Worker if (cmdLine.getGLContextFlags())
178*35238bceSAndroid Build Coastguard Worker ctxFlags = parseContextFlags(cmdLine.getGLContextFlags());
179*35238bceSAndroid Build Coastguard Worker
180*35238bceSAndroid Build Coastguard Worker config.type = glu::ContextType(apiType, ctxFlags);
181*35238bceSAndroid Build Coastguard Worker parseRenderConfig(&config, cmdLine);
182*35238bceSAndroid Build Coastguard Worker
183*35238bceSAndroid Build Coastguard Worker return createRenderContext(platform, cmdLine, config);
184*35238bceSAndroid Build Coastguard Worker }
185*35238bceSAndroid Build Coastguard Worker
getExtensions(const glw::Functions & gl,ApiType apiType)186*35238bceSAndroid Build Coastguard Worker static std::vector<std::string> getExtensions(const glw::Functions &gl, ApiType apiType)
187*35238bceSAndroid Build Coastguard Worker {
188*35238bceSAndroid Build Coastguard Worker using std::string;
189*35238bceSAndroid Build Coastguard Worker using std::vector;
190*35238bceSAndroid Build Coastguard Worker
191*35238bceSAndroid Build Coastguard Worker if (apiType.getProfile() == PROFILE_ES && apiType.getMajorVersion() == 2)
192*35238bceSAndroid Build Coastguard Worker {
193*35238bceSAndroid Build Coastguard Worker TCU_CHECK(gl.getString);
194*35238bceSAndroid Build Coastguard Worker
195*35238bceSAndroid Build Coastguard Worker const char *extStr = (const char *)gl.getString(GL_EXTENSIONS);
196*35238bceSAndroid Build Coastguard Worker GLU_EXPECT_NO_ERROR(gl.getError(), "glGetString(GL_EXTENSIONS)");
197*35238bceSAndroid Build Coastguard Worker
198*35238bceSAndroid Build Coastguard Worker if (extStr)
199*35238bceSAndroid Build Coastguard Worker return de::splitString(extStr);
200*35238bceSAndroid Build Coastguard Worker else
201*35238bceSAndroid Build Coastguard Worker throw tcu::TestError("glGetString(GL_EXTENSIONS) returned null pointer", DE_NULL, __FILE__, __LINE__);
202*35238bceSAndroid Build Coastguard Worker }
203*35238bceSAndroid Build Coastguard Worker else
204*35238bceSAndroid Build Coastguard Worker {
205*35238bceSAndroid Build Coastguard Worker int numExtensions = 0;
206*35238bceSAndroid Build Coastguard Worker vector<string> extensions;
207*35238bceSAndroid Build Coastguard Worker
208*35238bceSAndroid Build Coastguard Worker TCU_CHECK(gl.getIntegerv && gl.getStringi);
209*35238bceSAndroid Build Coastguard Worker
210*35238bceSAndroid Build Coastguard Worker gl.getIntegerv(GL_NUM_EXTENSIONS, &numExtensions);
211*35238bceSAndroid Build Coastguard Worker GLU_EXPECT_NO_ERROR(gl.getError(), "glGetIntegerv(GL_NUM_EXTENSIONS)");
212*35238bceSAndroid Build Coastguard Worker
213*35238bceSAndroid Build Coastguard Worker if (numExtensions > 0)
214*35238bceSAndroid Build Coastguard Worker {
215*35238bceSAndroid Build Coastguard Worker extensions.resize(numExtensions);
216*35238bceSAndroid Build Coastguard Worker
217*35238bceSAndroid Build Coastguard Worker for (int ndx = 0; ndx < numExtensions; ndx++)
218*35238bceSAndroid Build Coastguard Worker {
219*35238bceSAndroid Build Coastguard Worker const char *const ext = (const char *)gl.getStringi(GL_EXTENSIONS, ndx);
220*35238bceSAndroid Build Coastguard Worker GLU_EXPECT_NO_ERROR(gl.getError(), "glGetStringi(GL_EXTENSIONS)");
221*35238bceSAndroid Build Coastguard Worker
222*35238bceSAndroid Build Coastguard Worker if (ext)
223*35238bceSAndroid Build Coastguard Worker extensions[ndx] = ext;
224*35238bceSAndroid Build Coastguard Worker else
225*35238bceSAndroid Build Coastguard Worker throw tcu::TestError("glGetStringi(GL_EXTENSIONS) returned null pointer", DE_NULL, __FILE__,
226*35238bceSAndroid Build Coastguard Worker __LINE__);
227*35238bceSAndroid Build Coastguard Worker }
228*35238bceSAndroid Build Coastguard Worker }
229*35238bceSAndroid Build Coastguard Worker
230*35238bceSAndroid Build Coastguard Worker return extensions;
231*35238bceSAndroid Build Coastguard Worker }
232*35238bceSAndroid Build Coastguard Worker }
233*35238bceSAndroid Build Coastguard Worker
hasExtension(const glw::Functions & gl,ApiType apiType,const std::string & extension)234*35238bceSAndroid Build Coastguard Worker bool hasExtension(const glw::Functions &gl, ApiType apiType, const std::string &extension)
235*35238bceSAndroid Build Coastguard Worker {
236*35238bceSAndroid Build Coastguard Worker std::vector<std::string> extensions(getExtensions(gl, apiType));
237*35238bceSAndroid Build Coastguard Worker
238*35238bceSAndroid Build Coastguard Worker return de::contains(extensions.begin(), extensions.end(), extension);
239*35238bceSAndroid Build Coastguard Worker }
240*35238bceSAndroid Build Coastguard Worker
initCoreFunctions(glw::Functions * dst,const glw::FunctionLoader * loader,ApiType apiType)241*35238bceSAndroid Build Coastguard Worker void initCoreFunctions(glw::Functions *dst, const glw::FunctionLoader *loader, ApiType apiType)
242*35238bceSAndroid Build Coastguard Worker {
243*35238bceSAndroid Build Coastguard Worker static const struct
244*35238bceSAndroid Build Coastguard Worker {
245*35238bceSAndroid Build Coastguard Worker ApiType apiType;
246*35238bceSAndroid Build Coastguard Worker void (*initFunc)(glw::Functions *gl, const glw::FunctionLoader *loader);
247*35238bceSAndroid Build Coastguard Worker } s_initFuncs[] = {
248*35238bceSAndroid Build Coastguard Worker {ApiType::es(2, 0), glw::initES20},
249*35238bceSAndroid Build Coastguard Worker {ApiType::es(3, 0), glw::initES30},
250*35238bceSAndroid Build Coastguard Worker {ApiType::es(3, 1), glw::initES31},
251*35238bceSAndroid Build Coastguard Worker {ApiType::es(3, 2), glw::initES32},
252*35238bceSAndroid Build Coastguard Worker {ApiType::core(3, 0), glw::initGL30Core},
253*35238bceSAndroid Build Coastguard Worker {ApiType::core(3, 1), glw::initGL31Core},
254*35238bceSAndroid Build Coastguard Worker {ApiType::core(3, 2), glw::initGL32Core},
255*35238bceSAndroid Build Coastguard Worker {ApiType::core(3, 3), glw::initGL33Core},
256*35238bceSAndroid Build Coastguard Worker {ApiType::core(4, 0), glw::initGL40Core},
257*35238bceSAndroid Build Coastguard Worker {ApiType::core(4, 1), glw::initGL41Core},
258*35238bceSAndroid Build Coastguard Worker {ApiType::core(4, 2), glw::initGL42Core},
259*35238bceSAndroid Build Coastguard Worker {ApiType::core(4, 3), glw::initGL43Core},
260*35238bceSAndroid Build Coastguard Worker {ApiType::core(4, 4), glw::initGL44Core},
261*35238bceSAndroid Build Coastguard Worker {ApiType::core(4, 5), glw::initGL45Core},
262*35238bceSAndroid Build Coastguard Worker {ApiType::core(4, 6), glw::initGL46Core},
263*35238bceSAndroid Build Coastguard Worker // TODO: initialise actual compat functions rather than using core as a dummy
264*35238bceSAndroid Build Coastguard Worker {ApiType::compatibility(3, 2), glw::initGL32Core},
265*35238bceSAndroid Build Coastguard Worker {ApiType::compatibility(3, 3), glw::initGL33Core},
266*35238bceSAndroid Build Coastguard Worker {ApiType::compatibility(4, 0), glw::initGL40Core},
267*35238bceSAndroid Build Coastguard Worker {ApiType::compatibility(4, 1), glw::initGL41Core},
268*35238bceSAndroid Build Coastguard Worker {ApiType::compatibility(4, 2), glw::initGL42Core},
269*35238bceSAndroid Build Coastguard Worker {ApiType::compatibility(4, 3), glw::initGL43Core},
270*35238bceSAndroid Build Coastguard Worker {ApiType::compatibility(4, 4), glw::initGL44Core},
271*35238bceSAndroid Build Coastguard Worker {ApiType::compatibility(4, 5), glw::initGL45Core},
272*35238bceSAndroid Build Coastguard Worker {ApiType::compatibility(4, 6), glw::initGL46Core},
273*35238bceSAndroid Build Coastguard Worker };
274*35238bceSAndroid Build Coastguard Worker
275*35238bceSAndroid Build Coastguard Worker for (int ndx = 0; ndx < DE_LENGTH_OF_ARRAY(s_initFuncs); ndx++)
276*35238bceSAndroid Build Coastguard Worker {
277*35238bceSAndroid Build Coastguard Worker if (s_initFuncs[ndx].apiType == apiType)
278*35238bceSAndroid Build Coastguard Worker {
279*35238bceSAndroid Build Coastguard Worker s_initFuncs[ndx].initFunc(dst, loader);
280*35238bceSAndroid Build Coastguard Worker return;
281*35238bceSAndroid Build Coastguard Worker }
282*35238bceSAndroid Build Coastguard Worker }
283*35238bceSAndroid Build Coastguard Worker
284*35238bceSAndroid Build Coastguard Worker throw tcu::InternalError(std::string("Don't know how to load functions for ") + de::toString(apiType));
285*35238bceSAndroid Build Coastguard Worker }
286*35238bceSAndroid Build Coastguard Worker
initExtensionFunctions(glw::Functions * dst,const glw::FunctionLoader * loader,ApiType apiType)287*35238bceSAndroid Build Coastguard Worker void initExtensionFunctions(glw::Functions *dst, const glw::FunctionLoader *loader, ApiType apiType)
288*35238bceSAndroid Build Coastguard Worker {
289*35238bceSAndroid Build Coastguard Worker std::vector<std::string> extensions = getExtensions(*dst, apiType);
290*35238bceSAndroid Build Coastguard Worker
291*35238bceSAndroid Build Coastguard Worker if (!extensions.empty())
292*35238bceSAndroid Build Coastguard Worker {
293*35238bceSAndroid Build Coastguard Worker std::vector<const char *> extStr(extensions.size());
294*35238bceSAndroid Build Coastguard Worker
295*35238bceSAndroid Build Coastguard Worker for (size_t ndx = 0; ndx < extensions.size(); ndx++)
296*35238bceSAndroid Build Coastguard Worker extStr[ndx] = extensions[ndx].c_str();
297*35238bceSAndroid Build Coastguard Worker
298*35238bceSAndroid Build Coastguard Worker initExtensionFunctions(dst, loader, apiType, (int)extStr.size(), &extStr[0]);
299*35238bceSAndroid Build Coastguard Worker }
300*35238bceSAndroid Build Coastguard Worker }
301*35238bceSAndroid Build Coastguard Worker
initExtensionFunctions(glw::Functions * dst,const glw::FunctionLoader * loader,ApiType apiType,int numExtensions,const char * const * extensions)302*35238bceSAndroid Build Coastguard Worker void initExtensionFunctions(glw::Functions *dst, const glw::FunctionLoader *loader, ApiType apiType, int numExtensions,
303*35238bceSAndroid Build Coastguard Worker const char *const *extensions)
304*35238bceSAndroid Build Coastguard Worker {
305*35238bceSAndroid Build Coastguard Worker if (apiType.getProfile() == PROFILE_ES)
306*35238bceSAndroid Build Coastguard Worker glw::initExtensionsES(dst, loader, numExtensions, extensions);
307*35238bceSAndroid Build Coastguard Worker else
308*35238bceSAndroid Build Coastguard Worker glw::initExtensionsGL(dst, loader, numExtensions, extensions);
309*35238bceSAndroid Build Coastguard Worker }
310*35238bceSAndroid Build Coastguard Worker
initFunctions(glw::Functions * dst,const glw::FunctionLoader * loader,ApiType apiType)311*35238bceSAndroid Build Coastguard Worker void initFunctions(glw::Functions *dst, const glw::FunctionLoader *loader, ApiType apiType)
312*35238bceSAndroid Build Coastguard Worker {
313*35238bceSAndroid Build Coastguard Worker initCoreFunctions(dst, loader, apiType);
314*35238bceSAndroid Build Coastguard Worker initExtensionFunctions(dst, loader, apiType);
315*35238bceSAndroid Build Coastguard Worker }
316*35238bceSAndroid Build Coastguard Worker
getApiTypeDescription(ApiType type)317*35238bceSAndroid Build Coastguard Worker const char *getApiTypeDescription(ApiType type)
318*35238bceSAndroid Build Coastguard Worker {
319*35238bceSAndroid Build Coastguard Worker if (type == glu::ApiType::es(2, 0))
320*35238bceSAndroid Build Coastguard Worker return "OpenGL ES 2";
321*35238bceSAndroid Build Coastguard Worker else if (type == glu::ApiType::es(3, 0))
322*35238bceSAndroid Build Coastguard Worker return "OpenGL ES 3";
323*35238bceSAndroid Build Coastguard Worker else if (type == glu::ApiType::es(3, 1))
324*35238bceSAndroid Build Coastguard Worker return "OpenGL ES 3.1";
325*35238bceSAndroid Build Coastguard Worker else if (type == glu::ApiType::es(3, 2))
326*35238bceSAndroid Build Coastguard Worker return "OpenGL ES 3.2";
327*35238bceSAndroid Build Coastguard Worker else if (type == glu::ApiType::core(3, 0))
328*35238bceSAndroid Build Coastguard Worker return "OpenGL 3.0 core";
329*35238bceSAndroid Build Coastguard Worker else if (type == glu::ApiType::core(3, 1))
330*35238bceSAndroid Build Coastguard Worker return "OpenGL 3.1 core";
331*35238bceSAndroid Build Coastguard Worker else if (type == glu::ApiType::core(3, 2))
332*35238bceSAndroid Build Coastguard Worker return "OpenGL 3.2 core";
333*35238bceSAndroid Build Coastguard Worker else if (type == glu::ApiType::core(3, 3))
334*35238bceSAndroid Build Coastguard Worker return "OpenGL 3.3 core";
335*35238bceSAndroid Build Coastguard Worker else if (type == glu::ApiType::core(4, 0))
336*35238bceSAndroid Build Coastguard Worker return "OpenGL 4.0 core";
337*35238bceSAndroid Build Coastguard Worker else if (type == glu::ApiType::core(4, 1))
338*35238bceSAndroid Build Coastguard Worker return "OpenGL 4.1 core";
339*35238bceSAndroid Build Coastguard Worker else if (type == glu::ApiType::core(4, 2))
340*35238bceSAndroid Build Coastguard Worker return "OpenGL 4.2 core";
341*35238bceSAndroid Build Coastguard Worker else if (type == glu::ApiType::core(4, 3))
342*35238bceSAndroid Build Coastguard Worker return "OpenGL 4.3 core";
343*35238bceSAndroid Build Coastguard Worker else if (type == glu::ApiType::core(4, 4))
344*35238bceSAndroid Build Coastguard Worker return "OpenGL 4.4 core";
345*35238bceSAndroid Build Coastguard Worker else if (type == glu::ApiType::core(4, 5))
346*35238bceSAndroid Build Coastguard Worker return "OpenGL 4.5 core";
347*35238bceSAndroid Build Coastguard Worker else if (type == glu::ApiType::core(4, 6))
348*35238bceSAndroid Build Coastguard Worker return "OpenGL 4.6 core";
349*35238bceSAndroid Build Coastguard Worker else if (type == glu::ApiType::compatibility(3, 2))
350*35238bceSAndroid Build Coastguard Worker return "OpenGL 3.2 compatibility";
351*35238bceSAndroid Build Coastguard Worker else if (type == glu::ApiType::compatibility(3, 3))
352*35238bceSAndroid Build Coastguard Worker return "OpenGL 3.3 compatibility";
353*35238bceSAndroid Build Coastguard Worker else if (type == glu::ApiType::compatibility(4, 0))
354*35238bceSAndroid Build Coastguard Worker return "OpenGL 4.0 compatibility";
355*35238bceSAndroid Build Coastguard Worker else if (type == glu::ApiType::compatibility(4, 1))
356*35238bceSAndroid Build Coastguard Worker return "OpenGL 4.1 compatibility";
357*35238bceSAndroid Build Coastguard Worker else if (type == glu::ApiType::compatibility(4, 2))
358*35238bceSAndroid Build Coastguard Worker return "OpenGL 4.2 compatibility";
359*35238bceSAndroid Build Coastguard Worker else if (type == glu::ApiType::compatibility(4, 3))
360*35238bceSAndroid Build Coastguard Worker return "OpenGL 4.3 compatibility";
361*35238bceSAndroid Build Coastguard Worker else if (type == glu::ApiType::compatibility(4, 4))
362*35238bceSAndroid Build Coastguard Worker return "OpenGL 4.4 compatibility";
363*35238bceSAndroid Build Coastguard Worker else if (type == glu::ApiType::compatibility(4, 5))
364*35238bceSAndroid Build Coastguard Worker return "OpenGL 4.5 compatibility";
365*35238bceSAndroid Build Coastguard Worker else if (type == glu::ApiType::compatibility(4, 6))
366*35238bceSAndroid Build Coastguard Worker return "OpenGL 4.6 compatibility";
367*35238bceSAndroid Build Coastguard Worker else
368*35238bceSAndroid Build Coastguard Worker return DE_NULL;
369*35238bceSAndroid Build Coastguard Worker }
370*35238bceSAndroid Build Coastguard Worker
371*35238bceSAndroid Build Coastguard Worker } // namespace glu
372