Mesa 25.0.3: upgrade Mesa and add patches to this repo

This commit is contained in:
Anders Rytter Hansen 2025-04-15 16:08:39 +02:00
commit 1e0e785b14
10 changed files with 1630 additions and 4 deletions

View file

@ -0,0 +1,28 @@
From b97a4dc4caf609975ba9e80336e63ebc9545a91b Mon Sep 17 00:00:00 2001
From: Erik Faye-Lund <erik.faye-lund@collabora.com>
Date: Thu, 6 Mar 2025 13:53:07 +0100
Subject: [PATCH] docs/features: add VK_EXT_hdr_metadata
This was missed when it was recently added.
Fixes: 4b663d561b8 ("vulkan/wsi: implement support for VK_EXT_hdr_metadata on Wayland")
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/33918>
---
docs/features.txt | 1 +
1 file changed, 1 insertion(+)
diff --git a/docs/features.txt b/docs/features.txt
index 6e789b3ed29..53395bfee2a 100644
--- a/docs/features.txt
+++ b/docs/features.txt
@@ -612,6 +612,7 @@ Khronos extensions that are not part of any Vulkan version:
VK_EXT_global_priority DONE (anv, hasvk, panvk, radv, tu)
VK_EXT_global_priority_query DONE (anv, hasvk, panvk, radv, tu)
VK_EXT_graphics_pipeline_library DONE (anv, lvp, nvk, panvk, radv, tu, vn)
+ VK_EXT_hdr_metadata DONE (anv, lvp, nvk, panvk, radv, tu)
VK_EXT_headless_surface DONE (anv, dzn, hasvk, lvp, nvk, panvk, pvr, radv, tu, v3dv, vn)
VK_EXT_image_2d_view_of_3d DONE (anv, hasvk, lvp, nvk, radv, tu, vn)
VK_EXT_image_compression_control DONE (radv)
--
2.49.0

View file

@ -0,0 +1,116 @@
From c15c45c54bb2fd03b41416c6628efcb095eec4b6 Mon Sep 17 00:00:00 2001
From: Xaver Hugl <xaver.hugl@kde.org>
Date: Mon, 17 Feb 2025 16:25:09 +0100
Subject: [PATCH 1/4] increase required wayland-protocols version to 1.41
This version contains the color management protocol.
This commit also adjusts the build-wayland script to mention
that the DEBIAN_BASE_TAG also has to be bumped.
Signed-off-by: Xaver Hugl <xaver.hugl@kde.org>
Reviewed-by: Eric Engestrom <eric@igalia.com>
Reviewed-by: Sebastian Wick <sebastian.wick@redhat.com>
Acked-by: Daniel Stone <daniels@collabora.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/32038>
---
.gitlab-ci/container/build-wayland.sh | 4 +++-
.gitlab-ci/image-tags.yml | 16 ++++++++--------
meson.build | 2 +-
subprojects/wayland-protocols.wrap | 6 +++---
4 files changed, 15 insertions(+), 13 deletions(-)
diff --git a/.gitlab-ci/container/build-wayland.sh b/.gitlab-ci/container/build-wayland.sh
index d6117254e87..551edcfe7db 100644
--- a/.gitlab-ci/container/build-wayland.sh
+++ b/.gitlab-ci/container/build-wayland.sh
@@ -7,6 +7,8 @@ uncollapsed_section_start wayland "Building Wayland"
# When changing this file, you need to bump the following
# .gitlab-ci/image-tags.yml tags:
+# ALPINE_X86_64_BUILD_TAG
+# DEBIAN_BASE_TAG
# DEBIAN_BUILD_TAG
# DEBIAN_TEST_ANDROID_TAG
# DEBIAN_TEST_GL_TAG
@@ -15,7 +17,7 @@ uncollapsed_section_start wayland "Building Wayland"
# KERNEL_ROOTFS_TAG
export LIBWAYLAND_VERSION="1.21.0"
-export WAYLAND_PROTOCOLS_VERSION="1.38"
+export WAYLAND_PROTOCOLS_VERSION="1.41"
git clone https://gitlab.freedesktop.org/wayland/wayland
cd wayland
diff --git a/.gitlab-ci/image-tags.yml b/.gitlab-ci/image-tags.yml
index 89909ed7912..b8423ef3d4f 100644
--- a/.gitlab-ci/image-tags.yml
+++ b/.gitlab-ci/image-tags.yml
@@ -13,10 +13,10 @@
variables:
DEBIAN_X86_64_BUILD_BASE_IMAGE: "debian/x86_64_build-base"
- DEBIAN_BASE_TAG: "20250130-vvless"
+ DEBIAN_BASE_TAG: "20250223-way-prot"
DEBIAN_X86_64_BUILD_IMAGE_PATH: "debian/x86_64_build"
- DEBIAN_BUILD_TAG: "20250128-llvm19-up"
+ DEBIAN_BUILD_TAG: "20250223-way-prot"
DEBIAN_X86_64_TEST_BASE_IMAGE: "debian/x86_64_test-base"
DEBIAN_ARM64_TEST_BASE_IMAGE: "debian/arm64_test-base"
@@ -27,17 +27,17 @@ variables:
DEBIAN_ARM64_TEST_IMAGE_VK_PATH: "debian/arm64_test-vk"
DEBIAN_X86_64_TEST_ANDROID_IMAGE_PATH: "debian/x86_64_test-android"
- DEBIAN_TEST_ANDROID_TAG: "20250130-vvless"
- DEBIAN_TEST_GL_TAG: "20250327-piglit-250"
- DEBIAN_TEST_VK_TAG: "20250327-piglit-250"
- KERNEL_ROOTFS_TAG: "20250327-trace-250"
+ DEBIAN_TEST_ANDROID_TAG: "20250223-way-prot"
+ DEBIAN_TEST_GL_TAG: "20250223-way-prot"
+ DEBIAN_TEST_VK_TAG: "20250223-way-prot"
+ KERNEL_ROOTFS_TAG: "20250223-way-prot"
DEBIAN_PYUTILS_IMAGE: "debian/x86_64_pyutils"
DEBIAN_PYUTILS_TAG: "20250129-lavacli"
- ALPINE_X86_64_BUILD_TAG: "20250128-llversionm"
+ ALPINE_X86_64_BUILD_TAG: "20250223-way-prot"
ALPINE_X86_64_LAVA_SSH_TAG: "20250124-spirv-tools"
- FEDORA_X86_64_BUILD_TAG: "20250128-llversionm"
+ FEDORA_X86_64_BUILD_TAG: "20250223-way-prot"
KERNEL_TAG: "v6.13-rc4-mesa-5e77"
KERNEL_REPO: "gfx-ci/linux"
diff --git a/meson.build b/meson.build
index 095aec5d9ea..ddde02c1755 100644
--- a/meson.build
+++ b/meson.build
@@ -2058,7 +2058,7 @@ if with_platform_wayland
else
wl_scanner_arg = 'code'
endif
- dep_wl_protocols = dependency('wayland-protocols', version : '>= 1.38', default_options: [ 'tests=false' ])
+ dep_wl_protocols = dependency('wayland-protocols', version : '>= 1.41', default_options: [ 'tests=false' ])
dep_wayland_client = dependency('wayland-client', version : '>=1.18')
dep_wayland_server = dependency('wayland-server', version : '>=1.18')
if with_egl
diff --git a/subprojects/wayland-protocols.wrap b/subprojects/wayland-protocols.wrap
index 61f306bdffd..c82fece01e3 100644
--- a/subprojects/wayland-protocols.wrap
+++ b/subprojects/wayland-protocols.wrap
@@ -1,7 +1,7 @@
[wrap-file]
-directory = wayland-protocols-1.38
-source_url = https://gitlab.freedesktop.org/wayland/wayland-protocols/-/releases/1.38/downloads/wayland-protocols-1.38.tar.xz
-source_filename = wayland-protocols-1.38.tar.xz
+directory = wayland-protocols-1.41
+source_url = https://gitlab.freedesktop.org/wayland/wayland-protocols/-/releases/1.41/downloads/wayland-protocols-1.41.tar.xz
+source_filename = wayland-protocols-1.41.tar.xz
source_hash = ff17292c05159d2b20ce6cacfe42d7e31a28198fa1429a769b03af7c38581dbe
[provide]
--
2.47.0

View file

@ -0,0 +1,34 @@
From 7f749c41ba8d9918251c00eeb86d453cda5fbb7b Mon Sep 17 00:00:00 2001
From: Benjamin Lee <benjamin.lee@collabora.com>
Date: Tue, 25 Feb 2025 22:03:25 -0800
Subject: [PATCH] meson: update wayland-protocols source_hash
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
This was missed when updating to 1.41.
Signed-off-by: Benjamin Lee <benjamin.lee@collabora.com>
Fixes: 53b40a40f46 ("increase required wayland-protocols version to 1.41")
Reviewed-by: Tapani Pälli <tapani.palli@intel.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/33752>
---
subprojects/wayland-protocols.wrap | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/subprojects/wayland-protocols.wrap b/subprojects/wayland-protocols.wrap
index c82fece01e3..c6686b4ae4a 100644
--- a/subprojects/wayland-protocols.wrap
+++ b/subprojects/wayland-protocols.wrap
@@ -2,7 +2,7 @@
directory = wayland-protocols-1.41
source_url = https://gitlab.freedesktop.org/wayland/wayland-protocols/-/releases/1.41/downloads/wayland-protocols-1.41.tar.xz
source_filename = wayland-protocols-1.41.tar.xz
-source_hash = ff17292c05159d2b20ce6cacfe42d7e31a28198fa1429a769b03af7c38581dbe
+source_hash = 2786b6b1b79965e313f2c289c12075b9ed700d41844810c51afda10ee329576b
[provide]
wayland-protocols = wayland_protocols
--
2.49.0

View file

@ -0,0 +1,614 @@
From 5dd0635b31fcb6b12e9dcb3b908e501f153e7e8b Mon Sep 17 00:00:00 2001
From: Colin Marc <hi@colinmarc.com>
Date: Tue, 26 Mar 2024 11:12:28 +0100
Subject: [PATCH 2/4] vulkan/wsi: implement the Wayland color management
protocol
This allows applications to use color spaces other than sRGB, if the compositor
supports them.
The color management surface is only created if a non-sRGB and non-passthrough
colorspace is set on the surface, so applications can still use the protocol
directly if they prefer.
Co-authored-by: Xaver Hugl <xaver.hugl@kde.org>
Reviewed-by: Sebastian Wick <sebastian.wick@redhat.com>
Acked-by: Daniel Stone <daniels@collabora.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/32038>
---
src/egl/wayland/wayland-drm/meson.build | 1 +
src/vulkan/wsi/meson.build | 1 +
src/vulkan/wsi/wsi_common_wayland.c | 421 ++++++++++++++++++++++--
3 files changed, 400 insertions(+), 23 deletions(-)
diff --git a/src/egl/wayland/wayland-drm/meson.build b/src/egl/wayland/wayland-drm/meson.build
index 59ce3442499..d3b6c15ddd2 100644
--- a/src/egl/wayland/wayland-drm/meson.build
+++ b/src/egl/wayland/wayland-drm/meson.build
@@ -48,6 +48,7 @@ wp_protos = {
'presentation-time': 'stable/presentation-time/presentation-time.xml',
'tearing-control-v1': 'staging/tearing-control/tearing-control-v1.xml',
'linux-drm-syncobj-v1': 'staging/linux-drm-syncobj/linux-drm-syncobj-v1.xml',
+ 'color-management-v1': 'staging/color-management/color-management-v1.xml',
}
wp_files = {}
foreach name, xml : wp_protos
diff --git a/src/vulkan/wsi/meson.build b/src/vulkan/wsi/meson.build
index 6933eb780c4..ba609ab3151 100644
--- a/src/vulkan/wsi/meson.build
+++ b/src/vulkan/wsi/meson.build
@@ -22,6 +22,7 @@ if with_platform_wayland
files_vulkan_wsi += wp_files['tearing-control-v1']
links_vulkan_wsi += libloader_wayland_helper
files_vulkan_wsi += wp_files['linux-drm-syncobj-v1']
+ files_vulkan_wsi += wp_files['color-management-v1']
endif
if with_platform_windows
diff --git a/src/vulkan/wsi/wsi_common_wayland.c b/src/vulkan/wsi/wsi_common_wayland.c
index d6c1b862324..d4b47c1f1b8 100644
--- a/src/vulkan/wsi/wsi_common_wayland.c
+++ b/src/vulkan/wsi/wsi_common_wayland.c
@@ -47,6 +47,7 @@
#include "presentation-time-client-protocol.h"
#include "linux-drm-syncobj-v1-client-protocol.h"
#include "tearing-control-v1-client-protocol.h"
+#include "color-management-v1-client-protocol.h"
#include <util/cnd_monotonic.h>
#include <util/compiler.h>
@@ -110,8 +111,13 @@ struct wsi_wl_display {
struct wp_tearing_control_manager_v1 *tearing_control_manager;
struct wp_linux_drm_syncobj_manager_v1 *wl_syncobj;
+ struct wp_color_manager_v1 *color_manager;
+
struct dmabuf_feedback_format_table format_table;
+ struct u_vector color_primaries;
+ struct u_vector color_transfer_funcs;
+
/* users want per-chain wsi_wl_swapchain->present_ids.wp_presentation */
struct wp_presentation *wp_presentation_notwrapped;
uint32_t wp_presentation_version;
@@ -125,6 +131,9 @@ struct wsi_wl_display {
/* Formats populated by zwp_linux_dmabuf_v1 or wl_shm interfaces */
struct u_vector formats;
+ /* Additional colorspaces returned by wp_color_management_v1. */
+ struct u_vector colorspaces;
+
bool sw;
dev_t main_device;
@@ -180,6 +189,11 @@ struct wsi_wl_surface {
struct dmabuf_feedback dmabuf_feedback, pending_dmabuf_feedback;
struct wp_linux_drm_syncobj_surface_v1 *wl_syncobj_surface;
+
+ struct vk_instance *instance;
+ struct wp_color_management_surface_v1 *color_surface;
+ int color_surface_refcount;
+ VkColorSpaceKHR colorspace;
};
struct wsi_wl_swapchain {
@@ -230,6 +244,8 @@ struct wsi_wl_swapchain {
unsigned int refresh_nsec;
} present_ids;
+ VkColorSpaceKHR colorspace;
+
struct wsi_wl_image images[0];
};
VK_DEFINE_NONDISP_HANDLE_CASTS(wsi_wl_swapchain, base.base, VkSwapchainKHR,
@@ -885,6 +901,316 @@ static const struct wl_shm_listener shm_listener = {
.format = shm_handle_format
};
+static bool
+vector_contains(struct u_vector *vec, unsigned int val)
+{
+ unsigned int *ptr;
+
+ u_vector_foreach(ptr, vec)
+ if (*ptr == val)
+ return true;
+
+ return false;
+}
+
+struct Colorspace {
+ VkColorSpaceKHR colorspace;
+ enum wp_color_manager_v1_primaries primaries;
+ enum wp_color_manager_v1_transfer_function tf;
+};
+struct Colorspace colorspace_mapping[] = {
+ {
+ .colorspace = VK_COLOR_SPACE_SRGB_NONLINEAR_KHR,
+ .primaries = WP_COLOR_MANAGER_V1_PRIMARIES_SRGB,
+ .tf = WP_COLOR_MANAGER_V1_TRANSFER_FUNCTION_SRGB,
+ },
+ {
+ .colorspace = VK_COLOR_SPACE_DISPLAY_P3_NONLINEAR_EXT,
+ .primaries = WP_COLOR_MANAGER_V1_PRIMARIES_DISPLAY_P3,
+ .tf = WP_COLOR_MANAGER_V1_TRANSFER_FUNCTION_SRGB,
+ },
+ {
+ .colorspace = VK_COLOR_SPACE_EXTENDED_SRGB_LINEAR_EXT,
+ .primaries = WP_COLOR_MANAGER_V1_PRIMARIES_SRGB,
+ .tf = WP_COLOR_MANAGER_V1_TRANSFER_FUNCTION_EXT_LINEAR,
+ },
+ {
+ .colorspace = VK_COLOR_SPACE_DISPLAY_P3_LINEAR_EXT,
+ .primaries = WP_COLOR_MANAGER_V1_PRIMARIES_DISPLAY_P3,
+ .tf = WP_COLOR_MANAGER_V1_TRANSFER_FUNCTION_EXT_LINEAR,
+ },
+ {
+ .colorspace = VK_COLOR_SPACE_BT709_LINEAR_EXT,
+ .primaries = WP_COLOR_MANAGER_V1_PRIMARIES_SRGB,
+ .tf = WP_COLOR_MANAGER_V1_TRANSFER_FUNCTION_EXT_LINEAR,
+ },
+ {
+ .colorspace = VK_COLOR_SPACE_BT709_NONLINEAR_EXT,
+ .primaries = WP_COLOR_MANAGER_V1_PRIMARIES_SRGB,
+ .tf = WP_COLOR_MANAGER_V1_TRANSFER_FUNCTION_BT1886,
+ },
+ {
+ .colorspace = VK_COLOR_SPACE_BT2020_LINEAR_EXT,
+ .primaries = WP_COLOR_MANAGER_V1_PRIMARIES_BT2020,
+ .tf = WP_COLOR_MANAGER_V1_TRANSFER_FUNCTION_EXT_LINEAR,
+ },
+ {
+ .colorspace = VK_COLOR_SPACE_HDR10_ST2084_EXT,
+ .primaries = WP_COLOR_MANAGER_V1_PRIMARIES_BT2020,
+ .tf = WP_COLOR_MANAGER_V1_TRANSFER_FUNCTION_ST2084_PQ,
+ },
+ /* VK_COLOR_SPACE_DOLBYVISION_EXT is left out because it's deprecated */
+ {
+ .colorspace = VK_COLOR_SPACE_HDR10_HLG_EXT,
+ .primaries = WP_COLOR_MANAGER_V1_PRIMARIES_BT2020,
+ .tf = WP_COLOR_MANAGER_V1_TRANSFER_FUNCTION_HLG,
+ },
+ {
+ .colorspace = VK_COLOR_SPACE_ADOBERGB_LINEAR_EXT,
+ .primaries = WP_COLOR_MANAGER_V1_PRIMARIES_ADOBE_RGB,
+ .tf = WP_COLOR_MANAGER_V1_TRANSFER_FUNCTION_EXT_LINEAR,
+ },
+ /* VK_COLOR_SPACE_ADOBERGB_NONLINEAR_EXT is left out because there's no
+ * exactly matching transfer function in the Wayland protocol */
+ /* VK_COLOR_SPACE_PASS_THROUGH_EXT is handled elsewhere */
+ {
+ .colorspace = VK_COLOR_SPACE_EXTENDED_SRGB_NONLINEAR_EXT,
+ .primaries = WP_COLOR_MANAGER_V1_PRIMARIES_SRGB,
+ .tf = WP_COLOR_MANAGER_V1_TRANSFER_FUNCTION_EXT_SRGB,
+ },
+ /* VK_COLOR_SPACE_DISPLAY_NATIVE_AMD isn't supported */
+ /* VK_COLORSPACE_SRGB_NONLINEAR_KHR is just an alias */
+ /* VK_COLOR_SPACE_DCI_P3_LINEAR_EXT is just an alias */
+};
+
+static int
+wsi_wl_display_determine_colorspaces(struct wsi_wl_display *display)
+{
+ u_vector_finish(&display->colorspaces);
+ if (!u_vector_init(&display->colorspaces, 8, sizeof(VkColorSpaceKHR)))
+ return -1;
+
+ /* SRGB_NONLINEAR is always supported. */
+ VkColorSpaceKHR *new_cs = u_vector_add(&display->colorspaces);
+ if (!new_cs)
+ return -1;
+ *new_cs = VK_COLOR_SPACE_SRGB_NONLINEAR_KHR;
+
+ /* as is PASS_THROUGH */
+ new_cs = u_vector_add(&display->colorspaces);
+ if (!new_cs)
+ return -1;
+ *new_cs = VK_COLOR_SPACE_PASS_THROUGH_EXT;
+
+ if (!display->color_manager)
+ return 0;
+
+ 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++) {
+ if (!vector_contains(primaries, colorspace_mapping[i].primaries))
+ continue;
+ if (!vector_contains(tfs, colorspace_mapping[i].tf))
+ continue;
+ VkColorSpaceKHR *new_cs = u_vector_add(&display->colorspaces);
+ if (!new_cs)
+ return -1;
+ *new_cs = colorspace_mapping[i].colorspace;
+ }
+ return 0;
+}
+
+static void
+color_management_handle_supported_intent(void *data,
+ struct wp_color_manager_v1 *color_manager,
+ unsigned int intent)
+{
+ /* We only use the perceptual rendering intent, which is always supported. */
+}
+
+static void
+color_management_handle_supported_features(void *data,
+ struct wp_color_manager_v1 *color_manager,
+ unsigned int feature)
+{
+ /* We don't use any non-default features yet. */
+}
+
+static void
+color_management_handle_supported_tf_named(void *data,
+ struct wp_color_manager_v1 *color_manager,
+ unsigned int tf)
+{
+ struct wsi_wl_display *display = data;
+ unsigned int *new_tf = u_vector_add(&display->color_transfer_funcs);
+ if (new_tf)
+ *new_tf = tf;
+}
+
+static void
+color_management_handle_supported_primaries_named(void *data,
+ struct wp_color_manager_v1 *color_manager,
+ unsigned int primaries)
+{
+ struct wsi_wl_display *display = data;
+ unsigned int *new_primaries = u_vector_add(&display->color_primaries);
+ if (new_primaries)
+ *new_primaries = primaries;
+}
+
+static void
+color_management_handle_done(void *data, struct wp_color_manager_v1 *color_manager)
+{
+ /* Intentionally left blank */
+}
+
+static const struct wp_color_manager_v1_listener color_manager_listener = {
+ .supported_intent = color_management_handle_supported_intent,
+ .supported_feature = color_management_handle_supported_features,
+ .supported_tf_named = color_management_handle_supported_tf_named,
+ .supported_primaries_named = color_management_handle_supported_primaries_named,
+ .done = color_management_handle_done,
+};
+
+enum image_description_status {
+ undefined,
+ ready,
+ failed,
+};
+
+static void
+color_management_handle_image_desc_failed(void *data,
+ struct wp_image_description_v1 *desc,
+ unsigned int cause,
+ const char *msg)
+{
+ enum image_description_status *status = data;
+ *status = failed;
+}
+
+static void
+color_management_handle_image_desc_ready(void *data,
+ struct wp_image_description_v1 *desc,
+ unsigned int id)
+{
+ enum image_description_status *status = data;
+ *status = ready;
+}
+
+static const struct wp_image_description_v1_listener image_description_listener = {
+ .failed = color_management_handle_image_desc_failed,
+ .ready = color_management_handle_image_desc_ready,
+};
+
+static bool
+needs_color_surface(VkColorSpaceKHR colorspace)
+{
+ return colorspace != VK_COLOR_SPACE_PASS_THROUGH_EXT;
+}
+
+static void
+wsi_wl_surface_add_color_refcount(struct wsi_wl_surface *wsi_surface)
+{
+ wsi_surface->color_surface_refcount++;
+ if (wsi_surface->color_surface_refcount == 1) {
+ wsi_surface->color_surface =
+ wp_color_manager_v1_get_surface(wsi_surface->display->color_manager, wsi_surface->surface);
+ }
+}
+
+static void
+wsi_wl_surface_remove_color_refcount(struct wsi_wl_surface *wsi_surface)
+{
+ wsi_surface->color_surface_refcount--;
+ if (wsi_surface->color_surface_refcount == 0) {
+ wp_color_management_surface_v1_destroy(wsi_surface->color_surface);
+ wsi_surface->color_surface = NULL;
+ }
+}
+
+static VkResult
+wsi_wl_swapchain_update_colorspace(struct wsi_wl_swapchain *chain)
+{
+ struct wsi_wl_surface *surface = chain->wsi_wl_surface;
+ struct wsi_wl_display *display = surface->display;
+
+ /* we need the color management extension for
+ * everything except sRGB and PASS_THROUGH */
+ if (!display->color_manager) {
+ if (chain->colorspace == VK_COLOR_SPACE_SRGB_NONLINEAR_KHR ||
+ chain->colorspace == VK_COLOR_SPACE_PASS_THROUGH_EXT) {
+ return VK_SUCCESS;
+ } else {
+ return VK_ERROR_SURFACE_LOST_KHR;
+ }
+ }
+
+ bool new_color_surface = !surface->color_surface;
+ bool needs_color_surface_new = needs_color_surface(chain->colorspace);
+ bool needs_color_surface_old = needs_color_surface(surface->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) {
+ wsi_wl_surface_remove_color_refcount(surface);
+ }
+
+ if (!new_color_surface && surface->colorspace == chain->colorspace)
+ return VK_SUCCESS;
+
+ /* failure is fatal, so this potentially being wrong
+ in that case doesn't matter */
+ surface->colorspace = chain->colorspace;
+ if (!needs_color_surface_new)
+ return VK_SUCCESS;
+
+ struct wp_image_description_creator_params_v1 *creator =
+ wp_color_manager_v1_create_parametric_creator(display->color_manager);
+
+ if (!creator)
+ return VK_ERROR_SURFACE_LOST_KHR;
+
+ unsigned int primaries = 0;
+ unsigned int tf = 0;
+ for (int i = 0; i < ARRAY_SIZE(colorspace_mapping); i++) {
+ if (colorspace_mapping[i].colorspace == chain->colorspace) {
+ primaries = colorspace_mapping[i].primaries;
+ tf = colorspace_mapping[i].tf;
+ }
+ }
+
+ if (!primaries)
+ return VK_ERROR_SURFACE_LOST_KHR;
+
+ wp_image_description_creator_params_v1_set_primaries_named(creator, primaries);
+ wp_image_description_creator_params_v1_set_tf_named(creator, tf);
+
+ wl_proxy_set_queue((struct wl_proxy *) creator, display->queue);
+
+ struct wp_image_description_v1 *image_desc =
+ wp_image_description_creator_params_v1_create(creator);
+ if (!image_desc)
+ return VK_ERROR_SURFACE_LOST_KHR;
+
+ enum image_description_status status = undefined;
+ wp_image_description_v1_add_listener(image_desc, &image_description_listener, &status);
+
+ while (status == undefined) {
+ int ret = wl_display_dispatch_queue(display->wl_display, display->queue);
+ if (ret < 0)
+ return VK_ERROR_OUT_OF_DATE_KHR;
+ }
+ if (status == failed)
+ return VK_ERROR_SURFACE_LOST_KHR;
+
+ wp_color_management_surface_v1_set_image_description(chain->wsi_wl_surface->color_surface,
+ image_desc,
+ WP_COLOR_MANAGER_V1_RENDER_INTENT_PERCEPTUAL);
+ wp_image_description_v1_destroy(image_desc);
+
+ return VK_SUCCESS;
+}
+
+
static void
presentation_handle_clock_id(void* data, struct wp_presentation *wp_presentation, uint32_t clk_id)
{
@@ -942,6 +1268,17 @@ registry_handle_global(void *data, struct wl_registry *registry,
display->commit_timing_manager =
wl_registry_bind(registry, name, &wp_commit_timing_manager_v1_interface, 1);
}
+
+ if (strcmp(interface, wp_color_manager_v1_interface.name) == 0) {
+ display->color_manager =
+ wl_registry_bind(registry, name, &wp_color_manager_v1_interface, 1);
+
+ u_vector_init(&display->color_primaries, 8, sizeof(uint32_t));
+ u_vector_init(&display->color_transfer_funcs, 8, sizeof(uint32_t));
+
+ wp_color_manager_v1_add_listener(display->color_manager,
+ &color_manager_listener, display);
+ }
}
static void
@@ -961,6 +1298,10 @@ wsi_wl_display_finish(struct wsi_wl_display *display)
u_vector_foreach(f, &display->formats)
u_vector_finish(&f->modifiers);
u_vector_finish(&display->formats);
+ u_vector_finish(&display->colorspaces);
+ u_vector_finish(&display->color_primaries);
+ u_vector_finish(&display->color_transfer_funcs);
+
if (display->wl_shm)
wl_shm_destroy(display->wl_shm);
if (display->wl_syncobj)
@@ -975,6 +1316,8 @@ wsi_wl_display_finish(struct wsi_wl_display *display)
wp_commit_timing_manager_v1_destroy(display->commit_timing_manager);
if (display->tearing_control_manager)
wp_tearing_control_manager_v1_destroy(display->tearing_control_manager);
+ if (display->color_manager)
+ wp_color_manager_v1_destroy(display->color_manager);
if (display->wl_display_wrapper)
wl_proxy_wrapper_destroy(display->wl_display_wrapper);
if (display->queue)
@@ -1066,9 +1409,14 @@ wsi_wl_display_init(struct wsi_wayland *wsi_wl,
}
}
- /* Round-trip again to get formats and modifiers */
+ /* Round-trip again to get formats, modifiers and color properties */
wl_display_roundtrip_queue(display->wl_display, display->queue);
+ if (wsi_wl_display_determine_colorspaces(display) < 0) {
+ result = VK_ERROR_OUT_OF_HOST_MEMORY;
+ goto fail;
+ }
+
if (wsi_wl->wsi->force_bgra8_unorm_first) {
/* Find BGRA8_UNORM in the list and swap it to the first position if we
* can find it. Some apps get confused if SRGB is first in the list.
@@ -1358,6 +1706,8 @@ wsi_wl_surface_get_formats(VkIcdSurfaceBase *icd_surface,
VkSurfaceFormatKHR* pSurfaceFormats)
{
VkIcdSurfaceWayland *surface = (VkIcdSurfaceWayland *)icd_surface;
+ struct wsi_wl_surface *wsi_wl_surface =
+ wl_container_of((VkIcdSurfaceWayland *)icd_surface, wsi_wl_surface, base);
struct wsi_wayland *wsi =
(struct wsi_wayland *)wsi_device->wsi[VK_ICD_WSI_PLATFORM_WAYLAND];
@@ -1369,18 +1719,22 @@ wsi_wl_surface_get_formats(VkIcdSurfaceBase *icd_surface,
VK_OUTARRAY_MAKE_TYPED(VkSurfaceFormatKHR, out,
pSurfaceFormats, pSurfaceFormatCount);
- struct wsi_wl_format *disp_fmt;
- u_vector_foreach(disp_fmt, &display.formats) {
- /* Skip formats for which we can't support both alpha & opaque
- * formats.
- */
- if (!(disp_fmt->flags & WSI_WL_FMT_ALPHA) ||
- !(disp_fmt->flags & WSI_WL_FMT_OPAQUE))
- continue;
+ VkColorSpaceKHR *cs;
+ u_vector_foreach(cs, &display.colorspaces) {
+ struct wsi_wl_format *disp_fmt;
+ u_vector_foreach(disp_fmt, &display.formats) {
+ /* Skip formats for which we can't support both alpha & opaque
+ * formats.
+ */
+ if (!(disp_fmt->flags & WSI_WL_FMT_ALPHA) ||
+ !(disp_fmt->flags & WSI_WL_FMT_OPAQUE)) {
+ continue;
+ }
- vk_outarray_append_typed(VkSurfaceFormatKHR, &out, out_fmt) {
- out_fmt->format = disp_fmt->vk_format;
- out_fmt->colorSpace = VK_COLOR_SPACE_SRGB_NONLINEAR_KHR;
+ vk_outarray_append_typed(VkSurfaceFormatKHR, &out, out_fmt) {
+ out_fmt->format = disp_fmt->vk_format;
+ out_fmt->colorSpace = *cs;
+ }
}
}
@@ -1397,6 +1751,8 @@ wsi_wl_surface_get_formats2(VkIcdSurfaceBase *icd_surface,
VkSurfaceFormat2KHR* pSurfaceFormats)
{
VkIcdSurfaceWayland *surface = (VkIcdSurfaceWayland *)icd_surface;
+ struct wsi_wl_surface *wsi_wl_surface =
+ wl_container_of((VkIcdSurfaceWayland *)icd_surface, wsi_wl_surface, base);
struct wsi_wayland *wsi =
(struct wsi_wayland *)wsi_device->wsi[VK_ICD_WSI_PLATFORM_WAYLAND];
@@ -1408,18 +1764,22 @@ wsi_wl_surface_get_formats2(VkIcdSurfaceBase *icd_surface,
VK_OUTARRAY_MAKE_TYPED(VkSurfaceFormat2KHR, out,
pSurfaceFormats, pSurfaceFormatCount);
- struct wsi_wl_format *disp_fmt;
- u_vector_foreach(disp_fmt, &display.formats) {
- /* Skip formats for which we can't support both alpha & opaque
- * formats.
- */
- if (!(disp_fmt->flags & WSI_WL_FMT_ALPHA) ||
- !(disp_fmt->flags & WSI_WL_FMT_OPAQUE))
- continue;
+ VkColorSpaceKHR *cs;
+ u_vector_foreach(cs, &display.colorspaces) {
+ struct wsi_wl_format *disp_fmt;
+ u_vector_foreach(disp_fmt, &display.formats) {
+ /* Skip formats for which we can't support both alpha & opaque
+ * formats.
+ */
+ if (!(disp_fmt->flags & WSI_WL_FMT_ALPHA) ||
+ !(disp_fmt->flags & WSI_WL_FMT_OPAQUE)) {
+ continue;
+ }
- vk_outarray_append_typed(VkSurfaceFormat2KHR, &out, out_fmt) {
- out_fmt->surfaceFormat.format = disp_fmt->vk_format;
- out_fmt->surfaceFormat.colorSpace = VK_COLOR_SPACE_SRGB_NONLINEAR_KHR;
+ vk_outarray_append_typed(VkSurfaceFormat2KHR, &out, out_fmt) {
+ out_fmt->surfaceFormat.format = disp_fmt->vk_format;
+ out_fmt->surfaceFormat.colorSpace = *cs;
+ }
}
}
@@ -1515,6 +1875,9 @@ wsi_wl_surface_destroy(VkIcdSurfaceBase *icd_surface, VkInstance _instance,
dmabuf_feedback_fini(&wsi_wl_surface->pending_dmabuf_feedback);
}
+ if (wsi_wl_surface->color_surface)
+ wp_color_management_surface_v1_destroy(wsi_wl_surface->color_surface);
+
if (wsi_wl_surface->surface)
wl_proxy_wrapper_destroy(wsi_wl_surface->surface);
@@ -1837,6 +2200,9 @@ wsi_CreateWaylandSurfaceKHR(VkInstance _instance,
surface->display = pCreateInfo->display;
surface->surface = pCreateInfo->surface;
+ wsi_wl_surface->instance = instance;
+ wsi_wl_surface->colorspace = VK_COLOR_SPACE_SRGB_NONLINEAR_KHR;
+
*pSurface = VkIcdSurfaceBase_to_handle(&surface->base);
return VK_SUCCESS;
@@ -2459,6 +2825,10 @@ wsi_wl_swapchain_queue_present(struct wsi_swapchain *wsi_chain,
image->base.row_pitches[0] * chain->extent.height);
}
+ VkResult ret = wsi_wl_swapchain_update_colorspace(chain);
+ if (ret != VK_SUCCESS)
+ return ret;
+
/* For EXT_swapchain_maintenance1. We might have transitioned from FIFO to MAILBOX.
* In this case we need to let the FIFO request complete, before presenting MAILBOX. */
while (!chain->legacy_fifo_ready) {
@@ -2815,6 +3185,9 @@ 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->colorspace) && wsi_wl_surface->color_surface) {
+ wsi_wl_surface_remove_color_refcount(wsi_wl_surface);
+ }
/* Only unregister if we are the non-retired swapchain, or
* we are a retired swapchain and memory allocation failed,
@@ -2979,6 +3352,8 @@ wsi_wl_surface_create_swapchain(VkIcdSurfaceBase *icd_surface,
WP_TEARING_CONTROL_V1_PRESENTATION_HINT_ASYNC);
}
+ chain->colorspace = pCreateInfo->imageColorSpace;
+
enum wsi_wl_buffer_type buffer_type;
struct wsi_base_image_params *image_params = NULL;
struct wsi_cpu_image_params cpu_image_params;
--
2.49.0

View file

@ -0,0 +1,496 @@
From fbdd6fedb4af31db2f4dc0333751f8fd7779a841 Mon Sep 17 00:00:00 2001
From: Xaver Hugl <xaver.hugl@kde.org>
Date: Tue, 5 Nov 2024 19:17:28 +0100
Subject: [PATCH 3/4] vulkan/wsi: implement support for VK_EXT_hdr_metadata on
Wayland
Signed-off-by: Xaver Hugl <xaver.hugl@kde.org>
Reviewed-by: Alyssa Rosenzweig <alyssa@rosenzweig.io>
Reviewed-by: Sebastian Wick <sebastian.wick@redhat.com>
Acked-by: Daniel Stone <daniels@collabora.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/32038>
---
src/amd/vulkan/radv_physical_device.c | 1 +
src/asahi/vulkan/hk_physical_device.c | 1 +
src/freedreno/vulkan/tu_device.cc | 1 +
src/gallium/frontends/lavapipe/lvp_device.c | 1 +
src/intel/vulkan/anv_physical_device.c | 1 +
src/nouveau/vulkan/nvk_physical_device.c | 1 +
src/panfrost/vulkan/panvk_physical_device.c | 1 +
src/vulkan/wsi/wsi_common.c | 12 ++
src/vulkan/wsi/wsi_common_private.h | 2 +
src/vulkan/wsi/wsi_common_wayland.c | 151 ++++++++++++++++----
10 files changed, 146 insertions(+), 26 deletions(-)
diff --git a/src/amd/vulkan/radv_physical_device.c b/src/amd/vulkan/radv_physical_device.c
index 0d3660e7064..4dc4f647593 100644
--- a/src/amd/vulkan/radv_physical_device.c
+++ b/src/amd/vulkan/radv_physical_device.c
@@ -630,6 +630,7 @@ radv_physical_device_get_supported_extensions(const struct radv_physical_device
.EXT_global_priority = true,
.EXT_global_priority_query = true,
.EXT_graphics_pipeline_library = !pdev->use_llvm && !(instance->debug_flags & RADV_DEBUG_NO_GPL),
+ .EXT_hdr_metadata = true,
.EXT_host_query_reset = true,
.EXT_image_2d_view_of_3d = true,
.EXT_image_compression_control = true,
diff --git a/src/asahi/vulkan/hk_physical_device.c b/src/asahi/vulkan/hk_physical_device.c
index 8dcbd15c2b7..d916d749a0d 100644
--- a/src/asahi/vulkan/hk_physical_device.c
+++ b/src/asahi/vulkan/hk_physical_device.c
@@ -153,6 +153,7 @@ hk_get_device_extensions(const struct hk_instance *instance,
.EXT_global_priority = true,
.EXT_global_priority_query = true,
.EXT_graphics_pipeline_library = true,
+ .EXT_hdr_metadata = true,
.EXT_host_query_reset = true,
.EXT_host_image_copy = true,
.EXT_image_2d_view_of_3d = true,
diff --git a/src/freedreno/vulkan/tu_device.cc b/src/freedreno/vulkan/tu_device.cc
index 7b18dcf24f9..41d15d64733 100644
--- a/src/freedreno/vulkan/tu_device.cc
+++ b/src/freedreno/vulkan/tu_device.cc
@@ -274,6 +274,7 @@ get_device_extensions(const struct tu_physical_device *device,
.EXT_global_priority = true,
.EXT_global_priority_query = true,
.EXT_graphics_pipeline_library = true,
+ .EXT_hdr_metadata = true,
.EXT_host_image_copy = true,
.EXT_host_query_reset = true,
.EXT_image_2d_view_of_3d = true,
diff --git a/src/gallium/frontends/lavapipe/lvp_device.c b/src/gallium/frontends/lavapipe/lvp_device.c
index 934c501e231..260200e7d1c 100644
--- a/src/gallium/frontends/lavapipe/lvp_device.c
+++ b/src/gallium/frontends/lavapipe/lvp_device.c
@@ -211,6 +211,7 @@ static const struct vk_device_extension_table lvp_device_extensions_supported =
.EXT_extended_dynamic_state3 = true,
.EXT_external_memory_host = true,
.EXT_graphics_pipeline_library = true,
+ .EXT_hdr_metadata = true,
.EXT_host_image_copy = true,
.EXT_host_query_reset = true,
.EXT_image_2d_view_of_3d = true,
diff --git a/src/intel/vulkan/anv_physical_device.c b/src/intel/vulkan/anv_physical_device.c
index b2eda469415..8506790cd72 100644
--- a/src/intel/vulkan/anv_physical_device.c
+++ b/src/intel/vulkan/anv_physical_device.c
@@ -282,6 +282,7 @@ get_device_extensions(const struct anv_physical_device *device,
.EXT_global_priority_query = device->max_context_priority >=
VK_QUEUE_GLOBAL_PRIORITY_MEDIUM_KHR,
.EXT_graphics_pipeline_library = !debug_get_bool_option("ANV_NO_GPL", false),
+ .EXT_hdr_metadata = true,
.EXT_host_image_copy = !device->emu_astc_ldr,
.EXT_host_query_reset = true,
.EXT_image_2d_view_of_3d = true,
diff --git a/src/nouveau/vulkan/nvk_physical_device.c b/src/nouveau/vulkan/nvk_physical_device.c
index 9b05c1968aa..10ab3b6e488 100644
--- a/src/nouveau/vulkan/nvk_physical_device.c
+++ b/src/nouveau/vulkan/nvk_physical_device.c
@@ -229,6 +229,7 @@ nvk_get_device_extensions(const struct nvk_instance *instance,
.EXT_global_priority = true,
.EXT_global_priority_query = true,
.EXT_graphics_pipeline_library = true,
+ .EXT_hdr_metadata = true,
.EXT_host_query_reset = true,
.EXT_host_image_copy = info->cls_eng3d >= TURING_A,
.EXT_image_2d_view_of_3d = true,
diff --git a/src/panfrost/vulkan/panvk_physical_device.c b/src/panfrost/vulkan/panvk_physical_device.c
index dc3b371c3b0..4250d66bbb9 100644
--- a/src/panfrost/vulkan/panvk_physical_device.c
+++ b/src/panfrost/vulkan/panvk_physical_device.c
@@ -231,6 +231,7 @@ get_device_extensions(const struct panvk_physical_device *device,
.EXT_global_priority = true,
.EXT_global_priority_query = true,
.EXT_graphics_pipeline_library = true,
+ .EXT_hdr_metadata = true,
.EXT_host_query_reset = true,
.EXT_image_drm_format_modifier = true,
.EXT_image_robustness = true,
diff --git a/src/vulkan/wsi/wsi_common.c b/src/vulkan/wsi/wsi_common.c
index d18ca4d9ebd..7f41e61639f 100644
--- a/src/vulkan/wsi/wsi_common.c
+++ b/src/vulkan/wsi/wsi_common.c
@@ -2253,3 +2253,15 @@ wsi_device_supports_explicit_sync(struct wsi_device *device)
(device->timeline_semaphore_export_handle_types &
VK_EXTERNAL_SEMAPHORE_HANDLE_TYPE_OPAQUE_FD_BIT);
}
+
+VKAPI_ATTR void VKAPI_CALL
+wsi_SetHdrMetadataEXT(VkDevice device, uint32_t swapchainCount,
+ const VkSwapchainKHR* pSwapchains,
+ const VkHdrMetadataEXT* pMetadata)
+{
+ for (uint32_t i = 0; i < swapchainCount; i++) {
+ VK_FROM_HANDLE(wsi_swapchain, swapchain, pSwapchains[i]);
+ if (swapchain->set_hdr_metadata)
+ swapchain->set_hdr_metadata(swapchain, pMetadata);
+ }
+}
diff --git a/src/vulkan/wsi/wsi_common_private.h b/src/vulkan/wsi/wsi_common_private.h
index 849bdc6715f..40db1a7c176 100644
--- a/src/vulkan/wsi/wsi_common_private.h
+++ b/src/vulkan/wsi/wsi_common_private.h
@@ -223,6 +223,8 @@ struct wsi_swapchain {
const uint32_t *indices);
void (*set_present_mode)(struct wsi_swapchain *swap_chain,
VkPresentModeKHR mode);
+ void (*set_hdr_metadata)(struct wsi_swapchain *swap_chain,
+ const VkHdrMetadataEXT* pMetadata);
};
bool
diff --git a/src/vulkan/wsi/wsi_common_wayland.c b/src/vulkan/wsi/wsi_common_wayland.c
index d4b47c1f1b8..de12f524891 100644
--- a/src/vulkan/wsi/wsi_common_wayland.c
+++ b/src/vulkan/wsi/wsi_common_wayland.c
@@ -140,6 +140,11 @@ struct wsi_wl_display {
bool same_gpu;
clockid_t presentation_clock_id;
+
+ struct {
+ bool mastering_display_primaries;
+ bool extended_target_volume;
+ } color_features;
};
struct wsi_wayland {
@@ -191,9 +196,14 @@ struct wsi_wl_surface {
struct wp_linux_drm_syncobj_surface_v1 *wl_syncobj_surface;
struct vk_instance *instance;
- struct wp_color_management_surface_v1 *color_surface;
- int color_surface_refcount;
- VkColorSpaceKHR colorspace;
+
+ struct {
+ struct wp_color_management_surface_v1 *color_surface;
+ int color_surface_refcount;
+ VkColorSpaceKHR colorspace;
+ VkHdrMetadataEXT hdr_metadata;
+ bool has_hdr_metadata;
+ } color;
};
struct wsi_wl_swapchain {
@@ -244,7 +254,11 @@ struct wsi_wl_swapchain {
unsigned int refresh_nsec;
} present_ids;
- VkColorSpaceKHR colorspace;
+ struct {
+ VkColorSpaceKHR colorspace;
+ VkHdrMetadataEXT hdr_metadata;
+ bool has_hdr_metadata;
+ } color;
struct wsi_wl_image images[0];
};
@@ -917,58 +931,69 @@ struct Colorspace {
VkColorSpaceKHR colorspace;
enum wp_color_manager_v1_primaries primaries;
enum wp_color_manager_v1_transfer_function tf;
+ bool should_use_hdr_metadata;
};
struct Colorspace colorspace_mapping[] = {
{
.colorspace = VK_COLOR_SPACE_SRGB_NONLINEAR_KHR,
.primaries = WP_COLOR_MANAGER_V1_PRIMARIES_SRGB,
.tf = WP_COLOR_MANAGER_V1_TRANSFER_FUNCTION_SRGB,
+ .should_use_hdr_metadata = false,
},
{
.colorspace = VK_COLOR_SPACE_DISPLAY_P3_NONLINEAR_EXT,
.primaries = WP_COLOR_MANAGER_V1_PRIMARIES_DISPLAY_P3,
.tf = WP_COLOR_MANAGER_V1_TRANSFER_FUNCTION_SRGB,
+ .should_use_hdr_metadata = false,
},
{
.colorspace = VK_COLOR_SPACE_EXTENDED_SRGB_LINEAR_EXT,
.primaries = WP_COLOR_MANAGER_V1_PRIMARIES_SRGB,
.tf = WP_COLOR_MANAGER_V1_TRANSFER_FUNCTION_EXT_LINEAR,
+ .should_use_hdr_metadata = true,
},
{
.colorspace = VK_COLOR_SPACE_DISPLAY_P3_LINEAR_EXT,
.primaries = WP_COLOR_MANAGER_V1_PRIMARIES_DISPLAY_P3,
.tf = WP_COLOR_MANAGER_V1_TRANSFER_FUNCTION_EXT_LINEAR,
+ .should_use_hdr_metadata = false,
},
{
.colorspace = VK_COLOR_SPACE_BT709_LINEAR_EXT,
.primaries = WP_COLOR_MANAGER_V1_PRIMARIES_SRGB,
.tf = WP_COLOR_MANAGER_V1_TRANSFER_FUNCTION_EXT_LINEAR,
+ .should_use_hdr_metadata = false,
},
{
.colorspace = VK_COLOR_SPACE_BT709_NONLINEAR_EXT,
.primaries = WP_COLOR_MANAGER_V1_PRIMARIES_SRGB,
.tf = WP_COLOR_MANAGER_V1_TRANSFER_FUNCTION_BT1886,
+ .should_use_hdr_metadata = false,
},
{
.colorspace = VK_COLOR_SPACE_BT2020_LINEAR_EXT,
.primaries = WP_COLOR_MANAGER_V1_PRIMARIES_BT2020,
.tf = WP_COLOR_MANAGER_V1_TRANSFER_FUNCTION_EXT_LINEAR,
+ .should_use_hdr_metadata = false,
},
{
.colorspace = VK_COLOR_SPACE_HDR10_ST2084_EXT,
.primaries = WP_COLOR_MANAGER_V1_PRIMARIES_BT2020,
.tf = WP_COLOR_MANAGER_V1_TRANSFER_FUNCTION_ST2084_PQ,
+ .should_use_hdr_metadata = true,
},
/* VK_COLOR_SPACE_DOLBYVISION_EXT is left out because it's deprecated */
{
.colorspace = VK_COLOR_SPACE_HDR10_HLG_EXT,
.primaries = WP_COLOR_MANAGER_V1_PRIMARIES_BT2020,
.tf = WP_COLOR_MANAGER_V1_TRANSFER_FUNCTION_HLG,
+ .should_use_hdr_metadata = true,
},
{
.colorspace = VK_COLOR_SPACE_ADOBERGB_LINEAR_EXT,
.primaries = WP_COLOR_MANAGER_V1_PRIMARIES_ADOBE_RGB,
.tf = WP_COLOR_MANAGER_V1_TRANSFER_FUNCTION_EXT_LINEAR,
+ .should_use_hdr_metadata = false,
},
/* VK_COLOR_SPACE_ADOBERGB_NONLINEAR_EXT is left out because there's no
* exactly matching transfer function in the Wayland protocol */
@@ -977,6 +1002,7 @@ struct Colorspace colorspace_mapping[] = {
.colorspace = VK_COLOR_SPACE_EXTENDED_SRGB_NONLINEAR_EXT,
.primaries = WP_COLOR_MANAGER_V1_PRIMARIES_SRGB,
.tf = WP_COLOR_MANAGER_V1_TRANSFER_FUNCTION_EXT_SRGB,
+ .should_use_hdr_metadata = true,
},
/* VK_COLOR_SPACE_DISPLAY_NATIVE_AMD isn't supported */
/* VK_COLORSPACE_SRGB_NONLINEAR_KHR is just an alias */
@@ -1033,7 +1059,17 @@ color_management_handle_supported_features(void *data,
struct wp_color_manager_v1 *color_manager,
unsigned int feature)
{
- /* We don't use any non-default features yet. */
+ struct wsi_wl_display *display = data;
+ switch (feature) {
+ case WP_COLOR_MANAGER_V1_FEATURE_SET_MASTERING_DISPLAY_PRIMARIES:
+ display->color_features.mastering_display_primaries = true;
+ break;
+ case WP_COLOR_MANAGER_V1_FEATURE_EXTENDED_TARGET_VOLUME:
+ display->color_features.extended_target_volume = true;
+ break;
+ default:
+ break;
+ }
}
static void
@@ -1111,9 +1147,9 @@ needs_color_surface(VkColorSpaceKHR colorspace)
static void
wsi_wl_surface_add_color_refcount(struct wsi_wl_surface *wsi_surface)
{
- wsi_surface->color_surface_refcount++;
- if (wsi_surface->color_surface_refcount == 1) {
- wsi_surface->color_surface =
+ wsi_surface->color.color_surface_refcount++;
+ if (wsi_surface->color.color_surface_refcount == 1) {
+ wsi_surface->color.color_surface =
wp_color_manager_v1_get_surface(wsi_surface->display->color_manager, wsi_surface->surface);
}
}
@@ -1121,13 +1157,30 @@ wsi_wl_surface_add_color_refcount(struct wsi_wl_surface *wsi_surface)
static void
wsi_wl_surface_remove_color_refcount(struct wsi_wl_surface *wsi_surface)
{
- wsi_surface->color_surface_refcount--;
- if (wsi_surface->color_surface_refcount == 0) {
- wp_color_management_surface_v1_destroy(wsi_surface->color_surface);
- wsi_surface->color_surface = NULL;
+ wsi_surface->color.color_surface_refcount--;
+ if (wsi_surface->color.color_surface_refcount == 0) {
+ wp_color_management_surface_v1_destroy(wsi_surface->color.color_surface);
+ wsi_surface->color.color_surface = NULL;
}
}
+static bool
+compare_hdr_metadata(struct VkHdrMetadataEXT *l, struct VkHdrMetadataEXT *r)
+{
+ return l->displayPrimaryRed.x == r->displayPrimaryRed.x
+ && l->displayPrimaryRed.y == r->displayPrimaryRed.y
+ && l->displayPrimaryGreen.x == r->displayPrimaryGreen.x
+ && l->displayPrimaryGreen.y == r->displayPrimaryGreen.y
+ && l->displayPrimaryBlue.x == r->displayPrimaryBlue.x
+ && l->displayPrimaryBlue.y == r->displayPrimaryBlue.y
+ && l->whitePoint.x == r->whitePoint.x
+ && l->whitePoint.y == r->whitePoint.y
+ && l->maxLuminance == r->maxLuminance
+ && l->minLuminance == r->minLuminance
+ && l->maxContentLightLevel == r->maxContentLightLevel
+ && l->maxFrameAverageLightLevel == r->maxFrameAverageLightLevel;
+}
+
static VkResult
wsi_wl_swapchain_update_colorspace(struct wsi_wl_swapchain *chain)
{
@@ -1137,29 +1190,43 @@ wsi_wl_swapchain_update_colorspace(struct wsi_wl_swapchain *chain)
/* we need the color management extension for
* everything except sRGB and PASS_THROUGH */
if (!display->color_manager) {
- if (chain->colorspace == VK_COLOR_SPACE_SRGB_NONLINEAR_KHR ||
- chain->colorspace == VK_COLOR_SPACE_PASS_THROUGH_EXT) {
+ if (chain->color.colorspace == VK_COLOR_SPACE_SRGB_NONLINEAR_KHR ||
+ chain->color.colorspace == VK_COLOR_SPACE_PASS_THROUGH_EXT) {
return VK_SUCCESS;
} else {
return VK_ERROR_SURFACE_LOST_KHR;
}
}
- bool new_color_surface = !surface->color_surface;
- bool needs_color_surface_new = needs_color_surface(chain->colorspace);
- bool needs_color_surface_old = needs_color_surface(surface->colorspace);
+ 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);
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) {
wsi_wl_surface_remove_color_refcount(surface);
}
- if (!new_color_surface && surface->colorspace == chain->colorspace)
+ bool should_use_hdr_metadata = chain->color.has_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;
+ break;
+ }
+ }
+
+ if (!new_color_surface &&
+ surface->color.colorspace == chain->color.colorspace &&
+ surface->color.has_hdr_metadata == should_use_hdr_metadata &&
+ compare_hdr_metadata(&surface->color.hdr_metadata, &chain->color.hdr_metadata)) {
return VK_SUCCESS;
+ }
/* failure is fatal, so this potentially being wrong
in that case doesn't matter */
- surface->colorspace = chain->colorspace;
+ surface->color.colorspace = chain->color.colorspace;
+ surface->color.hdr_metadata = chain->color.hdr_metadata;
+ surface->color.has_hdr_metadata = should_use_hdr_metadata;
if (!needs_color_surface_new)
return VK_SUCCESS;
@@ -1172,7 +1239,7 @@ wsi_wl_swapchain_update_colorspace(struct wsi_wl_swapchain *chain)
unsigned int primaries = 0;
unsigned int tf = 0;
for (int i = 0; i < ARRAY_SIZE(colorspace_mapping); i++) {
- if (colorspace_mapping[i].colorspace == chain->colorspace) {
+ if (colorspace_mapping[i].colorspace == chain->color.colorspace) {
primaries = colorspace_mapping[i].primaries;
tf = colorspace_mapping[i].tf;
}
@@ -1183,6 +1250,29 @@ 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 && display->color_features.extended_target_volume) {
+ 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);
+ 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);
+ uint32_t green_x = round(chain->color.hdr_metadata.displayPrimaryGreen.x * 1000000);
+ uint32_t green_y = round(chain->color.hdr_metadata.displayPrimaryGreen.y * 1000000);
+ uint32_t blue_x = round(chain->color.hdr_metadata.displayPrimaryBlue.x * 1000000);
+ uint32_t blue_y = round(chain->color.hdr_metadata.displayPrimaryBlue.y * 1000000);
+ uint32_t white_x = round(chain->color.hdr_metadata.whitePoint.x * 1000000);
+ uint32_t white_y = round(chain->color.hdr_metadata.whitePoint.y * 1000000);
+ wp_image_description_creator_params_v1_set_mastering_display_primaries(creator, red_x, red_y,
+ 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);
+ }
+ }
wl_proxy_set_queue((struct wl_proxy *) creator, display->queue);
@@ -1202,7 +1292,7 @@ wsi_wl_swapchain_update_colorspace(struct wsi_wl_swapchain *chain)
if (status == failed)
return VK_ERROR_SURFACE_LOST_KHR;
- wp_color_management_surface_v1_set_image_description(chain->wsi_wl_surface->color_surface,
+ wp_color_management_surface_v1_set_image_description(chain->wsi_wl_surface->color.color_surface,
image_desc,
WP_COLOR_MANAGER_V1_RENDER_INTENT_PERCEPTUAL);
wp_image_description_v1_destroy(image_desc);
@@ -1210,6 +1300,14 @@ wsi_wl_swapchain_update_colorspace(struct wsi_wl_swapchain *chain)
return VK_SUCCESS;
}
+static void
+wsi_wl_swapchain_set_hdr_metadata(struct wsi_swapchain *wsi_chain,
+ const VkHdrMetadataEXT* pMetadata)
+{
+ struct wsi_wl_swapchain *chain = (struct wsi_wl_swapchain *)wsi_chain;
+ chain->color.hdr_metadata = *pMetadata;
+ chain->color.has_hdr_metadata = true;
+}
static void
presentation_handle_clock_id(void* data, struct wp_presentation *wp_presentation, uint32_t clk_id)
@@ -1875,8 +1973,8 @@ wsi_wl_surface_destroy(VkIcdSurfaceBase *icd_surface, VkInstance _instance,
dmabuf_feedback_fini(&wsi_wl_surface->pending_dmabuf_feedback);
}
- if (wsi_wl_surface->color_surface)
- wp_color_management_surface_v1_destroy(wsi_wl_surface->color_surface);
+ if (wsi_wl_surface->color.color_surface)
+ wp_color_management_surface_v1_destroy(wsi_wl_surface->color.color_surface);
if (wsi_wl_surface->surface)
wl_proxy_wrapper_destroy(wsi_wl_surface->surface);
@@ -2201,7 +2299,7 @@ wsi_CreateWaylandSurfaceKHR(VkInstance _instance,
surface->surface = pCreateInfo->surface;
wsi_wl_surface->instance = instance;
- wsi_wl_surface->colorspace = VK_COLOR_SPACE_SRGB_NONLINEAR_KHR;
+ wsi_wl_surface->color.colorspace = VK_COLOR_SPACE_SRGB_NONLINEAR_KHR;
*pSurface = VkIcdSurfaceBase_to_handle(&surface->base);
@@ -3185,7 +3283,7 @@ 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->colorspace) && wsi_wl_surface->color_surface) {
+ if (needs_color_surface(chain->color.colorspace) && wsi_wl_surface->color.color_surface) {
wsi_wl_surface_remove_color_refcount(wsi_wl_surface);
}
@@ -3352,7 +3450,7 @@ wsi_wl_surface_create_swapchain(VkIcdSurfaceBase *icd_surface,
WP_TEARING_CONTROL_V1_PRESENTATION_HINT_ASYNC);
}
- chain->colorspace = pCreateInfo->imageColorSpace;
+ chain->color.colorspace = pCreateInfo->imageColorSpace;
enum wsi_wl_buffer_type buffer_type;
struct wsi_base_image_params *image_params = NULL;
@@ -3426,6 +3524,7 @@ wsi_wl_surface_create_swapchain(VkIcdSurfaceBase *icd_surface,
chain->base.wait_for_present = wsi_wl_swapchain_wait_for_present;
chain->base.present_mode = present_mode;
chain->base.image_count = num_images;
+ chain->base.set_hdr_metadata = wsi_wl_swapchain_set_hdr_metadata;
chain->extent = pCreateInfo->imageExtent;
chain->vk_format = pCreateInfo->imageFormat;
chain->buffer_type = buffer_type;
--
2.49.0

View file

@ -0,0 +1,53 @@
From 692057de05dcf90ea9ac180a23d4996ebc1e7206 Mon Sep 17 00:00:00 2001
From: Xaver Hugl <xaver.hugl@kde.org>
Date: Thu, 7 Nov 2024 13:58:49 +0100
Subject: [PATCH 4/4] vulkan/wsi: handle the compositor not supporting extended
target volume better
Instead of unconditionally ignoring the HDR metadata, just attempt to create the image
description, and if it fails, fall back to creating it without HDR metadata.
Signed-off-by: Xaver Hugl <xaver.hugl@kde.org>
Reviewed-by: Sebastian Wick <sebastian.wick@redhat.com>
Acked-by: Daniel Stone <daniels@collabora.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/32038>
---
src/vulkan/wsi/wsi_common_wayland.c | 15 ++++++++++++---
1 file changed, 12 insertions(+), 3 deletions(-)
diff --git a/src/vulkan/wsi/wsi_common_wayland.c b/src/vulkan/wsi/wsi_common_wayland.c
index de12f524891..4c364401226 100644
--- a/src/vulkan/wsi/wsi_common_wayland.c
+++ b/src/vulkan/wsi/wsi_common_wayland.c
@@ -1250,7 +1250,7 @@ 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 && display->color_features.extended_target_volume) {
+ 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);
@@ -1289,8 +1289,17 @@ wsi_wl_swapchain_update_colorspace(struct wsi_wl_swapchain *chain)
if (ret < 0)
return VK_ERROR_OUT_OF_DATE_KHR;
}
- if (status == failed)
- return VK_ERROR_SURFACE_LOST_KHR;
+ if (status == failed) {
+ wp_image_description_v1_destroy(image_desc);
+ if (!display->color_features.extended_target_volume && should_use_hdr_metadata) {
+ /* VK_EXT_hdr_metadata doesn't specify if or how the metadata is used,
+ * so it's fine to try again without it. */
+ chain->color.has_hdr_metadata = false;
+ return wsi_wl_swapchain_update_colorspace(chain);
+ } else {
+ return VK_ERROR_SURFACE_LOST_KHR;
+ }
+ }
wp_color_management_surface_v1_set_image_description(chain->wsi_wl_surface->color.color_surface,
image_desc,
--
2.49.0

View file

@ -0,0 +1,117 @@
Subject: RE: Question about Mesa MLAA license
From: Jorge Jimenez <iryoku@gmail.com>
Date: 01/08/2013 12:50 PM
To: Tom Callaway <tcallawa@redhat.com>
CC: "jorge@iryoku.com" <jorge@iryoku.com>
Yes to both questions.
Thanks,
Jorge
From: Tom Callaway <tcallawa@redhat.com>
Sent: January 8, 2013 6:49 PM
To: Jorge Jimenez <iryoku@gmail.com>
CC: jorge@iryoku.com
Subject: Re: Question about Mesa MLAA license
On 01/08/2013 12:39 PM, Jorge Jimenez wrote:
> Hi Tom,
>
> What we meant with that is that we made an exception for clause 2.
> Instead of clause 2, in the case of the Mesa project, you have to name
> the technique Jimenez's MLAA in the config options of Mesa. We did that
> just to allow them to solve license issues. This exception should be for
> the Mesa project, and any project using Mesa, like Fedora.
>
> We want to widespread usage of our MLAA, so we want to avoid any kind of
> license complications. Hope current one is good for Fedora, if not
> please tell, and we'll see what we can do!
Okay, a few more questions:
* If Fedora decides to simply reproduce the quoted statement:
"Uses Jimenez's MLAA. Copyright (C) 2010 by Jorge Jimenez, Belen Masia,
Jose I. Echevarria, Fernando Navarro and Diego Gutierrez."
Specifically, if this is done as part of documentation included with
Mesa, is that sufficient to meet clause 2 even if the Mesa config option
is not set as described in your exception?
* Currently, the Mesa config option for MLAA says: "Morphological
anti-aliasing based on Jimenez\' MLAA. 0 to disable, 8 for default
quality". Is this in compliance with your exception?
Thanks again,
~tom
==
Fedora Project
Subject: RE: Question about Mesa MLAA license
From: Jorge Jimenez <iryoku@gmail.com>
Date: 01/08/2013 12:39 PM
To: "jorge@iryoku.com" <jorge@iryoku.com>, Tom Callaway <tcallawa@redhat.com>
Hi Tom,
What we meant with that is that we made an exception for clause 2.
Instead of clause 2, in the case of the Mesa project, you have to name
the technique Jimenez's MLAA in the config options of Mesa. We did that
just to allow them to solve license issues. This exception should be for
the Mesa project, and any project using Mesa, like Fedora.
We want to widespread usage of our MLAA, so we want to avoid any kind of
license complications. Hope current one is good for Fedora, if not
please tell, and we'll see what we can do!
Cheers,
Jorge
From: Tom Callaway <tcallawa@redhat.com>
Sent: January 8, 2013 6:30 PM
To: jorge@iryoku.com
Subject: Question about Mesa MLAA license
Jorge,
Thanks for all of your fantastic graphics work! I have been auditing
Fedora (a popular distribution of Linux) for license compliance and I
came across your MLAA code in Mesa.
The license says:
* 2. Redistributions in binary form must reproduce the following
statement:
*
* "Uses Jimenez's MLAA. Copyright (C) 2010 by Jorge Jimenez, Belen Masia,
* Jose I. Echevarria, Fernando Navarro and Diego Gutierrez."
*
* Only for use in the Mesa project, this point 2 is filled by naming the
* technique Jimenez's MLAA in the Mesa config options.
That wording is unclear. When you say "Only for use in the Mesa
project...", it seems like you could either be saying:
- This code may only be used as part of Mesa.
OR
- In Mesa, you can comply with clause 2 by simply selecting "Jimenez's
MLAA" in the Mesa config options.
*****
If the first item is true, then we may have to remove the MLAA code from
Fedora's copy of Mesa. However, looking at the license on your SMAA
code, I do not believe it to be the case. Please let me know either way!
Thanks in advance,
Tom Callaway
Fedora Legal
==
Fedora Project

View file

@ -0,0 +1,144 @@
From e4eb5e80c316c0af3fff310ca89e1175d81556c1 Mon Sep 17 00:00:00 2001
From: Nikita Popov <npopov@redhat.com>
Date: Thu, 27 Feb 2025 15:44:27 +0100
Subject: [PATCH] clover: Don't include libclc headers
Per https://github.com/llvm/llvm-project/issues/119967 these
headers are internal implementation details of libclc and were
never supposed to be installed. They are not available anymore
since LLVM 20. Instead opencl-c.h should be used.
There already ise a code path for including opencl-c.h, so always
use it.
This didn't work for me out of the box, because the build system
currently hardcodes the clang resource directory, which is incorrect
for Fedora at least. Fix this by using GetResourcePath +
CLANG_RESOURCE_DIR provided by clang instead. This is basically
the same as what is done in clc_helper.c
I've still retained the old behavior as a fallback just in case
(e.g. if clang is linked statically?)
Reviewed-by: Karol Herbst <kherbst@redhat.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/33805>
---
.../frontends/clover/llvm/invocation.cpp | 53 +++++++++++++------
src/gallium/frontends/clover/meson.build | 5 +-
2 files changed, 39 insertions(+), 19 deletions(-)
diff --git a/src/gallium/frontends/clover/llvm/invocation.cpp b/src/gallium/frontends/clover/llvm/invocation.cpp
index 3cbb05baecf67..ca030b404d791 100644
--- a/src/gallium/frontends/clover/llvm/invocation.cpp
+++ b/src/gallium/frontends/clover/llvm/invocation.cpp
@@ -24,6 +24,8 @@
// OTHER DEALINGS IN THE SOFTWARE.
//
+#include <dlfcn.h>
+
#include <llvm/IR/DiagnosticPrinter.h>
#include <llvm/IR/DiagnosticInfo.h>
#include <llvm/IR/LLVMContext.h>
@@ -39,6 +41,8 @@
#include <clang/Frontend/TextDiagnosticBuffer.h>
#include <clang/Frontend/TextDiagnosticPrinter.h>
#include <clang/Basic/TargetInfo.h>
+#include <clang/Config/config.h>
+#include <clang/Driver/Driver.h>
#if LLVM_VERSION_MAJOR >= 20
#include <llvm/Support/VirtualFileSystem.h>
@@ -323,6 +327,30 @@ namespace {
return c;
}
+ std::string getResourceDirectory() {
+ Dl_info info;
+ if (dladdr((void *)clang::CompilerInvocation::CreateFromArgs, &info) == 0) {
+ return FALLBACK_CLANG_RESOURCE_DIR;
+ }
+
+ char *libclang_path = realpath(info.dli_fname, NULL);
+ if (libclang_path == nullptr) {
+ return FALLBACK_CLANG_RESOURCE_DIR;
+ }
+
+ // GetResourcePath is a way to retrieve the actual libclang resource dir based on a given
+ // binary or library.
+ std::string clang_resource_dir =
+#if LLVM_VERSION_MAJOR >= 20
+ clang::driver::Driver::GetResourcesPath(std::string(libclang_path));
+#else
+ clang::driver::Driver::GetResourcesPath(std::string(libclang_path), CLANG_RESOURCE_DIR);
+#endif
+ free(libclang_path);
+
+ return clang_resource_dir;
+ }
+
std::unique_ptr<Module>
compile(LLVMContext &ctx, clang::CompilerInstance &c,
const std::string &name, const std::string &source,
@@ -331,25 +359,18 @@ namespace {
c.getFrontendOpts().ProgramAction = clang::frontend::EmitLLVMOnly;
c.getHeaderSearchOpts().UseBuiltinIncludes = true;
c.getHeaderSearchOpts().UseStandardSystemIncludes = true;
- c.getHeaderSearchOpts().ResourceDir = CLANG_RESOURCE_DIR;
- if (use_libclc) {
- // Add libclc generic search path
- c.getHeaderSearchOpts().AddPath(LIBCLC_INCLUDEDIR,
- clang::frontend::Angled,
- false, false);
+ std::string clang_resource_dir = getResourceDirectory();
+ c.getHeaderSearchOpts().ResourceDir = clang_resource_dir;
- // Add libclc include
- c.getPreprocessorOpts().Includes.push_back("clc/clc.h");
- } else {
- // Add opencl-c generic search path
- c.getHeaderSearchOpts().AddPath(CLANG_RESOURCE_DIR,
- clang::frontend::Angled,
- false, false);
+ // Add opencl-c generic search path
+ std::string clang_include_path = clang_resource_dir + "/include";
+ c.getHeaderSearchOpts().AddPath(clang_include_path,
+ clang::frontend::Angled,
+ false, false);
- // Add opencl include
- c.getPreprocessorOpts().Includes.push_back("opencl-c.h");
- }
+ // Add opencl include
+ c.getPreprocessorOpts().Includes.push_back("opencl-c.h");
// Add definition for the OpenCL version
const auto dev_version = dev.device_version();
diff --git a/src/gallium/frontends/clover/meson.build b/src/gallium/frontends/clover/meson.build
index e569b86a1bea7..56a9894f0dbb1 100644
--- a/src/gallium/frontends/clover/meson.build
+++ b/src/gallium/frontends/clover/meson.build
@@ -10,7 +10,6 @@ clover_opencl_cpp_args = [
'-DCL_USE_DEPRECATED_OPENCL_2_0_APIS',
'-DCL_USE_DEPRECATED_OPENCL_2_1_APIS',
'-DCL_USE_DEPRECATED_OPENCL_2_2_APIS',
- '-DLIBCLC_INCLUDEDIR="@0@/"'.format(dep_clc.get_variable(pkgconfig : 'includedir')),
'-DLIBCLC_LIBEXECDIR="@0@/"'.format(dep_clc.get_variable(pkgconfig : 'libexecdir'))
]
clover_incs = [inc_include, inc_src, inc_gallium, inc_gallium_aux]
@@ -43,9 +42,9 @@ libclllvm = static_library(
cpp_args : [
clover_cpp_args,
clover_opencl_cpp_args,
- '-DCLANG_RESOURCE_DIR="@0@"'.format(join_paths(
+ '-DFALLBACK_CLANG_RESOURCE_DIR="@0@"'.format(join_paths(
dep_llvm.get_variable(cmake : 'LLVM_LIBRARY_DIR', configtool: 'libdir'), 'clang',
- dep_llvm.version(), 'include',
+ dep_llvm.version()
)),
],
gnu_symbol_visibility : 'hidden',
--
GitLab

View file

@ -0,0 +1,11 @@
diff -up mesa-22.3.0-rc4/src/util/00-mesa-defaults.conf.dma mesa-22.3.0-rc4/src/util/00-mesa-defaults.conf
--- mesa-22.3.0-rc4/src/util/00-mesa-defaults.conf.dma 2022-11-25 10:32:32.175879868 +1000
+++ mesa-22.3.0-rc4/src/util/00-mesa-defaults.conf 2022-11-25 10:32:43.743067470 +1000
@@ -653,6 +653,7 @@ TODO: document the other workarounds.
<application name="gnome-shell" executable="gnome-shell">
<option name="adaptive_sync" value="false" />
<option name="v3d_nonmsaa_texture_size_limit" value="true" />
+ <option name="mesa_glthread" value="false"/>
</application>
<application name="Desktop — Plasma" executable="plasmashell">
<option name="adaptive_sync" value="false" />

View file

@ -69,7 +69,7 @@
Name: mesa
Summary: Mesa graphics libraries
%global ver 25.0.1
%global ver 25.0.3
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
@ -79,9 +79,22 @@ Source0: https://archive.mesa3d.org/mesa-%{ver}.tar.xz
# src/gallium/auxiliary/postprocess/pp_mlaa* have an ... interestingly worded license.
# Source1 contains email correspondence clarifying the license terms.
# Fedora opts to ignore the optional part of clause 2 and treat that code as 2 clause BSD.
Source1: https://src.fedoraproject.org/rpms/mesa/raw/f41/f/Mesa-MLAA-License-Clarification-Email.txt
Source1: Mesa-MLAA-License-Clarification-Email.txt
Patch10: https://src.fedoraproject.org/rpms/mesa/raw/f41/f/gnome-shell-glthread-disable.patch
Patch10: gnome-shell-glthread-disable.patch
# Backport of https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/33805
# to fix clover with libclc from LLVM 20.
Patch20: e4eb5e80c316c0af3fff310ca89e1175d81556c1.patch
# Backport of https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/32038
# and fixes: vulkan/wsi: implement the Wayland color management protocol
Patch21: 0001-increase-required-wayland-protocols-version-to-1.41.patch
Patch22: 0002-vulkan-wsi-implement-the-Wayland-color-management-pr.patch
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
BuildRequires: meson >= 1.3.0
BuildRequires: gcc
@ -318,7 +331,7 @@ Provides: libxatracker-devel%{?_isa}
%if 0%{?with_opencl}
%package libOpenCL
Summary: Mesa OpenCL runtime library
Requires: ocl-icd%{?_isa}
Requires: (ocl-icd%{?_isa} or OpenCL-ICD-Loader%{?_isa})
Requires: libclc%{?_isa}
Requires: %{name}-libgbm%{?_isa} = %{?epoch:%{epoch}:}%{version}-%{release}
Requires: opencl-filesystem