13c827367444ee418f129b2c238299f49d3264554Jarkko Poyry/*------------------------------------------------------------------------- 23c827367444ee418f129b2c238299f49d3264554Jarkko Poyry * drawElements Quality Program EGL Module 33c827367444ee418f129b2c238299f49d3264554Jarkko Poyry * --------------------------------------- 43c827367444ee418f129b2c238299f49d3264554Jarkko Poyry * 53c827367444ee418f129b2c238299f49d3264554Jarkko Poyry * Copyright 2014 The Android Open Source Project 63c827367444ee418f129b2c238299f49d3264554Jarkko Poyry * 73c827367444ee418f129b2c238299f49d3264554Jarkko Poyry * Licensed under the Apache License, Version 2.0 (the "License"); 83c827367444ee418f129b2c238299f49d3264554Jarkko Poyry * you may not use this file except in compliance with the License. 93c827367444ee418f129b2c238299f49d3264554Jarkko Poyry * You may obtain a copy of the License at 103c827367444ee418f129b2c238299f49d3264554Jarkko Poyry * 113c827367444ee418f129b2c238299f49d3264554Jarkko Poyry * http://www.apache.org/licenses/LICENSE-2.0 123c827367444ee418f129b2c238299f49d3264554Jarkko Poyry * 133c827367444ee418f129b2c238299f49d3264554Jarkko Poyry * Unless required by applicable law or agreed to in writing, software 143c827367444ee418f129b2c238299f49d3264554Jarkko Poyry * distributed under the License is distributed on an "AS IS" BASIS, 153c827367444ee418f129b2c238299f49d3264554Jarkko Poyry * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 163c827367444ee418f129b2c238299f49d3264554Jarkko Poyry * See the License for the specific language governing permissions and 173c827367444ee418f129b2c238299f49d3264554Jarkko Poyry * limitations under the License. 183c827367444ee418f129b2c238299f49d3264554Jarkko Poyry * 193c827367444ee418f129b2c238299f49d3264554Jarkko Poyry *//*! 203c827367444ee418f129b2c238299f49d3264554Jarkko Poyry * \file 213c827367444ee418f129b2c238299f49d3264554Jarkko Poyry * \brief Simple surface construction test. 223c827367444ee418f129b2c238299f49d3264554Jarkko Poyry *//*--------------------------------------------------------------------*/ 233c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 243c827367444ee418f129b2c238299f49d3264554Jarkko Poyry#include "teglCreateSurfaceTests.hpp" 253c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 263c827367444ee418f129b2c238299f49d3264554Jarkko Poyry#include "egluNativeDisplay.hpp" 273c827367444ee418f129b2c238299f49d3264554Jarkko Poyry#include "egluNativeWindow.hpp" 283c827367444ee418f129b2c238299f49d3264554Jarkko Poyry#include "egluNativePixmap.hpp" 293c827367444ee418f129b2c238299f49d3264554Jarkko Poyry#include "egluUtil.hpp" 303c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 313c827367444ee418f129b2c238299f49d3264554Jarkko Poyry#include "teglSimpleConfigCase.hpp" 323c827367444ee418f129b2c238299f49d3264554Jarkko Poyry#include "tcuTestContext.hpp" 333c827367444ee418f129b2c238299f49d3264554Jarkko Poyry#include "tcuCommandLine.hpp" 343c827367444ee418f129b2c238299f49d3264554Jarkko Poyry#include "tcuTestLog.hpp" 353c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 363c827367444ee418f129b2c238299f49d3264554Jarkko Poyry#include "deSTLUtil.hpp" 373c827367444ee418f129b2c238299f49d3264554Jarkko Poyry#include "deUniquePtr.hpp" 383c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 393c827367444ee418f129b2c238299f49d3264554Jarkko Poyry#include <memory> 403c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 413c827367444ee418f129b2c238299f49d3264554Jarkko Poyry#if !defined(EGL_EXT_platform_base) 423c827367444ee418f129b2c238299f49d3264554Jarkko Poyry# define EGL_EXT_platform_base 1 433c827367444ee418f129b2c238299f49d3264554Jarkko Poyry typedef EGLDisplay (EGLAPIENTRYP PFNEGLGETPLATFORMDISPLAYEXTPROC) (EGLenum platform, void *native_display, const EGLint *attrib_list); 443c827367444ee418f129b2c238299f49d3264554Jarkko Poyry typedef EGLSurface (EGLAPIENTRYP PFNEGLCREATEPLATFORMWINDOWSURFACEEXTPROC) (EGLDisplay dpy, EGLConfig config, void *native_window, const EGLint *attrib_list); 453c827367444ee418f129b2c238299f49d3264554Jarkko Poyry typedef EGLSurface (EGLAPIENTRYP PFNEGLCREATEPLATFORMPIXMAPSURFACEEXTPROC) (EGLDisplay dpy, EGLConfig config, void *native_pixmap, const EGLint *attrib_list); 463c827367444ee418f129b2c238299f49d3264554Jarkko Poyry#endif // EGL_EXT_platform_base 473c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 483c827367444ee418f129b2c238299f49d3264554Jarkko Poyryusing std::vector; 493c827367444ee418f129b2c238299f49d3264554Jarkko Poyryusing tcu::TestLog; 503c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 513c827367444ee418f129b2c238299f49d3264554Jarkko Poyrynamespace deqp 523c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{ 533c827367444ee418f129b2c238299f49d3264554Jarkko Poyrynamespace egl 543c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{ 553c827367444ee418f129b2c238299f49d3264554Jarkko Poyrynamespace 563c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{ 573c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 583c827367444ee418f129b2c238299f49d3264554Jarkko Poyryvoid checkEGLPlatformSupport (const char* platformExt) 593c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{ 603c827367444ee418f129b2c238299f49d3264554Jarkko Poyry std::vector<std::string> extensions = eglu::getPlatformExtensions(); 613c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 623c827367444ee418f129b2c238299f49d3264554Jarkko Poyry if (!de::contains(extensions.begin(), extensions.end(), platformExt)) 633c827367444ee418f129b2c238299f49d3264554Jarkko Poyry throw tcu::NotSupportedError((std::string("Platform extension '") + platformExt + "' not supported").c_str(), "", __FILE__, __LINE__); 643c827367444ee418f129b2c238299f49d3264554Jarkko Poyry} 653c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 663c827367444ee418f129b2c238299f49d3264554Jarkko PoyryEGLSurface createWindowSurface (EGLDisplay display, EGLConfig config, eglu::NativeDisplay& nativeDisplay, eglu::NativeWindow& window, bool useLegacyCreate) 673c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{ 683c827367444ee418f129b2c238299f49d3264554Jarkko Poyry EGLSurface surface = EGL_NO_SURFACE; 693c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 703c827367444ee418f129b2c238299f49d3264554Jarkko Poyry if (useLegacyCreate) 713c827367444ee418f129b2c238299f49d3264554Jarkko Poyry { 723c827367444ee418f129b2c238299f49d3264554Jarkko Poyry surface = eglCreateWindowSurface(display, config, window.getLegacyNative(), DE_NULL); 733c827367444ee418f129b2c238299f49d3264554Jarkko Poyry TCU_CHECK_EGL_MSG("eglCreateWindowSurface() failed"); 743c827367444ee418f129b2c238299f49d3264554Jarkko Poyry } 753c827367444ee418f129b2c238299f49d3264554Jarkko Poyry else 763c827367444ee418f129b2c238299f49d3264554Jarkko Poyry { 773c827367444ee418f129b2c238299f49d3264554Jarkko Poyry checkEGLPlatformSupport(nativeDisplay.getPlatformExtensionName()); 783c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 793c827367444ee418f129b2c238299f49d3264554Jarkko Poyry PFNEGLCREATEPLATFORMWINDOWSURFACEEXTPROC createPlatformWindowSurfaceEXT = (PFNEGLCREATEPLATFORMWINDOWSURFACEEXTPROC)eglGetProcAddress("eglCreatePlatformWindowSurfaceEXT"); 803c827367444ee418f129b2c238299f49d3264554Jarkko Poyry TCU_CHECK_EGL_MSG("eglGetProcAddress() failed"); 813c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 823c827367444ee418f129b2c238299f49d3264554Jarkko Poyry surface = createPlatformWindowSurfaceEXT(display, config, window.getPlatformNative(), DE_NULL); 833c827367444ee418f129b2c238299f49d3264554Jarkko Poyry TCU_CHECK_EGL_MSG("eglCreatePlatformWindowSurfaceEXT() failed"); 843c827367444ee418f129b2c238299f49d3264554Jarkko Poyry } 853c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 863c827367444ee418f129b2c238299f49d3264554Jarkko Poyry return surface; 873c827367444ee418f129b2c238299f49d3264554Jarkko Poyry} 883c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 893c827367444ee418f129b2c238299f49d3264554Jarkko PoyryEGLSurface createPixmapSurface (EGLDisplay display, EGLConfig config, eglu::NativeDisplay& nativeDisplay, eglu::NativePixmap& pixmap, bool useLegacyCreate) 903c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{ 913c827367444ee418f129b2c238299f49d3264554Jarkko Poyry EGLSurface surface = EGL_NO_SURFACE; 923c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 933c827367444ee418f129b2c238299f49d3264554Jarkko Poyry if (useLegacyCreate) 943c827367444ee418f129b2c238299f49d3264554Jarkko Poyry { 953c827367444ee418f129b2c238299f49d3264554Jarkko Poyry surface = eglCreatePixmapSurface(display, config, pixmap.getLegacyNative(), DE_NULL); 963c827367444ee418f129b2c238299f49d3264554Jarkko Poyry TCU_CHECK_EGL_MSG("eglCreatePixmapSurface() failed"); 973c827367444ee418f129b2c238299f49d3264554Jarkko Poyry } 983c827367444ee418f129b2c238299f49d3264554Jarkko Poyry else 993c827367444ee418f129b2c238299f49d3264554Jarkko Poyry { 1003c827367444ee418f129b2c238299f49d3264554Jarkko Poyry checkEGLPlatformSupport(nativeDisplay.getPlatformExtensionName()); 1013c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 1023c827367444ee418f129b2c238299f49d3264554Jarkko Poyry PFNEGLCREATEPLATFORMPIXMAPSURFACEEXTPROC createPlatformPixmapSurfaceEXT = (PFNEGLCREATEPLATFORMPIXMAPSURFACEEXTPROC)eglGetProcAddress("eglCreatePlatformPixmapSurfaceEXT"); 1033c827367444ee418f129b2c238299f49d3264554Jarkko Poyry TCU_CHECK_EGL_MSG("eglGetProcAddress() failed"); 1043c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 1053c827367444ee418f129b2c238299f49d3264554Jarkko Poyry surface = createPlatformPixmapSurfaceEXT(display, config, pixmap.getPlatformNative(), DE_NULL); 1063c827367444ee418f129b2c238299f49d3264554Jarkko Poyry TCU_CHECK_EGL_MSG("eglCreatePlatformPixmapSurfaceEXT() failed"); 1073c827367444ee418f129b2c238299f49d3264554Jarkko Poyry } 1083c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 1093c827367444ee418f129b2c238299f49d3264554Jarkko Poyry return surface; 1103c827367444ee418f129b2c238299f49d3264554Jarkko Poyry} 1113c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 1123c827367444ee418f129b2c238299f49d3264554Jarkko Poyryclass CreateWindowSurfaceCase : public SimpleConfigCase 1133c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{ 1143c827367444ee418f129b2c238299f49d3264554Jarkko Poyrypublic: 1153c827367444ee418f129b2c238299f49d3264554Jarkko Poyry CreateWindowSurfaceCase (EglTestContext& eglTestCtx, const char* name, const char* description, bool useLegacyCreate, const vector<EGLint>& configIds) 1163c827367444ee418f129b2c238299f49d3264554Jarkko Poyry : SimpleConfigCase (eglTestCtx, name, description, configIds) 1173c827367444ee418f129b2c238299f49d3264554Jarkko Poyry , m_useLegacyCreate (useLegacyCreate) 1183c827367444ee418f129b2c238299f49d3264554Jarkko Poyry { 1193c827367444ee418f129b2c238299f49d3264554Jarkko Poyry } 1203c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 1213c827367444ee418f129b2c238299f49d3264554Jarkko Poyry void executeForConfig (tcu::egl::Display& display, EGLConfig config) 1223c827367444ee418f129b2c238299f49d3264554Jarkko Poyry { 1233c827367444ee418f129b2c238299f49d3264554Jarkko Poyry TestLog& log = m_testCtx.getLog(); 1243c827367444ee418f129b2c238299f49d3264554Jarkko Poyry EGLint id = display.getConfigAttrib(config, EGL_CONFIG_ID); 1253c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 1263c827367444ee418f129b2c238299f49d3264554Jarkko Poyry // \todo [2011-03-23 pyry] Iterate thru all possible combinations of EGL_RENDER_BUFFER, EGL_VG_COLORSPACE and EGL_VG_ALPHA_FORMAT 1273c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 1283c827367444ee418f129b2c238299f49d3264554Jarkko Poyry if (m_useLegacyCreate) 1293c827367444ee418f129b2c238299f49d3264554Jarkko Poyry { 1303c827367444ee418f129b2c238299f49d3264554Jarkko Poyry if ((m_eglTestCtx.getNativeWindowFactory().getCapabilities() & eglu::NativeWindow::CAPABILITY_CREATE_SURFACE_LEGACY) == 0) 1313c827367444ee418f129b2c238299f49d3264554Jarkko Poyry throw tcu::NotSupportedError("Native window doesn't support legacy eglCreateWindowSurface()", "", __FILE__, __LINE__); 1323c827367444ee418f129b2c238299f49d3264554Jarkko Poyry } 1333c827367444ee418f129b2c238299f49d3264554Jarkko Poyry else 1343c827367444ee418f129b2c238299f49d3264554Jarkko Poyry { 1353c827367444ee418f129b2c238299f49d3264554Jarkko Poyry if ((m_eglTestCtx.getNativeWindowFactory().getCapabilities() & eglu::NativeWindow::CAPABILITY_CREATE_SURFACE_PLATFORM) == 0) 1363c827367444ee418f129b2c238299f49d3264554Jarkko Poyry throw tcu::NotSupportedError("Native window doesn't support eglCreatePlatformWindowSurfaceEXT()", "", __FILE__, __LINE__); 1373c827367444ee418f129b2c238299f49d3264554Jarkko Poyry } 1383c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 1393c827367444ee418f129b2c238299f49d3264554Jarkko Poyry log << TestLog::Message << "Creating window surface with config ID " << id << TestLog::EndMessage; 1403c827367444ee418f129b2c238299f49d3264554Jarkko Poyry TCU_CHECK_EGL(); 1413c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 1423c827367444ee418f129b2c238299f49d3264554Jarkko Poyry { 1433c827367444ee418f129b2c238299f49d3264554Jarkko Poyry const int width = 64; 1443c827367444ee418f129b2c238299f49d3264554Jarkko Poyry const int height = 64; 1453c827367444ee418f129b2c238299f49d3264554Jarkko Poyry de::UniquePtr<eglu::NativeWindow> window (m_eglTestCtx.createNativeWindow(display.getEGLDisplay(), config, DE_NULL, width, height, eglu::parseWindowVisibility(m_testCtx.getCommandLine()))); 1463c827367444ee418f129b2c238299f49d3264554Jarkko Poyry tcu::egl::WindowSurface surface (display, createWindowSurface(display.getEGLDisplay(), config, m_eglTestCtx.getNativeDisplay(), *window, m_useLegacyCreate)); 1473c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 1483c827367444ee418f129b2c238299f49d3264554Jarkko Poyry EGLint windowWidth = 0; 1493c827367444ee418f129b2c238299f49d3264554Jarkko Poyry EGLint windowHeight = 0; 1503c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 1513c827367444ee418f129b2c238299f49d3264554Jarkko Poyry TCU_CHECK_EGL_CALL(eglQuerySurface(display.getEGLDisplay(), surface.getEGLSurface(), EGL_WIDTH, &windowWidth)); 1523c827367444ee418f129b2c238299f49d3264554Jarkko Poyry TCU_CHECK_EGL_CALL(eglQuerySurface(display.getEGLDisplay(), surface.getEGLSurface(), EGL_HEIGHT, &windowHeight)); 1533c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 1543c827367444ee418f129b2c238299f49d3264554Jarkko Poyry if (windowWidth <= 0 || windowHeight <= 0) 1553c827367444ee418f129b2c238299f49d3264554Jarkko Poyry { 1563c827367444ee418f129b2c238299f49d3264554Jarkko Poyry log << TestLog::Message << " Fail, invalid surface size " << windowWidth << "x" << windowHeight << TestLog::EndMessage; 1573c827367444ee418f129b2c238299f49d3264554Jarkko Poyry m_testCtx.setTestResult(QP_TEST_RESULT_FAIL, "Invalid surface size"); 1583c827367444ee418f129b2c238299f49d3264554Jarkko Poyry } 1593c827367444ee418f129b2c238299f49d3264554Jarkko Poyry else 1603c827367444ee418f129b2c238299f49d3264554Jarkko Poyry log << TestLog::Message << " Pass" << TestLog::EndMessage; 1613c827367444ee418f129b2c238299f49d3264554Jarkko Poyry } 1623c827367444ee418f129b2c238299f49d3264554Jarkko Poyry } 1633c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 1643c827367444ee418f129b2c238299f49d3264554Jarkko Poyryprivate: 1653c827367444ee418f129b2c238299f49d3264554Jarkko Poyry bool m_useLegacyCreate; 1663c827367444ee418f129b2c238299f49d3264554Jarkko Poyry}; 1673c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 1683c827367444ee418f129b2c238299f49d3264554Jarkko Poyryclass CreatePixmapSurfaceCase : public SimpleConfigCase 1693c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{ 1703c827367444ee418f129b2c238299f49d3264554Jarkko Poyrypublic: 1713c827367444ee418f129b2c238299f49d3264554Jarkko Poyry CreatePixmapSurfaceCase (EglTestContext& eglTestCtx, const char* name, const char* description, bool useLegacyCreate, const vector<EGLint>& configIds) 1723c827367444ee418f129b2c238299f49d3264554Jarkko Poyry : SimpleConfigCase(eglTestCtx, name, description, configIds) 1733c827367444ee418f129b2c238299f49d3264554Jarkko Poyry , m_useLegacyCreate (useLegacyCreate) 1743c827367444ee418f129b2c238299f49d3264554Jarkko Poyry { 1753c827367444ee418f129b2c238299f49d3264554Jarkko Poyry } 1763c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 1773c827367444ee418f129b2c238299f49d3264554Jarkko Poyry void executeForConfig (tcu::egl::Display& display, EGLConfig config) 1783c827367444ee418f129b2c238299f49d3264554Jarkko Poyry { 1793c827367444ee418f129b2c238299f49d3264554Jarkko Poyry TestLog& log = m_testCtx.getLog(); 1803c827367444ee418f129b2c238299f49d3264554Jarkko Poyry EGLint id = display.getConfigAttrib(config, EGL_CONFIG_ID); 1813c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 1823c827367444ee418f129b2c238299f49d3264554Jarkko Poyry // \todo [2011-03-23 pyry] Iterate thru all possible combinations of EGL_RENDER_BUFFER, EGL_VG_COLORSPACE and EGL_VG_ALPHA_FORMAT 1833c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 1843c827367444ee418f129b2c238299f49d3264554Jarkko Poyry if (m_useLegacyCreate) 1853c827367444ee418f129b2c238299f49d3264554Jarkko Poyry { 1863c827367444ee418f129b2c238299f49d3264554Jarkko Poyry if ((m_eglTestCtx.getNativePixmapFactory().getCapabilities() & eglu::NativePixmap::CAPABILITY_CREATE_SURFACE_LEGACY) == 0) 1873c827367444ee418f129b2c238299f49d3264554Jarkko Poyry throw tcu::NotSupportedError("Native pixmap doesn't support legacy eglCreatePixmapSurface()", "", __FILE__, __LINE__); 1883c827367444ee418f129b2c238299f49d3264554Jarkko Poyry } 1893c827367444ee418f129b2c238299f49d3264554Jarkko Poyry else 1903c827367444ee418f129b2c238299f49d3264554Jarkko Poyry { 1913c827367444ee418f129b2c238299f49d3264554Jarkko Poyry if ((m_eglTestCtx.getNativePixmapFactory().getCapabilities() & eglu::NativePixmap::CAPABILITY_CREATE_SURFACE_PLATFORM) == 0) 1923c827367444ee418f129b2c238299f49d3264554Jarkko Poyry throw tcu::NotSupportedError("Native pixmap doesn't support eglCreatePlatformPixmapSurfaceEXT()", "", __FILE__, __LINE__); 1933c827367444ee418f129b2c238299f49d3264554Jarkko Poyry } 1943c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 1953c827367444ee418f129b2c238299f49d3264554Jarkko Poyry log << TestLog::Message << "Creating pixmap surface with config ID " << id << TestLog::EndMessage; 1963c827367444ee418f129b2c238299f49d3264554Jarkko Poyry TCU_CHECK_EGL(); 1973c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 1983c827367444ee418f129b2c238299f49d3264554Jarkko Poyry { 1993c827367444ee418f129b2c238299f49d3264554Jarkko Poyry const int width = 64; 2003c827367444ee418f129b2c238299f49d3264554Jarkko Poyry const int height = 64; 2013c827367444ee418f129b2c238299f49d3264554Jarkko Poyry de::UniquePtr<eglu::NativePixmap> pixmap (m_eglTestCtx.createNativePixmap(display.getEGLDisplay(), config, DE_NULL, width, height)); 2023c827367444ee418f129b2c238299f49d3264554Jarkko Poyry tcu::egl::PixmapSurface surface (display, createPixmapSurface(display.getEGLDisplay(), config, m_eglTestCtx.getNativeDisplay(), *pixmap, m_useLegacyCreate)); 2033c827367444ee418f129b2c238299f49d3264554Jarkko Poyry EGLint pixmapWidth = 0; 2043c827367444ee418f129b2c238299f49d3264554Jarkko Poyry EGLint pixmapHeight = 0; 2053c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 2063c827367444ee418f129b2c238299f49d3264554Jarkko Poyry TCU_CHECK_EGL_CALL(eglQuerySurface(display.getEGLDisplay(), surface.getEGLSurface(), EGL_WIDTH, &pixmapWidth)); 2073c827367444ee418f129b2c238299f49d3264554Jarkko Poyry TCU_CHECK_EGL_CALL(eglQuerySurface(display.getEGLDisplay(), surface.getEGLSurface(), EGL_HEIGHT, &pixmapHeight)); 2083c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 2093c827367444ee418f129b2c238299f49d3264554Jarkko Poyry if (pixmapWidth <= 0 || pixmapHeight <= 0) 2103c827367444ee418f129b2c238299f49d3264554Jarkko Poyry { 2113c827367444ee418f129b2c238299f49d3264554Jarkko Poyry log << TestLog::Message << " Fail, invalid surface size " << pixmapWidth << "x" << pixmapHeight << TestLog::EndMessage; 2123c827367444ee418f129b2c238299f49d3264554Jarkko Poyry m_testCtx.setTestResult(QP_TEST_RESULT_FAIL, "Invalid surface size"); 2133c827367444ee418f129b2c238299f49d3264554Jarkko Poyry } 2143c827367444ee418f129b2c238299f49d3264554Jarkko Poyry else 2153c827367444ee418f129b2c238299f49d3264554Jarkko Poyry log << TestLog::Message << " Pass" << TestLog::EndMessage; 2163c827367444ee418f129b2c238299f49d3264554Jarkko Poyry } 2173c827367444ee418f129b2c238299f49d3264554Jarkko Poyry } 2183c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 2193c827367444ee418f129b2c238299f49d3264554Jarkko Poyryprivate: 2203c827367444ee418f129b2c238299f49d3264554Jarkko Poyry bool m_useLegacyCreate; 2213c827367444ee418f129b2c238299f49d3264554Jarkko Poyry}; 2223c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 2233c827367444ee418f129b2c238299f49d3264554Jarkko Poyryclass CreatePbufferSurfaceCase : public SimpleConfigCase 2243c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{ 2253c827367444ee418f129b2c238299f49d3264554Jarkko Poyrypublic: 2263c827367444ee418f129b2c238299f49d3264554Jarkko Poyry CreatePbufferSurfaceCase (EglTestContext& eglTestCtx, const char* name, const char* description, const vector<EGLint>& configIds) 2273c827367444ee418f129b2c238299f49d3264554Jarkko Poyry : SimpleConfigCase(eglTestCtx, name, description, configIds) 2283c827367444ee418f129b2c238299f49d3264554Jarkko Poyry { 2293c827367444ee418f129b2c238299f49d3264554Jarkko Poyry } 2303c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 2313c827367444ee418f129b2c238299f49d3264554Jarkko Poyry void executeForConfig (tcu::egl::Display& display, EGLConfig config) 2323c827367444ee418f129b2c238299f49d3264554Jarkko Poyry { 2333c827367444ee418f129b2c238299f49d3264554Jarkko Poyry TestLog& log = m_testCtx.getLog(); 2343c827367444ee418f129b2c238299f49d3264554Jarkko Poyry EGLint id = display.getConfigAttrib(config, EGL_CONFIG_ID); 2353c827367444ee418f129b2c238299f49d3264554Jarkko Poyry int width = 64; 2363c827367444ee418f129b2c238299f49d3264554Jarkko Poyry int height = 64; 2373c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 2383c827367444ee418f129b2c238299f49d3264554Jarkko Poyry // \todo [2011-03-23 pyry] Iterate thru all possible combinations of EGL_RENDER_BUFFER, EGL_VG_COLORSPACE and EGL_VG_ALPHA_FORMAT 2393c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 2403c827367444ee418f129b2c238299f49d3264554Jarkko Poyry log << TestLog::Message << "Creating pbuffer surface with config ID " << id << TestLog::EndMessage; 2413c827367444ee418f129b2c238299f49d3264554Jarkko Poyry TCU_CHECK_EGL(); 2423c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 2433c827367444ee418f129b2c238299f49d3264554Jarkko Poyry // Clamp to maximums reported by implementation 2443c827367444ee418f129b2c238299f49d3264554Jarkko Poyry width = deMin32(width, display.getConfigAttrib(config, EGL_MAX_PBUFFER_WIDTH)); 2453c827367444ee418f129b2c238299f49d3264554Jarkko Poyry height = deMin32(height, display.getConfigAttrib(config, EGL_MAX_PBUFFER_HEIGHT)); 2463c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 2473c827367444ee418f129b2c238299f49d3264554Jarkko Poyry if (width == 0 || height == 0) 2483c827367444ee418f129b2c238299f49d3264554Jarkko Poyry { 2493c827367444ee418f129b2c238299f49d3264554Jarkko Poyry log << TestLog::Message << " Fail, maximum pbuffer size of " << width << "x" << height << " reported" << TestLog::EndMessage; 2503c827367444ee418f129b2c238299f49d3264554Jarkko Poyry m_testCtx.setTestResult(QP_TEST_RESULT_FAIL, "Invalid maximum pbuffer size"); 2513c827367444ee418f129b2c238299f49d3264554Jarkko Poyry return; 2523c827367444ee418f129b2c238299f49d3264554Jarkko Poyry } 2533c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 2543c827367444ee418f129b2c238299f49d3264554Jarkko Poyry // \todo [2011-03-23 pyry] Texture-backed variants! 2553c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 2563c827367444ee418f129b2c238299f49d3264554Jarkko Poyry EGLint attribs[] = 2573c827367444ee418f129b2c238299f49d3264554Jarkko Poyry { 2583c827367444ee418f129b2c238299f49d3264554Jarkko Poyry EGL_WIDTH, width, 2593c827367444ee418f129b2c238299f49d3264554Jarkko Poyry EGL_HEIGHT, height, 2603c827367444ee418f129b2c238299f49d3264554Jarkko Poyry EGL_TEXTURE_FORMAT, EGL_NO_TEXTURE, 2613c827367444ee418f129b2c238299f49d3264554Jarkko Poyry EGL_NONE 2623c827367444ee418f129b2c238299f49d3264554Jarkko Poyry }; 2633c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 2643c827367444ee418f129b2c238299f49d3264554Jarkko Poyry EGLSurface surface = eglCreatePbufferSurface(display.getEGLDisplay(), config, attribs); 2653c827367444ee418f129b2c238299f49d3264554Jarkko Poyry TCU_CHECK_EGL_MSG("Failed to create pbuffer"); 2663c827367444ee418f129b2c238299f49d3264554Jarkko Poyry TCU_CHECK(surface != EGL_NO_SURFACE); 2673c827367444ee418f129b2c238299f49d3264554Jarkko Poyry eglDestroySurface(display.getEGLDisplay(), surface); 2683c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 2693c827367444ee418f129b2c238299f49d3264554Jarkko Poyry log << TestLog::Message << " Pass" << TestLog::EndMessage; 2703c827367444ee418f129b2c238299f49d3264554Jarkko Poyry } 2713c827367444ee418f129b2c238299f49d3264554Jarkko Poyry}; 2723c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 2733c827367444ee418f129b2c238299f49d3264554Jarkko Poyry} // anonymous 2743c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 2753c827367444ee418f129b2c238299f49d3264554Jarkko PoyryCreateSurfaceTests::CreateSurfaceTests (EglTestContext& eglTestCtx) 2763c827367444ee418f129b2c238299f49d3264554Jarkko Poyry : TestCaseGroup(eglTestCtx, "create_surface", "Basic surface construction tests") 2773c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{ 2783c827367444ee418f129b2c238299f49d3264554Jarkko Poyry} 2793c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 2803c827367444ee418f129b2c238299f49d3264554Jarkko PoyryCreateSurfaceTests::~CreateSurfaceTests (void) 2813c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{ 2823c827367444ee418f129b2c238299f49d3264554Jarkko Poyry} 2833c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 2843c827367444ee418f129b2c238299f49d3264554Jarkko Poyryvoid CreateSurfaceTests::init (void) 2853c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{ 2863c827367444ee418f129b2c238299f49d3264554Jarkko Poyry // Window surfaces 2873c827367444ee418f129b2c238299f49d3264554Jarkko Poyry { 2883c827367444ee418f129b2c238299f49d3264554Jarkko Poyry tcu::TestCaseGroup* windowGroup = new tcu::TestCaseGroup(m_testCtx, "window", "Window surfaces"); 2893c827367444ee418f129b2c238299f49d3264554Jarkko Poyry addChild(windowGroup); 2903c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 2913c827367444ee418f129b2c238299f49d3264554Jarkko Poyry eglu::FilterList filters; 2923c827367444ee418f129b2c238299f49d3264554Jarkko Poyry filters << (eglu::ConfigSurfaceType() & EGL_WINDOW_BIT); 2933c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 2943c827367444ee418f129b2c238299f49d3264554Jarkko Poyry vector<NamedConfigIdSet> configIdSets; 2953c827367444ee418f129b2c238299f49d3264554Jarkko Poyry NamedConfigIdSet::getDefaultSets(configIdSets, m_eglTestCtx.getConfigs(), filters); 2963c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 2973c827367444ee418f129b2c238299f49d3264554Jarkko Poyry for (vector<NamedConfigIdSet>::iterator i = configIdSets.begin(); i != configIdSets.end(); i++) 2983c827367444ee418f129b2c238299f49d3264554Jarkko Poyry windowGroup->addChild(new CreateWindowSurfaceCase(m_eglTestCtx, i->getName(), i->getDescription(), true, i->getConfigIds())); 2993c827367444ee418f129b2c238299f49d3264554Jarkko Poyry } 3003c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 3013c827367444ee418f129b2c238299f49d3264554Jarkko Poyry // Pixmap surfaces 3023c827367444ee418f129b2c238299f49d3264554Jarkko Poyry { 3033c827367444ee418f129b2c238299f49d3264554Jarkko Poyry tcu::TestCaseGroup* pixmapGroup = new tcu::TestCaseGroup(m_testCtx, "pixmap", "Pixmap surfaces"); 3043c827367444ee418f129b2c238299f49d3264554Jarkko Poyry addChild(pixmapGroup); 3053c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 3063c827367444ee418f129b2c238299f49d3264554Jarkko Poyry eglu::FilterList filters; 3073c827367444ee418f129b2c238299f49d3264554Jarkko Poyry filters << (eglu::ConfigSurfaceType() & EGL_PIXMAP_BIT); 3083c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 3093c827367444ee418f129b2c238299f49d3264554Jarkko Poyry vector<NamedConfigIdSet> configIdSets; 3103c827367444ee418f129b2c238299f49d3264554Jarkko Poyry NamedConfigIdSet::getDefaultSets(configIdSets, m_eglTestCtx.getConfigs(), filters); 3113c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 3123c827367444ee418f129b2c238299f49d3264554Jarkko Poyry for (vector<NamedConfigIdSet>::iterator i = configIdSets.begin(); i != configIdSets.end(); i++) 3133c827367444ee418f129b2c238299f49d3264554Jarkko Poyry pixmapGroup->addChild(new CreatePixmapSurfaceCase(m_eglTestCtx, i->getName(), i->getDescription(), true, i->getConfigIds())); 3143c827367444ee418f129b2c238299f49d3264554Jarkko Poyry } 3153c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 3163c827367444ee418f129b2c238299f49d3264554Jarkko Poyry // Pbuffer surfaces 3173c827367444ee418f129b2c238299f49d3264554Jarkko Poyry { 3183c827367444ee418f129b2c238299f49d3264554Jarkko Poyry tcu::TestCaseGroup* pbufferGroup = new tcu::TestCaseGroup(m_testCtx, "pbuffer", "Pbuffer surfaces"); 3193c827367444ee418f129b2c238299f49d3264554Jarkko Poyry addChild(pbufferGroup); 3203c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 3213c827367444ee418f129b2c238299f49d3264554Jarkko Poyry eglu::FilterList filters; 3223c827367444ee418f129b2c238299f49d3264554Jarkko Poyry filters << (eglu::ConfigSurfaceType() & EGL_PBUFFER_BIT); 3233c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 3243c827367444ee418f129b2c238299f49d3264554Jarkko Poyry vector<NamedConfigIdSet> configIdSets; 3253c827367444ee418f129b2c238299f49d3264554Jarkko Poyry NamedConfigIdSet::getDefaultSets(configIdSets, m_eglTestCtx.getConfigs(), filters); 3263c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 3273c827367444ee418f129b2c238299f49d3264554Jarkko Poyry for (vector<NamedConfigIdSet>::iterator i = configIdSets.begin(); i != configIdSets.end(); i++) 3283c827367444ee418f129b2c238299f49d3264554Jarkko Poyry pbufferGroup->addChild(new CreatePbufferSurfaceCase(m_eglTestCtx, i->getName(), i->getDescription(), i->getConfigIds())); 3293c827367444ee418f129b2c238299f49d3264554Jarkko Poyry } 3303c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 3313c827367444ee418f129b2c238299f49d3264554Jarkko Poyry // Window surfaces with new platform extension 3323c827367444ee418f129b2c238299f49d3264554Jarkko Poyry { 3333c827367444ee418f129b2c238299f49d3264554Jarkko Poyry tcu::TestCaseGroup* windowGroup = new tcu::TestCaseGroup(m_testCtx, "platform_window", "Window surfaces with platform extension"); 3343c827367444ee418f129b2c238299f49d3264554Jarkko Poyry addChild(windowGroup); 3353c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 3363c827367444ee418f129b2c238299f49d3264554Jarkko Poyry eglu::FilterList filters; 3373c827367444ee418f129b2c238299f49d3264554Jarkko Poyry filters << (eglu::ConfigSurfaceType() & EGL_WINDOW_BIT); 3383c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 3393c827367444ee418f129b2c238299f49d3264554Jarkko Poyry vector<NamedConfigIdSet> configIdSets; 3403c827367444ee418f129b2c238299f49d3264554Jarkko Poyry NamedConfigIdSet::getDefaultSets(configIdSets, m_eglTestCtx.getConfigs(), filters); 3413c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 3423c827367444ee418f129b2c238299f49d3264554Jarkko Poyry for (vector<NamedConfigIdSet>::iterator i = configIdSets.begin(); i != configIdSets.end(); i++) 3433c827367444ee418f129b2c238299f49d3264554Jarkko Poyry windowGroup->addChild(new CreateWindowSurfaceCase(m_eglTestCtx, i->getName(), i->getDescription(), false, i->getConfigIds())); 3443c827367444ee418f129b2c238299f49d3264554Jarkko Poyry } 3453c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 3463c827367444ee418f129b2c238299f49d3264554Jarkko Poyry // Pixmap surfaces with new platform extension 3473c827367444ee418f129b2c238299f49d3264554Jarkko Poyry { 3483c827367444ee418f129b2c238299f49d3264554Jarkko Poyry tcu::TestCaseGroup* pixmapGroup = new tcu::TestCaseGroup(m_testCtx, "platform_pixmap", "Pixmap surfaces with platform extension"); 3493c827367444ee418f129b2c238299f49d3264554Jarkko Poyry addChild(pixmapGroup); 3503c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 3513c827367444ee418f129b2c238299f49d3264554Jarkko Poyry eglu::FilterList filters; 3523c827367444ee418f129b2c238299f49d3264554Jarkko Poyry filters << (eglu::ConfigSurfaceType() & EGL_PIXMAP_BIT); 3533c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 3543c827367444ee418f129b2c238299f49d3264554Jarkko Poyry vector<NamedConfigIdSet> configIdSets; 3553c827367444ee418f129b2c238299f49d3264554Jarkko Poyry NamedConfigIdSet::getDefaultSets(configIdSets, m_eglTestCtx.getConfigs(), filters); 3563c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 3573c827367444ee418f129b2c238299f49d3264554Jarkko Poyry for (vector<NamedConfigIdSet>::iterator i = configIdSets.begin(); i != configIdSets.end(); i++) 3583c827367444ee418f129b2c238299f49d3264554Jarkko Poyry pixmapGroup->addChild(new CreatePixmapSurfaceCase(m_eglTestCtx, i->getName(), i->getDescription(), false, i->getConfigIds())); 3593c827367444ee418f129b2c238299f49d3264554Jarkko Poyry } 3603c827367444ee418f129b2c238299f49d3264554Jarkko Poyry} 3613c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 3623c827367444ee418f129b2c238299f49d3264554Jarkko Poyry} // egl 3633c827367444ee418f129b2c238299f49d3264554Jarkko Poyry} // deqp 364