1*4882a593Smuzhiyun #ifndef _GLX_server_h_ 2*4882a593Smuzhiyun #define _GLX_server_h_ 3*4882a593Smuzhiyun 4*4882a593Smuzhiyun /* 5*4882a593Smuzhiyun * SGI FREE SOFTWARE LICENSE B (Version 2.0, Sept. 18, 2008) 6*4882a593Smuzhiyun * Copyright (C) 1991-2000 Silicon Graphics, Inc. All Rights Reserved. 7*4882a593Smuzhiyun * 8*4882a593Smuzhiyun * Permission is hereby granted, free of charge, to any person obtaining a 9*4882a593Smuzhiyun * copy of this software and associated documentation files (the "Software"), 10*4882a593Smuzhiyun * to deal in the Software without restriction, including without limitation 11*4882a593Smuzhiyun * the rights to use, copy, modify, merge, publish, distribute, sublicense, 12*4882a593Smuzhiyun * and/or sell copies of the Software, and to permit persons to whom the 13*4882a593Smuzhiyun * Software is furnished to do so, subject to the following conditions: 14*4882a593Smuzhiyun * 15*4882a593Smuzhiyun * The above copyright notice including the dates of first publication and 16*4882a593Smuzhiyun * either this permission notice or a reference to 17*4882a593Smuzhiyun * http://oss.sgi.com/projects/FreeB/ 18*4882a593Smuzhiyun * shall be included in all copies or substantial portions of the Software. 19*4882a593Smuzhiyun * 20*4882a593Smuzhiyun * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS 21*4882a593Smuzhiyun * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 22*4882a593Smuzhiyun * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL 23*4882a593Smuzhiyun * SILICON GRAPHICS, INC. BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, 24*4882a593Smuzhiyun * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF 25*4882a593Smuzhiyun * OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 26*4882a593Smuzhiyun * SOFTWARE. 27*4882a593Smuzhiyun * 28*4882a593Smuzhiyun * Except as contained in this notice, the name of Silicon Graphics, Inc. 29*4882a593Smuzhiyun * shall not be used in advertising or otherwise to promote the sale, use or 30*4882a593Smuzhiyun * other dealings in this Software without prior written authorization from 31*4882a593Smuzhiyun * Silicon Graphics, Inc. 32*4882a593Smuzhiyun */ 33*4882a593Smuzhiyun 34*4882a593Smuzhiyun #include "dmx.h" 35*4882a593Smuzhiyun 36*4882a593Smuzhiyun #include <misc.h> 37*4882a593Smuzhiyun #include <dixstruct.h> 38*4882a593Smuzhiyun #include <pixmapstr.h> 39*4882a593Smuzhiyun #include <gcstruct.h> 40*4882a593Smuzhiyun #include <extnsionst.h> 41*4882a593Smuzhiyun #include <resource.h> 42*4882a593Smuzhiyun #include <scrnintstr.h> 43*4882a593Smuzhiyun 44*4882a593Smuzhiyun #define GL_GLEXT_PROTOTYPES /* we want prototypes */ 45*4882a593Smuzhiyun #include <GL/gl.h> 46*4882a593Smuzhiyun #include <GL/glxproto.h> 47*4882a593Smuzhiyun #include <GL/glxint.h> 48*4882a593Smuzhiyun 49*4882a593Smuzhiyun #include "glxscreens.h" 50*4882a593Smuzhiyun #include "glxdrawable.h" 51*4882a593Smuzhiyun #include "glxcontext.h" 52*4882a593Smuzhiyun #include "glxerror.h" 53*4882a593Smuzhiyun 54*4882a593Smuzhiyun #define GLX_SERVER_MAJOR_VERSION 1 55*4882a593Smuzhiyun #define GLX_SERVER_MINOR_VERSION 3 56*4882a593Smuzhiyun 57*4882a593Smuzhiyun #ifndef True 58*4882a593Smuzhiyun #define True 1 59*4882a593Smuzhiyun #endif 60*4882a593Smuzhiyun #ifndef False 61*4882a593Smuzhiyun #define False 0 62*4882a593Smuzhiyun #endif 63*4882a593Smuzhiyun 64*4882a593Smuzhiyun /* 65*4882a593Smuzhiyun ** GLX resources. 66*4882a593Smuzhiyun typedef XID GLXContextID; 67*4882a593Smuzhiyun typedef XID GLXPixmap; 68*4882a593Smuzhiyun typedef XID GLXDrawable; 69*4882a593Smuzhiyun typedef XID GLXWindow; 70*4882a593Smuzhiyun typedef XID GLXPbuffer; 71*4882a593Smuzhiyun 72*4882a593Smuzhiyun typedef struct __GLXcontextRec *GLXContext; 73*4882a593Smuzhiyun */ 74*4882a593Smuzhiyun typedef struct __GLXclientStateRec __GLXclientState; 75*4882a593Smuzhiyun 76*4882a593Smuzhiyun extern __GLXscreenInfo *__glXActiveScreens; 77*4882a593Smuzhiyun extern GLint __glXNumActiveScreens; 78*4882a593Smuzhiyun 79*4882a593Smuzhiyun /************************************************************************/ 80*4882a593Smuzhiyun 81*4882a593Smuzhiyun /* 82*4882a593Smuzhiyun ** The last context used (from the server's persective) is cached. 83*4882a593Smuzhiyun */ 84*4882a593Smuzhiyun extern __GLXcontext *__glXLastContext; 85*4882a593Smuzhiyun extern __GLXcontext *__glXForceCurrent(__GLXclientState *, GLXContextTag, 86*4882a593Smuzhiyun int *); 87*4882a593Smuzhiyun 88*4882a593Smuzhiyun /************************************************************************/ 89*4882a593Smuzhiyun 90*4882a593Smuzhiyun typedef struct { 91*4882a593Smuzhiyun int elem_size; /* element size in bytes */ 92*4882a593Smuzhiyun int nelems; /* number of elements to swap */ 93*4882a593Smuzhiyun void (*swapfunc) (GLbyte * pc); 94*4882a593Smuzhiyun } __GLXRenderSwapInfo; 95*4882a593Smuzhiyun 96*4882a593Smuzhiyun /* 97*4882a593Smuzhiyun ** State kept per client. 98*4882a593Smuzhiyun */ 99*4882a593Smuzhiyun struct __GLXclientStateRec { 100*4882a593Smuzhiyun /* 101*4882a593Smuzhiyun ** Whether this structure is currently being used to support a client. 102*4882a593Smuzhiyun */ 103*4882a593Smuzhiyun Bool inUse; 104*4882a593Smuzhiyun 105*4882a593Smuzhiyun /* 106*4882a593Smuzhiyun ** Buffer for returned data. 107*4882a593Smuzhiyun */ 108*4882a593Smuzhiyun GLbyte *returnBuf; 109*4882a593Smuzhiyun GLint returnBufSize; 110*4882a593Smuzhiyun 111*4882a593Smuzhiyun /* 112*4882a593Smuzhiyun ** Keep a list of all the contexts that are current for this client's 113*4882a593Smuzhiyun ** threads. 114*4882a593Smuzhiyun */ 115*4882a593Smuzhiyun __GLXcontext **currentContexts; 116*4882a593Smuzhiyun DrawablePtr *currentDrawables; 117*4882a593Smuzhiyun GLint numCurrentContexts; 118*4882a593Smuzhiyun 119*4882a593Smuzhiyun /* Back pointer to X client record */ 120*4882a593Smuzhiyun ClientPtr client; 121*4882a593Smuzhiyun 122*4882a593Smuzhiyun char *GLClientextensions; 123*4882a593Smuzhiyun 124*4882a593Smuzhiyun GLXContextTag *be_currentCTag; 125*4882a593Smuzhiyun Display **be_displays; 126*4882a593Smuzhiyun 127*4882a593Smuzhiyun /* 128*4882a593Smuzhiyun ** Keep track of large rendering commands, which span multiple requests. 129*4882a593Smuzhiyun */ 130*4882a593Smuzhiyun GLint largeCmdBytesSoFar; /* bytes received so far */ 131*4882a593Smuzhiyun GLint largeCmdBytesTotal; /* total bytes expected */ 132*4882a593Smuzhiyun GLint largeCmdRequestsSoFar; /* requests received so far */ 133*4882a593Smuzhiyun GLint largeCmdRequestsTotal; /* total requests expected */ 134*4882a593Smuzhiyun void (*largeCmdRequestsSwapProc) (GLbyte *); 135*4882a593Smuzhiyun __GLXRenderSwapInfo *largeCmdRequestsSwap_info; 136*4882a593Smuzhiyun GLbyte *largeCmdBuf; 137*4882a593Smuzhiyun GLint largeCmdBufSize; 138*4882a593Smuzhiyun GLint largeCmdMaxReqDataSize; 139*4882a593Smuzhiyun 140*4882a593Smuzhiyun }; 141*4882a593Smuzhiyun 142*4882a593Smuzhiyun extern __GLXclientState *__glXClients[]; 143*4882a593Smuzhiyun 144*4882a593Smuzhiyun /************************************************************************/ 145*4882a593Smuzhiyun 146*4882a593Smuzhiyun /* 147*4882a593Smuzhiyun ** Dispatch tables. 148*4882a593Smuzhiyun */ 149*4882a593Smuzhiyun typedef void (*__GLXdispatchRenderProcPtr) (GLbyte *); 150*4882a593Smuzhiyun typedef int (*__GLXdispatchSingleProcPtr) (__GLXclientState *, GLbyte *); 151*4882a593Smuzhiyun typedef int (*__GLXdispatchVendorPrivProcPtr) (__GLXclientState *, GLbyte *); 152*4882a593Smuzhiyun extern __GLXdispatchVendorPrivProcPtr __glXVendorPrivTable_EXT[]; 153*4882a593Smuzhiyun extern __GLXdispatchVendorPrivProcPtr __glXSwapVendorPrivTable_EXT[]; 154*4882a593Smuzhiyun extern __GLXdispatchRenderProcPtr __glXSwapRenderTable[]; 155*4882a593Smuzhiyun 156*4882a593Smuzhiyun extern __GLXRenderSwapInfo __glXSwapRenderTable_EXT[]; 157*4882a593Smuzhiyun 158*4882a593Smuzhiyun /* 159*4882a593Smuzhiyun * Dispatch for GLX commands. 160*4882a593Smuzhiyun */ 161*4882a593Smuzhiyun typedef int (*__GLXprocPtr) (__GLXclientState *, char *pc); 162*4882a593Smuzhiyun extern __GLXprocPtr __glXProcTable[]; 163*4882a593Smuzhiyun 164*4882a593Smuzhiyun /* 165*4882a593Smuzhiyun * Tables for computing the size of each rendering command. 166*4882a593Smuzhiyun */ 167*4882a593Smuzhiyun typedef struct { 168*4882a593Smuzhiyun int bytes; 169*4882a593Smuzhiyun int (*varsize) (GLbyte * pc, Bool swap); 170*4882a593Smuzhiyun } __GLXrenderSizeData; 171*4882a593Smuzhiyun extern __GLXrenderSizeData __glXRenderSizeTable[]; 172*4882a593Smuzhiyun extern __GLXrenderSizeData __glXRenderSizeTable_EXT[]; 173*4882a593Smuzhiyun 174*4882a593Smuzhiyun /************************************************************************/ 175*4882a593Smuzhiyun 176*4882a593Smuzhiyun /* 177*4882a593Smuzhiyun ** X resources. 178*4882a593Smuzhiyun */ 179*4882a593Smuzhiyun extern RESTYPE __glXContextRes; 180*4882a593Smuzhiyun extern RESTYPE __glXClientRes; 181*4882a593Smuzhiyun extern RESTYPE __glXPixmapRes; 182*4882a593Smuzhiyun extern RESTYPE __glXDrawableRes; 183*4882a593Smuzhiyun extern RESTYPE __glXWindowRes; 184*4882a593Smuzhiyun extern RESTYPE __glXPbufferRes; 185*4882a593Smuzhiyun 186*4882a593Smuzhiyun /************************************************************************/ 187*4882a593Smuzhiyun 188*4882a593Smuzhiyun /* 189*4882a593Smuzhiyun ** Prototypes. 190*4882a593Smuzhiyun */ 191*4882a593Smuzhiyun 192*4882a593Smuzhiyun extern char *__glXcombine_strings(const char *, const char *); 193*4882a593Smuzhiyun 194*4882a593Smuzhiyun /* 195*4882a593Smuzhiyun ** Routines for sending swapped replies. 196*4882a593Smuzhiyun */ 197*4882a593Smuzhiyun 198*4882a593Smuzhiyun extern void __glXSwapMakeCurrentReply(ClientPtr client, 199*4882a593Smuzhiyun xGLXMakeCurrentReadSGIReply * reply); 200*4882a593Smuzhiyun 201*4882a593Smuzhiyun extern void __glXSwapIsDirectReply(ClientPtr client, xGLXIsDirectReply * reply); 202*4882a593Smuzhiyun extern void __glXSwapQueryVersionReply(ClientPtr client, 203*4882a593Smuzhiyun xGLXQueryVersionReply * reply); 204*4882a593Smuzhiyun extern void __glXSwapQueryContextInfoEXTReply(ClientPtr client, 205*4882a593Smuzhiyun xGLXQueryContextInfoEXTReply * 206*4882a593Smuzhiyun reply, int *buf); 207*4882a593Smuzhiyun extern void glxSwapQueryExtensionsStringReply(ClientPtr client, 208*4882a593Smuzhiyun xGLXQueryExtensionsStringReply * 209*4882a593Smuzhiyun reply, char *buf); 210*4882a593Smuzhiyun extern void glxSwapQueryServerStringReply(ClientPtr client, 211*4882a593Smuzhiyun xGLXQueryServerStringReply * reply, 212*4882a593Smuzhiyun char *buf); 213*4882a593Smuzhiyun extern void __glXSwapQueryContextReply(ClientPtr client, 214*4882a593Smuzhiyun xGLXQueryContextReply * reply, int *buf); 215*4882a593Smuzhiyun extern void __glXSwapGetDrawableAttributesReply(ClientPtr client, 216*4882a593Smuzhiyun xGLXGetDrawableAttributesReply * 217*4882a593Smuzhiyun reply, int *buf); 218*4882a593Smuzhiyun extern void __glXSwapQueryMaxSwapBarriersSGIXReply(ClientPtr client, 219*4882a593Smuzhiyun xGLXQueryMaxSwapBarriersSGIXReply 220*4882a593Smuzhiyun * reply); 221*4882a593Smuzhiyun 222*4882a593Smuzhiyun /* 223*4882a593Smuzhiyun * Routines for computing the size of variably-sized rendering commands. 224*4882a593Smuzhiyun */ 225*4882a593Smuzhiyun 226*4882a593Smuzhiyun extern int __glXTypeSize(GLenum enm); 227*4882a593Smuzhiyun extern int __glXImageSize(GLenum format, GLenum type, GLsizei w, GLsizei h, 228*4882a593Smuzhiyun GLint rowLength, GLint skipRows, GLint alignment); 229*4882a593Smuzhiyun extern int __glXImage3DSize(GLenum format, GLenum type, 230*4882a593Smuzhiyun GLsizei w, GLsizei h, GLsizei d, 231*4882a593Smuzhiyun GLint imageHeight, GLint rowLength, 232*4882a593Smuzhiyun GLint skipImages, GLint skipRows, GLint alignment); 233*4882a593Smuzhiyun 234*4882a593Smuzhiyun extern int __glXCallListsReqSize(GLbyte * pc, Bool swap); 235*4882a593Smuzhiyun extern int __glXBitmapReqSize(GLbyte * pc, Bool swap); 236*4882a593Smuzhiyun extern int __glXFogfvReqSize(GLbyte * pc, Bool swap); 237*4882a593Smuzhiyun extern int __glXFogivReqSize(GLbyte * pc, Bool swap); 238*4882a593Smuzhiyun extern int __glXLightfvReqSize(GLbyte * pc, Bool swap); 239*4882a593Smuzhiyun extern int __glXLightivReqSize(GLbyte * pc, Bool swap); 240*4882a593Smuzhiyun extern int __glXLightModelfvReqSize(GLbyte * pc, Bool swap); 241*4882a593Smuzhiyun extern int __glXLightModelivReqSize(GLbyte * pc, Bool swap); 242*4882a593Smuzhiyun extern int __glXMaterialfvReqSize(GLbyte * pc, Bool swap); 243*4882a593Smuzhiyun extern int __glXMaterialivReqSize(GLbyte * pc, Bool swap); 244*4882a593Smuzhiyun extern int __glXTexParameterfvReqSize(GLbyte * pc, Bool swap); 245*4882a593Smuzhiyun extern int __glXTexParameterivReqSize(GLbyte * pc, Bool swap); 246*4882a593Smuzhiyun extern int __glXTexImage1DReqSize(GLbyte * pc, Bool swap); 247*4882a593Smuzhiyun extern int __glXTexImage2DReqSize(GLbyte * pc, Bool swap); 248*4882a593Smuzhiyun extern int __glXTexEnvfvReqSize(GLbyte * pc, Bool swap); 249*4882a593Smuzhiyun extern int __glXTexEnvivReqSize(GLbyte * pc, Bool swap); 250*4882a593Smuzhiyun extern int __glXTexGendvReqSize(GLbyte * pc, Bool swap); 251*4882a593Smuzhiyun extern int __glXTexGenfvReqSize(GLbyte * pc, Bool swap); 252*4882a593Smuzhiyun extern int __glXTexGenivReqSize(GLbyte * pc, Bool swap); 253*4882a593Smuzhiyun extern int __glXMap1dReqSize(GLbyte * pc, Bool swap); 254*4882a593Smuzhiyun extern int __glXMap1fReqSize(GLbyte * pc, Bool swap); 255*4882a593Smuzhiyun extern int __glXMap2dReqSize(GLbyte * pc, Bool swap); 256*4882a593Smuzhiyun extern int __glXMap2fReqSize(GLbyte * pc, Bool swap); 257*4882a593Smuzhiyun extern int __glXPixelMapfvReqSize(GLbyte * pc, Bool swap); 258*4882a593Smuzhiyun extern int __glXPixelMapuivReqSize(GLbyte * pc, Bool swap); 259*4882a593Smuzhiyun extern int __glXPixelMapusvReqSize(GLbyte * pc, Bool swap); 260*4882a593Smuzhiyun extern int __glXDrawPixelsReqSize(GLbyte * pc, Bool swap); 261*4882a593Smuzhiyun extern int __glXDrawArraysSize(GLbyte * pc, Bool swap); 262*4882a593Smuzhiyun extern int __glXPrioritizeTexturesReqSize(GLbyte * pc, Bool swap); 263*4882a593Smuzhiyun extern int __glXTexSubImage1DReqSize(GLbyte * pc, Bool swap); 264*4882a593Smuzhiyun extern int __glXTexSubImage2DReqSize(GLbyte * pc, Bool swap); 265*4882a593Smuzhiyun extern int __glXTexImage3DReqSize(GLbyte * pc, Bool swap); 266*4882a593Smuzhiyun extern int __glXTexSubImage3DReqSize(GLbyte * pc, Bool swap); 267*4882a593Smuzhiyun extern int __glXConvolutionFilter1DReqSize(GLbyte * pc, Bool swap); 268*4882a593Smuzhiyun extern int __glXConvolutionFilter2DReqSize(GLbyte * pc, Bool swap); 269*4882a593Smuzhiyun extern int __glXConvolutionParameterivReqSize(GLbyte * pc, Bool swap); 270*4882a593Smuzhiyun extern int __glXConvolutionParameterfvReqSize(GLbyte * pc, Bool swap); 271*4882a593Smuzhiyun extern int __glXSeparableFilter2DReqSize(GLbyte * pc, Bool swap); 272*4882a593Smuzhiyun extern int __glXColorTableReqSize(GLbyte * pc, Bool swap); 273*4882a593Smuzhiyun extern int __glXColorSubTableReqSize(GLbyte * pc, Bool swap); 274*4882a593Smuzhiyun extern int __glXColorTableParameterfvReqSize(GLbyte * pc, Bool swap); 275*4882a593Smuzhiyun extern int __glXColorTableParameterivReqSize(GLbyte * pc, Bool swap); 276*4882a593Smuzhiyun 277*4882a593Smuzhiyun /* 278*4882a593Smuzhiyun * Routines for computing the size of returned data. 279*4882a593Smuzhiyun */ 280*4882a593Smuzhiyun extern int __glXConvolutionParameterivSize(GLenum pname); 281*4882a593Smuzhiyun extern int __glXConvolutionParameterfvSize(GLenum pname); 282*4882a593Smuzhiyun extern int __glXColorTableParameterfvSize(GLenum pname); 283*4882a593Smuzhiyun extern int __glXColorTableParameterivSize(GLenum pname); 284*4882a593Smuzhiyun 285*4882a593Smuzhiyun extern int __glXVersionMajor; 286*4882a593Smuzhiyun extern int __glXVersionMinor; 287*4882a593Smuzhiyun 288*4882a593Smuzhiyun #define __GLX_IS_VERSION_SUPPORTED(major,minor) \ 289*4882a593Smuzhiyun ( (__glXVersionMajor > (major)) || \ 290*4882a593Smuzhiyun ((__glXVersionMajor == (major)) && (__glXVersionMinor >= (minor))) ) 291*4882a593Smuzhiyun 292*4882a593Smuzhiyun #endif /* !__GLX_server_h__ */ 293