Add Linux vulkan init routines using xcb lib
This commit is contained in:
parent
a8053f72e5
commit
5d579fc846
|
@ -2,7 +2,7 @@
|
|||
******************************************************************************
|
||||
* Xenia : Xbox 360 Emulator Research Project *
|
||||
******************************************************************************
|
||||
* Copyright 2016 Ben Vanik. All rights reserved. *
|
||||
* Copyright 2017 Ben Vanik. All rights reserved. *
|
||||
* Released under the BSD license - see LICENSE in the root for more details. *
|
||||
******************************************************************************
|
||||
*/
|
||||
|
@ -25,6 +25,10 @@
|
|||
#include "xenia/ui/vulkan/vulkan_util.h"
|
||||
#include "xenia/ui/window.h"
|
||||
|
||||
#if XE_PLATFORM_LINUX
|
||||
#include "xenia/ui/window_gtk.h"
|
||||
#endif
|
||||
|
||||
namespace xe {
|
||||
namespace ui {
|
||||
namespace vulkan {
|
||||
|
@ -61,6 +65,30 @@ bool VulkanContext::Initialize() {
|
|||
auto err = vkCreateWin32SurfaceKHR(*provider->instance(), &create_info,
|
||||
nullptr, &surface);
|
||||
CheckResult(err, "vkCreateWin32SurfaceKHR");
|
||||
#elif XE_PLATFORM_LINUX
|
||||
#ifdef GDK_WINDOWING_X11
|
||||
GtkWidget* window_handle =
|
||||
static_cast<GtkWidget*>(target_window_->native_handle());
|
||||
GdkDisplay* gdk_display = gtk_widget_get_display(window_handle);
|
||||
assert(GDK_IS_X11_DISPLAY(gdk_display));
|
||||
xcb_connection_t* connection =
|
||||
XGetXCBConnection(gdk_x11_display_get_xdisplay(gdk_display));
|
||||
xcb_window_t window = gdk_x11_window_get_xid(
|
||||
gtk_widget_get_window(window_handle));
|
||||
VkXcbSurfaceCreateInfoKHR create_info;
|
||||
create_info.sType = VK_STRUCTURE_TYPE_XCB_SURFACE_CREATE_INFO_KHR;
|
||||
create_info.pNext = nullptr;
|
||||
create_info.flags = 0;
|
||||
create_info.connection = static_cast<xcb_connection_t*>
|
||||
(target_window_->native_platform_handle());
|
||||
create_info.window =
|
||||
static_cast<xcb_window_t>(window);
|
||||
auto err = vkCreateXcbSurfaceKHR(*provider->instance(), &create_info,
|
||||
nullptr, &surface);
|
||||
CheckResult(err, "vkCreateXcbSurfaceKHR");
|
||||
#else
|
||||
#error Unsupported GDK Backend on Linux.
|
||||
#endif // GDK_WINDOWING_X11
|
||||
#else
|
||||
#error Platform not yet implemented.
|
||||
#endif // XE_PLATFORM_WIN32
|
||||
|
|
|
@ -2,7 +2,7 @@
|
|||
******************************************************************************
|
||||
* Xenia : Xbox 360 Emulator Research Project *
|
||||
******************************************************************************
|
||||
* Copyright 2016 Ben Vanik. All rights reserved. *
|
||||
* Copyright 2017 Ben Vanik. All rights reserved. *
|
||||
* Released under the BSD license - see LICENSE in the root for more details. *
|
||||
******************************************************************************
|
||||
*/
|
||||
|
@ -26,6 +26,10 @@
|
|||
#include "xenia/ui/vulkan/vulkan_util.h"
|
||||
#include "xenia/ui/window.h"
|
||||
|
||||
#if XE_PLATFORM_LINUX
|
||||
#include "xenia/ui/window_gtk.h"
|
||||
#endif
|
||||
|
||||
#define VK_API_VERSION VK_API_VERSION_1_0
|
||||
|
||||
namespace xe {
|
||||
|
@ -385,6 +389,30 @@ bool VulkanInstance::QueryDevices(Window* any_target_window) {
|
|||
create_info.hwnd = static_cast<HWND>(any_target_window->native_handle());
|
||||
err = vkCreateWin32SurfaceKHR(handle, &create_info, nullptr, &any_surface);
|
||||
CheckResult(err, "vkCreateWin32SurfaceKHR");
|
||||
#elif XE_PLATFORM_LINUX
|
||||
#ifdef GDK_WINDOWING_X11
|
||||
GtkWidget* window_handle =
|
||||
static_cast<GtkWidget*>(any_target_window->native_handle());
|
||||
GdkDisplay* gdk_display = gtk_widget_get_display(window_handle);
|
||||
assert(GDK_IS_X11_DISPLAY(gdk_display));
|
||||
xcb_connection_t* connection =
|
||||
XGetXCBConnection(gdk_x11_display_get_xdisplay(gdk_display));
|
||||
xcb_window_t window = gdk_x11_window_get_xid(
|
||||
gtk_widget_get_window(window_handle));
|
||||
VkXcbSurfaceCreateInfoKHR create_info;
|
||||
create_info.sType = VK_STRUCTURE_TYPE_XCB_SURFACE_CREATE_INFO_KHR;
|
||||
create_info.pNext = nullptr;
|
||||
create_info.flags = 0;
|
||||
create_info.connection = static_cast<xcb_connection_t*>
|
||||
(any_target_window->native_platform_handle());
|
||||
create_info.window =
|
||||
static_cast<xcb_window_t>(window);
|
||||
auto err = vkCreateXcbSurfaceKHR(handle, &create_info,
|
||||
nullptr, &any_surface);
|
||||
CheckResult(err, "vkCreateXcbSurfaceKHR");
|
||||
#else
|
||||
#error Unsupported GDK Backend on Linux.
|
||||
#endif // GDK_WINDOWING_X11
|
||||
#else
|
||||
#error Platform not yet implemented.
|
||||
#endif // XE_PLATFORM_WIN32
|
||||
|
|
Loading…
Reference in New Issue