vulkan/wsi/wayland: Move drm syncobj to swapchain.

cc: mesa-stable
This commit is contained in:
Etaash Mathamsetty 2025-05-27 14:14:56 -04:00 committed by Etaash Mathamsetty
parent 26ef12f7c1
commit a2d765d4bf

View file

@ -185,9 +185,6 @@ struct wsi_wl_surface {
struct zwp_linux_dmabuf_feedback_v1 *wl_dmabuf_feedback;
struct dmabuf_feedback dmabuf_feedback, pending_dmabuf_feedback;
struct wp_linux_drm_syncobj_surface_v1 *wl_syncobj_surface;
struct vk_instance *instance;
struct {
@ -206,6 +203,7 @@ struct wsi_wl_swapchain {
struct wp_tearing_control_v1 *tearing_control;
struct wp_fifo_v1 *fifo;
struct wp_commit_timer_v1 *commit_timer;
struct wp_linux_drm_syncobj_surface_v1 *wl_syncobj_surface;
struct wl_callback *frame;
@ -1409,7 +1407,7 @@ wsi_wl_swapchain_update_colorspace(struct wsi_wl_swapchain *chain)
}
}
wp_color_management_surface_v1_set_image_description(chain->wsi_wl_surface->color.color_surface,
wp_color_management_surface_v1_set_image_description(chain->color.color_surface,
image_desc,
WP_COLOR_MANAGER_V1_RENDER_INTENT_PERCEPTUAL);
wp_image_description_v1_destroy(image_desc);
@ -2203,9 +2201,6 @@ wsi_wl_surface_destroy(VkIcdSurfaceBase *icd_surface, VkInstance _instance,
struct wsi_wl_surface *wsi_wl_surface =
wl_container_of((VkIcdSurfaceWayland *)icd_surface, wsi_wl_surface, base);
if (wsi_wl_surface->wl_syncobj_surface)
wp_linux_drm_syncobj_surface_v1_destroy(wsi_wl_surface->wl_syncobj_surface);
if (wsi_wl_surface->wl_dmabuf_feedback) {
zwp_linux_dmabuf_feedback_v1_destroy(wsi_wl_surface->wl_dmabuf_feedback);
dmabuf_feedback_fini(&wsi_wl_surface->dmabuf_feedback);
@ -2468,15 +2463,6 @@ static VkResult wsi_wl_surface_init(struct wsi_wl_surface *wsi_wl_surface,
wsi_wl_surface->display->queue);
}
if (wsi_wl_use_explicit_sync(wsi_wl_surface->display, wsi_device)) {
wsi_wl_surface->wl_syncobj_surface =
wp_linux_drm_syncobj_manager_v1_get_surface(wsi_wl_surface->display->wl_syncobj,
wsi_wl_surface->wayland_surface.wrapper);
if (!wsi_wl_surface->wl_syncobj_surface)
goto fail;
}
return VK_SUCCESS;
fail:
@ -3238,11 +3224,11 @@ wsi_wl_swapchain_queue_present(struct wsi_swapchain *wsi_chain,
/* Incremented by signal in base queue_present. */
uint64_t acquire_point = image->base.explicit_sync[WSI_ES_ACQUIRE].timeline;
uint64_t release_point = image->base.explicit_sync[WSI_ES_RELEASE].timeline;
wp_linux_drm_syncobj_surface_v1_set_acquire_point(wsi_wl_surface->wl_syncobj_surface,
wp_linux_drm_syncobj_surface_v1_set_acquire_point(chain->wl_syncobj_surface,
image->wl_syncobj_timeline[WSI_ES_ACQUIRE],
(uint32_t)(acquire_point >> 32),
(uint32_t)(acquire_point & 0xffffffff));
wp_linux_drm_syncobj_surface_v1_set_release_point(wsi_wl_surface->wl_syncobj_surface,
wp_linux_drm_syncobj_surface_v1_set_release_point(chain->wl_syncobj_surface,
image->wl_syncobj_timeline[WSI_ES_RELEASE],
(uint32_t)(release_point >> 32),
(uint32_t)(release_point & 0xffffffff));
@ -3591,6 +3577,8 @@ wsi_wl_swapchain_chain_free(struct wsi_wl_swapchain *chain,
wl_callback_destroy(chain->frame);
if (chain->tearing_control)
wp_tearing_control_v1_destroy(chain->tearing_control);
if (chain->wl_syncobj_surface)
wp_linux_drm_syncobj_surface_v1_destroy(chain->wl_syncobj_surface);
if (needs_color_surface(wsi_wl_surface->display, chain->color.colorspace) &&
wsi_wl_surface->color.color_surface) {
wsi_wl_surface_remove_color_refcount(wsi_wl_surface);
@ -3722,6 +3710,10 @@ wsi_wl_surface_create_swapchain(VkIcdSurfaceBase *icd_surface,
wp_commit_timer_v1_destroy(old_chain->commit_timer);
old_chain->commit_timer = NULL;
}
if (old_chain->wl_syncobj_surface) {
wp_linux_drm_syncobj_surface_v1_destroy(old_chain->wl_syncobj_surface);
old_chain->wl_syncobj_surface = NULL;
}
}
/* Take ownership of the wsi_wl_surface */
@ -3770,6 +3762,17 @@ wsi_wl_surface_create_swapchain(VkIcdSurfaceBase *icd_surface,
WP_TEARING_CONTROL_V1_PRESENTATION_HINT_ASYNC);
}
if (wsi_wl_use_explicit_sync(wsi_wl_surface->display, wsi_device)) {
chain->wl_syncobj_surface =
wp_linux_drm_syncobj_manager_v1_get_surface(wsi_wl_surface->display->wl_syncobj,
wsi_wl_surface->wayland_surface.wrapper);
if (!chain->wl_syncobj_surface) {
result = VK_ERROR_OUT_OF_HOST_MEMORY;
goto fail;
}
}
chain->color.colorspace = pCreateInfo->imageColorSpace;
enum wsi_wl_buffer_type buffer_type;