Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix Vulkan renderer on wayland #3143

Merged
merged 2 commits into from
Aug 2, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 19 additions & 0 deletions src/renderer_vk.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,10 @@
# import <Metal/Metal.h>
#endif // BX_PLATFORM_OSX

#if WL_EGL_PLATFORM
# include <wayland-egl-backend.h>
#endif

namespace bgfx { namespace vk
{
static char s_viewName[BGFX_CONFIG_MAX_VIEWS][BGFX_CONFIG_MAX_VIEW_NAME];
Expand Down Expand Up @@ -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)
{
Expand Down Expand Up @@ -6806,6 +6824,7 @@ VK_DESTROY
}
}
}
#endif // WL_EGL_PLATFORM
#elif BX_PLATFORM_OSX
{
if (NULL != vkCreateMacOSSurfaceMVK)
Expand Down
18 changes: 14 additions & 4 deletions src/renderer_vk.h
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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); \
Expand All @@ -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 */ \
Expand Down