[Mesa-dev] [PATCH 1/2] vulkan/wsi: use swapchain->alloc for destructors.
Dave Airlie
airlied at gmail.com
Wed Oct 19 00:08:17 UTC 2016
From: Dave Airlie <airlied at redhat.com>
As Jason pointed out the app has to pass in the same thing,
so just destroy using the one we copied earlier.
Signed-off-by: Dave Airlie <airlied at redhat.com>
---
src/amd/vulkan/radv_wsi.c | 2 +-
src/intel/vulkan/anv_wsi.c | 8 +-------
src/vulkan/wsi/wsi_common.h | 4 ++--
src/vulkan/wsi/wsi_common_wayland.c | 10 +++++-----
src/vulkan/wsi/wsi_common_x11.c | 7 +++----
5 files changed, 12 insertions(+), 19 deletions(-)
diff --git a/src/amd/vulkan/radv_wsi.c b/src/amd/vulkan/radv_wsi.c
index ba5c37b..3c3abe9 100644
--- a/src/amd/vulkan/radv_wsi.c
+++ b/src/amd/vulkan/radv_wsi.c
@@ -291,7 +291,7 @@ void radv_DestroySwapchainKHR(
radv_DestroyFence(device, swapchain->fences[i], pAllocator);
}
- swapchain->destroy(swapchain, pAllocator);
+ swapchain->destroy(swapchain);
}
VkResult radv_GetSwapchainImagesKHR(
diff --git a/src/intel/vulkan/anv_wsi.c b/src/intel/vulkan/anv_wsi.c
index 064581d..f816735 100644
--- a/src/intel/vulkan/anv_wsi.c
+++ b/src/intel/vulkan/anv_wsi.c
@@ -290,20 +290,14 @@ void anv_DestroySwapchainKHR(
VkSwapchainKHR _swapchain,
const VkAllocationCallbacks* pAllocator)
{
- ANV_FROM_HANDLE(anv_device, device, _device);
ANV_FROM_HANDLE(wsi_swapchain, swapchain, _swapchain);
- const VkAllocationCallbacks *alloc;
- if (pAllocator)
- alloc = pAllocator;
- else
- alloc = &device->alloc;
for (unsigned i = 0; i < ARRAY_SIZE(swapchain->fences); i++) {
if (swapchain->fences[i] != VK_NULL_HANDLE)
anv_DestroyFence(_device, swapchain->fences[i], pAllocator);
}
- swapchain->destroy(swapchain, alloc);
+ swapchain->destroy(swapchain);
}
VkResult anv_GetSwapchainImagesKHR(
diff --git a/src/vulkan/wsi/wsi_common.h b/src/vulkan/wsi/wsi_common.h
index ee67511..1f4e0ae 100644
--- a/src/vulkan/wsi/wsi_common.h
+++ b/src/vulkan/wsi/wsi_common.h
@@ -54,8 +54,8 @@ struct wsi_swapchain {
const struct wsi_image_fns *image_fns;
VkFence fences[3];
- VkResult (*destroy)(struct wsi_swapchain *swapchain,
- const VkAllocationCallbacks *pAllocator);
+ VkResult (*destroy)(struct wsi_swapchain *swapchain);
+
VkResult (*get_images)(struct wsi_swapchain *swapchain,
uint32_t *pCount, VkImage *pSwapchainImages);
VkResult (*acquire_next_image)(struct wsi_swapchain *swap_chain,
diff --git a/src/vulkan/wsi/wsi_common_wayland.c b/src/vulkan/wsi/wsi_common_wayland.c
index 32a0a51..ecb1ab5 100644
--- a/src/vulkan/wsi/wsi_common_wayland.c
+++ b/src/vulkan/wsi/wsi_common_wayland.c
@@ -647,19 +647,19 @@ wsi_wl_image_init(struct wsi_wl_swapchain *chain,
}
static VkResult
-wsi_wl_swapchain_destroy(struct wsi_swapchain *wsi_chain,
- const VkAllocationCallbacks *pAllocator)
+wsi_wl_swapchain_destroy(struct wsi_swapchain *wsi_chain)
{
struct wsi_wl_swapchain *chain = (struct wsi_wl_swapchain *)wsi_chain;
for (uint32_t i = 0; i < chain->image_count; i++) {
if (chain->images[i].buffer)
- chain->base.image_fns->free_wsi_image(chain->base.device, pAllocator,
+ chain->base.image_fns->free_wsi_image(chain->base.device,
+ &chain->base.alloc,
chain->images[i].image,
chain->images[i].memory);
}
- vk_free(pAllocator, chain);
+ vk_free(&chain->base.alloc, chain);
return VK_SUCCESS;
}
@@ -747,7 +747,7 @@ wsi_wl_surface_create_swapchain(VkIcdSurfaceBase *icd_surface,
return VK_SUCCESS;
fail:
- wsi_wl_swapchain_destroy(&chain->base, pAllocator);
+ wsi_wl_swapchain_destroy(&chain->base);
return result;
}
diff --git a/src/vulkan/wsi/wsi_common_x11.c b/src/vulkan/wsi/wsi_common_x11.c
index 241ef42..3bb8f35 100644
--- a/src/vulkan/wsi/wsi_common_x11.c
+++ b/src/vulkan/wsi/wsi_common_x11.c
@@ -706,16 +706,15 @@ x11_image_finish(struct x11_swapchain *chain,
}
static VkResult
-x11_swapchain_destroy(struct wsi_swapchain *anv_chain,
- const VkAllocationCallbacks *pAllocator)
+x11_swapchain_destroy(struct wsi_swapchain *anv_chain)
{
struct x11_swapchain *chain = (struct x11_swapchain *)anv_chain;
for (uint32_t i = 0; i < chain->image_count; i++)
- x11_image_finish(chain, pAllocator, &chain->images[i]);
+ x11_image_finish(chain, &chain->base.alloc, &chain->images[i]);
xcb_unregister_for_special_event(chain->conn, chain->special_event);
- vk_free(pAllocator, chain);
+ vk_free(&chain->base.alloc, chain);
return VK_SUCCESS;
}
--
2.5.5
More information about the mesa-dev
mailing list