1 // 2 // File: vk_icd.h 3 // 4 /* 5 * Copyright (c) 2015-2016 The Khronos Group Inc. 6 * Copyright (c) 2015-2016 Valve Corporation 7 * Copyright (c) 2015-2016 LunarG, Inc. 8 * 9 * Permission is hereby granted, free of charge, to any person obtaining a copy 10 * of this software and/or associated documentation files (the "Materials"), to 11 * deal in the Materials without restriction, including without limitation the 12 * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or 13 * sell copies of the Materials, and to permit persons to whom the Materials are 14 * furnished to do so, subject to the following conditions: 15 * 16 * The above copyright notice(s) and this permission notice shall be included in 17 * all copies or substantial portions of the Materials. 18 * 19 * THE MATERIALS ARE PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 20 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 21 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. 22 * 23 * IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, 24 * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR 25 * OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE MATERIALS OR THE 26 * USE OR OTHER DEALINGS IN THE MATERIALS. 27 * 28 */ 29 30 #ifndef VKICD_H 31 #define VKICD_H 32 33 #include "vulkan.h" 34 35 /* 36 * The ICD must reserve space for a pointer for the loader's dispatch 37 * table, at the start of <each object>. 38 * The ICD must initialize this variable using the SET_LOADER_MAGIC_VALUE macro. 39 */ 40 41 #define ICD_LOADER_MAGIC 0x01CDC0DE 42 43 typedef union _VK_LOADER_DATA { 44 uintptr_t loaderMagic; 45 void *loaderData; 46 } VK_LOADER_DATA; 47 48 static inline void set_loader_magic_value(void *pNewObject) { 49 VK_LOADER_DATA *loader_info = (VK_LOADER_DATA *)pNewObject; 50 loader_info->loaderMagic = ICD_LOADER_MAGIC; 51 } 52 53 static inline bool valid_loader_magic_value(void *pNewObject) { 54 const VK_LOADER_DATA *loader_info = (VK_LOADER_DATA *)pNewObject; 55 return (loader_info->loaderMagic & 0xffffffff) == ICD_LOADER_MAGIC; 56 } 57 58 /* 59 * Windows and Linux ICDs will treat VkSurfaceKHR as a pointer to a struct that 60 * contains the platform-specific connection and surface information. 61 */ 62 typedef enum _VkIcdWsiPlatform { 63 VK_ICD_WSI_PLATFORM_MIR, 64 VK_ICD_WSI_PLATFORM_WAYLAND, 65 VK_ICD_WSI_PLATFORM_WIN32, 66 VK_ICD_WSI_PLATFORM_XCB, 67 VK_ICD_WSI_PLATFORM_XLIB, 68 VK_ICD_WSI_PLATFORM_DISPLAY 69 } VkIcdWsiPlatform; 70 71 typedef struct _VkIcdSurfaceBase { 72 VkIcdWsiPlatform platform; 73 } VkIcdSurfaceBase; 74 75 #ifdef VK_USE_PLATFORM_MIR_KHR 76 typedef struct _VkIcdSurfaceMir { 77 VkIcdSurfaceBase base; 78 MirConnection *connection; 79 MirSurface *mirSurface; 80 } VkIcdSurfaceMir; 81 #endif // VK_USE_PLATFORM_MIR_KHR 82 83 #ifdef VK_USE_PLATFORM_WAYLAND_KHR 84 typedef struct _VkIcdSurfaceWayland { 85 VkIcdSurfaceBase base; 86 struct wl_display *display; 87 struct wl_surface *surface; 88 } VkIcdSurfaceWayland; 89 #endif // VK_USE_PLATFORM_WAYLAND_KHR 90 91 #ifdef VK_USE_PLATFORM_WIN32_KHR 92 typedef struct _VkIcdSurfaceWin32 { 93 VkIcdSurfaceBase base; 94 HINSTANCE hinstance; 95 HWND hwnd; 96 } VkIcdSurfaceWin32; 97 #endif // VK_USE_PLATFORM_WIN32_KHR 98 99 #ifdef VK_USE_PLATFORM_XCB_KHR 100 typedef struct _VkIcdSurfaceXcb { 101 VkIcdSurfaceBase base; 102 xcb_connection_t *connection; 103 xcb_window_t window; 104 } VkIcdSurfaceXcb; 105 #endif // VK_USE_PLATFORM_XCB_KHR 106 107 #ifdef VK_USE_PLATFORM_XLIB_KHR 108 typedef struct _VkIcdSurfaceXlib { 109 VkIcdSurfaceBase base; 110 Display *dpy; 111 Window window; 112 } VkIcdSurfaceXlib; 113 #endif // VK_USE_PLATFORM_XLIB_KHR 114 115 typedef struct _VkIcdSurfaceDisplay { 116 VkIcdSurfaceBase base; 117 VkDisplayModeKHR displayMode; 118 uint32_t planeIndex; 119 uint32_t planeStackIndex; 120 VkSurfaceTransformFlagBitsKHR transform; 121 float globalAlpha; 122 VkDisplayPlaneAlphaFlagBitsKHR alphaMode; 123 VkExtent2D imageExtent; 124 } VkIcdSurfaceDisplay; 125 #endif // VKICD_H 126