blob: 75ae58eb433e830373720b432096ced7dd2dca00 [file] [log] [blame]
Jarkko Poyry3c827362014-09-02 11:48:52 +03001/*-------------------------------------------------------------------------
2 * drawElements Quality Program EGL Module
3 * ---------------------------------------
4 *
5 * Copyright 2014 The Android Open Source Project
6 *
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
10 *
11 * http://www.apache.org/licenses/LICENSE-2.0
12 *
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.
18 *
19 *//*!
20 * \file
21 * \brief EGL_EXT_client_extensions tests
22 *//*--------------------------------------------------------------------*/
23
24#include "teglClientExtensionTests.hpp"
25
26#include "tcuTestLog.hpp"
27
Pyry Haulos3c67e4f2014-12-19 15:45:39 -080028#include "egluUtil.hpp"
29
30#include "eglwLibrary.hpp"
31#include "eglwEnums.hpp"
32
33#include "deStringUtil.hpp"
34#include "deSTLUtil.hpp"
Jarkko Poyry3c827362014-09-02 11:48:52 +030035
36#include <vector>
37#include <set>
38#include <string>
39#include <sstream>
40
41using std::string;
42using std::vector;
43using std::set;
44
45using tcu::TestLog;
46
Pyry Haulos3c67e4f2014-12-19 15:45:39 -080047using namespace eglw;
48
Jarkko Poyry3c827362014-09-02 11:48:52 +030049namespace deqp
50{
51namespace egl
52{
53namespace
54{
55
56static const char* const s_displayExtensionList[] =
57{
58 "EGL_KHR_config_attribs",
59 "EGL_KHR_lock_surface",
60 "EGL_KHR_image",
61 "EGL_KHR_vg_parent_image",
62 "EGL_KHR_gl_texture_2D_image",
63 "EGL_KHR_gl_texture_cubemap_image",
64 "EGL_KHR_gl_texture_3D_image",
65 "EGL_KHR_gl_renderbuffer_image",
66 "EGL_KHR_reusable_sync",
67 "EGL_KHR_image_base",
68 "EGL_KHR_image_pixmap",
69 "EGL_IMG_context_priority",
70 "EGL_KHR_lock_surface2",
71 "EGL_NV_coverage_sample",
72 "EGL_NV_depth_nonlinear",
73 "EGL_NV_sync",
74 "EGL_KHR_fence_sync",
75 "EGL_HI_clientpixmap",
76 "EGL_HI_colorformats",
77 "EGL_MESA_drm_image",
78 "EGL_NV_post_sub_buffer",
79 "EGL_ANGLE_query_surface_pointer",
80 "EGL_ANGLE_surface_d3d_texture_2d_share_handle",
81 "EGL_NV_coverage_sample_resolve",
82// "EGL_NV_system_time", \todo [mika] Unclear which one this is
83 "EGL_KHR_stream",
84 "EGL_KHR_stream_consumer_gltexture",
85 "EGL_KHR_stream_producer_eglsurface",
86 "EGL_KHR_stream_producer_aldatalocator",
87 "EGL_KHR_stream_fifo",
88 "EGL_EXT_create_context_robustness",
89 "EGL_ANGLE_d3d_share_handle_client_buffer",
90 "EGL_KHR_create_context",
91 "EGL_KHR_surfaceless_context",
92 "EGL_KHR_stream_cross_process_fd",
93 "EGL_EXT_multiview_window",
94 "EGL_KHR_wait_sync",
95 "EGL_NV_post_convert_rounding",
96 "EGL_NV_native_query",
97 "EGL_NV_3dvision_surface",
98 "EGL_ANDROID_framebuffer_target",
99 "EGL_ANDROID_blob_cache",
100 "EGL_ANDROID_image_native_buffer",
101 "EGL_ANDROID_native_fence_sync",
102 "EGL_ANDROID_recordable",
103 "EGL_EXT_buffer_age",
104 "EGL_EXT_image_dma_buf_import",
105 "EGL_ARM_pixmap_multisample_discard",
106 "EGL_EXT_swap_buffers_with_damage",
107 "EGL_NV_stream_sync",
108 "EGL_KHR_cl_event",
109 "EGL_KHR_get_all_proc_addresses"
110};
111
112static const char* const s_clientExtensionList[] =
113{
114 "EGL_EXT_platform_base",
115 "EGL_EXT_client_extensions",
116 "EGL_EXT_platform_x11",
117 "EGL_KHR_client_get_all_proc_addresses",
118 "EGL_MESA_platform_gbm",
119 "EGL_EXT_platform_wayland"
120};
121
Jarkko Poyry3c827362014-09-02 11:48:52 +0300122class BaseTest : public TestCase
123{
124public:
125 BaseTest (EglTestContext& eglTestCtx);
126 IterateResult iterate (void);
127};
128
129BaseTest::BaseTest (EglTestContext& eglTestCtx)
130 : TestCase(eglTestCtx, "base", "Basic tests for EGL_EXT_client_extensions")
131{
132}
133
134TestCase::IterateResult BaseTest::iterate (void)
135{
Pyry Haulos3c67e4f2014-12-19 15:45:39 -0800136 const Library& egl = m_eglTestCtx.getLibrary();
137 const char* const clientExtesionsStr = egl.queryString(EGL_NO_DISPLAY, EGL_EXTENSIONS);
138 const EGLint eglError = egl.getError();
Jarkko Poyry3c827362014-09-02 11:48:52 +0300139
140 if (eglError == EGL_BAD_DISPLAY)
Pyry Haulos3c67e4f2014-12-19 15:45:39 -0800141 TCU_THROW(NotSupportedError, "EGL_EXT_client_extensions not supported");
Jarkko Poyry3c827362014-09-02 11:48:52 +0300142 else if (eglError != EGL_SUCCESS)
Pyry Haulos3c67e4f2014-12-19 15:45:39 -0800143 throw eglu::Error(eglError, "eglQueryString()", DE_NULL, __FILE__, __LINE__);
Jarkko Poyry3c827362014-09-02 11:48:52 +0300144
145 TCU_CHECK(clientExtesionsStr);
146
147 {
Pyry Haulos3c67e4f2014-12-19 15:45:39 -0800148 bool found = false;
149 std::istringstream stream (clientExtesionsStr);
Jarkko Poyry3c827362014-09-02 11:48:52 +0300150 string extension;
151
152 while (std::getline(stream, extension, ' '))
153 {
154 if (extension == "EGL_EXT_client_extensions")
155 {
156 found = true;
157 break;
158 }
159 }
160
161 if (found)
162 m_testCtx.setTestResult(QP_TEST_RESULT_PASS, "Pass");
163 else
164 {
165 m_testCtx.getLog() << TestLog::Message << "eglQueryString(EGL_NO_DISPLAY, EGL_EXTENSIONS) didn't fail, but extension string doesn't contain EGL_EXT_client_extensions" <<TestLog::EndMessage;
166 m_testCtx.setTestResult(QP_TEST_RESULT_FAIL, "Fail");
167 }
168 }
169
170 return STOP;
171}
172
173class CheckExtensionsTest : public TestCase
174{
175public:
176 CheckExtensionsTest (EglTestContext& eglTestCtx);
177 IterateResult iterate (void);
178};
179
180CheckExtensionsTest::CheckExtensionsTest (EglTestContext& eglTestCtx)
181 : TestCase(eglTestCtx, "extensions", "Check that returned extensions are client or display extensions")
182{
183}
184
185TestCase::IterateResult CheckExtensionsTest::iterate (void)
186{
Pyry Haulos3c67e4f2014-12-19 15:45:39 -0800187 const Library& egl = m_eglTestCtx.getLibrary();
188 bool isOk = true;
189 const char* const clientExtensionsStr = egl.queryString(EGL_NO_DISPLAY, EGL_EXTENSIONS);
190 const EGLint eglQueryError = egl.getError();
Jarkko Poyry3c827362014-09-02 11:48:52 +0300191
Pyry Haulos3c67e4f2014-12-19 15:45:39 -0800192 set<string> knownClientExtensions (s_clientExtensionList, s_clientExtensionList + DE_LENGTH_OF_ARRAY(s_clientExtensionList));
193 set<string> knownDisplayExtensions (s_displayExtensionList, s_displayExtensionList + DE_LENGTH_OF_ARRAY(s_displayExtensionList));
Jarkko Poyry3c827362014-09-02 11:48:52 +0300194
Pyry Haulos3c67e4f2014-12-19 15:45:39 -0800195 vector<string> displayExtensions;
196 vector<string> clientExtensions;
Jarkko Poyry3c827362014-09-02 11:48:52 +0300197
198 if (eglQueryError == EGL_BAD_DISPLAY)
Pyry Haulos3c67e4f2014-12-19 15:45:39 -0800199 TCU_THROW(NotSupportedError, "EGL_EXT_client_extensions not supported");
Jarkko Poyry3c827362014-09-02 11:48:52 +0300200 else if (eglQueryError != EGL_SUCCESS)
Pyry Haulos3c67e4f2014-12-19 15:45:39 -0800201 throw eglu::Error(eglQueryError, "eglQueryString()", DE_NULL, __FILE__, __LINE__);
Jarkko Poyry3c827362014-09-02 11:48:52 +0300202
Pyry Haulos3c67e4f2014-12-19 15:45:39 -0800203 TCU_CHECK(clientExtensionsStr);
Jarkko Poyry3c827362014-09-02 11:48:52 +0300204
Pyry Haulos3c67e4f2014-12-19 15:45:39 -0800205 clientExtensions = de::splitString(clientExtensionsStr, ' ');
206
207 {
208 EGLDisplay display = eglu::getAndInitDisplay(m_eglTestCtx.getNativeDisplay());
209
210 displayExtensions = de::splitString(egl.queryString(display, EGL_EXTENSIONS), ' ');
211
212 egl.terminate(display);
213 }
Jarkko Poyry3c827362014-09-02 11:48:52 +0300214
215 for (int extNdx = 0; extNdx < (int)clientExtensions.size(); extNdx++)
216 {
217 if (knownDisplayExtensions.find(clientExtensions[extNdx]) != knownDisplayExtensions.end())
218 {
219 m_testCtx.getLog() << TestLog::Message << "'" << clientExtensions[extNdx] << "' is not client extension" << TestLog::EndMessage;
220 isOk = false;
221 }
222 }
223
224 for (int extNdx = 0; extNdx < (int)displayExtensions.size(); extNdx++)
225 {
226 if (knownClientExtensions.find(displayExtensions[extNdx]) != knownClientExtensions.end())
227 {
228 m_testCtx.getLog() << TestLog::Message << "'" << displayExtensions[extNdx] << "' is not display extension" << TestLog::EndMessage;
229 isOk = false;
230 }
231 }
232
233 if (isOk)
234 m_testCtx.setTestResult(QP_TEST_RESULT_PASS, "Pass");
235 else
236 m_testCtx.setTestResult(QP_TEST_RESULT_FAIL, "Fail");
237 return STOP;
238}
239
240
241class DisjointTest : public TestCase
242{
243public:
244 DisjointTest (EglTestContext& eglTestCtx);
245 IterateResult iterate (void);
246};
247
248DisjointTest::DisjointTest (EglTestContext& eglTestCtx)
249 : TestCase(eglTestCtx, "disjoint", "Check that client and display extensions are disjoint")
250{
251}
252
253TestCase::IterateResult DisjointTest::iterate (void)
254{
Pyry Haulos3c67e4f2014-12-19 15:45:39 -0800255 const Library& egl = m_eglTestCtx.getLibrary();
256 const char* const clientExtensionsStr = egl.queryString(EGL_NO_DISPLAY, EGL_EXTENSIONS);
257 const EGLint eglQueryError = egl.getError();
Jarkko Poyry3c827362014-09-02 11:48:52 +0300258
259 if (eglQueryError == EGL_BAD_DISPLAY)
Pyry Haulos3c67e4f2014-12-19 15:45:39 -0800260 TCU_THROW(NotSupportedError, "EGL_EXT_client_extensions not supported");
Jarkko Poyry3c827362014-09-02 11:48:52 +0300261 else if (eglQueryError != EGL_SUCCESS)
Pyry Haulos3c67e4f2014-12-19 15:45:39 -0800262 throw eglu::Error(eglQueryError, "eglQueryString()", DE_NULL, __FILE__, __LINE__);
Jarkko Poyry3c827362014-09-02 11:48:52 +0300263
Pyry Haulos3c67e4f2014-12-19 15:45:39 -0800264 vector<string> displayExtensions;
265 vector<string> clientExtensions;
Jarkko Poyry3c827362014-09-02 11:48:52 +0300266
Pyry Haulos3c67e4f2014-12-19 15:45:39 -0800267 clientExtensions = de::splitString(clientExtensionsStr, ' ');
268
269 {
270 EGLDisplay display = eglu::getAndInitDisplay(m_eglTestCtx.getNativeDisplay());
271
272 displayExtensions = de::splitString(egl.queryString(display, EGL_EXTENSIONS), ' ');
273
274 egl.terminate(display);
275 }
Jarkko Poyry3c827362014-09-02 11:48:52 +0300276
277 // Log client extensions
278 {
279 const tcu::ScopedLogSection section(m_testCtx.getLog(), "Client extensions", "Client extensions");
280
281 for (int extNdx = 0; extNdx < (int)clientExtensions.size(); extNdx++)
282 m_testCtx.getLog() << TestLog::Message << clientExtensions[extNdx] << TestLog::EndMessage;
283 }
284
285 // Log display extensions
286 {
287 const tcu::ScopedLogSection section(m_testCtx.getLog(), "Display extensions", "Display extensions");
288
289 for (int extNdx = 0; extNdx < (int)displayExtensions.size(); extNdx++)
290 m_testCtx.getLog() << TestLog::Message << displayExtensions[extNdx] << TestLog::EndMessage;
291 }
292
293 // Check that sets are disjoint
294 {
295 set<string> commonExtensionSet;
296 const set<string> clientExtensionSet(clientExtensions.begin(), clientExtensions.end());
297 const set<string> displayExtensionSet(displayExtensions.begin(), displayExtensions.end());
298
299 for (set<string>::const_iterator iter = clientExtensionSet.begin(); iter != clientExtensionSet.end(); ++iter)
300 {
301 if (displayExtensionSet.find(*iter) != displayExtensionSet.end())
302 commonExtensionSet.insert(*iter);
303 }
304
305 for (set<string>::const_iterator iter = commonExtensionSet.begin(); iter != commonExtensionSet.end(); ++iter)
306 m_testCtx.getLog() << TestLog::Message << "Extension '" << *iter << "' exists in client and display extension sets." << TestLog::EndMessage;
307
308 if (commonExtensionSet.empty())
309 m_testCtx.setTestResult(QP_TEST_RESULT_PASS, "Pass");
310 else
311 {
312 m_testCtx.getLog() << TestLog::Message << "Extension sets are not disjoint" << TestLog::EndMessage;
313 m_testCtx.setTestResult(QP_TEST_RESULT_FAIL, "Fail");
314 }
315 }
316
317 return STOP;
318}
319
320} // anonymous
321
322ClientExtensionTests::ClientExtensionTests (EglTestContext& eglTestCtx)
323 : TestCaseGroup(eglTestCtx, "client_extensions", "Test for EGL_EXT_client_extensions")
324{
325}
326
327void ClientExtensionTests::init (void)
328{
329 addChild(new BaseTest(m_eglTestCtx));
330 addChild(new DisjointTest(m_eglTestCtx));
331 addChild(new CheckExtensionsTest(m_eglTestCtx));
332}
333
334} // egl
335} // deqp