#include <string.h>
#include <stdlib.h>
#include <stdio.h>
-#ifdef WIN32
#include <stdint.h>
-#endif
+#include <pthread.h>
#include "GL/glxproto.h"
-#include "glapi/glapitable.h"
#include "glxconfig.h"
#include "glxhash.h"
-#if defined( PTHREADS )
-# include <pthread.h>
-#endif
+#include "util/macros.h"
#include "glxextensions.h"
-#define ARRAY_SIZE(a) (sizeof (a) / sizeof ((a)[0]))
+#if defined(USE_LIBGLVND)
+#define _GLX_PUBLIC _X_HIDDEN
+#else
+#define _GLX_PUBLIC _X_EXPORT
+#endif
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
#define GLX_MAJOR_VERSION 1 /* current version numbers */
#define GLX_MINOR_VERSION 4
#define __GLX_MAX_TEXTURE_UNITS 32
-typedef struct __GLXscreenConfigsRec __GLXscreenConfigs;
-typedef struct __GLXcontextRec __GLXcontext;
-typedef struct __GLXdrawableRec __GLXdrawable;
-typedef struct __GLXdisplayPrivateRec __GLXdisplayPrivate;
-typedef struct _glapi_table __GLapi;
+struct glx_display;
+struct glx_context;
/************************************************************************/
#ifdef GLX_DIRECT_RENDERING
-extern void DRI_glXUseXFont(GLXContext CC,
+extern void DRI_glXUseXFont(struct glx_context *ctx,
Font font, int first, int count, int listbase);
#endif
typedef struct __GLXDRIdisplayRec __GLXDRIdisplay;
typedef struct __GLXDRIscreenRec __GLXDRIscreen;
typedef struct __GLXDRIdrawableRec __GLXDRIdrawable;
-typedef struct __GLXDRIcontextRec __GLXDRIcontext;
-
-#include "glxextensions.h"
struct __GLXDRIdisplayRec
{
*/
void (*destroyDisplay) (__GLXDRIdisplay * display);
- __GLXscreenConfigs *(*createScreen)(int screen, __GLXdisplayPrivate * priv);
+ struct glx_screen *(*createScreen)(int screen, struct glx_display * priv);
};
struct __GLXDRIscreenRec {
- void (*destroyScreen)(__GLXscreenConfigs *psc);
+ void (*destroyScreen)(struct glx_screen *psc);
- __GLXcontext *(*createContext)(__GLXscreenConfigs *psc,
- struct glx_config *config,
- GLXContext shareList, int renderType);
+ struct glx_context *(*createContext)(struct glx_screen *psc,
+ struct glx_config *config,
+ struct glx_context *shareList,
+ int renderType);
- __GLXDRIdrawable *(*createDrawable)(__GLXscreenConfigs *psc,
+ __GLXDRIdrawable *(*createDrawable)(struct glx_screen *psc,
XID drawable,
GLXDrawable glxDrawable,
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 (*getDrawableMSC)(__GLXscreenConfigs *psc, __GLXDRIdrawable *pdraw,
+ 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,
int64_t divisor, int64_t remainder, int64_t *ust,
int64_t *msc, int64_t *sbc);
int (*setSwapInterval)(__GLXDRIdrawable *pdraw, int interval);
int (*getSwapInterval)(__GLXDRIdrawable *pdraw);
-};
-
-struct __GLXDRIcontextRec
-{
- Bool(*bindContext) (__GLXcontext *context, __GLXDRIdrawable *pdraw,
- __GLXDRIdrawable *pread);
- void (*unbindContext) (__GLXcontext *context);
+ int (*getBufferAge)(__GLXDRIdrawable *pdraw);
};
struct __GLXDRIdrawableRec
XID xDrawable;
XID drawable;
- __GLXscreenConfigs *psc;
+ struct glx_screen *psc;
GLenum textureTarget;
GLenum textureFormat; /* EXT_texture_from_pixmap support */
unsigned long eventMask;
+ int refcount;
};
/*
extern __GLXDRIdisplay *driswCreateDisplay(Display * dpy);
extern __GLXDRIdisplay *driCreateDisplay(Display * dpy);
extern __GLXDRIdisplay *dri2CreateDisplay(Display * dpy);
-extern void dri2InvalidateBuffers(Display *dpy, XID drawable);
+extern __GLXDRIdisplay *dri3_create_display(Display * dpy);
+extern __GLXDRIdisplay *driwindowsCreateDisplay(Display * dpy);
+/*
+**
+*/
+extern void dri2InvalidateBuffers(Display *dpy, XID drawable);
+extern unsigned dri2GetSwapEventType(Display *dpy, XID drawable);
/*
** Functions to obtain driver configuration information from a direct
__GLXattribute **stackPointer;
} __GLXattributeMachine;
+struct mesa_glinterop_device_info;
+struct mesa_glinterop_export_in;
+struct mesa_glinterop_export_out;
+
struct glx_context_vtable {
- void (*destroy)(__GLXcontext *ctx);
- void (*wait_gl)(__GLXcontext *ctx);
- void (*wait_x)(__GLXcontext *ctx);
- void (*use_x_font)(__GLXcontext *ctx,
+ 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_ctx);
+ void (*wait_gl)(struct glx_context *ctx);
+ void (*wait_x)(struct glx_context *ctx);
+ void (*use_x_font)(struct glx_context *ctx,
Font font, int first, int count, int listBase);
void (*bind_tex_image)(Display * dpy,
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);
+ int (*interop_query_device_info)(struct glx_context *ctx,
+ struct mesa_glinterop_device_info *out);
+ int (*interop_export_object)(struct glx_context *ctx,
+ struct mesa_glinterop_export_in *in,
+ struct mesa_glinterop_export_out *out);
};
-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.
*/
-struct __GLXcontextRec
+struct glx_context
{
/**
* \name Drawing command buffer.
GLint bufSize;
/*@} */
+ const struct glx_context_vtable *vtable;
+
/**
* The XID of this rendering context. When the context is created a
* new XID is allocated. This is set to None when the context is
* Screen number.
*/
GLint screen;
- __GLXscreenConfigs *psc;
+ struct glx_screen *psc;
/**
* \c GL_TRUE if the context was created with ImportContext, which
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.
- */
- void (*fillImage) (__GLXcontext *, GLint, GLint, GLint, GLint, GLenum,
- GLenum, const GLvoid *, GLubyte *, GLubyte *);
-
/**
* Client side attribs.
*/
*/
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".
*/
struct glx_config *config;
-#ifdef GLX_DIRECT_RENDERING
-#ifdef GLX_USE_APPLEGL
- void *driContext;
- Bool do_destroy;
-#else
- __GLXDRIcontext *driContext;
-#endif
-#endif
-
/**
* The current read-drawable for this context. Will be None if this
* context is not current to any drawable.
/*@} */
/**
- * 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];
+ /**
+ * GLX_ARB_create_context_no_error setting for this context.
+ * This needs to be kept here to enforce shared context rules.
+ */
+ Bool noError;
- const struct glx_context_vtable *vtable;
+ char gl_extension_bits[__GL_EXT_BYTES];
};
extern Bool
-glx_context_init(__GLXcontext *gc,
- __GLXscreenConfigs *psc, struct glx_config *fbconfig);
+glx_context_init(struct glx_context *gc,
+ struct glx_screen *psc, struct glx_config *fbconfig);
#define __glXSetError(gc,code) \
if (!(gc)->error) { \
(gc)->error = code; \
}
-extern void __glFreeAttributeState(__GLXcontext *);
+extern void __glFreeAttributeState(struct glx_context *);
/************************************************************************/
* a pointer to the config data for that screen (if the screen supports GL).
*/
struct glx_screen_vtable {
- __GLXcontext *(*create_context)(__GLXscreenConfigs *psc,
- struct glx_config *config,
- GLXContext shareList, int renderType);
+ struct glx_context *(*create_context)(struct glx_screen *psc,
+ 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 __GLXscreenConfigsRec
+struct glx_screen
{
const struct glx_screen_vtable *vtable;
*/
char *effectiveGLXexts;
- __GLXdisplayPrivate *display;
+ struct glx_display *display;
+
+ Display *dpy;
+ int scr;
#if defined(GLX_DIRECT_RENDERING) && !defined(GLX_USE_APPLEGL)
/**
* Per screen direct rendering interface functions and data.
*/
- Display *dpy;
- int scr;
-
__GLXDRIscreen *driScreen;
#endif
* Per-screen dynamic GLX extension tracking. The \c direct_support
* field only contains enough bits for 64 extensions. Should libGL
* ever need to track more than 64 GLX extensions, we can safely grow
- * this field. The \c __GLXscreenConfigs structure is not used outside
+ * this field. The \c struct glx_screen structure is not used outside
* libGL.
*/
/*@{ */
* Per display private data. One of these records exists for each display
* that is using the OpenGL (GLX) extension.
*/
-struct __GLXdisplayPrivateRec
+struct glx_display
{
/* The extension protocol codes */
XExtCodes *codes;
- struct __GLXdisplayPrivateRec *next;
+ struct glx_display *next;
/**
* Back pointer to the display
* Also, per screen data which now includes the server \c GLX_EXTENSION
* string.
*/
- __GLXscreenConfigs **screenConfigs;
+ struct glx_screen **screens;
+
+ __glxHashTable *glXDrawHash;
#if defined(GLX_DIRECT_RENDERING) && !defined(GLX_USE_APPLEGL)
__glxHashTable *drawHash;
__GLXDRIdisplay *driswDisplay;
__GLXDRIdisplay *driDisplay;
__GLXDRIdisplay *dri2Display;
+ __GLXDRIdisplay *dri3Display;
+#endif
+#ifdef GLX_USE_WINDOWSGL
+ __GLXDRIdisplay *windowsdriDisplay;
#endif
};
+struct glx_drawable {
+ XID xDrawable;
+ XID drawable;
+
+ uint32_t lastEventSbc;
+ int64_t eventSbcWrap;
+};
+
extern int
-glx_screen_init(__GLXscreenConfigs *psc,
- int screen, __GLXdisplayPrivate * priv);
+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 *
dri2GetGlxDrawableFromXDrawableId(Display *dpy, XID id);
#endif
-extern GLubyte *__glXFlushRenderBuffer(__GLXcontext *, GLubyte *);
+extern GLubyte *__glXFlushRenderBuffer(struct glx_context *, GLubyte *);
-extern void __glXSendLargeChunk(__GLXcontext * gc, GLint requestNumber,
+extern void __glXSendLargeChunk(struct glx_context * gc, GLint requestNumber,
GLint totalRequests,
const GLvoid * data, GLint dataLen);
-extern void __glXSendLargeCommand(__GLXcontext *, const GLvoid *, GLint,
+extern void __glXSendLargeCommand(struct glx_context *, const GLvoid *, GLint,
const GLvoid *, GLint);
/* Initialize the GLX extension for dpy */
-extern __GLXdisplayPrivate *__glXInitialize(Display *);
-
-extern void __glXPreferEGL(int state);
+extern struct glx_display *__glXInitialize(Display *);
/************************************************************************/
extern int __glXDebug;
/* This is per-thread storage in an MT environment */
-#if defined( PTHREADS )
-extern void __glXSetCurrentContext(__GLXcontext * c);
+extern void __glXSetCurrentContext(struct glx_context * c);
-# if defined( GLX_USE_TLS )
+# if defined( USE_ELF_TLS )
extern __thread void *__glX_tls_Context
__attribute__ ((tls_model("initial-exec")));
# else
-extern __GLXcontext *__glXGetCurrentContext(void);
-
-# endif /* defined( GLX_USE_TLS ) */
-
-#else
-
-extern __GLXcontext *__glXcurrentContext;
-#define __glXGetCurrentContext() __glXcurrentContext
-#define __glXSetCurrentContext(gc) __glXcurrentContext = gc
+extern struct glx_context *__glXGetCurrentContext(void);
-#endif /* defined( PTHREADS ) */
+# endif /* defined( USE_ELF_TLS ) */
extern void __glXSetCurrentContextNull(void);
** Global lock for all threads in this address space using the GLX
** extension
*/
-#if defined( PTHREADS )
extern pthread_mutex_t __glXmutex;
#define __glXLock() pthread_mutex_lock(&__glXmutex)
#define __glXUnlock() pthread_mutex_unlock(&__glXmutex)
-#else
-#define __glXLock()
-#define __glXUnlock()
-#endif
/*
** Setup for a command. Initialize the extension for dpy if necessary.
extern const GLuint __glXDefaultPixelStore[9];
/* Send an image to the server using RenderLarge. */
-extern void __glXSendLargeImage(__GLXcontext * gc, GLint compsize, GLint dim,
+extern void __glXSendLargeImage(struct glx_context * gc, GLint compsize, GLint dim,
GLint width, GLint height, GLint depth,
GLenum format, GLenum type,
const GLvoid * src, GLubyte * pc,
** updated to contain the modes needed by the server to decode the
** sent data.
*/
-extern void __glFillImage(__GLXcontext *, GLint, GLint, GLint, GLint, GLenum,
+extern void __glFillImage(struct glx_context *, GLint, GLint, GLint, GLint, GLenum,
GLenum, const GLvoid *, GLubyte *, GLubyte *);
/* Copy map data with a stride into a packed buffer */
** Empty an image out of the reply buffer into the clients memory applying
** the pack modes to pack back into the clients requested format.
*/
-extern void __glEmptyImage(__GLXcontext *, GLint, GLint, GLint, GLint, GLenum,
+extern void __glEmptyImage(struct glx_context *, GLint, GLint, GLint, GLint, GLenum,
GLenum, const GLubyte *, GLvoid *);
/*
** Allocate and Initialize Vertex Array client state, and free.
*/
-extern void __glXInitVertexArrayState(__GLXcontext *);
-extern void __glXFreeVertexArrayState(__GLXcontext *);
+extern void __glXInitVertexArrayState(struct glx_context *);
+extern void __glXFreeVertexArrayState(struct glx_context *);
/*
** Inform the Server of the major and minor numbers and of the client
*/
extern void __glXClientInfo(Display * dpy, int opcode);
+_X_HIDDEN void
+__glX_send_client_info(struct glx_display *glx_dpy);
+
/************************************************************************/
/*
extern char *__glXGetString(Display * dpy, int opcode,
CARD32 screen, CARD32 name);
-extern char *__glXstrdup(const char *str);
-
-
extern const char __glXGLClientVersion[];
extern const char __glXGLClientExtensions[];
#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
XExtDisplayInfo *__glXFindDisplay (Display *dpy);
extern void
-GarbageCollectDRIDrawables(__GLXscreenConfigs *psc);
+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 __GLXscreenConfigs *
-indirect_create_screen(int screen, __GLXdisplayPrivate * priv);
+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 *
+indirect_create_screen(int screen, struct glx_display * priv);
+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);
+
+
+extern int __glXGetDrawableAttribute(Display * dpy, GLXDrawable drawable,
+ int attribute, unsigned int *value);
+
+#ifdef __cplusplus
+}
+#endif
#endif /* !__GLX_client_h__ */