summaryrefslogtreecommitdiff
path: root/xc/extras/Mesa/src/X/fakeglx.c
diff options
context:
space:
mode:
Diffstat (limited to 'xc/extras/Mesa/src/X/fakeglx.c')
-rw-r--r--xc/extras/Mesa/src/X/fakeglx.c135
1 files changed, 115 insertions, 20 deletions
diff --git a/xc/extras/Mesa/src/X/fakeglx.c b/xc/extras/Mesa/src/X/fakeglx.c
index 16fb2f622..deba5af3d 100644
--- a/xc/extras/Mesa/src/X/fakeglx.c
+++ b/xc/extras/Mesa/src/X/fakeglx.c
@@ -70,6 +70,7 @@
/* Silence compiler warnings */
+extern void Fake_glXDummyFunc( void );
void Fake_glXDummyFunc( void )
{
(void) kernel8;
@@ -226,7 +227,9 @@ save_glx_visual( Display *dpy, XVisualInfo *vinfo,
GLboolean rgbFlag, GLboolean alphaFlag, GLboolean dbFlag,
GLboolean stereoFlag,
GLint depth_size, GLint stencil_size,
- GLint accum_size, GLint level )
+ GLint accumRedSize, GLint accumGreenSize,
+ GLint accumBlueSize, GLint accumAlphaSize,
+ GLint level )
{
GLboolean ximageFlag = GL_TRUE;
XMesaVisual xmvis;
@@ -269,7 +272,10 @@ save_glx_visual( Display *dpy, XVisualInfo *vinfo,
&& (v->gl_visual->AlphaBits > 0) == alphaFlag
&& (v->gl_visual->DepthBits >= depth_size || depth_size == 0)
&& (v->gl_visual->StencilBits >= stencil_size || stencil_size == 0)
- && (v->gl_visual->AccumBits >= accum_size || accum_size == 0)) {
+ && (v->gl_visual->AccumRedBits >= accumRedSize || accumRedSize == 0)
+ && (v->gl_visual->AccumGreenBits >= accumGreenSize || accumGreenSize == 0)
+ && (v->gl_visual->AccumBlueBits >= accumBlueSize || accumBlueSize == 0)
+ && (v->gl_visual->AccumAlphaBits >= accumAlphaSize || accumAlphaSize == 0)) {
/* now either compare XVisualInfo pointers or visual IDs */
if ((!comparePointers && v->visinfo->visualid == vinfo->visualid)
|| (comparePointers && v->vishandle == vinfo)) {
@@ -287,7 +293,10 @@ save_glx_visual( Display *dpy, XVisualInfo *vinfo,
xmvis = XMesaCreateVisual( dpy, vinfo, rgbFlag, alphaFlag, dbFlag,
stereoFlag, ximageFlag,
- depth_size, stencil_size, accum_size, level );
+ depth_size, stencil_size,
+ accumRedSize, accumBlueSize,
+ accumBlueSize, accumAlphaSize, 0, level,
+ GLX_NONE_EXT );
if (xmvis) {
VisualTable[NumVisuals] = xmvis;
NumVisuals++;
@@ -299,6 +308,11 @@ save_glx_visual( Display *dpy, XVisualInfo *vinfo,
/*
* Create a GLX visual from a regular XVisualInfo.
+ * This is called when Fake GLX is given an XVisualInfo which wasn't
+ * returned by glXChooseVisual. Since this is the first time we're
+ * considering this visual we'll take a guess at reasonable values
+ * for depth buffer size, stencil size, accum size, etc.
+ * This is the best we can do with a client-side emulation of GLX.
*/
static XMesaVisual
create_glx_visual( Display *dpy, XVisualInfo *visinfo )
@@ -315,7 +329,7 @@ create_glx_visual( Display *dpy, XVisualInfo *visinfo )
GL_FALSE, /* stereo */
0, /* depth bits */
0, /* stencil bits */
- 0, /* accum bits */
+ 0,0,0,0, /* accum bits */
vislevel /* level */
);
}
@@ -328,9 +342,12 @@ create_glx_visual( Display *dpy, XVisualInfo *visinfo )
GL_FALSE, /* alpha */
GL_TRUE, /* double */
GL_FALSE, /* stereo */
- 8*sizeof(GLdepth),
- 8*sizeof(GLstencil),
- 8*sizeof(GLaccum),
+ DEFAULT_SOFTWARE_DEPTH_BITS,
+ 8 * sizeof(GLstencil),
+ 8 * sizeof(GLaccum), /* r */
+ 8 * sizeof(GLaccum), /* g */
+ 8 * sizeof(GLaccum), /* b */
+ 8 * sizeof(GLaccum), /* a */
0 /* level */
);
}
@@ -860,11 +877,15 @@ Fake_glXChooseVisual( Display *dpy, int screen, int *list )
GLboolean stereo_flag = GL_FALSE;
GLint depth_size = 0;
GLint stencil_size = 0;
- GLint accum_size = 0;
+ GLint accumRedSize = 0;
+ GLint accumGreenSize = 0;
+ GLint accumBlueSize = 0;
+ GLint accumAlphaSize = 0;
int level = 0;
int visual_type = DONT_CARE;
int trans_type = DONT_CARE;
int trans_value = DONT_CARE;
+ GLint caveat = DONT_CARE;
parselist = list;
@@ -927,13 +948,31 @@ Fake_glXChooseVisual( Display *dpy, int screen, int *list )
stencil_size = *parselist++;
break;
case GLX_ACCUM_RED_SIZE:
+ parselist++;
+ {
+ GLint size = *parselist++;
+ accumRedSize = MAX2( accumRedSize, size );
+ }
+ break;
case GLX_ACCUM_GREEN_SIZE:
+ parselist++;
+ {
+ GLint size = *parselist++;
+ accumGreenSize = MAX2( accumGreenSize, size );
+ }
+ break;
case GLX_ACCUM_BLUE_SIZE:
+ parselist++;
+ {
+ GLint size = *parselist++;
+ accumBlueSize = MAX2( accumBlueSize, size );
+ }
+ break;
case GLX_ACCUM_ALPHA_SIZE:
parselist++;
{
GLint size = *parselist++;
- accum_size = MAX2( accum_size, size );
+ accumAlphaSize = MAX2( accumAlphaSize, size );
}
break;
@@ -961,6 +1000,14 @@ Fake_glXChooseVisual( Display *dpy, int screen, int *list )
parselist++;
break;
+ /*
+ * GLX_EXT_visual_info extension
+ */
+ case GLX_VISUAL_CAVEAT_EXT:
+ parselist++;
+ caveat = *parselist++; /* ignored for now */
+ break;
+
case None:
break;
default:
@@ -990,7 +1037,7 @@ Fake_glXChooseVisual( Display *dpy, int screen, int *list )
else {
/* Get a color index visual */
vis = choose_x_visual( dpy, screen, rgb_flag, min_ci, visual_type );
- accum_size = 0;
+ accumRedSize = accumGreenSize = accumBlueSize = accumAlphaSize = 0;
}
}
else {
@@ -1013,9 +1060,33 @@ Fake_glXChooseVisual( Display *dpy, int screen, int *list )
}
if (vis) {
+ /* Note: we're not exactly obeying the glXChooseVisual rules here.
+ * When GLX_DEPTH_SIZE = 1 is specified we're supposed to choose the
+ * largest depth buffer size, which is 32bits/value. However, we
+ * return 16 to maintain performance with earlier versions of Mesa.
+ */
+ if (depth_size == 1)
+ depth_size = DEFAULT_SOFTWARE_DEPTH_BITS;
+ else if (depth_size > 24)
+ depth_size = 31;
+ else if (depth_size > 16)
+ depth_size = 24;
+ /* we only support one size of stencil and accum buffers. */
+ if (stencil_size > 0)
+ stencil_size = STENCIL_BITS;
+ if (accumRedSize > 0)
+ accumRedSize = ACCUM_BITS;
+ if (accumGreenSize > 0)
+ accumGreenSize = ACCUM_BITS;
+ if (accumBlueSize > 0)
+ accumBlueSize = ACCUM_BITS;
+ if (accumAlphaSize > 0)
+ accumAlphaSize = ACCUM_BITS;
if (!save_glx_visual( dpy, vis, rgb_flag, alpha_flag, double_flag,
- stereo_flag,
- depth_size, stencil_size, accum_size, level ))
+ stereo_flag, depth_size, stencil_size,
+ accumRedSize, accumGreenSize,
+ accumBlueSize, accumAlphaSize,
+ level ))
return NULL;
}
@@ -1227,6 +1298,7 @@ Fake_glXQueryExtension( Display *dpy, int *errorb, int *event )
}
+extern void _kw_ungrab_all( Display *dpy );
void _kw_ungrab_all( Display *dpy )
{
XUngrabPointer( dpy, CurrentTime );
@@ -1372,15 +1444,16 @@ Fake_glXGetConfig( Display *dpy, XVisualInfo *visinfo,
*value = glxvis->gl_visual->StencilBits;
return 0;
case GLX_ACCUM_RED_SIZE:
+ *value = glxvis->gl_visual->AccumRedBits;
+ return 0;
case GLX_ACCUM_GREEN_SIZE:
+ *value = glxvis->gl_visual->AccumGreenBits;
+ return 0;
case GLX_ACCUM_BLUE_SIZE:
- *value = glxvis->gl_visual->AccumBits;
+ *value = glxvis->gl_visual->AccumBlueBits;
return 0;
case GLX_ACCUM_ALPHA_SIZE:
- if (glxvis->gl_visual->AlphaBits > 0)
- *value = glxvis->gl_visual->AccumBits;
- else
- *value = 0;
+ *value = glxvis->gl_visual->AccumAlphaBits;
return 0;
/*
@@ -1438,6 +1511,17 @@ Fake_glXGetConfig( Display *dpy, XVisualInfo *visinfo,
return 0;
/*
+ * GLX_EXT_visual_info extension
+ */
+ case GLX_VISUAL_CAVEAT_EXT:
+ /* test for zero, just in case */
+ if (glxvis->VisualCaveat > 0)
+ *value = glxvis->VisualCaveat;
+ else
+ *value = GLX_NONE_EXT;
+ return 0;
+
+ /*
* Extensions
*/
default:
@@ -1472,10 +1556,10 @@ static const char *get_extensions( void )
#ifdef FX
const char *fx = getenv("MESA_GLX_FX");
if (fx && fx[0] != 'd') {
- return "GLX_MESA_pixmap_colormap GLX_EXT_visual_info GLX_MESA_release_buffers GLX_MESA_copy_sub_buffer GLX_SGI_video_sync GLX_MESA_set_3dfx_mode GLX_ARB_get_proc_address";
+ return "GLX_MESA_pixmap_colormap GLX_EXT_visual_info GLX_EXT_visual_rating GLX_MESA_release_buffers GLX_MESA_copy_sub_buffer GLX_SGI_video_sync GLX_MESA_set_3dfx_mode GLX_ARB_get_proc_address";
}
#endif
- return "GLX_MESA_pixmap_colormap GLX_EXT_visual_info GLX_MESA_release_buffers GLX_MESA_copy_sub_buffer GLX_SGI_video_sync GLX_ARB_get_proc_address";
+ return "GLX_MESA_pixmap_colormap GLX_EXT_visual_info GLX_EXT_visual_rating GLX_MESA_release_buffers GLX_MESA_copy_sub_buffer GLX_SGI_video_sync GLX_ARB_get_proc_address";
}
@@ -1544,7 +1628,7 @@ Fake_glXGetClientString( Display *dpy, int name )
* GLX 1.3 and later
*/
-static GLXFBConfig
+static GLXFBConfig *
Fake_glXChooseFBConfig( Display *dpy, int screen,
const int *attribList, int *nitems )
{
@@ -1568,6 +1652,16 @@ Fake_glXGetFBConfigAttrib( Display *dpy, GLXFBConfig config,
}
+static GLXFBConfig *
+Fake_glXGetFBConfigs( Display *dpy, int screen, int *nelements )
+{
+ (void) dpy;
+ (void) screen;
+ (void) nelements;
+ return 0;
+}
+
+
static XVisualInfo *
Fake_glXGetVisualFromFBConfig( Display *dpy, GLXFBConfig config )
{
@@ -1745,6 +1839,7 @@ Fake_glXWaitVideoSyncSGI(int divisor, int remainder, unsigned int *count)
extern void Fake_glXUseXFont( Font font, int first, int count, int listbase );
+extern struct _glxapi_table *_mesa_GetGLXDispatchTable(void);
struct _glxapi_table *_mesa_GetGLXDispatchTable(void)
{
static struct _glxapi_table glx;