anv: Fix stride mismatch in mesa and minigbm
authorSai Teja Pottumuttu <sai.teja.pottumuttu@intel.com>
Tue, 28 Mar 2023 10:13:05 +0000 (10:13 +0000)
committerMarge Bot <emma+marge@anholt.net>
Wed, 29 Mar 2023 07:09:28 +0000 (07:09 +0000)
It is observed that in display resolutions where width is not equal to
stride, vulkan rendering is being distorted. This is happening due to
stride calculation mismatch between minigbm and mesa.

This fix makes sure that the stride calculated in minigbm is passed to
anv and isl.

The issue was found while debugging the following android cts tests and
thus fixes them as well.
android.graphics.cts.VulkanPreTransformTest#testVulkanPreTransformNotSetToMatchCurrentTransform
android.graphics.cts.VulkanPreTransformTest#testVulkanPreTransformSetToMatchCurrentTransform

Signed-off-by: Sai Teja Pottumuttu <sai.teja.pottumuttu@intel.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/22163>

src/intel/vulkan/anv_android.c
src/intel/vulkan/anv_image.c
src/intel/vulkan/anv_private.h

index c241a0e..c344698 100644 (file)
@@ -532,6 +532,8 @@ anv_image_init_from_gralloc(struct anv_device *device,
                                                base_info->tiling);
    assert(format != ISL_FORMAT_UNSUPPORTED);
 
+   anv_info.stride = gralloc_info->stride * (isl_format_get_layout(format)->bpb / 8);
+
    result = anv_image_init(device, image, &anv_info);
    if (result != VK_SUCCESS)
       goto fail_init;
index 6ea5088..1219c83 100644 (file)
@@ -1399,7 +1399,7 @@ anv_image_init(struct anv_device *device, struct anv_image *image,
                                            mod_explicit_info, isl_tiling_flags,
                                            create_info->isl_extra_usage_flags);
    } else {
-      r = add_all_surfaces_implicit_layout(device, image, fmt_list, 0,
+      r = add_all_surfaces_implicit_layout(device, image, fmt_list, create_info->stride,
                                            isl_tiling_flags,
                                            create_info->isl_extra_usage_flags);
    }
index d32c8e6..02b9806 100644 (file)
@@ -3985,6 +3985,9 @@ struct anv_image_create_info {
 
    /** These flags will be added to any derived from VkImageCreateInfo. */
    isl_surf_usage_flags_t isl_extra_usage_flags;
+
+   /** An opt-in stride, should be 0 for implicit layouts */
+   uint32_t stride;
 };
 
 VkResult anv_image_init(struct anv_device *device, struct anv_image *image,