oops do not commit emacs droppings

This commit is contained in:
matthieu 2008-11-02 15:03:19 +00:00
parent 8baeee737f
commit a5aec75608
4 changed files with 0 additions and 1614 deletions

View File

@ -1,441 +0,0 @@
/*
* Copyright 2008 George Sapountzis
*
* Permission is hereby granted, free of charge, to any person obtaining a
* copy of this software and associated documentation files (the "Software"),
* to deal in the Software without restriction, including without limitation
* the rights to use, copy, modify, merge, publish, distribute, sublicense,
* and/or sell copies of the Software, and to permit persons to whom the
* Software is furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice (including the next
* paragraph) shall be included in all copies or substantial portions of the
* Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
* THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE.
*/
#ifdef GLX_DIRECT_RENDERING
#include <X11/Xlib.h>
#include "glheader.h"
#include "glxclient.h"
#include "glcontextmodes.h"
#include <dlfcn.h>
#include "dri_common.h"
typedef struct __GLXDRIdisplayPrivateRec __GLXDRIdisplayPrivate;
typedef struct __GLXDRIcontextPrivateRec __GLXDRIcontextPrivate;
typedef struct __GLXDRIdrawablePrivateRec __GLXDRIdrawablePrivate;
struct __GLXDRIdisplayPrivateRec {
__GLXDRIdisplay base;
};
struct __GLXDRIcontextPrivateRec {
__GLXDRIcontext base;
__DRIcontext *driContext;
__GLXscreenConfigs *psc;
};
struct __GLXDRIdrawablePrivateRec {
__GLXDRIdrawable base;
GC gc;
GC swapgc;
XVisualInfo *visinfo;
XImage *ximage;
int bpp;
};
/**
* swrast loader functions
*/
static Bool XCreateDrawable(__GLXDRIdrawablePrivate *pdp,
Display *dpy, XID drawable, int visualid)
{
XGCValues gcvalues;
long visMask;
XVisualInfo visTemp;
int num_visuals;
/* create GC's */
pdp->gc = XCreateGC(dpy, drawable, 0, NULL);
pdp->swapgc = XCreateGC(dpy, drawable, 0, NULL);
gcvalues.function = GXcopy;
gcvalues.graphics_exposures = False;
XChangeGC(dpy, pdp->gc, GCFunction, &gcvalues);
XChangeGC(dpy, pdp->swapgc, GCFunction, &gcvalues);
XChangeGC(dpy, pdp->swapgc, GCGraphicsExposures, &gcvalues);
/* create XImage */
visTemp.screen = DefaultScreen(dpy);
visTemp.visualid = visualid;
visMask = (VisualScreenMask | VisualIDMask);
pdp->visinfo = XGetVisualInfo(dpy, visMask, &visTemp, &num_visuals);
pdp->ximage = XCreateImage(dpy,
pdp->visinfo->visual,
pdp->visinfo->depth,
ZPixmap, 0, /* format, offset */
NULL, /* data */
0, 0, /* size */
32, /* bitmap_pad */
0); /* bytes_per_line */
/* get the true number of bits per pixel */
pdp->bpp = pdp->ximage->bits_per_pixel;
return True;
}
static void XDestroyDrawable(__GLXDRIdrawablePrivate *pdp,
Display *dpy, XID drawable)
{
XDestroyImage(pdp->ximage);
XFree(pdp->visinfo);
XFreeGC(dpy, pdp->gc);
XFreeGC(dpy, pdp->swapgc);
}
static void
swrastGetDrawableInfo(__DRIdrawable *draw,
int *x, int *y, int *w, int *h,
void *loaderPrivate)
{
__GLXDRIdrawablePrivate *pdp = loaderPrivate;
__GLXDRIdrawable *pdraw = &(pdp->base);;
Display *dpy = pdraw->psc->dpy;
Drawable drawable;
Window root;
Status stat;
unsigned int bw, depth;
drawable = pdraw->xDrawable;
stat = XGetGeometry(dpy, drawable, &root,
x, y, (unsigned int *)w, (unsigned int *)h,
&bw, &depth);
}
static inline int
bytes_per_line(int w, int bpp, unsigned mul)
{
unsigned mask = mul - 1;
return ((w * bpp + mask) & ~mask) / 8;
}
static void
swrastPutImage(__DRIdrawable *draw, int op,
int x, int y, int w, int h, char *data,
void *loaderPrivate)
{
__GLXDRIdrawablePrivate *pdp = loaderPrivate;
__GLXDRIdrawable *pdraw = &(pdp->base);;
Display *dpy = pdraw->psc->dpy;
Drawable drawable;
XImage *ximage;
GC gc;
switch (op) {
case __DRI_SWRAST_IMAGE_OP_DRAW:
gc = pdp->gc;
break;
case __DRI_SWRAST_IMAGE_OP_SWAP:
gc = pdp->swapgc;
break;
default:
return;
}
drawable = pdraw->xDrawable;
ximage = pdp->ximage;
ximage->data = data;
ximage->width = w;
ximage->height = h;
ximage->bytes_per_line = bytes_per_line(w, pdp->bpp, 32);
XPutImage(dpy, drawable, gc, ximage, 0, 0, x, y, w, h);
ximage->data = NULL;
}
static void
swrastGetImage(__DRIdrawable *draw,
int x, int y, int w, int h, char *data,
void *loaderPrivate)
{
__GLXDRIdrawablePrivate *pdp = loaderPrivate;
__GLXDRIdrawable *pdraw = &(pdp->base);;
Display *dpy = pdraw->psc->dpy;
Drawable drawable;
XImage *ximage;
drawable = pdraw->xDrawable;
ximage = pdp->ximage;
ximage->data = data;
ximage->width = w;
ximage->height = h;
ximage->bytes_per_line = bytes_per_line(w, pdp->bpp, 32);
XGetSubImage(dpy, drawable, x, y, w, h, ~0L, ZPixmap, ximage, 0, 0);
ximage->data = NULL;
}
static const __DRIswrastLoaderExtension swrastLoaderExtension = {
{ __DRI_SWRAST_LOADER, __DRI_SWRAST_LOADER_VERSION },
swrastGetDrawableInfo,
swrastPutImage,
swrastGetImage
};
static const __DRIextension *loader_extensions[] = {
&systemTimeExtension.base,
&swrastLoaderExtension.base,
NULL
};
/**
* GLXDRI functions
*/
static void driDestroyContext(__GLXDRIcontext *context,
__GLXscreenConfigs *psc, Display *dpy)
{
__GLXDRIcontextPrivate *pcp = (__GLXDRIcontextPrivate *) context;
const __DRIcoreExtension *core = pcp->psc->core;
(*core->destroyContext)(pcp->driContext);
Xfree(pcp);
}
static Bool driBindContext(__GLXDRIcontext *context,
__GLXDRIdrawable *draw, __GLXDRIdrawable *read)
{
__GLXDRIcontextPrivate *pcp = (__GLXDRIcontextPrivate *) context;
const __DRIcoreExtension *core = pcp->psc->core;
return (*core->bindContext)(pcp->driContext,
draw->driDrawable,
read->driDrawable);
}
static void driUnbindContext(__GLXDRIcontext *context)
{
__GLXDRIcontextPrivate *pcp = (__GLXDRIcontextPrivate *) context;
const __DRIcoreExtension *core = pcp->psc->core;
(*core->unbindContext)(pcp->driContext);
}
static __GLXDRIcontext *driCreateContext(__GLXscreenConfigs *psc,
const __GLcontextModes *mode,
GLXContext gc,
GLXContext shareList, int renderType)
{
__GLXDRIcontextPrivate *pcp, *pcp_shared;
__GLXDRIconfigPrivate *config = (__GLXDRIconfigPrivate *) mode;
const __DRIcoreExtension *core = psc->core;
__DRIcontext *shared = NULL;
if (!psc || !psc->driScreen)
return NULL;
if (shareList) {
pcp_shared = (__GLXDRIcontextPrivate *) shareList->driContext;
shared = pcp_shared->driContext;
}
pcp = Xmalloc(sizeof *pcp);
if (pcp == NULL)
return NULL;
pcp->psc = psc;
pcp->driContext =
(*core->createNewContext)(psc->__driScreen,
config->driConfig, shared, pcp);
if (pcp->driContext == NULL) {
Xfree(pcp);
return NULL;
}
pcp->base.destroyContext = driDestroyContext;
pcp->base.bindContext = driBindContext;
pcp->base.unbindContext = driUnbindContext;
return &pcp->base;
}
static void driDestroyDrawable(__GLXDRIdrawable *pdraw)
{
__GLXDRIdrawablePrivate *pdp = (__GLXDRIdrawablePrivate *) pdraw;
const __DRIcoreExtension *core = pdraw->psc->core;
(*core->destroyDrawable)(pdraw->driDrawable);
XDestroyDrawable(pdp, pdraw->psc->dpy, pdraw->drawable);
Xfree(pdp);
}
static __GLXDRIdrawable *driCreateDrawable(__GLXscreenConfigs *psc,
XID xDrawable,
GLXDrawable drawable,
const __GLcontextModes *modes)
{
__GLXDRIdrawable *pdraw;
__GLXDRIdrawablePrivate *pdp;
__GLXDRIconfigPrivate *config = (__GLXDRIconfigPrivate *) modes;
const __DRIswrastExtension *swrast = psc->swrast;
/* Old dri can't handle GLX 1.3+ drawable constructors. */
if (xDrawable != drawable)
return NULL;
pdp = Xmalloc(sizeof(*pdp));
if (!pdp)
return NULL;
pdraw = &(pdp->base);
pdraw->xDrawable = xDrawable;
pdraw->drawable = drawable;
pdraw->psc = psc;
XCreateDrawable(pdp, psc->dpy, xDrawable, modes->visualID);
/* Create a new drawable */
pdraw->driDrawable =
(*swrast->createNewDrawable)(psc->__driScreen,
config->driConfig,
pdp);
if (!pdraw->driDrawable) {
XDestroyDrawable(pdp, psc->dpy, xDrawable);
Xfree(pdp);
return NULL;
}
pdraw->destroyDrawable = driDestroyDrawable;
return pdraw;
}
static void driDestroyScreen(__GLXscreenConfigs *psc)
{
/* Free the direct rendering per screen data */
(*psc->core->destroyScreen)(psc->__driScreen);
psc->__driScreen = NULL;
if (psc->driver)
dlclose(psc->driver);
}
static __GLXDRIscreen *driCreateScreen(__GLXscreenConfigs *psc, int screen,
__GLXdisplayPrivate *priv)
{
__GLXDRIscreen *psp;
const __DRIconfig **driver_configs;
const __DRIextension **extensions;
const char *driverName = "swrast";
int i;
psp = Xmalloc(sizeof *psp);
if (psp == NULL)
return NULL;
/* Initialize per screen dynamic client GLX extensions */
psc->ext_list_first_time = GL_TRUE;
psc->driver = driOpenDriver(driverName);
if (psc->driver == NULL)
goto handle_error;
extensions = dlsym(psc->driver, __DRI_DRIVER_EXTENSIONS);
if (extensions == NULL) {
ErrorMessageF("driver exports no extensions (%s)\n", dlerror());
goto handle_error;
}
for (i = 0; extensions[i]; i++) {
if (strcmp(extensions[i]->name, __DRI_CORE) == 0)
psc->core = (__DRIcoreExtension *) extensions[i];
if (strcmp(extensions[i]->name, __DRI_SWRAST) == 0)
psc->swrast = (__DRIswrastExtension *) extensions[i];
}
if (psc->core == NULL || psc->swrast == NULL) {
ErrorMessageF("core dri extension not found\n");
goto handle_error;
}
psc->__driScreen =
psc->swrast->createNewScreen(screen,
loader_extensions, &driver_configs, psc);
if (psc->__driScreen == NULL) {
ErrorMessageF("failed to create dri screen\n");
goto handle_error;
}
driBindExtensions(psc, 0);
psc->configs = driConvertConfigs(psc->core, psc->configs, driver_configs);
psc->visuals = driConvertConfigs(psc->core, psc->visuals, driver_configs);
psp->destroyScreen = driDestroyScreen;
psp->createContext = driCreateContext;
psp->createDrawable = driCreateDrawable;
return psp;
handle_error:
Xfree(psp);
if (psc->driver)
dlclose(psc->driver);
ErrorMessageF("reverting to indirect rendering\n");
return NULL;
}
/* Called from __glXFreeDisplayPrivate.
*/
static void driDestroyDisplay(__GLXDRIdisplay *dpy)
{
Xfree(dpy);
}
/*
* Allocate, initialize and return a __DRIdisplayPrivate object.
* This is called from __glXInitialize() when we are given a new
* display pointer.
*/
_X_HIDDEN __GLXDRIdisplay *driswCreateDisplay(Display *dpy)
{
__GLXDRIdisplayPrivate *pdpyp;
pdpyp = Xmalloc(sizeof *pdpyp);
if (pdpyp == NULL)
return NULL;
pdpyp->base.destroyDisplay = driDestroyDisplay;
pdpyp->base.createScreen = driCreateScreen;
return &pdpyp->base;
}
#endif /* GLX_DIRECT_RENDERING */

View File

@ -1,513 +0,0 @@
/*
* SGI FREE SOFTWARE LICENSE B (Version 2.0, Sept. 18, 2008)
* Copyright (C) 1991-2000 Silicon Graphics, Inc. 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"),
* to deal in the Software without restriction, including without limitation
* the rights to use, copy, modify, merge, publish, distribute, sublicense,
* and/or sell copies of the Software, and to permit persons to whom the
* Software is furnished to do so, subject to the following conditions:
*
* The above copyright notice including the dates of first publication and
* either this permission notice or a reference to
* http://oss.sgi.com/projects/FreeB/
* shall be included in all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
* OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
* SILICON GRAPHICS, INC. BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
* WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF
* OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE.
*
* Except as contained in this notice, the name of Silicon Graphics, Inc.
* shall not be used in advertising or otherwise to promote the sale, use or
* other dealings in this Software without prior written authorization from
* Silicon Graphics, Inc.
*/
/**
* \file glxcurrent.c
* Client-side GLX interface for current context management.
*/
#include "glxclient.h"
#include "glapi.h"
#include "glheader.h"
#include "indirect_init.h"
#ifdef GLX_DIRECT_RENDERING
#include "xf86dri.h"
#endif
/*
** We setup some dummy structures here so that the API can be used
** even if no context is current.
*/
static GLubyte dummyBuffer[__GLX_BUFFER_LIMIT_SIZE];
/*
** Dummy context used by small commands when there is no current context.
** All the
** gl and glx entry points are designed to operate as nop's when using
** the dummy context structure.
*/
static __GLXcontext dummyContext = {
&dummyBuffer[0],
&dummyBuffer[0],
&dummyBuffer[0],
&dummyBuffer[__GLX_BUFFER_LIMIT_SIZE],
sizeof(dummyBuffer),
};
/*
** All indirect rendering contexts will share the same indirect dispatch table.
*/
static __GLapi *IndirectAPI = NULL;
/*
* Current context management and locking
*/
#if defined( USE_XTHREADS )
/* thread safe */
static GLboolean TSDinitialized = GL_FALSE;
static xthread_key_t ContextTSD;
_X_HIDDEN __GLXcontext *__glXGetCurrentContext(void)
{
if (!TSDinitialized) {
xthread_key_create(&ContextTSD, NULL);
TSDinitialized = GL_TRUE;
return &dummyContext;
}
else {
void *p;
xthread_get_specific(ContextTSD, &p);
if (!p)
return &dummyContext;
else
return (__GLXcontext *) p;
}
}
_X_HIDDEN void __glXSetCurrentContext(__GLXcontext *c)
{
if (!TSDinitialized) {
xthread_key_create(&ContextTSD, NULL);
TSDinitialized = GL_TRUE;
}
xthread_set_specific(ContextTSD, c);
}
/* Used by the __glXLock() and __glXUnlock() macros */
_X_HIDDEN xmutex_rec __glXmutex;
#elif defined( PTHREADS )
_X_HIDDEN pthread_mutex_t __glXmutex = PTHREAD_MUTEX_INITIALIZER;
# if defined( GLX_USE_TLS )
/**
* Per-thread GLX context pointer.
*
* \c __glXSetCurrentContext is written is such a way that this pointer can
* \b never be \c NULL. This is important! Because of this
* \c __glXGetCurrentContext can be implemented as trivial macro.
*/
__thread void * __glX_tls_Context __attribute__((tls_model("initial-exec")))
= &dummyContext;
_X_HIDDEN void __glXSetCurrentContext( __GLXcontext * c )
{
__glX_tls_Context = (c != NULL) ? c : &dummyContext;
}
# else
static pthread_once_t once_control = PTHREAD_ONCE_INIT;
/**
* Per-thread data key.
*
* Once \c init_thread_data has been called, the per-thread data key will
* take a value of \c NULL. As each new thread is created the default
* value, in that thread, will be \c NULL.
*/
static pthread_key_t ContextTSD;
/**
* Initialize the per-thread data key.
*
* This function is called \b exactly once per-process (not per-thread!) to
* initialize the per-thread data key. This is ideally done using the
* \c pthread_once mechanism.
*/
static void init_thread_data( void )
{
if ( pthread_key_create( & ContextTSD, NULL ) != 0 ) {
perror( "pthread_key_create" );
exit( -1 );
}
}
_X_HIDDEN void __glXSetCurrentContext( __GLXcontext * c )
{
pthread_once( & once_control, init_thread_data );
pthread_setspecific( ContextTSD, c );
}
_X_HIDDEN __GLXcontext * __glXGetCurrentContext( void )
{
void * v;
pthread_once( & once_control, init_thread_data );
v = pthread_getspecific( ContextTSD );
return (v == NULL) ? & dummyContext : (__GLXcontext *) v;
}
# endif /* defined( GLX_USE_TLS ) */
#elif defined( THREADS )
#error Unknown threading method specified.
#else
/* not thread safe */
_X_HIDDEN __GLXcontext *__glXcurrentContext = &dummyContext;
#endif
_X_HIDDEN void __glXSetCurrentContextNull(void)
{
__glXSetCurrentContext(&dummyContext);
#ifdef GLX_DIRECT_RENDERING
_glapi_set_dispatch(NULL); /* no-op functions */
#endif
}
/************************************************************************/
PUBLIC GLXContext glXGetCurrentContext(void)
{
GLXContext cx = __glXGetCurrentContext();
if (cx == &dummyContext) {
return NULL;
} else {
return cx;
}
}
PUBLIC GLXDrawable glXGetCurrentDrawable(void)
{
GLXContext gc = __glXGetCurrentContext();
return gc->currentDrawable;
}
/************************************************************************/
/**
* Sends a GLX protocol message to the specified display to make the context
* and the drawables current.
*
* \param dpy Display to send the message to.
* \param opcode Major opcode value for the display.
* \param gc_id Context tag for the context to be made current.
* \param draw Drawable ID for the "draw" drawable.
* \param read Drawable ID for the "read" drawable.
* \param reply Space to store the X-server's reply.
*
* \warning
* This function assumes that \c dpy is locked with \c LockDisplay on entry.
*/
static Bool SendMakeCurrentRequest(Display *dpy, CARD8 opcode,
GLXContextID gc_id, GLXContextTag gc_tag,
GLXDrawable draw, GLXDrawable read,
xGLXMakeCurrentReply *reply)
{
Bool ret;
LockDisplay(dpy);
if (draw == read) {
xGLXMakeCurrentReq *req;
GetReq(GLXMakeCurrent,req);
req->reqType = opcode;
req->glxCode = X_GLXMakeCurrent;
req->drawable = draw;
req->context = gc_id;
req->oldContextTag = gc_tag;
}
else {
__GLXdisplayPrivate *priv = __glXInitialize(dpy);
/* If the server can support the GLX 1.3 version, we should
* perfer that. Not only that, some servers support GLX 1.3 but
* not the SGI extension.
*/
if ((priv->majorVersion > 1) || (priv->minorVersion >= 3)) {
xGLXMakeContextCurrentReq *req;
GetReq(GLXMakeContextCurrent,req);
req->reqType = opcode;
req->glxCode = X_GLXMakeContextCurrent;
req->drawable = draw;
req->readdrawable = read;
req->context = gc_id;
req->oldContextTag = gc_tag;
}
else {
xGLXVendorPrivateWithReplyReq *vpreq;
xGLXMakeCurrentReadSGIReq *req;
GetReqExtra(GLXVendorPrivateWithReply,
sz_xGLXMakeCurrentReadSGIReq-sz_xGLXVendorPrivateWithReplyReq,vpreq);
req = (xGLXMakeCurrentReadSGIReq *)vpreq;
req->reqType = opcode;
req->glxCode = X_GLXVendorPrivateWithReply;
req->vendorCode = X_GLXvop_MakeCurrentReadSGI;
req->drawable = draw;
req->readable = read;
req->context = gc_id;
req->oldContextTag = gc_tag;
}
}
ret = _XReply(dpy, (xReply*) reply, 0, False);
UnlockDisplay(dpy);
SyncHandle();
return ret;
}
#ifdef GLX_DIRECT_RENDERING
static __GLXDRIdrawable *
FetchDRIDrawable(Display *dpy,
GLXDrawable glxDrawable, GLXContext gc, Bool pre13)
{
__GLXdisplayPrivate * const priv = __glXInitialize(dpy);
__GLXDRIdrawable *pdraw;
__GLXscreenConfigs *psc;
XID drawable;
if (priv == NULL)
return NULL;
psc = &priv->screenConfigs[gc->screen];
if (psc->drawHash == NULL)
return NULL;
if (__glxHashLookup(psc->drawHash, glxDrawable, (void *) &pdraw) == 0)
return pdraw;
/* If this is glXMakeCurrent (pre GLX 1.3) we allow creating the
* GLX drawable on the fly. Otherwise we pass None as the X
* drawable */
if (pre13)
drawable = glxDrawable;
else
drawable = None;
pdraw = psc->driScreen->createDrawable(psc, drawable,
glxDrawable, gc->mode);
if (__glxHashInsert(psc->drawHash, glxDrawable, pdraw)) {
(*pdraw->destroyDrawable)(pdraw);
return NULL;
}
return pdraw;
}
#endif /* GLX_DIRECT_RENDERING */
/**
* Make a particular context current.
*
* \note This is in this file so that it can access dummyContext.
*/
static Bool MakeContextCurrent(Display *dpy, GLXDrawable draw,
GLXDrawable read, GLXContext gc,
Bool pre13)
{
xGLXMakeCurrentReply reply;
const GLXContext oldGC = __glXGetCurrentContext();
const CARD8 opcode = __glXSetupForCommand(dpy);
const CARD8 oldOpcode = ((gc == oldGC) || (oldGC == &dummyContext))
? opcode : __glXSetupForCommand(oldGC->currentDpy);
Bool bindReturnValue;
if (!opcode || !oldOpcode) {
return GL_FALSE;
}
/* Make sure that the new context has a nonzero ID. In the request,
* a zero context ID is used only to mean that we bind to no current
* context.
*/
if ((gc != NULL) && (gc->xid == None)) {
return GL_FALSE;
}
_glapi_check_multithread();
#ifdef GLX_DIRECT_RENDERING
/* Bind the direct rendering context to the drawable */
if (gc && gc->driContext) {
__GLXDRIdrawable *pdraw = FetchDRIDrawable(dpy, draw, gc, pre13);
__GLXDRIdrawable *pread = FetchDRIDrawable(dpy, read, gc, pre13);
bindReturnValue =
(gc->driContext->bindContext) (gc->driContext, pdraw, pread);
} else
#endif
{
/* Send a glXMakeCurrent request to bind the new context. */
bindReturnValue =
SendMakeCurrentRequest(dpy, opcode, gc ? gc->xid : None,
((dpy != oldGC->currentDpy) || oldGC->isDirect)
? None : oldGC->currentContextTag,
draw, read, &reply);
}
if (!bindReturnValue) {
return False;
}
#ifdef GLX_DIRECT_RENDERING
if ((dpy != oldGC->currentDpy || (gc && gc->driContext)) &&
!oldGC->isDirect && oldGC != &dummyContext) {
#else
if ((dpy != oldGC->currentDpy) && oldGC != &dummyContext) {
#endif
xGLXMakeCurrentReply dummy_reply;
/* We are either switching from one dpy to another and have to
* send a request to the previous dpy to unbind the previous
* context, or we are switching away from a indirect context to
* a direct context and have to send a request to the dpy to
* unbind the previous context.
*/
(void) SendMakeCurrentRequest(oldGC->currentDpy, oldOpcode, None,
oldGC->currentContextTag, None, None,
& dummy_reply);
}
#ifdef GLX_DIRECT_RENDERING
else if (oldGC->driContext) {
oldGC->driContext->unbindContext(oldGC->driContext);
}
#endif
/* Update our notion of what is current */
__glXLock();
if (gc == oldGC) {
/* Even though the contexts are the same the drawable might have
* changed. Note that gc cannot be the dummy, and that oldGC
* cannot be NULL, therefore if they are the same, gc is not
* NULL and not the dummy.
*/
gc->currentDrawable = draw;
gc->currentReadable = read;
} else {
if (oldGC != &dummyContext) {
/* Old current context is no longer current to anybody */
oldGC->currentDpy = 0;
oldGC->currentDrawable = None;
oldGC->currentReadable = None;
oldGC->currentContextTag = 0;
if (oldGC->xid == None) {
/* We are switching away from a context that was
* previously destroyed, so we need to free the memory
* for the old handle.
*/
#ifdef GLX_DIRECT_RENDERING
/* Destroy the old direct rendering context */
if (oldGC->driContext) {
oldGC->driContext->destroyContext(oldGC->driContext,
oldGC->psc,
oldGC->createDpy);
oldGC->driContext = NULL;
}
#endif
__glXFreeContext(oldGC);
}
}
if (gc) {
__glXSetCurrentContext(gc);
gc->currentDpy = dpy;
gc->currentDrawable = draw;
gc->currentReadable = read;
#ifdef GLX_DIRECT_RENDERING
if (!gc->driContext) {
#endif
if (!IndirectAPI)
IndirectAPI = __glXNewIndirectAPI();
_glapi_set_dispatch(IndirectAPI);
#ifdef GLX_USE_APPLEGL
do {
extern void XAppleDRIUseIndirectDispatch(void);
XAppleDRIUseIndirectDispatch();
} while (0);
#endif
__GLXattribute *state =
(__GLXattribute *)(gc->client_state_private);
gc->currentContextTag = reply.contextTag;
if (state->array_state == NULL) {
(void) glGetString(GL_EXTENSIONS);
(void) glGetString(GL_VERSION);
__glXInitVertexArrayState(gc);
}
#ifdef GLX_DIRECT_RENDERING
}
else {
gc->currentContextTag = -1;
}
#endif
} else {
__glXSetCurrentContextNull();
}
}
__glXUnlock();
return GL_TRUE;
}
PUBLIC Bool glXMakeCurrent(Display *dpy, GLXDrawable draw, GLXContext gc)
{
return MakeContextCurrent(dpy, draw, draw, gc, True);
}
PUBLIC GLX_ALIAS(Bool, glXMakeCurrentReadSGI,
(Display *dpy, GLXDrawable d, GLXDrawable r, GLXContext ctx),
(dpy, d, r, ctx, False), MakeContextCurrent)
PUBLIC GLX_ALIAS(Bool, glXMakeContextCurrent,
(Display *dpy, GLXDrawable d, GLXDrawable r, GLXContext ctx),
(dpy, d, r, ctx, False), MakeContextCurrent)

View File

@ -1,362 +0,0 @@
/* $XFree86$ */ /* -*- mode: c; c-basic-offset: 3 -*- */
/*
* Copyright 2000 Gareth Hughes
* 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"),
* to deal in the Software without restriction, including without limitation
* the rights to use, copy, modify, merge, publish, distribute, sublicense,
* and/or sell copies of the Software, and to permit persons to whom the
* Software is furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice (including the next
* paragraph) shall be included in all copies or substantial portions of the
* Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
* GARETH HUGHES BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
* IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
* CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
*/
/*
* Authors:
* Gareth Hughes <gareth@valinux.com>
* Leif Delgass <ldelgass@retinalburn.net>
* Jos<EFBFBD>Fonseca <j_r_fonseca@yahoo.co.uk>
*/
#ifndef __MACH64_CONTEXT_H__
#define __MACH64_CONTEXT_H__
#include "dri_util.h"
#include "drm.h"
#include "mach64_drm.h"
#include "mtypes.h"
#include "mach64_reg.h"
#include "texmem.h"
struct mach64_context;
typedef struct mach64_context mach64ContextRec;
typedef struct mach64_context *mach64ContextPtr;
#include "mach64_lock.h"
#include "mach64_screen.h"
/* Experimental driver options */
#define MACH64_CLIENT_STATE_EMITS 0
/* Performace monitoring */
#define ENABLE_PERF_BOXES 1
/* Native vertex format */
#define MACH64_NATIVE_VTXFMT 1
/* Flags for what context state needs to be updated:
*/
#define MACH64_NEW_ALPHA 0x0001
#define MACH64_NEW_DEPTH 0x0002
#define MACH64_NEW_FOG 0x0004
#define MACH64_NEW_CLIP 0x0008
#define MACH64_NEW_CULL 0x0010
#define MACH64_NEW_MASKS 0x0020
#define MACH64_NEW_RENDER_UNUSED 0x0040
#define MACH64_NEW_WINDOW 0x0080
#define MACH64_NEW_TEXTURE 0x0100
#define MACH64_NEW_CONTEXT 0x0200
#define MACH64_NEW_ALL 0x03ff
/* Flags for software fallback cases:
*/
#define MACH64_FALLBACK_TEXTURE 0x0001
#define MACH64_FALLBACK_DRAW_BUFFER 0x0002
#define MACH64_FALLBACK_READ_BUFFER 0x0004
#define MACH64_FALLBACK_STENCIL 0x0008
#define MACH64_FALLBACK_RENDER_MODE 0x0010
#define MACH64_FALLBACK_LOGICOP 0x0020
#define MACH64_FALLBACK_SEP_SPECULAR 0x0040
#define MACH64_FALLBACK_BLEND_EQ 0x0080
#define MACH64_FALLBACK_BLEND_FUNC 0x0100
#define MACH64_FALLBACK_DISABLE 0x0200
#define CARD32 GLuint /* KW: For building in mesa tree */
#if MACH64_NATIVE_VTXFMT
/* The vertex structures.
*/
/* The size of this union is not of relevence:
*/
union mach64_vertex_t {
GLfloat f[16];
GLuint ui[16];
GLushort us2[16][2];
GLubyte ub4[16][4];
};
typedef union mach64_vertex_t mach64Vertex, *mach64VertexPtr;
#else
/* Use the templated vertex format:
*/
#define TAG(x) mach64##x
#include "tnl_dd/t_dd_vertex.h"
#undef TAG
#endif /* MACH64_NATIVE_VTXFMT */
/* Subpixel offsets for window coordinates:
* These are enough to fix most glean tests except polygonOffset.
* There are also still some gaps that show in e.g. the tunnel Mesa demo
* or the lament xscreensaver hack.
*/
#define SUBPIXEL_X (0.0125F)
#define SUBPIXEL_Y (0.15F)
typedef void (*mach64_tri_func)( mach64ContextPtr,
mach64Vertex *,
mach64Vertex *,
mach64Vertex * );
typedef void (*mach64_line_func)( mach64ContextPtr,
mach64Vertex *,
mach64Vertex * );
typedef void (*mach64_point_func)( mach64ContextPtr,
mach64Vertex * );
struct mach64_texture_object {
driTextureObject base;
GLuint bufAddr;
GLint heap; /* same as base.heap->heapId */
/* For communicating values from mach64AllocTexObj(), mach64SetTexImages()
* to mach64UpdateTextureUnit(). Alternately, we can use the tObj values or
* set the context registers directly.
*/
GLint widthLog2;
GLint heightLog2;
GLint maxLog2;
GLint hasAlpha;
GLint textureFormat;
GLboolean BilinearMin;
GLboolean BilinearMag;
GLboolean ClampS;
GLboolean ClampT;
};
typedef struct mach64_texture_object mach64TexObj, *mach64TexObjPtr;
struct mach64_context {
GLcontext *glCtx;
/* Driver and hardware state management
*/
GLuint new_state;
GLuint dirty; /* Hardware state to be updated */
drm_mach64_context_regs_t setup;
GLuint NewGLState;
GLuint Fallback;
GLuint SetupIndex;
GLuint SetupNewInputs;
GLuint RenderIndex;
GLfloat hw_viewport[16];
GLfloat depth_scale;
GLuint vertex_size;
GLuint vertex_stride_shift;
GLuint vertex_format;
GLuint num_verts;
GLubyte *verts;
CARD32 Color; /* Current draw color */
CARD32 ClearColor; /* Color used to clear color buffer */
CARD32 ClearDepth; /* Value used to clear depth buffer */
/* Map GL texture units onto hardware
*/
GLint multitex;
GLint tmu_source[2];
GLint tex_dest[2];
/* Texture object bookkeeping
*/
mach64TexObjPtr CurrentTexObj[2];
GLint firstTexHeap, lastTexHeap;
driTexHeap *texture_heaps[MACH64_NR_TEX_HEAPS];
driTextureObject swapped;
/* Fallback rasterization functions
*/
mach64_point_func draw_point;
mach64_line_func draw_line;
mach64_tri_func draw_tri;
/* Culling */
GLfloat backface_sign;
/* DMA buffers
*/
void *vert_buf;
size_t vert_total;
unsigned vert_used;
GLuint hw_primitive;
GLenum render_primitive;
/* Visual, drawable, cliprect and scissor information
*/
GLint drawOffset, drawPitch;
GLint drawX, drawY; /* origin of drawable in draw buffer */
GLint readOffset, readPitch;
GLuint numClipRects; /* Cliprects for the draw buffer */
drm_clip_rect_t *pClipRects;
GLint scissor;
drm_clip_rect_t ScissorRect; /* Current software scissor */
/* Mirrors of some DRI state
*/
__DRIcontextPrivate *driContext; /* DRI context */
__DRIscreenPrivate *driScreen; /* DRI screen */
__DRIdrawablePrivate *driDrawable; /* DRI drawable bound to this ctx */
unsigned int lastStamp; /* mirror driDrawable->lastStamp */
drm_context_t hHWContext;
drm_hw_lock_t *driHwLock;
int driFd;
mach64ScreenPtr mach64Screen; /* Screen private DRI data */
drm_mach64_sarea_t *sarea; /* Private SAREA data */
GLuint hardwareWentIdle;
#if ENABLE_PERF_BOXES
/* Performance counters
*/
GLuint boxes; /* Draw performance boxes */
GLuint c_clears;
GLuint c_drawWaits;
GLuint c_textureSwaps;
GLuint c_textureBytes;
GLuint c_agpTextureBytes;
GLuint c_texsrc_agp;
GLuint c_texsrc_card;
GLuint c_vertexBuffers;
#endif
/* VBI
*/
GLuint do_irqs;
/* Configuration cache
*/
driOptionCache optionCache;
};
#define MACH64_CONTEXT(ctx) ((mach64ContextPtr)(ctx->DriverCtx))
extern GLboolean mach64CreateContext( const __GLcontextModes *glVisual,
__DRIcontextPrivate *driContextPriv,
void *sharedContextPrivate );
extern void mach64DestroyContext( __DRIcontextPrivate * );
extern GLboolean mach64MakeCurrent( __DRIcontextPrivate *driContextPriv,
__DRIdrawablePrivate *driDrawPriv,
__DRIdrawablePrivate *driReadPriv );
extern GLboolean mach64UnbindContext( __DRIcontextPrivate *driContextPriv );
/* ================================================================
* Byte ordering
*/
#if MESA_LITTLE_ENDIAN == 1
#define LE32_IN( x ) ( *(GLuint *)(x) )
#define LE32_IN_FLOAT( x ) ( *(GLfloat *)(x) )
#define LE32_OUT( x, y ) do { *(GLuint *)(x) = (y); } while (0)
#define LE32_OUT_FLOAT( x, y ) do { *(GLfloat *)(x) = (y); } while (0)
#else
#include <byteswap.h>
#define LE32_IN( x ) bswap_32( *(GLuint *)(x) )
#define LE32_IN_FLOAT( x ) \
({ \
GLuint __tmp = bswap_32( *(GLuint *)(x) ); \
*(GLfloat *)&__tmp; \
})
#define LE32_OUT( x, y ) do { *(GLuint *)(x) = bswap_32( y ); } while (0)
#define LE32_OUT_FLOAT( x, y ) \
do { \
GLuint __tmp; \
*(GLfloat *)&__tmp = (y); \
*(GLuint *)(x) = bswap_32( __tmp ); \
} while (0)
#endif
/* ================================================================
* DMA buffers
*/
#define DMALOCALS CARD32 *buf=NULL; int requested=0; int outcount=0
/* called while locked for interleaved client-side state emits */
#define DMAGETPTR( dwords ) \
do { \
requested = (dwords); \
buf = (CARD32 *)mach64AllocDmaLocked( mmesa, ((dwords)*4) ); \
outcount = 0; \
} while(0)
#define DMAOUTREG( reg, val ) \
do { \
LE32_OUT( &buf[outcount++], ADRINDEX( reg ) ); \
LE32_OUT( &buf[outcount++], ( val ) ); \
} while(0)
#define DMAADVANCE() \
do { \
if (outcount < requested) { \
mmesa->vert_used -= (requested - outcount) * 4; \
} \
} while(0)
/* ================================================================
* Debugging:
*/
#define DO_DEBUG 1
#if DO_DEBUG
extern int MACH64_DEBUG;
#else
#define MACH64_DEBUG 0
#endif
#define DEBUG_ALWAYS_SYNC 0x001
#define DEBUG_VERBOSE_API 0x002
#define DEBUG_VERBOSE_MSG 0x004
#define DEBUG_VERBOSE_LRU 0x008
#define DEBUG_VERBOSE_DRI 0x010
#define DEBUG_VERBOSE_IOCTL 0x020
#define DEBUG_VERBOSE_PRIMS 0x040
#define DEBUG_VERBOSE_COUNT 0x080
#define DEBUG_NOWAIT 0x100
#define DEBUG_VERBOSE_FALLBACK 0x200
#endif /* __MACH64_CONTEXT_H__ */

View File

@ -1,298 +0,0 @@
/**
* \file glheader.h
* Top-most include file.
*
* This is the top-most include file of the Mesa sources.
* It includes gl.h and all system headers which are needed.
* Other Mesa source files should \e not directly include any system
* headers. This allows system-dependent hacks/workarounds to be
* collected in one place.
*
* \note Actually, a lot of system-dependent stuff is now in imports.[ch].
*
* If you touch this file, everything gets recompiled!
*
* This file should be included before any other header in the .c files.
*
* Put compiler/OS/assembly pragmas and macros here to avoid
* cluttering other source files.
*/
/*
* Mesa 3-D graphics library
* Version: 6.5
*
* Copyright (C) 1999-2005 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"),
* to deal in the Software without restriction, including without limitation
* the rights to use, copy, modify, merge, publish, distribute, sublicense,
* and/or sell copies of the Software, and to permit persons to whom the
* Software is furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included
* in all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
* OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
* BRIAN PAUL BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
* AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
* CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
*/
#ifndef GLHEADER_H
#define GLHEADER_H
#include <assert.h>
#include <ctype.h>
#if defined(__alpha__) && defined(CCPML)
#include <cpml.h> /* use Compaq's Fast Math Library on Alpha */
#else
#include <math.h>
#endif
#include <limits.h>
#include <stdlib.h>
#include <stdio.h>
#include <string.h>
#if defined(__linux__) && defined(__i386__)
#include <fpu_control.h>
#endif
#include <float.h>
#include <stdarg.h>
/* Get typedefs for uintptr_t and friends */
#if defined(__MINGW32__) || defined(__NetBSD__)
# include <stdint.h>
#elif defined(_WIN32)
# include <BaseTsd.h>
# if _MSC_VER == 1200
typedef UINT_PTR uintptr_t;
# endif
#elif defined(__INTERIX)
/* Interix 3.x has a gcc that shadows this. */
# ifndef _UINTPTR_T_DEFINED
typedef unsigned long uintptr_t;
# define _UINTPTR_T_DEFINED
# endif
#else
# include <inttypes.h>
#endif
/* For platforms that have the C99 standard uint*_t,
but not the commonly used u_int*_t */
#if defined(__sun)
# define u_int8_t uint8_t
# define u_int16_t uint16_t
# define u_int32_t uint32_t
# define u_int64_t uint64_t
# define u_intptr_t uintptr_t
#endif
/* Sun compilers define __i386 instead of the gcc-style __i386__ */
#ifdef __SUNPRO_C
# if !defined(__i386__) && defined(__i386)
# define __i386__
# elif !defined(__amd64__) && defined(__amd64)
# define __amd64__
# elif !defined(__sparc__) && defined(__sparc)
# define __sparc__
# endif
# if !defined(__volatile)
# define __volatile volatile
# endif
#endif
#if defined(_WIN32) && !defined(__WIN32__) && !defined(__CYGWIN__) && !defined(BUILD_FOR_SNAP)
# define __WIN32__
# define finite _finite
#endif
#if defined(__WATCOMC__)
# define finite _finite
# pragma disable_message(201) /* Disable unreachable code warnings */
#endif
#ifdef WGLAPI
# undef WGLAPI
#endif
#if !defined(OPENSTEP) && (defined(__WIN32__) && !defined(__CYGWIN__)) && !defined(BUILD_FOR_SNAP)
# if !defined(__GNUC__) /* mingw environment */
# pragma warning( disable : 4068 ) /* unknown pragma */
# pragma warning( disable : 4710 ) /* function 'foo' not inlined */
# pragma warning( disable : 4711 ) /* function 'foo' selected for automatic inline expansion */
# pragma warning( disable : 4127 ) /* conditional expression is constant */
# if defined(MESA_MINWARN)
# pragma warning( disable : 4244 ) /* '=' : conversion from 'const double ' to 'float ', possible loss of data */
# pragma warning( disable : 4018 ) /* '<' : signed/unsigned mismatch */
# pragma warning( disable : 4305 ) /* '=' : truncation from 'const double ' to 'float ' */
# pragma warning( disable : 4550 ) /* 'function' undefined; assuming extern returning int */
# pragma warning( disable : 4761 ) /* integral size mismatch in argument; conversion supplied */
# endif
# endif
# if (defined(_MSC_VER) || defined(__MINGW32__)) && defined(BUILD_GL32) /* tag specify we're building mesa as a DLL */
# define WGLAPI __declspec(dllexport)
# elif (defined(_MSC_VER) || defined(__MINGW32__)) && defined(_DLL) /* tag specifying we're building for DLL runtime support */
# define WGLAPI __declspec(dllimport)
# else /* for use with static link lib build of Win32 edition only */
# define WGLAPI __declspec(dllimport)
# endif /* _STATIC_MESA support */
#endif /* WIN32 / CYGWIN bracket */
/*
* Either define MESA_BIG_ENDIAN or MESA_LITTLE_ENDIAN.
* Do not use them unless absolutely necessary!
* Try to use a runtime test instead.
* For now, only used by some DRI hardware drivers for color/texel packing.
*/
#if defined(BYTE_ORDER) && defined(BIG_ENDIAN) && BYTE_ORDER == BIG_ENDIAN
#if defined(__linux__)
#include <byteswap.h>
#define CPU_TO_LE32( x ) bswap_32( x )
#else /*__linux__*/
#include <sys/endian.h>
#define CPU_TO_LE32( x ) bswap32( x )
#error BEXXX
#endif /*__linux__*/
#define MESA_BIG_ENDIAN 1
#else
#define CPU_TO_LE32( x ) ( x )
#define MESA_LITTLE_ENDIAN 1
#endif
#define LE32_TO_CPU( x ) CPU_TO_LE32( x )
#define GL_GLEXT_PROTOTYPES
#include "GL/gl.h"
#include "GL/glext.h"
#if !defined(CAPI) && defined(WIN32) && !defined(BUILD_FOR_SNAP)
#define CAPI _cdecl
#endif
/* This is a macro on IRIX */
#ifdef _P
#undef _P
#endif
/* Turn off macro checking systems used by other libraries */
#ifdef CHECK
#undef CHECK
#endif
/* Create a macro so that asm functions can be linked into compilers other
* than GNU C
*/
#ifndef _ASMAPI
#if defined(WIN32) && !defined(BUILD_FOR_SNAP)/* was: !defined( __GNUC__ ) && !defined( VMS ) && !defined( __INTEL_COMPILER )*/
#define _ASMAPI __cdecl
#else
#define _ASMAPI
#endif
#ifdef PTR_DECL_IN_FRONT
#define _ASMAPIP * _ASMAPI
#else
#define _ASMAPIP _ASMAPI *
#endif
#endif
#ifdef USE_X86_ASM
#define _NORMAPI _ASMAPI
#define _NORMAPIP _ASMAPIP
#else
#define _NORMAPI
#define _NORMAPIP *
#endif
/* Function inlining */
#if defined(__GNUC__)
# define INLINE __inline__
#elif defined(__MSC__)
# define INLINE __inline
#elif defined(_MSC_VER)
# define INLINE __inline
#elif defined(__ICL)
# define INLINE __inline
#elif defined(__INTEL_COMPILER)
# define INLINE inline
#elif defined(__WATCOMC__) && (__WATCOMC__ >= 1100)
# define INLINE __inline
#elif defined(__SUNPRO_C) && defined(__C99FEATURES__)
# define INLINE inline
# define __inline inline
# define __inline__ inline
#elif (__STDC_VERSION__ >= 199901L) /* C99 */
# define INLINE inline
#else
# define INLINE
#endif
/* If we build the library with gcc's -fvisibility=hidden flag, we'll
* use the PUBLIC macro to mark functions that are to be exported.
*
* We also need to define a USED attribute, so the optimizer doesn't
* inline a static function that we later use in an alias. - ajax
*/
#if defined(__GNUC__) && (__GNUC__ * 100 + __GNUC_MINOR__) >= 303
# define PUBLIC __attribute__((visibility("default")))
# define USED __attribute__((used))
#else
# define PUBLIC
# define USED
#endif
/* Some compilers don't like some of Mesa's const usage */
#ifdef NO_CONST
# define CONST
#else
# define CONST const
#endif
#if defined(BUILD_FOR_SNAP) && defined(CHECKED)
# define ASSERT(X) _CHECK(X)
#elif defined(DEBUG)
# define ASSERT(X) assert(X)
#else
# define ASSERT(X)
#endif
#if (!defined(__GNUC__) || __GNUC__ < 3) && (!defined(__IBMC__) || __IBMC__ < 900)
# define __builtin_expect(x, y) x
#endif
/* The __FUNCTION__ gcc variable is generally only used for debugging.
* If we're not using gcc, define __FUNCTION__ as a cpp symbol here.
* Don't define it if using a newer Windows compiler.
*/
#ifndef __FUNCTION__
# if defined(__VMS)
# define __FUNCTION__ "VMS$NL:"
# elif ((!defined __GNUC__) || (__GNUC__ < 2)) && (!defined __xlC__) && \
(!defined(_MSC_VER) || _MSC_VER < 1300)
# if (__STDC_VERSION__ >= 199901L) /* C99 */ || \
(defined(__SUNPRO_C) && defined(__C99FEATURES__))
# define __FUNCTION__ __func__
# else
# define __FUNCTION__ "<unknown>"
# endif
# endif
#endif
#include "config.h"
#endif /* GLHEADER_H */