aboutsummaryrefslogtreecommitdiff
path: root/graphics/mesa-devel/files/patch-revert
blob: 355b0a4af7fa15b03ac51206af466178aeb7481f (plain) (blame)
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
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
Revert https://gitlab.freedesktop.org/mesa/mesa/-/commit/30b57f10b36d
due to https://gitlab.freedesktop.org/mesa/mesa/-/issues/6653

--- src/vulkan/wsi/wsi_common.c.orig	2022-06-10 22:14:14 UTC
+++ src/vulkan/wsi/wsi_common.c
@@ -64,7 +64,6 @@ wsi_device_init(struct wsi_device *wsi,
    wsi->sw = sw_device;
 #define WSI_GET_CB(func) \
    PFN_vk##func func = (PFN_vk##func)proc_addr(pdevice, "vk" #func)
-   WSI_GET_CB(GetPhysicalDeviceExternalSemaphoreProperties);
    WSI_GET_CB(GetPhysicalDeviceProperties2);
    WSI_GET_CB(GetPhysicalDeviceMemoryProperties);
    WSI_GET_CB(GetPhysicalDeviceQueueFamilyProperties);
@@ -84,23 +83,6 @@ wsi_device_init(struct wsi_device *wsi,
    GetPhysicalDeviceMemoryProperties(pdevice, &wsi->memory_props);
    GetPhysicalDeviceQueueFamilyProperties(pdevice, &wsi->queue_family_count, NULL);
 
-   for (VkExternalSemaphoreHandleTypeFlags handle_type = 1;
-        handle_type <= VK_EXTERNAL_SEMAPHORE_HANDLE_TYPE_SYNC_FD_BIT;
-        handle_type <<= 1) {
-      const VkPhysicalDeviceExternalSemaphoreInfo esi = {
-         .sType = VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_EXTERNAL_SEMAPHORE_INFO,
-         .handleType = handle_type,
-      };
-      VkExternalSemaphoreProperties esp = {
-         .sType = VK_STRUCTURE_TYPE_EXTERNAL_SEMAPHORE_PROPERTIES,
-      };
-      GetPhysicalDeviceExternalSemaphoreProperties(pdevice, &esi, &esp);
-
-      if (esp.externalSemaphoreFeatures &
-          VK_EXTERNAL_SEMAPHORE_FEATURE_EXPORTABLE_BIT)
-         wsi->semaphore_export_handle_types |= handle_type;
-   }
-
    list_inithead(&wsi->hotplug_fences);
 
 #define WSI_GET_CB(func) \
@@ -134,7 +116,6 @@ wsi_device_init(struct wsi_device *wsi,
    WSI_GET_CB(GetPhysicalDeviceFormatProperties);
    WSI_GET_CB(GetPhysicalDeviceFormatProperties2KHR);
    WSI_GET_CB(GetPhysicalDeviceImageFormatProperties2);
-   WSI_GET_CB(GetSemaphoreFdKHR);
    WSI_GET_CB(ResetFences);
    WSI_GET_CB(QueueSubmit);
    WSI_GET_CB(WaitForFences);
@@ -368,8 +349,6 @@ wsi_swapchain_finish(struct wsi_swapchain *chain)
 
       vk_free(&chain->alloc, chain->buffer_blit_semaphores);
    }
-   chain->wsi->DestroySemaphore(chain->device, chain->dma_buf_semaphore,
-                                &chain->alloc);
 
    int cmd_pools_count = chain->buffer_blit_queue != VK_NULL_HANDLE ?
       1 : chain->wsi->queue_family_count;
@@ -864,14 +843,6 @@ wsi_signal_semaphore_for_image(struct vk_device *devic
 
    vk_semaphore_reset_temporary(device, semaphore);
 
-#ifndef _WIN32
-   VkResult result = wsi_create_sync_for_dma_buf_wait(chain, image,
-                                                      VK_SYNC_FEATURE_GPU_WAIT,
-                                                      &semaphore->temporary);
-   if (result != VK_ERROR_FEATURE_NOT_PRESENT)
-      return result;
-#endif
-
    if (chain->wsi->signal_semaphore_with_memory) {
       return device->create_sync_for_memory(device, image->memory,
                                             false /* signal_memory */,
@@ -896,14 +867,6 @@ wsi_signal_fence_for_image(struct vk_device *device,
 
    vk_fence_reset_temporary(device, fence);
 
-#ifndef _WIN32
-   VkResult result = wsi_create_sync_for_dma_buf_wait(chain, image,
-                                                      VK_SYNC_FEATURE_CPU_WAIT,
-                                                      &fence->temporary);
-   if (result != VK_ERROR_FEATURE_NOT_PRESENT)
-      return result;
-#endif
-
    if (chain->wsi->signal_fence_with_memory) {
       return device->create_sync_for_memory(device, image->memory,
                                             false /* signal_memory */,
@@ -1073,49 +1036,15 @@ wsi_common_queue_present(const struct wsi_device *wsi,
 
       VkFence fence = swapchain->fences[image_index];
 
-      bool has_signal_dma_buf = false;
-#ifndef _WIN32
-      result = wsi_prepare_signal_dma_buf_from_semaphore(swapchain, image);
-      if (result == VK_SUCCESS) {
-         assert(submit_info.signalSemaphoreCount == 0);
-         submit_info.signalSemaphoreCount = 1;
-         submit_info.pSignalSemaphores = &swapchain->dma_buf_semaphore;
-         has_signal_dma_buf = true;
-      } else if (result == VK_ERROR_FEATURE_NOT_PRESENT) {
-         result = VK_SUCCESS;
-         has_signal_dma_buf = false;
-      } else {
-         goto fail_present;
-      }
-#endif
+      struct wsi_memory_signal_submit_info mem_signal = {
+         .sType = VK_STRUCTURE_TYPE_WSI_MEMORY_SIGNAL_SUBMIT_INFO_MESA,
+         .memory = image->memory,
+      };
+      __vk_append_struct(&submit_info, &mem_signal);
 
-      struct wsi_memory_signal_submit_info mem_signal;
-      if (!has_signal_dma_buf) {
-         /* If we don't have dma-buf signaling, signal the memory object by
-          * chaining wsi_memory_signal_submit_info into VkSubmitInfo.
-          */
-         result = VK_SUCCESS;
-         has_signal_dma_buf = false;
-         mem_signal = (struct wsi_memory_signal_submit_info) {
-            .sType = VK_STRUCTURE_TYPE_WSI_MEMORY_SIGNAL_SUBMIT_INFO_MESA,
-            .memory = image->memory,
-         };
-         __vk_append_struct(&submit_info, &mem_signal);
-      }
-
       result = wsi->QueueSubmit(submit_queue, 1, &submit_info, fence);
       if (result != VK_SUCCESS)
          goto fail_present;
-
-#ifndef _WIN32
-      if (has_signal_dma_buf) {
-         result = wsi_signal_dma_buf_from_semaphore(swapchain, image);
-         if (result != VK_SUCCESS)
-            goto fail_present;
-      }
-#else
-      assert(!has_signal_dma_buf);
-#endif
 
       if (wsi->sw)
 	      wsi->WaitForFences(device, 1, &swapchain->fences[image_index],
--- src/vulkan/wsi/wsi_common.h.orig	2022-06-10 22:14:14 UTC
+++ src/vulkan/wsi/wsi_common.h
@@ -102,8 +102,6 @@ struct wsi_device {
 
    VkPhysicalDevicePCIBusInfoPropertiesEXT pci_bus_info;
 
-   VkExternalSemaphoreHandleTypeFlags semaphore_export_handle_types;
-
    bool supports_modifiers;
    uint32_t maxImageDimension2D;
    VkPresentModeKHR override_present_mode;
@@ -211,7 +209,6 @@ struct wsi_device {
    WSI_CB(GetPhysicalDeviceFormatProperties);
    WSI_CB(GetPhysicalDeviceFormatProperties2KHR);
    WSI_CB(GetPhysicalDeviceImageFormatProperties2);
-   WSI_CB(GetSemaphoreFdKHR);
    WSI_CB(ResetFences);
    WSI_CB(QueueSubmit);
    WSI_CB(WaitForFences);
--- src/vulkan/wsi/wsi_common_drm.c.orig	2022-06-10 22:14:14 UTC
+++ src/vulkan/wsi/wsi_common_drm.c
@@ -26,220 +26,15 @@
 #include "util/macros.h"
 #include "util/os_file.h"
 #include "util/xmlconfig.h"
-#include "vk_device.h"
 #include "vk_format.h"
-#include "vk_physical_device.h"
 #include "vk_util.h"
 #include "drm-uapi/drm_fourcc.h"
 
-#include <errno.h>
-#include <linux/dma-buf.h>
-#include <linux/sync_file.h>
 #include <time.h>
 #include <unistd.h>
 #include <stdlib.h>
 #include <stdio.h>
 #include <xf86drm.h>
-
-struct dma_buf_export_sync_file_wsi {
-   __u32 flags;
-   __s32 fd;
-};
-
-struct dma_buf_import_sync_file_wsi {
-   __u32 flags;
-   __s32 fd;
-};
-
-#define DMA_BUF_IOCTL_EXPORT_SYNC_FILE_WSI   _IOWR(DMA_BUF_BASE, 2, struct dma_buf_export_sync_file_wsi)
-#define DMA_BUF_IOCTL_IMPORT_SYNC_FILE_WSI   _IOW(DMA_BUF_BASE, 3, struct dma_buf_import_sync_file_wsi)
-
-static VkResult
-wsi_dma_buf_export_sync_file(int dma_buf_fd, int *sync_file_fd)
-{
-   /* Don't keep trying an IOCTL that doesn't exist. */
-   static bool no_dma_buf_sync_file = false;
-   if (no_dma_buf_sync_file)
-      return VK_ERROR_FEATURE_NOT_PRESENT;
-
-   struct dma_buf_export_sync_file_wsi export = {
-      .flags = DMA_BUF_SYNC_RW,
-      .fd = -1,
-   };
-   int ret = drmIoctl(dma_buf_fd, DMA_BUF_IOCTL_EXPORT_SYNC_FILE_WSI, &export);
-   if (ret) {
-      if (errno == ENOTTY) {
-         no_dma_buf_sync_file = true;
-         return VK_ERROR_FEATURE_NOT_PRESENT;
-      } else {
-         return VK_ERROR_OUT_OF_HOST_MEMORY;
-      }
-   }
-
-   *sync_file_fd = export.fd;
-
-   return VK_SUCCESS;
-}
-
-static VkResult
-wsi_dma_buf_import_sync_file(int dma_buf_fd, int sync_file_fd)
-{
-   /* Don't keep trying an IOCTL that doesn't exist. */
-   static bool no_dma_buf_sync_file = false;
-   if (no_dma_buf_sync_file)
-      return VK_ERROR_FEATURE_NOT_PRESENT;
-
-   struct dma_buf_import_sync_file_wsi import = {
-      .flags = DMA_BUF_SYNC_RW,
-      .fd = sync_file_fd,
-   };
-   int ret = drmIoctl(dma_buf_fd, DMA_BUF_IOCTL_IMPORT_SYNC_FILE_WSI, &import);
-   if (ret) {
-      if (errno == ENOTTY) {
-         no_dma_buf_sync_file = true;
-         return VK_ERROR_FEATURE_NOT_PRESENT;
-      } else {
-         return VK_ERROR_OUT_OF_HOST_MEMORY;
-      }
-   }
-
-   return VK_SUCCESS;
-}
-
-static VkResult
-prepare_signal_dma_buf_from_semaphore(struct wsi_swapchain *chain,
-                                      const struct wsi_image *image)
-{
-   VkResult result;
-
-   if (!(chain->wsi->semaphore_export_handle_types &
-         VK_EXTERNAL_SEMAPHORE_HANDLE_TYPE_SYNC_FD_BIT))
-      return VK_ERROR_FEATURE_NOT_PRESENT;
-
-   int sync_file_fd = -1;
-   result = wsi_dma_buf_export_sync_file(image->dma_buf_fd, &sync_file_fd);
-   if (result != VK_SUCCESS)
-      return result;
-
-   result = wsi_dma_buf_import_sync_file(image->dma_buf_fd, sync_file_fd);
-   close(sync_file_fd);
-   if (result != VK_SUCCESS)
-      return result;
-
-   /* If we got here, all our checks pass.  Create the actual semaphore */
-   const VkExportSemaphoreCreateInfo export_info = {
-      .sType = VK_STRUCTURE_TYPE_EXPORT_SEMAPHORE_CREATE_INFO,
-      .handleTypes = VK_EXTERNAL_SEMAPHORE_HANDLE_TYPE_SYNC_FD_BIT,
-   };
-   const VkSemaphoreCreateInfo semaphore_info = {
-      .sType = VK_STRUCTURE_TYPE_SEMAPHORE_CREATE_INFO,
-      .pNext = &export_info,
-   };
-   result = chain->wsi->CreateSemaphore(chain->device, &semaphore_info,
-                                        &chain->alloc,
-                                        &chain->dma_buf_semaphore);
-   if (result != VK_SUCCESS)
-      return result;
-
-   return VK_SUCCESS;
-}
-
-VkResult
-wsi_prepare_signal_dma_buf_from_semaphore(struct wsi_swapchain *chain,
-                                          const struct wsi_image *image)
-{
-   VkResult result;
-
-   /* We cache result - 1 in the swapchain */
-   if (unlikely(chain->signal_dma_buf_from_semaphore == 0)) {
-      result = prepare_signal_dma_buf_from_semaphore(chain, image);
-      assert(result <= 0);
-      chain->signal_dma_buf_from_semaphore = (int)result - 1;
-   } else {
-      result = (VkResult)(chain->signal_dma_buf_from_semaphore + 1);
-   }
-
-   return result;
-}
-
-VkResult
-wsi_signal_dma_buf_from_semaphore(const struct wsi_swapchain *chain,
-                                  const struct wsi_image *image)
-{
-   VkResult result;
-
-   const VkSemaphoreGetFdInfoKHR get_fd_info = {
-      .sType = VK_STRUCTURE_TYPE_SEMAPHORE_GET_FD_INFO_KHR,
-      .semaphore = chain->dma_buf_semaphore,
-      .handleType = VK_EXTERNAL_SEMAPHORE_HANDLE_TYPE_SYNC_FD_BIT,
-   };
-   int sync_file_fd = -1;
-   result = chain->wsi->GetSemaphoreFdKHR(chain->device, &get_fd_info,
-                                          &sync_file_fd);
-   if (result != VK_SUCCESS)
-      return result;
-
-   result = wsi_dma_buf_import_sync_file(image->dma_buf_fd, sync_file_fd);
-   close(sync_file_fd);
-   return result;
-}
-
-static const struct vk_sync_type *
-get_sync_file_sync_type(struct vk_device *device,
-                        enum vk_sync_features req_features)
-{
-   for (const struct vk_sync_type *const *t =
-        device->physical->supported_sync_types; *t; t++) {
-      if (req_features & ~(*t)->features)
-         continue;
-
-      if ((*t)->import_sync_file != NULL)
-         return *t;
-   }
-
-   return NULL;
-}
-
-VkResult
-wsi_create_sync_for_dma_buf_wait(const struct wsi_swapchain *chain,
-                                 const struct wsi_image *image,
-                                 enum vk_sync_features req_features,
-                                 struct vk_sync **sync_out)
-{
-   VK_FROM_HANDLE(vk_device, device, chain->device);
-   VkResult result;
-
-   const struct vk_sync_type *sync_type =
-      get_sync_file_sync_type(device, req_features);
-   if (sync_type == NULL)
-      return VK_ERROR_FEATURE_NOT_PRESENT;
-
-   int sync_file_fd = -1;
-   result = wsi_dma_buf_export_sync_file(image->dma_buf_fd, &sync_file_fd);
-   if (result != VK_SUCCESS)
-      return result;
-
-   struct vk_sync *sync = NULL;
-   result = vk_sync_create(device, sync_type, VK_SYNC_IS_SHAREABLE, 0, &sync);
-   if (result != VK_SUCCESS)
-      goto fail_close_sync_file;
-
-   result = vk_sync_import_sync_file(device, sync, sync_file_fd);
-   if (result != VK_SUCCESS)
-      goto fail_destroy_sync;
-
-   close(sync_file_fd);
-   *sync_out = sync;
-
-   return VK_SUCCESS;
-
-fail_destroy_sync:
-   vk_sync_destroy(device, sync);
-fail_close_sync_file:
-   close(sync_file_fd);
-
-   return result;
-}
 
 bool
 wsi_common_drm_devices_equal(int fd_a, int fd_b)
--- src/vulkan/wsi/wsi_common_private.h.orig	2022-06-10 22:14:14 UTC
+++ src/vulkan/wsi/wsi_common_private.h
@@ -25,7 +25,6 @@
 
 #include "wsi_common.h"
 #include "vulkan/runtime/vk_object.h"
-#include "vulkan/runtime/vk_sync.h"
 
 struct wsi_image;
 struct wsi_swapchain;
@@ -98,9 +97,6 @@ struct wsi_swapchain {
    VkSemaphore* buffer_blit_semaphores;
    VkPresentModeKHR present_mode;
 
-   int signal_dma_buf_from_semaphore;
-   VkSemaphore dma_buf_semaphore;
-
    struct wsi_image_info image_info;
    uint32_t image_count;
 
@@ -197,17 +193,6 @@ wsi_destroy_image(const struct wsi_swapchain *chain,
 wsi_destroy_image(const struct wsi_swapchain *chain,
                   struct wsi_image *image);
 
-VkResult
-wsi_prepare_signal_dma_buf_from_semaphore(struct wsi_swapchain *chain,
-                                          const struct wsi_image *image);
-VkResult
-wsi_signal_dma_buf_from_semaphore(const struct wsi_swapchain *chain,
-                                  const struct wsi_image *image);
-VkResult
-wsi_create_sync_for_dma_buf_wait(const struct wsi_swapchain *chain,
-                                 const struct wsi_image *image,
-                                 enum vk_sync_features sync_features,
-                                 struct vk_sync **sync_out);
 
 struct wsi_interface {
    VkResult (*get_support)(VkIcdSurfaceBase *surface,