From 77fb8fb062457dad73bd763e97bf757b6cd04080 Mon Sep 17 00:00:00 2001 From: Lionel Landwerlin Date: Thu, 16 Oct 2025 10:36:28 +0300 Subject: [PATCH] anv: fix image-to-image copies of TileW images The intermediate buffer between the 2 images is linear, its stride should be a function of the tile's logical width. Normally this should map to the values reported by ISL except for TileW where for some reason it was decided to report 128 for TileW instead of the actual 64 size (see isl_tiling_get_info() ISL_TILING_W case) Signed-off-by: Lionel Landwerlin Cc: mesa-stable Reviewed-by: Alyssa Rosenzweig Part-of: --- src/intel/vulkan/anv_image_host_copy.c | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) diff --git a/src/intel/vulkan/anv_image_host_copy.c b/src/intel/vulkan/anv_image_host_copy.c index 46571bae9ed..d0f6d8e61b1 100644 --- a/src/intel/vulkan/anv_image_host_copy.c +++ b/src/intel/vulkan/anv_image_host_copy.c @@ -480,6 +480,9 @@ anv_CopyImageToMemory( return VK_SUCCESS; } +/* This functions copies from one image to another through an intermediate + * linear buffer. + */ static void copy_image_to_image(struct anv_device *device, struct anv_image *src_image, @@ -505,14 +508,11 @@ copy_image_to_image(struct anv_device *device, isl_surf_get_tile_info(src_surf, &src_tile); isl_surf_get_tile_info(dst_surf, &dst_tile); - uint32_t tile_width_B; uint32_t tile_width_el, tile_height_el; if (src_tile.phys_extent_B.w > dst_tile.phys_extent_B.w) { - tile_width_B = src_tile.phys_extent_B.w; tile_width_el = src_tile.logical_extent_el.w; tile_height_el = src_tile.logical_extent_el.h; } else { - tile_width_B = dst_tile.phys_extent_B.w; tile_width_el = dst_tile.logical_extent_el.w; tile_height_el = dst_tile.logical_extent_el.h; } @@ -527,14 +527,18 @@ copy_image_to_image(struct anv_device *device, VkExtent3D extent_el = vk_extent3d_to_el(src_surf->format, region->extent); + uint32_t linear_stride_B; /* linear-to-linear case */ if (tile_width_el == 1 && tile_height_el == 1) { tile_width_el = MIN2(4096 / (src_tile.format_bpb / 8), extent_el.width); tile_height_el = 4096 / (tile_width_el * (src_tile.format_bpb / 8)); - tile_width_B = tile_width_el * src_tile.format_bpb / 8; + linear_stride_B = tile_width_el * src_tile.format_bpb / 8; + } else { + linear_stride_B = src_tile.logical_extent_el.w * src_tile.format_bpb / 8; } + uint32_t layer_count = vk_image_subresource_layer_count(&src_image->vk, ®ion->srcSubresource); for (uint32_t a = 0; a < layer_count; a++) { @@ -559,7 +563,7 @@ copy_image_to_image(struct anv_device *device, src_binding, src_anv_surf->memory_range.offset, tmp_map, - tile_width_B, + linear_stride_B, &src_offset, &extent, region->srcSubresource.mipLevel, region->srcSubresource.baseArrayLayer, @@ -570,7 +574,7 @@ copy_image_to_image(struct anv_device *device, dst_binding, dst_anv_surf->memory_range.offset, tmp_map, - tile_width_B, + linear_stride_B, &dst_offset, &extent, region->dstSubresource.mipLevel, region->dstSubresource.baseArrayLayer,