[gtk+/wip/otte/vulkan: 5/5] xxx: half-finished wip commit



commit ddbe94f27fb7f6f05ca4758c2f743047afcf0169
Author: Benjamin Otte <otte redhat com>
Date:   Mon Nov 21 14:18:43 2016 +0100

    xxx: half-finished wip commit

 gdk/Makefile.am                |    3 +
 gdk/gdk.c                      |    3 +-
 gdk/gdk.h                      |    1 +
 gdk/gdkdisplayprivate.h        |   12 ++-
 gdk/gdkinternals.h             |    1 +
 gdk/gdktypes.h                 |    1 +
 gdk/gdkvulkancontext.c         |  303 ++++++++++++++++++++++++++++++++++++++++
 gdk/gdkvulkancontext.h         |   52 +++++++
 gdk/gdkvulkancontextprivate.h  |   81 +++++++++++
 gdk/x11/Makefile.am            |    2 +
 gdk/x11/gdkdisplay-x11.c       |    3 +
 gdk/x11/gdkvulkancontext-x11.c |   32 +++++
 gdk/x11/gdkvulkancontext-x11.h |   51 +++++++
 13 files changed, 542 insertions(+), 3 deletions(-)
---
diff --git a/gdk/Makefile.am b/gdk/Makefile.am
index 9549144..b16220f 100644
--- a/gdk/Makefile.am
+++ b/gdk/Makefile.am
@@ -90,6 +90,7 @@ gdk_public_h_sources =                                \
        gdkthreads.h                            \
        gdktypes.h                              \
        gdkvisual.h                             \
+       gdkvulkancontext.h                      \
        gdkwindow.h
 
 gdk_h_sources =                                        \
@@ -118,6 +119,7 @@ gdk_private_headers =                               \
        gdkintl.h                               \
        gdkkeysprivate.h                        \
        gdkvisualprivate.h                      \
+       gdkvulkancontextprivate.h               \
        gdkx.h
 
 gdk_c_sources =                                \
@@ -155,6 +157,7 @@ gdk_c_sources =                             \
        gdkseatdefault.c                        \
        gdkselection.c                          \
        gdkvisual.c                             \
+       gdkvulkancontext.c                      \
        gdkwindow.c                             \
        gdkwindowimpl.c
 
diff --git a/gdk/gdk.c b/gdk/gdk.c
index 050dfe6..a59a874 100644
--- a/gdk/gdk.c
+++ b/gdk/gdk.c
@@ -165,7 +165,8 @@ static const GDebugKey gdk_debug_keys[] = {
   { "eventloop",     GDK_DEBUG_EVENTLOOP },
   { "frames",        GDK_DEBUG_FRAMES },
   { "settings",      GDK_DEBUG_SETTINGS },
-  { "opengl",        GDK_DEBUG_OPENGL }
+  { "opengl",        GDK_DEBUG_OPENGL },
+  { "vulkan",        GDK_DEBUG_VULKAN }
 };
 
 static gboolean
diff --git a/gdk/gdk.h b/gdk/gdk.h
index 4a3b920..8525672 100644
--- a/gdk/gdk.h
+++ b/gdk/gdk.h
@@ -61,6 +61,7 @@
 #include <gdk/gdkthreads.h>
 #include <gdk/gdktypes.h>
 #include <gdk/gdkvisual.h>
+#include <gdk/gdkvulkancontext.h>
 #include <gdk/gdkwindow.h>
 
 #include <gdk/gdk-autocleanup.h>
diff --git a/gdk/gdkdisplayprivate.h b/gdk/gdkdisplayprivate.h
index a9fce70..fadefe7 100644
--- a/gdk/gdkdisplayprivate.h
+++ b/gdk/gdkdisplayprivate.h
@@ -24,6 +24,10 @@
 #include "gdkmonitor.h"
 #include "gdkinternals.h"
 
+#ifdef GDK_WINDOWING_VULKAN
+#include <vulkan/vulkan.h>
+#endif
+
 G_BEGIN_DECLS
 
 #define GDK_DISPLAY_CLASS(klass)      (G_TYPE_CHECK_CLASS_CAST ((klass), GDK_TYPE_DISPLAY, GdkDisplayClass))
@@ -120,9 +124,13 @@ struct _GdkDisplay
   guint double_click_time;  /* Maximum time between clicks in msecs */
   guint double_click_distance;   /* Maximum distance between clicks in pixels */
 
-  guint has_gl_extension_texture_non_power_of_two : 1;
-  guint has_gl_extension_texture_rectangle : 1;
+#ifdef GDK_WINDOWING_VULKAN
+  VkInstance vk_instance;
+  VkDevice   vk_device;
 
+  guint vulkan_inited : 1;
+  guint vulkan_available : 1;
+#endif /* GDK_WINDOWING_VULKAN */
   guint rgba : 1;
   guint composited : 1;
 
diff --git a/gdk/gdkinternals.h b/gdk/gdkinternals.h
index 9700627..ada2055 100644
--- a/gdk/gdkinternals.h
+++ b/gdk/gdkinternals.h
@@ -69,6 +69,7 @@ typedef enum {
   GDK_DEBUG_FRAMES        = 1 << 11,
   GDK_DEBUG_SETTINGS      = 1 << 12,
   GDK_DEBUG_OPENGL        = 1 << 13,
+  GDK_DEBUG_VULKAN        = 1 << 14
 } GdkDebugFlag;
 
 typedef enum {
diff --git a/gdk/gdktypes.h b/gdk/gdktypes.h
index a4ce12b..3d2edba 100644
--- a/gdk/gdktypes.h
+++ b/gdk/gdktypes.h
@@ -145,6 +145,7 @@ typedef struct _GdkAppLaunchContext   GdkAppLaunchContext;
 typedef struct _GdkSeat               GdkSeat;
 
 typedef struct _GdkGLContext          GdkGLContext;
+typedef struct _GdkVulkanContext      GdkVulkanContext;
 
 /**
  * GdkByteOrder:
diff --git a/gdk/gdkvulkancontext.c b/gdk/gdkvulkancontext.c
new file mode 100644
index 0000000..e4addc6
--- /dev/null
+++ b/gdk/gdkvulkancontext.c
@@ -0,0 +1,303 @@
+/* GDK - The GIMP Drawing Kit
+ *
+ * gdkvulkancontext-x11.c: X11 specific Vulkan wrappers
+ *
+ * Copyright © 2016  Benjamin Otte
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Library General Public
+ * License as published by the Free Software Foundation; either
+ * version 2 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * Library General Public License for more details.
+ *
+ * You should have received a copy of the GNU Library General Public
+ * License along with this library. If not, see <http://www.gnu.org/licenses/>.
+ */
+
+#include "config.h"
+
+#include "gdkvulkancontextprivate.h"
+
+#include <vulkan/vulkan.h>
+
+#include "gdkdisplayprivate.h"
+#include "gdkinternals.h"
+#include "gdkintl.h"
+
+typedef struct _GdkVulkanContextPrivate GdkVulkanContextPrivate;
+
+struct _GdkVulkanContextPrivate {
+  GdkWindow *window;
+};
+
+enum {
+  PROP_0,
+
+  PROP_DISPLAY,
+  PROP_WINDOW,
+
+  LAST_PROP
+};
+
+static GParamSpec *pspecs[LAST_PROP] = { NULL, };
+
+G_DEFINE_QUARK (gdk-vulkan-error-quark, gdk_vulkan_error)
+
+G_DEFINE_ABSTRACT_TYPE_WITH_PRIVATE (GdkVulkanContext, gdk_vulkan_context, G_TYPE_OBJECT)
+
+static void
+gdk_vulkan_context_dispose (GObject *gobject)
+{
+  GdkVulkanContext *context = GDK_VULKAN_CONTEXT (gobject);
+  GdkVulkanContextPrivate *priv = gdk_vulkan_context_get_instance_private (context);
+
+  g_clear_object (&priv->window);
+
+  G_OBJECT_CLASS (gdk_vulkan_context_parent_class)->dispose (gobject);
+}
+
+static void
+gdk_vulkan_context_set_property (GObject      *gobject,
+                                 guint         prop_id,
+                                 const GValue *value,
+                                 GParamSpec   *pspec)
+{
+  GdkVulkanContext *context = GDK_VULKAN_CONTEXT (gobject);
+  GdkVulkanContextPrivate *priv = gdk_vulkan_context_get_instance_private (context);
+
+  switch (prop_id)
+    {
+    case PROP_WINDOW:
+      priv->window = g_value_dup_object (value);
+      g_assert (priv->window != NULL);
+      break;
+
+    default:
+      G_OBJECT_WARN_INVALID_PROPERTY_ID (gobject, prop_id, pspec);
+    }
+}
+
+static void
+gdk_vulkan_context_get_property (GObject    *gobject,
+                                 guint       prop_id,
+                                 GValue     *value,
+                                 GParamSpec *pspec)
+{
+  GdkVulkanContext *context = GDK_VULKAN_CONTEXT (gobject);
+  GdkVulkanContextPrivate *priv = gdk_vulkan_context_get_instance_private (context);
+
+  switch (prop_id)
+    {
+    case PROP_DISPLAY:
+      g_value_set_object (value, gdk_vulkan_context_get_display (context));
+      break;
+
+    case PROP_WINDOW:
+      g_value_set_object (value, priv->window);
+      break;
+
+    default:
+      G_OBJECT_WARN_INVALID_PROPERTY_ID (gobject, prop_id, pspec);
+    }
+}
+
+static void
+gdk_vulkan_context_class_init (GdkVulkanContextClass *klass)
+{
+  GObjectClass *gobject_class = G_OBJECT_CLASS (klass);
+
+  gobject_class->set_property = gdk_vulkan_context_set_property;
+  gobject_class->get_property = gdk_vulkan_context_get_property;
+  gobject_class->dispose = gdk_vulkan_context_dispose;
+
+  /**
+   * GdkVulkanContext:display:
+   *
+   * The #GdkDisplay used to create the #GdkVulkanContext.
+   *
+   * Since: 3.16
+   */
+  pspecs[PROP_DISPLAY] =
+    g_param_spec_object ("display",
+                         P_("Display"),
+                         P_("The GDK display used to create the Vulkan context"),
+                         GDK_TYPE_DISPLAY,
+                         G_PARAM_READABLE |
+                         G_PARAM_STATIC_STRINGS);
+
+  /**
+   * GdkVulkanContext:window:
+   *
+   * The #GdkWindow the gl context is bound to.
+   *
+   * Since: 3.16
+   */
+  pspecs[PROP_WINDOW] =
+    g_param_spec_object ("window",
+                         P_("Window"),
+                         P_("The GDK window bound to the Vulkan context"),
+                         GDK_TYPE_WINDOW,
+                         G_PARAM_READWRITE |
+                         G_PARAM_CONSTRUCT_ONLY |
+                         G_PARAM_STATIC_STRINGS);
+
+  g_object_class_install_properties (gobject_class, LAST_PROP, pspecs);
+}
+
+static void
+gdk_vulkan_context_init (GdkVulkanContext *self)
+{
+}
+
+/**
+ * gdk_vulkan_context_get_display:
+ * @context: a #GdkVulkanContext
+ *
+ * Retrieves the #GdkDisplay the @context is created for
+ *
+ * Returns: (nullable) (transfer none): a #GdkDisplay or %NULL
+ *
+ * Since: 3.90
+ */
+GdkDisplay *
+gdk_vulkan_context_get_display (GdkVulkanContext *context)
+{
+  GdkVulkanContextPrivate *priv = gdk_vulkan_context_get_instance_private (context);
+
+  g_return_val_if_fail (GDK_IS_VULKAN_CONTEXT (context), NULL);
+
+  return priv->window ? gdk_window_get_display (priv->window) : NULL;
+}
+
+/**
+ * gdk_vulkan_context_get_window:
+ * @context: a #GdkVulkanContext
+ *
+ * Retrieves the #GdkWindow used by the @context.
+ *
+ * Returns: (nullable) (transfer none): a #GdkWindow or %NULL
+ *
+ * Since: 3.90
+ */
+GdkWindow *
+gdk_vulkan_context_get_window (GdkVulkanContext *context)
+{
+  GdkVulkanContextPrivate *priv = gdk_vulkan_context_get_instance_private (context);
+
+  g_return_val_if_fail (GDK_IS_VULKAN_CONTEXT (context), NULL);
+
+  return priv->window;
+}
+
+#ifdef GDK_WINDOWING_VULKAN
+
+static gboolean
+gdk_display_create_vulkan_device (GdkDisplay *display)
+{
+  uint32_t i;
+
+  uint32_t n_devices;
+  GDK_VK_CHECK(vkEnumeratePhysicalDevices, display->vk_instance, &n_devices, NULL);
+  VkPhysicalDevice devices[n_devices];
+  GDK_VK_CHECK(vkEnumeratePhysicalDevices, display->vk_instance, &n_devices, devices);
+
+  for (i = 0; i < n_devices; i++)
+    {
+      VkPhysicalDeviceProperties props;
+
+      vkGetPhysicalDeviceProperties (devices[i], &props);
+
+      GDK_NOTE (VULKAN, g_print ("Vulkan Device %u:", i));
+      GDK_NOTE (VULKAN, g_print ("    %s (%u)", props.deviceName, props.deviceType));
+      GDK_NOTE (VULKAN, g_print ("    vendor ID: 0x%Xu", props.vendorID));
+      GDK_NOTE (VULKAN, g_print ("    device ID: 0x%Xu", props.deviceID));
+      GDK_NOTE (VULKAN, g_print ("    API version %u.%u.%u",
+                                 VK_VERSION_MAJOR (props.apiVersion),
+                                 VK_VERSION_MINOR (props.apiVersion),
+                                 VK_VERSION_PATCH (props.apiVersion)));
+      GDK_NOTE (VULKAN, g_print ("    driver version %u.%u.%u",
+                                 VK_VERSION_MAJOR (props.driverVersion),
+                                 VK_VERSION_MINOR (props.driverVersion),
+                                 VK_VERSION_PATCH (props.driverVersion)));
+    }
+
+  return TRUE;
+}
+
+static gboolean
+gdk_display_create_vulkan_instance (GdkDisplay *display,
+                                    const char *wsi_extension_name)
+{
+  uint32_t i;
+
+  uint32_t n_extensions;
+  GDK_VK_CHECK (vkEnumerateInstanceExtensionProperties, NULL, &n_extensions, NULL);
+  VkExtensionProperties extensions[n_extensions];
+  GDK_VK_CHECK (vkEnumerateInstanceExtensionProperties, NULL, &n_extensions, extensions);
+
+  for (i = 0; i < n_extensions; i++)
+    {
+      GDK_NOTE (VULKAN, g_print ("Extension available: %s v%u.%u.%u\n",
+                                 extensions[i].extensionName,
+                                 VK_VERSION_MAJOR (extensions[i].specVersion),
+                                 VK_VERSION_MINOR (extensions[i].specVersion),
+                                 VK_VERSION_PATCH (extensions[i].specVersion)));
+    }
+
+  uint32_t n_layers;
+  GDK_VK_CHECK (vkEnumerateInstanceLayerProperties, &n_layers, NULL);
+  VkLayerProperties layers[n_layers];
+  GDK_VK_CHECK (vkEnumerateInstanceLayerProperties, &n_layers, layers);
+
+  for (i = 0; i < n_layers; i++)
+    {
+      GDK_NOTE (VULKAN, g_print ("Layer available: %s v%u.%u.%u (%s)\n",
+                                 layers[i].layerName,
+                                 VK_VERSION_MAJOR (layers[i].specVersion),
+                                 VK_VERSION_MINOR (layers[i].specVersion),
+                                 VK_VERSION_PATCH (layers[i].specVersion),
+                                 layers[i].description));
+    }
+
+  if (GDK_VK_CHECK (vkCreateInstance, &(VkInstanceCreateInfo) {
+                                           VK_STRUCTURE_TYPE_INSTANCE_CREATE_INFO,
+                                           NULL,
+                                           0,
+                                           &(VkApplicationInfo) {
+                                                VK_STRUCTURE_TYPE_APPLICATION_INFO,
+                                                NULL,
+                                                g_get_application_name (),
+                                                0,
+                                                "GTK+",
+                                                VK_MAKE_VERSION (GDK_MAJOR_VERSION, GDK_MINOR_VERSION, 
GDK_MICRO_VERSION),
+                                                VK_API_VERSION_1_0 },
+                                           0,
+                                           NULL,
+                                           1,
+                                           &wsi_extension_name },
+                                       NULL,
+                                       &display->vk_instance) != VK_SUCCESS)
+    return FALSE;
+
+  return gdk_display_create_vulkan_device (display);
+}
+
+gboolean
+gdk_display_init_vulkan (GdkDisplay *display,
+                         const char *wsi_extension_name)
+{
+  if (display->vulkan_inited)
+    return display->vulkan_available;
+
+  display->vulkan_available = gdk_display_create_vulkan_instance (display, wsi_extension_name);
+
+  display->vulkan_inited = TRUE;
+
+  return display->vulkan_available;
+}
+
+#endif /* GDK_WINDOWING_VULKAN */
diff --git a/gdk/gdkvulkancontext.h b/gdk/gdkvulkancontext.h
new file mode 100644
index 0000000..7a042f0
--- /dev/null
+++ b/gdk/gdkvulkancontext.h
@@ -0,0 +1,52 @@
+/* GDK - The GIMP Drawing Kit
+ *
+ * gdkvulkancontext.h:  specific Vulkan wrappers
+ *
+ * Copyright © 2016  Benjamin Otte
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Library General Public
+ * License as published by the Free Software Foundation; either
+ * version 2 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * Library General Public License for more details.
+ *
+ * You should have received a copy of the GNU Library General Public
+ * License along with this library. If not, see <http://www.gnu.org/licenses/>.
+ */
+
+#ifndef __GDK_VULKAN_CONTEXT__
+#define __GDK_VULKAN_CONTEXT__
+
+#if !defined (__GDK_H_INSIDE__) && !defined (GDK_COMPILATION)
+#error "Only <gdk/gdk.h> can be included directly."
+#endif
+
+#include <gdk/gdkversionmacros.h>
+#include <gdk/gdktypes.h>
+
+G_BEGIN_DECLS
+
+#define GDK_TYPE_VULKAN_CONTEXT             (gdk_vulkan_context_get_type ())
+#define GDK_VULKAN_CONTEXT(obj)             (G_TYPE_CHECK_INSTANCE_CAST ((obj), GDK_TYPE_VULKAN_CONTEXT, 
GdkVulkanContext))
+#define GDK_IS_VULKAN_CONTEXT(obj)          (G_TYPE_CHECK_INSTANCE_TYPE ((obj), GDK_TYPE_VULKAN_CONTEXT))
+
+#define GDK_VULKAN_ERROR                    (gdk_vulkan_error_quark ())
+
+GDK_AVAILABLE_IN_3_90
+GQuark gdk_vulkan_error_quark (void);
+
+GDK_AVAILABLE_IN_3_90
+GType gdk_vulkan_context_get_type (void) G_GNUC_CONST;
+
+GDK_AVAILABLE_IN_3_90
+GdkDisplay *            gdk_vulkan_context_get_display              (GdkVulkanContext  *context);
+GDK_AVAILABLE_IN_3_90
+GdkWindow *             gdk_vulkan_context_get_window               (GdkVulkanContext  *context);
+
+G_END_DECLS
+
+#endif /* __GDK_VULKAN_CONTEXT__ */
diff --git a/gdk/gdkvulkancontextprivate.h b/gdk/gdkvulkancontextprivate.h
new file mode 100644
index 0000000..5cdac48
--- /dev/null
+++ b/gdk/gdkvulkancontextprivate.h
@@ -0,0 +1,81 @@
+/* GDK - The GIMP Drawing Kit
+ *
+ * gdkvulkancontext-x11.h:  specific Vulkan wrappers
+ *
+ * Copyright © 2016  Benjamin Otte
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Library General Public
+ * License as published by the Free Software Foundation; either
+ * version 2 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * Library General Public License for more details.
+ *
+ * You should have received a copy of the GNU Library General Public
+ * License along with this library. If not, see <http://www.gnu.org/licenses/>.
+ */
+
+#ifndef __GDK_VULKAN_CONTEXT_PRIVATE__
+#define __GDK_VULKAN_CONTEXT_PRIVATE__
+
+#include "gdkvulkancontext.h"
+
+#include "gdkinternals.h"
+
+#include <vulkan/vulkan.h>
+
+G_BEGIN_DECLS
+
+#define GDK_VULKAN_CONTEXT_CLASS(klass)        (G_TYPE_CHECK_CLASS_CAST ((klass), GDK_TYPE_VULKAN_CONTEXT, 
GdkVulkanContextClass))
+#define GDK_IS_VULKAN_CONTEXT_CLASS(klass)     (G_TYPE_CHECK_CLASS_TYPE ((klass), GDK_TYPE_VULKAN_CONTEXT))
+#define GDK_VULKAN_CONTEXT_GET_CLASS(obj)      (G_TYPE_INSTANCE_GET_CLASS ((obj), GDK_TYPE_VULKAN_CONTEXT, 
GdkVulkanContextClass))
+
+typedef struct _GdkVulkanContextClass GdkVulkanContextClass;
+
+struct _GdkVulkanContext
+{
+  GObject parent_instance;
+};
+
+struct _GdkVulkanContextClass
+{
+  GObjectClass parent_class;
+};
+
+#ifdef GDK_WINDOWING_VULKAN
+
+static inline VkResult
+gdk_vulkan_handle_result (VkResult    res,
+                          const char *called_function)
+{
+  if (res != VK_SUCCESS)
+    {
+      GDK_NOTE (VULKAN,g_printerr ("%s(): %d\n", called_function, res));
+    }
+  return res;
+}
+
+#define GDK_VK_CHECK(func, ...) gdk_vulkan_handle_result (func (__VA_ARGS__), G_STRINGIFY (func))
+
+gboolean        gdk_display_init_vulkan                        (GdkDisplay      *display,
+                                                                const char      *wsi_extension_name);
+
+#else /* !GDK_WINDOWING_VULKAN */
+
+static inline gboolean
+gdk_display_init_vulkan (GdkDisplay *display,
+                         const char *wsi_extension_name)
+{
+  GDK_NOTE (VULKAN, g_print ("Support for Vulkan disabled at compile-time"));
+
+  return FALSE;
+}
+
+#endif /* !GDK_WINDOWING_VULKAN */
+
+G_END_DECLS
+
+#endif /* __GDK__VULKAN_CONTEXT_PRIVATE__ */
diff --git a/gdk/x11/Makefile.am b/gdk/x11/Makefile.am
index cd4d0e0..fc544e1 100644
--- a/gdk/x11/Makefile.am
+++ b/gdk/x11/Makefile.am
@@ -54,6 +54,8 @@ libgdk_x11_la_SOURCES =       \
        gdkselection-x11.c      \
        gdktestutils-x11.c      \
        gdkvisual-x11.c         \
+       gdkvulkancontext-x11.c  \
+       gdkvulkancontext-x11.h  \
        gdkwindow-x11.c         \
        gdkwindow-x11.h         \
        gdkxftdefaults.c        \
diff --git a/gdk/x11/gdkdisplay-x11.c b/gdk/x11/gdkdisplay-x11.c
index cca0b65..8852d67 100644
--- a/gdk/x11/gdkdisplay-x11.c
+++ b/gdk/x11/gdkdisplay-x11.c
@@ -38,6 +38,7 @@
 #include "gdkprivate-x11.h"
 #include "gdkscreen-x11.h"
 #include "gdkglcontext-x11.h"
+#include "gdkvulkancontext-x11.h"
 #include "gdk-private.h"
 
 #include <glib.h>
@@ -1597,6 +1598,8 @@ _gdk_x11_display_open (const gchar *display_name)
   gdk_display_set_composited (GDK_DISPLAY (display),
                               XGetSelectionOwner (GDK_DISPLAY_XDISPLAY (display), get_cm_atom (display)) != 
None);
 
+  gdk_display_init_vulkan (display, "VK_KHR_xlib_surface");
+
   g_signal_emit_by_name (display, "opened");
 
   return display;
diff --git a/gdk/x11/gdkvulkancontext-x11.c b/gdk/x11/gdkvulkancontext-x11.c
new file mode 100644
index 0000000..cb0bda2
--- /dev/null
+++ b/gdk/x11/gdkvulkancontext-x11.c
@@ -0,0 +1,32 @@
+/* GDK - The GIMP Drawing Kit
+ *
+ * gdkvulkancontext-x11.c: X11 specific Vulkan wrappers
+ *
+ * Copyright © 2016  Benjamin Otte
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Library General Public
+ * License as published by the Free Software Foundation; either
+ * version 2 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * Library General Public License for more details.
+ *
+ * You should have received a copy of the GNU Library General Public
+ * License along with this library. If not, see <http://www.gnu.org/licenses/>.
+ */
+
+#ifdef GDK_WINDOWING_VULKAN
+
+#include "config.h"
+
+#include "gdkvulkancontext-x11.h"
+
+#include <vulkan/vulkan.h>
+
+#include "gdkinternals.h"
+
+#endif /* GDK_WINDOWING_VULKAN */
+
diff --git a/gdk/x11/gdkvulkancontext-x11.h b/gdk/x11/gdkvulkancontext-x11.h
new file mode 100644
index 0000000..d4268df
--- /dev/null
+++ b/gdk/x11/gdkvulkancontext-x11.h
@@ -0,0 +1,51 @@
+/* GDK - The GIMP Drawing Kit
+ *
+ * gdkvulkancontext-x11.h: X11 specific Vulkan wrappers
+ *
+ * Copyright © 2016  Benjamin Otte
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Library General Public
+ * License as published by the Free Software Foundation; either
+ * version 2 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * Library General Public License for more details.
+ *
+ * You should have received a copy of the GNU Library General Public
+ * License along with this library. If not, see <http://www.gnu.org/licenses/>.
+ */
+
+#ifndef __GDK_X11_VULKAN_CONTEXT__
+#define __GDK_X11_VULKAN_CONTEXT__
+
+#ifdef GDK_WINDOWING_VULKAN
+
+#include "gdkvulkancontextprivate.h"
+
+G_BEGIN_DECLS
+
+#define GDK_TYPE_X11_VULKAN_CONTEXT            (gdk_x11_vulkan_context_get_type ())
+#define GDK_X11_VULKAN_CONTEXT(obj)            (G_TYPE_CHECK_INSTANCE_CAST ((obj), 
GDK_TYPE_X11_VULKAN_CONTEXT, GdkX11VulkanContext))
+#define GDK_IS_X11_VULKAN_CONTEXT(obj)         (G_TYPE_CHECK_INSTANCE_TYPE ((obj), 
GDK_TYPE_X11_VULKAN_CONTEXT))
+#define GDK_X11_VULKAN_CONTEXT_CLASS(klass)    (G_TYPE_CHECK_CLASS_CAST ((klass), 
GDK_TYPE_X11_VULKAN_CONTEXT, GdkX11VulkanContextClass))
+#define GDK_IS_X11_VULKAN_CONTEXT_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), 
GDK_TYPE_X11_VULKAN_CONTEXT))
+#define GDK_X11_VULKAN_CONTEXT_GET_CLASS(obj)  (G_TYPE_INSTANCE_GET_CLASS ((obj), 
GDK_TYPE_X11_VULKAN_CONTEXT, GdkX11VulkanContextClass))
+
+struct _GdkX11VulkanContext
+{
+  GdkVulkanContext parent_instance;
+};
+
+struct _GdkX11VulkanContextClass
+{
+  GdkVulkanContextClass parent_class;
+};
+
+G_END_DECLS
+
+#endif /* !GDK_WINDOWING_VULKAN */
+
+#endif /* __GDK_X11_VULKAN_CONTEXT__ */


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]