@@ -255,21 +255,6 @@ static void list_context_extensions(int client, int major, int minor)
255
255
}
256
256
}
257
257
258
- static void list_vulkan_instance_extensions (void )
259
- {
260
- printf ("Vulkan instance extensions:\n" );
261
-
262
- uint32_t ep_count ;
263
- vkEnumerateInstanceExtensionProperties (NULL , & ep_count , NULL );
264
- VkExtensionProperties * ep = calloc (ep_count , sizeof (VkExtensionProperties ));
265
- vkEnumerateInstanceExtensionProperties (NULL , & ep_count , ep );
266
-
267
- for (uint32_t i = 0 ; i < ep_count ; i ++ )
268
- printf (" %s (spec version %u)\n" , ep [i ].extensionName , ep [i ].specVersion );
269
-
270
- free (ep );
271
- }
272
-
273
258
static void list_vulkan_instance_layers (void )
274
259
{
275
260
printf ("Vulkan instance layers:\n" );
@@ -290,21 +275,6 @@ static void list_vulkan_instance_layers(void)
290
275
free (lp );
291
276
}
292
277
293
- static void list_vulkan_device_extensions (VkInstance instance , VkPhysicalDevice device )
294
- {
295
- printf ("Vulkan device extensions:\n" );
296
-
297
- uint32_t ep_count ;
298
- vkEnumerateDeviceExtensionProperties (device , NULL , & ep_count , NULL );
299
- VkExtensionProperties * ep = calloc (ep_count , sizeof (VkExtensionProperties ));
300
- vkEnumerateDeviceExtensionProperties (device , NULL , & ep_count , ep );
301
-
302
- for (uint32_t i = 0 ; i < ep_count ; i ++ )
303
- printf (" %s (spec version %u)\n" , ep [i ].extensionName , ep [i ].specVersion );
304
-
305
- free (ep );
306
- }
307
-
308
278
static void list_vulkan_device_layers (VkInstance instance , VkPhysicalDevice device )
309
279
{
310
280
printf ("Vulkan device layers:\n" );
@@ -953,20 +923,51 @@ int main(int argc, char** argv)
953
923
VK_VERSION_MAJOR (loader_version ),
954
924
VK_VERSION_MINOR (loader_version ));
955
925
956
- uint32_t re_count ;
957
- const char * * re = glfwGetRequiredInstanceExtensions (& re_count );
926
+ uint32_t glfw_re_count ;
927
+ const char * * glfw_re = glfwGetRequiredInstanceExtensions (& glfw_re_count );
928
+
929
+ uint32_t re_count = glfw_re_count ;
930
+ const char * * re = calloc (glfw_re_count , sizeof (char * ));
958
931
959
- if (re )
932
+ if (glfw_re )
960
933
{
961
934
printf ("Vulkan window surface required instance extensions:\n" );
962
- for (uint32_t i = 0 ; i < re_count ; i ++ )
963
- printf (" %s\n" , re [i ]);
935
+ for (uint32_t i = 0 ; i < glfw_re_count ; i ++ )
936
+ {
937
+ printf (" %s\n" , glfw_re [i ]);
938
+ re [i ] = glfw_re [i ];
939
+ }
964
940
}
965
941
else
966
942
printf ("Vulkan window surface extensions missing\n" );
967
943
944
+ uint32_t ep_count ;
945
+ vkEnumerateInstanceExtensionProperties (NULL , & ep_count , NULL );
946
+ VkExtensionProperties * ep = calloc (ep_count , sizeof (VkExtensionProperties ));
947
+ vkEnumerateInstanceExtensionProperties (NULL , & ep_count , ep );
948
+
968
949
if (list_extensions )
969
- list_vulkan_instance_extensions ();
950
+ {
951
+ printf ("Vulkan instance extensions:\n" );
952
+
953
+ for (uint32_t i = 0 ; i < ep_count ; i ++ )
954
+ printf (" %s (spec version %u)\n" , ep [i ].extensionName , ep [i ].specVersion );
955
+ }
956
+
957
+ bool portability_enumeration = false;
958
+
959
+ for (uint32_t i = 0 ; i < ep_count ; i ++ )
960
+ {
961
+ if (strcmp (ep [i ].extensionName , "VK_KHR_portability_enumeration" ) != 0 )
962
+ continue ;
963
+
964
+ re_count ++ ;
965
+ re = realloc (re , sizeof (char * ) * re_count );
966
+ re [re_count - 1 ] = "VK_KHR_portability_enumeration" ;
967
+ portability_enumeration = true;
968
+ }
969
+
970
+ free (ep );
970
971
971
972
if (list_layers )
972
973
list_vulkan_instance_layers ();
@@ -987,6 +988,9 @@ int main(int argc, char** argv)
987
988
ici .enabledExtensionCount = re_count ;
988
989
ici .ppEnabledExtensionNames = re ;
989
990
991
+ if (portability_enumeration )
992
+ ici .flags |= VK_INSTANCE_CREATE_ENUMERATE_PORTABILITY_BIT_KHR ;
993
+
990
994
VkInstance instance = VK_NULL_HANDLE ;
991
995
992
996
if (vkCreateInstance (& ici , NULL , & instance ) != VK_SUCCESS )
@@ -995,9 +999,11 @@ int main(int argc, char** argv)
995
999
exit (EXIT_FAILURE );
996
1000
}
997
1001
1002
+ free (re );
1003
+
998
1004
gladLoadVulkanUserPtr (NULL , (GLADuserptrloadfunc ) glfwGetInstanceProcAddress , instance );
999
1005
1000
- if (re )
1006
+ if (glfw_re_count )
1001
1007
{
1002
1008
VkSurfaceKHR surface = VK_NULL_HANDLE ;
1003
1009
@@ -1020,16 +1026,44 @@ int main(int argc, char** argv)
1020
1026
VkPhysicalDeviceProperties pdp ;
1021
1027
vkGetPhysicalDeviceProperties (pd [i ], & pdp );
1022
1028
1023
- printf ("Vulkan %s device: \"%s\" (API version %i.%i)\n" ,
1024
- get_device_type_name (pdp .deviceType ),
1025
- pdp .deviceName ,
1026
- VK_VERSION_MAJOR (pdp .apiVersion ),
1027
- VK_VERSION_MINOR (pdp .apiVersion ));
1028
-
1029
1029
uint32_t qfp_count ;
1030
1030
vkGetPhysicalDeviceQueueFamilyProperties (pd [i ], & qfp_count , NULL );
1031
1031
1032
- if (re )
1032
+ uint32_t ep_count ;
1033
+ vkEnumerateDeviceExtensionProperties (pd [i ], NULL , & ep_count , NULL );
1034
+ VkExtensionProperties * ep = calloc (ep_count , sizeof (VkExtensionProperties ));
1035
+ vkEnumerateDeviceExtensionProperties (pd [i ], NULL , & ep_count , ep );
1036
+
1037
+ if (portability_enumeration )
1038
+ {
1039
+ bool conformant = true;
1040
+
1041
+ for (uint32_t j = 0 ; j < ep_count ; j ++ )
1042
+ {
1043
+ if (strcmp (ep [j ].extensionName , "VK_KHR_portability_subset" ) == 0 )
1044
+ {
1045
+ conformant = false;
1046
+ break ;
1047
+ }
1048
+ }
1049
+
1050
+ printf ("Vulkan %s %s device: \"%s\" (API version %i.%i)\n" ,
1051
+ conformant ? "conformant" : "non-conformant" ,
1052
+ get_device_type_name (pdp .deviceType ),
1053
+ pdp .deviceName ,
1054
+ VK_VERSION_MAJOR (pdp .apiVersion ),
1055
+ VK_VERSION_MINOR (pdp .apiVersion ));
1056
+ }
1057
+ else
1058
+ {
1059
+ printf ("Vulkan %s device: \"%s\" (API version %i.%i)\n" ,
1060
+ get_device_type_name (pdp .deviceType ),
1061
+ pdp .deviceName ,
1062
+ VK_VERSION_MAJOR (pdp .apiVersion ),
1063
+ VK_VERSION_MINOR (pdp .apiVersion ));
1064
+ }
1065
+
1066
+ if (glfw_re_count )
1033
1067
{
1034
1068
printf ("Vulkan device queue family presentation support:\n" );
1035
1069
for (uint32_t j = 0 ; j < qfp_count ; j ++ )
@@ -1043,7 +1077,13 @@ int main(int argc, char** argv)
1043
1077
}
1044
1078
1045
1079
if (list_extensions )
1046
- list_vulkan_device_extensions (instance , pd [i ]);
1080
+ {
1081
+ printf ("Vulkan device extensions:\n" );
1082
+ for (uint32_t j = 0 ; j < ep_count ; j ++ )
1083
+ printf (" %s (spec version %u)\n" , ep [j ].extensionName , ep [j ].specVersion );
1084
+ }
1085
+
1086
+ free (ep );
1047
1087
1048
1088
if (list_layers )
1049
1089
list_vulkan_device_layers (instance , pd [i ]);
0 commit comments