Hash :
1f344d60
Author :
Date :
2020-11-05T16:33:42
Vulkan: Add support for headless surface How to enable: add below args config to args.gn in linux build ``` use_x11=false use_ozone=false angle_vulkan_display_mode="headless" ``` Bug: angleproject:5260 Change-Id: Iec931e74c061b56376ef028814859aa58af07f2f Reviewed-on: https://chromium-review.googlesource.com/c/angle/angle/+/2536518 Commit-Queue: Shahbaz Youssefi <syoussefi@chromium.org> Reviewed-by: Jamie Madill <jmadill@chromium.org> Reviewed-by: Shahbaz Youssefi <syoussefi@chromium.org>
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63
//
// 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.
//
// WindowSurfaceVkHeadless.cpp:
// Implements the class methods for WindowSurfaceVkHeadless.
//
#include "WindowSurfaceVkHeadless.h"
#include "libANGLE/renderer/vulkan/RendererVk.h"
namespace rx
{
WindowSurfaceVkHeadless::WindowSurfaceVkHeadless(const egl::SurfaceState &surfaceState,
EGLNativeWindowType window)
: WindowSurfaceVk(surfaceState, window)
{}
WindowSurfaceVkHeadless::~WindowSurfaceVkHeadless() {}
angle::Result WindowSurfaceVkHeadless::createSurfaceVk(vk::Context *context,
gl::Extents *extentsOut)
{
RendererVk *renderer = context->getRenderer();
ASSERT(renderer != nullptr);
VkInstance instance = renderer->getInstance();
VkHeadlessSurfaceCreateInfoEXT createInfo = {};
createInfo.sType = VK_STRUCTURE_TYPE_HEADLESS_SURFACE_CREATE_INFO_EXT;
ANGLE_VK_TRY(context, vkCreateHeadlessSurfaceEXT(instance, &createInfo, nullptr, &mSurface));
return getCurrentWindowSize(context, extentsOut);
}
angle::Result WindowSurfaceVkHeadless::getCurrentWindowSize(vk::Context *context,
gl::Extents *extentsOut)
{
const VkPhysicalDevice &physicalDevice = context->getRenderer()->getPhysicalDevice();
ANGLE_VK_TRY(context, vkGetPhysicalDeviceSurfaceCapabilitiesKHR(physicalDevice, mSurface,
&mSurfaceCaps));
// Spec: "For headless surfaces, currentExtent is the reserved value (0xFFFFFFFF, 0xFFFFFFFF).
// Whatever the application sets a swapchain's imageExtent to will be the size of the surface,
// after the first image is presented."
// For ANGLE, in headless mode, we share the same 'SimpleDisplayWindow' structure with front
// EGL window info to define the vulkan backend surface/image extents.
angle::vk::SimpleDisplayWindow *simpleWindow =
reinterpret_cast<angle::vk::SimpleDisplayWindow *>(mNativeWindowType);
// Update surface extent before output the new extent.
mSurfaceCaps.currentExtent.width = simpleWindow->width;
mSurfaceCaps.currentExtent.height = simpleWindow->height;
*extentsOut =
gl::Extents(mSurfaceCaps.currentExtent.width, mSurfaceCaps.currentExtent.height, 1);
return angle::Result::Continue;
}
} // namespace rx