anv/wsi: abstract wsi interfaces away from device a bit more.
authorDave Airlie <airlied@redhat.com>
Thu, 13 Oct 2016 04:14:52 +0000 (05:14 +0100)
committerDave Airlie <airlied@redhat.com>
Wed, 19 Oct 2016 00:15:42 +0000 (10:15 +1000)
This is a step towards separating out the wsi code for sharing

Reviewed-by: Jason Ekstrand <jason@jlekstrand.net>
src/intel/vulkan/anv_private.h
src/intel/vulkan/anv_wsi.c
src/intel/vulkan/anv_wsi_wayland.c
src/intel/vulkan/anv_wsi_x11.c

index 8ba03300ce154d1f6e3864ccd0f1a0256cf30c25..62d3300d0ce7597cf04c933ea4cca12d107a6520 100644 (file)
@@ -455,6 +455,10 @@ extern struct anv_dispatch_table dtable;
 
 #define VK_ICD_WSI_PLATFORM_MAX 5
 
+struct anv_wsi_device {
+    struct anv_wsi_interface *                  wsi[VK_ICD_WSI_PLATFORM_MAX];
+};
+
 struct anv_physical_device {
     VK_LOADER_DATA                              _loader_data;
 
@@ -471,7 +475,7 @@ struct anv_physical_device {
     uint32_t                                    eu_total;
     uint32_t                                    subslice_total;
 
-    struct anv_wsi_interface *                  wsi[VK_ICD_WSI_PLATFORM_MAX];
+    struct anv_wsi_device                       wsi_device;
 };
 
 struct anv_instance {
index bd20cedd13276dbdc5ce6272e8b5327deda90422..56ed3ec70291fce86a917b6b0fb58f2ec57988b3 100644 (file)
@@ -28,7 +28,7 @@ anv_init_wsi(struct anv_physical_device *physical_device)
 {
    VkResult result;
 
-   memset(physical_device->wsi, 0, sizeof(physical_device->wsi));
+   memset(physical_device->wsi_device.wsi, 0, sizeof(physical_device->wsi_device.wsi));
 
 #ifdef VK_USE_PLATFORM_XCB_KHR
    result = anv_x11_init_wsi(physical_device);
@@ -79,7 +79,7 @@ VkResult anv_GetPhysicalDeviceSurfaceSupportKHR(
 {
    ANV_FROM_HANDLE(anv_physical_device, device, physicalDevice);
    ANV_FROM_HANDLE(_VkIcdSurfaceBase, surface, _surface);
-   struct anv_wsi_interface *iface = device->wsi[surface->platform];
+   struct anv_wsi_interface *iface = device->wsi_device.wsi[surface->platform];
 
    return iface->get_support(surface, device, queueFamilyIndex, pSupported);
 }
@@ -91,7 +91,7 @@ VkResult anv_GetPhysicalDeviceSurfaceCapabilitiesKHR(
 {
    ANV_FROM_HANDLE(anv_physical_device, device, physicalDevice);
    ANV_FROM_HANDLE(_VkIcdSurfaceBase, surface, _surface);
-   struct anv_wsi_interface *iface = device->wsi[surface->platform];
+   struct anv_wsi_interface *iface = device->wsi_device.wsi[surface->platform];
 
    return iface->get_capabilities(surface, pSurfaceCapabilities);
 }
@@ -104,7 +104,7 @@ VkResult anv_GetPhysicalDeviceSurfaceFormatsKHR(
 {
    ANV_FROM_HANDLE(anv_physical_device, device, physicalDevice);
    ANV_FROM_HANDLE(_VkIcdSurfaceBase, surface, _surface);
-   struct anv_wsi_interface *iface = device->wsi[surface->platform];
+   struct anv_wsi_interface *iface = device->wsi_device.wsi[surface->platform];
 
    return iface->get_formats(surface, device, pSurfaceFormatCount,
                              pSurfaceFormats);
@@ -118,7 +118,7 @@ VkResult anv_GetPhysicalDeviceSurfacePresentModesKHR(
 {
    ANV_FROM_HANDLE(anv_physical_device, device, physicalDevice);
    ANV_FROM_HANDLE(_VkIcdSurfaceBase, surface, _surface);
-   struct anv_wsi_interface *iface = device->wsi[surface->platform];
+   struct anv_wsi_interface *iface = device->wsi_device.wsi[surface->platform];
 
    return iface->get_present_modes(surface, pPresentModeCount,
                                    pPresentModes);
@@ -133,7 +133,7 @@ VkResult anv_CreateSwapchainKHR(
    ANV_FROM_HANDLE(anv_device, device, _device);
    ANV_FROM_HANDLE(_VkIcdSurfaceBase, surface, pCreateInfo->surface);
    struct anv_wsi_interface *iface =
-      device->instance->physicalDevice.wsi[surface->platform];
+      device->instance->physicalDevice.wsi_device.wsi[surface->platform];
    struct anv_swapchain *swapchain;
 
    VkResult result = iface->create_swapchain(surface, device, pCreateInfo,
index 2563dd75692fd63581887e7283e78231c63bb1a5..2c9eecfa64a48a1594c9ed75eb9ceead9cb1488f 100644 (file)
@@ -286,11 +286,11 @@ fail:
 }
 
 static struct wsi_wl_display *
-wsi_wl_get_display(struct anv_physical_device *device,
+wsi_wl_get_display(struct anv_wsi_device *wsi_device,
                    struct wl_display *wl_display)
 {
    struct wsi_wayland *wsi =
-      (struct wsi_wayland *)device->wsi[VK_ICD_WSI_PLATFORM_WAYLAND];
+      (struct wsi_wayland *)wsi_device->wsi[VK_ICD_WSI_PLATFORM_WAYLAND];
 
    pthread_mutex_lock(&wsi->mutex);
 
@@ -327,7 +327,7 @@ VkBool32 anv_GetPhysicalDeviceWaylandPresentationSupportKHR(
 {
    ANV_FROM_HANDLE(anv_physical_device, physical_device, physicalDevice);
 
-   return wsi_wl_get_display(physical_device, display) != NULL;
+   return wsi_wl_get_display(&physical_device->wsi_device, display) != NULL;
 }
 
 static VkResult
@@ -380,7 +380,7 @@ wsi_wl_surface_get_formats(VkIcdSurfaceBase *icd_surface,
 {
    VkIcdSurfaceWayland *surface = (VkIcdSurfaceWayland *)icd_surface;
    struct wsi_wl_display *display =
-      wsi_wl_get_display(device, surface->display);
+      wsi_wl_get_display(&device->wsi_device, surface->display);
 
    uint32_t count = u_vector_length(&display->formats);
 
@@ -785,7 +785,7 @@ wsi_wl_surface_create_swapchain(VkIcdSurfaceBase *icd_surface,
       chain->images[i].buffer = NULL;
    chain->queue = NULL;
 
-   chain->display = wsi_wl_get_display(&device->instance->physicalDevice,
+   chain->display = wsi_wl_get_display(&device->instance->physicalDevice.wsi_device,
                                        surface->display);
    if (!chain->display) {
       result = vk_error(VK_ERROR_INITIALIZATION_FAILED);
@@ -856,7 +856,7 @@ anv_wl_init_wsi(struct anv_physical_device *device)
    wsi->base.get_present_modes = wsi_wl_surface_get_present_modes;
    wsi->base.create_swapchain = wsi_wl_surface_create_swapchain;
 
-   device->wsi[VK_ICD_WSI_PLATFORM_WAYLAND] = &wsi->base;
+   device->wsi_device.wsi[VK_ICD_WSI_PLATFORM_WAYLAND] = &wsi->base;
 
    return VK_SUCCESS;
 
@@ -866,7 +866,7 @@ fail_mutex:
 fail_alloc:
    vk_free(&device->instance->alloc, wsi);
 fail:
-   device->wsi[VK_ICD_WSI_PLATFORM_WAYLAND] = NULL;
+   device->wsi_device.wsi[VK_ICD_WSI_PLATFORM_WAYLAND] = NULL;
 
    return result;
 }
@@ -875,7 +875,7 @@ void
 anv_wl_finish_wsi(struct anv_physical_device *device)
 {
    struct wsi_wayland *wsi =
-      (struct wsi_wayland *)device->wsi[VK_ICD_WSI_PLATFORM_WAYLAND];
+      (struct wsi_wayland *)device->wsi_device.wsi[VK_ICD_WSI_PLATFORM_WAYLAND];
 
    if (wsi) {
       _mesa_hash_table_destroy(wsi->displays, NULL);
index 3c9d4bd1f0d8ec382338807a3f2a63d5a0aa4bd9..595c9222d89eb019af8934784ea8ee8e84a5fb55 100644 (file)
@@ -87,12 +87,12 @@ wsi_x11_connection_destroy(const VkAllocationCallbacks *alloc,
 }
 
 static struct wsi_x11_connection *
-wsi_x11_get_connection(struct anv_wsi_interface **wsi_dev,
+wsi_x11_get_connection(struct anv_wsi_device *wsi_dev,
                        const VkAllocationCallbacks *alloc,
                        xcb_connection_t *conn)
 {
    struct wsi_x11 *wsi =
-      (struct wsi_x11 *)wsi_dev[VK_ICD_WSI_PLATFORM_XCB];
+      (struct wsi_x11 *)wsi_dev->wsi[VK_ICD_WSI_PLATFORM_XCB];
 
    pthread_mutex_lock(&wsi->mutex);
 
@@ -242,7 +242,7 @@ VkBool32 anv_GetPhysicalDeviceXcbPresentationSupportKHR(
    ANV_FROM_HANDLE(anv_physical_device, device, physicalDevice);
 
    struct wsi_x11_connection *wsi_conn =
-      wsi_x11_get_connection(device->wsi, &device->instance->alloc, connection);
+      wsi_x11_get_connection(&device->wsi_device, &device->instance->alloc, connection);
 
    if (!wsi_conn->has_dri3) {
       fprintf(stderr, "vulkan: No DRI3 support\n");
@@ -299,7 +299,7 @@ x11_surface_get_support(VkIcdSurfaceBase *icd_surface,
    xcb_window_t window = x11_surface_get_window(icd_surface);
 
    struct wsi_x11_connection *wsi_conn =
-      wsi_x11_get_connection(device->wsi, &device->instance->alloc, conn);
+      wsi_x11_get_connection(&device->wsi_device, &device->instance->alloc, conn);
    if (!wsi_conn)
       return vk_error(VK_ERROR_OUT_OF_HOST_MEMORY);
 
@@ -934,8 +934,8 @@ anv_x11_init_wsi(struct anv_physical_device *device)
    wsi->base.get_present_modes = x11_surface_get_present_modes;
    wsi->base.create_swapchain = x11_surface_create_swapchain;
 
-   device->wsi[VK_ICD_WSI_PLATFORM_XCB] = &wsi->base;
-   device->wsi[VK_ICD_WSI_PLATFORM_XLIB] = &wsi->base;
+   device->wsi_device.wsi[VK_ICD_WSI_PLATFORM_XCB] = &wsi->base;
+   device->wsi_device.wsi[VK_ICD_WSI_PLATFORM_XLIB] = &wsi->base;
 
    return VK_SUCCESS;
 
@@ -944,8 +944,8 @@ fail_mutex:
 fail_alloc:
    vk_free(&device->instance->alloc, wsi);
 fail:
-   device->wsi[VK_ICD_WSI_PLATFORM_XCB] = NULL;
-   device->wsi[VK_ICD_WSI_PLATFORM_XLIB] = NULL;
+   device->wsi_device.wsi[VK_ICD_WSI_PLATFORM_XCB] = NULL;
+   device->wsi_device.wsi[VK_ICD_WSI_PLATFORM_XLIB] = NULL;
 
    return result;
 }
@@ -954,7 +954,7 @@ void
 anv_x11_finish_wsi(struct anv_physical_device *device)
 {
    struct wsi_x11 *wsi =
-      (struct wsi_x11 *)device->wsi[VK_ICD_WSI_PLATFORM_XCB];
+      (struct wsi_x11 *)device->wsi_device.wsi[VK_ICD_WSI_PLATFORM_XCB];
 
    if (wsi) {
       _mesa_hash_table_destroy(wsi->connections, NULL);