v3dv: fix align() computation for pixel formats with non-POT block sizes
authorEric Engestrom <eric@igalia.com>
Wed, 24 May 2023 19:39:16 +0000 (20:39 +0100)
committerMarge Bot <emma+marge@anholt.net>
Thu, 25 May 2023 20:25:04 +0000 (20:25 +0000)
Fixes hundreds of dEQP-VK.api.copy_and_blit.* tests when including the
assert that the alignment in align() is valid, as added in !20153.

Fixes: 3ba839bf734f37f50dfc ("v3dv: align compressed image regions to block size")
Signed-off-by: Eric Engestrom <eric@igalia.com>
Reviewed-by: Iago Toral Quiroga <itoral@igalia.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/23224>

src/broadcom/vulkan/v3dv_meta_copy.c

index 34310b7..dd02e16 100644 (file)
@@ -1207,14 +1207,21 @@ copy_image_blit(struct v3dv_cmd_buffer *cmd_buffer,
     * (since the region dimensions are already specified in terms of the source
     * image).
     */
+   uint32_t region_width = region->extent.width * src_scale_w;
+   uint32_t region_height = region->extent.height * src_scale_h;
+   if (src_block_w > 1)
+      region_width = util_next_power_of_two(region_width);
+   if (src_block_h > 1)
+      region_height = util_next_power_of_two(region_height);
+
    const VkOffset3D src_start = {
       region->srcOffset.x * src_scale_w,
       region->srcOffset.y * src_scale_h,
       region->srcOffset.z,
    };
    const VkOffset3D src_end = {
-      src_start.x + align(region->extent.width, src_block_w) * src_scale_w,
-      src_start.y + align(region->extent.height, src_block_h) * src_scale_h,
+      src_start.x + region_width,
+      src_start.y + region_height,
       src_start.z + region->extent.depth,
    };
 
@@ -1224,8 +1231,8 @@ copy_image_blit(struct v3dv_cmd_buffer *cmd_buffer,
       region->dstOffset.z,
    };
    const VkOffset3D dst_end = {
-      dst_start.x + align(region->extent.width, src_block_w) * src_scale_w,
-      dst_start.y + align(region->extent.height, src_block_h) * src_scale_h,
+      dst_start.x + region_width,
+      dst_start.y + region_height,
       dst_start.z + region->extent.depth,
    };