wsi/display: Clean up DRM hdr/color state on swapchain destruction

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.

Signed-off-by: Joshua Ashton <joshua@froggi.es>
Reviewed-by: Emma Anholt <emma@anholt.net>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/35461>
This commit is contained in:
Joshua Ashton 2022-11-15 21:08:40 +00:00 committed by Marge Bot
parent b4176393a0
commit 1ed78dd7ec

View file

@ -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.