VK_FORMAT_D16_UNORM is mandatory for 2D images, but Talos and
Serious Sam Fusion 2017 can use VK_FORMAT_D32_SFLOAT instead.

This implements some sort of drirc for radv (just based on
the application names).

This improves performance with Talos (73->76FPS) and Serious
Sam 2017 (119->134FPS) because they no longer use any 16bpp
depth surfaces and thus no HTILE decompressions are needed.

Signed-off-by: Samuel Pitoiset <[email protected]>
---
 src/amd/vulkan/radv_device.c  | 17 +++++++++++++++++
 src/amd/vulkan/radv_formats.c | 10 ++++++++++
 src/amd/vulkan/radv_private.h |  2 ++
 3 files changed, 29 insertions(+)

diff --git a/src/amd/vulkan/radv_device.c b/src/amd/vulkan/radv_device.c
index e34b19c648..391ae722bb 100644
--- a/src/amd/vulkan/radv_device.c
+++ b/src/amd/vulkan/radv_device.c
@@ -400,6 +400,23 @@ VkResult radv_CreateInstance(
        instance->perftest_flags = parse_debug_string(getenv("RADV_PERFTEST"),
                                                   radv_perftest_options);
 
+       if (pCreateInfo->pApplicationInfo &&
+           pCreateInfo->pApplicationInfo->pApplicationName) {
+               const char *name =
+                       pCreateInfo->pApplicationInfo->pApplicationName;
+
+               if (!strcmp(name, "Talos - Linux - 64bit") ||
+                   !strcmp(name, "Serious Sam Fusion 2017 - Linux - 64bit")) {
+                       /* Although, VK_FORMAT_D16_UNORM is mandatory for
+                        * VK_IMAGE_TYPE_2D, Talos and Serious Sam Fusion 2017
+                        * can use VK_FORMAT_D32_SFLOAT when D16_UNORM is not
+                        * supported. This improves performance on VI because
+                        * TC compatible HTILE only supports D32_SFLOAT.
+                        */
+                       instance->disable_d16_unorm_format = true;
+               }
+       }
+
        *pInstance = radv_instance_to_handle(instance);
 
        return VK_SUCCESS;
diff --git a/src/amd/vulkan/radv_formats.c b/src/amd/vulkan/radv_formats.c
index 5c79ea7406..2adb20254a 100644
--- a/src/amd/vulkan/radv_formats.c
+++ b/src/amd/vulkan/radv_formats.c
@@ -1122,6 +1122,16 @@ static VkResult radv_get_image_format_properties(struct 
radv_physical_device *ph
                }
        }
 
+       if (info->format == VK_FORMAT_D16_UNORM &&
+           physical_device->instance->disable_d16_unorm_format &&
+           physical_device->rad_info.chip_class == VI) {
+               /* Do not advertise D16_UNORM on VI because TC compatible HTILE
+                * only supports D32_SFLOAT (GFX9 supports both), and HTILE
+                * decompressions are costly.
+                */
+               goto unsupported;
+       }
+
        *pImageFormatProperties = (VkImageFormatProperties) {
                .maxExtent = maxExtent,
                .maxMipLevels = maxMipLevels,
diff --git a/src/amd/vulkan/radv_private.h b/src/amd/vulkan/radv_private.h
index 83965b41b2..2835bc03ea 100644
--- a/src/amd/vulkan/radv_private.h
+++ b/src/amd/vulkan/radv_private.h
@@ -298,6 +298,8 @@ struct radv_instance {
 
        uint64_t debug_flags;
        uint64_t perftest_flags;
+
+       bool disable_d16_unorm_format;
 };
 
 VkResult radv_init_wsi(struct radv_physical_device *physical_device);
-- 
2.15.0

_______________________________________________
mesa-dev mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/mesa-dev

Reply via email to