diff options
Diffstat (limited to 'recipes-graphics/vulkan/vulkan-wsi-layer')
3 files changed, 305 insertions, 0 deletions
diff --git a/recipes-graphics/vulkan/vulkan-wsi-layer/0001-MGS-6801-ccc-vkmark-on-wayland.patch b/recipes-graphics/vulkan/vulkan-wsi-layer/0001-MGS-6801-ccc-vkmark-on-wayland.patch new file mode 100644 index 000000000..48cfcd765 --- /dev/null +++ b/recipes-graphics/vulkan/vulkan-wsi-layer/0001-MGS-6801-ccc-vkmark-on-wayland.patch | |||
@@ -0,0 +1,30 @@ | |||
1 | From ada74fb0ca3099f33d173eb664bd7e42025a3277 Mon Sep 17 00:00:00 2001 | ||
2 | From: Prabhu Sundararaj <prabhu.sundararaj@nxp.com> | ||
3 | Date: Mon, 9 Dec 2024 09:15:11 +0800 | ||
4 | Subject: [PATCH 1/2] MGS-6801 [#ccc] vkmark on wayland | ||
5 | |||
6 | Extend the wayland surface properties with VK_COMPOSITE_ALPHA_OPAQUE_BIT_KHR | ||
7 | |||
8 | Upstream-Status: Inappropriate [i.MX-specific] | ||
9 | Signed-off-by: Prabhu Sundararaj <prabhu.sundararaj@nxp.com> | ||
10 | Signed-off-by: Jiyu Yang <jiyu.yang@nxp.com> | ||
11 | --- | ||
12 | wsi/wayland/surface_properties.cpp | 2 +- | ||
13 | 1 file changed, 1 insertion(+), 1 deletion(-) | ||
14 | |||
15 | diff --git a/wsi/wayland/surface_properties.cpp b/wsi/wayland/surface_properties.cpp | ||
16 | index e6435b9..bc1a737 100644 | ||
17 | --- a/wsi/wayland/surface_properties.cpp | ||
18 | +++ b/wsi/wayland/surface_properties.cpp | ||
19 | @@ -89,7 +89,7 @@ VkResult surface_properties::get_surface_capabilities(VkPhysicalDevice physical_ | ||
20 | |||
21 | /* Composite alpha */ | ||
22 | pSurfaceCapabilities->supportedCompositeAlpha = static_cast<VkCompositeAlphaFlagBitsKHR>( | ||
23 | - VK_COMPOSITE_ALPHA_PRE_MULTIPLIED_BIT_KHR | VK_COMPOSITE_ALPHA_INHERIT_BIT_KHR); | ||
24 | + VK_COMPOSITE_ALPHA_PRE_MULTIPLIED_BIT_KHR | VK_COMPOSITE_ALPHA_OPAQUE_BIT_KHR); | ||
25 | return VK_SUCCESS; | ||
26 | } | ||
27 | |||
28 | -- | ||
29 | 2.37.1 | ||
30 | |||
diff --git a/recipes-graphics/vulkan/vulkan-wsi-layer/0002-MGS-6823-nxp-Add-support-of-VK_COMPOSITE_ALPHA_OPAQU.patch b/recipes-graphics/vulkan/vulkan-wsi-layer/0002-MGS-6823-nxp-Add-support-of-VK_COMPOSITE_ALPHA_OPAQU.patch new file mode 100644 index 000000000..9955f415e --- /dev/null +++ b/recipes-graphics/vulkan/vulkan-wsi-layer/0002-MGS-6823-nxp-Add-support-of-VK_COMPOSITE_ALPHA_OPAQU.patch | |||
@@ -0,0 +1,243 @@ | |||
1 | From 4293d8835eaa45168c070793eefd8867c6ec7605 Mon Sep 17 00:00:00 2001 | ||
2 | From: Yuan Tian <yuan.tian@nxp.com> | ||
3 | Date: Thu, 27 Jul 2023 18:25:16 +0800 | ||
4 | Subject: [PATCH 2/2] MGS-6823 [#nxp] Add support of | ||
5 | VK_COMPOSITE_ALPHA_OPAQUE_BIT_KHR feature | ||
6 | |||
7 | Mali vulkan driver doesn't support VK_COMPOSITE_ALPHA_OPAQUE_BIT_KHR. It caused unwanted blending effect in many vulkan cases. | ||
8 | Add support of this feature to solve the problem. | ||
9 | |||
10 | Upstream-Status: Inappropriate [i.MX-specific] | ||
11 | Signed-off-by: Yuan Tian <yuan.tian@nxp.com> | ||
12 | Signed-off-by: Jiyu Yang <jiyu.yang@nxp.com> | ||
13 | --- | ||
14 | wsi/wayland/swapchain.cpp | 161 ++++++++++++++++++++++++++++++++++++++ | ||
15 | wsi/wayland/swapchain.hpp | 9 +++ | ||
16 | 2 files changed, 170 insertions(+) | ||
17 | |||
18 | Index: git/wsi/wayland/swapchain.cpp | ||
19 | =================================================================== | ||
20 | --- git.orig/wsi/wayland/swapchain.cpp | ||
21 | +++ git/wsi/wayland/swapchain.cpp | ||
22 | @@ -38,6 +38,7 @@ | ||
23 | #include <cstdio> | ||
24 | #include <climits> | ||
25 | #include <functional> | ||
26 | +#include <poll.h> | ||
27 | |||
28 | #include "util/drm/drm_utils.hpp" | ||
29 | #include "util/log.hpp" | ||
30 | @@ -72,12 +73,152 @@ swapchain::~swapchain() | ||
31 | wsialloc_delete(m_wsi_allocator); | ||
32 | } | ||
33 | m_wsi_allocator = nullptr; | ||
34 | + if (wlc.opaque_region) | ||
35 | + { | ||
36 | + wl_compositor_destroy(wlc.wl_compositor); | ||
37 | + wl_registry_destroy(wlc.registry); | ||
38 | + wl_region_destroy(wlc.opaque_region); | ||
39 | + wlc = {0}; | ||
40 | + } | ||
41 | if (m_buffer_queue != nullptr) | ||
42 | { | ||
43 | wl_event_queue_destroy(m_buffer_queue); | ||
44 | } | ||
45 | } | ||
46 | |||
47 | +static inline int | ||
48 | +poll_event(struct wl_display *wl_dpy, short int events, int timeout) | ||
49 | +{ | ||
50 | + int ret; | ||
51 | + struct pollfd pfd[1]; | ||
52 | + | ||
53 | + pfd[0].fd = wl_display_get_fd(wl_dpy); | ||
54 | + pfd[0].events = events; | ||
55 | + | ||
56 | + do | ||
57 | + { | ||
58 | + ret = poll(pfd, 1, timeout); | ||
59 | + } | ||
60 | + while (ret == -1 && errno == EINTR); | ||
61 | + | ||
62 | + return ret; | ||
63 | +} | ||
64 | + | ||
65 | +static int | ||
66 | +dispatch_queue_op(struct wl_display *wl_dpy, | ||
67 | + struct wl_event_queue *wl_queue, int timeout) | ||
68 | +{ | ||
69 | + int ret; | ||
70 | + | ||
71 | + if (wl_display_prepare_read_queue(wl_dpy, wl_queue) == -1) | ||
72 | + { | ||
73 | + return wl_display_dispatch_queue_pending(wl_dpy, wl_queue); | ||
74 | + } | ||
75 | + | ||
76 | + for (;;) | ||
77 | + { | ||
78 | + ret = wl_display_flush(wl_dpy); | ||
79 | + | ||
80 | + if (ret != -1 || errno != EAGAIN) | ||
81 | + break; | ||
82 | + | ||
83 | + if (poll_event(wl_dpy, POLLOUT, -1) == -1) | ||
84 | + { | ||
85 | + wl_display_cancel_read(wl_dpy); | ||
86 | + return -1; | ||
87 | + } | ||
88 | + } | ||
89 | + | ||
90 | + /* Don't stop if flushing hits an EPIPE; continue so we can read any | ||
91 | + * protocol error that may have triggered it. */ | ||
92 | + if (ret < 0 && errno != EPIPE) | ||
93 | + { | ||
94 | + wl_display_cancel_read(wl_dpy); | ||
95 | + return -1; | ||
96 | + } | ||
97 | + | ||
98 | + ret = poll_event(wl_dpy, POLLIN, timeout); | ||
99 | + | ||
100 | + /* cancel read when on error or timeout. */ | ||
101 | + if (ret == -1 || ret == 0) | ||
102 | + { | ||
103 | + wl_display_cancel_read(wl_dpy); | ||
104 | + return ret; | ||
105 | + } | ||
106 | + | ||
107 | + if (wl_display_read_events(wl_dpy) == -1) | ||
108 | + return -1; | ||
109 | + | ||
110 | + return wl_display_dispatch_queue_pending(wl_dpy, wl_queue); | ||
111 | +} | ||
112 | + | ||
113 | +static void | ||
114 | +sync_callback(void *data, struct wl_callback *callback, uint32_t serial) | ||
115 | +{ | ||
116 | + int *done = (int *)data; | ||
117 | + | ||
118 | + *done = 1; | ||
119 | + wl_callback_destroy(callback); | ||
120 | +} | ||
121 | + | ||
122 | +static const struct wl_callback_listener sync_listener = { | ||
123 | + sync_callback | ||
124 | +}; | ||
125 | + | ||
126 | +static int | ||
127 | +roundtrip_queue(struct wl_display *wl_dpy, struct wl_event_queue *wl_queue) | ||
128 | +{ | ||
129 | + struct wl_callback *callback; | ||
130 | + int done, ret = 0; | ||
131 | + | ||
132 | + done = 0; | ||
133 | + | ||
134 | + /* | ||
135 | + * This is to block read & dispatch events in other threads, so that the | ||
136 | + * callback is with correct queue and listener when 'done' event. | ||
137 | + */ | ||
138 | + while (wl_display_prepare_read_queue(wl_dpy, wl_queue) == -1) | ||
139 | + wl_display_dispatch_queue_pending(wl_dpy, wl_queue); | ||
140 | + | ||
141 | + callback = wl_display_sync(wl_dpy); | ||
142 | + | ||
143 | + if (callback == NULL) | ||
144 | + { | ||
145 | + wl_display_cancel_read(wl_dpy); | ||
146 | + return -1; | ||
147 | + } | ||
148 | + | ||
149 | + wl_proxy_set_queue((struct wl_proxy *) callback, wl_queue); | ||
150 | + wl_callback_add_listener(callback, &sync_listener, &done); | ||
151 | + | ||
152 | + wl_display_cancel_read(wl_dpy); | ||
153 | + | ||
154 | + while (!done && ret >= 0) | ||
155 | + ret = dispatch_queue_op(wl_dpy, wl_queue, 5); | ||
156 | + | ||
157 | + if (ret == -1 && !done) | ||
158 | + wl_callback_destroy(callback); | ||
159 | + | ||
160 | + return ret; | ||
161 | +} | ||
162 | + | ||
163 | +static void | ||
164 | +registry_handle_global(void *data, struct wl_registry *registry, uint32_t name, | ||
165 | + const char *interface, uint32_t version) | ||
166 | +{ | ||
167 | + wl_context *pwlc = (wl_context *)data; | ||
168 | + | ||
169 | + if(!pwlc->wl_compositor) | ||
170 | + { | ||
171 | + pwlc->wl_compositor = (wl_compositor *)wl_registry_bind(registry, name, &wl_compositor_interface, 1); | ||
172 | + wl_proxy_set_queue((struct wl_proxy *)pwlc->wl_compositor, pwlc->wl_queue); | ||
173 | + } | ||
174 | +} | ||
175 | + | ||
176 | +static const struct wl_registry_listener registry_listener = { | ||
177 | + registry_handle_global | ||
178 | +}; | ||
179 | + | ||
180 | VkResult swapchain::init_platform(VkDevice device, const VkSwapchainCreateInfoKHR *swapchain_create_info, | ||
181 | bool &use_presentation_thread) | ||
182 | { | ||
183 | @@ -124,6 +265,21 @@ VkResult swapchain::init_platform(VkDevi | ||
184 | use_presentation_thread = | ||
185 | WAYLAND_FIFO_PRESENTATION_THREAD_ENABLED && (m_present_mode != VK_PRESENT_MODE_MAILBOX_KHR); | ||
186 | |||
187 | + if (swapchain_create_info->compositeAlpha & VK_COMPOSITE_ALPHA_OPAQUE_BIT_KHR) | ||
188 | + { | ||
189 | + wlc.wl_queue = m_buffer_queue; | ||
190 | + wlc.registry = wl_display_get_registry(m_display); | ||
191 | + wl_proxy_set_queue((struct wl_proxy *)(wlc.registry), m_buffer_queue); | ||
192 | + wl_registry_add_listener(wlc.registry, ®istry_listener, &wlc); | ||
193 | + | ||
194 | + roundtrip_queue(m_display, m_buffer_queue); | ||
195 | + | ||
196 | + wlc.opaque_region = wl_compositor_create_region(wlc.wl_compositor); | ||
197 | + wl_proxy_set_queue((struct wl_proxy *)(wlc.opaque_region), m_buffer_queue); | ||
198 | + | ||
199 | + wl_region_add(wlc.opaque_region, 0, 0, swapchain_create_info->imageExtent.width, swapchain_create_info->imageExtent.height); | ||
200 | + } | ||
201 | + | ||
202 | return VK_SUCCESS; | ||
203 | } | ||
204 | |||
205 | @@ -494,6 +650,11 @@ void swapchain::present_image(const pend | ||
206 | set_error_state(VK_ERROR_SURFACE_LOST_KHR); | ||
207 | } | ||
208 | |||
209 | + if (wlc.opaque_region) | ||
210 | + { | ||
211 | + wl_surface_set_opaque_region(m_surface, wlc.opaque_region); | ||
212 | + } | ||
213 | + | ||
214 | wl_surface_attach(m_surface, image_data->buffer, 0, 0); | ||
215 | |||
216 | auto present_sync_fd = image_data->present_fence.export_sync_fd(); | ||
217 | Index: git/wsi/wayland/swapchain.hpp | ||
218 | =================================================================== | ||
219 | --- git.orig/wsi/wayland/swapchain.hpp | ||
220 | +++ git/wsi/wayland/swapchain.hpp | ||
221 | @@ -78,6 +78,14 @@ struct image_creation_parameters | ||
222 | } | ||
223 | }; | ||
224 | |||
225 | +struct wl_context | ||
226 | +{ | ||
227 | + struct wl_event_queue *wl_queue; | ||
228 | + struct wl_compositor *wl_compositor; | ||
229 | + struct wl_registry *registry; | ||
230 | + struct wl_region *opaque_region; | ||
231 | +}; | ||
232 | + | ||
233 | class swapchain : public wsi::swapchain_base | ||
234 | { | ||
235 | public: | ||
236 | @@ -190,6 +198,7 @@ private: | ||
237 | |||
238 | struct wl_display *m_display; | ||
239 | struct wl_surface *m_surface; | ||
240 | + struct wl_context wlc = {0}; | ||
241 | /** Raw pointer to the WSI Surface that this swapchain was created from. The Vulkan specification ensures that the | ||
242 | * surface is valid until swapchain is destroyed. */ | ||
243 | surface *m_wsi_surface; | ||
diff --git a/recipes-graphics/vulkan/vulkan-wsi-layer/0003-Update-minimum-version-of-CMake.patch b/recipes-graphics/vulkan/vulkan-wsi-layer/0003-Update-minimum-version-of-CMake.patch new file mode 100644 index 000000000..0bc00de02 --- /dev/null +++ b/recipes-graphics/vulkan/vulkan-wsi-layer/0003-Update-minimum-version-of-CMake.patch | |||
@@ -0,0 +1,32 @@ | |||
1 | From 0c4ed8178a25135ced9df8c8a8909e2882bfe869 Mon Sep 17 00:00:00 2001 | ||
2 | From: Maged Elnaggar <maged.elnaggar@arm.com> | ||
3 | Date: Tue, 17 Jun 2025 10:33:44 +0000 | ||
4 | Subject: [PATCH] Update minimum version of CMake | ||
5 | |||
6 | Set CMake minimum required version range to 3.4.3...4.0 | ||
7 | to silence compatibility errors in CMake 4.0 | ||
8 | by explicitly opting into all policies up to 4.0 | ||
9 | |||
10 | Upstream-Status: Backport [https://gitlab.freedesktop.org/mesa/vulkan-wsi-layer/-/commit/1eafebc56a7f735cd4e8298956d596c64ac9f681] | ||
11 | Signed-off-by: Maged Elnaggar <maged.elnaggar@arm.com> | ||
12 | Change-Id: I2e0527dde4e764e9c17f519fc0ddd3c0e382fa31 | ||
13 | --- | ||
14 | CMakeLists.txt | 2 +- | ||
15 | 1 file changed, 1 insertion(+), 1 deletion(-) | ||
16 | |||
17 | diff --git a/CMakeLists.txt b/CMakeLists.txt | ||
18 | index 4dc800c..b91cd54 100644 | ||
19 | --- a/CMakeLists.txt | ||
20 | +++ b/CMakeLists.txt | ||
21 | @@ -20,7 +20,7 @@ | ||
22 | # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE | ||
23 | # SOFTWARE. | ||
24 | |||
25 | -cmake_minimum_required(VERSION 3.4.3) | ||
26 | +cmake_minimum_required(VERSION 3.4.3...4.0) | ||
27 | project(VkLayer_window_system_integration) | ||
28 | |||
29 | find_package(PkgConfig REQUIRED) | ||
30 | -- | ||
31 | 2.34.1 | ||
32 | |||