From: Jason Ekstrand Date: Tue, 21 Apr 2020 22:00:39 +0000 (-0500) Subject: vulkan/wsi: Make wsi_swapchain inherit from vk_object_base X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=cb1e0db23e3fa17562bb276b125aeab0b85582cb;p=mesa.git vulkan/wsi: Make wsi_swapchain inherit from vk_object_base Reviewed-by: Lionel Landwerlin Acked-by: Kristian H. Kristensen Acked-by: Bas Nieuwenhuizen Reviewed-by: Samuel Pitoiset Part-of: --- diff --git a/src/vulkan/wsi/wsi_common.c b/src/vulkan/wsi/wsi_common.c index 44454190840..7df24a61603 100644 --- a/src/vulkan/wsi/wsi_common.c +++ b/src/vulkan/wsi/wsi_common.c @@ -206,6 +206,8 @@ wsi_swapchain_init(const struct wsi_device *wsi, memset(chain, 0, sizeof(*chain)); + vk_object_base_init(NULL, &chain->base, VK_OBJECT_TYPE_SWAPCHAIN_KHR); + chain->wsi = wsi; chain->device = device; chain->alloc = *pAllocator; @@ -305,6 +307,8 @@ wsi_swapchain_finish(struct wsi_swapchain *chain) &chain->alloc); } vk_free(&chain->alloc, chain->cmd_pools); + + vk_object_base_finish(&chain->base); } static uint32_t @@ -1061,7 +1065,7 @@ wsi_common_destroy_swapchain(VkDevice device, VkSwapchainKHR _swapchain, const VkAllocationCallbacks *pAllocator) { - WSI_FROM_HANDLE(wsi_swapchain, swapchain, _swapchain); + VK_FROM_HANDLE(wsi_swapchain, swapchain, _swapchain); if (!swapchain) return; @@ -1073,7 +1077,7 @@ wsi_common_get_images(VkSwapchainKHR _swapchain, uint32_t *pSwapchainImageCount, VkImage *pSwapchainImages) { - WSI_FROM_HANDLE(wsi_swapchain, swapchain, _swapchain); + VK_FROM_HANDLE(wsi_swapchain, swapchain, _swapchain); VK_OUTARRAY_MAKE(images, pSwapchainImages, pSwapchainImageCount); for (uint32_t i = 0; i < swapchain->image_count; i++) { @@ -1091,7 +1095,7 @@ wsi_common_acquire_next_image2(const struct wsi_device *wsi, const VkAcquireNextImageInfoKHR *pAcquireInfo, uint32_t *pImageIndex) { - WSI_FROM_HANDLE(wsi_swapchain, swapchain, pAcquireInfo->swapchain); + VK_FROM_HANDLE(wsi_swapchain, swapchain, pAcquireInfo->swapchain); VkResult result = swapchain->acquire_next_image(swapchain, pAcquireInfo, pImageIndex); @@ -1135,7 +1139,7 @@ wsi_common_queue_present(const struct wsi_device *wsi, vk_find_struct_const(pPresentInfo->pNext, PRESENT_REGIONS_KHR); for (uint32_t i = 0; i < pPresentInfo->swapchainCount; i++) { - WSI_FROM_HANDLE(wsi_swapchain, swapchain, pPresentInfo->pSwapchains[i]); + VK_FROM_HANDLE(wsi_swapchain, swapchain, pPresentInfo->pSwapchains[i]); uint32_t image_index = pPresentInfo->pImageIndices[i]; VkResult result; diff --git a/src/vulkan/wsi/wsi_common_private.h b/src/vulkan/wsi/wsi_common_private.h index 88c360a2409..4b569d54704 100644 --- a/src/vulkan/wsi/wsi_common_private.h +++ b/src/vulkan/wsi/wsi_common_private.h @@ -24,6 +24,7 @@ #define WSI_COMMON_PRIVATE_H #include "wsi_common.h" +#include "vulkan/util/vk_object.h" struct wsi_image { VkImage image; @@ -44,6 +45,8 @@ struct wsi_image { }; struct wsi_swapchain { + struct vk_object_base base; + const struct wsi_device *wsi; VkDevice device; @@ -158,23 +161,7 @@ void wsi_display_finish_wsi(struct wsi_device *wsi_device, const VkAllocationCallbacks *alloc); -#define WSI_DEFINE_NONDISP_HANDLE_CASTS(__wsi_type, __VkType) \ - \ - static inline struct __wsi_type * \ - __wsi_type ## _from_handle(__VkType _handle) \ - { \ - return (struct __wsi_type *)(uintptr_t) _handle; \ - } \ - \ - static inline __VkType \ - __wsi_type ## _to_handle(struct __wsi_type *_obj) \ - { \ - return (__VkType)(uintptr_t) _obj; \ - } - -#define WSI_FROM_HANDLE(__wsi_type, __name, __handle) \ - struct __wsi_type *__name = __wsi_type ## _from_handle(__handle) - -WSI_DEFINE_NONDISP_HANDLE_CASTS(wsi_swapchain, VkSwapchainKHR) +VK_DEFINE_NONDISP_HANDLE_CASTS(wsi_swapchain, base, VkSwapchainKHR, + VK_OBJECT_TYPE_SWAPCHAIN_KHR) #endif /* WSI_COMMON_PRIVATE_H */ diff --git a/src/vulkan/wsi/wsi_common_wayland.c b/src/vulkan/wsi/wsi_common_wayland.c index dcea92a858a..23f5765c57c 100644 --- a/src/vulkan/wsi/wsi_common_wayland.c +++ b/src/vulkan/wsi/wsi_common_wayland.c @@ -755,7 +755,8 @@ struct wsi_wl_swapchain { struct wsi_wl_image images[0]; }; -WSI_DEFINE_NONDISP_HANDLE_CASTS(wsi_wl_swapchain, VkSwapchainKHR) +VK_DEFINE_NONDISP_HANDLE_CASTS(wsi_wl_swapchain, base.base, VkSwapchainKHR, + VK_OBJECT_TYPE_SWAPCHAIN_KHR) static struct wsi_image * wsi_wl_swapchain_get_wsi_image(struct wsi_swapchain *wsi_chain, @@ -1075,7 +1076,7 @@ wsi_wl_surface_create_swapchain(VkIcdSurfaceBase *icd_surface, /* If we have an oldSwapchain parameter, copy the display struct over * from the old one so we don't have to fully re-initialize it. */ - WSI_FROM_HANDLE(wsi_wl_swapchain, old_chain, pCreateInfo->oldSwapchain); + VK_FROM_HANDLE(wsi_wl_swapchain, old_chain, pCreateInfo->oldSwapchain); chain->display = wsi_wl_display_ref(old_chain->display); } else { chain->display = NULL; diff --git a/src/vulkan/wsi/wsi_common_x11.c b/src/vulkan/wsi/wsi_common_x11.c index 95106af5b6e..fd275ce7930 100644 --- a/src/vulkan/wsi/wsi_common_x11.c +++ b/src/vulkan/wsi/wsi_common_x11.c @@ -777,7 +777,8 @@ struct x11_swapchain { struct x11_image images[0]; }; -WSI_DEFINE_NONDISP_HANDLE_CASTS(x11_swapchain, VkSwapchainKHR) +VK_DEFINE_NONDISP_HANDLE_CASTS(x11_swapchain, base.base, VkSwapchainKHR, + VK_OBJECT_TYPE_SWAPCHAIN_KHR) /** * Update the swapchain status with the result of an operation, and return @@ -1489,7 +1490,7 @@ x11_surface_create_swapchain(VkIcdSurfaceBase *icd_surface, * mode which provokes reallocation when anything changes, to make * sure we have the most optimal allocation. */ - WSI_FROM_HANDLE(x11_swapchain, old_chain, pCreateInfo->oldSwapchain); + VK_FROM_HANDLE(x11_swapchain, old_chain, pCreateInfo->oldSwapchain); if (old_chain) chain->last_present_mode = old_chain->last_present_mode; else