glxserver.h 7.8 KB

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