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