}
static enum isl_channel_select
-remap_swizzle(VkComponentSwizzle swizzle, VkComponentSwizzle component,
+remap_swizzle(VkComponentSwizzle swizzle,
struct isl_swizzle format_swizzle)
{
- if (swizzle == VK_COMPONENT_SWIZZLE_IDENTITY)
- swizzle = component;
-
switch (swizzle) {
case VK_COMPONENT_SWIZZLE_ZERO: return ISL_CHANNEL_SELECT_ZERO;
case VK_COMPONENT_SWIZZLE_ONE: return ISL_CHANNEL_SELECT_ONE;
ANV_FROM_HANDLE(anv_image, image, pCreateInfo->image);
struct anv_image_view *iview;
- iview = vk_object_zalloc(&device->vk, pAllocator, sizeof(*iview),
- VK_OBJECT_TYPE_IMAGE_VIEW);
+ iview = vk_image_view_create(&device->vk, pCreateInfo,
+ pAllocator, sizeof(*iview));
if (iview == NULL)
return vk_error(VK_ERROR_OUT_OF_HOST_MEMORY);
- const VkImageSubresourceRange *range = &pCreateInfo->subresourceRange;
-
- assert(range->layerCount > 0);
- assert(range->baseMipLevel < image->vk.mip_levels);
+ iview->image = image;
+ iview->n_planes = anv_image_aspect_get_planes(iview->vk.aspects);
/* Check if a conversion info was passed. */
const struct anv_format *conv_format = NULL;
conv_format = conversion->format;
}
- const VkImageUsageFlags image_usage =
- vk_image_usage(&image->vk, range->aspectMask);
-
- const VkImageViewUsageCreateInfo *usage_info =
- vk_find_struct_const(pCreateInfo, IMAGE_VIEW_USAGE_CREATE_INFO);
- VkImageUsageFlags view_usage = usage_info ? usage_info->usage : image_usage;
-
- /* View usage should be a subset of image usage */
- assert((view_usage & ~image_usage) == 0);
- assert(view_usage & (VK_IMAGE_USAGE_SAMPLED_BIT |
- VK_IMAGE_USAGE_STORAGE_BIT |
- VK_IMAGE_USAGE_COLOR_ATTACHMENT_BIT |
- VK_IMAGE_USAGE_INPUT_ATTACHMENT_BIT |
- VK_IMAGE_USAGE_DEPTH_STENCIL_ATTACHMENT_BIT));
-
- uint32_t layer_count = vk_image_subresource_layer_count(&image->vk, range);
- switch (image->vk.image_type) {
- default:
- unreachable("bad VkImageType");
- case VK_IMAGE_TYPE_1D:
- case VK_IMAGE_TYPE_2D:
- assert(range->baseArrayLayer + layer_count - 1
- <= image->vk.array_layers);
- break;
- case VK_IMAGE_TYPE_3D:
- assert(range->baseArrayLayer + layer_count - 1
- <= anv_minify(image->vk.extent.depth, range->baseMipLevel));
- break;
- }
-
- iview->image = image;
-
- /* First expand aspects to the image's ones (for example
- * VK_IMAGE_ASPECT_COLOR_BIT will be converted to
- * VK_IMAGE_ASPECT_PLANE_0_BIT | VK_IMAGE_ASPECT_PLANE_1_BIT |
- * VK_IMAGE_ASPECT_PLANE_2_BIT for an image of format
- * VK_FORMAT_G8_B8_R8_3PLANE_420_UNORM.
- */
- iview->aspects = vk_image_expand_aspect_mask(&image->vk, range->aspectMask);
- iview->n_planes = anv_image_aspect_get_planes(iview->aspects);
- iview->vk_format = pCreateInfo->format;
-
#ifdef ANDROID
/* "If image has an external format, format must be VK_FORMAT_UNDEFINED." */
assert(!image->vk.android_external_format ||
/* Format is undefined, this can happen when using external formats. Set
* view format from the passed conversion info.
*/
- if (iview->vk_format == VK_FORMAT_UNDEFINED && conv_format)
- iview->vk_format = conv_format->vk_format;
-
- iview->extent = vk_image_mip_level_extent(&image->vk, range->baseMipLevel);
+ if (iview->vk.format == VK_FORMAT_UNDEFINED && conv_format)
+ iview->vk.format = conv_format->vk_format;
/* Now go through the underlying image selected planes and map them to
* planes in the image view.
*/
- anv_foreach_image_aspect_bit(iaspect_bit, image, iview->aspects) {
+ anv_foreach_image_aspect_bit(iaspect_bit, image, iview->vk.aspects) {
const uint32_t iplane =
anv_aspect_to_plane(image->vk.aspects, 1UL << iaspect_bit);
const uint32_t vplane =
- anv_aspect_to_plane(iview->aspects, 1UL << iaspect_bit);
+ anv_aspect_to_plane(iview->vk.aspects, 1UL << iaspect_bit);
struct anv_format_plane format;
- if (image->vk.aspects & (VK_IMAGE_ASPECT_DEPTH_BIT |
- VK_IMAGE_ASPECT_STENCIL_BIT)) {
- /* With depth/stencil images, we're always given the full
- * depth/stencil format even if we're only taking one aspect.
- */
- assert(iview->vk_format == image->vk.format);
- format = anv_get_format_aspect(&device->info, iview->vk_format,
- 1u << iaspect_bit, image->vk.tiling);
- } else {
- /* With color images, we have three cases:
- *
- * 1. It's a single-plane image in which case vplane=0.
- *
- * 2. It's a YCbCr view of a multi-plane image in which case the
- * client will have asked for VK_IMAGE_ASPECT_COLOR_BIT and the
- * format provided will be the full planar format. In this case,
- * we want all the planes.
- *
- * 3. It's a single-plane view of a multi-plane image in which case
- * the client will have asked for VK_IMAGE_ASPECT_PLANE_N_BIT and
- * will have provided a format compatible with that specific
- * plane of the multi-planar format.
- *
- * In all three cases, the format provided by the client corresponds
- * to exactly the planes we have in the view so we can just grab the
- * format plane based on vplane.
- */
- format = anv_get_format_plane(&device->info, iview->vk_format,
- vplane, image->vk.tiling);
- }
+ format = anv_get_format_plane(&device->info, iview->vk.format,
+ vplane, image->vk.tiling);
iview->planes[vplane].image_plane = iplane;
iview->planes[vplane].isl = (struct isl_view) {
.format = format.isl_format,
- .base_level = range->baseMipLevel,
- .levels = vk_image_subresource_level_count(&image->vk, range),
- .base_array_layer = range->baseArrayLayer,
- .array_len = layer_count,
+ .base_level = iview->vk.base_mip_level,
+ .levels = iview->vk.level_count,
+ .base_array_layer = iview->vk.base_array_layer,
+ .array_len = iview->vk.layer_count,
.swizzle = {
- .r = remap_swizzle(pCreateInfo->components.r,
- VK_COMPONENT_SWIZZLE_R, format.swizzle),
- .g = remap_swizzle(pCreateInfo->components.g,
- VK_COMPONENT_SWIZZLE_G, format.swizzle),
- .b = remap_swizzle(pCreateInfo->components.b,
- VK_COMPONENT_SWIZZLE_B, format.swizzle),
- .a = remap_swizzle(pCreateInfo->components.a,
- VK_COMPONENT_SWIZZLE_A, format.swizzle),
+ .r = remap_swizzle(iview->vk.swizzle.r, format.swizzle),
+ .g = remap_swizzle(iview->vk.swizzle.g, format.swizzle),
+ .b = remap_swizzle(iview->vk.swizzle.b, format.swizzle),
+ .a = remap_swizzle(iview->vk.swizzle.a, format.swizzle),
},
};
if (pCreateInfo->viewType == VK_IMAGE_VIEW_TYPE_3D) {
iview->planes[vplane].isl.base_array_layer = 0;
- iview->planes[vplane].isl.array_len = iview->extent.depth;
+ iview->planes[vplane].isl.array_len = iview->vk.extent.depth;
}
if (pCreateInfo->viewType == VK_IMAGE_VIEW_TYPE_CUBE ||
iview->planes[vplane].isl.usage = 0;
}
- if (view_usage & VK_IMAGE_USAGE_SAMPLED_BIT ||
- (view_usage & VK_IMAGE_USAGE_INPUT_ATTACHMENT_BIT &&
- !(iview->aspects & VK_IMAGE_ASPECT_ANY_COLOR_BIT_ANV))) {
+ if (iview->vk.usage & VK_IMAGE_USAGE_SAMPLED_BIT ||
+ (iview->vk.usage & VK_IMAGE_USAGE_INPUT_ATTACHMENT_BIT &&
+ !(iview->vk.aspects & VK_IMAGE_ASPECT_ANY_COLOR_BIT_ANV))) {
iview->planes[vplane].optimal_sampler_surface_state.state = alloc_surface_state(device);
iview->planes[vplane].general_sampler_surface_state.state = alloc_surface_state(device);
}
/* NOTE: This one needs to go last since it may stomp isl_view.format */
- if (view_usage & VK_IMAGE_USAGE_STORAGE_BIT) {
+ if (iview->vk.usage & VK_IMAGE_USAGE_STORAGE_BIT) {
if (isl_is_storage_image_format(format.isl_format)) {
iview->planes[vplane].storage_surface_state.state =
alloc_surface_state(device);
}
}
- vk_object_free(&device->vk, pAllocator, iview);
+ vk_image_view_destroy(&device->vk, pAllocator, &iview->vk);
}
*/
if (render_area.offset.x != 0 ||
render_area.offset.y != 0 ||
- render_area.extent.width != iview->extent.width ||
- render_area.extent.height != iview->extent.height)
+ render_area.extent.width != iview->vk.extent.width ||
+ render_area.extent.height != iview->vk.extent.height)
return false;
/* On Broadwell and earlier, we can only handle 0/1 clear colors */
if (isl_color_value_requires_conversion(clear_color,
&iview->image->planes[0].primary_surface.isl,
&iview->planes[0].isl)) {
- anv_perf_warn(device, &iview->base,
+ anv_perf_warn(device, &iview->vk.base,
"Cannot fast-clear to colors which would require "
"format conversion on resolve");
return false;
att_state->clear_value = begin->pClearValues[i];
struct anv_image_view *iview = state->attachments[i].image_view;
- anv_assert(iview->vk_format == pass_att->format);
+ anv_assert(iview->vk.format == pass_att->format);
const uint32_t num_layers = iview->planes[0].isl.array_len;
att_state->pending_clear_views = (1 << num_layers) - 1;
case VK_DESCRIPTOR_TYPE_INPUT_ATTACHMENT:
assert(shader->stage == MESA_SHADER_FRAGMENT);
assert(desc->image_view != NULL);
- if ((desc->image_view->aspects & VK_IMAGE_ASPECT_ANY_COLOR_BIT_ANV) == 0) {
+ if ((desc->image_view->vk.aspects & VK_IMAGE_ASPECT_ANY_COLOR_BIT_ANV) == 0) {
/* For depth and stencil input attachments, we treat it like any
* old texture that a user may have bound.
*/
"corresponding SPIR-V format enum.");
vk_debug_report(&cmd_buffer->device->physical->instance->vk,
VK_DEBUG_REPORT_ERROR_BIT_EXT,
- &desc->image_view->base,
+ &desc->image_view->vk.base,
__LINE__, 0, "anv",
"Bound a image to a descriptor where the "
"descriptor does not have NonReadable "
* with depth.
*/
const struct isl_view *ds_view = &iview->planes[0].isl;
- if (iview->aspects & VK_IMAGE_ASPECT_DEPTH_BIT) {
+ if (iview->vk.aspects & VK_IMAGE_ASPECT_DEPTH_BIT) {
genX(cmd_buffer_mark_image_written)(cmd_buffer, iview->image,
VK_IMAGE_ASPECT_DEPTH_BIT,
att_state->aux_usage,
ds_view->base_array_layer,
fb->layers);
}
- if (iview->aspects & VK_IMAGE_ASPECT_STENCIL_BIT) {
+ if (iview->vk.aspects & VK_IMAGE_ASPECT_STENCIL_BIT) {
/* Even though stencil may be plane 1, it always shares a
* base_level with depth.
*/
enum isl_aux_usage dst_aux_usage =
cmd_buffer->state.attachments[dst_att].aux_usage;
- assert(src_iview->aspects == VK_IMAGE_ASPECT_COLOR_BIT &&
- dst_iview->aspects == VK_IMAGE_ASPECT_COLOR_BIT);
+ assert(src_iview->vk.aspects == VK_IMAGE_ASPECT_COLOR_BIT &&
+ dst_iview->vk.aspects == VK_IMAGE_ASPECT_COLOR_BIT);
anv_image_msaa_resolve(cmd_buffer,
src_iview->image, src_aux_usage,
*/
if (dst_iview->image->vk.image_type != VK_IMAGE_TYPE_3D &&
render_area.offset.x == 0 && render_area.offset.y == 0 &&
- render_area.extent.width == dst_iview->extent.width &&
- render_area.extent.height == dst_iview->extent.height)
+ render_area.extent.width == dst_iview->vk.extent.width &&
+ render_area.extent.height == dst_iview->vk.extent.height)
dst_initial_layout = VK_IMAGE_LAYOUT_UNDEFINED;
transition_depth_buffer(cmd_buffer, dst_iview->image,