summaryrefslogtreecommitdiff
path: root/src/glx/x11
diff options
context:
space:
mode:
Diffstat (limited to 'src/glx/x11')
-rw-r--r--src/glx/x11/dri2_glx.c52
-rw-r--r--src/glx/x11/glx_pbuffer.c1
-rw-r--r--src/glx/x11/glxclient.h6
-rw-r--r--src/glx/x11/glxcurrent.c48
-rw-r--r--src/glx/x11/indirect.c60
-rw-r--r--src/glx/x11/indirect_vertex_program.c4
-rw-r--r--src/glx/x11/pixelstore.c4
7 files changed, 112 insertions, 63 deletions
diff --git a/src/glx/x11/dri2_glx.c b/src/glx/x11/dri2_glx.c
index 0ef5d3ab56..9c8f1101b9 100644
--- a/src/glx/x11/dri2_glx.c
+++ b/src/glx/x11/dri2_glx.c
@@ -60,9 +60,6 @@ struct __GLXDRIdisplayPrivateRec {
int driMajor;
int driMinor;
int driPatch;
-
- unsigned long configureSeqno;
- Bool (*oldConfigProc)(Display *, XEvent *, xEvent *);
};
struct __GLXDRIcontextPrivateRec {
@@ -76,7 +73,6 @@ struct __GLXDRIdrawablePrivateRec {
__DRIbuffer buffers[5];
int bufferCount;
int width, height;
- unsigned long configureSeqno;
int have_back;
int have_front;
int have_fake_front;
@@ -174,7 +170,6 @@ static __GLXDRIdrawable *dri2CreateDrawable(__GLXscreenConfigs *psc,
pdraw->base.drawable = drawable;
pdraw->base.psc = psc;
pdraw->bufferCount = 0;
- pdraw->configureSeqno = ~0;
DRI2CreateDrawable(psc->dpy, xDrawable);
@@ -293,30 +288,9 @@ dri2GetBuffers(__DRIdrawable *driDrawable,
int *out_count, void *loaderPrivate)
{
__GLXDRIdrawablePrivate *pdraw = loaderPrivate;
- __GLXdisplayPrivate *dpyPriv = __glXInitialize(pdraw->base.psc->dpy);
- __GLXDRIdisplayPrivate *pdp = (__GLXDRIdisplayPrivate *)dpyPriv->dri2Display;
DRI2Buffer *buffers;
int i;
- /**
- * Check if a ConfigureNotify has come in since we last asked for the
- * buffers associated with this drawable. If not, we can assume that they're
- * the same set at glViewport time, and save a synchronous round-trip to the
- * X Server.
- */
- if (pdraw->configureSeqno == pdp->configureSeqno &&
- count == pdraw->bufferCount) {
- for (i = 0; i < count; i++) {
- if (pdraw->buffers[i].attachment != attachments[i])
- break;
- }
- if (i == count) {
- *out_count = pdraw->bufferCount;
- return pdraw->buffers;
- }
- }
- pdraw->configureSeqno = pdp->configureSeqno;
-
buffers = DRI2GetBuffers(pdraw->base.psc->dpy, pdraw->base.xDrawable,
width, height, attachments, count, out_count);
if (buffers == NULL)
@@ -468,28 +442,6 @@ static void dri2DestroyDisplay(__GLXDRIdisplay *dpy)
Xfree(dpy);
}
-/**
- * Makes a note on receiving ConfigureNotify that we need to re-check the
- * DRI2 buffers, as window sizes may have resulted in reallocation.
- */
-static Bool dri2ConfigureNotifyProc(Display *dpy, XEvent *re, xEvent *event)
-{
- __GLXdisplayPrivate *dpyPriv = __glXInitialize(dpy);
- __GLXDRIdisplayPrivate *pdp;
- Bool ret;
-
- /* We should always be able to find our pdp, as it only gets torn down
- * when the Display is torn down.
- */
- pdp = (__GLXDRIdisplayPrivate *)dpyPriv->dri2Display;
-
- ret = pdp->oldConfigProc(dpy, re, event);
-
- pdp->configureSeqno = re->xconfigure.serial;
-
- return ret;
-}
-
/*
* Allocate, initialize and return a __DRIdisplayPrivate object.
* This is called from __glXInitialize() when we are given a new
@@ -512,11 +464,7 @@ _X_HIDDEN __GLXDRIdisplay *dri2CreateDisplay(Display *dpy)
return NULL;
}
- pdp->oldConfigProc = XESetWireToEvent(dpy, ConfigureNotify,
- dri2ConfigureNotifyProc);
-
pdp->driPatch = 0;
- pdp->configureSeqno = 0;
pdp->base.destroyDisplay = dri2DestroyDisplay;
pdp->base.createScreen = dri2CreateScreen;
diff --git a/src/glx/x11/glx_pbuffer.c b/src/glx/x11/glx_pbuffer.c
index 6bcf965056..a06331fd7f 100644
--- a/src/glx/x11/glx_pbuffer.c
+++ b/src/glx/x11/glx_pbuffer.c
@@ -194,7 +194,6 @@ determineTextureTarget(const int *attribs, int numAttribs)
static GLenum
determineTextureFormat(const int *attribs, int numAttribs)
{
- GLenum target = 0;
int i;
for (i = 0; i < numAttribs; i++) {
diff --git a/src/glx/x11/glxclient.h b/src/glx/x11/glxclient.h
index c42e80a0e8..bf68d0f891 100644
--- a/src/glx/x11/glxclient.h
+++ b/src/glx/x11/glxclient.h
@@ -426,6 +426,11 @@ struct __GLXcontextRec {
int server_minor; /**< Minor version number. */
/*@}*/
+ /**
+ * Thread ID we're currently current in. Zero if none.
+ */
+ unsigned long thread_id;
+
char gl_extension_bits[ __GL_EXT_BYTES ];
};
@@ -609,7 +614,6 @@ extern void __glXSendLargeCommand(__GLXcontext *, const GLvoid *, GLint,
const GLvoid *, GLint);
/* Initialize the GLX extension for dpy */
-extern __GLXdisplayPrivate * __glXGetPrivateFromDisplay(Display *dpy);
extern __GLXdisplayPrivate *__glXInitialize(Display*);
extern void __glXPreferEGL(int state);
diff --git a/src/glx/x11/glxcurrent.c b/src/glx/x11/glxcurrent.c
index 4d0a7c65eb..01f4233241 100644
--- a/src/glx/x11/glxcurrent.c
+++ b/src/glx/x11/glxcurrent.c
@@ -339,6 +339,20 @@ FetchDRIDrawable(Display * dpy, GLXDrawable glxDrawable, GLXContext gc)
}
#endif /* GLX_DIRECT_RENDERING */
+static void
+__glXGenerateError(Display *dpy, GLXContext gc, XID resource,
+ BYTE errorCode, CARD16 minorCode)
+{
+ xError error;
+
+ error.errorCode = errorCode;
+ error.resourceID = resource;
+ error.sequenceNumber = dpy->request;
+ error.type = X_Error;
+ error.majorCode = gc->majorOpcode;
+ error.minorCode = minorCode;
+ _XError(dpy, &error);
+}
/**
* Make a particular context current.
@@ -369,8 +383,26 @@ MakeContextCurrent(Display * dpy, GLXDrawable draw,
return GL_FALSE;
}
+ if (gc == NULL && (draw != None || read != None)) {
+ __glXGenerateError(dpy, gc, (draw != None) ? draw : read,
+ BadMatch, X_GLXMakeContextCurrent);
+ return False;
+ }
+ if (gc != NULL && (draw == None || read == None)) {
+ __glXGenerateError(dpy, gc, None,
+ BadMatch, X_GLXMakeContextCurrent);
+ return False;
+ }
+
_glapi_check_multithread();
+ if (gc != NULL && gc->thread_id != 0 &&
+ gc->thread_id != _glthread_GetID()) {
+ __glXGenerateError(dpy, gc, gc->xid,
+ BadAccess, X_GLXMakeContextCurrent);
+ return False;
+ }
+
#ifdef GLX_DIRECT_RENDERING
/* Bind the direct rendering context to the drawable */
if (gc && gc->driContext) {
@@ -378,21 +410,17 @@ MakeContextCurrent(Display * dpy, GLXDrawable draw,
__GLXDRIdrawable *pread = FetchDRIDrawable(dpy, read, gc);
if ((pdraw == NULL) || (pread == NULL)) {
- xError error;
-
- error.errorCode = GLXBadDrawable;
- error.resourceID = (pdraw == NULL) ? draw : read;
- error.sequenceNumber = dpy->request;
- error.type = X_Error;
- error.majorCode = gc->majorOpcode;
- error.minorCode = X_GLXMakeContextCurrent;
- _XError(dpy, &error);
+ __glXGenerateError(dpy, gc, (pdraw == NULL) ? draw : read,
+ GLXBadDrawable, X_GLXMakeContextCurrent);
return False;
}
bindReturnValue =
(gc->driContext->bindContext) (gc->driContext, pdraw, pread);
}
+ else if (!gc && oldGC && oldGC->driContext) {
+ bindReturnValue = True;
+ }
else
#endif
{
@@ -453,6 +481,7 @@ MakeContextCurrent(Display * dpy, GLXDrawable draw,
oldGC->currentDrawable = None;
oldGC->currentReadable = None;
oldGC->currentContextTag = 0;
+ oldGC->thread_id = 0;
if (oldGC->xid == None) {
/* We are switching away from a context that was
@@ -477,6 +506,7 @@ MakeContextCurrent(Display * dpy, GLXDrawable draw,
gc->currentDpy = dpy;
gc->currentDrawable = draw;
gc->currentReadable = read;
+ gc->thread_id = _glthread_GetID();
#ifdef GLX_DIRECT_RENDERING
if (!gc->driContext) {
diff --git a/src/glx/x11/indirect.c b/src/glx/x11/indirect.c
index 08d52aeea3..aea117ec32 100644
--- a/src/glx/x11/indirect.c
+++ b/src/glx/x11/indirect.c
@@ -5198,9 +5198,13 @@ glDeleteTexturesEXT(GLsizei n, const GLuint * textures)
{
__GLXcontext *const gc = __glXGetCurrentContext();
+#ifdef GLX_DIRECT_RENDERING
if (gc->driContext) {
CALL_DeleteTextures(GET_DISPATCH(), (n, textures));
} else {
+#else
+ {
+#endif
__GLXcontext *const gc = __glXGetCurrentContext();
Display *const dpy = gc->currentDpy;
const GLuint cmdlen = 4 + __GLX_PAD((n * 4));
@@ -5266,9 +5270,13 @@ glGenTexturesEXT(GLsizei n, GLuint * textures)
{
__GLXcontext *const gc = __glXGetCurrentContext();
+#ifdef GLX_DIRECT_RENDERING
if (gc->driContext) {
CALL_GenTextures(GET_DISPATCH(), (n, textures));
} else {
+#else
+ {
+#endif
__GLXcontext *const gc = __glXGetCurrentContext();
Display *const dpy = gc->currentDpy;
const GLuint cmdlen = 4;
@@ -5328,9 +5336,13 @@ glIsTextureEXT(GLuint texture)
{
__GLXcontext *const gc = __glXGetCurrentContext();
+#ifdef GLX_DIRECT_RENDERING
if (gc->driContext) {
return CALL_IsTexture(GET_DISPATCH(), (texture));
} else {
+#else
+ {
+#endif
__GLXcontext *const gc = __glXGetCurrentContext();
Display *const dpy = gc->currentDpy;
GLboolean retval = (GLboolean) 0;
@@ -5641,9 +5653,13 @@ glGetColorTableEXT(GLenum target, GLenum format, GLenum type, GLvoid * table)
{
__GLXcontext *const gc = __glXGetCurrentContext();
+#ifdef GLX_DIRECT_RENDERING
if (gc->driContext) {
CALL_GetColorTable(GET_DISPATCH(), (target, format, type, table));
} else {
+#else
+ {
+#endif
__GLXcontext *const gc = __glXGetCurrentContext();
const __GLXattribute *const state = gc->client_state_private;
Display *const dpy = gc->currentDpy;
@@ -5714,10 +5730,14 @@ glGetColorTableParameterfvEXT(GLenum target, GLenum pname, GLfloat * params)
{
__GLXcontext *const gc = __glXGetCurrentContext();
+#ifdef GLX_DIRECT_RENDERING
if (gc->driContext) {
CALL_GetColorTableParameterfv(GET_DISPATCH(),
(target, pname, params));
} else {
+#else
+ {
+#endif
__GLXcontext *const gc = __glXGetCurrentContext();
Display *const dpy = gc->currentDpy;
const GLuint cmdlen = 8;
@@ -5784,10 +5804,14 @@ glGetColorTableParameterivEXT(GLenum target, GLenum pname, GLint * params)
{
__GLXcontext *const gc = __glXGetCurrentContext();
+#ifdef GLX_DIRECT_RENDERING
if (gc->driContext) {
CALL_GetColorTableParameteriv(GET_DISPATCH(),
(target, pname, params));
} else {
+#else
+ {
+#endif
__GLXcontext *const gc = __glXGetCurrentContext();
Display *const dpy = gc->currentDpy;
const GLuint cmdlen = 8;
@@ -6107,10 +6131,14 @@ gl_dispatch_stub_356(GLenum target, GLenum format, GLenum type,
{
__GLXcontext *const gc = __glXGetCurrentContext();
+#ifdef GLX_DIRECT_RENDERING
if (gc->driContext) {
CALL_GetConvolutionFilter(GET_DISPATCH(),
(target, format, type, image));
} else {
+#else
+ {
+#endif
__GLXcontext *const gc = __glXGetCurrentContext();
const __GLXattribute *const state = gc->client_state_private;
Display *const dpy = gc->currentDpy;
@@ -6182,10 +6210,14 @@ gl_dispatch_stub_357(GLenum target, GLenum pname, GLfloat * params)
{
__GLXcontext *const gc = __glXGetCurrentContext();
+#ifdef GLX_DIRECT_RENDERING
if (gc->driContext) {
CALL_GetConvolutionParameterfv(GET_DISPATCH(),
(target, pname, params));
} else {
+#else
+ {
+#endif
__GLXcontext *const gc = __glXGetCurrentContext();
Display *const dpy = gc->currentDpy;
const GLuint cmdlen = 8;
@@ -6252,10 +6284,14 @@ gl_dispatch_stub_358(GLenum target, GLenum pname, GLint * params)
{
__GLXcontext *const gc = __glXGetCurrentContext();
+#ifdef GLX_DIRECT_RENDERING
if (gc->driContext) {
CALL_GetConvolutionParameteriv(GET_DISPATCH(),
(target, pname, params));
} else {
+#else
+ {
+#endif
__GLXcontext *const gc = __glXGetCurrentContext();
Display *const dpy = gc->currentDpy;
const GLuint cmdlen = 8;
@@ -6329,10 +6365,14 @@ gl_dispatch_stub_361(GLenum target, GLboolean reset, GLenum format,
{
__GLXcontext *const gc = __glXGetCurrentContext();
+#ifdef GLX_DIRECT_RENDERING
if (gc->driContext) {
CALL_GetHistogram(GET_DISPATCH(),
(target, reset, format, type, values));
} else {
+#else
+ {
+#endif
__GLXcontext *const gc = __glXGetCurrentContext();
const __GLXattribute *const state = gc->client_state_private;
Display *const dpy = gc->currentDpy;
@@ -6403,9 +6443,13 @@ gl_dispatch_stub_362(GLenum target, GLenum pname, GLfloat * params)
{
__GLXcontext *const gc = __glXGetCurrentContext();
+#ifdef GLX_DIRECT_RENDERING
if (gc->driContext) {
CALL_GetHistogramParameterfv(GET_DISPATCH(), (target, pname, params));
} else {
+#else
+ {
+#endif
__GLXcontext *const gc = __glXGetCurrentContext();
Display *const dpy = gc->currentDpy;
const GLuint cmdlen = 8;
@@ -6471,9 +6515,13 @@ gl_dispatch_stub_363(GLenum target, GLenum pname, GLint * params)
{
__GLXcontext *const gc = __glXGetCurrentContext();
+#ifdef GLX_DIRECT_RENDERING
if (gc->driContext) {
CALL_GetHistogramParameteriv(GET_DISPATCH(), (target, pname, params));
} else {
+#else
+ {
+#endif
__GLXcontext *const gc = __glXGetCurrentContext();
Display *const dpy = gc->currentDpy;
const GLuint cmdlen = 8;
@@ -6543,9 +6591,13 @@ gl_dispatch_stub_364(GLenum target, GLboolean reset, GLenum format,
{
__GLXcontext *const gc = __glXGetCurrentContext();
+#ifdef GLX_DIRECT_RENDERING
if (gc->driContext) {
CALL_GetMinmax(GET_DISPATCH(), (target, reset, format, type, values));
} else {
+#else
+ {
+#endif
__GLXcontext *const gc = __glXGetCurrentContext();
const __GLXattribute *const state = gc->client_state_private;
Display *const dpy = gc->currentDpy;
@@ -6614,9 +6666,13 @@ gl_dispatch_stub_365(GLenum target, GLenum pname, GLfloat * params)
{
__GLXcontext *const gc = __glXGetCurrentContext();
+#ifdef GLX_DIRECT_RENDERING
if (gc->driContext) {
CALL_GetMinmaxParameterfv(GET_DISPATCH(), (target, pname, params));
} else {
+#else
+ {
+#endif
__GLXcontext *const gc = __glXGetCurrentContext();
Display *const dpy = gc->currentDpy;
const GLuint cmdlen = 8;
@@ -6679,9 +6735,13 @@ gl_dispatch_stub_366(GLenum target, GLenum pname, GLint * params)
{
__GLXcontext *const gc = __glXGetCurrentContext();
+#ifdef GLX_DIRECT_RENDERING
if (gc->driContext) {
CALL_GetMinmaxParameteriv(GET_DISPATCH(), (target, pname, params));
} else {
+#else
+ {
+#endif
__GLXcontext *const gc = __glXGetCurrentContext();
Display *const dpy = gc->currentDpy;
const GLuint cmdlen = 8;
diff --git a/src/glx/x11/indirect_vertex_program.c b/src/glx/x11/indirect_vertex_program.c
index 865a4b1ba1..3313ac008a 100644
--- a/src/glx/x11/indirect_vertex_program.c
+++ b/src/glx/x11/indirect_vertex_program.c
@@ -30,6 +30,10 @@
#include "indirect_vertex_array.h"
#include <GL/glxproto.h>
+#if !defined __GNUC__ || __GNUC__ < 3
+# define __builtin_expect(x, y) x
+#endif
+
static void
do_vertex_attrib_enable(GLuint index, GLboolean val)
{
diff --git a/src/glx/x11/pixelstore.c b/src/glx/x11/pixelstore.c
index 0eb31bf1e3..8b51b5d8b7 100644
--- a/src/glx/x11/pixelstore.c
+++ b/src/glx/x11/pixelstore.c
@@ -31,6 +31,10 @@
#include "glxclient.h"
#include "indirect.h"
+#if !defined __GNUC__ || __GNUC__ < 3
+# define __builtin_expect(x, y) x
+#endif
+
/**
* Send glPixelStore command to the server
*