Commit 529956f4 authored by Frederic Crozat's avatar Frederic Crozat Committed by Ray Strode

check-accelerated: check for llvmpipe

Check if running under llvmpipe and set Atom
_GNOME_IS_SOFTWARE_RENDERING to 1 in that case.

https://bugzilla.gnome.org/show_bug.cgi?id=704402
parent 2b5a5b98
......@@ -25,3 +25,5 @@
/* Exit value for helper */
#define HELPER_ACCEL 0
#define HELPER_NO_ACCEL 1
#define HELPER_SOFTWARE_RENDERING 2
......@@ -90,6 +90,7 @@
#define SIZE_ERROR -1
static int max_texture_size = SIZE_UNSET;
static int max_renderbuffer_size = SIZE_UNSET;
static gboolean has_llvmpipe = FALSE;
static inline void
_print_error (const char *str)
......@@ -278,6 +279,8 @@ _has_hardware_gl (Display *display)
renderer = (const char *) glGetString (GL_RENDERER);
if (_is_gl_renderer_blacklisted (renderer))
goto out;
if (renderer && strcasestr (renderer, "llvmpipe"))
has_llvmpipe = TRUE;
/* we need to get the max texture and renderbuffer sizes while we have
* a context, but we'll check their values later */
......@@ -444,6 +447,12 @@ main (int argc, char **argv)
goto out;
}
if (has_llvmpipe) {
_print_error ("llvmpipe detected.");
ret = HELPER_SOFTWARE_RENDERING;
goto out;
}
ret = HELPER_ACCEL;
out:
......
......@@ -41,6 +41,7 @@
#define ACCEL_CHECK_RUNNING 2
static Atom is_accelerated_atom;
static Atom is_software_rendering_atom;
static gboolean property_changed;
static void
......@@ -106,7 +107,7 @@ main (int argc, char **argv)
int estatus;
char *child_argv[] = { LIBEXECDIR "/gnome-session-check-accelerated-helper", NULL };
Window rootwin;
glong is_accelerated;
glong is_accelerated, is_software_rendering;
GError *error = NULL;
gtk_init (NULL, NULL);
......@@ -115,6 +116,7 @@ main (int argc, char **argv)
rootwin = gdk_x11_get_default_root_xwindow ();
is_accelerated_atom = gdk_x11_get_xatom_by_name_for_display (display, "_GNOME_SESSION_ACCELERATED");
is_software_rendering_atom = gdk_x11_get_xatom_by_name_for_display (display, "_GNOME_IS_SOFTWARE_RENDERING");
{
Atom type;
......@@ -163,10 +165,12 @@ main (int argc, char **argv)
if (!g_spawn_sync (NULL, (char**)child_argv, NULL, 0,
NULL, NULL, NULL, NULL, &estatus, &error)) {
is_accelerated = FALSE;
is_software_rendering = FALSE;
g_printerr ("gnome-session-check-accelerated: Failed to run helper: %s\n", error->message);
g_clear_error (&error);
} else {
is_accelerated = (WEXITSTATUS(estatus) == HELPER_ACCEL);
is_accelerated = (WEXITSTATUS(estatus) == HELPER_ACCEL) || (WEXITSTATUS(estatus) == HELPER_SOFTWARE_RENDERING);
is_software_rendering = (WEXITSTATUS(estatus) == HELPER_SOFTWARE_RENDERING);
if (!is_accelerated)
g_printerr ("gnome-session-check-accelerated: Helper exited with code %d\n", estatus);
}
......@@ -178,6 +182,13 @@ main (int argc, char **argv)
XA_CARDINAL, 32, PropModeReplace, (guchar *) &is_accelerated, 1);
}
if (is_software_rendering) {
XChangeProperty (GDK_DISPLAY_XDISPLAY (display),
rootwin,
is_software_rendering_atom,
XA_CARDINAL, 32, PropModeReplace, (guchar *) &is_software_rendering, 1);
}
gdk_display_sync (display);
return is_accelerated ? 0 : 1;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment