Commit b73eee71 by Sergey Ulanov Committed by Angle LUCI CQ

Reland: [Vulkan] Add DisplayVkNull

Currently all DisplayVk implementations depend on VK_KHR_swapchain and VK_KHR_surface extensions. When running Chromium on Fuchsia these extensions are never used (content is shown on the screen using ImagePipe API without dependency on swapchain). ANGLE still depended on these extensions for DisplayVkFuchsia. This CL adds DisplayVkNull, which allows to run ANGLE without dependency on swapchain. It's usable only offscreen and cannot present content on a surface. Bug: chromium:1203879 Change-Id: I5cadcdf46ed1cfb5ebb3cb69dbfef063e9e2b826 Reviewed-on: https://chromium-review.googlesource.com/c/angle/angle/+/3012368Reviewed-by: 's avatarJamie Madill <jmadill@chromium.org> Commit-Queue: Jamie Madill <jmadill@chromium.org>
parent 89f2a619
......@@ -138,7 +138,9 @@ config("internal_config") {
defines += [ "__ggp__" ]
}
if (angle_use_vulkan_display) {
if (angle_use_vulkan_null_display) {
defines += [ "ANGLE_USE_VULKAN_NULL_DISPLAY" ]
} else if (angle_use_vulkan_display) {
defines += [
"ANGLE_USE_VULKAN_DISPLAY",
"EGL_NO_X11",
......
......@@ -130,6 +130,10 @@ declare_args() {
(is_linux && (angle_use_x11 || angle_use_vulkan_display) &&
!is_chromeos) || is_android || is_fuchsia || is_ggp || is_mac)
# When set to true, ANGLE will not use VK_KHR_surface and VK_KHR_swapchain
# extensions. Content can be rendered only off-screen.
angle_use_vulkan_null_display = build_with_chromium && is_fuchsia
# Disable null backend to save space for official build.
angle_enable_null = !is_official_build
angle_enable_gl_desktop = !is_android && !is_ios
......
......@@ -54,9 +54,11 @@ group("angle_vulkan_entry_points") {
if (is_fuchsia) {
public_deps += [
"$angle_root/src/common/fuchsia_egl",
"//third_party/fuchsia-sdk:vulkan_base",
"//third_party/fuchsia-sdk/sdk/pkg/vulkan",
]
if (!angle_use_vulkan_null_display) {
public_deps += [ "//third_party/fuchsia-sdk/sdk/pkg/vulkan_layers:VkLayer_image_pipe_swapchain" ]
}
} else if (!is_android && !is_ggp) {
if (angle_shared_libvulkan) {
data_deps = [ "$angle_vulkan_loader_dir:libvulkan" ]
......
......@@ -365,7 +365,13 @@ rx::DisplayImpl *CreateDisplayFromAttribs(EGLAttrib displayType,
case EGL_PLATFORM_ANGLE_TYPE_VULKAN_ANGLE:
#if defined(ANGLE_ENABLE_VULKAN)
# if defined(ANGLE_PLATFORM_WINDOWS)
# if defined(ANGLE_USE_VULKAN_NULL_DISPLAY)
if (rx::IsVulkanNullDisplayAvailable())
{
impl = rx::CreateVulkanNullDisplay(state);
}
break;
# elif defined(ANGLE_PLATFORM_WINDOWS)
if (rx::IsVulkanWin32DisplayAvailable())
{
impl = rx::CreateVulkanWin32Display(state);
......
......@@ -127,6 +127,15 @@ if (angle_enable_cl) {
]
}
if (angle_use_vulkan_null_display) {
_vulkan_backend_sources += [
"null/DisplayVkNull.cpp",
"null/DisplayVkNull.h",
"null/WindowSurfaceVkNull.cpp",
"null/WindowSurfaceVkNull.h",
]
}
if (is_linux) {
_vulkan_backend_sources += [
"display/DisplayVkSimple.cpp",
......
......@@ -258,6 +258,11 @@ const char *DisplayVk::getWSILayer() const
return nullptr;
}
bool DisplayVk::isUsingSwapchain() const
{
return true;
}
bool DisplayVk::getScratchBuffer(size_t requstedSizeBytes,
angle::MemoryBuffer **scratchBufferOut) const
{
......
......@@ -123,6 +123,7 @@ class DisplayVk : public DisplayImpl, public vk::Context
virtual const char *getWSIExtension() const = 0;
virtual const char *getWSILayer() const;
virtual bool isUsingSwapchain() const;
// Determine if a config with given formats and sample counts is supported. This callback may
// modify the config to add or remove platform specific attributes such as nativeVisualID. If
......
......@@ -14,6 +14,10 @@
namespace rx
{
bool IsVulkanNullDisplayAvailable();
DisplayImpl *CreateVulkanNullDisplay(const egl::DisplayState &state);
#if defined(ANGLE_PLATFORM_WINDOWS)
bool IsVulkanWin32DisplayAvailable();
DisplayImpl *CreateVulkanWin32Display(const egl::DisplayState &state);
......
......@@ -937,8 +937,15 @@ angle::Result RendererVk::initialize(DisplayVk *displayVk,
}
vk::ExtensionNameList enabledInstanceExtensions;
enabledInstanceExtensions.push_back(VK_KHR_SURFACE_EXTENSION_NAME);
enabledInstanceExtensions.push_back(wsiExtension);
if (displayVk->isUsingSwapchain())
{
enabledInstanceExtensions.push_back(VK_KHR_SURFACE_EXTENSION_NAME);
}
if (wsiExtension)
{
enabledInstanceExtensions.push_back(wsiExtension);
}
mEnableDebugUtils = canLoadDebugUtils && mEnableValidationLayers &&
ExtensionFound(VK_EXT_DEBUG_UTILS_EXTENSION_NAME, instanceExtensionNames);
......@@ -1462,7 +1469,10 @@ angle::Result RendererVk::initializeDevice(DisplayVk *displayVk, uint32_t queueF
}
vk::ExtensionNameList enabledDeviceExtensions;
enabledDeviceExtensions.push_back(VK_KHR_SWAPCHAIN_EXTENSION_NAME);
if (displayVk->isUsingSwapchain())
{
enabledDeviceExtensions.push_back(VK_KHR_SWAPCHAIN_EXTENSION_NAME);
}
// Queues: map low, med, high priority to whatever is supported up to 3 queues
uint32_t queueCount = std::min(mQueueFamilyProperties[queueFamilyIndex].queueCount,
......
//
// Copyright 2021 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.
//
// DisplayVkNull.cpp:
// Implements the class methods for DisplayVkNull.
//
#include "DisplayVkNull.h"
#include "WindowSurfaceVkNull.h"
#include "libANGLE/Display.h"
#include "libANGLE/renderer/vulkan/RendererVk.h"
#include "libANGLE/renderer/vulkan/vk_caps_utils.h"
namespace rx
{
DisplayVkNull::DisplayVkNull(const egl::DisplayState &state) : DisplayVk(state) {}
bool DisplayVkNull::isValidNativeWindow(EGLNativeWindowType window) const
{
return false;
}
SurfaceImpl *DisplayVkNull::createWindowSurfaceVk(const egl::SurfaceState &state,
EGLNativeWindowType window)
{
return new WindowSurfaceVkNull(state, window);
}
const char *DisplayVkNull::getWSIExtension() const
{
return nullptr;
}
bool DisplayVkNull::isUsingSwapchain() const
{
return false;
}
egl::ConfigSet DisplayVkNull::generateConfigs()
{
constexpr GLenum kColorFormats[] = {GL_RGBA8, GL_BGRA8_EXT, GL_RGB565, GL_RGB8};
return egl_vk::GenerateConfigs(kColorFormats, egl_vk::kConfigDepthStencilFormats, this);
}
void DisplayVkNull::checkConfigSupport(egl::Config *config)
{
config->surfaceType &= ~EGL_WINDOW_BIT;
}
bool IsVulkanNullDisplayAvailable()
{
return true;
}
DisplayImpl *CreateVulkanNullDisplay(const egl::DisplayState &state)
{
return new DisplayVkNull(state);
}
} // namespace rx
//
// Copyright 2021 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.
//
// DisplayVkNull.h:
// Defines the class interface for DisplayVkNull, implementing
// DisplayVk that doesn't depend on Vulkan extensions. It cannot be
// used to output any content to a surface.
//
#ifndef LIBANGLE_RENDERER_VULKAN_NULL_DISPLAYVKNULL_H_
#define LIBANGLE_RENDERER_VULKAN_NULL_DISPLAYVKNULL_H_
#include "libANGLE/renderer/vulkan/DisplayVk.h"
namespace rx
{
class DisplayVkNull : public DisplayVk
{
public:
DisplayVkNull(const egl::DisplayState &state);
bool isValidNativeWindow(EGLNativeWindowType window) const override;
SurfaceImpl *createWindowSurfaceVk(const egl::SurfaceState &state,
EGLNativeWindowType window) override;
virtual const char *getWSIExtension() const override;
bool isUsingSwapchain() const override;
egl::ConfigSet generateConfigs() override;
void checkConfigSupport(egl::Config *config) override;
private:
std::vector<VkSurfaceFormatKHR> mSurfaceFormats;
};
} // namespace rx
#endif // LIBANGLE_RENDERER_VULKAN_NULL_DISPLAYVKNULL_H_
//
// Copyright 2021 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.
//
// WindowSurfaceVkNull.cpp:
// Implements the class methods for WindowSurfaceVkNull.
//
#include "WindowSurfaceVkNull.h"
#include "libANGLE/renderer/vulkan/RendererVk.h"
namespace rx
{
WindowSurfaceVkNull::WindowSurfaceVkNull(const egl::SurfaceState &surfaceState,
EGLNativeWindowType window)
: WindowSurfaceVk(surfaceState, window)
{}
WindowSurfaceVkNull::~WindowSurfaceVkNull() {}
angle::Result WindowSurfaceVkNull::createSurfaceVk(vk::Context *context, gl::Extents *extentsOut)
{
return angle::Result::Stop;
}
angle::Result WindowSurfaceVkNull::getCurrentWindowSize(vk::Context *context,
gl::Extents *extentsOut)
{
return angle::Result::Stop;
}
} // namespace rx
//
// Copyright 2021 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.
//
// WindowSurfaceVkNull.h:
// Defines the class interface for WindowSurfaceVkNull, implementing WindowSurfaceVk.
//
#ifndef LIBANGLE_RENDERER_VULKAN_NULL_WINDOWSURFACEVKNULL_H_
#define LIBANGLE_RENDERER_VULKAN_NULL_WINDOWSURFACEVKNULL_H_
#include "libANGLE/renderer/vulkan/SurfaceVk.h"
namespace rx
{
class WindowSurfaceVkNull final : public WindowSurfaceVk
{
public:
WindowSurfaceVkNull(const egl::SurfaceState &surfaceState, EGLNativeWindowType window);
~WindowSurfaceVkNull() 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_NULL_WINDOWSURFACEVKNULL_H_
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment