gnome-session/gnome-session-blacklist-hardware.patch

232 lines
6.7 KiB
Diff

From 50b121a7737a13bde1195d1aea215ff8789f65fd Mon Sep 17 00:00:00 2001
From: Vincent Untz <vuntz@gnome.org>
Date: Wed, 19 Oct 2011 14:27:25 +0200
Subject: [PATCH 1/2] tools: Use whitelist/blacklist regexps when evaluating
renderer
The regexps are in a file that we also ship.
https://bugzilla.gnome.org/show_bug.cgi?id=644325
---
data/Makefile.am | 5 +-
data/hardware-compatibility | 20 +++++
tools/Makefile.am | 3 +-
tools/gnome-session-check-accelerated-helper.c | 95 ++++++++++++++++++++++--
4 files changed, 115 insertions(+), 8 deletions(-)
create mode 100644 data/hardware-compatibility
diff --git a/data/Makefile.am b/data/Makefile.am
index cdd3201..6f0fb33 100644
--- a/data/Makefile.am
+++ b/data/Makefile.am
@@ -5,6 +5,9 @@ ui_DATA = \
session-properties.ui \
gsm-inhibit-dialog.ui
+hwcompatdir = $(pkgdatadir)
+hwcompat_DATA = hardware-compatibility
+
xsessiondir = $(datadir)/xsessions
xsession_in_files = gnome.desktop.in
xsession_DATA = $(xsession_in_files:.desktop.in=.desktop)
@@ -39,7 +42,7 @@ EXTRA_DIST = \
$(session_in_in_files) \
$(gsettings_SCHEMAS:.xml=.xml.in) \
$(ui_DATA) \
- $(pixmap_DATA_dist)
+ $(hwcompat_DATA)
CLEANFILES = \
$(gsettings_SCHEMAS) \
diff --git a/data/hardware-compatibility b/data/hardware-compatibility
new file mode 100644
index 0000000..b311898
--- /dev/null
+++ b/data/hardware-compatibility
@@ -0,0 +1,20 @@
+##
+## This file contains a list of blacklist/whitelist regular expressions for
+## renderer strings.
+##
+## The regular expressions are case-insensitive POSIX Extended Regular
+## Expressions. See regex(7) for details.
+##
+## Syntax:
+## - Comment lines start with '#'
+## - Lines starting with '+' are whitelisting.
+## - Lines starting with '-' are blacklisting.
+## - Lines not starting with '#', '+', '-' are ignored.
+##
+
+# Old Mesa software GL renderer
+-software rasterizer
+
+# Gallium has softpipe and llvmpipe
+-softpipe
+-llvmpipe
diff --git a/tools/Makefile.am b/tools/Makefile.am
index aaf1ca1..dc85836 100644
--- a/tools/Makefile.am
+++ b/tools/Makefile.am
@@ -26,7 +26,8 @@ gnome_session_quit_LDADD = \
gnome_session_check_accelerated_helper_SOURCES = \
gnome-session-check-accelerated-helper.c
-gnome_session_check_accelerated_helper_CPPFLAGS = \
+gnome_session_check_accelerated_helper_CPPFLAGS = \
+ -DPKGDATADIR=\""$(pkgdatadir)"\" \
$(GL_TEST_CFLAGS)
gnome_session_check_accelerated_helper_LDADD = \
diff --git a/tools/gnome-session-check-accelerated-helper.c b/tools/gnome-session-check-accelerated-helper.c
index c1b49e2..c0fa1e5 100644
--- a/tools/gnome-session-check-accelerated-helper.c
+++ b/tools/gnome-session-check-accelerated-helper.c
@@ -75,6 +75,8 @@
#include <stdlib.h>
#include <string.h>
+#include <regex.h>
+
#include <X11/Xlib.h>
#include <X11/extensions/Xcomposite.h>
#include <GL/gl.h>
@@ -148,6 +150,92 @@ _has_composite (Display *display)
}
static int
+_is_comment (const char *line)
+{
+ while (*line && isspace(*line))
+ line++;
+
+ if (*line == '#' || *line == '\0')
+ return 0;
+ else
+ return 1;
+}
+
+static int
+_is_gl_renderer_blacklisted (const char *renderer)
+{
+ FILE *blacklist;
+ char *line = NULL;
+ size_t line_len = 0;
+ int ret = 1;
+
+ blacklist = fopen(PKGDATADIR "/hardware-compatibility", "r");
+ if (blacklist == NULL)
+ goto out;
+
+ while (getline (&line, &line_len, blacklist) != -1) {
+ int whitelist = 0;
+ const char *re_str;
+ regex_t re;
+ int status;
+
+ if (line == NULL)
+ break;
+
+ /* Drop trailing \n */
+ line[strlen(line) - 1] = '\0';
+
+ if (_is_comment (line) == 0) {
+ free (line);
+ line = NULL;
+ continue;
+ }
+
+ if (line[0] == '+')
+ whitelist = 1;
+ else if (line[0] == '-')
+ whitelist = 0;
+ else {
+ _print_error ("Invalid syntax in this line for hardware compatibility:");
+ _print_error (line);
+ free (line);
+ line = NULL;
+ continue;
+ }
+
+ re_str = line + 1;
+
+ if (regcomp (&re, re_str, REG_EXTENDED|REG_ICASE|REG_NOSUB) != 0) {
+ _print_error ("Cannot use this regular expression for hardware compatibility:");
+ _print_error (re_str);
+ } else {
+ status = regexec (&re, renderer, 0, NULL, 0);
+ regfree(&re);
+
+ if (status == 0) {
+ if (whitelist)
+ ret = 0;
+ goto out;
+ }
+ }
+
+ free (line);
+ line = NULL;
+ }
+
+ ret = 0;
+
+out:
+ if (line != NULL)
+ free (line);
+
+ if (blacklist != NULL)
+ fclose (blacklist);
+
+ return ret;
+}
+
+static int
_has_hardware_gl (Display *display)
{
int screen;
@@ -193,12 +281,7 @@ _has_hardware_gl (Display *display)
goto out;
renderer = (const char *) glGetString (GL_RENDERER);
- /* The current Mesa software GL renderer string is
- * "Software Rasterizer".
- * Gallium has softpipe and llvmpipe. */
- if (strcasestr (renderer, "software rasterizer") != NULL ||
- strcasestr (renderer, "softpipe") != NULL ||
- strcasestr (renderer, "llvmpipe") != NULL)
+ if (_is_gl_renderer_blacklisted (renderer) != 0)
goto out;
/* we need to get the max texture size while we have a context,
--
1.7.7
From 5762becdbb2a308647067e0e09617b3f91f0ac0e Mon Sep 17 00:00:00 2001
From: Vincent Untz <vuntz@gnome.org>
Date: Wed, 19 Oct 2011 14:36:57 +0200
Subject: [PATCH 2/2] data: Blacklist Intel 830-865 hardware
https://bugzilla.gnome.org/show_bug.cgi?id=644325
---
data/hardware-compatibility | 3 +++
1 files changed, 3 insertions(+), 0 deletions(-)
diff --git a/data/hardware-compatibility b/data/hardware-compatibility
index b311898..ddbfe07 100644
--- a/data/hardware-compatibility
+++ b/data/hardware-compatibility
@@ -12,6 +12,9 @@
## - Lines not starting with '#', '+', '-' are ignored.
##
+# Intel 830-865
+-Intel(R) 8[[:digit:]]{2,2}[^[:digit:]]
+
# Old Mesa software GL renderer
-software rasterizer
--
1.7.7