anv: implement VK_EXT_image_compression_control

Limited to vkd3d right now, there are specific use cases there.

We don't want any app to disable compression, it should be mostly
transparent and we better be aware of potential bugs.

Signed-off-by: Lionel Landwerlin <lionel.g.landwerlin@intel.com>
Reviewed-by: José Roberto de Souza <jose.souza@intel.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/28632>
This commit is contained in:
Lionel Landwerlin
2024-04-08 16:33:29 +03:00
committed by Marge Bot
parent db6ee2e1bb
commit c94cd1235f
6 changed files with 61 additions and 5 deletions

View File

@@ -207,7 +207,8 @@ anv_image_choose_isl_surf_usage(struct anv_physical_device *device,
VkImageCreateFlags vk_create_flags,
VkImageUsageFlags vk_usage,
isl_surf_usage_flags_t isl_extra_usage,
VkImageAspectFlagBits aspect)
VkImageAspectFlagBits aspect,
VkImageCompressionFlagsEXT comp_flags)
{
isl_surf_usage_flags_t isl_usage = isl_extra_usage;
@@ -283,6 +284,9 @@ anv_image_choose_isl_surf_usage(struct anv_physical_device *device,
isl_usage |= ISL_SURF_USAGE_RENDER_TARGET_BIT;
}
if (comp_flags & VK_IMAGE_COMPRESSION_DISABLED_EXT)
isl_usage |= ISL_SURF_USAGE_DISABLE_AUX_BIT;
return isl_usage;
}
@@ -1324,7 +1328,8 @@ add_all_surfaces_implicit_layout(
isl_surf_usage_flags_t isl_usage =
anv_image_choose_isl_surf_usage(device->physical,
image->vk.create_flags, vk_usage,
isl_extra_usage_flags, aspect);
isl_extra_usage_flags, aspect,
image->vk.compr_flags);
result = add_primary_surface(device, image, plane, plane_format,
ANV_OFFSET_IMPLICIT, plane_stride,
@@ -1722,7 +1727,8 @@ anv_image_init(struct anv_device *device, struct anv_image *image,
isl_surf_usage_flags_t isl_usage = anv_image_choose_isl_surf_usage(
device->physical, image->vk.create_flags, image->vk.usage,
isl_extra_usage_flags, VK_IMAGE_ASPECT_COLOR_BIT);
isl_extra_usage_flags, VK_IMAGE_ASPECT_COLOR_BIT,
image->vk.compr_flags);
r = add_primary_surface(device, image, plane, plane_format,
ANV_OFFSET_IMPLICIT, 0,
@@ -2646,6 +2652,20 @@ anv_get_image_subresource_layout(const struct anv_image *image,
} else {
layout->subresourceLayout.size = mem_range->size;
}
VkImageCompressionPropertiesEXT *comp_props =
vk_find_struct(layout->pNext, IMAGE_COMPRESSION_PROPERTIES_EXT);
if (comp_props) {
comp_props->imageCompressionFixedRateFlags =
VK_IMAGE_COMPRESSION_FIXED_RATE_NONE_EXT;
comp_props->imageCompressionFlags = VK_IMAGE_COMPRESSION_DISABLED_EXT;
for (uint32_t p = 0; p < image->n_planes; p++) {
if (image->planes[p].aux_usage != ISL_AUX_USAGE_NONE) {
comp_props->imageCompressionFlags = VK_IMAGE_COMPRESSION_DEFAULT_EXT;
break;
}
}
}
}
void anv_GetDeviceImageSubresourceLayoutKHR(