{
VkResult result;
- memset(instance->wsi_impl, 0, sizeof(instance->wsi_impl));
-
result = anv_x11_init_wsi(instance);
if (result != VK_SUCCESS)
return result;
anv_x11_finish_wsi(instance);
}
-VkResult
-anv_GetPhysicalDeviceSurfaceSupportWSI(
- VkPhysicalDevice physicalDevice,
- uint32_t queueFamilyIndex,
- const VkSurfaceDescriptionWSI* pSurfaceDescription,
- VkBool32* pSupported)
+void anv_DestroySurfaceKHR(
+ VkInstance instance,
+ VkSurfaceKHR _surface,
+ const VkAllocationCallbacks* pAllocator)
{
- ANV_FROM_HANDLE(anv_physical_device, physical_device, physicalDevice);
+ ANV_FROM_HANDLE(anv_wsi_surface, surface, _surface);
- assert(pSurfaceDescription->sType ==
- VK_STRUCTURE_TYPE_SURFACE_DESCRIPTION_WINDOW_WSI);
-
- VkSurfaceDescriptionWindowWSI *window = (void *)pSurfaceDescription;
+ surface->destroy(surface, pAllocator);
+}
- struct anv_wsi_implementation *impl =
- physical_device->instance->wsi_impl[window->platform];
+VkResult anv_GetPhysicalDeviceSurfaceSupportKHR(
+ VkPhysicalDevice physicalDevice,
+ uint32_t queueFamilyIndex,
+ VkSurfaceKHR _surface,
+ VkBool32* pSupported)
+{
+ ANV_FROM_HANDLE(anv_physical_device, device, physicalDevice);
+ ANV_FROM_HANDLE(anv_wsi_surface, surface, _surface);
- if (impl) {
- return impl->get_window_supported(impl, physical_device,
- window, pSupported);
- } else {
- *pSupported = false;
- return VK_SUCCESS;
- }
+ return surface->get_support(surface, device, queueFamilyIndex, pSupported);
}
-VkResult
-anv_GetSurfaceInfoWSI(
- VkDevice _device,
- const VkSurfaceDescriptionWSI* pSurfaceDescription,
- VkSurfaceInfoTypeWSI infoType,
- size_t* pDataSize,
- void* pData)
+VkResult anv_GetPhysicalDeviceSurfaceCapabilitiesKHR(
+ VkPhysicalDevice physicalDevice,
+ VkSurfaceKHR _surface,
+ VkSurfaceCapabilitiesKHR* pSurfaceCapabilities)
{
- ANV_FROM_HANDLE(anv_device, device, _device);
-
- assert(pSurfaceDescription->sType ==
- VK_STRUCTURE_TYPE_SURFACE_DESCRIPTION_WINDOW_WSI);
- VkSurfaceDescriptionWindowWSI *window =
- (VkSurfaceDescriptionWindowWSI *)pSurfaceDescription;
+ ANV_FROM_HANDLE(anv_physical_device, device, physicalDevice);
+ ANV_FROM_HANDLE(anv_wsi_surface, surface, _surface);
- struct anv_wsi_implementation *impl =
- device->instance->wsi_impl[window->platform];
+ return surface->get_capabilities(surface, device, pSurfaceCapabilities);
+}
- assert(impl);
+VkResult anv_GetPhysicalDeviceSurfaceFormatsKHR(
+ VkPhysicalDevice physicalDevice,
+ VkSurfaceKHR _surface,
+ uint32_t* pSurfaceFormatCount,
+ VkSurfaceFormatKHR* pSurfaceFormats)
+{
+ ANV_FROM_HANDLE(anv_physical_device, device, physicalDevice);
+ ANV_FROM_HANDLE(anv_wsi_surface, surface, _surface);
- return impl->get_surface_info(impl, device, window, infoType,
- pDataSize, pData);
+ return surface->get_formats(surface, device, pSurfaceFormatCount,
+ pSurfaceFormats);
}
-VkResult
-anv_CreateSwapChainWSI(
- VkDevice _device,
- const VkSwapChainCreateInfoWSI* pCreateInfo,
- VkSwapChainWSI* pSwapChain)
+VkResult anv_GetPhysicalDeviceSurfacePresentModesKHR(
+ VkPhysicalDevice physicalDevice,
+ VkSurfaceKHR _surface,
+ uint32_t* pPresentModeCount,
+ VkPresentModeKHR* pPresentModes)
{
- ANV_FROM_HANDLE(anv_device, device, _device);
- struct anv_swap_chain *swap_chain;
- VkResult result;
+ ANV_FROM_HANDLE(anv_physical_device, device, physicalDevice);
+ ANV_FROM_HANDLE(anv_wsi_surface, surface, _surface);
- assert(pCreateInfo->pSurfaceDescription->sType ==
- VK_STRUCTURE_TYPE_SURFACE_DESCRIPTION_WINDOW_WSI);
- VkSurfaceDescriptionWindowWSI *window =
- (VkSurfaceDescriptionWindowWSI *)pCreateInfo->pSurfaceDescription;
-
- struct anv_wsi_implementation *impl =
- device->instance->wsi_impl[window->platform];
+ return surface->get_present_modes(surface, device, pPresentModeCount,
+ pPresentModes);
+}
- assert(impl);
+VkResult anv_CreateSwapchainKHR(
+ VkDevice _device,
+ const VkSwapchainCreateInfoKHR* pCreateInfo,
+ const VkAllocationCallbacks* pAllocator,
+ VkSwapchainKHR* pSwapchain)
+{
+ ANV_FROM_HANDLE(anv_device, device, _device);
+ ANV_FROM_HANDLE(anv_wsi_surface, surface, pCreateInfo->surface);
+ struct anv_swapchain *swapchain;
- result = impl->create_swap_chain(impl, device, pCreateInfo, &swap_chain);
+ VkResult result = surface->create_swapchain(surface, device, pCreateInfo,
+ pAllocator, &swapchain);
+ if (result != VK_SUCCESS)
+ return result;
- if (result == VK_SUCCESS)
- *pSwapChain = anv_swap_chain_to_handle(swap_chain);
+ *pSwapchain = anv_swapchain_to_handle(swapchain);
- return result;
+ return VK_SUCCESS;
}
-VkResult
-anv_DestroySwapChainWSI(
- VkDevice device,
- VkSwapChainWSI swapChain)
+void anv_DestroySwapchainKHR(
+ VkDevice device,
+ VkSwapchainKHR _swapchain,
+ const VkAllocationCallbacks* pAllocator)
{
- ANV_FROM_HANDLE(anv_swap_chain, swap_chain, swapChain);
-
- assert(swap_chain->device == anv_device_from_handle(device));
+ ANV_FROM_HANDLE(anv_swapchain, swapchain, _swapchain);
- return swap_chain->destroy(swap_chain);
+ swapchain->destroy(swapchain, pAllocator);
}
-VkResult
-anv_GetSwapChainInfoWSI(
- VkDevice device,
- VkSwapChainWSI swapChain,
- VkSwapChainInfoTypeWSI infoType,
- size_t* pDataSize,
- void* pData)
+VkResult anv_GetSwapchainImagesKHR(
+ VkDevice device,
+ VkSwapchainKHR _swapchain,
+ uint32_t* pSwapchainImageCount,
+ VkImage* pSwapchainImages)
{
- ANV_FROM_HANDLE(anv_swap_chain, swap_chain, swapChain);
-
- assert(swap_chain->device == anv_device_from_handle(device));
+ ANV_FROM_HANDLE(anv_swapchain, swapchain, _swapchain);
- return swap_chain->get_swap_chain_info(swap_chain, infoType,
- pDataSize, pData);
+ return swapchain->get_images(swapchain, pSwapchainImageCount,
+ pSwapchainImages);
}
-VkResult
-anv_AcquireNextImageWSI(
- VkDevice device,
- VkSwapChainWSI swapChain,
- uint64_t timeout,
- VkSemaphore semaphore,
- uint32_t* pImageIndex)
+VkResult anv_AcquireNextImageKHR(
+ VkDevice device,
+ VkSwapchainKHR _swapchain,
+ uint64_t timeout,
+ VkSemaphore semaphore,
+ VkFence fence,
+ uint32_t* pImageIndex)
{
- ANV_FROM_HANDLE(anv_swap_chain, swap_chain, swapChain);
-
- assert(swap_chain->device == anv_device_from_handle(device));
+ ANV_FROM_HANDLE(anv_swapchain, swapchain, _swapchain);
- return swap_chain->acquire_next_image(swap_chain,
- timeout, semaphore, pImageIndex);
+ return swapchain->acquire_next_image(swapchain, timeout, semaphore,
+ pImageIndex);
}
-VkResult
-anv_QueuePresentWSI(
+VkResult anv_QueuePresentKHR(
VkQueue _queue,
- VkPresentInfoWSI* pPresentInfo)
+ const VkPresentInfoKHR* 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]);
+ for (uint32_t i = 0; i < pPresentInfo->swapchainCount; i++) {
+ ANV_FROM_HANDLE(anv_swapchain, swapchain, pPresentInfo->pSwapchains[i]);
- assert(swap_chain->device == queue->device);
+ assert(swapchain->device == queue->device);
- result = swap_chain->queue_present(swap_chain, queue,
- pPresentInfo->imageIndices[i]);
+ result = swapchain->queue_present(swapchain, queue,
+ pPresentInfo->pImageIndices[i]);
/* TODO: What if one of them returns OUT_OF_DATE? */
if (result != VK_SUCCESS)
return result;