DRI2: Drop sarea, implement swap buffers in the X server.
[mesa.git] / src / glx / x11 / glxclient.h
index 002f7693a0c4dffba0e89ac207af6e52a2030b29..412511247efa4c89365c06dddf230da9f9b007cf 100644 (file)
@@ -59,7 +59,6 @@
 #include "GL/glxproto.h"
 #include "GL/internal/glcore.h"
 #include "glapitable.h"
-#include "glxextensions.h"
 #include "glxhash.h"
 #if defined( USE_XTHREADS )
 # include <X11/Xthreads.h>
@@ -67,6 +66,8 @@
 # include <pthread.h>
 #endif
 
+#include "glxextensions.h"
+
 #define GLX_MAJOR_VERSION      1       /* current version numbers */
 #define GLX_MINOR_VERSION      4
 
@@ -92,44 +93,67 @@ typedef struct _glapi_table __GLapi;
  * Display dependent methods.  This structure is initialized during the
  * \c driCreateDisplay call.
  */
-struct __DRIdisplayRec {
+typedef struct __GLXDRIdisplayRec __GLXDRIdisplay;
+typedef struct __GLXDRIscreenRec __GLXDRIscreen;
+typedef struct __GLXDRIdrawableRec __GLXDRIdrawable;
+typedef struct __GLXDRIcontextRec __GLXDRIcontext;
+
+#include "glxextensions.h"
+
+struct __GLXDRIdisplayRec {
     /**
      * Method to destroy the private DRI display data.
      */
-    void (*destroyDisplay)(Display *dpy, void *displayPrivate);
+    void (*destroyDisplay)(__GLXDRIdisplay *display);
 
-    /**
-     * Opaque pointer to private per display direct rendering data.
-     * \c NULL if direct rendering is not supported on this display.
-     */
-    struct __DRIdisplayPrivateRec *private;
+    __GLXDRIscreen *(*createScreen)(__GLXscreenConfigs *psc, int screen,
+                                   __GLXdisplayPrivate *priv);
+};
 
-    /**
-     * Array of pointers to methods to create and initialize the private DRI
-     * screen data.
-     */
-    PFNCREATENEWSCREENFUNC * createNewScreen;
+struct __GLXDRIscreenRec {
+
+    void (*destroyScreen)(__GLXscreenConfigs *psc);
+
+    __GLXDRIcontext *(*createContext)(__GLXscreenConfigs *psc,
+                                     const __GLcontextModes *mode,
+                                     GLXContext gc,
+                                     GLXContext shareList, int renderType);
+       
+    __GLXDRIdrawable *(*createDrawable)(__GLXscreenConfigs *psc,
+                                       XID drawable,
+                                       GLXDrawable glxDrawable,
+                                       const __GLcontextModes *modes);
+
+    void (*swapBuffers)(__GLXDRIdrawable *pdraw);
 };
 
+struct __GLXDRIcontextRec {
+    void (*destroyContext)(__GLXDRIcontext *context, __GLXscreenConfigs *psc,
+                          Display *dpy);
+    Bool (*bindContext)(__GLXDRIcontext *context,
+                       __GLXDRIdrawable *pdraw,
+                       __GLXDRIdrawable *pread);
+    
+    void (*unbindContext)(__GLXDRIcontext *context);
+};
 
-/*
-** We keep a linked list of these structures, one per DRI device driver.
-*/
-struct __DRIdriverRec {
-   const char *name;
-   const char *libpath;
-   void *handle;
-   PFNCREATENEWSCREENFUNC createNewScreenFunc;
-   struct __DRIdriverRec *next;
+struct __GLXDRIdrawableRec {
+    void (*destroyDrawable)(__GLXDRIdrawable *drawable);
+
+    XID xDrawable;
+    XID drawable;
+    __GLXscreenConfigs *psc;
+    GLenum textureTarget;
+    __DRIdrawable *driDrawable;
 };
 
 /*
 ** Function to create and DRI display data and initialize the display
 ** dependent methods.
 */
-extern void *driCreateDisplay(Display *dpy, __DRIdisplay *pdisp);
-
-extern  __DRIdriver *driGetDriver(Display *dpy, int scrNum);
+extern __GLXDRIdisplay *driswCreateDisplay(Display *dpy);
+extern __GLXDRIdisplay *driCreateDisplay(Display *dpy);
+extern __GLXDRIdisplay *dri2CreateDisplay(Display *dpy);
 
 extern void DRI_glXUseXFont( Font font, int first, int count, int listbase );
 
@@ -141,8 +165,6 @@ extern const char *glXGetScreenDriver (Display *dpy, int scrNum);
 
 extern const char *glXGetDriverConfig (const char *driverName);
 
-extern Bool __glXWindowExists(Display *dpy, GLXDrawable draw);
-
 #endif
 
 /************************************************************************/
@@ -349,15 +371,8 @@ struct __GLXcontextRec {
     const __GLcontextModes * mode;
 
 #ifdef GLX_DIRECT_RENDERING
-    /**
-     * Per context direct rendering interface functions and data.
-     */
-    __DRIcontext driContext;
-
-    /**
-     * XID for the server side drm_context_t
-     */
-    XID hwContextID;
+    __GLXDRIcontext *driContext;
+    __DRIcontext *__driContext;
 #endif
 
     /**
@@ -452,29 +467,40 @@ struct __GLXscreenConfigsRec {
     /**
      * Per screen direct rendering interface functions and data.
      */
-    __DRIscreen driScreen;
+    __DRIscreen *__driScreen;
+    const __DRIcoreExtension *core;
+    const __DRIlegacyExtension *legacy;
+    const __DRIswrastExtension *swrast;
+    const __DRIdri2Extension *dri2;
     __glxHashTable *drawHash;
     Display *dpy;
-    int scr;
+    int scr, fd;
+    void *driver;
+
+    __GLXDRIscreen *driScreen;
 
 #ifdef __DRI_COPY_SUB_BUFFER
-    __DRIcopySubBufferExtension *copySubBuffer;
+    const __DRIcopySubBufferExtension *copySubBuffer;
 #endif
 
 #ifdef __DRI_SWAP_CONTROL
-    __DRIswapControlExtension *swapControl;
+    const __DRIswapControlExtension *swapControl;
 #endif
 
 #ifdef __DRI_ALLOCATE
-    __DRIallocateExtension *allocate;
+    const __DRIallocateExtension *allocate;
 #endif
 
 #ifdef __DRI_FRAME_TRACKING
-    __DRIframeTrackingExtension *frameTracking;
+    const __DRIframeTrackingExtension *frameTracking;
 #endif
 
 #ifdef __DRI_MEDIA_STREAM_COUNTER
-    __DRImediaStreamCounterExtension *msc;
+    const __DRImediaStreamCounterExtension *msc;
+#endif
+
+#ifdef __DRI_TEX_BUFFER
+    const __DRItexBufferExtension *texBuffer;
 #endif
 
 #endif
@@ -545,23 +571,12 @@ struct __GLXdisplayPrivateRec {
     /**
      * Per display direct rendering interface functions and data.
      */
-    __DRIdisplay driDisplay;
+    __GLXDRIdisplay *driswDisplay;
+    __GLXDRIdisplay *driDisplay;
+    __GLXDRIdisplay *dri2Display;
 #endif
 };
 
-#ifdef GLX_DIRECT_RENDERING
-
-struct __GLXdrawableRec {
-    XID drawable;
-    __GLXscreenConfigs *psc;
-    __DRIdrawable driDrawable;
-};
-
-#endif
-
-
-
-void __glXFreeContext(__GLXcontext*);
 
 extern GLubyte *__glXFlushRenderBuffer(__GLXcontext*, GLubyte*);
 
@@ -605,6 +620,10 @@ extern __GLXcontext *__glXcurrentContext;
 
 #endif /* defined( USE_XTHREADS ) || defined( PTHREADS ) */
 
+extern void __glXSetCurrentContextNull(void);
+
+extern void __glXFreeContext(__GLXcontext*);
+
 
 /*
 ** Global lock for all threads in this address space using the GLX
@@ -679,9 +698,10 @@ extern void __glEmptyImage(__GLXcontext*, GLint, GLint, GLint, GLint, GLenum,
 
 
 /*
-** Allocate and Initialize Vertex Array client state 
+** Allocate and Initialize Vertex Array client state, and free.
 */
-extern void __glXInitVertexArrayState(__GLXcontext*);
+extern void __glXInitVertexArrayState(__GLXcontext *);
+extern void __glXFreeVertexArrayState(__GLXcontext *);
 
 /*
 ** Inform the Server of the major and minor numbers and of the client
@@ -722,7 +742,8 @@ extern GLboolean __glXGetMscRateOML(Display * dpy, GLXDrawable drawable,
 
 #ifdef GLX_DIRECT_RENDERING
 GLboolean
-__driGetMscRateOML(__DRIdrawable *draw, int32_t *numerator, int32_t *denominator);
+__driGetMscRateOML(__DRIdrawable *draw,
+                  int32_t *numerator, int32_t *denominator, void *private);
 #endif
 
 #endif /* !__GLX_client_h__ */