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
27 anv_init_wsi(struct anv_instance
*instance
)
29 memset(instance
->wsi_impl
, 0, sizeof(instance
->wsi_impl
));
30 return anv_x11_init_wsi(instance
);
34 anv_finish_wsi(struct anv_instance
*instance
)
36 anv_x11_finish_wsi(instance
);
40 anv_GetPhysicalDeviceSurfaceSupportWSI(
41 VkPhysicalDevice physicalDevice
,
42 uint32_t queueFamilyIndex
,
43 const VkSurfaceDescriptionWSI
* pSurfaceDescription
,
46 ANV_FROM_HANDLE(anv_physical_device
, physical_device
, physicalDevice
);
48 assert(pSurfaceDescription
->sType
==
49 VK_STRUCTURE_TYPE_SURFACE_DESCRIPTION_WINDOW_WSI
);
51 VkSurfaceDescriptionWindowWSI
*window
= (void *)pSurfaceDescription
;
53 struct anv_wsi_implementation
*impl
=
54 physical_device
->instance
->wsi_impl
[window
->platform
];
57 return impl
->get_window_supported(impl
, physical_device
,
66 anv_GetSurfaceInfoWSI(
68 const VkSurfaceDescriptionWSI
* pSurfaceDescription
,
69 VkSurfaceInfoTypeWSI infoType
,
73 ANV_FROM_HANDLE(anv_device
, device
, _device
);
75 assert(pSurfaceDescription
->sType
==
76 VK_STRUCTURE_TYPE_SURFACE_DESCRIPTION_WINDOW_WSI
);
77 VkSurfaceDescriptionWindowWSI
*window
=
78 (VkSurfaceDescriptionWindowWSI
*)pSurfaceDescription
;
80 struct anv_wsi_implementation
*impl
=
81 device
->instance
->wsi_impl
[window
->platform
];
85 return impl
->get_surface_info(impl
, device
, window
, infoType
,
90 anv_CreateSwapChainWSI(
92 const VkSwapChainCreateInfoWSI
* pCreateInfo
,
93 VkSwapChainWSI
* pSwapChain
)
95 ANV_FROM_HANDLE(anv_device
, device
, _device
);
96 struct anv_swap_chain
*swap_chain
;
99 assert(pCreateInfo
->pSurfaceDescription
->sType
==
100 VK_STRUCTURE_TYPE_SURFACE_DESCRIPTION_WINDOW_WSI
);
101 VkSurfaceDescriptionWindowWSI
*window
=
102 (VkSurfaceDescriptionWindowWSI
*)pCreateInfo
->pSurfaceDescription
;
104 struct anv_wsi_implementation
*impl
=
105 device
->instance
->wsi_impl
[window
->platform
];
109 result
= impl
->create_swap_chain(impl
, device
, pCreateInfo
, &swap_chain
);
111 if (result
== VK_SUCCESS
)
112 *pSwapChain
= anv_swap_chain_to_handle(swap_chain
);
118 anv_DestroySwapChainWSI(
120 VkSwapChainWSI swapChain
)
122 ANV_FROM_HANDLE(anv_swap_chain
, swap_chain
, swapChain
);
124 assert(swap_chain
->device
== anv_device_from_handle(device
));
126 return swap_chain
->destroy(swap_chain
);
130 anv_GetSwapChainInfoWSI(
132 VkSwapChainWSI swapChain
,
133 VkSwapChainInfoTypeWSI infoType
,
137 ANV_FROM_HANDLE(anv_swap_chain
, swap_chain
, swapChain
);
139 assert(swap_chain
->device
== anv_device_from_handle(device
));
141 return swap_chain
->get_swap_chain_info(swap_chain
, infoType
,
146 anv_AcquireNextImageWSI(
148 VkSwapChainWSI swapChain
,
150 VkSemaphore semaphore
,
151 uint32_t* pImageIndex
)
153 ANV_FROM_HANDLE(anv_swap_chain
, swap_chain
, swapChain
);
155 assert(swap_chain
->device
== anv_device_from_handle(device
));
157 return swap_chain
->acquire_next_image(swap_chain
,
158 timeout
, semaphore
, pImageIndex
);
164 VkPresentInfoWSI
* pPresentInfo
)
166 ANV_FROM_HANDLE(anv_queue
, queue
, _queue
);
169 for (uint32_t i
= 0; i
< pPresentInfo
->swapChainCount
; i
++) {
170 ANV_FROM_HANDLE(anv_swap_chain
, swap_chain
, pPresentInfo
->swapChains
[i
]);
172 assert(swap_chain
->device
== queue
->device
);
174 result
= swap_chain
->queue_present(swap_chain
, queue
,
175 pPresentInfo
->imageIndices
[i
]);
176 /* TODO: What if one of them returns OUT_OF_DATE? */
177 if (result
!= VK_SUCCESS
)