Karl Schultz | 673df32 | 2016-02-02 12:32:50 -0700 | [diff] [blame] | 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 | * |
Karl Schultz | 673df32 | 2016-02-02 12:32:50 -0700 | [diff] [blame] | 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 | |
Courtney Goeltzenleuchter | 89e99e6 | 2015-04-08 18:04:29 -0600 | [diff] [blame] | 30 | #ifndef VKICD_H |
| 31 | #define VKICD_H |
| 32 | |
Jon Ashburn | 00df045 | 2016-03-08 09:30:30 -0700 | [diff] [blame] | 33 | #include "vulkan.h" |
Courtney Goeltzenleuchter | 89e99e6 | 2015-04-08 18:04:29 -0600 | [diff] [blame] | 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 | |
Karl Schultz | 673df32 | 2016-02-02 12:32:50 -0700 | [diff] [blame] | 41 | #define ICD_LOADER_MAGIC 0x01CDC0DE |
Courtney Goeltzenleuchter | 89e99e6 | 2015-04-08 18:04:29 -0600 | [diff] [blame] | 42 | |
| 43 | typedef union _VK_LOADER_DATA { |
Karl Schultz | 673df32 | 2016-02-02 12:32:50 -0700 | [diff] [blame] | 44 | uintptr_t loaderMagic; |
| 45 | void *loaderData; |
Courtney Goeltzenleuchter | 89e99e6 | 2015-04-08 18:04:29 -0600 | [diff] [blame] | 46 | } VK_LOADER_DATA; |
| 47 | |
Karl Schultz | 673df32 | 2016-02-02 12:32:50 -0700 | [diff] [blame] | 48 | static inline void set_loader_magic_value(void *pNewObject) { |
| 49 | VK_LOADER_DATA *loader_info = (VK_LOADER_DATA *)pNewObject; |
Courtney Goeltzenleuchter | 89e99e6 | 2015-04-08 18:04:29 -0600 | [diff] [blame] | 50 | loader_info->loaderMagic = ICD_LOADER_MAGIC; |
| 51 | } |
| 52 | |
Karl Schultz | 673df32 | 2016-02-02 12:32:50 -0700 | [diff] [blame] | 53 | static inline bool valid_loader_magic_value(void *pNewObject) { |
| 54 | const VK_LOADER_DATA *loader_info = (VK_LOADER_DATA *)pNewObject; |
Courtney Goeltzenleuchter | 5f70fc4 | 2015-07-24 10:18:40 -0600 | [diff] [blame] | 55 | return (loader_info->loaderMagic & 0xffffffff) == ICD_LOADER_MAGIC; |
Courtney Goeltzenleuchter | 89e99e6 | 2015-04-08 18:04:29 -0600 | [diff] [blame] | 56 | } |
| 57 | |
Ian Elliott | 1bc1831 | 2015-11-18 12:19:12 -0700 | [diff] [blame] | 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, |
Jon Ashburn | 00df045 | 2016-03-08 09:30:30 -0700 | [diff] [blame] | 68 | VK_ICD_WSI_PLATFORM_DISPLAY |
Ian Elliott | 1bc1831 | 2015-11-18 12:19:12 -0700 | [diff] [blame] | 69 | } VkIcdWsiPlatform; |
| 70 | |
| 71 | typedef struct _VkIcdSurfaceBase { |
Karl Schultz | 673df32 | 2016-02-02 12:32:50 -0700 | [diff] [blame] | 72 | VkIcdWsiPlatform platform; |
Ian Elliott | 1bc1831 | 2015-11-18 12:19:12 -0700 | [diff] [blame] | 73 | } VkIcdSurfaceBase; |
| 74 | |
| 75 | #ifdef VK_USE_PLATFORM_MIR_KHR |
| 76 | typedef struct _VkIcdSurfaceMir { |
Karl Schultz | 673df32 | 2016-02-02 12:32:50 -0700 | [diff] [blame] | 77 | VkIcdSurfaceBase base; |
| 78 | MirConnection *connection; |
| 79 | MirSurface *mirSurface; |
Ian Elliott | 1bc1831 | 2015-11-18 12:19:12 -0700 | [diff] [blame] | 80 | } VkIcdSurfaceMir; |
| 81 | #endif // VK_USE_PLATFORM_MIR_KHR |
| 82 | |
| 83 | #ifdef VK_USE_PLATFORM_WAYLAND_KHR |
| 84 | typedef struct _VkIcdSurfaceWayland { |
Karl Schultz | 673df32 | 2016-02-02 12:32:50 -0700 | [diff] [blame] | 85 | VkIcdSurfaceBase base; |
| 86 | struct wl_display *display; |
| 87 | struct wl_surface *surface; |
Ian Elliott | 1bc1831 | 2015-11-18 12:19:12 -0700 | [diff] [blame] | 88 | } VkIcdSurfaceWayland; |
| 89 | #endif // VK_USE_PLATFORM_WAYLAND_KHR |
| 90 | |
| 91 | #ifdef VK_USE_PLATFORM_WIN32_KHR |
| 92 | typedef struct _VkIcdSurfaceWin32 { |
Karl Schultz | 673df32 | 2016-02-02 12:32:50 -0700 | [diff] [blame] | 93 | VkIcdSurfaceBase base; |
| 94 | HINSTANCE hinstance; |
| 95 | HWND hwnd; |
Ian Elliott | 1bc1831 | 2015-11-18 12:19:12 -0700 | [diff] [blame] | 96 | } VkIcdSurfaceWin32; |
| 97 | #endif // VK_USE_PLATFORM_WIN32_KHR |
| 98 | |
| 99 | #ifdef VK_USE_PLATFORM_XCB_KHR |
| 100 | typedef struct _VkIcdSurfaceXcb { |
Karl Schultz | 673df32 | 2016-02-02 12:32:50 -0700 | [diff] [blame] | 101 | VkIcdSurfaceBase base; |
| 102 | xcb_connection_t *connection; |
| 103 | xcb_window_t window; |
Ian Elliott | 1bc1831 | 2015-11-18 12:19:12 -0700 | [diff] [blame] | 104 | } VkIcdSurfaceXcb; |
| 105 | #endif // VK_USE_PLATFORM_XCB_KHR |
| 106 | |
| 107 | #ifdef VK_USE_PLATFORM_XLIB_KHR |
| 108 | typedef struct _VkIcdSurfaceXlib { |
Karl Schultz | 673df32 | 2016-02-02 12:32:50 -0700 | [diff] [blame] | 109 | VkIcdSurfaceBase base; |
| 110 | Display *dpy; |
| 111 | Window window; |
Ian Elliott | 1bc1831 | 2015-11-18 12:19:12 -0700 | [diff] [blame] | 112 | } VkIcdSurfaceXlib; |
| 113 | #endif // VK_USE_PLATFORM_XLIB_KHR |
| 114 | |
Jon Ashburn | 00df045 | 2016-03-08 09:30:30 -0700 | [diff] [blame] | 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; |
Courtney Goeltzenleuchter | 89e99e6 | 2015-04-08 18:04:29 -0600 | [diff] [blame] | 125 | #endif // VKICD_H |