fix GLX_USE_TLS breakage, fix a warning
[mesa.git] / src / mesa / drivers / x11 / xmesaP.h
index 46886eb9c615a53f12e75111b2e5e19481063238..e3d7cf381f7c52d2d43faa955ca8ac30df10099e 100644 (file)
@@ -1,10 +1,8 @@
-/* $Id: xmesaP.h,v 1.35 2003/02/25 19:26:30 brianp Exp $ */
-
 /*
  * Mesa 3-D graphics library
- * Version:  5.0.1
+ * Version:  7.1
  *
- * Copyright (C) 1999-2003  Brian Paul   All Rights Reserved.
+ * Copyright (C) 1999-2007  Brian Paul   All Rights Reserved.
  *
  * Permission is hereby granted, free of charge, to any person obtaining a
  * copy of this software and associated documentation files (the "Software"),
 #define XMESAP_H
 
 
-#ifdef XFree86Server
-# include "GL/xf86glx.h"
-# include "xf86glx_util.h"
-#else
-# ifdef USE_XSHM
-#  include <X11/extensions/XShm.h>
-# endif
-#endif
 #include "GL/xmesa.h"
 #include "mtypes.h"
 #if defined(FX)
 #include "GL/fxmesa.h"
-#include "FX/fxdrv.h"
+#include "xm_glide.h"
+#endif
+#ifdef XFree86Server
+#include "xm_image.h"
 #endif
 
 
 extern _glthread_Mutex _xmesa_lock;
 
+extern XMesaBuffer XMesaBufferList;
 
 /* for PF_8R8G8B24 pixel format */
 typedef struct {
@@ -56,10 +50,12 @@ typedef struct {
 } bgr_t;
 
 
+struct xmesa_renderbuffer;
+
+
 /* Function pointer for clearing color buffers */
-typedef void (*clear_func)( GLcontext *ctx,
-                            GLboolean all, GLint x, GLint y,
-                            GLint width, GLint height );
+typedef void (*ClearFunc)( GLcontext *ctx, struct xmesa_renderbuffer *xrb,
+                           GLint x, GLint y, GLint width, GLint height );
 
 
 
@@ -69,36 +65,36 @@ enum pixel_format {
    PF_Index,           /**< Color Index mode */
    PF_Truecolor,       /**< TrueColor or DirectColor, any depth */
    PF_Dither_True,     /**< TrueColor with dithering */
-   PF_8A8B8G8R,                /**< 32-bit TrueColor:  8-A, 8-B, 8-G, 8-R */
+   PF_8A8R8G8B,                /**< 32-bit TrueColor:  8-A, 8-R, 8-G, 8-B bits */
+   PF_8A8B8G8R,                /**< 32-bit TrueColor:  8-A, 8-B, 8-G, 8-R bits */
    PF_8R8G8B,          /**< 32-bit TrueColor:  8-R, 8-G, 8-B bits */
+   PF_8R8G8B24,                /**< 24-bit TrueColor:  8-R, 8-G, 8-B bits */
    PF_5R6G5B,          /**< 16-bit TrueColor:  5-R, 6-G, 5-B bits */
    PF_Dither,          /**< Color-mapped RGB with dither */
    PF_Lookup,          /**< Color-mapped RGB without dither */
    PF_HPCR,            /**< HP Color Recovery (ad@lms.be 30/08/95) */
    PF_1Bit,            /**< monochrome dithering of RGB */
    PF_Grayscale,       /**< Grayscale or StaticGray */
-   PF_8R8G8B24,                /**< 24-bit TrueColor: 8-R, 8-G, 8-B bits */
    PF_Dither_5R6G5B    /**< 16-bit dithered TrueColor: 5-R, 6-G, 5-B */
 };
 
 
-/*
- * "Derived" from GLvisual.  Basically corresponds to an XVisualInfo.
+/**
+ * Visual inforation, derived from GLvisual.
+ * Basically corresponds to an XVisualInfo.
  */
 struct xmesa_visual {
    GLvisual mesa_visual;       /* Device independent visual parameters */
    XMesaDisplay *display;      /* The X11 display */
 #ifdef XFree86Server
-   GLint screen_depth;         /* The depth of the screen */
+   GLint ColormapEntries;
+   GLint nplanes;
 #else
+   XMesaVisualInfo visinfo;    /* X's visual info (pointer to private copy) */
    XVisualInfo *vishandle;     /* Only used in fakeglx.c */
 #endif
-   XMesaVisualInfo visinfo;    /* X's visual info (pointer to private copy) */
    GLint BitsPerPixel;         /* True bits per pixel for XImages */
 
-   GLint level;                        /* 0=normal, 1=overlay, etc */
-   GLint VisualCaveat;          /* for GLX_EXT_visual_rating extension */
-
    GLboolean ximage_flag;      /* Use XImage for back buffer (not pixmap)? */
 
    enum pixel_format dithered_pf;  /* Pixel format when dithering */
@@ -108,9 +104,6 @@ struct xmesa_visual {
    GLfloat GreenGamma;
    GLfloat BlueGamma;
 
-   GLint rmult, gmult, bmult;  /* Range of color values */
-   GLint index_bits;           /* Bits per pixel in CI mode */
-
    /* For PF_TRUECOLOR */
    GLint rshift, gshift, bshift;/* Pixel color component shifts */
    GLubyte Kernel[16];         /* Dither kernel */
@@ -133,14 +126,13 @@ struct xmesa_visual {
 };
 
 
-/*
- * "Derived" from __GLcontextRec.  Basically corresponds to a GLXContext.
+/**
+ * Context info, dDerived from GLcontext.
+ * Basically corresponds to a GLXContext.
  */
 struct xmesa_context {
-   GLcontext *gl_ctx;          /* the core library context */
+   GLcontext mesa;             /* the core library context (containment) */
    XMesaVisual xm_visual;      /* Describes the buffers */
-   XMesaBuffer xm_draw_buffer; /* current draw framebuffer */
-   XMesaBuffer xm_read_buffer; /* current read framebuffer */
    XMesaBuffer xm_buffer;      /* current span/point/line/triangle buffer */
 
    XMesaDisplay *display;      /* == xm_visual->display */
@@ -154,7 +146,9 @@ struct xmesa_context {
 };
 
 
-
+/**
+ * Types of X/GLX drawables we might render into.
+ */
 typedef enum {
    WINDOW,          /* An X window */
    GLXWINDOW,       /* GLX window */
@@ -163,8 +157,51 @@ typedef enum {
 } BufferType;
 
 
-/*
- * "Derived" from GLframebuffer.  Basically corresponds to a GLXDrawable.
+/** Values for db_mode: */
+/*@{*/
+#define BACK_PIXMAP    1
+#define BACK_XIMAGE    2
+/*@}*/
+
+
+/**
+ * An xmesa_renderbuffer represents the back or front color buffer.
+ * For the front color buffer:
+ *    <drawable> is the X window
+ * For the back color buffer:
+ *    Either <ximage> or <pixmap> will be used, never both.
+ * In any case, <drawable> always equals <pixmap>.
+ * For stand-alone Mesa, we could merge <drawable> and <pixmap> into one
+ * field.  We don't do that for the server-side GLcore module because
+ * pixmaps and drawables are different and we'd need a bunch of casts.
+ */
+struct xmesa_renderbuffer
+{
+   struct gl_renderbuffer Base;  /* Base class */
+
+   XMesaBuffer Parent;  /**< The XMesaBuffer this renderbuffer belongs to */
+   XMesaDrawable drawable;     /* Usually the X window ID */
+   XMesaPixmap pixmap; /* Back color buffer */
+   XMesaImage *ximage; /* The back buffer, if not using a Pixmap */
+
+   GLubyte *origin1;   /* used for PIXEL_ADDR1 macro */
+   GLint width1;
+   GLushort *origin2;  /* used for PIXEL_ADDR2 macro */
+   GLint width2;
+   GLubyte *origin3;   /* used for PIXEL_ADDR3 macro */
+   GLint width3;
+   GLuint *origin4;    /* used for PIXEL_ADDR4 macro */
+   GLint width4;
+
+   GLint bottom;       /* used for FLIP macro, equals height - 1 */
+
+   ClearFunc clearFunc;
+};
+
+
+/**
+ * Framebuffer information, derived from.
+ * Basically corresponds to a GLXDrawable.
  */
 struct xmesa_buffer {
    GLframebuffer mesa_buffer;  /* depth, stencil, accum, etc buffers */
@@ -174,45 +211,28 @@ struct xmesa_buffer {
 
    XMesaDisplay *display;
    BufferType type;             /* window, pixmap, pbuffer or glxwindow */
-   XMesaDrawable frontbuffer;  /* either a window or pixmap */
-   XMesaPixmap backpixmap;     /* back buffer Pixmap */
-   XMesaImage *backimage;      /* back buffer simulated XImage */
 
-   XMesaDrawable buffer;       /* the current buffer, either equal to */
-                               /* frontbuffer, backpixmap or XIMAGE (None) */
+   struct xmesa_renderbuffer *frontxrb; /* front color renderbuffer */
+   struct xmesa_renderbuffer *backxrb;  /* back color renderbuffer */
 
    XMesaColormap cmap;         /* the X colormap */
 
    unsigned long selectedEvents;/* for pbuffers only */
 
-   GLint db_state;             /* 0 = single buffered */
+   GLint db_mode;              /* 0 = single buffered */
                                /* BACK_PIXMAP = use Pixmap for back buffer */
                                /* BACK_XIMAGE = use XImage for back buffer */
+   GLboolean swAlpha;
 
-#ifndef XFree86Server
    GLuint shm;                 /* X Shared Memory extension status:    */
                                /*    0 = not available                 */
                                /*    1 = XImage support available      */
                                /*    2 = Pixmap support available too  */
-#ifdef USE_XSHM
+#if defined(USE_XSHM) && !defined(XFree86Server)
    XShmSegmentInfo shminfo;
-#endif
 #endif
 
    XMesaImage *rowimage;       /* Used for optimized span writing */
-
-   GLuint width, height;       /* size of buffer */
-
-   GLint bottom;               /* used for FLIP macro below */
-   GLubyte *ximage_origin1;    /* used for PIXELADDR1 macro */
-   GLint ximage_width1;
-   GLushort *ximage_origin2;   /* used for PIXELADDR2 macro */
-   GLint ximage_width2;
-   GLubyte *ximage_origin3;    /* used for PIXELADDR3 macro */
-   GLint ximage_width3;
-   GLuint *ximage_origin4;     /* used for PIXELADDR4 macro */
-   GLint ximage_width4;
-
    XMesaPixmap stipple_pixmap; /* For polygon stippling */
    XMesaGC stipple_gc;         /* For polygon stippling */
 
@@ -247,22 +267,16 @@ struct xmesa_buffer {
    fxMesaContext FXctx;
 #endif
 
-   /* functions for clearing the front and back color buffers */
-   clear_func front_clear_func;
-   clear_func back_clear_func;
+   /* GLX_EXT_texture_from_pixmap */
+   GLint TextureTarget; /** GLX_TEXTURE_1D_EXT, for example */
+   GLint TextureFormat; /** GLX_TEXTURE_FORMAT_RGB_EXT, for example */
+   GLint TextureMipmap; /** 0 or 1 */
 
    struct xmesa_buffer *Next;  /* Linked list pointer: */
 };
 
 
-
-/* Values for xmesa->dest: */
-#define FRONT_PIXMAP   1
-#define BACK_PIXMAP    2
-#define BACK_XIMAGE    4
-
-
-/*
+/**
  * If pixelformat==PF_TRUECOLOR:
  */
 #define PACK_TRUECOLOR( PIXEL, R, G, B )       \
@@ -271,7 +285,7 @@ struct xmesa_buffer {
          | xmesa->xm_visual->BtoPixel[B];      \
 
 
-/*
+/**
  * If pixelformat==PF_TRUEDITHER:
  */
 #define PACK_TRUEDITHER( PIXEL, X, Y, R, G, B )                        \
@@ -284,14 +298,14 @@ struct xmesa_buffer {
 
 
 
-/*
+/**
  * If pixelformat==PF_8A8B8G8R:
  */
 #define PACK_8A8B8G8R( R, G, B, A )    \
        ( ((A) << 24) | ((B) << 16) | ((G) << 8) | (R) )
 
 
-/*
+/**
  * Like PACK_8A8B8G8R() but don't use alpha.  This is usually an acceptable
  * shortcut.
  */
@@ -299,21 +313,27 @@ struct xmesa_buffer {
 
 
 
-/*
+/**
  * If pixelformat==PF_8R8G8B:
  */
 #define PACK_8R8G8B( R, G, B)   ( ((R) << 16) | ((G) << 8) | (B) )
 
 
-/*
+/**
  * If pixelformat==PF_5R6G5B:
  */
 #define PACK_5R6G5B( R, G, B)   ( (((R) & 0xf8) << 8) | (((G) & 0xfc) << 3) | ((B) >> 3) )
 
 
+/**
+ * If pixelformat==PF_8A8R8G8B:
+ */
+#define PACK_8A8R8G8B( R, G, B, A )    \
+       ( ((A) << 24) | ((R) << 16) | ((G) << 8) | (B) )
 
 
-/*
+
+/**
  * If pixelformat==PF_DITHER:
  *
  * Improved 8-bit RGB dithering code contributed by Bob Mercier
@@ -334,24 +354,18 @@ struct xmesa_buffer {
 #define DITH_DY        4
 #define DITH_N (DITH_DX * DITH_DY)
 
-/*#define _dither(C,c,d)       (((unsigned)((DITH_N*(C-1)+1)*c+d))/(DITH_N*256))*/
 #define _dither(C, c, d)   (((unsigned)((DITH_N * (C - 1) + 1) * c + d)) >> 12)
 
 #define MAXC   256
-static int kernel8[DITH_DY * DITH_DX] = {
-    0 * MAXC,  8 * MAXC,  2 * MAXC, 10 * MAXC,
-   12 * MAXC,  4 * MAXC, 14 * MAXC,  6 * MAXC,
-    3 * MAXC, 11 * MAXC,  1 * MAXC,  9 * MAXC,
-   15 * MAXC,  7 * MAXC, 13 * MAXC,  5 * MAXC,
-};
+extern const int xmesa_kernel8[DITH_DY * DITH_DX];
 
 /* Dither for random X,Y */
 #define DITHER_SETUP                                           \
        int __d;                                                \
-       unsigned long *ctable = xmesa->xm_buffer->color_table;
+       unsigned long *ctable = XMESA_BUFFER(ctx->DrawBuffer)->color_table;
 
 #define DITHER( X, Y, R, G, B )                                \
-       (__d = kernel8[(((Y)&3)<<2) | ((X)&3)],         \
+       (__d = xmesa_kernel8[(((Y)&3)<<2) | ((X)&3)],   \
         ctable[DITH_MIX(_dither(DITH_R, (R), __d),     \
                         _dither(DITH_G, (G), __d),     \
                         _dither(DITH_B, (B), __d))])
@@ -359,8 +373,8 @@ static int kernel8[DITH_DY * DITH_DX] = {
 /* Dither for random X, fixed Y */
 #define XDITHER_SETUP(Y)                                       \
        int __d;                                                \
-       unsigned long *ctable = xmesa->xm_buffer->color_table;  \
-       int *kernel = &kernel8[ ((Y)&3) << 2 ];
+       unsigned long *ctable = XMESA_BUFFER(ctx->DrawBuffer)->color_table;     \
+       const int *kernel = &xmesa_kernel8[ ((Y)&3) << 2 ];
 
 #define XDITHER( X, R, G, B )                          \
        (__d = kernel[(X)&3],                           \
@@ -374,36 +388,35 @@ static int kernel8[DITH_DY * DITH_DX] = {
  * Dithering for flat-shaded triangles.  Precompute all 16 possible
  * pixel values given the triangle's RGB color.  Contributed by Martin Shenk.
  */
-static GLushort DitherValues[16];   /* array of (up to) 16-bit pixel values */
-
 #define FLAT_DITHER_SETUP( R, G, B )                                   \
+       GLushort ditherValues[16];                                      \
        {                                                               \
-          unsigned long *ctable = xmesa->xm_buffer->color_table;       \
+          unsigned long *ctable = XMESA_BUFFER(ctx->DrawBuffer)->color_table;  \
           int msdr = (DITH_N*((DITH_R)-1)+1) * (R);                    \
           int msdg = (DITH_N*((DITH_G)-1)+1) * (G);                    \
           int msdb = (DITH_N*((DITH_B)-1)+1) * (B);                    \
           int i;                                                       \
           for (i=0;i<16;i++) {                                         \
-             int k = kernel8[i];                                       \
-             int j = DITH_MIX( (msdr+k)>>12, (msdg+k)>>12, (msdb+k)>>12 );     \
-             DitherValues[i] = (GLushort) ctable[j];                   \
+             int k = xmesa_kernel8[i];                                 \
+             int j = DITH_MIX( (msdr+k)>>12, (msdg+k)>>12, (msdb+k)>>12 );\
+             ditherValues[i] = (GLushort) ctable[j];                   \
           }                                                            \
         }
 
 #define FLAT_DITHER_ROW_SETUP(Y)                                       \
-       GLushort *ditherRow = DitherValues + ( ((Y)&3) << 2);
+       GLushort *ditherRow = ditherValues + ( ((Y)&3) << 2);
 
 #define FLAT_DITHER(X)  ditherRow[(X)&3]
 
 
 
-/*
+/**
  * If pixelformat==PF_LOOKUP:
  */
 #define _dither_lookup(C, c)   (((unsigned)((DITH_N * (C - 1) + 1) * c)) >> 12)
 
 #define LOOKUP_SETUP                                           \
-       unsigned long *ctable = xmesa->xm_buffer->color_table
+       unsigned long *ctable = XMESA_BUFFER(ctx->DrawBuffer)->color_table
 
 #define LOOKUP( R, G, B )                              \
        ctable[DITH_MIX(_dither_lookup(DITH_R, (R)),    \
@@ -411,8 +424,7 @@ static GLushort DitherValues[16];   /* array of (up to) 16-bit pixel values */
                        _dither_lookup(DITH_B, (B)))]
 
 
-
-/*
+/**
  * If pixelformat==PF_HPCR:
  *
  *      HP Color Recovery dithering               (ad@lms.be 30/08/95)
@@ -422,75 +434,55 @@ static GLushort DitherValues[16];   /* array of (up to) 16-bit pixel values */
  *      corresponding  colormap (see tkInitWindow) AND doing some special
  *      dither.
  */
-static const short HPCR_DRGB[3][2][16] = {
-{
-    { 16, -4,  1,-11, 14, -6,  3, -9, 15, -5,  2,-10, 13, -7,  4, -8},
-    {-15,  5,  0, 12,-13,  7, -2, 10,-14,  6, -1, 11,-12,  8, -3,  9}
-},
-{
-    {-11, 15, -7,  3, -8, 14, -4,  2,-10, 16, -6,  4, -9, 13, -5,  1},
-    { 12,-14,  8, -2,  9,-13,  5, -1, 11,-15,  7, -3, 10,-12,  6,  0}
-},
-{
-    {  6,-18, 26,-14,  2,-22, 30,-10,  8,-16, 28,-12,  4,-20, 32, -8},
-    { -4, 20,-24, 16,  0, 24,-28, 12, -6, 18,-26, 14, -2, 22,-30, 10}
-}
-};
+extern const short xmesa_HPCR_DRGB[3][2][16];
 
 #define DITHER_HPCR( X, Y, R, G, B )                                      \
-  ( ((xmesa->xm_visual->hpcr_rgbTbl[0][R] + HPCR_DRGB[0][(Y)&1][(X)&15]) & 0xE0)     \
-  |(((xmesa->xm_visual->hpcr_rgbTbl[1][G] + HPCR_DRGB[1][(Y)&1][(X)&15]) & 0xE0)>>3) \
-  | ((xmesa->xm_visual->hpcr_rgbTbl[2][B] + HPCR_DRGB[2][(Y)&1][(X)&15])>>6)      \
+  ( ((xmesa->xm_visual->hpcr_rgbTbl[0][R] + xmesa_HPCR_DRGB[0][(Y)&1][(X)&15]) & 0xE0)     \
+  |(((xmesa->xm_visual->hpcr_rgbTbl[1][G] + xmesa_HPCR_DRGB[1][(Y)&1][(X)&15]) & 0xE0)>>3) \
+  | ((xmesa->xm_visual->hpcr_rgbTbl[2][B] + xmesa_HPCR_DRGB[2][(Y)&1][(X)&15])>>6)        \
   )
 
 
 
-/*
+/**
  * If pixelformat==PF_1BIT:
  */
-static int const kernel1[16] = {
-   0*47,  9*47,  4*47, 12*47,     /* 47 = (255*3)/16 */
-   6*47,  2*47, 14*47,  8*47,
-  10*47,  1*47,  5*47, 11*47,
-   7*47, 13*47,  3*47, 15*47 };
+extern const int xmesa_kernel1[16];
 
 #define SETUP_1BIT  int bitFlip = xmesa->xm_visual->bitFlip
 #define DITHER_1BIT( X, Y, R, G, B )   \
-       (( ((int)(R)+(int)(G)+(int)(B)) > kernel1[(((Y)&3) << 2) | ((X)&3)] ) ^ bitFlip)
+       (( ((int)(R)+(int)(G)+(int)(B)) > xmesa_kernel1[(((Y)&3) << 2) | ((X)&3)] ) ^ bitFlip)
 
 
 
-/*
+/**
  * If pixelformat==PF_GRAYSCALE:
  */
-#define GRAY_RGB( R, G, B )   xmesa->xm_buffer->color_table[((R) + (G) + (B))/3]
+#define GRAY_RGB( R, G, B )   XMESA_BUFFER(ctx->DrawBuffer)->color_table[((R) + (G) + (B))/3]
 
 
 
-#define XIMAGE None
-
-
-/*
+/**
  * Converts a GL window Y coord to an X window Y coord:
  */
-#define FLIP(BUFFER, Y)  ((BUFFER)->bottom-(Y))
+#define YFLIP(XRB, Y)  ((XRB)->bottom - (Y))
 
 
-/*
- * Return the address of a 1, 2 or 4-byte pixel in the back XImage:
+/**
+ * Return the address of a 1, 2 or 4-byte pixel in the buffer's XImage:
  * X==0 is left, Y==0 is bottom.
  */
-#define PIXELADDR1( BUFFER, X, Y )  \
-   ( (BUFFER)->ximage_origin1 - (Y) * (BUFFER)->ximage_width1 + (X) )
+#define PIXEL_ADDR1(XRB, X, Y)  \
+   ( (XRB)->origin1 - (Y) * (XRB)->width1 + (X) )
 
-#define PIXELADDR2( BUFFER, X, Y )  \
-   ( (BUFFER)->ximage_origin2 - (Y) * (BUFFER)->ximage_width2 + (X) )
+#define PIXEL_ADDR2(XRB, X, Y)  \
+   ( (XRB)->origin2 - (Y) * (XRB)->width2 + (X) )
 
-#define PIXELADDR3( BUFFER, X, Y )  \
-   ( (bgr_t *) ( (BUFFER)->ximage_origin3 - (Y) * (BUFFER)->ximage_width3 + 3 * (X) ))
+#define PIXEL_ADDR3(XRB, X, Y)  \
+   ( (bgr_t *) ( (XRB)->origin3 - (Y) * (XRB)->width3 + 3 * (X) ))
 
-#define PIXELADDR4( BUFFER, X, Y )  \
-   ( (BUFFER)->ximage_origin4 - (Y) * (BUFFER)->ximage_width4 + (X) )
+#define PIXEL_ADDR4(XRB, X, Y)  \
+   ( (XRB)->origin4 - (Y) * (XRB)->width4 + (X) )
 
 
 
@@ -498,17 +490,76 @@ static int const kernel1[16] = {
  * External functions:
  */
 
+extern struct xmesa_renderbuffer *
+xmesa_new_renderbuffer(GLcontext *ctx, GLuint name, const GLvisual *visual,
+                       GLboolean backBuffer);
+
+extern void
+xmesa_delete_framebuffer(struct gl_framebuffer *fb);
+
+extern XMesaBuffer
+xmesa_find_buffer(XMesaDisplay *dpy, XMesaColormap cmap, XMesaBuffer notThis);
+
 extern unsigned long
-xmesa_color_to_pixel( XMesaContext xmesa,
+xmesa_color_to_pixel( GLcontext *ctx,
                       GLubyte r, GLubyte g, GLubyte b, GLubyte a,
                       GLuint pixelFormat );
 
-extern void xmesa_alloc_back_buffer( XMesaBuffer b );
+extern void
+xmesa_get_window_size(XMesaDisplay *dpy, XMesaBuffer b,
+                      GLuint *width, GLuint *height);
+
+extern void
+xmesa_check_and_update_buffer_size(XMesaContext xmctx, XMesaBuffer drawBuffer);
+
+extern void
+xmesa_init_driver_functions( XMesaVisual xmvisual,
+                             struct dd_function_table *driver );
+
+extern void
+xmesa_update_state( GLcontext *ctx, GLbitfield new_state );
+
+extern void
+xmesa_set_renderbuffer_funcs(struct xmesa_renderbuffer *xrb,
+                             enum pixel_format pixelformat, GLint depth);
 
-extern void xmesa_init_pointers( GLcontext *ctx );
-extern void xmesa_update_state( GLcontext *ctx, GLuint new_state );
+extern void
+xmesa_destroy_buffers_on_display(XMesaDisplay *dpy);
+
+
+/**
+ * Using a function instead of an ordinary cast is safer.
+ */
+static INLINE struct xmesa_renderbuffer *
+xmesa_renderbuffer(struct gl_renderbuffer *rb)
+{
+   return (struct xmesa_renderbuffer *) rb;
+}
+
+
+/**
+ * Return pointer to XMesaContext corresponding to a Mesa GLcontext.
+ * Since we're using structure containment, it's just a cast!.
+ * XXX should use inlined function for better type safety.
+ */
+static INLINE XMesaContext
+XMESA_CONTEXT(GLcontext *ctx)
+{
+   return (XMesaContext) ctx;
+}
+
+
+/**
+ * Return pointer to XMesaBuffer corresponding to a Mesa GLframebuffer.
+ * Since we're using structure containment, it's just a cast!.
+ * XXX should use inlined function for better type safety.
+ */
+static INLINE XMesaBuffer
+XMESA_BUFFER(GLframebuffer *b)
+{
+   return (XMesaBuffer) b;
+}
 
-extern void xmesa_update_span_funcs( GLcontext *ctx );
 
 /* Plugged into the software rasterizer.  Try to use internal
  * swrast-style point, line and triangle functions.
@@ -522,22 +573,14 @@ extern void xmesa_register_swrast_functions( GLcontext *ctx );
 
 
 
-/* XXX this is a hack to implement shared display lists with 3Dfx */
-extern XMesaBuffer XMesaCreateWindowBuffer2( XMesaVisual v,
-                                            XMesaWindow w,
-                                            XMesaContext c
-                                          );
-
-/*
- * These are the extra routines required for integration with XFree86.
- * None of these routines should be user visible. -KEM
- */
-extern void XMesaSetVisualDisplay( XMesaDisplay *dpy, XMesaVisual v );
-extern GLboolean XMesaForceCurrent(XMesaContext c);
-extern GLboolean XMesaLoseCurrent(XMesaContext c);
-extern void XMesaReset( void );
-
-extern void xmesa_resize_buffers( GLframebuffer *buffer );
+#define ENABLE_EXT_texure_compression_s3tc 0 /* SW texture compression */
 
+#ifdef XFree86Server
+#define ENABLE_EXT_timer_query 0
+#elif defined(__STDC_VERSION__) && __STDC_VERSION__ >= 199901L
+#define ENABLE_EXT_timer_query 1 /* should have 64-bit GLuint64EXT */
+#else
+#define ENABLE_EXT_timer_query 0 /* may not have 64-bit GLuint64EXT */
+#endif
 
 #endif