Skip to content

Commit 4774ee2

Browse files
committed
Wayland support (vk only)
1 parent 3474816 commit 4774ee2

File tree

2 files changed

+17
-16
lines changed

2 files changed

+17
-16
lines changed

Graphics/GraphicsEngineVulkan/src/SwapChainVkImpl.cpp

Lines changed: 16 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -102,42 +102,42 @@ void SwapChainVkImpl::CreateSurface()
102102

103103
err = vkCreateMetalSurfaceEXT(m_Instance->GetVkInstance(), &surfaceCreateInfo, NULL, &m_VkSurface);
104104
}
105-
#elif defined(VK_USE_PLATFORM_WAYLAND_KHR)
106-
if (m_Window.pDisplay != nullptr)
105+
#elif defined(VK_USE_PLATFORM_WAYLAND_KHR) || defined(VK_USE_PLATFORM_XCB_KHR) || defined(VK_USE_PLATFORM_XLIB_KHR)
106+
bool foundPlatform = false;
107+
#if defined(VK_USE_PLATFORM_WAYLAND_KHR)
108+
if (m_Window.pDisplay != nullptr && m_Window.pWaylandSurface != nullptr)
107109
{
108110
VkWaylandSurfaceCreateInfoKHR surfaceCreateInfo{};
109111
surfaceCreateInfo.sType = VK_STRUCTURE_TYPE_WAYLAND_SURFACE_CREATE_INFO_KHR;
110-
surfaceCreateInfo.display = reinterpret_cast<struct wl_display*>(m_Window.pDisplay);
111-
surfaceCreateInfo.Surface = reinterpret_cast<struct wl_surface*>(nullptr);
112-
112+
surfaceCreateInfo.display = static_cast<wl_display*>(m_Window.pDisplay);
113+
surfaceCreateInfo.surface = static_cast<wl_surface*>(m_Window.pWaylandSurface);
113114
err = vkCreateWaylandSurfaceKHR(m_Instance->GetVkInstance(), &surfaceCreateInfo, nullptr, &m_VkSurface);
115+
foundPlatform = true;
114116
}
115-
#elif defined(VK_USE_PLATFORM_XCB_KHR) || defined(VK_USE_PLATFORM_XLIB_KHR)
116-
117-
# if defined(VK_USE_PLATFORM_XCB_KHR)
118-
if (m_Window.pXCBConnection != nullptr && m_Window.WindowId != 0)
117+
#endif
118+
#if defined(VK_USE_PLATFORM_XCB_KHR)
119+
if (!foundPlatform && m_Window.pXCBConnection != nullptr && m_Window.WindowId != 0)
119120
{
120121
VkXcbSurfaceCreateInfoKHR surfaceCreateInfo{};
121122
surfaceCreateInfo.sType = VK_STRUCTURE_TYPE_XCB_SURFACE_CREATE_INFO_KHR;
122123
surfaceCreateInfo.connection = reinterpret_cast<xcb_connection_t*>(m_Window.pXCBConnection);
123124
surfaceCreateInfo.window = m_Window.WindowId;
124-
125125
err = vkCreateXcbSurfaceKHR(m_Instance->GetVkInstance(), &surfaceCreateInfo, nullptr, &m_VkSurface);
126+
foundPlatform = true;
126127
}
127-
# endif
128-
129-
# if defined(VK_USE_PLATFORM_XLIB_KHR)
130-
if ((m_Window.pDisplay != nullptr && m_Window.WindowId != 0) && m_VkSurface == VK_NULL_HANDLE)
128+
#endif
129+
#if defined(VK_USE_PLATFORM_XLIB_KHR)
130+
if (!foundPlatform && (m_Window.pDisplay != nullptr && m_Window.WindowId != 0) && m_VkSurface == VK_NULL_HANDLE)
131131
{
132132
VkXlibSurfaceCreateInfoKHR surfaceCreateInfo{};
133133
surfaceCreateInfo.sType = VK_STRUCTURE_TYPE_XLIB_SURFACE_CREATE_INFO_KHR;
134134
surfaceCreateInfo.dpy = reinterpret_cast<Display*>(m_Window.pDisplay);
135135
surfaceCreateInfo.window = m_Window.WindowId;
136136

137137
err = vkCreateXlibSurfaceKHR(m_Instance->GetVkInstance(), &surfaceCreateInfo, nullptr, &m_VkSurface);
138+
foundPlatform = true;
138139
}
139-
# endif
140-
140+
#endif
141141
#endif
142142

143143
CHECK_VK_ERROR_AND_THROW(err, "Failed to create OS-specific surface");

Platforms/Linux/interface/LinuxNativeWindow.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,7 @@ struct LinuxNativeWindow
3737
Uint32 WindowId DEFAULT_INITIALIZER(0);
3838
void* pDisplay DEFAULT_INITIALIZER(nullptr);
3939
void* pXCBConnection DEFAULT_INITIALIZER(nullptr);
40+
void* pWaylandSurface DEFAULT_INITIALIZER(nullptr);
4041
};
4142

4243
DILIGENT_END_NAMESPACE // namespace Diligent

0 commit comments

Comments
 (0)