mirror of
https://gitlab.freedesktop.org/mesa/mesa.git
synced 2025-12-23 04:40:09 +01:00
vulkan/wsi: Make wsi_swapchain inherit from vk_object_base
Reviewed-by: Lionel Landwerlin <lionel.g.landwerlin@intel.com> Acked-by: Kristian H. Kristensen <hoegsberg@google.com> Acked-by: Bas Nieuwenhuizen <bas@basnieuwenhuizen.nl> Reviewed-by: Samuel Pitoiset <samuel.pitoiset@gmail.com> Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/4690>
This commit is contained in:
parent
32f20783a5
commit
cb1e0db23e
4 changed files with 19 additions and 26 deletions
|
|
@ -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;
|
||||
|
||||
|
|
|
|||
|
|
@ -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 */
|
||||
|
|
|
|||
|
|
@ -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;
|
||||
|
|
|
|||
|
|
@ -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
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue