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;
&chain->alloc);
}
vk_free(&chain->alloc, chain->cmd_pools);
+
+ vk_object_base_finish(&chain->base);
}
static uint32_t
VkSwapchainKHR _swapchain,
const VkAllocationCallbacks *pAllocator)
{
- WSI_FROM_HANDLE(wsi_swapchain, swapchain, _swapchain);
+ VK_FROM_HANDLE(wsi_swapchain, swapchain, _swapchain);
if (!swapchain)
return;
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++) {
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);
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;
#define WSI_COMMON_PRIVATE_H
#include "wsi_common.h"
+#include "vulkan/util/vk_object.h"
struct wsi_image {
VkImage image;
};
struct wsi_swapchain {
+ struct vk_object_base base;
+
const struct wsi_device *wsi;
VkDevice device;
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 */
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,
/* 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;
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
* 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