| Ian Elliott | 8aca839 | 2015-06-19 17:19:39 -0600 | [diff] [blame] | 1 | // |
| 2 | // File: vk_wsi_device_swapchain.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_DEVICE_SWAPCHAIN_H__ |
| 28 | #define __VK_WSI_DEVICE_SWAPCHAIN_H__ |
| 29 | |
| 30 | #include "vulkan.h" |
| 31 | |
| 32 | #define VK_WSI_DEVICE_SWAPCHAIN_REVISION 40 |
| 33 | #define VK_WSI_DEVICE_SWAPCHAIN_EXTENSION_NUMBER 2 |
| 34 | #define VK_WSI_DEVICE_SWAPCHAIN_EXTENSION_NAME "VK_WSI_device_swapchain" |
| 35 | |
| 36 | #ifdef __cplusplus |
| 37 | extern "C" |
| 38 | { |
| 39 | #endif // __cplusplus |
| 40 | |
| 41 | // ------------------------------------------------------------------------------------------------ |
| 42 | // Objects |
| 43 | |
| 44 | VK_DEFINE_NONDISP_HANDLE(VkSwapChainWSI); |
| 45 | |
| 46 | // ------------------------------------------------------------------------------------------------ |
| 47 | // Enumeration constants |
| 48 | |
| 49 | #define VK_WSI_DEVICE_SWAPCHAIN_ENUM(type,id) ((type)((int)0xc0000000 - VK_WSI_DEVICE_SWAPCHAIN_EXTENSION_NUMBER * -1024 + (id))) |
| 50 | #define VK_WSI_DEVICE_SWAPCHAIN_ENUM_POSITIVE(type,id) ((type)((int)0x40000000 + (VK_WSI_DEVICE_SWAPCHAIN_EXTENSION_NUMBER - 1) * 1024 + (id))) |
| 51 | |
| 52 | // Extend VkStructureType enum with extension specific constants |
| 53 | #define VK_STRUCTURE_TYPE_SWAP_CHAIN_CREATE_INFO_WSI VK_WSI_DEVICE_SWAPCHAIN_ENUM(VkStructureType, 0) |
| 54 | #define VK_STRUCTURE_TYPE_QUEUE_PRESENT_INFO_WSI VK_WSI_DEVICE_SWAPCHAIN_ENUM(VkStructureType, 1) |
| 55 | |
| 56 | // Extend VkImageLayout enum with extension specific constants |
| 57 | #define VK_IMAGE_LAYOUT_PRESENT_SOURCE_WSI VK_WSI_DEVICE_SWAPCHAIN_ENUM(VkImageLayout, 2) |
| 58 | |
| 59 | // Extend VkResult enum with extension specific constants |
| 60 | // Return codes for successful operation execution |
| 61 | #define VK_SUBOPTIMAL_WSI VK_WSI_DEVICE_SWAPCHAIN_ENUM_POSITIVE(VkResult, 3) |
| 62 | // Error codes |
| 63 | #define VK_ERROR_OUT_OF_DATE_WSI VK_WSI_DEVICE_SWAPCHAIN_ENUM(VkResult, 4) |
| 64 | |
| 65 | // ------------------------------------------------------------------------------------------------ |
| 66 | // Enumerations |
| 67 | |
| 68 | typedef enum VkSurfaceTransformWSI_ |
| 69 | { |
| 70 | VK_SURFACE_TRANSFORM_NONE_WSI = 0, |
| 71 | VK_SURFACE_TRANSFORM_ROT90_WSI = 1, |
| 72 | VK_SURFACE_TRANSFORM_ROT180_WSI = 2, |
| 73 | VK_SURFACE_TRANSFORM_ROT270_WSI = 3, |
| 74 | VK_SURFACE_TRANSFORM_HMIRROR_WSI = 4, |
| 75 | VK_SURFACE_TRANSFORM_HMIRROR_ROT90_WSI = 5, |
| 76 | VK_SURFACE_TRANSFORM_HMIRROR_ROT180_WSI = 6, |
| 77 | VK_SURFACE_TRANSFORM_HMIRROR_ROT270_WSI = 7, |
| 78 | VK_SURFACE_TRANSFORM_INHERIT_WSI = 8, |
| 79 | } VkSurfaceTransformWSI; |
| 80 | |
| 81 | typedef enum VkSurfaceTransformFlagBitsWSI_ |
| 82 | { |
| 83 | VK_SURFACE_TRANSFORM_NONE_BIT_WSI = 0x00000001, |
| 84 | VK_SURFACE_TRANSFORM_ROT90_BIT_WSI = 0x00000002, |
| 85 | VK_SURFACE_TRANSFORM_ROT180_BIT_WSI = 0x00000004, |
| 86 | VK_SURFACE_TRANSFORM_ROT270_BIT_WSI = 0x00000008, |
| 87 | VK_SURFACE_TRANSFORM_HMIRROR_BIT_WSI = 0x00000010, |
| 88 | VK_SURFACE_TRANSFORM_HMIRROR_ROT90_BIT_WSI = 0x00000020, |
| 89 | VK_SURFACE_TRANSFORM_HMIRROR_ROT180_BIT_WSI = 0x00000040, |
| 90 | VK_SURFACE_TRANSFORM_HMIRROR_ROT270_BIT_WSI = 0x00000080, |
| 91 | VK_SURFACE_TRANSFORM_INHERIT_BIT_WSI = 0x00000100, |
| 92 | } VkSurfaceTransformFlagBitsWSI; |
| 93 | typedef VkFlags VkSurfaceTransformFlagsWSI; |
| 94 | |
| 95 | typedef enum VkSurfaceInfoTypeWSI_ |
| 96 | { |
| 97 | VK_SURFACE_INFO_TYPE_PROPERTIES_WSI = 0, |
| 98 | VK_SURFACE_INFO_TYPE_FORMATS_WSI = 1, |
| 99 | VK_SURFACE_INFO_TYPE_PRESENT_MODES_WSI = 2, |
| 100 | VK_SURFACE_INFO_TYPE_BEGIN_RANGE_WSI = VK_SURFACE_INFO_TYPE_PROPERTIES_WSI, |
| 101 | VK_SURFACE_INFO_TYPE_END_RANGE_WSI = VK_SURFACE_INFO_TYPE_PRESENT_MODES_WSI, |
| 102 | VK_SURFACE_INFO_TYPE_NUM_WSI = (VK_SURFACE_INFO_TYPE_PRESENT_MODES_WSI - VK_SURFACE_INFO_TYPE_PROPERTIES_WSI + 1), |
| 103 | VK_SURFACE_INFO_TYPE_MAX_ENUM_WSI = 0x7FFFFFFF |
| 104 | } VkSurfaceInfoTypeWSI; |
| 105 | |
| 106 | typedef enum VkSwapChainInfoTypeWSI_ |
| 107 | { |
| 108 | VK_SWAP_CHAIN_INFO_TYPE_IMAGES_WSI = 0, |
| 109 | VK_SWAP_CHAIN_INFO_TYPE_BEGIN_RANGE_WSI = VK_SWAP_CHAIN_INFO_TYPE_IMAGES_WSI, |
| 110 | VK_SWAP_CHAIN_INFO_TYPE_END_RANGE_WSI = VK_SWAP_CHAIN_INFO_TYPE_IMAGES_WSI, |
| 111 | VK_SWAP_CHAIN_INFO_TYPE_NUM_WSI = (VK_SWAP_CHAIN_INFO_TYPE_IMAGES_WSI - VK_SWAP_CHAIN_INFO_TYPE_IMAGES_WSI + 1), |
| 112 | VK_SWAP_CHAIN_INFO_TYPE_MAX_ENUM_WSI = 0x7FFFFFFF |
| 113 | } VkSwapChainInfoTypeWSI; |
| 114 | |
| 115 | typedef enum VkPresentModeWSI_ |
| 116 | { |
| 117 | VK_PRESENT_MODE_IMMEDIATE_WSI = 0, |
| 118 | VK_PRESENT_MODE_MAILBOX_WSI = 1, |
| 119 | VK_PRESENT_MODE_FIFO_WSI = 2, |
| 120 | VK_PRESENT_MODE_BEGIN_RANGE_WSI = VK_PRESENT_MODE_IMMEDIATE_WSI, |
| 121 | VK_PRESENT_MODE_END_RANGE_WSI = VK_PRESENT_MODE_FIFO_WSI, |
| 122 | VK_PRESENT_MODE_NUM = (VK_PRESENT_MODE_FIFO_WSI - VK_PRESENT_MODE_IMMEDIATE_WSI + 1), |
| 123 | VK_PRESENT_MODE_MAX_ENUM_WSI = 0x7FFFFFFF |
| 124 | } VkPresentModeWSI; |
| 125 | |
| 126 | // ------------------------------------------------------------------------------------------------ |
| 127 | // Flags |
| 128 | |
| 129 | // ------------------------------------------------------------------------------------------------ |
| 130 | // Structures |
| 131 | |
| 132 | typedef struct VkSurfacePropertiesWSI_ |
| 133 | { |
| 134 | uint32_t minImageCount; // Supported minimum number of images for the surface |
| 135 | uint32_t maxImageCount; // Supported maximum number of images for the surface, 0 for unlimited |
| 136 | |
| 137 | VkExtent2D currentExtent; // Current image width and height for the surface, (-1, -1) if undefined. |
| 138 | VkExtent2D minImageExtent; // Supported minimum image width and height for the surface |
| 139 | VkExtent2D maxImageExtent; // Supported maximum image width and height for the surface |
| 140 | |
| 141 | VkSurfaceTransformFlagsWSI supportedTransforms;// 1 or more bits representing the transforms supported |
| 142 | VkSurfaceTransformWSI currentTransform; // The surface's current transform relative to the device's natural orientation. |
| 143 | |
| 144 | uint32_t maxImageArraySize; // Supported maximum number of image layers for the surface |
| 145 | |
| 146 | VkImageUsageFlags supportedUsageFlags;// Supported image usage flags for the surface |
| 147 | } VkSurfacePropertiesWSI; |
| 148 | |
| 149 | typedef struct VkSurfaceFormatPropertiesWSI_ |
| 150 | { |
| 151 | VkFormat format; // Supported rendering format for the surface |
| 152 | } VkSurfaceFormatPropertiesWSI; |
| 153 | |
| 154 | typedef struct VkSurfacePresentModePropertiesWSI_ |
| 155 | { |
| 156 | VkPresentModeWSI presentMode; // Supported presention mode for the surface |
| 157 | } VkSurfacePresentModePropertiesWSI; |
| 158 | |
| 159 | typedef struct VkSwapChainCreateInfoWSI_ |
| 160 | { |
| 161 | VkStructureType sType; // Must be VK_STRUCTURE_TYPE_SWAP_CHAIN_CREATE_INFO_WSI |
| 162 | const void* pNext; // Pointer to next structure |
| 163 | |
| 164 | const VkSurfaceDescriptionWSI* pSurfaceDescription;// describes the swap chain's target surface |
| 165 | |
| 166 | uint32_t minImageCount; // Minimum number of presentation images the application needs |
| 167 | VkFormat imageFormat; // Format of the presentation images |
| 168 | VkExtent2D imageExtent; // Dimensions of the presentation images |
| 169 | VkImageUsageFlags imageUsageFlags; // Bits indicating how the presentation images will be used |
| 170 | VkSurfaceTransformWSI preTransform; // The transform, relative to the device's natural orientation, applied to the image content prior to presentation |
| 171 | uint32_t imageArraySize; // Determines the number of views for multiview/stereo presentation |
| 172 | |
| 173 | VkPresentModeWSI presentMode; // Which presentation mode to use for presents on this swap chain. |
| 174 | |
| 175 | VkSwapChainWSI oldSwapChain; // Existing swap chain to replace, if any. |
| 176 | |
| 177 | VkBool32 clipped; // Specifies whether presentable images may be affected by window clip regions. |
| 178 | } VkSwapChainCreateInfoWSI; |
| 179 | |
| 180 | typedef struct VkSwapChainImagePropertiesWSI_ |
| 181 | { |
| 182 | VkImage image; // Persistent swap chain image handle |
| 183 | } VkSwapChainImagePropertiesWSI; |
| 184 | |
| 185 | typedef struct VkPresentInfoWSI_ |
| 186 | { |
| 187 | VkStructureType sType; // Must be VK_STRUCTURE_TYPE_QUEUE_PRESENT_INFO_WSI |
| 188 | const void* pNext; // Pointer to next structure |
| 189 | uint32_t swapChainCount; // Number of swap chains to present in this call |
| 190 | const VkSwapChainWSI* swapChains; // Swap chains to present an image from. |
| 191 | const uint32_t* imageIndices; // Indices of which swapChain images to present |
| 192 | } VkPresentInfoWSI; |
| 193 | |
| 194 | // ------------------------------------------------------------------------------------------------ |
| 195 | // Function types |
| 196 | |
| 197 | typedef VkResult (VKAPI *PFN_vkGetSurfaceInfoWSI)(VkDevice device, const VkSurfaceDescriptionWSI* pSurfaceDescription, VkSurfaceInfoTypeWSI infoType, size_t* pDataSize, void* pData); |
| 198 | typedef VkResult (VKAPI *PFN_vkCreateSwapChainWSI)(VkDevice device, const VkSwapChainCreateInfoWSI* pCreateInfo, VkSwapChainWSI* pSwapChain); |
| 199 | typedef VkResult (VKAPI *PFN_vkDestroySwapChainWSI)(VkDevice device, VkSwapChainWSI swapChain); |
| 200 | typedef VkResult (VKAPI *PFN_vkGetSwapChainInfoWSI)(VkDevice device, VkSwapChainWSI swapChain, VkSwapChainInfoTypeWSI infoType, size_t* pDataSize, void* pData); |
| 201 | typedef VkResult (VKAPI *PFN_vkAcquireNextImageWSI)(VkDevice device, VkSwapChainWSI swapChain, uint64_t timeout, VkSemaphore semaphore, uint32_t* pImageIndex); |
| 202 | typedef VkResult (VKAPI *PFN_vkQueuePresentWSI)(VkQueue queue, VkPresentInfoWSI* pPresentInfo); |
| 203 | |
| 204 | // ------------------------------------------------------------------------------------------------ |
| 205 | // Function prototypes |
| 206 | |
| 207 | #ifdef VK_PROTOTYPES |
| 208 | |
| 209 | VkResult VKAPI vkGetSurfaceInfoWSI( |
| 210 | VkDevice device, |
| 211 | const VkSurfaceDescriptionWSI* pSurfaceDescription, |
| 212 | VkSurfaceInfoTypeWSI infoType, |
| 213 | size_t* pDataSize, |
| 214 | void* pData); |
| 215 | |
| 216 | VkResult VKAPI vkCreateSwapChainWSI( |
| 217 | VkDevice device, |
| 218 | const VkSwapChainCreateInfoWSI* pCreateInfo, |
| 219 | VkSwapChainWSI* pSwapChain); |
| 220 | |
| 221 | VkResult VKAPI vkDestroySwapChainWSI( |
| 222 | VkDevice device, |
| 223 | VkSwapChainWSI swapChain); |
| 224 | |
| 225 | VkResult VKAPI vkGetSwapChainInfoWSI( |
| 226 | VkDevice device, |
| 227 | VkSwapChainWSI swapChain, |
| 228 | VkSwapChainInfoTypeWSI infoType, |
| 229 | size_t* pDataSize, |
| 230 | void* pData); |
| 231 | |
| 232 | VkResult VKAPI vkAcquireNextImageWSI( |
| 233 | VkDevice device, |
| 234 | VkSwapChainWSI swapChain, |
| 235 | uint64_t timeout, |
| 236 | VkSemaphore semaphore, |
| 237 | uint32_t* pImageIndex); |
| 238 | |
| 239 | VkResult VKAPI vkQueuePresentWSI( |
| 240 | VkQueue queue, |
| 241 | VkPresentInfoWSI* pPresentInfo); |
| 242 | |
| 243 | #endif // VK_PROTOTYPES |
| 244 | |
| 245 | #ifdef __cplusplus |
| 246 | } // extern "C" |
| 247 | #endif // __cplusplus |
| 248 | |
| 249 | #endif // __VK_WSI_SWAPCHAIN_H__ |