[Mesa-dev] [PATCH] miptree: Skip attempts to make unsupported images

Anuj Phogat anuj.phogat at gmail.com
Mon Jun 27 21:49:41 UTC 2016


On Mon, Jun 27, 2016 at 11:30 AM, Nanley Chery <nanleychery at gmail.com> wrote:
> This causes tests that attempt to create linear depth buffers on
> Gen7+ (unsupported), to be skipped.
>
> Signed-off-by: Nanley Chery <nanley.g.chery at intel.com>
> ---
>  src/tests/func/miptree/miptree.c | 39 ++++++++++++++++++++++++++++++++++-----
>  1 file changed, 34 insertions(+), 5 deletions(-)
>
> diff --git a/src/tests/func/miptree/miptree.c b/src/tests/func/miptree/miptree.c
> index 0ced389..37002cb 100644
> --- a/src/tests/func/miptree/miptree.c
> +++ b/src/tests/func/miptree/miptree.c
> @@ -410,6 +410,19 @@ miptree_destroy(miptree_t *mt)
>      free(mt);
>  }
>
> +static void
> +can_create_image(VkImageType type, VkImageTiling tiling,
> +                 uint32_t usage, VkFormat format)
> +{
> +    VkImageFormatProperties fmt_properties;
> +    VkResult result =
> +              vkGetPhysicalDeviceImageFormatProperties(t_physical_dev, format,
> +                                                       type, tiling, usage,
> +                                                       0, &fmt_properties);
> +    if (result == VK_ERROR_FORMAT_NOT_SUPPORTED)
> +       t_end(TEST_RESULT_SKIP);
> +}
> +
>  static const miptree_t *
>  miptree_create(void)
>  {
> @@ -424,10 +437,19 @@ miptree_create(void)
>      const uint32_t depth = params->depth;
>      const uint32_t array_length = params->array_length;
>      const size_t buffer_size = miptree_calc_buffer_size();
> +    const uint32_t usage_bits = VK_IMAGE_USAGE_TRANSFER_SRC_BIT |
> +                                VK_IMAGE_USAGE_TRANSFER_DST_BIT |
> +                                VK_IMAGE_USAGE_COLOR_ATTACHMENT_BIT |
> +                                VK_IMAGE_USAGE_SAMPLED_BIT;
> +    VkImageType image_type = image_type_from_image_view_type(params->view_type);
> +
> +    // Determine if an image can be created with this combination
> +    can_create_image(image_type, VK_IMAGE_TILING_OPTIMAL,
> +                     usage_bits, format);
>
>      // Create the image that will contain the real miptree.
>      VkImage image = qoCreateImage(t_device,
> -        .imageType = image_type_from_image_view_type(params->view_type),
> +        .imageType = image_type,
>          .format = format,
>          .mipLevels = levels,
>          .arrayLayers = array_length,
> @@ -437,10 +459,7 @@ miptree_create(void)
>              .depth = depth,
>          },
>          .tiling = VK_IMAGE_TILING_OPTIMAL,
> -        .usage = VK_IMAGE_USAGE_TRANSFER_SRC_BIT |
> -                 VK_IMAGE_USAGE_TRANSFER_DST_BIT |
> -                 VK_IMAGE_USAGE_COLOR_ATTACHMENT_BIT |
> -                 VK_IMAGE_USAGE_SAMPLED_BIT);
> +        .usage = usage_bits);
>      VkBuffer src_buffer = qoCreateBuffer(t_device,
>          .size = buffer_size,
>          .usage = VK_BUFFER_USAGE_TRANSFER_SRC_BIT);
> @@ -501,6 +520,11 @@ miptree_create(void)
>                  break;
>              case MIPTREE_UPLOAD_METHOD_COPY_FROM_LINEAR_IMAGE:
>              case MIPTREE_UPLOAD_METHOD_COPY_WITH_DRAW:
> +
> +                // Determine if an image can be created with this combination
> +                can_create_image(VK_IMAGE_TYPE_2D, VK_IMAGE_TILING_LINEAR,
> +                                 VK_IMAGE_USAGE_TRANSFER_SRC_BIT, format);
> +
>                  src_vk_image = qoCreateImage(t_device,
>                      .format = format,
>                      .mipLevels = 1,
> @@ -523,6 +547,11 @@ miptree_create(void)
>                  break;
>              case MIPTREE_DOWNLOAD_METHOD_COPY_TO_LINEAR_IMAGE:
>              case MIPTREE_DOWNLOAD_METHOD_COPY_WITH_DRAW:
> +
> +                // Determine if an image can be created with this combination
> +                can_create_image(VK_IMAGE_TYPE_2D, VK_IMAGE_TILING_LINEAR,
> +                                 VK_IMAGE_USAGE_TRANSFER_DST_BIT, format);
> +
>                  dest_vk_image = qoCreateImage(t_device,
>                      .format = format,
>                      .mipLevels = 1,
> --
> 2.9.0
>
> _______________________________________________
> mesa-dev mailing list
> mesa-dev at lists.freedesktop.org
> https://lists.freedesktop.org/mailman/listinfo/mesa-dev

Reviewed-by: Anuj Phogat <anuj.phogat at gmail.com>


More information about the mesa-dev mailing list