v3dv: only require 4-byte alignment for linear images
authorIago Toral Quiroga <itoral@igalia.com>
Mon, 11 May 2020 06:05:59 +0000 (08:05 +0200)
committerMarge Bot <eric+marge@anholt.net>
Tue, 13 Oct 2020 21:21:30 +0000 (21:21 +0000)
The page alignment requirement is for UIF images only, and for linear
images it is actually useful to use a 4-byte alignment so we can
use them to write images to linear buffers at arbitrary positions, which
we will need when copying subrects of an image to a buffer.

Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/6766>

src/broadcom/vulkan/v3dv_image.c

index c0fc31f..6830289 100644 (file)
@@ -225,13 +225,13 @@ v3d_setup_slices(struct v3dv_image *image)
     *
     * We additionally align to 4k, which improves UIF XOR performance.
     */
-   image->alignment = 4096;
-   uint32_t page_align_offset =
+   image->alignment = image->tiling == VK_IMAGE_TILING_LINEAR ? 4 : 4096;
+   uint32_t align_offset =
       align(image->slices[0].offset, image->alignment) - image->slices[0].offset;
-   if (page_align_offset) {
-      image->size += page_align_offset;
+   if (align_offset) {
+      image->size += align_offset;
       for (int i = 0; i < image->levels; i++)
-         image->slices[i].offset += page_align_offset;
+         image->slices[i].offset += align_offset;
    }
 
    /* Arrays and cube textures have a stride which is the distance from