glx/dri3: Track separate (ust, msc) for PresentPixmap vs. PresentNotifyMsc (v2)
[mesa.git] / src / glx / glxclient.h
index 324b5a65c190144b662d8e26855a446ce8227d94..74c19c485643746173955a15200e026329488867 100644 (file)
 #include <string.h>
 #include <stdlib.h>
 #include <stdio.h>
-#ifdef WIN32
+#ifdef _WIN32
 #include <stdint.h>
 #endif
 #include "GL/glxproto.h"
-#include "glapi/glapitable.h"
 #include "glxconfig.h"
 #include "glxhash.h"
-#if defined( PTHREADS )
+#if defined( HAVE_PTHREAD )
 # include <pthread.h>
 #endif
 
@@ -89,8 +88,6 @@ typedef struct __GLXDRIdisplayRec __GLXDRIdisplay;
 typedef struct __GLXDRIscreenRec __GLXDRIscreen;
 typedef struct __GLXDRIdrawableRec __GLXDRIdrawable;
 
-#include "glxextensions.h"
-
 struct __GLXDRIdisplayRec
 {
     /**
@@ -116,9 +113,9 @@ struct __GLXDRIscreenRec {
                                       struct glx_config *config);
 
    int64_t (*swapBuffers)(__GLXDRIdrawable *pdraw, int64_t target_msc,
-                         int64_t divisor, int64_t remainder);
+                         int64_t divisor, int64_t remainder, Bool flush);
    void (*copySubBuffer)(__GLXDRIdrawable *pdraw,
-                        int x, int y, int width, int height);
+                        int x, int y, int width, int height, Bool flush);
    int (*getDrawableMSC)(struct glx_screen *psc, __GLXDRIdrawable *pdraw,
                         int64_t *ust, int64_t *msc, int64_t *sbc);
    int (*waitForMSC)(__GLXDRIdrawable *pdraw, int64_t target_msc,
@@ -128,6 +125,7 @@ struct __GLXDRIscreenRec {
                     int64_t *msc, int64_t *sbc);
    int (*setSwapInterval)(__GLXDRIdrawable *pdraw, int interval);
    int (*getSwapInterval)(__GLXDRIdrawable *pdraw);
+   int (*getBufferAge)(__GLXDRIdrawable *pdraw);
 };
 
 struct __GLXDRIdrawableRec
@@ -140,6 +138,7 @@ struct __GLXDRIdrawableRec
    GLenum textureTarget;
    GLenum textureFormat;        /* EXT_texture_from_pixmap support */
    unsigned long eventMask;
+   int refcount;
 };
 
 /*
@@ -152,6 +151,7 @@ extern __GLXDRIdisplay *dri2CreateDisplay(Display * dpy);
 extern void dri2InvalidateBuffers(Display *dpy, XID drawable);
 extern unsigned dri2GetSwapEventType(Display *dpy, XID drawable);
 
+extern __GLXDRIdisplay *dri3_create_display(Display * dpy);
 
 /*
 ** Functions to obtain driver configuration information from a direct
@@ -216,7 +216,7 @@ struct glx_context_vtable {
    void (*destroy)(struct glx_context *ctx);
    int (*bind)(struct glx_context *context, struct glx_context *old,
               GLXDrawable draw, GLXDrawable read);
-   void (*unbind)(struct glx_context *context, struct glx_context *new);
+   void (*unbind)(struct glx_context *context, struct glx_context *new_ctx);
    void (*wait_gl)(struct glx_context *ctx);
    void (*wait_x)(struct glx_context *ctx);
    void (*use_x_font)(struct glx_context *ctx,
@@ -225,12 +225,9 @@ struct glx_context_vtable {
                          GLXDrawable drawable,
                          int buffer, const int *attrib_list);
    void (*release_tex_image)(Display * dpy, GLXDrawable drawable, int buffer);
-   
+   void * (*get_proc_address)(const char *symbol);
 };
 
-extern void
-glx_send_destroy_context(Display *dpy, XID xid);
-
 /**
  * GLX state that needs to be kept on the client.  One of these records
  * exist for each context that has been made current by this client.
@@ -311,14 +308,6 @@ struct glx_context
    GLuint *selectBuf;
    /*@} */
 
-    /**
-     * This is \c GL_TRUE if the pixel unpack modes are such that an image
-     * can be unpacked from the clients memory by just copying.  It may
-     * still be true that the server will have to do some work.  This
-     * just promises that a straight copy will fetch the correct bytes.
-     */
-   GLboolean fastImageUnpack;
-
     /**
      * Fill newImage with the unpacked form of \c oldImage getting it
      * ready for transport to the server.
@@ -343,6 +332,10 @@ struct glx_context
      */
    Bool isDirect;
 
+#if defined(GLX_DIRECT_RENDERING) && defined(GLX_USE_APPLEGL)
+   void *driContext;
+#endif
+
     /**
      * \c dpy of current display for this context.  Will be \c NULL if not
      * current to any display, or if this is the "dummy context".
@@ -421,9 +414,9 @@ struct glx_context
    /*@} */
 
    /**
-    * Thread ID we're currently current in. Zero if none.
+    * Number of threads we're currently current in.
     */
-   unsigned long thread_id;
+   unsigned long thread_refcount;
 
    char gl_extension_bits[__GL_EXT_BYTES];
 };
@@ -476,6 +469,19 @@ struct glx_screen_vtable {
                                         struct glx_config *config,
                                         struct glx_context *shareList,
                                         int renderType);
+
+   struct glx_context *(*create_context_attribs)(struct glx_screen *psc,
+                                                struct glx_config *config,
+                                                struct glx_context *shareList,
+                                                unsigned num_attrib,
+                                                const uint32_t *attribs,
+                                                unsigned *error);
+   int (*query_renderer_integer)(struct glx_screen *psc,
+                                 int attribute,
+                                 unsigned int *value);
+   int (*query_renderer_string)(struct glx_screen *psc,
+                                int attribute,
+                                const char **value);
 };
 
 struct glx_screen
@@ -572,6 +578,8 @@ struct glx_display
      */
    struct glx_screen **screens;
 
+   __glxHashTable *glXDrawHash;
+
 #if defined(GLX_DIRECT_RENDERING) && !defined(GLX_USE_APPLEGL)
    __glxHashTable *drawHash;
 
@@ -581,12 +589,23 @@ struct glx_display
    __GLXDRIdisplay *driswDisplay;
    __GLXDRIdisplay *driDisplay;
    __GLXDRIdisplay *dri2Display;
+   __GLXDRIdisplay *dri3Display;
 #endif
 };
 
+struct glx_drawable {
+   XID xDrawable;
+   XID drawable;
+
+   uint32_t lastEventSbc;
+   int64_t eventSbcWrap;
+};
+
 extern int
 glx_screen_init(struct glx_screen *psc,
                int screen, struct glx_display * priv);
+extern void
+glx_screen_cleanup(struct glx_screen *psc);
 
 #if defined(GLX_DIRECT_RENDERING) && !defined(GLX_USE_APPLEGL)
 extern __GLXDRIdrawable *
@@ -612,7 +631,7 @@ extern void __glXPreferEGL(int state);
 extern int __glXDebug;
 
 /* This is per-thread storage in an MT environment */
-#if defined( PTHREADS )
+#if defined( HAVE_PTHREAD )
 
 extern void __glXSetCurrentContext(struct glx_context * c);
 
@@ -635,7 +654,7 @@ extern struct glx_context *__glXcurrentContext;
 #define __glXGetCurrentContext() __glXcurrentContext
 #define __glXSetCurrentContext(gc) __glXcurrentContext = gc
 
-#endif /* defined( PTHREADS ) */
+#endif /* defined( HAVE_PTHREAD ) */
 
 extern void __glXSetCurrentContextNull(void);
 
@@ -644,7 +663,7 @@ extern void __glXSetCurrentContextNull(void);
 ** Global lock for all threads in this address space using the GLX
 ** extension
 */
-#if defined( PTHREADS )
+#if defined( HAVE_PTHREAD )
 extern pthread_mutex_t __glXmutex;
 #define __glXLock()    pthread_mutex_lock(&__glXmutex)
 #define __glXUnlock()  pthread_mutex_unlock(&__glXmutex)
@@ -722,6 +741,9 @@ extern void __glXFreeVertexArrayState(struct glx_context *);
 */
 extern void __glXClientInfo(Display * dpy, int opcode);
 
+_X_HIDDEN void
+__glX_send_client_info(struct glx_display *glx_dpy);
+
 /************************************************************************/
 
 /*
@@ -760,7 +782,7 @@ extern GLboolean __glXGetMscRateOML(Display * dpy, GLXDrawable drawable,
 
 #if defined(GLX_DIRECT_RENDERING) && !defined(GLX_USE_APPLEGL)
 extern GLboolean
-__glxGetMscRate(__GLXDRIdrawable *glxDraw,
+__glxGetMscRate(struct glx_screen *psc,
                int32_t * numerator, int32_t * denominator);
 
 /* So that dri2.c:DRI2WireToEvent() can access
@@ -772,9 +794,32 @@ GarbageCollectDRIDrawables(struct glx_screen *psc);
 
 extern __GLXDRIdrawable *
 GetGLXDRIDrawable(Display *dpy, GLXDrawable drawable);
+#endif
+
+extern struct glx_screen *GetGLXScreenConfigs(Display * dpy, int scrn);
 
+#ifdef GLX_USE_APPLEGL
+extern struct glx_screen *
+applegl_create_screen(int screen, struct glx_display * priv);
+
+extern struct glx_context *
+applegl_create_context(struct glx_screen *psc,
+                       struct glx_config *mode,
+                       struct glx_context *shareList, int renderType);
+
+extern int
+applegl_create_display(struct glx_display *display);
 #endif
 
+extern Bool validate_renderType_against_config(const struct glx_config *config,
+                                               int renderType);
+
+
+extern struct glx_drawable *GetGLXDrawable(Display *dpy, GLXDrawable drawable);
+extern int InitGLXDrawable(Display *dpy, struct glx_drawable *glxDraw,
+                          XID xDrawable, GLXDrawable drawable);
+extern void DestroyGLXDrawable(Display *dpy, GLXDrawable drawable);
+
 extern struct glx_context dummyContext;
 
 extern struct glx_screen *
@@ -783,5 +828,12 @@ extern struct glx_context *
 indirect_create_context(struct glx_screen *psc,
                        struct glx_config *mode,
                        struct glx_context *shareList, int renderType);
+extern struct glx_context *
+indirect_create_context_attribs(struct glx_screen *base,
+                                struct glx_config *config_base,
+                                struct glx_context *shareList,
+                                unsigned num_attribs,
+                                const uint32_t *attribs,
+                                unsigned *error);
 
 #endif /* !__GLX_client_h__ */