anv: Remove anv_physical_device_get_format_properties()
[mesa.git] / src / intel / vulkan / anv_formats.c
index 3c946308895cf5fb16f4ecc79331cd3030606bd5..25d34fcadc1bd7beb4198487155dde64279f82aa 100644 (file)
@@ -467,10 +467,10 @@ anv_get_format_plane(const struct gen_device_info *devinfo, VkFormat vk_format,
 // Format capabilities
 
 static VkFormatFeatureFlags
-get_image_format_properties(const struct gen_device_info *devinfo,
-                            VkFormat vk_format,
-                            const struct anv_format *anv_format,
-                            VkImageTiling vk_tiling)
+get_image_format_features(const struct gen_device_info *devinfo,
+                          VkFormat vk_format,
+                          const struct anv_format *anv_format,
+                          VkImageTiling vk_tiling)
 {
    VkFormatFeatureFlags flags = 0;
 
@@ -612,9 +612,9 @@ get_image_format_properties(const struct gen_device_info *devinfo,
 }
 
 static VkFormatFeatureFlags
-get_buffer_format_properties(const struct gen_device_info *devinfo,
-                             VkFormat vk_format,
-                             const struct anv_format *anv_format)
+get_buffer_format_features(const struct gen_device_info *devinfo,
+                           VkFormat vk_format,
+                           const struct anv_format *anv_format)
 {
    VkFormatFeatureFlags flags = 0;
 
@@ -651,42 +651,25 @@ get_buffer_format_properties(const struct gen_device_info *devinfo,
    return flags;
 }
 
-static void
-anv_physical_device_get_format_properties(struct anv_physical_device *physical_device,
-                                          VkFormat vk_format,
-                                          VkFormatProperties *out_properties)
-{
-   const struct gen_device_info *devinfo = &physical_device->info;
-   const struct anv_format *format = anv_get_format(vk_format);
-   VkFormatFeatureFlags linear = 0, tiled = 0;
-
-   if (format == NULL) {
-      /* Nothing to do here */
-   } else {
-      linear = get_image_format_properties(&physical_device->info, vk_format,
-                                           format, VK_IMAGE_TILING_LINEAR);
-      tiled = get_image_format_properties(&physical_device->info, vk_format,
-                                          format, VK_IMAGE_TILING_OPTIMAL);
-   }
-
-   out_properties->linearTilingFeatures = linear;
-   out_properties->optimalTilingFeatures = tiled;
-   out_properties->bufferFeatures =
-     get_buffer_format_properties(devinfo, vk_format, format);
-}
-
-
 void anv_GetPhysicalDeviceFormatProperties(
     VkPhysicalDevice                            physicalDevice,
-    VkFormat                                    format,
+    VkFormat                                    vk_format,
     VkFormatProperties*                         pFormatProperties)
 {
    ANV_FROM_HANDLE(anv_physical_device, physical_device, physicalDevice);
-
-   anv_physical_device_get_format_properties(
-               physical_device,
-               format,
-               pFormatProperties);
+   const struct gen_device_info *devinfo = &physical_device->info;
+   const struct anv_format *anv_format = anv_get_format(vk_format);
+
+   *pFormatProperties = (VkFormatProperties) {
+      .linearTilingFeatures =
+         get_image_format_features(devinfo, vk_format, anv_format,
+                                   VK_IMAGE_TILING_LINEAR),
+      .optimalTilingFeatures =
+         get_image_format_features(devinfo, vk_format, anv_format,
+                                   VK_IMAGE_TILING_OPTIMAL),
+      .bufferFeatures =
+         get_buffer_format_features(devinfo, vk_format, anv_format),
+   };
 }
 
 void anv_GetPhysicalDeviceFormatProperties2KHR(
@@ -713,30 +696,19 @@ anv_get_image_format_properties(
    VkImageFormatProperties *pImageFormatProperties,
    VkSamplerYcbcrConversionImageFormatPropertiesKHR *pYcbcrImageFormatProperties)
 {
-   VkFormatProperties format_props;
    VkFormatFeatureFlags format_feature_flags;
    VkExtent3D maxExtent;
    uint32_t maxMipLevels;
    uint32_t maxArraySize;
    VkSampleCountFlags sampleCounts = VK_SAMPLE_COUNT_1_BIT;
+   const struct gen_device_info *devinfo = &physical_device->info;
    const struct anv_format *format = anv_get_format(info->format);
 
    if (format == NULL)
       goto unsupported;
 
-   anv_physical_device_get_format_properties(physical_device, info->format,
-                                             &format_props);
-
-   /* Extract the VkFormatFeatureFlags that are relevant for the queried
-    * tiling.
-    */
-   if (info->tiling == VK_IMAGE_TILING_LINEAR) {
-      format_feature_flags = format_props.linearTilingFeatures;
-   } else if (info->tiling == VK_IMAGE_TILING_OPTIMAL) {
-      format_feature_flags = format_props.optimalTilingFeatures;
-   } else {
-      unreachable("bad VkImageTiling");
-   }
+   format_feature_flags = get_image_format_features(devinfo, info->format,
+                                                    format, info->tiling);
 
    switch (info->type) {
    default: