From: Mun Gwan-gyeong Date: Mon, 11 Jul 2016 23:14:13 +0000 (+0900) Subject: framework/platform: GH20, Add support for wayland platform. X-Git-Tag: upstream/0.1.0~738^2~5^2~4^2^2 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=204cab3e14d50366384eb129e35b8532e7c948d9;p=platform%2Fupstream%2FVK-GL-CTS.git framework/platform: GH20, Add support for wayland platform. This change adds wayland platform with wl_shell protocol. Signed-off-by: Mun Gwan-gyeong --- diff --git a/framework/egl/wrapper/eglwEnums.inl b/framework/egl/wrapper/eglwEnums.inl index 86b8cdb..bfa267d 100644 --- a/framework/egl/wrapper/eglwEnums.inl +++ b/framework/egl/wrapper/eglwEnums.inl @@ -238,6 +238,7 @@ #define EGL_LOSE_CONTEXT_ON_RESET_EXT 0x31BF #define EGL_PLATFORM_X11_EXT 0x31D5 #define EGL_PLATFORM_X11_SCREEN_EXT 0x31D6 +#define EGL_PLATFORM_WAYLAND_KHR 0x31D8 #define EGL_YUV_BUFFER_EXT 0x3300 #define EGL_YUV_ORDER_EXT 0x3301 #define EGL_YUV_ORDER_YUV_EXT 0x3302 diff --git a/framework/platform/wayland/tcuWayland.cpp b/framework/platform/wayland/tcuWayland.cpp new file mode 100644 index 0000000..70640bb --- /dev/null +++ b/framework/platform/wayland/tcuWayland.cpp @@ -0,0 +1,237 @@ +/*------------------------------------------------------------------------- + * 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 utilities. + *//*--------------------------------------------------------------------*/ + +#include "tcuWayland.hpp" +#include "gluRenderConfig.hpp" +#include "deMemory.h" + +#include + +namespace tcu +{ +namespace wayland +{ + +enum +{ + DEFAULT_WINDOW_WIDTH = 400, + DEFAULT_WINDOW_HEIGHT = 300 +}; + +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; +} +const struct wl_registry_listener Display::s_registryListener = +{ + Display::handleGlobal, + Display::handleGlobalRemove +}; + +const struct wl_shell_surface_listener Window::s_shellSurfaceListener = +{ + Window::handlePing, + Window::handleConfigure, + Window::handlePopupDone, +}; + +void Display::handleGlobal (void* data, struct wl_registry* registry, uint32_t id, const char* interface, uint32_t version) +{ + Display* _this = static_cast(data); + DE_UNREF(version); + + if (!strcmp(interface, "wl_compositor")) + _this->m_compositor = static_cast(wl_registry_bind(registry, id, &wl_compositor_interface, 3)); + /* Todo: when the xdg_shell protocol has stablized, we should move wl_shell to xdg_shell. */ + if (!strcmp(interface, "wl_shell")) + _this->m_shell = static_cast(wl_registry_bind(registry, id, &wl_shell_interface, 1)); +} + +void Display::handleGlobalRemove (void* data, struct wl_registry* registry, uint32_t name) +{ + DE_UNREF(data); + DE_UNREF(registry); + DE_UNREF(name); +} + +Display::Display (EventState& eventState, const char* name) + : m_eventState (eventState) + , m_display (DE_NULL) +{ + try + { + m_display = wl_display_connect(name); + if (!m_display) + throw ResourceError("Failed to open display", name, __FILE__, __LINE__); + + m_registry = wl_display_get_registry(m_display); + if (!m_registry) + throw ResourceError("Failed to get registry", name, __FILE__, __LINE__); + + wl_registry_add_listener(m_registry, &s_registryListener, this); + wl_display_roundtrip(m_display); + if (!m_compositor) + throw ResourceError("Failed to bind compositor", name, __FILE__, __LINE__); + if (!m_shell) + throw ResourceError("Failed to bind shell", name, __FILE__, __LINE__); + } + catch (...) + { + if (m_shell) + wl_shell_destroy(m_shell); + + if (m_compositor) + wl_compositor_destroy(m_compositor); + + if (m_registry) + wl_registry_destroy(m_registry); + + if (m_display) + wl_display_disconnect(m_display); + + throw; + } +} + +Display::~Display (void) +{ + if (m_shell) + wl_shell_destroy(m_shell); + + if (m_compositor) + wl_compositor_destroy(m_compositor); + + if (m_registry) + wl_registry_destroy(m_registry); + + if (m_display) + wl_display_disconnect(m_display); +} + +void Display::processEvents (void) +{ +} + +Window::Window (Display& display, int width, int height) + : m_display (display) +{ + try + { + m_surface = wl_compositor_create_surface(display.getCompositor()); + if (!m_surface) + throw ResourceError("Failed to create ", "surface", __FILE__, __LINE__); + + m_shellSurface = wl_shell_get_shell_surface(display.getShell(), m_surface); + if (!m_shellSurface) + throw ResourceError("Failed to create ", "shell_surface", __FILE__, __LINE__); + + wl_shell_surface_add_listener(m_shellSurface, &s_shellSurfaceListener, this); + wl_shell_surface_set_title(m_shellSurface, "CTS for OpenGL (ES)"); + wl_shell_surface_set_toplevel(m_shellSurface); + + if (width == glu::RenderConfig::DONT_CARE) + width = DEFAULT_WINDOW_WIDTH; + if (height == glu::RenderConfig::DONT_CARE) + height = DEFAULT_WINDOW_HEIGHT; + + m_window = wl_egl_window_create(m_surface, width, height); + if (!m_window) + throw ResourceError("Failed to create ", "window", __FILE__, __LINE__); + } + catch (...) + { + throw; + } + TCU_CHECK(m_window); +} + +void Window::setVisibility (bool visible) +{ + m_visible = visible; +} + +void Window::getDimensions (int* width, int* height) const +{ + wl_egl_window_get_attached_size(m_window, width, height); +} + +void Window::setDimensions (int width, int height) +{ + wl_egl_window_resize(m_window, width, height, 0, 0); +} + +void Window::processEvents (void) +{ +} + +void Window::handlePing (void* data, struct wl_shell_surface* shellSurface, uint32_t serial) +{ + DE_UNREF(data); + wl_shell_surface_pong(shellSurface, serial); +} + +void Window::handleConfigure (void* data, struct wl_shell_surface* shellSurface, uint32_t edges, int32_t width, int32_t height) +{ + DE_UNREF(data); + DE_UNREF(shellSurface); + DE_UNREF(edges); + DE_UNREF(width); + DE_UNREF(height); +} + +void Window::handlePopupDone (void* data, struct wl_shell_surface* shellSurface) +{ + DE_UNREF(data); + DE_UNREF(shellSurface); +} + +Window::~Window (void) +{ + if (m_window) + wl_egl_window_destroy(m_window); + if (m_shellSurface) + wl_shell_surface_destroy(m_shellSurface); + if (m_surface) + wl_surface_destroy(m_surface); +} + +} // wayland +} // tcu diff --git a/framework/platform/wayland/tcuWayland.hpp b/framework/platform/wayland/tcuWayland.hpp new file mode 100644 index 0000000..d4cc94c --- /dev/null +++ b/framework/platform/wayland/tcuWayland.hpp @@ -0,0 +1,125 @@ +#ifndef _TCUWAYLAND_HPP +#define _TCUWAYLAND_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 + * + * 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 utilities. + *//*--------------------------------------------------------------------*/ + +#include "tcuDefs.hpp" +#include "gluRenderConfig.hpp" +#include "gluPlatform.hpp" +#include "deMutex.hpp" + +#include +#include + +namespace tcu +{ +namespace wayland +{ + +class EventState +{ +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 +{ +public: + Display (EventState& platform, const char* name); + virtual ~Display (void); + + struct wl_display* getDisplay (void) { return m_display; } + struct wl_compositor* getCompositor (void) { return m_compositor; } + struct wl_shell* getShell (void) { return m_shell; } + + void processEvents (void); + +protected: + EventState& m_eventState; + struct wl_display* m_display; + struct wl_registry* m_registry; + struct wl_compositor* m_compositor; + struct wl_shell* m_shell; + +private: + Display (const Display&); + Display& operator= (const Display&); + + static const struct wl_registry_listener s_registryListener; + + static void handleGlobal (void* data, struct wl_registry* registry, uint32_t id, const char* interface, uint32_t version); + static void handleGlobalRemove (void* data, struct wl_registry* registry, uint32_t name); +}; + +class Window +{ +public: + Window (Display& display, int width, int height); + ~Window (void); + + void setVisibility (bool visible); + + void processEvents (void); + Display& getDisplay (void) { return m_display; } + void* getWindow (void) { return m_window; } + + void getDimensions (int* width, int* height) const; + void setDimensions (int width, int height); + +protected: + + Display& m_display; + struct wl_egl_window* m_window; + struct wl_surface* m_surface; + struct wl_shell_surface* m_shellSurface; + bool m_visible; + +private: + Window (const Window&); + Window& operator= (const Window&); + + static const struct wl_shell_surface_listener s_shellSurfaceListener; + + static void handlePing (void* data, struct wl_shell_surface* shellSurface, uint32_t serial); + static void handleConfigure (void* data, struct wl_shell_surface* shellSurface, uint32_t edges, int32_t width, int32_t height); + static void handlePopupDone (void* data, struct wl_shell_surface* shellSurface); +}; + +} // wayland +} // tcu + +#endif // _TCUWAYLAND_HPP diff --git a/framework/platform/wayland/tcuWaylandEglPlatform.cpp b/framework/platform/wayland/tcuWaylandEglPlatform.cpp new file mode 100644 index 0000000..89a51ac --- /dev/null +++ b/framework/platform/wayland/tcuWaylandEglPlatform.cpp @@ -0,0 +1,202 @@ +/*------------------------------------------------------------------------- + * 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 Egl Platform. + *//*--------------------------------------------------------------------*/ + +#include "tcuWaylandEglPlatform.hpp" +#include "egluGLContextFactory.hpp" +#include "eglwLibrary.hpp" +#include "eglwFunctions.hpp" +#include "eglwEnums.hpp" + +namespace tcu +{ +namespace wayland +{ +namespace egl +{ + +using std::string; + +using de::MovePtr; +using de::UniquePtr; +using glu::ContextFactory; +using eglu::GLContextFactory; +using eglu::NativeDisplay; +using eglu::NativeDisplayFactory; +using eglu::NativeWindow; +using eglu::NativeWindowFactory; +using eglu::NativePixmap; +using eglu::NativePixmapFactory; +using eglu::WindowParams; +using tcu::TextureLevel; + +class Display : public NativeDisplay +{ +public: + static const Capability CAPABILITIES = Capability(CAPABILITY_GET_DISPLAY_LEGACY| + CAPABILITY_GET_DISPLAY_PLATFORM); + + Display (MovePtr waylandDisplay) + : NativeDisplay (CAPABILITIES, + EGL_PLATFORM_WAYLAND_KHR, + "EGL_KHR_platform_wayland") + , m_display (waylandDisplay) + , m_library ("libEGL.so") {} + + ~Display(void) {} + wayland::Display& getWaylandDisplay (void) { return *m_display; } + eglw::EGLNativeDisplayType getLegacyNative (void) { return reinterpret_cast(m_display->getDisplay()); } + void* getPlatformNative (void) { return m_display->getDisplay(); } + const eglw::Library& getLibrary (void) const { return m_library; } + const eglw::EGLAttrib* getPlatformAttributes (void) const { return DE_NULL; } + +private: + UniquePtr m_display; + eglw::DefaultLibrary m_library; +}; + +class Window : public NativeWindow +{ +public: + static const Capability CAPABILITIES = Capability(CAPABILITY_CREATE_SURFACE_LEGACY | + CAPABILITY_GET_SURFACE_SIZE | + CAPABILITY_SET_SURFACE_SIZE | + CAPABILITY_GET_SCREEN_SIZE); + + Window (Display& display, + const WindowParams& params); + + eglw::EGLNativeWindowType getLegacyNative (void) { return reinterpret_cast(m_window.getWindow()); } + IVec2 getSurfaceSize (void) const; + void setSurfaceSize (IVec2 size); + IVec2 getScreenSize (void) const { return getSurfaceSize(); } + +private: + wayland::Window m_window; +}; + +Window::Window (Display& display, const WindowParams& params) + : NativeWindow (CAPABILITIES) + , m_window (display.getWaylandDisplay(), params.width, params.height) +{ +} + +IVec2 Window::getSurfaceSize (void) const +{ + IVec2 ret; + m_window.getDimensions(&ret.x(), &ret.y()); + return ret; +} + +void Window::setSurfaceSize (IVec2 size) +{ + m_window.setDimensions(size.x(), size.y()); +} + +class WindowFactory : public NativeWindowFactory +{ +public: + WindowFactory (void); + + NativeWindow* createWindow (NativeDisplay* nativeDisplay, + const WindowParams& params) const; + + NativeWindow* createWindow (NativeDisplay* nativeDisplay, + eglw::EGLDisplay display, + eglw::EGLConfig config, + const eglw::EGLAttrib* attribList, + const WindowParams& params) const; +}; + +WindowFactory::WindowFactory (void) + : NativeWindowFactory ("window", "Wayland Window", Window::CAPABILITIES) +{ +} + +NativeWindow* WindowFactory::createWindow (NativeDisplay* nativeDisplay, + const WindowParams& params) const +{ + Display& display = *dynamic_cast(nativeDisplay); + + return new Window(display, params); +} + +NativeWindow* WindowFactory::createWindow (NativeDisplay* nativeDisplay, + eglw::EGLDisplay eglDisplay, + eglw::EGLConfig config, + const eglw::EGLAttrib* attribList, + const WindowParams& params) const +{ + DE_UNREF(eglDisplay); + DE_UNREF(config); + DE_UNREF(attribList); + + Display& display = *dynamic_cast(nativeDisplay); + + return new Window(display, params); +} + +class DisplayFactory : public NativeDisplayFactory +{ +public: + DisplayFactory (EventState& eventState); + + NativeDisplay* createDisplay (const eglw::EGLAttrib* attribList) const; + +private: + EventState& m_eventState; +}; + +DisplayFactory::DisplayFactory (EventState& eventState) + : NativeDisplayFactory ("Wayland", "Native Wayland Display", + Display::CAPABILITIES, + EGL_PLATFORM_WAYLAND_KHR, + "EGL_KHR_platform_wayland") + , m_eventState (eventState) +{ + m_nativeWindowRegistry.registerFactory(new WindowFactory()); +} + +NativeDisplay* DisplayFactory::createDisplay (const eglw::EGLAttrib* attribList) const +{ + DE_UNREF(attribList); + + MovePtr waylandDisplay (new wayland::Display(m_eventState, DE_NULL)); + + return new Display(waylandDisplay); +} + +Platform::Platform (EventState& eventState) +{ + m_nativeDisplayFactoryRegistry.registerFactory(new DisplayFactory(eventState)); +} + +MovePtr Platform::createContextFactory (void) +{ + return MovePtr(new GLContextFactory(m_nativeDisplayFactoryRegistry)); +} + +} // egl +} // wayland +} // tcu diff --git a/framework/platform/wayland/tcuWaylandEglPlatform.hpp b/framework/platform/wayland/tcuWaylandEglPlatform.hpp new file mode 100644 index 0000000..e28ab2a --- /dev/null +++ b/framework/platform/wayland/tcuWaylandEglPlatform.hpp @@ -0,0 +1,53 @@ +#ifndef _TCUWAYLANDEGLPLATFORM_HPP +#define _TCUWAYLANDEGLPLATFORM_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 + * + * 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 Egl Platform. + *//*--------------------------------------------------------------------*/ + +#include "deUniquePtr.hpp" +#include "egluPlatform.hpp" +#include "gluContextFactory.hpp" +#include "tcuWayland.hpp" + +namespace tcu +{ +namespace wayland +{ +namespace egl +{ + +class Platform : public eglu::Platform +{ +public: + Platform (EventState& eventState); + ~Platform (void) {} + + de::MovePtr createContextFactory (void); +}; + +} +} // wayland +} // tcu + +#endif // _TCUWAYLANDEGLPLATFORM_HPP diff --git a/framework/platform/wayland/tcuWaylandPlatform.cpp b/framework/platform/wayland/tcuWaylandPlatform.cpp new file mode 100644 index 0000000..55391b4 --- /dev/null +++ b/framework/platform/wayland/tcuWaylandPlatform.cpp @@ -0,0 +1,132 @@ +/*------------------------------------------------------------------------- + * 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 "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 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 tcu::DynamicFunctionLibrary m_library; + const vk::PlatformDriver m_driver; +}; + +class WaylandVulkanPlatform : public vk::Platform +{ +public: + vk::Library* createLibrary (void) const + { + return new VulkanLibrary(); + } + + void 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 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; + } +}; + +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_glPlatform.registerFactory(m_eglPlatform.createContextFactory()); +} + +} // wayland +} // tcu + +tcu::Platform* createPlatform (void) +{ + return new tcu::wayland::WaylandPlatform(); +} diff --git a/framework/platform/wayland/tcuWaylandPlatform.hpp b/framework/platform/wayland/tcuWaylandPlatform.hpp new file mode 100644 index 0000000..ba73763 --- /dev/null +++ b/framework/platform/wayland/tcuWaylandPlatform.hpp @@ -0,0 +1,32 @@ +#ifndef _TCUWAYLANDPLATFORM_HPP +#define _TCUWAYLANDPLATFORM_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 + * + * 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 "tcuPlatform.hpp" + +tcu::Platform* createPlatform (void); + +#endif // _TCUWAYLANDPLATFORM_HPP diff --git a/scripts/egl/common.py b/scripts/egl/common.py index a4e7b67..7554f2b 100644 --- a/scripts/egl/common.py +++ b/scripts/egl/common.py @@ -59,6 +59,7 @@ EXTENSIONS = [ "EGL_EXT_create_context_robustness", "EGL_EXT_platform_base", "EGL_EXT_platform_x11", + "EGL_KHR_platform_wayland", "EGL_ANDROID_image_native_buffer", "EGL_EXT_yuv_surface", "EGL_EXT_buffer_age", diff --git a/targets/wayland/FindWayland.cmake b/targets/wayland/FindWayland.cmake new file mode 100644 index 0000000..f93218b --- /dev/null +++ b/targets/wayland/FindWayland.cmake @@ -0,0 +1,66 @@ +# Try to find Wayland on a Unix system +# +# This will define: +# +# WAYLAND_FOUND - True if Wayland is found +# WAYLAND_LIBRARIES - Link these to use Wayland +# WAYLAND_INCLUDE_DIR - Include directory for Wayland +# WAYLAND_DEFINITIONS - Compiler flags for using Wayland +# +# In addition the following more fine grained variables will be defined: +# +# WAYLAND_CLIENT_FOUND WAYLAND_CLIENT_INCLUDE_DIR WAYLAND_CLIENT_LIBRARIES +# WAYLAND_SERVER_FOUND WAYLAND_SERVER_INCLUDE_DIR WAYLAND_SERVER_LIBRARIES +# WAYLAND_EGL_FOUND WAYLAND_EGL_INCLUDE_DIR WAYLAND_EGL_LIBRARIES +# +# Copyright (c) 2013 Martin Gräßlin +# +# Redistribution and use is allowed according to the terms of the BSD license. +# For details see the accompanying COPYING-CMAKE-SCRIPTS file. + +IF (NOT WIN32) + IF (WAYLAND_INCLUDE_DIR AND WAYLAND_LIBRARIES) + # In the cache already + SET(WAYLAND_FIND_QUIETLY TRUE) + ENDIF () + + # Use pkg-config to get the directories and then use these values + # in the FIND_PATH() and FIND_LIBRARY() calls + FIND_PACKAGE(PkgConfig) + PKG_CHECK_MODULES(PKG_WAYLAND QUIET wayland-client wayland-server wayland-egl wayland-cursor) + + SET(WAYLAND_DEFINITIONS ${PKG_WAYLAND_CFLAGS}) + + FIND_PATH(WAYLAND_CLIENT_INCLUDE_DIR NAMES wayland-client.h HINTS ${PKG_WAYLAND_INCLUDE_DIRS}) + FIND_PATH(WAYLAND_SERVER_INCLUDE_DIR NAMES wayland-server.h HINTS ${PKG_WAYLAND_INCLUDE_DIRS}) + FIND_PATH(WAYLAND_EGL_INCLUDE_DIR NAMES wayland-egl.h HINTS ${PKG_WAYLAND_INCLUDE_DIRS}) + FIND_PATH(WAYLAND_CURSOR_INCLUDE_DIR NAMES wayland-cursor.h HINTS ${PKG_WAYLAND_INCLUDE_DIRS}) + + FIND_LIBRARY(WAYLAND_CLIENT_LIBRARIES NAMES wayland-client HINTS ${PKG_WAYLAND_LIBRARY_DIRS}) + FIND_LIBRARY(WAYLAND_SERVER_LIBRARIES NAMES wayland-server HINTS ${PKG_WAYLAND_LIBRARY_DIRS}) + FIND_LIBRARY(WAYLAND_EGL_LIBRARIES NAMES wayland-egl HINTS ${PKG_WAYLAND_LIBRARY_DIRS}) + FIND_LIBRARY(WAYLAND_CURSOR_LIBRARIES NAMES wayland-cursor HINTS ${PKG_WAYLAND_LIBRARY_DIRS}) + + set(WAYLAND_INCLUDE_DIR ${WAYLAND_CLIENT_INCLUDE_DIR} ${WAYLAND_SERVER_INCLUDE_DIR} ${WAYLAND_EGL_INCLUDE_DIR} ${WAYLAND_CURSOR_INCLUDE_DIR}) + + set(WAYLAND_LIBRARIES ${WAYLAND_CLIENT_LIBRARIES} ${WAYLAND_SERVER_LIBRARIES} ${WAYLAND_EGL_LIBRARIES} ${WAYLAND_CURSOR_LIBRARIES}) + + list(REMOVE_DUPLICATES WAYLAND_INCLUDE_DIR) + + include(FindPackageHandleStandardArgs) + + FIND_PACKAGE_HANDLE_STANDARD_ARGS(WAYLAND_CLIENT DEFAULT_MSG WAYLAND_CLIENT_LIBRARIES WAYLAND_CLIENT_INCLUDE_DIR) + FIND_PACKAGE_HANDLE_STANDARD_ARGS(WAYLAND_SERVER DEFAULT_MSG WAYLAND_SERVER_LIBRARIES WAYLAND_SERVER_INCLUDE_DIR) + FIND_PACKAGE_HANDLE_STANDARD_ARGS(WAYLAND_EGL DEFAULT_MSG WAYLAND_EGL_LIBRARIES WAYLAND_EGL_INCLUDE_DIR) + FIND_PACKAGE_HANDLE_STANDARD_ARGS(WAYLAND_CURSOR DEFAULT_MSG WAYLAND_CURSOR_LIBRARIES WAYLAND_CURSOR_INCLUDE_DIR) + FIND_PACKAGE_HANDLE_STANDARD_ARGS(WAYLAND DEFAULT_MSG WAYLAND_LIBRARIES WAYLAND_INCLUDE_DIR) + + MARK_AS_ADVANCED( + WAYLAND_INCLUDE_DIR WAYLAND_LIBRARIES + WAYLAND_CLIENT_INCLUDE_DIR WAYLAND_CLIENT_LIBRARIES + WAYLAND_SERVER_INCLUDE_DIR WAYLAND_SERVER_LIBRARIES + WAYLAND_EGL_INCLUDE_DIR WAYLAND_EGL_LIBRARIES + WAYLAND_CURSOR_INCLUDE_DIR WAYLAND_CURSOR_LIBRARIES + ) + +ENDIF () diff --git a/targets/wayland/wayland.cmake b/targets/wayland/wayland.cmake new file mode 100644 index 0000000..269ff5a --- /dev/null +++ b/targets/wayland/wayland.cmake @@ -0,0 +1,30 @@ +message("*** Using Wayland target") +set(DEQP_TARGET_NAME "WAYLAND") +set(DEQP_RUNTIME_LINK ON) +set(DEQP_SUPPORT_GLES2 ON) +set(DEQP_SUPPORT_GLES3 ON) +set(DEQP_SUPPORT_EGL ON) + +# Use Wayland target +set(DEQP_USE_WAYLAND ON) + +# Add FindWayland module +set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} "${CMAKE_SOURCE_DIR}/targets/wayland") + +find_package(Wayland) +if (NOT WAYLAND_FOUND) + message(FATAL_ERROR "Wayland development package not 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 + )