[Mesa-dev] [PATCH 06/14] anv/image: Better var names for image-create-info structs

Chad Versace chad at kiwitree.net
Thu Sep 28 00:11:52 UTC 2017


Upcoming patches teach vkCreateImage to understand
VkNativeBufferANDROID. And much later patches will do the same for
whatever VkImageCreateInfo-chained struct imports dma-bufs. And then
again for the struct that will be introduced by the inevitable extension
VK_ANDROID_external_memory_whatever. So let's reduce ambiguity now by
choosing better variable names in make_surface() and
anv_image_create_info().

Rename:
  struct anv_image_create_info *create_info -> anv_info
  VkImageCreateInfo *pCreateInfo            -> base_info
  VkImageCreateInfo *vk_info                -> base_info
---
 src/intel/vulkan/anv_image.c | 98 ++++++++++++++++++++++----------------------
 1 file changed, 49 insertions(+), 49 deletions(-)

diff --git a/src/intel/vulkan/anv_image.c b/src/intel/vulkan/anv_image.c
index 7561b9b52b4..6f6bd59e89d 100644
--- a/src/intel/vulkan/anv_image.c
+++ b/src/intel/vulkan/anv_image.c
@@ -120,20 +120,20 @@ add_surface(struct anv_image *image, struct anv_surface *surf)
 
 static bool
 all_formats_ccs_e_compatible(const struct gen_device_info *devinfo,
-                             const struct VkImageCreateInfo *vk_info)
+                             const struct VkImageCreateInfo *base_info)
 {
    enum isl_format format =
-      anv_get_isl_format(devinfo, vk_info->format,
-                         VK_IMAGE_ASPECT_COLOR_BIT, vk_info->tiling);
+      anv_get_isl_format(devinfo, base_info->format,
+                         VK_IMAGE_ASPECT_COLOR_BIT, base_info->tiling);
 
    if (!isl_format_supports_ccs_e(devinfo, format))
       return false;
 
-   if (!(vk_info->flags & VK_IMAGE_CREATE_MUTABLE_FORMAT_BIT))
+   if (!(base_info->flags & VK_IMAGE_CREATE_MUTABLE_FORMAT_BIT))
       return true;
 
    const VkImageFormatListCreateInfoKHR *fmt_list =
-      vk_find_struct_const(vk_info->pNext, IMAGE_FORMAT_LIST_CREATE_INFO_KHR);
+      vk_find_struct_const(base_info->pNext, IMAGE_FORMAT_LIST_CREATE_INFO_KHR);
 
    if (!fmt_list || fmt_list->viewFormatCount == 0)
       return false;
@@ -141,7 +141,7 @@ all_formats_ccs_e_compatible(const struct gen_device_info *devinfo,
    for (uint32_t i = 0; i < fmt_list->viewFormatCount; i++) {
       enum isl_format view_format =
          anv_get_isl_format(devinfo, fmt_list->pViewFormats[i],
-                            VK_IMAGE_ASPECT_COLOR_BIT, vk_info->tiling);
+                            VK_IMAGE_ASPECT_COLOR_BIT, base_info->tiling);
 
       if (!isl_formats_are_ccs_e_compatible(devinfo, format, view_format))
          return false;
@@ -238,7 +238,7 @@ make_surface(const struct anv_device *dev,
              const struct anv_image_create_info *anv_info,
              VkImageAspectFlags aspect)
 {
-   const VkImageCreateInfo *vk_info = anv_info->vk_info;
+   const VkImageCreateInfo *base_info = anv_info->vk_info;
    bool ok UNUSED;
 
    static const enum isl_surf_dim vk_to_isl_surf_dim[] = {
@@ -251,7 +251,7 @@ make_surface(const struct anv_device *dev,
     * result with an optionally provided ISL tiling argument.
     */
    isl_tiling_flags_t tiling_flags =
-      (vk_info->tiling == VK_IMAGE_TILING_LINEAR) ?
+      (base_info->tiling == VK_IMAGE_TILING_LINEAR) ?
       ISL_TILING_LINEAR_BIT : ISL_TILING_ANY_MASK;
 
    if (anv_info->isl_tiling_flags)
@@ -261,11 +261,11 @@ make_surface(const struct anv_device *dev,
 
    struct anv_surface *anv_surf = get_surface(image, aspect);
 
-   image->extent = anv_sanitize_image_extent(vk_info->imageType,
-                                             vk_info->extent);
+   image->extent = anv_sanitize_image_extent(base_info->imageType,
+                                             base_info->extent);
 
-   enum isl_format format = anv_get_isl_format(&dev->info, vk_info->format,
-                                               aspect, vk_info->tiling);
+   enum isl_format format = anv_get_isl_format(&dev->info, base_info->format,
+                                               aspect, base_info->tiling);
    assert(format != ISL_FORMAT_UNSUPPORTED);
 
    /* If an image is created as BLOCK_TEXEL_VIEW_COMPATIBLE, then we need to
@@ -276,25 +276,25 @@ make_surface(const struct anv_device *dev,
     */
    bool needs_shadow = false;
    if (dev->info.gen <= 8 &&
-       (vk_info->flags & VK_IMAGE_CREATE_BLOCK_TEXEL_VIEW_COMPATIBLE_BIT_KHR) &&
-       vk_info->tiling == VK_IMAGE_TILING_OPTIMAL) {
+       (base_info->flags & VK_IMAGE_CREATE_BLOCK_TEXEL_VIEW_COMPATIBLE_BIT_KHR) &&
+       base_info->tiling == VK_IMAGE_TILING_OPTIMAL) {
       assert(isl_format_is_compressed(format));
       tiling_flags = ISL_TILING_LINEAR_BIT;
       needs_shadow = true;
    }
 
    ok = isl_surf_init(&dev->isl_dev, &anv_surf->isl,
-      .dim = vk_to_isl_surf_dim[vk_info->imageType],
+      .dim = vk_to_isl_surf_dim[base_info->imageType],
       .format = format,
       .width = image->extent.width,
       .height = image->extent.height,
       .depth = image->extent.depth,
-      .levels = vk_info->mipLevels,
-      .array_len = vk_info->arrayLayers,
-      .samples = vk_info->samples,
+      .levels = base_info->mipLevels,
+      .array_len = base_info->arrayLayers,
+      .samples = base_info->samples,
       .min_alignment = 0,
       .row_pitch = anv_info->stride,
-      .usage = choose_isl_surf_usage(vk_info->flags, image->usage, aspect),
+      .usage = choose_isl_surf_usage(base_info->flags, image->usage, aspect),
       .tiling_flags = tiling_flags);
 
    /* isl_surf_init() will fail only if provided invalid input. Invalid input
@@ -313,14 +313,14 @@ make_surface(const struct anv_device *dev,
       assert(tiling_flags == ISL_TILING_LINEAR_BIT);
 
       ok = isl_surf_init(&dev->isl_dev, &image->shadow_surface.isl,
-         .dim = vk_to_isl_surf_dim[vk_info->imageType],
+         .dim = vk_to_isl_surf_dim[base_info->imageType],
          .format = format,
          .width = image->extent.width,
          .height = image->extent.height,
          .depth = image->extent.depth,
-         .levels = vk_info->mipLevels,
-         .array_len = vk_info->arrayLayers,
-         .samples = vk_info->samples,
+         .levels = base_info->mipLevels,
+         .array_len = base_info->arrayLayers,
+         .samples = base_info->samples,
          .min_alignment = 0,
          .row_pitch = anv_info->stride,
          .usage = choose_isl_surf_usage(image->usage, image->usage, aspect),
@@ -349,12 +349,12 @@ make_surface(const struct anv_device *dev,
          /* It will never be used as an attachment, HiZ is pointless. */
       } else if (dev->info.gen == 7) {
          anv_perf_warn(dev->instance, image, "Implement gen7 HiZ");
-      } else if (vk_info->mipLevels > 1) {
+      } else if (base_info->mipLevels > 1) {
          anv_perf_warn(dev->instance, image, "Enable multi-LOD HiZ");
-      } else if (vk_info->arrayLayers > 1) {
+      } else if (base_info->arrayLayers > 1) {
          anv_perf_warn(dev->instance, image,
                        "Implement multi-arrayLayer HiZ clears and resolves");
-      } else if (dev->info.gen == 8 && vk_info->samples > 1) {
+      } else if (dev->info.gen == 8 && base_info->samples > 1) {
          anv_perf_warn(dev->instance, image, "Enable gen8 multisampled HiZ");
       } else if (!unlikely(INTEL_DEBUG & DEBUG_NO_HIZ)) {
          assert(image->aux_surface.isl.size == 0);
@@ -364,7 +364,7 @@ make_surface(const struct anv_device *dev,
          add_surface(image, &image->aux_surface);
          image->aux_usage = ISL_AUX_USAGE_HIZ;
       }
-   } else if (aspect == VK_IMAGE_ASPECT_COLOR_BIT && vk_info->samples == 1) {
+   } else if (aspect == VK_IMAGE_ASPECT_COLOR_BIT && base_info->samples == 1) {
       if (!unlikely(INTEL_DEBUG & DEBUG_NO_RBC)) {
          assert(image->aux_surface.isl.size == 0);
          ok = isl_surf_get_ccs_surf(&dev->isl_dev, &anv_surf->isl,
@@ -397,15 +397,15 @@ make_surface(const struct anv_device *dev,
              * a render target.  This means that it's safe to just leave
              * compression on at all times for these formats.
              */
-            if (!(vk_info->usage & VK_IMAGE_USAGE_STORAGE_BIT) &&
-                all_formats_ccs_e_compatible(&dev->info, vk_info)) {
+            if (!(base_info->usage & VK_IMAGE_USAGE_STORAGE_BIT) &&
+                all_formats_ccs_e_compatible(&dev->info, base_info)) {
                image->aux_usage = ISL_AUX_USAGE_CCS_E;
             }
          }
       }
-   } else if (aspect == VK_IMAGE_ASPECT_COLOR_BIT && vk_info->samples > 1) {
+   } else if (aspect == VK_IMAGE_ASPECT_COLOR_BIT && base_info->samples > 1) {
       assert(image->aux_surface.isl.size == 0);
-      assert(!(vk_info->usage & VK_IMAGE_USAGE_STORAGE_BIT));
+      assert(!(base_info->usage & VK_IMAGE_USAGE_STORAGE_BIT));
       ok = isl_surf_get_mcs_surf(&dev->isl_dev, &anv_surf->isl,
                                  &image->aux_surface.isl);
       if (ok) {
@@ -420,43 +420,43 @@ make_surface(const struct anv_device *dev,
 
 VkResult
 anv_image_create(VkDevice _device,
-                 const struct anv_image_create_info *create_info,
+                 const struct anv_image_create_info *anv_info,
                  const VkAllocationCallbacks* alloc,
                  VkImage *pImage)
 {
    ANV_FROM_HANDLE(anv_device, device, _device);
-   const VkImageCreateInfo *pCreateInfo = create_info->vk_info;
+   const VkImageCreateInfo *base_info = anv_info->vk_info;
    struct anv_image *image = NULL;
    VkResult r;
 
-   assert(pCreateInfo->sType == VK_STRUCTURE_TYPE_IMAGE_CREATE_INFO);
+   assert(base_info->sType == VK_STRUCTURE_TYPE_IMAGE_CREATE_INFO);
 
-   anv_assert(pCreateInfo->mipLevels > 0);
-   anv_assert(pCreateInfo->arrayLayers > 0);
-   anv_assert(pCreateInfo->samples > 0);
-   anv_assert(pCreateInfo->extent.width > 0);
-   anv_assert(pCreateInfo->extent.height > 0);
-   anv_assert(pCreateInfo->extent.depth > 0);
+   anv_assert(base_info->mipLevels > 0);
+   anv_assert(base_info->arrayLayers > 0);
+   anv_assert(base_info->samples > 0);
+   anv_assert(base_info->extent.width > 0);
+   anv_assert(base_info->extent.height > 0);
+   anv_assert(base_info->extent.depth > 0);
 
    image = vk_zalloc2(&device->alloc, alloc, sizeof(*image), 8,
                        VK_SYSTEM_ALLOCATION_SCOPE_OBJECT);
    if (!image)
       return vk_error(VK_ERROR_OUT_OF_HOST_MEMORY);
 
-   image->type = pCreateInfo->imageType;
-   image->extent = pCreateInfo->extent;
-   image->vk_format = pCreateInfo->format;
+   image->type = base_info->imageType;
+   image->extent = base_info->extent;
+   image->vk_format = base_info->format;
    image->aspects = vk_format_aspects(image->vk_format);
-   image->levels = pCreateInfo->mipLevels;
-   image->array_size = pCreateInfo->arrayLayers;
-   image->samples = pCreateInfo->samples;
-   image->usage = pCreateInfo->usage;
-   image->tiling = pCreateInfo->tiling;
+   image->levels = base_info->mipLevels;
+   image->array_size = base_info->arrayLayers;
+   image->samples = base_info->samples;
+   image->usage = base_info->usage;
+   image->tiling = base_info->tiling;
    image->aux_usage = ISL_AUX_USAGE_NONE;
 
    uint32_t b;
    for_each_bit(b, image->aspects) {
-      r = make_surface(device, image, create_info, (1 << b));
+      r = make_surface(device, image, anv_info, (1 << b));
       if (r != VK_SUCCESS)
          goto fail;
    }
-- 
2.13.5



More information about the mesa-dev mailing list