diff --git a/.pick_status.json b/.pick_status.json index 78fa2dfc86d..2516800c491 100644 --- a/.pick_status.json +++ b/.pick_status.json @@ -34,7 +34,7 @@ "description": "wsi/wayland: Zero min_luminance, max_luminance HDR light levels are valid.", "nominated": true, "nomination_type": 2, - "resolution": 0, + "resolution": 1, "main_sha": null, "because_sha": "cb7726bb2cf7e25661c1401dbef2a6a597748ecd", "notes": null diff --git a/src/vulkan/wsi/wsi_common_wayland.c b/src/vulkan/wsi/wsi_common_wayland.c index ae9aa257bf6..cf3749be6d4 100644 --- a/src/vulkan/wsi/wsi_common_wayland.c +++ b/src/vulkan/wsi/wsi_common_wayland.c @@ -1192,18 +1192,26 @@ is_hdr_metadata_legal(struct wayland_hdr_metadata *l) if (l->max_cll != 0) { if (l->max_cll * MIN_LUM_FACTOR < l->min_luminance) return false; - if (l->max_cll > l->max_luminance) + if (l->max_luminance != 0 && l->max_cll > l->max_luminance) return false; } if (l->max_fall != 0) { if (l->max_fall * MIN_LUM_FACTOR < l->min_luminance) return false; - if (l->max_fall > l->max_luminance) + if (l->max_luminance != 0 && l->max_fall > l->max_luminance) return false; if (l->max_cll != 0 && l->max_fall > l->max_cll) { return false; } } + + /* Be lenient here for a zero (=undefined) max_luminance and handle + * this in the calling code instead, by not sending min/max mastering + * luminance data to Wayland, thereby avoiding protocol errors. + */ + if (l->max_luminance == 0) + return true; + return l->max_luminance * MIN_LUM_FACTOR > l->min_luminance; } @@ -1321,9 +1329,15 @@ wsi_wl_swapchain_update_colorspace(struct wsi_wl_swapchain *chain) green_x, green_y, blue_x, blue_y, white_x, white_y); - wp_image_description_creator_params_v1_set_mastering_luminance(creator, - wayland_hdr_metadata.min_luminance, - wayland_hdr_metadata.max_luminance); + + /* A max_luminance of 0 is legal by spec and means "undefined", but would cause a + * Wayland protocol error, so skip setting mastering luminance for zero value. + */ + if (wayland_hdr_metadata.max_luminance != 0) { + wp_image_description_creator_params_v1_set_mastering_luminance(creator, + wayland_hdr_metadata.min_luminance, + wayland_hdr_metadata.max_luminance); + } } }