mesa 25.0.7

This commit is contained in:
Anders Rytter Hansen 2025-06-05 17:45:13 +02:00
commit 19b421152c
7 changed files with 316 additions and 2 deletions

View file

@ -0,0 +1,59 @@
From 779c8d1669fa74b31e296519f6920e5479c19973 Mon Sep 17 00:00:00 2001
From: Xaver Hugl <xaver.hugl@kde.org>
Date: Thu, 27 Feb 2025 14:56:06 +0100
Subject: [PATCH] vulkan/wsi: don't use sRGB if the compositor doesn't support
it
This could realistically happen if the compositor doesn't support parametric image
descriptions at all, in which case we'd get a protocol error for trying to use it.
Signed-off-by: Xaver Hugl <xaver.hugl@kde.org>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/33804>
---
src/vulkan/wsi/wsi_common_wayland.c | 15 +++++++++++----
1 file changed, 11 insertions(+), 4 deletions(-)
diff --git a/src/vulkan/wsi/wsi_common_wayland.c b/src/vulkan/wsi/wsi_common_wayland.c
index 098ba9c80928e..3f636a5aad1a0 100644
--- a/src/vulkan/wsi/wsi_common_wayland.c
+++ b/src/vulkan/wsi/wsi_common_wayland.c
@@ -1139,8 +1139,14 @@ static const struct wp_image_description_v1_listener image_description_listener
};
static bool
-needs_color_surface(VkColorSpaceKHR colorspace)
+needs_color_surface(struct wsi_wl_display *display, VkColorSpaceKHR colorspace)
{
+ if (colorspace == VK_COLOR_SPACE_SRGB_NONLINEAR_KHR) {
+ /* we want to use a color surface to set sRGB if possible, but
+ * only if the compositor actually supports sRGB */
+ return vector_contains(&display->color_primaries, WP_COLOR_MANAGER_V1_PRIMARIES_SRGB)
+ && vector_contains(&display->color_transfer_funcs, WP_COLOR_MANAGER_V1_TRANSFER_FUNCTION_SRGB);
+ }
return colorspace != VK_COLOR_SPACE_PASS_THROUGH_EXT;
}
@@ -1199,8 +1205,8 @@ 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(chain->color.colorspace);
- bool needs_color_surface_old = needs_color_surface(surface->color.colorspace);
+ 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) {
wsi_wl_surface_add_color_refcount(surface);
} else if (needs_color_surface_old && !needs_color_surface_new) {
@@ -3293,7 +3299,8 @@ wsi_wl_swapchain_chain_free(struct wsi_wl_swapchain *chain,
wl_callback_destroy(chain->frame);
if (chain->tearing_control)
wp_tearing_control_v1_destroy(chain->tearing_control);
- if (needs_color_surface(chain->color.colorspace) && wsi_wl_surface->color.color_surface) {
+ if (needs_color_surface(wsi_wl_surface->display, chain->color.colorspace) &&
+ wsi_wl_surface->color.color_surface) {
wsi_wl_surface_remove_color_refcount(wsi_wl_surface);
}
--
GitLab

View file

@ -0,0 +1,100 @@
From cb7726bb2cf7e25661c1401dbef2a6a597748ecd Mon Sep 17 00:00:00 2001
From: Xaver Hugl <xaver.hugl@kde.org>
Date: Tue, 11 Mar 2025 13:48:31 +0100
Subject: [PATCH] vulkan/wsi: validate HDR metadata to not cause protocol
errors
If it would trigger a protocol error, we must not use it.
Signed-off-by: Xaver Hugl <xaver.hugl@kde.org>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/34000>
---
src/vulkan/wsi/wsi_common_wayland.c | 51 ++++++++++++++++++++++++-----
1 file changed, 43 insertions(+), 8 deletions(-)
diff --git a/src/vulkan/wsi/wsi_common_wayland.c b/src/vulkan/wsi/wsi_common_wayland.c
index ddfbd863c94b0..68254dc8610dc 100644
--- a/src/vulkan/wsi/wsi_common_wayland.c
+++ b/src/vulkan/wsi/wsi_common_wayland.c
@@ -1172,6 +1172,36 @@ wsi_wl_surface_remove_color_refcount(struct wsi_wl_surface *wsi_surface)
}
}
+struct wayland_hdr_metadata {
+ uint32_t min_luminance;
+ uint32_t max_luminance;
+ uint32_t max_fall;
+ uint32_t max_cll;
+};
+
+#define MIN_LUM_FACTOR 10000
+
+static bool
+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)
+ 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)
+ return false;
+ if (l->max_cll != 0 && l->max_fall > l->max_cll) {
+ return false;
+ }
+ }
+ return l->max_luminance * MIN_LUM_FACTOR > l->min_luminance;
+}
+
static bool
compare_hdr_metadata(struct VkHdrMetadataEXT *l, struct VkHdrMetadataEXT *r)
{
@@ -1215,7 +1245,14 @@ wsi_wl_swapchain_update_colorspace(struct wsi_wl_swapchain *chain)
wsi_wl_surface_remove_color_refcount(surface);
}
- bool should_use_hdr_metadata = chain->color.has_hdr_metadata;
+ struct wayland_hdr_metadata wayland_hdr_metadata = {
+ .min_luminance = round(MIN_LUM_FACTOR * chain->color.hdr_metadata.minLuminance),
+ .max_luminance = round(chain->color.hdr_metadata.maxLuminance),
+ .max_fall = round(chain->color.hdr_metadata.maxFrameAverageLightLevel),
+ .max_cll = round(chain->color.hdr_metadata.maxContentLightLevel),
+ };
+ bool should_use_hdr_metadata = chain->color.has_hdr_metadata
+ && is_hdr_metadata_legal(&wayland_hdr_metadata);
for (int i = 0; i < ARRAY_SIZE(colorspace_mapping); i++) {
if (colorspace_mapping[i].colorspace == chain->color.colorspace) {
should_use_hdr_metadata &= colorspace_mapping[i].should_use_hdr_metadata;
@@ -1259,10 +1296,8 @@ wsi_wl_swapchain_update_colorspace(struct wsi_wl_swapchain *chain)
wp_image_description_creator_params_v1_set_primaries_named(creator, primaries);
wp_image_description_creator_params_v1_set_tf_named(creator, tf);
if (should_use_hdr_metadata) {
- uint32_t max_cll = round(chain->color.hdr_metadata.maxContentLightLevel);
- uint32_t max_fall = round(chain->color.hdr_metadata.maxFrameAverageLightLevel);
- wp_image_description_creator_params_v1_set_max_cll(creator, max_cll);
- wp_image_description_creator_params_v1_set_max_fall(creator, max_fall);
+ wp_image_description_creator_params_v1_set_max_cll(creator, wayland_hdr_metadata.max_cll);
+ wp_image_description_creator_params_v1_set_max_fall(creator, wayland_hdr_metadata.max_fall);
if (display->color_features.mastering_display_primaries) {
uint32_t red_x = round(chain->color.hdr_metadata.displayPrimaryRed.x * 1000000);
uint32_t red_y = round(chain->color.hdr_metadata.displayPrimaryRed.y * 1000000);
@@ -1276,9 +1311,9 @@ wsi_wl_swapchain_update_colorspace(struct wsi_wl_swapchain *chain)
green_x, green_y,
blue_x, blue_y,
white_x, white_y);
- uint32_t min_lum = round(chain->color.hdr_metadata.minLuminance * 10000);
- uint32_t max_lum = round(chain->color.hdr_metadata.maxLuminance);
- wp_image_description_creator_params_v1_set_mastering_luminance(creator, min_lum, max_lum);
+ wp_image_description_creator_params_v1_set_mastering_luminance(creator,
+ wayland_hdr_metadata.min_luminance,
+ wayland_hdr_metadata.max_luminance);
}
}
--
GitLab

View file

@ -0,0 +1,33 @@
From c2570055d5b45df6f2c10c2c1f2235c77db5641f Mon Sep 17 00:00:00 2001
From: Lars-Ivar Hesselberg Simonsen <lars-ivar.simonsen@arm.com>
Date: Mon, 7 Apr 2025 16:29:25 +0200
Subject: [PATCH] vulkan/wsi/wayland: Avoid duplicate colorspace entry
The colorspace SRGB_NONLINEAR could be added twice when querying
available formats, leading to duplicate entries and VulkanCTS WSI test
failures.
Fixes: 789507c99c6 ("vulkan/wsi: implement the Wayland color management protocol")
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/34410>
---
src/vulkan/wsi/wsi_common_wayland.c | 4 +++-
1 file changed, 3 insertions(+), 1 deletion(-)
diff --git a/src/vulkan/wsi/wsi_common_wayland.c b/src/vulkan/wsi/wsi_common_wayland.c
index 6632522292798..ddfbd863c94b0 100644
--- a/src/vulkan/wsi/wsi_common_wayland.c
+++ b/src/vulkan/wsi/wsi_common_wayland.c
@@ -1033,7 +1033,9 @@ wsi_wl_display_determine_colorspaces(struct wsi_wl_display *display)
struct u_vector *tfs = &display->color_transfer_funcs;
struct u_vector *primaries = &display->color_primaries;
- for (int i = 0; i < ARRAY_SIZE(colorspace_mapping); i++) {
+ /* Skip SRGB_NONLINEAR (i = 0), which has already been added above. */
+ assert(colorspace_mapping[0].colorspace == VK_COLOR_SPACE_SRGB_NONLINEAR_KHR);
+ for (int i = 1; i < ARRAY_SIZE(colorspace_mapping); i++) {
if (!vector_contains(primaries, colorspace_mapping[i].primaries))
continue;
if (!vector_contains(tfs, colorspace_mapping[i].tf))
--
GitLab

View file

@ -0,0 +1,38 @@
From dc90e33ad2b693b1b97ba844a79d709d15c45a2d Mon Sep 17 00:00:00 2001
From: llyyr <llyyr.public@gmail.com>
Date: Thu, 3 Apr 2025 09:19:42 +0530
Subject: [PATCH] vulkan/wsi/wayland: initialize surface colorspace with
PASS_THROUGH_EXT
Starting with sRGB meant we would refcount to -1 if an application
chooses PASS_THROUGH. Instead, just initialize with PASS_THROUGH so the
initial refcount of 0 reflects reality.
Previously, we would segfault if an application chose PASS_THROUGH at
swapchain initialization then switched to a color managed colorspace
later in the runtime, because we would increment refcount from -1 -> 0
and this would result in not creating a new color managed surface.
Fixes: 789507c99c67 ("vulkan/wsi: implement the Wayland color management protocol")
Signed-off-by: llyyr <llyyr.public@gmail.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/34353>
---
src/vulkan/wsi/wsi_common_wayland.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/src/vulkan/wsi/wsi_common_wayland.c b/src/vulkan/wsi/wsi_common_wayland.c
index 3f636a5aad1a0..57436b12a9efc 100644
--- a/src/vulkan/wsi/wsi_common_wayland.c
+++ b/src/vulkan/wsi/wsi_common_wayland.c
@@ -2315,7 +2315,7 @@ wsi_CreateWaylandSurfaceKHR(VkInstance _instance,
surface->surface = pCreateInfo->surface;
wsi_wl_surface->instance = instance;
- wsi_wl_surface->color.colorspace = VK_COLOR_SPACE_SRGB_NONLINEAR_KHR;
+ wsi_wl_surface->color.colorspace = VK_COLOR_SPACE_PASS_THROUGH_EXT;
*pSurface = VkIcdSurfaceBase_to_handle(&surface->base);
--
GitLab

View file

@ -0,0 +1,38 @@
From 033ce1bae1505467fb69bf727377318421cb7731 Mon Sep 17 00:00:00 2001
From: llyyr <llyyr.public@gmail.com>
Date: Fri, 25 Apr 2025 10:41:06 +0530
Subject: [PATCH] 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: 789507c99c67 ("vulkan/wsi: implement the Wayland color management protocol")
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/34708>
---
src/vulkan/wsi/wsi_common_wayland.c | 5 +++--
1 file changed, 3 insertions(+), 2 deletions(-)
diff --git a/src/vulkan/wsi/wsi_common_wayland.c b/src/vulkan/wsi/wsi_common_wayland.c
index 7c1efda1f274e..938a9cd7c181b 100644
--- a/src/vulkan/wsi/wsi_common_wayland.c
+++ b/src/vulkan/wsi/wsi_common_wayland.c
@@ -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);
--
GitLab

View file

@ -0,0 +1,34 @@
From 0c1f2b90c97b46b6c0576643353f4c0a494e36a6 Mon Sep 17 00:00:00 2001
From: Xaver Hugl <xaver.hugl@kde.org>
Date: Tue, 11 Mar 2025 14:11:23 +0100
Subject: [PATCH] vulkan/wsi: warn once when HDR metadata is skipped because of
protocol errors
Signed-off-by: Xaver Hugl <xaver.hugl@kde.org>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/34000>
---
src/vulkan/wsi/wsi_common_wayland.c | 8 ++++++--
1 file changed, 6 insertions(+), 2 deletions(-)
diff --git a/src/vulkan/wsi/wsi_common_wayland.c b/src/vulkan/wsi/wsi_common_wayland.c
index 68254dc8610dc..6be46f49d1492 100644
--- a/src/vulkan/wsi/wsi_common_wayland.c
+++ b/src/vulkan/wsi/wsi_common_wayland.c
@@ -1251,8 +1251,12 @@ wsi_wl_swapchain_update_colorspace(struct wsi_wl_swapchain *chain)
.max_fall = round(chain->color.hdr_metadata.maxFrameAverageLightLevel),
.max_cll = round(chain->color.hdr_metadata.maxContentLightLevel),
};
- bool should_use_hdr_metadata = chain->color.has_hdr_metadata
- && is_hdr_metadata_legal(&wayland_hdr_metadata);
+ bool should_use_hdr_metadata = chain->color.has_hdr_metadata;
+ if (should_use_hdr_metadata) {
+ should_use_hdr_metadata &= is_hdr_metadata_legal(&wayland_hdr_metadata);
+ if (!should_use_hdr_metadata)
+ mesa_log_once(MESA_LOG_WARN, "Not using HDR metadata to avoid protocol errors");
+ }
for (int i = 0; i < ARRAY_SIZE(colorspace_mapping); i++) {
if (colorspace_mapping[i].colorspace == chain->color.colorspace) {
should_use_hdr_metadata &= colorspace_mapping[i].should_use_hdr_metadata;
--
GitLab

View file

@ -69,7 +69,7 @@
Name: mesa
Summary: Mesa graphics libraries
%global ver 25.0.4
%global ver 25.0.7
Version: %{lua:ver = string.gsub(rpm.expand("%{ver}"), "-", "~"); print(ver)}
Release: 10.clang.skylake%{?dist}
License: MIT AND BSD-3-Clause AND SGI-B-2.0
@ -95,12 +95,24 @@ Patch23: 0003-vulkan-wsi-implement-support-for-VK_EXT_hdr_metadata.patch
Patch24: 0004-vulkan-wsi-handle-the-compositor-not-supporting-exte.patch
Patch25: 0001-meson-update-wayland-protocols-source_hash.patch
Patch26: 0001-docs-features-add-VK_EXT_hdr_metadata.patch
# Additional fixups for color management:
# https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/33804
Patch27: 0001-vulkan-wsi-dont-use-srgb-if-the-compositor.patch
# https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/34000
Patch28: 0001-vulkan-wsi-validate-hdr-metadata.patch
Patch29: 0002-vulkan-wsi-warn-once-when-hdr-metadata-is-skipped.patch
# https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/34353
Patch30: 0001-vulkan-wsi-wayland-initialize-surface-colorspace.patch
# https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/34410
Patch31: 0001-vulkan-wsi-wayland-avoid-duplicate-colorspace-entry.patch
# https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/34708
Patch32: 0001-vulkan-wsi-wayland-make-needs_color_surface_old_check_if.patch
# This patch makes Fedora CI fail and causes issues in QEMU. Revert it until
# we find a fix.
# https://bugzilla.redhat.com/show_bug.cgi?id=2360851
# https://gitlab.freedesktop.org/mesa/mesa/-/issues/13009
Patch30: 0001-Revert-kopper-Explicitly-choose-zink.patch
Patch40: 0001-Revert-kopper-Explicitly-choose-zink.patch
BuildRequires: meson >= 1.3.0
BuildRequires: gcc