blob: a64936413dea33759672045b3332f924c36e4bbe [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"
Courtney Goeltzenleuchter64d1a712015-04-08 18:04:29 -060027
28/*
Jon Ashburn17b4c862016-04-25 11:09:37 -060029 * Loader-ICD version negotiation API
30 */
31#define CURRENT_LOADER_ICD_INTERFACE_VERSION 2
32#define MIN_SUPPORTED_LOADER_ICD_INTERFACE_VERSION 0
33typedef VkResult (VKAPI_PTR *PFN_vkNegotiateLoaderICDInterfaceVersion)(uint32_t *pVersion);
34/*
Courtney Goeltzenleuchter64d1a712015-04-08 18:04:29 -060035 * The ICD must reserve space for a pointer for the loader's dispatch
36 * table, at the start of <each object>.
37 * The ICD must initialize this variable using the SET_LOADER_MAGIC_VALUE macro.
38 */
39
Karl Schultz37419ed2016-02-02 12:32:50 -070040#define ICD_LOADER_MAGIC 0x01CDC0DE
Courtney Goeltzenleuchter64d1a712015-04-08 18:04:29 -060041
Mark Lobodzinski2b46a9d2016-05-19 17:17:58 -060042typedef union {
Karl Schultz37419ed2016-02-02 12:32:50 -070043 uintptr_t loaderMagic;
44 void *loaderData;
Courtney Goeltzenleuchter64d1a712015-04-08 18:04:29 -060045} VK_LOADER_DATA;
46
Karl Schultz37419ed2016-02-02 12:32:50 -070047static inline void set_loader_magic_value(void *pNewObject) {
48 VK_LOADER_DATA *loader_info = (VK_LOADER_DATA *)pNewObject;
Courtney Goeltzenleuchter64d1a712015-04-08 18:04:29 -060049 loader_info->loaderMagic = ICD_LOADER_MAGIC;
50}
51
Karl Schultz37419ed2016-02-02 12:32:50 -070052static inline bool valid_loader_magic_value(void *pNewObject) {
53 const VK_LOADER_DATA *loader_info = (VK_LOADER_DATA *)pNewObject;
Courtney Goeltzenleuchter2e991f82015-07-24 10:18:40 -060054 return (loader_info->loaderMagic & 0xffffffff) == ICD_LOADER_MAGIC;
Courtney Goeltzenleuchter64d1a712015-04-08 18:04:29 -060055}
56
Ian Elliott4d520542015-11-18 12:19:12 -070057/*
58 * Windows and Linux ICDs will treat VkSurfaceKHR as a pointer to a struct that
59 * contains the platform-specific connection and surface information.
60 */
Mark Lobodzinski2b46a9d2016-05-19 17:17:58 -060061typedef enum {
Ian Elliott4d520542015-11-18 12:19:12 -070062 VK_ICD_WSI_PLATFORM_MIR,
63 VK_ICD_WSI_PLATFORM_WAYLAND,
64 VK_ICD_WSI_PLATFORM_WIN32,
65 VK_ICD_WSI_PLATFORM_XCB,
66 VK_ICD_WSI_PLATFORM_XLIB,
Jon Ashburnc7d3e732016-03-08 09:30:30 -070067 VK_ICD_WSI_PLATFORM_DISPLAY
Ian Elliott4d520542015-11-18 12:19:12 -070068} VkIcdWsiPlatform;
69
Mark Lobodzinski2b46a9d2016-05-19 17:17:58 -060070typedef struct {
Karl Schultz37419ed2016-02-02 12:32:50 -070071 VkIcdWsiPlatform platform;
Ian Elliott4d520542015-11-18 12:19:12 -070072} VkIcdSurfaceBase;
73
74#ifdef VK_USE_PLATFORM_MIR_KHR
Mark Lobodzinski2b46a9d2016-05-19 17:17:58 -060075typedef struct {
Karl Schultz37419ed2016-02-02 12:32:50 -070076 VkIcdSurfaceBase base;
77 MirConnection *connection;
78 MirSurface *mirSurface;
Ian Elliott4d520542015-11-18 12:19:12 -070079} VkIcdSurfaceMir;
80#endif // VK_USE_PLATFORM_MIR_KHR
81
82#ifdef VK_USE_PLATFORM_WAYLAND_KHR
Mark Lobodzinski2b46a9d2016-05-19 17:17:58 -060083typedef struct {
Karl Schultz37419ed2016-02-02 12:32:50 -070084 VkIcdSurfaceBase base;
85 struct wl_display *display;
86 struct wl_surface *surface;
Ian Elliott4d520542015-11-18 12:19:12 -070087} VkIcdSurfaceWayland;
88#endif // VK_USE_PLATFORM_WAYLAND_KHR
89
90#ifdef VK_USE_PLATFORM_WIN32_KHR
Mark Lobodzinski2b46a9d2016-05-19 17:17:58 -060091typedef struct {
Karl Schultz37419ed2016-02-02 12:32:50 -070092 VkIcdSurfaceBase base;
93 HINSTANCE hinstance;
94 HWND hwnd;
Ian Elliott4d520542015-11-18 12:19:12 -070095} VkIcdSurfaceWin32;
96#endif // VK_USE_PLATFORM_WIN32_KHR
97
98#ifdef VK_USE_PLATFORM_XCB_KHR
Mark Lobodzinski2b46a9d2016-05-19 17:17:58 -060099typedef struct {
Karl Schultz37419ed2016-02-02 12:32:50 -0700100 VkIcdSurfaceBase base;
101 xcb_connection_t *connection;
102 xcb_window_t window;
Ian Elliott4d520542015-11-18 12:19:12 -0700103} VkIcdSurfaceXcb;
104#endif // VK_USE_PLATFORM_XCB_KHR
105
106#ifdef VK_USE_PLATFORM_XLIB_KHR
Mark Lobodzinski2b46a9d2016-05-19 17:17:58 -0600107typedef struct {
Karl Schultz37419ed2016-02-02 12:32:50 -0700108 VkIcdSurfaceBase base;
109 Display *dpy;
110 Window window;
Ian Elliott4d520542015-11-18 12:19:12 -0700111} VkIcdSurfaceXlib;
112#endif // VK_USE_PLATFORM_XLIB_KHR
113
Mark Lobodzinski2b46a9d2016-05-19 17:17:58 -0600114typedef struct {
Jon Ashburnc7d3e732016-03-08 09:30:30 -0700115 VkIcdSurfaceBase base;
116 VkDisplayModeKHR displayMode;
117 uint32_t planeIndex;
118 uint32_t planeStackIndex;
119 VkSurfaceTransformFlagBitsKHR transform;
120 float globalAlpha;
121 VkDisplayPlaneAlphaFlagBitsKHR alphaMode;
122 VkExtent2D imageExtent;
123} VkIcdSurfaceDisplay;
Courtney Goeltzenleuchter64d1a712015-04-08 18:04:29 -0600124#endif // VKICD_H