summaryrefslogtreecommitdiffstats
path: root/src/vulkan/anv_wsi.c
diff options
context:
space:
mode:
authorJason Ekstrand <[email protected]>2015-09-04 11:14:45 -0700
committerJason Ekstrand <[email protected]>2015-09-04 17:55:42 -0700
commit348cb29a20e5076b84d0e6d01ffa7b6128b80ea8 (patch)
treece3a9661c82302e7e22ca1a90e1a0759e538028f /src/vulkan/anv_wsi.c
parent06d8fd58818c4574ba233edb4566509577d79dd0 (diff)
vk/wsi: Move to a clallback system for the entire WSI implementation
We do this for two reasons: First, because it allows us to simplify WSI and compiling in/out support for a particular platform is as simple as calling or not calling the platform-specific init function. Second, the implementation gives us a place for a given chunk of the WSI to stash stuff in the instance.
Diffstat (limited to 'src/vulkan/anv_wsi.c')
-rw-r--r--src/vulkan/anv_wsi.c54
1 files changed, 37 insertions, 17 deletions
diff --git a/src/vulkan/anv_wsi.c b/src/vulkan/anv_wsi.c
index 404c905d419..24379337a5e 100644
--- a/src/vulkan/anv_wsi.c
+++ b/src/vulkan/anv_wsi.c
@@ -24,20 +24,42 @@
#include "anv_wsi.h"
VkResult
+anv_init_wsi(struct anv_instance *instance)
+{
+ memset(instance->wsi_impl, 0, sizeof(instance->wsi_impl));
+ return anv_x11_init_wsi(instance);
+}
+
+void
+anv_finish_wsi(struct anv_instance *instance)
+{
+ anv_x11_finish_wsi(instance);
+}
+
+VkResult
anv_GetPhysicalDeviceSurfaceSupportWSI(
VkPhysicalDevice physicalDevice,
uint32_t queueFamilyIndex,
const VkSurfaceDescriptionWSI* pSurfaceDescription,
VkBool32* pSupported)
{
+ ANV_FROM_HANDLE(anv_physical_device, physical_device, physicalDevice);
+
assert(pSurfaceDescription->sType ==
VK_STRUCTURE_TYPE_SURFACE_DESCRIPTION_WINDOW_WSI);
VkSurfaceDescriptionWindowWSI *window = (void *)pSurfaceDescription;
- *pSupported = window->platform == VK_PLATFORM_XCB_WSI;
+ struct anv_wsi_implementation *impl =
+ physical_device->instance->wsi_impl[window->platform];
- return VK_SUCCESS;
+ if (impl) {
+ return impl->get_window_supported(impl, physical_device,
+ window, pSupported);
+ } else {
+ *pSupported = false;
+ return VK_SUCCESS;
+ }
}
VkResult
@@ -55,13 +77,13 @@ anv_GetSurfaceInfoWSI(
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);
- }
+ struct anv_wsi_implementation *impl =
+ device->instance->wsi_impl[window->platform];
+
+ assert(impl);
+
+ return impl->get_surface_info(impl, device, window, infoType,
+ pDataSize, pData);
}
VkResult
@@ -79,14 +101,12 @@ anv_CreateSwapChainWSI(
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);
- }
+ struct anv_wsi_implementation *impl =
+ device->instance->wsi_impl[window->platform];
+
+ assert(impl);
+
+ result = impl->create_swap_chain(impl, device, pCreateInfo, &swap_chain);
if (result == VK_SUCCESS)
*pSwapChain = anv_swap_chain_to_handle(swap_chain);