2 // File: vk_ext_khr_device_swapchain.h
5 ** Copyright (c) 2015 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_EXT_KHR_DEVICE_SWAPCHAIN_H__
28 #define __VK_EXT_KHR_DEVICE_SWAPCHAIN_H__
32 #define VK_EXT_KHR_DEVICE_SWAPCHAIN_REVISION 53
33 #define VK_EXT_KHR_DEVICE_SWAPCHAIN_EXTENSION_NUMBER 2
34 #define VK_EXT_KHR_DEVICE_SWAPCHAIN_EXTENSION_NAME "VK_EXT_KHR_device_swapchain"
41 // ------------------------------------------------------------------------------------------------
44 VK_DEFINE_NON_DISPATCHABLE_HANDLE(VkSwapchainKHR
);
46 // ------------------------------------------------------------------------------------------------
47 // Enumeration constants
49 #define VK_EXT_KHR_DEVICE_SWAPCHAIN_ENUM(type,id) ((type)((int)0xc0000000 - VK_EXT_KHR_DEVICE_SWAPCHAIN_EXTENSION_NUMBER * -1024 + (id)))
50 #define VK_EXT_KHR_DEVICE_SWAPCHAIN_ENUM_POSITIVE(type,id) ((type)((int)0x40000000 + (VK_EXT_KHR_DEVICE_SWAPCHAIN_EXTENSION_NUMBER - 1) * 1024 + (id)))
52 // Extend VkStructureType enum with extension specific constants
53 #define VK_STRUCTURE_TYPE_SWAPCHAIN_CREATE_INFO_KHR VK_EXT_KHR_DEVICE_SWAPCHAIN_ENUM(VkStructureType, 0)
54 #define VK_STRUCTURE_TYPE_PRESENT_INFO_KHR VK_EXT_KHR_DEVICE_SWAPCHAIN_ENUM(VkStructureType, 1)
56 // Extend VkImageLayout enum with extension specific constants
57 #define VK_IMAGE_LAYOUT_PRESENT_SOURCE_KHR VK_EXT_KHR_DEVICE_SWAPCHAIN_ENUM(VkImageLayout, 2)
59 // Extend VkResult enum with extension specific constants
60 // Return codes for successful operation execution
61 #define VK_SUBOPTIMAL_KHR VK_EXT_KHR_DEVICE_SWAPCHAIN_ENUM_POSITIVE(VkResult, 3)
63 #define VK_ERROR_OUT_OF_DATE_KHR VK_EXT_KHR_DEVICE_SWAPCHAIN_ENUM(VkResult, 4)
65 // ------------------------------------------------------------------------------------------------
69 VK_PRESENT_MODE_IMMEDIATE_KHR
= 0,
70 VK_PRESENT_MODE_MAILBOX_KHR
= 1,
71 VK_PRESENT_MODE_FIFO_KHR
= 2,
72 VK_PRESENT_MODE_BEGIN_RANGE_KHR
= VK_PRESENT_MODE_IMMEDIATE_KHR
,
73 VK_PRESENT_MODE_END_RANGE_KHR
= VK_PRESENT_MODE_FIFO_KHR
,
74 VK_PRESENT_MODE_NUM
= (VK_PRESENT_MODE_FIFO_KHR
- VK_PRESENT_MODE_IMMEDIATE_KHR
+ 1),
75 VK_PRESENT_MODE_MAX_ENUM_KHR
= 0x7FFFFFFF
79 VK_COLORSPACE_SRGB_NONLINEAR_KHR
= 0x00000000,
80 VK_COLORSPACE_NUM
= (VK_COLORSPACE_SRGB_NONLINEAR_KHR
- VK_COLORSPACE_SRGB_NONLINEAR_KHR
+ 1),
81 VK_COLORSPACE_MAX_ENUM_KHR
= 0x7FFFFFFF
84 // ------------------------------------------------------------------------------------------------
87 // ------------------------------------------------------------------------------------------------
91 uint32_t minImageCount
; // Supported minimum number of images for the surface
92 uint32_t maxImageCount
; // Supported maximum number of images for the surface, 0 for unlimited
94 VkExtent2D currentExtent
; // Current image width and height for the surface, (-1, -1) if undefined
95 VkExtent2D minImageExtent
; // Supported minimum image width and height for the surface
96 VkExtent2D maxImageExtent
; // Supported maximum image width and height for the surface
98 VkSurfaceTransformFlagsKHR supportedTransforms
;// 1 or more bits representing the transforms supported
99 VkSurfaceTransformKHR currentTransform
; // The surface's current transform relative to the device's natural orientation
101 uint32_t maxImageArraySize
; // Supported maximum number of image layers for the surface
103 VkImageUsageFlags supportedUsageFlags
;// Supported image usage flags for the surface
104 } VkSurfacePropertiesKHR
;
107 VkFormat format
; // Supported pair of rendering format
108 VkColorSpaceKHR colorSpace
; // and colorspace for the surface
109 } VkSurfaceFormatKHR
;
112 VkStructureType sType
; // Must be VK_STRUCTURE_TYPE_SWAPCHAIN_CREATE_INFO_KHR
113 const void* pNext
; // Pointer to next structure
115 const VkSurfaceDescriptionKHR
* pSurfaceDescription
;// describes the swap chain's target surface
117 uint32_t minImageCount
; // Minimum number of presentation images the application needs
118 VkFormat imageFormat
; // Format of the presentation images
119 VkColorSpaceKHR imageColorSpace
; // Colorspace of the presentation images
120 VkExtent2D imageExtent
; // Dimensions of the presentation images
121 VkImageUsageFlags imageUsageFlags
; // Bits indicating how the presentation images will be used
122 VkSurfaceTransformKHR preTransform
; // The transform, relative to the device's natural orientation, applied to the image content prior to presentation
123 uint32_t imageArraySize
; // Determines the number of views for multiview/stereo presentation
125 VkSharingMode sharingMode
; // Sharing mode used for the presentation images
126 uint32_t queueFamilyCount
; // Number of queue families having access to the images in case of concurrent sharing mode
127 const uint32_t* pQueueFamilyIndices
; // Array of queue family indices having access to the images in case of concurrent sharing mode
129 VkPresentModeKHR presentMode
; // Which presentation mode to use for presents on this swap chain
131 VkSwapchainKHR oldSwapchain
; // Existing swap chain to replace, if any
133 VkBool32 clipped
; // Specifies whether presentable images may be affected by window clip regions
134 } VkSwapchainCreateInfoKHR
;
137 VkStructureType sType
; // Must be VK_STRUCTURE_TYPE_PRESENT_INFO_KHR
138 const void* pNext
; // Pointer to next structure
139 uint32_t swapchainCount
; // Number of swap chains to present in this call
140 const VkSwapchainKHR
* swapchains
; // Swap chains to present an image from
141 const uint32_t* imageIndices
; // Indices of which swapchain images to present
144 // ------------------------------------------------------------------------------------------------
147 typedef VkResult (VKAPI_PTR
*PFN_vkGetSurfacePropertiesKHR
)(VkDevice device
, const VkSurfaceDescriptionKHR
* pSurfaceDescription
, VkSurfacePropertiesKHR
* pSurfaceProperties
);
148 typedef VkResult (VKAPI_PTR
*PFN_vkGetSurfaceFormatsKHR
)(VkDevice device
, const VkSurfaceDescriptionKHR
* pSurfaceDescription
, uint32_t* pCount
, VkSurfaceFormatKHR
* pSurfaceFormats
);
149 typedef VkResult (VKAPI_PTR
*PFN_vkGetSurfacePresentModesKHR
)(VkDevice device
, const VkSurfaceDescriptionKHR
* pSurfaceDescription
, uint32_t* pCount
, VkPresentModeKHR
* pPresentModes
);
150 typedef VkResult (VKAPI_PTR
*PFN_vkCreateSwapchainKHR
)(VkDevice device
, const VkSwapchainCreateInfoKHR
* pCreateInfo
, VkSwapchainKHR
* pSwapchain
);
151 typedef VkResult (VKAPI_PTR
*PFN_vkDestroySwapchainKHR
)(VkDevice device
, VkSwapchainKHR swapchain
);
152 typedef VkResult (VKAPI_PTR
*PFN_vkGetSwapchainImagesKHR
)(VkDevice device
, VkSwapchainKHR swapchain
, uint32_t* pCount
, VkImage
* pSwapchainImages
);
153 typedef VkResult (VKAPI_PTR
*PFN_vkAcquireNextImageKHR
)(VkDevice device
, VkSwapchainKHR swapchain
, uint64_t timeout
, VkSemaphore semaphore
, uint32_t* pImageIndex
);
154 typedef VkResult (VKAPI_PTR
*PFN_vkQueuePresentKHR
)(VkQueue queue
, VkPresentInfoKHR
* pPresentInfo
);
156 // ------------------------------------------------------------------------------------------------
157 // Function prototypes
161 VKAPI_ATTR VkResult VKAPI_CALL
vkGetSurfacePropertiesKHR(
163 const VkSurfaceDescriptionKHR
* pSurfaceDescription
,
164 VkSurfacePropertiesKHR
* pSurfaceProperties
);
166 VKAPI_ATTR VkResult VKAPI_CALL
vkGetSurfaceFormatsKHR(
168 const VkSurfaceDescriptionKHR
* pSurfaceDescription
,
170 VkSurfaceFormatKHR
* pSurfaceFormats
);
172 VKAPI_ATTR VkResult VKAPI_CALL
vkGetSurfacePresentModesKHR(
174 const VkSurfaceDescriptionKHR
* pSurfaceDescription
,
176 VkPresentModeKHR
* pPresentModes
);
178 VKAPI_ATTR VkResult VKAPI_CALL
vkCreateSwapchainKHR(
180 const VkSwapchainCreateInfoKHR
* pCreateInfo
,
181 VkSwapchainKHR
* pSwapchain
);
183 VKAPI_ATTR VkResult VKAPI_CALL
vkDestroySwapchainKHR(
185 VkSwapchainKHR swapchain
);
187 VKAPI_ATTR VkResult VKAPI_CALL
vkGetSwapchainImagesKHR(
189 VkSwapchainKHR swapchain
,
191 VkImage
* pSwapchainImages
);
193 VKAPI_ATTR VkResult VKAPI_CALL
vkAcquireNextImageKHR(
195 VkSwapchainKHR swapchain
,
197 VkSemaphore semaphore
,
198 uint32_t* pImageIndex
);
200 VKAPI_ATTR VkResult VKAPI_CALL
vkQueuePresentKHR(
202 VkPresentInfoKHR
* pPresentInfo
);
204 #endif // VK_PROTOTYPES
208 #endif // __cplusplus
210 #endif // __VK_EXT_KHR_SWAPCHAIN_H__