Lines Matching refs:image
80 /* blorp implements transfers by sampling from the source image. */
86 /* blorp implements transfers by rendering into the destination image.
129 get_surface(struct anv_image *image, VkImageAspectFlagBits aspect)
131 uint32_t plane = anv_image_aspect_to_plane(image->aspects, aspect);
132 return &image->planes[plane].surface;
136 add_surface(struct anv_image *image, struct anv_surface *surf, uint32_t plane)
140 if (image->disjoint) {
141 surf->offset = align_u32(image->planes[plane].size,
145 surf->offset = align_u32(image->size, surf->isl.alignment_B);
147 if (image->planes[plane].size == 0)
148 image->planes[plane].offset = image->size;
151 image->size = surf->offset + surf->isl.size_B;
152 image->planes[plane].size = (surf->offset + surf->isl.size_B) - image->planes[plane].offset;
154 image->alignment = MAX2(image->alignment, surf->isl.alignment_B);
155 image->planes[plane].alignment = MAX2(image->planes[plane].alignment,
163 struct anv_image *image)
166 anv_get_isl_format(devinfo, image->vk_format,
167 VK_IMAGE_ASPECT_COLOR_BIT, image->tiling);
172 if (!(image->create_flags & VK_IMAGE_CREATE_MUTABLE_FORMAT_BIT))
181 VK_IMAGE_ASPECT_COLOR_BIT, image->tiling);
193 * allows us to access the image's subresources while being aware of their
198 * image (hence a single RENDER_SURFACE_STATE), we only allow fast-clears on
203 * The fast clear portion of the image is laid out in the following order:
207 * * On gen9+, 1 dword per level and layer of the image (3D levels count
214 * all of the values in the fast clear portion of the image are initialized
227 * from the image layouts. The command streamer inspects the fast clear
245 add_aux_state_tracking_buffer(struct anv_image *image,
249 assert(image && device);
250 assert(image->planes[plane].aux_surface.isl.size_B > 0 &&
251 image->aspects & VK_IMAGE_ASPECT_ANY_COLOR_BIT_ANV);
257 assert(image->alignment % 4 == 0);
258 assert((image->planes[plane].offset + image->planes[plane].size) % 4 == 0);
261 if (image->disjoint) {
262 assert(image->planes[plane].size ==
263 (image->planes[plane].offset + image->planes[plane].size));
265 assert(image->size ==
266 (image->planes[plane].offset + image->planes[plane].size));
277 if (image->planes[plane].aux_usage == ISL_AUX_USAGE_CCS_E) {
278 if (image->type == VK_IMAGE_TYPE_3D) {
279 for (uint32_t l = 0; l < image->levels; l++)
280 state_size += anv_minify(image->extent.depth, l) * 4;
282 state_size += image->levels * image->array_size * 4;
286 image->planes[plane].fast_clear_state_offset =
287 image->planes[plane].offset + image->planes[plane].size;
289 image->planes[plane].size += state_size;
290 image->size += state_size;
295 * image's memory requirements (that is, the image's size and alignment).
299 struct anv_image *image,
313 image->extent = anv_sanitize_image_extent(image->type, image->extent);
315 const unsigned plane = anv_image_aspect_to_plane(image->aspects, aspect);
317 anv_get_format_plane(&dev->info, image->vk_format, aspect, image->tiling);
318 struct anv_surface *anv_surf = &image->planes[plane].surface;
321 choose_isl_surf_usage(image->create_flags, image->usage,
324 /* If an image is created as BLOCK_TEXEL_VIEW_COMPATIBLE, then we need to
332 (image->create_flags & VK_IMAGE_CREATE_BLOCK_TEXEL_VIEW_COMPATIBLE_BIT) &&
333 image->tiling == VK_IMAGE_TILING_OPTIMAL) {
340 .dim = vk_to_isl_surf_dim[image->type],
342 .width = image->extent.width / plane_format.denominator_scales[0],
343 .height = image->extent.height / plane_format.denominator_scales[1],
344 .depth = image->extent.depth,
345 .levels = image->levels,
346 .array_len = image->array_size,
347 .samples = image->samples,
356 image->planes[plane].aux_usage = ISL_AUX_USAGE_NONE;
358 add_surface(image, anv_surf, plane);
360 /* If an image is created as BLOCK_TEXEL_VIEW_COMPATIBLE, then we need to
368 ok = isl_surf_init(&dev->isl_dev, &image->planes[plane].shadow_surface.isl,
369 .dim = vk_to_isl_surf_dim[image->type],
371 .width = image->extent.width,
372 .height = image->extent.height,
373 .depth = image->extent.depth,
374 .levels = image->levels,
375 .array_len = image->array_size,
376 .samples = image->samples,
387 add_surface(image, &image->planes[plane].shadow_surface, plane);
396 assert(!(image->usage & VK_IMAGE_USAGE_STORAGE_BIT));
401 if (!(image->usage & VK_IMAGE_USAGE_DEPTH_STENCIL_ATTACHMENT_BIT)) {
404 anv_perf_warn(dev->instance, image, "Implement gen7 HiZ");
405 } else if (image->levels > 1) {
406 anv_perf_warn(dev->instance, image, "Enable multi-LOD HiZ");
407 } else if (image->array_size > 1) {
408 anv_perf_warn(dev->instance, image,
410 } else if (dev->info.gen == 8 && image->samples > 1) {
411 anv_perf_warn(dev->instance, image, "Enable gen8 multisampled HiZ");
413 assert(image->planes[plane].aux_surface.isl.size_B == 0);
415 &image->planes[plane].surface.isl,
416 &image->planes[plane].aux_surface.isl);
418 add_surface(image, &image->planes[plane].aux_surface, plane);
419 image->planes[plane].aux_usage = ISL_AUX_USAGE_HIZ;
421 } else if ((aspect & VK_IMAGE_ASPECT_ANY_COLOR_BIT_ANV) && image->samples == 1) {
434 image->n_planes == 1 &&
435 (image->create_flags & VK_IMAGE_CREATE_ALIAS_BIT) == 0 &&
439 assert(image->planes[plane].aux_surface.isl.size_B == 0);
441 &image->planes[plane].surface.isl,
442 &image->planes[plane].aux_surface.isl, 0);
446 * to the image with CCS enabled).
451 * image, we currently don't have things hooked up to get it
454 anv_perf_warn(dev->instance, image,
455 "This image format doesn't support rendering. "
457 image->planes[plane].aux_surface.isl.size_B = 0;
461 add_surface(image, &image->planes[plane].aux_surface, plane);
462 add_aux_state_tracking_buffer(image, plane, dev);
468 * image, then it will only be used through the sampler or the as
472 if (!(image->usage & VK_IMAGE_USAGE_STORAGE_BIT) &&
473 image->ccs_e_compatible) {
474 image->planes[plane].aux_usage = ISL_AUX_USAGE_CCS_E;
478 } else if ((aspect & VK_IMAGE_ASPECT_ANY_COLOR_BIT_ANV) && image->samples > 1) {
479 assert(!(image->usage & VK_IMAGE_USAGE_STORAGE_BIT));
480 assert(image->planes[plane].aux_surface.isl.size_B == 0);
482 &image->planes[plane].surface.isl,
483 &image->planes[plane].aux_surface.isl);
485 add_surface(image, &image->planes[plane].aux_surface, plane);
486 add_aux_state_tracking_buffer(image, plane, dev);
487 image->planes[plane].aux_usage = ISL_AUX_USAGE_MCS;
491 assert((image->planes[plane].offset + image->planes[plane].size) == image->size);
496 assert((MAX2(image->planes[plane].surface.offset,
497 image->planes[plane].aux_surface.offset) +
498 (image->planes[plane].aux_surface.isl.size_B > 0 ?
499 image->planes[plane].aux_surface.isl.size_B :
500 image->planes[plane].surface.isl.size_B)) <=
501 (image->planes[plane].offset + image->planes[plane].size));
503 if (image->planes[plane].aux_surface.isl.size_B) {
504 /* assert(image->planes[plane].fast_clear_state_offset == */
505 /* (image->planes[plane].aux_surface.offset + image->planes[plane].aux_surface.isl.size_B)); */
506 assert(image->planes[plane].fast_clear_state_offset <
507 (image->planes[plane].offset + image->planes[plane].size));
555 struct anv_image *image = NULL;
576 image = vk_zalloc2(&device->alloc, alloc, sizeof(*image), 8,
578 if (!image)
581 image->type = pCreateInfo->imageType;
582 image->extent = pCreateInfo->extent;
583 image->vk_format = pCreateInfo->format;
584 image->format = anv_get_format(pCreateInfo->format);
585 image->aspects = vk_format_aspects(image->vk_format);
586 image->levels = pCreateInfo->mipLevels;
587 image->array_size = pCreateInfo->arrayLayers;
588 image->samples = pCreateInfo->samples;
589 image->usage = pCreateInfo->usage;
590 image->create_flags = pCreateInfo->flags;
591 image->tiling = pCreateInfo->tiling;
592 image->disjoint = pCreateInfo->flags & VK_IMAGE_CREATE_DISJOINT_BIT;
593 image->needs_set_tiling = wsi_info && wsi_info->scanout;
594 image->drm_format_mod = isl_mod_info ? isl_mod_info->modifier :
601 image->external_format = true;
602 *pImage = anv_image_to_handle(image);
606 const struct anv_format *format = anv_get_format(image->vk_format);
611 image->needs_set_tiling);
613 image->n_planes = format->n_planes;
619 image->ccs_e_compatible =
620 all_formats_ccs_e_compatible(&device->info, fmt_list, image);
623 for_each_bit(b, image->aspects) {
624 r = make_surface(device, image, create_info->stride, isl_tiling_flags,
630 *pImage = anv_image_to_handle(image);
635 if (image)
636 vk_free2(&device->alloc, alloc, image);
654 ANV_FROM_HANDLE(anv_image, image, images[index]);
657 return image;
687 /* If the image has a particular modifier, specify that modifier. */
744 ANV_FROM_HANDLE(anv_image, image, _image);
746 if (!image)
749 for (uint32_t p = 0; p < image->n_planes; ++p) {
750 if (image->planes[p].bo_is_owned) {
751 assert(image->planes[p].address.bo != NULL);
753 image->planes[p].address.bo);
757 vk_free2(&device->alloc, pAllocator, image);
761 struct anv_image *image,
766 assert(!image->planes[plane].bo_is_owned);
769 image->planes[plane].address = ANV_NULL_ADDRESS;
773 image->planes[plane].address = (struct anv_address) {
784 struct anv_image *image,
838 image->vk_format = vk_format;
839 image->format = anv_get_format(vk_format);
840 image->aspects = vk_format_aspects(image->vk_format);
841 image->n_planes = image->format->n_planes;
842 image->ccs_e_compatible = false;
848 for_each_bit(b, image->aspects) {
849 VkResult r = make_surface(device, image, stride, isl_tiling_flags,
864 ANV_FROM_HANDLE(anv_image, image, _image);
867 resolve_ahw_image(device, image, mem);
870 anv_foreach_image_aspect_bit(aspect_bit, image, image->aspects) {
872 anv_image_aspect_to_plane(image->aspects, 1UL << aspect_bit);
873 anv_image_bind_memory_plane(device, image
889 ANV_FROM_HANDLE(anv_image, image, bind_info->image);
891 /* Resolve will alter the image's aspects, do this first. */
893 resolve_ahw_image(device, image, mem);
895 VkImageAspectFlags aspects = image->aspects;
912 assert(image->aspects == swapchain_image->aspects);
916 anv_foreach_image_aspect_bit(aspect_bit, image, aspects) {
918 anv_image_aspect_to_plane(image->aspects, 1UL << aspect_bit);
922 anv_image_bind_memory_plane(device, image, plane,
941 anv_foreach_image_aspect_bit(aspect_bit, image, aspects) {
943 anv_image_aspect_to_plane(image->aspects, 1UL << aspect_bit);
944 anv_image_bind_memory_plane(device, image, plane,
958 ANV_FROM_HANDLE(anv_image, image, _image);
962 image->drm_format_mod != DRM_FORMAT_MOD_INVALID &&
963 isl_drm_modifier_has_aux(image->drm_format_mod))
964 surface = &image->planes[0].aux_surface;
966 surface = get_surface(image, subresource->aspectMask);
985 layout->size = layout->rowPitch * anv_minify(image->extent.height,
999 * @param image The image that may contain a collection of buffers.
1000 * @param aspect The aspect of the image to be accessed.
1001 * @param layout The current layout of the image aspect(s).
1007 const struct anv_image * const image,
1016 /* The layout of a NULL image is not properly defined. */
1017 assert(image != NULL);
1019 /* The aspect must be exactly one of the image aspects. */
1020 assert(util_bitcount(aspect) == 1 && (aspect & image->aspects));
1024 uint32_t plane = anv_image_aspect_to_plane(image->aspects, aspect);
1029 if (image->planes[plane].aux_surface.isl.size_B == 0)
1033 assert(image->tiling == VK_IMAGE_TILING_OPTIMAL);
1043 unreachable("Invalid image layout.");
1066 assert(image->planes[plane].aux_usage == ISL_AUX_USAGE_HIZ);
1069 assert(image->aspects & VK_IMAGE_ASPECT_ANY_COLOR_BIT_ANV);
1070 return image->planes[plane].aux_usage;
1077 assert((image->aspects & VK_IMAGE_ASPECT_ANY_COLOR_BIT_ANV) == 0);
1081 if (anv_can_sample_with_hiz(devinfo, image))
1086 return image->planes[plane].aux_usage;
1091 assert(image->aspects == VK_IMAGE_ASPECT_COLOR_BIT);
1093 /* When handing the image off to the presentation engine, we need to
1101 isl_drm_modifier_get_info(image->drm_format_mod);
1109 if (image->planes[plane].aux_usage == ISL_AUX_USAGE_NONE) {
1110 assert(image->samples == 1);
1113 assert(image->planes[plane].aux_usage != ISL_AUX_USAGE_CCS_D);
1114 return image->planes[plane].aux_usage;
1140 * given image in the given VkImageLayout.
1143 * @param image The image that may contain a collection of buffers.
1144 * @param aspect The aspect of the image to be accessed.
1145 * @param layout The current layout of the image aspect(s).
1149 const struct anv_image * const image,
1153 /* The aspect must be exactly one of the image aspects. */
1154 assert(util_bitcount(aspect) == 1 && (aspect & image->aspects));
1156 uint32_t plane = anv_image_aspect_to_plane(image->aspects, aspect);
1159 if (image->planes[plane].aux_surface.isl.size_B == 0)
1163 assert(image->tiling == VK_IMAGE_TILING_OPTIMAL);
1174 anv_layout_to_aux_usage(devinfo, image, aspect, layout);
1179 assert(image->aspects & VK_IMAGE_ASPECT_ANY_COLOR_BIT_ANV);
1184 if (devinfo->gen == 7 && !devinfo->is_haswell && image->samples > 1)
1192 assert(image->aspects == VK_IMAGE_ASPECT_COLOR_BIT);
1198 isl_drm_modifier_get_info(image->drm_format_mod);
1205 /* If the image has MCS or CCS_E enabled all the time then we can use
1210 if (image->planes[plane].aux_usage == ISL_AUX_USAGE_MCS ||
1211 image->planes[plane].aux_usage == ISL_AUX_USAGE_CCS_E)
1246 const struct anv_image *image,
1256 uint32_t plane = anv_image_aspect_to_plane(image->aspects, aspect);
1258 const struct anv_surface *surface = &image->planes[plane].surface,
1259 *aux_surface = &image->planes[plane].aux_surface;
1269 if (image->planes[plane].shadow_surface.isl.size_B > 0 &&
1274 assert(image->planes[plane].shadow_surface.isl.tiling != ISL_TILING_LINEAR);
1275 surface = &image->planes[plane].shadow_surface;
1295 anv_address_add(image->planes[plane].address, surface->offset);
1320 * image formats. Translate it into the closest format the hardware
1350 /* The newly created image represents the one subimage we're
1357 /* We're making an uncompressed view here. The image dimensions need
1382 aux_address = anv_address_add(image->planes[plane].address,
1395 clear_address = anv_image_get_clear_color_addr(device, image, aspect);
1484 ANV_FROM_HANDLE(anv_image, image, pCreateInfo->image);
1495 assert(range->baseMipLevel < image->levels);
1502 /* If image has an external format, the pNext chain must contain an instance of
1504 * external format as image."
1506 assert(!image->external_format || conv_info);
1515 VkImageUsageFlags view_usage = usage_info ? usage_info->usage : image->usage;
1516 /* View usage should be a subset of image usage */
1517 assert((view_usage & ~image->usage) == 0);
1524 switch (image->type) {
1529 assert(range->baseArrayLayer + anv_get_layerCount(image, range) - 1 <= image->array_size);
1532 assert(range->baseArrayLayer + anv_get_layerCount(image, range) - 1
1533 <= anv_minify(image->extent.depth, range->baseMipLevel));
1537 /* First expand aspects to the image's ones (for example
1540 * VK_IMAGE_ASPECT_PLANE_2_BIT for an image of format
1544 anv_image_expand_aspects(image, range->aspectMask);
1546 iview->image = image;
1548 /* Remap the expanded aspects for the image view. For example if only
1551 * the image view, it only has a single plane.
1557 /* "If image has an external format, format must be VK_FORMAT_UNDEFINED." */
1558 assert(!image->external_format || pCreateInfo->format == VK_FORMAT_UNDEFINED);
1567 .width = anv_minify(image->extent.width , range->baseMipLevel),
1568 .height = anv_minify(image->extent.height, range->baseMipLevel),
1569 .depth = anv_minify(image->extent.depth , range->baseMipLevel),
1572 /* Now go through the underlying image selected planes (computed in
1573 * expanded_aspects) and map them to planes in the image view.
1576 anv_foreach_image_aspect_bit(iaspect_bit, image, expanded_aspects) {
1578 anv_image_aspect_to_plane(image->aspects, 1UL << iaspect_bit);
1583 vplane_aspect, image->tiling);
1590 .levels = anv_get_levelCount(image, range),
1592 .array_len = anv_get_layerCount(image, range),
1624 anv_layout_to_aux_usage(&device->info, image, 1UL << iaspect_bit,
1627 anv_layout_to_aux_usage(&device->info, image, 1UL << iaspect_bit,
1630 anv_image_fill_surface_state(device, image, 1ULL << iaspect_bit,
1638 anv_image_fill_surface_state(device, image, 1ULL << iaspect_bit,
1652 anv_image_fill_surface_state(device, image, 1ULL << iaspect_bit,
1660 anv_image_fill_surface_state(device, image, 1ULL << iaspect_bit,
1811 anv_image_get_surface_for_aspect_mask(const struct anv_image *image,
1818 assert(image->aspects == VK_IMAGE_ASPECT_COLOR_BIT);
1822 assert(image->aspects & VK_IMAGE_ASPECT_DEPTH_BIT);
1826 assert(image->aspects & VK_IMAGE_ASPECT_STENCIL_BIT);
1836 * Image views with both depth and stencil aspects are only valid for
1841 if (image->aspects & VK_IMAGE_ASPECT_DEPTH_BIT) {
1844 assert(image->aspects == VK_IMAGE_ASPECT_STENCIL_BIT);
1849 assert((image->aspects & ~VK_IMAGE_ASPECT_ANY_COLOR_BIT_ANV) == 0);
1853 assert((image->aspects & ~VK_IMAGE_ASPECT_ANY_COLOR_BIT_ANV) == 0);
1857 assert((image->aspects & ~VK_IMAGE_ASPECT_ANY_COLOR_BIT_ANV) == 0);
1861 unreachable("image does not have aspect");
1865 uint32_t plane = anv_image_aspect_to_plane(image->aspects, sanitized_mask);
1866 return &image->planes[plane].surface;