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 Surface query tests.
22 *//*--------------------------------------------------------------------*/
24 #include "teglQuerySurfaceTests.hpp"
26 #include "teglSimpleConfigCase.hpp"
28 #include "egluNativeDisplay.hpp"
29 #include "egluNativeWindow.hpp"
30 #include "egluNativePixmap.hpp"
31 #include "egluStrUtil.hpp"
32 #include "egluUtil.hpp"
33 #include "egluUnique.hpp"
35 #include "eglwLibrary.hpp"
36 #include "eglwEnums.hpp"
38 #include "tcuTestLog.hpp"
39 #include "tcuTestContext.hpp"
40 #include "tcuCommandLine.hpp"
42 #include "deUniquePtr.hpp"
52 using eglu::ConfigInfo;
56 static void logSurfaceAttribute (tcu::TestLog& log, EGLint attribute, EGLint value)
58 const char* name = eglu::getSurfaceAttribName(attribute);
59 const eglu::SurfaceAttribValueFmt valueFmt (attribute, value);
61 log << TestLog::Message << " " << name << ": " << valueFmt << TestLog::EndMessage;
64 static void logSurfaceAttributes (tcu::TestLog& log, const Library& egl, EGLDisplay display, EGLSurface surface, const EGLint* attributes, int numAttribs)
66 for (int ndx = 0; ndx < numAttribs; ndx++)
67 logSurfaceAttribute(log, attributes[ndx], eglu::querySurfaceInt(egl, display, surface, attributes[ndx]));
70 static void logCommonSurfaceAttributes (tcu::TestLog& log, const Library& egl, EGLDisplay display, EGLSurface surface)
72 static const EGLint attributes[] =
77 EGL_HORIZONTAL_RESOLUTION,
78 EGL_VERTICAL_RESOLUTION,
79 EGL_MULTISAMPLE_RESOLVE,
80 EGL_PIXEL_ASPECT_RATIO,
87 logSurfaceAttributes(log, egl, display, surface, attributes, DE_LENGTH_OF_ARRAY(attributes));
90 static void logPbufferSurfaceAttributes (tcu::TestLog& log, const Library& egl, EGLDisplay display, EGLSurface surface)
92 static const EGLint attributes[] =
101 logSurfaceAttributes(log, egl, display, surface, attributes, DE_LENGTH_OF_ARRAY(attributes));
104 class QuerySurfaceCase : public SimpleConfigCase
107 QuerySurfaceCase (EglTestContext& eglTestCtx, const char* name, const char* description, const eglu::FilterList& filters);
109 void checkCommonAttributes (EGLDisplay display, EGLSurface surface, const ConfigInfo& info);
110 void checkNonPbufferAttributes (EGLDisplay display, EGLSurface surface);
113 QuerySurfaceCase::QuerySurfaceCase (EglTestContext& eglTestCtx, const char* name, const char* description, const eglu::FilterList& filters)
114 : SimpleConfigCase(eglTestCtx, name, description, filters)
118 void QuerySurfaceCase::checkCommonAttributes (EGLDisplay display, EGLSurface surface, const ConfigInfo& info)
120 const Library& egl = m_eglTestCtx.getLibrary();
121 tcu::TestLog& log = m_testCtx.getLog();
123 // Attributes which are common to all surface types
127 const EGLint id = eglu::querySurfaceInt(egl, display, surface, EGL_CONFIG_ID);
129 if (id != info.configId)
131 log << TestLog::Message << " Fail, config ID " << id << " does not match the one used to create the surface" << TestLog::EndMessage;
132 m_testCtx.setTestResult(QP_TEST_RESULT_FAIL, "Config ID mismatch");
138 const EGLint width = eglu::querySurfaceInt(egl, display, surface, EGL_WIDTH);
139 const EGLint height = eglu::querySurfaceInt(egl, display, surface, EGL_HEIGHT);
141 if (width <= 0 || height <= 0)
143 log << TestLog::Message << " Fail, invalid surface size " << width << "x" << height << TestLog::EndMessage;
144 m_testCtx.setTestResult(QP_TEST_RESULT_FAIL, "Invalid surface size");
148 // Horizontal and vertical resolution
150 const EGLint hRes = eglu::querySurfaceInt(egl, display, surface, EGL_HORIZONTAL_RESOLUTION);
151 const EGLint vRes = eglu::querySurfaceInt(egl, display, surface, EGL_VERTICAL_RESOLUTION);
153 if ((hRes <= 0 || vRes <= 0) && (hRes != EGL_UNKNOWN && vRes != EGL_UNKNOWN))
155 log << TestLog::Message << " Fail, invalid surface resolution " << hRes << "x" << vRes << TestLog::EndMessage;
156 m_testCtx.setTestResult(QP_TEST_RESULT_FAIL, "Invalid surface resolution");
160 // Pixel aspect ratio
162 const EGLint pixelRatio = eglu::querySurfaceInt(egl, display, surface, EGL_PIXEL_ASPECT_RATIO);
164 if (pixelRatio <= 0 && pixelRatio != EGL_UNKNOWN)
166 log << TestLog::Message << " Fail, invalid pixel aspect ratio " << eglu::querySurfaceInt(egl, display, surface, EGL_PIXEL_ASPECT_RATIO) << TestLog::EndMessage;
167 m_testCtx.setTestResult(QP_TEST_RESULT_FAIL, "Invalid pixel aspect ratio");
173 const EGLint renderBuffer = eglu::querySurfaceInt(egl, display, surface, EGL_RENDER_BUFFER);
175 if (renderBuffer != EGL_BACK_BUFFER && renderBuffer != EGL_SINGLE_BUFFER)
177 log << TestLog::Message << " Fail, invalid render buffer value " << renderBuffer << TestLog::EndMessage;
178 m_testCtx.setTestResult(QP_TEST_RESULT_FAIL, "Invalid render buffer");
182 // Multisample resolve
184 const EGLint multisampleResolve = eglu::querySurfaceInt(egl, display, surface, EGL_MULTISAMPLE_RESOLVE);
186 if (multisampleResolve != EGL_MULTISAMPLE_RESOLVE_DEFAULT && multisampleResolve != EGL_MULTISAMPLE_RESOLVE_BOX)
188 log << TestLog::Message << " Fail, invalid multisample resolve value " << multisampleResolve << TestLog::EndMessage;
189 m_testCtx.setTestResult(QP_TEST_RESULT_FAIL, "Invalid multisample resolve");
192 if (multisampleResolve == EGL_MULTISAMPLE_RESOLVE_BOX && !(info.surfaceType & EGL_MULTISAMPLE_RESOLVE_BOX_BIT))
194 log << TestLog::Message << " Fail, multisample resolve is reported as box filter but configuration does not support it." << TestLog::EndMessage;
195 m_testCtx.setTestResult(QP_TEST_RESULT_FAIL, "Invalid multisample resolve");
201 const EGLint swapBehavior = eglu::querySurfaceInt(egl, display, surface, EGL_SWAP_BEHAVIOR);
203 if (swapBehavior != EGL_BUFFER_DESTROYED && swapBehavior != EGL_BUFFER_PRESERVED)
205 log << TestLog::Message << " Fail, invalid swap behavior value " << swapBehavior << TestLog::EndMessage;
206 m_testCtx.setTestResult(QP_TEST_RESULT_FAIL, "Invalid swap behavior");
209 if (swapBehavior == EGL_BUFFER_PRESERVED && !(info.surfaceType & EGL_SWAP_BEHAVIOR_PRESERVED_BIT))
211 log << TestLog::Message << " Fail, swap behavior is reported as preserve but configuration does not support it." << TestLog::EndMessage;
212 m_testCtx.setTestResult(QP_TEST_RESULT_FAIL, "Invalid swap behavior");
218 const EGLint alphaFormat = eglu::querySurfaceInt(egl, display, surface, EGL_ALPHA_FORMAT);
220 if (alphaFormat != EGL_ALPHA_FORMAT_NONPRE && alphaFormat != EGL_ALPHA_FORMAT_PRE)
222 log << TestLog::Message << " Fail, invalid alpha format value " << alphaFormat << TestLog::EndMessage;
223 m_testCtx.setTestResult(QP_TEST_RESULT_FAIL, "Invalid alpha format");
226 if (alphaFormat == EGL_ALPHA_FORMAT_PRE && !(info.surfaceType & EGL_VG_ALPHA_FORMAT_PRE_BIT))
228 log << TestLog::Message << " Fail, is set to use premultiplied alpha but configuration does not support it." << TestLog::EndMessage;
229 m_testCtx.setTestResult(QP_TEST_RESULT_FAIL, "Invalid alpha format");
235 const EGLint colorspace = eglu::querySurfaceInt(egl, display, surface, EGL_COLORSPACE);
237 if (colorspace != EGL_VG_COLORSPACE_sRGB && colorspace != EGL_VG_COLORSPACE_LINEAR)
239 log << TestLog::Message << " Fail, invalid color space value " << colorspace << TestLog::EndMessage;
240 m_testCtx.setTestResult(QP_TEST_RESULT_FAIL, "Invalid color space");
243 if (colorspace == EGL_VG_COLORSPACE_LINEAR && !(info.surfaceType & EGL_VG_COLORSPACE_LINEAR_BIT))
245 log << TestLog::Message << " Fail, is set to use a linear color space but configuration does not support it." << TestLog::EndMessage;
246 m_testCtx.setTestResult(QP_TEST_RESULT_FAIL, "Invalid color space");
251 void QuerySurfaceCase::checkNonPbufferAttributes (EGLDisplay display, EGLSurface surface)
253 const Library& egl = m_eglTestCtx.getLibrary();
254 const EGLint uninitializedMagicValue = -42;
255 tcu::TestLog& log = m_testCtx.getLog();
256 EGLint value = uninitializedMagicValue;
258 static const EGLint pbufferAttribs[] =
267 for (int ndx = 0; ndx < DE_LENGTH_OF_ARRAY(pbufferAttribs); ndx++)
269 const EGLint attribute = pbufferAttribs[ndx];
270 const std::string name = eglu::getSurfaceAttribName(pbufferAttribs[ndx]);
272 egl.querySurface(display, surface, attribute, &value);
275 const EGLint error = egl.getError();
277 if (error != EGL_SUCCESS)
279 log << TestLog::Message << " Fail, querying " << name << " from a non-pbuffer surface should not result in an error, received "
280 << eglu::getErrorStr(error) << TestLog::EndMessage;
281 m_testCtx.setTestResult(QP_TEST_RESULT_FAIL, "Illegal error condition");
286 // "For a window or pixmap surface, the contents of value are not modified."
287 if (value != uninitializedMagicValue)
289 log << TestLog::Message << " Fail, return value contents were modified when querying " << name << " from a non-pbuffer surface." << TestLog::EndMessage;
290 m_testCtx.setTestResult(QP_TEST_RESULT_FAIL, "Illegal modification of return value");
295 class QuerySurfaceSimpleWindowCase : public QuerySurfaceCase
298 QuerySurfaceSimpleWindowCase (EglTestContext& eglTestCtx, const char* name, const char* description, const eglu::FilterList& filters)
299 : QuerySurfaceCase(eglTestCtx, name, description, filters)
303 void executeForConfig (EGLDisplay display, EGLConfig config)
305 const Library& egl = m_eglTestCtx.getLibrary();
306 tcu::TestLog& log = m_testCtx.getLog();
307 const int width = 64;
308 const int height = 64;
309 const eglu::NativeWindowFactory& windowFactory = eglu::selectNativeWindowFactory(m_eglTestCtx.getNativeDisplayFactory(), m_testCtx.getCommandLine());
312 eglu::queryCoreConfigInfo(egl, display, config, &info);
314 log << TestLog::Message << "Creating window surface with config ID " << info.configId << TestLog::EndMessage;
315 EGLU_CHECK_MSG(egl, "before queries");
317 de::UniquePtr<eglu::NativeWindow> window (windowFactory.createWindow(&m_eglTestCtx.getNativeDisplay(), display, config, DE_NULL, eglu::WindowParams(width, height, eglu::parseWindowVisibility(m_testCtx.getCommandLine()))));
318 eglu::UniqueSurface surface (egl, display, eglu::createWindowSurface(m_eglTestCtx.getNativeDisplay(), *window, display, config, DE_NULL));
320 logCommonSurfaceAttributes (log, egl, display, *surface);
321 checkCommonAttributes (display, *surface, info);
322 checkNonPbufferAttributes (display, *surface);
326 class QuerySurfaceSimplePixmapCase : public QuerySurfaceCase
329 QuerySurfaceSimplePixmapCase (EglTestContext& eglTestCtx, const char* name, const char* description, const eglu::FilterList& filters)
330 : QuerySurfaceCase(eglTestCtx, name, description, filters)
334 void executeForConfig (EGLDisplay display, EGLConfig config)
336 const Library& egl = m_eglTestCtx.getLibrary();
337 tcu::TestLog& log = m_testCtx.getLog();
338 const int width = 64;
339 const int height = 64;
340 const eglu::NativePixmapFactory& pixmapFactory = eglu::selectNativePixmapFactory(m_eglTestCtx.getNativeDisplayFactory(), m_testCtx.getCommandLine());
343 eglu::queryCoreConfigInfo(egl, display, config, &info);
345 log << TestLog::Message << "Creating pixmap surface with config ID " << info.configId << TestLog::EndMessage;
346 EGLU_CHECK_MSG(egl, "before queries");
348 de::UniquePtr<eglu::NativePixmap> pixmap (pixmapFactory.createPixmap(&m_eglTestCtx.getNativeDisplay(), display, config, DE_NULL, width, height));
349 eglu::UniqueSurface surface (egl, display, eglu::createPixmapSurface(m_eglTestCtx.getNativeDisplay(), *pixmap, display, config, DE_NULL));
351 logCommonSurfaceAttributes (log, egl, display, *surface);
352 checkCommonAttributes (display, *surface, info);
353 checkNonPbufferAttributes (display, *surface);
357 class QuerySurfaceSimplePbufferCase : public QuerySurfaceCase
360 QuerySurfaceSimplePbufferCase (EglTestContext& eglTestCtx, const char* name, const char* description, const eglu::FilterList& filters)
361 : QuerySurfaceCase(eglTestCtx, name, description, filters)
365 void executeForConfig (EGLDisplay display, EGLConfig config)
367 const Library& egl = m_eglTestCtx.getLibrary();
368 tcu::TestLog& log = m_testCtx.getLog();
373 eglu::queryCoreConfigInfo(egl, display, config, &info);
375 log << TestLog::Message << "Creating pbuffer surface with config ID " << info.configId << TestLog::EndMessage;
376 EGLU_CHECK_MSG(egl, "before queries");
378 // Clamp to maximums reported by implementation
379 width = deMin32(width, eglu::getConfigAttribInt(egl, display, config, EGL_MAX_PBUFFER_WIDTH));
380 height = deMin32(height, eglu::getConfigAttribInt(egl, display, config, EGL_MAX_PBUFFER_HEIGHT));
382 if (width == 0 || height == 0)
384 log << TestLog::Message << " Fail, maximum pbuffer size of " << width << "x" << height << " reported" << TestLog::EndMessage;
385 m_testCtx.setTestResult(QP_TEST_RESULT_FAIL, "Invalid maximum pbuffer size");
389 const EGLint attribs[] =
393 EGL_TEXTURE_FORMAT, EGL_NO_TEXTURE,
398 eglu::UniqueSurface surface(egl, display, egl.createPbufferSurface(display, config, attribs));
400 logCommonSurfaceAttributes (log, egl, display, *surface);
401 logPbufferSurfaceAttributes (log, egl, display, *surface);
402 checkCommonAttributes (display, *surface, info);
404 // Pbuffer-specific attributes
408 const EGLint largestPbuffer = eglu::querySurfaceInt(egl, display, *surface, EGL_LARGEST_PBUFFER);
410 if (largestPbuffer != EGL_FALSE && largestPbuffer != EGL_TRUE)
412 log << TestLog::Message << " Fail, invalid largest pbuffer value " << largestPbuffer << TestLog::EndMessage;
413 m_testCtx.setTestResult(QP_TEST_RESULT_FAIL, "Invalid largest pbuffer");
419 const EGLint textureFormat = eglu::querySurfaceInt(egl, display, *surface, EGL_TEXTURE_FORMAT);
421 if (textureFormat != EGL_NO_TEXTURE && textureFormat != EGL_TEXTURE_RGB && textureFormat != EGL_TEXTURE_RGBA)
423 log << TestLog::Message << " Fail, invalid texture format value " << textureFormat << TestLog::EndMessage;
424 m_testCtx.setTestResult(QP_TEST_RESULT_FAIL, "Invalid texture format");
430 const EGLint textureTarget = eglu::querySurfaceInt(egl, display, *surface, EGL_TEXTURE_TARGET);
432 if (textureTarget != EGL_NO_TEXTURE && textureTarget != EGL_TEXTURE_2D)
434 log << TestLog::Message << " Fail, invalid texture target value " << textureTarget << TestLog::EndMessage;
435 m_testCtx.setTestResult(QP_TEST_RESULT_FAIL, "Invalid texture target");
441 const EGLint mipmapTexture = eglu::querySurfaceInt(egl, display, *surface, EGL_MIPMAP_TEXTURE);
443 if (mipmapTexture != EGL_FALSE && mipmapTexture != EGL_TRUE)
445 log << TestLog::Message << " Fail, invalid mipmap texture value " << mipmapTexture << TestLog::EndMessage;
446 m_testCtx.setTestResult(QP_TEST_RESULT_FAIL, "Invalid mipmap texture");
453 class SurfaceAttribCase : public SimpleConfigCase
456 SurfaceAttribCase (EglTestContext& eglTestCtx, const char* name, const char* description, const eglu::FilterList& filters);
457 virtual ~SurfaceAttribCase (void) {}
459 void testAttributes (EGLDisplay display, EGLSurface surface, EGLint surfaceType, const ConfigInfo& info);
462 SurfaceAttribCase::SurfaceAttribCase (EglTestContext& eglTestCtx, const char* name, const char* description, const eglu::FilterList& filters)
463 : SimpleConfigCase(eglTestCtx, name, description, filters)
467 void SurfaceAttribCase::testAttributes (EGLDisplay display, EGLSurface surface, EGLint surfaceType, const ConfigInfo& info)
469 const Library& egl = m_eglTestCtx.getLibrary();
470 tcu::TestLog& log = m_testCtx.getLog();
471 const eglu::Version version = eglu::getVersion(egl, display);
473 if (version.getMajor() == 1 && version.getMinor() == 0)
475 log << TestLog::Message << "No attributes can be set in EGL 1.0" << TestLog::EndMessage;
480 if (info.renderableType & EGL_OPENGL_ES_BIT || info.renderableType & EGL_OPENGL_ES2_BIT)
482 const EGLint initialValue = 0xDEADBAAD;
483 EGLint value = initialValue;
485 EGLU_CHECK_CALL(egl, querySurface(display, surface, EGL_MIPMAP_LEVEL, &value));
487 logSurfaceAttribute(log, EGL_MIPMAP_LEVEL, value);
489 if (surfaceType == EGL_PBUFFER_BIT)
493 log << TestLog::Message << " Fail, initial mipmap level value should be 0, is " << value << TestLog::EndMessage;
494 m_testCtx.setTestResult(QP_TEST_RESULT_FAIL, "Invalid default mipmap level");
497 else if (value != initialValue)
499 log << TestLog::Message << " Fail, eglQuerySurface changed value when querying EGL_MIPMAP_LEVEL for non-pbuffer surface. Result: " << value << ". Expected: " << initialValue << TestLog::EndMessage;
500 m_testCtx.setTestResult(QP_TEST_RESULT_FAIL, "EGL_MIPMAP_LEVEL query modified result for non-pbuffer surface.");
503 egl.surfaceAttrib(display, surface, EGL_MIPMAP_LEVEL, 1);
506 const EGLint error = egl.getError();
508 if (error != EGL_SUCCESS)
510 log << TestLog::Message << " Fail, setting EGL_MIPMAP_LEVEL should not result in an error, received " << eglu::getErrorStr(error) << TestLog::EndMessage;
512 m_testCtx.setTestResult(QP_TEST_RESULT_FAIL, "Illegal error condition");
517 // Only mipmap level can be set in EGL 1.3 and lower
518 if (version.getMajor() == 1 && version.getMinor() <= 3) return;
520 // Multisample resolve
522 const EGLint value = eglu::querySurfaceInt(egl, display, surface, EGL_MULTISAMPLE_RESOLVE);
524 logSurfaceAttribute(log, EGL_MULTISAMPLE_RESOLVE, value);
526 if (value != EGL_MULTISAMPLE_RESOLVE_DEFAULT)
528 log << TestLog::Message << " Fail, initial multisample resolve value should be EGL_MULTISAMPLE_RESOLVE_DEFAULT, is "
529 << eglu::getSurfaceAttribValueStr(EGL_MULTISAMPLE_RESOLVE, value) << TestLog::EndMessage;
530 m_testCtx.setTestResult(QP_TEST_RESULT_FAIL, "Invalid default multisample resolve");
533 if (info.renderableType & EGL_MULTISAMPLE_RESOLVE_BOX_BIT)
535 log << TestLog::Message << " Box filter is supported by surface, trying to set." << TestLog::EndMessage;
537 egl.surfaceAttrib(display, surface, EGL_MULTISAMPLE_RESOLVE, EGL_MULTISAMPLE_RESOLVE_BOX);
539 if (eglu::querySurfaceInt(egl, display, surface, EGL_MULTISAMPLE_RESOLVE) != EGL_MULTISAMPLE_RESOLVE_BOX)
541 log << TestLog::Message << " Fail, tried to enable box filter but value did not change.";
542 m_testCtx.setTestResult(QP_TEST_RESULT_FAIL, "Failed to set multisample resolve");
549 const EGLint value = eglu::querySurfaceInt(egl, display, surface, EGL_SWAP_BEHAVIOR);
551 logSurfaceAttribute(log, EGL_SWAP_BEHAVIOR, value);
553 if (info.renderableType & EGL_SWAP_BEHAVIOR_PRESERVED_BIT)
555 const EGLint nextValue = (value == EGL_BUFFER_DESTROYED) ? EGL_BUFFER_PRESERVED : EGL_BUFFER_DESTROYED;
557 egl.surfaceAttrib(display, surface, EGL_SWAP_BEHAVIOR, nextValue);
559 if (eglu::querySurfaceInt(egl, display, surface, EGL_SWAP_BEHAVIOR) != nextValue)
561 log << TestLog::Message << " Fail, tried to set swap behavior to " << eglu::getSurfaceAttribStr(nextValue) << TestLog::EndMessage;
562 m_testCtx.setTestResult(QP_TEST_RESULT_FAIL, "Failed to set swap behavior");
568 class SurfaceAttribWindowCase : public SurfaceAttribCase
571 SurfaceAttribWindowCase (EglTestContext& eglTestCtx, const char* name, const char* description, const eglu::FilterList& filters)
572 : SurfaceAttribCase(eglTestCtx, name, description, filters)
576 void executeForConfig (EGLDisplay display, EGLConfig config)
578 const Library& egl = m_eglTestCtx.getLibrary();
579 tcu::TestLog& log = m_testCtx.getLog();
580 const int width = 64;
581 const int height = 64;
582 const eglu::NativeWindowFactory& windowFactory = eglu::selectNativeWindowFactory(m_eglTestCtx.getNativeDisplayFactory(), m_testCtx.getCommandLine());
585 eglu::queryCoreConfigInfo(egl, display, config, &info);
587 log << TestLog::Message << "Creating window surface with config ID " << info.configId << TestLog::EndMessage;
588 EGLU_CHECK_MSG(egl, "before queries");
590 de::UniquePtr<eglu::NativeWindow> window (windowFactory.createWindow(&m_eglTestCtx.getNativeDisplay(), display, config, DE_NULL, eglu::WindowParams(width, height, eglu::parseWindowVisibility(m_testCtx.getCommandLine()))));
591 eglu::UniqueSurface surface (egl, display, eglu::createWindowSurface(m_eglTestCtx.getNativeDisplay(), *window, display, config, DE_NULL));
593 testAttributes(display, *surface, EGL_WINDOW_BIT, info);
597 class SurfaceAttribPixmapCase : public SurfaceAttribCase
600 SurfaceAttribPixmapCase (EglTestContext& eglTestCtx, const char* name, const char* description, const eglu::FilterList& filters)
601 : SurfaceAttribCase(eglTestCtx, name, description, filters)
605 void executeForConfig (EGLDisplay display, EGLConfig config)
607 const Library& egl = m_eglTestCtx.getLibrary();
608 tcu::TestLog& log = m_testCtx.getLog();
609 const int width = 64;
610 const int height = 64;
611 const eglu::NativePixmapFactory& pixmapFactory = eglu::selectNativePixmapFactory(m_eglTestCtx.getNativeDisplayFactory(), m_testCtx.getCommandLine());
614 eglu::queryCoreConfigInfo(egl, display, config, &info);
616 log << TestLog::Message << "Creating pixmap surface with config ID " << info.configId << TestLog::EndMessage;
617 EGLU_CHECK_MSG(egl, "before queries");
619 de::UniquePtr<eglu::NativePixmap> pixmap (pixmapFactory.createPixmap(&m_eglTestCtx.getNativeDisplay(), display, config, DE_NULL, width, height));
620 eglu::UniqueSurface surface (egl, display, eglu::createPixmapSurface(m_eglTestCtx.getNativeDisplay(), *pixmap, display, config, DE_NULL));
622 testAttributes(display, *surface, EGL_PIXMAP_BIT, info);
626 class SurfaceAttribPbufferCase : public SurfaceAttribCase
629 SurfaceAttribPbufferCase (EglTestContext& eglTestCtx, const char* name, const char* description, const eglu::FilterList& filters)
630 : SurfaceAttribCase(eglTestCtx, name, description, filters)
634 void executeForConfig (EGLDisplay display, EGLConfig config)
636 const Library& egl = m_eglTestCtx.getLibrary();
637 tcu::TestLog& log = m_testCtx.getLog();
642 eglu::queryCoreConfigInfo(egl, display, config, &info);
644 log << TestLog::Message << "Creating pbuffer surface with config ID " << info.configId << TestLog::EndMessage;
645 EGLU_CHECK_MSG(egl, "before queries");
647 // Clamp to maximums reported by implementation
648 width = deMin32(width, eglu::getConfigAttribInt(egl, display, config, EGL_MAX_PBUFFER_WIDTH));
649 height = deMin32(height, eglu::getConfigAttribInt(egl, display, config, EGL_MAX_PBUFFER_HEIGHT));
651 if (width == 0 || height == 0)
653 log << TestLog::Message << " Fail, maximum pbuffer size of " << width << "x" << height << " reported" << TestLog::EndMessage;
654 m_testCtx.setTestResult(QP_TEST_RESULT_FAIL, "Invalid maximum pbuffer size");
658 const EGLint attribs[] =
662 EGL_TEXTURE_FORMAT, EGL_NO_TEXTURE,
666 eglu::UniqueSurface surface(egl, display, egl.createPbufferSurface(display, config, attribs));
668 testAttributes(display, *surface, EGL_PBUFFER_BIT, info);
672 QuerySurfaceTests::QuerySurfaceTests (EglTestContext& eglTestCtx)
673 : TestCaseGroup(eglTestCtx, "query_surface", "Surface Query Tests")
677 QuerySurfaceTests::~QuerySurfaceTests (void)
681 template <deUint32 Type>
682 static bool surfaceType (const eglu::CandidateConfig& c)
684 return (c.surfaceType() & Type) == Type;
687 void QuerySurfaceTests::init (void)
691 tcu::TestCaseGroup* simpleGroup = new tcu::TestCaseGroup(m_testCtx, "simple", "Simple queries");
692 addChild(simpleGroup);
696 tcu::TestCaseGroup* windowGroup = new tcu::TestCaseGroup(m_testCtx, "window", "Window surfaces");
697 simpleGroup->addChild(windowGroup);
699 eglu::FilterList baseFilters;
700 baseFilters << surfaceType<EGL_WINDOW_BIT>;
702 std::vector<NamedFilterList> filterLists;
703 getDefaultFilterLists(filterLists, baseFilters);
705 for (std::vector<NamedFilterList>::iterator i = filterLists.begin(); i != filterLists.end(); i++)
706 windowGroup->addChild(new QuerySurfaceSimpleWindowCase(m_eglTestCtx, i->getName(), i->getDescription(), *i));
711 tcu::TestCaseGroup* pixmapGroup = new tcu::TestCaseGroup(m_testCtx, "pixmap", "Pixmap surfaces");
712 simpleGroup->addChild(pixmapGroup);
714 eglu::FilterList baseFilters;
715 baseFilters << surfaceType<EGL_PIXMAP_BIT>;
717 std::vector<NamedFilterList> filterLists;
718 getDefaultFilterLists(filterLists, baseFilters);
720 for (std::vector<NamedFilterList>::iterator i = filterLists.begin(); i != filterLists.end(); i++)
721 pixmapGroup->addChild(new QuerySurfaceSimplePixmapCase(m_eglTestCtx, i->getName(), i->getDescription(), *i));
726 tcu::TestCaseGroup* pbufferGroup = new tcu::TestCaseGroup(m_testCtx, "pbuffer", "Pbuffer surfaces");
727 simpleGroup->addChild(pbufferGroup);
729 eglu::FilterList baseFilters;
730 baseFilters << surfaceType<EGL_PBUFFER_BIT>;
732 std::vector<NamedFilterList> filterLists;
733 getDefaultFilterLists(filterLists, baseFilters);
735 for (std::vector<NamedFilterList>::iterator i = filterLists.begin(); i != filterLists.end(); i++)
736 pbufferGroup->addChild(new QuerySurfaceSimplePbufferCase(m_eglTestCtx, i->getName(), i->getDescription(), *i));
740 // Set surface attributes
742 tcu::TestCaseGroup* setAttributeGroup = new tcu::TestCaseGroup(m_testCtx, "set_attribute", "Setting attributes");
743 addChild(setAttributeGroup);
747 tcu::TestCaseGroup* windowGroup = new tcu::TestCaseGroup(m_testCtx, "window", "Window surfaces");
748 setAttributeGroup->addChild(windowGroup);
750 eglu::FilterList baseFilters;
751 baseFilters << surfaceType<EGL_WINDOW_BIT>;
753 std::vector<NamedFilterList> filterLists;
754 getDefaultFilterLists(filterLists, baseFilters);
756 for (std::vector<NamedFilterList>::iterator i = filterLists.begin(); i != filterLists.end(); i++)
757 windowGroup->addChild(new SurfaceAttribWindowCase(m_eglTestCtx, i->getName(), i->getDescription(), *i));
762 tcu::TestCaseGroup* pixmapGroup = new tcu::TestCaseGroup(m_testCtx, "pixmap", "Pixmap surfaces");
763 setAttributeGroup->addChild(pixmapGroup);
765 eglu::FilterList baseFilters;
766 baseFilters << surfaceType<EGL_PIXMAP_BIT>;
768 std::vector<NamedFilterList> filterLists;
769 getDefaultFilterLists(filterLists, baseFilters);
771 for (std::vector<NamedFilterList>::iterator i = filterLists.begin(); i != filterLists.end(); i++)
772 pixmapGroup->addChild(new SurfaceAttribPixmapCase(m_eglTestCtx, i->getName(), i->getDescription(), *i));
777 tcu::TestCaseGroup* pbufferGroup = new tcu::TestCaseGroup(m_testCtx, "pbuffer", "Pbuffer surfaces");
778 setAttributeGroup->addChild(pbufferGroup);
780 eglu::FilterList baseFilters;
781 baseFilters << surfaceType<EGL_PBUFFER_BIT>;
783 std::vector<NamedFilterList> filterLists;
784 getDefaultFilterLists(filterLists, baseFilters);
786 for (std::vector<NamedFilterList>::iterator i = filterLists.begin(); i != filterLists.end(); i++)
787 pbufferGroup->addChild(new SurfaceAttribPbufferCase(m_eglTestCtx, i->getName(), i->getDescription(), *i));