@@ -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" );
0 commit comments