From fb656f34939464780ac1aba47668278ca81f70a6 Mon Sep 17 00:00:00 2001 From: Triang3l Date: Sat, 10 Aug 2019 14:52:33 +0300 Subject: [PATCH] [Vulkan v2] GDK VkSurface --- src/xenia/ui/vk/vulkan_context.cc | 15 +++++++++++++++ src/xenia/ui/vk/vulkan_provider.h | 9 ++++++++- 2 files changed, 23 insertions(+), 1 deletion(-) diff --git a/src/xenia/ui/vk/vulkan_context.cc b/src/xenia/ui/vk/vulkan_context.cc index ebcc079e4..15f427604 100644 --- a/src/xenia/ui/vk/vulkan_context.cc +++ b/src/xenia/ui/vk/vulkan_context.cc @@ -66,6 +66,21 @@ bool VulkanContext::Initialize() { static_cast(target_window_->native_handle()); surface_create_result = vkCreateWin32SurfaceKHR( instance, &surface_create_info, nullptr, &surface_); +#elif XE_PLATFORM_LINUX +#ifdef GDK_WINDOWING_X11 + VkXcbSurfaceCreateInfoKHR surface_create_info; + surface_create_info.sType = VK_STRUCTURE_TYPE_XCB_SURFACE_CREATE_INFO_KHR; + surface_create_info.pNext = nullptr; + surface_create_info.flags = 0; + surface_create_info.connection = static_cast( + target_window_->native_platform_handle()); + surface_create_info.window = gdk_x11_window_get_xid(gtk_widget_get_window( + static_cast(target_window_->native_handle()))); + surface_create_result = vkCreateXcbSurfaceKHR( + instance, &surface_create_info, nullptr, &surface_); +#else +#error No Vulkan surface creation for the GDK backend implemented yet. +#endif #else #error No Vulkan surface creation for the platform implemented yet. #endif diff --git a/src/xenia/ui/vk/vulkan_provider.h b/src/xenia/ui/vk/vulkan_provider.h index 71285b5ee..950c784fc 100644 --- a/src/xenia/ui/vk/vulkan_provider.h +++ b/src/xenia/ui/vk/vulkan_provider.h @@ -16,9 +16,16 @@ #include "xenia/base/platform.h" #include "xenia/ui/graphics_provider.h" -#if XE_PLATFORM_WIN32 && !defined(VK_USE_PLATFORM_WIN32_KHR) +#if XE_PLATFORM_WIN32 +#ifndef VK_USE_PLATFORM_WIN32_KHR #define VK_USE_PLATFORM_WIN32_KHR 1 #endif +#elif XE_PLATFORM_LINUX +#include "xenia/ui/window_gtk.h" +#if defined(GDK_WINDOWING_X11) && !defined(VK_USE_PLATFORM_XCB_KHR) +#define VK_USE_PLATFORM_XCB_KHR 1 +#endif +#endif #include "third_party/volk/volk.h" #define XELOGVK XELOGI