diff --git a/src/amd/vulkan/radv_meta_blit.c b/src/amd/vulkan/radv_meta_blit.c index 2c1a13228d..f0c6d8591e 100644 --- a/src/amd/vulkan/radv_meta_blit.c +++ b/src/amd/vulkan/radv_meta_blit.c @@ -517,22 +517,6 @@ void radv_CmdBlitImage( for (unsigned r = 0; r < regionCount; r++) { const VkImageSubresourceLayers *src_res = &pRegions[r].srcSubresource; const VkImageSubresourceLayers *dst_res = &pRegions[r].dstSubresource; - struct radv_image_view src_iview; - radv_image_view_init(&src_iview, cmd_buffer->device, - &(VkImageViewCreateInfo) { - .sType = VK_STRUCTURE_TYPE_IMAGE_VIEW_CREATE_INFO, - .image = srcImage, - .viewType = radv_meta_get_view_type(src_image), - .format = src_image->vk_format, - .subresourceRange = { - .aspectMask = src_res->aspectMask, - .baseMipLevel = src_res->mipLevel, - .levelCount = 1, - .baseArrayLayer = src_res->baseArrayLayer, - .layerCount = 1 - }, - }); - unsigned dst_start, dst_end; if (dest_image->type == VK_IMAGE_TYPE_3D) { assert(dst_res->baseArrayLayer == 0); @@ -557,6 +541,12 @@ void radv_CmdBlitImage( float src_z_step = (float)(src_end + 1 - src_start) / (float)(dst_end + 1 - dst_start); + int dest_z_step = dest_image->type == VK_IMAGE_TYPE_3D ? 1 : 0; + + if (dest_image->type != VK_IMAGE_TYPE_3D) { + src_z_step = 0.0f; + } + if (flip_z) { src_start = src_end; src_z_step *= -1; @@ -584,12 +574,12 @@ void radv_CmdBlitImage( const VkOffset3D dest_offset_0 = { .x = dst_x0, .y = dst_y0, - .z = dst_start + i , + .z = dst_start + i * dest_z_step, }; const VkOffset3D dest_offset_1 = { .x = dst_x1, .y = dst_y1, - .z = dst_start + i , + .z = dst_start + i * dest_z_step, }; VkOffset3D src_offset_0 = { .x = src_x0, @@ -605,6 +595,22 @@ void radv_CmdBlitImage( radv_meta_get_iview_layer(dest_image, dst_res, &dest_offset_0); + struct radv_image_view src_iview; + radv_image_view_init(&src_iview, cmd_buffer->device, + &(VkImageViewCreateInfo) { + .sType = VK_STRUCTURE_TYPE_IMAGE_VIEW_CREATE_INFO, + .image = srcImage, + .viewType = radv_meta_get_view_type(src_image), + .format = src_image->vk_format, + .subresourceRange = { + .aspectMask = src_res->aspectMask, + .baseMipLevel = src_res->mipLevel, + .levelCount = 1, + .baseArrayLayer = src_res->baseArrayLayer + i, + .layerCount = 1 + }, + }); + radv_image_view_init(&dest_iview, cmd_buffer->device, &(VkImageViewCreateInfo) { .sType = VK_STRUCTURE_TYPE_IMAGE_VIEW_CREATE_INFO, @@ -615,7 +621,7 @@ void radv_CmdBlitImage( .aspectMask = dst_res->aspectMask, .baseMipLevel = dst_res->mipLevel, .levelCount = 1, - .baseArrayLayer = dest_array_slice, + .baseArrayLayer = dest_array_slice + i, .layerCount = 1 }, });