1 /*-------------------------------------------------------------------------
2 * drawElements Quality Program EGL Module
3 * ---------------------------------------
5 * Copyright 2014 The Android Open Source Project
7 * Licensed under the Apache License, Version 2.0 (the "License");
8 * you may not use this file except in compliance with the License.
9 * You may obtain a copy of the License at
11 * http://www.apache.org/licenses/LICENSE-2.0
13 * Unless required by applicable law or agreed to in writing, software
14 * distributed under the License is distributed on an "AS IS" BASIS,
15 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16 * See the License for the specific language governing permissions and
17 * limitations under the License.
21 * \brief EGL_KHR_surfaceless_context extension tests
22 *//*--------------------------------------------------------------------*/
24 #include "teglSurfacelessContextTests.hpp"
25 #include "teglSimpleConfigCase.hpp"
27 #include "egluStrUtil.hpp"
28 #include "egluUtil.hpp"
29 #include "egluUnique.hpp"
31 #include "tcuTestLog.hpp"
33 #include "eglwLibrary.hpp"
34 #include "eglwEnums.hpp"
36 #include "deSTLUtil.hpp"
55 class SurfacelessContextCase : public SimpleConfigCase
58 SurfacelessContextCase (EglTestContext& eglTestCtx, const char* name, const char* description, const eglu::FilterList& filters);
59 ~SurfacelessContextCase (void);
61 void executeForConfig (EGLDisplay display, EGLConfig config);
64 SurfacelessContextCase::SurfacelessContextCase (EglTestContext& eglTestCtx, const char* name, const char* description, const eglu::FilterList& filters)
65 : SimpleConfigCase(eglTestCtx, name, description, filters)
69 SurfacelessContextCase::~SurfacelessContextCase (void)
73 void SurfacelessContextCase::executeForConfig (EGLDisplay display, EGLConfig config)
75 const Library& egl = m_eglTestCtx.getLibrary();
76 TestLog& log = m_testCtx.getLog();
77 const EGLint id = eglu::getConfigAttribInt(egl, display, config, EGL_CONFIG_ID);
78 const EGLint apiBits = eglu::getConfigAttribInt(egl, display, config, EGL_RENDERABLE_TYPE);
80 static const EGLint es1Attrs[] = { EGL_CONTEXT_CLIENT_VERSION, 1, EGL_NONE };
81 static const EGLint es2Attrs[] = { EGL_CONTEXT_CLIENT_VERSION, 2, EGL_NONE };
82 static const EGLint es3Attrs[] = { EGL_CONTEXT_MAJOR_VERSION_KHR, 3, EGL_NONE };
89 const EGLint* ctxAttrs;
92 { "OpenGL", EGL_OPENGL_API, EGL_OPENGL_BIT, DE_NULL },
93 { "OpenGL ES 1", EGL_OPENGL_ES_API, EGL_OPENGL_ES_BIT, es1Attrs },
94 { "OpenGL ES 2", EGL_OPENGL_ES_API, EGL_OPENGL_ES2_BIT, es2Attrs },
95 { "OpenGL ES 3", EGL_OPENGL_ES_API, EGL_OPENGL_ES3_BIT_KHR, es3Attrs },
96 { "OpenVG", EGL_OPENVG_API, EGL_OPENVG_BIT, DE_NULL }
99 if (!eglu::hasExtension(egl, display, "EGL_KHR_surfaceless_context"))
100 TCU_THROW(NotSupportedError, "EGL_KHR_surfaceless_context not supported");
102 for (int apiNdx = 0; apiNdx < (int)DE_LENGTH_OF_ARRAY(apis); apiNdx++)
104 if ((apiBits & apis[apiNdx].apiBit) == 0)
105 continue; // Not supported API
107 log << TestLog::Message << "Creating " << apis[apiNdx].name << " context with config ID " << id << TestLog::EndMessage;
109 EGLU_CHECK_CALL(egl, bindAPI(apis[apiNdx].api));
111 eglu::UniqueContext context(egl, display, egl.createContext(display, config, EGL_NO_CONTEXT, apis[apiNdx].ctxAttrs));
112 EGLU_CHECK_MSG(egl, "eglCreateContext()");
114 if (!egl.makeCurrent(display, EGL_NO_SURFACE, EGL_NO_SURFACE, *context))
116 const EGLenum err = egl.getError();
118 if (err == EGL_BAD_MATCH)
120 log << TestLog::Message << " eglMakeCurrent() failed with EGL_BAD_MATCH. Context doesn't support surfaceless mode." << TestLog::EndMessage;
125 log << TestLog::Message << " Fail, context: " << tcu::toHex(*context) << ", error: " << eglu::getErrorName(err) << TestLog::EndMessage;
126 m_testCtx.setTestResult(QP_TEST_RESULT_FAIL, "Failed to make context current");
131 EGLU_CHECK_CALL(egl, makeCurrent(display, EGL_NO_SURFACE, EGL_NO_SURFACE, EGL_NO_CONTEXT));
133 log << TestLog::Message << " Pass" << TestLog::EndMessage;
141 SurfacelessContextTests::SurfacelessContextTests (EglTestContext& eglTestCtx)
142 : TestCaseGroup (eglTestCtx, "surfaceless_context", "EGL_KHR_surfaceless_context extension tests")
146 void SurfacelessContextTests::init (void)
148 vector<NamedFilterList> filterLists;
149 getDefaultFilterLists(filterLists, eglu::FilterList());
151 for (vector<NamedFilterList>::const_iterator i = filterLists.begin(); i != filterLists.end(); i++)
152 addChild(new SurfacelessContextCase(m_eglTestCtx, i->getName(), i->getDescription(), *i));