1*35238bceSAndroid Build Coastguard Worker /*-------------------------------------------------------------------------
2*35238bceSAndroid Build Coastguard Worker * drawElements Quality Program EGL Module
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 Extension function pointer query tests.
22*35238bceSAndroid Build Coastguard Worker *//*--------------------------------------------------------------------*/
23*35238bceSAndroid Build Coastguard Worker
24*35238bceSAndroid Build Coastguard Worker #include "teglGetProcAddressTests.hpp"
25*35238bceSAndroid Build Coastguard Worker #include "teglTestCase.hpp"
26*35238bceSAndroid Build Coastguard Worker #include "egluCallLogWrapper.hpp"
27*35238bceSAndroid Build Coastguard Worker #include "egluStrUtil.hpp"
28*35238bceSAndroid Build Coastguard Worker #include "egluUtil.hpp"
29*35238bceSAndroid Build Coastguard Worker #include "eglwLibrary.hpp"
30*35238bceSAndroid Build Coastguard Worker #include "eglwEnums.hpp"
31*35238bceSAndroid Build Coastguard Worker #include "tcuTestLog.hpp"
32*35238bceSAndroid Build Coastguard Worker #include "deSTLUtil.hpp"
33*35238bceSAndroid Build Coastguard Worker #include "deStringUtil.hpp"
34*35238bceSAndroid Build Coastguard Worker
35*35238bceSAndroid Build Coastguard Worker namespace deqp
36*35238bceSAndroid Build Coastguard Worker {
37*35238bceSAndroid Build Coastguard Worker namespace egl
38*35238bceSAndroid Build Coastguard Worker {
39*35238bceSAndroid Build Coastguard Worker
40*35238bceSAndroid Build Coastguard Worker namespace
41*35238bceSAndroid Build Coastguard Worker {
42*35238bceSAndroid Build Coastguard Worker
43*35238bceSAndroid Build Coastguard Worker #define EGL_MAKE_VERSION(major, minor) (((major) << 12) | (minor))
44*35238bceSAndroid Build Coastguard Worker
45*35238bceSAndroid Build Coastguard Worker using tcu::TestLog;
46*35238bceSAndroid Build Coastguard Worker using namespace eglw;
47*35238bceSAndroid Build Coastguard Worker
48*35238bceSAndroid Build Coastguard Worker // Function name strings generated from API headers
49*35238bceSAndroid Build Coastguard Worker
50*35238bceSAndroid Build Coastguard Worker #include "teglGetProcAddressTests.inl"
51*35238bceSAndroid Build Coastguard Worker
52*35238bceSAndroid Build Coastguard Worker struct FunctionNames
53*35238bceSAndroid Build Coastguard Worker {
54*35238bceSAndroid Build Coastguard Worker int numFunctions;
55*35238bceSAndroid Build Coastguard Worker const char *const *functions;
56*35238bceSAndroid Build Coastguard Worker
FunctionNamesdeqp::egl::__anon71ac69b90111::FunctionNames57*35238bceSAndroid Build Coastguard Worker FunctionNames(int numFunctions_, const char *const *functions_) : numFunctions(numFunctions_), functions(functions_)
58*35238bceSAndroid Build Coastguard Worker {
59*35238bceSAndroid Build Coastguard Worker }
60*35238bceSAndroid Build Coastguard Worker };
61*35238bceSAndroid Build Coastguard Worker
getExtFunctionNames(const std::string & extName)62*35238bceSAndroid Build Coastguard Worker FunctionNames getExtFunctionNames(const std::string &extName)
63*35238bceSAndroid Build Coastguard Worker {
64*35238bceSAndroid Build Coastguard Worker for (int ndx = 0; ndx <= DE_LENGTH_OF_ARRAY(s_extensions); ndx++)
65*35238bceSAndroid Build Coastguard Worker {
66*35238bceSAndroid Build Coastguard Worker if (extName == s_extensions[ndx].name)
67*35238bceSAndroid Build Coastguard Worker return FunctionNames(s_extensions[ndx].numFunctions, s_extensions[ndx].functions);
68*35238bceSAndroid Build Coastguard Worker }
69*35238bceSAndroid Build Coastguard Worker
70*35238bceSAndroid Build Coastguard Worker DE_ASSERT(false);
71*35238bceSAndroid Build Coastguard Worker return FunctionNames(0, DE_NULL);
72*35238bceSAndroid Build Coastguard Worker }
73*35238bceSAndroid Build Coastguard Worker
74*35238bceSAndroid Build Coastguard Worker } // namespace
75*35238bceSAndroid Build Coastguard Worker
76*35238bceSAndroid Build Coastguard Worker // Base class for eglGetProcAddress() test cases
77*35238bceSAndroid Build Coastguard Worker
78*35238bceSAndroid Build Coastguard Worker class GetProcAddressCase : public TestCase, protected eglu::CallLogWrapper
79*35238bceSAndroid Build Coastguard Worker {
80*35238bceSAndroid Build Coastguard Worker public:
81*35238bceSAndroid Build Coastguard Worker GetProcAddressCase(EglTestContext &eglTestCtx, const char *name, const char *description);
82*35238bceSAndroid Build Coastguard Worker virtual ~GetProcAddressCase(void);
83*35238bceSAndroid Build Coastguard Worker
84*35238bceSAndroid Build Coastguard Worker void init(void);
85*35238bceSAndroid Build Coastguard Worker void deinit(void);
86*35238bceSAndroid Build Coastguard Worker IterateResult iterate(void);
87*35238bceSAndroid Build Coastguard Worker
88*35238bceSAndroid Build Coastguard Worker bool isSupported(const std::string &extName);
89*35238bceSAndroid Build Coastguard Worker
90*35238bceSAndroid Build Coastguard Worker virtual void executeTest(void) = 0;
91*35238bceSAndroid Build Coastguard Worker
92*35238bceSAndroid Build Coastguard Worker protected:
93*35238bceSAndroid Build Coastguard Worker EGLDisplay m_display;
94*35238bceSAndroid Build Coastguard Worker int m_eglVersion;
95*35238bceSAndroid Build Coastguard Worker
96*35238bceSAndroid Build Coastguard Worker private:
97*35238bceSAndroid Build Coastguard Worker std::vector<std::string> m_supported;
98*35238bceSAndroid Build Coastguard Worker };
99*35238bceSAndroid Build Coastguard Worker
GetProcAddressCase(EglTestContext & eglTestCtx,const char * name,const char * description)100*35238bceSAndroid Build Coastguard Worker GetProcAddressCase::GetProcAddressCase(EglTestContext &eglTestCtx, const char *name, const char *description)
101*35238bceSAndroid Build Coastguard Worker : TestCase(eglTestCtx, name, description)
102*35238bceSAndroid Build Coastguard Worker , CallLogWrapper(eglTestCtx.getLibrary(), eglTestCtx.getTestContext().getLog())
103*35238bceSAndroid Build Coastguard Worker , m_display(EGL_NO_DISPLAY)
104*35238bceSAndroid Build Coastguard Worker {
105*35238bceSAndroid Build Coastguard Worker }
106*35238bceSAndroid Build Coastguard Worker
~GetProcAddressCase(void)107*35238bceSAndroid Build Coastguard Worker GetProcAddressCase::~GetProcAddressCase(void)
108*35238bceSAndroid Build Coastguard Worker {
109*35238bceSAndroid Build Coastguard Worker }
110*35238bceSAndroid Build Coastguard Worker
init(void)111*35238bceSAndroid Build Coastguard Worker void GetProcAddressCase::init(void)
112*35238bceSAndroid Build Coastguard Worker {
113*35238bceSAndroid Build Coastguard Worker try
114*35238bceSAndroid Build Coastguard Worker {
115*35238bceSAndroid Build Coastguard Worker m_supported = eglu::getClientExtensions(m_eglTestCtx.getLibrary());
116*35238bceSAndroid Build Coastguard Worker }
117*35238bceSAndroid Build Coastguard Worker catch (const tcu::NotSupportedError &)
118*35238bceSAndroid Build Coastguard Worker {
119*35238bceSAndroid Build Coastguard Worker // Ignore case where EGL client extensions are not supported
120*35238bceSAndroid Build Coastguard Worker // that's okay for these tests.
121*35238bceSAndroid Build Coastguard Worker }
122*35238bceSAndroid Build Coastguard Worker
123*35238bceSAndroid Build Coastguard Worker DE_ASSERT(m_display == EGL_NO_DISPLAY);
124*35238bceSAndroid Build Coastguard Worker
125*35238bceSAndroid Build Coastguard Worker m_display = eglu::getAndInitDisplay(m_eglTestCtx.getNativeDisplay());
126*35238bceSAndroid Build Coastguard Worker
127*35238bceSAndroid Build Coastguard Worker // The EGL_VERSION string is laid out as follows:
128*35238bceSAndroid Build Coastguard Worker // major_version.minor_version space vendor_specific_info
129*35238bceSAndroid Build Coastguard Worker // Split version from vendor_specific_info
130*35238bceSAndroid Build Coastguard Worker std::vector<std::string> tokens = de::splitString(eglQueryString(m_display, EGL_VERSION), ' ');
131*35238bceSAndroid Build Coastguard Worker // split version into major & minor
132*35238bceSAndroid Build Coastguard Worker std::vector<std::string> values = de::splitString(tokens[0], '.');
133*35238bceSAndroid Build Coastguard Worker m_eglVersion = EGL_MAKE_VERSION(atoi(values[0].c_str()), atoi(values[1].c_str()));
134*35238bceSAndroid Build Coastguard Worker
135*35238bceSAndroid Build Coastguard Worker {
136*35238bceSAndroid Build Coastguard Worker const std::vector<std::string> displayExtensios =
137*35238bceSAndroid Build Coastguard Worker eglu::getDisplayExtensions(m_eglTestCtx.getLibrary(), m_display);
138*35238bceSAndroid Build Coastguard Worker m_supported.insert(m_supported.end(), displayExtensios.begin(), displayExtensios.end());
139*35238bceSAndroid Build Coastguard Worker }
140*35238bceSAndroid Build Coastguard Worker
141*35238bceSAndroid Build Coastguard Worker m_testCtx.setTestResult(QP_TEST_RESULT_PASS, "Pass");
142*35238bceSAndroid Build Coastguard Worker }
143*35238bceSAndroid Build Coastguard Worker
deinit(void)144*35238bceSAndroid Build Coastguard Worker void GetProcAddressCase::deinit(void)
145*35238bceSAndroid Build Coastguard Worker {
146*35238bceSAndroid Build Coastguard Worker m_eglTestCtx.getLibrary().terminate(m_display);
147*35238bceSAndroid Build Coastguard Worker m_display = EGL_NO_DISPLAY;
148*35238bceSAndroid Build Coastguard Worker }
149*35238bceSAndroid Build Coastguard Worker
iterate(void)150*35238bceSAndroid Build Coastguard Worker tcu::TestNode::IterateResult GetProcAddressCase::iterate(void)
151*35238bceSAndroid Build Coastguard Worker {
152*35238bceSAndroid Build Coastguard Worker enableLogging(true);
153*35238bceSAndroid Build Coastguard Worker
154*35238bceSAndroid Build Coastguard Worker executeTest();
155*35238bceSAndroid Build Coastguard Worker
156*35238bceSAndroid Build Coastguard Worker enableLogging(false);
157*35238bceSAndroid Build Coastguard Worker
158*35238bceSAndroid Build Coastguard Worker return STOP;
159*35238bceSAndroid Build Coastguard Worker }
160*35238bceSAndroid Build Coastguard Worker
isSupported(const std::string & extName)161*35238bceSAndroid Build Coastguard Worker bool GetProcAddressCase::isSupported(const std::string &extName)
162*35238bceSAndroid Build Coastguard Worker {
163*35238bceSAndroid Build Coastguard Worker return de::contains(m_supported.begin(), m_supported.end(), extName);
164*35238bceSAndroid Build Coastguard Worker }
165*35238bceSAndroid Build Coastguard Worker
166*35238bceSAndroid Build Coastguard Worker // Test by extension
167*35238bceSAndroid Build Coastguard Worker
168*35238bceSAndroid Build Coastguard Worker class GetProcAddressExtensionCase : public GetProcAddressCase
169*35238bceSAndroid Build Coastguard Worker {
170*35238bceSAndroid Build Coastguard Worker public:
GetProcAddressExtensionCase(EglTestContext & eglTestCtx,const char * name,const char * description,const std::string & extName)171*35238bceSAndroid Build Coastguard Worker GetProcAddressExtensionCase(EglTestContext &eglTestCtx, const char *name, const char *description,
172*35238bceSAndroid Build Coastguard Worker const std::string &extName)
173*35238bceSAndroid Build Coastguard Worker : GetProcAddressCase(eglTestCtx, name, description)
174*35238bceSAndroid Build Coastguard Worker , m_extName(extName)
175*35238bceSAndroid Build Coastguard Worker {
176*35238bceSAndroid Build Coastguard Worker }
177*35238bceSAndroid Build Coastguard Worker
~GetProcAddressExtensionCase(void)178*35238bceSAndroid Build Coastguard Worker virtual ~GetProcAddressExtensionCase(void)
179*35238bceSAndroid Build Coastguard Worker {
180*35238bceSAndroid Build Coastguard Worker }
181*35238bceSAndroid Build Coastguard Worker
executeTest(void)182*35238bceSAndroid Build Coastguard Worker void executeTest(void)
183*35238bceSAndroid Build Coastguard Worker {
184*35238bceSAndroid Build Coastguard Worker TestLog &log = m_testCtx.getLog();
185*35238bceSAndroid Build Coastguard Worker bool supported = isSupported(m_extName);
186*35238bceSAndroid Build Coastguard Worker const FunctionNames funcNames = getExtFunctionNames(m_extName);
187*35238bceSAndroid Build Coastguard Worker
188*35238bceSAndroid Build Coastguard Worker DE_ASSERT(funcNames.numFunctions > 0);
189*35238bceSAndroid Build Coastguard Worker
190*35238bceSAndroid Build Coastguard Worker log << TestLog::Message << m_extName << ": " << (supported ? "supported" : "not supported")
191*35238bceSAndroid Build Coastguard Worker << TestLog::EndMessage;
192*35238bceSAndroid Build Coastguard Worker log << TestLog::Message << TestLog::EndMessage;
193*35238bceSAndroid Build Coastguard Worker
194*35238bceSAndroid Build Coastguard Worker for (int funcNdx = 0; funcNdx < funcNames.numFunctions; funcNdx++)
195*35238bceSAndroid Build Coastguard Worker {
196*35238bceSAndroid Build Coastguard Worker const char *funcName = funcNames.functions[funcNdx];
197*35238bceSAndroid Build Coastguard Worker void (*funcPtr)(void);
198*35238bceSAndroid Build Coastguard Worker
199*35238bceSAndroid Build Coastguard Worker funcPtr = eglGetProcAddress(funcName);
200*35238bceSAndroid Build Coastguard Worker eglu::checkError(eglGetError(), "eglGetProcAddress()", __FILE__, __LINE__);
201*35238bceSAndroid Build Coastguard Worker
202*35238bceSAndroid Build Coastguard Worker if (supported && funcPtr == 0)
203*35238bceSAndroid Build Coastguard Worker {
204*35238bceSAndroid Build Coastguard Worker log << TestLog::Message << "Fail, received null pointer for supported extension function: " << funcName
205*35238bceSAndroid Build Coastguard Worker << TestLog::EndMessage;
206*35238bceSAndroid Build Coastguard Worker m_testCtx.setTestResult(QP_TEST_RESULT_FAIL, "Unexpected null pointer");
207*35238bceSAndroid Build Coastguard Worker }
208*35238bceSAndroid Build Coastguard Worker }
209*35238bceSAndroid Build Coastguard Worker }
210*35238bceSAndroid Build Coastguard Worker
211*35238bceSAndroid Build Coastguard Worker private:
212*35238bceSAndroid Build Coastguard Worker std::string m_extName;
213*35238bceSAndroid Build Coastguard Worker };
214*35238bceSAndroid Build Coastguard Worker
215*35238bceSAndroid Build Coastguard Worker // Test core functions
216*35238bceSAndroid Build Coastguard Worker
217*35238bceSAndroid Build Coastguard Worker class GetProcAddressCoreFunctionsCase : public GetProcAddressCase
218*35238bceSAndroid Build Coastguard Worker {
219*35238bceSAndroid Build Coastguard Worker public:
220*35238bceSAndroid Build Coastguard Worker enum ApiType
221*35238bceSAndroid Build Coastguard Worker {
222*35238bceSAndroid Build Coastguard Worker EGL14,
223*35238bceSAndroid Build Coastguard Worker EGL15,
224*35238bceSAndroid Build Coastguard Worker GLES,
225*35238bceSAndroid Build Coastguard Worker GLES2,
226*35238bceSAndroid Build Coastguard Worker GLES3
227*35238bceSAndroid Build Coastguard Worker };
228*35238bceSAndroid Build Coastguard Worker
GetProcAddressCoreFunctionsCase(EglTestContext & eglTestCtx,const char * name,const char * description,const ApiType apiType)229*35238bceSAndroid Build Coastguard Worker GetProcAddressCoreFunctionsCase(EglTestContext &eglTestCtx, const char *name, const char *description,
230*35238bceSAndroid Build Coastguard Worker const ApiType apiType)
231*35238bceSAndroid Build Coastguard Worker : GetProcAddressCase(eglTestCtx, name, description)
232*35238bceSAndroid Build Coastguard Worker , m_apiType(apiType)
233*35238bceSAndroid Build Coastguard Worker {
234*35238bceSAndroid Build Coastguard Worker }
235*35238bceSAndroid Build Coastguard Worker
~GetProcAddressCoreFunctionsCase(void)236*35238bceSAndroid Build Coastguard Worker virtual ~GetProcAddressCoreFunctionsCase(void)
237*35238bceSAndroid Build Coastguard Worker {
238*35238bceSAndroid Build Coastguard Worker }
239*35238bceSAndroid Build Coastguard Worker
RenderableType(ApiType type)240*35238bceSAndroid Build Coastguard Worker EGLint RenderableType(ApiType type)
241*35238bceSAndroid Build Coastguard Worker {
242*35238bceSAndroid Build Coastguard Worker EGLint renderableType = EGL_OPENGL_ES_BIT;
243*35238bceSAndroid Build Coastguard Worker switch (type)
244*35238bceSAndroid Build Coastguard Worker {
245*35238bceSAndroid Build Coastguard Worker case EGL14:
246*35238bceSAndroid Build Coastguard Worker case EGL15:
247*35238bceSAndroid Build Coastguard Worker case GLES:
248*35238bceSAndroid Build Coastguard Worker renderableType = EGL_OPENGL_ES_BIT;
249*35238bceSAndroid Build Coastguard Worker break;
250*35238bceSAndroid Build Coastguard Worker case GLES2:
251*35238bceSAndroid Build Coastguard Worker renderableType = EGL_OPENGL_ES2_BIT;
252*35238bceSAndroid Build Coastguard Worker break;
253*35238bceSAndroid Build Coastguard Worker case GLES3:
254*35238bceSAndroid Build Coastguard Worker renderableType = EGL_OPENGL_ES3_BIT_KHR;
255*35238bceSAndroid Build Coastguard Worker break;
256*35238bceSAndroid Build Coastguard Worker }
257*35238bceSAndroid Build Coastguard Worker return renderableType;
258*35238bceSAndroid Build Coastguard Worker }
259*35238bceSAndroid Build Coastguard Worker
isApiSupported(void)260*35238bceSAndroid Build Coastguard Worker bool isApiSupported(void)
261*35238bceSAndroid Build Coastguard Worker {
262*35238bceSAndroid Build Coastguard Worker EGLint renderableType = EGL_OPENGL_ES_BIT;
263*35238bceSAndroid Build Coastguard Worker switch (m_apiType)
264*35238bceSAndroid Build Coastguard Worker {
265*35238bceSAndroid Build Coastguard Worker case EGL14:
266*35238bceSAndroid Build Coastguard Worker return m_eglVersion >= EGL_MAKE_VERSION(1, 4);
267*35238bceSAndroid Build Coastguard Worker case EGL15:
268*35238bceSAndroid Build Coastguard Worker // With Android Q, EGL 1.5 entry points must have valid
269*35238bceSAndroid Build Coastguard Worker // GetProcAddress.
270*35238bceSAndroid Build Coastguard Worker return m_eglVersion >= EGL_MAKE_VERSION(1, 5);
271*35238bceSAndroid Build Coastguard Worker case GLES:
272*35238bceSAndroid Build Coastguard Worker case GLES2:
273*35238bceSAndroid Build Coastguard Worker case GLES3:
274*35238bceSAndroid Build Coastguard Worker renderableType = RenderableType(m_apiType);
275*35238bceSAndroid Build Coastguard Worker break;
276*35238bceSAndroid Build Coastguard Worker }
277*35238bceSAndroid Build Coastguard Worker return (eglu::getRenderableAPIsMask(m_eglTestCtx.getLibrary(), m_display) & renderableType) == renderableType;
278*35238bceSAndroid Build Coastguard Worker }
279*35238bceSAndroid Build Coastguard Worker
getCoreFunctionNames(EGLint apiType)280*35238bceSAndroid Build Coastguard Worker FunctionNames getCoreFunctionNames(EGLint apiType)
281*35238bceSAndroid Build Coastguard Worker {
282*35238bceSAndroid Build Coastguard Worker switch (apiType)
283*35238bceSAndroid Build Coastguard Worker {
284*35238bceSAndroid Build Coastguard Worker case EGL14:
285*35238bceSAndroid Build Coastguard Worker return FunctionNames(DE_LENGTH_OF_ARRAY(s_EGL14), s_EGL14);
286*35238bceSAndroid Build Coastguard Worker case EGL15:
287*35238bceSAndroid Build Coastguard Worker return FunctionNames(DE_LENGTH_OF_ARRAY(s_EGL15), s_EGL15);
288*35238bceSAndroid Build Coastguard Worker case GLES:
289*35238bceSAndroid Build Coastguard Worker return FunctionNames(DE_LENGTH_OF_ARRAY(s_GLES10), s_GLES10);
290*35238bceSAndroid Build Coastguard Worker case GLES2:
291*35238bceSAndroid Build Coastguard Worker return FunctionNames(DE_LENGTH_OF_ARRAY(s_GLES20), s_GLES20);
292*35238bceSAndroid Build Coastguard Worker case GLES3:
293*35238bceSAndroid Build Coastguard Worker return FunctionNames(DE_LENGTH_OF_ARRAY(s_GLES30), s_GLES30);
294*35238bceSAndroid Build Coastguard Worker default:
295*35238bceSAndroid Build Coastguard Worker DE_ASSERT(false);
296*35238bceSAndroid Build Coastguard Worker }
297*35238bceSAndroid Build Coastguard Worker
298*35238bceSAndroid Build Coastguard Worker return FunctionNames(0, DE_NULL);
299*35238bceSAndroid Build Coastguard Worker }
300*35238bceSAndroid Build Coastguard Worker
executeTest(void)301*35238bceSAndroid Build Coastguard Worker void executeTest(void)
302*35238bceSAndroid Build Coastguard Worker {
303*35238bceSAndroid Build Coastguard Worker TestLog &log = m_testCtx.getLog();
304*35238bceSAndroid Build Coastguard Worker const bool funcPtrSupported = isSupported("EGL_KHR_get_all_proc_addresses");
305*35238bceSAndroid Build Coastguard Worker const bool apiSupported = isApiSupported();
306*35238bceSAndroid Build Coastguard Worker const FunctionNames funcNames = getCoreFunctionNames(m_apiType);
307*35238bceSAndroid Build Coastguard Worker
308*35238bceSAndroid Build Coastguard Worker log << TestLog::Message
309*35238bceSAndroid Build Coastguard Worker << "EGL_KHR_get_all_proc_addresses: " << (funcPtrSupported ? "supported" : "not supported")
310*35238bceSAndroid Build Coastguard Worker << TestLog::EndMessage;
311*35238bceSAndroid Build Coastguard Worker log << TestLog::Message << TestLog::EndMessage;
312*35238bceSAndroid Build Coastguard Worker
313*35238bceSAndroid Build Coastguard Worker if (!apiSupported)
314*35238bceSAndroid Build Coastguard Worker {
315*35238bceSAndroid Build Coastguard Worker switch (m_apiType)
316*35238bceSAndroid Build Coastguard Worker {
317*35238bceSAndroid Build Coastguard Worker case EGL14:
318*35238bceSAndroid Build Coastguard Worker log << TestLog::Message << " EGL not supported by any available configuration." << TestLog::EndMessage;
319*35238bceSAndroid Build Coastguard Worker break;
320*35238bceSAndroid Build Coastguard Worker case EGL15:
321*35238bceSAndroid Build Coastguard Worker log << TestLog::Message << " EGL 1.5 not supported by any available configuration."
322*35238bceSAndroid Build Coastguard Worker << TestLog::EndMessage;
323*35238bceSAndroid Build Coastguard Worker break;
324*35238bceSAndroid Build Coastguard Worker case GLES:
325*35238bceSAndroid Build Coastguard Worker case GLES2:
326*35238bceSAndroid Build Coastguard Worker case GLES3:
327*35238bceSAndroid Build Coastguard Worker log << TestLog::Message << eglu::getConfigAttribValueStr(EGL_RENDERABLE_TYPE, RenderableType(m_apiType))
328*35238bceSAndroid Build Coastguard Worker << " not supported by any available configuration." << TestLog::EndMessage;
329*35238bceSAndroid Build Coastguard Worker break;
330*35238bceSAndroid Build Coastguard Worker }
331*35238bceSAndroid Build Coastguard Worker log << TestLog::Message << TestLog::EndMessage;
332*35238bceSAndroid Build Coastguard Worker }
333*35238bceSAndroid Build Coastguard Worker
334*35238bceSAndroid Build Coastguard Worker for (int funcNdx = 0; funcNdx < funcNames.numFunctions; funcNdx++)
335*35238bceSAndroid Build Coastguard Worker {
336*35238bceSAndroid Build Coastguard Worker const char *funcName = funcNames.functions[funcNdx];
337*35238bceSAndroid Build Coastguard Worker void (*funcPtr)(void);
338*35238bceSAndroid Build Coastguard Worker
339*35238bceSAndroid Build Coastguard Worker funcPtr = eglGetProcAddress(funcName);
340*35238bceSAndroid Build Coastguard Worker eglu::checkError(eglGetError(), "eglGetProcAddress()", __FILE__, __LINE__);
341*35238bceSAndroid Build Coastguard Worker
342*35238bceSAndroid Build Coastguard Worker if (apiSupported && funcPtrSupported && (funcPtr == 0))
343*35238bceSAndroid Build Coastguard Worker {
344*35238bceSAndroid Build Coastguard Worker log << TestLog::Message << "Fail, received null pointer for supported function: " << funcName
345*35238bceSAndroid Build Coastguard Worker << TestLog::EndMessage;
346*35238bceSAndroid Build Coastguard Worker m_testCtx.setTestResult(QP_TEST_RESULT_FAIL, "Unexpected null pointer");
347*35238bceSAndroid Build Coastguard Worker }
348*35238bceSAndroid Build Coastguard Worker else if (!apiSupported && (funcPtr != 0))
349*35238bceSAndroid Build Coastguard Worker {
350*35238bceSAndroid Build Coastguard Worker log << TestLog::Message << "Warning, received non-null value for unsupported function: " << funcName
351*35238bceSAndroid Build Coastguard Worker << TestLog::EndMessage;
352*35238bceSAndroid Build Coastguard Worker m_testCtx.setTestResult(QP_TEST_RESULT_QUALITY_WARNING, "Non-null value for unsupported function");
353*35238bceSAndroid Build Coastguard Worker }
354*35238bceSAndroid Build Coastguard Worker }
355*35238bceSAndroid Build Coastguard Worker }
356*35238bceSAndroid Build Coastguard Worker
357*35238bceSAndroid Build Coastguard Worker private:
358*35238bceSAndroid Build Coastguard Worker const ApiType m_apiType;
359*35238bceSAndroid Build Coastguard Worker };
360*35238bceSAndroid Build Coastguard Worker
GetProcAddressTests(EglTestContext & eglTestCtx)361*35238bceSAndroid Build Coastguard Worker GetProcAddressTests::GetProcAddressTests(EglTestContext &eglTestCtx)
362*35238bceSAndroid Build Coastguard Worker : TestCaseGroup(eglTestCtx, "get_proc_address", "eglGetProcAddress() tests")
363*35238bceSAndroid Build Coastguard Worker {
364*35238bceSAndroid Build Coastguard Worker }
365*35238bceSAndroid Build Coastguard Worker
~GetProcAddressTests(void)366*35238bceSAndroid Build Coastguard Worker GetProcAddressTests::~GetProcAddressTests(void)
367*35238bceSAndroid Build Coastguard Worker {
368*35238bceSAndroid Build Coastguard Worker }
369*35238bceSAndroid Build Coastguard Worker
init(void)370*35238bceSAndroid Build Coastguard Worker void GetProcAddressTests::init(void)
371*35238bceSAndroid Build Coastguard Worker {
372*35238bceSAndroid Build Coastguard Worker // extensions
373*35238bceSAndroid Build Coastguard Worker {
374*35238bceSAndroid Build Coastguard Worker tcu::TestCaseGroup *extensionsGroup = new tcu::TestCaseGroup(m_testCtx, "extension", "Test EGL extensions");
375*35238bceSAndroid Build Coastguard Worker addChild(extensionsGroup);
376*35238bceSAndroid Build Coastguard Worker
377*35238bceSAndroid Build Coastguard Worker for (int extNdx = 0; extNdx < DE_LENGTH_OF_ARRAY(s_extensions); extNdx++)
378*35238bceSAndroid Build Coastguard Worker {
379*35238bceSAndroid Build Coastguard Worker const std::string &extName = s_extensions[extNdx].name;
380*35238bceSAndroid Build Coastguard Worker std::string testName(extName);
381*35238bceSAndroid Build Coastguard Worker
382*35238bceSAndroid Build Coastguard Worker for (size_t ndx = 0; ndx < extName.length(); ndx++)
383*35238bceSAndroid Build Coastguard Worker testName[ndx] = de::toLower(extName[ndx]);
384*35238bceSAndroid Build Coastguard Worker
385*35238bceSAndroid Build Coastguard Worker extensionsGroup->addChild(
386*35238bceSAndroid Build Coastguard Worker new GetProcAddressExtensionCase(m_eglTestCtx, testName.c_str(), ("Test " + extName).c_str(), extName));
387*35238bceSAndroid Build Coastguard Worker }
388*35238bceSAndroid Build Coastguard Worker }
389*35238bceSAndroid Build Coastguard Worker
390*35238bceSAndroid Build Coastguard Worker // core functions
391*35238bceSAndroid Build Coastguard Worker {
392*35238bceSAndroid Build Coastguard Worker tcu::TestCaseGroup *coreFuncGroup = new tcu::TestCaseGroup(m_testCtx, "core", "Test core functions");
393*35238bceSAndroid Build Coastguard Worker addChild(coreFuncGroup);
394*35238bceSAndroid Build Coastguard Worker
395*35238bceSAndroid Build Coastguard Worker coreFuncGroup->addChild(new GetProcAddressCoreFunctionsCase(m_eglTestCtx, "egl", "Test EGL core functions",
396*35238bceSAndroid Build Coastguard Worker GetProcAddressCoreFunctionsCase::EGL14));
397*35238bceSAndroid Build Coastguard Worker
398*35238bceSAndroid Build Coastguard Worker coreFuncGroup->addChild(new GetProcAddressCoreFunctionsCase(m_eglTestCtx, "egl15", "Test EGL 1.5 functions",
399*35238bceSAndroid Build Coastguard Worker GetProcAddressCoreFunctionsCase::EGL15));
400*35238bceSAndroid Build Coastguard Worker coreFuncGroup->addChild(new GetProcAddressCoreFunctionsCase(
401*35238bceSAndroid Build Coastguard Worker m_eglTestCtx, "gles", "Test OpenGL ES core functions", GetProcAddressCoreFunctionsCase::GLES));
402*35238bceSAndroid Build Coastguard Worker coreFuncGroup->addChild(new GetProcAddressCoreFunctionsCase(
403*35238bceSAndroid Build Coastguard Worker m_eglTestCtx, "gles2", "Test OpenGL ES 2 core functions", GetProcAddressCoreFunctionsCase::GLES2));
404*35238bceSAndroid Build Coastguard Worker coreFuncGroup->addChild(new GetProcAddressCoreFunctionsCase(
405*35238bceSAndroid Build Coastguard Worker m_eglTestCtx, "gles3", "Test OpenGL ES 3 core functions", GetProcAddressCoreFunctionsCase::GLES3));
406*35238bceSAndroid Build Coastguard Worker }
407*35238bceSAndroid Build Coastguard Worker }
408*35238bceSAndroid Build Coastguard Worker
409*35238bceSAndroid Build Coastguard Worker } // namespace egl
410*35238bceSAndroid Build Coastguard Worker } // namespace deqp
411