summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorSamuel Pitoiset <[email protected]>2018-09-28 15:05:24 +0200
committerSamuel Pitoiset <[email protected]>2018-10-01 12:13:09 +0200
commitf622ab889ae911704eb659909ac9723c312bdb20 (patch)
tree8455b538857a21ea2f91a5734803d04a591bb47c /src
parentdc91c4d40acaf5a8ea72e9c0c25eceafc89e9c42 (diff)
radv: add a sanity check for mutable formats and TC-compat HTILE
If apps use the MUTABLE bit and the same formats as the image one in the list, we can still enable TC-compat HTILE. I don't think this happens often but given the fact that TC-compat HTILE allows a nice boost in some situations, it's worth checking. Signed-off-by: Samuel Pitoiset <[email protected]> Reviewed-by: Bas Nieuwenhuizen <[email protected]>
Diffstat (limited to 'src')
-rw-r--r--src/amd/vulkan/radv_image.c27
1 files changed, 22 insertions, 5 deletions
diff --git a/src/amd/vulkan/radv_image.c b/src/amd/vulkan/radv_image.c
index 65a62fb991a..64346aa340f 100644
--- a/src/amd/vulkan/radv_image.c
+++ b/src/amd/vulkan/radv_image.c
@@ -72,11 +72,8 @@ radv_use_tc_compat_htile_for_image(struct radv_device *device,
if (device->physical_device->rad_info.chip_class < VI)
return false;
- if (pCreateInfo->usage & VK_IMAGE_USAGE_STORAGE_BIT)
- return false;
-
- if (pCreateInfo->flags & (VK_IMAGE_CREATE_MUTABLE_FORMAT_BIT |
- VK_IMAGE_CREATE_EXTENDED_USAGE_BIT_KHR))
+ if ((pCreateInfo->usage & VK_IMAGE_USAGE_STORAGE_BIT) ||
+ (pCreateInfo->flags & VK_IMAGE_CREATE_EXTENDED_USAGE_BIT_KHR))
return false;
if (pCreateInfo->tiling == VK_IMAGE_TILING_LINEAR)
@@ -100,6 +97,26 @@ radv_use_tc_compat_htile_for_image(struct radv_device *device,
pCreateInfo->format != VK_FORMAT_D16_UNORM)
return false;
+ 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);
+
+ /* We have to ignore the existence of the list if viewFormatCount = 0 */
+ if (format_list && format_list->viewFormatCount) {
+ /* compatibility is transitive, so we only need to check
+ * one format with everything else.
+ */
+ for (unsigned i = 0; i < format_list->viewFormatCount; ++i) {
+ if (pCreateInfo->format != format_list->pViewFormats[i])
+ return false;
+ }
+ } else {
+ return false;
+ }
+ }
+
return true;
}