From d4e5449f46d3379560efcb4890d9d9ea97531b8a Mon Sep 17 00:00:00 2001 From: Lokomojo <2168418+Lokomojo@users.noreply.github.com> Date: Thu, 27 Nov 2025 06:51:19 +0000 Subject: [PATCH] Wayland support (vk only) --- .../GraphicsEngineVulkan/src/SwapChainVkImpl.cpp | 12 ++++++------ Platforms/Linux/interface/LinuxNativeWindow.h | 7 ++++--- 2 files changed, 10 insertions(+), 9 deletions(-) diff --git a/Graphics/GraphicsEngineVulkan/src/SwapChainVkImpl.cpp b/Graphics/GraphicsEngineVulkan/src/SwapChainVkImpl.cpp index 993eb703b..8a069c45a 100644 --- a/Graphics/GraphicsEngineVulkan/src/SwapChainVkImpl.cpp +++ b/Graphics/GraphicsEngineVulkan/src/SwapChainVkImpl.cpp @@ -102,17 +102,17 @@ void SwapChainVkImpl::CreateSurface() err = vkCreateMetalSurfaceEXT(m_Instance->GetVkInstance(), &surfaceCreateInfo, NULL, &m_VkSurface); } -#elif defined(VK_USE_PLATFORM_WAYLAND_KHR) - if (m_Window.pDisplay != nullptr) +#elif defined(VK_USE_PLATFORM_WAYLAND_KHR) || defined(VK_USE_PLATFORM_XCB_KHR) || defined(VK_USE_PLATFORM_XLIB_KHR) +# if defined(VK_USE_PLATFORM_WAYLAND_KHR) + if (m_Window.pDisplay != nullptr && m_Window.pWaylandSurface != nullptr) { VkWaylandSurfaceCreateInfoKHR surfaceCreateInfo{}; surfaceCreateInfo.sType = VK_STRUCTURE_TYPE_WAYLAND_SURFACE_CREATE_INFO_KHR; - surfaceCreateInfo.display = reinterpret_cast(m_Window.pDisplay); - surfaceCreateInfo.Surface = reinterpret_cast(nullptr); - + surfaceCreateInfo.display = static_cast(m_Window.pDisplay); + surfaceCreateInfo.surface = static_cast(m_Window.pWaylandSurface); err = vkCreateWaylandSurfaceKHR(m_Instance->GetVkInstance(), &surfaceCreateInfo, nullptr, &m_VkSurface); } -#elif defined(VK_USE_PLATFORM_XCB_KHR) || defined(VK_USE_PLATFORM_XLIB_KHR) +# endif # if defined(VK_USE_PLATFORM_XCB_KHR) if (m_Window.pXCBConnection != nullptr && m_Window.WindowId != 0) diff --git a/Platforms/Linux/interface/LinuxNativeWindow.h b/Platforms/Linux/interface/LinuxNativeWindow.h index 81a62953e..376f74816 100644 --- a/Platforms/Linux/interface/LinuxNativeWindow.h +++ b/Platforms/Linux/interface/LinuxNativeWindow.h @@ -34,9 +34,10 @@ DILIGENT_BEGIN_NAMESPACE(Diligent) struct LinuxNativeWindow { - Uint32 WindowId DEFAULT_INITIALIZER(0); - void* pDisplay DEFAULT_INITIALIZER(nullptr); - void* pXCBConnection DEFAULT_INITIALIZER(nullptr); + Uint32 WindowId DEFAULT_INITIALIZER(0); + void* pDisplay DEFAULT_INITIALIZER(nullptr); + void* pXCBConnection DEFAULT_INITIALIZER(nullptr); + void* pWaylandSurface DEFAULT_INITIALIZER(nullptr); }; DILIGENT_END_NAMESPACE // namespace Diligent