Improve test for using LIBGL_ALWAYS_INDIRECT

Now that Clutter has support for ARB_texture_rectangle, we need
to enable EXT_texture_from_pixmap support more widely.

Parse the glxinfo output more accurately and detect when
EXT_texture_rectangle is supported client and server but not
is not active, and force indirect rendering only in that case.

svn path=/trunk/; revision=119
This commit is contained in:
Owen Taylor 2008-12-05 16:15:49 +00:00
parent 6c1cea927c
commit 65989de535

View File

@ -1,8 +1,28 @@
from optparse import OptionParser from optparse import OptionParser
import os import os
import re
import subprocess import subprocess
import sys import sys
GLXINFO_RE = re.compile(r"^(\S.*):\s*\n((?:^\s+.*\n)*)", re.MULTILINE)
def _get_glx_extensions():
"""Return a tuple of server, client, and effective GLX extensions"""
glxinfo = subprocess.Popen(["glxinfo"], stdout=subprocess.PIPE)
glxinfo_output = glxinfo.communicate()[0]
glxinfo.wait()
glxinfo_map = {}
for m in GLXINFO_RE.finditer(glxinfo_output):
glxinfo_map[m.group(1)] = m.group(2)
server_glx_extensions = set(re.split("\s*,\s*", glxinfo_map['server glx extensions'].strip()))
client_glx_extensions = set(re.split("\s*,\s*", glxinfo_map['client glx extensions'].strip()))
glx_extensions = set(re.split("\s*,\s*", glxinfo_map['GLX extensions'].strip()))
return (server_glx_extensions, client_glx_extensions, glx_extensions)
class Launcher: class Launcher:
def __init__(self): def __init__(self):
self.use_tfp = True self.use_tfp = True
@ -41,6 +61,7 @@ class Launcher:
"""Starts gnome-shell. Returns a subprocess.Popen object""" """Starts gnome-shell. Returns a subprocess.Popen object"""
use_tfp = self.use_tfp use_tfp = self.use_tfp
force_indirect = False
# Allow disabling usage of the EXT_texture_for_pixmap extension. # Allow disabling usage of the EXT_texture_for_pixmap extension.
# FIXME: Move this to ClutterGlxPixmap like # FIXME: Move this to ClutterGlxPixmap like
@ -50,13 +71,21 @@ class Launcher:
use_tfp = False use_tfp = False
if use_tfp: if use_tfp:
# Check if GLX supports GL_ARB_texture_non_power_of_two; currently clutter # Decide if we need to set LIBGL_ALWAYS_INDIRECT=1 to get the texture_from_pixmap
# can only use GLX_EXT_texture_for_pixmap if we have that extension. # extension; we take having the extension be supported on both the client and
glxinfo = subprocess.Popen(["glxinfo"], stdout=subprocess.PIPE) # server but not in the list of effective extensions as a signal of needing
glxinfo_output = glxinfo.communicate()[0] # to force indirect rendering.
glxinfo.wait() #
# (The Xepyhr DRI support confuses this heuristic but we disable TFP in
# start-in-Xepyhr)
#
(server_glx_extensions, client_glx_extensions, glx_extensions) = _get_glx_extensions()
use_tfp = "GL_ARB_texture_non_power_of_two" in glxinfo_output if ("GLX_EXT_texture_from_pixmap" in server_glx_extensions and
"GLX_EXT_texture_from_pixmap" in client_glx_extensions and
(not "GLX_EXT_texture_from_pixmap" in glx_extensions)):
force_indirect = True
# Now launch metacity-clutter with our plugin # Now launch metacity-clutter with our plugin
env=dict(os.environ) env=dict(os.environ)
@ -65,13 +94,13 @@ class Launcher:
'LD_LIBRARY_PATH' : os.environ.get('LD_LIBRARY_PATH', '') + ':' + self.plugin_dir, 'LD_LIBRARY_PATH' : os.environ.get('LD_LIBRARY_PATH', '') + ':' + self.plugin_dir,
'GNOME_DISABLE_CRASH_DIALOG' : '1'}) 'GNOME_DISABLE_CRASH_DIALOG' : '1'})
if use_tfp: if force_indirect:
# If we have NPOT textures, then we want to use GLX_EXT_texture_from_pixmap; in if self.options.verbose:
# most cases, we have to force indirect rendering to do this. DRI2 will lift print "Forcing indirect GL"
# that restriction; in which case what we should do is parse the information
# from glxinfo more carefully... if the extension isn't listed under # This is Mesa specific; the NVIDIA proprietary drivers drivers use
# "GLX extensions" with LIBGL_ALWAYS_INDIRECT unset, then set LIBGL_ALWAYS_INDIRECT # __GL_FORCE_INDIRECT=1 instead. But we don't need to force indirect
# and try again. # rendering for NVIDIA.
env['LIBGL_ALWAYS_INDIRECT'] = '1' env['LIBGL_ALWAYS_INDIRECT'] = '1'
if not self.options.verbose: if not self.options.verbose: