radv: Add support for more DCC compression with VK_KHR_image_format_list.
authorBas Nieuwenhuizen <bas@basnieuwenhuizen.nl>
Fri, 15 Sep 2017 22:30:18 +0000 (00:30 +0200)
committerBas Nieuwenhuizen <bas@basnieuwenhuizen.nl>
Sat, 16 Sep 2017 09:55:56 +0000 (11:55 +0200)
Reviewed-by: Dave Airlie <airlied@redhat.com>
src/amd/vulkan/radv_device.c
src/amd/vulkan/radv_image.c

index c112453e395d668e88d3d3db0a92ea691685343c..e6d595dfbe5e33a45cf597c83fa44136112de69e 100644 (file)
@@ -170,6 +170,10 @@ static const VkExtensionProperties common_device_extensions[] = {
                .extensionName = VK_KHR_VARIABLE_POINTERS_EXTENSION_NAME,
                .specVersion = 1,
        },
+       {
+               .extensionName = VK_KHR_IMAGE_FORMAT_LIST_EXTENSION_NAME,
+               .specVersion = 1,
+       },
 };
 static const VkExtensionProperties ext_sema_device_extensions[] = {
        {
index 9c04d7ecca54c6133034e5914a3d14439f91853d..aeec5ce8822e163056b747850cd4111c3073f4cb 100644 (file)
@@ -116,14 +116,32 @@ radv_init_surface(struct radv_device *device,
 
        surface->flags |= RADEON_SURF_OPTIMIZE_FOR_SPACE;
 
+       bool dcc_compatible_formats = !radv_is_colorbuffer_format_supported(pCreateInfo->format, &blendable);
+       if (pCreateInfo->flags & VK_IMAGE_CREATE_MUTABLE_FORMAT_BIT) {
+               const struct  VkImageFormatListCreateInfoKHR *format_list =
+                         (const struct  VkImageFormatListCreateInfoKHR *)
+                               vk_find_struct_const(pCreateInfo->pNext,
+                                                    IMAGE_FORMAT_LIST_CREATE_INFO_KHR);
+               if (format_list) {
+                       /* compatibility is transitive, so we only need to check
+                        * one format with everything else. */
+                       for (unsigned i = 0; i < format_list->viewFormatCount; ++i) {
+                               if (!radv_dcc_formats_compatible(pCreateInfo->format,
+                                                                format_list->pViewFormats[i]))
+                                       dcc_compatible_formats = false;
+                       }
+               } else {
+                       dcc_compatible_formats = false;
+               }
+       }
+
        if ((pCreateInfo->usage & (VK_IMAGE_USAGE_TRANSFER_SRC_BIT |
                                   VK_IMAGE_USAGE_STORAGE_BIT)) ||
-           (pCreateInfo->flags & VK_IMAGE_CREATE_MUTABLE_FORMAT_BIT) ||
+           !dcc_compatible_formats ||
             (pCreateInfo->tiling == VK_IMAGE_TILING_LINEAR) ||
             pCreateInfo->mipLevels > 1 || pCreateInfo->arrayLayers > 1 ||
             device->physical_device->rad_info.chip_class < VI ||
-            create_info->scanout || (device->debug_flags & RADV_DEBUG_NO_DCC) ||
-            !radv_is_colorbuffer_format_supported(pCreateInfo->format, &blendable))
+            create_info->scanout || (device->debug_flags & RADV_DEBUG_NO_DCC))
                surface->flags |= RADEON_SURF_DISABLE_DCC;
        if (create_info->scanout)
                surface->flags |= RADEON_SURF_SCANOUT;