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 Config query tests.
22*35238bceSAndroid Build Coastguard Worker *//*--------------------------------------------------------------------*/
23*35238bceSAndroid Build Coastguard Worker
24*35238bceSAndroid Build Coastguard Worker #include "teglQueryContextTests.hpp"
25*35238bceSAndroid Build Coastguard Worker #include "teglRenderCase.hpp"
26*35238bceSAndroid Build Coastguard Worker #include "teglRenderCase.hpp"
27*35238bceSAndroid Build Coastguard Worker #include "egluCallLogWrapper.hpp"
28*35238bceSAndroid Build Coastguard Worker #include "egluStrUtil.hpp"
29*35238bceSAndroid Build Coastguard Worker #include "tcuCommandLine.hpp"
30*35238bceSAndroid Build Coastguard Worker #include "tcuTestLog.hpp"
31*35238bceSAndroid Build Coastguard Worker #include "tcuTestContext.hpp"
32*35238bceSAndroid Build Coastguard Worker
33*35238bceSAndroid Build Coastguard Worker #include "egluUtil.hpp"
34*35238bceSAndroid Build Coastguard Worker #include "egluNativeDisplay.hpp"
35*35238bceSAndroid Build Coastguard Worker #include "egluNativeWindow.hpp"
36*35238bceSAndroid Build Coastguard Worker #include "egluNativePixmap.hpp"
37*35238bceSAndroid Build Coastguard Worker
38*35238bceSAndroid Build Coastguard Worker #include "eglwLibrary.hpp"
39*35238bceSAndroid Build Coastguard Worker #include "eglwEnums.hpp"
40*35238bceSAndroid Build Coastguard Worker
41*35238bceSAndroid Build Coastguard Worker #include "deUniquePtr.hpp"
42*35238bceSAndroid Build Coastguard Worker #include "deSTLUtil.hpp"
43*35238bceSAndroid Build Coastguard Worker
44*35238bceSAndroid Build Coastguard Worker #include <vector>
45*35238bceSAndroid Build Coastguard Worker
46*35238bceSAndroid Build Coastguard Worker namespace deqp
47*35238bceSAndroid Build Coastguard Worker {
48*35238bceSAndroid Build Coastguard Worker namespace egl
49*35238bceSAndroid Build Coastguard Worker {
50*35238bceSAndroid Build Coastguard Worker
51*35238bceSAndroid Build Coastguard Worker using eglu::ConfigInfo;
52*35238bceSAndroid Build Coastguard Worker using std::vector;
53*35238bceSAndroid Build Coastguard Worker using tcu::TestLog;
54*35238bceSAndroid Build Coastguard Worker using namespace eglw;
55*35238bceSAndroid Build Coastguard Worker
getClientTypeFromAPIBit(EGLint apiBit)56*35238bceSAndroid Build Coastguard Worker static EGLint getClientTypeFromAPIBit(EGLint apiBit)
57*35238bceSAndroid Build Coastguard Worker {
58*35238bceSAndroid Build Coastguard Worker switch (apiBit)
59*35238bceSAndroid Build Coastguard Worker {
60*35238bceSAndroid Build Coastguard Worker case EGL_OPENGL_BIT:
61*35238bceSAndroid Build Coastguard Worker return EGL_OPENGL_API;
62*35238bceSAndroid Build Coastguard Worker case EGL_OPENGL_ES_BIT:
63*35238bceSAndroid Build Coastguard Worker return EGL_OPENGL_ES_API;
64*35238bceSAndroid Build Coastguard Worker case EGL_OPENGL_ES2_BIT:
65*35238bceSAndroid Build Coastguard Worker return EGL_OPENGL_ES_API;
66*35238bceSAndroid Build Coastguard Worker case EGL_OPENGL_ES3_BIT:
67*35238bceSAndroid Build Coastguard Worker return EGL_OPENGL_ES_API;
68*35238bceSAndroid Build Coastguard Worker case EGL_OPENVG_BIT:
69*35238bceSAndroid Build Coastguard Worker return EGL_OPENVG_API;
70*35238bceSAndroid Build Coastguard Worker default:
71*35238bceSAndroid Build Coastguard Worker DE_ASSERT(false);
72*35238bceSAndroid Build Coastguard Worker return 0;
73*35238bceSAndroid Build Coastguard Worker }
74*35238bceSAndroid Build Coastguard Worker }
75*35238bceSAndroid Build Coastguard Worker
getMinClientMajorVersion(EGLint apiBit)76*35238bceSAndroid Build Coastguard Worker static EGLint getMinClientMajorVersion(EGLint apiBit)
77*35238bceSAndroid Build Coastguard Worker {
78*35238bceSAndroid Build Coastguard Worker switch (apiBit)
79*35238bceSAndroid Build Coastguard Worker {
80*35238bceSAndroid Build Coastguard Worker case EGL_OPENGL_BIT:
81*35238bceSAndroid Build Coastguard Worker return 1;
82*35238bceSAndroid Build Coastguard Worker case EGL_OPENGL_ES_BIT:
83*35238bceSAndroid Build Coastguard Worker return 1;
84*35238bceSAndroid Build Coastguard Worker case EGL_OPENGL_ES2_BIT:
85*35238bceSAndroid Build Coastguard Worker return 2;
86*35238bceSAndroid Build Coastguard Worker case EGL_OPENGL_ES3_BIT:
87*35238bceSAndroid Build Coastguard Worker return 3;
88*35238bceSAndroid Build Coastguard Worker case EGL_OPENVG_BIT:
89*35238bceSAndroid Build Coastguard Worker return 1;
90*35238bceSAndroid Build Coastguard Worker default:
91*35238bceSAndroid Build Coastguard Worker DE_ASSERT(false);
92*35238bceSAndroid Build Coastguard Worker return 0;
93*35238bceSAndroid Build Coastguard Worker }
94*35238bceSAndroid Build Coastguard Worker }
95*35238bceSAndroid Build Coastguard Worker
96*35238bceSAndroid Build Coastguard Worker class GetCurrentContextCase : public SingleContextRenderCase, private eglu::CallLogWrapper
97*35238bceSAndroid Build Coastguard Worker {
98*35238bceSAndroid Build Coastguard Worker public:
GetCurrentContextCase(EglTestContext & eglTestCtx,const char * name,const char * description,const eglu::FilterList & filters,EGLint surfaceTypeMask)99*35238bceSAndroid Build Coastguard Worker GetCurrentContextCase(EglTestContext &eglTestCtx, const char *name, const char *description,
100*35238bceSAndroid Build Coastguard Worker const eglu::FilterList &filters, EGLint surfaceTypeMask)
101*35238bceSAndroid Build Coastguard Worker : SingleContextRenderCase(eglTestCtx, name, description, getBuildClientAPIMask(), surfaceTypeMask, filters)
102*35238bceSAndroid Build Coastguard Worker , eglu::CallLogWrapper(eglTestCtx.getLibrary(), m_testCtx.getLog())
103*35238bceSAndroid Build Coastguard Worker {
104*35238bceSAndroid Build Coastguard Worker }
105*35238bceSAndroid Build Coastguard Worker
executeForContext(EGLDisplay display,EGLContext context,EGLSurface surface,const Config & config)106*35238bceSAndroid Build Coastguard Worker void executeForContext(EGLDisplay display, EGLContext context, EGLSurface surface, const Config &config)
107*35238bceSAndroid Build Coastguard Worker {
108*35238bceSAndroid Build Coastguard Worker const Library &egl = m_eglTestCtx.getLibrary();
109*35238bceSAndroid Build Coastguard Worker TestLog &log = m_testCtx.getLog();
110*35238bceSAndroid Build Coastguard Worker
111*35238bceSAndroid Build Coastguard Worker DE_UNREF(display);
112*35238bceSAndroid Build Coastguard Worker DE_UNREF(surface);
113*35238bceSAndroid Build Coastguard Worker DE_UNREF(config);
114*35238bceSAndroid Build Coastguard Worker
115*35238bceSAndroid Build Coastguard Worker enableLogging(true);
116*35238bceSAndroid Build Coastguard Worker
117*35238bceSAndroid Build Coastguard Worker const EGLContext gotContext = eglGetCurrentContext();
118*35238bceSAndroid Build Coastguard Worker EGLU_CHECK_MSG(egl, "eglGetCurrentContext");
119*35238bceSAndroid Build Coastguard Worker
120*35238bceSAndroid Build Coastguard Worker if (gotContext == context)
121*35238bceSAndroid Build Coastguard Worker {
122*35238bceSAndroid Build Coastguard Worker log << TestLog::Message << " Pass" << TestLog::EndMessage;
123*35238bceSAndroid Build Coastguard Worker }
124*35238bceSAndroid Build Coastguard Worker else if (gotContext == EGL_NO_CONTEXT)
125*35238bceSAndroid Build Coastguard Worker {
126*35238bceSAndroid Build Coastguard Worker log << TestLog::Message << " Fail, got EGL_NO_CONTEXT" << TestLog::EndMessage;
127*35238bceSAndroid Build Coastguard Worker m_testCtx.setTestResult(QP_TEST_RESULT_FAIL, "Unexpected EGL_NO_CONTEXT");
128*35238bceSAndroid Build Coastguard Worker }
129*35238bceSAndroid Build Coastguard Worker else if (gotContext != context)
130*35238bceSAndroid Build Coastguard Worker {
131*35238bceSAndroid Build Coastguard Worker log << TestLog::Message << " Fail, call returned the wrong context. Expected: " << tcu::toHex(context)
132*35238bceSAndroid Build Coastguard Worker << ", got: " << tcu::toHex(gotContext) << TestLog::EndMessage;
133*35238bceSAndroid Build Coastguard Worker m_testCtx.setTestResult(QP_TEST_RESULT_FAIL, "Invalid context");
134*35238bceSAndroid Build Coastguard Worker }
135*35238bceSAndroid Build Coastguard Worker
136*35238bceSAndroid Build Coastguard Worker enableLogging(false);
137*35238bceSAndroid Build Coastguard Worker }
138*35238bceSAndroid Build Coastguard Worker };
139*35238bceSAndroid Build Coastguard Worker
140*35238bceSAndroid Build Coastguard Worker class GetCurrentSurfaceCase : public SingleContextRenderCase, private eglu::CallLogWrapper
141*35238bceSAndroid Build Coastguard Worker {
142*35238bceSAndroid Build Coastguard Worker public:
GetCurrentSurfaceCase(EglTestContext & eglTestCtx,const char * name,const char * description,const eglu::FilterList & filters,EGLint surfaceTypeMask)143*35238bceSAndroid Build Coastguard Worker GetCurrentSurfaceCase(EglTestContext &eglTestCtx, const char *name, const char *description,
144*35238bceSAndroid Build Coastguard Worker const eglu::FilterList &filters, EGLint surfaceTypeMask)
145*35238bceSAndroid Build Coastguard Worker : SingleContextRenderCase(eglTestCtx, name, description, getBuildClientAPIMask(), surfaceTypeMask, filters)
146*35238bceSAndroid Build Coastguard Worker , eglu::CallLogWrapper(eglTestCtx.getLibrary(), m_testCtx.getLog())
147*35238bceSAndroid Build Coastguard Worker {
148*35238bceSAndroid Build Coastguard Worker }
149*35238bceSAndroid Build Coastguard Worker
executeForContext(EGLDisplay display,EGLContext context,EGLSurface surface,const Config & config)150*35238bceSAndroid Build Coastguard Worker void executeForContext(EGLDisplay display, EGLContext context, EGLSurface surface, const Config &config)
151*35238bceSAndroid Build Coastguard Worker {
152*35238bceSAndroid Build Coastguard Worker const Library &egl = m_eglTestCtx.getLibrary();
153*35238bceSAndroid Build Coastguard Worker TestLog &log = m_testCtx.getLog();
154*35238bceSAndroid Build Coastguard Worker
155*35238bceSAndroid Build Coastguard Worker DE_UNREF(display);
156*35238bceSAndroid Build Coastguard Worker DE_UNREF(context);
157*35238bceSAndroid Build Coastguard Worker DE_UNREF(config);
158*35238bceSAndroid Build Coastguard Worker
159*35238bceSAndroid Build Coastguard Worker enableLogging(true);
160*35238bceSAndroid Build Coastguard Worker
161*35238bceSAndroid Build Coastguard Worker const EGLContext gotReadSurface = eglGetCurrentSurface(EGL_READ);
162*35238bceSAndroid Build Coastguard Worker EGLU_CHECK_MSG(egl, "eglGetCurrentSurface(EGL_READ)");
163*35238bceSAndroid Build Coastguard Worker
164*35238bceSAndroid Build Coastguard Worker const EGLContext gotDrawSurface = eglGetCurrentSurface(EGL_DRAW);
165*35238bceSAndroid Build Coastguard Worker EGLU_CHECK_MSG(egl, "eglGetCurrentSurface(EGL_DRAW)");
166*35238bceSAndroid Build Coastguard Worker
167*35238bceSAndroid Build Coastguard Worker if (gotReadSurface == surface && gotDrawSurface == surface)
168*35238bceSAndroid Build Coastguard Worker {
169*35238bceSAndroid Build Coastguard Worker log << TestLog::Message << " Pass" << TestLog::EndMessage;
170*35238bceSAndroid Build Coastguard Worker }
171*35238bceSAndroid Build Coastguard Worker else
172*35238bceSAndroid Build Coastguard Worker {
173*35238bceSAndroid Build Coastguard Worker log << TestLog::Message << " Fail, read surface: " << tcu::toHex(gotReadSurface)
174*35238bceSAndroid Build Coastguard Worker << ", draw surface: " << tcu::toHex(gotDrawSurface) << ", expected: " << tcu::toHex(surface)
175*35238bceSAndroid Build Coastguard Worker << TestLog::EndMessage;
176*35238bceSAndroid Build Coastguard Worker m_testCtx.setTestResult(QP_TEST_RESULT_FAIL, "Invalid surface");
177*35238bceSAndroid Build Coastguard Worker }
178*35238bceSAndroid Build Coastguard Worker
179*35238bceSAndroid Build Coastguard Worker enableLogging(false);
180*35238bceSAndroid Build Coastguard Worker }
181*35238bceSAndroid Build Coastguard Worker };
182*35238bceSAndroid Build Coastguard Worker
183*35238bceSAndroid Build Coastguard Worker class GetCurrentDisplayCase : public SingleContextRenderCase, private eglu::CallLogWrapper
184*35238bceSAndroid Build Coastguard Worker {
185*35238bceSAndroid Build Coastguard Worker public:
GetCurrentDisplayCase(EglTestContext & eglTestCtx,const char * name,const char * description,const eglu::FilterList & filters,EGLint surfaceTypeMask)186*35238bceSAndroid Build Coastguard Worker GetCurrentDisplayCase(EglTestContext &eglTestCtx, const char *name, const char *description,
187*35238bceSAndroid Build Coastguard Worker const eglu::FilterList &filters, EGLint surfaceTypeMask)
188*35238bceSAndroid Build Coastguard Worker : SingleContextRenderCase(eglTestCtx, name, description, getBuildClientAPIMask(), surfaceTypeMask, filters)
189*35238bceSAndroid Build Coastguard Worker , eglu::CallLogWrapper(eglTestCtx.getLibrary(), m_testCtx.getLog())
190*35238bceSAndroid Build Coastguard Worker {
191*35238bceSAndroid Build Coastguard Worker }
192*35238bceSAndroid Build Coastguard Worker
executeForContext(EGLDisplay display,EGLContext context,EGLSurface surface,const Config & config)193*35238bceSAndroid Build Coastguard Worker void executeForContext(EGLDisplay display, EGLContext context, EGLSurface surface, const Config &config)
194*35238bceSAndroid Build Coastguard Worker {
195*35238bceSAndroid Build Coastguard Worker const Library &egl = m_eglTestCtx.getLibrary();
196*35238bceSAndroid Build Coastguard Worker TestLog &log = m_testCtx.getLog();
197*35238bceSAndroid Build Coastguard Worker
198*35238bceSAndroid Build Coastguard Worker DE_UNREF(surface && context);
199*35238bceSAndroid Build Coastguard Worker DE_UNREF(config);
200*35238bceSAndroid Build Coastguard Worker
201*35238bceSAndroid Build Coastguard Worker enableLogging(true);
202*35238bceSAndroid Build Coastguard Worker
203*35238bceSAndroid Build Coastguard Worker const EGLDisplay gotDisplay = eglGetCurrentDisplay();
204*35238bceSAndroid Build Coastguard Worker EGLU_CHECK_MSG(egl, "eglGetCurrentDisplay");
205*35238bceSAndroid Build Coastguard Worker
206*35238bceSAndroid Build Coastguard Worker if (gotDisplay == display)
207*35238bceSAndroid Build Coastguard Worker {
208*35238bceSAndroid Build Coastguard Worker log << TestLog::Message << " Pass" << TestLog::EndMessage;
209*35238bceSAndroid Build Coastguard Worker }
210*35238bceSAndroid Build Coastguard Worker else if (gotDisplay == EGL_NO_DISPLAY)
211*35238bceSAndroid Build Coastguard Worker {
212*35238bceSAndroid Build Coastguard Worker log << TestLog::Message << " Fail, got EGL_NO_DISPLAY" << TestLog::EndMessage;
213*35238bceSAndroid Build Coastguard Worker m_testCtx.setTestResult(QP_TEST_RESULT_FAIL, "Unexpected EGL_NO_DISPLAY");
214*35238bceSAndroid Build Coastguard Worker }
215*35238bceSAndroid Build Coastguard Worker else if (gotDisplay != display)
216*35238bceSAndroid Build Coastguard Worker {
217*35238bceSAndroid Build Coastguard Worker log << TestLog::Message << " Fail, call returned the wrong display. Expected: " << tcu::toHex(display)
218*35238bceSAndroid Build Coastguard Worker << ", got: " << tcu::toHex(gotDisplay) << TestLog::EndMessage;
219*35238bceSAndroid Build Coastguard Worker m_testCtx.setTestResult(QP_TEST_RESULT_FAIL, "Invalid display");
220*35238bceSAndroid Build Coastguard Worker }
221*35238bceSAndroid Build Coastguard Worker
222*35238bceSAndroid Build Coastguard Worker enableLogging(false);
223*35238bceSAndroid Build Coastguard Worker }
224*35238bceSAndroid Build Coastguard Worker };
225*35238bceSAndroid Build Coastguard Worker
226*35238bceSAndroid Build Coastguard Worker class QueryContextCase : public SingleContextRenderCase, private eglu::CallLogWrapper
227*35238bceSAndroid Build Coastguard Worker {
228*35238bceSAndroid Build Coastguard Worker public:
QueryContextCase(EglTestContext & eglTestCtx,const char * name,const char * description,const eglu::FilterList & filters,EGLint surfaceTypeMask)229*35238bceSAndroid Build Coastguard Worker QueryContextCase(EglTestContext &eglTestCtx, const char *name, const char *description,
230*35238bceSAndroid Build Coastguard Worker const eglu::FilterList &filters, EGLint surfaceTypeMask)
231*35238bceSAndroid Build Coastguard Worker : SingleContextRenderCase(eglTestCtx, name, description, getBuildClientAPIMask(), surfaceTypeMask, filters)
232*35238bceSAndroid Build Coastguard Worker , eglu::CallLogWrapper(eglTestCtx.getLibrary(), m_testCtx.getLog())
233*35238bceSAndroid Build Coastguard Worker {
234*35238bceSAndroid Build Coastguard Worker }
235*35238bceSAndroid Build Coastguard Worker
getContextAttrib(EGLDisplay display,EGLContext context,EGLint attrib)236*35238bceSAndroid Build Coastguard Worker EGLint getContextAttrib(EGLDisplay display, EGLContext context, EGLint attrib)
237*35238bceSAndroid Build Coastguard Worker {
238*35238bceSAndroid Build Coastguard Worker const Library &egl = m_eglTestCtx.getLibrary();
239*35238bceSAndroid Build Coastguard Worker EGLint value;
240*35238bceSAndroid Build Coastguard Worker EGLU_CHECK_CALL(egl, queryContext(display, context, attrib, &value));
241*35238bceSAndroid Build Coastguard Worker
242*35238bceSAndroid Build Coastguard Worker return value;
243*35238bceSAndroid Build Coastguard Worker }
244*35238bceSAndroid Build Coastguard Worker
executeForContext(EGLDisplay display,EGLContext context,EGLSurface surface,const Config & config)245*35238bceSAndroid Build Coastguard Worker void executeForContext(EGLDisplay display, EGLContext context, EGLSurface surface, const Config &config)
246*35238bceSAndroid Build Coastguard Worker {
247*35238bceSAndroid Build Coastguard Worker const Library &egl = m_eglTestCtx.getLibrary();
248*35238bceSAndroid Build Coastguard Worker TestLog &log = m_testCtx.getLog();
249*35238bceSAndroid Build Coastguard Worker const eglu::Version version = eglu::getVersion(egl, display);
250*35238bceSAndroid Build Coastguard Worker
251*35238bceSAndroid Build Coastguard Worker DE_UNREF(surface);
252*35238bceSAndroid Build Coastguard Worker enableLogging(true);
253*35238bceSAndroid Build Coastguard Worker
254*35238bceSAndroid Build Coastguard Worker // Config ID
255*35238bceSAndroid Build Coastguard Worker {
256*35238bceSAndroid Build Coastguard Worker const EGLint configID = getContextAttrib(display, context, EGL_CONFIG_ID);
257*35238bceSAndroid Build Coastguard Worker const EGLint surfaceConfigID = eglu::getConfigAttribInt(egl, display, config.config, EGL_CONFIG_ID);
258*35238bceSAndroid Build Coastguard Worker
259*35238bceSAndroid Build Coastguard Worker if (configID != surfaceConfigID)
260*35238bceSAndroid Build Coastguard Worker {
261*35238bceSAndroid Build Coastguard Worker log << TestLog::Message << " Fail, config ID doesn't match the one used to create the context."
262*35238bceSAndroid Build Coastguard Worker << TestLog::EndMessage;
263*35238bceSAndroid Build Coastguard Worker m_testCtx.setTestResult(QP_TEST_RESULT_FAIL, "Invalid config ID");
264*35238bceSAndroid Build Coastguard Worker }
265*35238bceSAndroid Build Coastguard Worker }
266*35238bceSAndroid Build Coastguard Worker
267*35238bceSAndroid Build Coastguard Worker // Client API type
268*35238bceSAndroid Build Coastguard Worker if (version >= eglu::Version(1, 2))
269*35238bceSAndroid Build Coastguard Worker {
270*35238bceSAndroid Build Coastguard Worker const EGLint clientType = getContextAttrib(display, context, EGL_CONTEXT_CLIENT_TYPE);
271*35238bceSAndroid Build Coastguard Worker
272*35238bceSAndroid Build Coastguard Worker if (clientType != getClientTypeFromAPIBit(config.apiBits))
273*35238bceSAndroid Build Coastguard Worker {
274*35238bceSAndroid Build Coastguard Worker log << TestLog::Message << " Fail, client API type doesn't match." << TestLog::EndMessage;
275*35238bceSAndroid Build Coastguard Worker m_testCtx.setTestResult(QP_TEST_RESULT_FAIL, "Invalid client API type");
276*35238bceSAndroid Build Coastguard Worker }
277*35238bceSAndroid Build Coastguard Worker }
278*35238bceSAndroid Build Coastguard Worker
279*35238bceSAndroid Build Coastguard Worker // Client API version
280*35238bceSAndroid Build Coastguard Worker if (version >= eglu::Version(1, 3))
281*35238bceSAndroid Build Coastguard Worker {
282*35238bceSAndroid Build Coastguard Worker const EGLint clientVersion = getContextAttrib(display, context, EGL_CONTEXT_CLIENT_VERSION);
283*35238bceSAndroid Build Coastguard Worker
284*35238bceSAndroid Build Coastguard Worker // \todo [2014-10-21 mika] Query actual supported api version from client api to make this check stricter.
285*35238bceSAndroid Build Coastguard Worker if (clientVersion < getMinClientMajorVersion(config.apiBits))
286*35238bceSAndroid Build Coastguard Worker {
287*35238bceSAndroid Build Coastguard Worker log << TestLog::Message << " Fail, client API version doesn't match." << TestLog::EndMessage;
288*35238bceSAndroid Build Coastguard Worker m_testCtx.setTestResult(QP_TEST_RESULT_FAIL, "Invalid client API version");
289*35238bceSAndroid Build Coastguard Worker }
290*35238bceSAndroid Build Coastguard Worker }
291*35238bceSAndroid Build Coastguard Worker
292*35238bceSAndroid Build Coastguard Worker // Render buffer
293*35238bceSAndroid Build Coastguard Worker if (version >= eglu::Version(1, 2))
294*35238bceSAndroid Build Coastguard Worker {
295*35238bceSAndroid Build Coastguard Worker const EGLint renderBuffer = getContextAttrib(display, context, EGL_RENDER_BUFFER);
296*35238bceSAndroid Build Coastguard Worker
297*35238bceSAndroid Build Coastguard Worker if (config.surfaceTypeBit == EGL_PIXMAP_BIT && renderBuffer != EGL_SINGLE_BUFFER)
298*35238bceSAndroid Build Coastguard Worker {
299*35238bceSAndroid Build Coastguard Worker log << TestLog::Message << " Fail, render buffer should be EGL_SINGLE_BUFFER for a pixmap surface."
300*35238bceSAndroid Build Coastguard Worker << TestLog::EndMessage;
301*35238bceSAndroid Build Coastguard Worker m_testCtx.setTestResult(QP_TEST_RESULT_FAIL, "Invalid render buffer");
302*35238bceSAndroid Build Coastguard Worker }
303*35238bceSAndroid Build Coastguard Worker else if (config.surfaceTypeBit == EGL_PBUFFER_BIT && renderBuffer != EGL_BACK_BUFFER)
304*35238bceSAndroid Build Coastguard Worker {
305*35238bceSAndroid Build Coastguard Worker log << TestLog::Message << " Fail, render buffer should be EGL_BACK_BUFFER for a pbuffer surface."
306*35238bceSAndroid Build Coastguard Worker << TestLog::EndMessage;
307*35238bceSAndroid Build Coastguard Worker m_testCtx.setTestResult(QP_TEST_RESULT_FAIL, "Invalid render buffer");
308*35238bceSAndroid Build Coastguard Worker }
309*35238bceSAndroid Build Coastguard Worker else if (config.surfaceTypeBit == EGL_WINDOW_BIT && renderBuffer != EGL_SINGLE_BUFFER &&
310*35238bceSAndroid Build Coastguard Worker renderBuffer != EGL_BACK_BUFFER)
311*35238bceSAndroid Build Coastguard Worker {
312*35238bceSAndroid Build Coastguard Worker log << TestLog::Message
313*35238bceSAndroid Build Coastguard Worker << " Fail, render buffer should be either EGL_SINGLE_BUFFER or EGL_BACK_BUFFER for a window "
314*35238bceSAndroid Build Coastguard Worker "surface."
315*35238bceSAndroid Build Coastguard Worker << TestLog::EndMessage;
316*35238bceSAndroid Build Coastguard Worker m_testCtx.setTestResult(QP_TEST_RESULT_FAIL, "Invalid render buffer");
317*35238bceSAndroid Build Coastguard Worker }
318*35238bceSAndroid Build Coastguard Worker }
319*35238bceSAndroid Build Coastguard Worker
320*35238bceSAndroid Build Coastguard Worker enableLogging(false);
321*35238bceSAndroid Build Coastguard Worker
322*35238bceSAndroid Build Coastguard Worker log << TestLog::Message << " Pass" << TestLog::EndMessage;
323*35238bceSAndroid Build Coastguard Worker }
324*35238bceSAndroid Build Coastguard Worker };
325*35238bceSAndroid Build Coastguard Worker
326*35238bceSAndroid Build Coastguard Worker class QueryAPICase : public TestCase, private eglu::CallLogWrapper
327*35238bceSAndroid Build Coastguard Worker {
328*35238bceSAndroid Build Coastguard Worker public:
QueryAPICase(EglTestContext & eglTestCtx,const char * name,const char * description)329*35238bceSAndroid Build Coastguard Worker QueryAPICase(EglTestContext &eglTestCtx, const char *name, const char *description)
330*35238bceSAndroid Build Coastguard Worker : TestCase(eglTestCtx, name, description)
331*35238bceSAndroid Build Coastguard Worker , CallLogWrapper(eglTestCtx.getLibrary(), eglTestCtx.getTestContext().getLog())
332*35238bceSAndroid Build Coastguard Worker {
333*35238bceSAndroid Build Coastguard Worker }
334*35238bceSAndroid Build Coastguard Worker
init(void)335*35238bceSAndroid Build Coastguard Worker void init(void)
336*35238bceSAndroid Build Coastguard Worker {
337*35238bceSAndroid Build Coastguard Worker m_testCtx.setTestResult(QP_TEST_RESULT_PASS, "Pass");
338*35238bceSAndroid Build Coastguard Worker }
339*35238bceSAndroid Build Coastguard Worker
iterate(void)340*35238bceSAndroid Build Coastguard Worker IterateResult iterate(void)
341*35238bceSAndroid Build Coastguard Worker {
342*35238bceSAndroid Build Coastguard Worker const Library &egl = m_eglTestCtx.getLibrary();
343*35238bceSAndroid Build Coastguard Worker EGLDisplay display = eglu::getAndInitDisplay(m_eglTestCtx.getNativeDisplay());
344*35238bceSAndroid Build Coastguard Worker tcu::TestLog &log = m_testCtx.getLog();
345*35238bceSAndroid Build Coastguard Worker const EGLenum apis[] = {EGL_OPENGL_API, EGL_OPENGL_ES_API, EGL_OPENVG_API};
346*35238bceSAndroid Build Coastguard Worker const vector<EGLenum> supportedAPIs = eglu::getClientAPIs(egl, display);
347*35238bceSAndroid Build Coastguard Worker
348*35238bceSAndroid Build Coastguard Worker enableLogging(true);
349*35238bceSAndroid Build Coastguard Worker
350*35238bceSAndroid Build Coastguard Worker {
351*35238bceSAndroid Build Coastguard Worker const EGLenum api = eglQueryAPI();
352*35238bceSAndroid Build Coastguard Worker
353*35238bceSAndroid Build Coastguard Worker if (api != EGL_OPENGL_ES_API &&
354*35238bceSAndroid Build Coastguard Worker (de::contains(supportedAPIs.begin(), supportedAPIs.end(), EGL_OPENGL_ES_API)))
355*35238bceSAndroid Build Coastguard Worker {
356*35238bceSAndroid Build Coastguard Worker log << TestLog::Message
357*35238bceSAndroid Build Coastguard Worker << " Fail, initial value should be EGL_OPENGL_ES_API if OpenGL ES is supported."
358*35238bceSAndroid Build Coastguard Worker << TestLog::EndMessage;
359*35238bceSAndroid Build Coastguard Worker m_testCtx.setTestResult(QP_TEST_RESULT_FAIL, "Invalid default value");
360*35238bceSAndroid Build Coastguard Worker }
361*35238bceSAndroid Build Coastguard Worker else if (api != EGL_NONE && !(de::contains(supportedAPIs.begin(), supportedAPIs.end(), EGL_OPENGL_ES_API)))
362*35238bceSAndroid Build Coastguard Worker {
363*35238bceSAndroid Build Coastguard Worker log << TestLog::Message << " Fail, initial value should be EGL_NONE if OpenGL ES is not supported."
364*35238bceSAndroid Build Coastguard Worker << TestLog::EndMessage;
365*35238bceSAndroid Build Coastguard Worker m_testCtx.setTestResult(QP_TEST_RESULT_FAIL, "Invalid default value");
366*35238bceSAndroid Build Coastguard Worker }
367*35238bceSAndroid Build Coastguard Worker }
368*35238bceSAndroid Build Coastguard Worker
369*35238bceSAndroid Build Coastguard Worker for (int ndx = 0; ndx < DE_LENGTH_OF_ARRAY(apis); ndx++)
370*35238bceSAndroid Build Coastguard Worker {
371*35238bceSAndroid Build Coastguard Worker const EGLenum api = apis[ndx];
372*35238bceSAndroid Build Coastguard Worker
373*35238bceSAndroid Build Coastguard Worker log << TestLog::Message << TestLog::EndMessage;
374*35238bceSAndroid Build Coastguard Worker
375*35238bceSAndroid Build Coastguard Worker if (de::contains(supportedAPIs.begin(), supportedAPIs.end(), api))
376*35238bceSAndroid Build Coastguard Worker {
377*35238bceSAndroid Build Coastguard Worker egl.bindAPI(api);
378*35238bceSAndroid Build Coastguard Worker
379*35238bceSAndroid Build Coastguard Worker if (api != egl.queryAPI())
380*35238bceSAndroid Build Coastguard Worker {
381*35238bceSAndroid Build Coastguard Worker log << TestLog::Message << " Fail, return value does not match previously bound API."
382*35238bceSAndroid Build Coastguard Worker << TestLog::EndMessage;
383*35238bceSAndroid Build Coastguard Worker m_testCtx.setTestResult(QP_TEST_RESULT_FAIL, "Invalid return value");
384*35238bceSAndroid Build Coastguard Worker }
385*35238bceSAndroid Build Coastguard Worker }
386*35238bceSAndroid Build Coastguard Worker else
387*35238bceSAndroid Build Coastguard Worker {
388*35238bceSAndroid Build Coastguard Worker log << TestLog::Message << eglu::getAPIStr(api) << " not supported." << TestLog::EndMessage;
389*35238bceSAndroid Build Coastguard Worker }
390*35238bceSAndroid Build Coastguard Worker }
391*35238bceSAndroid Build Coastguard Worker
392*35238bceSAndroid Build Coastguard Worker enableLogging(false);
393*35238bceSAndroid Build Coastguard Worker eglTerminate(display);
394*35238bceSAndroid Build Coastguard Worker return STOP;
395*35238bceSAndroid Build Coastguard Worker }
396*35238bceSAndroid Build Coastguard Worker };
397*35238bceSAndroid Build Coastguard Worker
QueryContextTests(EglTestContext & eglTestCtx)398*35238bceSAndroid Build Coastguard Worker QueryContextTests::QueryContextTests(EglTestContext &eglTestCtx)
399*35238bceSAndroid Build Coastguard Worker : TestCaseGroup(eglTestCtx, "query_context", "Rendering context query tests")
400*35238bceSAndroid Build Coastguard Worker {
401*35238bceSAndroid Build Coastguard Worker }
402*35238bceSAndroid Build Coastguard Worker
~QueryContextTests(void)403*35238bceSAndroid Build Coastguard Worker QueryContextTests::~QueryContextTests(void)
404*35238bceSAndroid Build Coastguard Worker {
405*35238bceSAndroid Build Coastguard Worker }
406*35238bceSAndroid Build Coastguard Worker
407*35238bceSAndroid Build Coastguard Worker template <class QueryContextClass>
createQueryContextGroups(EglTestContext & eglTestCtx,tcu::TestCaseGroup * group)408*35238bceSAndroid Build Coastguard Worker void createQueryContextGroups(EglTestContext &eglTestCtx, tcu::TestCaseGroup *group)
409*35238bceSAndroid Build Coastguard Worker {
410*35238bceSAndroid Build Coastguard Worker std::vector<RenderFilterList> filterLists;
411*35238bceSAndroid Build Coastguard Worker
412*35238bceSAndroid Build Coastguard Worker getDefaultRenderFilterLists(filterLists, eglu::FilterList());
413*35238bceSAndroid Build Coastguard Worker
414*35238bceSAndroid Build Coastguard Worker for (std::vector<RenderFilterList>::const_iterator listIter = filterLists.begin(); listIter != filterLists.end();
415*35238bceSAndroid Build Coastguard Worker listIter++)
416*35238bceSAndroid Build Coastguard Worker group->addChild(
417*35238bceSAndroid Build Coastguard Worker new QueryContextClass(eglTestCtx, listIter->getName(), "", *listIter, listIter->getSurfaceTypeMask()));
418*35238bceSAndroid Build Coastguard Worker }
419*35238bceSAndroid Build Coastguard Worker
init(void)420*35238bceSAndroid Build Coastguard Worker void QueryContextTests::init(void)
421*35238bceSAndroid Build Coastguard Worker {
422*35238bceSAndroid Build Coastguard Worker {
423*35238bceSAndroid Build Coastguard Worker tcu::TestCaseGroup *simpleGroup = new tcu::TestCaseGroup(m_testCtx, "simple", "Simple API tests");
424*35238bceSAndroid Build Coastguard Worker addChild(simpleGroup);
425*35238bceSAndroid Build Coastguard Worker
426*35238bceSAndroid Build Coastguard Worker simpleGroup->addChild(new QueryAPICase(m_eglTestCtx, "query_api", "eglQueryAPI() test"));
427*35238bceSAndroid Build Coastguard Worker }
428*35238bceSAndroid Build Coastguard Worker
429*35238bceSAndroid Build Coastguard Worker // eglGetCurrentContext
430*35238bceSAndroid Build Coastguard Worker {
431*35238bceSAndroid Build Coastguard Worker tcu::TestCaseGroup *getCurrentContextGroup =
432*35238bceSAndroid Build Coastguard Worker new tcu::TestCaseGroup(m_testCtx, "get_current_context", "eglGetCurrentContext() tests");
433*35238bceSAndroid Build Coastguard Worker addChild(getCurrentContextGroup);
434*35238bceSAndroid Build Coastguard Worker
435*35238bceSAndroid Build Coastguard Worker createQueryContextGroups<GetCurrentContextCase>(m_eglTestCtx, getCurrentContextGroup);
436*35238bceSAndroid Build Coastguard Worker }
437*35238bceSAndroid Build Coastguard Worker
438*35238bceSAndroid Build Coastguard Worker // eglGetCurrentSurface
439*35238bceSAndroid Build Coastguard Worker {
440*35238bceSAndroid Build Coastguard Worker tcu::TestCaseGroup *getCurrentSurfaceGroup =
441*35238bceSAndroid Build Coastguard Worker new tcu::TestCaseGroup(m_testCtx, "get_current_surface", "eglGetCurrentSurface() tests");
442*35238bceSAndroid Build Coastguard Worker addChild(getCurrentSurfaceGroup);
443*35238bceSAndroid Build Coastguard Worker
444*35238bceSAndroid Build Coastguard Worker createQueryContextGroups<GetCurrentSurfaceCase>(m_eglTestCtx, getCurrentSurfaceGroup);
445*35238bceSAndroid Build Coastguard Worker }
446*35238bceSAndroid Build Coastguard Worker
447*35238bceSAndroid Build Coastguard Worker // eglGetCurrentDisplay
448*35238bceSAndroid Build Coastguard Worker {
449*35238bceSAndroid Build Coastguard Worker tcu::TestCaseGroup *getCurrentDisplayGroup =
450*35238bceSAndroid Build Coastguard Worker new tcu::TestCaseGroup(m_testCtx, "get_current_display", "eglGetCurrentDisplay() tests");
451*35238bceSAndroid Build Coastguard Worker addChild(getCurrentDisplayGroup);
452*35238bceSAndroid Build Coastguard Worker
453*35238bceSAndroid Build Coastguard Worker createQueryContextGroups<GetCurrentDisplayCase>(m_eglTestCtx, getCurrentDisplayGroup);
454*35238bceSAndroid Build Coastguard Worker }
455*35238bceSAndroid Build Coastguard Worker
456*35238bceSAndroid Build Coastguard Worker // eglQueryContext
457*35238bceSAndroid Build Coastguard Worker {
458*35238bceSAndroid Build Coastguard Worker tcu::TestCaseGroup *queryContextGroup =
459*35238bceSAndroid Build Coastguard Worker new tcu::TestCaseGroup(m_testCtx, "query_context", "eglQueryContext() tests");
460*35238bceSAndroid Build Coastguard Worker addChild(queryContextGroup);
461*35238bceSAndroid Build Coastguard Worker
462*35238bceSAndroid Build Coastguard Worker createQueryContextGroups<QueryContextCase>(m_eglTestCtx, queryContextGroup);
463*35238bceSAndroid Build Coastguard Worker }
464*35238bceSAndroid Build Coastguard Worker }
465*35238bceSAndroid Build Coastguard Worker
466*35238bceSAndroid Build Coastguard Worker } // namespace egl
467*35238bceSAndroid Build Coastguard Worker } // namespace deqp
468