[gnome-session] main: automatically fallback to software gl



commit 51d5b07a1a74b153604b47f47fec3783c30e3511
Author: Ray Strode <rstrode redhat com>
Date:   Tue Mar 5 23:08:58 2013 -0500

    main: automatically fallback to software gl
    
    Now that we have working software GL available, use it if
    hardware GL isn't up to muster.
    
    https://bugzilla.gnome.org/show_bug.cgi?id=672943

 gnome-session/main.c |   42 +++++++++++++++++++++++++++++++++++++++++-
 1 files changed, 41 insertions(+), 1 deletions(-)
---
diff --git a/gnome-session/main.c b/gnome-session/main.c
index d0a83ad..b6ee6ce 100644
--- a/gnome-session/main.c
+++ b/gnome-session/main.c
@@ -251,16 +251,31 @@ require_dbus_session (int      argc,
         return TRUE;
 }
 
+static gboolean
+check_gl (GError **error)
+{
+        int status;
+        char *argv[] = { LIBEXECDIR "/gnome-session-check-accelerated", NULL };
+
+        if (!g_spawn_sync (NULL, (char **) argv, NULL, 0, NULL, NULL, NULL, NULL,
+                           &status, error)) {
+                return FALSE;
+        }
+
+        return g_spawn_check_exit_status (status, error);
+}
+
 int
 main (int argc, char **argv)
 {
-        GError           *error;
+        GError           *error = NULL;
         char             *display_str;
         GsmManager       *manager;
         GsmStore         *client_store;
         static char     **override_autostart_dirs = NULL;
         static char      *opt_session_name = NULL;
         const char       *session_name;
+        gboolean          gl_failed = FALSE;
         static GOptionEntry entries[] = {
                 { "autostart", 'a', 0, G_OPTION_ARG_STRING_ARRAY, &override_autostart_dirs, N_("Override 
standard autostart directories"), N_("AUTOSTART_DIR") },
                 { "session", 0, 0, G_OPTION_ARG_STRING, &opt_session_name, N_("Session to use"), 
N_("SESSION_NAME") },
@@ -277,6 +292,25 @@ main (int argc, char **argv)
                 gsm_util_init_error (TRUE, "%s", error->message);
         }
 
+        /* Check GL, if it doesn't work out then force software fallback */
+        if (!check_gl (&error)) {
+                gl_failed = TRUE;
+
+                g_debug ("hardware acceleration check failed: %s",
+                         error? error->message : "");
+                g_clear_error (&error);
+                if (g_getenv ("LIBGL_ALWAYS_SOFTWARE") == NULL) {
+                        g_setenv ("LIBGL_ALWAYS_SOFTWARE", "1", TRUE);
+                        if (!check_gl (&error)) {
+                                g_warning ("software acceleration check failed: %s",
+                                           error? error->message : "");
+                                g_clear_error (&error);
+                        } else {
+                                gl_failed = FALSE;
+                        }
+                }
+        }
+
         bindtextdomain (GETTEXT_PACKAGE, LOCALE_DIR);
         bind_textdomain_codeset (GETTEXT_PACKAGE, "UTF-8");
         textdomain (GETTEXT_PACKAGE);
@@ -296,6 +330,12 @@ main (int argc, char **argv)
                 exit (0);
         }
 
+        if (gl_failed) {
+                gsm_fail_whale_dialog_we_failed (FALSE, TRUE, NULL);
+                gtk_main ();
+                exit (1);
+        }
+
         if (please_fail) {
                 gsm_fail_whale_dialog_we_failed (TRUE, TRUE, NULL);
                 gtk_main ();


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]