WSI-ICD: Created per-platform structs for platform-specific info.
authorIan Elliott <ianelliott@google.com>
Wed, 18 Nov 2015 19:19:12 +0000 (12:19 -0700)
committerJon Ashburn <jon@lunarg.com>
Tue, 1 Dec 2015 17:18:23 +0000 (10:18 -0700)
Per Khronos Bugzilla Bug 15077, on Windows and Linux, VkSurfaceKHR is treated
as a pointer to platform-specific structs that contain the platform-specific
connection and surface/window info.  The Vulkan loader vkCreate*SurfaceKHR()
functions will fill in the struct.  ICDs and layers will cast VkSurfaceKHR to a
pointer to the appropriate VkIcdSurface* struct.

include/vulkan/vk_icd.h

index 634d653..43e37ef 100644 (file)
@@ -29,5 +29,61 @@ static inline bool valid_loader_magic_value(void* pNewObject) {
     return (loader_info->loaderMagic & 0xffffffff) == ICD_LOADER_MAGIC;
 }
 
+/*
+ * Windows and Linux ICDs will treat VkSurfaceKHR as a pointer to a struct that
+ * contains the platform-specific connection and surface information.
+ */
+typedef enum _VkIcdWsiPlatform {
+    VK_ICD_WSI_PLATFORM_MIR,
+    VK_ICD_WSI_PLATFORM_WAYLAND,
+    VK_ICD_WSI_PLATFORM_WIN32,
+    VK_ICD_WSI_PLATFORM_XCB,
+    VK_ICD_WSI_PLATFORM_XLIB,
+} VkIcdWsiPlatform;
+
+typedef struct _VkIcdSurfaceBase {
+    VkIcdWsiPlatform   platform;
+} VkIcdSurfaceBase;
+
+#ifdef VK_USE_PLATFORM_MIR_KHR
+typedef struct _VkIcdSurfaceMir {
+    VkIcdSurfaceBase   base;
+    MirConnection*     connection;
+    MirSurface*        mirSurface;
+} VkIcdSurfaceMir;
+#endif // VK_USE_PLATFORM_MIR_KHR
+
+#ifdef VK_USE_PLATFORM_WAYLAND_KHR
+typedef struct _VkIcdSurfaceWayland {
+    VkIcdSurfaceBase   base;
+    struct wl_display* display;
+    struct wl_surface* surface;
+} VkIcdSurfaceWayland;
+#endif // VK_USE_PLATFORM_WAYLAND_KHR
+
+#ifdef VK_USE_PLATFORM_WIN32_KHR
+typedef struct _VkIcdSurfaceWin32 {
+    VkIcdSurfaceBase   base;
+    HINSTANCE          hinstance,
+    HWND               hwnd,
+} VkIcdSurfaceWin32;
+#endif // VK_USE_PLATFORM_WIN32_KHR
+
+#ifdef VK_USE_PLATFORM_XCB_KHR
+typedef struct _VkIcdSurfaceXcb {
+    VkIcdSurfaceBase   base;
+    xcb_connection_t*  connection;
+    xcb_window_t       window;
+} VkIcdSurfaceXcb;
+#endif // VK_USE_PLATFORM_XCB_KHR
+
+#ifdef VK_USE_PLATFORM_XLIB_KHR
+typedef struct _VkIcdSurfaceXlib {
+    VkIcdSurfaceBase   base;
+    Display*           dpy;
+    Window             window;
+} VkIcdSurfaceXlib;
+#endif // VK_USE_PLATFORM_XLIB_KHR
+
 #endif // VKICD_H