From 3e4c3b8c8a853b8c551150c6946672f734335307 Mon Sep 17 00:00:00 2001 From: Yiwei Zhang Date: Thu, 15 Apr 2021 22:55:31 +0000 Subject: [PATCH] vkr: use virgl_resource_export_fd to get fd and type The resource can be pipe_resource in our use cases. Signed-off-by: Yiwei Zhang Reviewed-by: Chia-I Wu --- src/vkr_renderer.c | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/src/vkr_renderer.c b/src/vkr_renderer.c index 1797c79..7dee52b 100644 --- a/src/vkr_renderer.c +++ b/src/vkr_renderer.c @@ -3305,8 +3305,11 @@ vkr_dispatch_vkGetMemoryResourcePropertiesMESA(struct vn_dispatch_context *dispa return; } + int fd = -1; + enum virgl_resource_fd_type fd_type = virgl_resource_export_fd(att->resource, &fd); VkExternalMemoryHandleTypeFlagBits handle_type; - if (!vkr_get_fd_handle_type_from_virgl_fd_type(dev->physical_device, att->resource->fd_type, &handle_type)) { + if (!vkr_get_fd_handle_type_from_virgl_fd_type(dev->physical_device, fd_type, &handle_type)) { + close(fd); args->ret = VK_ERROR_INVALID_EXTERNAL_HANDLE; return; } @@ -3317,8 +3320,9 @@ vkr_dispatch_vkGetMemoryResourcePropertiesMESA(struct vn_dispatch_context *dispa .memoryTypeBits = 0, }; vn_replace_vkGetMemoryResourcePropertiesMESA_args_handle(args); - args->ret = dev->get_memory_fd_properties(args->device, handle_type, att->resource->fd, &memory_fd_properties); + args->ret = dev->get_memory_fd_properties(args->device, handle_type, fd, &memory_fd_properties); args->pMemoryResourceProperties->memoryTypeBits = memory_fd_properties.memoryTypeBits; + close(fd); } static void