[Mesa-dev] [PATCH 12/22] anv/wsi: switch to using VkDevice in swapchain

Dave Airlie airlied at gmail.com
Mon Oct 17 04:24:35 UTC 2016


From: Dave Airlie <airlied at redhat.com>

---
 src/intel/vulkan/anv_wsi.c         |  2 +-
 src/intel/vulkan/anv_wsi.h         |  2 +-
 src/intel/vulkan/anv_wsi_wayland.c | 15 ++++++++-------
 src/intel/vulkan/anv_wsi_x11.c     |  9 ++++-----
 4 files changed, 14 insertions(+), 14 deletions(-)

diff --git a/src/intel/vulkan/anv_wsi.c b/src/intel/vulkan/anv_wsi.c
index 5b94e75..f91e6f6 100644
--- a/src/intel/vulkan/anv_wsi.c
+++ b/src/intel/vulkan/anv_wsi.c
@@ -207,7 +207,7 @@ VkResult anv_QueuePresentKHR(
    for (uint32_t i = 0; i < pPresentInfo->swapchainCount; i++) {
       ANV_FROM_HANDLE(anv_swapchain, swapchain, pPresentInfo->pSwapchains[i]);
 
-      assert(swapchain->device == queue->device);
+      assert(anv_device_from_handle(swapchain->device) == queue->device);
 
       if (swapchain->fences[0] == VK_NULL_HANDLE) {
          result = anv_CreateFence(anv_device_to_handle(queue->device),
diff --git a/src/intel/vulkan/anv_wsi.h b/src/intel/vulkan/anv_wsi.h
index 8b1f106..1b7147d 100644
--- a/src/intel/vulkan/anv_wsi.h
+++ b/src/intel/vulkan/anv_wsi.h
@@ -51,8 +51,8 @@ struct anv_wsi_interface {
 };
 
 struct anv_swapchain {
-   struct anv_device *device;
 
+   VkDevice device;
    VkAllocationCallbacks alloc;
 
    VkFence fences[3];
diff --git a/src/intel/vulkan/anv_wsi_wayland.c b/src/intel/vulkan/anv_wsi_wayland.c
index 0c55ad2..dc239c9 100644
--- a/src/intel/vulkan/anv_wsi_wayland.c
+++ b/src/intel/vulkan/anv_wsi_wayland.c
@@ -588,7 +588,7 @@ static void
 wsi_wl_image_finish(struct wsi_wl_swapchain *chain, struct wsi_wl_image *image,
                     const VkAllocationCallbacks* pAllocator)
 {
-   VkDevice vk_device = anv_device_to_handle(chain->base.device);
+   VkDevice vk_device = chain->base.device;
    anv_FreeMemory(vk_device, anv_device_memory_to_handle(image->memory),
                   pAllocator);
    anv_DestroyImage(vk_device, anv_image_to_handle(image->image),
@@ -615,7 +615,8 @@ wsi_wl_image_init(struct wsi_wl_swapchain *chain,
                   const VkSwapchainCreateInfoKHR *pCreateInfo,
                   const VkAllocationCallbacks* pAllocator)
 {
-   VkDevice vk_device = anv_device_to_handle(chain->base.device);
+   VkDevice vk_device = chain->base.device;
+   struct anv_device *device = anv_device_from_handle(vk_device);
    VkResult result;
 
    VkImage vk_image;
@@ -674,7 +675,7 @@ wsi_wl_image_init(struct wsi_wl_swapchain *chain,
    if (result != VK_SUCCESS)
       goto fail_mem;
 
-   int ret = anv_gem_set_tiling(chain->base.device,
+   int ret = anv_gem_set_tiling(device,
                                 image->memory->bo.gem_handle,
                                 surface->isl.row_pitch, I915_TILING_X);
    if (ret) {
@@ -683,7 +684,7 @@ wsi_wl_image_init(struct wsi_wl_swapchain *chain,
       goto fail_mem;
    }
 
-   int fd = anv_gem_handle_to_fd(chain->base.device,
+   int fd = anv_gem_handle_to_fd(device,
                                  image->memory->bo.gem_handle);
    if (fd == -1) {
       /* FINISHME: Choose a better error. */
@@ -720,13 +721,13 @@ wsi_wl_swapchain_destroy(struct anv_swapchain *anv_chain,
                          const VkAllocationCallbacks *pAllocator)
 {
    struct wsi_wl_swapchain *chain = (struct wsi_wl_swapchain *)anv_chain;
-
+   struct anv_device *device = anv_device_from_handle(chain->base.device);
    for (uint32_t i = 0; i < chain->image_count; i++) {
       if (chain->images[i].buffer)
          wsi_wl_image_finish(chain, &chain->images[i], pAllocator);
    }
 
-   vk_free2(&chain->base.device->alloc, pAllocator, chain);
+   vk_free2(&device->alloc, pAllocator, chain);
 
    return VK_SUCCESS;
 }
@@ -763,7 +764,7 @@ wsi_wl_surface_create_swapchain(VkIcdSurfaceBase *icd_surface,
    if (chain == NULL)
       return vk_error(VK_ERROR_OUT_OF_HOST_MEMORY);
 
-   chain->base.device = device;
+   chain->base.device = anv_device_to_handle(device);
    chain->base.destroy = wsi_wl_swapchain_destroy;
    chain->base.get_images = wsi_wl_swapchain_get_images;
    chain->base.acquire_next_image = wsi_wl_swapchain_acquire_next_image;
diff --git a/src/intel/vulkan/anv_wsi_x11.c b/src/intel/vulkan/anv_wsi_x11.c
index 06f0566..8f9f741 100644
--- a/src/intel/vulkan/anv_wsi_x11.c
+++ b/src/intel/vulkan/anv_wsi_x11.c
@@ -844,8 +844,7 @@ x11_image_finish(struct x11_swapchain *chain,
    cookie = xcb_free_pixmap(chain->conn, image->pixmap);
    xcb_discard_reply(chain->conn, cookie.sequence);
 
-   x11_anv_free_image(anv_device_to_handle(chain->base.device),
-                      pAllocator,
+   x11_anv_free_image(chain->base.device, pAllocator,
                       image->image, image->memory);
 }
 
@@ -854,13 +853,13 @@ x11_swapchain_destroy(struct anv_swapchain *anv_chain,
                       const VkAllocationCallbacks *pAllocator)
 {
    struct x11_swapchain *chain = (struct x11_swapchain *)anv_chain;
-
+   struct anv_device *device = anv_device_from_handle(chain->base.device);
    for (uint32_t i = 0; i < chain->image_count; i++)
       x11_image_finish(chain, pAllocator, &chain->images[i]);
 
    xcb_unregister_for_special_event(chain->conn, chain->special_event);
 
-   vk_free2(&chain->base.device->alloc, pAllocator, chain);
+   vk_free2(&device->alloc, pAllocator, chain);
 
    return VK_SUCCESS;
 }
@@ -895,7 +894,7 @@ x11_surface_create_swapchain(VkIcdSurfaceBase *icd_surface,
    if (chain == NULL)
       return vk_error(VK_ERROR_OUT_OF_HOST_MEMORY);
 
-   chain->base.device = device;
+   chain->base.device = anv_device_to_handle(device);
    chain->base.destroy = x11_swapchain_destroy;
    chain->base.get_images = x11_get_images;
    chain->base.acquire_next_image = x11_acquire_next_image;
-- 
2.5.5



More information about the mesa-dev mailing list