diff --git a/src/freedreno/vulkan/tu_formats.c b/src/freedreno/vulkan/tu_formats.c index 7cddf96e974..75a3ce74eae 100644 --- a/src/freedreno/vulkan/tu_formats.c +++ b/src/freedreno/vulkan/tu_formats.c @@ -431,7 +431,9 @@ tu_GetPhysicalDeviceFormatProperties2( /* note: ubwc_possible() argument values to be ignored except for format */ if (pFormatProperties->formatProperties.optimalTilingFeatures && tiling_possible(format) && - ubwc_possible(format, VK_IMAGE_TYPE_2D, 0, 0, physical_device->info, VK_SAMPLE_COUNT_1_BIT, false)) { + ubwc_possible(NULL, format, VK_IMAGE_TYPE_2D, 0, 0, + physical_device->info, VK_SAMPLE_COUNT_1_BIT, + false)) { vk_outarray_append_typed(VkDrmFormatModifierPropertiesEXT, &out, mod_props) { mod_props->drmFormatModifier = DRM_FORMAT_MOD_QCOM_COMPRESSED; mod_props->drmFormatModifierPlaneCount = tu6_plane_count(format); @@ -485,8 +487,11 @@ tu_get_image_format_properties( return VK_ERROR_FORMAT_NOT_SUPPORTED; } - if (!ubwc_possible(info->format, info->type, info->usage, info->usage, physical_device->info, sampleCounts, false)) + if (!ubwc_possible(NULL, info->format, info->type, info->usage, + info->usage, physical_device->info, sampleCounts, + false)) { return VK_ERROR_FORMAT_NOT_SUPPORTED; + } format_feature_flags = format_props.optimalTilingFeatures; break; diff --git a/src/freedreno/vulkan/tu_image.c b/src/freedreno/vulkan/tu_image.c index d66264ddd50..8bb83f4087e 100644 --- a/src/freedreno/vulkan/tu_image.c +++ b/src/freedreno/vulkan/tu_image.c @@ -268,10 +268,20 @@ tiling_possible(VkFormat format) return true; } +/* Checks if we should advertise UBWC support for the given usage. + * + * Used by both vkCreateImage and vkGetPhysicalDeviceFormatProperties2, so the + * logical tu_device may be NULL. + */ bool -ubwc_possible(VkFormat format, VkImageType type, VkImageUsageFlags usage, - VkImageUsageFlags stencil_usage, const struct fd_dev_info *info, - VkSampleCountFlagBits samples, bool use_z24uint_s8uint) +ubwc_possible(struct tu_device *device, + VkFormat format, + VkImageType type, + VkImageUsageFlags usage, + VkImageUsageFlags stencil_usage, + const struct fd_dev_info *info, + VkSampleCountFlagBits samples, + bool use_z24uint_s8uint) { /* no UBWC with compressed formats, E5B9G9R9, S8_UINT * (S8_UINT because separate stencil doesn't have UBWC-enable bit) @@ -297,7 +307,12 @@ ubwc_possible(VkFormat format, VkImageType type, VkImageUsageFlags usage, return false; if (type == VK_IMAGE_TYPE_3D) { - tu_finishme("UBWC with 3D textures"); + if (device) { + perf_debug(device, + "Disabling UBWC for %s 3D image, but it should be " + "possible to support.", + util_format_name(vk_format_to_pipe_format(format))); + } return false; } @@ -310,8 +325,15 @@ ubwc_possible(VkFormat format, VkImageType type, VkImageUsageFlags usage, * UBWC-enabled mipmaps in freedreno currently. Just match the closed GL * behavior of no UBWC. */ - if ((usage | stencil_usage) & VK_IMAGE_USAGE_STORAGE_BIT) + if ((usage | stencil_usage) & VK_IMAGE_USAGE_STORAGE_BIT) { + if (device) { + perf_debug(device, + "Disabling UBWC for %s storage image, but should be " + "possible to support", + util_format_name(vk_format_to_pipe_format(format))); + } return false; + } /* Disable UBWC for D24S8 on A630 in some cases * @@ -332,8 +354,19 @@ ubwc_possible(VkFormat format, VkImageType type, VkImageUsageFlags usage, (stencil_usage & (VK_IMAGE_USAGE_SAMPLED_BIT | VK_IMAGE_USAGE_INPUT_ATTACHMENT_BIT))) return false; - if (!info->a6xx.has_z24uint_s8uint && samples > VK_SAMPLE_COUNT_1_BIT) + /* This meant to disable UBWC for MSAA z24s8, but accidentally disables it + * for all MSAA. https://gitlab.freedesktop.org/mesa/mesa/-/issues/7438 + */ + if (!info->a6xx.has_z24uint_s8uint && samples > VK_SAMPLE_COUNT_1_BIT) { + if (device) { + perf_debug(device, + "Disabling UBWC for %d-sample %s image, but it should be " + "possible to support", + samples, + util_format_name(vk_format_to_pipe_format(format))); + } return false; + } return true; } @@ -421,7 +454,8 @@ tu_image_init(struct tu_device *device, struct tu_image *image, /* Whether a view of the image with an R8G8 format could be made. */ bool has_r8g8 = tu_is_r8g8(format); - if (!ubwc_possible(image->vk.format, pCreateInfo->imageType, + if (ubwc_enabled && + !ubwc_possible(device, image->vk.format, pCreateInfo->imageType, pCreateInfo->usage, image->vk.stencil_usage, device->physical_device->info, pCreateInfo->samples, device->use_z24uint_s8uint)) diff --git a/src/freedreno/vulkan/tu_image.h b/src/freedreno/vulkan/tu_image.h index d76f501d6c4..d877d0eb986 100644 --- a/src/freedreno/vulkan/tu_image.h +++ b/src/freedreno/vulkan/tu_image.h @@ -101,8 +101,13 @@ bool tiling_possible(VkFormat format); bool -ubwc_possible(VkFormat format, VkImageType type, VkImageUsageFlags usage, VkImageUsageFlags stencil_usage, - const struct fd_dev_info *info, VkSampleCountFlagBits samples, +ubwc_possible(struct tu_device *device, + VkFormat format, + VkImageType type, + VkImageUsageFlags usage, + VkImageUsageFlags stencil_usage, + const struct fd_dev_info *info, + VkSampleCountFlagBits samples, bool use_z24uint_s8uint); void