From 09c4a911e5a1aa1970b96b3dbba3585be616559d Mon Sep 17 00:00:00 2001 From: Bas Nieuwenhuizen Date: Sun, 15 Jul 2018 20:09:28 +0200 Subject: [PATCH] radv: Add logic for subsampled format descriptions. Reviewed-by: Samuel Pitoiset --- src/amd/vulkan/radv_formats.c | 12 ++++++++++++ src/amd/vulkan/radv_image.c | 3 +++ src/amd/vulkan/vk_format.h | 13 +++++++++++++ 3 files changed, 28 insertions(+) diff --git a/src/amd/vulkan/radv_formats.c b/src/amd/vulkan/radv_formats.c index 0a3ff9ebbd9..773600b7f5d 100644 --- a/src/amd/vulkan/radv_formats.c +++ b/src/amd/vulkan/radv_formats.c @@ -180,6 +180,18 @@ uint32_t radv_translate_tex_dataformat(VkFormat format, break; } + if (desc->layout == VK_FORMAT_LAYOUT_SUBSAMPLED) { + switch(format) { + /* Don't ask me why this looks inverted. PAL does the same. */ + case VK_FORMAT_G8B8G8R8_422_UNORM: + return V_008F14_IMG_DATA_FORMAT_BG_RG; + case VK_FORMAT_B8G8R8G8_422_UNORM: + return V_008F14_IMG_DATA_FORMAT_GB_GR; + default: + goto out_unknown; + } + } + if (desc->layout == VK_FORMAT_LAYOUT_RGTC) { switch(format) { case VK_FORMAT_BC4_UNORM_BLOCK: diff --git a/src/amd/vulkan/radv_image.c b/src/amd/vulkan/radv_image.c index dba8c1f4502..6fea8f911d3 100644 --- a/src/amd/vulkan/radv_image.c +++ b/src/amd/vulkan/radv_image.c @@ -149,6 +149,9 @@ radv_use_dcc_for_image(struct radv_device *device, if (pCreateInfo->tiling == VK_IMAGE_TILING_LINEAR) return false; + if (vk_format_is_subsampled(pCreateInfo->format)) + return false; + /* TODO: Enable DCC for mipmaps and array layers. */ if (pCreateInfo->mipLevels > 1 || pCreateInfo->arrayLayers > 1) return false; diff --git a/src/amd/vulkan/vk_format.h b/src/amd/vulkan/vk_format.h index 933db4d961c..e89896c8969 100644 --- a/src/amd/vulkan/vk_format.h +++ b/src/amd/vulkan/vk_format.h @@ -325,6 +325,19 @@ vk_format_is_compressed(VkFormat format) } } +static inline bool +vk_format_is_subsampled(VkFormat format) +{ + const struct vk_format_description *desc = vk_format_description(format); + + assert(desc); + if (!desc) { + return false; + } + + return desc->layout == VK_FORMAT_LAYOUT_SUBSAMPLED; +} + static inline bool vk_format_has_depth(const struct vk_format_description *desc) { -- 2.30.2