From: Chia-I Wu Date: Tue, 12 Feb 2019 01:04:54 +0000 (-0800) Subject: vulkan/wsi: move modifier array into wsi_wl_swapchain X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=ab74937b2c8880d3c084f792f37c6b8d953f9e4b;p=mesa.git vulkan/wsi: move modifier array into wsi_wl_swapchain This avoids repeated checks for each wsi_wl_image. Signed-off-by: Chia-I Wu Reviewed-by: Daniel Stone --- diff --git a/src/vulkan/wsi/wsi_common_wayland.c b/src/vulkan/wsi/wsi_common_wayland.c index a312a99d412..16eaadffb23 100644 --- a/src/vulkan/wsi/wsi_common_wayland.c +++ b/src/vulkan/wsi/wsi_common_wayland.c @@ -684,6 +684,9 @@ struct wsi_wl_swapchain { VkFormat vk_format; uint32_t drm_format; + uint32_t num_drm_modifiers; + const uint64_t * drm_modifiers; + VkPresentModeKHR present_mode; bool fifo_ready; @@ -816,29 +819,12 @@ wsi_wl_image_init(struct wsi_wl_swapchain *chain, const VkAllocationCallbacks* pAllocator) { struct wsi_wl_display *display = chain->display; - const uint64_t *modifiers = NULL; - uint32_t num_modifiers = 0; VkResult result; - if (display->dmabuf && chain->base.wsi->supports_modifiers) { - switch (chain->drm_format) { - case WL_DRM_FORMAT_ARGB8888: - modifiers = u_vector_tail(&display->modifiers.argb8888); - num_modifiers = u_vector_length(&display->modifiers.argb8888); - break; - case WL_DRM_FORMAT_XRGB8888: - modifiers = u_vector_tail(&display->modifiers.xrgb8888); - num_modifiers = u_vector_length(&display->modifiers.xrgb8888); - break; - default: - break; - } - } - result = wsi_create_native_image(&chain->base, pCreateInfo, - num_modifiers > 0 ? 1 : 0, - &num_modifiers, &modifiers, - &image->base); + chain->num_drm_modifiers > 0 ? 1 : 0, + &chain->num_drm_modifiers, + &chain->drm_modifiers, &image->base); if (result != VK_SUCCESS) return result; @@ -1003,6 +989,32 @@ wsi_wl_surface_create_swapchain(VkIcdSurfaceBase *icd_surface, chain->display->queue); chain->surface_version = wl_proxy_get_version((void *)surface->surface); + chain->num_drm_modifiers = 0; + chain->drm_modifiers = 0; + + /* Use explicit DRM format modifiers when both the server and the driver + * support them. + */ + if (chain->display->dmabuf && chain->base.wsi->supports_modifiers) { + struct u_vector *modifiers; + switch (chain->drm_format) { + case WL_DRM_FORMAT_ARGB8888: + modifiers = &chain->display->modifiers.argb8888; + break; + case WL_DRM_FORMAT_XRGB8888: + modifiers = &chain->display->modifiers.xrgb8888; + break; + default: + modifiers = NULL; + break; + } + + if (modifiers) { + chain->drm_modifiers = u_vector_tail(modifiers); + chain->num_drm_modifiers = u_vector_length(modifiers); + } + } + chain->drm_wrapper = wl_proxy_create_wrapper(chain->display->drm); if (!chain->drm_wrapper) { result = VK_ERROR_OUT_OF_HOST_MEMORY;