blob: 5dd11ff71a0e2d24cee50948b90237d44b90b053 [file] [log] [blame]
Karl Schultz37419ed2016-02-02 12:32:50 -07001//
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 Confidential Information as defined by the Khronos
20 * Membership Agreement until designated non-confidential by Khronos, at which
21 * point this condition clause shall be removed.
22 *
23 * THE MATERIALS ARE PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
24 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
25 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
26 *
27 * IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
28 * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
29 * OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE MATERIALS OR THE
30 * USE OR OTHER DEALINGS IN THE MATERIALS.
31 *
32 */
33
Courtney Goeltzenleuchter64d1a712015-04-08 18:04:29 -060034#ifndef VKICD_H
35#define VKICD_H
36
Courtney Goeltzenleuchterb0cedb82015-04-09 11:52:55 -060037#include "vk_platform.h"
Courtney Goeltzenleuchter64d1a712015-04-08 18:04:29 -060038
39/*
40 * The ICD must reserve space for a pointer for the loader's dispatch
41 * table, at the start of <each object>.
42 * The ICD must initialize this variable using the SET_LOADER_MAGIC_VALUE macro.
43 */
44
Karl Schultz37419ed2016-02-02 12:32:50 -070045#define ICD_LOADER_MAGIC 0x01CDC0DE
Courtney Goeltzenleuchter64d1a712015-04-08 18:04:29 -060046
47typedef union _VK_LOADER_DATA {
Karl Schultz37419ed2016-02-02 12:32:50 -070048 uintptr_t loaderMagic;
49 void *loaderData;
Courtney Goeltzenleuchter64d1a712015-04-08 18:04:29 -060050} VK_LOADER_DATA;
51
Karl Schultz37419ed2016-02-02 12:32:50 -070052static inline void set_loader_magic_value(void *pNewObject) {
53 VK_LOADER_DATA *loader_info = (VK_LOADER_DATA *)pNewObject;
Courtney Goeltzenleuchter64d1a712015-04-08 18:04:29 -060054 loader_info->loaderMagic = ICD_LOADER_MAGIC;
55}
56
Karl Schultz37419ed2016-02-02 12:32:50 -070057static inline bool valid_loader_magic_value(void *pNewObject) {
58 const VK_LOADER_DATA *loader_info = (VK_LOADER_DATA *)pNewObject;
Courtney Goeltzenleuchter2e991f82015-07-24 10:18:40 -060059 return (loader_info->loaderMagic & 0xffffffff) == ICD_LOADER_MAGIC;
Courtney Goeltzenleuchter64d1a712015-04-08 18:04:29 -060060}
61
Ian Elliott4d520542015-11-18 12:19:12 -070062/*
63 * Windows and Linux ICDs will treat VkSurfaceKHR as a pointer to a struct that
64 * contains the platform-specific connection and surface information.
65 */
66typedef enum _VkIcdWsiPlatform {
67 VK_ICD_WSI_PLATFORM_MIR,
68 VK_ICD_WSI_PLATFORM_WAYLAND,
69 VK_ICD_WSI_PLATFORM_WIN32,
70 VK_ICD_WSI_PLATFORM_XCB,
71 VK_ICD_WSI_PLATFORM_XLIB,
72} VkIcdWsiPlatform;
73
74typedef struct _VkIcdSurfaceBase {
Karl Schultz37419ed2016-02-02 12:32:50 -070075 VkIcdWsiPlatform platform;
Ian Elliott4d520542015-11-18 12:19:12 -070076} VkIcdSurfaceBase;
77
78#ifdef VK_USE_PLATFORM_MIR_KHR
79typedef struct _VkIcdSurfaceMir {
Karl Schultz37419ed2016-02-02 12:32:50 -070080 VkIcdSurfaceBase base;
81 MirConnection *connection;
82 MirSurface *mirSurface;
Ian Elliott4d520542015-11-18 12:19:12 -070083} VkIcdSurfaceMir;
84#endif // VK_USE_PLATFORM_MIR_KHR
85
86#ifdef VK_USE_PLATFORM_WAYLAND_KHR
87typedef struct _VkIcdSurfaceWayland {
Karl Schultz37419ed2016-02-02 12:32:50 -070088 VkIcdSurfaceBase base;
89 struct wl_display *display;
90 struct wl_surface *surface;
Ian Elliott4d520542015-11-18 12:19:12 -070091} VkIcdSurfaceWayland;
92#endif // VK_USE_PLATFORM_WAYLAND_KHR
93
94#ifdef VK_USE_PLATFORM_WIN32_KHR
95typedef struct _VkIcdSurfaceWin32 {
Karl Schultz37419ed2016-02-02 12:32:50 -070096 VkIcdSurfaceBase base;
97 HINSTANCE hinstance;
98 HWND hwnd;
Ian Elliott4d520542015-11-18 12:19:12 -070099} VkIcdSurfaceWin32;
100#endif // VK_USE_PLATFORM_WIN32_KHR
101
102#ifdef VK_USE_PLATFORM_XCB_KHR
103typedef struct _VkIcdSurfaceXcb {
Karl Schultz37419ed2016-02-02 12:32:50 -0700104 VkIcdSurfaceBase base;
105 xcb_connection_t *connection;
106 xcb_window_t window;
Ian Elliott4d520542015-11-18 12:19:12 -0700107} VkIcdSurfaceXcb;
108#endif // VK_USE_PLATFORM_XCB_KHR
109
110#ifdef VK_USE_PLATFORM_XLIB_KHR
111typedef struct _VkIcdSurfaceXlib {
Karl Schultz37419ed2016-02-02 12:32:50 -0700112 VkIcdSurfaceBase base;
113 Display *dpy;
114 Window window;
Ian Elliott4d520542015-11-18 12:19:12 -0700115} VkIcdSurfaceXlib;
116#endif // VK_USE_PLATFORM_XLIB_KHR
117
Courtney Goeltzenleuchter64d1a712015-04-08 18:04:29 -0600118#endif // VKICD_H