From d5e2f6631491f5ee6fe13d0d77a95d113056a29e Mon Sep 17 00:00:00 2001 From: Iago Toral Quiroga Date: Fri, 7 Jun 2024 10:08:31 +0200 Subject: [PATCH] v3dv: disable some TLB paths for cases of linear depth/stencil stores MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit In the case of buffer to image stores, we work around the limitation for linear images by loading D/S data into a the color tile buffer using a compatible format, however, this only works for formats with a single aspect, for combined depth/stencil formats, since the copies are specified to only copy a single aspect, we need to be able to preserve the contents of the other aspect in the destination image, and for that we still use the depth/stencil buffer, so we are affected by the restriction. Fixes some VK_KHR_maintenance5 CTS tests that hit this scenario, such as some tests in: dEQP-VK.api.copy_and_blit.core.image_to_image.all_formats.depth_stencil.2d_to_1d.* In the case of image to image copies, we don't have any workarounds for linear depth/stencil so we always want to skip the TLB path. I have not seen any tests hit this scenario. Reviewed-by: Alejandro Piñeiro Part-of: --- src/broadcom/vulkan/v3dv_meta_copy.c | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+) diff --git a/src/broadcom/vulkan/v3dv_meta_copy.c b/src/broadcom/vulkan/v3dv_meta_copy.c index f4b7e5a61e9..3d38b8d65ad 100644 --- a/src/broadcom/vulkan/v3dv_meta_copy.c +++ b/src/broadcom/vulkan/v3dv_meta_copy.c @@ -1314,6 +1314,10 @@ copy_image_tlb(struct v3dv_cmd_buffer *cmd_buffer, return false; } + /* We can't do TLB stores of linear D/S */ + if (!dst->tiled && vk_format_is_depth_or_stencil(fb_format)) + return false; + /* From the Vulkan spec, VkImageCopy valid usage: * * "If neither the calling command’s srcImage nor the calling command’s @@ -1993,6 +1997,28 @@ copy_buffer_to_image_tlb(struct v3dv_cmd_buffer *cmd_buffer, return false; } + /* From the Vulkan spec for VkBufferImageCopy2: + * + * "The aspectMask member of imageSubresource must only have a + * single bit set." + * + * For us this has relevant implications because we can't do TLB stores + * of linear depth/stencil so we work around this by loading D/S data to the + * color tile buffer using a compatible color format (see + * emit_copy_buffer_to_layer_per_tile_list and choose_tlb_format functions), + * however, when we are copying a single aspect to a combined D/S image + * we need to preserve the other aspect, and for that we will still use the + * D/S tile buffer to load and store the aspect of the image we need to + * preserve, so in this case we are still constrained by the hw restriction + * for linear D/S stores. + */ + assert(util_bitcount(region->imageSubresource.aspectMask) == 1); + if (!image->tiled && + vk_format_has_depth(fb_format) && + vk_format_has_stencil(fb_format)) { + return false; + } + uint32_t internal_type, internal_bpp; v3dv_X(cmd_buffer->device, get_internal_type_bpp_for_image_aspects) (fb_format, region->imageSubresource.aspectMask,