示例#1
0
static VkResult
gdk_win32_vulkan_context_create_surface (GdkVulkanContext *context,
                                         VkSurfaceKHR     *surface)
{
  GdkWindow *window = gdk_draw_context_get_window (GDK_DRAW_CONTEXT (context));
  GdkDisplay *display = gdk_draw_context_get_display (GDK_DRAW_CONTEXT (context));
  VkWin32SurfaceCreateInfoKHR info;

  info.sType = VK_STRUCTURE_TYPE_WIN32_SURFACE_CREATE_INFO_KHR;
  info.pNext = NULL;
  info.flags = 0;
  info.hinstance = _gdk_dll_hinstance;
  info.hwnd = GDK_WINDOW_HWND (window);

  /* This is necessary so that Vulkan sees the Window.
   * Usually, vkCreateWin32SurfaceKHR() will not cause a problem to happen as
   * it just creates resources, but futher calls with the resulting surface
   * do cause issues.
   */
  gdk_display_sync (display);

  return GDK_VK_CHECK (vkCreateWin32SurfaceKHR,
                       gdk_vulkan_context_get_instance (context),
                       &info,
                       NULL,
                       surface);
}
示例#2
0
static VkResult
gdk_x11_vulkan_context_create_surface (GdkVulkanContext *context,
                                       VkSurfaceKHR     *surface)
{
  GdkSurface *window = gdk_draw_context_get_surface (GDK_DRAW_CONTEXT (context));
  GdkDisplay *display = gdk_draw_context_get_display (GDK_DRAW_CONTEXT (context));

  /* This is necessary so that Vulkan sees the Window.
   * Usually, vkCreateXlibSurfaceKHR() will not cause a problem to happen as
   * it just creates resources, but futher calls with the resulting surface
   * do cause issues.
   */
  gdk_display_sync (display);

  return GDK_VK_CHECK (vkCreateXlibSurfaceKHR, gdk_vulkan_context_get_instance (context),
                                               &(VkXlibSurfaceCreateInfoKHR) {
                                                   VK_STRUCTURE_TYPE_XLIB_SURFACE_CREATE_INFO_KHR,
                                                   NULL,
                                                   0,
                                                   gdk_x11_display_get_xdisplay (display),
                                                   gdk_x11_surface_get_xid (window)
                                               },
                                               NULL,
                                               surface);
}