turnip: implement VK_EXT_filter_cubic
authorJonathan Marek <jonathan@marek.ca>
Wed, 22 Apr 2020 02:01:03 +0000 (22:01 -0400)
committerMarge Bot <eric+marge@anholt.net>
Wed, 22 Apr 2020 19:03:58 +0000 (19:03 +0000)
Signed-off-by: Jonathan Marek <jonathan@marek.ca>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/4672>

src/freedreno/registers/a6xx.xml
src/freedreno/vulkan/tu_device.c
src/freedreno/vulkan/tu_extensions.py
src/freedreno/vulkan/tu_formats.c

index a2bda8aee1049bfe2a297b6013173a2051794520..5d6ddcf1785099e62534f1172b7130223526cef3 100644 (file)
@@ -3291,6 +3291,7 @@ to upconvert to 32b float internally?
                <value name="A6XX_TEX_NEAREST" value="0"/>
                <value name="A6XX_TEX_LINEAR" value="1"/>
                <value name="A6XX_TEX_ANISO" value="2"/>
+               <value name="A6XX_TEX_CUBIC" value="3"/> <!-- a650 only -->
        </enum>
        <enum name="a6xx_tex_clamp"> <!-- same as a4xx? -->
                <value name="A6XX_TEX_REPEAT" value="0"/>
index 73c264417eb4d8c7c4334538d1404fe08f674dff..77794eb3733e20c825a9fd95ffb8a08f11409417 100644 (file)
@@ -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;
index 498b38613b69148c764922a0030c2ad6cba67c24..e003ea7025285393ca47901ff16c89649f5434d6 100644 (file)
@@ -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:
index d4100760032cacadb85fe2b3bc5c8181458d6254..3195baca6c4ed369bb9ce4db1fb2adbcf387a563 100644 (file)
@@ -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: