diff --git a/src/renderer_vk.cpp b/src/renderer_vk.cpp index b406b3f33b..435d332fd2 100644 --- a/src/renderer_vk.cpp +++ b/src/renderer_vk.cpp @@ -17,6 +17,10 @@ # import #endif // BX_PLATFORM_OSX +#if WL_EGL_PLATFORM +# include +#endif + namespace bgfx { namespace vk { static char s_viewName[BGFX_CONFIG_MAX_VIEWS][BGFX_CONFIG_MAX_VIEW_NAME]; @@ -6770,6 +6774,20 @@ VK_DESTROY } } #elif BX_PLATFORM_LINUX +#if WL_EGL_PLATFORM + { + if (NULL != vkCreateWaylandSurfaceKHR) + { + VkWaylandSurfaceCreateInfoKHR sci; + sci.sType = VK_STRUCTURE_TYPE_WAYLAND_SURFACE_CREATE_INFO_KHR; + sci.pNext = NULL; + sci.flags = 0; + sci.display = (wl_display*)g_platformData.ndt; + sci.surface = (wl_surface*)((wl_egl_window*)g_platformData.nwh)->surface; + result = vkCreateWaylandSurfaceKHR(instance, &sci, allocatorCb, &m_surface); + } + } +#else { if (NULL != vkCreateXlibSurfaceKHR) { @@ -6806,6 +6824,7 @@ VK_DESTROY } } } +#endif // WL_EGL_PLATFORM #elif BX_PLATFORM_OSX { if (NULL != vkCreateMacOSSurfaceMVK) diff --git a/src/renderer_vk.h b/src/renderer_vk.h index 8014e26e06..9d07d8e4d3 100644 --- a/src/renderer_vk.h +++ b/src/renderer_vk.h @@ -11,10 +11,14 @@ # define KHR_SURFACE_EXTENSION_NAME VK_KHR_ANDROID_SURFACE_EXTENSION_NAME # define VK_IMPORT_INSTANCE_PLATFORM VK_IMPORT_INSTANCE_ANDROID #elif BX_PLATFORM_LINUX +#if WL_EGL_PLATFORM +# define VK_USE_PLATFORM_WAYLAND_KHR +# define KHR_SURFACE_EXTENSION_NAME VK_KHR_WAYLAND_SURFACE_EXTENSION_NAME +#else # define VK_USE_PLATFORM_XLIB_KHR # define VK_USE_PLATFORM_XCB_KHR -//# define VK_USE_PLATFORM_WAYLAND_KHR # define KHR_SURFACE_EXTENSION_NAME VK_KHR_XCB_SURFACE_EXTENSION_NAME +#endif // WL_EGL_PLATFORM # define VK_IMPORT_INSTANCE_PLATFORM VK_IMPORT_INSTANCE_LINUX #elif BX_PLATFORM_WINDOWS # define VK_USE_PLATFORM_WIN32_KHR @@ -62,6 +66,14 @@ /* VK_KHR_android_surface */ \ VK_IMPORT_INSTANCE_FUNC(true, vkCreateAndroidSurfaceKHR); \ +#if WL_EGL_PLATFORM +#define VK_IMPORT_INSTANCE_LINUX \ + /* VK_KHR_wayland_surface */ \ + VK_IMPORT_INSTANCE_FUNC(true, vkCreateWaylandSurfaceKHR); \ + VK_IMPORT_INSTANCE_FUNC(true, vkGetPhysicalDeviceWaylandPresentationSupportKHR); \ + + +#else #define VK_IMPORT_INSTANCE_LINUX \ /* VK_KHR_xlib_surface */ \ VK_IMPORT_INSTANCE_FUNC(true, vkCreateXlibSurfaceKHR); \ @@ -70,9 +82,7 @@ VK_IMPORT_INSTANCE_FUNC(true, vkCreateXcbSurfaceKHR); \ VK_IMPORT_INSTANCE_FUNC(true, vkGetPhysicalDeviceXcbPresentationSupportKHR); \ -// /* VK_KHR_wayland_surface */ -// VK_IMPORT_INSTANCE_FUNC(true, vkCreateWaylandSurfaceKHR); -// VK_IMPORT_INSTANCE_FUNC(true, vkGetPhysicalDeviceWaylandPresentationSupportKHR); +#endif // WL_EGL_PLATFORM #define VK_IMPORT_INSTANCE_WINDOWS \ /* VK_KHR_win32_surface */ \