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@engestrom.ch> Reviewed-by: Iago Toral Quiroga <itoral@igalia.com> Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/14372>
This commit is contained in:
parent
dfb1e1777c
commit
b2073f5e5d
|
@ -376,56 +376,6 @@ radv_GetSwapchainGrallocUsage2ANDROID(VkDevice device_h, VkFormat format,
|
||||||
return VK_ERROR_FORMAT_NOT_SUPPORTED;
|
return VK_ERROR_FORMAT_NOT_SUPPORTED;
|
||||||
#endif
|
#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
|
#endif
|
||||||
|
|
||||||
#if RADV_SUPPORT_ANDROID_HARDWARE_BUFFER
|
#if RADV_SUPPORT_ANDROID_HARDWARE_BUFFER
|
||||||
|
|
|
@ -81,6 +81,7 @@ endif
|
||||||
|
|
||||||
if with_platform_android
|
if with_platform_android
|
||||||
vulkan_runtime_files += files('vk_android.c')
|
vulkan_runtime_files += files('vk_android.c')
|
||||||
|
vulkan_runtime_deps += dep_android
|
||||||
endif
|
endif
|
||||||
|
|
||||||
vk_common_entrypoints = custom_target(
|
vk_common_entrypoints = custom_target(
|
||||||
|
|
|
@ -24,6 +24,9 @@
|
||||||
#include "vk_common_entrypoints.h"
|
#include "vk_common_entrypoints.h"
|
||||||
#include "vk_device.h"
|
#include "vk_device.h"
|
||||||
#include "vk_log.h"
|
#include "vk_log.h"
|
||||||
|
#include "vk_queue.h"
|
||||||
|
|
||||||
|
#include "util/libsync.h"
|
||||||
|
|
||||||
#include <unistd.h>
|
#include <unistd.h>
|
||||||
|
|
||||||
|
@ -104,3 +107,56 @@ vk_common_AcquireImageANDROID(VkDevice _device,
|
||||||
|
|
||||||
return result;
|
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;
|
||||||
|
}
|
||||||
|
|
Loading…
Reference in New Issue