vulkan/wsi: Initialize individual WSI interfaces in wsi_device_init
authorJason Ekstrand <jason.ekstrand@intel.com>
Thu, 16 Nov 2017 20:49:27 +0000 (12:49 -0800)
committerJason Ekstrand <jason.ekstrand@intel.com>
Mon, 4 Dec 2017 18:04:19 +0000 (10:04 -0800)
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>
src/amd/vulkan/radv_wsi.c
src/intel/vulkan/anv_wsi.c
src/vulkan/wsi/wsi_common.c
src/vulkan/wsi/wsi_common.h
src/vulkan/wsi/wsi_common_private.h

index aa06944e95eccb9180e75e7ca10f13dede801055..cb61eb660241788da08d8643fc2a6a04f049688e 100644 (file)
@@ -38,41 +38,17 @@ radv_wsi_proc_addr(VkPhysicalDevice physicalDevice, const char *pName)
 VkResult
 radv_init_wsi(struct radv_physical_device *physical_device)
 {
-       VkResult result;
-
-       wsi_device_init(&physical_device->wsi_device,
-                       radv_physical_device_to_handle(physical_device),
-                       radv_wsi_proc_addr);
-
-#ifdef VK_USE_PLATFORM_XCB_KHR
-       result = wsi_x11_init_wsi(&physical_device->wsi_device, &physical_device->instance->alloc);
-       if (result != VK_SUCCESS)
-               return result;
-#endif
-
-#ifdef VK_USE_PLATFORM_WAYLAND_KHR
-       result = wsi_wl_init_wsi(&physical_device->wsi_device, &physical_device->instance->alloc,
-                                radv_physical_device_to_handle(physical_device));
-       if (result != VK_SUCCESS) {
-#ifdef VK_USE_PLATFORM_XCB_KHR
-               wsi_x11_finish_wsi(&physical_device->wsi_device, &physical_device->instance->alloc);
-#endif
-               return result;
-       }
-#endif
-
-       return VK_SUCCESS;
+       return wsi_device_init(&physical_device->wsi_device,
+                              radv_physical_device_to_handle(physical_device),
+                              radv_wsi_proc_addr,
+                              &physical_device->instance->alloc);
 }
 
 void
 radv_finish_wsi(struct radv_physical_device *physical_device)
 {
-#ifdef VK_USE_PLATFORM_WAYLAND_KHR
-       wsi_wl_finish_wsi(&physical_device->wsi_device, &physical_device->instance->alloc);
-#endif
-#ifdef VK_USE_PLATFORM_XCB_KHR
-       wsi_x11_finish_wsi(&physical_device->wsi_device, &physical_device->instance->alloc);
-#endif
+       wsi_device_finish(&physical_device->wsi_device,
+                         &physical_device->instance->alloc);
 }
 
 void radv_DestroySurfaceKHR(
index add983f4ab22387bb28f4b6ad02bb357c493f980..6082c3dd0937262c02e31140bdf09f348b514315 100644 (file)
@@ -36,41 +36,17 @@ anv_wsi_proc_addr(VkPhysicalDevice physicalDevice, const char *pName)
 VkResult
 anv_init_wsi(struct anv_physical_device *physical_device)
 {
-   VkResult result;
-
-   wsi_device_init(&physical_device->wsi_device,
-                   anv_physical_device_to_handle(physical_device),
-                   anv_wsi_proc_addr);
-
-#ifdef VK_USE_PLATFORM_XCB_KHR
-   result = wsi_x11_init_wsi(&physical_device->wsi_device, &physical_device->instance->alloc);
-   if (result != VK_SUCCESS)
-      return result;
-#endif
-
-#ifdef VK_USE_PLATFORM_WAYLAND_KHR
-   result = wsi_wl_init_wsi(&physical_device->wsi_device, &physical_device->instance->alloc,
-                            anv_physical_device_to_handle(physical_device));
-   if (result != VK_SUCCESS) {
-#ifdef VK_USE_PLATFORM_XCB_KHR
-      wsi_x11_finish_wsi(&physical_device->wsi_device, &physical_device->instance->alloc);
-#endif
-      return result;
-   }
-#endif
-
-   return VK_SUCCESS;
+   return wsi_device_init(&physical_device->wsi_device,
+                          anv_physical_device_to_handle(physical_device),
+                          anv_wsi_proc_addr,
+                          &physical_device->instance->alloc);
 }
 
 void
 anv_finish_wsi(struct anv_physical_device *physical_device)
 {
-#ifdef VK_USE_PLATFORM_WAYLAND_KHR
-   wsi_wl_finish_wsi(&physical_device->wsi_device, &physical_device->instance->alloc);
-#endif
-#ifdef VK_USE_PLATFORM_XCB_KHR
-   wsi_x11_finish_wsi(&physical_device->wsi_device, &physical_device->instance->alloc);
-#endif
+   wsi_device_finish(&physical_device->wsi_device,
+                     &physical_device->instance->alloc);
 }
 
 void anv_DestroySurfaceKHR(
index 9a5c78381ce004d9afff33a0e84009fe61750077..2de5f154c8a8d8606bed9e26a1b4f9861defa388 100644 (file)
 #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
index 65814435ce496d2d0e5b234896e0225a6e8c141b..3e0d3be1c24155aa395ab9463e56f32a3e61c545 100644 (file)
@@ -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,
index e29a239bd782ecb9d69100f082a2603c5067c720..503b2a015dc696517991f4467b2233fb20ebde33 100644 (file)
@@ -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)              \
                                                                            \