summaryrefslogtreecommitdiffstats
path: root/src/vulkan/anv_wsi.c
diff options
context:
space:
mode:
authorJason Ekstrand <[email protected]>2015-09-01 18:59:06 -0700
committerJason Ekstrand <[email protected]>2015-09-04 17:55:42 -0700
commitca3cfbf6f1e009c0208ffaa483c8a7e80394639d (patch)
tree16e4f40d8e2a879eaff8e3a23aa54626de1c716b /src/vulkan/anv_wsi.c
parent3d9fbb6575697744642c28464fb098552576ac97 (diff)
vk: Add an initial implementation of the actual Khronos WSI extension
Unfortunately, this is a very large commit and removes the old LunarG WSI extension. This is because there are a couple of entrypoints that have the same name between the two extensions so implementing them both is impractiacl. Support is still incomplete, but this is enough to get vkcube up and going again.
Diffstat (limited to 'src/vulkan/anv_wsi.c')
-rw-r--r--src/vulkan/anv_wsi.c146
1 files changed, 145 insertions, 1 deletions
diff --git a/src/vulkan/anv_wsi.c b/src/vulkan/anv_wsi.c
index 5ae9b85e540..5c2dbb5fbca 100644
--- a/src/vulkan/anv_wsi.c
+++ b/src/vulkan/anv_wsi.c
@@ -21,7 +21,7 @@
* IN THE SOFTWARE.
*/
-#include "anv_private.h"
+#include "anv_wsi.h"
VkResult
anv_GetPhysicalDeviceSurfaceSupportWSI(
@@ -39,3 +39,147 @@ anv_GetPhysicalDeviceSurfaceSupportWSI(
return VK_SUCCESS;
}
+
+VkResult
+anv_GetSurfaceInfoWSI(
+ VkDevice _device,
+ const VkSurfaceDescriptionWSI* pSurfaceDescription,
+ VkSurfaceInfoTypeWSI infoType,
+ size_t* pDataSize,
+ void* pData)
+{
+ ANV_FROM_HANDLE(anv_device, device, _device);
+
+ assert(pSurfaceDescription->sType ==
+ VK_STRUCTURE_TYPE_SURFACE_DESCRIPTION_WINDOW_WSI);
+ VkSurfaceDescriptionWindowWSI *window =
+ (VkSurfaceDescriptionWindowWSI *)pSurfaceDescription;
+
+ switch (window->platform) {
+ case VK_PLATFORM_XCB_WSI:
+ return anv_x11_get_surface_info(device, window, infoType,
+ pDataSize, pData);
+ default:
+ return vk_error(VK_ERROR_INVALID_VALUE);
+ }
+}
+
+VkResult
+anv_CreateSwapChainWSI(
+ VkDevice _device,
+ const VkSwapChainCreateInfoWSI* pCreateInfo,
+ VkSwapChainWSI* pSwapChain)
+{
+ ANV_FROM_HANDLE(anv_device, device, _device);
+ struct anv_swap_chain *swap_chain;
+ VkResult result;
+
+ assert(pCreateInfo->pSurfaceDescription->sType ==
+ VK_STRUCTURE_TYPE_SURFACE_DESCRIPTION_WINDOW_WSI);
+ VkSurfaceDescriptionWindowWSI *window =
+ (VkSurfaceDescriptionWindowWSI *)pCreateInfo->pSurfaceDescription;
+
+ switch (window->platform) {
+ case VK_PLATFORM_XCB_WSI:
+ result = anv_x11_create_swap_chain(device, pCreateInfo,
+ (void *)&swap_chain);
+ break;
+ default:
+ return vk_error(VK_ERROR_INVALID_VALUE);
+ }
+
+ if (result == VK_SUCCESS)
+ *pSwapChain = anv_swap_chain_to_handle(swap_chain);
+
+ return result;
+}
+
+VkResult
+anv_DestroySwapChainWSI(
+ VkDevice device,
+ VkSwapChainWSI swapChain)
+{
+ ANV_FROM_HANDLE(anv_swap_chain, swap_chain, swapChain);
+
+ assert(swap_chain->device == anv_device_from_handle(device));
+
+ switch (swap_chain->type) {
+ case ANV_SWAP_CHAIN_TYPE_X11:
+ return anv_x11_destroy_swap_chain((void *)swap_chain);
+ default:
+ return vk_error(VK_ERROR_INVALID_VALUE);
+ }
+}
+
+VkResult
+anv_GetSwapChainInfoWSI(
+ VkDevice device,
+ VkSwapChainWSI swapChain,
+ VkSwapChainInfoTypeWSI infoType,
+ size_t* pDataSize,
+ void* pData)
+{
+ ANV_FROM_HANDLE(anv_swap_chain, swap_chain, swapChain);
+
+ assert(swap_chain->device == anv_device_from_handle(device));
+
+ switch (swap_chain->type) {
+ case ANV_SWAP_CHAIN_TYPE_X11:
+ return anv_x11_get_swap_chain_info((void *)swap_chain,
+ infoType, pDataSize, pData);
+ default:
+ return vk_error(VK_ERROR_INVALID_VALUE);
+ }
+}
+
+VkResult
+anv_AcquireNextImageWSI(
+ VkDevice device,
+ VkSwapChainWSI swapChain,
+ uint64_t timeout,
+ VkSemaphore semaphore,
+ uint32_t* pImageIndex)
+{
+ ANV_FROM_HANDLE(anv_swap_chain, swap_chain, swapChain);
+
+ assert(swap_chain->device == anv_device_from_handle(device));
+
+ switch (swap_chain->type) {
+ case ANV_SWAP_CHAIN_TYPE_X11:
+ return anv_x11_acquire_next_image((void *)swap_chain,
+ timeout, semaphore, pImageIndex);
+ default:
+ return vk_error(VK_ERROR_INVALID_VALUE);
+ }
+}
+
+VkResult
+anv_QueuePresentWSI(
+ VkQueue _queue,
+ VkPresentInfoWSI* pPresentInfo)
+{
+ ANV_FROM_HANDLE(anv_queue, queue, _queue);
+ VkResult result;
+
+ for (uint32_t i = 0; i < pPresentInfo->swapChainCount; i++) {
+ ANV_FROM_HANDLE(anv_swap_chain, swap_chain, pPresentInfo->swapChains[i]);
+
+ assert(swap_chain->device == queue->device);
+
+ switch (swap_chain->type) {
+ case ANV_SWAP_CHAIN_TYPE_X11:
+ result = anv_x11_queue_present(queue, (void *)swap_chain,
+ pPresentInfo->imageIndices[i]);
+ /* TODO: What if one of them returns OUT_OF_DATE? */
+ if (result != VK_SUCCESS)
+ return result;
+ else
+ continue;
+
+ default:
+ return vk_error(VK_ERROR_INVALID_VALUE);
+ }
+ }
+
+ return VK_SUCCESS;
+}