From b9dd117ad3e52b929c4ee7c3e5d20442ab42b274 Mon Sep 17 00:00:00 2001 From: Slawomir Cygan Date: Wed, 11 Jan 2017 17:17:11 +0100 Subject: [PATCH] Refactor X11 and wayland platforms to run alongside each other This adds a capability for running Vulkan WSI ane EGL tests on both X11 and wayland compositors from one binary built in 'default' target. The change replaces X11 & wayland tcu::Platform-s with one common 'linux' platform, that is parametrized by DEQP_SUPPORT_ (X11|GLX|XCB|WAYLAND) at compile time. This new platform supports creating WSI displays and EGL contexts for each of compositors enabled at build-time. To choose EGL compositor use --deqp-egl-display-type=x11 or Wayland. No functional change is made to 'wayland' target: it is still possible to build Wayland-only binary using that target. VK-GL-CTS issue: 83 Components: Framework Affects: dEQP-VK.wsi.* and all tests using EGL. Change-Id: I1d8725d1329e1071ac545f765c374d2d7d5a29df --- framework/platform/CMakeLists.txt | 81 +++++++++--- .../{X11/tcuX11.cpp => lnx/X11/tcuLnxX11.cpp} | 26 +--- .../{X11/tcuX11.hpp => lnx/X11/tcuLnxX11.hpp} | 33 +---- .../X11/tcuLnxX11EglDisplayFactory.cpp} | 19 ++- .../lnx/X11/tcuLnxX11EglDisplayFactory.hpp | 45 +++++++ .../X11/tcuLnxX11GlxPlatform.cpp} | 10 +- .../X11/tcuLnxX11GlxPlatform.hpp} | 11 +- .../tcuX11Xcb.cpp => lnx/X11/tcuLnxX11Xcb.cpp} | 5 +- .../tcuX11Xcb.hpp => lnx/X11/tcuLnxX11Xcb.hpp} | 11 +- framework/platform/lnx/tcuLnx.cpp | 54 ++++++++ .../tcuWaylandEglPlatform.hpp => lnx/tcuLnx.hpp} | 46 ++++--- framework/platform/lnx/tcuLnxEglPlatform.cpp | 63 +++++++++ .../tcuLnxEglPlatform.hpp} | 20 +-- .../tcuX11Platform.cpp => lnx/tcuLnxPlatform.cpp} | 43 +++--- .../tcuX11Platform.hpp => lnx/tcuLnxPlatform.hpp} | 10 +- .../tcuLnxVulkanPlatform.cpp} | 115 ++++++++++++---- .../tcuLnxVulkanPlatform.hpp} | 15 ++- .../wayland/tcuLnxWayland.cpp} | 25 +--- .../wayland/tcuLnxWayland.hpp} | 35 +---- .../wayland/tcuLnxWaylandEglDisplayFactory.cpp} | 18 +-- .../wayland/tcuLnxWaylandEglDisplayFactory.hpp} | 27 +++- framework/platform/wayland/tcuWaylandPlatform.cpp | 83 ------------ .../platform/wayland/tcuWaylandVulkanPlatform.cpp | 147 --------------------- .../platform/wayland/tcuWaylandVulkanPlatform.hpp | 52 -------- targets/{wayland => default}/FindWayland.cmake | 0 targets/default/default.cmake | 6 + targets/wayland/wayland.cmake | 16 +-- 27 files changed, 471 insertions(+), 545 deletions(-) rename framework/platform/{X11/tcuX11.cpp => lnx/X11/tcuLnxX11.cpp} (95%) rename framework/platform/{X11/tcuX11.hpp => lnx/X11/tcuLnxX11.hpp} (87%) rename framework/platform/{X11/tcuX11EglPlatform.cpp => lnx/X11/tcuLnxX11EglDisplayFactory.cpp} (96%) create mode 100644 framework/platform/lnx/X11/tcuLnxX11EglDisplayFactory.hpp rename framework/platform/{X11/tcuX11GlxPlatform.cpp => lnx/X11/tcuLnxX11GlxPlatform.cpp} (99%) rename framework/platform/{X11/tcuX11GlxPlatform.hpp => lnx/X11/tcuLnxX11GlxPlatform.hpp} (88%) rename framework/platform/{X11/tcuX11Xcb.cpp => lnx/X11/tcuLnxX11Xcb.cpp} (98%) rename framework/platform/{X11/tcuX11Xcb.hpp => lnx/X11/tcuLnxX11Xcb.hpp} (94%) create mode 100644 framework/platform/lnx/tcuLnx.cpp rename framework/platform/{wayland/tcuWaylandEglPlatform.hpp => lnx/tcuLnx.hpp} (56%) create mode 100644 framework/platform/lnx/tcuLnxEglPlatform.cpp rename framework/platform/{X11/tcuX11EglPlatform.hpp => lnx/tcuLnxEglPlatform.hpp} (83%) rename framework/platform/{X11/tcuX11Platform.cpp => lnx/tcuLnxPlatform.cpp} (70%) rename framework/platform/{X11/tcuX11Platform.hpp => lnx/tcuLnxPlatform.hpp} (84%) rename framework/platform/{X11/tcuX11VulkanPlatform.cpp => lnx/tcuLnxVulkanPlatform.cpp} (53%) rename framework/platform/{X11/tcuX11VulkanPlatform.hpp => lnx/tcuLnxVulkanPlatform.hpp} (87%) rename framework/platform/{wayland/tcuWayland.cpp => lnx/wayland/tcuLnxWayland.cpp} (94%) rename framework/platform/{wayland/tcuWayland.hpp => lnx/wayland/tcuLnxWayland.hpp} (86%) rename framework/platform/{wayland/tcuWaylandEglPlatform.cpp => lnx/wayland/tcuLnxWaylandEglDisplayFactory.cpp} (94%) rename framework/platform/{wayland/tcuWaylandPlatform.hpp => lnx/wayland/tcuLnxWaylandEglDisplayFactory.hpp} (70%) delete mode 100644 framework/platform/wayland/tcuWaylandPlatform.cpp delete mode 100644 framework/platform/wayland/tcuWaylandVulkanPlatform.cpp delete mode 100644 framework/platform/wayland/tcuWaylandVulkanPlatform.hpp rename targets/{wayland => default}/FindWayland.cmake (100%) diff --git a/framework/platform/CMakeLists.txt b/framework/platform/CMakeLists.txt index b868ac0..d13f8c9 100644 --- a/framework/platform/CMakeLists.txt +++ b/framework/platform/CMakeLists.txt @@ -19,36 +19,70 @@ if (NOT DEFINED TCUTIL_PLATFORM_SRCS) win32/tcuWin32VulkanPlatform.cpp ) - elseif ((DE_OS_IS_UNIX OR DE_OS_IS_OSX) AND DEQP_USE_X11) - message(STATUS "DEQP_SUPPORT_GLX = ${DEQP_SUPPORT_GLX}") - if (DEQP_SUPPORT_GLX) - add_definitions(-DDEQP_SUPPORT_GLX=1) - endif () + elseif ((DE_OS_IS_UNIX OR DE_OS_IS_OSX) AND (DEQP_USE_X11 OR DEQP_USE_WAYLAND)) set(TCUTIL_PLATFORM_SRCS - X11/tcuX11.cpp - X11/tcuX11.hpp - X11/tcuX11EglPlatform.hpp - X11/tcuX11EglPlatform.cpp - X11/tcuX11Platform.hpp - X11/tcuX11Platform.cpp - X11/tcuX11VulkanPlatform.hpp - X11/tcuX11VulkanPlatform.cpp - ) - if (DEQP_USE_XCB) + lnx/tcuLnx.cpp + lnx/tcuLnx.cpp + lnx/tcuLnxPlatform.cpp + lnx/tcuLnxPlatform.hpp + lnx/tcuLnxEglPlatform.hpp + lnx/tcuLnxEglPlatform.cpp + lnx/tcuLnxVulkanPlatform.hpp + lnx/tcuLnxVulkanPlatform.cpp + ) + + include_directories(lnx) + + if (DEQP_USE_X11) + add_definitions(-DDEQP_SUPPORT_X11=1) + include_directories(lnx/X11) + + message(STATUS "DEQP_SUPPORT_GLX = ${DEQP_SUPPORT_GLX}") + + if (DEQP_SUPPORT_GLX) + add_definitions(-DDEQP_SUPPORT_GLX=1) + endif () + set(TCUTIL_PLATFORM_SRCS ${TCUTIL_PLATFORM_SRCS} - X11/tcuX11Xcb.hpp - X11/tcuX11Xcb.cpp + lnx/X11/tcuLnxX11.cpp + lnx/X11/tcuLnxX11.hpp + lnx/X11/tcuLnxX11EglDisplayFactory.hpp + lnx/X11/tcuLnxX11EglDisplayFactory.cpp ) + + if (DEQP_USE_XCB) + set(TCUTIL_PLATFORM_SRCS + ${TCUTIL_PLATFORM_SRCS} + lnx/X11/tcuLnxX11Xcb.hpp + lnx/X11/tcuLnxX11Xcb.cpp + ) + endif() + + if (DEQP_SUPPORT_GLX) + set(TCUTIL_PLATFORM_SRCS + ${TCUTIL_PLATFORM_SRCS} + lnx/X11/tcuLnxX11GlxPlatform.hpp + lnx/X11/tcuLnxX11GlxPlatform.cpp + ) + endif() endif() - if (DEQP_SUPPORT_GLX) + + if (DEQP_USE_WAYLAND) + add_definitions(-DDEQP_SUPPORT_WAYLAND=1) + include_directories(lnx/wayland) + set(TCUTIL_PLATFORM_SRCS ${TCUTIL_PLATFORM_SRCS} - X11/tcuX11GlxPlatform.hpp - X11/tcuX11GlxPlatform.cpp + lnx/wayland/tcuLnxWayland.hpp + lnx/wayland/tcuLnxWayland.cpp + lnx/wayland/tcuLnxWaylandEglDisplayFactory.cpp + lnx/wayland/tcuLnxWaylandEglDisplayFactory.hpp ) + include_directories(wayland) endif() + elseif (DE_OS_IS_ANDROID) set(TCUTIL_PLATFORM_SRCS android/tcuAndroidExecService.cpp @@ -120,10 +154,15 @@ if (DEQP_USE_X11) if (DEQP_USE_XCB) find_package(XCB REQUIRED) target_link_libraries(tcutil-platform ${XCB_LIBRARIES}) - add_definitions(-DDEQP_SUPPORT_XCB=1) + add_definitions(-DDEQP_SUPPORT_XCB=1) endif () if (DEQP_SUPPORT_GLX) # GLX functions don't currently have wrappers, so link directly to libGL. target_link_libraries(tcutil-platform GL) endif () + if (DEQP_USE_WAYLAND) + find_package(Wayland REQUIRED) + target_link_libraries(tcutil-platform ${WAYLAND_LIBRARIES}) + add_definitions(-DDEQP_SUPPORT_WAYLAND=1) + endif () endif () diff --git a/framework/platform/X11/tcuX11.cpp b/framework/platform/lnx/X11/tcuLnxX11.cpp similarity index 95% rename from framework/platform/X11/tcuX11.cpp rename to framework/platform/lnx/X11/tcuLnxX11.cpp index ee24d13..84cc387 100644 --- a/framework/platform/X11/tcuX11.cpp +++ b/framework/platform/lnx/X11/tcuLnxX11.cpp @@ -21,7 +21,7 @@ * \brief X11 utilities. *//*--------------------------------------------------------------------*/ -#include "tcuX11.hpp" +#include "tcuLnxX11.hpp" #include "gluRenderConfig.hpp" #include "deMemory.h" @@ -29,29 +29,10 @@ namespace tcu { -namespace x11 -{ - -EventState::EventState (void) - : m_quit(false) +namespace lnx { -} - -EventState::~EventState (void) -{ -} - -void EventState::setQuitFlag (bool quit) -{ - de::ScopedLock lock(m_mutex); - m_quit = quit; -} - -bool EventState::getQuitFlag (void) +namespace x11 { - de::ScopedLock lock(m_mutex); - return m_quit; -} DisplayBase::DisplayBase (EventState& platform) : m_eventState (platform) @@ -263,4 +244,5 @@ XlibWindow::~XlibWindow (void) } } // x11 +} // lnx } // tcu diff --git a/framework/platform/X11/tcuX11.hpp b/framework/platform/lnx/X11/tcuLnxX11.hpp similarity index 87% rename from framework/platform/X11/tcuX11.hpp rename to framework/platform/lnx/X11/tcuLnxX11.hpp index 02a731b..13ad602 100644 --- a/framework/platform/X11/tcuX11.hpp +++ b/framework/platform/lnx/X11/tcuLnxX11.hpp @@ -1,5 +1,5 @@ -#ifndef _TCUX11_HPP -#define _TCUX11_HPP +#ifndef _TCULNXX11_HPP +#define _TCULNXX11_HPP /*------------------------------------------------------------------------- * drawElements Quality Program Tester Core * ---------------------------------------- @@ -26,7 +26,7 @@ #include "tcuDefs.hpp" #include "gluRenderConfig.hpp" #include "gluPlatform.hpp" -#include "deMutex.hpp" +#include "tcuLnx.hpp" #include #include @@ -35,30 +35,10 @@ namespace tcu { -namespace x11 -{ -enum +namespace lnx { - DEFAULT_WINDOW_WIDTH = 400, - DEFAULT_WINDOW_HEIGHT = 300 -}; - -class EventState +namespace x11 { -public: - EventState (void); - virtual ~EventState (void); - void setQuitFlag (bool quit); - bool getQuitFlag (void); - -protected: - de::Mutex m_mutex; - bool m_quit; - -private: - EventState (const EventState&); - EventState& operator= (const EventState&); -}; class DisplayBase { @@ -146,6 +126,7 @@ private: }; } // x11 +} // lnx } // tcu -#endif // _TCUX11_HPP +#endif // _TCULNXX11_HPP diff --git a/framework/platform/X11/tcuX11EglPlatform.cpp b/framework/platform/lnx/X11/tcuLnxX11EglDisplayFactory.cpp similarity index 96% rename from framework/platform/X11/tcuX11EglPlatform.cpp rename to framework/platform/lnx/X11/tcuLnxX11EglDisplayFactory.cpp index ca90bc3..074dbb1 100644 --- a/framework/platform/X11/tcuX11EglPlatform.cpp +++ b/framework/platform/lnx/X11/tcuLnxX11EglDisplayFactory.cpp @@ -18,17 +18,21 @@ * *//*! * \file - * \brief X11Egl Platform. + * \brief X11Egl Display Factory. *//*--------------------------------------------------------------------*/ -#include "tcuX11EglPlatform.hpp" +#include "tcuLnxX11EglDisplayFactory.hpp" +#include "tcuLnxX11.hpp" #include "egluGLContextFactory.hpp" #include "eglwLibrary.hpp" #include "eglwFunctions.hpp" #include "eglwEnums.hpp" +#include "deUniquePtr.hpp" namespace tcu { +namespace lnx +{ namespace x11 { namespace egl @@ -286,17 +290,12 @@ NativeDisplay* DisplayFactory::createDisplay (const eglw::EGLAttrib* attribList) return new Display(x11Display); } -Platform::Platform (EventState& eventState) +NativeDisplayFactory* createDisplayFactory (EventState& eventState) { - m_nativeDisplayFactoryRegistry.registerFactory(new DisplayFactory(eventState)); + return new DisplayFactory(eventState); } -MovePtr Platform::createContextFactory (void) -{ - return MovePtr(new GLContextFactory(m_nativeDisplayFactoryRegistry)); -} - - } // egl } // x11 +} // lnx } // tcu diff --git a/framework/platform/lnx/X11/tcuLnxX11EglDisplayFactory.hpp b/framework/platform/lnx/X11/tcuLnxX11EglDisplayFactory.hpp new file mode 100644 index 0000000..6096b0e --- /dev/null +++ b/framework/platform/lnx/X11/tcuLnxX11EglDisplayFactory.hpp @@ -0,0 +1,45 @@ +#ifndef _TCULNXX11EGLDISPLAYFACTORY_HPP +#define _TCULNXX11EGLDISPLAYFACTORY_HPP +/*------------------------------------------------------------------------- + * drawElements Quality Program Tester Core + * ---------------------------------------- + * + * Copyright 2014 The Android Open Source Project + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + *//*! + * \file + * \brief X11Egl Display Factory. + *//*--------------------------------------------------------------------*/ + +#include "tcuLnx.hpp" +#include "egluNativeDisplay.hpp" + +namespace tcu +{ +namespace lnx +{ +namespace x11 +{ +namespace egl +{ + +eglu::NativeDisplayFactory* createDisplayFactory (EventState& eventState); + +} +} // x11 +} // lnx +} // tcu + +#endif // _TCULNXX11EGLDISPLAYFACTORY_HPP diff --git a/framework/platform/X11/tcuX11GlxPlatform.cpp b/framework/platform/lnx/X11/tcuLnxX11GlxPlatform.cpp similarity index 99% rename from framework/platform/X11/tcuX11GlxPlatform.cpp rename to framework/platform/lnx/X11/tcuLnxX11GlxPlatform.cpp index 3dc27b3..312e4cf 100644 --- a/framework/platform/X11/tcuX11GlxPlatform.cpp +++ b/framework/platform/lnx/X11/tcuLnxX11GlxPlatform.cpp @@ -21,8 +21,7 @@ * \brief Platform that uses X11 via GLX. *//*--------------------------------------------------------------------*/ -#include "tcuX11GlxPlatform.hpp" -#include "tcuX11Platform.hpp" +#include "tcuLnxX11GlxPlatform.hpp" #include "tcuRenderTarget.hpp" #include "glwInitFunctions.hpp" @@ -37,6 +36,8 @@ namespace tcu { +namespace lnx +{ namespace x11 { namespace glx @@ -185,7 +186,7 @@ private: extern "C" { - static int tcuX11GlxErrorHandler (::Display* display, XErrorEvent* event) + static int tcuLnxX11GlxErrorHandler (::Display* display, XErrorEvent* event) { char buf[80]; XGetErrorText(display, event->error_code, buf, sizeof(buf)); @@ -204,7 +205,7 @@ GlxContextFactory::GlxContextFactory (EventState& eventState) reinterpret_cast("glXCreateContextAttribsARB"))))) , m_eventState (eventState) { - XSetErrorHandler(tcuX11GlxErrorHandler); + XSetErrorHandler(tcuLnxX11GlxErrorHandler); } RenderContext* GlxContextFactory::createContext (const RenderConfig& config, @@ -682,4 +683,5 @@ MovePtr createContextFactory (EventState& eventState) } // glx } // x11 +} // lnx } // tcu diff --git a/framework/platform/X11/tcuX11GlxPlatform.hpp b/framework/platform/lnx/X11/tcuLnxX11GlxPlatform.hpp similarity index 88% rename from framework/platform/X11/tcuX11GlxPlatform.hpp rename to framework/platform/lnx/X11/tcuLnxX11GlxPlatform.hpp index 53ebcd4..5ac379e 100644 --- a/framework/platform/X11/tcuX11GlxPlatform.hpp +++ b/framework/platform/lnx/X11/tcuLnxX11GlxPlatform.hpp @@ -1,5 +1,5 @@ -#ifndef _TCUX11GLXPLATFORM_HPP -#define _TCUX11GLXPLATFORM_HPP +#ifndef _TCULNXX11GLXPLATFORM_HPP +#define _TCULNXX11GLXPLATFORM_HPP /*------------------------------------------------------------------------- * drawElements Quality Program Tester Core * ---------------------------------------- @@ -25,10 +25,12 @@ #include "gluContextFactory.hpp" #include "deUniquePtr.hpp" -#include "tcuX11.hpp" +#include "tcuLnxX11.hpp" namespace tcu { +namespace lnx +{ namespace x11 { namespace glx @@ -37,7 +39,8 @@ namespace glx de::MovePtr createContextFactory (EventState& eventState); } // glx +} // lnx } // x11 } // tcu -#endif // _TCUX11GLXPLATFORM_HPP +#endif // _TCULNXX11GLXPLATFORM_HPP diff --git a/framework/platform/X11/tcuX11Xcb.cpp b/framework/platform/lnx/X11/tcuLnxX11Xcb.cpp similarity index 98% rename from framework/platform/X11/tcuX11Xcb.cpp rename to framework/platform/lnx/X11/tcuLnxX11Xcb.cpp index c224c75..de87b0c 100644 --- a/framework/platform/X11/tcuX11Xcb.cpp +++ b/framework/platform/lnx/X11/tcuLnxX11Xcb.cpp @@ -21,11 +21,13 @@ * \brief X11 using XCB utilities. *//*--------------------------------------------------------------------*/ -#include "tcuX11Xcb.hpp" +#include "tcuLnxX11Xcb.hpp" #include "deMemory.h" namespace tcu { +namespace lnx +{ namespace x11 { @@ -166,4 +168,5 @@ void XcbWindow::setDimensions (int width, int height) } } // xcb +} // lnx } // tcu diff --git a/framework/platform/X11/tcuX11Xcb.hpp b/framework/platform/lnx/X11/tcuLnxX11Xcb.hpp similarity index 94% rename from framework/platform/X11/tcuX11Xcb.hpp rename to framework/platform/lnx/X11/tcuLnxX11Xcb.hpp index 82ff9b2..c00c413 100644 --- a/framework/platform/X11/tcuX11Xcb.hpp +++ b/framework/platform/lnx/X11/tcuLnxX11Xcb.hpp @@ -1,5 +1,5 @@ -#ifndef _TCUX11XCB_HPP -#define _TCUX11XCB_HPP +#ifndef _TCULNXX11XCB_HPP +#define _TCULNXX11XCB_HPP /*------------------------------------------------------------------------- * drawElements Quality Program Tester Core * ---------------------------------------- @@ -23,11 +23,13 @@ * \brief X11 using XCB utilities. *//*--------------------------------------------------------------------*/ -#include "tcuX11.hpp" +#include "tcuLnxX11.hpp" #include namespace tcu { +namespace lnx +{ namespace x11 { @@ -78,6 +80,7 @@ private: }; } // x11 +} // lnx } // tcu -#endif // _TCUX11XCB_HPP +#endif // _TCULNXX11XCB_HPP diff --git a/framework/platform/lnx/tcuLnx.cpp b/framework/platform/lnx/tcuLnx.cpp new file mode 100644 index 0000000..32ecd89 --- /dev/null +++ b/framework/platform/lnx/tcuLnx.cpp @@ -0,0 +1,54 @@ +/*------------------------------------------------------------------------- + * drawElements Quality Program Tester Core + * ---------------------------------------- + * + * Copyright 2017 The Android Open Source Project + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + *//*! + * \file + * \brief Linux utilities. + *//*--------------------------------------------------------------------*/ + +#include "tcuLnx.hpp" + + +namespace tcu +{ +namespace lnx +{ + +EventState::EventState (void) + : m_quit(false) +{ +} + +EventState::~EventState (void) +{ +} + +void EventState::setQuitFlag (bool quit) +{ + de::ScopedLock lock(m_mutex); + m_quit = quit; +} + +bool EventState::getQuitFlag (void) +{ + de::ScopedLock lock(m_mutex); + return m_quit; +} + +} // lnx +} // tcu diff --git a/framework/platform/wayland/tcuWaylandEglPlatform.hpp b/framework/platform/lnx/tcuLnx.hpp similarity index 56% rename from framework/platform/wayland/tcuWaylandEglPlatform.hpp rename to framework/platform/lnx/tcuLnx.hpp index e28ab2a..ad5cba5 100644 --- a/framework/platform/wayland/tcuWaylandEglPlatform.hpp +++ b/framework/platform/lnx/tcuLnx.hpp @@ -1,12 +1,10 @@ -#ifndef _TCUWAYLANDEGLPLATFORM_HPP -#define _TCUWAYLANDEGLPLATFORM_HPP +#ifndef _TCULNX_HPP +#define _TCULNX_HPP /*------------------------------------------------------------------------- * drawElements Quality Program Tester Core * ---------------------------------------- * - * Copyright (c) 2014 The Android Open Source Project - * Copyright (c) 2016 The Khronos Group Inc. - * Copyright (c) 2016 Mun Gwan-gyeong + * Copyright 2017 The Android Open Source Project * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -22,32 +20,42 @@ * *//*! * \file - * \brief wayland Egl Platform. + * \brief Linux utilities. *//*--------------------------------------------------------------------*/ -#include "deUniquePtr.hpp" -#include "egluPlatform.hpp" -#include "gluContextFactory.hpp" -#include "tcuWayland.hpp" +#include "tcuDefs.hpp" +#include "deMutex.hpp" namespace tcu { -namespace wayland +// This namespace should be named 'linux', however some compilers still +// define obsolete 'linux' macro alongside '__linux__' +namespace lnx { -namespace egl +enum { + DEFAULT_WINDOW_WIDTH = 400, + DEFAULT_WINDOW_HEIGHT = 300 +}; -class Platform : public eglu::Platform +class EventState { public: - Platform (EventState& eventState); - ~Platform (void) {} + EventState (void); + virtual ~EventState (void); + void setQuitFlag (bool quit); + bool getQuitFlag (void); + + protected: + de::Mutex m_mutex; + bool m_quit; - de::MovePtr createContextFactory (void); +private: + EventState (const EventState&); + EventState& operator= (const EventState&); }; -} -} // wayland +} // lnx } // tcu -#endif // _TCUWAYLANDEGLPLATFORM_HPP +#endif // _TCULNX_HPP diff --git a/framework/platform/lnx/tcuLnxEglPlatform.cpp b/framework/platform/lnx/tcuLnxEglPlatform.cpp new file mode 100644 index 0000000..22646ca --- /dev/null +++ b/framework/platform/lnx/tcuLnxEglPlatform.cpp @@ -0,0 +1,63 @@ +/*------------------------------------------------------------------------- + * drawElements Quality Program Tester Core + * ---------------------------------------- + * + * Copyright (c) 2016 The Khronos Group Inc. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + *//*! + * \file + * \brief Linux EGL Platform. + *//*--------------------------------------------------------------------*/ + +#include "tcuLnxEglPlatform.hpp" + +#if defined (DEQP_SUPPORT_X11) +# include "tcuLnxX11EglDisplayFactory.hpp" +#endif // DEQP_SUPPORT_X11 + +#if defined (DEQP_SUPPORT_WAYLAND) +# include "tcuLnxWaylandEglDisplayFactory.hpp" +#endif // DEQP_SUPPORT_WAYLAND + +#include "egluGLContextFactory.hpp" + +namespace tcu +{ +namespace lnx +{ +namespace egl +{ + +Platform::Platform (EventState& eventState) +{ +#if defined (DEQP_SUPPORT_X11) + m_nativeDisplayFactoryRegistry.registerFactory(x11::egl::createDisplayFactory(eventState)); +#endif // DEQP_SUPPORT_X11 + +#if defined (DEQP_SUPPORT_WAYLAND) + m_nativeDisplayFactoryRegistry.registerFactory(wayland::egl::createDisplayFactory(eventState)); +#endif // DEQP_SUPPORT_WAYLAND + +} + +de::MovePtr Platform::createContextFactory (void) +{ + return de::MovePtr(new eglu::GLContextFactory(m_nativeDisplayFactoryRegistry)); +} + +} // egl +} // linux +} // tcu + diff --git a/framework/platform/X11/tcuX11EglPlatform.hpp b/framework/platform/lnx/tcuLnxEglPlatform.hpp similarity index 83% rename from framework/platform/X11/tcuX11EglPlatform.hpp rename to framework/platform/lnx/tcuLnxEglPlatform.hpp index c9517d7..c8b6aaf 100644 --- a/framework/platform/X11/tcuX11EglPlatform.hpp +++ b/framework/platform/lnx/tcuLnxEglPlatform.hpp @@ -1,10 +1,10 @@ -#ifndef _TCUX11EGLPLATFORM_HPP -#define _TCUX11EGLPLATFORM_HPP +#ifndef _TCULNXEGLPLATFORM_HPP +#define _TCULNXEGLPLATFORM_HPP /*------------------------------------------------------------------------- * drawElements Quality Program Tester Core * ---------------------------------------- * - * Copyright 2014 The Android Open Source Project + * Copyright (c) 2016 The Khronos Group Inc. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -20,17 +20,17 @@ * *//*! * \file - * \brief X11Egl Platform. + * \brief Linux EGL Platform. *//*--------------------------------------------------------------------*/ -#include "deUniquePtr.hpp" +#include "tcuLnx.hpp" #include "egluPlatform.hpp" +#include "deUniquePtr.hpp" #include "gluContextFactory.hpp" -#include "tcuX11.hpp" namespace tcu { -namespace x11 +namespace lnx { namespace egl { @@ -44,8 +44,8 @@ public: de::MovePtr createContextFactory (void); }; -} -} // x11 +} // egl +} // linux } // tcu -#endif // _TCUX11EGLPLATFORM_HPP +#endif // _TCULNXEGLPLATFORM_HPP diff --git a/framework/platform/X11/tcuX11Platform.cpp b/framework/platform/lnx/tcuLnxPlatform.cpp similarity index 70% rename from framework/platform/X11/tcuX11Platform.cpp rename to framework/platform/lnx/tcuLnxPlatform.cpp index 830a463..55e18a8 100644 --- a/framework/platform/X11/tcuX11Platform.cpp +++ b/framework/platform/lnx/tcuLnxPlatform.cpp @@ -2,7 +2,7 @@ * drawElements Quality Program Tester Core * ---------------------------------------- * - * Copyright 2014 The Android Open Source Project + * Copyright 2017 The Android Open Source Project * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -18,36 +18,31 @@ * *//*! * \file - * \brief X11 Platform. + * \brief Linux Platform. *//*--------------------------------------------------------------------*/ -#include "tcuX11Platform.hpp" -#include "vkWsiPlatform.hpp" +#include "tcuLnxPlatform.hpp" + +#include "tcuLnxVulkanPlatform.hpp" +#include "tcuLnxEglPlatform.hpp" #include "deUniquePtr.hpp" #include "gluPlatform.hpp" #include "vkPlatform.hpp" -#include "tcuX11.hpp" -#include "tcuFunctionLibrary.hpp" -#include "deMemory.h" -#include "tcuX11VulkanPlatform.hpp" -#include "tcuX11EglPlatform.hpp" #if defined (DEQP_SUPPORT_GLX) -# include "tcuX11GlxPlatform.hpp" -#endif - -#include +# include "tcuLnxX11GlxPlatform.hpp" +#endif // DEQP_SUPPORT_GLX using de::MovePtr; using de::UniquePtr; namespace tcu { -namespace x11 +namespace lnx { -class X11GLPlatform : public glu::Platform +class LinuxGLPlatform : public glu::Platform { public: void registerFactory (de::MovePtr factory) @@ -56,10 +51,10 @@ public: } }; -class X11Platform : public tcu::Platform +class LinuxPlatform : public tcu::Platform { public: - X11Platform (void); + LinuxPlatform (void); bool processEvents (void) { return !m_eventState.getQuitFlag(); } const vk::Platform& getVulkanPlatform (void) const { return m_vkPlatform; } @@ -68,26 +63,26 @@ public: private: EventState m_eventState; - x11::VulkanPlatform m_vkPlatform; - x11::egl::Platform m_eglPlatform; - X11GLPlatform m_glPlatform; + VulkanPlatform m_vkPlatform; + egl::Platform m_eglPlatform; + LinuxGLPlatform m_glPlatform; }; -X11Platform::X11Platform (void) +LinuxPlatform::LinuxPlatform (void) : m_vkPlatform (m_eventState) , m_eglPlatform (m_eventState) { #if defined (DEQP_SUPPORT_GLX) - m_glPlatform.registerFactory(glx::createContextFactory(m_eventState)); + m_glPlatform.registerFactory(x11::glx::createContextFactory(m_eventState)); #endif // DEQP_SUPPORT_GLX m_glPlatform.registerFactory(m_eglPlatform.createContextFactory()); } -} // x11 +} // lnx } // tcu tcu::Platform* createPlatform (void) { - return new tcu::x11::X11Platform(); + return new tcu::lnx::LinuxPlatform(); } diff --git a/framework/platform/X11/tcuX11Platform.hpp b/framework/platform/lnx/tcuLnxPlatform.hpp similarity index 84% rename from framework/platform/X11/tcuX11Platform.hpp rename to framework/platform/lnx/tcuLnxPlatform.hpp index 5b89c09..3f8a842 100644 --- a/framework/platform/X11/tcuX11Platform.hpp +++ b/framework/platform/lnx/tcuLnxPlatform.hpp @@ -1,10 +1,10 @@ -#ifndef _TCUX11PLATFORM_HPP -#define _TCUX11PLATFORM_HPP +#ifndef _TCULNXPLATFORM_HPP +#define _TCULNXPLATFORM_HPP /*------------------------------------------------------------------------- * drawElements Quality Program Tester Core * ---------------------------------------- * - * Copyright 2014 The Android Open Source Project + * Copyright 2017 The Android Open Source Project * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -20,11 +20,11 @@ * *//*! * \file - * \brief X11 Platform. + * \brief Linux Platform. *//*--------------------------------------------------------------------*/ #include "tcuPlatform.hpp" tcu::Platform* createPlatform (void); -#endif // _TCUX11PLATFORM_HPP +#endif // _TCULNXPLATFORM_HPP diff --git a/framework/platform/X11/tcuX11VulkanPlatform.cpp b/framework/platform/lnx/tcuLnxVulkanPlatform.cpp similarity index 53% rename from framework/platform/X11/tcuX11VulkanPlatform.cpp rename to framework/platform/lnx/tcuLnxVulkanPlatform.cpp index a566e21..02720f6 100644 --- a/framework/platform/X11/tcuX11VulkanPlatform.cpp +++ b/framework/platform/lnx/tcuLnxVulkanPlatform.cpp @@ -18,14 +18,14 @@ * *//*! * \file - * \brief X11Vulkan Platform. + * \brief Linux Vulkan Platform. *//*--------------------------------------------------------------------*/ -#include "tcuX11VulkanPlatform.hpp" -#include "tcuX11Platform.hpp" +#include "tcuLnxVulkanPlatform.hpp" +#include "tcuLnxPlatform.hpp" #include "vkWsiPlatform.hpp" #include "gluPlatform.hpp" -#include "tcuX11.hpp" +#include "tcuLnx.hpp" #include "tcuFunctionLibrary.hpp" #include "deUniquePtr.hpp" #include "deMemory.h" @@ -35,19 +35,28 @@ using de::MovePtr; using de::UniquePtr; -#if defined (DEQP_SUPPORT_XCB) -#include "tcuX11Xcb.hpp" -#endif // DEQP_SUPPORT_XCB +#if defined (DEQP_SUPPORT_X11) +# include "tcuLnxX11.hpp" +# if defined (DEQP_SUPPORT_XCB) +# include "tcuLnxX11Xcb.hpp" +# endif // DEQP_SUPPORT_XCB +#endif // DEQP_SUPPORT_X11 + +#if defined (DEQP_SUPPORT_WAYLAND) +# include "tcuLnxWayland.hpp" +#endif // DEQP_SUPPORT_WAYLAND namespace tcu { -namespace x11 +namespace lnx { +#if defined (DEQP_SUPPORT_X11) + class VulkanWindowXlib : public vk::wsi::XlibWindowInterface { public: - VulkanWindowXlib (MovePtr window) + VulkanWindowXlib (MovePtr window) : vk::wsi::XlibWindowInterface (vk::pt::XlibWindow(window->getXID())) , m_window (window) { @@ -59,36 +68,38 @@ public: } private: - UniquePtr m_window; + UniquePtr m_window; }; class VulkanDisplayXlib : public vk::wsi::XlibDisplayInterface { public: - VulkanDisplayXlib (MovePtr display) - : vk::wsi::XlibDisplayInterface (vk::pt::XlibDisplayPtr(((XlibDisplay*)display.get())->getXDisplay())) + VulkanDisplayXlib (MovePtr display) + : vk::wsi::XlibDisplayInterface (vk::pt::XlibDisplayPtr(((x11::XlibDisplay*)display.get())->getXDisplay())) , m_display (display) { } vk::wsi::Window* createWindow (const Maybe& initialSize) const { - XlibDisplay* instance = (XlibDisplay*)(m_display.get()); - const deUint32 height = !initialSize ? (deUint32)DEFAULT_WINDOW_HEIGHT : initialSize->y(); - const deUint32 width = !initialSize ? (deUint32)DEFAULT_WINDOW_WIDTH : initialSize->x(); - return new VulkanWindowXlib(MovePtr(new XlibWindow(*instance, (int)width, (int)height, instance->getVisual(0)))); + x11::XlibDisplay* instance = (x11::XlibDisplay*)(m_display.get()); + const deUint32 height = !initialSize ? (deUint32)DEFAULT_WINDOW_HEIGHT : initialSize->y(); + const deUint32 width = !initialSize ? (deUint32)DEFAULT_WINDOW_WIDTH : initialSize->x(); + return new VulkanWindowXlib(MovePtr(new x11::XlibWindow(*instance, (int)width, (int)height, instance->getVisual(0)))); } private: - MovePtr m_display; + MovePtr m_display; }; +#endif // DEQP_SUPPORT_X11 + #if defined (DEQP_SUPPORT_XCB) class VulkanWindowXcb : public vk::wsi::XcbWindowInterface { public: - VulkanWindowXcb (MovePtr window) + VulkanWindowXcb (MovePtr window) : vk::wsi::XcbWindowInterface (vk::pt::XcbWindow(window->getXID())) , m_window (window) { @@ -100,30 +111,70 @@ public: } private: - UniquePtr m_window; + UniquePtr m_window; }; class VulkanDisplayXcb : public vk::wsi::XcbDisplayInterface { public: - VulkanDisplayXcb (MovePtr display) - : vk::wsi::XcbDisplayInterface (vk::pt::XcbConnectionPtr(((XcbDisplay*)display.get())->getConnection())) + VulkanDisplayXcb (MovePtr display) + : vk::wsi::XcbDisplayInterface (vk::pt::XcbConnectionPtr(((x11::XcbDisplay*)display.get())->getConnection())) + , m_display (display) + { + } + + vk::wsi::Window* createWindow (const Maybe& initialSize) const + { + x11::XcbDisplay* instance = (x11::XcbDisplay*)(m_display.get()); + const deUint32 height = !initialSize ? (deUint32)DEFAULT_WINDOW_HEIGHT : initialSize->y(); + const deUint32 width = !initialSize ? (deUint32)DEFAULT_WINDOW_WIDTH : initialSize->x(); + return new VulkanWindowXcb(MovePtr(new x11::XcbWindow(*instance, (int)width, (int)height, DE_NULL))); + } + +private: + MovePtr m_display; +}; +#endif // DEQP_SUPPORT_XCB + +#if defined (DEQP_SUPPORT_WAYLAND) +class VulkanWindowWayland : public vk::wsi::WaylandWindowInterface +{ +public: + VulkanWindowWayland (MovePtr window) + : vk::wsi::WaylandWindowInterface (vk::pt::WaylandSurfacePtr(window->getSurface())) + , m_window (window) + { + } + + void resize (const UVec2& newSize) + { + m_window->setDimensions((int)newSize.x(), (int)newSize.y()); + } + +private: + UniquePtr m_window; +}; + +class VulkanDisplayWayland : public vk::wsi::WaylandDisplayInterface +{ +public: + VulkanDisplayWayland (MovePtr display) + : vk::wsi::WaylandDisplayInterface (vk::pt::WaylandDisplayPtr(display->getDisplay())) , m_display (display) { } vk::wsi::Window* createWindow (const Maybe& initialSize) const { - XcbDisplay* instance = (XcbDisplay*)(m_display.get()); const deUint32 height = !initialSize ? (deUint32)DEFAULT_WINDOW_HEIGHT : initialSize->y(); const deUint32 width = !initialSize ? (deUint32)DEFAULT_WINDOW_WIDTH : initialSize->x(); - return new VulkanWindowXcb(MovePtr(new XcbWindow(*instance, (int)width, (int)height, DE_NULL))); + return new VulkanWindowWayland(MovePtr(new wayland::Window(*m_display, (int)width, (int)height))); } private: - MovePtr m_display; + MovePtr m_display; }; -#endif // DEQP_SUPPORT_XCB +#endif // DEQP_SUPPORT_WAYLAND class VulkanLibrary : public vk::Library { @@ -153,14 +204,22 @@ vk::wsi::Display* VulkanPlatform::createWsiDisplay (vk::wsi::Type wsiType) const { switch(wsiType) { +#if defined (DEQP_SUPPORT_X11) case vk::wsi::TYPE_XLIB: - return new VulkanDisplayXlib(MovePtr(new XlibDisplay(m_eventState,""))); + return new VulkanDisplayXlib(MovePtr(new x11::XlibDisplay(m_eventState,""))); break; +#endif // DEQP_SUPPORT_X11 #if defined (DEQP_SUPPORT_XCB) case vk::wsi::TYPE_XCB: - return new VulkanDisplayXcb(MovePtr(new XcbDisplay(m_eventState,""))); + return new VulkanDisplayXcb(MovePtr(new x11::XcbDisplay(m_eventState,""))); break; #endif // DEQP_SUPPORT_XCB +#if defined (DEQP_SUPPORT_WAYLAND) + case vk::wsi::TYPE_WAYLAND: + return new VulkanDisplayWayland(MovePtr(new wayland::Display(m_eventState, DE_NULL))); + break; +#endif // DEQP_SUPPORT_WAYLAND + default: TCU_THROW(NotSupportedError, "WSI type not supported"); @@ -194,6 +253,6 @@ void VulkanPlatform::getMemoryLimits (vk::PlatformMemoryLimits& limits) const limits.devicePageTableHierarchyLevels = 3; } -} // x11 +} // linux } // tcu diff --git a/framework/platform/X11/tcuX11VulkanPlatform.hpp b/framework/platform/lnx/tcuLnxVulkanPlatform.hpp similarity index 87% rename from framework/platform/X11/tcuX11VulkanPlatform.hpp rename to framework/platform/lnx/tcuLnxVulkanPlatform.hpp index 4137b59..b025f55 100644 --- a/framework/platform/X11/tcuX11VulkanPlatform.hpp +++ b/framework/platform/lnx/tcuLnxVulkanPlatform.hpp @@ -1,5 +1,5 @@ -#ifndef _TCUX11VULKANPLATFORM_HPP -#define _TCUX11VULKANPLATFORM_HPP +#ifndef _TCULNXVULKANPLATFORM_HPP +#define _TCULNXVULKANPLATFORM_HPP /*------------------------------------------------------------------------- * drawElements Quality Program Tester Core * ---------------------------------------- @@ -20,16 +20,17 @@ * *//*! * \file - * \brief X11Vulkan Platform. + * \brief Linux Vulkan Platform. *//*--------------------------------------------------------------------*/ #include "vkWsiPlatform.hpp" #include "vkPlatform.hpp" -#include "tcuX11.hpp" +#include "tcuLnx.hpp" namespace tcu { -namespace x11 +namespace lnx + { class VulkanPlatform : public vk::Platform @@ -46,7 +47,7 @@ private : }; -} // x11 +} // linux } // tcu -#endif // _TCUX11VULKANPLATFORM_HPP +#endif // _TCULNXVULKANPLATFORM_HPP diff --git a/framework/platform/wayland/tcuWayland.cpp b/framework/platform/lnx/wayland/tcuLnxWayland.cpp similarity index 94% rename from framework/platform/wayland/tcuWayland.cpp rename to framework/platform/lnx/wayland/tcuLnxWayland.cpp index 071cbb4..6d12543 100644 --- a/framework/platform/wayland/tcuWayland.cpp +++ b/framework/platform/lnx/wayland/tcuLnxWayland.cpp @@ -23,7 +23,7 @@ * \brief wayland utilities. *//*--------------------------------------------------------------------*/ -#include "tcuWayland.hpp" +#include "tcuLnxWayland.hpp" #include "gluRenderConfig.hpp" #include "deMemory.h" @@ -31,29 +31,11 @@ namespace tcu { -namespace wayland -{ - -EventState::EventState (void) - : m_quit(false) -{ -} - -EventState::~EventState (void) +namespace lnx { -} - -void EventState::setQuitFlag (bool quit) +namespace wayland { - de::ScopedLock lock(m_mutex); - m_quit = quit; -} -bool EventState::getQuitFlag (void) -{ - de::ScopedLock lock(m_mutex); - return m_quit; -} const struct wl_registry_listener Display::s_registryListener = { Display::handleGlobal, @@ -231,4 +213,5 @@ Window::~Window (void) } } // wayland +} // lnx } // tcu diff --git a/framework/platform/wayland/tcuWayland.hpp b/framework/platform/lnx/wayland/tcuLnxWayland.hpp similarity index 86% rename from framework/platform/wayland/tcuWayland.hpp rename to framework/platform/lnx/wayland/tcuLnxWayland.hpp index 2a2468c..b5d1f9e 100644 --- a/framework/platform/wayland/tcuWayland.hpp +++ b/framework/platform/lnx/wayland/tcuLnxWayland.hpp @@ -1,5 +1,5 @@ -#ifndef _TCUWAYLAND_HPP -#define _TCUWAYLAND_HPP +#ifndef _TCULNXWAYLAND_HPP +#define _TCULNXWAYLAND_HPP /*------------------------------------------------------------------------- * drawElements Quality Program Tester Core * ---------------------------------------- @@ -28,39 +28,17 @@ #include "tcuDefs.hpp" #include "gluRenderConfig.hpp" #include "gluPlatform.hpp" -#include "deMutex.hpp" +#include "tcuLnx.hpp" #include #include namespace tcu { -namespace wayland -{ - -enum +namespace lnx { - DEFAULT_WINDOW_WIDTH = 400, - DEFAULT_WINDOW_HEIGHT = 300 -}; - -class EventState +namespace wayland { -public: - EventState (void); - virtual ~EventState (void); - - void setQuitFlag (bool quit); - bool getQuitFlag (void); - -protected: - de::Mutex m_mutex; - bool m_quit; - -private: - EventState (const EventState&); - EventState& operator= (const EventState&); -}; class Display { @@ -127,6 +105,7 @@ private: }; } // wayland +} // lnx } // tcu -#endif // _TCUWAYLAND_HPP +#endif // _TCULNXWAYLAND_HPP diff --git a/framework/platform/wayland/tcuWaylandEglPlatform.cpp b/framework/platform/lnx/wayland/tcuLnxWaylandEglDisplayFactory.cpp similarity index 94% rename from framework/platform/wayland/tcuWaylandEglPlatform.cpp rename to framework/platform/lnx/wayland/tcuLnxWaylandEglDisplayFactory.cpp index 89a51ac..d462670 100644 --- a/framework/platform/wayland/tcuWaylandEglPlatform.cpp +++ b/framework/platform/lnx/wayland/tcuLnxWaylandEglDisplayFactory.cpp @@ -20,17 +20,21 @@ * *//*! * \file - * \brief wayland Egl Platform. + * \brief wayland Egl Display Factory. *//*--------------------------------------------------------------------*/ -#include "tcuWaylandEglPlatform.hpp" +#include "tcuLnxWaylandEglDisplayFactory.hpp" +#include "tcuLnxWayland.hpp" #include "egluGLContextFactory.hpp" #include "eglwLibrary.hpp" #include "eglwFunctions.hpp" #include "eglwEnums.hpp" +#include "deUniquePtr.hpp" namespace tcu { +namespace lnx +{ namespace wayland { namespace egl @@ -187,16 +191,12 @@ NativeDisplay* DisplayFactory::createDisplay (const eglw::EGLAttrib* attribList) return new Display(waylandDisplay); } -Platform::Platform (EventState& eventState) -{ - m_nativeDisplayFactoryRegistry.registerFactory(new DisplayFactory(eventState)); -} - -MovePtr Platform::createContextFactory (void) +NativeDisplayFactory* createDisplayFactory (EventState& eventState) { - return MovePtr(new GLContextFactory(m_nativeDisplayFactoryRegistry)); + return new DisplayFactory(eventState); } } // egl } // wayland +} // lnx } // tcu diff --git a/framework/platform/wayland/tcuWaylandPlatform.hpp b/framework/platform/lnx/wayland/tcuLnxWaylandEglDisplayFactory.hpp similarity index 70% rename from framework/platform/wayland/tcuWaylandPlatform.hpp rename to framework/platform/lnx/wayland/tcuLnxWaylandEglDisplayFactory.hpp index ba73763..5b15883 100644 --- a/framework/platform/wayland/tcuWaylandPlatform.hpp +++ b/framework/platform/lnx/wayland/tcuLnxWaylandEglDisplayFactory.hpp @@ -1,5 +1,5 @@ -#ifndef _TCUWAYLANDPLATFORM_HPP -#define _TCUWAYLANDPLATFORM_HPP +#ifndef _TCULNXWAYLANDEGLDISPLAYFACTORY_HPP +#define _TCULNXWAYLANDEGLDISPLAYFACTORY_HPP /*------------------------------------------------------------------------- * drawElements Quality Program Tester Core * ---------------------------------------- @@ -22,11 +22,26 @@ * *//*! * \file - * \brief Wayland Platform. + * \brief wayland Egl Display Factory. *//*--------------------------------------------------------------------*/ -#include "tcuPlatform.hpp" +#include "tcuLnx.hpp" +#include "egluNativeDisplay.hpp" -tcu::Platform* createPlatform (void); +namespace tcu +{ +namespace lnx +{ +namespace wayland +{ +namespace egl +{ -#endif // _TCUWAYLANDPLATFORM_HPP +eglu::NativeDisplayFactory* createDisplayFactory (EventState& eventState); + +} // egl +} // wayland +} // lnx +} // tcu + +#endif // _TCULNXWAYLANDEGLDISPLAYFACTORY_HPP diff --git a/framework/platform/wayland/tcuWaylandPlatform.cpp b/framework/platform/wayland/tcuWaylandPlatform.cpp deleted file mode 100644 index bf3f001..0000000 --- a/framework/platform/wayland/tcuWaylandPlatform.cpp +++ /dev/null @@ -1,83 +0,0 @@ -/*------------------------------------------------------------------------- - * drawElements Quality Program Tester Core - * ---------------------------------------- - * - * Copyright (c) 2014 The Android Open Source Project - * Copyright (c) 2016 The Khronos Group Inc. - * Copyright (c) 2016 Mun Gwan-gyeong - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - *//*! - * \file - * \brief wayland Platform. - *//*--------------------------------------------------------------------*/ - -#include "tcuWaylandPlatform.hpp" -#include "tcuWaylandEglPlatform.hpp" - -#include "deUniquePtr.hpp" -#include "gluPlatform.hpp" -#include "vkPlatform.hpp" -#include "tcuWayland.hpp" -#include "tcuWaylandVulkanPlatform.hpp" -#include "tcuFunctionLibrary.hpp" -#include "deMemory.h" - -#include - -namespace tcu -{ -namespace wayland -{ - -class WaylandGLPlatform : public glu::Platform -{ -public: - void registerFactory (de::MovePtr factory) - { - m_contextFactoryRegistry.registerFactory(factory.release()); - } -}; - -class WaylandPlatform : public tcu::Platform -{ -public: - WaylandPlatform (void); - bool processEvents (void) { return !m_eventState.getQuitFlag(); } - const glu::Platform& getGLPlatform (void) const { return m_glPlatform; } - const eglu::Platform& getEGLPlatform (void) const { return m_eglPlatform; } - const vk::Platform& getVulkanPlatform (void) const { return m_vkPlatform; } - - -private: - EventState m_eventState; - wayland::egl::Platform m_eglPlatform; - WaylandGLPlatform m_glPlatform; - WaylandVulkanPlatform m_vkPlatform; -}; - -WaylandPlatform::WaylandPlatform (void) - : m_eglPlatform (m_eventState) - , m_vkPlatform (m_eventState) -{ - m_glPlatform.registerFactory(m_eglPlatform.createContextFactory()); -} - -} // wayland -} // tcu - -tcu::Platform* createPlatform (void) -{ - return new tcu::wayland::WaylandPlatform(); -} diff --git a/framework/platform/wayland/tcuWaylandVulkanPlatform.cpp b/framework/platform/wayland/tcuWaylandVulkanPlatform.cpp deleted file mode 100644 index 77b686e..0000000 --- a/framework/platform/wayland/tcuWaylandVulkanPlatform.cpp +++ /dev/null @@ -1,147 +0,0 @@ -/*------------------------------------------------------------------------- - * drawElements Quality Program Tester Core - * ---------------------------------------- - * - * Copyright (c) 2016 The Khronos Group Inc. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - *//*! - * \file - * \brief Wayland Vulkan Platform. - *//*--------------------------------------------------------------------*/ - -#include "tcuWaylandVulkanPlatform.hpp" -#include "tcuWaylandPlatform.hpp" -#include "vkWsiPlatform.hpp" -#include "gluPlatform.hpp" -#include "tcuWayland.hpp" -#include "tcuFunctionLibrary.hpp" -#include "deUniquePtr.hpp" -#include "deMemory.h" - -#include - -using de::MovePtr; -using de::UniquePtr; - -namespace tcu -{ -namespace wayland -{ - -class VulkanWindowWayland : public vk::wsi::WaylandWindowInterface -{ -public: - VulkanWindowWayland (MovePtr window) - : vk::wsi::WaylandWindowInterface (vk::pt::WaylandSurfacePtr(window->getSurface())) - , m_window (window) - { - } - - void resize (const UVec2& newSize) - { - m_window->setDimensions((int)newSize.x(), (int)newSize.y()); - } - -private: - UniquePtr m_window; -}; - -class VulkanDisplayWayland : public vk::wsi::WaylandDisplayInterface -{ -public: - VulkanDisplayWayland (MovePtr display) - : vk::wsi::WaylandDisplayInterface (vk::pt::WaylandDisplayPtr(display->getDisplay())) - , m_display (display) - { - } - - vk::wsi::Window* createWindow (const Maybe& initialSize) const - { - const deUint32 height = !initialSize ? (deUint32)DEFAULT_WINDOW_HEIGHT : initialSize->y(); - const deUint32 width = !initialSize ? (deUint32)DEFAULT_WINDOW_WIDTH : initialSize->x(); - return new VulkanWindowWayland(MovePtr(new wayland::Window(*m_display, (int)width, (int)height))); - } - -private: - MovePtr m_display; -}; - -class VulkanLibrary : public vk::Library -{ -public: - VulkanLibrary (void) - : m_library ("libvulkan.so.1") - , m_driver (m_library) - { - } - - const vk::PlatformInterface& getPlatformInterface (void) const - { - return m_driver; - } - -private: - const DynamicFunctionLibrary m_library; - const vk::PlatformDriver m_driver; -}; - -WaylandVulkanPlatform::WaylandVulkanPlatform (EventState& eventState) - : m_eventState(eventState) -{ -} - -vk::wsi::Display* WaylandVulkanPlatform::createWsiDisplay (vk::wsi::Type wsiType) const -{ - switch(wsiType) - { - case vk::wsi::TYPE_WAYLAND: - return new VulkanDisplayWayland(MovePtr(new Display(m_eventState, DE_NULL))); - break; - default: - TCU_THROW(NotSupportedError, "WSI type not supported"); - - }; -} - -vk::Library* WaylandVulkanPlatform::createLibrary (void) const -{ - return new VulkanLibrary(); -} - -void WaylandVulkanPlatform::describePlatform (std::ostream& dst) const -{ - utsname sysInfo; - deMemset(&sysInfo, 0, sizeof(sysInfo)); - - if (uname(&sysInfo) != 0) - throw std::runtime_error("uname() failed"); - - dst << "OS: " << sysInfo.sysname << " " << sysInfo.release << " " << sysInfo.version << "\n"; - dst << "CPU: " << sysInfo.machine << "\n"; -} - -void WaylandVulkanPlatform::getMemoryLimits (vk::PlatformMemoryLimits& limits) const -{ - limits.totalSystemMemory = 256*1024*1024; - limits.totalDeviceLocalMemory = 128*1024*1024; - limits.deviceMemoryAllocationGranularity = 64*1024; - limits.devicePageSize = 4096; - limits.devicePageTableEntrySize = 8; - limits.devicePageTableHierarchyLevels = 3; -} - -} // wayland -} // tcu - diff --git a/framework/platform/wayland/tcuWaylandVulkanPlatform.hpp b/framework/platform/wayland/tcuWaylandVulkanPlatform.hpp deleted file mode 100644 index dfa5828..0000000 --- a/framework/platform/wayland/tcuWaylandVulkanPlatform.hpp +++ /dev/null @@ -1,52 +0,0 @@ -#ifndef _TCUWAYLANDVULKANPLATFORM_HPP -#define _TCUWAYLANDVULKANPLATFORM_HPP -/*------------------------------------------------------------------------- - * drawElements Quality Program Tester Core - * ---------------------------------------- - * - * Copyright (c) 2016 The Khronos Group Inc. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - *//*! - * \file - * \brief Wayland Vulkan Platform. - *//*--------------------------------------------------------------------*/ - -#include "vkWsiPlatform.hpp" -#include "vkPlatform.hpp" -#include "tcuWayland.hpp" - -namespace tcu -{ -namespace wayland -{ - -class WaylandVulkanPlatform : public vk::Platform -{ -public: - WaylandVulkanPlatform (EventState& eventState); - vk::wsi::Display* createWsiDisplay (vk::wsi::Type wsiType) const; - vk::Library* createLibrary (void) const; - void describePlatform (std::ostream& dst) const; - void getMemoryLimits (vk::PlatformMemoryLimits& limits) const; - -private : - EventState& m_eventState; -}; - - -} // wayland -} // tcu - -#endif // _TCUWAYLANDVULKANPLATFORM_HPP diff --git a/targets/wayland/FindWayland.cmake b/targets/default/FindWayland.cmake similarity index 100% rename from targets/wayland/FindWayland.cmake rename to targets/default/FindWayland.cmake diff --git a/targets/default/default.cmake b/targets/default/default.cmake index d4c95bc..6281a63 100644 --- a/targets/default/default.cmake +++ b/targets/default/default.cmake @@ -66,4 +66,10 @@ if (DE_OS_IS_UNIX) set(DEQP_PLATFORM_LIBRARIES ${XCB_LIBRARIES}) include_directories(${XCB_INCLUDE_DIR}) endif () + find_package(Wayland) + if (WAYLAND_FOUND) + set(DEQP_USE_WAYLAND ON) + set(DEQP_PLATFORM_LIBRARIES ${WAYLAND_LIBRARIES}) + include_directories(${WAYLAND_INCLUDE_DIR}) + endif () endif () diff --git a/targets/wayland/wayland.cmake b/targets/wayland/wayland.cmake index 3de6e7c..8adc417 100644 --- a/targets/wayland/wayland.cmake +++ b/targets/wayland/wayland.cmake @@ -25,7 +25,7 @@ set(DEQP_TARGET_NAME "Wayland") set(DEQP_USE_WAYLAND ON) # Add FindWayland module -set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} "${CMAKE_SOURCE_DIR}/targets/wayland") +set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} "${CMAKE_SOURCE_DIR}/targets/default") find_package(Wayland) if (NOT WAYLAND_FOUND) @@ -33,16 +33,4 @@ if (NOT WAYLAND_FOUND) endif () set(DEQP_PLATFORM_LIBRARIES ${WAYLAND_LIBRARIES}) -include_directories(${WAYLAND_INCLUDE_DIR}) - -# Platform sources -set(TCUTIL_PLATFORM_SRCS - wayland/tcuWayland.cpp - wayland/tcuWayland.hpp - wayland/tcuWaylandPlatform.cpp - wayland/tcuWaylandPlatform.hpp - wayland/tcuWaylandEglPlatform.cpp - wayland/tcuWaylandEglPlatform.hpp - wayland/tcuWaylandVulkanPlatform.cpp - wayland/tcuWaylandVulkanPlatform.hpp - ) +include_directories(${WAYLAND_INCLUDE_DIR}) \ No newline at end of file -- 2.7.4