2 // File: vk_wsi_display.h
5 ** Copyright (c) 2014 The Khronos Group Inc.
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:
15 ** The above copyright notice and this permission notice shall be included
16 ** in all copies or substantial portions of the Materials.
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.
27 #ifndef __VK_WSI_LUNARG_H__
28 #define __VK_WSI_LUNARG_H__
32 #define VK_WSI_LUNARG_REVISION 3
33 #define VK_WSI_LUNARG_EXTENSION_NUMBER 1
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
48 // This macro defines the BEGIN_RANGE, END_RANGE, NUM, and MAX_ENUM constants for
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), \
56 // This is a helper macro to define the value of flag bit enum values.
57 #define VK_BIT(bit) (1 << (bit))
59 // ------------------------------------------------------------------------------------------------
62 VK_DEFINE_DISP_SUBCLASS_HANDLE(VkDisplayWSI
, VkObject
)
63 VK_DEFINE_DISP_SUBCLASS_HANDLE(VkSwapChainWSI
, VkObject
)
65 // ------------------------------------------------------------------------------------------------
66 // Enumeration constants
68 #define VK_WSI_LUNARG_ENUM(type,id) ((type)(VK_WSI_LUNARG_EXTENSION_NUMBER * -1000 + (id)))
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)
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)
78 // Extend VkImageLayout enum with extension specific constants
79 #define VK_IMAGE_LAYOUT_PRESENT_SOURCE_WSI VK_WSI_LUNARG_ENUM(VkImageLayout, 0)
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)
85 // ------------------------------------------------------------------------------------------------
88 typedef enum VkDisplayInfoTypeWSI_
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
93 VK_ENUM_RANGE(DISPLAY_INFO_TYPE
, FORMAT_PROPERTIES_WSI
, FORMAT_PROPERTIES_WSI
)
94 } VkDisplayInfoTypeWSI
;
96 typedef enum VkSwapChainInfoTypeWSI_
98 // Info type for vkGetSwapChainInfo()
99 VK_SWAP_CHAIN_INFO_TYPE_PERSISTENT_IMAGES_WSI
= 0x00000000, // Return information about the persistent images of the swapchain
101 VK_ENUM_RANGE(SWAP_CHAIN_INFO_TYPE
, PERSISTENT_IMAGES_WSI
, PERSISTENT_IMAGES_WSI
)
102 } VkSwapChainInfoTypeWSI
;
104 // ------------------------------------------------------------------------------------------------
107 typedef VkFlags VkSwapModeFlagsWSI
;
108 typedef enum VkSwapModeFlagBitsWSI_
110 VK_SWAP_MODE_FLIP_BIT_WSI
= VK_BIT(0),
111 VK_SWAP_MODE_BLIT_BIT_WSI
= VK_BIT(1),
112 } VkSwapModeFlagBitsWSI
;
114 // ------------------------------------------------------------------------------------------------
117 typedef struct VkDisplayPropertiesWSI_
119 VkDisplayWSI display
; // Handle of the display object
120 VkExtent2D physicalResolution
; // Max resolution for CRT?
121 } VkDisplayPropertiesWSI
;
123 typedef struct VkDisplayFormatPropertiesWSI_
125 VkFormat swapChainFormat
; // Format of the images of the swap chain
126 } VkDisplayFormatPropertiesWSI
;
128 typedef struct VkSwapChainCreateInfoWSI_
130 VkStructureType sType
; // Must be VK_STRUCTURE_TYPE_SWAP_CHAIN_CREATE_INFO_WSI
131 const void* pNext
; // Pointer to next structure
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
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
143 uint32_t imageCount
; // Number of images in the swap chain
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)
150 VkFlags swapModeFlags
; // Allowed swap modes (see VkSwapModeFlagsWSI)
151 } VkSwapChainCreateInfoWSI
;
153 typedef struct VkSwapChainImageInfoWSI_
155 VkImage image
; // Persistent swap chain image handle
156 VkDeviceMemory memory
; // Persistent swap chain image's memory handle
157 } VkSwapChainImageInfoWSI
;
159 typedef struct VkPhysicalDeviceQueuePresentPropertiesWSI_
161 VkBool32 supportsPresent
; // Tells whether the queue supports presenting
162 } VkPhysicalDeviceQueuePresentPropertiesWSI
;
164 typedef struct VkPresentInfoWSI_
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
172 // ------------------------------------------------------------------------------------------------
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
);
181 // ------------------------------------------------------------------------------------------------
182 // Function prototypes
186 VkResult VKAPI
vkGetDisplayInfoWSI(
187 VkDisplayWSI display
,
188 VkDisplayInfoTypeWSI infoType
,
192 VkResult VKAPI
vkCreateSwapChainWSI(
194 const VkSwapChainCreateInfoWSI
* pCreateInfo
,
195 VkSwapChainWSI
* pSwapChain
);
197 VkResult VKAPI
vkDestroySwapChainWSI(
198 VkSwapChainWSI swapChain
);
200 VkResult VKAPI
vkGetSwapChainInfoWSI(
201 VkSwapChainWSI swapChain
,
202 VkSwapChainInfoTypeWSI infoType
,
206 VkResult VKAPI
vkQueuePresentWSI(
208 const VkPresentInfoWSI
* pPresentInfo
);
210 #endif // VK_PROTOTYPES
214 #endif // __cplusplus
216 #endif // __VK_WSI_LUNARG_H__