mirror of
https://gitlab.gnome.org/GNOME/gtk.git
synced 2024-12-26 13:41:07 +00:00
Merge branch 'matthiasc/for-main' into 'main'
gsk: Drop statistics from GSK_DEBUG=renderer See merge request GNOME/gtk!7203
This commit is contained in:
commit
744016e768
@ -68,6 +68,11 @@ gdk_x11_vulkan_context_end_frame (GdkDrawContext *context,
|
|||||||
GDK_DRAW_CONTEXT_CLASS (gdk_x11_vulkan_context_parent_class)->end_frame (context, painted);
|
GDK_DRAW_CONTEXT_CLASS (gdk_x11_vulkan_context_parent_class)->end_frame (context, painted);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static void
|
||||||
|
gdk_x11_vulkan_context_empty_frame (GdkDrawContext *draw_context)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
gdk_x11_vulkan_context_class_init (GdkX11VulkanContextClass *klass)
|
gdk_x11_vulkan_context_class_init (GdkX11VulkanContextClass *klass)
|
||||||
{
|
{
|
||||||
@ -75,6 +80,7 @@ gdk_x11_vulkan_context_class_init (GdkX11VulkanContextClass *klass)
|
|||||||
GdkDrawContextClass *draw_context_class = GDK_DRAW_CONTEXT_CLASS (klass);
|
GdkDrawContextClass *draw_context_class = GDK_DRAW_CONTEXT_CLASS (klass);
|
||||||
|
|
||||||
draw_context_class->end_frame = gdk_x11_vulkan_context_end_frame;
|
draw_context_class->end_frame = gdk_x11_vulkan_context_end_frame;
|
||||||
|
draw_context_class->empty_frame = gdk_x11_vulkan_context_empty_frame;
|
||||||
|
|
||||||
context_class->create_surface = gdk_x11_vulkan_context_create_surface;
|
context_class->create_surface = gdk_x11_vulkan_context_create_surface;
|
||||||
}
|
}
|
||||||
|
@ -428,21 +428,6 @@ gsk_renderer_render_texture (GskRenderer *renderer,
|
|||||||
|
|
||||||
texture = GSK_RENDERER_GET_CLASS (renderer)->render_texture (renderer, root, viewport);
|
texture = GSK_RENDERER_GET_CLASS (renderer)->render_texture (renderer, root, viewport);
|
||||||
|
|
||||||
if (GSK_RENDERER_DEBUG_CHECK (renderer, RENDERER))
|
|
||||||
{
|
|
||||||
GString *buf = g_string_new ("*** Texture stats ***\n\n");
|
|
||||||
|
|
||||||
gsk_profiler_append_counters (priv->profiler, buf);
|
|
||||||
g_string_append_c (buf, '\n');
|
|
||||||
|
|
||||||
gsk_profiler_append_timers (priv->profiler, buf);
|
|
||||||
g_string_append_c (buf, '\n');
|
|
||||||
|
|
||||||
g_print ("%s\n***\n\n", buf->str);
|
|
||||||
|
|
||||||
g_string_free (buf, TRUE);
|
|
||||||
}
|
|
||||||
|
|
||||||
return texture;
|
return texture;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -509,21 +494,6 @@ gsk_renderer_render (GskRenderer *renderer,
|
|||||||
|
|
||||||
renderer_class->render (renderer, root, clip);
|
renderer_class->render (renderer, root, clip);
|
||||||
|
|
||||||
if (GSK_RENDERER_DEBUG_CHECK (renderer, RENDERER))
|
|
||||||
{
|
|
||||||
GString *buf = g_string_new ("*** Frame stats ***\n\n");
|
|
||||||
|
|
||||||
gsk_profiler_append_counters (priv->profiler, buf);
|
|
||||||
g_string_append_c (buf, '\n');
|
|
||||||
|
|
||||||
gsk_profiler_append_timers (priv->profiler, buf);
|
|
||||||
g_string_append_c (buf, '\n');
|
|
||||||
|
|
||||||
g_print ("%s\n***\n\n", buf->str);
|
|
||||||
|
|
||||||
g_string_free (buf, TRUE);
|
|
||||||
}
|
|
||||||
|
|
||||||
g_clear_pointer (&priv->prev_node, gsk_render_node_unref);
|
g_clear_pointer (&priv->prev_node, gsk_render_node_unref);
|
||||||
cairo_region_destroy (clip);
|
cairo_region_destroy (clip);
|
||||||
g_clear_pointer (&offload, gsk_offload_free);
|
g_clear_pointer (&offload, gsk_offload_free);
|
||||||
@ -609,12 +579,17 @@ get_renderer_for_display (GdkSurface *surface)
|
|||||||
static GType
|
static GType
|
||||||
get_renderer_for_env_var (GdkSurface *surface)
|
get_renderer_for_env_var (GdkSurface *surface)
|
||||||
{
|
{
|
||||||
static GType env_var_type = G_TYPE_NONE;
|
static GType env_var_type = G_TYPE_INVALID;
|
||||||
|
|
||||||
if (env_var_type == G_TYPE_NONE)
|
if (env_var_type == G_TYPE_INVALID)
|
||||||
{
|
{
|
||||||
const char *renderer_name = g_getenv ("GSK_RENDERER");
|
const char *renderer_name = g_getenv ("GSK_RENDERER");
|
||||||
env_var_type = get_renderer_for_name (renderer_name);
|
env_var_type = get_renderer_for_name (renderer_name);
|
||||||
|
if (env_var_type != G_TYPE_INVALID)
|
||||||
|
GSK_DEBUG (RENDERER,
|
||||||
|
"Environment variable GSK_RENDERER=%s set, trying %s",
|
||||||
|
renderer_name,
|
||||||
|
g_type_name (env_var_type));
|
||||||
}
|
}
|
||||||
|
|
||||||
return env_var_type;
|
return env_var_type;
|
||||||
@ -632,83 +607,115 @@ get_renderer_for_backend (GdkSurface *surface)
|
|||||||
}
|
}
|
||||||
|
|
||||||
static gboolean
|
static gboolean
|
||||||
gl_software_rendering (GdkSurface *surface)
|
gl_supported_platform (GdkSurface *surface,
|
||||||
|
GType renderer_type,
|
||||||
|
gboolean as_fallback)
|
||||||
{
|
{
|
||||||
GdkDisplay *display = gdk_surface_get_display (surface);
|
GdkDisplay *display = gdk_surface_get_display (surface);
|
||||||
GdkGLContext *context;
|
GdkGLContext *context;
|
||||||
|
GError *error = NULL;
|
||||||
|
|
||||||
if (!gdk_display_prepare_gl (display, NULL))
|
if (!gdk_display_prepare_gl (display, &error))
|
||||||
return G_TYPE_INVALID;
|
{
|
||||||
|
if (!as_fallback)
|
||||||
|
GSK_DEBUG (RENDERER, "Not using GL: %s", error->message);
|
||||||
|
g_clear_error (&error);
|
||||||
|
return FALSE;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (as_fallback)
|
||||||
|
return TRUE;
|
||||||
|
|
||||||
context = gdk_display_get_gl_context (display);
|
context = gdk_display_get_gl_context (display);
|
||||||
gdk_gl_context_make_current (context);
|
gdk_gl_context_make_current (context);
|
||||||
|
|
||||||
return strstr ((const char *) glGetString (GL_RENDERER), "llvmpipe") != NULL;
|
if (strstr ((const char *) glGetString (GL_RENDERER), "llvmpipe") != NULL)
|
||||||
|
{
|
||||||
|
GSK_DEBUG (RENDERER, "Not using '%s': renderer is llvmpipe", g_type_name (renderer_type));
|
||||||
|
return FALSE;
|
||||||
|
}
|
||||||
|
|
||||||
|
return TRUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
static GType
|
static GType
|
||||||
get_renderer_for_gl (GdkSurface *surface)
|
get_renderer_for_gl (GdkSurface *surface)
|
||||||
{
|
{
|
||||||
if (gl_software_rendering (surface))
|
if (!gl_supported_platform (surface, gsk_ngl_renderer_get_type (), FALSE))
|
||||||
return G_TYPE_INVALID;
|
return G_TYPE_INVALID;
|
||||||
|
|
||||||
return gsk_ngl_renderer_get_type ();
|
return gsk_ngl_renderer_get_type ();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static GType
|
||||||
|
get_renderer_for_gl_fallback (GdkSurface *surface)
|
||||||
|
{
|
||||||
|
if (!gl_supported_platform (surface, GSK_TYPE_GL_RENDERER, TRUE))
|
||||||
|
return G_TYPE_INVALID;
|
||||||
|
|
||||||
|
return GSK_TYPE_GL_RENDERER;
|
||||||
|
}
|
||||||
|
|
||||||
#ifdef GDK_RENDERING_VULKAN
|
#ifdef GDK_RENDERING_VULKAN
|
||||||
static gboolean
|
static gboolean
|
||||||
vulkan_software_rendering (GdkSurface *surface)
|
vulkan_supported_platform (GdkSurface *surface,
|
||||||
|
GType renderer_type,
|
||||||
|
gboolean as_fallback)
|
||||||
{
|
{
|
||||||
GdkDisplay *display = gdk_surface_get_display (surface);
|
GdkDisplay *display = gdk_surface_get_display (surface);
|
||||||
VkPhysicalDeviceProperties props;
|
VkPhysicalDeviceProperties props;
|
||||||
|
GError *error = NULL;
|
||||||
|
|
||||||
if (!gdk_display_init_vulkan (display, NULL))
|
if (!gdk_display_init_vulkan (display, &error))
|
||||||
return G_TYPE_INVALID;
|
{
|
||||||
|
if (!as_fallback)
|
||||||
|
GSK_DEBUG (RENDERER, "Not using Vulkan: %s", error->message);
|
||||||
|
g_clear_error (&error);
|
||||||
|
return FALSE;
|
||||||
|
}
|
||||||
|
|
||||||
vkGetPhysicalDeviceProperties (display->vk_physical_device, &props);
|
vkGetPhysicalDeviceProperties (display->vk_physical_device, &props);
|
||||||
|
|
||||||
return props.deviceType == VK_PHYSICAL_DEVICE_TYPE_CPU;
|
if (props.deviceType == VK_PHYSICAL_DEVICE_TYPE_CPU)
|
||||||
}
|
{
|
||||||
#endif
|
if (!as_fallback)
|
||||||
|
GSK_DEBUG (RENDERER,
|
||||||
|
"Not using '%s': device is CPU",
|
||||||
|
g_type_name (renderer_type));
|
||||||
|
return FALSE;
|
||||||
|
}
|
||||||
|
|
||||||
static GType
|
if (as_fallback)
|
||||||
get_renderer_for_vulkan (GdkSurface *surface)
|
return TRUE;
|
||||||
{
|
|
||||||
#ifdef GDK_RENDERING_VULKAN
|
|
||||||
if (vulkan_software_rendering (surface))
|
|
||||||
return G_TYPE_INVALID;
|
|
||||||
|
|
||||||
return GSK_TYPE_VULKAN_RENDERER;
|
|
||||||
#else
|
|
||||||
return G_TYPE_INVALID;
|
|
||||||
#endif
|
|
||||||
}
|
|
||||||
|
|
||||||
static gboolean
|
|
||||||
vulkan_friendly_platform (GdkSurface *surface)
|
|
||||||
{
|
|
||||||
#ifdef GDK_WINDOWING_WAYLAND
|
#ifdef GDK_WINDOWING_WAYLAND
|
||||||
if (GDK_IS_WAYLAND_DISPLAY (gdk_surface_get_display (surface)))
|
if (GDK_IS_WAYLAND_DISPLAY (gdk_surface_get_display (surface)))
|
||||||
return TRUE;
|
return TRUE;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
GSK_DEBUG (RENDERER, "Not using '%s': platform is not Wayland", g_type_name (renderer_type));
|
||||||
|
|
||||||
return FALSE;
|
return FALSE;
|
||||||
}
|
}
|
||||||
|
|
||||||
static GType
|
static GType
|
||||||
get_renderer_for_vulkan_friendly_platform (GdkSurface *surface)
|
get_renderer_for_vulkan (GdkSurface *surface)
|
||||||
{
|
{
|
||||||
if (vulkan_friendly_platform (surface))
|
if (!vulkan_supported_platform (surface, GSK_TYPE_VULKAN_RENDERER, FALSE))
|
||||||
return get_renderer_for_vulkan (surface);
|
return G_TYPE_INVALID;
|
||||||
|
|
||||||
return G_TYPE_INVALID;
|
return GSK_TYPE_VULKAN_RENDERER;
|
||||||
}
|
}
|
||||||
|
|
||||||
static GType
|
static GType
|
||||||
get_renderer_for_gles2 (GdkSurface *surface)
|
get_renderer_for_vulkan_fallback (GdkSurface *surface)
|
||||||
{
|
{
|
||||||
return GSK_TYPE_GL_RENDERER;
|
if (!vulkan_supported_platform (surface, GSK_TYPE_VULKAN_RENDERER, TRUE))
|
||||||
|
return G_TYPE_INVALID;
|
||||||
|
|
||||||
|
return GSK_TYPE_VULKAN_RENDERER;
|
||||||
}
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
static GType
|
static GType
|
||||||
get_renderer_fallback (GdkSurface *surface)
|
get_renderer_fallback (GdkSurface *surface)
|
||||||
@ -722,10 +729,14 @@ static struct {
|
|||||||
{ get_renderer_for_display },
|
{ get_renderer_for_display },
|
||||||
{ get_renderer_for_env_var },
|
{ get_renderer_for_env_var },
|
||||||
{ get_renderer_for_backend },
|
{ get_renderer_for_backend },
|
||||||
{ get_renderer_for_vulkan_friendly_platform },
|
#ifdef GDK_RENDERING_VULKAN
|
||||||
{ get_renderer_for_gl },
|
|
||||||
{ get_renderer_for_vulkan },
|
{ get_renderer_for_vulkan },
|
||||||
{ get_renderer_for_gles2 },
|
#endif
|
||||||
|
{ get_renderer_for_gl },
|
||||||
|
#ifdef GDK_RENDERING_VULKAN
|
||||||
|
{ get_renderer_for_vulkan_fallback },
|
||||||
|
#endif
|
||||||
|
{ get_renderer_for_gl_fallback },
|
||||||
{ get_renderer_fallback },
|
{ get_renderer_fallback },
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -763,17 +774,19 @@ gsk_renderer_new_for_surface (GdkSurface *surface)
|
|||||||
|
|
||||||
if (gsk_renderer_realize (renderer, surface, &error))
|
if (gsk_renderer_realize (renderer, surface, &error))
|
||||||
{
|
{
|
||||||
GSK_RENDERER_DEBUG (renderer, RENDERER,
|
GSK_DEBUG (RENDERER,
|
||||||
"Using renderer of type '%s' for surface '%s'",
|
"Using renderer '%s' for surface '%s'",
|
||||||
G_OBJECT_TYPE_NAME (renderer),
|
G_OBJECT_TYPE_NAME (renderer),
|
||||||
G_OBJECT_TYPE_NAME (surface));
|
G_OBJECT_TYPE_NAME (surface));
|
||||||
return renderer;
|
return renderer;
|
||||||
}
|
}
|
||||||
|
|
||||||
g_message ("Failed to realize renderer of type '%s' for surface '%s': %s\n",
|
GSK_DEBUG (RENDERER,
|
||||||
|
"Failed to realize renderer '%s' for surface '%s': %s",
|
||||||
G_OBJECT_TYPE_NAME (renderer),
|
G_OBJECT_TYPE_NAME (renderer),
|
||||||
G_OBJECT_TYPE_NAME (surface),
|
G_OBJECT_TYPE_NAME (surface),
|
||||||
error->message);
|
error->message);
|
||||||
|
|
||||||
g_object_unref (renderer);
|
g_object_unref (renderer);
|
||||||
g_clear_error (&error);
|
g_clear_error (&error);
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user