2006-11-26 11:13:41 -07:00
|
|
|
/*
|
2009-09-06 13:44:18 -06:00
|
|
|
* 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.
|
|
|
|
*/
|
2006-11-26 11:13:41 -07:00
|
|
|
|
|
|
|
#ifdef HAVE_DMX_CONFIG_H
|
|
|
|
#include <dmx-config.h>
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#include "dmx.h"
|
|
|
|
|
|
|
|
#include "glxserver.h"
|
|
|
|
#include <windowstr.h>
|
|
|
|
#include <propertyst.h>
|
|
|
|
#include <os.h>
|
|
|
|
#include "g_disptab.h"
|
|
|
|
#include "glxutil.h"
|
|
|
|
#include "glxext.h"
|
|
|
|
#include "glxvisuals.h"
|
|
|
|
#include "micmap.h"
|
|
|
|
#include "glxswap.h"
|
2013-06-07 11:28:45 -06:00
|
|
|
#include "extinit.h"
|
|
|
|
#include "glx_extinit.h"
|
2006-11-26 11:13:41 -07:00
|
|
|
|
|
|
|
/*
|
|
|
|
** Forward declarations.
|
|
|
|
*/
|
|
|
|
static int __glXSwapDispatch(ClientPtr);
|
|
|
|
static int __glXDispatch(ClientPtr);
|
|
|
|
|
|
|
|
/*
|
|
|
|
** Called when the extension is reset.
|
|
|
|
*/
|
2012-06-10 07:21:05 -06:00
|
|
|
static void
|
|
|
|
ResetExtension(ExtensionEntry * extEntry)
|
2006-11-26 11:13:41 -07:00
|
|
|
{
|
|
|
|
__glXFlushContextCache();
|
|
|
|
__glXScreenReset();
|
|
|
|
SwapBarrierReset();
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
** Initialize the per-client context storage.
|
|
|
|
*/
|
2012-06-10 07:21:05 -06:00
|
|
|
static void
|
|
|
|
ResetClientState(int clientIndex)
|
2006-11-26 11:13:41 -07:00
|
|
|
{
|
|
|
|
__GLXclientState *cl = __glXClients[clientIndex];
|
|
|
|
Display **keep_be_displays;
|
|
|
|
int i;
|
|
|
|
|
2011-11-05 07:32:40 -06:00
|
|
|
free(cl->returnBuf);
|
|
|
|
free(cl->currentContexts);
|
|
|
|
free(cl->currentDrawables);
|
|
|
|
free(cl->largeCmdBuf);
|
2006-11-26 11:13:41 -07:00
|
|
|
|
2012-06-10 07:21:05 -06:00
|
|
|
for (i = 0; i < screenInfo.numScreens; i++) {
|
|
|
|
if (cl->be_displays[i])
|
|
|
|
XCloseDisplay(cl->be_displays[i]);
|
2006-11-26 11:13:41 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
keep_be_displays = cl->be_displays;
|
|
|
|
memset(cl, 0, sizeof(__GLXclientState));
|
|
|
|
cl->be_displays = keep_be_displays;
|
|
|
|
|
2011-11-05 07:32:40 -06:00
|
|
|
free(cl->GLClientextensions);
|
2006-11-26 11:13:41 -07:00
|
|
|
|
|
|
|
memset(cl->be_displays, 0, screenInfo.numScreens * sizeof(Display *));
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
** This procedure is called when the client who created the context goes
|
|
|
|
** away OR when glXDestroyContext is called. In either case, all we do is
|
|
|
|
** flag that the ID is no longer valid, and (maybe) free the context.
|
|
|
|
** use.
|
|
|
|
*/
|
2012-06-10 07:21:05 -06:00
|
|
|
static int
|
|
|
|
ContextGone(__GLXcontext * cx, XID id)
|
2006-11-26 11:13:41 -07:00
|
|
|
{
|
|
|
|
cx->idExists = GL_FALSE;
|
|
|
|
if (!cx->isCurrent) {
|
2012-06-10 07:21:05 -06:00
|
|
|
__glXFreeContext(cx);
|
2006-11-26 11:13:41 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
return True;
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
** Free a client's state.
|
|
|
|
*/
|
2012-06-10 07:21:05 -06:00
|
|
|
static int
|
|
|
|
ClientGone(int clientIndex, XID id)
|
2006-11-26 11:13:41 -07:00
|
|
|
{
|
|
|
|
__GLXcontext *cx;
|
|
|
|
__GLXclientState *cl = __glXClients[clientIndex];
|
|
|
|
int i;
|
|
|
|
|
|
|
|
if (cl) {
|
2012-06-10 07:21:05 -06:00
|
|
|
/*
|
|
|
|
** Free all the contexts that are current for this client.
|
|
|
|
*/
|
|
|
|
for (i = 0; i < cl->numCurrentContexts; i++) {
|
|
|
|
cx = cl->currentContexts[i];
|
|
|
|
if (cx) {
|
|
|
|
cx->isCurrent = GL_FALSE;
|
|
|
|
if (!cx->idExists) {
|
|
|
|
__glXFreeContext(cx);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
/*
|
|
|
|
** Re-initialize the client state structure. Don't free it because
|
|
|
|
** we'll probably get another client with this index and use the struct
|
|
|
|
** again. There is a maximum of MAXCLIENTS of these structures.
|
|
|
|
*/
|
|
|
|
ResetClientState(clientIndex);
|
2006-11-26 11:13:41 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
return True;
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
** Free a GLX Pixmap.
|
|
|
|
*/
|
2012-06-10 07:21:05 -06:00
|
|
|
void
|
|
|
|
__glXFreeGLXPixmap(__GLXpixmap * pGlxPixmap)
|
2006-11-26 11:13:41 -07:00
|
|
|
{
|
2012-06-10 07:21:05 -06:00
|
|
|
if (!pGlxPixmap->idExists && !pGlxPixmap->refcnt) {
|
|
|
|
|
|
|
|
PixmapPtr pPixmap = (PixmapPtr) pGlxPixmap->pDraw;
|
|
|
|
|
|
|
|
/*
|
|
|
|
** The DestroyPixmap routine should decrement the refcount and free
|
|
|
|
** only if it's zero.
|
|
|
|
*/
|
|
|
|
(*pGlxPixmap->pScreen->DestroyPixmap) (pPixmap);
|
|
|
|
free(pGlxPixmap->be_xids);
|
|
|
|
free(pGlxPixmap);
|
2006-11-26 11:13:41 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
2012-06-10 07:21:05 -06:00
|
|
|
static int
|
|
|
|
PixmapGone(__GLXpixmap * pGlxPixmap, XID id)
|
2006-11-26 11:13:41 -07:00
|
|
|
{
|
|
|
|
|
|
|
|
pGlxPixmap->idExists = False;
|
2012-06-10 07:21:05 -06:00
|
|
|
__glXFreeGLXPixmap(pGlxPixmap);
|
2006-11-26 11:13:41 -07:00
|
|
|
|
|
|
|
return True;
|
|
|
|
}
|
|
|
|
|
2012-06-10 07:21:05 -06:00
|
|
|
void
|
|
|
|
__glXFreeGLXWindow(__glXWindow * pGlxWindow)
|
2006-11-26 11:13:41 -07:00
|
|
|
{
|
|
|
|
if (!pGlxWindow->idExists && !pGlxWindow->refcnt) {
|
2012-06-10 07:21:05 -06:00
|
|
|
WindowPtr pWindow = (WindowPtr) pGlxWindow->pDraw;
|
|
|
|
WindowPtr ret;
|
2006-11-26 11:13:41 -07:00
|
|
|
|
2014-09-27 11:52:59 -06:00
|
|
|
dixLookupResourceByType((void *) &ret,
|
2012-06-10 07:21:05 -06:00
|
|
|
pWindow->drawable.id, RT_WINDOW,
|
|
|
|
NullClient, DixUnknownAccess);
|
2011-11-05 07:32:40 -06:00
|
|
|
if (ret == pWindow) {
|
2012-06-10 07:21:05 -06:00
|
|
|
(*pGlxWindow->pScreen->DestroyWindow) (pWindow);
|
2006-11-26 11:13:41 -07:00
|
|
|
}
|
|
|
|
|
2012-06-10 07:21:05 -06:00
|
|
|
free(pGlxWindow);
|
2006-11-26 11:13:41 -07:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2012-06-10 07:21:05 -06:00
|
|
|
static void
|
|
|
|
WindowGone(__glXWindow * pGlxWindow, XID id)
|
2006-11-26 11:13:41 -07:00
|
|
|
{
|
|
|
|
pGlxWindow->idExists = False;
|
|
|
|
__glXFreeGLXWindow(pGlxWindow);
|
|
|
|
}
|
|
|
|
|
2012-06-10 07:21:05 -06:00
|
|
|
void
|
|
|
|
__glXFreeGLXPbuffer(__glXPbuffer * pGlxPbuffer)
|
2006-11-26 11:13:41 -07:00
|
|
|
{
|
|
|
|
if (!pGlxPbuffer->idExists && !pGlxPbuffer->refcnt) {
|
2010-12-05 08:36:02 -07:00
|
|
|
free(pGlxPbuffer->be_xids);
|
|
|
|
free(pGlxPbuffer);
|
2006-11-26 11:13:41 -07:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2012-06-10 07:21:05 -06:00
|
|
|
static void
|
|
|
|
PbufferGone(__glXPbuffer * pGlxPbuffer, XID id)
|
2006-11-26 11:13:41 -07:00
|
|
|
{
|
|
|
|
pGlxPbuffer->idExists = False;
|
|
|
|
__glXFreeGLXPbuffer(pGlxPbuffer);
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
** Free a context.
|
|
|
|
*/
|
2012-06-10 07:21:05 -06:00
|
|
|
GLboolean
|
|
|
|
__glXFreeContext(__GLXcontext * cx)
|
2006-11-26 11:13:41 -07:00
|
|
|
{
|
2012-06-10 07:21:05 -06:00
|
|
|
if (cx->idExists || cx->isCurrent)
|
|
|
|
return GL_FALSE;
|
|
|
|
|
2011-11-05 07:32:40 -06:00
|
|
|
free(cx->feedbackBuf);
|
|
|
|
free(cx->selectBuf);
|
|
|
|
free(cx->real_ids);
|
|
|
|
free(cx->real_vids);
|
2006-11-26 11:13:41 -07:00
|
|
|
|
|
|
|
if (cx->pGlxPixmap) {
|
2012-06-10 07:21:05 -06:00
|
|
|
/*
|
|
|
|
** The previous drawable was a glx pixmap, release it.
|
|
|
|
*/
|
|
|
|
cx->pGlxPixmap->refcnt--;
|
|
|
|
__glXFreeGLXPixmap(cx->pGlxPixmap);
|
|
|
|
cx->pGlxPixmap = 0;
|
2006-11-26 11:13:41 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
if (cx->pGlxReadPixmap) {
|
2012-06-10 07:21:05 -06:00
|
|
|
/*
|
|
|
|
** The previous drawable was a glx pixmap, release it.
|
|
|
|
*/
|
|
|
|
cx->pGlxReadPixmap->refcnt--;
|
|
|
|
__glXFreeGLXPixmap(cx->pGlxReadPixmap);
|
|
|
|
cx->pGlxReadPixmap = 0;
|
2006-11-26 11:13:41 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
if (cx->pGlxWindow) {
|
2012-06-10 07:21:05 -06:00
|
|
|
/*
|
|
|
|
** The previous drawable was a glx window, release it.
|
|
|
|
*/
|
|
|
|
cx->pGlxWindow->refcnt--;
|
|
|
|
__glXFreeGLXWindow(cx->pGlxWindow);
|
|
|
|
cx->pGlxWindow = 0;
|
2006-11-26 11:13:41 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
if (cx->pGlxReadWindow) {
|
2012-06-10 07:21:05 -06:00
|
|
|
/*
|
|
|
|
** The previous drawable was a glx window, release it.
|
|
|
|
*/
|
|
|
|
cx->pGlxReadWindow->refcnt--;
|
|
|
|
__glXFreeGLXWindow(cx->pGlxReadWindow);
|
|
|
|
cx->pGlxReadWindow = 0;
|
2006-11-26 11:13:41 -07:00
|
|
|
}
|
|
|
|
|
2011-11-05 07:32:40 -06:00
|
|
|
free(cx);
|
2006-11-26 11:13:41 -07:00
|
|
|
|
|
|
|
if (cx == __glXLastContext) {
|
2012-06-10 07:21:05 -06:00
|
|
|
__glXFlushContextCache();
|
2006-11-26 11:13:41 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
return GL_TRUE;
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
** Initialize the GLX extension.
|
|
|
|
*/
|
2012-06-10 07:21:05 -06:00
|
|
|
void
|
|
|
|
GlxExtensionInit(void)
|
2006-11-26 11:13:41 -07:00
|
|
|
{
|
|
|
|
ExtensionEntry *extEntry;
|
|
|
|
int i;
|
|
|
|
int glxSupported = 1;
|
|
|
|
|
|
|
|
/*
|
2012-06-10 07:21:05 -06:00
|
|
|
// do not initialize GLX extension if GLX is not supported
|
|
|
|
// by ALL back-end servers.
|
|
|
|
*/
|
|
|
|
for (i = 0; i < screenInfo.numScreens; i++) {
|
|
|
|
glxSupported &= (dmxScreens[i].glxMajorOpcode > 0);
|
2006-11-26 11:13:41 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
if (!glxSupported || !dmxGLXProxy) {
|
2012-06-10 07:21:05 -06:00
|
|
|
return;
|
2006-11-26 11:13:41 -07:00
|
|
|
}
|
2012-06-10 07:21:05 -06:00
|
|
|
|
|
|
|
__glXContextRes = CreateNewResourceType((DeleteType) ContextGone,
|
|
|
|
"GLXContext");
|
|
|
|
__glXClientRes = CreateNewResourceType((DeleteType) ClientGone,
|
|
|
|
"GLXClient");
|
|
|
|
__glXPixmapRes = CreateNewResourceType((DeleteType) PixmapGone,
|
|
|
|
"GLXPixmap");
|
|
|
|
__glXWindowRes = CreateNewResourceType((DeleteType) WindowGone,
|
|
|
|
"GLXWindow");
|
|
|
|
__glXPbufferRes = CreateNewResourceType((DeleteType) PbufferGone,
|
|
|
|
"GLXPbuffer");
|
2010-07-27 13:02:24 -06:00
|
|
|
|
|
|
|
if (!__glXContextRes || !__glXClientRes || !__glXPixmapRes ||
|
2012-06-10 07:21:05 -06:00
|
|
|
!__glXWindowRes || !__glXPbufferRes)
|
|
|
|
return;
|
2006-11-26 11:13:41 -07:00
|
|
|
|
|
|
|
/*
|
2012-06-10 07:21:05 -06:00
|
|
|
** Add extension to server extensions.
|
|
|
|
*/
|
2006-11-26 11:13:41 -07:00
|
|
|
extEntry = AddExtension(GLX_EXTENSION_NAME, __GLX_NUMBER_EVENTS,
|
2012-06-10 07:21:05 -06:00
|
|
|
__GLX_NUMBER_ERRORS, __glXDispatch,
|
|
|
|
__glXSwapDispatch, ResetExtension,
|
|
|
|
StandardMinorOpcode);
|
2006-11-26 11:13:41 -07:00
|
|
|
if (!extEntry) {
|
2012-06-10 07:21:05 -06:00
|
|
|
FatalError("__glXExtensionInit: AddExtensions failed\n");
|
|
|
|
return;
|
2006-11-26 11:13:41 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
__glXerrorBase = extEntry->errorBase;
|
|
|
|
__glXBadContext = extEntry->errorBase + GLXBadContext;
|
|
|
|
__glXBadContextState = extEntry->errorBase + GLXBadContextState;
|
|
|
|
__glXBadDrawable = extEntry->errorBase + GLXBadDrawable;
|
|
|
|
__glXBadPixmap = extEntry->errorBase + GLXBadPixmap;
|
|
|
|
__glXBadContextTag = extEntry->errorBase + GLXBadContextTag;
|
|
|
|
__glXBadCurrentWindow = extEntry->errorBase + GLXBadCurrentWindow;
|
|
|
|
__glXBadRenderRequest = extEntry->errorBase + GLXBadRenderRequest;
|
|
|
|
__glXBadLargeRequest = extEntry->errorBase + GLXBadLargeRequest;
|
|
|
|
__glXUnsupportedPrivateRequest = extEntry->errorBase +
|
2012-06-10 07:21:05 -06:00
|
|
|
GLXUnsupportedPrivateRequest;
|
2006-11-26 11:13:41 -07:00
|
|
|
__glXBadFBConfig = extEntry->errorBase + GLXBadFBConfig;
|
|
|
|
__glXBadPbuffer = extEntry->errorBase + GLXBadPbuffer;
|
|
|
|
|
|
|
|
/*
|
2012-06-10 07:21:05 -06:00
|
|
|
** Initialize table of client state. There is never a client 0.
|
|
|
|
*/
|
2016-05-29 06:02:34 -06:00
|
|
|
for (i = 1; i <= LimitClients; i++) {
|
2012-06-10 07:21:05 -06:00
|
|
|
__glXClients[i] = 0;
|
2006-11-26 11:13:41 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
2012-06-10 07:21:05 -06:00
|
|
|
** Initialize screen specific data.
|
|
|
|
*/
|
2006-11-26 11:13:41 -07:00
|
|
|
__glXScreenInit(screenInfo.numScreens);
|
|
|
|
|
|
|
|
/*
|
2012-06-10 07:21:05 -06:00
|
|
|
** Initialize swap barrier support.
|
|
|
|
*/
|
2006-11-26 11:13:41 -07:00
|
|
|
SwapBarrierInit();
|
|
|
|
}
|
|
|
|
|
|
|
|
/************************************************************************/
|
|
|
|
|
2012-06-10 07:21:05 -06:00
|
|
|
Bool
|
|
|
|
__glXCoreType(void)
|
2006-11-26 11:13:41 -07:00
|
|
|
{
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
/************************************************************************/
|
|
|
|
|
2012-06-10 07:21:05 -06:00
|
|
|
void
|
|
|
|
__glXFlushContextCache(void)
|
2006-11-26 11:13:41 -07:00
|
|
|
{
|
|
|
|
__glXLastContext = 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
/************************************************************************/
|
|
|
|
|
|
|
|
/*
|
|
|
|
** Top level dispatcher; all commands are executed from here down.
|
|
|
|
*/
|
2012-06-10 07:21:05 -06:00
|
|
|
static int
|
|
|
|
__glXDispatch(ClientPtr client)
|
2006-11-26 11:13:41 -07:00
|
|
|
{
|
|
|
|
REQUEST(xGLXSingleReq);
|
|
|
|
CARD8 opcode;
|
2012-06-10 07:21:05 -06:00
|
|
|
int (*proc) (__GLXclientState * cl, GLbyte * pc);
|
2006-11-26 11:13:41 -07:00
|
|
|
__GLXclientState *cl;
|
|
|
|
|
|
|
|
opcode = stuff->glxCode;
|
|
|
|
cl = __glXClients[client->index];
|
|
|
|
if (!cl) {
|
2012-06-10 07:21:05 -06:00
|
|
|
cl = calloc(1, sizeof(__GLXclientState));
|
|
|
|
__glXClients[client->index] = cl;
|
|
|
|
if (!cl) {
|
|
|
|
return BadAlloc;
|
|
|
|
}
|
|
|
|
|
|
|
|
cl->be_displays = calloc(screenInfo.numScreens, sizeof(Display *));
|
|
|
|
if (!cl->be_displays) {
|
|
|
|
free(cl);
|
|
|
|
return BadAlloc;
|
|
|
|
}
|
2006-11-26 11:13:41 -07:00
|
|
|
}
|
2012-06-10 07:21:05 -06:00
|
|
|
|
2006-11-26 11:13:41 -07:00
|
|
|
if (!cl->inUse) {
|
2012-06-10 07:21:05 -06:00
|
|
|
/*
|
|
|
|
** This is first request from this client. Associate a resource
|
|
|
|
** with the client so we will be notified when the client dies.
|
|
|
|
*/
|
|
|
|
XID xid = FakeClientID(client->index);
|
|
|
|
|
2014-09-27 11:52:59 -06:00
|
|
|
if (!AddResource(xid, __glXClientRes, (void *) (long) client->index)) {
|
2012-06-10 07:21:05 -06:00
|
|
|
return BadAlloc;
|
|
|
|
}
|
|
|
|
ResetClientState(client->index);
|
|
|
|
cl->largeCmdRequestsTotal = 0;
|
|
|
|
cl->inUse = GL_TRUE;
|
|
|
|
cl->client = client;
|
2006-11-26 11:13:41 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
2012-06-10 07:21:05 -06:00
|
|
|
** Check for valid opcode.
|
|
|
|
*/
|
2006-11-26 11:13:41 -07:00
|
|
|
if (opcode >= __GLX_SINGLE_TABLE_SIZE) {
|
2012-06-10 07:21:05 -06:00
|
|
|
return BadRequest;
|
2006-11-26 11:13:41 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
2012-06-10 07:21:05 -06:00
|
|
|
** Use the opcode to index into the procedure table.
|
|
|
|
*/
|
2006-11-26 11:13:41 -07:00
|
|
|
proc = __glXSingleTable[opcode];
|
2012-06-10 07:21:05 -06:00
|
|
|
return (*proc) (cl, (GLbyte *) stuff);
|
2006-11-26 11:13:41 -07:00
|
|
|
}
|
|
|
|
|
2012-06-10 07:21:05 -06:00
|
|
|
static int
|
|
|
|
__glXSwapDispatch(ClientPtr client)
|
2006-11-26 11:13:41 -07:00
|
|
|
{
|
|
|
|
REQUEST(xGLXSingleReq);
|
|
|
|
CARD8 opcode;
|
2012-06-10 07:21:05 -06:00
|
|
|
int (*proc) (__GLXclientState * cl, GLbyte * pc);
|
2006-11-26 11:13:41 -07:00
|
|
|
__GLXclientState *cl;
|
|
|
|
|
|
|
|
opcode = stuff->glxCode;
|
|
|
|
cl = __glXClients[client->index];
|
|
|
|
if (!cl) {
|
2012-06-10 07:21:05 -06:00
|
|
|
cl = calloc(1, sizeof(__GLXclientState));
|
|
|
|
__glXClients[client->index] = cl;
|
|
|
|
if (!cl) {
|
|
|
|
return BadAlloc;
|
|
|
|
}
|
|
|
|
|
|
|
|
cl->be_displays = calloc(screenInfo.numScreens, sizeof(Display *));
|
|
|
|
if (!cl->be_displays) {
|
|
|
|
free(cl);
|
|
|
|
return BadAlloc;
|
|
|
|
}
|
2006-11-26 11:13:41 -07:00
|
|
|
}
|
2012-06-10 07:21:05 -06:00
|
|
|
|
2006-11-26 11:13:41 -07:00
|
|
|
if (!cl->inUse) {
|
2012-06-10 07:21:05 -06:00
|
|
|
/*
|
|
|
|
** This is first request from this client. Associate a resource
|
|
|
|
** with the client so we will be notified when the client dies.
|
|
|
|
*/
|
|
|
|
XID xid = FakeClientID(client->index);
|
|
|
|
|
2014-09-27 11:52:59 -06:00
|
|
|
if (!AddResource(xid, __glXClientRes, (void *) (long) client->index)) {
|
2012-06-10 07:21:05 -06:00
|
|
|
return BadAlloc;
|
|
|
|
}
|
|
|
|
ResetClientState(client->index);
|
|
|
|
cl->inUse = GL_TRUE;
|
|
|
|
cl->client = client;
|
2006-11-26 11:13:41 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
2012-06-10 07:21:05 -06:00
|
|
|
** Check for valid opcode.
|
|
|
|
*/
|
2006-11-26 11:13:41 -07:00
|
|
|
if (opcode >= __GLX_SINGLE_TABLE_SIZE) {
|
2012-06-10 07:21:05 -06:00
|
|
|
return BadRequest;
|
2006-11-26 11:13:41 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
2012-06-10 07:21:05 -06:00
|
|
|
** Use the opcode to index into the procedure table.
|
|
|
|
*/
|
2006-11-26 11:13:41 -07:00
|
|
|
proc = __glXSwapSingleTable[opcode];
|
2012-06-10 07:21:05 -06:00
|
|
|
return (*proc) (cl, (GLbyte *) stuff);
|
2006-11-26 11:13:41 -07:00
|
|
|
}
|
|
|
|
|
2012-06-10 07:21:05 -06:00
|
|
|
int
|
|
|
|
__glXNoSuchSingleOpcode(__GLXclientState * cl, GLbyte * pc)
|
2006-11-26 11:13:41 -07:00
|
|
|
{
|
|
|
|
return BadRequest;
|
|
|
|
}
|
|
|
|
|
2012-06-10 07:21:05 -06:00
|
|
|
void
|
|
|
|
__glXNoSuchRenderOpcode(GLbyte * pc)
|
2006-11-26 11:13:41 -07:00
|
|
|
{
|
|
|
|
return;
|
|
|
|
}
|