From 9daeb504543ccf3851ed058a860ada7d84de6f22 Mon Sep 17 00:00:00 2001 From: Jonathan Marek Date: Tue, 21 Apr 2020 22:01:03 -0400 Subject: [PATCH] turnip: implement VK_EXT_filter_cubic Signed-off-by: Jonathan Marek Part-of: --- src/freedreno/registers/a6xx.xml | 1 + src/freedreno/vulkan/tu_device.c | 3 +- src/freedreno/vulkan/tu_extensions.py | 2 ++ src/freedreno/vulkan/tu_formats.c | 40 +++++++++++++++++++++++---- 4 files changed, 40 insertions(+), 6 deletions(-) diff --git a/src/freedreno/registers/a6xx.xml b/src/freedreno/registers/a6xx.xml index a2bda8aee10..5d6ddcf1785 100644 --- a/src/freedreno/registers/a6xx.xml +++ b/src/freedreno/registers/a6xx.xml @@ -3291,6 +3291,7 @@ to upconvert to 32b float internally? + diff --git a/src/freedreno/vulkan/tu_device.c b/src/freedreno/vulkan/tu_device.c index 73c264417eb..77794eb3733 100644 --- a/src/freedreno/vulkan/tu_device.c +++ b/src/freedreno/vulkan/tu_device.c @@ -2093,7 +2093,8 @@ tu6_tex_filter(VkFilter filter, unsigned aniso) return A6XX_TEX_NEAREST; case VK_FILTER_LINEAR: return aniso ? A6XX_TEX_ANISO : A6XX_TEX_LINEAR; - case VK_FILTER_CUBIC_IMG: + case VK_FILTER_CUBIC_EXT: + return A6XX_TEX_CUBIC; default: unreachable("illegal texture filter"); break; diff --git a/src/freedreno/vulkan/tu_extensions.py b/src/freedreno/vulkan/tu_extensions.py index 498b38613b6..e003ea70252 100644 --- a/src/freedreno/vulkan/tu_extensions.py +++ b/src/freedreno/vulkan/tu_extensions.py @@ -82,6 +82,8 @@ EXTENSIONS = [ Extension('VK_ANDROID_native_buffer', 1, True), Extension('VK_KHR_external_semaphore_fd', 1, True), Extension('VK_KHR_external_fence_fd', 1, True), + Extension('VK_IMG_filter_cubic', 1, 'device->gpu_id == 650'), + Extension('VK_EXT_filter_cubic', 1, 'device->gpu_id == 650'), ] class VkVersion: diff --git a/src/freedreno/vulkan/tu_formats.c b/src/freedreno/vulkan/tu_formats.c index d4100760032..3195baca6c4 100644 --- a/src/freedreno/vulkan/tu_formats.c +++ b/src/freedreno/vulkan/tu_formats.c @@ -384,6 +384,9 @@ tu_physical_device_get_format_properties( VK_FORMAT_FEATURE_SAMPLED_IMAGE_BIT | VK_FORMAT_FEATURE_SAMPLED_IMAGE_FILTER_LINEAR_BIT; buffer |= VK_FORMAT_FEATURE_UNIFORM_TEXEL_BUFFER_BIT; + + if (physical_device->supported_extensions.EXT_filter_cubic) + optimal |= VK_FORMAT_FEATURE_SAMPLED_IMAGE_FILTER_CUBIC_BIT_EXT; } if (native_fmt.supported & FMT_COLOR) { @@ -457,8 +460,8 @@ static VkResult tu_get_image_format_properties( struct tu_physical_device *physical_device, const VkPhysicalDeviceImageFormatInfo2 *info, - VkImageFormatProperties *pImageFormatProperties) - + VkImageFormatProperties *pImageFormatProperties, + VkFormatFeatureFlags *p_feature_flags) { VkFormatProperties format_props; VkFormatFeatureFlags format_feature_flags; @@ -580,6 +583,9 @@ tu_get_image_format_properties( .maxResourceSize = UINT32_MAX, }; + if (p_feature_flags) + *p_feature_flags = format_feature_flags; + return VK_SUCCESS; unsupported: *pImageFormatProperties = (VkImageFormatProperties) { @@ -616,7 +622,7 @@ tu_GetPhysicalDeviceImageFormatProperties( }; return tu_get_image_format_properties(physical_device, &info, - pImageFormatProperties); + pImageFormatProperties, NULL); } static VkResult @@ -683,11 +689,14 @@ tu_GetPhysicalDeviceImageFormatProperties2( { TU_FROM_HANDLE(tu_physical_device, physical_device, physicalDevice); const VkPhysicalDeviceExternalImageFormatInfo *external_info = NULL; + const VkPhysicalDeviceImageViewImageFormatInfoEXT *image_view_info = NULL; VkExternalImageFormatProperties *external_props = NULL; + VkFilterCubicImageViewImageFormatPropertiesEXT *cubic_props = NULL; + VkFormatFeatureFlags format_feature_flags; VkResult result; - result = tu_get_image_format_properties( - physical_device, base_info, &base_props->imageFormatProperties); + result = tu_get_image_format_properties(physical_device, + base_info, &base_props->imageFormatProperties, &format_feature_flags); if (result != VK_SUCCESS) return result; @@ -698,6 +707,9 @@ tu_GetPhysicalDeviceImageFormatProperties2( case VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_EXTERNAL_IMAGE_FORMAT_INFO: external_info = (const void *) s; break; + case VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_IMAGE_VIEW_IMAGE_FORMAT_INFO_EXT: + image_view_info = (const void *) s; + break; default: break; } @@ -710,6 +722,9 @@ tu_GetPhysicalDeviceImageFormatProperties2( case VK_STRUCTURE_TYPE_EXTERNAL_IMAGE_FORMAT_PROPERTIES: external_props = (void *) s; break; + case VK_STRUCTURE_TYPE_FILTER_CUBIC_IMAGE_VIEW_IMAGE_FORMAT_PROPERTIES_EXT: + cubic_props = (void *) s; + break; default: break; } @@ -729,6 +744,21 @@ tu_GetPhysicalDeviceImageFormatProperties2( goto fail; } + if (cubic_props) { + /* note: blob only allows cubic filtering for 2D and 2D array views + * its likely we can enable it for 1D and CUBE, needs testing however + */ + if ((image_view_info->imageViewType == VK_IMAGE_VIEW_TYPE_2D || + image_view_info->imageViewType == VK_IMAGE_VIEW_TYPE_2D_ARRAY) && + (format_feature_flags & VK_FORMAT_FEATURE_SAMPLED_IMAGE_FILTER_CUBIC_BIT_EXT)) { + cubic_props->filterCubic = true; + cubic_props->filterCubicMinmax = true; + } else { + cubic_props->filterCubic = false; + cubic_props->filterCubicMinmax = false; + } + } + return VK_SUCCESS; fail: -- 2.30.2