vulkan: put interesting code before boring code
authorConstantine Shablya <constantine.shablya@collabora.com>
Fri, 7 Apr 2023 01:00:52 +0000 (04:00 +0300)
committerMarge Bot <emma+marge@anholt.net>
Wed, 3 May 2023 03:27:54 +0000 (03:27 +0000)
Reviewed-by: Faith Ekstrand <faith.ekstrand@collabora.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/22333>

src/vulkan/util/vk_physical_device_features.py

index a971341..53a61ff 100644 (file)
@@ -236,14 +236,32 @@ vk_physical_device_check_device_features(struct vk_physical_device *physical_dev
    return VK_SUCCESS;
 }
 
-void
-vk_set_physical_device_features_1_0(struct vk_features *all_features,
-                                    const VkPhysicalDeviceFeatures *pFeatures)
+VKAPI_ATTR void VKAPI_CALL
+vk_common_GetPhysicalDeviceFeatures2(VkPhysicalDevice physicalDevice,
+                                     VkPhysicalDeviceFeatures2 *pFeatures)
 {
+   VK_FROM_HANDLE(vk_physical_device, pdevice, physicalDevice);
+
 % for flag in pdev_features:
-   if (pFeatures->${flag})
-      all_features->${flag} = true;
+   pFeatures->features.${flag} = pdevice->supported_features.${flag};
+% endfor
+
+   vk_foreach_struct(ext, pFeatures) {
+      switch (ext->sType) {
+% for f in feature_structs:
+      case ${f.s_type}: {
+         ${f.c_type} *features = (void *) ext;
+% for flag in f.features:
+         features->${flag} = pdevice->supported_features.${get_renamed_feature(f.c_type, flag)};
+% endfor
+         break;
+      }
+
 % endfor
+      default:
+         break;
+      }
+   }
 }
 
 void
@@ -275,32 +293,14 @@ vk_set_physical_device_features(struct vk_features *all_features,
    }
 }
 
-VKAPI_ATTR void VKAPI_CALL
-vk_common_GetPhysicalDeviceFeatures2(VkPhysicalDevice physicalDevice,
-                                     VkPhysicalDeviceFeatures2 *pFeatures)
+void
+vk_set_physical_device_features_1_0(struct vk_features *all_features,
+                                    const VkPhysicalDeviceFeatures *pFeatures)
 {
-   VK_FROM_HANDLE(vk_physical_device, pdevice, physicalDevice);
-
 % for flag in pdev_features:
-   pFeatures->features.${flag} = pdevice->supported_features.${flag};
-% endfor
-
-   vk_foreach_struct(ext, pFeatures) {
-      switch (ext->sType) {
-% for f in feature_structs:
-      case ${f.s_type}: {
-         ${f.c_type} *features = (void *) ext;
-% for flag in f.features:
-         features->${flag} = pdevice->supported_features.${get_renamed_feature(f.c_type, flag)};
-% endfor
-         break;
-      }
-
+   if (pFeatures->${flag})
+      all_features->${flag} = true;
 % endfor
-      default:
-         break;
-      }
-   }
 }
 """, output_encoding='utf-8')
 
@@ -320,13 +320,13 @@ struct vk_features {
 };
 
 void
-vk_set_physical_device_features_1_0(struct vk_features *all_features,
-                                    const VkPhysicalDeviceFeatures *pFeatures);
-
-void
 vk_set_physical_device_features(struct vk_features *all_features,
                                 const VkPhysicalDeviceFeatures2 *pFeatures);
 
+void
+vk_set_physical_device_features_1_0(struct vk_features *all_features,
+                                    const VkPhysicalDeviceFeatures *pFeatures);
+
 #ifdef __cplusplus
 }
 #endif