__tpl_wl_vk_wsi_surface_destroy_swapchain(tpl_surface_t *surface)
{
tpl_wayland_vk_wsi_surface_t *wayland_vk_wsi_surface = NULL;
+ tpl_wayland_vk_wsi_display_t *wayland_vk_wsi_display = NULL;
tpl_result_t res = TPL_ERROR_NONE;
unsigned int ref;
TPL_ASSERT(surface);
TPL_ASSERT(surface->backend.data);
TPL_ASSERT(surface->display);
+ TPL_ASSERT(surface->display->backend.data);
wayland_vk_wsi_surface = (tpl_wayland_vk_wsi_surface_t *) surface->backend.data;
- TPL_ASSERT(wayland_vk_wsi_surface);
+ wayland_vk_wsi_display = (tpl_wayland_vk_wsi_display_t *) surface->display->backend.data;
- ref = __tpl_util_atomic_dec(&wayland_vk_wsi_surface->swapchain_reference);
- if (ref > 0) {
- TPL_LOG_T("WL_VK",
- "This swapchain is still valid. | twe_surface(%p)",
- wayland_vk_wsi_surface->twe_surface);
- return TPL_ERROR_NONE;
- }
+ if (twe_display_lock(wayland_vk_wsi_display->twe_display) == TPL_ERROR_NONE) {
+ ref = __tpl_util_atomic_dec(&wayland_vk_wsi_surface->swapchain_reference);
+ if (ref > 0) {
+ TPL_LOG_T("WL_VK",
+ "This swapchain is still valid. | twe_surface(%p)",
+ wayland_vk_wsi_surface->twe_surface);
+ return TPL_ERROR_NONE;
+ }
- if (wayland_vk_wsi_surface->reset) {
- TPL_LOG_T("WL_VK",
- "Since reset is in the TRUE state, it will not be destroyed.");
- return TPL_ERROR_NONE;
- }
+ if (wayland_vk_wsi_surface->reset) {
+ TPL_LOG_T("WL_VK",
+ "Since reset is in the TRUE state, it will not be destroyed.");
+ return TPL_ERROR_NONE;
+ }
- res = twe_surface_destroy_swapchain(wayland_vk_wsi_surface->twe_surface);
- if (res != TPL_ERROR_NONE) {
- TPL_ERR("Failed to destroy swapchain. twe_surface(%p)",
- wayland_vk_wsi_surface->twe_surface);
- return res;
- }
+ res = twe_surface_destroy_swapchain(wayland_vk_wsi_surface->twe_surface);
+ if (res != TPL_ERROR_NONE) {
+ TPL_ERR("Failed to destroy swapchain. twe_surface(%p)",
+ wayland_vk_wsi_surface->twe_surface);
+ return res;
+ }
- wayland_vk_wsi_surface->tbm_queue = NULL;
+ wayland_vk_wsi_surface->tbm_queue = NULL;
+
+ twe_display_unlock(wayland_vk_wsi_display->twe_display);
+ }
return TPL_ERROR_NONE;
}