2 * Copyright © 2015 Intel Corporation
4 * Permission is hereby granted, free of charge, to any person obtaining a
5 * copy of this software and associated documentation files (the "Software"),
6 * to deal in the Software without restriction, including without limitation
7 * the rights to use, copy, modify, merge, publish, distribute, sublicense,
8 * and/or sell copies of the Software, and to permit persons to whom the
9 * Software is furnished to do so, subject to the following conditions:
11 * The above copyright notice and this permission notice (including the next
12 * paragraph) shall be included in all copies or substantial portions of the
15 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
18 * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
20 * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
30 #include <vulkan/vulkan.h>
31 #include <vulkan/vk_icd.h>
33 /* This is guaranteed to not collide with anything because it's in the
34 * VK_KHR_swapchain namespace but not actually used by the extension.
36 #define VK_STRUCTURE_TYPE_WSI_IMAGE_CREATE_INFO_MESA (VkStructureType)1000001002
37 #define VK_STRUCTURE_TYPE_WSI_MEMORY_ALLOCATE_INFO_MESA (VkStructureType)1000001003
39 struct wsi_image_create_info
{
40 VkStructureType sType
;
45 struct wsi_memory_allocate_info
{
46 VkStructureType sType
;
53 #define VK_ICD_WSI_PLATFORM_MAX 5
56 VkPhysicalDeviceMemoryProperties memory_props
;
57 uint32_t queue_family_count
;
59 uint32_t (*queue_get_family_index
)(VkQueue queue
);
61 #define WSI_CB(cb) PFN_vk##cb cb
62 WSI_CB(AllocateMemory
);
63 WSI_CB(AllocateCommandBuffers
);
64 WSI_CB(BindBufferMemory
);
65 WSI_CB(BindImageMemory
);
66 WSI_CB(BeginCommandBuffer
);
67 WSI_CB(CmdCopyImageToBuffer
);
69 WSI_CB(CreateCommandPool
);
72 WSI_CB(DestroyBuffer
);
73 WSI_CB(DestroyCommandPool
);
76 WSI_CB(EndCommandBuffer
);
78 WSI_CB(FreeCommandBuffers
);
79 WSI_CB(GetBufferMemoryRequirements
);
80 WSI_CB(GetImageMemoryRequirements
);
81 WSI_CB(GetImageSubresourceLayout
);
82 WSI_CB(GetMemoryFdKHR
);
85 WSI_CB(WaitForFences
);
88 struct wsi_interface
* wsi
[VK_ICD_WSI_PLATFORM_MAX
];
91 typedef PFN_vkVoidFunction (VKAPI_PTR
*WSI_FN_GetPhysicalDeviceProcAddr
)(VkPhysicalDevice physicalDevice
, const char* pName
);
94 wsi_device_init(struct wsi_device
*wsi
,
95 VkPhysicalDevice pdevice
,
96 WSI_FN_GetPhysicalDeviceProcAddr proc_addr
);
98 #define WSI_CB(cb) PFN_vk##cb cb
99 struct wsi_callbacks
{
100 VkPhysicalDevice (*device_get_physical
)(VkDevice
);
102 WSI_CB(GetDeviceProcAddr
);
103 WSI_CB(GetPhysicalDeviceFormatProperties
);
104 WSI_CB(GetPhysicalDeviceMemoryProperties
);
105 WSI_CB(GetPhysicalDeviceQueueFamilyProperties
);
109 #define ICD_DEFINE_NONDISP_HANDLE_CASTS(__VkIcdType, __VkType) \
111 static inline __VkIcdType * \
112 __VkIcdType ## _from_handle(__VkType _handle) \
114 return (__VkIcdType *)(uintptr_t) _handle; \
117 static inline __VkType \
118 __VkIcdType ## _to_handle(__VkIcdType *_obj) \
120 return (__VkType)(uintptr_t) _obj; \
123 #define ICD_FROM_HANDLE(__VkIcdType, __name, __handle) \
124 __VkIcdType *__name = __VkIcdType ## _from_handle(__handle)
126 ICD_DEFINE_NONDISP_HANDLE_CASTS(VkIcdSurfaceBase
, VkSurfaceKHR
)
128 VkResult
wsi_x11_init_wsi(struct wsi_device
*wsi_device
,
129 const VkAllocationCallbacks
*alloc
);
130 void wsi_x11_finish_wsi(struct wsi_device
*wsi_device
,
131 const VkAllocationCallbacks
*alloc
);
132 VkResult
wsi_wl_init_wsi(struct wsi_device
*wsi_device
,
133 const VkAllocationCallbacks
*alloc
,
134 VkPhysicalDevice physical_device
,
135 const struct wsi_callbacks
*cbs
);
136 void wsi_wl_finish_wsi(struct wsi_device
*wsi_device
,
137 const VkAllocationCallbacks
*alloc
);
140 wsi_common_get_surface_support(struct wsi_device
*wsi_device
,
142 uint32_t queueFamilyIndex
,
143 VkSurfaceKHR surface
,
144 const VkAllocationCallbacks
*alloc
,
145 VkBool32
* pSupported
);
148 wsi_common_get_surface_capabilities(struct wsi_device
*wsi_device
,
149 VkSurfaceKHR surface
,
150 VkSurfaceCapabilitiesKHR
*pSurfaceCapabilities
);
153 wsi_common_get_surface_capabilities2(struct wsi_device
*wsi_device
,
154 const VkPhysicalDeviceSurfaceInfo2KHR
*pSurfaceInfo
,
155 VkSurfaceCapabilities2KHR
*pSurfaceCapabilities
);
158 wsi_common_get_surface_formats(struct wsi_device
*wsi_device
,
159 VkSurfaceKHR surface
,
160 uint32_t *pSurfaceFormatCount
,
161 VkSurfaceFormatKHR
*pSurfaceFormats
);
164 wsi_common_get_surface_formats2(struct wsi_device
*wsi_device
,
165 const VkPhysicalDeviceSurfaceInfo2KHR
*pSurfaceInfo
,
166 uint32_t *pSurfaceFormatCount
,
167 VkSurfaceFormat2KHR
*pSurfaceFormats
);
170 wsi_common_get_surface_present_modes(struct wsi_device
*wsi_device
,
171 VkSurfaceKHR surface
,
172 uint32_t *pPresentModeCount
,
173 VkPresentModeKHR
*pPresentModes
);
176 wsi_common_get_images(VkSwapchainKHR _swapchain
,
177 uint32_t *pSwapchainImageCount
,
178 VkImage
*pSwapchainImages
);
181 wsi_common_acquire_next_image(const struct wsi_device
*wsi
,
183 VkSwapchainKHR swapchain
,
185 VkSemaphore semaphore
,
186 uint32_t *pImageIndex
);
189 wsi_common_create_swapchain(struct wsi_device
*wsi
,
192 const VkSwapchainCreateInfoKHR
*pCreateInfo
,
193 const VkAllocationCallbacks
*pAllocator
,
194 VkSwapchainKHR
*pSwapchain
);
196 wsi_common_destroy_swapchain(VkDevice device
,
197 VkSwapchainKHR swapchain
,
198 const VkAllocationCallbacks
*pAllocator
);
201 wsi_common_queue_present(const struct wsi_device
*wsi
,
204 int queue_family_index
,
205 const VkPresentInfoKHR
*pPresentInfo
);