| 1983 | } |
| 1984 | |
| 1985 | void Demo::create_surface() { |
| 1986 | // Create a WSI surface for the window: |
| 1987 | #if defined(VK_USE_PLATFORM_WIN32_KHR) |
| 1988 | if (wsi_platform == WsiPlatform::win32) { |
| 1989 | auto const createInfo = vk::Win32SurfaceCreateInfoKHR().setHinstance(connection).setHwnd(window); |
| 1990 | |
| 1991 | auto result = inst.createWin32SurfaceKHR(&createInfo, nullptr, &surface); |
| 1992 | VERIFY(result == vk::Result::eSuccess); |
| 1993 | } |
| 1994 | #endif |
| 1995 | #if defined(VK_USE_PLATFORM_WAYLAND_KHR) |
| 1996 | |
| 1997 | if (wsi_platform == WsiPlatform::wayland) { |
| 1998 | auto const createInfo = vk::WaylandSurfaceCreateInfoKHR().setDisplay(wayland_display).setSurface(wayland_window); |
| 1999 | |
| 2000 | auto result = inst.createWaylandSurfaceKHR(&createInfo, nullptr, &surface); |
| 2001 | VERIFY(result == vk::Result::eSuccess); |
| 2002 | return; |
| 2003 | } |
| 2004 | #endif |
| 2005 | #if defined(VK_USE_PLATFORM_XLIB_KHR) |
| 2006 | if (wsi_platform == WsiPlatform::xlib) { |
| 2007 | auto const createInfo = vk::XlibSurfaceCreateInfoKHR().setDpy(xlib_display).setWindow(xlib_window); |
| 2008 | |
| 2009 | auto result = inst.createXlibSurfaceKHR(&createInfo, nullptr, &surface); |
| 2010 | VERIFY(result == vk::Result::eSuccess); |
| 2011 | } |
| 2012 | #endif |
| 2013 | #if defined(VK_USE_PLATFORM_XCB_KHR) |
| 2014 | if (wsi_platform == WsiPlatform::xcb) { |
| 2015 | auto const createInfo = vk::XcbSurfaceCreateInfoKHR().setConnection(connection).setWindow(xcb_window); |
| 2016 | |
| 2017 | auto result = inst.createXcbSurfaceKHR(&createInfo, nullptr, &surface); |
| 2018 | VERIFY(result == vk::Result::eSuccess); |
| 2019 | } |
| 2020 | #endif |
| 2021 | #if defined(VK_USE_PLATFORM_DIRECTFB_EXT) |
| 2022 | if (wsi_platform == WsiPlatform::directfb) { |
| 2023 | auto const createInfo = vk::DirectFBSurfaceCreateInfoEXT().setDfb(dfb).setSurface(directfb_window); |
| 2024 | |
| 2025 | auto result = inst.createDirectFBSurfaceEXT(&createInfo, nullptr, &surface); |
| 2026 | VERIFY(result == vk::Result::eSuccess); |
| 2027 | } |
| 2028 | #endif |
| 2029 | #if defined(VK_USE_PLATFORM_METAL_EXT) |
| 2030 | { |
| 2031 | auto const createInfo = vk::MetalSurfaceCreateInfoEXT().setPLayer(static_cast<CAMetalLayer *>(caMetalLayer)); |
| 2032 | |
| 2033 | auto result = inst.createMetalSurfaceEXT(&createInfo, nullptr, &surface); |
| 2034 | VERIFY(result == vk::Result::eSuccess); |
| 2035 | } |
| 2036 | #endif |
| 2037 | #if defined(VK_USE_PLATFORM_DISPLAY_KHR) |
| 2038 | if (wsi_platform == WsiPlatform::display) { |
| 2039 | auto result = create_display_surface(); |
| 2040 | VERIFY(result == vk::Result::eSuccess); |
| 2041 | } |
| 2042 | #endif |