Move hyperpipe and swapbarrier extension funcs to screen private struct.

This gets rid of a couple more global arrays and gets the two extensions
more in line with the general extension mechanism.
This commit is contained in:
Kristian Høgsberg 2007-05-31 22:55:47 -04:00
parent 781515bb63
commit 600028305c
5 changed files with 50 additions and 70 deletions

View File

@ -2088,13 +2088,14 @@ int __glXDisp_BindSwapBarrierSGIX(__GLXclientState *cl, GLbyte *pc)
int barrier = req->barrier; int barrier = req->barrier;
DrawablePtr pDraw; DrawablePtr pDraw;
int screen, rc; int screen, rc;
__GLXscreen *pGlxScreen;
rc = dixLookupDrawable(&pDraw, drawable, client, 0, DixUnknownAccess); rc = dixLookupDrawable(&pDraw, drawable, client, 0, DixUnknownAccess);
pGlxScreen = glxGetScreen(pDraw->pScreen);
if (rc == Success && (pDraw->type == DRAWABLE_WINDOW)) { if (rc == Success && (pDraw->type == DRAWABLE_WINDOW)) {
screen = pDraw->pScreen->myNum; screen = pDraw->pScreen->myNum;
if (__glXSwapBarrierFuncs && if (pGlxScreen->swapBarrierFuncs) {
__glXSwapBarrierFuncs[screen].bindSwapBarrierFunc) { int ret = pGlxScreen->swapBarrierFuncs->bindSwapBarrierFunc(screen, drawable, barrier);
int ret = __glXSwapBarrierFuncs[screen].bindSwapBarrierFunc(screen, drawable, barrier);
if (ret == Success) { if (ret == Success) {
if (barrier) if (barrier)
/* add source for cleanup when drawable is gone */ /* add source for cleanup when drawable is gone */
@ -2118,10 +2119,11 @@ int __glXDisp_QueryMaxSwapBarriersSGIX(__GLXclientState *cl, GLbyte *pc)
(xGLXQueryMaxSwapBarriersSGIXReq *) pc; (xGLXQueryMaxSwapBarriersSGIXReq *) pc;
xGLXQueryMaxSwapBarriersSGIXReply reply; xGLXQueryMaxSwapBarriersSGIXReply reply;
int screen = req->screen; int screen = req->screen;
__GLXscreen *pGlxScreen;
if (__glXSwapBarrierFuncs && pGlxScreen = glxGetScreen(screenInfo.screens[screen]);
__glXSwapBarrierFuncs[screen].queryMaxSwapBarriersFunc) if (pGlxScreen->swapBarrierFuncs)
reply.max = __glXSwapBarrierFuncs[screen].queryMaxSwapBarriersFunc(screen); reply.max = pGlxScreen->swapBarrierFuncs->queryMaxSwapBarriersFunc(screen);
else else
reply.max = 0; reply.max = 0;
@ -2154,11 +2156,12 @@ int __glXDisp_QueryHyperpipeNetworkSGIX(__GLXclientState *cl, GLbyte *pc)
int npipes=0; int npipes=0;
int n= 0; int n= 0;
__GLXscreen *pGlxScreen;
if (__glXHyperpipeFuncs && pGlxScreen = glxGetScreen(screenInfo.screens[screen]);
__glXHyperpipeFuncs[screen].queryHyperpipeNetworkFunc != NULL) { if (pGlxScreen->hyperpipeFuncs) {
rdata = rdata =
(__glXHyperpipeFuncs[screen].queryHyperpipeNetworkFunc(screen, &npipes, &n)); (pGlxScreen->hyperpipeFuncs->queryHyperpipeNetworkFunc(screen, &npipes, &n));
} }
length = __GLX_PAD(n) >> 2; length = __GLX_PAD(n) >> 2;
reply.type = X_Reply; reply.type = X_Reply;
@ -2191,13 +2194,13 @@ int __glXDisp_DestroyHyperpipeConfigSGIX (__GLXclientState *cl, GLbyte *pc)
int screen = req->screen; int screen = req->screen;
int success = GLX_BAD_HYPERPIPE_SGIX; int success = GLX_BAD_HYPERPIPE_SGIX;
int hpId ; int hpId ;
__GLXscreen *pGlxScreen;
hpId = req->hpId; hpId = req->hpId;
pGlxScreen = glxGetScreen(screenInfo.screens[screen]);
if (__glXHyperpipeFuncs && if (pGlxScreen->hyperpipeFuncs) {
__glXHyperpipeFuncs[screen].destroyHyperpipeConfigFunc != NULL) { success = pGlxScreen->hyperpipeFuncs->destroyHyperpipeConfigFunc(screen, hpId);
success = __glXHyperpipeFuncs[screen].destroyHyperpipeConfigFunc(screen, hpId);
} }
reply.type = X_Reply; reply.type = X_Reply;
@ -2229,12 +2232,13 @@ int __glXDisp_QueryHyperpipeConfigSGIX(__GLXclientState *cl, GLbyte *pc)
int npipes=0; int npipes=0;
int n= 0; int n= 0;
int hpId; int hpId;
__GLXscreen *pGlxScreen;
hpId = req->hpId; hpId = req->hpId;
if (__glXHyperpipeFuncs && pGlxScreen = glxGetScreen(screenInfo.screens[screen]);
__glXHyperpipeFuncs[screen].queryHyperpipeConfigFunc != NULL) { if (pGlxScreen->hyperpipeFuncs) {
rdata = __glXHyperpipeFuncs[screen].queryHyperpipeConfigFunc(screen, hpId,&npipes, &n); rdata = pGlxScreen->hyperpipeFuncs->queryHyperpipeConfigFunc(screen, hpId,&npipes, &n);
} }
length = __GLX_PAD(n) >> 2; length = __GLX_PAD(n) >> 2;
@ -2272,14 +2276,15 @@ int __glXDisp_HyperpipeConfigSGIX(__GLXclientState *cl, GLbyte *pc)
int npipes=0, networkId; int npipes=0, networkId;
int hpId=-1; int hpId=-1;
__GLXscreen *pGlxScreen;
pGlxScreen = glxGetScreen(screenInfo.screens[screen]);
networkId = (int)req->networkId; networkId = (int)req->networkId;
npipes = (int)req->npipes; npipes = (int)req->npipes;
rdata = (void *)(req +1); rdata = (void *)(req +1);
if (__glXHyperpipeFuncs && if (pGlxScreen->hyperpipeFuncs) {
__glXHyperpipeFuncs[screen].hyperpipeConfigFunc != NULL) { pGlxScreen->hyperpipeFuncs->hyperpipeConfigFunc(screen,networkId,
__glXHyperpipeFuncs[screen].hyperpipeConfigFunc(screen,networkId,
&hpId, &npipes, &hpId, &npipes,
(void *) rdata); (void *) rdata);
} }

View File

@ -198,9 +198,10 @@ extern RESTYPE __glXSwapBarrierRes;
static int SwapBarrierGone(int screen, XID drawable) static int SwapBarrierGone(int screen, XID drawable)
{ {
if (__glXSwapBarrierFuncs && __GLXscreen *pGlxScreen = glxGetScreen(screenInfo.screens[screen]);
__glXSwapBarrierFuncs[screen].bindSwapBarrierFunc != NULL) {
__glXSwapBarrierFuncs[screen].bindSwapBarrierFunc(screen, drawable, 0); if (pGlxScreen->swapBarrierFuncs) {
pGlxScreen->swapBarrierFuncs->bindSwapBarrierFunc(screen, drawable, 0);
} }
FreeResourceByType(drawable, __glXSwapBarrierRes, FALSE); FreeResourceByType(drawable, __glXSwapBarrierRes, FALSE);
return True; return True;

View File

@ -106,25 +106,5 @@ extern int GlxInitVisuals(
int preferredVis int preferredVis
); );
typedef struct {
void * (* queryHyperpipeNetworkFunc)(int, int *, int *);
void * (* queryHyperpipeConfigFunc)(int, int, int *, int *);
int (* destroyHyperpipeConfigFunc)(int, int);
void * (* hyperpipeConfigFunc)(int, int, int *, int *, void *);
} __GLXHyperpipeExtensionFuncs;
extern void __glXHyperpipeInit(int screen, __GLXHyperpipeExtensionFuncs *funcs);
extern __GLXHyperpipeExtensionFuncs *__glXHyperpipeFuncs;
typedef struct {
int (* bindSwapBarrierFunc)(int, XID, int);
int (* queryMaxSwapBarriersFunc)(int);
} __GLXSwapBarrierExtensionFuncs;
extern void __glXSwapBarrierInit(int screen, __GLXSwapBarrierExtensionFuncs *funcs);
extern __GLXSwapBarrierExtensionFuncs *__glXSwapBarrierFuncs;
#endif /* _glxext_h_ */ #endif /* _glxext_h_ */

View File

@ -181,12 +181,6 @@ static char GLXServerExtensions[] =
"GLX_MESA_copy_sub_buffer " "GLX_MESA_copy_sub_buffer "
; ;
__GLXSwapBarrierExtensionFuncs *__glXSwapBarrierFuncs = NULL;
static int __glXNumSwapBarrierFuncs = 0;
__GLXHyperpipeExtensionFuncs *__glXHyperpipeFuncs = NULL;
static int __glXNumHyperpipeFuncs = 0;
/* /*
** This hook gets called when a window moves or changes size. ** This hook gets called when a window moves or changes size.
*/ */
@ -256,34 +250,16 @@ static Bool glxPositionWindow(WindowPtr pWin, int x, int y)
void __glXHyperpipeInit(int screen, __GLXHyperpipeExtensionFuncs *funcs) void __glXHyperpipeInit(int screen, __GLXHyperpipeExtensionFuncs *funcs)
{ {
if (__glXNumHyperpipeFuncs < screen + 1) { __GLXscreen *pGlxScreen = glxGetScreen(screenInfo.screens[screen]);
__glXHyperpipeFuncs = xrealloc(__glXHyperpipeFuncs,
(screen+1) * sizeof(__GLXHyperpipeExtensionFuncs));
__glXNumHyperpipeFuncs = screen + 1;
}
__glXHyperpipeFuncs[screen].queryHyperpipeNetworkFunc = pGlxScreen->hyperpipeFuncs = funcs;
*funcs->queryHyperpipeNetworkFunc;
__glXHyperpipeFuncs[screen].queryHyperpipeConfigFunc =
*funcs->queryHyperpipeConfigFunc;
__glXHyperpipeFuncs[screen].destroyHyperpipeConfigFunc =
*funcs->destroyHyperpipeConfigFunc;
__glXHyperpipeFuncs[screen].hyperpipeConfigFunc =
*funcs->hyperpipeConfigFunc;
} }
void __glXSwapBarrierInit(int screen, __GLXSwapBarrierExtensionFuncs *funcs) void __glXSwapBarrierInit(int screen, __GLXSwapBarrierExtensionFuncs *funcs)
{ {
if (__glXNumSwapBarrierFuncs < screen + 1) { __GLXscreen *pGlxScreen = glxGetScreen(screenInfo.screens[screen]);
__glXSwapBarrierFuncs = xrealloc(__glXSwapBarrierFuncs,
(screen+1) * sizeof(__GLXSwapBarrierExtensionFuncs));
__glXNumSwapBarrierFuncs = screen + 1;
}
__glXSwapBarrierFuncs[screen].bindSwapBarrierFunc = pGlxScreen->swapBarrierFuncs = funcs;
funcs->bindSwapBarrierFunc;
__glXSwapBarrierFuncs[screen].queryMaxSwapBarriersFunc =
funcs->queryMaxSwapBarriersFunc;
} }
static Bool static Bool

View File

@ -42,6 +42,21 @@
#include "GL/internal/glcore.h" #include "GL/internal/glcore.h"
typedef struct {
void * (* queryHyperpipeNetworkFunc)(int, int *, int *);
void * (* queryHyperpipeConfigFunc)(int, int, int *, int *);
int (* destroyHyperpipeConfigFunc)(int, int);
void * (* hyperpipeConfigFunc)(int, int, int *, int *, void *);
} __GLXHyperpipeExtensionFuncs;
typedef struct {
int (* bindSwapBarrierFunc)(int, XID, int);
int (* queryMaxSwapBarriersFunc)(int);
} __GLXSwapBarrierExtensionFuncs;
void __glXHyperpipeInit(int screen, __GLXHyperpipeExtensionFuncs *funcs);
void __glXSwapBarrierInit(int screen, __GLXSwapBarrierExtensionFuncs *funcs);
/* /*
** Screen dependent data. These methods are the interface between the DIX ** Screen dependent data. These methods are the interface between the DIX
** and DDX layers of the GLX server extension. The methods provide an ** and DDX layers of the GLX server extension. The methods provide an
@ -62,6 +77,9 @@ struct __GLXscreen {
int (*swapInterval) (__GLXdrawable *drawable, int (*swapInterval) (__GLXdrawable *drawable,
int interval); int interval);
__GLXHyperpipeExtensionFuncs *hyperpipeFuncs;
__GLXSwapBarrierExtensionFuncs *swapBarrierFuncs;
ScreenPtr pScreen; ScreenPtr pScreen;
/** /**