From 1e0c3529e7ecd885949a44a44d1083f1560acaca Mon Sep 17 00:00:00 2001 From: Yiwei Zhang Date: Fri, 18 Jul 2025 00:38:27 -0700 Subject: [PATCH] nvk: clean up existing nvk_android frontend 1. No need custom nvk_AcquireImageANDROID to wait for the HWC release fence, since nvk is able to properly import the sync file. 2. Document the nvk_QueueSignalReleaseImageANDROID behavior. 3. Drop redundant header and includes. Part-of: --- src/nouveau/vulkan/nvk_android.c | 45 +++++++------------------------- src/nouveau/vulkan/nvk_android.h | 40 ---------------------------- 2 files changed, 9 insertions(+), 76 deletions(-) delete mode 100644 src/nouveau/vulkan/nvk_android.h diff --git a/src/nouveau/vulkan/nvk_android.c b/src/nouveau/vulkan/nvk_android.c index 7133b50b9ec..671b838b886 100644 --- a/src/nouveau/vulkan/nvk_android.c +++ b/src/nouveau/vulkan/nvk_android.c @@ -8,47 +8,11 @@ #include "nvk_private.h" -#include "nvk_android.h" #include "nvk_entrypoints.h" #include "vk_android.h" -#include "util/libsync.h" -#include "util/os_file.h" #include "vk_device.h" -#include "vk_fence.h" #include "vk_queue.h" -#include "vk_semaphore.h" - -VKAPI_ATTR VkResult VKAPI_CALL -nvk_AcquireImageANDROID(VkDevice _device, - VkImage image, - int nativeFenceFd, - VkSemaphore semaphore, - VkFence fence) -{ - VK_FROM_HANDLE(vk_device, vk_device, _device); - VkResult result = VK_SUCCESS; - - if(nativeFenceFd >= 0) - { - sync_wait(nativeFenceFd, -1); - close(nativeFenceFd); - } - - if(fence != VK_NULL_HANDLE) - { - VK_FROM_HANDLE(vk_fence, vk_fence, fence); - result = vk_sync_signal(vk_device, &vk_fence->permanent, 0); - } - - if(result == VK_SUCCESS && semaphore != VK_NULL_HANDLE) - { - VK_FROM_HANDLE(vk_semaphore, vk_semaphore, semaphore); - result = vk_sync_signal(vk_device, &vk_semaphore->permanent, 0); - } - - return result; -} VKAPI_ATTR VkResult VKAPI_CALL nvk_QueueSignalReleaseImageANDROID(VkQueue _queue, @@ -60,6 +24,15 @@ nvk_QueueSignalReleaseImageANDROID(VkQueue _queue, VK_FROM_HANDLE(vk_queue, queue, _queue); struct vk_device *device = queue->base.device; + /* This is to workaround nouveau not supporting native_fence_fd cap. On + * Android, the platform SurfaceFlinger RenderEngine has required + * EGL_ANDROID_native_fence_sync to import the sync file presented along + * with the wsi image when the sync fd is not -1. + * + * Can drop this if EGL is provided by layering (ANGLE or Zink) on top of + * Vulkan SYNC_FD and AHB support, or SurfaceFlinger RenderEngine backend + * is configured to use skiavk so that NVK is used for client composition. + */ device->dispatch_table.QueueWaitIdle(_queue); *pNativeFenceFd = -1; diff --git a/src/nouveau/vulkan/nvk_android.h b/src/nouveau/vulkan/nvk_android.h deleted file mode 100644 index 15c90e4229c..00000000000 --- a/src/nouveau/vulkan/nvk_android.h +++ /dev/null @@ -1,40 +0,0 @@ -/* - * Copyright © 2024 Mauro Rossi - * - * Permission is hereby granted, free of charge, to any person obtaining a - * copy of this software and associated documentation files (the "Software"), - * to deal in the Software without restriction, including without limitation - * the rights to use, copy, modify, merge, publish, distribute, sublicense, - * and/or sell copies of the Software, and to permit persons to whom the - * Software is furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice (including the next - * paragraph) shall be included in all copies or substantial portions of the - * Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL - * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING - * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS - * IN THE SOFTWARE. - */ - -#ifndef NVK_ANDROID_H -#define NVK_ANDROID_H - -#include "util/detect_os.h" - -#if DETECT_OS_ANDROID -extern VkFormat -vk_format_from_android(unsigned android_format, unsigned android_usage); -#else -static inline VkFormat -vk_format_from_android(unsigned android_format, unsigned android_usage) -{ - return VK_FORMAT_UNDEFINED; -} -#endif - -#endif /* NVK_ANDROID_H */