vk/0.210.0: Rework QueueFamilyProperties
[mesa.git] / include / vulkan / vk_ext_khr_device_swapchain.h
1 //
2 // File: vk_ext_khr_device_swapchain.h
3 //
4 /*
5 ** Copyright (c) 2015 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_EXT_KHR_DEVICE_SWAPCHAIN_H__
28 #define __VK_EXT_KHR_DEVICE_SWAPCHAIN_H__
29
30 #include "vulkan.h"
31
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"
35
36 #ifdef __cplusplus
37 extern "C"
38 {
39 #endif // __cplusplus
40
41 // ------------------------------------------------------------------------------------------------
42 // Objects
43
44 VK_DEFINE_NON_DISPATCHABLE_HANDLE(VkSwapchainKHR);
45
46 // ------------------------------------------------------------------------------------------------
47 // Enumeration constants
48
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)))
51
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)
55
56 // Extend VkImageLayout enum with extension specific constants
57 #define VK_IMAGE_LAYOUT_PRESENT_SOURCE_KHR VK_EXT_KHR_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_KHR VK_EXT_KHR_DEVICE_SWAPCHAIN_ENUM_POSITIVE(VkResult, 3)
62 // Error codes
63 #define VK_ERROR_OUT_OF_DATE_KHR VK_EXT_KHR_DEVICE_SWAPCHAIN_ENUM(VkResult, 4)
64
65 // ------------------------------------------------------------------------------------------------
66 // Enumerations
67
68 typedef enum {
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
76 } VkPresentModeKHR;
77
78 typedef enum {
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
82 } VkColorSpaceKHR;
83
84 // ------------------------------------------------------------------------------------------------
85 // Flags
86
87 // ------------------------------------------------------------------------------------------------
88 // Structures
89
90 typedef struct {
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
93
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
97
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
100
101 uint32_t maxImageArraySize; // Supported maximum number of image layers for the surface
102
103 VkImageUsageFlags supportedUsageFlags;// Supported image usage flags for the surface
104 } VkSurfacePropertiesKHR;
105
106 typedef struct {
107 VkFormat format; // Supported pair of rendering format
108 VkColorSpaceKHR colorSpace; // and colorspace for the surface
109 } VkSurfaceFormatKHR;
110
111 typedef struct {
112 VkStructureType sType; // Must be VK_STRUCTURE_TYPE_SWAPCHAIN_CREATE_INFO_KHR
113 const void* pNext; // Pointer to next structure
114
115 const VkSurfaceDescriptionKHR* pSurfaceDescription;// describes the swap chain's target surface
116
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
124
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
128
129 VkPresentModeKHR presentMode; // Which presentation mode to use for presents on this swap chain
130
131 VkSwapchainKHR oldSwapchain; // Existing swap chain to replace, if any
132
133 VkBool32 clipped; // Specifies whether presentable images may be affected by window clip regions
134 } VkSwapchainCreateInfoKHR;
135
136 typedef struct {
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
142 } VkPresentInfoKHR;
143
144 // ------------------------------------------------------------------------------------------------
145 // Function types
146
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);
155
156 // ------------------------------------------------------------------------------------------------
157 // Function prototypes
158
159 #ifdef VK_PROTOTYPES
160
161 VKAPI_ATTR VkResult VKAPI_CALL vkGetSurfacePropertiesKHR(
162 VkDevice device,
163 const VkSurfaceDescriptionKHR* pSurfaceDescription,
164 VkSurfacePropertiesKHR* pSurfaceProperties);
165
166 VKAPI_ATTR VkResult VKAPI_CALL vkGetSurfaceFormatsKHR(
167 VkDevice device,
168 const VkSurfaceDescriptionKHR* pSurfaceDescription,
169 uint32_t* pCount,
170 VkSurfaceFormatKHR* pSurfaceFormats);
171
172 VKAPI_ATTR VkResult VKAPI_CALL vkGetSurfacePresentModesKHR(
173 VkDevice device,
174 const VkSurfaceDescriptionKHR* pSurfaceDescription,
175 uint32_t* pCount,
176 VkPresentModeKHR* pPresentModes);
177
178 VKAPI_ATTR VkResult VKAPI_CALL vkCreateSwapchainKHR(
179 VkDevice device,
180 const VkSwapchainCreateInfoKHR* pCreateInfo,
181 VkSwapchainKHR* pSwapchain);
182
183 VKAPI_ATTR VkResult VKAPI_CALL vkDestroySwapchainKHR(
184 VkDevice device,
185 VkSwapchainKHR swapchain);
186
187 VKAPI_ATTR VkResult VKAPI_CALL vkGetSwapchainImagesKHR(
188 VkDevice device,
189 VkSwapchainKHR swapchain,
190 uint32_t* pCount,
191 VkImage* pSwapchainImages);
192
193 VKAPI_ATTR VkResult VKAPI_CALL vkAcquireNextImageKHR(
194 VkDevice device,
195 VkSwapchainKHR swapchain,
196 uint64_t timeout,
197 VkSemaphore semaphore,
198 uint32_t* pImageIndex);
199
200 VKAPI_ATTR VkResult VKAPI_CALL vkQueuePresentKHR(
201 VkQueue queue,
202 VkPresentInfoKHR* pPresentInfo);
203
204 #endif // VK_PROTOTYPES
205
206 #ifdef __cplusplus
207 } // extern "C"
208 #endif // __cplusplus
209
210 #endif // __VK_EXT_KHR_SWAPCHAIN_H__