From: Daniel Stone <dani...@collabora.com> The only use for this boolean was to decide whether or not it should export a dmabuf FD. Simplify things a bit by giving that directly.
Signed-off-by: Daniel Stone <dani...@collabora.com> --- src/amd/vulkan/radv_wsi.c | 6 ++++-- src/intel/vulkan/anv_wsi.c | 21 +++++++++++++-------- src/vulkan/wsi/wsi_common.h | 2 +- src/vulkan/wsi/wsi_common_wayland.c | 2 +- src/vulkan/wsi/wsi_common_x11.c | 4 ++-- 5 files changed, 21 insertions(+), 14 deletions(-) diff --git a/src/amd/vulkan/radv_wsi.c b/src/amd/vulkan/radv_wsi.c index a790ea979b..9a490e1e76 100644 --- a/src/amd/vulkan/radv_wsi.c +++ b/src/amd/vulkan/radv_wsi.c @@ -142,7 +142,7 @@ static VkResult radv_wsi_image_create(VkDevice device_h, const VkSwapchainCreateInfoKHR *pCreateInfo, const VkAllocationCallbacks* pAllocator, - bool needs_linear_copy, + bool should_export, bool linear, struct wsi_image_base *wsi_image) { @@ -208,11 +208,13 @@ radv_wsi_image_create(VkDevice device_h, * return the fd for the image in the no copy mode, * or the fd for the linear image if a copy is required. */ - if (!needs_linear_copy || (needs_linear_copy && linear)) { + if (should_export) { RADV_FROM_HANDLE(radv_device_memory, memory, memory_h); if (!radv_get_memory_fd(device, memory, &fd)) goto fail_alloc_memory; wsi_image->fd = fd; + } else { + wsi_image->fd = -1; } surface = &image->surface; diff --git a/src/intel/vulkan/anv_wsi.c b/src/intel/vulkan/anv_wsi.c index d9481d1f1c..a1b12e5f72 100644 --- a/src/intel/vulkan/anv_wsi.c +++ b/src/intel/vulkan/anv_wsi.c @@ -172,7 +172,7 @@ static VkResult anv_wsi_image_create(VkDevice device_h, const VkSwapchainCreateInfoKHR *pCreateInfo, const VkAllocationCallbacks* pAllocator, - bool different_gpu, + bool should_export, bool linear, struct wsi_image_base *wsi_image) { @@ -249,13 +249,18 @@ anv_wsi_image_create(VkDevice device_h, goto fail_alloc_memory; } - int fd = anv_gem_handle_to_fd(device, memory->bo->gem_handle); - if (fd == -1) { - /* FINISHME: Choose a better error. */ - result = vk_errorf(device->instance, device, - VK_ERROR_OUT_OF_DEVICE_MEMORY, - "handle_to_fd failed: %m"); - goto fail_alloc_memory; + int fd; + if (should_export) { + fd = anv_gem_handle_to_fd(device, memory->bo->gem_handle); + if (fd == -1) { + /* FINISHME: Choose a better error. */ + result = vk_errorf(device->instance, device, + VK_ERROR_OUT_OF_DEVICE_MEMORY, + "handle_to_fd failed: %m"); + goto fail_alloc_memory; + } + } else { + fd = -1; } wsi_image->image = image_h; diff --git a/src/vulkan/wsi/wsi_common.h b/src/vulkan/wsi/wsi_common.h index 2a9092479d..1103703b0e 100644 --- a/src/vulkan/wsi/wsi_common.h +++ b/src/vulkan/wsi/wsi_common.h @@ -44,7 +44,7 @@ struct wsi_image_fns { VkResult (*create_wsi_image)(VkDevice device_h, const VkSwapchainCreateInfoKHR *pCreateInfo, const VkAllocationCallbacks *pAllocator, - bool needs_linear_copy, + bool should_export, bool linear, struct wsi_image_base *image_p); void (*free_wsi_image)(VkDevice device, diff --git a/src/vulkan/wsi/wsi_common_wayland.c b/src/vulkan/wsi/wsi_common_wayland.c index 3e94034077..8ff57522bb 100644 --- a/src/vulkan/wsi/wsi_common_wayland.c +++ b/src/vulkan/wsi/wsi_common_wayland.c @@ -697,7 +697,7 @@ wsi_wl_image_init(struct wsi_wl_swapchain *chain, result = chain->base.image_fns->create_wsi_image(vk_device, pCreateInfo, pAllocator, - false, + true, false, &image->base); if (result != VK_SUCCESS) diff --git a/src/vulkan/wsi/wsi_common_x11.c b/src/vulkan/wsi/wsi_common_x11.c index 580a200d73..997255913c 100644 --- a/src/vulkan/wsi/wsi_common_x11.c +++ b/src/vulkan/wsi/wsi_common_x11.c @@ -962,7 +962,7 @@ x11_image_init(VkDevice device_h, struct x11_swapchain *chain, result = chain->base.image_fns->create_wsi_image(device_h, pCreateInfo, pAllocator, - chain->base.needs_linear_copy, + !chain->base.needs_linear_copy, false, &image->base); if (result != VK_SUCCESS) @@ -972,7 +972,7 @@ x11_image_init(VkDevice device_h, struct x11_swapchain *chain, result = chain->base.image_fns->create_wsi_image(device_h, pCreateInfo, pAllocator, - chain->base.needs_linear_copy, + true, true, &image->linear_base); -- 2.13.0 _______________________________________________ xorg-devel@lists.x.org: X.Org development Archives: http://lists.x.org/archives/xorg-devel Info: https://lists.x.org/mailman/listinfo/xorg-devel