mirror of
https://gitlab.freedesktop.org/mesa/mesa.git
synced 2025-12-20 05:10:11 +01:00
wsi/wayland: Zero min_luminance, max_luminance HDR light levels are valid.
CTA-861-G section 6.9.1 Static Metadata Type 1 declares that zero values for different groups of HDR Metadata properties are allowed, including zero nits values for max display mastering luminance, max content light level, max frame-average light level and min display mastering luminance. A zero value is meant to be treated by the video sink as "undefined" / "unknown", and handled accordingly. This is common for dynamically generated visual content. The is_hdr_metadata_legal() function in the Vulkan/WSI/Wayland HDR backend currently declares HDR light level metadata as invalid if the mastering display min_luminance and max_luminance light levels are set to the legal level of zero nits. This causes valid HDR metadata as set by the client via vkSetHdrMetadata() to be not sent to the compositor. Fix this by skipping checks that don't apply if min_luminance or max_luminance are zero. If max_luminance is zero then we skip sending of mastering display min/max luminance to Wayland, as sending a a max_luminance <= min_luminance would trigger a protocol error. All other valid data is still send, ie. color primaries, white-point, content light levels. Fixes:cb7726bb2c("vulkan/wsi: validate HDR metadata to not cause protocol errors") Signed-off-by: Mario Kleiner <mario.kleiner.de@gmail.com> Co-authored-by: Michel Dänzer <michel@daenzer.net> Reviewed-by: Xaver Hugl <xaver.hugl@kde.org> (cherry picked from commit490f05f82c) Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/38432>
This commit is contained in:
parent
23665f9bd9
commit
28ca4a48d6
2 changed files with 20 additions and 6 deletions
|
|
@ -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
|
||||
|
|
|
|||
|
|
@ -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);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue