blob: b8c7efcb6bb5dc7d53a67f9ea037ef0a145bd9d9 [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 *
Jon Ashburn3ebf1252016-04-19 11:30:31 -06009 * Licensed under the Apache License, Version 2.0 (the "License");
10 * you may not use this file except in compliance with the License.
11 * You may obtain a copy of the License at
Karl Schultz37419ed2016-02-02 12:32:50 -070012 *
Jon Ashburn3ebf1252016-04-19 11:30:31 -060013 * http://www.apache.org/licenses/LICENSE-2.0
Karl Schultz37419ed2016-02-02 12:32:50 -070014 *
Jon Ashburn3ebf1252016-04-19 11:30:31 -060015 * Unless required by applicable law or agreed to in writing, software
16 * distributed under the License is distributed on an "AS IS" BASIS,
17 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
18 * See the License for the specific language governing permissions and
19 * limitations under the License.
Karl Schultz37419ed2016-02-02 12:32:50 -070020 *
21 */
22
Courtney Goeltzenleuchter64d1a712015-04-08 18:04:29 -060023#ifndef VKICD_H
24#define VKICD_H
25
Jon Ashburnc7d3e732016-03-08 09:30:30 -070026#include "vulkan.h"
Yamakaky93c76f12017-03-13 11:06:49 -040027#include <stdbool.h>
Courtney Goeltzenleuchter64d1a712015-04-08 18:04:29 -060028
Mark Young39389872017-01-19 21:10:49 -070029// Loader-ICD version negotiation API. Versions add the following features:
30// Version 0 - Initial. Doesn't support vk_icdGetInstanceProcAddr
31// or vk_icdNegotiateLoaderICDInterfaceVersion.
32// Version 1 - Add support for vk_icdGetInstanceProcAddr.
33// Version 2 - Add Loader/ICD Interface version negotiation
34// via vk_icdNegotiateLoaderICDInterfaceVersion.
35// Version 3 - Add ICD creation/destruction of KHR_surface objects.
36// Version 4 - Add unknown physical device extension qyering via
37// vk_icdGetPhysicalDeviceProcAddr.
Mark Young02df1a82017-04-18 19:52:18 -060038// Version 5 - Tells ICDs that the loader is now paying attention to the
39// application version of Vulkan passed into the ApplicationInfo
40// structure during vkCreateInstance. This will tell the ICD
41// that if the loader is older, it should automatically fail a
42// call for any API version > 1.0. Otherwise, the loader will
43// manually determine if it can support the expected version.
44#define CURRENT_LOADER_ICD_INTERFACE_VERSION 5
Jon Ashburn17b4c862016-04-25 11:09:37 -060045#define MIN_SUPPORTED_LOADER_ICD_INTERFACE_VERSION 0
Mark Young39389872017-01-19 21:10:49 -070046#define MIN_PHYS_DEV_EXTENSION_ICD_INTERFACE_VERSION 4
Jon Ashburn17b4c862016-04-25 11:09:37 -060047typedef VkResult (VKAPI_PTR *PFN_vkNegotiateLoaderICDInterfaceVersion)(uint32_t *pVersion);
Mark Young39389872017-01-19 21:10:49 -070048
49// This is defined in vk_layer.h which will be found by the loader, but if an ICD is building against this
Lenny Komow0f7496d2017-09-05 09:21:47 -060050// file directly, it won't be found.
Mark Young39389872017-01-19 21:10:49 -070051#ifndef PFN_GetPhysicalDeviceProcAddr
52typedef PFN_vkVoidFunction (VKAPI_PTR *PFN_GetPhysicalDeviceProcAddr)(VkInstance instance, const char* pName);
53#endif
54
Jon Ashburn17b4c862016-04-25 11:09:37 -060055/*
Courtney Goeltzenleuchter64d1a712015-04-08 18:04:29 -060056 * The ICD must reserve space for a pointer for the loader's dispatch
57 * table, at the start of <each object>.
58 * The ICD must initialize this variable using the SET_LOADER_MAGIC_VALUE macro.
59 */
60
Karl Schultz37419ed2016-02-02 12:32:50 -070061#define ICD_LOADER_MAGIC 0x01CDC0DE
Courtney Goeltzenleuchter64d1a712015-04-08 18:04:29 -060062
Mark Lobodzinski2b46a9d2016-05-19 17:17:58 -060063typedef union {
Karl Schultz37419ed2016-02-02 12:32:50 -070064 uintptr_t loaderMagic;
65 void *loaderData;
Courtney Goeltzenleuchter64d1a712015-04-08 18:04:29 -060066} VK_LOADER_DATA;
67
Karl Schultz37419ed2016-02-02 12:32:50 -070068static inline void set_loader_magic_value(void *pNewObject) {
69 VK_LOADER_DATA *loader_info = (VK_LOADER_DATA *)pNewObject;
Courtney Goeltzenleuchter64d1a712015-04-08 18:04:29 -060070 loader_info->loaderMagic = ICD_LOADER_MAGIC;
71}
72
Karl Schultz37419ed2016-02-02 12:32:50 -070073static inline bool valid_loader_magic_value(void *pNewObject) {
74 const VK_LOADER_DATA *loader_info = (VK_LOADER_DATA *)pNewObject;
Courtney Goeltzenleuchter2e991f82015-07-24 10:18:40 -060075 return (loader_info->loaderMagic & 0xffffffff) == ICD_LOADER_MAGIC;
Courtney Goeltzenleuchter64d1a712015-04-08 18:04:29 -060076}
77
Ian Elliott4d520542015-11-18 12:19:12 -070078/*
79 * Windows and Linux ICDs will treat VkSurfaceKHR as a pointer to a struct that
80 * contains the platform-specific connection and surface information.
81 */
Mark Lobodzinski2b46a9d2016-05-19 17:17:58 -060082typedef enum {
Ian Elliott4d520542015-11-18 12:19:12 -070083 VK_ICD_WSI_PLATFORM_MIR,
84 VK_ICD_WSI_PLATFORM_WAYLAND,
85 VK_ICD_WSI_PLATFORM_WIN32,
86 VK_ICD_WSI_PLATFORM_XCB,
87 VK_ICD_WSI_PLATFORM_XLIB,
Jon Ashburnc7d3e732016-03-08 09:30:30 -070088 VK_ICD_WSI_PLATFORM_DISPLAY
Ian Elliott4d520542015-11-18 12:19:12 -070089} VkIcdWsiPlatform;
90
Mark Lobodzinski2b46a9d2016-05-19 17:17:58 -060091typedef struct {
Karl Schultz37419ed2016-02-02 12:32:50 -070092 VkIcdWsiPlatform platform;
Ian Elliott4d520542015-11-18 12:19:12 -070093} VkIcdSurfaceBase;
94
95#ifdef VK_USE_PLATFORM_MIR_KHR
Mark Lobodzinski2b46a9d2016-05-19 17:17:58 -060096typedef struct {
Karl Schultz37419ed2016-02-02 12:32:50 -070097 VkIcdSurfaceBase base;
98 MirConnection *connection;
99 MirSurface *mirSurface;
Ian Elliott4d520542015-11-18 12:19:12 -0700100} VkIcdSurfaceMir;
101#endif // VK_USE_PLATFORM_MIR_KHR
102
103#ifdef VK_USE_PLATFORM_WAYLAND_KHR
Mark Lobodzinski2b46a9d2016-05-19 17:17:58 -0600104typedef struct {
Karl Schultz37419ed2016-02-02 12:32:50 -0700105 VkIcdSurfaceBase base;
106 struct wl_display *display;
107 struct wl_surface *surface;
Ian Elliott4d520542015-11-18 12:19:12 -0700108} VkIcdSurfaceWayland;
109#endif // VK_USE_PLATFORM_WAYLAND_KHR
110
111#ifdef VK_USE_PLATFORM_WIN32_KHR
Mark Lobodzinski2b46a9d2016-05-19 17:17:58 -0600112typedef struct {
Karl Schultz37419ed2016-02-02 12:32:50 -0700113 VkIcdSurfaceBase base;
114 HINSTANCE hinstance;
115 HWND hwnd;
Ian Elliott4d520542015-11-18 12:19:12 -0700116} VkIcdSurfaceWin32;
117#endif // VK_USE_PLATFORM_WIN32_KHR
118
119#ifdef VK_USE_PLATFORM_XCB_KHR
Mark Lobodzinski2b46a9d2016-05-19 17:17:58 -0600120typedef struct {
Karl Schultz37419ed2016-02-02 12:32:50 -0700121 VkIcdSurfaceBase base;
122 xcb_connection_t *connection;
123 xcb_window_t window;
Ian Elliott4d520542015-11-18 12:19:12 -0700124} VkIcdSurfaceXcb;
125#endif // VK_USE_PLATFORM_XCB_KHR
126
127#ifdef VK_USE_PLATFORM_XLIB_KHR
Mark Lobodzinski2b46a9d2016-05-19 17:17:58 -0600128typedef struct {
Karl Schultz37419ed2016-02-02 12:32:50 -0700129 VkIcdSurfaceBase base;
130 Display *dpy;
131 Window window;
Ian Elliott4d520542015-11-18 12:19:12 -0700132} VkIcdSurfaceXlib;
133#endif // VK_USE_PLATFORM_XLIB_KHR
134
Cody Northropfa2f36c2016-09-22 14:39:16 -0600135#ifdef VK_USE_PLATFORM_ANDROID_KHR
136typedef struct {
137 ANativeWindow* window;
138} VkIcdSurfaceAndroid;
139#endif //VK_USE_PLATFORM_ANDROID_KHR
140
Mark Lobodzinski2b46a9d2016-05-19 17:17:58 -0600141typedef struct {
Jon Ashburnc7d3e732016-03-08 09:30:30 -0700142 VkIcdSurfaceBase base;
143 VkDisplayModeKHR displayMode;
144 uint32_t planeIndex;
145 uint32_t planeStackIndex;
146 VkSurfaceTransformFlagBitsKHR transform;
147 float globalAlpha;
148 VkDisplayPlaneAlphaFlagBitsKHR alphaMode;
149 VkExtent2D imageExtent;
150} VkIcdSurfaceDisplay;
Mark Young16573c72016-06-28 10:52:43 -0600151
Courtney Goeltzenleuchter64d1a712015-04-08 18:04:29 -0600152#endif // VKICD_H