v3dv: return early on image to buffer blit copies if image is linear
authorIago Toral Quiroga <itoral@igalia.com>
Tue, 15 Mar 2022 09:56:31 +0000 (10:56 +0100)
committerMarge Bot <emma+marge@anholt.net>
Fri, 18 Mar 2022 13:17:58 +0000 (13:17 +0000)
This path uses a shader blit to implement the copy which is only
supported for tiled images (except 1D). While blit_shader() already
checks for this, this path does a lot of heavy lifting to prepare for
the blit_shader call so we rather avoid that if possible when we know
blit_shader won't be able to implement the blit.

Reviewed-by: Alejandro PiƱeiro <apinheiro@igalia.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/15342>

src/broadcom/vulkan/v3dv_meta_copy.c

index 937d152..c474b50 100644 (file)
@@ -447,6 +447,15 @@ copy_image_to_buffer_blit(struct v3dv_cmd_buffer *cmd_buffer,
 {
    bool handled = false;
 
+   /* This path uses a shader blit which doesn't support linear images. Return
+    * early to avoid all te heavy lifting in preparation for the blit_shader()
+    * call that is bound to fail in that scenario.
+    */
+   if (image->vk.tiling == VK_IMAGE_TILING_LINEAR &&
+       image->vk.image_type != VK_IMAGE_TYPE_1D) {
+      return handled;
+   }
+
    /* Generally, the bpp of the data in the buffer matches that of the
     * source image. The exception is the case where we are copying
     * stencil (8bpp) to a combined d24s8 image (32bpp).
@@ -3817,8 +3826,10 @@ blit_shader(struct v3dv_cmd_buffer *cmd_buffer,
           !vk_format_is_depth_or_stencil(dst_format));
 
    /* Can't sample from linear images */
-   if (src->vk.tiling == VK_IMAGE_TILING_LINEAR && src->vk.image_type != VK_IMAGE_TYPE_1D)
+   if (src->vk.tiling == VK_IMAGE_TILING_LINEAR &&
+       src->vk.image_type != VK_IMAGE_TYPE_1D) {
       return false;
+   }
 
    VkImageBlit2KHR region = *_region;
    /* Rewrite combined D/S blits to compatible color blits */