Module: Mesa Branch: staging/23.3 Commit: d1fc7854dc171b7bca97de30e40940ae7ce4fc6a URL: http://cgit.freedesktop.org/mesa/mesa/commit/?id=d1fc7854dc171b7bca97de30e40940ae7ce4fc6a
Author: Yiwei Zhang <[email protected]> Date: Sat Dec 9 23:31:05 2023 +0000 vulkan/wsi/wayland: ensure drm modifiers stored in chain are immutable Chain stored modifiers point to the mapping of the current feedback shmem of the surface. The surface tracked feedback mapping will be gone and replaced with new mapping during surface_dmabuf_feedback_done. There are two issues here: 1. One issue is that the existing mapping is closed before been used to compare against new modifiers in sets_of_modifiers_are_the_same. 2. The other issue is that when the chain is still optimal, the chain persists while the mapping is still replaced with the one from the new format table shmem. This change makes a deep copy of the modifiers to store in the chain to ensure the modifiers used for the current chain are immutable through the chain lifecycle. Cc: mesa-stable Signed-off-by: Yiwei Zhang <[email protected]> Reviewed-by: Lionel Landwerlin <[email protected]> Reviewed-by: Leandro Ribeiro <[email protected]> Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/26618> (cherry picked from commit ddf2ca4faffdd309638aa0ebfcba2c43b4fc439d) --- .pick_status.json | 2 +- src/vulkan/wsi/wsi_common_wayland.c | 13 ++++++++++++- 2 files changed, 13 insertions(+), 2 deletions(-) diff --git a/.pick_status.json b/.pick_status.json index 621d38f2616..bbfbf4fca4e 100644 --- a/.pick_status.json +++ b/.pick_status.json @@ -14,7 +14,7 @@ "description": "vulkan/wsi/wayland: ensure drm modifiers stored in chain are immutable", "nominated": true, "nomination_type": 0, - "resolution": 0, + "resolution": 1, "main_sha": null, "because_sha": null, "notes": null diff --git a/src/vulkan/wsi/wsi_common_wayland.c b/src/vulkan/wsi/wsi_common_wayland.c index 94b9217cbdf..22e26bacbc5 100644 --- a/src/vulkan/wsi/wsi_common_wayland.c +++ b/src/vulkan/wsi/wsi_common_wayland.c @@ -2215,6 +2215,8 @@ wsi_wl_swapchain_chain_free(struct wsi_wl_swapchain *chain, pthread_mutex_destroy(&chain->present_ids.lock); } + vk_free(pAllocator, (void *)chain->drm_modifiers); + wsi_swapchain_finish(&chain->base); } @@ -2370,7 +2372,16 @@ wsi_wl_surface_create_swapchain(VkIcdSurfaceBase *icd_surface, chain->shm_format = wl_shm_format_for_vk_format(chain->vk_format, alpha); } chain->num_drm_modifiers = num_drm_modifiers; - chain->drm_modifiers = drm_modifiers; + if (num_drm_modifiers) { + uint64_t *drm_modifiers_copy = + vk_alloc(pAllocator, sizeof(*drm_modifiers) * num_drm_modifiers, 8, + VK_SYSTEM_ALLOCATION_SCOPE_OBJECT); + if (!drm_modifiers_copy) + goto fail; + + typed_memcpy(drm_modifiers_copy, drm_modifiers, num_drm_modifiers); + chain->drm_modifiers = drm_modifiers_copy; + } if (chain->wsi_wl_surface->display->wp_presentation_notwrapped) { if (!wsi_init_pthread_cond_monotonic(&chain->present_ids.list_advanced))
