Mesa (main): radv: Move QueueSignalReleaseImageANDROID to common code

GitLab Mirror gitlab-mirror at kemper.freedesktop.org
Wed Jan 5 17:04:26 UTC 2022


Module: Mesa
Branch: main
Commit: b2073f5e5d689a8458b331b5be9608bf5717cfa4
URL:    http://cgit.freedesktop.org/mesa/mesa/commit/?id=b2073f5e5d689a8458b331b5be9608bf5717cfa4

Author: Jason Ekstrand <jason at jlekstrand.net>
Date:   Sat Jan  1 23:03:36 2022 -0600

radv: Move QueueSignalReleaseImageANDROID to common code

This is mostly a copy+paste job but with a few syntax changes to make it
follow more closely with other common Vulkan code.

Reviewed-by: Eric Engestrom <eric at engestrom.ch>
Reviewed-by: Iago Toral Quiroga <itoral at igalia.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/14372>

---

 src/amd/vulkan/radv_android.c   | 50 ------------------------------------
 src/vulkan/runtime/meson.build  |  1 +
 src/vulkan/runtime/vk_android.c | 56 +++++++++++++++++++++++++++++++++++++++++
 3 files changed, 57 insertions(+), 50 deletions(-)

diff --git a/src/amd/vulkan/radv_android.c b/src/amd/vulkan/radv_android.c
index 4ead3284c03..d0fca992723 100644
--- a/src/amd/vulkan/radv_android.c
+++ b/src/amd/vulkan/radv_android.c
@@ -376,56 +376,6 @@ radv_GetSwapchainGrallocUsage2ANDROID(VkDevice device_h, VkFormat format,
    return VK_ERROR_FORMAT_NOT_SUPPORTED;
 #endif
 }
-
-VkResult
-radv_QueueSignalReleaseImageANDROID(VkQueue _queue, uint32_t waitSemaphoreCount,
-                                    const VkSemaphore *pWaitSemaphores, VkImage image,
-                                    int *pNativeFenceFd)
-{
-   RADV_FROM_HANDLE(radv_queue, queue, _queue);
-   VkResult result = VK_SUCCESS;
-
-   if (waitSemaphoreCount == 0) {
-      if (pNativeFenceFd)
-         *pNativeFenceFd = -1;
-      return VK_SUCCESS;
-   }
-
-   int fd = -1;
-
-   for (uint32_t i = 0; i < waitSemaphoreCount; ++i) {
-      int tmp_fd;
-      result = queue->device->vk.dispatch_table.GetSemaphoreFdKHR(
-         radv_device_to_handle(queue->device),
-         &(VkSemaphoreGetFdInfoKHR){
-            .sType = VK_STRUCTURE_TYPE_SEMAPHORE_GET_FD_INFO_KHR,
-            .handleType = VK_EXTERNAL_SEMAPHORE_HANDLE_TYPE_SYNC_FD_BIT,
-            .semaphore = pWaitSemaphores[i],
-         },
-         &tmp_fd);
-      if (result != VK_SUCCESS) {
-         if (fd >= 0)
-            close(fd);
-         return result;
-      }
-
-      if (fd < 0)
-         fd = tmp_fd;
-      else if (tmp_fd >= 0) {
-         sync_accumulate("radv", &fd, tmp_fd);
-         close(tmp_fd);
-      }
-   }
-
-   if (pNativeFenceFd) {
-      *pNativeFenceFd = fd;
-   } else if (fd >= 0) {
-      close(fd);
-      /* We still need to do the exports, to reset the semaphores, but
-       * otherwise we don't wait on them. */
-   }
-   return VK_SUCCESS;
-}
 #endif
 
 #if RADV_SUPPORT_ANDROID_HARDWARE_BUFFER
diff --git a/src/vulkan/runtime/meson.build b/src/vulkan/runtime/meson.build
index 6026b175c47..2eabf06d0dc 100644
--- a/src/vulkan/runtime/meson.build
+++ b/src/vulkan/runtime/meson.build
@@ -81,6 +81,7 @@ endif
 
 if with_platform_android
   vulkan_runtime_files += files('vk_android.c')
+  vulkan_runtime_deps += dep_android
 endif
 
 vk_common_entrypoints = custom_target(
diff --git a/src/vulkan/runtime/vk_android.c b/src/vulkan/runtime/vk_android.c
index 88790f3381d..0a4a666e803 100644
--- a/src/vulkan/runtime/vk_android.c
+++ b/src/vulkan/runtime/vk_android.c
@@ -24,6 +24,9 @@
 #include "vk_common_entrypoints.h"
 #include "vk_device.h"
 #include "vk_log.h"
+#include "vk_queue.h"
+
+#include "util/libsync.h"
 
 #include <unistd.h>
 
@@ -104,3 +107,56 @@ vk_common_AcquireImageANDROID(VkDevice _device,
 
    return result;
 }
+
+
+VKAPI_ATTR VkResult VKAPI_CALL
+vk_common_QueueSignalReleaseImageANDROID(VkQueue _queue,
+                                         uint32_t waitSemaphoreCount,
+                                         const VkSemaphore *pWaitSemaphores,
+                                         VkImage image,
+                                         int *pNativeFenceFd)
+{
+   VK_FROM_HANDLE(vk_queue, queue, _queue);
+   struct vk_device *device = queue->base.device;
+   VkResult result = VK_SUCCESS;
+
+   if (waitSemaphoreCount == 0) {
+      if (pNativeFenceFd)
+         *pNativeFenceFd = -1;
+      return VK_SUCCESS;
+   }
+
+   int fd = -1;
+
+   for (uint32_t i = 0; i < waitSemaphoreCount; ++i) {
+      const VkSemaphoreGetFdInfoKHR get_fd = {
+         .sType = VK_STRUCTURE_TYPE_SEMAPHORE_GET_FD_INFO_KHR,
+         .handleType = VK_EXTERNAL_SEMAPHORE_HANDLE_TYPE_SYNC_FD_BIT,
+         .semaphore = pWaitSemaphores[i],
+      };
+      int tmp_fd;
+      result = device->dispatch_table.GetSemaphoreFdKHR(vk_device_to_handle(device),
+                                                        &get_fd, &tmp_fd);
+      if (result != VK_SUCCESS) {
+         if (fd >= 0)
+            close(fd);
+         return result;
+      }
+
+      if (fd < 0) {
+         fd = tmp_fd;
+      } else if (tmp_fd >= 0) {
+         sync_accumulate("vulkan", &fd, tmp_fd);
+         close(tmp_fd);
+      }
+   }
+
+   if (pNativeFenceFd) {
+      *pNativeFenceFd = fd;
+   } else if (fd >= 0) {
+      close(fd);
+      /* We still need to do the exports, to reset the semaphores, but
+       * otherwise we don't wait on them. */
+   }
+   return VK_SUCCESS;
+}



More information about the mesa-commit mailing list