From 61180d011c3c252aab7eeeebb6146e7818fcf61d Mon Sep 17 00:00:00 2001 From: Xiaoxuan Liu Date: Mon, 12 Oct 2020 16:40:13 +0800 Subject: [PATCH] Reland "Add support for Linux vulkan backend with VK_KHR_display" This is a reland of a7bb6a9b15ddeb8497523f8871deb25de2676d9f Original change's description: > Add support for Linux vulkan backend with VK_KHR_display > > Implement Linux simple display mode with vulkan backend > through VK_KHR_display. > > Added value 'EGL_PLATFORM_VULKAN_DISPLAY_MODE_SIMPLE_ANGLE' for > attribute EGL_PLATFORM_ANGLE_NATIVE_PLATFORM_TYPE_ANGLE to identify > the new simple display mode. Also reserved > EGL_PLATFORM_VULKAN_DISPLAY_MODE_HEADLESS_ANGLE for headless mode. > > How to enable: > Add > > ``` > use_x11=false > angle_vulkan_display_mode="simple" # default value > ``` > > into args.gn, then compile with linux vulkan args. > > Bug: angleproject:5214 > Change-Id: I1247585b9de8b55df106aba99322281f1c183203 > Reviewed-on: https://chromium-review.googlesource.com/c/angle/angle/+/2494320 > Commit-Queue: Jamie Madill > Reviewed-by: Jamie Madill > Reviewed-by: Shahbaz Youssefi Bug: angleproject:5214 Change-Id: I3921f6cb292c86658f39e739a878baad1ef64dba Reviewed-on: https://chromium-review.googlesource.com/c/angle/angle/+/2515327 Commit-Queue: Xiaoxuan Liu Commit-Queue: Jamie Madill Reviewed-by: Jamie Madill --- BUILD.gn | 9 ++ extensions/EGL_ANGLE_platform_angle.txt | 1 + extensions/EGL_ANGLE_vulkan_display.txt | 95 +++++++++++++++++++ gni/angle.gni | 14 ++- include/EGL/eglext_angle.h | 2 + src/common/vulkan/vulkan_icd.h | 6 ++ src/libANGLE/Display.cpp | 28 +++++- src/libANGLE/renderer/vulkan/BUILD.gn | 9 ++ src/libANGLE/renderer/vulkan/DisplayVk_api.h | 3 + .../vulkan/display/DisplayVkSimple.cpp | 64 +++++++++++++ .../renderer/vulkan/display/DisplayVkSimple.h | 41 ++++++++ .../vulkan/display/WindowSurfaceVkSimple.cpp | 82 ++++++++++++++++ .../vulkan/display/WindowSurfaceVkSimple.h | 31 ++++++ .../test_utils/angle_test_instantiate.cpp | 2 +- util/BUILD.gn | 10 +- util/display/DisplayPixmap.cpp | 16 ++++ util/display/DisplayWindow.cpp | 87 +++++++++++++++++ util/display/DisplayWindow.h | 51 ++++++++++ 18 files changed, 543 insertions(+), 8 deletions(-) create mode 100644 extensions/EGL_ANGLE_vulkan_display.txt create mode 100644 src/libANGLE/renderer/vulkan/display/DisplayVkSimple.cpp create mode 100644 src/libANGLE/renderer/vulkan/display/DisplayVkSimple.h create mode 100644 src/libANGLE/renderer/vulkan/display/WindowSurfaceVkSimple.cpp create mode 100644 src/libANGLE/renderer/vulkan/display/WindowSurfaceVkSimple.h create mode 100644 util/display/DisplayPixmap.cpp create mode 100644 util/display/DisplayWindow.cpp create mode 100644 util/display/DisplayWindow.h diff --git a/BUILD.gn b/BUILD.gn index f65500307..8e35dc527 100644 --- a/BUILD.gn +++ b/BUILD.gn @@ -114,6 +114,15 @@ config("internal_config") { if (is_ggp) { defines += [ "__ggp__" ] } + + if (angle_use_vulkan_display) { + defines += [ "ANGLE_USE_VULKAN_DISPLAY" ] + if (angle_vulkan_display_mode == "simple") { + defines += [ "ANGLE_VULKAN_DISPLAY_MODE_SIMPLE" ] + } else if (angle_vulkan_display_mode == "headless") { + defines += [ "ANGLE_VULKAN_DISPLAY_MODE_HEADLESS" ] + } + } } config("constructor_and_destructor_warnings") { diff --git a/extensions/EGL_ANGLE_platform_angle.txt b/extensions/EGL_ANGLE_platform_angle.txt index c9f8a5062..9689e1d7a 100644 --- a/extensions/EGL_ANGLE_platform_angle.txt +++ b/extensions/EGL_ANGLE_platform_angle.txt @@ -71,6 +71,7 @@ New Tokens EGL_PLATFORM_ANGLE_MAX_VERSION_MAJOR_ANGLE 0x3204 EGL_PLATFORM_ANGLE_MAX_VERSION_MINOR_ANGLE 0x3205 EGL_PLATFORM_ANGLE_DEBUG_LAYERS_ENABLED 0x3451 + EGL_PLATFORM_ANGLE_NATIVE_PLATFORM_TYPE_ANGLE 0x348F Accepted as values for the EGL_PLATFORM_ANGLE_TYPE_ANGLE attribute: diff --git a/extensions/EGL_ANGLE_vulkan_display.txt b/extensions/EGL_ANGLE_vulkan_display.txt new file mode 100644 index 000000000..7f750a780 --- /dev/null +++ b/extensions/EGL_ANGLE_vulkan_display.txt @@ -0,0 +1,95 @@ +Name + + ANGLE_vulkan_display + +Name Strings + + EGL_ANGLE_vulkan_display + +Contributors + + Xiaoxuan Liu, Arm Ltd. + Sunny Sun, Arm Ltd. + +Contacts + + Xiaoxuan Liu, Arm Ltd. (xiaoxuan 'dot' liu 'at' arm 'dot' com) + +Status + + Draft + +Version + + Version 1, 2020-10-29 + +Number + + EGL Extension XXX + +Extension Type + + EGL client extension + +Dependencies + + Requires EGL_EXT_platform_angle_vulkan. + +Overview + + This extension allows ANGLE to use simple display mode through + VK_KHR_display without native platform support (e.g. X11, GBM). + The EGLSurfaces to be created from native types only contain the + basic width and height info. + +New Types + + The basic structure to represent a display window, used by vulkan + backend to create valid display with VK_KHR_display. + + typedef struct displayWindow + { + khronos_uint16_t width; + khronos_uint16_t height; + } DisplayWindow; + +New Procedures and Functions + + None + +New Tokens + + Accepted as values for the EGL_PLATFORM_ANGLE_NATIVE_PLATFORM_TYPE_ANGLE + attribute: + + EGL_PLATFORM_VULKAN_DISPLAY_MODE_SIMPLE_ANGLE 0x34A4 + EGL_PLATFORM_VULKAN_DISPLAY_MODE_HEADLESS_ANGLE 0x34A5 + +Additions to the EGL Specification + + None + +New Behavior + + To obtain an simple EGLDisplay backed by a ANGLE vulkan with + VK_KHR_display, request a display that is backed by a Vulkan driver + through EGL_ANGLE_platform_angle_vulkan. And the value of attribute + EGL_PLATFORM_ANGLE_NATIVE_PLATFORM_TYPE_ANGLE should be + EGL_PLATFORM_VULKAN_DISPLAY_MODE_SIMPLE_ANGLE or + EGL_PLATFORM_VULKAN_DISPLAY_MODE_HEADLESS_ANGLE. + + If an EGLDisplay is backed by ANGLE vulkan VK_KHR_display and the + value of attribute EGL_PLATFORM_ANGLE_NATIVE_PLATFORM_TYPE_ANGLE is + set but neither EGL_PLATFORM_VULKAN_DISPLAY_MODE_SIMPLE_ANGLE or + EGL_PLATFORM_VULKAN_DISPLAY_MODE_HEADLESS_ANGLE, then EGL_NO_DISPLAY + should be returned. + +Issues + + None + +Revision History + + Version 1, 2020-10-29 (Xiaoxuan Liu) + - Initial draft + diff --git a/gni/angle.gni b/gni/angle.gni index 289d8bafe..c6908afb0 100644 --- a/gni/angle.gni +++ b/gni/angle.gni @@ -9,6 +9,9 @@ declare_args() { # Extract native libs in ANGLE apk. Useful for flamegraph generation. angle_extract_native_libs = false + + # Display mode for ANGLE vulkan display, could be 'simple' or 'headless', default is 'simple'. + angle_vulkan_display_mode = "simple" } if (angle_has_build) { @@ -27,6 +30,7 @@ if (angle_has_build) { } angle_use_x11 = use_x11 && !is_ggp + angle_use_vulkan_display = is_linux && !use_x11 && !is_ggp && !use_ozone } else { declare_args() { is_ubsan = false @@ -35,6 +39,7 @@ if (angle_has_build) { build_with_chromium = false dcheck_always_on = false angle_use_x11 = (is_linux || is_chromeos) && !is_ggp + angle_use_vulkan_display = is_linux && !angle_use_x11 && !is_ggp use_ozone = false ozone_platform_gbm = false use_fuzzing_engine = false @@ -101,10 +106,11 @@ declare_args() { # Vulkan Validation Layers compatibility issues, see http://crrev/c/1405714. # Otherwise, API level 24 would have been enough. angle_enable_vulkan = - angle_has_build && ((is_win && !angle_is_winuwp) || - (is_linux && angle_use_x11 && !is_chromeos) || - (is_android && ndk_api_level_at_least_26) || - is_fuchsia || is_ggp || is_mac) + angle_has_build && + ((is_win && !angle_is_winuwp) || + (is_linux && (angle_use_x11 || angle_use_vulkan_display) && + !is_chromeos) || (is_android && ndk_api_level_at_least_26) || + is_fuchsia || is_ggp || is_mac) angle_enable_null = true angle_enable_essl = true angle_enable_glsl = true diff --git a/include/EGL/eglext_angle.h b/include/EGL/eglext_angle.h index b5b669521..5b237388a 100644 --- a/include/EGL/eglext_angle.h +++ b/include/EGL/eglext_angle.h @@ -94,6 +94,8 @@ #ifndef EGL_ANGLE_platform_angle_vulkan #define EGL_ANGLE_platform_angle_vulkan 1 #define EGL_PLATFORM_ANGLE_TYPE_VULKAN_ANGLE 0x3450 +#define EGL_PLATFORM_VULKAN_DISPLAY_MODE_SIMPLE_ANGLE 0x34A4 +#define EGL_PLATFORM_VULKAN_DISPLAY_MODE_HEADLESS_ANGLE 0x34A5 #endif /* EGL_ANGLE_platform_angle_vulkan */ #ifndef EGL_ANGLE_platform_angle_metal diff --git a/src/common/vulkan/vulkan_icd.h b/src/common/vulkan/vulkan_icd.h index c612c15c6..8479fbd14 100644 --- a/src/common/vulkan/vulkan_icd.h +++ b/src/common/vulkan/vulkan_icd.h @@ -27,6 +27,12 @@ enum class ICD SwiftShader, }; +struct SimpleDisplayWindow +{ + uint16_t width; + uint16_t height; +}; + class ScopedVkLoaderEnvironment : angle::NonCopyable { public: diff --git a/src/libANGLE/Display.cpp b/src/libANGLE/Display.cpp index ccf24a57b..4587da7e3 100644 --- a/src/libANGLE/Display.cpp +++ b/src/libANGLE/Display.cpp @@ -226,11 +226,17 @@ EGLAttrib GetDeviceTypeFromEnvironment() EGLAttrib GetPlatformTypeFromEnvironment() { -#if defined(ANGLE_USE_X11) && !defined(ANGLE_USE_OZONE) +#if defined(ANGLE_USE_OZONE) + return 0; +#elif defined(ANGLE_USE_X11) return EGL_PLATFORM_X11_EXT; +#elif defined(ANGLE_USE_VULKAN_DISPLAY) && defined(ANGLE_VULKAN_DISPLAY_MODE_SIMPLE) + return EGL_PLATFORM_VULKAN_DISPLAY_MODE_SIMPLE_ANGLE; +#elif defined(ANGLE_USE_VULKAN_DISPLAY) && defined(ANGLE_VULKAN_DISPLAY_MODE_HEADLESS) + return EGL_PLATFORM_VULKAN_DISPLAY_MODE_HEADLESS_ANGLE; #else return 0; -#endif +#endif // defined(ANGLE_USE_OZONE) } rx::DisplayImpl *CreateDisplayFromAttribs(EGLAttrib displayType, @@ -354,6 +360,24 @@ rx::DisplayImpl *CreateDisplayFromAttribs(EGLAttrib displayType, impl = rx::CreateVulkanXcbDisplay(state); break; } +# elif defined(ANGLE_USE_VULKAN_DISPLAY) + if (platformType == EGL_PLATFORM_VULKAN_DISPLAY_MODE_SIMPLE_ANGLE && + rx::IsVulkanSimpleDisplayAvailable()) + { + impl = rx::CreateVulkanSimpleDisplay(state); + } + else if (platformType == EGL_PLATFORM_VULKAN_DISPLAY_MODE_HEADLESS_ANGLE) + { + // TODO: anglebug.com/5260 + // Add support for headless rendering + UNIMPLEMENTED(); + } + else + { + // Not supported creation type on vulkan display, fail display creation. + impl = nullptr; + } + break; # endif # elif defined(ANGLE_PLATFORM_ANDROID) if (rx::IsVulkanAndroidDisplayAvailable()) diff --git a/src/libANGLE/renderer/vulkan/BUILD.gn b/src/libANGLE/renderer/vulkan/BUILD.gn index 34591a4a4..54c461481 100644 --- a/src/libANGLE/renderer/vulkan/BUILD.gn +++ b/src/libANGLE/renderer/vulkan/BUILD.gn @@ -101,6 +101,15 @@ _vulkan_backend_sources = [ "vk_wrapper.h", ] +if (is_linux) { + _vulkan_backend_sources += [ + "display/DisplayVkSimple.cpp", + "display/DisplayVkSimple.h", + "display/WindowSurfaceVkSimple.cpp", + "display/WindowSurfaceVkSimple.h", + ] +} + if (is_android) { _vulkan_backend_sources += [ "android/DisplayVkAndroid.cpp", diff --git a/src/libANGLE/renderer/vulkan/DisplayVk_api.h b/src/libANGLE/renderer/vulkan/DisplayVk_api.h index 21e36a76b..03a627f9f 100644 --- a/src/libANGLE/renderer/vulkan/DisplayVk_api.h +++ b/src/libANGLE/renderer/vulkan/DisplayVk_api.h @@ -22,6 +22,9 @@ DisplayImpl *CreateVulkanWin32Display(const egl::DisplayState &state); #if defined(ANGLE_PLATFORM_LINUX) bool IsVulkanXcbDisplayAvailable(); DisplayImpl *CreateVulkanXcbDisplay(const egl::DisplayState &state); + +bool IsVulkanSimpleDisplayAvailable(); +DisplayImpl *CreateVulkanSimpleDisplay(const egl::DisplayState &state); #endif // defined(ANGLE_PLATFORM_LINUX) #if defined(ANGLE_PLATFORM_ANDROID) diff --git a/src/libANGLE/renderer/vulkan/display/DisplayVkSimple.cpp b/src/libANGLE/renderer/vulkan/display/DisplayVkSimple.cpp new file mode 100644 index 000000000..5cdb63d68 --- /dev/null +++ b/src/libANGLE/renderer/vulkan/display/DisplayVkSimple.cpp @@ -0,0 +1,64 @@ +// +// Copyright 2020 The ANGLE Project Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. +// +// DisplayVkSimple.cpp: +// Implements the class methods for DisplayVkSimple. +// + +#include "DisplayVkSimple.h" +#include "WindowSurfaceVkSimple.h" + +#include "libANGLE/Display.h" +#include "libANGLE/renderer/vulkan/RendererVk.h" +#include "libANGLE/renderer/vulkan/vk_caps_utils.h" + +namespace rx +{ + +DisplayVkSimple::DisplayVkSimple(const egl::DisplayState &state) : DisplayVk(state) {} + +void DisplayVkSimple::terminate() +{ + DisplayVk::terminate(); +} + +bool DisplayVkSimple::isValidNativeWindow(EGLNativeWindowType window) const +{ + return true; +} + +SurfaceImpl *DisplayVkSimple::createWindowSurfaceVk(const egl::SurfaceState &state, + EGLNativeWindowType window) +{ + return new WindowSurfaceVkSimple(state, window); +} + +egl::ConfigSet DisplayVkSimple::generateConfigs() +{ + constexpr GLenum kColorFormats[] = {GL_RGBA8, GL_BGRA8_EXT, GL_RGB565, GL_RGB8}; + + return egl_vk::GenerateConfigs(kColorFormats, egl_vk::kConfigDepthStencilFormats, this); +} + +// TODO: anglebug.com/5214 +// Detemine if check is needed. +void DisplayVkSimple::checkConfigSupport(egl::Config *config) {} + +const char *DisplayVkSimple::getWSIExtension() const +{ + return VK_KHR_DISPLAY_EXTENSION_NAME; +} + +bool IsVulkanSimpleDisplayAvailable() +{ + return true; +} + +DisplayImpl *CreateVulkanSimpleDisplay(const egl::DisplayState &state) +{ + return new DisplayVkSimple(state); +} + +} // namespace rx diff --git a/src/libANGLE/renderer/vulkan/display/DisplayVkSimple.h b/src/libANGLE/renderer/vulkan/display/DisplayVkSimple.h new file mode 100644 index 000000000..2ac304201 --- /dev/null +++ b/src/libANGLE/renderer/vulkan/display/DisplayVkSimple.h @@ -0,0 +1,41 @@ +// +// Copyright 2020 The ANGLE Project Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. +// +// DisplayVkSimple.h: +// Defines the class interface for DisplayVkSimple, implementing +// DisplayVk for Linux via VK_KHR_display. +// + +#ifndef LIBANGLE_RENDERER_VULKAN_DISPLAY_DISPLAYVKSIMPLE_H_ +#define LIBANGLE_RENDERER_VULKAN_DISPLAY_DISPLAYVKSIMPLE_H_ + +#include "libANGLE/renderer/vulkan/DisplayVk.h" + +namespace rx +{ + +class DisplayVkSimple : public DisplayVk +{ + public: + DisplayVkSimple(const egl::DisplayState &state); + void terminate() override; + + bool isValidNativeWindow(EGLNativeWindowType window) const override; + + SurfaceImpl *createWindowSurfaceVk(const egl::SurfaceState &state, + EGLNativeWindowType window) override; + + egl::ConfigSet generateConfigs() override; + void checkConfigSupport(egl::Config *config) override; + + const char *getWSIExtension() const override; + + private: + std::vector mSurfaceFormats; +}; + +} // namespace rx + +#endif // LIBANGLE_RENDERER_VULKAN_DISPLAY_DISPLAYVKSIMPLE_H_ diff --git a/src/libANGLE/renderer/vulkan/display/WindowSurfaceVkSimple.cpp b/src/libANGLE/renderer/vulkan/display/WindowSurfaceVkSimple.cpp new file mode 100644 index 000000000..d96bf530d --- /dev/null +++ b/src/libANGLE/renderer/vulkan/display/WindowSurfaceVkSimple.cpp @@ -0,0 +1,82 @@ +// +// Copyright 2020 The ANGLE Project Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. +// +// WindowSurfaceVkSimple.cpp: +// Implements the class methods for WindowSurfaceVkSimple. +// + +#include "WindowSurfaceVkSimple.h" +#include "libANGLE/renderer/vulkan/RendererVk.h" + +namespace rx +{ + +WindowSurfaceVkSimple::WindowSurfaceVkSimple(const egl::SurfaceState &surfaceState, + EGLNativeWindowType window) + : WindowSurfaceVk(surfaceState, window) +{} + +WindowSurfaceVkSimple::~WindowSurfaceVkSimple() {} + +angle::Result WindowSurfaceVkSimple::createSurfaceVk(vk::Context *context, gl::Extents *extentsOut) +{ + RendererVk *renderer = context->getRenderer(); + ASSERT(renderer != nullptr); + VkInstance instance = renderer->getInstance(); + VkPhysicalDevice physicalDevice = renderer->getPhysicalDevice(); + + // Query if there is a valid display + uint32_t count = 1; + ANGLE_VK_TRY(context, vkGetPhysicalDeviceDisplayPropertiesKHR(physicalDevice, &count, nullptr)); + + // Get display properties + VkDisplayPropertiesKHR prop = {}; + count = 1; + ANGLE_VK_TRY(context, vkGetPhysicalDeviceDisplayPropertiesKHR(physicalDevice, &count, &prop)); + + // we should have a valid display now + ASSERT(prop.display != VK_NULL_HANDLE); + ANGLE_VK_TRY(context, + vkGetDisplayModePropertiesKHR(physicalDevice, prop.display, &count, nullptr)); + + ASSERT(count != 0); + std::vector modeProperties(count); + ANGLE_VK_TRY(context, vkGetDisplayModePropertiesKHR(physicalDevice, prop.display, &count, + modeProperties.data())); + + angle::vk::SimpleDisplayWindow *displayWindow = + reinterpret_cast(mNativeWindowType); + VkDisplaySurfaceCreateInfoKHR info = {}; + info.sType = VK_STRUCTURE_TYPE_DISPLAY_SURFACE_CREATE_INFO_KHR; + info.flags = 0; + info.displayMode = modeProperties[0].displayMode; + info.planeIndex = 0; + info.planeStackIndex = 0; + info.transform = VK_SURFACE_TRANSFORM_IDENTITY_BIT_KHR; + info.globalAlpha = 1.0f; + info.alphaMode = VK_DISPLAY_PLANE_ALPHA_GLOBAL_BIT_KHR; + info.imageExtent.width = displayWindow->width; + info.imageExtent.height = displayWindow->height; + + ANGLE_VK_TRY(context, vkCreateDisplayPlaneSurfaceKHR(instance, &info, nullptr, &mSurface)); + + return getCurrentWindowSize(context, extentsOut); +} + +angle::Result WindowSurfaceVkSimple::getCurrentWindowSize(vk::Context *context, + gl::Extents *extentsOut) +{ + RendererVk *renderer = context->getRenderer(); + const VkPhysicalDevice &physicalDevice = renderer->getPhysicalDevice(); + + ANGLE_VK_TRY(context, vkGetPhysicalDeviceSurfaceCapabilitiesKHR(physicalDevice, mSurface, + &mSurfaceCaps)); + + *extentsOut = + gl::Extents(mSurfaceCaps.currentExtent.width, mSurfaceCaps.currentExtent.height, 1); + return angle::Result::Continue; +} + +} // namespace rx diff --git a/src/libANGLE/renderer/vulkan/display/WindowSurfaceVkSimple.h b/src/libANGLE/renderer/vulkan/display/WindowSurfaceVkSimple.h new file mode 100644 index 000000000..e5412add3 --- /dev/null +++ b/src/libANGLE/renderer/vulkan/display/WindowSurfaceVkSimple.h @@ -0,0 +1,31 @@ +// +// Copyright 2020 The ANGLE Project Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. +// +// WindowSurfaceVkSimple.h: +// Defines the class interface for WindowSurfaceVkSimple, implementing WindowSurfaceVk. +// + +#ifndef LIBANGLE_RENDERER_VULKAN_DISPLAY_WINDOWSURFACEVKSIMPLE_H_ +#define LIBANGLE_RENDERER_VULKAN_DISPLAY_WINDOWSURFACEVKSIMPLE_H_ + +#include "libANGLE/renderer/vulkan/SurfaceVk.h" + +namespace rx +{ + +class WindowSurfaceVkSimple : public WindowSurfaceVk +{ + public: + WindowSurfaceVkSimple(const egl::SurfaceState &surfaceState, EGLNativeWindowType window); + ~WindowSurfaceVkSimple() final; + + private: + angle::Result createSurfaceVk(vk::Context *context, gl::Extents *extentsOut) override; + angle::Result getCurrentWindowSize(vk::Context *context, gl::Extents *extentsOut) override; +}; + +} // namespace rx + +#endif // LIBANGLE_RENDERER_VULKAN_DISPLAY_WINDOWSURFACEVKSIMPLE_H_ diff --git a/src/tests/test_utils/angle_test_instantiate.cpp b/src/tests/test_utils/angle_test_instantiate.cpp index 3b8d92518..1c4eb0731 100644 --- a/src/tests/test_utils/angle_test_instantiate.cpp +++ b/src/tests/test_utils/angle_test_instantiate.cpp @@ -233,7 +233,7 @@ bool IsARM64() bool IsOzone() { -#if defined(USE_OZONE) && defined(USE_X11) +#if defined(USE_OZONE) && (defined(USE_X11) || defined(ANGLE_USE_VULKAN_DISPLAY)) // We do not have a proper support for Ozone/Linux yet. Still, we need to figure out how to // properly initialize tests and differentiate between X11 and Wayland. Probably, passing a // command line argument could be sufficient. At the moment, run tests only for X11 backend diff --git a/util/BUILD.gn b/util/BUILD.gn index c4d3ede53..a95218e94 100644 --- a/util/BUILD.gn +++ b/util/BUILD.gn @@ -40,6 +40,14 @@ if (is_win) { } } +if (is_linux) { + _util_sources += [ + "display/DisplayPixmap.cpp", + "display/DisplayWindow.cpp", + "display/DisplayWindow.h", + ] +} + if (angle_use_x11) { _util_sources += [ "x11/X11Pixmap.cpp", @@ -56,7 +64,7 @@ if (is_fuchsia) { "fuchsia/ScenicWindow.cpp", "fuchsia/ScenicWindow.h", ] -} else if (use_ozone && !angle_use_x11) { +} else if (use_ozone && !angle_use_x11 && !angle_use_vulkan_display) { # Use X11 impl by default otherwise switch to fake Ozone impl that does not # seem to do anything real. # TODO(msisov): probably, we need to have a proper support for different diff --git a/util/display/DisplayPixmap.cpp b/util/display/DisplayPixmap.cpp new file mode 100644 index 000000000..27d2734a3 --- /dev/null +++ b/util/display/DisplayPixmap.cpp @@ -0,0 +1,16 @@ +// +// Copyright 2020 The ANGLE Project Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. +// + +// DisplayPixmap.cpp: Implementation of OSPixmap for Linux Display + +#include "util/OSPixmap.h" + +#if defined(ANGLE_USE_VULKAN_DISPLAY) +OSPixmap *CreateOSPixmap() +{ + return nullptr; +} +#endif diff --git a/util/display/DisplayWindow.cpp b/util/display/DisplayWindow.cpp new file mode 100644 index 000000000..d11f52262 --- /dev/null +++ b/util/display/DisplayWindow.cpp @@ -0,0 +1,87 @@ +// +// Copyright 2020 The ANGLE Project Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. +// + +// DisplayWindow.cpp: Implementation of OSWindow for Linux Display + +#include "util/display/DisplayWindow.h" + +#include "common/debug.h" +#include "util/Timer.h" +#include "util/test_utils.h" + +DisplayWindow::DisplayWindow() +{ + mWindow.width = 0; + mWindow.height = 0; +} + +DisplayWindow::~DisplayWindow() {} + +bool DisplayWindow::initializeImpl(const std::string &name, int width, int height) +{ + return resize(width, height); +} + +void DisplayWindow::disableErrorMessageDialog() {} + +void DisplayWindow::destroy() {} + +void DisplayWindow::resetNativeWindow() {} + +EGLNativeWindowType DisplayWindow::getNativeWindow() const +{ + return (EGLNativeWindowType)&mWindow; +} + +EGLNativeDisplayType DisplayWindow::getNativeDisplay() const +{ + return NULL; +} + +void DisplayWindow::messageLoop() {} + +void DisplayWindow::setMousePosition(int x, int y) +{ + UNIMPLEMENTED(); +} + +bool DisplayWindow::setOrientation(int width, int height) +{ + UNIMPLEMENTED(); + return true; +} + +bool DisplayWindow::setPosition(int x, int y) +{ + UNIMPLEMENTED(); + return true; +} + +bool DisplayWindow::resize(int width, int height) +{ + mWindow.width = width; + mWindow.height = height; + return true; +} + +void DisplayWindow::setVisible(bool isVisible) {} + +void DisplayWindow::signalTestEvent() +{ + Event event; + event.Type = Event::EVENT_TEST; + event.Move.X = 0; + event.Move.Y = 0; + pushEvent(event); +} + +// static +#if defined(ANGLE_USE_VULKAN_DISPLAY) +OSWindow *OSWindow::New() +{ + return new DisplayWindow(); +} +#endif diff --git a/util/display/DisplayWindow.h b/util/display/DisplayWindow.h new file mode 100644 index 000000000..463fe4491 --- /dev/null +++ b/util/display/DisplayWindow.h @@ -0,0 +1,51 @@ +// +// Copyright 2020 The ANGLE Project Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. +// + +// DisplayWindow.h: Definition of the implementation of OSWindow for Linux Display + +#ifndef UTIL_DISPLAY_WINDOW_H_ +#define UTIL_DISPLAY_WINDOW_H_ + +#include +#include "util/OSWindow.h" +#include "util/util_export.h" + +struct SimpleDisplayWindow +{ + uint16_t width; + uint16_t height; +}; + +class ANGLE_UTIL_EXPORT DisplayWindow : public OSWindow +{ + public: + DisplayWindow(); + DisplayWindow(int visualId); + ~DisplayWindow() override; + + void disableErrorMessageDialog() override; + void destroy() override; + + void resetNativeWindow() override; + EGLNativeWindowType getNativeWindow() const override; + EGLNativeDisplayType getNativeDisplay() const override; + + void messageLoop() override; + + void setMousePosition(int x, int y) override; + bool setOrientation(int width, int height) override; + bool setPosition(int x, int y) override; + bool resize(int width, int height) override; + void setVisible(bool isVisible) override; + + void signalTestEvent() override; + + private: + bool initializeImpl(const std::string &name, int width, int height) override; + SimpleDisplayWindow mWindow; +}; + +#endif // UTIL_DISPLAY_WINDOW_H_