Merge branch 'matthiasc/for-main' into 'main'

vulkan: Improve logging around caches

See merge request GNOME/gtk!7208
This commit is contained in:
Matthias Clasen 2024-04-30 16:11:25 +00:00
commit 46866b8a66
2 changed files with 39 additions and 4 deletions

View File

@ -20,6 +20,7 @@
#include "config.h"
#include <gtk/gtk.h>
#include <glib/gstdio.h>
#include <glib/gi18n.h>
#include "demos.h"
#include "fontify.h"
@ -923,6 +924,34 @@ clear_search (GtkSearchBar *bar)
}
}
static void
search_results_update (GObject *filter_model,
GParamSpec *pspec,
GtkEntry *entry)
{
gsize n_items = g_list_model_get_n_items (G_LIST_MODEL (filter_model));
if (strlen (gtk_editable_get_text (GTK_EDITABLE (entry))) > 0)
{
char *text;
if (n_items > 0)
text = g_strdup_printf (ngettext ("%ld search result", "%ld search results", n_items), n_items);
else
text = g_strdup (_("No search results"));
gtk_accessible_update_property (GTK_ACCESSIBLE (entry),
GTK_ACCESSIBLE_PROPERTY_DESCRIPTION, text,
-1);
g_free (text);
}
else
{
gtk_accessible_reset_property (GTK_ACCESSIBLE (entry), GTK_ACCESSIBLE_PROPERTY_DESCRIPTION);
}
}
static void
activate (GApplication *app)
{
@ -970,6 +999,7 @@ activate (GApplication *app)
search_entry = GTK_WIDGET (gtk_builder_get_object (builder, "search-entry"));
g_signal_connect (search_entry, "search-changed", G_CALLBACK (demo_search_changed_cb), filter);
g_signal_connect (filter_model, "notify::n-items", G_CALLBACK (search_results_update), search_entry);
selection = gtk_single_selection_new (G_LIST_MODEL (filter_model));
g_signal_connect (selection, "notify::selected-item", G_CALLBACK (selection_cb), NULL);

View File

@ -1126,14 +1126,13 @@ gdk_vulkan_save_pipeline_cache (GdkDisplay *display)
GDK_VK_CHECK (vkGetPipelineCacheData, device, cache, &size, NULL);
if (size == 0)
return TRUE;
if (size == display->vk_pipeline_cache_size)
{
GDK_DEBUG (VULKAN, "pipeline cache size (%zu bytes) unchanged, skipping save", size);
return TRUE;
}
data = g_malloc (size);
if (GDK_VK_CHECK (vkGetPipelineCacheData, device, cache, &size, data) != VK_SUCCESS)
{
@ -1153,7 +1152,7 @@ gdk_vulkan_save_pipeline_cache (GdkDisplay *display)
file = gdk_vulkan_get_pipeline_cache_file (display);
GDK_DEBUG (VULKAN, "Saving pipeline cache to %s", g_file_peek_path (file));
GDK_DEBUG (VULKAN, "Saving pipeline cache of size %lu to %s", size, g_file_peek_path (file));
if (!g_file_replace_contents (file,
data,
@ -1196,13 +1195,14 @@ gdk_vulkan_save_pipeline_cache (GdkDisplay *display)
}
gdk_profiler_end_markf (begin_time,
"Save Vulkan pipeline cache", "%s size %ld",
"Save Vulkan pipeline cache", "%s size %lu",
g_file_peek_path (file), size);
g_object_unref (file);
g_free (data);
g_free (display->vk_pipeline_cache_etag);
display->vk_pipeline_cache_etag = etag;
display->vk_pipeline_cache_size = size;
return TRUE;
}
@ -1242,6 +1242,11 @@ gdk_display_create_pipeline_cache (GdkDisplay *display)
},
NULL,
&display->vk_pipeline_cache);
GDK_DEBUG (VULKAN, "Creating empty pipeline cache");
}
else
{
GDK_DEBUG (VULKAN, "Loading pipeline cache (%lu bytes)", display->vk_pipeline_cache_size);
}
}