Find a file
David Harvey-Macaulay 5b6fe3301f Apply workaround for Wayland set_queue race
Wayland objects receive events from the server into an event queue.
Unless specified otherwise, events from the server arrive to the event
queue belonging to the parent object. It is beneficial for us to
override this default queue assignment so that we receive only the
events we are interested in.

We currently override the default event queue assignment using
wl_proxy_set_queue after object construction:

struct wl_object *child_object = wl_create_object(parent_object);
wl_proxy_set_queue((struct wl_proxy *)child_object, queue);

There is a race condition here: events may be received into the parent's
queue before we have a chance to perform this override. This will lead
to hangs if we are expecting an event to arrive to our specific queue.
To workaround this issue, we can use a wrapper object to specify the
desired event queue at the time of object creation:

struct wl_object *parent_wrapper = wl_proxy_create_wrapper(parent_object);
wl_proxy_set_queue((struct wl_proxy *)parent_wrapper, queue);
struct wl_object *child_object = wl_create_object(parent_wrapper);
wl_proxy_wrapper_destroy(parent_wrapper);

This commit applies this workaround to all object allocations whose
intended event queues differ from the default assignment to avoid the
aforementioned race condition.

Change-Id: I3e6a7c679280f0d66b02ab7eab06a010e9e24b36
Signed-off-by: David Harvey-Macaulay <david.harvey-macaulay@arm.com>
2021-04-08 13:08:56 +01:00
layer Adds initial support for VK_KHR_wayland_surface. 2021-02-09 18:22:09 +00:00
util Adds initial support for VK_KHR_wayland_surface. 2021-02-09 18:22:09 +00:00
wsi Apply workaround for Wayland set_queue race 2021-04-08 13:08:56 +01:00
.clang-format Initial sources for the vulkan-wsi-layer project 2019-05-31 15:48:05 +01:00
.gitlab-ci.yml Add a simple build test to the Vulkan WSI Layer's CI 2019-09-30 16:06:46 +01:00
CMakeLists.txt Use zwp_linux_dmabuf_v1 interface to query supported formats 2021-03-30 16:54:21 +01:00
DCO.txt Initial sources for the vulkan-wsi-layer project 2019-05-31 15:48:05 +01:00
LICENSE Initial sources for the vulkan-wsi-layer project 2019-05-31 15:48:05 +01:00
README.md Adds initial support for VK_KHR_wayland_surface. 2021-02-09 18:22:09 +00:00

Vulkan® Window System Integration Layer

Introduction

This project is a Vulkan® layer which implements some of the Vulkan® window system integration extensions such as VK_KHR_swapchain. The layer is designed to be GPU vendor agnostic when used as part of the Vulkan® ICD/loader architecture.

Our vision for the project is to become the de facto implementation for Vulkan® window system integration extensions so that they need not be implemented in the ICD; instead, the implementation of these extensions are shared across vendors for mutual benefit.

The project currently implements support for VK_EXT_headless_surface and its dependencies. Experimental support for VK_KHR_wayland_surface can be enabled via a build option as explained below.

Building

Dependencies

  • CMake version 3.4.3 or above.
  • C++11 compiler.
  • Vulkan® loader and associated headers with support for the VK_EXT_headless_surface extension.

Building the Vulkan® loader

This step is not necessary if your system already has a loader and associated headers with support for the VK_EXT_headless_surface extension. We include these instructions for completeness.

git clone https://github.com/KhronosGroup/Vulkan-Loader.git
mkdir Vulkan-Loader/build
cd Vulkan-Loader/build
../scripts/update_deps.py
cmake -C helper.cmake ..
make
make install

Building the layer

The layer requires a version of the loader and headers that includes support for the VK_EXT_headless_surface extension. By default, the build system will use the system Vulkan® headers as reported by pkg-config. This may be overriden by specifying VULKAN_CXX_INCLUDE in the CMake configuration, for example:

cmake . -DVULKAN_CXX_INCLUDE="path/to/vulkan-headers"

If the loader and associated headers already meet the requirements of the layer then the build steps are straightforward:

cmake . -Bbuild
make -C build

Building with Wayland support

In order to build with Wayland support the BUILD_WSI_WAYLAND build option must be used, the SELECT_EXTERNAL_ALLOCATOR option has to be set to an allocator (currently only ion is supported) and the KERNEL_DIR option must be defined as the root of the Linux kernel source.

cmake . -DVULKAN_CXX_INCLUDE="path/to/vulkan-header" \
        -DBUILD_WSI_WAYLAND=1 \
        -DSELECT_EXTERNAL_ALLOCATOR=ion \
        -DKERNEL_DIR="path/to/linux-kernel-source"

Wayland support is still EXPERIMENTAL. What this means in practice is that the support is incomplete and not ready for prime time.

Installation

Copy the shared library libVkLayer_window_system_integration.so and JSON configuration VkLayer_window_system_integration.json into a Vulkan® implicit layer directory.

Contributing

We are open for contributions.

  • The software is provided under the MIT license. Contributions to this project are accepted under the same license.
  • Please also ensure that each commit in the series has at least one Signed-off-by: line, using your real name and email address. The names in the Signed-off-by: and Author: lines must match. If anyone else contributes to the commit, they must also add their own Signed-off-by: line. By adding this line the contributor certifies the contribution is made under the terms of the Developer Certificate of Origin (DCO).
  • Questions, bug reports, et cetera are raised and discussed on the issues page.
  • Please make merge requests into the master branch.
  • Code should be formatted with clang-format using the project's .clang-format configuration.

Contributors are expected to abide by the freedesktop.org code of conduct.

Khronos® Conformance

This software is based on a published Khronos® Specification and is expected to pass the relevant parts of the Khronos® Conformance Testing Process when used as part of a conformant Vulkan® implementation.