*/
#include "glxclient.h"
+#include "glapi.h"
+#include "glxextensions.h"
+#include "glcontextmodes.h"
+
+#ifdef GLX_DIRECT_RENDERING
#ifdef GLX_USE_APPLEGL
#include "apple_glx_context.h"
#include "apple_glx.h"
#include "glx_error.h"
+#define GC_IS_DIRECT(gc) ((gc)->isDirect)
#else
-#include "glapi.h"
-#endif
-#include "glxextensions.h"
-#include "glcontextmodes.h"
-
-#if defined(GLX_DIRECT_RENDERING) && !defined(GLX_USE_APPLEGL)
#include <sys/time.h>
#include <X11/extensions/xf86vmode.h>
#include "xf86dri.h"
#define GC_IS_DIRECT(gc) ((gc)->driContext != NULL)
+#endif
#else
#define GC_IS_DIRECT(gc) (0)
#endif
/****************************************************************************/
-#ifdef GLX_DIRECT_RENDERING
+#if defined(GLX_DIRECT_RENDERING) && !defined(GLX_USE_APPLEGL)
static Bool windowExistsFlag;
static int
gc->maxSmallRenderCommandSize = bufSize;
#ifdef GLX_USE_APPLEGL
- gc->apple = NULL;
+ gc->driContext = NULL;
gc->do_destroy = False;
#endif
{
GLXContext gc;
#ifdef GLX_DIRECT_RENDERING
+#ifdef GLX_USE_APPLEGL
+ int errorcode;
+ bool x11error;
+#else
__GLXscreenConfigs *const psc = GetGLXScreenConfigs(dpy, screen);
#endif
-#ifdef GLX_USE_APPLEGL
- int errorcode;
- bool x11error;
#endif
if (dpy == NULL)
if (!gc)
return NULL;
-#ifndef GLX_USE_APPLEGL
+#ifndef GLX_USE_APPLEGL /* TODO: darwin indirect */
#ifdef GLX_DIRECT_RENDERING
if (allowDirect && psc->driScreen) {
gc->driContext = psc->driScreen->createContext(psc, fbconfig, gc,
#endif
gc->imported = GL_FALSE;
+ gc->renderType = renderType;
+
+ /* TODO: darwin: Integrate with above to do indirect */
#ifdef GLX_USE_APPLEGL
- if(apple_glx_create_context(&gc->apple, dpy, screen, fbconfig,
- shareList ? shareList->apple : NULL,
+ if(apple_glx_create_context(&gc->driContext, dpy, screen, fbconfig,
+ shareList ? shareList->driContext : NULL,
&errorcode, &x11error)) {
__glXSendError(dpy, errorcode, 0, X_GLXCreateContext, x11error);
__glXFreeContext(gc);
gc->currentContextTag = -1;
gc->mode = fbconfig;
gc->isDirect = allowDirect;
-#else
- gc->renderType = renderType;
#endif
return gc;
XFree((char *) gc->version);
if (gc->extensions)
XFree((char *) gc->extensions);
-#ifndef GLX_USE_APPLEGL
__glFreeAttributeState(gc);
-#endif
XFree((char *) gc->buf);
Xfree((char *) gc->client_state_private);
XFree((char *) gc);
static void
DestroyContext(Display * dpy, GLXContext gc)
{
-#ifndef GLX_USE_APPLEGL
+#ifndef GLX_USE_APPLEGL /* TODO: darwin: indirect */
xGLXDestroyContextReq *req;
GLXContextID xid;
CARD8 opcode;
return;
}
-#ifdef GLX_DIRECT_RENDERING
+#if defined(GLX_DIRECT_RENDERING) && !defined(GLX_USE_APPLEGL)
/* Destroy the direct rendering context */
if (gc->driContext) {
(*gc->driContext->destroyContext) (gc->driContext, gc->psc, dpy);
/* Destroy the handle if not current to anybody */
__glXUnlock();
#ifdef GLX_USE_APPLEGL
- if(gc->apple)
- apple_glx_destroy_context(&gc->apple, dpy);
+ if(gc->driContext)
+ apple_glx_destroy_context(&gc->driContext, dpy);
#endif
__glXFreeContext(gc);
}
#ifdef GLX_USE_APPLEGL
glFinish();
#else
-#ifdef GLX_DIRECT_RENDERING
+#if defined(GLX_DIRECT_RENDERING) && !defined(GLX_USE_APPLEGL)
if (gc->driContext) {
int screen;
__GLXDRIdrawable *pdraw =
__glXFlushRenderBuffer(gc, gc->pc);
#ifdef GLX_USE_APPLEGL
- apple_glx_waitx(dpy, gc->apple);
+ apple_glx_waitx(dpy, gc->driContext);
#else
-#ifdef GLX_DIRECT_RENDERING
+#if defined(GLX_DIRECT_RENDERING) && !defined(GLX_USE_APPLEGL)
if (gc->driContext) {
int screen;
__GLXDRIdrawable *pdraw =
#ifdef GLX_USE_APPLEGL
DRI_glXUseXFont(font, first, count, listBase);
#else
-#ifdef GLX_DIRECT_RENDERING
+#if defined(GLX_DIRECT_RENDERING) && !defined(GLX_USE_APPLEGL)
if (gc->driContext) {
DRI_glXUseXFont(font, first, count, listBase);
return;
int errorcode;
bool x11error;
- if(apple_glx_copy_context(gc->apple, source->apple, dest->apple,
+ if(apple_glx_copy_context(gc->driContext, source->driContext, dest->driContext,
mask, &errorcode, &x11error)) {
__glXSendError(dpy, errorcode, 0, X_GLXCopyContext, x11error);
}
return;
}
-#ifdef GLX_DIRECT_RENDERING
+#if defined(GLX_DIRECT_RENDERING) && !defined(GLX_USE_APPLEGL)
if (gc->driContext) {
/* NOT_DONE: This does not work yet */
}
}
-#ifndef GLX_USE_APPLEGL
/**
* Determine if a context uses direct rendering.
*
static Bool
__glXIsDirect(Display * dpy, GLXContextID contextID)
{
+#ifndef GLX_USE_APPLEGL /* TODO: apple indirect */
+ return GC_IS_DIRECT(gc);
+#else
#if !defined(USE_XCB)
xGLXIsDirectReq *req;
xGLXIsDirectReply reply;
return reply.isDirect;
#endif /* USE_XCB */
-}
#endif /* GLX_USE_APPLEGL */
+}
/**
* \todo
PUBLIC Bool
glXIsDirect(Display * dpy, GLXContext gc)
{
-#ifdef GLX_USE_APPLEGL
- /*
- * This isn't an ideal test.
- * glXIsDirect should probably search a list of contexts.
- */
- if(NULL == gc) {
- __glXSendError(dpy, GLXBadContext, 0, X_GLXIsDirect, false);
- return False;
- }
- return gc->isDirect;
-#else
if (!gc) {
return GL_FALSE;
}
return GL_TRUE;
}
return __glXIsDirect(dpy, gc->xid);
-#endif /* GLX_USE_APPLEGL */
}
PUBLIC GLXPixmap
UnlockDisplay(dpy);
SyncHandle();
-#ifdef GLX_DIRECT_RENDERING
+#if defined(GLX_DIRECT_RENDERING) && !defined(GLX_USE_APPLEGL)
do {
/* FIXME: Maybe delay __DRIdrawable creation until the drawable
* is actually bound to a context... */
UnlockDisplay(dpy);
SyncHandle();
-#ifdef GLX_DIRECT_RENDERING
+#if defined(GLX_DIRECT_RENDERING) && !defined(GLX_USE_APPLEGL)
{
int screen;
__GLXdisplayPrivate *const priv = __glXInitialize(dpy);
{
#ifdef GLX_USE_APPLEGL
GLXContext gc = glXGetCurrentContext();
- if(gc && apple_glx_is_current_drawable(dpy, gc->apple, drawable)) {
- apple_glx_swap_buffers(gc->apple);
+ if(gc && apple_glx_is_current_drawable(dpy, gc->driContext, drawable)) {
+ apple_glx_swap_buffers(gc->driContext);
} else {
__glXSendError(dpy, GLXBadCurrentWindow, 0, X_GLXSwapBuffers, false);
}
xGLXSwapBuffersReq *req;
#endif
-#ifdef GLX_DIRECT_RENDERING
+#if defined(GLX_DIRECT_RENDERING) && !defined(GLX_USE_APPLEGL)
__GLXDRIdrawable *pdraw = GetGLXDRIDrawable(dpy, drawable, NULL);
if (pdraw != NULL) {
}
__glXCalculateUsableExtensions(psc,
-#ifdef GLX_DIRECT_RENDERING
+#if defined(GLX_DIRECT_RENDERING) && !defined(GLX_USE_APPLEGL)
(psc->driScreen != NULL),
#else
GL_FALSE,
int retVal;
/* get the information from the server if we don't have it already */
-#ifdef GLX_DIRECT_RENDERING
+#if defined(GLX_DIRECT_RENDERING) && !defined(GLX_USE_APPLEGL)
if (!ctx->driContext && (ctx->mode == NULL)) {
#else
if (ctx->mode == NULL) {
return False;
}
-#ifdef GLX_DIRECT_RENDERING
+#if defined(GLX_DIRECT_RENDERING) && !defined(GLX_USE_APPLEGL)
_X_HIDDEN GLboolean
__driGetMscRateOML(__DRIdrawable * draw,
int32_t * numerator, int32_t * denominator, void *private)
if (divisor > 0 && remainder >= divisor)
return -1;
+ if (target_msc == 0 && divisor == 0 && remainder == 0)
+ remainder = 1;
+
#ifdef __DRI_SWAP_BUFFER_COUNTER
if (psc->counters != NULL)
return (*psc->sbc->swapBuffersMSC)(pdraw->driDrawable, target_msc,
i++;
}
-#ifdef GLX_DIRECT_RENDERING
+#if defined(GLX_DIRECT_RENDERING) && !defined(GLX_USE_APPLEGL)
if (gc->driContext) {
__GLXDRIdrawable *pdraw = GetGLXDRIDrawable(dpy, drawable, NULL);
GLX_FUNCTION2(glXReleaseTexImageEXT, __glXReleaseTexImageEXT),
#endif
-#ifdef GLX_DIRECT_RENDERING
+#if defined(GLX_DIRECT_RENDERING) && !defined(GLX_USE_APPLEGL)
/*** DRI configuration ***/
GLX_FUNCTION(glXGetScreenDriver),
GLX_FUNCTION(glXGetDriverConfig),
#endif /* __GNUC__ */
-#ifdef GLX_DIRECT_RENDERING
+#if defined(GLX_DIRECT_RENDERING) && !defined(GLX_USE_APPLEGL)
/**
* Get the unadjusted system time (UST). Currently, the UST is measured in
* microseconds since Epoc. The actual resolution of the UST may vary from