+ struct anv_surface *surface =
+ anv_image_get_surface_for_aspect_mask(image, range->aspectMask);
+
+ iview->image = image;
+ iview->bo = image->bo;
+ iview->offset = image->offset + surface->offset + offset;
+
+ iview->aspect_mask = pCreateInfo->subresourceRange.aspectMask;
+ iview->vk_format = pCreateInfo->format;
+
+ struct anv_format_swizzle swizzle;
+ iview->format = anv_get_isl_format(pCreateInfo->format, iview->aspect_mask,
+ image->tiling, &swizzle);
+ iview->swizzle.r = remap_swizzle(pCreateInfo->components.r,
+ VK_COMPONENT_SWIZZLE_R, swizzle);
+ iview->swizzle.g = remap_swizzle(pCreateInfo->components.g,
+ VK_COMPONENT_SWIZZLE_G, swizzle);
+ iview->swizzle.b = remap_swizzle(pCreateInfo->components.b,
+ VK_COMPONENT_SWIZZLE_B, swizzle);
+ iview->swizzle.a = remap_swizzle(pCreateInfo->components.a,
+ VK_COMPONENT_SWIZZLE_A, swizzle);
+
+ iview->base_layer = range->baseArrayLayer;
+ iview->base_mip = range->baseMipLevel;
+
+ if (!isl_format_is_compressed(iview->format) &&
+ isl_format_is_compressed(image->format->isl_format)) {
+ /* Scale the ImageView extent by the backing Image. This is used
+ * internally when an uncompressed ImageView is created on a
+ * compressed Image. The ImageView can therefore be used for copying
+ * data from a source Image to a destination Image.
+ */
+ const struct isl_format_layout * isl_layout = image->format->isl_layout;
+
+ iview->level_0_extent.depth = anv_minify(image->extent.depth, range->baseMipLevel);
+ iview->level_0_extent.depth = DIV_ROUND_UP(iview->level_0_extent.depth, isl_layout->bd);
+
+ iview->level_0_extent.height = isl_surf_get_array_pitch_el_rows(&surface->isl) * image->array_size;
+ iview->level_0_extent.width = isl_surf_get_row_pitch_el(&surface->isl);
+ mCreateInfo.subresourceRange.baseMipLevel = 0;
+ mCreateInfo.subresourceRange.baseArrayLayer = 0;
+ } else {
+ iview->level_0_extent.width = image->extent.width;
+ iview->level_0_extent.height = image->extent.height;
+ iview->level_0_extent.depth = image->extent.depth;
+ }
+
+ iview->extent = (VkExtent3D) {
+ .width = anv_minify(iview->level_0_extent.width , range->baseMipLevel),
+ .height = anv_minify(iview->level_0_extent.height, range->baseMipLevel),
+ .depth = anv_minify(iview->level_0_extent.depth , range->baseMipLevel),
+ };
+
+ if (image->usage & VK_IMAGE_USAGE_SAMPLED_BIT) {
+ iview->sampler_surface_state = alloc_surface_state(device, cmd_buffer);
+
+ anv_fill_image_surface_state(device, iview->sampler_surface_state,
+ iview, &mCreateInfo,
+ VK_IMAGE_USAGE_SAMPLED_BIT);
+ } else {
+ iview->sampler_surface_state.alloc_size = 0;
+ }
+
+ if (image->usage & VK_IMAGE_USAGE_COLOR_ATTACHMENT_BIT) {
+ iview->color_rt_surface_state = alloc_surface_state(device, cmd_buffer);
+
+ anv_fill_image_surface_state(device, iview->color_rt_surface_state,
+ iview, &mCreateInfo,
+ VK_IMAGE_USAGE_COLOR_ATTACHMENT_BIT);
+ } else {
+ iview->color_rt_surface_state.alloc_size = 0;
+ }
+
+ if (image->usage & VK_IMAGE_USAGE_STORAGE_BIT) {
+ iview->storage_surface_state = alloc_surface_state(device, cmd_buffer);
+
+ if (has_matching_storage_typed_format(device, iview->format))
+ anv_fill_image_surface_state(device, iview->storage_surface_state,
+ iview, &mCreateInfo,
+ VK_IMAGE_USAGE_STORAGE_BIT);