inspector: List all Vulkan extensions and layers

Same as for GL.
This commit is contained in:
Matthias Clasen
2024-10-24 22:05:41 -04:00
parent 9adc09bc0b
commit d40be28ff4
2 changed files with 139 additions and 100 deletions

View File

@@ -98,9 +98,9 @@ struct _GtkInspectorGeneral
GtkStringList *egl_extensions_list;
GtkWidget *vulkan_box;
GtkWidget *vulkan_extensions_row;
GtkWidget *vulkan_extensions_box;
GtkStringList *vulkan_extensions_list;
GtkWidget *vulkan_layers_row;
GtkWidget *vulkan_layers_box;
GtkStringList *vulkan_layers_list;
GtkWidget *device_box;
GtkWidget *gtk_version;
GtkWidget *gdk_backend;
@@ -470,93 +470,49 @@ init_gl (GtkInspectorGeneral *gen)
#ifdef GDK_RENDERING_VULKAN
static void
add_instance_extensions (GtkInspectorGeneral *gen,
...)
add_instance_extensions (GtkStringList *list)
{
uint32_t i;
uint32_t n_extensions;
VkExtensionProperties *extensions;
va_list args;
const char *name;
vkEnumerateInstanceExtensionProperties (NULL, &n_extensions, NULL);
extensions = g_newa (VkExtensionProperties, n_extensions);
vkEnumerateInstanceExtensionProperties (NULL, &n_extensions, extensions);
va_start (args, gen);
while ((name = va_arg (args, const char *)) != NULL)
{
for (i = 0; i < n_extensions; i++)
{
if (g_str_equal (extensions[i].extensionName, name))
break;
}
add_check_row (gen, GTK_LIST_BOX (gen->vulkan_extensions_box), name, i < n_extensions, 0);
}
va_end (args);
for (i = 0; i < n_extensions; i++)
gtk_string_list_append (list, extensions[i].extensionName);
}
static void
add_device_extensions (GtkInspectorGeneral *gen,
...)
add_device_extensions (VkPhysicalDevice device,
GtkStringList *list)
{
uint32_t i;
uint32_t n_extensions;
VkExtensionProperties *extensions;
va_list args;
const char *name;
vkEnumerateDeviceExtensionProperties (gen->display->vk_physical_device, NULL, &n_extensions, NULL);
vkEnumerateDeviceExtensionProperties (device, NULL, &n_extensions, NULL);
extensions = g_newa (VkExtensionProperties, n_extensions);
vkEnumerateDeviceExtensionProperties (gen->display->vk_physical_device, NULL, &n_extensions, extensions);
vkEnumerateDeviceExtensionProperties (device, NULL, &n_extensions, extensions);
va_start (args, gen);
while ((name = va_arg (args, const char *)) != NULL)
{
for (i = 0; i < n_extensions; i++)
{
if (g_str_equal (extensions[i].extensionName, name))
break;
}
add_check_row (gen, GTK_LIST_BOX (gen->vulkan_extensions_box), name, i < n_extensions, 0);
}
va_end (args);
for (i = 0; i < n_extensions; i++)
gtk_string_list_append (list, extensions[i].extensionName);
}
static gboolean
add_layers (GtkInspectorGeneral *gen,
...)
static void
add_layers (GtkStringList *list)
{
uint32_t i;
uint32_t n_layers;
VkLayerProperties *layers;
va_list args;
const char *name;
vkEnumerateInstanceLayerProperties (&n_layers, NULL);
layers = g_newa (VkLayerProperties, n_layers);
vkEnumerateInstanceLayerProperties (&n_layers, layers);
va_start (args, gen);
while ((name = va_arg (args, const char *)) != NULL)
{
for (i = 0; i < n_layers; i++)
{
if (g_str_equal (layers[i].layerName, "VK_LAYER_KHRONOS_validation"))
break;
}
add_check_row (gen, GTK_LIST_BOX (gen->vulkan_layers_box), name, i < n_layers, 0);
}
return FALSE;
for (i = 0; i < n_layers; i++)
gtk_string_list_append (list, layers[i].layerName);
}
#endif
@@ -602,32 +558,9 @@ init_vulkan (GtkInspectorGeneral *gen)
g_free (api_version);
g_free (driver_version);
add_instance_extensions (gen,
VK_KHR_SURFACE_EXTENSION_NAME,
"VK_KHR_xlib_surface",
"VK_KHR_wayland_surface",
VK_EXT_SURFACE_MAINTENANCE_1_EXTENSION_NAME,
VK_EXT_DEBUG_REPORT_EXTENSION_NAME,
VK_KHR_EXTERNAL_MEMORY_CAPABILITIES_EXTENSION_NAME,
VK_KHR_EXTERNAL_SEMAPHORE_CAPABILITIES_EXTENSION_NAME,
VK_KHR_GET_SURFACE_CAPABILITIES_2_EXTENSION_NAME,
VK_KHR_GET_PHYSICAL_DEVICE_PROPERTIES_2_EXTENSION_NAME,
NULL);
add_device_extensions (gen,
VK_KHR_SWAPCHAIN_EXTENSION_NAME,
VK_KHR_SAMPLER_YCBCR_CONVERSION_EXTENSION_NAME,
VK_KHR_EXTERNAL_MEMORY_FD_EXTENSION_NAME,
VK_EXT_IMAGE_DRM_FORMAT_MODIFIER_EXTENSION_NAME,
VK_EXT_EXTERNAL_MEMORY_DMA_BUF_EXTENSION_NAME,
VK_KHR_EXTERNAL_SEMAPHORE_FD_EXTENSION_NAME,
VK_KHR_INCREMENTAL_PRESENT_EXTENSION_NAME,
VK_EXT_SWAPCHAIN_MAINTENANCE_1_EXTENSION_NAME,
NULL);
add_layers (gen,
"VK_LAYER_KHRONOS_validation",
NULL);
add_instance_extensions (gen->vulkan_extensions_list);
add_device_extensions (gen->display->vk_physical_device, gen->vulkan_extensions_list);
add_layers (gen->vulkan_layers_list);
}
else
#endif
@@ -1325,9 +1258,9 @@ gtk_inspector_general_class_init (GtkInspectorGeneralClass *klass)
gtk_widget_class_bind_template_child (widget_class, GtkInspectorGeneral, egl_extensions_list);
gtk_widget_class_bind_template_child (widget_class, GtkInspectorGeneral, vulkan_box);
gtk_widget_class_bind_template_child (widget_class, GtkInspectorGeneral, vulkan_extensions_row);
gtk_widget_class_bind_template_child (widget_class, GtkInspectorGeneral, vulkan_extensions_box);
gtk_widget_class_bind_template_child (widget_class, GtkInspectorGeneral, vulkan_extensions_list);
gtk_widget_class_bind_template_child (widget_class, GtkInspectorGeneral, vulkan_layers_row);
gtk_widget_class_bind_template_child (widget_class, GtkInspectorGeneral, vulkan_layers_box);
gtk_widget_class_bind_template_child (widget_class, GtkInspectorGeneral, vulkan_layers_list);
gtk_widget_class_bind_template_child (widget_class, GtkInspectorGeneral, gtk_version);
gtk_widget_class_bind_template_child (widget_class, GtkInspectorGeneral, gdk_backend);
gtk_widget_class_bind_template_child (widget_class, GtkInspectorGeneral, gsk_renderer);

View File

@@ -1082,13 +1082,56 @@
</object>
</property>
<child>
<object class="GtkListBox" id="vulkan_layers_box">
<object class="GtkBox">
<property name="margin-top">20</property>
<property name="selection-mode">none</property>
<property name="halign">center</property>
<style>
<class name="rich-list"/>
</style>
<property name="orientation">vertical</property>
<child>
<object class="GtkListView">
<style>
<class name="rich-list"/>
</style>
<property name="model">
<object class="GtkNoSelection">
<property name="model">
<object class="GtkSortListModel">
<property name="sorter">
<object class="GtkStringSorter">
<property name='expression'>
<lookup name='string' type='GtkStringObject' />
</property>
</object>
</property>
<property name="model">
<object class="GtkStringList" id="vulkan_layers_list" />
</property>
</object>
</property>
</object>
</property>
<property name="factory">
<object class="GtkBuilderListItemFactory">
<property name="bytes"><![CDATA[
<?xml version="1.0" encoding="UTF-8"?>
<interface>
<template class='GtkListItem'>
<property name='activatable'>0</property>
<property name='child'>
<object class='GtkInscription'>
<property name='xalign'>0</property>
<binding name='text'>
<lookup name='string' type='GtkStringObject'>
<lookup name='item'>GtkListItem</lookup>
</lookup>
</binding>
</object>
</property>
</template>
</interface>
]]></property>
</object>
</property>
</object>
</child>
</object>
</child>
</object>
@@ -1100,20 +1143,83 @@
<property name="activatable">0</property>
<child>
<object class="GtkExpander">
<property name="valign">center</property>
<property name="label-widget">
<object class="GtkLabel">
<property name="label" translatable="yes">Extensions</property>
<property name="label" translatable="yes">Vulkan Extensions</property>
<property name="margin-start">10</property>
</object>
</property>
<child>
<object class="GtkListBox" id="vulkan_extensions_box">
<object class="GtkBox">
<property name="margin-top">20</property>
<property name="selection-mode">none</property>
<property name="halign">center</property>
<style>
<class name="rich-list"/>
</style>
<property name="orientation">vertical</property>
<child>
<object class="GtkSearchEntry" id="vulkan_extensions_searchentry"/>
</child>
<child>
<object class="GtkListView">
<style>
<class name="rich-list"/>
</style>
<property name="model">
<object class="GtkNoSelection">
<property name="model">
<object class="GtkFilterListModel">
<property name="filter">
<object class="GtkStringFilter">
<property name="expression">
<lookup name='string' type='GtkStringObject' />
</property>
<binding name="search">
<lookup name="text" type="GtkSearchEntry">
vulkan_extensions_searchentry
</lookup>
</binding>
</object>
</property>
<property name="model">
<object class="GtkSortListModel">
<property name="sorter">
<object class="GtkStringSorter">
<property name='expression'>
<lookup name='string' type='GtkStringObject' />
</property>
</object>
</property>
<property name="model">
<object class="GtkStringList" id="vulkan_extensions_list" />
</property>
</object>
</property>
</object>
</property>
</object>
</property>
<property name="factory">
<object class="GtkBuilderListItemFactory">
<property name="bytes"><![CDATA[
<?xml version="1.0" encoding="UTF-8"?>
<interface>
<template class='GtkListItem'>
<property name='activatable'>0</property>
<property name='child'>
<object class='GtkInscription'>
<property name='xalign'>0</property>
<binding name='text'>
<lookup name='string' type='GtkStringObject'>
<lookup name='item'>GtkListItem</lookup>
</lookup>
</binding>
</object>
</property>
</template>
</interface>
]]></property>
</object>
</property>
</object>
</child>
</object>
</child>
</object>