summaryrefslogtreecommitdiffstats
path: root/src/vulkan
diff options
context:
space:
mode:
authorJason Ekstrand <jason.ekstrand@intel.com>2017-11-16 12:49:27 -0800
committerJason Ekstrand <jason.ekstrand@intel.com>2017-12-04 10:04:19 -0800
commit0a10e3770f79e5e5c450e31ff1bfc2d045940b56 (patch)
tree0fc4cf9b249721814b9bc7bf57d7d6f90b8b4c4d /src/vulkan
parent2e3e55110b0b528f23339453e9acf73513dfd6bb (diff)
vulkan/wsi: Initialize individual WSI interfaces in wsi_device_init
Now that we have anv_device_init/finish functions, there's no reason to have the individual driver do any more work than that. Reviewed-by: Dave Airlie <airlied@redhat.com> Reviewed-by: Chad Versace <chadversary@chromium.org>
Diffstat (limited to 'src/vulkan')
-rw-r--r--src/vulkan/wsi/wsi_common.c37
-rw-r--r--src/vulkan/wsi/wsi_common.h19
-rw-r--r--src/vulkan/wsi/wsi_common_private.h10
3 files changed, 52 insertions, 14 deletions
diff --git a/src/vulkan/wsi/wsi_common.c b/src/vulkan/wsi/wsi_common.c
index 9a5c78381ce..2de5f154c8a 100644
--- a/src/vulkan/wsi/wsi_common.c
+++ b/src/vulkan/wsi/wsi_common.c
@@ -25,11 +25,14 @@
#include "util/macros.h"
#include "vk_util.h"
-void
+VkResult
wsi_device_init(struct wsi_device *wsi,
VkPhysicalDevice pdevice,
- WSI_FN_GetPhysicalDeviceProcAddr proc_addr)
+ WSI_FN_GetPhysicalDeviceProcAddr proc_addr,
+ const VkAllocationCallbacks *alloc)
{
+ VkResult result;
+
memset(wsi, 0, sizeof(*wsi));
#define WSI_GET_CB(func) \
@@ -69,6 +72,36 @@ wsi_device_init(struct wsi_device *wsi,
WSI_GET_CB(QueueSubmit);
WSI_GET_CB(WaitForFences);
#undef WSI_GET_CB
+
+#ifdef VK_USE_PLATFORM_XCB_KHR
+ result = wsi_x11_init_wsi(wsi, alloc);
+ if (result != VK_SUCCESS)
+ return result;
+#endif
+
+#ifdef VK_USE_PLATFORM_WAYLAND_KHR
+ result = wsi_wl_init_wsi(wsi, alloc, pdevice);
+ if (result != VK_SUCCESS) {
+#ifdef VK_USE_PLATFORM_XCB_KHR
+ wsi_x11_finish_wsi(wsi, alloc);
+#endif
+ return result;
+ }
+#endif
+
+ return VK_SUCCESS;
+}
+
+void
+wsi_device_finish(struct wsi_device *wsi,
+ const VkAllocationCallbacks *alloc)
+{
+#ifdef VK_USE_PLATFORM_WAYLAND_KHR
+ wsi_wl_finish_wsi(wsi, alloc);
+#endif
+#ifdef VK_USE_PLATFORM_XCB_KHR
+ wsi_x11_finish_wsi(wsi, alloc);
+#endif
}
VkResult
diff --git a/src/vulkan/wsi/wsi_common.h b/src/vulkan/wsi/wsi_common.h
index 65814435ce4..3e0d3be1c24 100644
--- a/src/vulkan/wsi/wsi_common.h
+++ b/src/vulkan/wsi/wsi_common.h
@@ -89,10 +89,15 @@ struct wsi_device {
typedef PFN_vkVoidFunction (VKAPI_PTR *WSI_FN_GetPhysicalDeviceProcAddr)(VkPhysicalDevice physicalDevice, const char* pName);
-void
+VkResult
wsi_device_init(struct wsi_device *wsi,
VkPhysicalDevice pdevice,
- WSI_FN_GetPhysicalDeviceProcAddr proc_addr);
+ WSI_FN_GetPhysicalDeviceProcAddr proc_addr,
+ const VkAllocationCallbacks *alloc);
+
+void
+wsi_device_finish(struct wsi_device *wsi,
+ const VkAllocationCallbacks *alloc);
#define ICD_DEFINE_NONDISP_HANDLE_CASTS(__VkIcdType, __VkType) \
\
@@ -113,16 +118,6 @@ wsi_device_init(struct wsi_device *wsi,
ICD_DEFINE_NONDISP_HANDLE_CASTS(VkIcdSurfaceBase, VkSurfaceKHR)
-VkResult wsi_x11_init_wsi(struct wsi_device *wsi_device,
- const VkAllocationCallbacks *alloc);
-void wsi_x11_finish_wsi(struct wsi_device *wsi_device,
- const VkAllocationCallbacks *alloc);
-VkResult wsi_wl_init_wsi(struct wsi_device *wsi_device,
- const VkAllocationCallbacks *alloc,
- VkPhysicalDevice physical_device);
-void wsi_wl_finish_wsi(struct wsi_device *wsi_device,
- const VkAllocationCallbacks *alloc);
-
VkResult
wsi_common_get_surface_support(struct wsi_device *wsi_device,
int local_fd,
diff --git a/src/vulkan/wsi/wsi_common_private.h b/src/vulkan/wsi/wsi_common_private.h
index e29a239bd78..503b2a015dc 100644
--- a/src/vulkan/wsi/wsi_common_private.h
+++ b/src/vulkan/wsi/wsi_common_private.h
@@ -124,6 +124,16 @@ struct wsi_interface {
struct wsi_swapchain **swapchain);
};
+VkResult wsi_x11_init_wsi(struct wsi_device *wsi_device,
+ const VkAllocationCallbacks *alloc);
+void wsi_x11_finish_wsi(struct wsi_device *wsi_device,
+ const VkAllocationCallbacks *alloc);
+VkResult wsi_wl_init_wsi(struct wsi_device *wsi_device,
+ const VkAllocationCallbacks *alloc,
+ VkPhysicalDevice physical_device);
+void wsi_wl_finish_wsi(struct wsi_device *wsi_device,
+ const VkAllocationCallbacks *alloc);
+
#define WSI_DEFINE_NONDISP_HANDLE_CASTS(__wsi_type, __VkType) \
\