mirror of
https://gitlab.freedesktop.org/mesa/mesa.git
synced 2026-05-05 09:38:07 +02:00
vk/wsi: unify dmabuf exporting
Acked-by: Daniel Stone <daniels@collabora.com> Reviewed-by: Joshua Ashton <joshua@froggi.es> Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/23835>
This commit is contained in:
parent
2b885b233f
commit
a69a4f393b
1 changed files with 19 additions and 18 deletions
|
|
@ -450,6 +450,23 @@ fail_oom:
|
|||
return VK_ERROR_OUT_OF_HOST_MEMORY;
|
||||
}
|
||||
|
||||
static VkResult
|
||||
wsi_init_image_dmabuf_fd(const struct wsi_swapchain *chain,
|
||||
struct wsi_image *image,
|
||||
bool linear)
|
||||
{
|
||||
const struct wsi_device *wsi = chain->wsi;
|
||||
const VkMemoryGetFdInfoKHR memory_get_fd_info = {
|
||||
.sType = VK_STRUCTURE_TYPE_MEMORY_GET_FD_INFO_KHR,
|
||||
.pNext = NULL,
|
||||
.memory = linear ? image->blit.memory : image->memory,
|
||||
.handleType = VK_EXTERNAL_MEMORY_HANDLE_TYPE_DMA_BUF_BIT_EXT,
|
||||
};
|
||||
|
||||
return wsi->GetMemoryFdKHR(chain->device, &memory_get_fd_info,
|
||||
&image->dma_buf_fd);
|
||||
}
|
||||
|
||||
static VkResult
|
||||
wsi_create_native_image_mem(const struct wsi_swapchain *chain,
|
||||
const struct wsi_image_info *info,
|
||||
|
|
@ -489,15 +506,7 @@ wsi_create_native_image_mem(const struct wsi_swapchain *chain,
|
|||
if (result != VK_SUCCESS)
|
||||
return result;
|
||||
|
||||
const VkMemoryGetFdInfoKHR memory_get_fd_info = {
|
||||
.sType = VK_STRUCTURE_TYPE_MEMORY_GET_FD_INFO_KHR,
|
||||
.pNext = NULL,
|
||||
.memory = image->memory,
|
||||
.handleType = VK_EXTERNAL_MEMORY_HANDLE_TYPE_DMA_BUF_BIT_EXT,
|
||||
};
|
||||
|
||||
result = wsi->GetMemoryFdKHR(chain->device, &memory_get_fd_info,
|
||||
&image->dma_buf_fd);
|
||||
result = wsi_init_image_dmabuf_fd(chain, image, false);
|
||||
if (result != VK_SUCCESS)
|
||||
return result;
|
||||
|
||||
|
|
@ -558,7 +567,6 @@ wsi_create_prime_image_mem(const struct wsi_swapchain *chain,
|
|||
const struct wsi_image_info *info,
|
||||
struct wsi_image *image)
|
||||
{
|
||||
const struct wsi_device *wsi = chain->wsi;
|
||||
VkResult result =
|
||||
wsi_create_buffer_blit_context(chain, info, image,
|
||||
VK_EXTERNAL_MEMORY_HANDLE_TYPE_DMA_BUF_BIT_EXT,
|
||||
|
|
@ -566,14 +574,7 @@ wsi_create_prime_image_mem(const struct wsi_swapchain *chain,
|
|||
if (result != VK_SUCCESS)
|
||||
return result;
|
||||
|
||||
const VkMemoryGetFdInfoKHR linear_memory_get_fd_info = {
|
||||
.sType = VK_STRUCTURE_TYPE_MEMORY_GET_FD_INFO_KHR,
|
||||
.pNext = NULL,
|
||||
.memory = image->blit.memory,
|
||||
.handleType = VK_EXTERNAL_MEMORY_HANDLE_TYPE_DMA_BUF_BIT_EXT,
|
||||
};
|
||||
result = wsi->GetMemoryFdKHR(chain->device, &linear_memory_get_fd_info,
|
||||
&image->dma_buf_fd);
|
||||
result = wsi_init_image_dmabuf_fd(chain, image, true);
|
||||
if (result != VK_SUCCESS)
|
||||
return result;
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue