From 0fa78aab193dc4089f2d9a6ecebb06e2684f840c Mon Sep 17 00:00:00 2001 From: Tom Hochstein Date: Fri, 15 Aug 2025 11:50:34 -0500 Subject: vulkan-wsi-layer: Initial version Signed-off-by: Tom Hochstein --- .../0001-MGS-6801-ccc-vkmark-on-wayland.patch | 30 +++ ...p-Add-support-of-VK_COMPOSITE_ALPHA_OPAQU.patch | 243 +++++++++++++++++++++ .../0003-Update-minimum-version-of-CMake.patch | 32 +++ recipes-graphics/vulkan/vulkan-wsi-layer_git.bb | 54 +++++ 4 files changed, 359 insertions(+) create mode 100644 recipes-graphics/vulkan/vulkan-wsi-layer/0001-MGS-6801-ccc-vkmark-on-wayland.patch create mode 100644 recipes-graphics/vulkan/vulkan-wsi-layer/0002-MGS-6823-nxp-Add-support-of-VK_COMPOSITE_ALPHA_OPAQU.patch create mode 100644 recipes-graphics/vulkan/vulkan-wsi-layer/0003-Update-minimum-version-of-CMake.patch create mode 100644 recipes-graphics/vulkan/vulkan-wsi-layer_git.bb (limited to 'recipes-graphics') diff --git a/recipes-graphics/vulkan/vulkan-wsi-layer/0001-MGS-6801-ccc-vkmark-on-wayland.patch b/recipes-graphics/vulkan/vulkan-wsi-layer/0001-MGS-6801-ccc-vkmark-on-wayland.patch new file mode 100644 index 000000000..48cfcd765 --- /dev/null +++ b/recipes-graphics/vulkan/vulkan-wsi-layer/0001-MGS-6801-ccc-vkmark-on-wayland.patch @@ -0,0 +1,30 @@ +From ada74fb0ca3099f33d173eb664bd7e42025a3277 Mon Sep 17 00:00:00 2001 +From: Prabhu Sundararaj +Date: Mon, 9 Dec 2024 09:15:11 +0800 +Subject: [PATCH 1/2] MGS-6801 [#ccc] vkmark on wayland + +Extend the wayland surface properties with VK_COMPOSITE_ALPHA_OPAQUE_BIT_KHR + +Upstream-Status: Inappropriate [i.MX-specific] +Signed-off-by: Prabhu Sundararaj +Signed-off-by: Jiyu Yang +--- + wsi/wayland/surface_properties.cpp | 2 +- + 1 file changed, 1 insertion(+), 1 deletion(-) + +diff --git a/wsi/wayland/surface_properties.cpp b/wsi/wayland/surface_properties.cpp +index e6435b9..bc1a737 100644 +--- a/wsi/wayland/surface_properties.cpp ++++ b/wsi/wayland/surface_properties.cpp +@@ -89,7 +89,7 @@ VkResult surface_properties::get_surface_capabilities(VkPhysicalDevice physical_ + + /* Composite alpha */ + pSurfaceCapabilities->supportedCompositeAlpha = static_cast( +- VK_COMPOSITE_ALPHA_PRE_MULTIPLIED_BIT_KHR | VK_COMPOSITE_ALPHA_INHERIT_BIT_KHR); ++ VK_COMPOSITE_ALPHA_PRE_MULTIPLIED_BIT_KHR | VK_COMPOSITE_ALPHA_OPAQUE_BIT_KHR); + return VK_SUCCESS; + } + +-- +2.37.1 + diff --git a/recipes-graphics/vulkan/vulkan-wsi-layer/0002-MGS-6823-nxp-Add-support-of-VK_COMPOSITE_ALPHA_OPAQU.patch b/recipes-graphics/vulkan/vulkan-wsi-layer/0002-MGS-6823-nxp-Add-support-of-VK_COMPOSITE_ALPHA_OPAQU.patch new file mode 100644 index 000000000..9955f415e --- /dev/null +++ b/recipes-graphics/vulkan/vulkan-wsi-layer/0002-MGS-6823-nxp-Add-support-of-VK_COMPOSITE_ALPHA_OPAQU.patch @@ -0,0 +1,243 @@ +From 4293d8835eaa45168c070793eefd8867c6ec7605 Mon Sep 17 00:00:00 2001 +From: Yuan Tian +Date: Thu, 27 Jul 2023 18:25:16 +0800 +Subject: [PATCH 2/2] MGS-6823 [#nxp] Add support of + VK_COMPOSITE_ALPHA_OPAQUE_BIT_KHR feature + +Mali vulkan driver doesn't support VK_COMPOSITE_ALPHA_OPAQUE_BIT_KHR. It caused unwanted blending effect in many vulkan cases. +Add support of this feature to solve the problem. + +Upstream-Status: Inappropriate [i.MX-specific] +Signed-off-by: Yuan Tian +Signed-off-by: Jiyu Yang +--- + wsi/wayland/swapchain.cpp | 161 ++++++++++++++++++++++++++++++++++++++ + wsi/wayland/swapchain.hpp | 9 +++ + 2 files changed, 170 insertions(+) + +Index: git/wsi/wayland/swapchain.cpp +=================================================================== +--- git.orig/wsi/wayland/swapchain.cpp ++++ git/wsi/wayland/swapchain.cpp +@@ -38,6 +38,7 @@ + #include + #include + #include ++#include + + #include "util/drm/drm_utils.hpp" + #include "util/log.hpp" +@@ -72,12 +73,152 @@ swapchain::~swapchain() + wsialloc_delete(m_wsi_allocator); + } + m_wsi_allocator = nullptr; ++ if (wlc.opaque_region) ++ { ++ wl_compositor_destroy(wlc.wl_compositor); ++ wl_registry_destroy(wlc.registry); ++ wl_region_destroy(wlc.opaque_region); ++ wlc = {0}; ++ } + if (m_buffer_queue != nullptr) + { + wl_event_queue_destroy(m_buffer_queue); + } + } + ++static inline int ++poll_event(struct wl_display *wl_dpy, short int events, int timeout) ++{ ++ int ret; ++ struct pollfd pfd[1]; ++ ++ pfd[0].fd = wl_display_get_fd(wl_dpy); ++ pfd[0].events = events; ++ ++ do ++ { ++ ret = poll(pfd, 1, timeout); ++ } ++ while (ret == -1 && errno == EINTR); ++ ++ return ret; ++} ++ ++static int ++dispatch_queue_op(struct wl_display *wl_dpy, ++ struct wl_event_queue *wl_queue, int timeout) ++{ ++ int ret; ++ ++ if (wl_display_prepare_read_queue(wl_dpy, wl_queue) == -1) ++ { ++ return wl_display_dispatch_queue_pending(wl_dpy, wl_queue); ++ } ++ ++ for (;;) ++ { ++ ret = wl_display_flush(wl_dpy); ++ ++ if (ret != -1 || errno != EAGAIN) ++ break; ++ ++ if (poll_event(wl_dpy, POLLOUT, -1) == -1) ++ { ++ wl_display_cancel_read(wl_dpy); ++ return -1; ++ } ++ } ++ ++ /* Don't stop if flushing hits an EPIPE; continue so we can read any ++ * protocol error that may have triggered it. */ ++ if (ret < 0 && errno != EPIPE) ++ { ++ wl_display_cancel_read(wl_dpy); ++ return -1; ++ } ++ ++ ret = poll_event(wl_dpy, POLLIN, timeout); ++ ++ /* cancel read when on error or timeout. */ ++ if (ret == -1 || ret == 0) ++ { ++ wl_display_cancel_read(wl_dpy); ++ return ret; ++ } ++ ++ if (wl_display_read_events(wl_dpy) == -1) ++ return -1; ++ ++ return wl_display_dispatch_queue_pending(wl_dpy, wl_queue); ++} ++ ++static void ++sync_callback(void *data, struct wl_callback *callback, uint32_t serial) ++{ ++ int *done = (int *)data; ++ ++ *done = 1; ++ wl_callback_destroy(callback); ++} ++ ++static const struct wl_callback_listener sync_listener = { ++ sync_callback ++}; ++ ++static int ++roundtrip_queue(struct wl_display *wl_dpy, struct wl_event_queue *wl_queue) ++{ ++ struct wl_callback *callback; ++ int done, ret = 0; ++ ++ done = 0; ++ ++ /* ++ * This is to block read & dispatch events in other threads, so that the ++ * callback is with correct queue and listener when 'done' event. ++ */ ++ while (wl_display_prepare_read_queue(wl_dpy, wl_queue) == -1) ++ wl_display_dispatch_queue_pending(wl_dpy, wl_queue); ++ ++ callback = wl_display_sync(wl_dpy); ++ ++ if (callback == NULL) ++ { ++ wl_display_cancel_read(wl_dpy); ++ return -1; ++ } ++ ++ wl_proxy_set_queue((struct wl_proxy *) callback, wl_queue); ++ wl_callback_add_listener(callback, &sync_listener, &done); ++ ++ wl_display_cancel_read(wl_dpy); ++ ++ while (!done && ret >= 0) ++ ret = dispatch_queue_op(wl_dpy, wl_queue, 5); ++ ++ if (ret == -1 && !done) ++ wl_callback_destroy(callback); ++ ++ return ret; ++} ++ ++static void ++registry_handle_global(void *data, struct wl_registry *registry, uint32_t name, ++ const char *interface, uint32_t version) ++{ ++ wl_context *pwlc = (wl_context *)data; ++ ++ if(!pwlc->wl_compositor) ++ { ++ pwlc->wl_compositor = (wl_compositor *)wl_registry_bind(registry, name, &wl_compositor_interface, 1); ++ wl_proxy_set_queue((struct wl_proxy *)pwlc->wl_compositor, pwlc->wl_queue); ++ } ++} ++ ++static const struct wl_registry_listener registry_listener = { ++ registry_handle_global ++}; ++ + VkResult swapchain::init_platform(VkDevice device, const VkSwapchainCreateInfoKHR *swapchain_create_info, + bool &use_presentation_thread) + { +@@ -124,6 +265,21 @@ VkResult swapchain::init_platform(VkDevi + use_presentation_thread = + WAYLAND_FIFO_PRESENTATION_THREAD_ENABLED && (m_present_mode != VK_PRESENT_MODE_MAILBOX_KHR); + ++ if (swapchain_create_info->compositeAlpha & VK_COMPOSITE_ALPHA_OPAQUE_BIT_KHR) ++ { ++ wlc.wl_queue = m_buffer_queue; ++ wlc.registry = wl_display_get_registry(m_display); ++ wl_proxy_set_queue((struct wl_proxy *)(wlc.registry), m_buffer_queue); ++ wl_registry_add_listener(wlc.registry, ®istry_listener, &wlc); ++ ++ roundtrip_queue(m_display, m_buffer_queue); ++ ++ wlc.opaque_region = wl_compositor_create_region(wlc.wl_compositor); ++ wl_proxy_set_queue((struct wl_proxy *)(wlc.opaque_region), m_buffer_queue); ++ ++ wl_region_add(wlc.opaque_region, 0, 0, swapchain_create_info->imageExtent.width, swapchain_create_info->imageExtent.height); ++ } ++ + return VK_SUCCESS; + } + +@@ -494,6 +650,11 @@ void swapchain::present_image(const pend + set_error_state(VK_ERROR_SURFACE_LOST_KHR); + } + ++ if (wlc.opaque_region) ++ { ++ wl_surface_set_opaque_region(m_surface, wlc.opaque_region); ++ } ++ + wl_surface_attach(m_surface, image_data->buffer, 0, 0); + + auto present_sync_fd = image_data->present_fence.export_sync_fd(); +Index: git/wsi/wayland/swapchain.hpp +=================================================================== +--- git.orig/wsi/wayland/swapchain.hpp ++++ git/wsi/wayland/swapchain.hpp +@@ -78,6 +78,14 @@ struct image_creation_parameters + } + }; + ++struct wl_context ++{ ++ struct wl_event_queue *wl_queue; ++ struct wl_compositor *wl_compositor; ++ struct wl_registry *registry; ++ struct wl_region *opaque_region; ++}; ++ + class swapchain : public wsi::swapchain_base + { + public: +@@ -190,6 +198,7 @@ private: + + struct wl_display *m_display; + struct wl_surface *m_surface; ++ struct wl_context wlc = {0}; + /** Raw pointer to the WSI Surface that this swapchain was created from. The Vulkan specification ensures that the + * surface is valid until swapchain is destroyed. */ + surface *m_wsi_surface; diff --git a/recipes-graphics/vulkan/vulkan-wsi-layer/0003-Update-minimum-version-of-CMake.patch b/recipes-graphics/vulkan/vulkan-wsi-layer/0003-Update-minimum-version-of-CMake.patch new file mode 100644 index 000000000..0bc00de02 --- /dev/null +++ b/recipes-graphics/vulkan/vulkan-wsi-layer/0003-Update-minimum-version-of-CMake.patch @@ -0,0 +1,32 @@ +From 0c4ed8178a25135ced9df8c8a8909e2882bfe869 Mon Sep 17 00:00:00 2001 +From: Maged Elnaggar +Date: Tue, 17 Jun 2025 10:33:44 +0000 +Subject: [PATCH] Update minimum version of CMake + +Set CMake minimum required version range to 3.4.3...4.0 +to silence compatibility errors in CMake 4.0 +by explicitly opting into all policies up to 4.0 + +Upstream-Status: Backport [https://gitlab.freedesktop.org/mesa/vulkan-wsi-layer/-/commit/1eafebc56a7f735cd4e8298956d596c64ac9f681] +Signed-off-by: Maged Elnaggar +Change-Id: I2e0527dde4e764e9c17f519fc0ddd3c0e382fa31 +--- + CMakeLists.txt | 2 +- + 1 file changed, 1 insertion(+), 1 deletion(-) + +diff --git a/CMakeLists.txt b/CMakeLists.txt +index 4dc800c..b91cd54 100644 +--- a/CMakeLists.txt ++++ b/CMakeLists.txt +@@ -20,7 +20,7 @@ + # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + # SOFTWARE. + +-cmake_minimum_required(VERSION 3.4.3) ++cmake_minimum_required(VERSION 3.4.3...4.0) + project(VkLayer_window_system_integration) + + find_package(PkgConfig REQUIRED) +-- +2.34.1 + diff --git a/recipes-graphics/vulkan/vulkan-wsi-layer_git.bb b/recipes-graphics/vulkan/vulkan-wsi-layer_git.bb new file mode 100644 index 000000000..efa6accb3 --- /dev/null +++ b/recipes-graphics/vulkan/vulkan-wsi-layer_git.bb @@ -0,0 +1,54 @@ +DESCRIPTION = "Vulkan Window System Integration Layer" +LICENSE = "MIT" +LIC_FILES_CHKSUM = "file://LICENSE;md5=c2e771b72d60a13d2de384cb49055d00" +DEPENDS = "libdrm vulkan-loader" + +PV = "0.0+git${SRCPV}" + +SRC_URI = "git://gitlab.freedesktop.org/mesa/vulkan-wsi-layer.git;protocol=https;branch=main \ + file://0001-MGS-6801-ccc-vkmark-on-wayland.patch \ + file://0002-MGS-6823-nxp-Add-support-of-VK_COMPOSITE_ALPHA_OPAQU.patch \ + file://0003-Update-minimum-version-of-CMake.patch" +SRCREV = "cb1a50cf7e640ad7306e673131ded98c0f133628" + +inherit cmake pkgconfig + +PACKAGECONFIG ??= "${@bb.utils.contains('DISTRO_FEATURES', 'wayland', 'wayland', 'headless', d)}" + +PACKAGECONFIG[headless] = " \ + -DBUILD_WSI_HEADLESS=1, \ + -DBUILD_WSI_HEADLESS=0, \ + ,,, \ + wayland" +PACKAGECONFIG[wayland] = " \ + -DBUILD_WSI_WAYLAND=1 -DENABLE_WAYLAND_FIFO_PRESENTATION_THREAD=1 -DSELECT_EXTERNAL_ALLOCATOR=dma_buf_heaps, \ + -DBUILD_WSI_WAYLAND=0, \ + wayland wayland-native wayland-protocols,,, \ + headless" + +EXTRA_OECMAKE = " \ + -DBUILD_WSI_DISPLAY=0 \ + -DBUILD_WSI_IMAGE_COMPRESSION_CONTROL_SWAPCHAIN=1 \ + -DCMAKE_BUILD_TYPE=Release \ + -DCMAKE_EXPORT_COMPILE_COMMANDS=1 \ + -DENABLE_INSTRUMENTATION=1 \ + -DKERNEL_HEADER_DIR=${KERNEL_HEADER_DIR} \ + -DVULKAN_WSI_LAYER_EXPERIMENTAL=0 " + +# The KERNEL_HEADER_DIR setting is required by the CMake apparently +# in order to find the DRM headers. However, the Yocto build provides +# the DRM headers via a separate recipe libdrm in order to avoid the +# kernel dependency. The CMake fails if the variable is not defined, +# so set it to an invalid value in case the build ever actually needs +# the kernel headers for something else. +KERNEL_HEADER_DIR = "KERNEL_HEADER_DIR_NOT_PROVIDED_BY_YOCTO" + +do_install() { + install -d ${D}${sysconfdir}/vulkan/implicit_layer.d + install -m 0755 ${B}/libVkLayer_window_system_integration.so ${D}${sysconfdir}/vulkan/implicit_layer.d/ + install -m 0644 ${B}/VkLayer_window_system_integration.json ${D}${sysconfdir}/vulkan/implicit_layer.d +} + +# Adjust packaging variables for unversioned library +SOLIBS = ".so" +FILES_SOLIBSDEV = "" -- cgit v1.2.3-54-g00ecf