vulkan/wsi/wayland: make needs_color_surface_old check if surface exists

Otherwise we end up removing refcount even when we don't have a color
surface already for applications going from SRGB_NONLINEAR to
PASS_THROUGH dring runtime.

To reproduce the bug, start mpv with "--target-colorspace-hint=yes" then
set it to "no" during runtime with a keybind

Fixes: 789507c99c ("vulkan/wsi: implement the Wayland color management protocol")
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/34708>
(cherry picked from commit 033ce1bae1)
This commit is contained in:
llyyr 2025-04-25 10:41:06 +05:30 committed by Eric Engestrom
parent 7e425861cf
commit b0b1820098
2 changed files with 4 additions and 3 deletions

View file

@ -664,7 +664,7 @@
"description": "vulkan/wsi/wayland: make needs_color_surface_old check if surface exists",
"nominated": true,
"nomination_type": 2,
"resolution": 0,
"resolution": 1,
"main_sha": null,
"because_sha": "789507c99c672320d50a6d8eb6910da51aa75443",
"notes": null

View file

@ -1238,8 +1238,9 @@ wsi_wl_swapchain_update_colorspace(struct wsi_wl_swapchain *chain)
bool new_color_surface = !surface->color.color_surface;
bool needs_color_surface_new = needs_color_surface(display, chain->color.colorspace);
bool needs_color_surface_old = needs_color_surface(display, surface->color.colorspace);
if ((new_color_surface || !needs_color_surface_old) && needs_color_surface_new) {
bool needs_color_surface_old = surface->color.color_surface &&
needs_color_surface(display, surface->color.colorspace);
if (!needs_color_surface_old && needs_color_surface_new) {
wsi_wl_surface_add_color_refcount(surface);
} else if (needs_color_surface_old && !needs_color_surface_new) {
wsi_wl_surface_remove_color_refcount(surface);