glxserver.h revision 4642e01f
1#ifdef HAVE_DIX_CONFIG_H 2#include <dix-config.h> 3#endif 4 5#ifndef _GLX_server_h_ 6#define _GLX_server_h_ 7 8/* 9 * SGI FREE SOFTWARE LICENSE B (Version 2.0, Sept. 18, 2008) 10 * Copyright (C) 1991-2000 Silicon Graphics, Inc. All Rights Reserved. 11 * 12 * Permission is hereby granted, free of charge, to any person obtaining a 13 * copy of this software and associated documentation files (the "Software"), 14 * to deal in the Software without restriction, including without limitation 15 * the rights to use, copy, modify, merge, publish, distribute, sublicense, 16 * and/or sell copies of the Software, and to permit persons to whom the 17 * Software is furnished to do so, subject to the following conditions: 18 * 19 * The above copyright notice including the dates of first publication and 20 * either this permission notice or a reference to 21 * http://oss.sgi.com/projects/FreeB/ 22 * shall be included in all copies or substantial portions of the Software. 23 * 24 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS 25 * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 26 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL 27 * SILICON GRAPHICS, INC. BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, 28 * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF 29 * OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 30 * SOFTWARE. 31 * 32 * Except as contained in this notice, the name of Silicon Graphics, Inc. 33 * shall not be used in advertising or otherwise to promote the sale, use or 34 * other dealings in this Software without prior written authorization from 35 * Silicon Graphics, Inc. 36 */ 37 38#include <X11/X.h> 39#include <X11/Xproto.h> 40#include <X11/Xmd.h> 41#include <misc.h> 42#include <dixstruct.h> 43#include <pixmapstr.h> 44#include <gcstruct.h> 45#include <extnsionst.h> 46#include <resource.h> 47#include <scrnintstr.h> 48 49/* 50** The X header misc.h defines these math functions. 51*/ 52#undef abs 53#undef fabs 54 55#define GL_GLEXT_PROTOTYPES /* we want prototypes */ 56#include <GL/gl.h> 57#include <GL/glxproto.h> 58#include <GL/glxint.h> 59 60/* For glxscreens.h */ 61typedef struct __GLXdrawable __GLXdrawable; 62typedef struct __GLXcontext __GLXcontext; 63 64#include "glxscreens.h" 65#include "glxdrawable.h" 66#include "glxcontext.h" 67 68 69#define GLX_SERVER_MAJOR_VERSION 1 70#define GLX_SERVER_MINOR_VERSION 2 71 72#ifndef True 73#define True 1 74#endif 75#ifndef False 76#define False 0 77#endif 78 79/* 80** GLX resources. 81*/ 82typedef XID GLXContextID; 83typedef XID GLXPixmap; 84typedef XID GLXDrawable; 85 86typedef struct __GLXclientStateRec __GLXclientState; 87 88extern __GLXscreen *glxGetScreen(ScreenPtr pScreen); 89extern __GLXclientState *glxGetClient(ClientPtr pClient); 90 91/************************************************************************/ 92 93void GlxExtensionInit(void); 94 95void GlxSetVisualConfigs(int nconfigs, 96 __GLXvisualConfig *configs, void **privates); 97 98struct _glapi_table; 99void GlxSetRenderTables (struct _glapi_table *table); 100 101void __glXScreenInitVisuals(__GLXscreen *screen); 102 103/* 104** The last context used (from the server's persective) is cached. 105*/ 106extern __GLXcontext *__glXLastContext; 107extern __GLXcontext *__glXForceCurrent(__GLXclientState*, GLXContextTag, int*); 108 109extern ClientPtr __pGlxClient; 110 111int __glXError(int error); 112 113/* 114** Macros to set, unset, and retrieve the flag that says whether a context 115** has unflushed commands. 116*/ 117#define __GLX_NOTE_UNFLUSHED_CMDS(glxc) glxc->hasUnflushedCommands = GL_TRUE 118#define __GLX_NOTE_FLUSHED_CMDS(glxc) glxc->hasUnflushedCommands = GL_FALSE 119#define __GLX_HAS_UNFLUSHED_CMDS(glxc) (glxc->hasUnflushedCommands) 120 121/************************************************************************/ 122 123typedef struct __GLXprovider __GLXprovider; 124struct __GLXprovider { 125 __GLXscreen *(*screenProbe)(ScreenPtr pScreen); 126 const char *name; 127 __GLXprovider *next; 128}; 129 130void GlxPushProvider(__GLXprovider *provider); 131 132enum { 133 GLX_MINIMAL_VISUALS, 134 GLX_TYPICAL_VISUALS, 135 GLX_ALL_VISUALS 136}; 137 138void __glXsetEnterLeaveServerFuncs(void (*enter)(GLboolean), 139 void (*leave)(GLboolean)); 140void __glXenterServer(GLboolean rendering); 141void __glXleaveServer(GLboolean rendering); 142 143void glxSuspendClients(void); 144void glxResumeClients(void); 145 146/* 147** State kept per client. 148*/ 149struct __GLXclientStateRec { 150 /* 151 ** Whether this structure is currently being used to support a client. 152 */ 153 Bool inUse; 154 155 /* 156 ** Buffer for returned data. 157 */ 158 GLbyte *returnBuf; 159 GLint returnBufSize; 160 161 /* 162 ** Keep track of large rendering commands, which span multiple requests. 163 */ 164 GLint largeCmdBytesSoFar; /* bytes received so far */ 165 GLint largeCmdBytesTotal; /* total bytes expected */ 166 GLint largeCmdRequestsSoFar; /* requests received so far */ 167 GLint largeCmdRequestsTotal; /* total requests expected */ 168 GLbyte *largeCmdBuf; 169 GLint largeCmdBufSize; 170 171 /* 172 ** Keep a list of all the contexts that are current for this client's 173 ** threads. 174 */ 175 __GLXcontext **currentContexts; 176 GLint numCurrentContexts; 177 178 /* Back pointer to X client record */ 179 ClientPtr client; 180 181 int GLClientmajorVersion; 182 int GLClientminorVersion; 183 char *GLClientextensions; 184}; 185 186/************************************************************************/ 187 188/* 189** Dispatch tables. 190*/ 191typedef void (*__GLXdispatchRenderProcPtr)(GLbyte *); 192typedef int (*__GLXdispatchSingleProcPtr)(__GLXclientState *, GLbyte *); 193typedef int (*__GLXdispatchVendorPrivProcPtr)(__GLXclientState *, GLbyte *); 194 195/* 196 * Dispatch for GLX commands. 197 */ 198typedef int (*__GLXprocPtr)(__GLXclientState *, char *pc); 199 200/* 201 * Tables for computing the size of each rendering command. 202 */ 203typedef int (*gl_proto_size_func)(const GLbyte *, Bool); 204 205typedef struct { 206 int bytes; 207 gl_proto_size_func varsize; 208} __GLXrenderSizeData; 209 210/************************************************************************/ 211 212/* 213** X resources. 214*/ 215extern RESTYPE __glXContextRes; 216extern RESTYPE __glXClientRes; 217extern RESTYPE __glXPixmapRes; 218extern RESTYPE __glXDrawableRes; 219 220/************************************************************************/ 221 222/* 223** Prototypes. 224*/ 225 226extern char *__glXcombine_strings(const char *, const char *); 227 228/* 229** Routines for sending swapped replies. 230*/ 231 232extern void __glXSwapMakeCurrentReply(ClientPtr client, 233 xGLXMakeCurrentReply *reply); 234extern void __glXSwapIsDirectReply(ClientPtr client, 235 xGLXIsDirectReply *reply); 236extern void __glXSwapQueryVersionReply(ClientPtr client, 237 xGLXQueryVersionReply *reply); 238extern void __glXSwapQueryContextInfoEXTReply(ClientPtr client, 239 xGLXQueryContextInfoEXTReply *reply, 240 int *buf); 241extern void __glXSwapGetDrawableAttributesReply(ClientPtr client, 242 xGLXGetDrawableAttributesReply *reply, CARD32 *buf); 243extern void glxSwapQueryExtensionsStringReply(ClientPtr client, 244 xGLXQueryExtensionsStringReply *reply, char *buf); 245extern void glxSwapQueryServerStringReply(ClientPtr client, 246 xGLXQueryServerStringReply *reply, char *buf); 247 248 249/* 250 * Routines for computing the size of variably-sized rendering commands. 251 */ 252 253extern int __glXTypeSize(GLenum enm); 254extern int __glXImageSize(GLenum format, GLenum type, 255 GLenum target, GLsizei w, GLsizei h, GLsizei d, 256 GLint imageHeight, GLint rowLength, GLint skipImages, GLint skipRows, 257 GLint alignment); 258 259#endif /* !__GLX_server_h__ */ 260