From 0c943bbb6498319d3ee5405c969c4a7f7dd34104 Mon Sep 17 00:00:00 2001 From: Vlad Zahorodnii Date: Thu, 27 Mar 2025 10:42:58 +0200 Subject: [PATCH] vulkan/wsi/wayland: Damage whole surface using wl_surface_damage_buffer() Most compositors work with damage in the buffer local coordinate space. This change spares the compositors some work converting the provided INT32_MAX x INT32_MAX damage region to the buffer local coordinate space. It has no significant performance impact, but it'd still be nice to use wl_surface_damage_buffer() if possible. Part-of: --- src/vulkan/wsi/wsi_common_wayland.c | 19 +++++++++++-------- 1 file changed, 11 insertions(+), 8 deletions(-) diff --git a/src/vulkan/wsi/wsi_common_wayland.c b/src/vulkan/wsi/wsi_common_wayland.c index 57436b12a9e..2227930c826 100644 --- a/src/vulkan/wsi/wsi_common_wayland.c +++ b/src/vulkan/wsi/wsi_common_wayland.c @@ -2972,14 +2972,17 @@ wsi_wl_swapchain_queue_present(struct wsi_swapchain *wsi_chain, assert(image_index < chain->base.image_count); wl_surface_attach(wsi_wl_surface->surface, chain->images[image_index].buffer, 0, 0); - if (wl_surface_get_version(wsi_wl_surface->surface) >= 4 && damage && - damage->pRectangles && damage->rectangleCount > 0) { - for (unsigned i = 0; i < damage->rectangleCount; i++) { - const VkRectLayerKHR *rect = &damage->pRectangles[i]; - assert(rect->layer == 0); - wl_surface_damage_buffer(wsi_wl_surface->surface, - rect->offset.x, rect->offset.y, - rect->extent.width, rect->extent.height); + if (wl_surface_get_version(wsi_wl_surface->surface) >= WL_SURFACE_DAMAGE_BUFFER_SINCE_VERSION) { + if (damage && damage->pRectangles && damage->rectangleCount > 0) { + for (unsigned i = 0; i < damage->rectangleCount; i++) { + const VkRectLayerKHR *rect = &damage->pRectangles[i]; + assert(rect->layer == 0); + wl_surface_damage_buffer(wsi_wl_surface->surface, + rect->offset.x, rect->offset.y, + rect->extent.width, rect->extent.height); + } + } else { + wl_surface_damage_buffer(wsi_wl_surface->surface, 0, 0, INT32_MAX, INT32_MAX); } } else { wl_surface_damage(wsi_wl_surface->surface, 0, 0, INT32_MAX, INT32_MAX);