diff --git a/src/vulkan/wsi/wsi_common_display.c b/src/vulkan/wsi/wsi_common_display.c index b73eec57bb5..f4dab910f79 100644 --- a/src/vulkan/wsi/wsi_common_display.c +++ b/src/vulkan/wsi/wsi_common_display.c @@ -372,6 +372,9 @@ struct wsi_display_sync { static uint64_t fence_sequence; +static void +_wsi_display_cleanup_state(struct wsi_display_swapchain *chain); + ICD_DEFINE_NONDISP_HANDLE_CASTS(wsi_display_mode, VkDisplayModeKHR) ICD_DEFINE_NONDISP_HANDLE_CASTS(wsi_display_connector, VkDisplayKHR) @@ -1528,6 +1531,8 @@ wsi_display_swapchain_destroy(struct wsi_swapchain *drv_chain, struct wsi_display_swapchain *chain = (struct wsi_display_swapchain *) drv_chain; + _wsi_display_cleanup_state(chain); + for (uint32_t i = 0; i < chain->base.image_count; i++) wsi_display_image_finish(drv_chain, &chain->images[i]); @@ -2499,6 +2504,30 @@ out: return ret; } +static void +_wsi_display_cleanup_state(struct wsi_display_swapchain *chain) +{ + VkIcdSurfaceDisplay *surface = chain->surface; + wsi_display_mode *display_mode = + wsi_display_mode_from_handle(surface->displayMode); + wsi_display_connector *connector = display_mode->connector; + + /* Reset our color outcome to defaults, and update the state. + * We need to clean up after our mess, for any other compositors, + * etc that come after us that may not be aware of properties + * we have set. + * We can do this by just setting ourselves back to sRGB and therefore + * SDR and updating like normal. + * We only need to do this if we have a color outcome serial that isn't + * 0, the default. + */ + if (chain->color_outcome_serial) { + chain->color_outcome_serial = 0; + chain->base.image_info.color_space = VK_COLOR_SPACE_SRGB_NONLINEAR_KHR; + drm_atomic_commit(connector, &chain->images[0]); + } +} + /* * Check to see if the kernel has no flip queued and if there's an image * waiting to be displayed.