#ifdef GLX_DIRECT_RENDERING
#ifdef GLX_USE_APPLEGL
-#include "apple_glx_context.h"
-#include "apple_glx.h"
+#include "apple/apple_glx_context.h"
+#include "apple/apple_glx.h"
#else
#include <sys/time.h>
#ifdef XF86VIDMODE
#include <X11/extensions/xf86vmode.h>
#endif
-#include "xf86dri.h"
#endif
-#else
#endif
#include <X11/Xlib-xcb.h>
#include <xcb/xcb.h>
#include <xcb/glx.h>
+#include "GL/mesa_glinterop.h"
static const char __glXGLXClientVendorName[] = "Mesa Project and SGI";
static const char __glXGLXClientVersion[] = "1.4";
return (GLXContext) gc;
}
-_X_EXPORT GLXContext
+_GLX_PUBLIC GLXContext
glXCreateContext(Display * dpy, XVisualInfo * vis,
GLXContext shareList, Bool allowDirect)
{
** Destroy the named context
*/
-_X_EXPORT void
+_GLX_PUBLIC void
glXDestroyContext(Display * dpy, GLXContext ctx)
{
struct glx_context *gc = (struct glx_context *) ctx;
/*
** Return the major and minor version #s for the GLX extension
*/
-_X_EXPORT Bool
+_GLX_PUBLIC Bool
glXQueryVersion(Display * dpy, int *major, int *minor)
{
struct glx_display *priv;
}
/*
-** Query the existance of the GLX extension
+** Query the existence of the GLX extension
*/
-_X_EXPORT Bool
+_GLX_PUBLIC Bool
glXQueryExtension(Display * dpy, int *errorBase, int *eventBase)
{
int major_op, erb, evb;
** Put a barrier in the token stream that forces the GL to finish its
** work before X can proceed.
*/
-_X_EXPORT void
+_GLX_PUBLIC void
glXWaitGL(void)
{
struct glx_context *gc = __glXGetCurrentContext();
- if (gc && gc->vtable->wait_gl)
+ if (gc != &dummyContext && gc->vtable->wait_gl)
gc->vtable->wait_gl(gc);
}
** Put a barrier in the token stream that forces X to finish its
** work before GL can proceed.
*/
-_X_EXPORT void
+_GLX_PUBLIC void
glXWaitX(void)
{
struct glx_context *gc = __glXGetCurrentContext();
- if (gc && gc->vtable->wait_x)
+ if (gc != &dummyContext && gc->vtable->wait_x)
gc->vtable->wait_x(gc);
}
-_X_EXPORT void
+_GLX_PUBLIC void
glXUseXFont(Font font, int first, int count, int listBase)
{
struct glx_context *gc = __glXGetCurrentContext();
- if (gc && gc->vtable->use_x_font)
+ if (gc != &dummyContext && gc->vtable->use_x_font)
gc->vtable->use_x_font(gc, font, first, count, listBase);
}
** Copy the source context to the destination context using the
** attribute "mask".
*/
-_X_EXPORT void
+_GLX_PUBLIC void
glXCopyContext(Display * dpy, GLXContext source_user,
GLXContext dest_user, unsigned long mask)
{
* \c GLX_DIRECT_RENDERING is not defined? Do we really need to bother with
* the GLX protocol here at all?
*/
-_X_EXPORT Bool
+_GLX_PUBLIC Bool
glXIsDirect(Display * dpy, GLXContext gc_user)
{
struct glx_context *gc = (struct glx_context *) gc_user;
#endif
}
-_X_EXPORT GLXPixmap
+_GLX_PUBLIC GLXPixmap
glXCreateGLXPixmap(Display * dpy, XVisualInfo * vis, Pixmap pixmap)
{
#ifdef GLX_USE_APPLEGL
/*
** Destroy the named pixmap
*/
-_X_EXPORT void
+_GLX_PUBLIC void
glXDestroyGLXPixmap(Display * dpy, GLXPixmap glxpixmap)
{
#ifdef GLX_USE_APPLEGL
#endif /* GLX_USE_APPLEGL */
}
-_X_EXPORT void
+_GLX_PUBLIC void
glXSwapBuffers(Display * dpy, GLXDrawable drawable)
{
#ifdef GLX_USE_APPLEGL
__GLXDRIdrawable *pdraw = GetGLXDRIDrawable(dpy, drawable);
if (pdraw != NULL) {
- Bool flush = gc && drawable == gc->currentDrawable;
+ Bool flush = gc != &dummyContext && drawable == gc->currentDrawable;
(*pdraw->psc->driScreen->swapBuffers)(pdraw, 0, 0, 0, flush);
return;
** The calling thread may or may not have a current context. If it
** does, send the context tag so the server can do a flush.
*/
- if ((gc != NULL) && (dpy == gc->currentDpy) &&
+ if ((gc != &dummyContext) && (dpy == gc->currentDpy) &&
((drawable == gc->currentDrawable)
|| (drawable == gc->currentReadable))) {
tag = gc->currentContextTag;
** Return configuration information for the given display, screen and
** visual combination.
*/
-_X_EXPORT int
+_GLX_PUBLIC int
glXGetConfig(Display * dpy, XVisualInfo * vis, int attribute,
int *value_return)
{
fbconfig_compare(struct glx_config **a, struct glx_config **b)
{
/* The order of these comparisons must NOT change. It is defined by
- * the GLX 1.3 spec and ARB_multisample.
+ * the GLX 1.4 specification.
*/
PREFER_SMALLER(visualSelectGroup);
PREFER_SMALLER(numAuxBuffers);
+ PREFER_SMALLER(sampleBuffers);
+ PREFER_SMALLER(samples);
+
PREFER_LARGER_OR_ZERO(depthBits);
PREFER_SMALLER(stencilBits);
PREFER_SMALLER(visualType);
- /* None of the multisample specs say where this comparison should happen,
- * so I put it near the end.
- */
- PREFER_SMALLER(sampleBuffers);
- PREFER_SMALLER(samples);
-
/* None of the pbuffer or fbconfig specs say that this comparison needs
* to happen at all, but it seems like it should.
*/
** Return the visual that best matches the template. Return None if no
** visual matches the template.
*/
-_X_EXPORT XVisualInfo *
+_GLX_PUBLIC XVisualInfo *
glXChooseVisual(Display * dpy, int screen, int *attribList)
{
XVisualInfo *visualList = NULL;
}
-_X_EXPORT const char *
+_GLX_PUBLIC const char *
glXQueryExtensionsString(Display * dpy, int screen)
{
struct glx_screen *psc;
return psc->effectiveGLXexts;
}
-_X_EXPORT const char *
+_GLX_PUBLIC const char *
glXGetClientString(Display * dpy, int name)
{
(void) dpy;
}
}
-_X_EXPORT const char *
+_GLX_PUBLIC const char *
glXQueryServerString(Display * dpy, int screen, int name)
{
struct glx_screen *psc;
return *str;
}
-void
-__glXClientInfo(Display * dpy, int opcode)
-{
- char *ext_str = __glXGetClientGLExtensionString();
- int size = strlen(ext_str) + 1;
-
- xcb_connection_t *c = XGetXCBConnection(dpy);
- xcb_glx_client_info(c,
- GLX_MAJOR_VERSION, GLX_MINOR_VERSION, size, ext_str);
-
- free(ext_str);
-}
-
/*
** EXT_import_context
*/
-_X_EXPORT Display *
+_GLX_PUBLIC Display *
glXGetCurrentDisplay(void)
{
struct glx_context *gc = __glXGetCurrentContext();
- if (NULL == gc)
+ if (gc == &dummyContext)
return NULL;
return gc->currentDpy;
}
-_X_EXPORT
+_GLX_PUBLIC
GLX_ALIAS(Display *, glXGetCurrentDisplayEXT, (void), (),
glXGetCurrentDisplay)
#ifndef GLX_USE_APPLEGL
-_X_EXPORT GLXContext
+_GLX_PUBLIC GLXContext
glXImportContextEXT(Display *dpy, GLXContextID contextID)
{
struct glx_display *priv = __glXInitialize(dpy);
#endif
-_X_EXPORT int
+_GLX_PUBLIC int
glXQueryContext(Display * dpy, GLXContext ctx_user, int attribute, int *value)
{
struct glx_context *ctx = (struct glx_context *) ctx_user;
return Success;
}
-_X_EXPORT
+_GLX_PUBLIC
GLX_ALIAS(int, glXQueryContextInfoEXT,
(Display * dpy, GLXContext ctx, int attribute, int *value),
(dpy, ctx, attribute, value), glXQueryContext)
-_X_EXPORT GLXContextID glXGetContextIDEXT(const GLXContext ctx_user)
+_GLX_PUBLIC GLXContextID glXGetContextIDEXT(const GLXContext ctx_user)
{
struct glx_context *ctx = (struct glx_context *) ctx_user;
return (ctx == NULL) ? None : ctx->xid;
}
-_X_EXPORT void
+_GLX_PUBLIC void
glXFreeContextEXT(Display *dpy, GLXContext ctx)
{
struct glx_context *gc = (struct glx_context *) ctx;
__glXUnlock();
}
-_X_EXPORT GLXFBConfig *
+_GLX_PUBLIC GLXFBConfig *
glXChooseFBConfig(Display * dpy, int screen,
const int *attribList, int *nitems)
{
}
-_X_EXPORT GLXContext
+_GLX_PUBLIC GLXContext
glXCreateNewContext(Display * dpy, GLXFBConfig fbconfig,
int renderType, GLXContext shareList, Bool allowDirect)
{
struct glx_config *config = (struct glx_config *) fbconfig;
+ int screen = DefaultScreen(dpy);
+ struct glx_config **config_list;
+ int list_size;
+ unsigned i;
+
+ if (!config) {
+ __glXSendError(dpy, GLXBadFBConfig, 0, X_GLXCreateNewContext, false);
+ return NULL;
+ }
+
+ config_list = (struct glx_config **)
+ glXGetFBConfigs(dpy, screen, &list_size);
+
+ for (i = 0; i < list_size; i++) {
+ if (config_list[i] == config)
+ break;
+ }
+ free(config_list);
+
+ if (i == list_size) {
+ __glXSendError(dpy, GLXBadFBConfig, 0, X_GLXCreateNewContext, false);
+ return NULL;
+ }
return CreateContext(dpy, config->fbconfigID, config, shareList,
allowDirect, X_GLXCreateNewContext, renderType,
}
-_X_EXPORT GLXDrawable
+_GLX_PUBLIC GLXDrawable
glXGetCurrentReadDrawable(void)
{
struct glx_context *gc = __glXGetCurrentContext();
}
-_X_EXPORT GLXFBConfig *
+_GLX_PUBLIC GLXFBConfig *
glXGetFBConfigs(Display * dpy, int screen, int *nelements)
{
struct glx_display *priv = __glXInitialize(dpy);
*nelements = 0;
if (priv && (priv->screens != NULL)
- && (screen >= 0) && (screen <= ScreenCount(dpy))
+ && (screen >= 0) && (screen < ScreenCount(dpy))
&& (priv->screens[screen]->configs != NULL)
&& (priv->screens[screen]->configs->fbconfigID
!= (int) GLX_DONT_CARE)) {
}
-_X_EXPORT int
+_GLX_PUBLIC int
glXGetFBConfigAttrib(Display * dpy, GLXFBConfig fbconfig,
int attribute, int *value)
{
}
-_X_EXPORT XVisualInfo *
+_GLX_PUBLIC XVisualInfo *
glXGetVisualFromFBConfig(Display * dpy, GLXFBConfig fbconfig)
{
XVisualInfo visualTemplate;
CARD32 *interval_ptr;
CARD8 opcode;
- if (gc == NULL) {
+ if (gc == &dummyContext) {
return GLX_BAD_CONTEXT;
}
#ifdef GLX_DIRECT_RENDERING
struct glx_context *gc = __glXGetCurrentContext();
- if (gc != NULL && gc->isDirect) {
+ if (gc != &dummyContext && gc->isDirect) {
struct glx_screen *psc;
psc = GetGLXScreenConfigs( gc->currentDpy, gc->screen);
#ifdef GLX_DIRECT_RENDERING
struct glx_context *gc = __glXGetCurrentContext();
- if (gc != NULL && gc->isDirect) {
+ if (gc != &dummyContext && gc->isDirect) {
struct glx_screen *psc;
psc = GetGLXScreenConfigs( gc->currentDpy, gc->screen);
__GLXDRIdrawable *pdraw;
#endif
- if (!gc)
+ if (gc == &dummyContext)
return GLX_BAD_CONTEXT;
#ifdef GLX_DIRECT_RENDERING
if (divisor <= 0 || remainder < 0)
return GLX_BAD_VALUE;
- if (!gc)
+ if (gc == &dummyContext)
return GLX_BAD_CONTEXT;
#ifdef GLX_DIRECT_RENDERING
** GLX_functions table.
*/
-_X_EXPORT
+_GLX_PUBLIC
GLX_ALIAS(int, glXGetFBConfigAttribSGIX,
(Display * dpy, GLXFBConfigSGIX config, int attribute, int *value),
(dpy, config, attribute, value), glXGetFBConfigAttrib)
-_X_EXPORT GLX_ALIAS(GLXFBConfigSGIX *, glXChooseFBConfigSGIX,
+_GLX_PUBLIC GLX_ALIAS(GLXFBConfigSGIX *, glXChooseFBConfigSGIX,
(Display * dpy, int screen, int *attrib_list,
int *nelements), (dpy, screen, attrib_list, nelements),
glXChooseFBConfig)
-_X_EXPORT GLX_ALIAS(XVisualInfo *, glXGetVisualFromFBConfigSGIX,
+_GLX_PUBLIC GLX_ALIAS(XVisualInfo *, glXGetVisualFromFBConfigSGIX,
(Display * dpy, GLXFBConfigSGIX config),
(dpy, config), glXGetVisualFromFBConfig)
-_X_EXPORT GLXPixmap
+_GLX_PUBLIC GLXPixmap
glXCreateGLXPixmapWithConfigSGIX(Display * dpy,
GLXFBConfigSGIX fbconfig,
Pixmap pixmap)
#endif
}
-_X_EXPORT GLXContext
+_GLX_PUBLIC GLXContext
glXCreateContextWithConfigSGIX(Display * dpy,
GLXFBConfigSGIX fbconfig, int renderType,
GLXContext shareList, Bool allowDirect)
}
-_X_EXPORT GLXFBConfigSGIX
+_GLX_PUBLIC GLXFBConfigSGIX
glXGetFBConfigFromVisualSGIX(Display * dpy, XVisualInfo * vis)
{
struct glx_display *priv;
struct glx_screen *psc = pdraw ? pdraw->psc : NULL;
#endif
- if (!gc) /* no GLX for this */
+ if (gc == &dummyContext) /* no GLX for this */
return -1;
#ifdef GLX_DIRECT_RENDERING
}
-_X_EXPORT GLXPixmap
+_GLX_PUBLIC GLXPixmap
glXCreateGLXPixmapMESA(Display * dpy, XVisualInfo * visual,
Pixmap pixmap, Colormap cmap)
{
** does, send the context tag so the server can do a flush.
*/
gc = __glXGetCurrentContext();
- if ((gc != NULL) && (dpy == gc->currentDpy) &&
+ if ((gc != &dummyContext) && (dpy == gc->currentDpy) &&
((drawable == gc->currentDrawable) ||
(drawable == gc->currentReadable))) {
tag = gc->currentContextTag;
{
struct glx_context *gc = __glXGetCurrentContext();
- if (gc == NULL || gc->vtable->bind_tex_image == NULL)
+ if (gc == &dummyContext || gc->vtable->bind_tex_image == NULL)
return;
gc->vtable->bind_tex_image(dpy, drawable, buffer, attrib_list);
{
struct glx_context *gc = __glXGetCurrentContext();
- if (gc == NULL || gc->vtable->release_tex_image == NULL)
+ if (gc == &dummyContext || gc->vtable->release_tex_image == NULL)
return;
gc->vtable->release_tex_image(dpy, drawable, buffer);
#endif /* GLX_USE_APPLEGL */
-/**
- * \c strdup is actually not a standard ANSI C or POSIX routine.
- * Irix will not define it if ANSI mode is in effect.
- *
- * \sa strdup
- */
-_X_HIDDEN char *
-__glXstrdup(const char *str)
-{
- char *copy;
- copy = malloc(strlen(str) + 1);
- if (!copy)
- return NULL;
- strcpy(copy, str);
- return copy;
-}
-
/*
** glXGetProcAddress support
*/
GLX_FUNCTION2(glXReleaseTexImageEXT, __glXReleaseTexImageEXT),
#endif
-#if defined(GLX_DIRECT_RENDERING) && !defined(GLX_USE_APPLEGL)
+#if defined(GLX_DIRECT_RENDERING) && defined(GLX_USE_DRM)
/*** DRI configuration ***/
GLX_FUNCTION(glXGetScreenDriver),
GLX_FUNCTION(glXGetDriverConfig),
*
* \sa glXGetProcAddress
*/
-_X_EXPORT void (*glXGetProcAddressARB(const GLubyte * procName)) (void)
+_GLX_PUBLIC void (*glXGetProcAddressARB(const GLubyte * procName)) (void)
{
typedef void (*gl_function) (void);
gl_function f;
*
* \sa glXGetProcAddressARB
*/
-_X_EXPORT void (*glXGetProcAddress(const GLubyte * procName)) (void)
+_GLX_PUBLIC void (*glXGetProcAddress(const GLubyte * procName)) (void)
#if defined(__GNUC__) && !defined(GLX_ALIAS_UNSUPPORTED)
+# if defined(USE_MGL_NAMESPACE)
+ __attribute__ ((alias("mglXGetProcAddressARB")));
+# else
__attribute__ ((alias("glXGetProcAddressARB")));
+# endif
#else
{
return glXGetProcAddressARB(procName);
}
}
#endif /* GLX_DIRECT_RENDERING */
+
+#if defined(GLX_DIRECT_RENDERING) && !defined(GLX_USE_APPLEGL)
+
+int
+MesaGLInteropGLXQueryDeviceInfo(Display *dpy, GLXContext context,
+ struct mesa_glinterop_device_info *out)
+{
+ struct glx_context *gc = (struct glx_context*)context;
+ int ret;
+
+ __glXLock();
+
+ if (!gc || gc->xid == None || !gc->isDirect) {
+ __glXUnlock();
+ return MESA_GLINTEROP_INVALID_CONTEXT;
+ }
+
+ if (!gc->vtable->interop_query_device_info) {
+ __glXUnlock();
+ return MESA_GLINTEROP_UNSUPPORTED;
+ }
+
+ ret = gc->vtable->interop_query_device_info(gc, out);
+ __glXUnlock();
+ return ret;
+}
+
+int
+MesaGLInteropGLXExportObject(Display *dpy, GLXContext context,
+ struct mesa_glinterop_export_in *in,
+ struct mesa_glinterop_export_out *out)
+{
+ struct glx_context *gc = (struct glx_context*)context;
+ int ret;
+
+ __glXLock();
+
+ if (!gc || gc->xid == None || !gc->isDirect) {
+ __glXUnlock();
+ return MESA_GLINTEROP_INVALID_CONTEXT;
+ }
+
+ if (!gc->vtable->interop_export_object) {
+ __glXUnlock();
+ return MESA_GLINTEROP_UNSUPPORTED;
+ }
+
+ ret = gc->vtable->interop_export_object(gc, in, out);
+ __glXUnlock();
+ return ret;
+}
+
+#endif /* defined(GLX_DIRECT_RENDERING) && !defined(GLX_USE_APPLEGL) */