From 65e4873d829debd4951a26eb0e190f3b6982ba48 Mon Sep 17 00:00:00 2001 From: Boris Brezillon Date: Wed, 27 Apr 2022 18:19:40 +0200 Subject: [PATCH] vulkan/wsi: Dissociate the blit context and image configuration steps Even if all implementations wsi_configure_buffer_image() will need to configure the image as well, it feels a bit weird to call wsi_configure_image() from there, so let's the wsi_configure_buffer_image() users call wsi_configure_image() too. Reviewed-by: Jesse Natalie Reviewed-by: Daniel Stone Reviewed-by: Jason Ekstrand Part-of: --- src/vulkan/wsi/wsi_common.c | 31 ++++++++++------------------- src/vulkan/wsi/wsi_common_drm.c | 9 +++++---- src/vulkan/wsi/wsi_common_private.h | 2 +- 3 files changed, 17 insertions(+), 25 deletions(-) diff --git a/src/vulkan/wsi/wsi_common.c b/src/vulkan/wsi/wsi_common.c index b0cf99081f1..a6fbc01970d 100644 --- a/src/vulkan/wsi/wsi_common.c +++ b/src/vulkan/wsi/wsi_common.c @@ -1737,7 +1737,7 @@ wsi_finish_create_blit_context(const struct wsi_swapchain *chain, return VK_SUCCESS; } -VkResult +void wsi_configure_buffer_image(UNUSED const struct wsi_swapchain *chain, const VkSwapchainCreateInfoKHR *pCreateInfo, uint32_t stride_align, uint32_t size_align, @@ -1748,11 +1748,6 @@ wsi_configure_buffer_image(UNUSED const struct wsi_swapchain *chain, assert(util_is_power_of_two_nonzero(stride_align)); assert(util_is_power_of_two_nonzero(size_align)); - VkResult result = wsi_configure_image(chain, pCreateInfo, - 0 /* handle_types */, info); - if (result != VK_SUCCESS) - return result; - info->create.usage |= VK_IMAGE_USAGE_TRANSFER_SRC_BIT; info->wsi.blit_src = true; @@ -1771,8 +1766,6 @@ wsi_configure_buffer_image(UNUSED const struct wsi_swapchain *chain, info->linear_size = ALIGN_POT(info->linear_size, size_align); info->finish_create = wsi_finish_create_blit_context; - - return VK_SUCCESS; } static VkResult @@ -1884,26 +1877,24 @@ wsi_configure_cpu_image(const struct wsi_swapchain *chain, chain->blit.type == WSI_SWAPCHAIN_BUFFER_BLIT); VkExternalMemoryHandleTypeFlags handle_types = 0; - if (params->alloc_shm) + if (params->alloc_shm && chain->blit.type != WSI_SWAPCHAIN_NO_BLIT) handle_types = VK_EXTERNAL_MEMORY_HANDLE_TYPE_HOST_ALLOCATION_BIT_EXT; + VkResult result = wsi_configure_image(chain, pCreateInfo, + handle_types, info); + if (result != VK_SUCCESS) + return result; + if (chain->blit.type != WSI_SWAPCHAIN_NO_BLIT) { - VkResult result = wsi_configure_buffer_image(chain, pCreateInfo, - 1 /* stride_align */, - 1 /* size_align */, - info); - if (result != VK_SUCCESS) - return result; + wsi_configure_buffer_image(chain, pCreateInfo, + 1 /* stride_align */, + 1 /* size_align */, + info); info->select_blit_dst_memory_type = wsi_select_host_memory_type; info->select_image_memory_type = wsi_select_device_memory_type; info->create_mem = wsi_create_cpu_buffer_image_mem; } else { - VkResult result = wsi_configure_image(chain, pCreateInfo, - handle_types, info); - if (result != VK_SUCCESS) - return result; - /* Force the image to be linear */ info->create.tiling = VK_IMAGE_TILING_LINEAR; diff --git a/src/vulkan/wsi/wsi_common_drm.c b/src/vulkan/wsi/wsi_common_drm.c index 59319204917..b3269566e04 100644 --- a/src/vulkan/wsi/wsi_common_drm.c +++ b/src/vulkan/wsi/wsi_common_drm.c @@ -604,13 +604,14 @@ wsi_configure_prime_image(UNUSED const struct wsi_swapchain *chain, wsi_memory_type_select_cb select_buffer_memory_type, struct wsi_image_info *info) { - VkResult result = - wsi_configure_buffer_image(chain, pCreateInfo, - WSI_PRIME_LINEAR_STRIDE_ALIGN, 4096, - info); + VkResult result = wsi_configure_image(chain, pCreateInfo, + 0 /* handle_types */, info); if (result != VK_SUCCESS) return result; + wsi_configure_buffer_image(chain, pCreateInfo, + WSI_PRIME_LINEAR_STRIDE_ALIGN, 4096, + info); info->prime_use_linear_modifier = use_modifier; info->create_mem = wsi_create_prime_image_mem; diff --git a/src/vulkan/wsi/wsi_common_private.h b/src/vulkan/wsi/wsi_common_private.h index 4ec4591b964..6cc442176eb 100644 --- a/src/vulkan/wsi/wsi_common_private.h +++ b/src/vulkan/wsi/wsi_common_private.h @@ -239,7 +239,7 @@ wsi_finish_create_blit_context(const struct wsi_swapchain *chain, const struct wsi_image_info *info, struct wsi_image *image); -VkResult +void wsi_configure_buffer_image(UNUSED const struct wsi_swapchain *chain, const VkSwapchainCreateInfoKHR *pCreateInfo, uint32_t stride_align, uint32_t size_align,