1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
|
From 7154ec4750e1a92a8b3b77bcd3f75650ffbba0be Mon Sep 17 00:00:00 2001
From: Etaash Mathamsetty
<45927311+Etaash-mathamsetty@users.noreply.github.com>
Date: Tue, 27 May 2025 14:14:56 -0400
Subject: [PATCH 1/2] vulkan/wsi/wayland: Move drm syncobj to swapchain.
cc: mesa-stable
---
src/vulkan/wsi/wsi_common_wayland.c | 39 ++++++++++++++++-------------
1 file changed, 21 insertions(+), 18 deletions(-)
diff --git a/src/vulkan/wsi/wsi_common_wayland.c b/src/vulkan/wsi/wsi_common_wayland.c
index dd15d03846b0a..5feefc89da86e 100644
--- a/src/vulkan/wsi/wsi_common_wayland.c
+++ b/src/vulkan/wsi/wsi_common_wayland.c
@@ -184,9 +184,6 @@ struct wsi_wl_surface {
struct zwp_linux_dmabuf_feedback_v1 *wl_dmabuf_feedback;
struct dmabuf_feedback dmabuf_feedback, pending_dmabuf_feedback;
-
- struct wp_linux_drm_syncobj_surface_v1 *wl_syncobj_surface;
-
struct vk_instance *instance;
struct {
@@ -205,6 +202,7 @@ struct wsi_wl_swapchain {
struct wp_tearing_control_v1 *tearing_control;
struct wp_fifo_v1 *fifo;
struct wp_commit_timer_v1 *commit_timer;
+ struct wp_linux_drm_syncobj_surface_v1 *wl_syncobj_surface;
struct wl_callback *frame;
@@ -1333,7 +1331,7 @@ wsi_wl_swapchain_update_colorspace(struct wsi_wl_swapchain *chain)
}
}
- wp_color_management_surface_v1_set_image_description(chain->wsi_wl_surface->color.color_surface,
+ wp_color_management_surface_v1_set_image_description(chain->color.color_surface,
image_desc,
WP_COLOR_MANAGER_V1_RENDER_INTENT_PERCEPTUAL);
wp_image_description_v1_destroy(image_desc);
@@ -2046,9 +2044,6 @@ wsi_wl_surface_destroy(VkIcdSurfaceBase *icd_surface, VkInstance _instance,
struct wsi_wl_surface *wsi_wl_surface =
wl_container_of((VkIcdSurfaceWayland *)icd_surface, wsi_wl_surface, base);
- if (wsi_wl_surface->wl_syncobj_surface)
- wp_linux_drm_syncobj_surface_v1_destroy(wsi_wl_surface->wl_syncobj_surface);
-
if (wsi_wl_surface->wl_dmabuf_feedback) {
zwp_linux_dmabuf_feedback_v1_destroy(wsi_wl_surface->wl_dmabuf_feedback);
dmabuf_feedback_fini(&wsi_wl_surface->dmabuf_feedback);
@@ -2312,15 +2307,6 @@ static VkResult wsi_wl_surface_init(struct wsi_wl_surface *wsi_wl_surface,
wsi_wl_surface->display->queue);
}
- if (wsi_wl_use_explicit_sync(wsi_wl_surface->display, wsi_device)) {
- wsi_wl_surface->wl_syncobj_surface =
- wp_linux_drm_syncobj_manager_v1_get_surface(wsi_wl_surface->display->wl_syncobj,
- wsi_wl_surface->wayland_surface.wrapper);
-
- if (!wsi_wl_surface->wl_syncobj_surface)
- goto fail;
- }
-
return VK_SUCCESS;
fail:
@@ -2988,11 +2974,11 @@ wsi_wl_swapchain_queue_present(struct wsi_swapchain *wsi_chain,
/* Incremented by signal in base queue_present. */
uint64_t acquire_point = image->base.explicit_sync[WSI_ES_ACQUIRE].timeline;
uint64_t release_point = image->base.explicit_sync[WSI_ES_RELEASE].timeline;
- wp_linux_drm_syncobj_surface_v1_set_acquire_point(wsi_wl_surface->wl_syncobj_surface,
+ wp_linux_drm_syncobj_surface_v1_set_acquire_point(chain->wl_syncobj_surface,
image->wl_syncobj_timeline[WSI_ES_ACQUIRE],
(uint32_t)(acquire_point >> 32),
(uint32_t)(acquire_point & 0xffffffff));
- wp_linux_drm_syncobj_surface_v1_set_release_point(wsi_wl_surface->wl_syncobj_surface,
+ wp_linux_drm_syncobj_surface_v1_set_release_point(chain->wl_syncobj_surface,
image->wl_syncobj_timeline[WSI_ES_RELEASE],
(uint32_t)(release_point >> 32),
(uint32_t)(release_point & 0xffffffff));
@@ -3335,6 +3321,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 (chain->wl_syncobj_surface)
+ wp_linux_drm_syncobj_surface_v1_destroy(chain->wl_syncobj_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);
@@ -3452,6 +3440,10 @@ wsi_wl_surface_create_swapchain(VkIcdSurfaceBase *icd_surface,
wp_commit_timer_v1_destroy(old_chain->commit_timer);
old_chain->commit_timer = NULL;
}
+ if (old_chain->wl_syncobj_surface) {
+ wp_linux_drm_syncobj_surface_v1_destroy(old_chain->wl_syncobj_surface);
+ old_chain->wl_syncobj_surface = NULL;
+ }
}
/* Take ownership of the wsi_wl_surface */
@@ -3500,6 +3492,17 @@ wsi_wl_surface_create_swapchain(VkIcdSurfaceBase *icd_surface,
WP_TEARING_CONTROL_V1_PRESENTATION_HINT_ASYNC);
}
+ if (wsi_wl_use_explicit_sync(wsi_wl_surface->display, wsi_device)) {
+ chain->wl_syncobj_surface =
+ wp_linux_drm_syncobj_manager_v1_get_surface(wsi_wl_surface->display->wl_syncobj,
+ wsi_wl_surface->wayland_surface.wrapper);
+
+ if (!chain->wl_syncobj_surface) {
+ result = VK_ERROR_OUT_OF_HOST_MEMORY;
+ goto fail;
+ }
+ }
+
chain->color.colorspace = pCreateInfo->imageColorSpace;
enum wsi_wl_buffer_type buffer_type;
--
GitLab
From 9c7b53543b08a43a288d86eae8dc481163f3519f Mon Sep 17 00:00:00 2001
From: Etaash Mathamsetty
<45927311+Etaash-mathamsetty@users.noreply.github.com>
Date: Tue, 27 May 2025 15:01:29 -0400
Subject: [PATCH 2/2] vulkan/wsi/wayland: Move color management surface to
swapchain.
cc: mesa-stable
---
src/vulkan/wsi/wsi_common_wayland.c | 45 +++++++++++++++--------------
1 file changed, 23 insertions(+), 22 deletions(-)
diff --git a/src/vulkan/wsi/wsi_common_wayland.c b/src/vulkan/wsi/wsi_common_wayland.c
index 5feefc89da86e..02d5313188a15 100644
--- a/src/vulkan/wsi/wsi_common_wayland.c
+++ b/src/vulkan/wsi/wsi_common_wayland.c
@@ -187,8 +187,6 @@ struct wsi_wl_surface {
struct vk_instance *instance;
struct {
- struct wp_color_management_surface_v1 *color_surface;
- int color_surface_refcount;
VkColorSpaceKHR colorspace;
VkHdrMetadataEXT hdr_metadata;
bool has_hdr_metadata;
@@ -247,6 +245,8 @@ struct wsi_wl_swapchain {
} present_ids;
struct {
+ struct wp_color_management_surface_v1 *color_surface;
+ int color_surface_refcount;
VkColorSpaceKHR colorspace;
VkHdrMetadataEXT hdr_metadata;
bool has_hdr_metadata;
@@ -1134,23 +1134,24 @@ needs_color_surface(struct wsi_wl_display *display, VkColorSpaceKHR colorspace)
}
static void
-wsi_wl_surface_add_color_refcount(struct wsi_wl_surface *wsi_surface)
+wsi_wl_swapchain_add_color_refcount(struct wsi_wl_swapchain *chain)
{
- wsi_surface->color.color_surface_refcount++;
- if (wsi_surface->color.color_surface_refcount == 1) {
- wsi_surface->color.color_surface =
+ struct wsi_wl_surface *wsi_surface = chain->wsi_wl_surface;
+ chain->color.color_surface_refcount++;
+ if (chain->color.color_surface_refcount == 1) {
+ chain->color.color_surface =
wp_color_manager_v1_get_surface(wsi_surface->display->color_manager,
wsi_surface->wayland_surface.wrapper);
}
}
static void
-wsi_wl_surface_remove_color_refcount(struct wsi_wl_surface *wsi_surface)
+wsi_wl_swapchain_remove_color_refcount(struct wsi_wl_swapchain *chain)
{
- 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;
+ chain->color.color_surface_refcount--;
+ if (chain->color.color_surface_refcount == 0) {
+ wp_color_management_surface_v1_destroy(chain->color.color_surface);
+ chain->color.color_surface = NULL;
}
}
@@ -1218,14 +1219,14 @@ wsi_wl_swapchain_update_colorspace(struct wsi_wl_swapchain *chain)
}
}
- bool new_color_surface = !surface->color.color_surface;
+ bool new_color_surface = !chain->color.color_surface;
bool needs_color_surface_new = needs_color_surface(display, chain->color.colorspace);
- bool needs_color_surface_old = surface->color.color_surface &&
+ bool needs_color_surface_old = chain->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);
+ wsi_wl_swapchain_add_color_refcount(chain);
} else if (needs_color_surface_old && !needs_color_surface_new) {
- wsi_wl_surface_remove_color_refcount(surface);
+ wsi_wl_swapchain_remove_color_refcount(chain);
}
struct wayland_hdr_metadata wayland_hdr_metadata = {
@@ -2050,9 +2051,6 @@ wsi_wl_surface_destroy(VkIcdSurfaceBase *icd_surface, VkInstance _instance,
dmabuf_feedback_fini(&wsi_wl_surface->pending_dmabuf_feedback);
}
- if (wsi_wl_surface->color.color_surface)
- wp_color_management_surface_v1_destroy(wsi_wl_surface->color.color_surface);
-
loader_wayland_surface_destroy(&wsi_wl_surface->wayland_surface);
if (wsi_wl_surface->display)
@@ -3323,10 +3321,8 @@ wsi_wl_swapchain_chain_free(struct wsi_wl_swapchain *chain,
wp_tearing_control_v1_destroy(chain->tearing_control);
if (chain->wl_syncobj_surface)
wp_linux_drm_syncobj_surface_v1_destroy(chain->wl_syncobj_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);
- }
+ if (chain->color.color_surface)
+ wp_color_management_surface_v1_destroy(chain->color.color_surface);
/* Only unregister if we are the non-retired swapchain, or
* we are a retired swapchain and memory allocation failed,
@@ -3444,6 +3440,11 @@ wsi_wl_surface_create_swapchain(VkIcdSurfaceBase *icd_surface,
wp_linux_drm_syncobj_surface_v1_destroy(old_chain->wl_syncobj_surface);
old_chain->wl_syncobj_surface = NULL;
}
+ if (old_chain->color.color_surface) {
+ wp_color_management_surface_v1_destroy(old_chain->color.color_surface);
+ old_chain->color.color_surface_refcount = 0;
+ old_chain->color.color_surface = NULL;
+ }
}
/* Take ownership of the wsi_wl_surface */
--
GitLab
|