Rather than ripping out the rug from under the user, worst-case the app
doesn't draw correctly but at least the user has a chance to save. The
trace logs will still give necessary info to know something went wrong.
This is the logical follow-up to the previous patch. Given enough time,
I suggest an app that triggers one of these cases will be encountered.
While we don't want to start baby-sitting bad applications, we should at
least be as lenient as other known GL drivers.
-Nathan
>From 9dd98f7bcfaf643b1f59133afaea7e4e76266622 Mon Sep 17 00:00:00 2001
From: Nathan Kidd <nk...@opentext.com>
Date: Fri, 13 May 2011 13:01:56 -0400
Subject: [PATCH] Make glXGetConfig/glXGetFBConfigAttrib return errors instead of dying.
It really is unkind to kill a process when it isn't absolutely necessary,
and when there exists a valid way to inform it of an error.
The glXGetFBConfigAttrib return values are fudging a bit. For a bad
config Mesa will return GLXBadFBConfig (9) but that requires glxproto.h.
NVIDIA simply segvs. We either return GLX_BAD_VALUE or GLX_BAD_VISUAL.
---
rr/faker-glx.cpp | 26 +++++++++++++++++++-------
1 files changed, 19 insertions(+), 7 deletions(-)
diff --git a/rr/faker-glx.cpp b/rr/faker-glx.cpp
index 0d681d8..9173919 100644
--- a/rr/faker-glx.cpp
+++ b/rr/faker-glx.cpp
@@ -268,14 +268,19 @@ int glXGetConfig(Display *dpy, XVisualInfo *vis, int attrib, int *value)
int dummy;
stoptrace(); if(value) {prargi(*value);} closetrace();
if(!_XQueryExtension(dpy, "GLX", &dummy, &dummy, &dummy))
- retval=0;
+ retval=GLX_NO_EXTENSION;
else retval=_glXGetConfig(dpy, vis, attrib, value);
return retval;
}
- if(!(c=_MatchConfig(dpy, vis))) _throw("Could not obtain Pbuffer-capable RGB visual on the server");
-
- if(attrib==GLX_USE_GL)
+ if(!(c=_MatchConfig(dpy, vis)))
+ {
+ if (fconfig.verbose || fconfig.trace)
+ rrout.println("[VGL] WARNING: Could not match visual"
+ " to a local FBConfig.");
+ retval=GLX_BAD_VISUAL;
+ }
+ else if(attrib==GLX_USE_GL)
{
if(vis->c_class==TrueColor || vis->c_class==PseudoColor) *value=1;
else *value=0;
@@ -384,6 +389,8 @@ GLXDrawable glXGetCurrentReadDrawableSGI(void)
int glXGetFBConfigAttrib(Display *dpy, GLXFBConfig config, int attribute, int *value)
{
VisualID vid=0; int retval=0;
+ if(!dpy || !config || !value) return GLX_BAD_VALUE;
+
TRY();
// Prevent recursion && handle overlay configs
@@ -391,15 +398,20 @@ int glXGetFBConfigAttrib(Display *dpy, GLXFBConfig config, int attribute, int *v
return _glXGetFBConfigAttrib(dpy, config, attribute, value);
////////////////////
- if(!dpy || !value) throw rrerror("glXGetFBConfigAttrib", "Invalid argument");
int screen=DefaultScreen(dpy);
opentrace(glXGetFBConfigAttrib); prargd(dpy); prargc(config);
prargi(attribute); starttrace();
if(!(vid=_MatchVisual(dpy, config)))
- throw rrerror("glXGetFBConfigAttrib", "Invalid FB config");
-
+ {
+ if (fconfig.verbose || fconfig.trace)
+ rrout.println("[VGL] WARNING: Could not match config"
+ " to a local FBConfig.");
+ retval=GLX_BAD_VISUAL;
+ stoptrace(); closetrace();
+ return retval;
+ }
int c_class=__vglVisualClass(dpy, screen, vid);
if(c_class==PseudoColor && (attribute==GLX_RED_SIZE || attribute==GLX_GREEN_SIZE
|| attribute==GLX_BLUE_SIZE || attribute==GLX_ALPHA_SIZE
--
1.6.3.3
------------------------------------------------------------------------------
Achieve unprecedented app performance and reliability
What every C/C++ and Fortran developer should know.
Learn how Intel has extended the reach of its next-generation tools
to help boost performance applications - inlcuding clusters.
http://p.sf.net/sfu/intel-dev2devmay
_______________________________________________
VirtualGL-Devel mailing list
VirtualGL-Devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/virtualgl-devel