Red screen on Linux

Oddly no validation error
This commit is contained in:
2025-10-03 20:42:04 +01:00
parent 655964852c
commit 9f2ef576b9
4 changed files with 100 additions and 0 deletions

View File

@@ -68,6 +68,8 @@
#if OS_WINDOWS
#define WIN32_LEAN_AND_MEAN 1
#include <windows.h>
#elif OS_LINUX
#include <dlfcn.h>
#endif
#endif // LD_CORE_PLATFORM_H_

View File

@@ -23,6 +23,46 @@ static void Vk_CreateSurface(SDL_Window *window) {
vk.err = vk.CreateWin32SurfaceKHR(vk.instance, &create_info, 0, &vk.surface);
}
#elif OS_LINUX
#define VK_PLATFORM_SURFACE_EXTENSION \
VK_KHR_XLIB_SURFACE_EXTENSION_NAME, \
VK_KHR_WAYLAND_SURFACE_EXTENSION_NAME
static void *Vk_LoadLibrary() {
void *result = dlopen("libvulkan.so", RTLD_LAZY);
if (result != 0) {
vk.GetInstanceProcAddr = (PFN_vkGetInstanceProcAddr) dlsym(result, "vkGetInstanceProcAddr");
}
return result;
}
static void Vk_CreateSurface(SDL_Window *window) {
SDL_PropertiesID prop_id = SDL_GetWindowProperties(window);
struct wl_display *wl_display = SDL_GetPointerProperty(prop_id, SDL_PROP_WINDOW_WAYLAND_DISPLAY_POINTER, 0);
if (wl_display == 0) {
// Assume we are running via X11 if there isn't a vaild Wayland display
//
VkXlibSurfaceCreateInfoKHR create_info = { 0 };
create_info.sType = VK_STRUCTURE_TYPE_XLIB_SURFACE_CREATE_INFO_KHR;
create_info.dpy = SDL_GetPointerProperty(prop_id, SDL_PROP_WINDOW_X11_DISPLAY_POINTER, 0);
create_info.window = SDL_GetNumberProperty(prop_id, SDL_PROP_WINDOW_X11_WINDOW_NUMBER, 0);
vk.err = vk.CreateXlibSurfaceKHR(vk.instance, &create_info, 0, &vk.surface);
}
else {
VkWaylandSurfaceCreateInfoKHR create_info = { 0 };
create_info.sType = VK_STRUCTURE_TYPE_WAYLAND_SURFACE_CREATE_INFO_KHR;
create_info.display = wl_display;
create_info.surface = SDL_GetPointerProperty(prop_id, SDL_PROP_WINDOW_WAYLAND_SURFACE_POINTER, 0);
vk.err = vk.CreateWaylandSurfaceKHR(vk.instance, &create_info, 0, &vk.surface);
}
}
#endif
Vk_Context vk;

View File

@@ -10,6 +10,14 @@
#if defined(VK_USE_PLATFORM_WIN32_KHR)
VK_FUNC(CreateWin32SurfaceKHR);
#endif
#if defined(VK_USE_PLATFORM_WAYLAND_KHR)
VK_FUNC(CreateWaylandSurfaceKHR);
#endif
#if defined(VK_USE_PLATFORM_XLIB_KHR)
VK_FUNC(CreateXlibSurfaceKHR);
#endif
#undef VK_INSTANCE_FUNCTIONS
#endif