Ian Elliott | 2350cf8 | 2015-04-03 09:45:49 -0600 | [diff] [blame] | 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 | // ------------------------------------------------------------------------------------------------ |
| 41 | // Objects |
| 42 | |
Ian Elliott | 3a93185 | 2015-04-07 13:50:42 -0600 | [diff] [blame] | 43 | VK_DEFINE_DISP_SUBCLASS_HANDLE(VkDisplayWSI, VkObject) |
| 44 | VK_DEFINE_DISP_SUBCLASS_HANDLE(VkSwapChainWSI, VkObject) |
Ian Elliott | 2350cf8 | 2015-04-03 09:45:49 -0600 | [diff] [blame] | 45 | |
| 46 | // ------------------------------------------------------------------------------------------------ |
| 47 | // Enumeration constants |
| 48 | |
| 49 | #define VK_WSI_LUNARG_ENUM(type,id) ((type)(VK_WSI_LUNARG_EXTENSION_NUMBER * -1000 + (id))) |
| 50 | |
| 51 | // Extend VkPhysicalDeviceInfoType enum with extension specific constants |
| 52 | #define VK_PHYSICAL_DEVICE_INFO_TYPE_DISPLAY_PROPERTIES_WSI VK_WSI_LUNARG_ENUM(VkPhysicalDeviceInfoType, 0) |
| 53 | #define VK_PHYSICAL_DEVICE_INFO_TYPE_QUEUE_PRESENT_PROPERTIES_WSI VK_WSI_LUNARG_ENUM(VkPhysicalDeviceInfoType, 1) |
| 54 | |
| 55 | // Extend VkStructureType enum with extension specific constants |
| 56 | #define VK_STRUCTURE_TYPE_SWAP_CHAIN_CREATE_INFO_WSI VK_WSI_LUNARG_ENUM(VkStructureType, 0) |
| 57 | #define VK_STRUCTURE_TYPE_PRESENT_INFO_WSI VK_WSI_LUNARG_ENUM(VkStructureType, 1) |
| 58 | |
| 59 | // Extend VkImageLayout enum with extension specific constants |
| 60 | #define VK_IMAGE_LAYOUT_PRESENT_SOURCE_WSI VK_WSI_LUNARG_ENUM(VkImageLayout, 0) |
| 61 | |
Ian Elliott | 3a93185 | 2015-04-07 13:50:42 -0600 | [diff] [blame] | 62 | // Extend VkObjectType enum for new objects |
| 63 | #define VK_OBJECT_TYPE_DISPLAY_WSI VK_WSI_LUNARG_ENUM(VkObjectType, 0) |
| 64 | #define VK_OBJECT_TYPE_SWAP_CHAIN_WSI VK_WSI_LUNARG_ENUM(VkObjectType, 1) |
| 65 | |
Ian Elliott | 2350cf8 | 2015-04-03 09:45:49 -0600 | [diff] [blame] | 66 | // ------------------------------------------------------------------------------------------------ |
| 67 | // Enumerations |
| 68 | |
| 69 | typedef enum VkDisplayInfoTypeWSI_ |
| 70 | { |
| 71 | // Info type for vkGetDisplayInfo() |
| 72 | VK_DISPLAY_INFO_TYPE_FORMAT_PROPERTIES_WSI = 0x00000003, // Return the VkFormat(s) supported for swap chains with the display |
| 73 | |
| 74 | VK_ENUM_RANGE(DISPLAY_INFO_TYPE, FORMAT_PROPERTIES_WSI, FORMAT_PROPERTIES_WSI) |
| 75 | } VkDisplayInfoTypeWSI; |
| 76 | |
| 77 | typedef enum VkSwapChainInfoTypeWSI_ |
| 78 | { |
| 79 | // Info type for vkGetSwapChainInfo() |
| 80 | VK_SWAP_CHAIN_INFO_TYPE_PERSISTENT_IMAGES_WSI = 0x00000000, // Return information about the persistent images of the swapchain |
| 81 | |
| 82 | VK_ENUM_RANGE(SWAP_CHAIN_INFO_TYPE, PERSISTENT_IMAGES_WSI, PERSISTENT_IMAGES_WSI) |
| 83 | } VkSwapChainInfoTypeWSI; |
| 84 | |
| 85 | // ------------------------------------------------------------------------------------------------ |
| 86 | // Flags |
| 87 | |
| 88 | typedef VkFlags VkSwapModeFlagsWSI; |
| 89 | typedef enum VkSwapModeFlagBitsWSI_ |
| 90 | { |
| 91 | VK_SWAP_MODE_FLIP_BIT_WSI = VK_BIT(0), |
| 92 | VK_SWAP_MODE_BLIT_BIT_WSI = VK_BIT(1), |
| 93 | } VkSwapModeFlagBitsWSI; |
| 94 | |
| 95 | // ------------------------------------------------------------------------------------------------ |
| 96 | // Structures |
| 97 | |
| 98 | typedef struct VkDisplayPropertiesWSI_ |
| 99 | { |
| 100 | VkDisplayWSI display; // Handle of the display object |
| 101 | VkExtent2D physicalResolution; // Max resolution for CRT? |
| 102 | } VkDisplayPropertiesWSI; |
| 103 | |
| 104 | typedef struct VkDisplayFormatPropertiesWSI_ |
| 105 | { |
| 106 | VkDisplayWSI display; // Handle of the display object |
| 107 | VkFormat swapChainFormat; // Format of the images of the swap chain |
| 108 | } VkDisplayFormatPropertiesWSI; |
| 109 | |
| 110 | typedef struct VkSwapChainCreateInfoWSI_ |
| 111 | { |
| 112 | VkStructureType sType; // Must be VK_STRUCTURE_TYPE_SWAP_CHAIN_CREATE_INFO_WSI |
| 113 | const void* pNext; // Pointer to next structure |
| 114 | |
| 115 | // TBD: It is not yet clear what the use will be for the following two |
| 116 | // values. It seems to be needed for more-global window-system handles |
| 117 | // (e.g. X11 display). If not needed for the SDK, we will drop it from |
| 118 | // this extension, and from a future version of this header. |
| 119 | const void* pNativeWindowSystemHandle; // Pointer to native window system handle |
| 120 | const void* pNativeWindowHandle; // Pointer to native window handle |
| 121 | |
| 122 | uint32_t displayCount; // Number of displays the swap chain is created for |
| 123 | const VkDisplayWSI* pDisplays; // displayCount number of display objects the swap chain is created for |
| 124 | |
| 125 | uint32_t imageCount; // Number of images in the swap chain |
| 126 | |
| 127 | VkFormat imageFormat; // Format of the images of the swap chain |
| 128 | VkExtent2D imageExtent; // Width and height of the images of the swap chain |
| 129 | uint32_t imageArraySize; // Number of layers of the images of the swap chain (needed for multi-view rendering) |
| 130 | VkFlags imageUsageFlags; // Usage flags for the images of the swap chain (see VkImageUsageFlags) |
| 131 | |
| 132 | VkFlags swapModeFlags; // Allowed swap modes (see VkSwapModeFlagsWSI) |
| 133 | } VkSwapChainCreateInfoWSI; |
| 134 | |
| 135 | typedef struct VkSwapChainImageInfo_ |
| 136 | { |
| 137 | VkImage image; // Persistent swap chain image handle |
| 138 | VkDeviceMemory memory; // Persistent swap chain image's memory handle |
| 139 | } VkSwapChainImageInfo; |
| 140 | |
| 141 | typedef struct VkPhysicalDeviceQueuePresentPropertiesWSI_ |
| 142 | { |
| 143 | bool32_t supportsPresent; // Tells whether the queue supports presenting |
| 144 | } VkPhysicalDeviceQueuePresentPropertiesWSI; |
| 145 | |
| 146 | typedef struct VkPresentInfoWSI_ |
| 147 | { |
| 148 | VkStructureType sType; // Must be VK_STRUCTURE_TYPE_PRESENT_INFO_WSI |
| 149 | const void* pNext; // Pointer to next structure |
| 150 | VkImage image; // Image to present |
| 151 | uint32_t flipInterval; // Flip interval |
| 152 | } VkPresentInfoWSI; |
| 153 | |
| 154 | // ------------------------------------------------------------------------------------------------ |
| 155 | // Function types |
| 156 | |
| 157 | typedef VkResult (VKAPI *PFN_vkGetDisplayInfoWSI)(VkDisplayWSI display, VkDisplayInfoTypeWSI infoType, size_t* pDataSize, void* pData); |
| 158 | typedef VkResult (VKAPI *PFN_vkCreateSwapChainWSI)(VkDevice device, const VkSwapChainCreateInfoWSI* pCreateInfo, VkSwapChainWSI* pSwapChain); |
| 159 | typedef VkResult (VKAPI *PFN_vkDestroySwapChainWSI)(VkSwapChainWSI swapChain); |
| 160 | typedef VkResult (VKAPI *PFN_vkGetSwapChainInfoWSI)(VkSwapChainWSI swapChain, VkSwapChainInfoTypeWSI infoType, size_t* pDataSize, void* pData); |
| 161 | typedef VkResult (VKAPI *PFN_vkQueuePresentWSI)(VkQueue queue, VkPresentInfoWSI* pPresentInfo); |
| 162 | |
| 163 | // ------------------------------------------------------------------------------------------------ |
| 164 | // Function prototypes |
| 165 | |
| 166 | #ifdef VK_PROTOTYPES |
| 167 | |
| 168 | VkResult VKAPI vkGetDisplayInfoWSI( |
| 169 | VkDisplayWSI display, |
| 170 | VkDisplayInfoTypeWSI infoType, |
| 171 | size_t* pDataSize, |
| 172 | void* pData); |
| 173 | |
| 174 | VkResult VKAPI vkCreateSwapChainWSI( |
| 175 | VkDevice device, |
| 176 | const VkSwapChainCreateInfoWSI* pCreateInfo, |
| 177 | VkSwapChainWSI* pSwapChain); |
| 178 | |
| 179 | VkResult VKAPI vkDestroySwapChainWSI( |
| 180 | VkSwapChainWSI swapChain); |
| 181 | |
| 182 | VkResult VKAPI vkGetSwapChainInfoWSI( |
| 183 | VkSwapChainWSI swapChain, |
| 184 | VkSwapChainInfoTypeWSI infoType, |
| 185 | size_t* pDataSize, |
| 186 | void* pData); |
| 187 | |
| 188 | VkResult VKAPI vkQueuePresentWSI( |
| 189 | VkQueue queue, |
| 190 | VkPresentInfoWSI* pPresentInfo); |
| 191 | |
| 192 | #endif // VK_PROTOTYPES |
| 193 | |
| 194 | #ifdef __cplusplus |
| 195 | } // extern "C" |
| 196 | #endif // __cplusplus |
| 197 | |
| 198 | #endif // __VK_WSI_LUNARG_H__ |