vk: Add the new extension/layer enumeration entrypoints
[mesa.git] / include / vulkan / vk_wsi_lunarg.h
1 //
2 // File: vk_wsi_display.h
3 //
4 /*
5 ** Copyright (c) 2014 The Khronos Group Inc.
6 **
7 ** Permission is hereby granted, free of charge, to any person obtaining a
8 ** copy of this software and/or associated documentation files (the
9 ** "Materials"), to deal in the Materials without restriction, including
10 ** without limitation the rights to use, copy, modify, merge, publish,
11 ** distribute, sublicense, and/or sell copies of the Materials, and to
12 ** permit persons to whom the Materials are furnished to do so, subject to
13 ** the following conditions:
14 **
15 ** The above copyright notice and this permission notice shall be included
16 ** in all copies or substantial portions of the Materials.
17 **
18 ** THE MATERIALS ARE PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
19 ** EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
20 ** MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
21 ** IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
22 ** CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
23 ** TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
24 ** MATERIALS OR THE USE OR OTHER DEALINGS IN THE MATERIALS.
25 */
26
27 #ifndef __VK_WSI_LUNARG_H__
28 #define __VK_WSI_LUNARG_H__
29
30 #include "vulkan.h"
31
32 #define VK_WSI_LUNARG_REVISION 3
33 #define VK_WSI_LUNARG_EXTENSION_NUMBER 1
34
35 #ifdef __cplusplus
36 extern "C"
37 {
38 #endif // __cplusplus
39
40 // This macro defines INT_MAX in enumerations to force compilers to use 32 bits
41 // to represent them. This may or may not be necessary on some compilers. The
42 // option to compile it out may allow compilers that warn about missing enumerants
43 // in switch statements to be silenced.
44 // Using this macro is not needed for flag bit enums because those aren't used
45 // as storage type anywhere.
46 #define VK_MAX_ENUM(Prefix) VK_##Prefix##_MAX_ENUM = 0x7FFFFFFF
47
48 // This macro defines the BEGIN_RANGE, END_RANGE, NUM, and MAX_ENUM constants for
49 // the enumerations.
50 #define VK_ENUM_RANGE(Prefix, First, Last) \
51 VK_##Prefix##_BEGIN_RANGE = VK_##Prefix##_##First, \
52 VK_##Prefix##_END_RANGE = VK_##Prefix##_##Last, \
53 VK_NUM_##Prefix = (VK_##Prefix##_END_RANGE - VK_##Prefix##_BEGIN_RANGE + 1), \
54 VK_MAX_ENUM(Prefix)
55
56 // This is a helper macro to define the value of flag bit enum values.
57 #define VK_BIT(bit) (1 << (bit))
58
59 // ------------------------------------------------------------------------------------------------
60 // Objects
61
62 VK_DEFINE_DISP_SUBCLASS_HANDLE(VkDisplayWSI, VkObject)
63 VK_DEFINE_DISP_SUBCLASS_HANDLE(VkSwapChainWSI, VkObject)
64
65 // ------------------------------------------------------------------------------------------------
66 // Enumeration constants
67
68 #define VK_WSI_LUNARG_ENUM(type,id) ((type)(VK_WSI_LUNARG_EXTENSION_NUMBER * -1000 + (id)))
69
70 // Extend VkPhysicalDeviceInfoType enum with extension specific constants
71 #define VK_PHYSICAL_DEVICE_INFO_TYPE_DISPLAY_PROPERTIES_WSI VK_WSI_LUNARG_ENUM(VkPhysicalDeviceInfoType, 0)
72 #define VK_PHYSICAL_DEVICE_INFO_TYPE_QUEUE_PRESENT_PROPERTIES_WSI VK_WSI_LUNARG_ENUM(VkPhysicalDeviceInfoType, 1)
73
74 // Extend VkStructureType enum with extension specific constants
75 #define VK_STRUCTURE_TYPE_SWAP_CHAIN_CREATE_INFO_WSI VK_WSI_LUNARG_ENUM(VkStructureType, 0)
76 #define VK_STRUCTURE_TYPE_PRESENT_INFO_WSI VK_WSI_LUNARG_ENUM(VkStructureType, 1)
77
78 // Extend VkImageLayout enum with extension specific constants
79 #define VK_IMAGE_LAYOUT_PRESENT_SOURCE_WSI VK_WSI_LUNARG_ENUM(VkImageLayout, 0)
80
81 // Extend VkObjectType enum for new objects
82 #define VK_OBJECT_TYPE_DISPLAY_WSI VK_WSI_LUNARG_ENUM(VkObjectType, 0)
83 #define VK_OBJECT_TYPE_SWAP_CHAIN_WSI VK_WSI_LUNARG_ENUM(VkObjectType, 1)
84
85 // ------------------------------------------------------------------------------------------------
86 // Enumerations
87
88 typedef enum VkDisplayInfoTypeWSI_
89 {
90 // Info type for vkGetDisplayInfo()
91 VK_DISPLAY_INFO_TYPE_FORMAT_PROPERTIES_WSI = 0x00000003, // Return the VkFormat(s) supported for swap chains with the display
92
93 VK_ENUM_RANGE(DISPLAY_INFO_TYPE, FORMAT_PROPERTIES_WSI, FORMAT_PROPERTIES_WSI)
94 } VkDisplayInfoTypeWSI;
95
96 typedef enum VkSwapChainInfoTypeWSI_
97 {
98 // Info type for vkGetSwapChainInfo()
99 VK_SWAP_CHAIN_INFO_TYPE_PERSISTENT_IMAGES_WSI = 0x00000000, // Return information about the persistent images of the swapchain
100
101 VK_ENUM_RANGE(SWAP_CHAIN_INFO_TYPE, PERSISTENT_IMAGES_WSI, PERSISTENT_IMAGES_WSI)
102 } VkSwapChainInfoTypeWSI;
103
104 // ------------------------------------------------------------------------------------------------
105 // Flags
106
107 typedef VkFlags VkSwapModeFlagsWSI;
108 typedef enum VkSwapModeFlagBitsWSI_
109 {
110 VK_SWAP_MODE_FLIP_BIT_WSI = VK_BIT(0),
111 VK_SWAP_MODE_BLIT_BIT_WSI = VK_BIT(1),
112 } VkSwapModeFlagBitsWSI;
113
114 // ------------------------------------------------------------------------------------------------
115 // Structures
116
117 typedef struct VkDisplayPropertiesWSI_
118 {
119 VkDisplayWSI display; // Handle of the display object
120 VkExtent2D physicalResolution; // Max resolution for CRT?
121 } VkDisplayPropertiesWSI;
122
123 typedef struct VkDisplayFormatPropertiesWSI_
124 {
125 VkFormat swapChainFormat; // Format of the images of the swap chain
126 } VkDisplayFormatPropertiesWSI;
127
128 typedef struct VkSwapChainCreateInfoWSI_
129 {
130 VkStructureType sType; // Must be VK_STRUCTURE_TYPE_SWAP_CHAIN_CREATE_INFO_WSI
131 const void* pNext; // Pointer to next structure
132
133 // TBD: It is not yet clear what the use will be for the following two
134 // values. It seems to be needed for more-global window-system handles
135 // (e.g. X11 display). If not needed for the SDK, we will drop it from
136 // this extension, and from a future version of this header.
137 const void* pNativeWindowSystemHandle; // Pointer to native window system handle
138 const void* pNativeWindowHandle; // Pointer to native window handle
139
140 uint32_t displayCount; // Number of displays the swap chain is created for
141 const VkDisplayWSI* pDisplays; // displayCount number of display objects the swap chain is created for
142
143 uint32_t imageCount; // Number of images in the swap chain
144
145 VkFormat imageFormat; // Format of the images of the swap chain
146 VkExtent2D imageExtent; // Width and height of the images of the swap chain
147 uint32_t imageArraySize; // Number of layers of the images of the swap chain (needed for multi-view rendering)
148 VkFlags imageUsageFlags; // Usage flags for the images of the swap chain (see VkImageUsageFlags)
149
150 VkFlags swapModeFlags; // Allowed swap modes (see VkSwapModeFlagsWSI)
151 } VkSwapChainCreateInfoWSI;
152
153 typedef struct VkSwapChainImageInfoWSI_
154 {
155 VkImage image; // Persistent swap chain image handle
156 VkDeviceMemory memory; // Persistent swap chain image's memory handle
157 } VkSwapChainImageInfoWSI;
158
159 typedef struct VkPhysicalDeviceQueuePresentPropertiesWSI_
160 {
161 VkBool32 supportsPresent; // Tells whether the queue supports presenting
162 } VkPhysicalDeviceQueuePresentPropertiesWSI;
163
164 typedef struct VkPresentInfoWSI_
165 {
166 VkStructureType sType; // Must be VK_STRUCTURE_TYPE_PRESENT_INFO_WSI
167 const void* pNext; // Pointer to next structure
168 VkImage image; // Image to present
169 uint32_t flipInterval; // Flip interval
170 } VkPresentInfoWSI;
171
172 // ------------------------------------------------------------------------------------------------
173 // Function types
174
175 typedef VkResult (VKAPI *PFN_vkGetDisplayInfoWSI)(VkDisplayWSI display, VkDisplayInfoTypeWSI infoType, size_t* pDataSize, void* pData);
176 typedef VkResult (VKAPI *PFN_vkCreateSwapChainWSI)(VkDevice device, const VkSwapChainCreateInfoWSI* pCreateInfo, VkSwapChainWSI* pSwapChain);
177 typedef VkResult (VKAPI *PFN_vkDestroySwapChainWSI)(VkSwapChainWSI swapChain);
178 typedef VkResult (VKAPI *PFN_vkGetSwapChainInfoWSI)(VkSwapChainWSI swapChain, VkSwapChainInfoTypeWSI infoType, size_t* pDataSize, void* pData);
179 typedef VkResult (VKAPI *PFN_vkQueuePresentWSI)(VkQueue queue, const VkPresentInfoWSI* pPresentInfo);
180
181 // ------------------------------------------------------------------------------------------------
182 // Function prototypes
183
184 #ifdef VK_PROTOTYPES
185
186 VkResult VKAPI vkGetDisplayInfoWSI(
187 VkDisplayWSI display,
188 VkDisplayInfoTypeWSI infoType,
189 size_t* pDataSize,
190 void* pData);
191
192 VkResult VKAPI vkCreateSwapChainWSI(
193 VkDevice device,
194 const VkSwapChainCreateInfoWSI* pCreateInfo,
195 VkSwapChainWSI* pSwapChain);
196
197 VkResult VKAPI vkDestroySwapChainWSI(
198 VkSwapChainWSI swapChain);
199
200 VkResult VKAPI vkGetSwapChainInfoWSI(
201 VkSwapChainWSI swapChain,
202 VkSwapChainInfoTypeWSI infoType,
203 size_t* pDataSize,
204 void* pData);
205
206 VkResult VKAPI vkQueuePresentWSI(
207 VkQueue queue,
208 const VkPresentInfoWSI* pPresentInfo);
209
210 #endif // VK_PROTOTYPES
211
212 #ifdef __cplusplus
213 } // extern "C"
214 #endif // __cplusplus
215
216 #endif // __VK_WSI_LUNARG_H__